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

Function getCore

packages/vite/hmr/client/utils.ts:44–83  ·  view source on GitHub ↗
(name: 'Application' | 'Frame' | 'Page' | 'Label')

Source from the content-addressed store, hash-verified

42
43// Resolve NativeScript core classes/Application from the vendor realm or globalThis.
44export function getCore(name: 'Application' | 'Frame' | 'Page' | 'Label'): any {
45 const g = globalThis;
46 // 1) Prefer vendor registry to guarantee single realm
47 try {
48 const reg: Map<string, any> | undefined = g.__nsVendorRegistry;
49 if (reg && typeof reg.get === 'function') {
50 const mod = reg.get('@nativescript/core');
51 const ns = (mod && (mod.default || mod)) || mod;
52 if (name === 'Application' && (ns?.Application || ns)) return ns.Application || ns;
53 if (ns && ns[name]) return ns[name];
54 }
55 } catch {}
56 // 2) Fallback to global installed
57 try {
58 if (g && g[name]) return g[name];
59 } catch {}
60 // 3) Device require (still resolves to vendor realm when available)
61 try {
62 const req = g && (g.__nsVendorRequire || g.__nsRequire || g.require);
63 if (typeof req === 'function') {
64 const mod = req('@nativescript/core');
65 const ns = (mod && (mod.default || mod)) || mod;
66 if (name === 'Application' && (ns?.Application || ns)) return ns.Application || ns;
67 if (ns && ns[name]) return ns[name];
68 }
69 } catch {}
70 // 4) Last resort: nativeRequire if available
71 try {
72 const nativeReq = g && g.__nativeRequire;
73 if (typeof nativeReq === 'function') {
74 try {
75 const mod = nativeReq('@nativescript/core', '/');
76 const ns = (mod && (mod.default || mod)) || mod;
77 if (name === 'Application' && (ns?.Application || ns)) return ns.Application || ns;
78 if (ns && ns[name]) return ns[name];
79 } catch {}
80 }
81 } catch {}
82 return undefined;
83}
84
85// last mounted app instance
86let CURRENT_APP: any | null = null;

Callers 13

index.tsFile · 0.70
installDeepDiagnosticsFunction · 0.70
getTopmostFunction · 0.70
applyFullGraphFunction · 0.70
buildTargetFunction · 0.70
__nsNavigateUsingAppFunction · 0.70
processQueueFunction · 0.70
performResetRootFunction · 0.70
createRootFactoryFunction · 0.70
logUiSnapshotFunction · 0.70
getRootForVueFunction · 0.50

Calls 2

reqFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected