diff options
author | stephan <stephan@noemail.net> | 2022-10-19 01:07:30 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-10-19 01:07:30 +0000 |
commit | 71de8e02416aa9a4ad90ac6958ff3fa025a33d2d (patch) | |
tree | 0c2b079d3d1015cbbc4af3dfd08107e96d2e2d1d /ext/wasm/sqlite3-worker1.js | |
parent | b5e2e6fcd39901f3280a4bbbfec7f41d4bcc48f8 (diff) | |
download | sqlite-71de8e02416aa9a4ad90ac6958ff3fa025a33d2d.tar.gz sqlite-71de8e02416aa9a4ad90ac6958ff3fa025a33d2d.zip |
Considerable wasm/js build cleanups and reworking. Remove wasmfs builds from the end-user deliverables and disable the wasmfs build by default, per /chat discussion, as it doubles our deliverable count for only marginal gain. Attempt to move the sqlite3.js/wasm files into subdirectories but rediscovered that that breaks loading in Worker mode because URI resolution of the wasm files differs depending on whether the main script is loaded from a script tag or a Worker.
FossilOrigin-Name: 5b23e0675efdd2f1ea7b4f5836a579e8d6aa8a25b3f1a6a950520ad845ff01bb
Diffstat (limited to 'ext/wasm/sqlite3-worker1.js')
-rw-r--r-- | ext/wasm/sqlite3-worker1.js | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/ext/wasm/sqlite3-worker1.js b/ext/wasm/sqlite3-worker1.js index 167c6a5c7..fef155e1f 100644 --- a/ext/wasm/sqlite3-worker1.js +++ b/ext/wasm/sqlite3-worker1.js @@ -25,13 +25,29 @@ Worker-specific API needs to pass _this_ file (or equivalent) to the Worker constructor and then listen for an event in the form shown above in order to know when the module has completed initialization. + + This file accepts a couple of URL arguments to adjust how it loads + sqlite3.js: + + - `sqlite3.dir`, if set, treats the given directory name as the + directory from which `sqlite3.js` will be loaded. + - `sqlite3.js`, if set, is used as the URI to `sqlite3.js` and it + may contain path elements, e.g. `sqlite3.js=foo/bar/my-sqlite3.js`. + + By default is loads 'sqlite3.js'. */ "use strict"; (()=>{ const urlParams = new URL(self.location.href).searchParams; - importScripts(urlParams.has('wasmfs') - ? 'sqlite3-wasmfs.js' - : 'sqlite3.js'); + let theJs; + if(urlParams.has('sqlite3.js')){ + theJs = urlParams.get('sqlite3.js'); + }else if(urlParams.has('sqlite3.dir')){ + theJs = urlParams.get('sqlite3.dir')+'/sqlite3.js'; + }else{ + theJs = 'sqlite3.js'; + } + importScripts(theJs); sqlite3InitModule().then((sqlite3)=>{ sqlite3.capi.sqlite3_wasmfs_opfs_dir(); sqlite3.initWorker1API(); |