(opts?: { wsUrl?: string })
| 1506 | } |
| 1507 | |
| 1508 | export function initHmrClient(opts?: { wsUrl?: string }) { |
| 1509 | if (opts?.wsUrl) { |
| 1510 | setHMRWsUrl(opts.wsUrl); |
| 1511 | } |
| 1512 | if (VERBOSE) console.log('[hmr-client] Initializing HMR client', getHMRWsUrl() ? `(ws: ${getHMRWsUrl()})` : ''); |
| 1513 | // Prevent duplicate client initialization across re-evaluations |
| 1514 | const g: any = globalThis as any; |
| 1515 | if (g.__NS_HMR_CLIENT_ACTIVE__) { |
| 1516 | if (VERBOSE) console.log('[hmr-client] HMR client already active; skipping duplicate init'); |
| 1517 | return; |
| 1518 | } |
| 1519 | g.__NS_HMR_CLIENT_ACTIVE__ = true; |
| 1520 | ensureCoreAliasesOnGlobalThis(); |
| 1521 | connectHmr(); |
| 1522 | // Best-effort: install back wrapper even before first remount; original root may be captured later |
| 1523 | switch (__NS_TARGET_FLAVOR__) { |
| 1524 | case 'vue': |
| 1525 | ensureBackWrapperInstalled(performResetRoot, getCore); |
| 1526 | break; |
| 1527 | } |
| 1528 | } |
| 1529 | export default function startViteHMR(opts?: { wsUrl?: string }) { |
| 1530 | if (VERBOSE) console.log('[hmr-client] Starting HMR client', opts); |
| 1531 | initHmrClient(opts); |
no test coverage detected