diff options
author | stephan <stephan@noemail.net> | 2022-10-16 15:38:03 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-10-16 15:38:03 +0000 |
commit | 956392694abaaa832ec3186f7b6af5043f71e623 (patch) | |
tree | 2ada9a4e82af9e423971afc30c4ff1557dac10ea /ext/wasm/api | |
parent | 879164ed74846a4bdfcd513c200c70debf0b9409 (diff) | |
download | sqlite-956392694abaaa832ec3186f7b6af5043f71e623.tar.gz sqlite-956392694abaaa832ec3186f7b6af5043f71e623.zip |
Add a top-level license and build-time version info header to generated sqlite3*.js. Correct a broken link in ext/wasm/index.html.
FossilOrigin-Name: 0f1a06e8e39a1fbc74f1aff9cc59787282dfbf847d6c5c7edb3f7d410db0e4b7
Diffstat (limited to 'ext/wasm/api')
-rw-r--r-- | ext/wasm/api/extern-post-js.js | 3 | ||||
-rw-r--r-- | ext/wasm/api/extern-pre-js.js | 3 | ||||
-rw-r--r-- | ext/wasm/api/post-js-footer.js | 3 | ||||
-rw-r--r-- | ext/wasm/api/pre-js.js | 7 | ||||
-rw-r--r-- | ext/wasm/api/sqlite3-api-cleanup.js | 27 | ||||
-rw-r--r-- | ext/wasm/api/sqlite3-license-version-header.js | 25 |
6 files changed, 52 insertions, 16 deletions
diff --git a/ext/wasm/api/extern-post-js.js b/ext/wasm/api/extern-post-js.js index 5ebb5a31e..51e8d12b2 100644 --- a/ext/wasm/api/extern-post-js.js +++ b/ext/wasm/api/extern-post-js.js @@ -1,5 +1,6 @@ /* extern-post-js.js must be appended to the resulting sqlite3.js - file. */ + file. It gets its name from being used as the value for + the --extern-post-js=... Emscripten flag. */ (function(){ /** In order to hide the sqlite3InitModule()'s resulting Emscripten diff --git a/ext/wasm/api/extern-pre-js.js b/ext/wasm/api/extern-pre-js.js index 26d066d2e..7d47d33e3 100644 --- a/ext/wasm/api/extern-pre-js.js +++ b/ext/wasm/api/extern-pre-js.js @@ -1,4 +1,7 @@ /* extern-pre-js.js must be prepended to the resulting sqlite3.js file. This file is currently only used for holding snippets during test and development. + + It gets its name from being used as the value for the + --extern-pre-js=... Emscripten flag. */ diff --git a/ext/wasm/api/post-js-footer.js b/ext/wasm/api/post-js-footer.js index ee470928b..58882cbd9 100644 --- a/ext/wasm/api/post-js-footer.js +++ b/ext/wasm/api/post-js-footer.js @@ -1,3 +1,4 @@ /* The current function scope was opened via post-js-header.js, which - gets prepended to this at build-time. */ + gets prepended to this at build-time. This file closes that + scope. */ })/*postRun.push(...)*/; diff --git a/ext/wasm/api/pre-js.js b/ext/wasm/api/pre-js.js index 502ecf348..b6630416d 100644 --- a/ext/wasm/api/pre-js.js +++ b/ext/wasm/api/pre-js.js @@ -1,3 +1,9 @@ +/** + BEGIN FILE: api/pre-js.js + + This file is intended to be prepended to the sqlite3.js build using + Emscripten's --pre-js=THIS_FILE flag (or equivalent). +*/ Module['locateFile'] = function(path, prefix) { return prefix + path; }; @@ -39,3 +45,4 @@ Module[xInstantiateWasm] = function callee(imports,onSuccess){ scripts. */ Module[xInstantiateWasm].uri = 'sqlite3.wasm'; +/* END FILE: api/pre-js.js */ diff --git a/ext/wasm/api/sqlite3-api-cleanup.js b/ext/wasm/api/sqlite3-api-cleanup.js index c2a342589..555e5d31c 100644 --- a/ext/wasm/api/sqlite3-api-cleanup.js +++ b/ext/wasm/api/sqlite3-api-cleanup.js @@ -20,17 +20,15 @@ if('undefined' !== typeof Module){ // presumably an Emscripten build /** Install a suitable default configuration for sqlite3ApiBootstrap(). */ - const SABC = self.sqlite3ApiConfig || Object.create(null); - if(undefined===SABC.Module){ - SABC.Module = Module /* ==> Currently needs to be exposed here for - test code. NOT part of the public API. */; - } - if(undefined===SABC.exports){ - SABC.exports = Module['asm']; - } - if(undefined===SABC.memory){ - SABC.memory = Module.wasmMemory /* gets set if built with -sIMPORT_MEMORY */; - } + const SABC = Object.assign( + Object.create(null), { + Module: Module /* ==> Currently needs to be exposed here for + test code. NOT part of the public API. */, + exports: Module['asm'], + memory: Module.wasmMemory /* gets set if built with -sIMPORT_MEMORY */ + }, + self.sqlite3ApiConfig || Object.create(null) + ); /** For current (2022-08-22) purposes, automatically call @@ -38,10 +36,11 @@ if('undefined' !== typeof Module){ // presumably an Emscripten build point, as we really want client code to be able to call this to configure certain parts. Clients may modify self.sqlite3ApiBootstrap.defaultConfig to tweak the default - configuration used by a no-args call to sqlite3ApiBootstrap(). + 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. */ //console.warn("self.sqlite3ApiConfig = ",self.sqlite3ApiConfig); - const rmApiConfig = (SABC !== self.sqlite3ApiConfig); self.sqlite3ApiConfig = SABC; let sqlite3; try{ @@ -51,7 +50,7 @@ if('undefined' !== typeof Module){ // presumably an Emscripten build throw e; }finally{ delete self.sqlite3ApiBootstrap; - if(rmApiConfig) delete self.sqlite3ApiConfig; + delete self.sqlite3ApiConfig; } if(self.location && +self.location.port > 1024){ diff --git a/ext/wasm/api/sqlite3-license-version-header.js b/ext/wasm/api/sqlite3-license-version-header.js new file mode 100644 index 000000000..f8b3eddc5 --- /dev/null +++ b/ext/wasm/api/sqlite3-license-version-header.js @@ -0,0 +1,25 @@ +/* +** LICENSE for the sqlite3 WebAssembly/JavaScript APIs. +** +** This bundle (typically released as sqlite3.js or sqlite3-wasmfs.js) +** is an amalgamation of JavaScript source code from two projects: +** +** 1) https://emscripten.org: the Emscripten "glue code" is covered by +** the terms of the MIT license and University of Illinois/NCSA +** Open Source License, as described at: +** +** https://emscripten.org/docs/introducing_emscripten/emscripten_license.html +** +** 2) https://sqlite.org: all code and documentation labeled as being +** from this source are released under the same terms as the sqlite3 +** C library: +** +** 2022-10-16 +** +** 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. +*/ |