@powersync/web 0.0.0-dev-20260202162549 → 0.0.0-dev-20260202163643

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 (99) hide show
  1. package/dist/0b19af1befc07ce338dd.wasm +0 -0
  2. package/dist/2632c3bda9473da74fd5.wasm +0 -0
  3. package/dist/64f5351ba3784bfe2f3e.wasm +0 -0
  4. package/dist/9318ca94aac4d0fe0135.wasm +0 -0
  5. package/dist/_journeyapps_wa-sqlite-_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapp-89f0ba.index.umd.js +1878 -0
  6. package/dist/_journeyapps_wa-sqlite-_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapp-89f0ba.index.umd.js.map +1 -0
  7. package/dist/_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapps_wa-sqlite_src_example-2530150.index.umd.js +555 -0
  8. package/dist/_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapps_wa-sqlite_src_example-2530150.index.umd.js.map +1 -0
  9. package/dist/_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapps_wa-sqlite_src_example-2530151.index.umd.js +555 -0
  10. package/dist/_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapps_wa-sqlite_src_example-2530151.index.umd.js.map +1 -0
  11. package/dist/index.umd.js +8253 -0
  12. package/dist/index.umd.js.map +1 -0
  13. package/dist/worker/SharedSyncImplementation.umd.js +19059 -0
  14. package/dist/worker/SharedSyncImplementation.umd.js.map +1 -0
  15. package/dist/worker/WASQLiteDB.umd.js +17736 -0
  16. package/dist/worker/WASQLiteDB.umd.js.map +1 -0
  17. package/dist/worker/node_modules_pnpm_bson_6_10_4_node_modules_bson_lib_bson_mjs.umd.js +4646 -0
  18. package/dist/worker/node_modules_pnpm_bson_6_10_4_node_modules_bson_lib_bson_mjs.umd.js.map +1 -0
  19. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-3a94cf.umd.js +44 -0
  20. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-3a94cf.umd.js.map +1 -0
  21. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-868779.umd.js +44 -0
  22. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-868779.umd.js.map +1 -0
  23. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-f60d0d.umd.js +44 -0
  24. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-f60d0d.umd.js.map +1 -0
  25. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js +44 -0
  26. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js.map +1 -0
  27. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-0d2437.umd.js +2478 -0
  28. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-0d2437.umd.js.map +1 -0
  29. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-1d4e74.umd.js +1820 -0
  30. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-1d4e74.umd.js.map +1 -0
  31. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-3622cf.umd.js +1681 -0
  32. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-3622cf.umd.js.map +1 -0
  33. package/lib/package.json +95 -0
  34. package/lib/src/attachments/IndexDBFileSystemAdapter.d.ts +25 -0
  35. package/lib/src/attachments/IndexDBFileSystemAdapter.js +104 -0
  36. package/lib/src/db/NavigatorTriggerClaimManager.d.ts +6 -0
  37. package/lib/src/db/NavigatorTriggerClaimManager.js +20 -0
  38. package/lib/src/db/PowerSyncDatabase.d.ts +79 -0
  39. package/lib/src/db/PowerSyncDatabase.js +166 -0
  40. package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.d.ts +23 -0
  41. package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.js +26 -0
  42. package/lib/src/db/adapters/AbstractWebSQLOpenFactory.d.ts +17 -0
  43. package/lib/src/db/adapters/AbstractWebSQLOpenFactory.js +33 -0
  44. package/lib/src/db/adapters/AsyncDatabaseConnection.d.ts +49 -0
  45. package/lib/src/db/adapters/AsyncDatabaseConnection.js +1 -0
  46. package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.d.ts +109 -0
  47. package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.js +401 -0
  48. package/lib/src/db/adapters/SSRDBAdapter.d.ts +31 -0
  49. package/lib/src/db/adapters/SSRDBAdapter.js +69 -0
  50. package/lib/src/db/adapters/WebDBAdapter.d.ts +20 -0
  51. package/lib/src/db/adapters/WebDBAdapter.js +1 -0
  52. package/lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.d.ts +59 -0
  53. package/lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js +147 -0
  54. package/lib/src/db/adapters/wa-sqlite/InternalWASQLiteDBAdapter.d.ts +12 -0
  55. package/lib/src/db/adapters/wa-sqlite/InternalWASQLiteDBAdapter.js +19 -0
  56. package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.d.ts +155 -0
  57. package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js +401 -0
  58. package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.d.ts +32 -0
  59. package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.js +49 -0
  60. package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.d.ts +23 -0
  61. package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js +96 -0
  62. package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.d.ts +15 -0
  63. package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.js +21 -0
  64. package/lib/src/db/adapters/web-sql-flags.d.ts +87 -0
  65. package/lib/src/db/adapters/web-sql-flags.js +36 -0
  66. package/lib/src/db/sync/SSRWebStreamingSyncImplementation.d.ts +48 -0
  67. package/lib/src/db/sync/SSRWebStreamingSyncImplementation.js +65 -0
  68. package/lib/src/db/sync/SharedWebStreamingSyncImplementation.d.ts +57 -0
  69. package/lib/src/db/sync/SharedWebStreamingSyncImplementation.js +237 -0
  70. package/lib/src/db/sync/WebRemote.d.ts +9 -0
  71. package/lib/src/db/sync/WebRemote.js +44 -0
  72. package/lib/src/db/sync/WebStreamingSyncImplementation.d.ts +13 -0
  73. package/lib/src/db/sync/WebStreamingSyncImplementation.js +18 -0
  74. package/lib/src/db/sync/userAgent.d.ts +17 -0
  75. package/lib/src/db/sync/userAgent.js +64 -0
  76. package/lib/src/index.d.ts +14 -0
  77. package/lib/src/index.js +14 -0
  78. package/lib/src/shared/navigator.d.ts +1 -0
  79. package/lib/src/shared/navigator.js +6 -0
  80. package/lib/src/worker/db/SharedWASQLiteConnection.d.ts +42 -0
  81. package/lib/src/worker/db/SharedWASQLiteConnection.js +90 -0
  82. package/lib/src/worker/db/WASQLiteDB.worker.d.ts +4 -0
  83. package/lib/src/worker/db/WASQLiteDB.worker.js +69 -0
  84. package/lib/src/worker/db/WorkerWASQLiteConnection.d.ts +9 -0
  85. package/lib/src/worker/db/WorkerWASQLiteConnection.js +12 -0
  86. package/lib/src/worker/db/open-worker-database.d.ts +14 -0
  87. package/lib/src/worker/db/open-worker-database.js +52 -0
  88. package/lib/src/worker/sync/AbstractSharedSyncClientProvider.d.ts +19 -0
  89. package/lib/src/worker/sync/AbstractSharedSyncClientProvider.js +5 -0
  90. package/lib/src/worker/sync/BroadcastLogger.d.ts +47 -0
  91. package/lib/src/worker/sync/BroadcastLogger.js +128 -0
  92. package/lib/src/worker/sync/SharedSyncImplementation.d.ts +137 -0
  93. package/lib/src/worker/sync/SharedSyncImplementation.js +495 -0
  94. package/lib/src/worker/sync/SharedSyncImplementation.worker.d.ts +1 -0
  95. package/lib/src/worker/sync/SharedSyncImplementation.worker.js +11 -0
  96. package/lib/src/worker/sync/WorkerClient.d.ts +31 -0
  97. package/lib/src/worker/sync/WorkerClient.js +84 -0
  98. package/lib/tsconfig.tsbuildinfo +1 -0
  99. package/package.json +3 -3
