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