interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / wasm / api / post-js-footer.js

72 lines · 3019 bytes Raw Blame History
1/*
2 2022-07-22
3
4 The author disclaims copyright to this source code. In place of a
5 legal notice, here is a blessing:
6
7 * May you do good and not evil.
8 * May you find forgiveness for yourself and forgive others.
9 * May you share freely, never taking more than you give.
10
11 ***********************************************************************
12
13 This file is the tail end of the sqlite3-api.js constellation,
14 closing the function scope opened by post-js-header.js.
15
16 In terms of amalgamation code placement, this file is appended
17 immediately after the final sqlite3-api-*.js piece. Those files
18 cooperate to prepare sqlite3ApiBootstrap() and this file calls it.
19 It is run within a context which gives it access to Emscripten's
20 Module object, after sqlite3.wasm is loaded but before
21 sqlite3ApiBootstrap() has been called.
22
23 Because this code resides (after building) inside the function
24 installed by post-js-header.js, it has access to state set up by
25 pre-js.c-pp.js and friends.
26*/
27try{
28 /* We are in the closing block of Module.runSQLite3PostLoadInit(),
29 so its arguments are visible here, as are symbols exposed by the
30 amalgamated library JS files. */
31
32 /* Config options for sqlite3ApiBootstrap(). */
33 const bootstrapConfig = Object.assign(
34 Object.create(null),
35 /** The WASM-environment-dependent configuration for sqlite3ApiBootstrap() */
36 {
37 memory: ('undefined'!==typeof wasmMemory)
38 ? wasmMemory
39 : EmscriptenModule['wasmMemory'],
40 exports: ('undefined'!==typeof wasmExports)
41 ? wasmExports /* emscripten >=3.1.44 */
42 : (Object.prototype.hasOwnProperty.call(EmscriptenModule,'wasmExports')
43 ? EmscriptenModule['wasmExports']
44 : EmscriptenModule['asm']/* emscripten <=3.1.43 */)
45 },
46 sqlite3ApiBootstrap.defaultConfig, // default options
47 globalThis.sqlite3ApiConfig ?? {} // optional client-provided options
48 );
49
50 sqlite3InitScriptInfo.debugModule("Bootstrapping lib config", bootstrapConfig);
51
52 /**
53 For purposes of the Emscripten build, call sqlite3ApiBootstrap().
54 Ideally clients should be able to inject their own config here,
55 but that's not practical in this particular build constellation
56 because of the order everything happens in. Clients may either
57 define globalThis.sqlite3ApiConfig or modify
58 sqlite3ApiBootstrap.defaultConfig to tweak the default
59 configuration used by a no-args call to sqlite3ApiBootstrap(),
60 but must have first loaded their WASM module in order to be able
61 to provide the necessary configuration state.
62 */
63 const p = sqlite3ApiBootstrap(bootstrapConfig);
64 return p /* the eventual result of sqlite3InitModule() */;
65}catch(e){
66 console.error("sqlite3ApiBootstrap() error:",e);
67 throw e;
68}
69
70//console.warn("This is the end of the Module.runSQLite3PostLoadInit handler.");
71}/*Module.runSQLite3PostLoadInit(...)*/;
72//console.warn("This is the end of the setup of the (pending) Module.runSQLite3PostLoadInit");