1f71c954cSstephanModule['locateFile'] = function(path, prefix) { 2f71c954cSstephan return prefix + path; 3f71c954cSstephan}; 4f71c954cSstephan 5f71c954cSstephan/** 6f71c954cSstephan Bug warning: this xInstantiateWasm bit must remain disabled 7f71c954cSstephan until this bug is resolved or wasmfs won't work: 8f71c954cSstephan 9f71c954cSstephan https://github.com/emscripten-core/emscripten/issues/17951 10f71c954cSstephan*/ 11f71c954cSstephanconst xInstantiateWasm = 1 12f71c954cSstephan ? 'emscripten-bug-17951' 13f71c954cSstephan : 'instantiateWasm'; 14f71c954cSstephanModule[xInstantiateWasm] = function callee(imports,onSuccess){ 15*f6c686c9Sstephan imports.env.foo = function(){}; 16f71c954cSstephan console.warn("instantiateWasm() uri =",callee.uri, self.location.href); 17f71c954cSstephan const wfetch = ()=>fetch(callee.uri, {credentials: 'same-origin'}); 18f71c954cSstephan const loadWasm = WebAssembly.instantiateStreaming 19*f6c686c9Sstephan ? async ()=>{ 20f71c954cSstephan return WebAssembly.instantiateStreaming(wfetch(), imports) 21f71c954cSstephan .then((arg)=>onSuccess(arg.instance, arg.module)); 22f71c954cSstephan } 23*f6c686c9Sstephan : async ()=>{ // Safari < v15 24f71c954cSstephan return wfetch() 25f71c954cSstephan .then(response => response.arrayBuffer()) 26f71c954cSstephan .then(bytes => WebAssembly.instantiate(bytes, imports)) 27f71c954cSstephan .then((arg)=>onSuccess(arg.instance, arg.module)); 28f71c954cSstephan }; 29f71c954cSstephan loadWasm(); 30f71c954cSstephan return {}; 31f71c954cSstephan}; 32f71c954cSstephan/* 33*f6c686c9Sstephan It is literally impossible to reliably get the name of _this_ script 34*f6c686c9Sstephan at runtime, so impossible to derive X.wasm from script name 35*f6c686c9Sstephan X.js. Thus we need, at build-time, to redefine 36*f6c686c9Sstephan Module[xInstantiateWasm].uri by appending it to a build-specific 37*f6c686c9Sstephan copy of this file with the name of the wasm file. This is apparently 38*f6c686c9Sstephan why Emscripten hard-codes the name of the wasm file into their glue 39*f6c686c9Sstephan scripts. 40f71c954cSstephan*/ 41f71c954cSstephanModule[xInstantiateWasm].uri = 'sqlite3.wasm'; 42