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

Function buildTarget

packages/vite/hmr/client/index.ts:686–741  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 }
719 } catch {}
720 const root = new RootCtor();
721 const vm = typeof (app as any).runWithContext === 'function' ? (app as any).runWithContext(() => (app as any).mount(root) as any) : ((app as any).mount(root) as any);
722 setCurrentApp(app);
723 const el = vm?.$el;
724 const nativeView = el?.nativeView;
725 if (!nativeView) throw new Error('navigation mount did not yield a nativeView');
726 const P = getCore('Page');
727 const ctorName = String(nativeView?.constructor?.name || '').replace(/^_+/, '');
728 if (ctorName === 'Page' || /^Page(\$\d+)?$/.test(ctorName)) {
729 return nativeView;
730 }
731 if (typeof P === 'function') {
732 const pg = new (P as any)();
733 (pg as any).content = nativeView;
734 // Hide default ActionBar for wrapped views to avoid double bars
735 try {
736 (pg as any).actionBarHidden = true;
737 } catch {}
738 return pg;
739 }
740 return nativeView; // fallback
741 };
742 let frame = opts && (opts as any).frame ? (opts as any).frame : getRootFrame();
743 if (!frame) {

Callers 1

__nsNavigateUsingAppFunction · 0.85

Calls 12

getCurrentAppFunction · 0.85
normalizeComponentFunction · 0.85
ensurePiniaOnAppFunction · 0.85
reqFunction · 0.85
setCurrentAppFunction · 0.85
forEachMethod · 0.80
replaceMethod · 0.80
getCoreFunction · 0.70
getMethod · 0.65
StringClass · 0.50
callMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected