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

Function load

runtime/worker/engine.js:52–81  ·  view source on GitHub ↗
({ wasmUrl, integrity = true, loaders: loaderUrls = [], imports = null, version = null, availableHosts = [] }, manifests = [])

Source from the content-addressed store, hash-verified

50let mainThreadManifests = [];
51
52export async function load({ wasmUrl, integrity = true, loaders: loaderUrls = [], imports = null, version = null, availableHosts = [] }, manifests = []) {
53 const t0 = performance.now();
54 importsMap = imports;
55 lazyHostNames = availableHosts;
56
57 cache = await openCache(integrity);
58 integrityActive = cache instanceof MemoryCache ? false : Boolean(integrity);
59
60 if (integrityActive) {
61 const stored = await cache.getVersion();
62 if (!version || stored !== version) {
63 await cache.clear();
64 if (version) await cache.setVersion(version);
65 }
66 }
67
68 loaders = await Promise.all(
69 loaderUrls.map(async (url) => (await import(url)).default)
70 );
71
72 mainThreadManifests = manifests;
73
74 // Plain fetch, no SRI; the browser decodes any Content-Encoding (br/gzip) before compileStreaming.
75 const response = await fetch(wasmUrl);
76 if (!response.ok) throw new Error(`fetch failed for '${wasmUrl}' (${response.status})`);
77 const wrapped = new Response(response.body, { headers: { 'Content-Type': 'application/wasm' } });
78 wasmModule = await WebAssembly.compileStreaming(wrapped);
79
80 return { integrityActive, loadMs: performance.now() - t0 };
81}
82
83export async function run({ src, entryDir = '', baseUrl = null, onLine, incremental = false }) {
84 if (!wasmModule) throw new Error('engine.load() must be called before run()');

Callers 5

addFunction · 0.85
removeFunction · 0.85
run_scriptFunction · 0.85
runFunction · 0.85
runFunction · 0.85

Calls 5

openCacheFunction · 0.85
fetchFunction · 0.85
getVersionMethod · 0.45
clearMethod · 0.45
setVersionMethod · 0.45

Tested by

no test coverage detected