@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
package/src/FacadeVFS.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Copyright 2024 Roy T. Hashimoto. All Rights Reserved.
2
- import * as VFS from './VFS.js';
2
+ import * as VFS from './VFS.js'
3
3
 
4
- const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;
4
+ const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor
5
5
 
6
6
  // Convenience base class for a JavaScript VFS.
7
7
  // The raw xOpen, xRead, etc. function signatures receive only C primitives
@@ -10,168 +10,165 @@ const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;
10
10
  // such as string, Uint8Array, and DataView.
11
11
  export class FacadeVFS extends VFS.Base {
12
12
  /**
13
- * @param {string} name
14
- * @param {object} module
13
+ * @param {string} name
14
+ * @param {object} module
15
15
  */
16
- constructor(name, module) {
17
- super(name, module);
18
- }
19
16
 
20
17
  /**
21
18
  * Override to indicate which methods are asynchronous.
22
- * @param {string} methodName
19
+ * @param {string} methodName
23
20
  * @returns {boolean}
24
21
  */
25
22
  hasAsyncMethod(methodName) {
26
23
  // The input argument is a string like "xOpen", so convert to "jOpen".
27
24
  // Then check if the method exists and is async.
28
- const jMethodName = `j${methodName.slice(1)}`;
29
- return this[jMethodName] instanceof AsyncFunction;
25
+ const jMethodName = `j${methodName.slice(1)}`
26
+ return this[jMethodName] instanceof AsyncFunction
30
27
  }
31
-
28
+
32
29
  /**
33
30
  * Return the filename for a file id for use by mixins.
34
- * @param {number} pFile
31
+ * @param {number} pFile
35
32
  * @returns {string}
36
33
  */
37
34
  getFilename(pFile) {
38
- throw new Error('unimplemented');
35
+ throw new Error('unimplemented')
39
36
  }
40
37
 
41
38
  /**
42
- * @param {string?} filename
43
- * @param {number} pFile
44
- * @param {number} flags
45
- * @param {DataView} pOutFlags
39
+ * @param {string?} filename
40
+ * @param {number} pFile
41
+ * @param {number} flags
42
+ * @param {DataView} pOutFlags
46
43
  * @returns {number|Promise<number>}
47
44
  */
48
45
  jOpen(filename, pFile, flags, pOutFlags) {
49
- return VFS.SQLITE_CANTOPEN;
46
+ return VFS.SQLITE_CANTOPEN
50
47
  }
51
48
 
52
49
  /**
53
- * @param {string} filename
54
- * @param {number} syncDir
50
+ * @param {string} filename
51
+ * @param {number} syncDir
55
52
  * @returns {number|Promise<number>}
56
53
  */
57
54
  jDelete(filename, syncDir) {
58
- return VFS.SQLITE_OK;
55
+ return VFS.SQLITE_OK
59
56
  }
60
57
 
61
58
  /**
62
- * @param {string} filename
63
- * @param {number} flags
64
- * @param {DataView} pResOut
59
+ * @param {string} filename
60
+ * @param {number} flags
61
+ * @param {DataView} pResOut
65
62
  * @returns {number|Promise<number>}
66
63
  */
67
64
  jAccess(filename, flags, pResOut) {
68
- return VFS.SQLITE_OK;
65
+ return VFS.SQLITE_OK
69
66
  }
70
67
 
71
68
  /**
72
- * @param {string} filename
73
- * @param {Uint8Array} zOut
69
+ * @param {string} filename
70
+ * @param {Uint8Array} zOut
74
71
  * @returns {number|Promise<number>}
75
72
  */
76
73
  jFullPathname(filename, zOut) {
77
74
  // Copy the filename to the output buffer.
78
- const { read, written } = new TextEncoder().encodeInto(filename, zOut);
79
- if (read < filename.length) return VFS.SQLITE_IOERR;
80
- if (written >= zOut.length) return VFS.SQLITE_IOERR;
81
- zOut[written] = 0;
82
- return VFS.SQLITE_OK;
75
+ const { read, written } = new TextEncoder().encodeInto(filename, zOut)
76
+ if (read < filename.length) return VFS.SQLITE_IOERR
77
+ if (written >= zOut.length) return VFS.SQLITE_IOERR
78
+ zOut[written] = 0
79
+ return VFS.SQLITE_OK
83
80
  }
84
81
 
85
82
  /**
86
- * @param {Uint8Array} zBuf
83
+ * @param {Uint8Array} zBuf
87
84
  * @returns {number|Promise<number>}
88
85
  */
89
86
  jGetLastError(zBuf) {
90
- return VFS.SQLITE_OK;
87
+ return VFS.SQLITE_OK
91
88
  }
92
89
 
93
90
  /**
94
- * @param {number} pFile
91
+ * @param {number} pFile
95
92
  * @returns {number|Promise<number>}
96
93
  */
97
94
  jClose(pFile) {
98
- return VFS.SQLITE_OK;
95
+ return VFS.SQLITE_OK
99
96
  }
100
97
 
101
98
  /**
102
- * @param {number} pFile
103
- * @param {Uint8Array} pData
104
- * @param {number} iOffset
99
+ * @param {number} pFile
100
+ * @param {Uint8Array} pData
101
+ * @param {number} iOffset
105
102
  * @returns {number|Promise<number>}
106
103
  */
107
104
  jRead(pFile, pData, iOffset) {
108
- pData.fill(0);
109
- return VFS.SQLITE_IOERR_SHORT_READ;
105
+ pData.fill(0)
106
+ return VFS.SQLITE_IOERR_SHORT_READ
110
107
  }
111
108
 
112
109
  /**
113
- * @param {number} pFile
114
- * @param {Uint8Array} pData
115
- * @param {number} iOffset
110
+ * @param {number} pFile
111
+ * @param {Uint8Array} pData
112
+ * @param {number} iOffset
116
113
  * @returns {number|Promise<number>}
117
114
  */
118
115
  jWrite(pFile, pData, iOffset) {
119
- return VFS.SQLITE_IOERR_WRITE;
116
+ return VFS.SQLITE_IOERR_WRITE
120
117
  }
121
118
 
122
119
  /**
123
- * @param {number} pFile
124
- * @param {number} size
120
+ * @param {number} pFile
121
+ * @param {number} size
125
122
  * @returns {number|Promise<number>}
126
123
  */
127
124
  jTruncate(pFile, size) {
128
- return VFS.SQLITE_OK;
125
+ return VFS.SQLITE_OK
129
126
  }
130
127
 
131
128
  /**
132
- * @param {number} pFile
133
- * @param {number} flags
129
+ * @param {number} pFile
130
+ * @param {number} flags
134
131
  * @returns {number|Promise<number>}
135
132
  */
136
133
  jSync(pFile, flags) {
137
- return VFS.SQLITE_OK;
134
+ return VFS.SQLITE_OK
138
135
  }
139
136
 
140
137
  /**
141
- * @param {number} pFile
138
+ * @param {number} pFile
142
139
  * @param {DataView} pSize
143
140
  * @returns {number|Promise<number>}
144
141
  */
145
142
  jFileSize(pFile, pSize) {
146
- return VFS.SQLITE_OK;
143
+ return VFS.SQLITE_OK
147
144
  }
148
145
 
149
146
  /**
150
- * @param {number} pFile
151
- * @param {number} lockType
147
+ * @param {number} pFile
148
+ * @param {number} lockType
152
149
  * @returns {number|Promise<number>}
153
150
  */
154
151
  jLock(pFile, lockType) {
155
- return VFS.SQLITE_OK;
152
+ return VFS.SQLITE_OK
156
153
  }
157
154
 
158
155
  /**
159
- * @param {number} pFile
160
- * @param {number} lockType
156
+ * @param {number} pFile
157
+ * @param {number} lockType
161
158
  * @returns {number|Promise<number>}
162
159
  */
163
160
  jUnlock(pFile, lockType) {
164
- return VFS.SQLITE_OK;
161
+ return VFS.SQLITE_OK
165
162
  }
166
163
 
167
164
  /**
168
- * @param {number} pFile
169
- * @param {DataView} pResOut
165
+ * @param {number} pFile
166
+ * @param {DataView} pResOut
170
167
  * @returns {number|Promise<number>}
171
168
  */
172
169
  jCheckReservedLock(pFile, pResOut) {
173
- pResOut.setInt32(0, 0, true);
174
- return VFS.SQLITE_OK;
170
+ pResOut.setInt32(0, 0, true)
171
+ return VFS.SQLITE_OK
175
172
  }
176
173
 
177
174
  /**
@@ -181,7 +178,7 @@ export class FacadeVFS extends VFS.Base {
181
178
  * @returns {number|Promise<number>}
182
179
  */
183
180
  jFileControl(pFile, op, pArg) {
184
- return VFS.SQLITE_NOTFOUND;
181
+ return VFS.SQLITE_NOTFOUND
185
182
  }
186
183
 
187
184
  /**
@@ -189,7 +186,7 @@ export class FacadeVFS extends VFS.Base {
189
186
  * @returns {number|Promise<number>}
190
187
  */
191
188
  jSectorSize(pFile) {
192
- return super.xSectorSize(pFile);
189
+ return super.xSectorSize(pFile)
193
190
  }
194
191
 
195
192
  /**
@@ -197,210 +194,208 @@ export class FacadeVFS extends VFS.Base {
197
194
  * @returns {number|Promise<number>}
198
195
  */
199
196
  jDeviceCharacteristics(pFile) {
200
- return 0;
197
+ return 0
201
198
  }
202
199
 
203
200
  /**
204
- * @param {number} pVfs
205
- * @param {number} zName
206
- * @param {number} pFile
207
- * @param {number} flags
208
- * @param {number} pOutFlags
201
+ * @param {number} pVfs
202
+ * @param {number} zName
203
+ * @param {number} pFile
204
+ * @param {number} flags
205
+ * @param {number} pOutFlags
209
206
  * @returns {number|Promise<number>}
210
207
  */
211
208
  xOpen(pVfs, zName, pFile, flags, pOutFlags) {
212
- const filename = this.#decodeFilename(zName, flags);
213
- const pOutFlagsView = this.#makeTypedDataView('Int32', pOutFlags);
214
- this['log']?.('jOpen', filename, pFile, '0x' + flags.toString(16));
215
- return this.jOpen(filename, pFile, flags, pOutFlagsView);
209
+ const filename = this.#decodeFilename(zName, flags)
210
+ const pOutFlagsView = this.#makeTypedDataView('Int32', pOutFlags)
211
+ this['log']?.('jOpen', filename, pFile, '0x' + flags.toString(16))
212
+ return this.jOpen(filename, pFile, flags, pOutFlagsView)
216
213
  }
217
214
 
218
215
  /**
219
- * @param {number} pVfs
220
- * @param {number} zName
221
- * @param {number} syncDir
216
+ * @param {number} pVfs
217
+ * @param {number} zName
218
+ * @param {number} syncDir
222
219
  * @returns {number|Promise<number>}
223
220
  */
224
221
  xDelete(pVfs, zName, syncDir) {
225
- const filename = this._module.UTF8ToString(zName);
226
- this['log']?.('jDelete', filename, syncDir);
227
- return this.jDelete(filename, syncDir);
222
+ const filename = this._module.UTF8ToString(zName)
223
+ this['log']?.('jDelete', filename, syncDir)
224
+ return this.jDelete(filename, syncDir)
228
225
  }
229
226
 
230
227
  /**
231
- * @param {number} pVfs
232
- * @param {number} zName
233
- * @param {number} flags
234
- * @param {number} pResOut
228
+ * @param {number} pVfs
229
+ * @param {number} zName
230
+ * @param {number} flags
231
+ * @param {number} pResOut
235
232
  * @returns {number|Promise<number>}
236
233
  */
237
234
  xAccess(pVfs, zName, flags, pResOut) {
238
- const filename = this._module.UTF8ToString(zName);
239
- const pResOutView = this.#makeTypedDataView('Int32', pResOut);
240
- this['log']?.('jAccess', filename, flags);
241
- return this.jAccess(filename, flags, pResOutView);
235
+ const filename = this._module.UTF8ToString(zName)
236
+ const pResOutView = this.#makeTypedDataView('Int32', pResOut)
237
+ this['log']?.('jAccess', filename, flags)
238
+ return this.jAccess(filename, flags, pResOutView)
242
239
  }
243
240
 
244
241
  /**
245
- * @param {number} pVfs
246
- * @param {number} zName
247
- * @param {number} nOut
248
- * @param {number} zOut
242
+ * @param {number} pVfs
243
+ * @param {number} zName
244
+ * @param {number} nOut
245
+ * @param {number} zOut
249
246
  * @returns {number|Promise<number>}
250
247
  */
251
248
  xFullPathname(pVfs, zName, nOut, zOut) {
252
- const filename = this._module.UTF8ToString(zName);
253
- const zOutArray = this._module.HEAPU8.subarray(zOut, zOut + nOut);
254
- this['log']?.('jFullPathname', filename, nOut);
255
- return this.jFullPathname(filename, zOutArray);
249
+ const filename = this._module.UTF8ToString(zName)
250
+ const zOutArray = this._module.HEAPU8.subarray(zOut, zOut + nOut)
251
+ this['log']?.('jFullPathname', filename, nOut)
252
+ return this.jFullPathname(filename, zOutArray)
256
253
  }
257
254
 
258
255
  /**
259
- * @param {number} pVfs
260
- * @param {number} nBuf
261
- * @param {number} zBuf
256
+ * @param {number} pVfs
257
+ * @param {number} nBuf
258
+ * @param {number} zBuf
262
259
  * @returns {number|Promise<number>}
263
260
  */
264
261
  xGetLastError(pVfs, nBuf, zBuf) {
265
- const zBufArray = this._module.HEAPU8.subarray(zBuf, zBuf + nBuf);
266
- this['log']?.('jGetLastError', nBuf);
267
- return this.jGetLastError(zBufArray);
262
+ const zBufArray = this._module.HEAPU8.subarray(zBuf, zBuf + nBuf)
263
+ this['log']?.('jGetLastError', nBuf)
264
+ return this.jGetLastError(zBufArray)
268
265
  }
269
266
 
270
267
  /**
271
- * @param {number} pFile
268
+ * @param {number} pFile
272
269
  * @returns {number|Promise<number>}
273
270
  */
274
271
  xClose(pFile) {
275
- this['log']?.('jClose', pFile);
276
- return this.jClose(pFile);
272
+ this['log']?.('jClose', pFile)
273
+ return this.jClose(pFile)
277
274
  }
278
275
 
279
276
  /**
280
- * @param {number} pFile
281
- * @param {number} pData
282
- * @param {number} iAmt
283
- * @param {number} iOffsetLo
284
- * @param {number} iOffsetHi
277
+ * @param {number} pFile
278
+ * @param {number} pData
279
+ * @param {number} iAmt
280
+ * @param {number} iOffsetLo
281
+ * @param {number} iOffsetHi
285
282
  * @returns {number|Promise<number>}
286
283
  */
287
284
  xRead(pFile, pData, iAmt, iOffsetLo, iOffsetHi) {
288
- const pDataArray = this.#makeDataArray(pData, iAmt);
289
- const iOffset = delegalize(iOffsetLo, iOffsetHi);
290
- this['log']?.('jRead', pFile, iAmt, iOffset);
291
- return this.jRead(pFile, pDataArray, iOffset);
285
+ const pDataArray = this.#makeDataArray(pData, iAmt)
286
+ const iOffset = delegalize(iOffsetLo, iOffsetHi)
287
+ this['log']?.('jRead', pFile, iAmt, iOffset)
288
+ return this.jRead(pFile, pDataArray, iOffset)
292
289
  }
293
290
 
294
291
  /**
295
- * @param {number} pFile
296
- * @param {number} pData
297
- * @param {number} iAmt
298
- * @param {number} iOffsetLo
299
- * @param {number} iOffsetHi
292
+ * @param {number} pFile
293
+ * @param {number} pData
294
+ * @param {number} iAmt
295
+ * @param {number} iOffsetLo
296
+ * @param {number} iOffsetHi
300
297
  * @returns {number|Promise<number>}
301
298
  */
302
299
  xWrite(pFile, pData, iAmt, iOffsetLo, iOffsetHi) {
303
- const pDataArray = this.#makeDataArray(pData, iAmt);
304
- const iOffset = delegalize(iOffsetLo, iOffsetHi);
305
- this['log']?.('jWrite', pFile, pDataArray, iOffset);
306
- return this.jWrite(pFile, pDataArray, iOffset);
300
+ const pDataArray = this.#makeDataArray(pData, iAmt)
301
+ const iOffset = delegalize(iOffsetLo, iOffsetHi)
302
+ this['log']?.('jWrite', pFile, pDataArray, iOffset)
303
+ return this.jWrite(pFile, pDataArray, iOffset)
307
304
  }
308
305
 
309
306
  /**
310
- * @param {number} pFile
311
- * @param {number} sizeLo
312
- * @param {number} sizeHi
307
+ * @param {number} pFile
308
+ * @param {number} sizeLo
309
+ * @param {number} sizeHi
313
310
  * @returns {number|Promise<number>}
314
311
  */
315
312
  xTruncate(pFile, sizeLo, sizeHi) {
316
- const size = delegalize(sizeLo, sizeHi);
317
- this['log']?.('jTruncate', pFile, size);
318
- return this.jTruncate(pFile, size);
313
+ const size = delegalize(sizeLo, sizeHi)
314
+ this['log']?.('jTruncate', pFile, size)
315
+ return this.jTruncate(pFile, size)
319
316
  }
320
317
 
321
318
  /**
322
- * @param {number} pFile
323
- * @param {number} flags
319
+ * @param {number} pFile
320
+ * @param {number} flags
324
321
  * @returns {number|Promise<number>}
325
322
  */
326
323
  xSync(pFile, flags) {
327
- this['log']?.('jSync', pFile, flags);
328
- return this.jSync(pFile, flags);
324
+ this['log']?.('jSync', pFile, flags)
325
+ return this.jSync(pFile, flags)
329
326
  }
330
327
 
331
328
  /**
332
- *
333
- * @param {number} pFile
334
- * @param {number} pSize
329
+ *
330
+ * @param {number} pFile
331
+ * @param {number} pSize
335
332
  * @returns {number|Promise<number>}
336
333
  */
337
334
  xFileSize(pFile, pSize) {
338
- const pSizeView = this.#makeTypedDataView('BigInt64', pSize);
339
- this['log']?.('jFileSize', pFile);
340
- return this.jFileSize(pFile, pSizeView);
335
+ const pSizeView = this.#makeTypedDataView('BigInt64', pSize)
336
+ this['log']?.('jFileSize', pFile)
337
+ return this.jFileSize(pFile, pSizeView)
341
338
  }
342
339
 
343
340
  /**
344
- * @param {number} pFile
345
- * @param {number} lockType
341
+ * @param {number} pFile
342
+ * @param {number} lockType
346
343
  * @returns {number|Promise<number>}
347
344
  */
348
345
  xLock(pFile, lockType) {
349
- this['log']?.('jLock', pFile, lockType);
350
- return this.jLock(pFile, lockType);
346
+ this['log']?.('jLock', pFile, lockType)
347
+ return this.jLock(pFile, lockType)
351
348
  }
352
349
 
353
350
  /**
354
- * @param {number} pFile
355
- * @param {number} lockType
351
+ * @param {number} pFile
352
+ * @param {number} lockType
356
353
  * @returns {number|Promise<number>}
357
354
  */
358
355
  xUnlock(pFile, lockType) {
359
- this['log']?.('jUnlock', pFile, lockType);
360
- return this.jUnlock(pFile, lockType);
361
- }
356
+ this['log']?.('jUnlock', pFile, lockType)
357
+ return this.jUnlock(pFile, lockType)
358
+ }
362
359
 
363
360
  /**
364
- * @param {number} pFile
365
- * @param {number} pResOut
361
+ * @param {number} pFile
362
+ * @param {number} pResOut
366
363
  * @returns {number|Promise<number>}
367
364
  */
368
365
  xCheckReservedLock(pFile, pResOut) {
369
- const pResOutView = this.#makeTypedDataView('Int32', pResOut);
370
- this['log']?.('jCheckReservedLock', pFile);
371
- return this.jCheckReservedLock(pFile, pResOutView);
366
+ const pResOutView = this.#makeTypedDataView('Int32', pResOut)
367
+ this['log']?.('jCheckReservedLock', pFile)
368
+ return this.jCheckReservedLock(pFile, pResOutView)
372
369
  }
373
370
 
374
371
  /**
375
- * @param {number} pFile
376
- * @param {number} op
377
- * @param {number} pArg
372
+ * @param {number} pFile
373
+ * @param {number} op
374
+ * @param {number} pArg
378
375
  * @returns {number|Promise<number>}
379
376
  */
380
377
  xFileControl(pFile, op, pArg) {
381
- const pArgView = new DataView(
382
- this._module.HEAPU8.buffer,
383
- this._module.HEAPU8.byteOffset + pArg);
384
- this['log']?.('jFileControl', pFile, op, pArgView);
385
- return this.jFileControl(pFile, op, pArgView);
378
+ const pArgView = new DataView(this._module.HEAPU8.buffer, this._module.HEAPU8.byteOffset + pArg)
379
+ this['log']?.('jFileControl', pFile, op, pArgView)
380
+ return this.jFileControl(pFile, op, pArgView)
386
381
  }
