@livestore/wa-sqlite 0.4.0-dev.22 → 0.4.0-dev.24
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/vfs_xOpen.js
CHANGED
|
@@ -1,91 +1,92 @@
|
|
|
1
|
-
import * as Comlink from 'comlink'
|
|
2
|
-
import * as VFS from '../src/VFS.js';
|
|
1
|
+
import * as Comlink from 'comlink'
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import * as VFS from '../src/VFS.js'
|
|
4
|
+
|
|
5
|
+
const FILEID = 1
|
|
5
6
|
|
|
6
7
|
export function vfs_xOpen(context) {
|
|
7
|
-
describe('vfs_xOpen', function() {
|
|
8
|
-
let proxy, vfs
|
|
9
|
-
beforeEach(async function() {
|
|
10
|
-
proxy = await context.create()
|
|
11
|
-
vfs = proxy.vfs
|
|
12
|
-
})
|
|
8
|
+
describe('vfs_xOpen', function () {
|
|
9
|
+
let proxy, vfs
|
|
10
|
+
beforeEach(async function () {
|
|
11
|
+
proxy = await context.create()
|
|
12
|
+
vfs = proxy.vfs
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
afterEach(async function () {
|
|
16
|
+
await context.destroy(proxy)
|
|
17
|
+
})
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
it('should create a file', async function () {
|
|
20
|
+
let rc
|
|
21
|
+
const pOpenOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
22
|
+
const openFlags = VFS.SQLITE_OPEN_CREATE | VFS.SQLITE_OPEN_READWRITE
|
|
23
|
+
rc = await vfs.jOpen('test', FILEID, openFlags, pOpenOutput)
|
|
24
|
+
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
25
|
+
expect(pOpenOutput.getInt32(0, true)).toEqual(openFlags)
|
|
17
26
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
expect(rc).toEqual(VFS.SQLITE_OK);
|
|
24
|
-
expect(pOpenOutput.getInt32(0, true)).toEqual(openFlags);
|
|
27
|
+
const pAccessOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
28
|
+
rc = await vfs.jAccess('test', VFS.SQLITE_ACCESS_READWRITE, pAccessOutput)
|
|
29
|
+
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
30
|
+
expect(pAccessOutput.getInt32(0, true)).not.toEqual(0)
|
|
31
|
+
})
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
rc
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
33
|
+
it('should create a database file', async function () {
|
|
34
|
+
let rc
|
|
35
|
+
const pOpenOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
36
|
+
const openFlags = VFS.SQLITE_OPEN_CREATE | VFS.SQLITE_OPEN_READWRITE | VFS.SQLITE_OPEN_MAIN_DB
|
|
31
37
|
|
|
32
|
-
it('should create a database file', async function() {
|
|
33
|
-
let rc;
|
|
34
|
-
const pOpenOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)));
|
|
35
|
-
const openFlags = VFS.SQLITE_OPEN_CREATE | VFS.SQLITE_OPEN_READWRITE | VFS.SQLITE_OPEN_MAIN_DB;
|
|
36
|
-
|
|
37
38
|
do {
|
|
38
|
-
const nRetryOps = await proxy.module.retryOps.length
|
|
39
|
+
const nRetryOps = await proxy.module.retryOps.length
|
|
39
40
|
for (let i = 0; i < nRetryOps; i++) {
|
|
40
|
-
await proxy.module.retryOps[i]
|
|
41
|
+
await proxy.module.retryOps[i]
|
|
41
42
|
}
|
|
42
|
-
rc = await vfs.jOpen('test',
|
|
43
|
-
} while (rc === VFS.SQLITE_BUSY)
|
|
44
|
-
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
45
|
-
expect(pOpenOutput.getInt32(0, true)).toEqual(openFlags)
|
|
43
|
+
rc = await vfs.jOpen('test', 1, openFlags, pOpenOutput)
|
|
44
|
+
} while (rc === VFS.SQLITE_BUSY)
|
|
45
|
+
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
46
|
+
expect(pOpenOutput.getInt32(0, true)).toEqual(openFlags)
|
|
46
47
|
|
|
47
|
-
const pAccessOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
48
|
-
rc = await vfs.jAccess('test', VFS.SQLITE_ACCESS_READWRITE, pAccessOutput)
|
|
49
|
-
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
50
|
-
expect(pAccessOutput.getInt32(0, true)).not.toEqual(0)
|
|
51
|
-
})
|
|
48
|
+
const pAccessOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
49
|
+
rc = await vfs.jAccess('test', VFS.SQLITE_ACCESS_READWRITE, pAccessOutput)
|
|
50
|
+
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
51
|
+
expect(pAccessOutput.getInt32(0, true)).not.toEqual(0)
|
|
52
|
+
})
|
|
52
53
|
|
|
53
|
-
it('should not create a file', async function() {
|
|
54
|
-
let rc
|
|
55
|
-
const pOpenOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
56
|
-
const openFlags = VFS.SQLITE_OPEN_READWRITE
|
|
57
|
-
rc = await vfs.jOpen('test',
|
|
58
|
-
expect(rc).toEqual(VFS.SQLITE_CANTOPEN)
|
|
54
|
+
it('should not create a file', async function () {
|
|
55
|
+
let rc
|
|
56
|
+
const pOpenOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
57
|
+
const openFlags = VFS.SQLITE_OPEN_READWRITE
|
|
58
|
+
rc = await vfs.jOpen('test', 1, openFlags, pOpenOutput)
|
|
59
|
+
expect(rc).toEqual(VFS.SQLITE_CANTOPEN)
|
|
59
60
|
|
|
60
|
-
const pAccessOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
61
|
-
rc = await vfs.jAccess('test', VFS.SQLITE_ACCESS_READWRITE, pAccessOutput)
|
|
62
|
-
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
63
|
-
expect(pAccessOutput.getInt32(0, true)).toEqual(0)
|
|
64
|
-
})
|
|
61
|
+
const pAccessOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
62
|
+
rc = await vfs.jAccess('test', VFS.SQLITE_ACCESS_READWRITE, pAccessOutput)
|
|
63
|
+
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
64
|
+
expect(pAccessOutput.getInt32(0, true)).toEqual(0)
|
|
65
|
+
})
|
|
65
66
|
|
|
66
|
-
it('should open an existing file', async function() {
|
|
67
|
-
let rc
|
|
68
|
-
const pOpenOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
69
|
-
const openFlags = VFS.SQLITE_OPEN_CREATE | VFS.SQLITE_OPEN_READWRITE
|
|
70
|
-
rc = await vfs.jOpen('test', FILEID, openFlags, pOpenOutput)
|
|
71
|
-
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
67
|
+
it('should open an existing file', async function () {
|
|
68
|
+
let rc
|
|
69
|
+
const pOpenOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
70
|
+
const openFlags = VFS.SQLITE_OPEN_CREATE | VFS.SQLITE_OPEN_READWRITE
|
|
71
|
+
rc = await vfs.jOpen('test', FILEID, openFlags, pOpenOutput)
|
|
72
|
+
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
72
73
|
|
|
73
74
|
// Close the file because some VFS implementations don't allow
|
|
74
75
|
// multiple open handles.
|
|
75
|
-
await vfs.jClose(FILEID)
|
|
76
|
+
await vfs.jClose(FILEID)
|
|
76
77
|
|
|
77
|
-
rc = await vfs.jOpen('test', FILEID, VFS.SQLITE_OPEN_READWRITE, pOpenOutput)
|
|
78
|
-
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
79
|
-
expect(pOpenOutput.getInt32(0, true)).toEqual(VFS.SQLITE_OPEN_READWRITE)
|
|
80
|
-
})
|
|
78
|
+
rc = await vfs.jOpen('test', FILEID, VFS.SQLITE_OPEN_READWRITE, pOpenOutput)
|
|
79
|
+
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
80
|
+
expect(pOpenOutput.getInt32(0, true)).toEqual(VFS.SQLITE_OPEN_READWRITE)
|
|
81
|
+
})
|
|
81
82
|
|
|
82
|
-
it('should create an anonymous file', async function() {
|
|
83
|
-
let rc
|
|
84
|
-
const pOpenOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
85
|
-
const openFlags = VFS.SQLITE_OPEN_CREATE | VFS.SQLITE_OPEN_READWRITE
|
|
86
|
-
rc = await vfs.jOpen(null, FILEID, openFlags, pOpenOutput)
|
|
87
|
-
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
88
|
-
expect(pOpenOutput.getInt32(0, true)).toEqual(openFlags)
|
|
89
|
-
})
|
|
90
|
-
})
|
|
91
|
-
}
|
|
83
|
+
it('should create an anonymous file', async function () {
|
|
84
|
+
let rc
|
|
85
|
+
const pOpenOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
86
|
+
const openFlags = VFS.SQLITE_OPEN_CREATE | VFS.SQLITE_OPEN_READWRITE
|
|
87
|
+
rc = await vfs.jOpen(null, FILEID, openFlags, pOpenOutput)
|
|
88
|
+
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
89
|
+
expect(pOpenOutput.getInt32(0, true)).toEqual(openFlags)
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
}
|
package/test/vfs_xRead.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import * as Comlink from 'comlink'
|
|
2
|
-
import * as VFS from '../src/VFS.js';
|
|
1
|
+
import * as Comlink from 'comlink'
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import * as VFS from '../src/VFS.js'
|
|
4
|
+
|
|
5
|
+
const FILEID = 1
|
|
5
6
|
|
|
6
7
|
export function vfs_xRead(context) {
|
|
7
|
-
describe('vfs_xRead', function() {
|
|
8
|
-
let proxy, vfs
|
|
9
|
-
beforeEach(async function() {
|
|
10
|
-
proxy = await context.create()
|
|
11
|
-
vfs = proxy.vfs
|
|
12
|
-
})
|
|
8
|
+
describe('vfs_xRead', function () {
|
|
9
|
+
let proxy, vfs
|
|
10
|
+
beforeEach(async function () {
|
|
11
|
+
proxy = await context.create()
|
|
12
|
+
vfs = proxy.vfs
|
|
13
|
+
})
|
|
13
14
|
|
|
14
|
-
afterEach(async function() {
|
|
15
|
-
await context.destroy(proxy)
|
|
16
|
-
})
|
|
15
|
+
afterEach(async function () {
|
|
16
|
+
await context.destroy(proxy)
|
|
17
|
+
})
|
|
17
18
|
|
|
18
|
-
it('should signal short read', async function() {
|
|
19
|
-
let rc
|
|
20
|
-
const pOpenOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
21
|
-
const openFlags = VFS.SQLITE_OPEN_CREATE | VFS.SQLITE_OPEN_READWRITE
|
|
22
|
-
rc = await vfs.jOpen('test', FILEID, openFlags, pOpenOutput)
|
|
23
|
-
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
19
|
+
it('should signal short read', async function () {
|
|
20
|
+
let rc
|
|
21
|
+
const pOpenOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
22
|
+
const openFlags = VFS.SQLITE_OPEN_CREATE | VFS.SQLITE_OPEN_READWRITE
|
|
23
|
+
rc = await vfs.jOpen('test', FILEID, openFlags, pOpenOutput)
|
|
24
|
+
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
24
25
|
|
|
25
|
-
const pData = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])
|
|
26
|
-
const iOffset = 0
|
|
27
|
-
rc = await vfs.jWrite(FILEID, pData, iOffset)
|
|
28
|
-
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
26
|
+
const pData = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])
|
|
27
|
+
const iOffset = 0
|
|
28
|
+
rc = await vfs.jWrite(FILEID, pData, iOffset)
|
|
29
|
+
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
29
30
|
|
|
30
|
-
const pReadData = Comlink.proxy(new Uint8Array(pData.length * 2).fill(0xfb))
|
|
31
|
-
rc = await vfs.jRead(FILEID, pReadData, iOffset)
|
|
32
|
-
expect(rc).toEqual(VFS.SQLITE_IOERR_SHORT_READ)
|
|
33
|
-
expect(pReadData.subarray(0, pData.length)).toEqual(pData)
|
|
34
|
-
expect(pReadData.subarray(pData.length))
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
31
|
+
const pReadData = Comlink.proxy(new Uint8Array(pData.length * 2).fill(0xfb))
|
|
32
|
+
rc = await vfs.jRead(FILEID, pReadData, iOffset)
|
|
33
|
+
expect(rc).toEqual(VFS.SQLITE_IOERR_SHORT_READ)
|
|
34
|
+
expect(pReadData.subarray(0, pData.length)).toEqual(pData)
|
|
35
|
+
expect(pReadData.subarray(pData.length)).toEqual(new Uint8Array(pReadData.length - pData.length))
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
}
|
package/test/vfs_xWrite.js
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
import * as Comlink from 'comlink'
|
|
2
|
-
import * as VFS from '../src/VFS.js';
|
|
1
|
+
import * as Comlink from 'comlink'
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import * as VFS from '../src/VFS.js'
|
|
4
|
+
|
|
5
|
+
const FILEID = 1
|
|
5
6
|
|
|
6
7
|
export function vfs_xWrite(context) {
|
|
7
|
-
describe('vfs_xWrite', function() {
|
|
8
|
-
let proxy, vfs
|
|
9
|
-
beforeEach(async function() {
|
|
10
|
-
proxy = await context.create()
|
|
11
|
-
vfs = proxy.vfs
|
|
12
|
-
})
|
|
8
|
+
describe('vfs_xWrite', function () {
|
|
9
|
+
let proxy, vfs
|
|
10
|
+
beforeEach(async function () {
|
|
11
|
+
proxy = await context.create()
|
|
12
|
+
vfs = proxy.vfs
|
|
13
|
+
})
|
|
13
14
|
|
|
14
|
-
afterEach(async function() {
|
|
15
|
-
await context.destroy(proxy)
|
|
16
|
-
})
|
|
15
|
+
afterEach(async function () {
|
|
16
|
+
await context.destroy(proxy)
|
|
17
|
+
})
|
|
17
18
|
|
|
18
|
-
it('should round-trip data', async function() {
|
|
19
|
-
let rc
|
|
20
|
-
const pOpenOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
21
|
-
const openFlags = VFS.SQLITE_OPEN_CREATE | VFS.SQLITE_OPEN_READWRITE
|
|
22
|
-
rc = await vfs.jOpen('test', FILEID, openFlags, pOpenOutput)
|
|
23
|
-
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
19
|
+
it('should round-trip data', async function () {
|
|
20
|
+
let rc
|
|
21
|
+
const pOpenOutput = Comlink.proxy(new DataView(new ArrayBuffer(4)))
|
|
22
|
+
const openFlags = VFS.SQLITE_OPEN_CREATE | VFS.SQLITE_OPEN_READWRITE
|
|
23
|
+
rc = await vfs.jOpen('test', FILEID, openFlags, pOpenOutput)
|
|
24
|
+
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
24
25
|
|
|
25
|
-
const pData = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])
|
|
26
|
-
const iOffset = 0
|
|
27
|
-
rc = await vfs.jWrite(FILEID, pData, iOffset)
|
|
28
|
-
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
26
|
+
const pData = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])
|
|
27
|
+
const iOffset = 0
|
|
28
|
+
rc = await vfs.jWrite(FILEID, pData, iOffset)
|
|
29
|
+
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
29
30
|
|
|
30
|
-
const pReadData = Comlink.proxy(new Uint8Array(pData.length))
|
|
31
|
-
rc = await vfs.jRead(FILEID, pReadData, iOffset)
|
|
32
|
-
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
33
|
-
expect([...pReadData]).toEqual([...pData])
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
}
|
|
31
|
+
const pReadData = Comlink.proxy(new Uint8Array(pData.length))
|
|
32
|
+
rc = await vfs.jRead(FILEID, pReadData, iOffset)
|
|
33
|
+
expect(rc).toEqual(VFS.SQLITE_OK)
|
|
34
|
+
expect([...pReadData]).toEqual([...pData])
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
}
|