@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.
Files changed (62) hide show
  1. package/README.md +46 -36
  2. package/dist/README.md +13 -13
  3. package/dist/fts5/wa-sqlite.mjs +1 -1
  4. package/dist/fts5/wa-sqlite.node.mjs +1 -1
  5. package/dist/fts5/wa-sqlite.node.wasm +0 -0
  6. package/dist/fts5/wa-sqlite.wasm +0 -0
  7. package/dist/wa-sqlite-async.mjs +1 -1
  8. package/dist/wa-sqlite-async.wasm +0 -0
  9. package/dist/wa-sqlite-jspi.mjs +1 -1
  10. package/dist/wa-sqlite-jspi.wasm +0 -0
  11. package/dist/wa-sqlite.mjs +1 -1
  12. package/dist/wa-sqlite.node.mjs +1 -1
  13. package/dist/wa-sqlite.node.wasm +0 -0
  14. package/dist/wa-sqlite.wasm +0 -0
  15. package/package.json +40 -29
  16. package/src/FacadeVFS.js +252 -261
  17. package/src/VFS.js +84 -85
  18. package/src/WebLocksMixin.js +357 -351
  19. package/src/examples/AccessHandlePoolVFS.js +185 -194
  20. package/src/examples/IDBBatchAtomicVFS.js +429 -409
  21. package/src/examples/IDBMirrorVFS.js +402 -409
  22. package/src/examples/MemoryAsyncVFS.js +32 -37
  23. package/src/examples/MemoryVFS.js +71 -75
  24. package/src/examples/OPFSAdaptiveVFS.js +206 -206
  25. package/src/examples/OPFSAnyContextVFS.js +141 -140
  26. package/src/examples/OPFSCoopSyncVFS.js +297 -299
  27. package/src/examples/OPFSPermutedVFS.js +529 -540
  28. package/src/examples/README.md +27 -15
  29. package/src/examples/tag.js +27 -27
  30. package/src/sqlite-api.js +910 -941
  31. package/src/sqlite-constants.js +246 -232
  32. package/src/types/globals.d.ts +52 -52
  33. package/src/types/index.d.ts +586 -576
  34. package/test/AccessHandlePoolVFS.test.js +21 -21
  35. package/test/IDBBatchAtomicVFS.test.js +69 -69
  36. package/test/IDBMirrorVFS.test.js +21 -21
  37. package/test/MemoryAsyncVFS.test.js +21 -21
  38. package/test/MemoryVFS.test.js +21 -21
  39. package/test/OPFSAdaptiveVFS.test.js +21 -21
  40. package/test/OPFSAnyContextVFS.test.js +21 -21
  41. package/test/OPFSCoopSyncVFS.test.js +21 -21
  42. package/test/OPFSPermutedVFS.test.js +21 -21
  43. package/test/TestContext.js +44 -41
  44. package/test/WebLocksMixin.test.js +369 -360
  45. package/test/api.test.js +23 -23
  46. package/test/api_exec.js +72 -61
  47. package/test/api_misc.js +53 -54
  48. package/test/api_statements.js +271 -279
  49. package/test/callbacks.test.js +492 -478
  50. package/test/data/idbv5.json +1135 -1
  51. package/test/sql.test.js +30 -30
  52. package/test/sql_0001.js +49 -33
  53. package/test/sql_0002.js +55 -34
  54. package/test/sql_0003.js +85 -49
  55. package/test/sql_0004.js +76 -47
  56. package/test/sql_0005.js +60 -44
  57. package/test/test-worker.js +171 -163
  58. package/test/vfs_xAccess.js +1 -2
  59. package/test/vfs_xClose.js +50 -49
  60. package/test/vfs_xOpen.js +73 -72
  61. package/test/vfs_xRead.js +31 -31
  62. package/test/vfs_xWrite.js +30 -29
@@ -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('message', (event) => {
45
- if (event.ports[0]) {
46
- return resolve(event.ports[0]);
47
- }
48
- const e = new Error(event.data.message);
49
- throw Object.assign(e, event.data);
50
- }, { once: true });
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
- 1, 111, 0, 0, 10, 4, 1, 2, 0, 11,
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: ["externref"],
89
+ results: ['externref'],
87
90
  },
88
91
  instance.exports.o,
89
- { promising: "first" }
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
  }