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

Function addCandidate

packages/vite/hmr/server/websocket.ts:5388–5413  ·  view source on GitHub ↗
(orig: string)

Source from the content-addressed store, hash-verified

5386 const raw = collectImportDependencies(code, rel);
5387 const filtered: Set<string> = new Set();
5388 const addCandidate = (orig: string) => {
5389 if (!orig) return;
5390 let cleaned = orig.replace(PAT.QUERY_PATTERN, '');
5391 if (isCoreGlobalsReference(cleaned)) return;
5392 if (isNativeScriptCoreModule(cleaned)) return;
5393 if (isNativeScriptPluginModule(cleaned)) return;
5394 if (resolveVendorFromCandidate(cleaned)) return;
5395 if (/\bdep-[a-f0-9]{8}\.mjs$/i.test(cleaned)) return;
5396 if (/\bsfc-[a-f0-9]{8}\.mjs$/i.test(cleaned)) return;
5397 // Normalize __NSDOC__/ prefix
5398 if (cleaned.startsWith('__NSDOC__/')) {
5399 cleaned = cleaned.substring('__NSDOC__/'.length);
5400 if (!cleaned.startsWith('/')) cleaned = '/' + cleaned;
5401 }
5402 // Relative path (./ or ../) → resolve to absolute /path relative to SFC file
5403 if (cleaned.startsWith('./') || cleaned.startsWith('../')) {
5404 const importerDir = path.posix.dirname(rel);
5405 let abs = path.posix.normalize(path.posix.join(importerDir, cleaned));
5406 if (!abs.startsWith('/')) abs = '/' + abs;
5407 cleaned = abs;
5408 }
5409 if (!cleaned.startsWith('/')) return; // still not absolute app path
5410 cleaned = cleaned.replace(/\.(ts|js|tsx|jsx|mts|cts)$/i, '.mjs');
5411 if (!/\.mjs$/i.test(cleaned)) return;
5412 filtered.add(cleaned);
5413 };
5414 for (const spec of raw) {
5415 addCandidate(spec);
5416 }

Callers 1

handleHotUpdateFunction · 0.85

Calls 8

isCoreGlobalsReferenceFunction · 0.85
isNativeScriptCoreModuleFunction · 0.85
replaceMethod · 0.80
joinMethod · 0.80
addMethod · 0.65
testMethod · 0.45

Tested by

no test coverage detected