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

Function __nsNavigateUsingApp

packages/vite/hmr/client/index.ts:661–799  ·  view source on GitHub ↗
(comp: any, opts: any = {})

Source from the content-addressed store, hash-verified

659
660// Deterministic navigation using the current Vue app instance rather than vendor-held rootApp
661function __nsNavigateUsingApp(comp: any, opts: any = {}) {
662 const g = globalThis as any;
663 switch (__NS_TARGET_FLAVOR__) {
664 case 'vue':
665 ensureVueGlobals();
666 break;
667 }
668 const AppFactory = g.createApp;
669 const RootCtor = g.NSVRoot;
670 if (typeof AppFactory !== 'function' || typeof RootCtor !== 'function') {
671 throw new Error('Vue runtime not initialized');
672 }
673 try {
674 const top = (g.Frame && g.Frame.topmost && g.Frame.topmost()) || null;
675 const ctor = top && top.constructor && top.constructor.name;
676 if (VERBOSE)
677 console.log('[app-nav] begin', {
678 hmrRealm: g.__NS_HMR_REALM__ || 'unknown',
679 rtRealm: g.__NS_RT_REALM__ || 'unknown',
680 topCtor: ctor,
681 hasTop: !!top,
682 });
683 } catch {}
684 // Build a fresh Page each time the factory is invoked to avoid reusing a Page instance
685 // across fragment recreations (Android) or multiple frame attachments.
686 const buildTarget = () => {
687 const existingApp = getCurrentApp();
688 const baseProvides = (existingApp && existingApp._context && existingApp._context.provides) || {};
689 const app = AppFactory(normalizeComponent(comp, comp && (comp.__name || comp.name)));
690 switch (__NS_TARGET_FLAVOR__) {
691 case 'vue':
692 ensurePiniaOnApp(app);
693 break;
694 }
695 try {
696 const registry: Map<string, any> | undefined = g.__nsVendorRegistry;
697 const req: any = registry?.get ? g.__nsVendorRequire || g.__nsRequire || g.require : g.__nsRequire || g.require;
698 let rh: any = null;
699 if (registry && registry.has('nativescript-vue/dist/runtimeHelpers')) rh = registry.get('nativescript-vue/dist/runtimeHelpers');
700 if (!rh && typeof req === 'function') {
701 try {
702 rh = req('nativescript-vue/dist/runtimeHelpers');
703 } catch {}
704 }
705 const setRootApp = rh && (rh.setRootApp || rh.default?.setRootApp);
706 if (typeof setRootApp === 'function') setRootApp(app);
707 } catch {}
708 try {
709 const ctx = app?._context;
710 if (ctx) {
711 const prov = (ctx.provides ||= {});
712 Object.getOwnPropertyNames(baseProvides).forEach((k) => {
713 if (!Object.prototype.hasOwnProperty.call(prov, k)) prov[k] = baseProvides[k];
714 });
715 Object.getOwnPropertySymbols(baseProvides).forEach((s) => {
716 if (!Object.prototype.hasOwnProperty.call(prov, s)) prov[s] = (baseProvides as any)[s];
717 });
718 }

Callers

nothing calls this directly

Calls 13

ensureVueGlobalsFunction · 0.85
getRootFrameFunction · 0.85
buildTargetFunction · 0.85
attachDiagnosticsToFrameFunction · 0.85
setRootFrameFunction · 0.85
summarizeNavEntryFunction · 0.85
getCoreFunction · 0.70
navigateMethod · 0.65
topmostMethod · 0.45
logMethod · 0.45
resetRootViewMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected