diff options
author | stephan <stephan@noemail.net> | 2023-03-07 19:12:06 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2023-03-07 19:12:06 +0000 |
commit | 4214cc32ba2082b90dde97495058c45920235bf4 (patch) | |
tree | 1728d17a0729bdbd450e11bf0eecb4c02ca06691 /ext/wasm/api/sqlite3-api-cleanup.js | |
parent | 7272f6d64d88da451f18aa515db06ed6f2b459d4 (diff) | |
download | sqlite-4214cc32ba2082b90dde97495058c45920235bf4.tar.gz sqlite-4214cc32ba2082b90dde97495058c45920235bf4.zip |
Replace use of 'self' in JS code with 'globalThis', as that works in browsers and node environments. Avoid using globalThis.location if it's not set (e.g. in node). Based on feedback in [forum:ac7a94d4f77db235|forum post ac7a94d4f77db235]. Minor JS build tweaks.
FossilOrigin-Name: dbbe8f25e58738c10b6192d41f1e3886983871f17631cbc45ce626d3f05a6e26
Diffstat (limited to 'ext/wasm/api/sqlite3-api-cleanup.js')
-rw-r--r-- | ext/wasm/api/sqlite3-api-cleanup.js | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/ext/wasm/api/sqlite3-api-cleanup.js b/ext/wasm/api/sqlite3-api-cleanup.js index 7c23f8f89..d38b401bf 100644 --- a/ext/wasm/api/sqlite3-api-cleanup.js +++ b/ext/wasm/api/sqlite3-api-cleanup.js @@ -25,7 +25,7 @@ if('undefined' !== typeof Module){ // presumably an Emscripten build exports: Module['asm'], memory: Module.wasmMemory /* gets set if built with -sIMPORT_MEMORY */ }, - self.sqlite3ApiConfig || {} + globalThis.sqlite3ApiConfig || {} ); /** @@ -33,29 +33,29 @@ if('undefined' !== typeof Module){ // presumably an Emscripten build 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. Clients may modify - self.sqlite3ApiBootstrap.defaultConfig to tweak the default + globalThis.sqlite3ApiBootstrap.defaultConfig to tweak the default 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); - self.sqlite3ApiConfig = SABC; + //console.warn("globalThis.sqlite3ApiConfig = ",globalThis.sqlite3ApiConfig); + globalThis.sqlite3ApiConfig = SABC; let sqlite3; try{ - sqlite3 = self.sqlite3ApiBootstrap(); + sqlite3 = globalThis.sqlite3ApiBootstrap(); }catch(e){ console.error("sqlite3ApiBootstrap() error:",e); throw e; }finally{ - delete self.sqlite3ApiBootstrap; - delete self.sqlite3ApiConfig; + delete globalThis.sqlite3ApiBootstrap; + delete globalThis.sqlite3ApiConfig; } Module.sqlite3 = sqlite3 /* Needed for customized sqlite3InitModule() to be able to pass the sqlite3 object off to the client. */; }else{ console.warn("This is not running in an Emscripten module context, so", - "self.sqlite3ApiBootstrap() is _not_ being called due to lack", + "globalThis.sqlite3ApiBootstrap() is _not_ being called due to lack", "of config info for the WASM environment.", "It must be called manually."); } |