mirror of
https://github.com/sqlite/sqlite.git
synced 2025-12-20 01:22:32 +03:00
Move sqlite3-api-cleanup.js into post-js-footer.js to remove the final direct Emscripten dependency from the intermediary build product sqlite3-api.js (the whole library, waiting to be bootstrapped). This is partly in response to [forum:4b7d45433731d2e0|forum post 4b7d45433731d2e0], which demonstrates a potential use case for a standalone sqlite3-api.js. This is a build/doc change, not a functional one.
FossilOrigin-Name: 2fcbd8e17d8f1dd7e9d45168805dba718777e46803d9375a4212296d3d0cd89c
This commit is contained in:
@@ -1,3 +1,71 @@
|
||||
/*
|
||||
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,
|
||||
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.
|
||||
|
||||
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{
|
||||
/* Config options for sqlite3ApiBootstrap(). */
|
||||
const bootstrapConfig = Object.assign(
|
||||
Object.create(null),
|
||||
globalThis.sqlite3ApiBootstrap.defaultConfig, // default options
|
||||
globalThis.sqlite3ApiConfig || {}, // optional client-provided options
|
||||
/** 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 */)
|
||||
}
|
||||
);
|
||||
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user