diff options
author | stephan <stephan@noemail.net> | 2022-09-29 13:17:50 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-09-29 13:17:50 +0000 |
commit | b94a98607a3bd4dd55f4d5ce16f171ba066bafb2 (patch) | |
tree | 097b3fae84f287075120e7685458c4d1bb98af60 /ext/wasm/test-opfs-vfs.js | |
parent | 4b884bb4c77cb4b1e5059395212160f4ee48cc53 (diff) | |
download | sqlite-b94a98607a3bd4dd55f4d5ce16f171ba066bafb2.tar.gz sqlite-b94a98607a3bd4dd55f4d5ce16f171ba066bafb2.zip |
Rework the Emscripten-emitted module loader/init function such that it passes on the sqlite3 module, instead of the Emscripten module, to the first then() of sqlite3InitModule()'s returned Promise. This eliminates any need to mention the Emscripten module object in client-side code unless they want to configure it in advance for loading-status reports.
FossilOrigin-Name: 0dbaa0e2b5abf5c23e2039ec90a3055ebb3c063aaf4e556c42546defe6fbb86d
Diffstat (limited to 'ext/wasm/test-opfs-vfs.js')
-rw-r--r-- | ext/wasm/test-opfs-vfs.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/wasm/test-opfs-vfs.js b/ext/wasm/test-opfs-vfs.js index 93e9e0eb6..78f86e380 100644 --- a/ext/wasm/test-opfs-vfs.js +++ b/ext/wasm/test-opfs-vfs.js @@ -28,7 +28,13 @@ const tryOpfsVfs = function(sqlite3){ const log = (...args)=>console.log(logPrefix,...args); const warn = (...args)=>console.warn(logPrefix,...args); const error = (...args)=>console.error(logPrefix,...args); + const opfs = sqlite3.opfs; log("tryOpfsVfs()"); + if(!sqlite3.opfs){ + const e = toss("OPFS is not available."); + error(e); + throw e; + } const capi = sqlite3.capi; const pVfs = capi.sqlite3_vfs_find("opfs") || toss("Missing 'opfs' VFS."); const oVfs = capi.sqlite3_vfs.instanceForPointer(pVfs) || toss("Unexpected instanceForPointer() result.");; @@ -38,7 +44,6 @@ const tryOpfsVfs = function(sqlite3){ const dbFile = "my-persistent.db"; if(urlArgs.has('delete')) sqlite3.opfs.deleteEntry(dbFile); - const opfs = sqlite3.opfs; const db = new opfs.OpfsDb(dbFile); log("db file:",db.filename); try{ @@ -78,7 +83,6 @@ const tryOpfsVfs = function(sqlite3){ importScripts('sqlite3.js'); self.sqlite3InitModule() - .then((EmscriptenModule)=>EmscriptenModule.sqlite3.asyncPostInit()) .then((sqlite3)=>tryOpfsVfs(sqlite3)) .catch((e)=>{ console.error("Error initializing module:",e); |