387
382
 
388
383
  /**
389
- * @param {number} pFile
384
+ * @param {number} pFile
390
385
  * @returns {number|Promise<number>}
391
386
  */
392
387
  xSectorSize(pFile) {
393
- this['log']?.('jSectorSize', pFile);
394
- return this.jSectorSize(pFile);
388
+ this['log']?.('jSectorSize', pFile)
389
+ return this.jSectorSize(pFile)
395
390
  }
396
391
 
397
392
  /**
398
- * @param {number} pFile
393
+ * @param {number} pFile
399
394
  * @returns {number|Promise<number>}
400
395
  */
401
396
  xDeviceCharacteristics(pFile) {
402
- this['log']?.('jDeviceCharacteristics', pFile);
403
- return this.jDeviceCharacteristics(pFile);
397
+ this['log']?.('jDeviceCharacteristics', pFile)
398
+ return this.jDeviceCharacteristics(pFile)
404
399
  }
405
400
 
406
401
  /**
@@ -408,13 +403,13 @@ export class FacadeVFS extends VFS.Base {
408
403
  * Pointers to a single value are passed using a DataView-like class.
409
404
  * This wrapper class prevents use of incorrect type or endianness, and
410
405
  * reacquires the underlying buffer when the WebAssembly memory is resized.
411
- * @param {'Int32'|'BigInt64'} type
412
- * @param {number} byteOffset
406
+ * @param {'Int32'|'BigInt64'} type
407
+ * @param {number} byteOffset
413
408
  * @returns {DataView}
414
409
  */
