(newComponent: any)
| 1148 | } |
| 1149 | |
| 1150 | async 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 { |
no test coverage detected