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

Function performResetRoot

packages/vite/hmr/client/index.ts:1150–1506  ·  view source on GitHub ↗
(newComponent: any)

Source from the content-addressed store, hash-verified

1148}
1149
1150async function performResetRoot(newComponent: any): Promise<boolean> {
1151 const tStart = Date.now();
1152 // Guard against re-entrant or rapid successive resets
1153 try {
1154 (globalThis as any).__NS_DEV_RESET_IN_PROGRESS__ = true;
1155 } catch {}
1156 try {
1157 ensureCoreAliasesOnGlobalThis();
1158 } catch {}
1159 try {
1160 if (VERBOSE) logUiSnapshot('pre-performResetRoot');
1161 } catch {}
1162 if (VERBOSE) {
1163 try {
1164 const g: any = globalThis as any;
1165 const vF = getCore('Frame');
1166 console.log('[hmr-client] alias check before remount', {
1167 globalFrameHasTopmost: typeof g?.Frame?.topmost === 'function',
1168 vendorFrameHasTopmost: typeof vF?.topmost === 'function',
1169 sameFrameRef: vF === g?.Frame,
1170 appHasReset: typeof g?.Application?.resetRootView === 'function',
1171 pageIsCtor: typeof g?.Page === 'function',
1172 });
1173 } catch {}
1174 }
1175 if (VERBOSE) {
1176 console.log('[hmr-client] Single-path: replace current root Page');
1177 console.log('[hmr-client] Component details:', {
1178 componentName: (newComponent as any)?.__name,
1179 componentFile: (newComponent as any)?.__file,
1180 hasRender: !!(newComponent as any)?.render,
1181 hasSetup: !!(newComponent as any)?.setup,
1182 componentKeys: Object.keys(newComponent || {}),
1183 });
1184 }
1185
1186 // Factory that mounts the component and returns a Page (from core aggregator realm)
1187 type RootFactory = { readonly kind: 'page' | 'frame'; create: () => any };
1188 function createRootFactory(): RootFactory {
1189 let rootKind: 'page' | 'frame' = 'page';
1190 let cachedRoot: any = undefined;
1191 const state = {
1192 getRootKind: () => rootKind,
1193 setRootKind: (k: 'page' | 'frame') => {
1194 rootKind = k;
1195 },
1196 getCachedRoot: () => cachedRoot,
1197 setCachedRoot: (r: any) => {
1198 cachedRoot = r;
1199 },
1200 };
1201 const factory: RootFactory = {
1202 get kind() {
1203 return rootKind;
1204 },
1205 create: () => {
1206 if (cachedRoot) return cachedRoot;
1207 try {

Callers 3

applyFullGraphFunction · 0.85
handleHmrMessageFunction · 0.85

Calls 15

logUiSnapshotFunction · 0.85
withEventsFunction · 0.85
createRootFactoryFunction · 0.85
getRootFrameFunction · 0.85
attachDiagnosticsToFrameFunction · 0.85
setRootFrameFunction · 0.85
reqFunction · 0.85
warnMethod · 0.80
replaceMethod · 0.80
getCoreFunction · 0.70
keysMethod · 0.65

Tested by

no test coverage detected