415
410
  #makeTypedDataView(type, byteOffset) {
416
411
  // @ts-ignore
417
- return new DataViewProxy(this._module, byteOffset, type);
412
+ return new DataViewProxy(this._module, byteOffset, type)
418
413
  }
419
414
 
420
415
  /**
@@ -422,13 +417,13 @@ export class FacadeVFS extends VFS.Base {
422
417
  * Memory blocks are passed as a Uint8Array-like class. This wrapper
423
418
  * class reacquires the underlying buffer when the WebAssembly memory
424
419
  * is resized.
425
- * @param {number} byteOffset
426
- * @param {number} byteLength
420
+ * @param {number} byteOffset
421
+ * @param {number} byteLength
427
422
  * @returns {Uint8Array}
428
423
  */
429
424
  #makeDataArray(byteOffset, byteLength) {
430
425
  // @ts-ignore
431
- return new Uint8ArrayProxy(this._module, byteOffset, byteLength);
426
+ return new Uint8ArrayProxy(this._module, byteOffset, byteLength)
432
427
  }
433
428
 
434
429
  #decodeFilename(zName, flags) {
@@ -436,41 +431,41 @@ export class FacadeVFS extends VFS.Base {
436
431
  // The first null-terminated string is the URI path. Subsequent
437
432
  // strings are query parameter keys and values.
438
433
  // https://www.sqlite.org/c3ref/open.html#urifilenamesinsqlite3open
439
- let pName = zName;
440
- let state = 1;
441
- const charCodes = [];
434
+ let pName = zName
435
+ let state = 1
436
+ const charCodes = []
442
437
  while (state) {
443
- const charCode = this._module.HEAPU8[pName++];
438
+ const charCode = this._module.HEAPU8[pName++]
444
439
  if (charCode) {
445
- charCodes.push(charCode);
440
+ charCodes.push(charCode)
446
441
  } else {
447
- if (!this._module.HEAPU8[pName]) state = null;
442
+ if (!this._module.HEAPU8[pName]) state = null
448
443
  switch (state) {
449
444
  case 1: // path
450
- charCodes.push('?'.charCodeAt(0));
451
- state = 2;
452
- break;
445
+ charCodes.push('?'.charCodeAt(0))
446
+ state = 2
447
+ break
453
448
  case 2: // key
454
- charCodes.push('='.charCodeAt(0));
455
- state = 3;
456
- break;
449
+ charCodes.push('='.charCodeAt(0))
450
+ state = 3
451
+ break
457
452
  case 3: // value
458
- charCodes.push('&'.charCodeAt(0));
459
- state = 2;
460
- break;
453
+ charCodes.push('&'.charCodeAt(0))
454
+ state = 2
455
+ break
461
456
  }
462
457
  }
463
458
  }
464
- return new TextDecoder().decode(new Uint8Array(charCodes));
459
+ return new TextDecoder().decode(new Uint8Array(charCodes))
465
460
  }
