@powersync/web 0.0.0-dev-20260226160112 → 0.0.0-dev-20260305092446

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 (43) hide show
  1. package/dist/index.umd.js +64 -4091
  2. package/dist/index.umd.js.map +1 -1
  3. package/dist/worker/SharedSyncImplementation.umd.js +350 -405
  4. package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
  5. package/dist/worker/WASQLiteDB.umd.js +351 -406
  6. package/dist/worker/WASQLiteDB.umd.js.map +1 -1
  7. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-b9c070.umd.js +31 -0
  8. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-b9c070.umd.js.map +1 -0
  9. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-c99c07.umd.js +31 -0
  10. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-c99c07.umd.js.map +1 -0
  11. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-cc5fcc.umd.js +31 -0
  12. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-cc5fcc.umd.js.map +1 -0
  13. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js +31 -0
  14. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js.map +1 -0
  15. package/dist/worker/{node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--1787c2.umd.js → node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-0df390.umd.js} +24 -24
  16. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-0df390.umd.js.map +1 -0
  17. package/dist/worker/{node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--a6ce73.umd.js → node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-151024.umd.js} +18 -18
  18. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-151024.umd.js.map +1 -0
  19. package/dist/worker/{node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--0e69f0.umd.js → node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-c01ef0.umd.js} +20 -20
  20. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-c01ef0.umd.js.map +1 -0
  21. package/lib/package.json +1 -1
  22. package/lib/src/db/adapters/wa-sqlite/InternalWASQLiteDBAdapter.js +2 -4
  23. package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.d.ts +1 -10
  24. package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js +21 -36
  25. package/lib/src/worker/db/open-worker-database.js +2 -2
  26. package/lib/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +5 -5
  28. package/src/db/adapters/wa-sqlite/InternalWASQLiteDBAdapter.ts +3 -4
  29. package/src/db/adapters/wa-sqlite/WASQLiteConnection.ts +19 -41
  30. package/src/worker/db/open-worker-database.ts +2 -2
  31. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--0e69f0.umd.js.map +0 -1
  32. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--1787c2.umd.js.map +0 -1
  33. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--24f702.umd.js +0 -3494
  34. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--24f702.umd.js.map +0 -1
  35. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--4e15a2.umd.js +0 -31
  36. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--4e15a2.umd.js.map +0 -1
  37. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--7ba318.umd.js +0 -31
  38. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--7ba318.umd.js.map +0 -1
  39. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--919198.umd.js +0 -31
  40. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--919198.umd.js.map +0 -1
  41. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--997c14.umd.js +0 -31
  42. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--997c14.umd.js.map +0 -1
  43. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--a6ce73.umd.js.map +0 -1
