1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

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
This commit is contained in:
stephan
2023-03-05 07:44:23 +00:00
parent 32b3444f15
commit eac6e8cb6a
5 changed files with 30 additions and 20 deletions

View File

@ -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){