466
- return zName ? this._module.UTF8ToString(zName) : null;
461
+ return zName ? this._module.UTF8ToString(zName) : null
467
462
  }
468
463
  }
469
464
 
470
465
  // Emscripten "legalizes" 64-bit integer arguments by passing them as
471
466
  // two 32-bit signed integers.
472
467
  function delegalize(lo32, hi32) {
473
- return (hi32 * 0x100000000) + lo32 + (lo32 < 0 ? 2**32 : 0);
468
+ return hi32 * 0x100000000 + lo32 + (lo32 < 0 ? 2 ** 32 : 0)
474
469
  }
475
470
 
476
471
  // This class provides a Uint8Array-like interface for a WebAssembly memory
@@ -484,131 +479,129 @@ function delegalize(lo32, hi32) {
484
479
  // a Uint8Array may not work. Use subarray() to get a real Uint8Array
485
480
  // if needed.
486
481
  class Uint8ArrayProxy {
487
- #module;
482
+ #module
488
483
 
489
484
  #_array = new Uint8Array()
490
485
  get #array() {
491
486
  if (this.#_array.buffer.byteLength === 0) {
492
487
  // WebAssembly memory resize detached the buffer so re-create the
493
488
  // array with the new buffer.
494
- this.#_array = this.#module.HEAPU8.subarray(
495
- this.byteOffset,
496
- this.byteOffset + this.byteLength);
489
+ this.#_array = this.#module.HEAPU8.subarray(this.byteOffset, this.byteOffset + this.byteLength)
497
490
  }
498
- return this.#_array;
491
+ return this.#_array
499
492
  }
