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-worker1.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-worker1.js')
-rw-r--r-- | ext/wasm/api/sqlite3-api-worker1.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/wasm/api/sqlite3-api-worker1.js b/ext/wasm/api/sqlite3-api-worker1.js index f82be6cd0..5120ed006 100644 --- a/ext/wasm/api/sqlite3-api-worker1.js +++ b/ext/wasm/api/sqlite3-api-worker1.js @@ -313,7 +313,7 @@ options.columnNames may be populated by the call to db.exec(). */ -self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ +globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ sqlite3.initWorker1API = function(){ 'use strict'; const toss = (...args)=>{throw new Error(args.join(' '))}; @@ -382,10 +382,10 @@ sqlite3.initWorker1API = function(){ */ post: function(msg,xferList){ if(xferList && xferList.length){ - self.postMessage( msg, Array.from(xferList) ); + globalThis.postMessage( msg, Array.from(xferList) ); xferList.length = 0; }else{ - self.postMessage(msg); + globalThis.postMessage(msg); } }, /** Map of DB IDs to DBs. */ @@ -589,7 +589,7 @@ sqlite3.initWorker1API = function(){ } }/*wMsgHandler*/; - self.onmessage = async function(ev){ + globalThis.onmessage = async function(ev){ ev = ev.data; let result, dbId = ev.dbId, evType = ev.type; const arrivalTime = performance.now(); @@ -637,6 +637,6 @@ sqlite3.initWorker1API = function(){ result: result }, wState.xfer); }; - self.postMessage({type:'sqlite3-api',result:'worker1-ready'}); + globalThis.postMessage({type:'sqlite3-api',result:'worker1-ready'}); }.bind({self, sqlite3}); }); |