mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
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
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user