mirror of
https://github.com/sqlite/sqlite.git
synced 2025-12-20 01:22:32 +03:00
73 lines
3.0 KiB
JavaScript
73 lines
3.0 KiB
JavaScript
/*
|
|
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,
|
|
closing the function scope opened by post-js-header.js.
|
|
|
|
In terms of amalgamation code placement, this file is appended
|
|
immediately after the final sqlite3-api-*.js piece. Those files
|
|
cooperate to prepare sqlite3ApiBootstrap() and this file calls it.
|
|
It is run within a context which gives it access to Emscripten's
|
|
Module object, after sqlite3.wasm is loaded but before
|
|
sqlite3ApiBootstrap() has been called.
|
|
|
|
Because this code resides (after building) inside the function
|
|
installed by post-js-header.js, it has access to state set up by
|
|
pre-js.c-pp.js and friends.
|
|
*/
|
|
try{
|
|
/* We are in the closing block of Module.runSQLite3PostLoadInit(), so
|
|
its arguments are visible here. */
|
|
|
|
/* Config options for sqlite3ApiBootstrap(). */
|
|
const bootstrapConfig = Object.assign(
|
|
Object.create(null),
|
|
/** The WASM-environment-dependent configuration for sqlite3ApiBootstrap() */
|
|
{
|
|
memory: ('undefined'!==typeof wasmMemory)
|
|
? wasmMemory
|
|
: EmscriptenModule['wasmMemory'],
|
|
exports: ('undefined'!==typeof wasmExports)
|
|
? wasmExports /* emscripten >=3.1.44 */
|
|
: (Object.prototype.hasOwnProperty.call(EmscriptenModule,'wasmExports')
|
|
? EmscriptenModule['wasmExports']
|
|
: EmscriptenModule['asm']/* emscripten <=3.1.43 */)
|
|
},
|
|
globalThis.sqlite3ApiBootstrap.defaultConfig, // default options
|
|
globalThis.sqlite3ApiConfig || {} // optional client-provided options
|
|
);
|
|
|
|
sqlite3InitScriptInfo.debugModule("Bootstrapping lib config", bootstrapConfig);
|
|
|
|
/**
|
|
For purposes of the Emscripten build, call sqlite3ApiBootstrap().
|
|
Ideally clients should be able to inject their own config here,
|
|
but that's not practical in this particular build constellation
|
|
because of the order everything happens in. Clients may either
|
|
define globalThis.sqlite3ApiConfig or modify
|
|
globalThis.sqlite3ApiBootstrap.defaultConfig to tweak the default
|
|
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.
|
|
*/
|
|
const p = globalThis.sqlite3ApiBootstrap(bootstrapConfig);
|
|
delete globalThis.sqlite3ApiBootstrap;
|
|
return p /* the eventual result of globalThis.sqlite3InitModule() */;
|
|
}catch(e){
|
|
console.error("sqlite3ApiBootstrap() error:",e);
|
|
throw e;
|
|
}
|
|
|
|
//console.warn("This is the end of the Module.runSQLite3PostLoadInit handler.");
|
|
}/*Module.runSQLite3PostLoadInit(...)*/;
|
|
//console.warn("This is the end of the setup of the (pending) Module.runSQLite3PostLoadInit");
|