500
493
 
501
494
  /**
502
495
  * @param {*} module
503
- * @param {number} byteOffset
504
- * @param {number} byteLength
496
+ * @param {number} byteOffset
497
+ * @param {number} byteLength
505
498
  */
506
499
  constructor(module, byteOffset, byteLength) {
507
- this.#module = module;
508
- this.byteOffset = byteOffset;
509
- this.length = this.byteLength = byteLength;
500
+ this.#module = module
501
+ this.byteOffset = byteOffset
502
+ this.length = this.byteLength = byteLength
510
503
  }
511
504
 
512
505
  get buffer() {
513
- return this.#array.buffer;
506
+ return this.#array.buffer
514
507
  }
515
508
 
516
509
  at(index) {
517
- return this.#array.at(index);
510
+ return this.#array.at(index)
518
511
  }
519
512
  copyWithin(target, start, end) {
520
- this.#array.copyWithin(target, start, end);
513
+ this.#array.copyWithin(target, start, end)
521
514
  }
522
515
  entries() {
523
- return this.#array.entries();
516
+ return this.#array.entries()
524
517
  }
525
518
  every(predicate) {
526
- return this.#array.every(predicate);
519
+ return this.#array.every(predicate)
527
520
  }
528
521
  fill(value, start, end) {
529
- this.#array.fill(value, start, end);
522
+ this.#array.fill(value, start, end)
530
523
  }
