2022-08-10 11:26:08 +00:00
|
|
|
/*
|
|
|
|
2022-07-22
|
|
|
|
|
|
|
|
The author disclaims copyright to this source code. In place of a
|
|
|
|
legal notice, here is a blessing:
|
|
|
|
|
|
|
|
* May you do good and not evil.
|
|
|
|
* May you find forgiveness for yourself and forgive others.
|
|
|
|
* May you share freely, never taking more than you give.
|
|
|
|
|
|
|
|
***********************************************************************
|
|
|
|
|
|
|
|
This file is the tail end of the sqlite3-api.js constellation,
|
2022-08-22 21:37:17 +00:00
|
|
|
intended to be appended after all other sqlite3-api-*.js files so
|
|
|
|
that it can finalize any setup and clean up any global symbols
|
|
|
|
temporarily used for setting up the API's various subsystems.
|
2022-08-10 11:26:08 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
2022-08-22 21:37:17 +00:00
|
|
|
if('undefined' !== typeof Module){ // presumably an Emscripten build
|
2022-08-22 13:34:13 +00:00
|
|
|
/**
|
2022-08-24 05:59:23 +00:00
|
|
|
Install a suitable default configuration for sqlite3ApiBootstrap().
|
2022-08-22 13:34:13 +00:00
|
|
|
*/
|
2022-10-16 15:38:03 +00:00
|
|
|
const SABC = Object.assign(
|
|
|
|
Object.create(null), {
|
2023-07-27 01:38:19 +00:00
|
|
|
exports: ('undefined'===typeof wasmExports)
|
|
|
|
? Module['asm']/* emscripten <=3.1.43 */
|
|
|
|
: wasmExports /* emscripten >=3.1.44 */,
|
2023-07-12 09:30:13 +00:00
|
|
|
memory: Module.wasmMemory /* gets set if built with -sIMPORTED_MEMORY */
|
2022-10-16 15:38:03 +00:00
|
|
|
},
|
2023-03-07 19:12:06 +00:00
|
|
|
globalThis.sqlite3ApiConfig || {}
|
2022-10-16 15:38:03 +00:00
|
|
|
);
|
2022-08-22 13:34:13 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-22 21:37:17 +00:00
|
|
|
For current (2022-08-22) purposes, automatically call
|
|
|
|
sqlite3ApiBootstrap(). That decision will be revisited at some
|
|
|
|
point, as we really want client code to be able to call this to
|
2022-08-24 05:59:23 +00:00
|
|
|
configure certain parts. Clients may modify
|
2023-03-07 19:12:06 +00:00
|
|
|
globalThis.sqlite3ApiBootstrap.defaultConfig to tweak the default
|
2022-10-16 15:38:03 +00:00
|
|
|
configuration used by a no-args call to sqlite3ApiBootstrap(),
|
|
|
|
but must have first loaded their WASM module in order to be
|
|
|
|
able to provide the necessary configuration state.
|
2022-08-22 21:37:17 +00:00
|
|
|
*/
|
2023-03-07 19:12:06 +00:00
|
|
|
//console.warn("globalThis.sqlite3ApiConfig = ",globalThis.sqlite3ApiConfig);
|
|
|
|
globalThis.sqlite3ApiConfig = SABC;
|
2022-09-13 19:27:03 +00:00
|
|
|
let sqlite3;
|
|
|
|
try{
|
2023-03-07 19:12:06 +00:00
|
|
|
sqlite3 = globalThis.sqlite3ApiBootstrap();
|
2022-09-30 20:35:37 +00:00
|
|
|
}catch(e){
|
|
|
|
console.error("sqlite3ApiBootstrap() error:",e);
|
|
|
|
throw e;
|
2022-09-13 19:27:03 +00:00
|
|
|
}finally{
|
2023-03-07 19:12:06 +00:00
|
|
|
delete globalThis.sqlite3ApiBootstrap;
|
|
|
|
delete globalThis.sqlite3ApiConfig;
|
2022-09-13 19:27:03 +00:00
|
|
|
}
|
2022-08-22 13:34:13 +00:00
|
|
|
|
2022-09-29 16:54:23 +00:00
|
|
|
Module.sqlite3 = sqlite3 /* Needed for customized sqlite3InitModule() to be able to
|
|
|
|
pass the sqlite3 object off to the client. */;
|
2022-08-24 05:59:23 +00:00
|
|
|
}else{
|
|
|
|
console.warn("This is not running in an Emscripten module context, so",
|
2023-03-07 19:12:06 +00:00
|
|
|
"globalThis.sqlite3ApiBootstrap() is _not_ being called due to lack",
|
2022-08-24 05:59:23 +00:00
|
|
|
"of config info for the WASM environment.",
|
|
|
|
"It must be called manually.");
|
2022-08-22 21:37:17 +00:00
|
|
|
}
|