Tweaks to the Worker1 and Promiser APIs prompted by documenting them.

FossilOrigin-Name: c68b9aa160e2c1197ae7eb06a634017ac2b281393074afa4582762d5458c6889
This commit is contained in:
stephan 2022-09-30 23:02:11 +00:00
parent e67a0f40e4
commit ae589b69db
5 changed files with 27 additions and 33 deletions

View File

@ -159,7 +159,7 @@
bigIntEnabled: bool. True if BigInt support is enabled.
wasmfsOpfsDir: path prefix, if any, _intended_ for use with
OPFS persistent storage.
WASMFS OPFS persistent storage.
wasmfsOpfsEnabled: true if persistent storage is enabled in the
current environment. Only files stored under wasmfsOpfsDir
@ -188,15 +188,6 @@
See the sqlite3.oo1.DB constructor for peculiarities and
transformations,
persistent [=false]: if true and filename is not one of ("",
":memory:"), prepend sqlite3.capi.sqlite3_wasmfs_opfs_dir()
to the given filename so that it is stored in persistent storage
_if_ the environment supports it. If persistent storage is not
supported, the filename is used as-is.
// TODO?: ^^^^ maybe rework that, now that we have the non-WASMFS
// OFPS.
}
}
```
@ -218,8 +209,7 @@
Only the `open` operation includes it in the `result` property.
persistent: true if the given filename resides in the
known-persistent storage, else false. This determination is
independent of the `persistent` input argument.
known-persistent storage, else false.
}
}
@ -239,7 +229,7 @@
unlink: if truthy, the associated db will be unlinked (removed)
from the virtual filesystems. Failure to unlink is silently
ignored.
ignored. Does not currently work for all storage backends.
}
}
@ -324,7 +314,7 @@
layer won't emit a result value of `undefined`.)
The callback proxy must not recurse into this interface. An exec()
call will type up the Worker thread, causing any recursion attempt
call will tie up the Worker thread, causing any recursion attempt
to wait until the first exec() is completed.
The response is the input options object (or a synthesized one if

View File

@ -32,10 +32,10 @@
It requires a configuration object with the following properties:
- `worker` (required): a Worker instance which loads
`sqlite3-worker1.js` or a functional equivalent. Note that this
function replaces the worker.onmessage property. This property
may alternately be a function, in which case this function
re-assigns this property with the result of calling that
`sqlite3-worker1.js` or a functional equivalent. Note that the
promiser factory replaces the worker.onmessage property. This
config option may alternately be a function, in which case this
function re-assigns this property with the result of calling that
function, enabling delayed instantiation of a Worker.
- `onready` (optional, but...): this callback is called with no
@ -147,6 +147,14 @@
*/
self.sqlite3Worker1Promiser = function callee(config = callee.defaultConfig){
// Inspired by: https://stackoverflow.com/a/52439530
if(1===arguments.length && 'function'===typeof arguments[0]){
const f = config;
config = Object.assign(Object.create(null), callee.defaultConfig);
config.onready = f;
}
/* Maintenance reminder: when passed a config object, the reference
must be used as-is, instead of normalizing it to another object,
so that we can communicate the dbId through it. */
const handlerMap = Object.create(null);
const noop = function(){};
const err = config.onerror || noop;
@ -156,6 +164,7 @@ self.sqlite3Worker1Promiser = function callee(config = callee.defaultConfig){
return msg.type+'#'+(idTypeMap[msg.type] = (idTypeMap[msg.type]||0) + 1);
};
const toss = (...args)=>{throw new Error(args.join(' '))};
if(!config.worker) config.worker = callee.defaultConfig.worker;
if('function'===typeof config.worker) config.worker = config.worker();
config.worker.onmessage = function(ev){
ev = ev.data;

View File

@ -86,16 +86,11 @@
await wtest('open', {
filename: dbFilename,
persistent: sqConfig.wasmfsOpfsEnabled,
simulateError: 0 /* if true, fail the 'open' */,
}, function(ev){
const r = ev.result;
log("then open result",r);
T.assert(r.persistent === sqConfig.wasmfsOpfsEnabled)
.assert(r.persistent
? (dbFilename!==r.filename)
: (dbFilename==r.filename))
.assert(ev.dbId === r.dbId)
T.assert(ev.dbId === r.dbId)
.assert(ev.messageId)
.assert(promiserConfig.dbId === ev.dbId);
}).then(runTests2);

View File

@ -1,5 +1,5 @@
C Add\sJS\swrapper\sfor\ssqlite3_exec()\swhich\sknows\show\sto\shandle\sa\sJS\scallback.\sAdd\ssome\sconsole.error()\sreporting\sof\smodule-load\sfailures,\sas\sthey\sotherwise\soften\sget\ssilently\sswallowed\sup\sby\sthe\sloader's\smechanisms.\sAdd\s'flexible-string'\sJS-to-WASM\sargument\sconverter\swhich\sperforms\smore\sX-to-string\sconversions\sthan\sthe\s'string'\sarg\sconverter\sdoes.
D 2022-09-30T20:35:37.991
C Tweaks\sto\sthe\sWorker1\sand\sPromiser\sAPIs\sprompted\sby\sdocumenting\sthem.
D 2022-09-30T23:02:11.824
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -489,7 +489,7 @@ F ext/wasm/api/sqlite3-api-glue.js ead29e6008ba148e7c67ad2bd928819dc72313ad2dcd3
F ext/wasm/api/sqlite3-api-oo1.js 9caed0757a5e039ed92467e827fd3ca347fa08f19fe086fcbdd14a4ebe9c2f01
F ext/wasm/api/sqlite3-api-opfs.js 1b097808b7b081b0f0700cf97d49ef19760e401706168edff9cd45cf9169f541
F ext/wasm/api/sqlite3-api-prologue.js cac3bc095171dca4aaf3611e0dd60a850c8e9fbeeeba8f21792ed1948d24dacc
F ext/wasm/api/sqlite3-api-worker1.js 2e8a037a76d20c7653e5a392d9830f17a22ce6736ffd0597aa39b69d1c01ad2c
F ext/wasm/api/sqlite3-api-worker1.js 5fb9d178be5215107fc97eb67b9364d0ade3d4a90194b07a630afe6103c83408
F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9
F ext/wasm/api/sqlite3-wasm.c 336389b23c9b83763177499e49a0967949c392b2f7d84fbbb52ad6678e159f18
F ext/wasm/batch-runner.html c363032aba7a525920f61f8be112a29459f73f07e46f0ba3b7730081a617826e
@ -523,12 +523,12 @@ F ext/wasm/split-speedtest1-script.sh a3e271938d4d14ee49105eb05567c6a69ba4c1f129
F ext/wasm/sql/000-mandelbrot.sql 775337a4b80938ac8146aedf88808282f04d02d983d82675bd63d9c2d97a15f0
F ext/wasm/sql/001-sudoku.sql 35b7cb7239ba5d5f193bc05ec379bcf66891bce6f2a5b3879f2f78d0917299b5
F ext/wasm/sqlite3-opfs-async-proxy.js 7367733ce409c8106b6c49e8ef2b55440e9974a64f39e0c97f5e3a4587d1fc2a
F ext/wasm/sqlite3-worker1-promiser.js cca2b853692e4715b4761c46678f96d80819d4756de557922a815149fb93397e
F ext/wasm/sqlite3-worker1-promiser.js 4769b7a0a3d5fa1594ca555e8a3050c17f000fdebdabbc77c31a339ec914c405
F ext/wasm/sqlite3-worker1.js 5266ebc4d709fe23d2d076ae44e6085fbc32b82f26ef514b947312f36b1206a9
F ext/wasm/test-opfs-vfs.html eb69dda21eb414b8f5e3f7c1cc0f774103cc9c0f87b2d28a33419e778abfbab5
F ext/wasm/test-opfs-vfs.js a59ff9210b17d46b0c6fbf6a0ba60143c033327865f2e556e14f06280cef62ac
F ext/wasm/testing-worker1-promiser.html 6eaec6e04a56cf24cf4fa8ef49d78ce8905dde1354235c9125dca6885f7ce893
F ext/wasm/testing-worker1-promiser.js ee1ac4950720c07541e791b7f35bdf420e8ab81a74049cc65394371b0c53c480
F ext/wasm/testing-worker1-promiser.js 4de504b3c79564f0b3975c5e652b4bc16e37d2cc2e29b3a06233a17df5ad8eed
F ext/wasm/testing1.html 50575755e43232dbe4c2f97c9086b3118eb91ec2ee1fae931e6d7669fb17fcae
F ext/wasm/testing1.js 5584e9b68f797dbc0f6161360f2c6840169533813d92c74d355a3e78dd5bb539
F ext/wasm/testing2.html a66951c38137ff1d687df79466351f3c734fa9c6d9cce71d3cf97c291b2167e3
@ -2029,8 +2029,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 711f458d188a0dbe6612069c856ade29323ab426dfa4f80e7b82757ccc474cb8
R 84d8e08f60a70faceba1089503bc1c19
P 96818aa83f4ccc574f558231249ecbdd39763b4351cf4cf6d33f53774a3ee5e6
R 572b0ac83bec64a69d8e85421a244ded
U stephan
Z f9cd8bd536b2dd8409558133f7a063eb
Z 43e7dcdb92d55bec08378952a610d517
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
96818aa83f4ccc574f558231249ecbdd39763b4351cf4cf6d33f53774a3ee5e6
c68b9aa160e2c1197ae7eb06a634017ac2b281393074afa4582762d5458c6889