531
524
  filter(predicate) {
532
- return this.#array.filter(predicate);
525
+ return this.#array.filter(predicate)
533
526
  }
534
527
  find(predicate) {
535
- return this.#array.find(predicate);
528
+ return this.#array.find(predicate)
536
529
  }
537
530
  findIndex(predicate) {
538
- return this.#array.findIndex(predicate);
531
+ return this.#array.findIndex(predicate)
539
532
  }
540
533
  findLast(predicate) {
541
- return this.#array.findLast(predicate);
534
+ return this.#array.findLast(predicate)
542
535
  }
543
536
  findLastIndex(predicate) {
544
- return this.#array.findLastIndex(predicate);
537
+ return this.#array.findLastIndex(predicate)
545
538
  }
546
539
  forEach(callback) {
547
- this.#array.forEach(callback);
540
+ this.#array.forEach(callback)
548
541
  }
549
542
  includes(value, start) {
550
- return this.#array.includes(value, start);
543
+ return this.#array.includes(value, start)
551
544
  }
552
545
  indexOf(value, start) {
553
- return this.#array.indexOf(value, start);
546
+ return this.#array.indexOf(value, start)
554
547
  }
555
548
  join(separator) {
556
- return this.#array.join(separator);
549
+ return this.#array.join(separator)
557
550
  }
558
551
  keys() {
559
- return this.#array.keys();
552
+ return this.#array.keys()
560
553
  }
561
554
  lastIndexOf(value, start) {
562
- return this.#array.lastIndexOf(value, start);
555
+ return this.#array.lastIndexOf(value, start)
563
556
  }
564
557
  map(callback) {
565
- return this.#array.map(callback);
558
+ return this.#array.map(callback)
566
559
  }
567
560
  reduce(callback, initialValue) {
568
- return this.#array.reduce(callback, initialValue);
561
+ return this.#array.reduce(callback, initialValue)
569
562
  }
570
563
  reduceRight(callback, initialValue) {
571
- return this.#array.reduceRight(callback, initialValue);
564
+ return this.#array.reduceRight(callback, initialValue)
572
565
  }
573
566
  reverse() {
574
- this.#array.reverse();
567
+ this.#array.reverse()
575
568
  }
576
569
  set(array, offset) {
577
- this.#array.set(array, offset);
570
+ this.#array.set(array, offset)
578
571
  }
579
572
  slice(start, end) {
580
- return this.#array.slice(start, end);
573
+ return this.#array.slice(start, end)
581
574
  }
582
575
  some(predicate) {
583
- return this.#array.some(predicate);
576
+ return this.#array.some(predicate)
584
577
  }
585
578
  sort(compareFn) {
586
- this.#array.sort(compareFn);
579
+ this.#array.sort(compareFn)
587
580
  }
588
581
  subarray(begin, end) {
589
- return this.#array.subarray(begin, end);
582
+ return this.#array.subarray(begin, end)
590
583
  }
591
584
  toLocaleString(locales, options) {
592
585
  // @ts-ignore
593
- return this.#array.toLocaleString(locales, options);
586
+ return this.#array.toLocaleString(locales, options)
594
587
  }
595
588
  toReversed() {
596
- return this.#array.toReversed();
589
+ return this.#array.toReversed()
597
590
  }
