aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-cleanup.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-08-24 05:59:23 +0000
committerstephan <stephan@noemail.net>2022-08-24 05:59:23 +0000
commit9a34509a06ad893ae3ac786363ebf8d29b3e3a7c (patch)
tree45fe8feae7e32d3a5db59c969857486de728d168 /ext/wasm/api/sqlite3-api-cleanup.js
parentefeee19a958b905cc8e939e54b2959089bb89108 (diff)
downloadsqlite-9a34509a06ad893ae3ac786363ebf8d29b3e3a7c.tar.gz
sqlite-9a34509a06ad893ae3ac786363ebf8d29b3e3a7c.zip
More work on how to configure the sqlite3 JS API bootstrapping process from higher-level code. Initial version of sqlite3-worker1-promiser, a Promise-based proxy for the Worker API #1.
FossilOrigin-Name: b030f321bd5a38cdd5d6f6735f201afa62d30d2b0ba02e67f055b4895553a878
Diffstat (limited to 'ext/wasm/api/sqlite3-api-cleanup.js')
-rw-r--r--ext/wasm/api/sqlite3-api-cleanup.js45
1 files changed, 15 insertions, 30 deletions
diff --git a/ext/wasm/api/sqlite3-api-cleanup.js b/ext/wasm/api/sqlite3-api-cleanup.js
index d989facca..ed6b8c40e 100644
--- a/ext/wasm/api/sqlite3-api-cleanup.js
+++ b/ext/wasm/api/sqlite3-api-cleanup.js
@@ -18,44 +18,24 @@
'use strict';
if('undefined' !== typeof Module){ // presumably an Emscripten build
/**
- Replace sqlite3ApiBootstrap() with a variant which plugs in the
- Emscripten-based config for all config options which the client
- does not provide.
+ Install a suitable default configuration for sqlite3ApiBootstrap().
*/
- const SAB = self.sqlite3ApiBootstrap;
- self.sqlite3ApiBootstrap = function(apiConfig){
- apiConfig = apiConfig || {};
- const configDefaults = {
- Module: Module /* ==> Emscripten-style Module object. 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 */
- };
- const config = {};
- Object.keys(configDefaults).forEach(function(k){
- config[k] = Object.getOwnPropertyDescriptor(apiConfig, k)
- ? apiConfig[k] : configDefaults[k];
- });
- // Copy over any properties apiConfig defines but configDefaults does not...
- Object.keys(apiConfig).forEach(function(k){
- if(!Object.getOwnPropertyDescriptor(config, k)){
- config[k] = apiConfig[k];
- }
- });
- return SAB(config);
- };
+ const SABC = self.sqlite3ApiBootstrap.defaultConfig;
+ SABC.Module = Module /* ==> Current needs to be exposed here for test code. NOT part
+ of the public API. */;
+ SABC.exports = Module['asm'];
+ SABC.memory = Module.wasmMemory /* gets set if built with -sIMPORT_MEMORY */;
/**
For current (2022-08-22) purposes, automatically call
sqlite3ApiBootstrap(). That decision will be revisited at some
point, as we really want client code to be able to call this to
- configure certain parts. If the global sqliteApiConfig property
- is available, it is assumed to be a config object for
- sqlite3ApiBootstrap().
+ configure certain parts. Clients may modify
+ self.sqlite3ApiBootstrap.defaultConfig to tweak the default
+ configuration used by a no-args call to sqlite3ApiBootstrap().
*/
//console.warn("self.sqlite3ApiConfig = ",self.sqlite3ApiConfig);
- const sqlite3 = self.sqlite3ApiBootstrap(self.sqlite3ApiConfig || Object.create(null));
+ const sqlite3 = self.sqlite3ApiBootstrap();
delete self.sqlite3ApiBootstrap;
if(self.location && +self.location.port > 1024){
@@ -67,4 +47,9 @@ if('undefined' !== typeof Module){ // presumably an Emscripten build
delete sqlite3.capi.util /* arguable, but these are (currently) internal-use APIs */;
//console.warn("Module.sqlite3 =",Module.sqlite3);
Module.sqlite3 = sqlite3 /* Currently needed by test code and sqlite3-worker1.js */;
+}else{
+ console.warn("This is not running in an Emscripten module context, so",
+ "self.sqlite3ApiBootstrap() is _not_ being called due to lack",
+ "of config info for the WASM environment.",
+ "It must be called manually.");
}