MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / scanImports

Function scanImports

runtime/src/prefetch.js:29–43  ·  view source on GitHub ↗
(src, exports)

Source from the content-addressed store, hash-verified

27
28/* Imports of `src`, classified, via the compiler (single source of truth). Returns [{ bare, spec }]. */
29function scanImports(src, exports) {
30 if (typeof exports.extract_imports !== 'function') {
31 throw new Error('compiler is missing extract_imports; runtime and wasm are out of sync');
32 }
33 const bytes = TE.encode(src);
34 const len = Math.min(bytes.length, SOURCE_LIMIT);
35 new Uint8Array(exports.memory.buffer, exports.src_ptr(), len).set(bytes.subarray(0, len));
36 const outLen = exports.extract_imports(len);
37 if (!outLen) return [];
38 const text = TD.decode(new Uint8Array(exports.memory.buffer, exports.out_ptr(), outLen));
39 return text.split('\n').filter(Boolean).map((line) => ({
40 bare: line[0] === 'b',
41 spec: line.slice(line.indexOf('\t') + 1),
42 }));
43}
44
45export async function bfsPrefetch(rootSrc, exports, lockfile, ctx) {
46 const { fetchedSources, knownMissing, importsMap, mainThreadSpecs } = ctx;

Callers 1

bfsPrefetchFunction · 0.85

Calls 1

setMethod · 0.80

Tested by

no test coverage detected