@@ -0,0 +1,2478 @@
1
+ "use strict";
2
+ (self["webpackChunksdk_web"] = self["webpackChunksdk_web"] || []).push([["node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-0d2437"],{
3
+
4
+ /***/ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/FacadeVFS.js"
5
+ /*!******************************************************************************************************************!*\
6
+ !*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/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@1.4.1/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@1.4.1/node_modules/@journeyapps/wa-sqlite/src/VFS.js"
739
+ /*!************************************************************************************************************!*\
740
+ !*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/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@1.4.1/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@1.4.1/node_modules/@journeyapps/wa-sqlite/src/WebLocksMixin.js"
1208
+ /*!**********************************************************************************************************************!*\
1209
+ !*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/WebLocksMixin.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 */ WebLocksMixin: () => (/* binding */ WebLocksMixin)
1216
+ /* harmony export */ });
1217
+ /* harmony import */ var _VFS_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./VFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/VFS.js");
1218
+
1219
+
1220
+ // Options for navigator.locks.request().
1221
+ /** @type {LockOptions} */ const SHARED = { mode: 'shared' };
1222
+ /** @type {LockOptions} */ const POLL_SHARED = { ifAvailable: true, mode: 'shared' };
1223
+ /** @type {LockOptions} */ const POLL_EXCLUSIVE = { ifAvailable: true, mode: 'exclusive' };
1224
+
1225
+ const POLICIES = ['exclusive', 'shared', 'shared+hint'];
1226
+
1227
+ /**
1228
+ * @typedef LockState
1229
+ * @property {string} baseName
1230
+ * @property {number} type
1231
+ * @property {boolean} writeHint
1232
+ *
1233
+ * These properties are functions that release a specific lock.
1234
+ * @property {(() => void)?} [gate]
1235
+ * @property {(() => void)?} [access]
1236
+ * @property {(() => void)?} [reserved]
1237
+ * @property {(() => void)?} [hint]
1238
+ */
1239
+
1240
+ /**
1241
+ * Mix-in for FacadeVFS that implements the SQLite VFS locking protocol.
1242
+ * @param {*} superclass FacadeVFS (or subclass)
1243
+ * @returns
1244
+ */
1245
+ const WebLocksMixin = superclass => class extends superclass {
1246
+ #options = {
1247
+ lockPolicy: 'exclusive',
1248
+ lockTimeout: Infinity
1249
+ };
1250
+
1251
+ /** @type {Map<number, LockState>} */ #mapIdToState = new Map();
1252
+
1253
+ constructor(name, module, options) {
1254
+ super(name, module, options);
1255
+ Object.assign(this.#options, options);
1256
+ if (POLICIES.indexOf(this.#options.lockPolicy) === -1) {
1257
+ throw new Error(`WebLocksMixin: invalid lock mode: ${options.lockPolicy}`);
1258
+ }
1259
+ }
1260
+
1261
+ /**
1262
+ * @param {number} fileId
1263
+ * @param {number} lockType
1264
+ * @returns {Promise<number>}
1265
+ */
1266
+ async jLock(fileId, lockType) {
1267
+ try {
1268
+ const lockState = this.#getLockState(fileId);
1269
+ if (lockType <= lockState.type) return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1270
+
1271
+ switch (this.#options.lockPolicy) {
1272
+ case 'exclusive':
1273
+ return await this.#lockExclusive(lockState, lockType);
1274
+ case 'shared':
1275
+ case 'shared+hint':
1276
+ return await this.#lockShared(lockState, lockType);
1277
+ }
1278
+ } catch (e) {
1279
+ console.error('WebLocksMixin: lock error', e);
1280
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_LOCK;
1281
+ }
1282
+ }
1283
+
1284
+ /**
1285
+ * @param {number} fileId
1286
+ * @param {number} lockType
1287
+ * @returns {Promise<number>}
1288
+ */
1289
+ async jUnlock(fileId, lockType) {
1290
+ try {
1291
+ const lockState = this.#getLockState(fileId);
1292
+ if (!(lockType < lockState.type)) return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1293
+
1294
+ switch (this.#options.lockPolicy) {
1295
+ case 'exclusive':
1296
+ return await this.#unlockExclusive(lockState, lockType);
1297
+ case 'shared':
1298
+ case 'shared+hint':
1299
+ return await this.#unlockShared(lockState, lockType);
1300
+ }
1301
+ } catch (e) {
1302
+ console.error('WebLocksMixin: unlock error', e);
1303
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_UNLOCK;
1304
+ }
1305
+ }
1306
+
1307
+ /**
1308
+ * @param {number} fileId
1309
+ * @param {DataView} pResOut
1310
+ * @returns {Promise<number>}
1311
+ */
1312
+ async jCheckReservedLock(fileId, pResOut) {
1313
+ try {
1314
+ const lockState = this.#getLockState(fileId);
1315
+ switch (this.#options.lockPolicy) {
1316
+ case 'exclusive':
1317
+ return this.#checkReservedExclusive(lockState, pResOut);
1318
+ case 'shared':
1319
+ case 'shared+hint':
1320
+ return await this.#checkReservedShared(lockState, pResOut);
1321
+ }
1322
+ } catch (e) {
1323
+ console.error('WebLocksMixin: check reserved lock error', e);
1324
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_CHECKRESERVEDLOCK;
1325
+ }
1326
+ pResOut.setInt32(0, 0, true);
1327
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1328
+ }
1329
+
1330
+ /**
1331
+ * @param {number} fileId
1332
+ * @param {number} op
1333
+ * @param {DataView} pArg
1334
+ * @returns {number|Promise<number>}
1335
+ */
1336
+ jFileControl(fileId, op, pArg) {
1337
+ if (op === WebLocksMixin.WRITE_HINT_OP_CODE &&
1338
+ this.#options.lockPolicy === 'shared+hint'){
1339
+ const lockState = this.#getLockState(fileId);
1340
+ lockState.writeHint = true;
1341
+ }
1342
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOTFOUND;
1343
+ }
1344
+
1345
+ #getLockState(fileId) {
1346
+ let lockState = this.#mapIdToState.get(fileId);
1347
+ if (!lockState) {
1348
+ // The state doesn't exist yet so create it.
1349
+ const name = this.getFilename(fileId);
1350
+ lockState = {
1351
+ baseName: name,
1352
+ type: _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_NONE,
1353
+ writeHint: false
1354
+ };
1355
+ this.#mapIdToState.set(fileId, lockState);
1356
+ }
1357
+ return lockState
1358
+ }
1359
+
1360
+ /**
1361
+ * @param {LockState} lockState
1362
+ * @param {number} lockType
1363
+ * @returns
1364
+ */
1365
+ async #lockExclusive(lockState, lockType) {
1366
+ if (!lockState.access) {
1367
+ if (!await this.#acquire(lockState, 'access')) {
1368
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BUSY;
1369
+ }
1370
+ console.assert(!!lockState.access);
1371
+ }
1372
+ lockState.type = lockType;
1373
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1374
+ }
1375
+
1376
+ /**
1377
+ * @param {LockState} lockState
1378
+ * @param {number} lockType
1379
+ * @returns {number}
1380
+ */
1381
+ #unlockExclusive(lockState, lockType) {
1382
+ if (lockType === _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_NONE) {
1383
+ lockState.access?.();
1384
+ console.assert(!lockState.access);
1385
+ }
1386
+ lockState.type = lockType;
1387
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1388
+ }
1389
+
1390
+ /**
1391
+ * @param {LockState} lockState
1392
+ * @param {DataView} pResOut
1393
+ * @returns {number}
1394
+ */
1395
+ #checkReservedExclusive(lockState, pResOut) {
1396
+ pResOut.setInt32(0, 0, true);
1397
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1398
+ }
1399
+
1400
+ /**
1401
+ * @param {LockState} lockState
1402
+ * @param {number} lockType
1403
+ * @returns
1404
+ */
1405
+ async #lockShared(lockState, lockType) {
1406
+ switch (lockState.type) {
1407
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_NONE:
1408
+ switch (lockType) {
1409
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_SHARED:
1410
+ if (lockState.writeHint) {
1411
+ // xFileControl() has hinted that this transaction will
1412
+ // write. Acquire the hint lock, which is required to reach
1413
+ // the RESERVED state.
1414
+ if (!await this.#acquire(lockState, 'hint')) {
1415
+ // Timeout before lock acquired.
1416
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BUSY;
1417
+ }
1418
+ }
1419
+
1420
+ // Must have the gate lock to request the access lock.
1421
+ if (!await this.#acquire(lockState, 'gate', SHARED)) {
1422
+ // Timeout before lock acquired.
1423
+ lockState.hint?.();
1424
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BUSY;
1425
+ }
1426
+ await this.#acquire(lockState, 'access', SHARED);
1427
+ lockState.gate();
1428
+ console.assert(!lockState.gate);
1429
+ console.assert(!!lockState.access);
1430
+ console.assert(!lockState.reserved);
1431
+ break;
1432
+
1433
+ default:
1434
+ throw new Error('unsupported lock transition');
1435
+ }
1436
+ break;
1437
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_SHARED:
1438
+ switch (lockType) {
1439
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_RESERVED:
1440
+ if (this.#options.lockPolicy === 'shared+hint') {
1441
+ // Ideally we should already have the hint lock, but if not
1442
+ // poll for it here.
1443
+ if (!lockState.hint &&
1444
+ !await this.#acquire(lockState, 'hint', POLL_EXCLUSIVE)) {
1445
+ // Another connection has the hint lock so this is a
1446
+ // deadlock. This connection must retry.
1447
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BUSY;
1448
+ }
1449
+ }
1450
+
1451
+ // Poll for the reserved lock. This should always succeed
1452
+ // if all clients use the 'shared+hint' policy.
1453
+ if (!await this.#acquire(lockState, 'reserved', POLL_EXCLUSIVE)) {
1454
+ // This is a deadlock. The connection holding the reserved
1455
+ // lock blocks us, and it can't acquire an exclusive access
1456
+ // lock because we hold a shared access lock. This connection
1457
+ // must retry.
1458
+ lockState.hint?.();
1459
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BUSY;
1460
+ }
1461
+ lockState.access();
1462
+ console.assert(!lockState.gate);
1463
+ console.assert(!lockState.access);
1464
+ console.assert(!!lockState.reserved);
1465
+ break;
1466
+
1467
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_EXCLUSIVE:
1468
+ // Jumping directly from SHARED to EXCLUSIVE without passing
1469
+ // through RESERVED is only done with a hot journal.
1470
+ if (!await this.#acquire(lockState, 'gate')) {
1471
+ // Timeout before lock acquired.
1472
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BUSY;
1473
+ }
1474
+ lockState.access();
1475
+ if (!await this.#acquire(lockState, 'access')) {
1476
+ // Timeout before lock acquired.
1477
+ lockState.gate();
1478
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BUSY;
1479
+ }
1480
+ console.assert(!!lockState.gate);
1481
+ console.assert(!!lockState.access);
1482
+ console.assert(!lockState.reserved);
1483
+ break;
1484
+
1485
+ default:
1486
+ throw new Error('unsupported lock transition');
1487
+ }
1488
+ break;
1489
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_RESERVED:
1490
+ switch (lockType) {
1491
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_EXCLUSIVE:
1492
+ // Prevent other connections from entering the SHARED state.
1493
+ if (!await this.#acquire(lockState, 'gate')) {
1494
+ // Timeout before lock acquired.
1495
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BUSY;
1496
+ }
1497
+
1498
+ // Block until all other connections exit the SHARED state.
1499
+ if (!await this.#acquire(lockState, 'access')) {
1500
+ // Timeout before lock acquired.
1501
+ lockState.gate();
1502
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BUSY;
1503
+ }
1504
+ console.assert(!!lockState.gate);
1505
+ console.assert(!!lockState.access);
1506
+ console.assert(!!lockState.reserved);
1507
+ break;
1508
+
1509
+ default:
1510
+ throw new Error('unsupported lock transition');
1511
+ }
1512
+ break;
1513
+ }
1514
+ lockState.type = lockType;
1515
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1516
+ }
1517
+
1518
+ /**
1519
+ * @param {LockState} lockState
1520
+ * @param {number} lockType
1521
+ * @returns
1522
+ */
1523
+ async #unlockShared(lockState, lockType) {
1524
+ // lockType can only be SQLITE_LOCK_SHARED or SQLITE_LOCK_NONE.
1525
+ if (lockType === _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_NONE) {
1526
+ lockState.access?.();
1527
+ lockState.gate?.();
1528
+ lockState.reserved?.();
1529
+ lockState.hint?.();
1530
+ lockState.writeHint = false;
1531
+ console.assert(!lockState.access);
1532
+ console.assert(!lockState.gate);
1533
+ console.assert(!lockState.reserved);
1534
+ console.assert(!lockState.hint);
1535
+ } else { // lockType === VFS.SQLITE_LOCK_SHARED
1536
+ switch (lockState.type) {
1537
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_EXCLUSIVE:
1538
+ // Release our exclusive access lock and reacquire it with a
1539
+ // shared lock. This should always succeed because we hold
1540
+ // the gate lock.
1541
+ lockState.access();
1542
+ await this.#acquire(lockState, 'access', SHARED);
1543
+
1544
+ // Release our gate and reserved locks. We might not have a
1545
+ // reserved lock if we were handling a hot journal.
1546
+ lockState.gate();
1547
+ lockState.reserved?.();
1548
+ lockState.hint?.();
1549
+ console.assert(!!lockState.access);
1550
+ console.assert(!lockState.gate);
1551
+ console.assert(!lockState.reserved);
1552
+ break;
1553
+
1554
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_RESERVED:
1555
+ // This transition is rare, probably only on an I/O error
1556
+ // while writing to a journal file.
1557
+ await this.#acquire(lockState, 'access', SHARED);
1558
+ lockState.reserved();
1559
+ lockState.hint?.();
1560
+ console.assert(!!lockState.access);
1561
+ console.assert(!lockState.gate);
1562
+ console.assert(!lockState.reserved);
1563
+ break;
1564
+ }
1565
+ }
1566
+ lockState.type = lockType;
1567
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1568
+ }
1569
+
1570
+ /**
1571
+ * @param {LockState} lockState
1572
+ * @param {DataView} pResOut
1573
+ * @returns {Promise<number>}
1574
+ */
1575
+ async #checkReservedShared(lockState, pResOut) {
1576
+ if (await this.#acquire(lockState, 'reserved', POLL_SHARED)) {
1577
+ // We were able to get the lock so it was not reserved.
1578
+ lockState.reserved();
1579
+ pResOut.setInt32(0, 0, true);
1580
+ } else {
1581
+ pResOut.setInt32(0, 1, true);
1582
+ }
1583
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1584
+ }
1585
+
1586
+ /**
1587
+ * @param {LockState} lockState
1588
+ * @param {'gate'|'access'|'reserved'|'hint'} name
1589
+ * @param {LockOptions} options
1590
+ * @returns {Promise<boolean>}
1591
+ */
1592
+ #acquire(lockState, name, options = {}) {
1593
+ console.assert(!lockState[name]);
1594
+ return new Promise(resolve => {
1595
+ if (!options.ifAvailable && this.#options.lockTimeout < Infinity) {
1596
+ // Add a timeout to the lock request.
1597
+ const controller = new AbortController();
1598
+ options = Object.assign({}, options, { signal: controller.signal });
1599
+ setTimeout(() => {
1600
+ controller.abort();
1601
+ resolve?.(false);
1602
+ }, this.#options.lockTimeout);
1603
+ }
1604
+
1605
+ const lockName = `lock##${lockState.baseName}##${name}`;
1606
+ navigator.locks.request(lockName, options, lock => {
1607
+ if (lock) {
1608
+ return new Promise(release => {
1609
+ lockState[name] = () => {
1610
+ release();
1611
+ lockState[name] = null;
1612
+ };
1613
+ resolve(true);
1614
+ resolve = null;
1615
+ });
1616
+ } else {
1617
+ lockState[name] = null;
1618
+ resolve(false);
1619
+ resolve = null;
1620
+ }
1621
+ }).catch(e => {
1622
+ if (e.name !== 'AbortError') throw e;
1623
+ });
1624
+ });
1625
+ }
1626
+ }
1627
+
1628
+ WebLocksMixin.WRITE_HINT_OP_CODE = -9999;
1629
+
1630
+ /***/ },
1631
+
1632
+ /***/ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js"
1633
+ /*!***********************************************************************************************************************************!*\
1634
+ !*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js ***!
1635
+ \***********************************************************************************************************************************/
1636
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1637
+
1638
+ __webpack_require__.r(__webpack_exports__);
1639
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1640
+ /* harmony export */ IDBBatchAtomicVFS: () => (/* binding */ IDBBatchAtomicVFS),
1641
+ /* harmony export */ IDBContext: () => (/* binding */ IDBContext)
1642
+ /* harmony export */ });
1643
+ /* harmony import */ var _FacadeVFS_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../FacadeVFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/FacadeVFS.js");
1644
+ /* harmony import */ var _VFS_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../VFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/VFS.js");
1645
+ /* harmony import */ var _WebLocksMixin_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../WebLocksMixin.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/WebLocksMixin.js");
1646
+ // Copyright 2024 Roy T. Hashimoto. All Rights Reserved.
1647
+
1648
+
1649
+
1650
+
1651
+ const RETRYABLE_ERRORS = new Set([
1652
+ 'TransactionInactiveError',
1653
+ 'InvalidStateError'
1654
+ ]);
1655
+
1656
+ /**
1657
+ * @typedef Metadata
1658
+ * @property {string} name
1659
+ * @property {number} fileSize
1660
+ * @property {number} version
1661
+ * @property {number} [pendingVersion]
1662
+ */
1663
+
1664
+ class File {
1665
+ /** @type {string} */ path;
1666
+ /** @type {number} */ flags;
1667
+
1668
+ /** @type {Metadata} */ metadata;
1669
+ /** @type {number} */ fileSize = 0;
1670
+
1671
+ /** @type {boolean} */ needsMetadataSync = false;
1672
+ /** @type {Metadata} */ rollback = null;
1673
+ /** @type {Set<number>} */ changedPages = new Set();
1674
+
1675
+ /** @type {string} */ synchronous = 'full';
1676
+ /** @type {IDBTransactionOptions} */ txOptions = { durability: 'strict' };
1677
+
1678
+ constructor(path, flags, metadata) {
1679
+ this.path = path;
1680
+ this.flags = flags;
1681
+ this.metadata = metadata;
1682
+ }
1683
+ }
1684
+
1685
+ class IDBBatchAtomicVFS extends (0,_WebLocksMixin_js__WEBPACK_IMPORTED_MODULE_2__.WebLocksMixin)(_FacadeVFS_js__WEBPACK_IMPORTED_MODULE_0__.FacadeVFS) {
1686
+ /** @type {Map<number, File>} */ mapIdToFile = new Map();
1687
+ lastError = null;
1688
+
1689
+ log = null; // console.log
1690
+
1691
+ /** @type {Promise} */ #isReady;
1692
+ /** @type {IDBContext} */ #idb;
1693
+
1694
+ static async create(name, module, options) {
1695
+ const vfs = new IDBBatchAtomicVFS(name, module, options);
1696
+ await vfs.isReady();
1697
+ return vfs;
1698
+ }
1699
+
1700
+ constructor(name, module, options = {}) {
1701
+ super(name, module, options);
1702
+ this.#isReady = this.#initialize(options.idbName ?? name);
1703
+ }
1704
+
1705
+ async #initialize(name) {
1706
+ this.#idb = await IDBContext.create(name);
1707
+ }
1708
+
1709
+ close() {
1710
+ this.#idb.close();
1711
+ }
1712
+
1713
+ async isReady() {
1714
+ await super.isReady();
1715
+ await this.#isReady;
1716
+ }
1717
+
1718
+ getFilename(fileId) {
1719
+ const pathname = this.mapIdToFile.get(fileId).path;
1720
+ return `IDB(${this.name}):${pathname}`
1721
+ }
1722
+
1723
+ /**
1724
+ * @param {string?} zName
1725
+ * @param {number} fileId
1726
+ * @param {number} flags
1727
+ * @param {DataView} pOutFlags
1728
+ * @returns {Promise<number>}
1729
+ */
1730
+ async jOpen(zName, fileId, flags, pOutFlags) {
1731
+ try {
1732
+ const url = new URL(zName || Math.random().toString(36).slice(2), 'file://');
1733
+ const path = url.pathname;
1734
+
1735
+ let meta = await this.#idb.q(({ metadata }) => metadata.get(path));
1736
+ if (!meta && (flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_CREATE)) {
1737
+ meta = {
1738
+ name: path,
1739
+ fileSize: 0,
1740
+ version: 0
1741
+ };
1742
+ await this.#idb.q(({ metadata }) => metadata.put(meta), 'rw');
1743
+ }
1744
+
1745
+ if (!meta) {
1746
+ throw new Error(`File ${path} not found`);
1747
+ }
1748
+
1749
+ const file = new File(path, flags, meta);
1750
+ this.mapIdToFile.set(fileId, file);
1751
+ pOutFlags.setInt32(0, flags, true);
1752
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1753
+ } catch (e) {
1754
+ this.lastError = e;
1755
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_CANTOPEN;
1756
+ }
1757
+ }
1758
+
1759
+ /**
1760
+ * @param {string} zName
1761
+ * @param {number} syncDir
1762
+ * @returns {Promise<number>}
1763
+ */
1764
+ async jDelete(zName, syncDir) {
1765
+ try {
1766
+ const url = new URL(zName, 'file://');
1767
+ const path = url.pathname;
1768
+
1769
+ this.#idb.q(({ metadata, blocks }) => {
1770
+ const range = IDBKeyRange.bound([path, -Infinity], [path, Infinity]);
1771
+ blocks.delete(range);
1772
+ metadata.delete(path);
1773
+ }, 'rw');
1774
+
1775
+ if (syncDir) {
1776
+ await this.#idb.sync(false);
1777
+ }
1778
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1779
+ } catch (e) {
1780
+ this.lastError = e;
1781
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_DELETE;
1782
+ }
1783
+ }
1784
+
1785
+ /**
1786
+ * @param {string} zName
1787
+ * @param {number} flags
1788
+ * @param {DataView} pResOut
1789
+ * @returns {Promise<number>}
1790
+ */
1791
+ async jAccess(zName, flags, pResOut) {
1792
+ try {
1793
+ const url = new URL(zName, 'file://');
1794
+ const path = url.pathname;
1795
+
1796
+ const meta = await this.#idb.q(({ metadata }) => metadata.get(path));
1797
+ pResOut.setInt32(0, meta ? 1 : 0, true);
1798
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1799
+ } catch (e) {
1800
+ this.lastError = e;
1801
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_ACCESS;
1802
+ }
1803
+ }
1804
+
1805
+ /**
1806
+ * @param {number} fileId
1807
+ * @returns {Promise<number>}
1808
+ */
1809
+ async jClose(fileId) {
1810
+ try {
1811
+ const file = this.mapIdToFile.get(fileId);
1812
+ this.mapIdToFile.delete(fileId);
1813
+
1814
+ if (file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_DELETEONCLOSE) {
1815
+ await this.#idb.q(({ metadata, blocks }) => {
1816
+ metadata.delete(file.path);
1817
+ blocks.delete(IDBKeyRange.bound([file.path, 0], [file.path, Infinity]));
1818
+ }, 'rw');
1819
+ }
1820
+
1821
+ if (file.needsMetadataSync) {
1822
+ this.#idb.q(({ metadata }) => metadata.put(file.metadata), 'rw');
1823
+ }
1824
+ await this.#idb.sync(file.synchronous === 'full');
1825
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1826
+ } catch (e) {
1827
+ this.lastError = e;
1828
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_CLOSE;
1829
+ }
1830
+ }
1831
+
1832
+ /**
1833
+ * @param {number} fileId
1834
+ * @param {Uint8Array} pData
1835
+ * @param {number} iOffset
1836
+ * @returns {Promise<number>}
1837
+ */
1838
+ async jRead(fileId, pData, iOffset) {
1839
+ try {
1840
+ const file = this.mapIdToFile.get(fileId);
1841
+
1842
+ let pDataOffset = 0;
1843
+ while (pDataOffset < pData.byteLength) {
1844
+ // Fetch the IndexedDB block for this file location.
1845
+ const fileOffset = iOffset + pDataOffset;
1846
+ const block = await this.#idb.q(({ blocks }) => {
1847
+ const range = IDBKeyRange.bound([file.path, -fileOffset], [file.path, Infinity]);
1848
+ return blocks.get(range);
1849
+ });
1850
+
1851
+ if (!block || block.data.byteLength - block.offset <= fileOffset) {
1852
+ pData.fill(0, pDataOffset);
1853
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_SHORT_READ;
1854
+ }
1855
+
1856
+ // Copy block data.
1857
+ const dst = pData.subarray(pDataOffset);
1858
+ const srcOffset = fileOffset + block.offset;
1859
+ const nBytesToCopy = Math.min(
1860
+ Math.max(block.data.byteLength - srcOffset, 0),
1861
+ dst.byteLength);
1862
+ dst.set(block.data.subarray(srcOffset, srcOffset + nBytesToCopy));
1863
+ pDataOffset += nBytesToCopy;
1864
+ }
1865
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1866
+ } catch (e) {
1867
+ this.lastError = e;
1868
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_READ;
1869
+ }
1870
+ }
1871
+
1872
+ /**
1873
+ * @param {number} fileId
1874
+ * @param {Uint8Array} pData
1875
+ * @param {number} iOffset
1876
+ * @returns {number}
1877
+ */
1878
+ jWrite(fileId, pData, iOffset) {
1879
+ try {
1880
+ const file = this.mapIdToFile.get(fileId);
1881
+ if (file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB) {
1882
+ if (!file.rollback) {
1883
+ // Begin a new write transaction.
1884
+ // Add pendingVersion to the metadata in IndexedDB. If we crash
1885
+ // during the transaction, this lets subsequent connections
1886
+ // know to remove blocks from the failed transaction.
1887
+ const pending = Object.assign(
1888
+ { pendingVersion: file.metadata.version - 1 },
1889
+ file.metadata);
1890
+ this.#idb.q(({ metadata }) => metadata.put(pending), 'rw', file.txOptions);
1891
+
1892
+ file.rollback = Object.assign({}, file.metadata);
1893
+ file.metadata.version--;
1894
+ }
1895
+ }
1896
+
1897
+ if (file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB) {
1898
+ file.changedPages.add(iOffset);
1899
+ }
1900
+
1901
+ const data = pData.slice();
1902
+ const version = file.metadata.version;
1903
+ const isOverwrite = iOffset < file.metadata.fileSize;
1904
+ if (!isOverwrite ||
1905
+ file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB ||
1906
+ file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_TEMP_DB) {
1907
+ const block = {
1908
+ path: file.path,
1909
+ offset: -iOffset,
1910
+ version: version,
1911
+ data: pData.slice()
1912
+ };
1913
+ this.#idb.q(({ blocks }) => {
1914
+ blocks.put(block);
1915
+ file.changedPages.add(iOffset);
1916
+ }, 'rw', file.txOptions);
1917
+ } else {
1918
+ this.#idb.q(async ({ blocks }) => {
1919
+ // Read the existing block.
1920
+ const range = IDBKeyRange.bound(
1921
+ [file.path, -iOffset],
1922
+ [file.path, Infinity]);
1923
+ const block = await blocks.get(range);
1924
+
1925
+ // Modify the block data.
1926
+ // @ts-ignore
1927
+ block.data.subarray(iOffset + block.offset).set(data);
1928
+
1929
+ // Write back.
1930
+ blocks.put(block);
1931
+ }, 'rw', file.txOptions);
1932
+
1933
+ }
1934
+
1935
+ if (file.metadata.fileSize < iOffset + pData.length) {
1936
+ file.metadata.fileSize = iOffset + pData.length;
1937
+ file.needsMetadataSync = true;
1938
+ }
1939
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1940
+ } catch (e) {
1941
+ this.lastError = e;
1942
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_WRITE;
1943
+ }
1944
+ }
1945
+
1946
+ /**
1947
+ * @param {number} fileId
1948
+ * @param {number} iSize
1949
+ * @returns {number}
1950
+ */
1951
+ jTruncate(fileId, iSize) {
1952
+ try {
1953
+ const file = this.mapIdToFile.get(fileId);
1954
+ if (iSize < file.metadata.fileSize) {
1955
+ this.#idb.q(({ blocks }) => {
1956
+ const range = IDBKeyRange.bound(
1957
+ [file.path, -Infinity],
1958
+ [file.path, -iSize, Infinity]);
1959
+ blocks.delete(range);
1960
+ }, 'rw', file.txOptions);
1961
+ file.metadata.fileSize = iSize;
1962
+ file.needsMetadataSync = true;
1963
+ }
1964
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1965
+ } catch (e) {
1966
+ this.lastError = e;
1967
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_TRUNCATE;
1968
+ }
1969
+ }
1970
+
1971
+ /**
1972
+ * @param {number} fileId
1973
+ * @param {number} flags
1974
+ * @returns {Promise<number>}
1975
+ */
1976
+ async jSync(fileId, flags) {
1977
+ try {
1978
+ const file = this.mapIdToFile.get(fileId);
1979
+ if (file.needsMetadataSync) {
1980
+ this.#idb.q(({ metadata }) => metadata.put(file.metadata), 'rw', file.txOptions);
1981
+ file.needsMetadataSync = false;
1982
+ }
1983
+
1984
+ if (file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB) {
1985
+ // Sync is only needed here for durability. Visibility for other
1986
+ // connections is ensured in jUnlock().
1987
+ if (file.synchronous === 'full') {
1988
+ await this.#idb.sync(true);
1989
+ }
1990
+ } else {
1991
+ await this.#idb.sync(file.synchronous === 'full');
1992
+ }
1993
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
1994
+ } catch (e) {
1995
+ this.lastError = e;
1996
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_FSYNC;
1997
+ }
1998
+ }
1999
+
2000
+ /**
2001
+ * @param {number} fileId
2002
+ * @param {DataView} pSize64
2003
+ * @returns {number}
2004
+ */
2005
+ jFileSize(fileId, pSize64) {
2006
+ try {
2007
+ const file = this.mapIdToFile.get(fileId);
2008
+ pSize64.setBigInt64(0, BigInt(file.metadata.fileSize), true);
2009
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
2010
+ } catch (e) {
2011
+ this.lastError = e;
2012
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR_FSTAT;
2013
+ }
2014
+ }
2015
+
2016
+ /**
2017
+ * @param {number} fileId
2018
+ * @param {number} lockType
2019
+ * @returns {Promise<number>}
2020
+ */
2021
+ async jLock(fileId, lockType) {
2022
+ // Call the actual lock implementation.
2023
+ const file = this.mapIdToFile.get(fileId);
2024
+ const result = await super.jLock(fileId, lockType);
2025
+
2026
+ if (lockType === _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_LOCK_SHARED) {
2027
+ // Update metadata.
2028
+ file.metadata = await this.#idb.q(async ({ metadata, blocks }) => {
2029
+ // @ts-ignore
2030
+ /** @type {Metadata} */ const m = await metadata.get(file.path);
2031
+ if (m.pendingVersion) {
2032
+ console.warn(`removing failed transaction ${m.pendingVersion}`);
2033
+ await new Promise((resolve, reject) => {
2034
+ const range = IDBKeyRange.bound([m.name, -Infinity], [m.name, Infinity]);
2035
+ const request = blocks.openCursor(range);
2036
+ request.onsuccess = () => {
2037
+ const cursor = request.result;
2038
+ if (cursor) {
2039
+ const block = cursor.value;
2040
+ if (block.version < m.version) {
2041
+ cursor.delete();
2042
+ }
2043
+ cursor.continue();
2044
+ } else {
2045
+ resolve();
2046
+ }
2047
+ };
2048
+ request.onerror = () => reject(request.error);
2049
+ })
2050
+
2051
+ delete m.pendingVersion;
2052
+ metadata.put(m);
2053
+ }
2054
+ return m;
2055
+ }, 'rw', file.txOptions);
2056
+ }
2057
+ return result;
2058
+ }
2059
+
2060
+ /**
2061
+ * @param {number} fileId
2062
+ * @param {number} lockType
2063
+ * @returns {Promise<number>}
2064
+ */
2065
+ async jUnlock(fileId, lockType) {
2066
+ if (lockType === _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_LOCK_NONE) {
2067
+ const file = this.mapIdToFile.get(fileId);
2068
+ await this.#idb.sync(file.synchronous === 'full');
2069
+ }
2070
+
2071
+ // Call the actual unlock implementation.
2072
+ return super.jUnlock(fileId, lockType);
2073
+ }
2074
+
2075
+ /**
2076
+ * @param {number} fileId
2077
+ * @param {number} op
2078
+ * @param {DataView} pArg
2079
+ * @returns {number|Promise<number>}
2080
+ */
2081
+ jFileControl(fileId, op, pArg) {
2082
+ try {
2083
+ const file = this.mapIdToFile.get(fileId);
2084
+ switch (op) {
2085
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_FCNTL_PRAGMA:
2086
+ const key = extractString(pArg, 4);
2087
+ const value = extractString(pArg, 8);
2088
+ this.log?.('xFileControl', file.path, 'PRAGMA', key, value);
2089
+ const setPragmaResponse = response => {
2090
+ const encoded = new TextEncoder().encode(response);
2091
+ const out = this._module._sqlite3_malloc(encoded.byteLength);
2092
+ const outArray = this._module.HEAPU8.subarray(out, out + encoded.byteLength);
2093
+ outArray.set(encoded);
2094
+ pArg.setUint32(0, out, true);
2095
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_ERROR;
2096
+ };
2097
+ switch (key.toLowerCase()) {
2098
+ case 'page_size':
2099
+ if (file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OPEN_MAIN_DB) {
2100
+ // Don't allow changing the page size.
2101
+ if (value && file.metadata.fileSize) {
2102
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_ERROR;
2103
+ }
2104
+ }
2105
+ break;
2106
+ case 'synchronous':
2107
+ if (value) {
2108
+ switch (value.toLowerCase()) {
2109
+ case '0':
2110
+ case 'off':
2111
+ file.synchronous = 'off';
2112
+ file.txOptions = { durability: 'relaxed' };
2113
+ break;
2114
+ case '1':
2115
+ case 'normal':
2116
+ file.synchronous = 'normal';
2117
+ file.txOptions = { durability: 'relaxed' };
2118
+ break;
2119
+ case '2':
2120
+ case '3':
2121
+ case 'full':
2122
+ case 'extra':
2123
+ file.synchronous = 'full';
2124
+ file.txOptions = { durability: 'strict' };
2125
+ break;
2126
+ }
2127
+ }
2128
+ break;
2129
+ case 'write_hint':
2130
+ return super.jFileControl(fileId, _WebLocksMixin_js__WEBPACK_IMPORTED_MODULE_2__.WebLocksMixin.WRITE_HINT_OP_CODE, null);
2131
+ }
2132
+ break;
2133
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_FCNTL_SYNC:
2134
+ this.log?.('xFileControl', file.path, 'SYNC');
2135
+ if (file.rollback) {
2136
+ const commitMetadata = Object.assign({}, file.metadata);
2137
+ const prevFileSize = file.rollback.fileSize
2138
+ this.#idb.q(({ metadata, blocks }) => {
2139
+ metadata.put(commitMetadata);
2140
+
2141
+ // Remove old page versions.
2142
+ for (const offset of file.changedPages) {
2143
+ if (offset < prevFileSize) {
2144
+ const range = IDBKeyRange.bound(
2145
+ [file.path, -offset, commitMetadata.version],
2146
+ [file.path, -offset, Infinity],
2147
+ true);
2148
+ blocks.delete(range);
2149
+ }
2150
+ }
2151
+ file.changedPages.clear();
2152
+ }, 'rw', file.txOptions);
2153
+ file.needsMetadataSync = false;
2154
+ file.rollback = null;
2155
+ }
2156
+ break;
2157
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_FCNTL_BEGIN_ATOMIC_WRITE:
2158
+ // Every write transaction is atomic, so this is a no-op.
2159
+ this.log?.('xFileControl', file.path, 'BEGIN_ATOMIC_WRITE');
2160
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
2161
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_FCNTL_COMMIT_ATOMIC_WRITE:
2162
+ // Every write transaction is atomic, so this is a no-op.
2163
+ this.log?.('xFileControl', file.path, 'COMMIT_ATOMIC_WRITE');
2164
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
2165
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE:
2166
+ this.log?.('xFileControl', file.path, 'ROLLBACK_ATOMIC_WRITE');
2167
+ file.metadata = file.rollback;
2168
+ const rollbackMetadata = Object.assign({}, file.metadata);
2169
+ this.#idb.q(({ metadata, blocks }) => {
2170
+ metadata.put(rollbackMetadata);
2171
+
2172
+ // Remove pages.
2173
+ for (const offset of file.changedPages) {
2174
+ blocks.delete([file.path, -offset, rollbackMetadata.version - 1]);
2175
+ }
2176
+ file.changedPages.clear();
2177
+ }, 'rw', file.txOptions);
2178
+ file.needsMetadataSync = false;
2179
+ file.rollback = null;
2180
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK;
2181
+ }
2182
+ } catch (e) {
2183
+ this.lastError = e;
2184
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOERR;
2185
+ }
2186
+ return super.jFileControl(fileId, op, pArg);
2187
+ }
2188
+
2189
+ /**
2190
+ * @param {number} pFile
2191
+ * @returns {number|Promise<number>}
2192
+ */
2193
+ jDeviceCharacteristics(pFile) {
2194
+ return 0
2195
+ | _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOCAP_BATCH_ATOMIC
2196
+ | _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN;
2197
+ }
2198
+
2199
+ /**
2200
+ * @param {Uint8Array} zBuf
2201
+ * @returns {number|Promise<number>}
2202
+ */
2203
+ jGetLastError(zBuf) {
2204
+ if (this.lastError) {
2205
+ console.error(this.lastError);
2206
+ const outputArray = zBuf.subarray(0, zBuf.byteLength - 1);
2207
+ const { written } = new TextEncoder().encodeInto(this.lastError.message, outputArray);
2208
+ zBuf[written] = 0;
2209
+ }
2210
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_1__.SQLITE_OK
2211
+ }
2212
+ }
2213
+
2214
+ function extractString(dataView, offset) {
2215
+ const p = dataView.getUint32(offset, true);
2216
+ if (p) {
2217
+ const chars = new Uint8Array(dataView.buffer, p);
2218
+ return new TextDecoder().decode(chars.subarray(0, chars.indexOf(0)));
2219
+ }
2220
+ return null;
2221
+ }
2222
+
2223
+ class IDBContext {
2224
+ /** @type {IDBDatabase} */ #database;
2225
+
2226
+ /** @type {Promise} */ #chain = null;
2227
+ /** @type {Promise<any>} */ #txComplete = Promise.resolve();
2228
+ /** @type {IDBRequest?} */ #request = null;
2229
+ /** @type {WeakSet<IDBTransaction>} */ #txPending = new WeakSet();
2230
+
2231
+ log = null;
2232
+
2233
+ static async create(name) {
2234
+ const database = await new Promise((resolve, reject) => {
2235
+ const request = indexedDB.open(name, 6);
2236
+ request.onupgradeneeded = async event => {
2237
+ const db = request.result;
2238
+ if (event.oldVersion) {
2239
+ console.log(`Upgrading IndexedDB from version ${event.oldVersion}`);
2240
+ }
2241
+ switch (event.oldVersion) {
2242
+ case 0:
2243
+ // Start with the original schema.
2244
+ db.createObjectStore('blocks', { keyPath: ['path', 'offset', 'version']})
2245
+ .createIndex('version', ['path', 'version']);
2246
+ // fall through intentionally
2247
+ case 5:
2248
+ const tx = request.transaction;
2249
+ const blocks = tx.objectStore('blocks');
2250
+ blocks.deleteIndex('version');
2251
+ const metadata = db.createObjectStore('metadata', { keyPath: 'name' });
2252
+
2253
+ await new Promise((resolve, reject) => {
2254
+ // Iterate over all the blocks.
2255
+ let lastBlock = {};
2256
+ const request = tx.objectStore('blocks').openCursor();
2257
+ request.onsuccess = () => {
2258
+ const cursor = request.result;
2259
+ if (cursor) {
2260
+ const block = cursor.value;
2261
+ if (typeof block.offset !== 'number' ||
2262
+ (block.path === lastBlock.path && block.offset === lastBlock.offset)) {
2263
+ // Remove superceded block (or the "purge" info).
2264
+ cursor.delete();
2265
+ } else if (block.offset === 0) {
2266
+ // Move metadata to its own store.
2267
+ metadata.put({
2268
+ name: block.path,
2269
+ fileSize: block.fileSize,
2270
+ version: block.version
2271
+ });
2272
+
2273
+ delete block.fileSize;
2274
+ cursor.update(block);
2275
+ }
2276
+ lastBlock = block;
2277
+ cursor.continue();
2278
+ } else {
2279
+ resolve();
2280
+ }
2281
+ };
2282
+ request.onerror = () => reject(request.error);
2283
+ });
2284
+ break;
2285
+ }
2286
+ };
2287
+ request.onsuccess = () => resolve(request.result);
2288
+ request.onerror = () => reject(request.error);
2289
+ });
2290
+ return new IDBContext(database);
2291
+ }
2292
+
2293
+ constructor(database) {
2294
+ this.#database = database;
2295
+ }
2296
+
2297
+ close() {
2298
+ this.#database.close();
2299
+ }
2300
+
2301
+ /**
2302
+ * @param {(stores: Object.<string, IDBObjectStore>) => any} f
2303
+ * @param {'ro'|'rw'} mode
2304
+ * @returns {Promise<any>}
2305
+ */
2306
+ q(f, mode = 'ro', options = {}) {
2307
+ /** @type {IDBTransactionMode} */
2308
+ const txMode = mode === 'ro' ? 'readonly' : 'readwrite';
2309
+ const txOptions = Object.assign({
2310
+ /** @type {IDBTransactionDurability} */ durability: 'default'
2311
+ }, options);
2312
+
2313
+ // Ensure that queries run sequentially. If any function rejects,
2314
+ // or any request has an error, or the transaction does not commit,
2315
+ // then no subsequent functions will run until sync() or reset().
2316
+ this.#chain = (this.#chain || Promise.resolve())
2317
+ .then(() => this.#q(f, txMode, txOptions));
2318
+ return this.#chain;
2319
+ }
2320
+
2321
+ /**
2322
+ * @param {(stores: Object.<string, IDBObjectStore>) => any} f
2323
+ * @param {IDBTransactionMode} mode
2324
+ * @param {IDBTransactionOptions} options
2325
+ * @returns {Promise<any>}
2326
+ */
2327
+ async #q(f, mode, options) {
2328
+ /** @type {IDBTransaction} */ let tx;
2329
+ if (this.#request &&
2330
+ this.#txPending.has(this.#request.transaction) &&
2331
+ this.#request.transaction.mode >= mode &&
2332
+ this.#request.transaction.durability === options.durability) {
2333
+ // The previous request transaction is compatible and has
2334
+ // not yet completed.
2335
+ tx = this.#request.transaction;
2336
+
2337
+ // If the previous request is pending, wait for it to complete.
2338
+ // This ensures that the transaction will be active.
2339
+ if (this.#request.readyState === 'pending') {
2340
+ await new Promise(resolve => {
2341
+ this.#request.addEventListener('success', resolve, { once: true });
2342
+ this.#request.addEventListener('error', resolve, { once: true });
2343
+ });
2344
+ }
2345
+ }
2346
+
2347
+ for (let i = 0; i < 2; ++i) {
2348
+ if (!tx) {
2349
+ // The current transaction is missing or doesn't match so
2350
+ // replace it with a new one. wait for the previous
2351
+ // transaction to complete so the lifetimes do not overlap.
2352
+ await this.#txComplete;
2353
+
2354
+ // Create the new transaction.
2355
+ // @ts-ignore
2356
+ tx = this.#database.transaction(this.#database.objectStoreNames, mode, options);
2357
+ this.log?.('IDBTransaction open', mode);
2358
+ this.#txPending.add(tx);
2359
+ this.#txComplete = new Promise((resolve, reject) => {
2360
+ tx.addEventListener('complete', () => {
2361
+ this.log?.('IDBTransaction complete');
2362
+ this.#txPending.delete(tx);
2363
+ resolve();
2364
+ });
2365
+ tx.addEventListener('abort', () => {
2366
+ this.#txPending.delete(tx);
2367
+ reject(new Error('transaction aborted'));
2368
+ });
2369
+ });
2370
+ }
2371
+
2372
+ try {
2373
+ // @ts-ignore
2374
+ // Create object store proxies.
2375
+ const objectStores = [...tx.objectStoreNames].map(name => {
2376
+ return [name, this.proxyStoreOrIndex(tx.objectStore(name))];
2377
+ });
2378
+
2379
+ // Execute the function.
2380
+ return await f(Object.fromEntries(objectStores));
2381
+ } catch (e) {
2382
+ // Use a new transaction if this one was inactive. This will
2383
+ // happen if the last request in the transaction completed
2384
+ // in a previous task but the transaction has not yet committed.
2385
+ if (!i && RETRYABLE_ERRORS.has(e.name)) {
2386
+ this.log?.(`${e.name}, retrying`);
2387
+ tx = null;
2388
+ continue;
2389
+ }
2390
+ throw e;
2391
+ }
2392
+ }
2393
+ }
2394
+
2395
+ /**
2396
+ * Object store methods that return an IDBRequest, except for cursor
2397
+ * creation, are wrapped to return a Promise. In addition, the
2398
+ * request is used internally for chaining.
2399
+ * @param {IDBObjectStore} objectStore
2400
+ * @returns
2401
+ */
2402
+ proxyStoreOrIndex(objectStore) {
2403
+ return new Proxy(objectStore, {
2404
+ get: (target, property, receiver) => {
2405
+ const result = Reflect.get(target, property, receiver);
2406
+ if (typeof result === 'function') {
2407
+ return (...args) => {
2408
+ const maybeRequest = Reflect.apply(result, target, args);
2409
+ // @ts-ignore
2410
+ if (maybeRequest instanceof IDBRequest && !property.endsWith('Cursor')) {
2411
+ // // Debug logging.
2412
+ // this.log?.(`${target.name}.${String(property)}`, args);
2413
+ // maybeRequest.addEventListener('success', () => {
2414
+ // this.log?.(`${target.name}.${String(property)} success`, maybeRequest.result);
2415
+ // });
2416
+ // maybeRequest.addEventListener('error', () => {
2417
+ // this.log?.(`${target.name}.${String(property)} error`, maybeRequest.error);
2418
+ // });
2419
+
2420
+ // Save the request.
2421
+ this.#request = maybeRequest;
2422
+
2423
+ // Abort the transaction on error.
2424
+ maybeRequest.addEventListener('error', () => {
2425
+ console.error(maybeRequest.error);
2426
+ maybeRequest.transaction.abort();
2427
+ }, { once: true });
2428
+
2429
+ // Return a Promise.
2430
+ return wrap(maybeRequest);
2431
+ }
2432
+ return maybeRequest;
2433
+ }
2434
+ }
2435
+ return result;
2436
+ }
2437
+ });
2438
+ }
2439
+
2440
+ /**
2441
+ * @param {boolean} durable
2442
+ */
2443
+ async sync(durable) {
2444
+ if (this.#chain) {
2445
+ // This waits for all IndexedDB calls to be made.
2446
+ await this.#chain;
2447
+ if (durable) {
2448
+ // This waits for the final transaction to commit.
2449
+ await this.#txComplete;
2450
+ }
2451
+ this.reset();
2452
+ }
2453
+ }
2454
+
2455
+ reset() {
2456
+ this.#chain = null;
2457
+ this.#txComplete = Promise.resolve();
2458
+ this.#request = null;
2459
+ }
2460
+ }
2461
+
2462
+ /**
2463
+ * @param {IDBRequest} request
2464
+ * @returns {Promise}
2465
+ */
2466
+ function wrap(request) {
2467
+ return new Promise((resolve, reject) => {
2468
+ request.onsuccess = () => resolve(request.result);
2469
+ request.onerror = () => reject(request.error);
2470
+ });
2471
+ }
2472
+
2473
+
2474
+
2475
+ /***/ }
2476
+
2477
+ }]);
2478
+ //# sourceMappingURL=node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-0d2437.umd.js.map