598
591
  toSorted(compareFn) {
599
- return this.#array.toSorted(compareFn);
592
+ return this.#array.toSorted(compareFn)
600
593
  }
601
594
  toString() {
602
- return this.#array.toString();
595
+ return this.#array.toString()
603
596
  }
604
597
  values() {
605
- return this.#array.values();
598
+ return this.#array.values()
606
599
  }
607
600
  with(index, value) {
608
- return this.#array.with(index, value);
601
+ return this.#array.with(index, value)
609
602
  }
610
603
  [Symbol.iterator]() {
611
- return this.#array[Symbol.iterator]();
604
+ return this.#array[Symbol.iterator]()
612
605
  }
613
606
  }
614
607
 
@@ -617,65 +610,63 @@ class Uint8ArrayProxy {
617
610
  // the underlying buffer when the WebAssembly memory is resized, which can
618
611
  // happen when the memory is detached and resized by the WebAssembly module.
619
612
  class DataViewProxy {
620
- #module;
621
- #type;
613
+ #module
614
+ #type
622
615
 
623
- #_view = new DataView(new ArrayBuffer(0));
616
+ #_view = new DataView(new ArrayBuffer(0))
624
617
  get #view() {
625
618
  if (this.#_view.buffer.byteLength === 0) {
626
619
  // WebAssembly memory resize detached the buffer so re-create the
627
620
  // view with the new buffer.
628
- this.#_view = new DataView(
629
- this.#module.HEAPU8.buffer,
630
- this.#module.HEAPU8.byteOffset + this.byteOffset);
621
+ this.#_view = new DataView(this.#module.HEAPU8.buffer, this.#module.HEAPU8.byteOffset + this.byteOffset)
631
622
  }
632
- return this.#_view;
623
+ return this.#_view
633
624
  }
634
625
 
635
626
  /**
636
627
  * @param {*} module
637
- * @param {number} byteOffset
628
+ * @param {number} byteOffset
638
629
  * @param {'Int32'|'BigInt64'} type
639
630
  */
640
631
  constructor(module, byteOffset, type) {
641
- this.#module = module;
642
- this.byteOffset = byteOffset;
643
- this.#type = type;
632
+ this.#module = module
633
+ this.byteOffset = byteOffset
634
+ this.#type = type
644
635
  }
645
636
 
646
637
  get buffer() {
647
- return this.#view.buffer;
638
+ return this.#view.buffer
648
639
  }
649
640
  get byteLength() {
650
- return this.#type === 'Int32' ? 4 : 8;
641
+ return this.#type === 'Int32' ? 4 : 8
651
642
  }
652
643
 
653
644
  getInt32(byteOffset, littleEndian) {
654
645
  if (this.#type !== 'Int32') {
655
- throw new Error('invalid type');
646
+ throw new Error('invalid type')
656
647
  }
657
- if (!littleEndian) throw new Error('must be little endian');
658
- return this.#view.getInt32(byteOffset, littleEndian);
648
+ if (!littleEndian) throw new Error('must be little endian')
649
+ return this.#view.getInt32(byteOffset, littleEndian)
659
650
  }
660
651
  setInt32(byteOffset, value, littleEndian) {
661
652
  if (this.#type !== 'Int32') {
662
- throw new Error('invalid type');
653
+ throw new Error('invalid type')
663
654
  }
664
- if (!littleEndian) throw new Error('must be little endian');
665
- this.#view.setInt32(byteOffset, value, littleEndian);
655
+ if (!littleEndian) throw new Error('must be little endian')
656
+ this.#view.setInt32(byteOffset, value, littleEndian)
666
657
  }
667
658
  getBigInt64(byteOffset, littleEndian) {
668
659
  if (this.#type !== 'BigInt64') {
669
- throw new Error('invalid type');
660
+ throw new Error('invalid type')
670
661
  }
671
- if (!littleEndian) throw new Error('must be little endian');
672
- return this.#view.getBigInt64(byteOffset, littleEndian);
662
+ if (!littleEndian) throw new Error('must be little endian')
663
+ return this.#view.getBigInt64(byteOffset, littleEndian)
673
664
  }
674
665
  setBigInt64(byteOffset, value, littleEndian) {
675
666
  if (this.#type !== 'BigInt64') {
676
- throw new Error('invalid type');
667
+ throw new Error('invalid type')
677
668
  }
678
- if (!littleEndian) throw new Error('must be little endian');
679
- this.#view.setBigInt64(byteOffset, value, littleEndian);
669
+ if (!littleEndian) throw new Error('must be little endian')
670
+ this.#view.setBigInt64(byteOffset, value, littleEndian)
680
671
  }
681
- }
672
+ }