diff options
author | stephan <stephan@noemail.net> | 2022-09-30 11:01:44 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-09-30 11:01:44 +0000 |
commit | f6c686c9f4dc33c66e103d0af437aaf5ae2c20b6 (patch) | |
tree | 3b34e6d2ccb202bcb4f7db83893e0fc5e5885879 /ext/wasm/api/pre-js.js | |
parent | 53d4e01d063ebee14ff06706b58faba0d07df136 (diff) | |
download | sqlite-f6c686c9f4dc33c66e103d0af437aaf5ae2c20b6.tar.gz sqlite-f6c686c9f4dc33c66e103d0af437aaf5ae2c20b6.zip |
Add oo1.JsStorageDb() as a convenience wrapper for oo1.DB(...,'kvvfs'). Minor doc cleanups.
FossilOrigin-Name: 8a7998709f859a562cf6829485cb9921f8823af0efabe003741348ab1169fb89
Diffstat (limited to 'ext/wasm/api/pre-js.js')
-rw-r--r-- | ext/wasm/api/pre-js.js | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ext/wasm/api/pre-js.js b/ext/wasm/api/pre-js.js index f373fecec..502ecf348 100644 --- a/ext/wasm/api/pre-js.js +++ b/ext/wasm/api/pre-js.js @@ -12,15 +12,15 @@ const xInstantiateWasm = 1 ? 'emscripten-bug-17951' : 'instantiateWasm'; Module[xInstantiateWasm] = function callee(imports,onSuccess){ - imports.foo = function(){}; + imports.env.foo = function(){}; console.warn("instantiateWasm() uri =",callee.uri, self.location.href); const wfetch = ()=>fetch(callee.uri, {credentials: 'same-origin'}); const loadWasm = WebAssembly.instantiateStreaming - ? function loadWasmStreaming(){ + ? async ()=>{ return WebAssembly.instantiateStreaming(wfetch(), imports) .then((arg)=>onSuccess(arg.instance, arg.module)); } - : function loadWasmOldSchool(){ // Safari < v15 + : async ()=>{ // Safari < v15 return wfetch() .then(response => response.arrayBuffer()) .then(bytes => WebAssembly.instantiate(bytes, imports)) @@ -30,11 +30,12 @@ Module[xInstantiateWasm] = function callee(imports,onSuccess){ return {}; }; /* - It is literally impossible to get the name of a Worker's own script, - so impossible to derive X.wasm from script name X.js. Thus we need, - at build-time, to redifine Module['instantiateWasm'].uri by - appending it to a build-specific copy of this file with the name of - the wasm file. This is apparently why Emscripten hard-codes the name of - the wasm file into their glue scripts. + It is literally impossible to reliably get the name of _this_ script + at runtime, so impossible to derive X.wasm from script name + X.js. Thus we need, at build-time, to redefine + Module[xInstantiateWasm].uri by appending it to a build-specific + copy of this file with the name of the wasm file. This is apparently + why Emscripten hard-codes the name of the wasm file into their glue + scripts. */ Module[xInstantiateWasm].uri = 'sqlite3.wasm'; |