diff options
author | stephan <stephan@noemail.net> | 2023-03-05 07:44:23 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2023-03-05 07:44:23 +0000 |
commit | eac6e8cb6a177500422de07f75a089cad162c5f2 (patch) | |
tree | 750e5d94f10a6861e31a5e34aba5013f81f2c814 /ext/wasm/api/sqlite3-worker1-promiser.c-pp.js | |
parent | 32b3444f1518d02898ea0b8cbd5a73c7a142cb2a (diff) | |
download | sqlite-eac6e8cb6a177500422de07f75a089cad162c5f2.tar.gz sqlite-eac6e8cb6a177500422de07f75a089cad162c5f2.zip |
Rename sqlite3-worker1-bundler-friendly.js to sqlite3-worker1-bundler-friendly.mjs and refactor it to work as an ES6 module, based on feedback in [forum post a255f89c2eadf4c4|forum:a255f89c2eadf4c4].
FossilOrigin-Name: af312b131457743d98b84137bd51d9ba60e0daf0bd8f5a66f05956ca35ab68fb
Diffstat (limited to 'ext/wasm/api/sqlite3-worker1-promiser.c-pp.js')
-rw-r--r-- | ext/wasm/api/sqlite3-worker1-promiser.c-pp.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js index 0f1ae39ea..86ac279ed 100644 --- a/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js +++ b/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js @@ -114,7 +114,7 @@ by all client code except that which tests this API. The `row` property contains the row result in the form implied by the `rowMode` option (defaulting to `'array'`). The `rowNumber` is a - 1-based integer value incremented by 1 on each call into th + 1-based integer value incremented by 1 on each call into the callback. At the end of the result set, the same event is fired with @@ -122,6 +122,15 @@ the end of the result set has been reached. Note that the rows arrive via worker-posted messages, with all the implications of that. + + Notable shortcomings: + + - This API was not designed with ES6 modules in mind. Neither Firefox + nor Safari support, as of March 2023, the {type:"module"} flag to the + Worker constructor, so that particular usage is not something we're going + to target for the time being: + + https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker */ self.sqlite3Worker1Promiser = function callee(config = callee.defaultConfig){ // Inspired by: https://stackoverflow.com/a/52439530 @@ -160,7 +169,7 @@ self.sqlite3Worker1Promiser = function callee(config = callee.defaultConfig){ if(msgHandler && msgHandler.onrow){ msgHandler.onrow(ev); return; - } + } if(config.onunhandled) config.onunhandled(arguments[0]); else err("sqlite3Worker1Promiser() unhandled worker message:",ev); return; @@ -239,7 +248,10 @@ self.sqlite3Worker1Promiser = function callee(config = callee.defaultConfig){ self.sqlite3Worker1Promiser.defaultConfig = { worker: function(){ //#if target=es6-bundler-friendly - return new Worker("sqlite3-worker1.js"); + return new Worker("sqlite3-worker1-bundler-friendly.mjs",{ + type: 'module' /* Noting that neither Firefox nor Safari suppor this, + as of this writing. */ + }); //#else let theJs = "sqlite3-worker1.js"; if(this.currentScript){ |