@livestore/wa-sqlite 0.4.0-dev.22 → 0.4.0-dev.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -36
- package/dist/README.md +13 -13
- package/dist/fts5/wa-sqlite.mjs +1 -1
- package/dist/fts5/wa-sqlite.node.mjs +1 -1
- package/dist/fts5/wa-sqlite.node.wasm +0 -0
- package/dist/fts5/wa-sqlite.wasm +0 -0
- package/dist/wa-sqlite-async.mjs +1 -1
- package/dist/wa-sqlite-async.wasm +0 -0
- package/dist/wa-sqlite-jspi.mjs +1 -1
- package/dist/wa-sqlite-jspi.wasm +0 -0
- package/dist/wa-sqlite.mjs +1 -1
- package/dist/wa-sqlite.node.mjs +1 -1
- package/dist/wa-sqlite.node.wasm +0 -0
- package/dist/wa-sqlite.wasm +0 -0
- package/package.json +40 -29
- package/src/FacadeVFS.js +252 -261
- package/src/VFS.js +84 -85
- package/src/WebLocksMixin.js +357 -351
- package/src/examples/AccessHandlePoolVFS.js +185 -194
- package/src/examples/IDBBatchAtomicVFS.js +429 -409
- package/src/examples/IDBMirrorVFS.js +402 -409
- package/src/examples/MemoryAsyncVFS.js +32 -37
- package/src/examples/MemoryVFS.js +71 -75
- package/src/examples/OPFSAdaptiveVFS.js +206 -206
- package/src/examples/OPFSAnyContextVFS.js +141 -140
- package/src/examples/OPFSCoopSyncVFS.js +297 -299
- package/src/examples/OPFSPermutedVFS.js +529 -540
- package/src/examples/README.md +27 -15
- package/src/examples/tag.js +27 -27
- package/src/sqlite-api.js +910 -941
- package/src/sqlite-constants.js +246 -232
- package/src/types/globals.d.ts +52 -52
- package/src/types/index.d.ts +586 -576
- package/test/AccessHandlePoolVFS.test.js +21 -21
- package/test/IDBBatchAtomicVFS.test.js +69 -69
- package/test/IDBMirrorVFS.test.js +21 -21
- package/test/MemoryAsyncVFS.test.js +21 -21
- package/test/MemoryVFS.test.js +21 -21
- package/test/OPFSAdaptiveVFS.test.js +21 -21
- package/test/OPFSAnyContextVFS.test.js +21 -21
- package/test/OPFSCoopSyncVFS.test.js +21 -21
- package/test/OPFSPermutedVFS.test.js +21 -21
- package/test/TestContext.js +44 -41
- package/test/WebLocksMixin.test.js +369 -360
- package/test/api.test.js +23 -23
- package/test/api_exec.js +72 -61
- package/test/api_misc.js +53 -54
- package/test/api_statements.js +271 -279
- package/test/callbacks.test.js +492 -478
- package/test/data/idbv5.json +1135 -1
- package/test/sql.test.js +30 -30
- package/test/sql_0001.js +49 -33
- package/test/sql_0002.js +55 -34
- package/test/sql_0003.js +85 -49
- package/test/sql_0004.js +76 -47
- package/test/sql_0005.js +60 -44
- package/test/test-worker.js +171 -163
- package/test/vfs_xAccess.js +1 -2
- package/test/vfs_xClose.js +50 -49
- package/test/vfs_xOpen.js +73 -72
- package/test/vfs_xRead.js +31 -31
- package/test/vfs_xWrite.js +30 -29
package/test/TestContext.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as Comlink from 'comlink'
|
|
1
|
+
import * as Comlink from 'comlink'
|
|
2
2
|
|
|
3
|
-
const TEST_WORKER_URL = './test-worker.js'
|
|
4
|
-
const TEST_WORKER_TERMINATE = true
|
|
3
|
+
const TEST_WORKER_URL = './test-worker.js'
|
|
4
|
+
const TEST_WORKER_TERMINATE = true
|
|
5
5
|
|
|
6
|
-
const mapProxyToReleaser = new WeakMap()
|
|
7
|
-
const workerFinalization = new FinalizationRegistry(release => release())
|
|
6
|
+
const mapProxyToReleaser = new WeakMap()
|
|
7
|
+
const workerFinalization = new FinalizationRegistry((release) => release())
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @typedef TestContextParams
|
|
@@ -17,57 +17,61 @@ const workerFinalization = new FinalizationRegistry(release => release());
|
|
|
17
17
|
const DEFAULT_PARAMS = Object.freeze({
|
|
18
18
|
build: 'default',
|
|
19
19
|
config: 'default',
|
|
20
|
-
reset: true
|
|
21
|
-
})
|
|
20
|
+
reset: true,
|
|
21
|
+
})
|
|
22
22
|
|
|
23
23
|
export class TestContext {
|
|
24
|
-
#params = structuredClone(DEFAULT_PARAMS)
|
|
24
|
+
#params = structuredClone(DEFAULT_PARAMS)
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* @param {TestContextParams} params
|
|
27
|
+
* @param {TestContextParams} params
|
|
28
28
|
*/
|
|
29
29
|
constructor(params = {}) {
|
|
30
|
-
Object.assign(this.#params, params)
|
|
30
|
+
Object.assign(this.#params, params)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
async create(extras = {}) {
|
|
34
|
-
const url = new URL(TEST_WORKER_URL, import.meta.url)
|
|
34
|
+
const url = new URL(TEST_WORKER_URL, import.meta.url)
|
|
35
35
|
for (const [key, value] of Object.entries(this.#params)) {
|
|
36
|
-
url.searchParams.set(key, value.toString())
|
|
36
|
+
url.searchParams.set(key, value.toString())
|
|
37
37
|
}
|
|
38
38
|
for (const [key, value] of Object.entries(extras)) {
|
|
39
|
-
url.searchParams.set(key, value.toString())
|
|
39
|
+
url.searchParams.set(key, value.toString())
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const worker = new Worker(url, { type: 'module' })
|
|
43
|
-
const port = await new Promise(resolve => {
|
|
44
|
-
worker.addEventListener(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
const worker = new Worker(url, { type: 'module' })
|
|
43
|
+
const port = await new Promise((resolve) => {
|
|
44
|
+
worker.addEventListener(
|
|
45
|
+
'message',
|
|
46
|
+
(event) => {
|
|
47
|
+
if (event.ports[0]) {
|
|
48
|
+
return resolve(event.ports[0])
|
|
49
|
+
}
|
|
50
|
+
const e = new Error(event.data.message)
|
|
51
|
+
throw Object.assign(e, event.data)
|
|
52
|
+
},
|
|
53
|
+
{ once: true },
|
|
54
|
+
)
|
|
55
|
+
})
|
|
52
56
|
|
|
53
|
-
const proxy = Comlink.wrap(port)
|
|
57
|
+
const proxy = Comlink.wrap(port)
|
|
54
58
|
if (TEST_WORKER_TERMINATE) {
|
|
55
59
|
function releaser() {
|
|
56
|
-
worker.terminate()
|
|
60
|
+
worker.terminate()
|
|
57
61
|
}
|
|
58
|
-
mapProxyToReleaser.set(proxy, releaser)
|
|
59
|
-
workerFinalization.register(proxy, releaser)
|
|
62
|
+
mapProxyToReleaser.set(proxy, releaser)
|
|
63
|
+
workerFinalization.register(proxy, releaser)
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
return proxy
|
|
66
|
+
return proxy
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
async destroy(proxy) {
|
|
66
|
-
proxy[Comlink.releaseProxy]()
|
|
67
|
-
const releaser = mapProxyToReleaser.get(proxy)
|
|
70
|
+
proxy[Comlink.releaseProxy]()
|
|
71
|
+
const releaser = mapProxyToReleaser.get(proxy)
|
|
68
72
|
if (releaser) {
|
|
69
|
-
workerFinalization.unregister(releaser)
|
|
70
|
-
releaser()
|
|
73
|
+
workerFinalization.unregister(releaser)
|
|
74
|
+
releaser()
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
|
|
@@ -75,22 +79,21 @@ export class TestContext {
|
|
|
75
79
|
static async supportsJSPI() {
|
|
76
80
|
try {
|
|
77
81
|
const m = new Uint8Array([
|
|
78
|
-
0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 111, 0, 3, 2, 1, 0, 7, 5, 1,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const { instance } = await WebAssembly.instantiate(m);
|
|
82
|
+
0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 111, 0, 3, 2, 1, 0, 7, 5, 1, 1, 111, 0, 0, 10, 4, 1, 2, 0, 11,
|
|
83
|
+
])
|
|
84
|
+
const { instance } = await WebAssembly.instantiate(m)
|
|
82
85
|
// @ts-ignore
|
|
83
86
|
new WebAssembly.Function(
|
|
84
87
|
{
|
|
85
88
|
parameters: [],
|
|
86
|
-
results: [
|
|
89
|
+
results: ['externref'],
|
|
87
90
|
},
|
|
88
91
|
instance.exports.o,
|
|
89
|
-
{ promising:
|
|
90
|
-
)
|
|
91
|
-
return true
|
|
92
|
+
{ promising: 'first' },
|
|
93
|
+
)
|
|
94
|
+
return true
|
|
92
95
|
} catch (e) {
|
|
93
|
-
return false
|
|
96
|
+
return false
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
99
|
}
|