(moduleArg = {})
| 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. |
| 41 | async 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. |
| 60 | var 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 | |
| 65 | var ENVIRONMENT_IS_WEB = false; |
| 66 | var ENVIRONMENT_IS_WORKER = false; |
| 67 | var ENVIRONMENT_IS_NODE = true; |
| 68 | var ENVIRONMENT_IS_SHELL = false; |
| 69 | |
| 70 | if (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 | /** |
nothing calls this directly
no test coverage detected