MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / initHmrClient

Function initHmrClient

packages/vite/hmr/client/index.ts:1508–1528  ·  view source on GitHub ↗
(opts?: { wsUrl?: string })

Source from the content-addressed store, hash-verified

1506}
1507
1508export 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}
1529export default function startViteHMR(opts?: { wsUrl?: string }) {
1530 if (VERBOSE) console.log('[hmr-client] Starting HMR client', opts);
1531 initHmrClient(opts);

Callers 1

startViteHMRFunction · 0.85

Calls 6

setHMRWsUrlFunction · 0.85
getHMRWsUrlFunction · 0.85
connectHmrFunction · 0.85
logMethod · 0.45

Tested by

no test coverage detected