aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/scratchpad-wasmfs-main.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2023-07-13 04:26:13 +0000
committerstephan <stephan@noemail.net>2023-07-13 04:26:13 +0000
commit01bdff7a1c64b258261e1555957d95a203aba590 (patch)
treee4f7ee1a66caffcbd571a328e15b14f28d247bea /ext/wasm/scratchpad-wasmfs-main.js
parent81602595a0eb65272e83f98a2a4e581bed757996 (diff)
downloadsqlite-01bdff7a1c64b258261e1555957d95a203aba590.tar.gz
sqlite-01bdff7a1c64b258261e1555957d95a203aba590.zip
Get wasmfs build and its bare-bones test app working again, albeit currently in ES6 mode only.
FossilOrigin-Name: 647761ed422f196f94facc88bbddd7219a2c1a6301a5f847b0a32d3e405233a7
Diffstat (limited to 'ext/wasm/scratchpad-wasmfs-main.js')
-rw-r--r--ext/wasm/scratchpad-wasmfs-main.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/ext/wasm/scratchpad-wasmfs-main.js b/ext/wasm/scratchpad-wasmfs-main.js
index 56f9325de..3fb8d6af0 100644
--- a/ext/wasm/scratchpad-wasmfs-main.js
+++ b/ext/wasm/scratchpad-wasmfs-main.js
@@ -14,6 +14,9 @@
main JS thread and sqlite3.js must have been loaded before it.
*/
'use strict';
+//importScripts('jswasm/sqlite3-wasmfs.js');
+import sqlite3InitModule from './jswasm/sqlite3-wasmfs.mjs';
+//console.log('sqlite3InitModule =',sqlite3InitModule);
(function(){
const toss = function(...args){throw new Error(args.join(' '))};
const log = console.log.bind(console),
@@ -38,6 +41,7 @@
const capi = sqlite3.capi,
oo = sqlite3.oo1,
wasm = sqlite3.wasm;
+ stdout("Loaded module:",sqlite3);
stdout("Loaded sqlite3:",capi.sqlite3_libversion(), capi.sqlite3_sourceid());
const persistentDir = capi.sqlite3_wasmfs_opfs_dir();
if(persistentDir){
@@ -66,5 +70,15 @@
stdout("Total test time:",(performance.now() - startTime),"ms");
};
- sqlite3InitModule(self.sqlite3TestModule).then(runTests);
+ sqlite3InitModule(globalThis.sqlite3TestModule).then((X)=>{
+ /*
+ 2023-07-13: we're passed the Emscripten Module object here
+ instead of the sqlite3 object. This differs from the canonical
+ build and is a side effect of WASMFS's requirement
+ that the module init function (i.e. sqlite3InitModule())
+ return its initial arrgument (the Emscripten Module).
+ */
+ stdout("then() got",X.sqlite3,X);
+ runTests(X.sqlite3 || X);
+ });
})();