@@ -1,3494 +0,0 @@
1
- "use strict";
2
- (self["webpackChunksdk_web"] = self["webpackChunksdk_web"] || []).push([["node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--24f702"],{
3
-
4
- /***/ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/FacadeVFS.js"
5
- /*!*************************************************************************************************************************************!*\
6
- !*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/FacadeVFS.js ***!
7
- \*************************************************************************************************************************************/
8
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9
-
10
- __webpack_require__.r(__webpack_exports__);
11
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12
- /* harmony export */ FacadeVFS: () => (/* binding */ FacadeVFS)
13
- /* harmony export */ });
14
- /* harmony import */ var _VFS_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./VFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/VFS.js");
15
- // Copyright 2024 Roy T. Hashimoto. All Rights Reserved.
16
-
17
-
18
- const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;
19
-
20
- // Milliseconds since Julian epoch as a BigInt.
21
- // https://github.com/sqlite/sqlite/blob/e57527c14f7b7cfa6e32eeab5c549d50c4fa3674/src/os_unix.c#L6872-L6882
22
- const UNIX_EPOCH = 24405875n * 8640000n;
23
-
24
- // Convenience base class for a JavaScript VFS.
25
- // The raw xOpen, xRead, etc. function signatures receive only C primitives
26
- // which aren't easy to work with. This class provides corresponding calls
27
- // like jOpen, jRead, etc., which receive JavaScript-friendlier arguments
28
- // such as string, Uint8Array, and DataView.
29
- class FacadeVFS extends _VFS_js__WEBPACK_IMPORTED_MODULE_0__.Base {
30
- /**
31
- * @param {string} name
32
- * @param {object} module
33
- */
34
- constructor(name, module) {
35
- super(name, module);
36
- }
37
-
38
- /**
39
- * Override to indicate which methods are asynchronous.
40
- * @param {string} methodName
41
- * @returns {boolean}
42
- */
43
- hasAsyncMethod(methodName) {
44
- // The input argument is a string like "xOpen", so convert to "jOpen".
45
- // Then check if the method exists and is async.
46
- const jMethodName = `j${methodName.slice(1)}`;
47
- return this[jMethodName] instanceof AsyncFunction;
48
- }
49
-
50
- /**
51
- * Return the filename for a file id for use by mixins.
52
- * @param {number} pFile
53
- * @returns {string}
54
- */
55
- getFilename(pFile) {
56
- throw new Error('unimplemented');
57
- }
58
-
59
- /**
60
- * @param {string?} filename
61
- * @param {number} pFile
62
- * @param {number} flags
63
- * @param {DataView} pOutFlags
64
- * @returns {number|Promise<number>}
65
- */
66
- jOpen(filename, pFile, flags, pOutFlags) {
67
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CANTOPEN;
68
- }
69
-
70
- /**
71
- * @param {string} filename
72
- * @param {number} syncDir
73
- * @returns {number|Promise<number>}
74
- */
75
- jDelete(filename, syncDir) {
76
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
77
- }
78
-
79
- /**
80
- * @param {string} filename
81
- * @param {number} flags
82
- * @param {DataView} pResOut
83
- * @returns {number|Promise<number>}
84
- */
85
- jAccess(filename, flags, pResOut) {
86
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
87
- }
88
-
89
- /**
90
- * @param {string} filename
91
- * @param {Uint8Array} zOut
92
- * @returns {number|Promise<number>}
93
- */
94
- jFullPathname(filename, zOut) {
95
- // Copy the filename to the output buffer.
96
- const { read, written } = new TextEncoder().encodeInto(filename, zOut);
97
- if (read < filename.length) return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
98
- if (written >= zOut.length) return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
99
- zOut[written] = 0;
100
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
101
- }
102
-
103
- /**
104
- * @param {Uint8Array} zBuf
105
- * @returns {number|Promise<number>}
106
- */
107
- jGetLastError(zBuf) {
108
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
109
- }
110
-
111
- /**
112
- * @param {number} pFile
113
- * @returns {number|Promise<number>}
114
- */
115
- jClose(pFile) {
116
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
117
- }
118
-
119
- /**
120
- * @param {number} pFile
121
- * @param {Uint8Array} pData
122
- * @param {number} iOffset
123
- * @returns {number|Promise<number>}
124
- */
125
- jRead(pFile, pData, iOffset) {
126
- pData.fill(0);
127
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_SHORT_READ;
128
- }
129
-
130
- /**
131
- * @param {number} pFile
132
- * @param {Uint8Array} pData
133
- * @param {number} iOffset
134
- * @returns {number|Promise<number>}
135
- */
136
- jWrite(pFile, pData, iOffset) {
137
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_WRITE;
138
- }
139
-
140
- /**
141
- * @param {number} pFile
142
- * @param {number} size
143
- * @returns {number|Promise<number>}
144
- */
145
- jTruncate(pFile, size) {
146
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
147
- }
148
-
149
- /**
150
- * @param {number} pFile
151
- * @param {number} flags
152
- * @returns {number|Promise<number>}
153
- */
154
- jSync(pFile, flags) {
155
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
156
- }
157
-
158
- /**
159
- * @param {number} pFile
160
- * @param {DataView} pSize
161
- * @returns {number|Promise<number>}
162
- */
163
- jFileSize(pFile, pSize) {
164
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
165
- }
166
-
167
- /**
168
- * @param {number} pFile
169
- * @param {number} lockType
170
- * @returns {number|Promise<number>}
171
- */
172
- jLock(pFile, lockType) {
173
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
174
- }
175
-
176
- /**
177
- * @param {number} pFile
178
- * @param {number} lockType
179
- * @returns {number|Promise<number>}
180
- */
181
- jUnlock(pFile, lockType) {
182
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
183
- }
184
-
185
- /**
186
- * @param {number} pFile
187
- * @param {DataView} pResOut
188
- * @returns {number|Promise<number>}
189
- */
190
- jCheckReservedLock(pFile, pResOut) {
191
- pResOut.setInt32(0, 0, true);
192
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
193
- }
194
-
195
- /**
196
- * @param {number} pFile
197
- * @param {number} op
198
- * @param {DataView} pArg
199
- * @returns {number|Promise<number>}
200
- */
201
- jFileControl(pFile, op, pArg) {
202
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOTFOUND;
203
- }
204
-
205
- /**
206
- * @param {number} pFile
207
- * @returns {number|Promise<number>}
208
- */
209
- jSectorSize(pFile) {
210
- return super.xSectorSize(pFile);
211
- }
212
-
213
- /**
214
- * @param {number} pFile
215
- * @returns {number|Promise<number>}
216
- */
217
- jDeviceCharacteristics(pFile) {
218
- return 0;
219
- }
220
-
221
- /**
222
- * @param {number} pVfs
223
- * @param {number} zName
224
- * @param {number} pFile
225
- * @param {number} flags
226
- * @param {number} pOutFlags
227
- * @returns {number|Promise<number>}
228
- */
229
- xOpen(pVfs, zName, pFile, flags, pOutFlags) {
230
- const filename = this.#decodeFilename(zName, flags);
231
- const pOutFlagsView = this.#makeTypedDataView('Int32', pOutFlags);
232
- this['log']?.('jOpen', filename, pFile, '0x' + flags.toString(16));
233
- return this.jOpen(filename, pFile, flags, pOutFlagsView);
234
- }
235
-
236
- /**
237
- * @param {number} pVfs
238
- * @param {number} nByte
239
- * @param {number} pCharOut
240
- * @returns {number|Promise<number>}
241
- */
242
- xRandomness(pVfs, nByte, pCharOut) {
243
- const randomArray = new Uint8Array(nByte);
244
- crypto.getRandomValues(randomArray);
245
- // Copy randomArray to the WebAssembly memory
246
- const buffer = pCharOut; // Pointer to memory in WebAssembly
247
- this._module.HEAPU8.set(randomArray, buffer); // Copy randomArray into memory starting at buffer
248
- return nByte;
249
- }
250
-
251
- /**
252
- * Gets the current time as milliseconds since Unix epoch
253
- * @param {number} pVfs pointer to the VFS
254
- * @param {number} pTime pointer to write the time value
255
- * @returns {number} SQLite error code
256
- */
257
- xCurrentTimeInt64(pVfs, pTime) {
258
- // Create a DataView to write the current time
259
- const timeView = this.#makeTypedDataView('BigInt64', pTime);
260
-
261
- const currentTime = BigInt(Date.now());
262
- // Convert the current time to milliseconds since Unix epoch
263
- const value = UNIX_EPOCH + currentTime;
264
-
265
- // Write the time value to the pointer location
266
- timeView.setBigInt64(0, value, true);
267
-
268
- return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
269
- }
270
-
271
- /**
272
- * @param {number} pVfs
273
- * @param {number} zName
274
- * @param {number} syncDir
275
- * @returns {number|Promise<number>}
276
- */
277
- xDelete(pVfs, zName, syncDir) {
278
- const filename = this._module.UTF8ToString(zName);
279
- this['log']?.('jDelete', filename, syncDir);
280
- return this.jDelete(filename, syncDir);
281
- }
282
-
283
- /**
284
- * @param {number} pVfs
285
- * @param {number} zName
286
- * @param {number} flags
287
- * @param {number} pResOut
288
- * @returns {number|Promise<number>}
289
- */
290
- xAccess(pVfs, zName, flags, pResOut) {
291
- const filename = this._module.UTF8ToString(zName);
292
- const pResOutView = this.#makeTypedDataView('Int32', pResOut);
293
- this['log']?.('jAccess', filename, flags);
294
- return this.jAccess(filename, flags, pResOutView);
295
- }
296
-
297
- /**
298
- * @param {number} pVfs
299
- * @param {number} zName
300
- * @param {number} nOut
301
- * @param {number} zOut
302
- * @returns {number|Promise<number>}
303
- */
304
- xFullPathname(pVfs, zName, nOut, zOut) {
305
- const filename = this._module.UTF8ToString(zName);
306
- const zOutArray = this._module.HEAPU8.subarray(zOut, zOut + nOut);
307
- this['log']?.('jFullPathname', filename, nOut);
308
- return this.jFullPathname(filename, zOutArray);
309
- }
310
-
311
- /**
312
- * @param {number} pVfs
313
- * @param {number} nBuf
314
- * @param {number} zBuf
315
- * @returns {number|Promise<number>}
316
- */
317
- xGetLastError(pVfs, nBuf, zBuf) {
318
- const zBufArray = this._module.HEAPU8.subarray(zBuf, zBuf + nBuf);
319
- this['log']?.('jGetLastError', nBuf);
320
- return this.jGetLastError(zBufArray);
321
- }
322
-
323
- /**
324
- * @param {number} pFile
325
- * @returns {number|Promise<number>}
326
- */
327
- xClose(pFile) {
328
- this['log']?.('jClose', pFile);
329
- return this.jClose(pFile);
330
- }
331
-
332
- /**
333
- * @param {number} pFile
334
- * @param {number} pData
335
- * @param {number} iAmt
336
- * @param {number} iOffsetLo
337
- * @param {number} iOffsetHi
338
- * @returns {number|Promise<number>}
339
- */
340
- xRead(pFile, pData, iAmt, iOffsetLo, iOffsetHi) {
341
- const pDataArray = this.#makeDataArray(pData, iAmt);
342
- const iOffset = delegalize(iOffsetLo, iOffsetHi);
343
- this['log']?.('jRead', pFile, iAmt, iOffset);
344
- return this.jRead(pFile, pDataArray, iOffset);
345
- }
346
-
347
- /**
348
- * @param {number} pFile
349
- * @param {number} pData
350
- * @param {number} iAmt
351
- * @param {number} iOffsetLo
352
- * @param {number} iOffsetHi
353
- * @returns {number|Promise<number>}
354
- */
355
- xWrite(pFile, pData, iAmt, iOffsetLo, iOffsetHi) {
356
- const pDataArray = this.#makeDataArray(pData, iAmt);
357
- const iOffset = delegalize(iOffsetLo, iOffsetHi);
358
- this['log']?.('jWrite', pFile, pDataArray, iOffset);
359
- return this.jWrite(pFile, pDataArray, iOffset);
360
- }
361
-
362
- /**
363
- * @param {number} pFile
364
- * @param {number} sizeLo
365
- * @param {number} sizeHi
366
- * @returns {number|Promise<number>}
367
- */
368
- xTruncate(pFile, sizeLo, sizeHi) {
369
- const size = delegalize(sizeLo, sizeHi);
370
- this['log']?.('jTruncate', pFile, size);
371
- return this.jTruncate(pFile, size);
372
- }
373
-
374
- /**
375
- * @param {number} pFile
376
- * @param {number} flags
377
- * @returns {number|Promise<number>}
378
- */
379
- xSync(pFile, flags) {
380
- this['log']?.('jSync', pFile, flags);
381
- return this.jSync(pFile, flags);
382
- }
383
-
384
- /**
385
- *
386
- * @param {number} pFile
387
- * @param {number} pSize
388
- * @returns {number|Promise<number>}
389
- */
390
- xFileSize(pFile, pSize) {
391
- const pSizeView = this.#makeTypedDataView('BigInt64', pSize);
392
- this['log']?.('jFileSize', pFile);
393
- return this.jFileSize(pFile, pSizeView);
394
- }
395
-
396
- /**
397
- * @param {number} pFile
398
- * @param {number} lockType
399
- * @returns {number|Promise<number>}
400
- */
401
- xLock(pFile, lockType) {
402
- this['log']?.('jLock', pFile, lockType);
403
- return this.jLock(pFile, lockType);
404
- }
405
-
406
- /**
407
- * @param {number} pFile
408
- * @param {number} lockType
409
- * @returns {number|Promise<number>}
410
- */
411
- xUnlock(pFile, lockType) {
412
- this['log']?.('jUnlock', pFile, lockType);
413
- return this.jUnlock(pFile, lockType);
414
- }
415
-
416
- /**
417
- * @param {number} pFile
418
- * @param {number} pResOut
419
- * @returns {number|Promise<number>}
420
- */
421
- xCheckReservedLock(pFile, pResOut) {
422
- const pResOutView = this.#makeTypedDataView('Int32', pResOut);
423
- this['log']?.('jCheckReservedLock', pFile);
424
- return this.jCheckReservedLock(pFile, pResOutView);
425
- }
426
-
427
- /**
428
- * @param {number} pFile
429
- * @param {number} op
430
- * @param {number} pArg
431
- * @returns {number|Promise<number>}
432
- */
433
- xFileControl(pFile, op, pArg) {
434
- const pArgView = new DataView(
435
- this._module.HEAPU8.buffer,
436
- this._module.HEAPU8.byteOffset + pArg);
437
- this['log']?.('jFileControl', pFile, op, pArgView);
438
- return this.jFileControl(pFile, op, pArgView);
439
- }
440
-
441
- /**
442
- * @param {number} pFile
443
- * @returns {number|Promise<number>}
444
- */
445
- xSectorSize(pFile) {
446
- this['log']?.('jSectorSize', pFile);
447
- return this.jSectorSize(pFile);
448
- }
449
-
450
- /**
451
- * @param {number} pFile
452
- * @returns {number|Promise<number>}
453
- */
454
- xDeviceCharacteristics(pFile) {
455
- this['log']?.('jDeviceCharacteristics', pFile);
456
- return this.jDeviceCharacteristics(pFile);
457
- }
458
-
459
- /**
460
- * Wrapped DataView for pointer arguments.
461
- * Pointers to a single value are passed using a DataView-like class.
462
- * This wrapper class prevents use of incorrect type or endianness, and
463
- * reacquires the underlying buffer when the WebAssembly memory is resized.
464
- * @param {'Int32'|'BigInt64'} type
465
- * @param {number} byteOffset
466
- * @returns {DataView}
467
- */
468
- #makeTypedDataView(type, byteOffset) {
469
- // @ts-ignore
470
- return new DataViewProxy(this._module, byteOffset, type);
471
- }
472
-
473
- /**
474
- * Wrapped Uint8Array for buffer arguments.
475
- * Memory blocks are passed as a Uint8Array-like class. This wrapper
476
- * class reacquires the underlying buffer when the WebAssembly memory
477
- * is resized.
478
- * @param {number} byteOffset
479
- * @param {number} byteLength
480
- * @returns {Uint8Array}
481
- */
482
- #makeDataArray(byteOffset, byteLength) {
483
- // @ts-ignore
484
- return new Uint8ArrayProxy(this._module, byteOffset, byteLength);
485
- }
486
-
487
- #decodeFilename(zName, flags) {
488
- if (flags & _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_URI) {
489
- // The first null-terminated string is the URI path. Subsequent
490
- // strings are query parameter keys and values.
491
- // https://www.sqlite.org/c3ref/open.html#urifilenamesinsqlite3open
492
- let pName = zName;
493
- let state = 1;
494
- const charCodes = [];
495
- while (state) {
496
- const charCode = this._module.HEAPU8[pName++];
497
- if (charCode) {
498
- charCodes.push(charCode);
499
- } else {
500
- if (!this._module.HEAPU8[pName]) state = null;
501
- switch (state) {
502
- case 1: // path
503
- charCodes.push('?'.charCodeAt(0));
504
- state = 2;
505
- break;
506
- case 2: // key
507
- charCodes.push('='.charCodeAt(0));
508
- state = 3;
509
- break;
510
- case 3: // value
511
- charCodes.push('&'.charCodeAt(0));
512
- state = 2;
513
- break;
514
- }
515
- }
516
- }
517
- return new TextDecoder().decode(new Uint8Array(charCodes));
518
- }
519
- return zName ? this._module.UTF8ToString(zName) : null;
520
- }
521
- }
522
-
523
- // Emscripten "legalizes" 64-bit integer arguments by passing them as
524
- // two 32-bit signed integers.
525
- function delegalize(lo32, hi32) {
526
- return (hi32 * 0x100000000) + lo32 + (lo32 < 0 ? 2**32 : 0);
527
- }
528
-
529
- // This class provides a Uint8Array-like interface for a WebAssembly memory
530
- // buffer. It is used to access memory blocks passed as arguments to
531
- // xRead, xWrite, etc. The class reacquires the underlying buffer when the
532
- // WebAssembly memory is resized, which can happen when the memory is
533
- // detached and resized by the WebAssembly module.
534
- //
535
- // Note that although this class implements the same methods as Uint8Array,
536
- // it is not a real Uint8Array and passing it to functions that expect
537
- // a Uint8Array may not work. Use subarray() to get a real Uint8Array
538
- // if needed.
539
- class Uint8ArrayProxy {
540
- #module;
541
-
542
- #_array = new Uint8Array()
543
- get #array() {
544
- if (this.#_array.buffer.byteLength === 0) {
545
- // WebAssembly memory resize detached the buffer so re-create the
546
- // array with the new buffer.
547
- this.#_array = this.#module.HEAPU8.subarray(
548
- this.byteOffset,
549
- this.byteOffset + this.byteLength);
550
- }
551
- return this.#_array;
552
- }
553
-
554
- /**
555
- * @param {*} module
556
- * @param {number} byteOffset
557
- * @param {number} byteLength
558
- */
559
- constructor(module, byteOffset, byteLength) {
560
- this.#module = module;
561
- this.byteOffset = byteOffset;
562
- this.length = this.byteLength = byteLength;
563
- }
564
-
565
- get buffer() {
566
- return this.#array.buffer;
567
- }
568
-
569
- at(index) {
570
- return this.#array.at(index);
571
- }
572
- copyWithin(target, start, end) {
573
- this.#array.copyWithin(target, start, end);
574
- }
575
- entries() {
576
- return this.#array.entries();
577
- }
578
- every(predicate) {
579
- return this.#array.every(predicate);
580
- }
581
- fill(value, start, end) {
582
- this.#array.fill(value, start, end);
583
- }
584
- filter(predicate) {
585
- return this.#array.filter(predicate);
586
- }
587
- find(predicate) {
588
- return this.#array.find(predicate);
589
- }
590
- findIndex(predicate) {
591
- return this.#array.findIndex(predicate);
592
- }
593
- findLast(predicate) {
594
- return this.#array.findLast(predicate);
595
- }
596
- findLastIndex(predicate) {
597
- return this.#array.findLastIndex(predicate);
598
- }
599
- forEach(callback) {
600
- this.#array.forEach(callback);
601
- }
602
- includes(value, start) {
603
- return this.#array.includes(value, start);
604
- }
605
- indexOf(value, start) {
606
- return this.#array.indexOf(value, start);
607
- }
608
- join(separator) {
609
- return this.#array.join(separator);
610
- }
611
- keys() {
612
- return this.#array.keys();
613
- }
614
- lastIndexOf(value, start) {
615
- return this.#array.lastIndexOf(value, start);
616
- }
617
- map(callback) {
618
- return this.#array.map(callback);
619
- }
620
- reduce(callback, initialValue) {
621
- return this.#array.reduce(callback, initialValue);
622
- }
623
- reduceRight(callback, initialValue) {
624
- return this.#array.reduceRight(callback, initialValue);
625
- }
626
- reverse() {
627
- this.#array.reverse();
628
- }
629
- set(array, offset) {
630
- this.#array.set(array, offset);
631
- }
632
- slice(start, end) {
633
- return this.#array.slice(start, end);
634
- }
635
- some(predicate) {
636
- return this.#array.some(predicate);
637
- }
638
- sort(compareFn) {
639
- this.#array.sort(compareFn);
640
- }
641
- subarray(begin, end) {
642
- return this.#array.subarray(begin, end);
643
- }
644
- toLocaleString(locales, options) {
645
- // @ts-ignore
646
- return this.#array.toLocaleString(locales, options);
647
- }
648
- toReversed() {
649
- return this.#array.toReversed();
650
- }
651
- toSorted(compareFn) {
652
- return this.#array.toSorted(compareFn);
653
- }
654
- toString() {
655
- return this.#array.toString();
656
- }
657
- values() {
658
- return this.#array.values();
659
- }
660
- with(index, value) {
661
- return this.#array.with(index, value);
662
- }
663
- [Symbol.iterator]() {
664
- return this.#array[Symbol.iterator]();
665
- }
666
- }
667
-
668
- // This class provides a DataView-like interface for a WebAssembly memory
669
- // buffer, restricted to either Int32 or BigInt64 types. It also reacquires
670
- // the underlying buffer when the WebAssembly memory is resized, which can
671
- // happen when the memory is detached and resized by the WebAssembly module.
672
- class DataViewProxy {
673
- #module;
674
- #type;
675
-
676
- #_view = new DataView(new ArrayBuffer(0));
677
- get #view() {
678
- if (this.#_view.buffer.byteLength === 0) {
679
- // WebAssembly memory resize detached the buffer so re-create the
680
- // view with the new buffer.
681
- this.#_view = new DataView(
682
- this.#module.HEAPU8.buffer,
683
- this.#module.HEAPU8.byteOffset + this.byteOffset);
684
- }
685
- return this.#_view;
686
- }
687
-
688
- /**
689
- * @param {*} module
690
- * @param {number} byteOffset
691
- * @param {'Int32'|'BigInt64'} type
692
- */
693
- constructor(module, byteOffset, type) {
694
- this.#module = module;
695
- this.byteOffset = byteOffset;
696
- this.#type = type;
697
- }
698
-
699
- get buffer() {
700
- return this.#view.buffer;
701
- }
702
- get byteLength() {
703
- return this.#type === 'Int32' ? 4 : 8;
704
- }
705
-
706
- getInt32(byteOffset, littleEndian) {
707
- if (this.#type !== 'Int32') {
708
- throw new Error('invalid type');
709
- }
710
- if (!littleEndian) throw new Error('must be little endian');
711
- return this.#view.getInt32(byteOffset, littleEndian);
712
- }
713
- setInt32(byteOffset, value, littleEndian) {
714
- if (this.#type !== 'Int32') {
715
- throw new Error('invalid type');
716
- }
717
- if (!littleEndian) throw new Error('must be little endian');
718
- this.#view.setInt32(byteOffset, value, littleEndian);
719
- }
720
- getBigInt64(byteOffset, littleEndian) {
721
- if (this.#type !== 'BigInt64') {
722
- throw new Error('invalid type');
723
- }
724
- if (!littleEndian) throw new Error('must be little endian');
725
- return this.#view.getBigInt64(byteOffset, littleEndian);
726
- }
727
- setBigInt64(byteOffset, value, littleEndian) {
728
- if (this.#type !== 'BigInt64') {
729
- throw new Error('invalid type');
730
- }
731
- if (!littleEndian) throw new Error('must be little endian');
732
- this.#view.setBigInt64(byteOffset, value, littleEndian);
733
- }
734
- }
735
-
736
- /***/ },
737
-
738
- /***/ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/VFS.js"
739
- /*!*******************************************************************************************************************************!*\
740
- !*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/VFS.js ***!
741
- \*******************************************************************************************************************************/
742
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
743
-
744
- __webpack_require__.r(__webpack_exports__);
745
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
746
- /* harmony export */ Base: () => (/* binding */ Base),
747
- /* harmony export */ FILE_TYPE_MASK: () => (/* binding */ FILE_TYPE_MASK),
748
- /* harmony export */ SQLITE_ABORT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ABORT),
749
- /* harmony export */ SQLITE_ACCESS_EXISTS: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ACCESS_EXISTS),
750
- /* harmony export */ SQLITE_ACCESS_READ: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ACCESS_READ),
751
- /* harmony export */ SQLITE_ACCESS_READWRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ACCESS_READWRITE),
752
- /* harmony export */ SQLITE_ALTER_TABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ALTER_TABLE),
753
- /* harmony export */ SQLITE_ANALYZE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ANALYZE),
754
- /* harmony export */ SQLITE_ATTACH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ATTACH),
755
- /* harmony export */ SQLITE_AUTH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_AUTH),
756
- /* harmony export */ SQLITE_BLOB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BLOB),
757
- /* harmony export */ SQLITE_BUSY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BUSY),
758
- /* harmony export */ SQLITE_CANTOPEN: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CANTOPEN),
759
- /* harmony export */ SQLITE_CONSTRAINT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT),
760
- /* harmony export */ SQLITE_CONSTRAINT_CHECK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_CHECK),
761
- /* harmony export */ SQLITE_CONSTRAINT_COMMITHOOK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_COMMITHOOK),
762
- /* harmony export */ SQLITE_CONSTRAINT_FOREIGNKEY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_FOREIGNKEY),
763
- /* harmony export */ SQLITE_CONSTRAINT_FUNCTION: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_FUNCTION),
764
- /* harmony export */ SQLITE_CONSTRAINT_NOTNULL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_NOTNULL),
765
- /* harmony export */ SQLITE_CONSTRAINT_PINNED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_PINNED),
766
- /* harmony export */ SQLITE_CONSTRAINT_PRIMARYKEY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_PRIMARYKEY),
767
- /* harmony export */ SQLITE_CONSTRAINT_ROWID: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_ROWID),
768
- /* harmony export */ SQLITE_CONSTRAINT_TRIGGER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_TRIGGER),
769
- /* harmony export */ SQLITE_CONSTRAINT_UNIQUE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_UNIQUE),
770
- /* harmony export */ SQLITE_CONSTRAINT_VTAB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_VTAB),
771
- /* harmony export */ SQLITE_COPY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_COPY),
772
- /* harmony export */ SQLITE_CORRUPT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CORRUPT),
773
- /* harmony export */ SQLITE_CREATE_INDEX: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_INDEX),
774
- /* harmony export */ SQLITE_CREATE_TABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_TABLE),
775
- /* harmony export */ SQLITE_CREATE_TEMP_INDEX: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_TEMP_INDEX),
776
- /* harmony export */ SQLITE_CREATE_TEMP_TABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_TEMP_TABLE),
777
- /* harmony export */ SQLITE_CREATE_TEMP_TRIGGER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_TEMP_TRIGGER),
778
- /* harmony export */ SQLITE_CREATE_TEMP_VIEW: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_TEMP_VIEW),
779
- /* harmony export */ SQLITE_CREATE_TRIGGER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_TRIGGER),
780
- /* harmony export */ SQLITE_CREATE_VIEW: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_VIEW),
781
- /* harmony export */ SQLITE_CREATE_VTABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_VTABLE),
782
- /* harmony export */ SQLITE_DELETE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DELETE),
783
- /* harmony export */ SQLITE_DENY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DENY),
784
- /* harmony export */ SQLITE_DETACH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DETACH),
785
- /* harmony export */ SQLITE_DETERMINISTIC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DETERMINISTIC),
786
- /* harmony export */ SQLITE_DIRECTONLY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DIRECTONLY),
787
- /* harmony export */ SQLITE_DONE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DONE),
788
- /* harmony export */ SQLITE_DROP_INDEX: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_INDEX),
789
- /* harmony export */ SQLITE_DROP_TABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_TABLE),
790
- /* harmony export */ SQLITE_DROP_TEMP_INDEX: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_TEMP_INDEX),
791
- /* harmony export */ SQLITE_DROP_TEMP_TABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_TEMP_TABLE),
792
- /* harmony export */ SQLITE_DROP_TEMP_TRIGGER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_TEMP_TRIGGER),
793
- /* harmony export */ SQLITE_DROP_TEMP_VIEW: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_TEMP_VIEW),
794
- /* harmony export */ SQLITE_DROP_TRIGGER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_TRIGGER),
795
- /* harmony export */ SQLITE_DROP_VIEW: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_VIEW),
796
- /* harmony export */ SQLITE_DROP_VTABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_VTABLE),
797
- /* harmony export */ SQLITE_EMPTY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_EMPTY),
798
- /* harmony export */ SQLITE_ERROR: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ERROR),
799
- /* harmony export */ SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_BEGIN_ATOMIC_WRITE),
800
- /* harmony export */ SQLITE_FCNTL_BUSYHANDLER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_BUSYHANDLER),
801
- /* harmony export */ SQLITE_FCNTL_CHUNK_SIZE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_CHUNK_SIZE),
802
- /* harmony export */ SQLITE_FCNTL_CKPT_DONE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_CKPT_DONE),
803
- /* harmony export */ SQLITE_FCNTL_CKPT_START: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_CKPT_START),
804
- /* harmony export */ SQLITE_FCNTL_COMMIT_ATOMIC_WRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_COMMIT_ATOMIC_WRITE),
805
- /* harmony export */ SQLITE_FCNTL_COMMIT_PHASETWO: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_COMMIT_PHASETWO),
806
- /* harmony export */ SQLITE_FCNTL_DATA_VERSION: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_DATA_VERSION),
807
- /* harmony export */ SQLITE_FCNTL_FILE_POINTER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_FILE_POINTER),
808
- /* harmony export */ SQLITE_FCNTL_GET_LOCKPROXYFILE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_GET_LOCKPROXYFILE),
809
- /* harmony export */ SQLITE_FCNTL_HAS_MOVED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_HAS_MOVED),
810
- /* harmony export */ SQLITE_FCNTL_JOURNAL_POINTER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_JOURNAL_POINTER),
811
- /* harmony export */ SQLITE_FCNTL_LAST_ERRNO: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_LAST_ERRNO),
812
- /* harmony export */ SQLITE_FCNTL_LOCKSTATE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_LOCKSTATE),
813
- /* harmony export */ SQLITE_FCNTL_LOCK_TIMEOUT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_LOCK_TIMEOUT),
814
- /* harmony export */ SQLITE_FCNTL_MMAP_SIZE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_MMAP_SIZE),
815
- /* harmony export */ SQLITE_FCNTL_OVERWRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_OVERWRITE),
816
- /* harmony export */ SQLITE_FCNTL_PDB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_PDB),
817
- /* harmony export */ SQLITE_FCNTL_PERSIST_WAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_PERSIST_WAL),
818
- /* harmony export */ SQLITE_FCNTL_POWERSAFE_OVERWRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_POWERSAFE_OVERWRITE),
819
- /* harmony export */ SQLITE_FCNTL_PRAGMA: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_PRAGMA),
820
- /* harmony export */ SQLITE_FCNTL_RBU: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_RBU),
821
- /* harmony export */ SQLITE_FCNTL_RESERVE_BYTES: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_RESERVE_BYTES),
822
- /* harmony export */ SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE),
823
- /* harmony export */ SQLITE_FCNTL_SET_LOCKPROXYFILE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_SET_LOCKPROXYFILE),
824
- /* harmony export */ SQLITE_FCNTL_SIZE_HINT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_SIZE_HINT),
825
- /* harmony export */ SQLITE_FCNTL_SIZE_LIMIT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_SIZE_LIMIT),
826
- /* harmony export */ SQLITE_FCNTL_SYNC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_SYNC),
827
- /* harmony export */ SQLITE_FCNTL_SYNC_OMITTED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_SYNC_OMITTED),
828
- /* harmony export */ SQLITE_FCNTL_TEMPFILENAME: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_TEMPFILENAME),
829
- /* harmony export */ SQLITE_FCNTL_TRACE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_TRACE),
830
- /* harmony export */ SQLITE_FCNTL_VFSNAME: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_VFSNAME),
831
- /* harmony export */ SQLITE_FCNTL_VFS_POINTER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_VFS_POINTER),
832
- /* harmony export */ SQLITE_FCNTL_WAL_BLOCK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_WAL_BLOCK),
833
- /* harmony export */ SQLITE_FCNTL_WIN32_AV_RETRY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_WIN32_AV_RETRY),
834
- /* harmony export */ SQLITE_FCNTL_WIN32_GET_HANDLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_WIN32_GET_HANDLE),
835
- /* harmony export */ SQLITE_FCNTL_WIN32_SET_HANDLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_WIN32_SET_HANDLE),
836
- /* harmony export */ SQLITE_FCNTL_ZIPVFS: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_ZIPVFS),
837
- /* harmony export */ SQLITE_FLOAT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FLOAT),
838
- /* harmony export */ SQLITE_FORMAT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FORMAT),
839
- /* harmony export */ SQLITE_FULL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FULL),
840
- /* harmony export */ SQLITE_FUNCTION: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FUNCTION),
841
- /* harmony export */ SQLITE_IGNORE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IGNORE),
842
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_EQ: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_EQ),
843
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_FUNCTION: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_FUNCTION),
844
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_GE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_GE),
845
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_GLOB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_GLOB),
846
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_GT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_GT),
847
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_IS: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_IS),
848
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_ISNOT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_ISNOT),
849
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_ISNOTNULL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_ISNOTNULL),
850
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_ISNULL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_ISNULL),
851
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_LE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_LE),
852
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_LIKE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_LIKE),
853
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_LT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_LT),
854
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_MATCH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_MATCH),
855
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_NE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_NE),
856
- /* harmony export */ SQLITE_INDEX_CONSTRAINT_REGEXP: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_REGEXP),
857
- /* harmony export */ SQLITE_INDEX_SCAN_UNIQUE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_SCAN_UNIQUE),
858
- /* harmony export */ SQLITE_INNOCUOUS: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INNOCUOUS),
859
- /* harmony export */ SQLITE_INSERT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INSERT),
860
- /* harmony export */ SQLITE_INTEGER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INTEGER),
861
- /* harmony export */ SQLITE_INTERNAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INTERNAL),
862
- /* harmony export */ SQLITE_INTERRUPT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INTERRUPT),
863
- /* harmony export */ SQLITE_IOCAP_ATOMIC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC),
864
- /* harmony export */ SQLITE_IOCAP_ATOMIC16K: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC16K),
865
- /* harmony export */ SQLITE_IOCAP_ATOMIC1K: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC1K),
866
- /* harmony export */ SQLITE_IOCAP_ATOMIC2K: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC2K),
867
- /* harmony export */ SQLITE_IOCAP_ATOMIC32K: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC32K),
868
- /* harmony export */ SQLITE_IOCAP_ATOMIC4K: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC4K),
869
- /* harmony export */ SQLITE_IOCAP_ATOMIC512: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC512),
870
- /* harmony export */ SQLITE_IOCAP_ATOMIC64K: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC64K),
871
- /* harmony export */ SQLITE_IOCAP_ATOMIC8K: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC8K),
872
- /* harmony export */ SQLITE_IOCAP_BATCH_ATOMIC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_BATCH_ATOMIC),
873
- /* harmony export */ SQLITE_IOCAP_IMMUTABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_IMMUTABLE),
874
- /* harmony export */ SQLITE_IOCAP_POWERSAFE_OVERWRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_POWERSAFE_OVERWRITE),
875
- /* harmony export */ SQLITE_IOCAP_SAFE_APPEND: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_SAFE_APPEND),
876
- /* harmony export */ SQLITE_IOCAP_SEQUENTIAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_SEQUENTIAL),
877
- /* harmony export */ SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN),
878
- /* harmony export */ SQLITE_IOERR: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR),
879
- /* harmony export */ SQLITE_IOERR_ACCESS: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_ACCESS),
880
- /* harmony export */ SQLITE_IOERR_BEGIN_ATOMIC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_BEGIN_ATOMIC),
881
- /* harmony export */ SQLITE_IOERR_CHECKRESERVEDLOCK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_CHECKRESERVEDLOCK),
882
- /* harmony export */ SQLITE_IOERR_CLOSE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_CLOSE),
883
- /* harmony export */ SQLITE_IOERR_COMMIT_ATOMIC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_COMMIT_ATOMIC),
884
- /* harmony export */ SQLITE_IOERR_DATA: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_DATA),
885
- /* harmony export */ SQLITE_IOERR_DELETE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_DELETE),
886
- /* harmony export */ SQLITE_IOERR_DELETE_NOENT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_DELETE_NOENT),
887
- /* harmony export */ SQLITE_IOERR_DIR_FSYNC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_DIR_FSYNC),
888
- /* harmony export */ SQLITE_IOERR_FSTAT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_FSTAT),
889
- /* harmony export */ SQLITE_IOERR_FSYNC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_FSYNC),
890
- /* harmony export */ SQLITE_IOERR_GETTEMPPATH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_GETTEMPPATH),
891
- /* harmony export */ SQLITE_IOERR_LOCK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_LOCK),
892
- /* harmony export */ SQLITE_IOERR_NOMEM: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_NOMEM),
893
- /* harmony export */ SQLITE_IOERR_RDLOCK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_RDLOCK),
894
- /* harmony export */ SQLITE_IOERR_READ: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_READ),
895
- /* harmony export */ SQLITE_IOERR_ROLLBACK_ATOMIC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_ROLLBACK_ATOMIC),
896
- /* harmony export */ SQLITE_IOERR_SEEK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_SEEK),
897
- /* harmony export */ SQLITE_IOERR_SHORT_READ: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_SHORT_READ),
898
- /* harmony export */ SQLITE_IOERR_TRUNCATE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_TRUNCATE),
899
- /* harmony export */ SQLITE_IOERR_UNLOCK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_UNLOCK),
900
- /* harmony export */ SQLITE_IOERR_VNODE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_VNODE),
901
- /* harmony export */ SQLITE_IOERR_WRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_WRITE),
902
- /* harmony export */ SQLITE_LIMIT_ATTACHED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_ATTACHED),
903
- /* harmony export */ SQLITE_LIMIT_COLUMN: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_COLUMN),
904
- /* harmony export */ SQLITE_LIMIT_COMPOUND_SELECT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_COMPOUND_SELECT),
905
- /* harmony export */ SQLITE_LIMIT_EXPR_DEPTH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_EXPR_DEPTH),
906
- /* harmony export */ SQLITE_LIMIT_FUNCTION_ARG: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_FUNCTION_ARG),
907
- /* harmony export */ SQLITE_LIMIT_LENGTH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_LENGTH),
908
- /* harmony export */ SQLITE_LIMIT_LIKE_PATTERN_LENGTH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_LIKE_PATTERN_LENGTH),
909
- /* harmony export */ SQLITE_LIMIT_SQL_LENGTH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_SQL_LENGTH),
910
- /* harmony export */ SQLITE_LIMIT_TRIGGER_DEPTH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_TRIGGER_DEPTH),
911
- /* harmony export */ SQLITE_LIMIT_VARIABLE_NUMBER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_VARIABLE_NUMBER),
912
- /* harmony export */ SQLITE_LIMIT_VDBE_OP: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_VDBE_OP),
913
- /* harmony export */ SQLITE_LIMIT_WORKER_THREADS: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_WORKER_THREADS),
914
- /* harmony export */ SQLITE_LOCKED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCKED),
915
- /* harmony export */ SQLITE_LOCK_EXCLUSIVE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_EXCLUSIVE),
916
- /* harmony export */ SQLITE_LOCK_NONE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_NONE),
917
- /* harmony export */ SQLITE_LOCK_PENDING: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_PENDING),
918
- /* harmony export */ SQLITE_LOCK_RESERVED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_RESERVED),
919
- /* harmony export */ SQLITE_LOCK_SHARED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_SHARED),
920
- /* harmony export */ SQLITE_MISMATCH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_MISMATCH),
921
- /* harmony export */ SQLITE_MISUSE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_MISUSE),
922
- /* harmony export */ SQLITE_NOLFS: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOLFS),
923
- /* harmony export */ SQLITE_NOMEM: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOMEM),
924
- /* harmony export */ SQLITE_NOTADB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOTADB),
925
- /* harmony export */ SQLITE_NOTFOUND: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOTFOUND),
926
- /* harmony export */ SQLITE_NOTICE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOTICE),
927
- /* harmony export */ SQLITE_NULL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NULL),
928
- /* harmony export */ SQLITE_OK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK),
929
- /* harmony export */ SQLITE_OPEN_AUTOPROXY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_AUTOPROXY),
930
- /* harmony export */ SQLITE_OPEN_CREATE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_CREATE),
931
- /* harmony export */ SQLITE_OPEN_DELETEONCLOSE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_DELETEONCLOSE),
932
- /* harmony export */ SQLITE_OPEN_EXCLUSIVE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_EXCLUSIVE),
933
- /* harmony export */ SQLITE_OPEN_FULLMUTEX: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_FULLMUTEX),
934
- /* harmony export */ SQLITE_OPEN_MAIN_DB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_MAIN_DB),
935
- /* harmony export */ SQLITE_OPEN_MAIN_JOURNAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_MAIN_JOURNAL),
936
- /* harmony export */ SQLITE_OPEN_MEMORY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_MEMORY),
937
- /* harmony export */ SQLITE_OPEN_NOFOLLOW: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_NOFOLLOW),
938
- /* harmony export */ SQLITE_OPEN_NOMUTEX: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_NOMUTEX),
939
- /* harmony export */ SQLITE_OPEN_PRIVATECACHE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_PRIVATECACHE),
940
- /* harmony export */ SQLITE_OPEN_READONLY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_READONLY),
941
- /* harmony export */ SQLITE_OPEN_READWRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_READWRITE),
942
- /* harmony export */ SQLITE_OPEN_SHAREDCACHE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_SHAREDCACHE),
943
- /* harmony export */ SQLITE_OPEN_SUBJOURNAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_SUBJOURNAL),
944
- /* harmony export */ SQLITE_OPEN_SUPER_JOURNAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_SUPER_JOURNAL),
945
- /* harmony export */ SQLITE_OPEN_TEMP_DB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_TEMP_DB),
946
- /* harmony export */ SQLITE_OPEN_TEMP_JOURNAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_TEMP_JOURNAL),
947
- /* harmony export */ SQLITE_OPEN_TRANSIENT_DB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_TRANSIENT_DB),
948
- /* harmony export */ SQLITE_OPEN_URI: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_URI),
949
- /* harmony export */ SQLITE_OPEN_WAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_WAL),
950
- /* harmony export */ SQLITE_PERM: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_PERM),
951
- /* harmony export */ SQLITE_PRAGMA: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_PRAGMA),
952
- /* harmony export */ SQLITE_PREPARE_NORMALIZED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_PREPARE_NORMALIZED),
953
- /* harmony export */ SQLITE_PREPARE_NO_VTAB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_PREPARE_NO_VTAB),
954
- /* harmony export */ SQLITE_PREPARE_PERSISTENT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_PREPARE_PERSISTENT),
955
- /* harmony export */ SQLITE_PROTOCOL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_PROTOCOL),
956
- /* harmony export */ SQLITE_RANGE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_RANGE),
957
- /* harmony export */ SQLITE_READ: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_READ),
958
- /* harmony export */ SQLITE_READONLY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_READONLY),
959
- /* harmony export */ SQLITE_RECURSIVE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_RECURSIVE),
960
- /* harmony export */ SQLITE_REINDEX: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_REINDEX),
961
- /* harmony export */ SQLITE_ROW: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ROW),
962
- /* harmony export */ SQLITE_SAVEPOINT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_SAVEPOINT),
963
- /* harmony export */ SQLITE_SCHEMA: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_SCHEMA),
964
- /* harmony export */ SQLITE_SELECT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_SELECT),
965
- /* harmony export */ SQLITE_STATIC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_STATIC),
966
- /* harmony export */ SQLITE_SUBTYPE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_SUBTYPE),
967
- /* harmony export */ SQLITE_SYNC_DATAONLY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_SYNC_DATAONLY),
968
- /* harmony export */ SQLITE_SYNC_FULL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_SYNC_FULL),
969
- /* harmony export */ SQLITE_SYNC_NORMAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_SYNC_NORMAL),
970
- /* harmony export */ SQLITE_TEXT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_TEXT),
971
- /* harmony export */ SQLITE_TOOBIG: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_TOOBIG),
972
- /* harmony export */ SQLITE_TRANSACTION: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_TRANSACTION),
973
- /* harmony export */ SQLITE_TRANSIENT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_TRANSIENT),
974
- /* harmony export */ SQLITE_UPDATE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_UPDATE),
975
- /* harmony export */ SQLITE_UTF16: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_UTF16),
976
- /* harmony export */ SQLITE_UTF16BE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_UTF16BE),
977
- /* harmony export */ SQLITE_UTF16LE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_UTF16LE),
978
- /* harmony export */ SQLITE_UTF8: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_UTF8),
979
- /* harmony export */ SQLITE_WARNING: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_WARNING)
980
- /* harmony export */ });
981
- /* harmony import */ var _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sqlite-constants.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js");
982
- // Copyright 2024 Roy T. Hashimoto. All Rights Reserved.
983
-
984
-
985
-
986
- const DEFAULT_SECTOR_SIZE = 512;
987
-
988
- // Base class for a VFS.
989
- class Base {
990
- name;
991
- mxPathname = 64;
992
- _module;
993
-
994
- /**
995
- * @param {string} name
996
- * @param {object} module
997
- */
998
- constructor(name, module) {
999
- this.name = name;
1000
- this._module = module;
1001
- }
1002
-
1003
- /**
1004
- * @returns {void|Promise<void>}
1005
- */
1006
- close() {
1007
- }
1008
-
1009
- /**
1010
- * @returns {boolean|Promise<boolean>}
1011
- */
1012
- isReady() {
1013
- return true;
1014
- }
1015
-
1016
- /**
1017
- * Overload in subclasses to indicate which methods are asynchronous.
1018
- * @param {string} methodName
1019
- * @returns {boolean}
1020
- */
1021
- hasAsyncMethod(methodName) {
1022
- return false;
1023
- }
1024
-
1025
- /**
1026
- * @param {number} pVfs
1027
- * @param {number} zName
1028
- * @param {number} pFile
1029
- * @param {number} flags
1030
- * @param {number} pOutFlags
1031
- * @returns {number|Promise<number>}
1032
- */
1033
- xOpen(pVfs, zName, pFile, flags, pOutFlags) {
1034
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CANTOPEN;
1035
- }
1036
-
1037
- /**
1038
- * @param {number} pVfs
1039
- * @param {number} zName
1040
- * @param {number} syncDir
1041
- * @returns {number|Promise<number>}
1042
- */
1043
- xDelete(pVfs, zName, syncDir) {
1044
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1045
- }
1046
-
1047
- /**
1048
- * @param {number} pVfs
1049
- * @param {number} zName
1050
- * @param {number} flags
1051
- * @param {number} pResOut
1052
- * @returns {number|Promise<number>}
1053
- */
1054
- xAccess(pVfs, zName, flags, pResOut) {
1055
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1056
- }
1057
-
1058
- /**
1059
- * @param {number} pVfs
1060
- * @param {number} zName
1061
- * @param {number} nOut
1062
- * @param {number} zOut
1063
- * @returns {number|Promise<number>}
1064
- */
1065
- xFullPathname(pVfs, zName, nOut, zOut) {
1066
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1067
- }
1068
-
1069
- /**
1070
- * @param {number} pVfs
1071
- * @param {number} nBuf
1072
- * @param {number} zBuf
1073
- * @returns {number|Promise<number>}
1074
- */
1075
- xGetLastError(pVfs, nBuf, zBuf) {
1076
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1077
- }
1078
-
1079
- /**
1080
- * @param {number} pFile
1081
- * @returns {number|Promise<number>}
1082
- */
1083
- xClose(pFile) {
1084
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1085
- }
1086
-
1087
- /**
1088
- * @param {number} pFile
1089
- * @param {number} pData
1090
- * @param {number} iAmt
1091
- * @param {number} iOffsetLo
1092
- * @param {number} iOffsetHi
1093
- * @returns {number|Promise<number>}
1094
- */
1095
- xRead(pFile, pData, iAmt, iOffsetLo, iOffsetHi) {
1096
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1097
- }
1098
-
1099
- /**
1100
- * @param {number} pFile
1101
- * @param {number} pData
1102
- * @param {number} iAmt
1103
- * @param {number} iOffsetLo
1104
- * @param {number} iOffsetHi
1105
- * @returns {number|Promise<number>}
1106
- */
1107
- xWrite(pFile, pData, iAmt, iOffsetLo, iOffsetHi) {
1108
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1109
- }
1110
-
1111
- /**
1112
- * @param {number} pFile
1113
- * @param {number} sizeLo
1114
- * @param {number} sizeHi
1115
- * @returns {number|Promise<number>}
1116
- */
1117
- xTruncate(pFile, sizeLo, sizeHi) {
1118
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1119
- }
1120
-
1121
- /**
1122
- * @param {number} pFile
1123
- * @param {number} flags
1124
- * @returns {number|Promise<number>}
1125
- */
1126
- xSync(pFile, flags) {
1127
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1128
- }
1129
-
1130
- /**
1131
- *
1132
- * @param {number} pFile
1133
- * @param {number} pSize
1134
- * @returns {number|Promise<number>}
1135
- */
1136
- xFileSize(pFile, pSize) {
1137
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1138
- }
1139
-
1140
- /**
1141
- * @param {number} pFile
1142
- * @param {number} lockType
1143
- * @returns {number|Promise<number>}
1144
- */
1145
- xLock(pFile, lockType) {
1146
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1147
- }
1148
-
1149
- /**
1150
- * @param {number} pFile
1151
- * @param {number} lockType
1152
- * @returns {number|Promise<number>}
1153
- */
1154
- xUnlock(pFile, lockType) {
1155
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1156
- }
1157
-
1158
- /**
1159
- * @param {number} pFile
1160
- * @param {number} pResOut
1161
- * @returns {number|Promise<number>}
1162
- */
1163
- xCheckReservedLock(pFile, pResOut) {
1164
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1165
- }
1166
-
1167
- /**
1168
- * @param {number} pFile
1169
- * @param {number} op
1170
- * @param {number} pArg
1171
- * @returns {number|Promise<number>}
1172
- */
1173
- xFileControl(pFile, op, pArg) {
1174
- return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOTFOUND;
1175
- }
1176
-
1177
- /**
1178
- * @param {number} pFile
1179
- * @returns {number|Promise<number>}
1180
- */
1181
- xSectorSize(pFile) {
1182
- return DEFAULT_SECTOR_SIZE;
1183
- }
1184
-
1185
- /**
1186
- * @param {number} pFile
1187
- * @returns {number|Promise<number>}
1188
- */
1189
- xDeviceCharacteristics(pFile) {
1190
- return 0;
1191
- }
1192
- }
1193
-
1194
- const FILE_TYPE_MASK = [
1195
- _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_MAIN_DB,
1196
- _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_MAIN_JOURNAL,
1197
- _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_TEMP_DB,
1198
- _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_TEMP_JOURNAL,
1199
- _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_TRANSIENT_DB,
1200
- _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_SUBJOURNAL,
1201
- _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_SUPER_JOURNAL,
1202
- _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_WAL
1203
- ].reduce((mask, element) => mask | element);
1204
-
1205
- /***/ },
1206
-
1207
- /***/ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/LazyLock.js"
1208
- /*!*********************************************************************************************************************************************!*\
1209
- !*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/LazyLock.js ***!
1210
- \*********************************************************************************************************************************************/
1211
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1212
-
1213
- __webpack_require__.r(__webpack_exports__);
1214
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1215
- /* harmony export */ LazyLock: () => (/* binding */ LazyLock)
1216
- /* harmony export */ });
1217
- /* harmony import */ var _Lock_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Lock.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/Lock.js");
1218
-
1219
-
1220
- class LazyLock extends _Lock_js__WEBPACK_IMPORTED_MODULE_0__.Lock {
1221
- #channel;
1222
- #isBusy = false;
1223
- #hasReleaseRequest = false;
1224
-
1225
- /**
1226
- * @param {string} name
1227
- */
1228
- constructor(name) {
1229
- super(name);
1230
- this.#channel = new BroadcastChannel(name);
1231
- this.#channel.onmessage = (event) => {
1232
- if (this.#isBusy) {
1233
- // We're using the lock so postpone the release.
1234
- this.#hasReleaseRequest = true;
1235
- } else {
1236
- this.release();
1237
- }
1238
- }
1239
- }
1240
-
1241
- close() {
1242
- super.close();
1243
- this.#channel.onmessage = null;
1244
- this.#channel.close();
1245
- }
1246
-
1247
- /**
1248
- * @param {LockMode} mode
1249
- * @param {number} timeout
1250
- * @returns {Promise<boolean>}
1251
- */
1252
- async acquire(mode, timeout = -1) {
1253
- this.#isBusy = true;
1254
- try {
1255
- if (mode === this.mode) {
1256
- // We never had to release the lock.
1257
- return true;
1258
- }
1259
-
1260
- if (this.mode) {
1261
- // Release the lock to acquire it in a different mode.
1262
- super.release();
1263
- } else {
1264
- // Poll for the lock. This isn't necessary but if it works it avoids
1265
- // the BroadcastChannel traffic.
1266
- if (await super.acquire(mode, 0)) {
1267
- return true;
1268
- }
1269
- }
1270
-
1271
- // Request the lock.
1272
- const pResult = super.acquire(mode, timeout)
1273
- this.#channel.postMessage({});
1274
-
1275
- return await pResult;
1276
- } catch (e) {
1277
- this.release();
1278
- throw e;
1279
- }
1280
- }
1281
-
1282
- /**
1283
- * @param {LockMode} mode
1284
- * @returns {boolean}
1285
- */
1286
- acquireIfHeld(mode) {
1287
- if (mode === this.mode) {
1288
- this.#isBusy = true;
1289
- return true;
1290
- }
1291
- return false;
1292
- }
1293
-
1294
- release() {
1295
- super.release();
1296
- this.#isBusy = false;
1297
- this.#hasReleaseRequest = false;
1298
- }
1299
-
1300
- releaseLazy() {
1301
- // Release the lock only if someone else wants it.
1302
- this.#isBusy = false;
1303
- if (this.#hasReleaseRequest) {
1304
- this.release();
1305
- }
1306
- }
1307
- }
1308
-
1309
- /***/ },
1310
-
1311
- /***/ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/Lock.js"
1312
- /*!*****************************************************************************************************************************************!*\
1313
- !*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/Lock.js ***!
1314
- \*****************************************************************************************************************************************/
1315
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1316
-
1317
- __webpack_require__.r(__webpack_exports__);
1318
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1319
- /* harmony export */ Lock: () => (/* binding */ Lock)
1320
- /* harmony export */ });
1321
- // This is a convenience wrapper for the Web Locks API.
1322
- class Lock {
1323
- #name;
1324
- /** @type {LockMode?} */ #mode = null;
1325
- #releaser = null;
1326
-
1327
- /**
1328
- * @param {string} name
1329
- */
1330
- constructor(name) {
1331
- this.#name = name;
1332
- }
1333
-
1334
- get name() { return this.#name; }
1335
- get mode() { return this.#mode; }
1336
-
1337
- close() {
1338
- this.release();
1339
- }
1340
-
1341
- /**
1342
- * @param {'shared'|'exclusive'} mode
1343
- * @param {number} timeout -1 for infinite, 0 for poll, >0 for milliseconds
1344
- * @return {Promise<boolean>} true if lock acquired, false on failed poll
1345
- */
1346
- async acquire(mode, timeout = -1) {
1347
- if (this.#releaser) {
1348
- throw new Error(`Lock ${this.#name} is already acquired`);
1349
- }
1350
- return new Promise((resolve, reject) => {
1351
- /** @type {LockOptions} */
1352
- const options = { mode, ifAvailable: timeout === 0 };
1353
- let timeoutId;
1354
- if (timeout > 0) {
1355
- const abortController = new AbortController();
1356
- timeoutId = self.setTimeout(() => {
1357
- abortController.abort();
1358
- }, timeout);
1359
- options.signal = abortController.signal;
1360
- }
1361
-
1362
- navigator.locks.request(this.#name, options, lock => {
1363
- if (timeoutId) clearTimeout(timeoutId);
1364
- if (lock === null) {
1365
- // Polling (with timeout = 0) did not acquire the lock.
1366
- return resolve(false);
1367
- }
1368
-
1369
- // Lock acquired. The lock is released when this returned
1370
- // Promise is resolved.
1371
- this.#mode = mode;
1372
- return new Promise(releaser => {
1373
- this.#releaser = releaser;
1374
- resolve(true);
1375
- })
1376
- }).catch(e => {
1377
- return reject(e);
1378
- });
1379
- });
1380
- }
1381
-
1382
- release() {
1383
- this.#releaser?.();
1384
- this.#releaser = null;
1385
- this.#mode = null;
1386
- }
1387
- }
1388
-
1389
-
1390
- /***/ },
1391
-
1392
- /***/ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/OPFSWriteAheadVFS.js"
1393
- /*!******************************************************************************************************************************************************!*\
1394
- !*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/OPFSWriteAheadVFS.js ***!
1395
- \******************************************************************************************************************************************************/
1396
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1397
-
1398
- __webpack_require__.r(__webpack_exports__);
1399
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1400
- /* harmony export */ OPFSWriteAheadVFS: () => (/* binding */ OPFSWriteAheadVFS)
1401
- /* harmony export */ });
1402
- /* harmony import */ var _FacadeVFS_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../FacadeVFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/FacadeVFS.js");
1403
- /* harmony import */ var _VFS_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../VFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/VFS.js");
1404
- /* harmony import */ var _LazyLock_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./LazyLock.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/LazyLock.js");
1405
- /* harmony import */ var _WriteAhead_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./WriteAhead.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/WriteAhead.js");
1406
-
1407
-
1408
-
1409
-
1410
-
1411
- const LIBRARY_FILES_ROOT = '.wa-sqlite';
1412
- const DEFAULT_TEMP_FILES = 6;
1413
-
1414
- const finalizationRegistry = new FinalizationRegistry((/** @type {() => void} */ f) => f());
1415
-
1416
- /**
1417
- * @typedef FileEntry
1418
- * @property {string} zName
1419
- * @property {number} flags
1420
- * @property {FileSystemSyncAccessHandle} [accessHandle]
1421
-
1422
- * Main database file properties:
1423
- * @property {*} [retryResult]
1424
- * @property {FileSystemSyncAccessHandle} [waHandle]
1425
- * @property {FileSystemSyncAccessHandle} [journalHandle]
1426
- *
1427
- * @property {boolean} [useWriteAhead]
1428
- * @property {'reserved'|'exclusive'} [writeHint]
1429
- * @property {'normal'|'exclusive'|null} [lockingMode]
1430
- * @property {number} [lockState] SQLITE_LOCK_*
1431
- * @property {LazyLock} [readLock]
1432
- * @property {LazyLock} [writeLock]
1433
- * @property {'none'|'read'|'write'|'readwrite'} [useLazyLock]
1434
- * @property {number} [timeout]
1435
- * @property {0|1|2|3} [synchronous]
1436
- *
1437
- * @property {WriteAhead} [writeAhead]
1438
- */
1439
-
1440
- /**
1441
- * @typedef OPFSWriteAheadOptions
1442
- * @property {number} [nTmpFiles]
1443
- * @property {number} [autoCheckpointPages]
1444
- * @property {number} [heartbeatInterval]
1445
- * @property {number} [heartbeatActionDelay]
1446
- */
1447
-
1448
- class OPFSWriteAheadVFS extends _FacadeVFS_js__WEBPACK_IMPORTED_MODULE_0__.FacadeVFS {
1449
- lastError = null;
1450
- log = null;
1451
-
1452
- /** @type {Map<number, FileEntry>} */ mapIdToFile = new Map();
1453
- /** @type {Map<string, FileEntry>} */ mapPathToFile = new Map();
1454
-
1455
- /** @type {Map<string, FileSystemSyncAccessHandle>} */ boundTempFiles = new Map();
1456
- /** @type {Set<FileSystemSyncAccessHandle>} */ unboundTempFiles = new Set();
1457
- /** @type {OPFSWriteAheadOptions} */ options = {
1458
- nTmpFiles: DEFAULT_TEMP_FILES
1459
- };
1460
-
1461
- _ready;
1462
-
1463
- static async create(name, module, options) {
1464
- const vfs = new OPFSWriteAheadVFS(name, module);
1465
- Object.assign(vfs.options, options);
1466
- await vfs.isReady();
1467
- return vfs;
1468
- }
1469
-
1470
- constructor(name, module) {
1471
- super(name, module);
1472
- this._ready = (async () => {
1473
- // Ensure the library files root directory exists.
1474
- let dirHandle = await navigator.storage.getDirectory();
1475
- dirHandle = await dirHandle.getDirectoryHandle(LIBRARY_FILES_ROOT, { create: true });
1476
-
1477
- // Clean up any stale session directories.
1478
- // @ts-ignore
1479
- for await (const name of dirHandle.keys()) {
1480
- if (name.startsWith('.session-')) {
1481
- // Acquire a lock on the session directory to ensure it is not in use.
1482
- await navigator.locks.request(name, { ifAvailable: true }, async lock => {
1483
- if (lock) {
1484
- // This directory is not in use.
1485
- try {
1486
- await dirHandle.removeEntry(name, { recursive: true });
1487
- } catch (e) {
1488
- // Ignore errors, will try again next time.
1489
- }
1490
- }
1491
- });
1492
- }
1493
- }
1494
-
1495
- // Create our session directory.
1496
- const dirName = `.session-${Math.random().toString(16).slice(2)}`;
1497
- await new Promise(resolve => {
1498
- navigator.locks.request(dirName, () => {
1499
- // @ts-ignore
1500
- resolve();
1501
- return new Promise(release => {
1502
- // @ts-ignore
1503
- finalizationRegistry.register(this, release);
1504
- });
1505
- });
1506
- });
1507
- dirHandle = await dirHandle.getDirectoryHandle(dirName, { create: true });
1508
-
1509
- // Create temporary files.
1510
- for (let i = 0; i < this.options.nTmpFiles; i++) {
1511
- const fileHandle= await dirHandle.getFileHandle(i.toString(), { create: true });
1512
- const accessHandle = await fileHandle.createSyncAccessHandle();
1513
- finalizationRegistry.register(this, () => accessHandle.close());
1514
- this.unboundTempFiles.add(accessHandle);
1515
- }
1516
- })();
1517
- }
1518
-
1519
- isReady() {
1520
- return Promise.all([super.isReady(), this._ready]).then(() => true);
1521
- }
1522
-
1523
- /**
1524
- * @param {string?} zName
1525
- * @param {number} fileId
1526
- * @param {number} flags
1527
- * @param {DataView} pOutFlags
1528
- * @returns {number}
1529
- */
1530
- jOpen(zName, fileId, flags, pOutFlags) {
1531
- try {
1532
- if (zName === null) {
1533
- // Generate a temporary filename. This will only be used as a
1534
- // key to map to a pre-opened temporary file access handle.
1535
- zName = Math.random().toString(16).slice(2);
1536
- }
1537
-
1538
- const file = this.mapPathToFile.get(zName) ?? {
1539
- zName,
1540
- flags,
1541
- retryResult: null,
1542
- };
1543
- this.mapPathToFile.set(zName, file);
1544
-
1545
- if (flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB) {
1546
- // Open database and journal files with a retry operation.
1547
- if (file.retryResult === null) {
1548
- // This is the initial open attempt. Start the asynchronous task
1549
- // and return SQLITE_BUSY to force a retry.
1550
- this._module.retryOps.push(this.#retryOpen(zName, flags, fileId, pOutFlags));
1551
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_BUSY;
1552
- } else if (file.retryResult instanceof Error) {
1553
- throw file.retryResult;
1554
- }
1555
-
1556
- // Initialize database file state.
1557
- file.accessHandle = file.retryResult.accessHandle;
1558
- file.journalHandle = file.retryResult.journalHandle;
1559
- file.waHandle = file.retryResult.waHandle;
1560
- file.writeAhead = file.retryResult.writeAhead;
1561
- file.retryResult = null;
1562
-
1563
- file.lockState = _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_LOCK_NONE;
1564
- file.lockingMode = null;
1565
- file.readLock = new _LazyLock_js__WEBPACK_IMPORTED_MODULE_2__.LazyLock(`${zName}#read`);
1566
- file.writeLock = new _LazyLock_js__WEBPACK_IMPORTED_MODULE_2__.LazyLock(`${zName}#write`);
1567
- file.useLazyLock = 'readwrite';
1568
- file.timeout = -1;
1569
- file.synchronous = 1; // NORMAL
1570
- file.useWriteAhead = true;
1571
- file.writeHint = null;
1572
- } else if (flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_JOURNAL) {
1573
- // A journal file is managed with its main database so look that up.
1574
- const dbFile = this.#getDbFileFromJournalName(zName);
1575
- if (!dbFile) {
1576
- throw new Error(`database file not found for journal ${zName}`);
1577
- }
1578
-
1579
- // Determine whether to use the public journal (which is hot or
1580
- // could become hot) or a private journal from the session directory.
1581
- // This is necessary because read connections can test a journal
1582
- // for hotness while a write-ahead transaction is in progress.
1583
- if (!dbFile.useWriteAhead || dbFile.journalHandle.getSize() > 0) {
1584
- // Either write-ahead is not being used, or a hot journal is being
1585
- // opened for recovery. Use the public journal.
1586
- file.accessHandle = dbFile.journalHandle;
1587
- } else if (dbFile.useWriteAhead && dbFile.lockState > _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_LOCK_SHARED) {
1588
- // The journal is being opened for a write-ahead transaction.
1589
- // This journal can never be hot so don't expose it to other
1590
- // connections.
1591
- file.accessHandle = this.#openTemporaryFile(zName);
1592
- } else {
1593
- throw new Error('unexpected journal file conditions');
1594
- }
1595
- } else if (flags & (_VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_WAL | _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_SUPER_JOURNAL)) {
1596
- throw new Error('WAL and super-journal files are not supported');
1597
- } else {
1598
- // This is a temporary file. Use an unbound pre-opened accessHandle.
1599
- file.accessHandle = this.#openTemporaryFile(zName);
1600
- }
1601
-
1602
- this.mapIdToFile.set(fileId, file);
1603
- pOutFlags.setInt32(0, flags, true);
1604
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1605
- } catch (e) {
1606
- console.error(e.stack);
1607
- this.lastError = e;
1608
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_CANTOPEN;
1609
- }
1610
- }
1611
-
1612
- /**
1613
- * @param {string} zName
1614
- * @param {number} syncDir
1615
- * @returns {number}
1616
- */
1617
- jDelete(zName, syncDir) {
1618
- try {
1619
- if (this.boundTempFiles.has(zName)) {
1620
- const file = this.mapPathToFile.get(zName);
1621
- this.#deleteTemporaryFile(file);
1622
- } else if (zName.endsWith('-journal')) {
1623
- const dbFile = this.#getDbFileFromJournalName(zName);
1624
- dbFile?.journalHandle.truncate(0);
1625
- dbFile?.journalHandle.flush();
1626
- this.mapPathToFile.delete(zName);
1627
- } else {
1628
- throw new Error(`unexpected file deletion: ${zName}`);
1629
- }
1630
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1631
- } catch (e) {
1632
- console.error(e.stack);
1633
- this.lastError = e;
1634
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_DELETE;
1635
- }
1636
- }
1637
-
1638
- /**
1639
- * @param {string} zName
1640
- * @param {number} flags
1641
- * @param {DataView} pResOut
1642
- * @returns {number}
1643
- */
1644
- jAccess(zName, flags, pResOut) {
1645
- try {
1646
- // Special case main journal files.
1647
- if (zName.endsWith('-journal')) {
1648
- const dbFile = this.#getDbFileFromJournalName(zName);
1649
- if (dbFile) {
1650
- if (dbFile.lockState <= _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_LOCK_SHARED) {
1651
- // SQLite is testing for a hot journal. Journals created in the
1652
- // session directory for write-ahead transactions are never hot,
1653
- // i.e. they are used only for rollback. So here we look for
1654
- // the status of the public journal.
1655
- if (dbFile.journalHandle.getSize() === 0) {
1656
- // Treat an empty journal file as non-existent.
1657
- pResOut.setInt32(0, 0, true);
1658
- } else {
1659
- pResOut.setInt32(0, 1, true);
1660
- }
1661
- }
1662
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1663
- }
1664
- }
1665
-
1666
- const file = this.mapPathToFile.get(zName);
1667
- pResOut.setInt32(0, file ? 1 : 0, true);
1668
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1669
- } catch (e) {
1670
- console.error(e.stack);
1671
- this.lastError = e;
1672
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_ACCESS;
1673
- }
1674
- }
1675
-
1676
- /**
1677
- * @param {number} fileId
1678
- * @returns {number}
1679
- */
1680
- jClose(fileId) {
1681
- try {
1682
- const file = this.mapIdToFile.get(fileId);
1683
- if (file?.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB) {
1684
- file.writeAhead.close();
1685
- file.accessHandle.close();
1686
- file.waHandle.close();
1687
- this.mapPathToFile.delete(file?.zName);
1688
-
1689
- file.journalHandle.close();
1690
- const journalPath = this.#getJournalNameFromDbName(file.zName);
1691
- this.mapPathToFile.delete(journalPath);
1692
-
1693
- file.readLock.close();
1694
- file.writeLock.close();
1695
- } else if (file?.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_JOURNAL) {
1696
- // The actual OPFS journal file is managed with the main database
1697
- // file, so don't close the access handle here.
1698
- } else if (file?.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_DELETEONCLOSE) {
1699
- this.#deleteTemporaryFile(file);
1700
- }
1701
-
1702
- // Disassociate fileId from file entry.
1703
- this.mapIdToFile.delete(fileId);
1704
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1705
- } catch (e) {
1706
- console.error(e.stack);
1707
- this.lastError = e;
1708
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_CLOSE;
1709
- }
1710
- }
1711
-
1712
- /**
1713
- * @param {number} fileId
1714
- * @param {Uint8Array} pData
1715
- * @param {number} iOffset
1716
- * @returns {number}
1717
- */
1718
- jRead(fileId, pData, iOffset) {
1719
- try {
1720
- const file = this.mapIdToFile.get(fileId);
1721
-
1722
- let bytesRead = null;
1723
- if (file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB) {
1724
- // Try reading from the write-ahead overlays first. A read on the
1725
- // database file is always a complete page, except when reading
1726
- // from the 100-byte header.
1727
- const pageOffset = iOffset < 100 ? iOffset : 0;
1728
- const page = file.writeAhead.read(iOffset - pageOffset);
1729
- if (page) {
1730
- const readData = page.subarray(pageOffset, pageOffset + pData.byteLength);
1731
- pData.set(readData);
1732
- bytesRead = readData.byteLength;
1733
- }
1734
- }
1735
-
1736
- if (bytesRead === null) {
1737
- // Read directly from the OPFS file.
1738
-
1739
- // On Chrome (at least), passing pData to accessHandle.read() is
1740
- // an error because pData is a Proxy of a Uint8Array. Calling
1741
- // subarray() produces a real Uint8Array and that works.
1742
- bytesRead = file.accessHandle.read(pData.subarray(), { at: iOffset });
1743
- }
1744
-
1745
- if (bytesRead < pData.byteLength) {
1746
- pData.fill(0, bytesRead);
1747
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_SHORT_READ;
1748
- }
1749
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1750
- } catch (e) {
1751
- console.error(e.stack);
1752
- this.lastError = e;
1753
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_READ;
1754
- }
1755
- }
1756
-
1757
- /**
1758
- * @param {number} fileId
1759
- * @param {Uint8Array} pData
1760
- * @param {number} iOffset
1761
- * @returns {number}
1762
- */
1763
- jWrite(fileId, pData, iOffset) {
1764
- try {
1765
- const file = this.mapIdToFile.get(fileId);
1766
- if (file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB) {
1767
- if (file.useWriteAhead) {
1768
- // Write to the write-ahead overlay.
1769
- file.writeAhead.write(iOffset, pData);
1770
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1771
- }
1772
- }
1773
-
1774
- // On Chrome (at least), passing pData to accessHandle.write() is
1775
- // an error because pData is a Proxy of a Uint8Array. Calling
1776
- // subarray() produces a real Uint8Array and that works.
1777
- file.accessHandle.write(pData.subarray(), { at: iOffset });
1778
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1779
- } catch (e) {
1780
- console.error(e.stack);
1781
- this.lastError = e;
1782
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_WRITE;
1783
- }
1784
- }
1785
-
1786
- /**
1787
- * @param {number} fileId
1788
- * @param {number} iSize
1789
- * @returns {number}
1790
- */
1791
- jTruncate(fileId, iSize) {
1792
- try {
1793
- const file = this.mapIdToFile.get(fileId);
1794
- if (file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB) {
1795
- if (file.useWriteAhead) {
1796
- file.writeAhead.truncate(iSize);
1797
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1798
- }
1799
- }
1800
- file.accessHandle.truncate(iSize);
1801
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1802
- } catch (e) {
1803
- console.error(e.stack);
1804
- this.lastError = e;
1805
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_TRUNCATE;
1806
- }
1807
- }
1808
-
1809
- /**
1810
- * @param {number} fileId
1811
- * @param {number} flags
1812
- * @returns {number}
1813
- */
1814
- jSync(fileId, flags) {
1815
- try {
1816
- const file = this.mapIdToFile.get(fileId);
1817
- if (file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB) {
1818
- if (file.useWriteAhead) {
1819
- const durability = file.synchronous > 1 ? 'strict' : 'relaxed';
1820
- file.writeAhead.sync({ durability });
1821
- } else {
1822
- file.accessHandle.flush();
1823
- }
1824
- } else if (!this.boundTempFiles.has(file.zName)) {
1825
- // Persistent journal file requires sync.
1826
- file.accessHandle.flush();
1827
- } else {
1828
- // This is a temporary file so sync is not needed.
1829
- // Temporary journals are only used for rollback by the
1830
- // connection that created them, not for recovery.
1831
- }
1832
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1833
- } catch (e) {
1834
- console.error(e.stack);
1835
- this.lastError = e;
1836
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_FSYNC;
1837
- }
1838
- }
1839
-
1840
- /**
1841
- * @param {number} fileId
1842
- * @param {DataView} pSize64
1843
- * @returns {number}
1844
- */
1845
- jFileSize(fileId, pSize64) {
1846
- try {
1847
- const file = this.mapIdToFile.get(fileId);
1848
-
1849
- let size;
1850
- if (file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB) {
1851
- size = file.writeAhead.getFileSize() || file.accessHandle.getSize();
1852
- } else {
1853
- size = file.accessHandle.getSize();
1854
- }
1855
- pSize64.setBigInt64(0, BigInt(size), true);
1856
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1857
- } catch (e) {
1858
- console.error(e.stack);
1859
- this.lastError = e;
1860
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_FSTAT;
1861
- }
1862
- }
1863
-
1864
- /**
1865
- * @param {number} pFile
1866
- * @param {number} lockType
1867
- * @returns {number|Promise<number>}
1868
- */
1869
- jLock(pFile, lockType) {
1870
- try {
1871
- const file = this.mapIdToFile.get(pFile);
1872
- if (file.lockState === _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_LOCK_NONE && lockType === _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_LOCK_SHARED) {
1873
- // We do all our locking work in this transition.
1874
- if (file.retryResult === null) {
1875
- if (file.lockingMode === 'exclusive') {
1876
- // SQLite exclusive locking mode really means that no unlocking
1877
- // is done, not that the locking state is immediately EXCLUSIVE.
1878
- // This is a problem if the first transaction after setting
1879
- // exclusive locking mode does not come with a write hint, so
1880
- // we force the write hint here.
1881
- file.writeHint = 'exclusive';
1882
- file.useWriteAhead = false;
1883
- }
1884
-
1885
- // There are three distinct cases. In each case if the required
1886
- // lock is already held then we can proceed synchronously.
1887
- // Otherwise we need to acquire state asynchronously and retry.
1888
- if (!file.writeHint) {
1889
- // Case 1: Read transaction with write-ahead logging.
1890
- if (!file.readLock.acquireIfHeld('shared')) {
1891
- file.retryResult = {};
1892
- this._module.retryOps.push(this.#retryLockRead(file));
1893
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_BUSY;
1894
- } else {
1895
- file.writeAhead.isolateForRead();
1896
- }
1897
- } else {
1898
- if (file.useWriteAhead) {
1899
- // Case 2: Write transaction with write-ahead logging.
1900
- if (!file.writeLock.acquireIfHeld('exclusive')) {
1901
- file.retryResult = {};
1902
- this._module.retryOps.push(this.#retryLockWrite(file));
1903
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_BUSY;
1904
- } else {
1905
- file.writeAhead.isolateForWrite();
1906
- }
1907
- } else {
1908
- // Case 3: Transaction without write-ahead logging.
1909
- file.retryResult = {};
1910
- this._module.retryOps.push(this.#retryLockExclusive(file));
1911
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_BUSY;
1912
- }
1913
- }
1914
- } else if (file.retryResult instanceof Error) {
1915
- throw file.retryResult;
1916
- }
1917
-
1918
- // We have acquired the needed locks, either synchronously or
1919
- // via retry.
1920
- file.retryResult = null;
1921
- } else if (lockType >= _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_LOCK_RESERVED && !file.writeLock.mode) {
1922
- // This is a write transaction but we don't already have the write
1923
- // lock. This happens when the write hint was not used, which this
1924
- // VFS treats as an error.
1925
- throw new Error('Multi-statement write transaction cannot use BEGIN DEFERRED');
1926
- }
1927
- file.lockState = lockType;
1928
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1929
- } catch (e) {
1930
- if (e.name === 'AbortError') {
1931
- // Timeout expired while waiting for the lock.
1932
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_BUSY;
1933
- }
1934
-
1935
- console.error(e.stack);
1936
- this.lastError = e;
1937
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_LOCK;
1938
- }
1939
- }
1940
-
1941
- /**
1942
- * @param {number} pFile
1943
- * @param {number} lockType
1944
- * @returns {number}
1945
- */
1946
- jUnlock(pFile, lockType) {
1947
- try {
1948
- const file = this.mapIdToFile.get(pFile);
1949
-
1950
- // If retryResult is non-null, an asynchronous lock operation is in
1951
- // progress. In that case, don't change any locks.
1952
- if (!file.retryResult && lockType === _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_LOCK_NONE) {
1953
- // In this VFS, this is the only unlock transition that matters.
1954
- if (file.useWriteAhead) {
1955
- // Exit write-ahead isolation.
1956
- file.writeAhead.rejoin();
1957
- }
1958
-
1959
- // Release any locks.
1960
- switch (file.useLazyLock) {
1961
- case 'none':
1962
- file.writeLock.release();
1963
- file.readLock.release();
1964
- break;
1965
- case 'read':
1966
- file.writeLock.release();
1967
- file.readLock.releaseLazy();
1968
- break;
1969
- case 'write':
1970
- file.writeLock.releaseLazy();
1971
- file.readLock.release();
1972
- break;
1973
- case 'readwrite':
1974
- file.writeLock.releaseLazy();
1975
- file.readLock.releaseLazy();
1976
- break;
1977
- }
1978
-
1979
- // Reset state for the next transaction.
1980
- file.writeHint = null;
1981
- if (file.lockingMode === 'normal') {
1982
- file.useWriteAhead = true;
1983
- }
1984
- }
1985
- file.lockState = lockType;
1986
- } catch (e) {
1987
- console.error(e.stack);
1988
- this.lastError = e;
1989
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_UNLOCK;
1990
- }
1991
- }
1992
-
1993
- /**
1994
- * @param {number} pFile
1995
- * @param {DataView} pResOut
1996
- * @returns {number}
1997
- */
1998
- jCheckReservedLock(pFile, pResOut) {
1999
- // This function is only called in the SHARED lock state, and when
2000
- // a potentially hot journal file exists. Such a journal can only
2001
- // be created without using write-ahead, and such a connection
2002
- // cannot co-exist with this connection in SHARED.
2003
- pResOut.setInt32(0, 0, true);
2004
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
2005
- }
2006
-
2007
- /**
2008
- * @param {number} pFile
2009
- * @param {number} op
2010
- * @param {DataView} pArg
2011
- * @returns {number}
2012
- */
2013
- jFileControl(pFile, op, pArg) {
2014
- try {
2015
- const file = this.mapIdToFile.get(pFile);
2016
- switch (op) {
2017
- case _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_FCNTL_PRAGMA:
2018
- const key = this._module.UTF8ToString(pArg.getUint32(4, true));
2019
- const valueAddress = pArg.getUint32(8, true);
2020
- const value = valueAddress ? this._module.UTF8ToString(valueAddress) : null;
2021
- this.log?.(`PRAGMA ${key} ${value}`);
2022
- switch (key.toLowerCase()) {
2023
- case 'experimental_pragma_20251114':
2024
- // After entering the SHARED locking state on the next
2025
- // transaction, SQLite intends to immediately (barring a hot
2026
- // journal) transition to RESERVED if value is '1', or
2027
- // EXCLUSIVE if value is '2'.
2028
- switch (value) {
2029
- case '1':
2030
- file.writeHint = 'reserved';
2031
- break;
2032
- case '2':
2033
- file.writeHint = 'exclusive';
2034
- break;
2035
- default:
2036
- throw new Error(`unexpected write hint value: ${value}`);
2037
- }
2038
- break;
2039
- case 'busy_timeout':
2040
- // Override SQLite's handling of busy timeouts with our
2041
- // blocking lock timeouts.
2042
- if (value !== null) {
2043
- file.timeout = parseInt(value);
2044
- } else {
2045
- // Return current timeout.
2046
- const s = file.timeout.toString();
2047
- const ptr = this._module._sqlite3_malloc64(s.length + 1);
2048
- this._module.stringToUTF8(s, ptr, s.length + 1);
2049
- pArg.setUint32(0, ptr, true);
2050
- }
2051
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
2052
- case 'locking_mode':
2053
- // Track SQLite locking mode. We will use write-ahead only in
2054
- // normal locking mode.
2055
- switch (value?.toLowerCase()) {
2056
- case 'normal':
2057
- file.lockingMode = 'normal';
2058
- break;
2059
- case 'exclusive':
2060
- file.lockingMode = 'exclusive';
2061
- break;
2062
- }
2063
- break;
2064
- case 'synchronous':
2065
- if (value !== null) {
2066
- switch (value.toLowerCase()) {
2067
- case 'off':
2068
- case '0':
2069
- file.synchronous = 0;
2070
- break;
2071
- case 'normal':
2072
- case '1':
2073
- file.synchronous = 1;
2074
- break;
2075
- case 'full':
2076
- case '2':
2077
- file.synchronous = 2;
2078
- break;
2079
- case 'extra':
2080
- case '3':
2081
- file.synchronous = 3;
2082
- break;
2083
- default:
2084
- throw new Error(`unexpected synchronous value: ${value}`);
2085
- }
2086
- }
2087
- break;
2088
- case 'vfs_trace':
2089
- // This is a trace feature for debugging only.
2090
- if (value !== null) {
2091
- this.log = parseInt(value) !== 0 ? console.debug : null;
2092
- file.writeAhead.log = this.log;
2093
- }
2094
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
2095
- case 'wal_autocheckpoint':
2096
- if (value !== null) {
2097
- const nPages = parseInt(value);
2098
- file.writeAhead.options.autoCheckpointPages = Math.max(nPages, 0);
2099
- }
2100
- break;
2101
- case 'wal_checkpoint':
2102
- const checkpointMode = (value ?? 'passive').toLowerCase();
2103
- switch (checkpointMode) {
2104
- case 'passive':
2105
- case 'full':
2106
- case 'restart':
2107
- case 'truncate':
2108
- if (file.lockState !== _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_LOCK_NONE) {
2109
- throw new Error('invalid while database is locked');
2110
- }
2111
-
2112
- this._module.pendingOps.push(this.#pendingCheckpoint(file, checkpointMode));
2113
- break;
2114
- case 'noop':
2115
- break;
2116
- default:
2117
- throw new Error(`unexpected wal_checkpoint mode: ${value}`);
2118
- }
2119
-
2120
- // Return the approximate size of the write-ahead data (which
2121
- // may be smaller than the actual file size). SQLite returns
2122
- // different information, but that is not feasible from a VFS.
2123
- {
2124
- const s = file.writeAhead.getWriteAheadSize().toString();
2125
- const ptr = this._module._sqlite3_malloc64(s.length + 1);
2126
- this._module.stringToUTF8(s, ptr, s.length + 1);
2127
- pArg.setUint32(0, ptr, true);
2128
- }
2129
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
2130
- case 'lazy_lock':
2131
- if (value !== null) {
2132
- const useLazyLock = value.toLowerCase();
2133
- switch (useLazyLock) {
2134
- case 'read':
2135
- case 'write':
2136
- case 'readwrite':
2137
- case 'none':
2138
- file.useLazyLock = useLazyLock;
2139
- break;
2140
- default:
2141
- throw new Error(`unexpected value for lazy_lock: ${value}`);
2142
- }
2143
- }
2144
- {
2145
- const s = file.useLazyLock;
2146
- const ptr = this._module._sqlite3_malloc64(s.length + 1);
2147
- this._module.stringToUTF8(s, ptr, s.length + 1);
2148
- pArg.setUint32(0, ptr, true);
2149
- }
2150
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
2151
- case 'write_ahead':
2152
- // For testing purposes only: enable or disable write-ahead mode.
2153
- if (value !== null) {
2154
- if (file.lockState !== _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_LOCK_NONE) {
2155
- throw new Error('cannot change write_ahead mode while database is locked');
2156
- }
2157
- file.useWriteAhead = parseInt(value) !== 0;
2158
- } else {
2159
- const s = (file.useWriteAhead ? '1' : '0');
2160
- const ptr = this._module._sqlite3_malloc64(s.length + 1);
2161
- this._module.stringToUTF8(s, ptr, s.length + 1);
2162
- pArg.setUint32(0, ptr, true);
2163
- }
2164
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
2165
- }
2166
- break;
2167
-
2168
- // Support SQLite batch atomic write transactions.
2169
- case _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_FCNTL_BEGIN_ATOMIC_WRITE:
2170
- case _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_FCNTL_COMMIT_ATOMIC_WRITE:
2171
- if (file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB) {
2172
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
2173
- }
2174
- break;
2175
- case _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE:
2176
- if (file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB) {
2177
- file.writeAhead.rollback();
2178
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
2179
- }
2180
- break;
2181
-
2182
- case _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_FCNTL_SYNC:
2183
- if (file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB) {
2184
- if (file.useWriteAhead) {
2185
- file.writeAhead.commit();
2186
- }
2187
- }
2188
- break;
2189
- }
2190
- } catch (e) {
2191
- console.error(e.stack);
2192
- this.lastError = e;
2193
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR;
2194
- }
2195
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_NOTFOUND;
2196
- }
2197
-
2198
- /**
2199
- * @param {number} pFile
2200
- * @returns {number}
2201
- */
2202
- jDeviceCharacteristics(pFile) {
2203
- let result = _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN;
2204
-
2205
- const file = this.mapIdToFile.get(pFile);
2206
- if (file.useWriteAhead) {
2207
- // When write-ahead is in use, we can do batch atomic writes.
2208
- result |= _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOCAP_BATCH_ATOMIC;
2209
- }
2210
- return result;
2211
- }
2212
-
2213
- /**
2214
- * @param {Uint8Array} zBuf
2215
- * @returns {number}
2216
- */
2217
- jGetLastError(zBuf) {
2218
- if (this.lastError) {
2219
- console.error(this.lastError);
2220
- const outputArray = zBuf.subarray(0, zBuf.byteLength - 1);
2221
- const { written } = new TextEncoder().encodeInto(this.lastError.message, outputArray);
2222
- zBuf[written] = 0;
2223
- }
2224
- return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK
2225
- }
2226
-
2227
- /**
2228
- * @param {string} zName
2229
- * @returns {FileSystemSyncAccessHandle}
2230
- */
2231
- #openTemporaryFile(zName) {
2232
- if (this.unboundTempFiles.size === 0) {
2233
- throw new Error('no temporary files available');
2234
- }
2235
-
2236
- // Bind an access handle from the temporary pool.
2237
- const accessHandle = this.unboundTempFiles.values().next().value;
2238
- this.unboundTempFiles.delete(accessHandle);
2239
- this.boundTempFiles.set(zName, accessHandle);
2240
- return accessHandle;
2241
- }
2242
-
2243
- /**
2244
- * @param {FileEntry} file
2245
- */
2246
- #deleteTemporaryFile(file) {
2247
- file.accessHandle.truncate(0);
2248
-
2249
- // Temporary files are not actually deleted, just returned to the pool.
2250
- this.mapPathToFile.delete(file.zName);
2251
- this.unboundTempFiles.add(file.accessHandle);
2252
- this.boundTempFiles.delete(file.zName);
2253
- }
2254
-
2255
- /**
2256
- * @param {string} dbName
2257
- * @returns {string}
2258
- */
2259
- #getJournalNameFromDbName(dbName) {
2260
- return `${dbName}-journal`;
2261
- }
2262
-
2263
- #getWriteAheadNameFromDbName(dbName) {
2264
- // Our WAL file is not compatible with SQLite WAL, so use a distinct name.
2265
- return `${dbName}-waf`;
2266
- }
2267
-
2268
- /**
2269
- * @param {string} journalName
2270
- * @returns {FileEntry}
2271
- */
2272
- #getDbFileFromJournalName(journalName) {
2273
- const dbFilename = journalName.slice(0, -'-journal'.length);
2274
- return this.mapPathToFile.get(dbFilename);
2275
- }
2276
-
2277
- /**
2278
- * Asynchronous PRAGMA operation to checkpoint the write-ahead log.
2279
- * @param {FileEntry} file
2280
- * @param {'passive'|'full'|'restart'|'truncate'} mode
2281
- */
2282
- async #pendingCheckpoint(file, mode) {
2283
- try {
2284
- if (mode !== 'passive') {
2285
- await file.writeLock.acquire('exclusive');
2286
- }
2287
-
2288
- await file.writeAhead.checkpoint(mode);
2289
- } catch (e) {
2290
- if (e.name === 'AbortError') {
2291
- e.code = _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_BUSY;
2292
- }
2293
- throw e;
2294
- } finally {
2295
- file.writeLock.release();
2296
- }
2297
- }
2298
-
2299
- /**
2300
- * @param {FileEntry} file
2301
- */
2302
- async #retryLockRead(file) {
2303
- try {
2304
- await file.readLock.acquire('shared', file.timeout);
2305
- file.writeAhead.isolateForRead();
2306
- file.retryResult = {};
2307
- } catch (e) {
2308
- if (file.readLock.mode) {
2309
- file.readLock.release();
2310
- }
2311
- file.retryResult = e;
2312
- }
2313
- }
2314
-
2315
- /**
2316
- * @param {FileEntry} file
2317
- */
2318
- async #retryLockWrite(file) {
2319
- try {
2320
- // Write-ahead transactions only need writeLock, not readLock.
2321
- await file.writeLock.acquire('exclusive', file.timeout);
2322
- file.writeAhead.isolateForWrite();
2323
- file.retryResult = {};
2324
- } catch (e) {
2325
- if (file.writeLock.mode) {
2326
- file.writeLock.release();
2327
- }
2328
- file.retryResult = e;
2329
- }
2330
- }
2331
-
2332
- /**
2333
- * @param {FileEntry} file
2334
- */
2335
- async #retryLockExclusive(file) {
2336
- try {
2337
- // This transaction will write directly to the database,
2338
- // i.e. not using write-ahead. Get exclusive access.
2339
- await file.readLock.acquire('exclusive', file.timeout);
2340
- await file.writeLock.acquire('exclusive', file.timeout);
2341
-
2342
- // Transfer everything in write-ahead to the OPFS file.
2343
- await file.writeAhead.checkpoint('restart');
2344
- file.retryResult = {};
2345
- } catch (e) {
2346
- if (file.writeLock.mode) {
2347
- file.writeLock.release();
2348
- }
2349
- if (file.readLock.mode) {
2350
- file.readLock.release();
2351
- }
2352
- file.retryResult = e;
2353
- }
2354
- }
2355
-
2356
- /**
2357
- * Handle asynchronous jOpen() tasks.
2358
- * @param {string} zName
2359
- * @param {number} flags
2360
- * @param {number} fileId
2361
- * @param {DataView} pOutFlags
2362
- * @returns {Promise<void>}
2363
- */
2364
- async #retryOpen(zName, flags, fileId, pOutFlags) {
2365
- /** @type {(() => void)[]} */ const onError = [];
2366
- const file = this.mapPathToFile.get(zName);
2367
- try {
2368
- await navigator.locks.request(`${zName}#open`, async lock => {
2369
- // Parse the path components.
2370
- const directoryNames = zName.split('/').filter(d => d);
2371
- const dbName = directoryNames.pop();
2372
-
2373
- // Get the OPFS directory handle.
2374
- let dirHandle = await navigator.storage.getDirectory();
2375
- const create = !!(flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_CREATE);
2376
- for (const directoryName of directoryNames) {
2377
- dirHandle = await dirHandle.getDirectoryHandle(directoryName, { create });
2378
- }
2379
-
2380
- // Open the main database OPFS file. We need to know whether the file
2381
- // was created or not so we know whether to remove any existing
2382
- // IndexedDB database with the same name. This will not be necessary
2383
- // if the write-ahead data is moved to OPFS entirely.
2384
- let created = false;
2385
- /** @type {FileSystemSyncAccessHandle} */ let accessHandle;
2386
- try {
2387
- const fileHandle = await dirHandle.getFileHandle(dbName);
2388
- // @ts-ignore
2389
- accessHandle = await fileHandle.createSyncAccessHandle({
2390
- mode: 'readwrite-unsafe'
2391
- });
2392
- } catch (e) {
2393
- if (e.name === 'NotFoundError' && create) {
2394
- const fileHandle = await dirHandle.getFileHandle(dbName, { create });
2395
- // @ts-ignore
2396
- accessHandle = await fileHandle.createSyncAccessHandle({
2397
- mode: 'readwrite-unsafe'
2398
- });
2399
- created = true;
2400
- } else {
2401
- throw e;
2402
- }
2403
- }
2404
- onError.push(() => {
2405
- accessHandle.close();
2406
- if (created) {
2407
- dirHandle.removeEntry(dbName);
2408
- }
2409
- });
2410
-
2411
- // Pre-open the journal OPFS file here.
2412
- const journalName = this.#getJournalNameFromDbName(dbName);
2413
- const fileHandle = await dirHandle.getFileHandle(journalName, { create: true });
2414
- // @ts-ignore
2415
- const journalHandle = await fileHandle.createSyncAccessHandle({
2416
- mode: 'readwrite-unsafe'
2417
- });
2418
- onError.push(() => {
2419
- journalHandle.close();
2420
- if (created) {
2421
- dirHandle.removeEntry(journalName);
2422
- }
2423
- });
2424
-
2425
- // Open the WAL file.
2426
- const waName = this.#getWriteAheadNameFromDbName(dbName);
2427
- const waFileHandle = await dirHandle.getFileHandle(waName, { create: true });
2428
- // @ts-ignore
2429
- const waHandle = await waFileHandle.createSyncAccessHandle({
2430
- mode: 'readwrite-unsafe'
2431
- });
2432
- onError.push(() => {
2433
- waHandle.close();
2434
- if (created) {
2435
- dirHandle.removeEntry(waName);
2436
- }
2437
- });
2438
-
2439
- // Create the write-ahead manager.
2440
- const writeAhead = new _WriteAhead_js__WEBPACK_IMPORTED_MODULE_3__.WriteAhead(
2441
- zName,
2442
- accessHandle,
2443
- waHandle,
2444
- Object.assign({ create: created }, this.options));
2445
- await writeAhead.ready();
2446
-
2447
- file.retryResult = { accessHandle, waHandle, journalHandle, writeAhead };
2448
- });
2449
- } catch (e) {
2450
- while (onError.length) {
2451
- onError.pop()();
2452
- }
2453
- file.retryResult = e;
2454
- }
2455
- }
2456
- }
2457
-
2458
-
2459
- /***/ },
2460
-
2461
- /***/ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/WriteAhead.js"
2462
- /*!***********************************************************************************************************************************************!*\
2463
- !*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/WriteAhead.js ***!
2464
- \***********************************************************************************************************************************************/
2465
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2466
-
2467
- __webpack_require__.r(__webpack_exports__);
2468
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2469
- /* harmony export */ WriteAhead: () => (/* binding */ WriteAhead)
2470
- /* harmony export */ });
2471
- /* harmony import */ var _Lock_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Lock.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/Lock.js");
2472
-
2473
-
2474
- const DEFAULT_AUTOCHECKPOINT_PAGES = 1000;
2475
- const DEFAULT_BACKSTOP_INTERVAL = 30_000;
2476
-
2477
- const SECTOR_SIZE = 4096;
2478
- const WAL_FILE_HEADER_SIZE = 32;
2479
- const WAL_FRAME_BASE = SECTOR_SIZE + WAL_FILE_HEADER_SIZE; // first frame starts at this offset
2480
-
2481
- /**
2482
- * @typedef PageEntry
2483
- * @property {number} waOffset location in WAL file
2484
- * @property {number} pageSize
2485
- * @property {Uint8Array} [pageData]
2486
- */
2487
-
2488
- /**
2489
- * @typedef Transaction
2490
- * @property {number} id
2491
- * @property {Map<number, PageEntry>} pages address to page data mapping
2492
- * @property {number} dbFileSize
2493
- * @property {number} dbPageSize
2494
- * @property {number} waOffsetEnd
2495
- */
2496
-
2497
- /**
2498
- * @typedef WriteAheadOptions
2499
- * @property {boolean} [create=false] true if database is being created
2500
- * @property {number} [autoCheckpointPages]
2501
- * @property {number} [backstopInterval]
2502
- */
2503
-
2504
- class WriteAhead {
2505
- log = null;
2506
- /** @type {WriteAheadOptions} */ options = {
2507
- create: false,
2508
- autoCheckpointPages: DEFAULT_AUTOCHECKPOINT_PAGES,
2509
- backstopInterval: DEFAULT_BACKSTOP_INTERVAL,
2510
- };
2511
-
2512
- #zName;
2513
- #dbHandle;
2514
- #waFile;
2515
-
2516
- #dbFileSize = 0;
2517
-
2518
- /** @type {Promise<any>} */ #ready;
2519
- /** @type {'read'|'write'} */ #isolationState = null
2520
-
2521
- /** @type {Lock} */ #txIdLock = null;
2522
- /** @type {Transaction} */ #txActive = null;
2523
-
2524
- /** @type {Map<number, PageEntry>} */ #waOverlay = new Map();
2525
- /** @type {Map<number, Transaction>} */ #mapIdToTx = new Map();
2526
- /** @type {Map<number, Transaction>} */ #pendingTx = new Map();
2527
- #mapIdToTxPageCount = 0;
2528
-
2529
- #broadcastChannel;
2530
- /** @type {number} */ #backstopTimer;
2531
-
2532
- /**
2533
- * @param {string} zName
2534
- * @param {FileSystemSyncAccessHandle} dbHandle
2535
- * @param {FileSystemSyncAccessHandle} waHandle
2536
- * @param {WriteAheadOptions} options
2537
- */
2538
- constructor(zName, dbHandle, waHandle, options) {
2539
- this.#zName = zName;
2540
- this.#dbHandle = dbHandle;
2541
- this.#waFile = new WriteAheadFile(waHandle);
2542
- this.options = Object.assign(this.options, options);
2543
-
2544
- // All the asynchronous initialization is done here.
2545
- this.#ready = (async () => {
2546
- // Disable checkpointing by other connections until we're ready.
2547
- await navigator.locks.request(`${this.#zName}-ckpt`, async () => {
2548
- await this.#updateTxIdLock();
2549
- });
2550
-
2551
- // Load all the transactions from the WAL file.
2552
- if (this.options.create) {
2553
- this.#waFile.create();
2554
- }
2555
-
2556
- this.#waFile.open();
2557
- for (const tx of this.#waFile.readAllTx()) {
2558
- this.#activateTx(tx);
2559
- }
2560
- this.#updateTxIdLock(); // doesn't need await
2561
-
2562
- // Listen for transactions and checkpoints from other connections.
2563
- this.#broadcastChannel = new BroadcastChannel(`${zName}#wa`);
2564
- this.#broadcastChannel.onmessage = (event) => {
2565
- this.#handleMessage(event);
2566
- };
2567
-
2568
- // Schedule backstop. The backstop is a guard against a crash in
2569
- // another context between persisting a transaction and broadcasting
2570
- // it.
2571
- this.#backstop();
2572
- })();
2573
- }
2574
-
2575
- /**
2576
- * @returns {Promise<void>}
2577
- */
2578
- ready() {
2579
- return this.#ready;
2580
- }
2581
-
2582
- close() {
2583
- // Stop asynchronous maintenance.
2584
- this.#broadcastChannel.onmessage = null;
2585
- clearTimeout(this.#backstopTimer);
2586
-
2587
- // Wait for any pending commit to complete.
2588
- this.#txIdLock?.release();
2589
- this.#broadcastChannel.close();
2590
- }
2591
-
2592
- /**
2593
- * Freeze our view of the database.
2594
- * The view includes the transactions received so far but is not
2595
- * guaranteed to be completely up to date (this allows this method
2596
- * to be synchronous). Unfreeze the view with rejoin().
2597
- */
2598
- isolateForRead() {
2599
- if (this.#isolationState !== null) {
2600
- throw new Error('Already in isolated state');
2601
- }
2602
- this.#isolationState = 'read';
2603
-
2604
- if (this.#waFile.checkReset()) {
2605
- // The WAL file has been restarted after a full checkpoint. Our
2606
- // view must be at the final transaction before the checkpoint for
2607
- // that to have happened. The previous overlay is now stale. In
2608
- // case we haven't received the checkpoint broadcast, make sure
2609
- // the overlay is cleared.
2610
- this.#handleCheckpoint(this.#waFile.txId);
2611
- }
2612
- }
2613
-
2614
- /**
2615
- * Freeze our view of the database for writing.
2616
- * The view includes all transactions. Unfreeze the view with rejoin().
2617
- */
2618
- isolateForWrite() {
2619
- if (this.#isolationState !== null) {
2620
- throw new Error('Already in isolated state');
2621
- }
2622
- this.#isolationState = 'write';
2623
-
2624
- // Backstop is not needed while writing because we will be current.
2625
- clearTimeout(this.#backstopTimer);
2626
- this.#backstopTimer = null;
2627
-
2628
- if (this.#waFile.checkReset()) {
2629
- // The WAL file has been restarted after a full checkpoint. Our
2630
- // view must be at the final transaction before the checkpoint for
2631
- // that to have happened. The previous overlay is now stale. In
2632
- // case we haven't received the checkpoint broadcast, make sure
2633
- // the overlay is cleared.
2634
- this.#handleCheckpoint(this.#waFile.txId);
2635
- }
2636
-
2637
- // A writer needs all previous transactions assimilated.
2638
- this.#advanceTxId({ readToCurrent: true });
2639
- }
2640
-
2641
- rejoin() {
2642
- if (this.#isolationState === 'write') {
2643
- // Resume backstop after write isolation.
2644
- this.#backstop();
2645
-
2646
- // We need a place for a connection that only does write transactions
2647
- // to auto-checkpoint. This the best place because writing is
2648
- // complete.
2649
- this.#autoCheckpoint();
2650
- } else {
2651
- // Catch up on new transactions that arrived while isolated.
2652
- this.#advanceTxId({ autoCheckpoint: true });
2653
- }
2654
- this.#isolationState = null;
2655
- }
2656
-
2657
- /**
2658
- * @param {number} offset
2659
- * @return {Uint8Array?}
2660
- */
2661
- read(offset) {
2662
- // First look for the page in any write transaction in progress.
2663
- // If the page is not found in the transaction overlay, look in the
2664
- // write-ahead overlay.
2665
- const pageEntry = this.#txActive?.pages.get(offset) ?? this.#waOverlay.get(offset);
2666
- if (pageEntry) {
2667
- this.log?.(`%cread page at offset ${offset} from WAL ${pageEntry.waOffset}`, 'background-color: gold;');
2668
- if (pageEntry.pageData) {
2669
- // Page data is cached.
2670
- return pageEntry.pageData;
2671
- }
2672
-
2673
- // Read the page from the WAL file.
2674
- const buffer = new Uint8Array(pageEntry.pageSize);
2675
- this.#waFile.accessHandle.read(buffer, { at: pageEntry.waOffset });
2676
- return buffer;
2677
- }
2678
- return null;
2679
- }
2680
-
2681
- /**
2682
- * @param {number} offset
2683
- * @param {Uint8Array} data
2684
- */
2685
- write(offset, data) {
2686
- if (this.#isolationState !== 'write') {
2687
- throw new Error('Not in write isolated state');
2688
- }
2689
-
2690
- if (!this.#txActive) {
2691
- // There is no active transaction so create one.
2692
- this.#txActive = this.#waFile.beginTx();
2693
- }
2694
- const waOffset = this.#waFile.writePage(offset, data.slice());
2695
- this.log?.(`%c#write page at ${offset} to WAL ${waOffset}`, 'background-color: lightskyblue;');
2696
- }
2697
-
2698
- /**
2699
- * @param {number} newSize
2700
- */
2701
- truncate(newSize) {
2702
- // Remove any pages past the truncation point. We don't need to save
2703
- // the file size because that will be extracted from page 1.
2704
- for (const offset of this.#txActive.pages.keys()) {
2705
- if (offset >= newSize) {
2706
- this.#txActive.pages.delete(offset);
2707
- }
2708
- }
2709
- }
2710
-
2711
- getFileSize() {
2712
- // If the overlay is empty, the last file size may no longer be valid
2713
- // if direct changes were made to the main database file.
2714
- return this.#waOverlay.size ? this.#dbFileSize : null;
2715
- }
2716
-
2717
- commit() {
2718
- // Persist the final pending transaction page with the database size.
2719
- this.#waFile.commitTx();
2720
-
2721
- // Incorporate the transaction locally.
2722
- this.#activateTx(this.#txActive);
2723
- this.#updateTxIdLock();
2724
-
2725
- // Send the transaction to other connections.
2726
- const payload = { type: 'tx', tx: this.#txActive };
2727
- this.#broadcastChannel.postMessage(payload);
2728
- this.#txActive = null;
2729
-
2730
- }
2731
-
2732
- rollback() {
2733
- // Discard transaction pages.
2734
- this.#waFile.abortTx();
2735
- this.#txActive = null;
2736
- }
2737
-
2738
- /**
2739
- * @param {{durability: 'strict'|'relaxed'}} options
2740
- */
2741
- sync(options) {
2742
- if (options.durability === 'strict') {
2743
- this.#waFile.accessHandle.flush();
2744
- }
2745
- }
2746
-
2747
- /**
2748
- * Flush all write-ahead transactions to the main database file.
2749
- * There must be no other connections reading or writing.
2750
- * @param {'passive'|'full'|'restart'|'truncate'} mode
2751
- */
2752
- async checkpoint(mode) {
2753
- if (mode !== 'passive') {
2754
- this.isolateForWrite();
2755
- }
2756
- try {
2757
- const options = {
2758
- isRestart: mode !== 'passive',
2759
- isRequired: mode !== 'passive'
2760
- };
2761
- await this.#checkpoint(options);
2762
-
2763
- if (mode === 'truncate') {
2764
- this.#waFile.accessHandle.truncate(this.#waFile.currentOffset);
2765
- this.log?.(`%ccheckpoint restart WAL file`, 'background-color: lightgreen;');
2766
- }
2767
- } finally {
2768
- if (mode !== 'passive') {
2769
- this.rejoin();
2770
- }
2771
- }
2772
- }
2773
-
2774
- /**
2775
- * Return the known usage size of the write-ahead file. Note that the
2776
- * actual file size may be larger than reported if this connection is
2777
- * not current or if the file has obsolete content past the current point.
2778
- * @returns {number}
2779
- */
2780
- getWriteAheadSize() {
2781
- return this.#waFile.currentOffset;
2782
- }
2783
-
2784
- /**
2785
- * Incorporate a transaction into our view of the database.
2786
- * @param {Transaction} tx
2787
- */
2788
- #activateTx(tx) {
2789
- // Transfer to the active collection of transactions.
2790
- this.#mapIdToTx.set(tx.id, tx);
2791
- this.#mapIdToTxPageCount += tx.pages.size;
2792
-
2793
- // Add transaction pages to the write-ahead overlay.
2794
- for (const [offset, pageEntry] of tx.pages) {
2795
- this.#waOverlay.set(offset, pageEntry);
2796
- }
2797
- this.#dbFileSize = tx.dbFileSize;
2798
- }
2799
-
2800
- /**
2801
- * Advance the local view of the database. By default, advance to the
2802
- * last broadcast transaction. Optionally, also advance through any
2803
- * additional transactions in the WAL file to be fully current.
2804
- *
2805
- * @param {{readToCurrent?: boolean, autoCheckpoint?: boolean}} options
2806
- */
2807
- #advanceTxId(options = {}) {
2808
- let didAdvance = false;
2809
- while (this.#pendingTx.size) {
2810
- // Fetch the next transaction in sequence. Usually this will come
2811
- // from pendingTx, but if it is missing then read it from the file.
2812
- const nextTxId = this.#waFile.txId + 1;
2813
- let tx;
2814
- if (this.#pendingTx.has(nextTxId)) {
2815
- tx = this.#pendingTx.get(nextTxId);
2816
- this.#pendingTx.delete(tx.id);
2817
- this.#waFile.skipTx(tx.id, tx.waOffsetEnd);
2818
- } else {
2819
- tx = this.#waFile.readTx();
2820
- }
2821
-
2822
- this.#activateTx(tx);
2823
- didAdvance = true;
2824
- }
2825
-
2826
- if (options.readToCurrent) {
2827
- // Read all additional transactions from the WAL file.
2828
- for (const tx of this.#waFile.readAllTx()) {
2829
- this.#activateTx(tx);
2830
- didAdvance = true;
2831
- }
2832
- }
2833
-
2834
- if (didAdvance) {
2835
- // Publish our new view txId.
2836
- this.#updateTxIdLock();
2837
-
2838
- if (options.autoCheckpoint) {
2839
- this.#autoCheckpoint();
2840
- }
2841
- }
2842
- }
2843
-
2844
- #autoCheckpoint() {
2845
- // Perform an automatic checkpoint if enabled and needed. Automatic
2846
- // checkpoints are passive, so this will not change the WAL file
2847
- // usage or size.
2848
- if (this.options.autoCheckpointPages > 0 &&
2849
- this.#mapIdToTxPageCount >= this.options.autoCheckpointPages) {
2850
- this.log?.(`%cauto-checkpoint`, 'background-color: lightgreen;');
2851
- this.checkpoint('passive');
2852
- }
2853
- }
2854
-
2855
- /**
2856
- * Move pages from write-ahead to main database file.
2857
- *
2858
- * @param {{isRestart?: boolean, isRequired?: boolean}} options
2859
- */
2860
- async #checkpoint(options = {}) {
2861
- // By default, checkpointing is abandoned if another connection is
2862
- // already checkpointing. With the isRequired option, a checkpoint
2863
- // is always performed. This is necessary for leaving write-ahead
2864
- // mode or a user-requested checkpoint.
2865
- const lockOptions = {
2866
- ifAvailable: !options.isRequired,
2867
- };
2868
-
2869
- await navigator.locks.request(`${this.#zName}-ckpt`, lockOptions, async lock => {
2870
- if (!lock) return null;
2871
-
2872
- /** @type {number} */ let ckptId;
2873
- if (options.isRestart) {
2874
- // Full checkpoint, use the current WAL file txId.
2875
- ckptId = this.#waFile.txId;
2876
-
2877
- // Wait for all connections to reach this txId.
2878
- await this.#waitForTxIdLocks(value => value.maxTxId >= ckptId);
2879
- this.log?.(`%c#checkpoint full txId ${ckptId}`, 'background-color: lightgreen;');
2880
- } else {
2881
- // Not a full checkpoint, so find the lowest txId in use by any
2882
- // connection.
2883
- ckptId = (await this.#getTxIdLocks())
2884
- .reduce((min, value) => Math.min(min, value.maxTxId), this.#waFile.txId);
2885
- this.log?.(`%c#checkpoint partial txId ${ckptId}`, 'background-color: lightgreen;');
2886
- }
2887
-
2888
- // Sync the WAL file. This ensures that if there is a crash after
2889
- // part of the WAL has been copied, the uncopied part will still be
2890
- // available afterwards.
2891
- this.#waFile.accessHandle.flush();
2892
-
2893
- // Starting at ckptId and going backwards (earlier), write transaction
2894
- // pages to the main database file. Do not overwrite a page written
2895
- // by a later transaction.
2896
- const writtenOffsets = new Set();
2897
- let dbFileSize = 0;
2898
- let tx = /** @type {Transaction} */ ({ id: ckptId + 1 });
2899
- while (tx = this.#mapIdToTx.get(tx.id - 1)) {
2900
- if (tx.id === ckptId) {
2901
- // Set the file size from the latest transaction. This may be
2902
- // unnecessary as SQLite is not known to reduce the database size
2903
- // except with VACUUM.
2904
- dbFileSize = tx.dbFileSize;
2905
- this.#dbHandle.truncate(dbFileSize);
2906
- }
2907
-
2908
- for (const [offset, pageEntry] of tx.pages) {
2909
- if (offset < dbFileSize && !writtenOffsets.has(offset)) {
2910
- let pageData = pageEntry.pageData;
2911
- if (!pageData) {
2912
- // Page data was not cached, so read it from the WAL file.
2913
- pageData = new Uint8Array(pageEntry.pageSize);
2914
- const nRead = this.#waFile.accessHandle.read(
2915
- pageData,
2916
- { at: pageEntry.waOffset });
2917
- if (nRead !== pageData.byteLength) {
2918
- throw new Error('Checkpoint read failed');
2919
- }
2920
- }
2921
-
2922
- // Write the page to the database file.
2923
- const nWritten = this.#dbHandle.write(pageData, { at: offset });
2924
- if (nWritten !== pageData.byteLength) {
2925
- throw new Error('Checkpoint write failed');
2926
- }
2927
- writtenOffsets.add(offset);
2928
- this.log?.(`%c#checkpoint wrote txId ${tx.id} page at ${offset} to database`, 'background-color: lightgreen;');
2929
- }
2930
- }
2931
- }
2932
-
2933
- if (writtenOffsets.size > 0) {
2934
- if (ckptId == this.#waFile.txId) {
2935
- // Ensure data is safely in the file.
2936
- this.log?.(`%c#checkpoint flush database file`, 'background-color: lightgreen;');
2937
- this.#dbHandle.flush();
2938
- }
2939
-
2940
- // Notify other connections and ourselves of the checkpoint.
2941
- this.#broadcastChannel.postMessage({
2942
- type: 'ckpt',
2943
- ckptId,
2944
- });
2945
- this.#handleCheckpoint(ckptId);
2946
- }
2947
-
2948
- if (options.isRestart) {
2949
- // Wait for all connections to clear their overlay.
2950
- await this.#waitForTxIdLocks(value => value.minTxId > ckptId);
2951
-
2952
- this.#waFile.reset();
2953
- }
2954
- });
2955
- }
2956
-
2957
- /**
2958
- * After a checkpoint, remove checkpointed pages from write-ahead.
2959
- * The checkpoint may be been done locally or by another connection.
2960
- * @param {number} ckptId
2961
- */
2962
- #handleCheckpoint(ckptId) {
2963
- this.log?.(`%c#handleCheckpoint to txId ${ckptId}`, 'background-color: lightgreen;');
2964
-
2965
- // Loop backwards from ckptId.
2966
- let tx = /** @type {Transaction} */ ({ id: ckptId + 1 });
2967
- while (tx = this.#mapIdToTx.get(tx.id - 1)) {
2968
- // Remove pages from write-ahead overlay.
2969
- for (const [offset, page] of tx.pages.entries()) {
2970
- // Be sure not to remove a newer version of the page.
2971
- const overlayPage = this.#waOverlay.get(offset);
2972
- if (overlayPage === page) {
2973
- this.log?.(`%cremove txId ${tx.id} page at offset ${offset}`, 'background-color: lightgreen;');
2974
- this.#waOverlay.delete(offset);
2975
- }
2976
- }
2977
-
2978
- // Remove transaction.
2979
- this.#mapIdToTx.delete(tx.id);
2980
- this.#mapIdToTxPageCount -= tx.pages.size;
2981
- }
2982
- this.#updateTxIdLock();
2983
- }
2984
-
2985
- /**
2986
- * @param {MessageEvent} event
2987
- */
2988
- #handleMessage(event) {
2989
- if (event.data.type === 'tx') {
2990
- // New transaction from another connection. Don't use it if we
2991
- // already have it.
2992
- /** @type {Transaction} */ const tx = event.data.tx;
2993
- if (tx.id > this.#waFile.txId) {
2994
- this.#pendingTx.set(tx.id, tx);
2995
- if (this.#isolationState === null) {
2996
- // Not in an isolated state, so advance our view of the database.
2997
- this.#advanceTxId({ autoCheckpoint: true });
2998
- }
2999
- }
3000
- } else if (event.data.type === 'ckpt') {
3001
- // Checkpoint notification from another connection.
3002
- /** @type {number} */ const ckptId = event.data.ckptId;
3003
- this.#handleCheckpoint(ckptId);
3004
- }
3005
- }
3006
-
3007
- /**
3008
- * Periodic check for recovering from lost transaction broadcasts.
3009
- */
3010
- async #backstop() {
3011
- try {
3012
- if (this.#backstopTimer) {
3013
- if (this.#isolationState === null) {
3014
- // Not in an isolated state, so advance our view of the database.
3015
- const oldTxId = this.#waFile.txId;
3016
- this.#advanceTxId({ readToCurrent: true });
3017
- if (this.#waFile.txId > oldTxId) {
3018
- this.log?.(`%cbackstop txId ${oldTxId} -> ${this.#waFile.txId}`, 'background-color: lightyellow;');
3019
- }
3020
- }
3021
- }
3022
- } catch (e) {
3023
- console.error('Backstop failed', e);
3024
- }
3025
-
3026
- // Schedule next backstop. Add a bit of jitter to decorrelate
3027
- // backstops across multiple connections.
3028
- const delay = this.options.backstopInterval * (0.9 + 0.2 * Math.random());
3029
- this.#backstopTimer = self.setTimeout(() => {
3030
- this.#backstop();
3031
- }, delay);
3032
- }
3033
-
3034
- /**
3035
- * Update the lock that publishes our current txId.
3036
- */
3037
- async #updateTxIdLock() {
3038
- // Our view of the database, i.e. the txId, is encoded into the name
3039
- // of a lock so other connections can see it. When our txId changes,
3040
- // we acquire a new lock and release the old one. We must not release
3041
- // the old lock until the new one is in place.
3042
- const oldLock = this.#txIdLock;
3043
- const newLockName = this.#encodeTxIdLockName();
3044
- if (oldLock?.name !== newLockName) {
3045
- this.#txIdLock = new _Lock_js__WEBPACK_IMPORTED_MODULE_0__.Lock(newLockName);
3046
- await this.#txIdLock.acquire('shared').then(() => {
3047
- // The new lock is acquired.
3048
- oldLock?.release();
3049
- });
3050
-
3051
- if (this.log) {
3052
- const { minTxId, maxTxId } = this.#decodeTxIdLockName(newLockName);
3053
- this.log?.(`%ctxId to ${minTxId}:${maxTxId}`, 'background-color: pink;');
3054
- }
3055
- }
3056
- }
3057
-
3058
- /**
3059
- * Get all txId locks for this database.
3060
- * @returns {Promise<{name: string, minTxId: number, maxTxId: number}[]>}
3061
- */
3062
- async #getTxIdLocks() {
3063
- const { held } = await navigator.locks.query();
3064
- return held
3065
- .map(lock => this.#decodeTxIdLockName(lock.name))
3066
- .filter(value => value !== null)
3067
- }
3068
-
3069
- /**
3070
- * @returns {string}
3071
- */
3072
- #encodeTxIdLockName() {
3073
- // The maxTxId is our current view of the database. The minTxId is
3074
- // the lowest txId we get pages from the WAL for, which is the lowest
3075
- // key in mapIdToTx. If mapIdToTx is empty then we aren't reading
3076
- // from the WAL at all - in this case we arbitrarily set minTxId to
3077
- // invalid value maxTxId + 1.
3078
- const maxTxId = this.#waFile.txId;
3079
- const minTxId = this.#mapIdToTx.keys().next().value ?? (maxTxId + 1);
3080
- return `${this.#zName}-txId<${minTxId}:${maxTxId}>`;
3081
- }
3082
-
3083
- /**
3084
- * @param {string} lockName
3085
- * @returns {{name: string, minTxId: number, maxTxId: number}}
3086
- */
3087
- #decodeTxIdLockName(lockName) {
3088
- const match = lockName.match(/^(.*)-txId<(\d+):(\d+)>$/);
3089
- if (match?.[1] === this.#zName) {
3090
- // This txId lock is for this database.
3091
- return {
3092
- name: match[1],
3093
- minTxId: parseInt(match[2]),
3094
- maxTxId: parseInt(match[3])
3095
- };
3096
- }
3097
- return null;
3098
- }
3099
-
3100
- /**
3101
- * Wait for all txId locks that fail the provided predicate.
3102
- * @param {(lock: {name: string, minTxId: number, maxTxId: number}) => boolean} predicate
3103
- */
3104
- async #waitForTxIdLocks(predicate) {
3105
- /** @type {string[]} */ let failingLockNames = [];
3106
- do {
3107
- // Wait for all connections that fail the predicate.
3108
- await Promise.all(
3109
- failingLockNames.map(name => navigator.locks.request(name, async () => {}))
3110
- );
3111
-
3112
- // Refresh the list of failing locks.
3113
- failingLockNames = (await this.#getTxIdLocks())
3114
- .filter(value => !predicate(value))
3115
- .map(value => value.name);
3116
- } while (failingLockNames.length > 0);
3117
- }
3118
- }
3119
-
3120
- class WriteAheadFile {
3121
- static MAGIC = 0x377f0684;
3122
- static FILE_HEADER_SIZE = 32;
3123
- static FRAME_HEADER_SIZE = 32;
3124
- static FRAME_TYPE_PAGE = 0;
3125
- static FRAME_TYPE_COMMIT = 1;
3126
-
3127
- /** @type {FileSystemSyncAccessHandle} */ accessHandle;
3128
- /** @type {number} */ currentOffset;
3129
-
3130
- txId = 0;
3131
- salt1 = 0;
3132
- salt2 = 0;
3133
-
3134
- /** @type {Transaction} */ txInProgress = null;
3135
-
3136
- constructor(accessHandle) {
3137
- this.accessHandle = accessHandle;
3138
- }
3139
-
3140
- create() {
3141
- this.accessHandle.truncate(0);
3142
- this.#writeFileHeader();
3143
- }
3144
-
3145
- open() {
3146
- // Read file headers from both header slots and use the one with the
3147
- // higher nextTxId.
3148
- const fileHeader = [0, SECTOR_SIZE]
3149
- .map(offset => this.#readFileHeader(offset))
3150
- .filter(h => h)
3151
- .sort((a, b) => b.nextTxId - a.nextTxId)[0];
3152
-
3153
- this.currentOffset = WAL_FRAME_BASE;
3154
- this.txId = fileHeader.nextTxId - 1;
3155
- this.salt1 = fileHeader.salt1;
3156
- this.salt2 = fileHeader.salt2;
3157
- }
3158
-
3159
- reset(options = { truncate: true }) {
3160
- const fileHeader = this.#writeFileHeader();
3161
- if (options.truncate) {
3162
- this.accessHandle.truncate(WAL_FRAME_BASE);
3163
- }
3164
-
3165
- this.currentOffset = WAL_FRAME_BASE;
3166
- this.salt1 = fileHeader.salt1;
3167
- this.salt2 = fileHeader.salt2;
3168
- }
3169
-
3170
- checkReset() {
3171
- // Check for a new header. There are two header slots in the file.
3172
- // Look in the slot that is not current, which will be at offset 0
3173
- // or SECTOR_SIZE depending on the current salt1 value (salt1 is
3174
- // incremented on each new header).
3175
- const headerOffset = (this.salt1 & 0x1) ? 0 : SECTOR_SIZE;
3176
- const fileHeader = this.#readFileHeader(headerOffset);
3177
- if (fileHeader?.nextTxId > this.txId &&
3178
- fileHeader.salt1 === ((this.salt1 + 1) | 0)) {
3179
- // The WAL file has been reset.
3180
- this.currentOffset = WAL_FRAME_BASE;
3181
- this.salt1 = fileHeader.salt1;
3182
- this.salt2 = fileHeader.salt2;
3183
- return true;
3184
- }
3185
- return false;
3186
- }
3187
-
3188
- *readAllTx() {
3189
- while (true) {
3190
- const tx = this.readTx();
3191
- if (!tx) break;
3192
- yield tx;
3193
- }
3194
- }
3195
-
3196
- /**
3197
- * @returns {Transaction?}
3198
- */
3199
- readTx() {
3200
- // Read the next complete transaction or return null.
3201
- let offset = this.currentOffset;
3202
- /** @type {Transaction?} */ let tx = null;
3203
- while (true) {
3204
- const frame = this.#readFrame(offset);
3205
- if (!frame) return null;
3206
-
3207
- if (frame.frameType === WriteAheadFile.FRAME_TYPE_COMMIT) {
3208
- // Update the instance state.
3209
- this.txId += 1;
3210
- this.currentOffset = offset + frame.byteLength;
3211
-
3212
- tx.id = this.txId;
3213
- tx.dbFileSize = frame.dbFileSize;
3214
- tx.waOffsetEnd = this.currentOffset;
3215
- return tx;
3216
- }
3217
-
3218
- // frameType === WriteAheadFile.FRAME_TYPE_PAGE
3219
- if (!tx) {
3220
- tx = {
3221
- id: 0, // placeholder
3222
- pages: new Map(),
3223
- dbFileSize: 0, // placeholder
3224
- dbPageSize: frame.pageData.byteLength,
3225
- waOffsetEnd: 0 // placeholder
3226
- };
3227
- }
3228
-
3229
- tx.pages.set(
3230
- frame.pageOffset,
3231
- {
3232
- pageSize: frame.pageData.byteLength,
3233
- waOffset: offset + WriteAheadFile.FRAME_HEADER_SIZE
3234
- });
3235
-
3236
- offset += frame.byteLength;
3237
- }
3238
- }
3239
-
3240
- /**
3241
- * This method is called when transaction(s) have been received by other
3242
- * means than readTx(), e.g. via BroadcastChannel.
3243
- *
3244
- * @param {number} txId
3245
- * @param {number} offset
3246
- */
3247
- skipTx(txId, offset) {
3248
- this.txId = txId;
3249
- this.currentOffset = offset;
3250
- }
3251
-
3252
- /**
3253
- *
3254
- * @param {{overwrite?: boolean}} options
3255
- * @returns {Transaction}
3256
- */
3257
- beginTx(options = {}) {
3258
- this.txInProgress = {
3259
- id: this.txId + 1,
3260
- pages: new Map(),
3261
- dbFileSize: 0,
3262
- dbPageSize: 0,
3263
- waOffsetEnd: this.currentOffset
3264
- };
3265
- return this.txInProgress;
3266
- }
3267
-
3268
- /**
3269
- * Write a page frame to the WAL file.
3270
- *
3271
- * @param {number} pageOffset
3272
- * @param {Uint8Array} pageData
3273
- */
3274
- writePage(pageOffset, pageData) {
3275
- const headerView = new DataView(new ArrayBuffer(WriteAheadFile.FRAME_HEADER_SIZE));
3276
- headerView.setUint8(0, WriteAheadFile.FRAME_TYPE_PAGE);
3277
- headerView.setUint16(2, pageData.byteLength === 65536 ? 1 : pageData.byteLength);
3278
- headerView.setBigUint64(8, BigInt(pageOffset));
3279
- headerView.setUint32(16, this.salt1);
3280
- headerView.setUint32(20, this.salt2);
3281
-
3282
- const checksum = new Checksum();
3283
- checksum.update(new Uint8Array(headerView.buffer, 0, WriteAheadFile.FRAME_HEADER_SIZE - 8));
3284
- checksum.update(pageData);
3285
- headerView.setUint32(24, checksum.s0);
3286
- headerView.setUint32(28, checksum.s1);
3287
-
3288
- const bytesWritten =
3289
- this.accessHandle.write(headerView, { at: this.txInProgress.waOffsetEnd }) +
3290
- this.accessHandle.write(pageData, {
3291
- at: this.txInProgress.waOffsetEnd + WriteAheadFile.FRAME_HEADER_SIZE
3292
- });
3293
- if (bytesWritten !== headerView.byteLength + pageData.byteLength) {
3294
- throw new Error('write failed');
3295
- }
3296
-
3297
- const pageEntry = {
3298
- pageSize: pageData.byteLength,
3299
- waOffset: this.txInProgress.waOffsetEnd + WriteAheadFile.FRAME_HEADER_SIZE
3300
- };
3301
- if (pageOffset === 0) {
3302
- // This is page 1, which contains the database header.
3303
- const dataView = new DataView(pageData.buffer, pageData.byteOffset, pageData.byteLength);
3304
- const pageCount = dataView.getUint32(28);
3305
- this.txInProgress.dbFileSize = pageCount * pageData.byteLength;
3306
- this.txInProgress.dbPageSize = pageData.byteLength;
3307
-
3308
- // Cache page 1 as a performance optimization and to exercise the
3309
- // cache code path.
3310
- pageEntry.pageData = pageData;
3311
- }
3312
-
3313
- this.txInProgress.pages.set(pageOffset, pageEntry);
3314
- this.txInProgress.waOffsetEnd += bytesWritten;
3315
-
3316
- return pageEntry.waOffset;
3317
- }
3318
-
3319
- /**
3320
- * @returns {Transaction}
3321
- */
3322
- commitTx() {
3323
- const headerView = new DataView(new ArrayBuffer(WriteAheadFile.FRAME_HEADER_SIZE));
3324
- headerView.setUint8(0, WriteAheadFile.FRAME_TYPE_COMMIT);
3325
- headerView.setBigUint64(8, BigInt(this.txInProgress.dbFileSize));
3326
- headerView.setUint32(16, this.salt1);
3327
- headerView.setUint32(20, this.salt2);
3328
-
3329
- const checksum = new Checksum();
3330
- checksum.update(new Uint8Array(headerView.buffer, 0, WriteAheadFile.FRAME_HEADER_SIZE - 8));
3331
- headerView.setUint32(24, checksum.s0);
3332
- headerView.setUint32(28, checksum.s1);
3333
-
3334
- const bytesWritten = this.accessHandle.write(headerView, {
3335
- at: this.txInProgress.waOffsetEnd
3336
- });
3337
- if (bytesWritten !== headerView.byteLength) {
3338
- throw new Error('write failed');
3339
- }
3340
- this.txInProgress.waOffsetEnd += bytesWritten;
3341
-
3342
- const tx = this.txInProgress;
3343
- this.txInProgress = null;
3344
- this.currentOffset = tx.waOffsetEnd;
3345
- this.txId = tx.id;
3346
- return tx;
3347
- }
3348
-
3349
- abortTx() {
3350
- this.txInProgress = null;
3351
- }
3352
-
3353
- #readFileHeader(offset) {
3354
- const headerView = new DataView(new ArrayBuffer(WriteAheadFile.FILE_HEADER_SIZE));
3355
- if (this.accessHandle.read(headerView, { at: offset }) !== headerView.byteLength) {
3356
- return null;
3357
- }
3358
-
3359
- if (headerView.getUint32(0) !== WriteAheadFile.MAGIC) return null;
3360
-
3361
- const checksum = new Checksum();
3362
- checksum.update(new Uint8Array(headerView.buffer, 0, WriteAheadFile.FILE_HEADER_SIZE - 8));
3363
- if (!checksum.matches(headerView.getUint32(24), headerView.getUint32(28))) {
3364
- return null;
3365
- }
3366
-
3367
- return {
3368
- nextTxId: Number(headerView.getBigUint64(8)),
3369
- salt1: headerView.getUint32(16),
3370
- salt2: headerView.getUint32(20)
3371
- }
3372
- }
3373
-
3374
- #readFrame(offset) {
3375
- const headerView = new DataView(new ArrayBuffer(WriteAheadFile.FRAME_HEADER_SIZE));
3376
- if (this.accessHandle.read(headerView, { at: offset }) !== headerView.byteLength) {
3377
- // EOF, not an error.
3378
- return null;
3379
- }
3380
-
3381
- // Verify the frame header salt values match the file header.
3382
- const frameSalt1 = headerView.getUint32(16);
3383
- const frameSalt2 = headerView.getUint32(20);
3384
- if (frameSalt1 !== this.salt1 || frameSalt2 !== this.salt2) {
3385
- // Not necessarily an error, could be from a restart without
3386
- // truncation.
3387
- return null;
3388
- }
3389
-
3390
- const payloadSize = (size => size === 1 ? 65536 : size)(headerView.getUint16(2));
3391
- /** @type {Uint8Array} */ let payloadData;
3392
- if (payloadSize) {
3393
- payloadData = new Uint8Array(payloadSize);
3394
- const payloadBytesRead = this.accessHandle.read(
3395
- payloadData,
3396
- { at: offset + WriteAheadFile.FRAME_HEADER_SIZE });
3397
- if (payloadBytesRead !== payloadSize ) return null;
3398
- }
3399
-
3400
- const checksum = new Checksum();
3401
- checksum.update(new Uint8Array(headerView.buffer, 0, WriteAheadFile.FRAME_HEADER_SIZE - 8));
3402
- if (payloadData) {
3403
- checksum.update(payloadData);
3404
- }
3405
- if (!checksum.matches(headerView.getUint32(24), headerView.getUint32(28))) {
3406
- // Not necessarily an error, could be from a restart without
3407
- // truncation.
3408
- return null;
3409
- }
3410
-
3411
- const frameType = headerView.getUint8(0);
3412
- if (frameType === WriteAheadFile.FRAME_TYPE_PAGE) {
3413
- return {
3414
- frameType,
3415
- byteLength: WriteAheadFile.FRAME_HEADER_SIZE + payloadSize,
3416
- pageOffset: Number(headerView.getBigUint64(8)),
3417
- pageData: payloadData
3418
- }
3419
- } else if (frameType === WriteAheadFile.FRAME_TYPE_COMMIT) {
3420
- // Flags byte is currently unused. A possible future use would be
3421
- // to indicate an overwrite commit to trigger clearing the overlay.
3422
- // This might allow a page size change by VACUUM.
3423
- const flags = headerView.getUint8(1);
3424
- return {
3425
- frameType,
3426
- byteLength: WriteAheadFile.FRAME_HEADER_SIZE,
3427
- dbFileSize: Number(headerView.getBigUint64(8)),
3428
- isOverwrite: !!(flags & 0x1)
3429
- }
3430
- }
3431
- throw new Error(`Invalid frame type: ${frameType}`);
3432
- }
3433
-
3434
- #writeFileHeader() {
3435
- // Derive new values from the previous values. Note that salt1 always
3436
- // flips between even and odd so successive headers are written to
3437
- // alternating slots. If the write fails, the file remains in a valid
3438
- // state.
3439
- const nextTxId = this.txId + 1;
3440
- const salt1 = (this.salt1 + 1) | 0;
3441
- const salt2 = Math.floor(Math.random() * 0xffffffff);
3442
- const headerView = new DataView(new ArrayBuffer(WriteAheadFile.FILE_HEADER_SIZE));
3443
- headerView.setUint32(0, WriteAheadFile.MAGIC);
3444
- headerView.setBigUint64(8, BigInt(nextTxId));
3445
- headerView.setUint32(16, salt1);
3446
- headerView.setUint32(20, salt2);
3447
-
3448
- const checksum = new Checksum();
3449
- checksum.update(new Uint8Array(headerView.buffer, 0, WriteAheadFile.FILE_HEADER_SIZE - 8));
3450
- headerView.setUint32(24, checksum.s0);
3451
- headerView.setUint32(28, checksum.s1);
3452
-
3453
- // A header with an even salt1 is written at offset 0, and with an
3454
- // odd salt1 at SECTOR_SIZE.
3455
- const headerOffset = (salt1 & 0x1) ? SECTOR_SIZE : 0;
3456
- const bytesWritten = this.accessHandle.write(headerView, { at: headerOffset });
3457
- if (bytesWritten !== headerView.byteLength) {
3458
- throw new Error('write failed');
3459
- }
3460
-
3461
- this.accessHandle.flush();
3462
- return { nextTxId, salt1, salt2 };
3463
- }
3464
- }
3465
-
3466
- // https://www.sqlite.org/fileformat.html#checksum_algorithm
3467
- class Checksum {
3468
- /** @type {number} */ s0 = 0;
3469
- /** @type {number} */ s1 = 0;
3470
-
3471
- /**
3472
- * @param {ArrayBuffer|ArrayBufferView} data
3473
- */
3474
- update(data) {
3475
- if ((data.byteLength % 8) !== 0) throw new Error('Data must be a multiple of 8 bytes');
3476
- const words = ArrayBuffer.isView(data) ?
3477
- new Uint32Array(data.buffer, data.byteOffset, data.byteLength / 4) :
3478
- new Uint32Array(data);
3479
- for (let i = 0; i < words.length; i += 2) {
3480
- this.s0 = (this.s0 + words[i] + this.s1) >>> 0;
3481
- this.s1 = (this.s1 + words[i + 1] + this.s0) >>> 0;
3482
- }
3483
- }
3484
-
3485
- matches(s0, s1) {
3486
- return this.s0 === s0 && this.s1 === s1;
3487
- }
3488
- }
3489
-
3490
-
3491
- /***/ }
3492
-
3493
- }]);
3494
- //# sourceMappingURL=node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--24f702.umd.js.map