MCPcopy Create free account
hub / github.com/GoogleChrome/samples / sqlite3InitModule

Function sqlite3InitModule

sqlite-wasm-cos/sqlite3-node.mjs:41–18077  ·  view source on GitHub ↗
(moduleArg = {})

Source from the content-addressed store, hash-verified

39// When targeting node and ES6 we use `await import ..` in the generated code
40// so the outer function needs to be marked as async.
41async function sqlite3InitModule(moduleArg = {}) {
42 var moduleRtn;
43
44// include: shell.js
45// include: minimum_runtime_check.js
46// end include: minimum_runtime_check.js
47// The Module object: Our interface to the outside world. We import
48// and export values on it. There are various ways Module can be used:
49// 1. Not defined. We create it here
50// 2. A function parameter, function(moduleArg) => Promise<Module>
51// 3. pre-run appended it, var Module = {}; ..generated code..
52// 4. External script tag defines var Module.
53// We need to check if Module already exists (e.g. case 3 above).
54// Substitution will be replaced with actual code on later stage of the build,
55// this way Closure Compiler will not mangle it (e.g. case 4. above).
56// Note that if you want to run closure, and also to use Module
57// after the generated code, you will need to define var Module = {};
58// before the code. Then that object will be used in the code, and you
59// can continue to use Module afterwards as well.
60var Module = moduleArg;
61
62// Determine the runtime environment we are in. You can customize this by
63// setting the ENVIRONMENT setting at compile time (see settings.js).
64
65var ENVIRONMENT_IS_WEB = false;
66var ENVIRONMENT_IS_WORKER = false;
67var ENVIRONMENT_IS_NODE = true;
68var ENVIRONMENT_IS_SHELL = false;
69
70if (ENVIRONMENT_IS_NODE) {
71 // When building an ES module `require` is not normally available.
72 // We need to use `createRequire()` to construct the require()` function.
73 const { createRequire } = await import('node:module');
74 /** @suppress{duplicate} */
75 var require = createRequire(import.meta.url);
76
77}
78
79// --pre-jses are emitted after the Module integration code, so that they can
80// refer to Module (if they choose; they can also define Module)
81// include: ./bld/pre-js.node.js
82/**
83 BEGIN FILE: api/pre-js.js
84
85 This file is intended to be prepended to the sqlite3.js build using
86 Emscripten's --pre-js=THIS_FILE flag (or equivalent). It is run
87 from inside of sqlite3InitModule(), after Emscripten's Module is
88 defined, but early enough that we can ammend, or even outright
89 replace, Module from here.
90
91 Because this runs in-between Emscripten's own bootstrapping and
92 Emscripten's main work, we must be careful with file-local symbol
93 names. e.g. don't overwrite anything Emscripten defines and do not
94 use 'const' for local symbols which Emscripten might try to use for
95 itself. i.e. try to keep file-local symbol names obnoxiously
96 collision-resistant.
97*/
98/**

Callers

nothing calls this directly

Calls 15

callbackFunction · 0.85
setMethod · 0.80
addMethod · 0.80
toStringMethod · 0.80
encodeMethod · 0.80
cleanupMethod · 0.80
finalizeMethod · 0.80
isFileURIFunction · 0.70
trimFunction · 0.70
initMemoryFunction · 0.70
createWasmFunction · 0.70
runFunction · 0.70

Tested by

no test coverage detected