@powersync/web 1.6.0 → 1.8.0

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 (75) hide show
  1. package/README.md +1 -1
  2. package/dist/fe5d98632ac68b2022d7.wasm +0 -0
  3. package/dist/index.umd.js +40336 -0
  4. package/dist/index.umd.js.map +1 -0
  5. package/dist/worker/SharedSyncImplementation.umd.js +4174 -0
  6. package/dist/worker/SharedSyncImplementation.umd.js.map +1 -0
  7. package/dist/worker/WASQLiteDB.umd.js +2780 -0
  8. package/dist/worker/WASQLiteDB.umd.js.map +1 -0
  9. package/dist/worker/node_modules_bson_lib_bson_mjs.umd.js +4437 -0
  10. package/dist/worker/node_modules_bson_lib_bson_mjs.umd.js.map +1 -0
  11. package/dist/worker/node_modules_crypto-browserify_index_js.umd.js +33582 -0
  12. package/dist/worker/node_modules_crypto-browserify_index_js.umd.js.map +1 -0
  13. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite-async_mjs.umd.js +175 -0
  14. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite-async_mjs.umd.js.map +1 -0
  15. package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_IDBBatchAtomicVFS_js.umd.js +1926 -0
  16. package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_IDBBatchAtomicVFS_js.umd.js.map +1 -0
  17. package/lib/package.json +89 -0
  18. package/lib/src/db/PowerSyncDatabase.d.ts +19 -7
  19. package/lib/src/db/PowerSyncDatabase.js +1 -0
  20. package/lib/src/db/PowerSyncDatabase.js.map +1 -0
  21. package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.js +1 -0
  22. package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.js.map +1 -0
  23. package/lib/src/db/adapters/AbstractWebSQLOpenFactory.d.ts +2 -2
  24. package/lib/src/db/adapters/AbstractWebSQLOpenFactory.js +5 -4
  25. package/lib/src/db/adapters/AbstractWebSQLOpenFactory.js.map +1 -0
  26. package/lib/src/db/adapters/SSRDBAdapter.js +1 -0
  27. package/lib/src/db/adapters/SSRDBAdapter.js.map +1 -0
  28. package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.d.ts +3 -2
  29. package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.js +11 -3
  30. package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.js.map +1 -0
  31. package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js +1 -0
  32. package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js.map +1 -0
  33. package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.js +1 -0
  34. package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.js.map +1 -0
  35. package/lib/src/db/adapters/web-sql-flags.d.ts +13 -2
  36. package/lib/src/db/adapters/web-sql-flags.js +1 -0
  37. package/lib/src/db/adapters/web-sql-flags.js.map +1 -0
  38. package/lib/src/db/sync/SSRWebStreamingSyncImplementation.d.ts +34 -2
  39. package/lib/src/db/sync/SSRWebStreamingSyncImplementation.js +44 -3
  40. package/lib/src/db/sync/SSRWebStreamingSyncImplementation.js.map +1 -0
  41. package/lib/src/db/sync/SharedWebStreamingSyncImplementation.js +33 -9
  42. package/lib/src/db/sync/SharedWebStreamingSyncImplementation.js.map +1 -0
  43. package/lib/src/db/sync/WebRemote.d.ts +1 -0
  44. package/lib/src/db/sync/WebRemote.js +12 -0
  45. package/lib/src/db/sync/WebRemote.js.map +1 -0
  46. package/lib/src/db/sync/WebStreamingSyncImplementation.d.ts +9 -2
  47. package/lib/src/db/sync/WebStreamingSyncImplementation.js +1 -0
  48. package/lib/src/db/sync/WebStreamingSyncImplementation.js.map +1 -0
  49. package/lib/src/db/sync/userAgent.d.ts +17 -0
  50. package/lib/src/db/sync/userAgent.js +65 -0
  51. package/lib/src/db/sync/userAgent.js.map +1 -0
  52. package/lib/src/index.js +1 -0
  53. package/lib/src/index.js.map +1 -0
  54. package/lib/src/shared/open-db.js +1 -0
  55. package/lib/src/shared/open-db.js.map +1 -0
  56. package/lib/src/shared/types.js +1 -0
  57. package/lib/src/shared/types.js.map +1 -0
  58. package/lib/src/worker/db/WASQLiteDB.worker.d.ts +4 -1
  59. package/lib/src/worker/db/WASQLiteDB.worker.js +61 -1
  60. package/lib/src/worker/db/WASQLiteDB.worker.js.map +1 -0
  61. package/lib/src/worker/db/open-worker-database.d.ts +4 -2
  62. package/lib/src/worker/db/open-worker-database.js +41 -20
  63. package/lib/src/worker/db/open-worker-database.js.map +1 -0
  64. package/lib/src/worker/sync/AbstractSharedSyncClientProvider.js +1 -0
  65. package/lib/src/worker/sync/AbstractSharedSyncClientProvider.js.map +1 -0
  66. package/lib/src/worker/sync/BroadcastLogger.js +1 -0
  67. package/lib/src/worker/sync/BroadcastLogger.js.map +1 -0
  68. package/lib/src/worker/sync/SharedSyncImplementation.js +1 -0
  69. package/lib/src/worker/sync/SharedSyncImplementation.js.map +1 -0
  70. package/lib/src/worker/sync/SharedSyncImplementation.worker.js +1 -0
  71. package/lib/src/worker/sync/SharedSyncImplementation.worker.js.map +1 -0
  72. package/lib/tsconfig.tsbuildinfo +1 -1
  73. package/package.json +36 -14
  74. package/lib/src/worker/db/SharedWASQLiteDB.worker.d.ts +0 -1
  75. package/lib/src/worker/db/SharedWASQLiteDB.worker.js +0 -49
@@ -0,0 +1,1926 @@
1
+ "use strict";
2
+ (self["webpackChunksdk_web"] = self["webpackChunksdk_web"] || []).push([["node_modules_journeyapps_wa-sqlite_src_examples_IDBBatchAtomicVFS_js"],{
3
+
4
+ /***/ "../../node_modules/@journeyapps/wa-sqlite/src/VFS.js":
5
+ /*!************************************************************!*\
6
+ !*** ../../node_modules/@journeyapps/wa-sqlite/src/VFS.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 */ Base: () => (/* binding */ Base),
13
+ /* harmony export */ FILE_TYPE_MASK: () => (/* binding */ FILE_TYPE_MASK),
14
+ /* harmony export */ SQLITE_ABORT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ABORT),
15
+ /* harmony export */ SQLITE_ACCESS_EXISTS: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ACCESS_EXISTS),
16
+ /* harmony export */ SQLITE_ACCESS_READ: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ACCESS_READ),
17
+ /* harmony export */ SQLITE_ACCESS_READWRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ACCESS_READWRITE),
18
+ /* harmony export */ SQLITE_ALTER_TABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ALTER_TABLE),
19
+ /* harmony export */ SQLITE_ANALYZE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ANALYZE),
20
+ /* harmony export */ SQLITE_ATTACH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ATTACH),
21
+ /* harmony export */ SQLITE_AUTH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_AUTH),
22
+ /* harmony export */ SQLITE_BLOB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BLOB),
23
+ /* harmony export */ SQLITE_BUSY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BUSY),
24
+ /* harmony export */ SQLITE_CANTOPEN: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CANTOPEN),
25
+ /* harmony export */ SQLITE_CONSTRAINT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT),
26
+ /* harmony export */ SQLITE_CONSTRAINT_CHECK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_CHECK),
27
+ /* harmony export */ SQLITE_CONSTRAINT_COMMITHOOK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_COMMITHOOK),
28
+ /* harmony export */ SQLITE_CONSTRAINT_FOREIGNKEY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_FOREIGNKEY),
29
+ /* harmony export */ SQLITE_CONSTRAINT_FUNCTION: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_FUNCTION),
30
+ /* harmony export */ SQLITE_CONSTRAINT_NOTNULL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_NOTNULL),
31
+ /* harmony export */ SQLITE_CONSTRAINT_PINNED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_PINNED),
32
+ /* harmony export */ SQLITE_CONSTRAINT_PRIMARYKEY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_PRIMARYKEY),
33
+ /* harmony export */ SQLITE_CONSTRAINT_ROWID: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_ROWID),
34
+ /* harmony export */ SQLITE_CONSTRAINT_TRIGGER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_TRIGGER),
35
+ /* harmony export */ SQLITE_CONSTRAINT_UNIQUE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_UNIQUE),
36
+ /* harmony export */ SQLITE_CONSTRAINT_VTAB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CONSTRAINT_VTAB),
37
+ /* harmony export */ SQLITE_COPY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_COPY),
38
+ /* harmony export */ SQLITE_CORRUPT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CORRUPT),
39
+ /* harmony export */ SQLITE_CREATE_INDEX: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_INDEX),
40
+ /* harmony export */ SQLITE_CREATE_TABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_TABLE),
41
+ /* harmony export */ SQLITE_CREATE_TEMP_INDEX: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_TEMP_INDEX),
42
+ /* harmony export */ SQLITE_CREATE_TEMP_TABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_TEMP_TABLE),
43
+ /* harmony export */ SQLITE_CREATE_TEMP_TRIGGER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_TEMP_TRIGGER),
44
+ /* harmony export */ SQLITE_CREATE_TEMP_VIEW: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_TEMP_VIEW),
45
+ /* harmony export */ SQLITE_CREATE_TRIGGER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_TRIGGER),
46
+ /* harmony export */ SQLITE_CREATE_VIEW: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_VIEW),
47
+ /* harmony export */ SQLITE_CREATE_VTABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CREATE_VTABLE),
48
+ /* harmony export */ SQLITE_DELETE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DELETE),
49
+ /* harmony export */ SQLITE_DENY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DENY),
50
+ /* harmony export */ SQLITE_DETACH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DETACH),
51
+ /* harmony export */ SQLITE_DETERMINISTIC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DETERMINISTIC),
52
+ /* harmony export */ SQLITE_DIRECTONLY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DIRECTONLY),
53
+ /* harmony export */ SQLITE_DONE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DONE),
54
+ /* harmony export */ SQLITE_DROP_INDEX: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_INDEX),
55
+ /* harmony export */ SQLITE_DROP_TABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_TABLE),
56
+ /* harmony export */ SQLITE_DROP_TEMP_INDEX: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_TEMP_INDEX),
57
+ /* harmony export */ SQLITE_DROP_TEMP_TABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_TEMP_TABLE),
58
+ /* harmony export */ SQLITE_DROP_TEMP_TRIGGER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_TEMP_TRIGGER),
59
+ /* harmony export */ SQLITE_DROP_TEMP_VIEW: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_TEMP_VIEW),
60
+ /* harmony export */ SQLITE_DROP_TRIGGER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_TRIGGER),
61
+ /* harmony export */ SQLITE_DROP_VIEW: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_VIEW),
62
+ /* harmony export */ SQLITE_DROP_VTABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DROP_VTABLE),
63
+ /* harmony export */ SQLITE_EMPTY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_EMPTY),
64
+ /* harmony export */ SQLITE_ERROR: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ERROR),
65
+ /* harmony export */ SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_BEGIN_ATOMIC_WRITE),
66
+ /* harmony export */ SQLITE_FCNTL_BUSYHANDLER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_BUSYHANDLER),
67
+ /* harmony export */ SQLITE_FCNTL_CHUNK_SIZE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_CHUNK_SIZE),
68
+ /* harmony export */ SQLITE_FCNTL_CKPT_DONE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_CKPT_DONE),
69
+ /* harmony export */ SQLITE_FCNTL_CKPT_START: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_CKPT_START),
70
+ /* harmony export */ SQLITE_FCNTL_COMMIT_ATOMIC_WRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_COMMIT_ATOMIC_WRITE),
71
+ /* harmony export */ SQLITE_FCNTL_COMMIT_PHASETWO: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_COMMIT_PHASETWO),
72
+ /* harmony export */ SQLITE_FCNTL_DATA_VERSION: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_DATA_VERSION),
73
+ /* harmony export */ SQLITE_FCNTL_FILE_POINTER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_FILE_POINTER),
74
+ /* harmony export */ SQLITE_FCNTL_GET_LOCKPROXYFILE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_GET_LOCKPROXYFILE),
75
+ /* harmony export */ SQLITE_FCNTL_HAS_MOVED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_HAS_MOVED),
76
+ /* harmony export */ SQLITE_FCNTL_JOURNAL_POINTER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_JOURNAL_POINTER),
77
+ /* harmony export */ SQLITE_FCNTL_LAST_ERRNO: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_LAST_ERRNO),
78
+ /* harmony export */ SQLITE_FCNTL_LOCKSTATE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_LOCKSTATE),
79
+ /* harmony export */ SQLITE_FCNTL_LOCK_TIMEOUT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_LOCK_TIMEOUT),
80
+ /* harmony export */ SQLITE_FCNTL_MMAP_SIZE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_MMAP_SIZE),
81
+ /* harmony export */ SQLITE_FCNTL_OVERWRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_OVERWRITE),
82
+ /* harmony export */ SQLITE_FCNTL_PDB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_PDB),
83
+ /* harmony export */ SQLITE_FCNTL_PERSIST_WAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_PERSIST_WAL),
84
+ /* harmony export */ SQLITE_FCNTL_POWERSAFE_OVERWRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_POWERSAFE_OVERWRITE),
85
+ /* harmony export */ SQLITE_FCNTL_PRAGMA: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_PRAGMA),
86
+ /* harmony export */ SQLITE_FCNTL_RBU: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_RBU),
87
+ /* harmony export */ SQLITE_FCNTL_RESERVE_BYTES: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_RESERVE_BYTES),
88
+ /* harmony export */ SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE),
89
+ /* harmony export */ SQLITE_FCNTL_SET_LOCKPROXYFILE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_SET_LOCKPROXYFILE),
90
+ /* harmony export */ SQLITE_FCNTL_SIZE_HINT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_SIZE_HINT),
91
+ /* harmony export */ SQLITE_FCNTL_SIZE_LIMIT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_SIZE_LIMIT),
92
+ /* harmony export */ SQLITE_FCNTL_SYNC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_SYNC),
93
+ /* harmony export */ SQLITE_FCNTL_SYNC_OMITTED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_SYNC_OMITTED),
94
+ /* harmony export */ SQLITE_FCNTL_TEMPFILENAME: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_TEMPFILENAME),
95
+ /* harmony export */ SQLITE_FCNTL_TRACE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_TRACE),
96
+ /* harmony export */ SQLITE_FCNTL_VFSNAME: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_VFSNAME),
97
+ /* harmony export */ SQLITE_FCNTL_VFS_POINTER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_VFS_POINTER),
98
+ /* harmony export */ SQLITE_FCNTL_WAL_BLOCK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_WAL_BLOCK),
99
+ /* harmony export */ SQLITE_FCNTL_WIN32_AV_RETRY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_WIN32_AV_RETRY),
100
+ /* harmony export */ SQLITE_FCNTL_WIN32_GET_HANDLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_WIN32_GET_HANDLE),
101
+ /* harmony export */ SQLITE_FCNTL_WIN32_SET_HANDLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_WIN32_SET_HANDLE),
102
+ /* harmony export */ SQLITE_FCNTL_ZIPVFS: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FCNTL_ZIPVFS),
103
+ /* harmony export */ SQLITE_FLOAT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FLOAT),
104
+ /* harmony export */ SQLITE_FORMAT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FORMAT),
105
+ /* harmony export */ SQLITE_FULL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FULL),
106
+ /* harmony export */ SQLITE_FUNCTION: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_FUNCTION),
107
+ /* harmony export */ SQLITE_IGNORE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IGNORE),
108
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_EQ: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_EQ),
109
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_FUNCTION: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_FUNCTION),
110
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_GE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_GE),
111
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_GLOB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_GLOB),
112
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_GT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_GT),
113
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_IS: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_IS),
114
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_ISNOT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_ISNOT),
115
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_ISNOTNULL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_ISNOTNULL),
116
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_ISNULL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_ISNULL),
117
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_LE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_LE),
118
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_LIKE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_LIKE),
119
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_LT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_LT),
120
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_MATCH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_MATCH),
121
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_NE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_NE),
122
+ /* harmony export */ SQLITE_INDEX_CONSTRAINT_REGEXP: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_CONSTRAINT_REGEXP),
123
+ /* harmony export */ SQLITE_INDEX_SCAN_UNIQUE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INDEX_SCAN_UNIQUE),
124
+ /* harmony export */ SQLITE_INNOCUOUS: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INNOCUOUS),
125
+ /* harmony export */ SQLITE_INSERT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INSERT),
126
+ /* harmony export */ SQLITE_INTEGER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INTEGER),
127
+ /* harmony export */ SQLITE_INTERNAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INTERNAL),
128
+ /* harmony export */ SQLITE_INTERRUPT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_INTERRUPT),
129
+ /* harmony export */ SQLITE_IOCAP_ATOMIC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC),
130
+ /* harmony export */ SQLITE_IOCAP_ATOMIC16K: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC16K),
131
+ /* harmony export */ SQLITE_IOCAP_ATOMIC1K: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC1K),
132
+ /* harmony export */ SQLITE_IOCAP_ATOMIC2K: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC2K),
133
+ /* harmony export */ SQLITE_IOCAP_ATOMIC32K: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC32K),
134
+ /* harmony export */ SQLITE_IOCAP_ATOMIC4K: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC4K),
135
+ /* harmony export */ SQLITE_IOCAP_ATOMIC512: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC512),
136
+ /* harmony export */ SQLITE_IOCAP_ATOMIC64K: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC64K),
137
+ /* harmony export */ SQLITE_IOCAP_ATOMIC8K: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_ATOMIC8K),
138
+ /* harmony export */ SQLITE_IOCAP_BATCH_ATOMIC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_BATCH_ATOMIC),
139
+ /* harmony export */ SQLITE_IOCAP_IMMUTABLE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_IMMUTABLE),
140
+ /* harmony export */ SQLITE_IOCAP_POWERSAFE_OVERWRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_POWERSAFE_OVERWRITE),
141
+ /* harmony export */ SQLITE_IOCAP_SAFE_APPEND: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_SAFE_APPEND),
142
+ /* harmony export */ SQLITE_IOCAP_SEQUENTIAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_SEQUENTIAL),
143
+ /* harmony export */ SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN),
144
+ /* harmony export */ SQLITE_IOERR: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR),
145
+ /* harmony export */ SQLITE_IOERR_ACCESS: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_ACCESS),
146
+ /* harmony export */ SQLITE_IOERR_BEGIN_ATOMIC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_BEGIN_ATOMIC),
147
+ /* harmony export */ SQLITE_IOERR_CHECKRESERVEDLOCK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_CHECKRESERVEDLOCK),
148
+ /* harmony export */ SQLITE_IOERR_CLOSE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_CLOSE),
149
+ /* harmony export */ SQLITE_IOERR_COMMIT_ATOMIC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_COMMIT_ATOMIC),
150
+ /* harmony export */ SQLITE_IOERR_DATA: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_DATA),
151
+ /* harmony export */ SQLITE_IOERR_DELETE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_DELETE),
152
+ /* harmony export */ SQLITE_IOERR_DELETE_NOENT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_DELETE_NOENT),
153
+ /* harmony export */ SQLITE_IOERR_DIR_FSYNC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_DIR_FSYNC),
154
+ /* harmony export */ SQLITE_IOERR_FSTAT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_FSTAT),
155
+ /* harmony export */ SQLITE_IOERR_FSYNC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_FSYNC),
156
+ /* harmony export */ SQLITE_IOERR_GETTEMPPATH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_GETTEMPPATH),
157
+ /* harmony export */ SQLITE_IOERR_LOCK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_LOCK),
158
+ /* harmony export */ SQLITE_IOERR_NOMEM: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_NOMEM),
159
+ /* harmony export */ SQLITE_IOERR_RDLOCK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_RDLOCK),
160
+ /* harmony export */ SQLITE_IOERR_READ: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_READ),
161
+ /* harmony export */ SQLITE_IOERR_ROLLBACK_ATOMIC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_ROLLBACK_ATOMIC),
162
+ /* harmony export */ SQLITE_IOERR_SEEK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_SEEK),
163
+ /* harmony export */ SQLITE_IOERR_SHORT_READ: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_SHORT_READ),
164
+ /* harmony export */ SQLITE_IOERR_TRUNCATE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_TRUNCATE),
165
+ /* harmony export */ SQLITE_IOERR_UNLOCK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_UNLOCK),
166
+ /* harmony export */ SQLITE_IOERR_VNODE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_VNODE),
167
+ /* harmony export */ SQLITE_IOERR_WRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_WRITE),
168
+ /* harmony export */ SQLITE_LIMIT_ATTACHED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_ATTACHED),
169
+ /* harmony export */ SQLITE_LIMIT_COLUMN: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_COLUMN),
170
+ /* harmony export */ SQLITE_LIMIT_COMPOUND_SELECT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_COMPOUND_SELECT),
171
+ /* harmony export */ SQLITE_LIMIT_EXPR_DEPTH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_EXPR_DEPTH),
172
+ /* harmony export */ SQLITE_LIMIT_FUNCTION_ARG: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_FUNCTION_ARG),
173
+ /* harmony export */ SQLITE_LIMIT_LENGTH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_LENGTH),
174
+ /* harmony export */ SQLITE_LIMIT_LIKE_PATTERN_LENGTH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_LIKE_PATTERN_LENGTH),
175
+ /* harmony export */ SQLITE_LIMIT_SQL_LENGTH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_SQL_LENGTH),
176
+ /* harmony export */ SQLITE_LIMIT_TRIGGER_DEPTH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_TRIGGER_DEPTH),
177
+ /* harmony export */ SQLITE_LIMIT_VARIABLE_NUMBER: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_VARIABLE_NUMBER),
178
+ /* harmony export */ SQLITE_LIMIT_VDBE_OP: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_VDBE_OP),
179
+ /* harmony export */ SQLITE_LIMIT_WORKER_THREADS: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LIMIT_WORKER_THREADS),
180
+ /* harmony export */ SQLITE_LOCKED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCKED),
181
+ /* harmony export */ SQLITE_LOCK_EXCLUSIVE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_EXCLUSIVE),
182
+ /* harmony export */ SQLITE_LOCK_NONE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_NONE),
183
+ /* harmony export */ SQLITE_LOCK_PENDING: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_PENDING),
184
+ /* harmony export */ SQLITE_LOCK_RESERVED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_RESERVED),
185
+ /* harmony export */ SQLITE_LOCK_SHARED: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_SHARED),
186
+ /* harmony export */ SQLITE_MISMATCH: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_MISMATCH),
187
+ /* harmony export */ SQLITE_MISUSE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_MISUSE),
188
+ /* harmony export */ SQLITE_NOLFS: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOLFS),
189
+ /* harmony export */ SQLITE_NOMEM: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOMEM),
190
+ /* harmony export */ SQLITE_NOTADB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOTADB),
191
+ /* harmony export */ SQLITE_NOTFOUND: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOTFOUND),
192
+ /* harmony export */ SQLITE_NOTICE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOTICE),
193
+ /* harmony export */ SQLITE_NULL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NULL),
194
+ /* harmony export */ SQLITE_OK: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK),
195
+ /* harmony export */ SQLITE_OPEN_AUTOPROXY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_AUTOPROXY),
196
+ /* harmony export */ SQLITE_OPEN_CREATE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_CREATE),
197
+ /* harmony export */ SQLITE_OPEN_DELETEONCLOSE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_DELETEONCLOSE),
198
+ /* harmony export */ SQLITE_OPEN_EXCLUSIVE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_EXCLUSIVE),
199
+ /* harmony export */ SQLITE_OPEN_FULLMUTEX: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_FULLMUTEX),
200
+ /* harmony export */ SQLITE_OPEN_MAIN_DB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_MAIN_DB),
201
+ /* harmony export */ SQLITE_OPEN_MAIN_JOURNAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_MAIN_JOURNAL),
202
+ /* harmony export */ SQLITE_OPEN_MEMORY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_MEMORY),
203
+ /* harmony export */ SQLITE_OPEN_NOFOLLOW: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_NOFOLLOW),
204
+ /* harmony export */ SQLITE_OPEN_NOMUTEX: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_NOMUTEX),
205
+ /* harmony export */ SQLITE_OPEN_PRIVATECACHE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_PRIVATECACHE),
206
+ /* harmony export */ SQLITE_OPEN_READONLY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_READONLY),
207
+ /* harmony export */ SQLITE_OPEN_READWRITE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_READWRITE),
208
+ /* harmony export */ SQLITE_OPEN_SHAREDCACHE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_SHAREDCACHE),
209
+ /* harmony export */ SQLITE_OPEN_SUBJOURNAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_SUBJOURNAL),
210
+ /* harmony export */ SQLITE_OPEN_SUPER_JOURNAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_SUPER_JOURNAL),
211
+ /* harmony export */ SQLITE_OPEN_TEMP_DB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_TEMP_DB),
212
+ /* harmony export */ SQLITE_OPEN_TEMP_JOURNAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_TEMP_JOURNAL),
213
+ /* harmony export */ SQLITE_OPEN_TRANSIENT_DB: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_TRANSIENT_DB),
214
+ /* harmony export */ SQLITE_OPEN_URI: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_URI),
215
+ /* harmony export */ SQLITE_OPEN_WAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_WAL),
216
+ /* harmony export */ SQLITE_PERM: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_PERM),
217
+ /* harmony export */ SQLITE_PRAGMA: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_PRAGMA),
218
+ /* harmony export */ SQLITE_PROTOCOL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_PROTOCOL),
219
+ /* harmony export */ SQLITE_RANGE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_RANGE),
220
+ /* harmony export */ SQLITE_READ: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_READ),
221
+ /* harmony export */ SQLITE_READONLY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_READONLY),
222
+ /* harmony export */ SQLITE_RECURSIVE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_RECURSIVE),
223
+ /* harmony export */ SQLITE_REINDEX: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_REINDEX),
224
+ /* harmony export */ SQLITE_ROW: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ROW),
225
+ /* harmony export */ SQLITE_SAVEPOINT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_SAVEPOINT),
226
+ /* harmony export */ SQLITE_SCHEMA: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_SCHEMA),
227
+ /* harmony export */ SQLITE_SELECT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_SELECT),
228
+ /* harmony export */ SQLITE_STATIC: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_STATIC),
229
+ /* harmony export */ SQLITE_SUBTYPE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_SUBTYPE),
230
+ /* harmony export */ SQLITE_SYNC_DATAONLY: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_SYNC_DATAONLY),
231
+ /* harmony export */ SQLITE_SYNC_FULL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_SYNC_FULL),
232
+ /* harmony export */ SQLITE_SYNC_NORMAL: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_SYNC_NORMAL),
233
+ /* harmony export */ SQLITE_TEXT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_TEXT),
234
+ /* harmony export */ SQLITE_TOOBIG: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_TOOBIG),
235
+ /* harmony export */ SQLITE_TRANSACTION: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_TRANSACTION),
236
+ /* harmony export */ SQLITE_TRANSIENT: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_TRANSIENT),
237
+ /* harmony export */ SQLITE_UPDATE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_UPDATE),
238
+ /* harmony export */ SQLITE_UTF16: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_UTF16),
239
+ /* harmony export */ SQLITE_UTF16BE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_UTF16BE),
240
+ /* harmony export */ SQLITE_UTF16LE: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_UTF16LE),
241
+ /* harmony export */ SQLITE_UTF8: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_UTF8),
242
+ /* harmony export */ SQLITE_WARNING: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_WARNING)
243
+ /* harmony export */ });
244
+ /* harmony import */ var _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sqlite-constants.js */ "../../node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js");
245
+ // Copyright 2022 Roy T. Hashimoto. All Rights Reserved.
246
+
247
+
248
+
249
+ // Base class for a VFS.
250
+ class Base {
251
+ mxPathName = 64;
252
+
253
+ /**
254
+ * @param {number} fileId
255
+ * @returns {number}
256
+ */
257
+ xClose(fileId) {
258
+ return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
259
+ }
260
+
261
+ /**
262
+ * @param {number} fileId
263
+ * @param {Uint8Array} pData
264
+ * @param {number} iOffset
265
+ * @returns {number}
266
+ */
267
+ xRead(fileId, pData, iOffset) {
268
+ return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
269
+ }
270
+
271
+ /**
272
+ * @param {number} fileId
273
+ * @param {Uint8Array} pData
274
+ * @param {number} iOffset
275
+ * @returns {number}
276
+ */
277
+ xWrite(fileId, pData, iOffset) {
278
+ return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
279
+ }
280
+
281
+ /**
282
+ * @param {number} fileId
283
+ * @param {number} iSize
284
+ * @returns {number}
285
+ */
286
+ xTruncate(fileId, iSize) {
287
+ return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
288
+ }
289
+
290
+ /**
291
+ * @param {number} fileId
292
+ * @param {*} flags
293
+ * @returns {number}
294
+ */
295
+ xSync(fileId, flags) {
296
+ return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
297
+ }
298
+
299
+ /**
300
+ * @param {number} fileId
301
+ * @param {DataView} pSize64
302
+ * @returns {number}
303
+ */
304
+ xFileSize(fileId, pSize64) {
305
+ return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
306
+ }
307
+
308
+ /**
309
+ * @param {number} fileId
310
+ * @param {number} flags
311
+ * @returns {number}
312
+ */
313
+ xLock(fileId, flags) {
314
+ return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
315
+ }
316
+
317
+ /**
318
+ * @param {number} fileId
319
+ * @param {number} flags
320
+ * @returns {number}
321
+ */
322
+ xUnlock(fileId, flags) {
323
+ return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
324
+ }
325
+
326
+ /**
327
+ * @param {number} fileId
328
+ * @param {DataView} pResOut
329
+ * @returns {number}
330
+ */
331
+ xCheckReservedLock(fileId, pResOut) {
332
+ pResOut.setInt32(0, 0, true);
333
+ return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
334
+ }
335
+
336
+ /**
337
+ * @param {number} fileId
338
+ * @param {number} op
339
+ * @param {DataView} pArg
340
+ * @returns {number}
341
+ */
342
+ xFileControl(fileId, op, pArg) {
343
+ return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOTFOUND;
344
+ }
345
+
346
+ /**
347
+ * @param {number} fileId
348
+ * @returns {number}
349
+ */
350
+ xSectorSize(fileId) {
351
+ return 512;
352
+ }
353
+
354
+ /**
355
+ * @param {number} fileId
356
+ * @returns {number}
357
+ */
358
+ xDeviceCharacteristics(fileId) {
359
+ return 0;
360
+ }
361
+
362
+ /**
363
+ * @param {string?} name
364
+ * @param {number} fileId
365
+ * @param {number} flags
366
+ * @param {DataView} pOutFlags
367
+ * @returns {number}
368
+ */
369
+ xOpen(name, fileId, flags, pOutFlags) {
370
+ return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CANTOPEN;
371
+ }
372
+
373
+ /**
374
+ * @param {string} name
375
+ * @param {number} syncDir
376
+ * @returns {number}
377
+ */
378
+ xDelete(name, syncDir) {
379
+ return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
380
+ }
381
+
382
+ /**
383
+ * @param {string} name
384
+ * @param {number} flags
385
+ * @param {DataView} pResOut
386
+ * @returns {number}
387
+ */
388
+ xAccess(name, flags, pResOut) {
389
+ return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
390
+ }
391
+
392
+ /**
393
+ * Handle asynchronous operation. This implementation will be overriden on
394
+ * registration by an Asyncify build.
395
+ * @param {function(): Promise<number>} f
396
+ * @returns {number}
397
+ */
398
+ handleAsync(f) {
399
+ // This default implementation deliberately does not match the
400
+ // declared signature. It will be used in testing VFS classes
401
+ // separately from SQLite. This will work acceptably for methods
402
+ // that simply return the handleAsync() result without using it.
403
+ // @ts-ignore
404
+ return f();
405
+ }
406
+ }
407
+
408
+ const FILE_TYPE_MASK = [
409
+ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_MAIN_DB,
410
+ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_MAIN_JOURNAL,
411
+ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_TEMP_DB,
412
+ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_TEMP_JOURNAL,
413
+ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_TRANSIENT_DB,
414
+ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_SUBJOURNAL,
415
+ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_SUPER_JOURNAL
416
+ ].reduce((mask, element) => mask | element);
417
+
418
+ /***/ }),
419
+
420
+ /***/ "../../node_modules/@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js":
421
+ /*!***********************************************************************************!*\
422
+ !*** ../../node_modules/@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js ***!
423
+ \***********************************************************************************/
424
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
425
+
426
+ __webpack_require__.r(__webpack_exports__);
427
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
428
+ /* harmony export */ IDBBatchAtomicVFS: () => (/* binding */ IDBBatchAtomicVFS)
429
+ /* harmony export */ });
430
+ /* harmony import */ var _VFS_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../VFS.js */ "../../node_modules/@journeyapps/wa-sqlite/src/VFS.js");
431
+ /* harmony import */ var _WebLocks_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./WebLocks.js */ "../../node_modules/@journeyapps/wa-sqlite/src/examples/WebLocks.js");
432
+ /* harmony import */ var _IDBContext_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./IDBContext.js */ "../../node_modules/@journeyapps/wa-sqlite/src/examples/IDBContext.js");
433
+ // Copyright 2022 Roy T. Hashimoto. All Rights Reserved.
434
+
435
+
436
+
437
+
438
+ const SECTOR_SIZE = 512;
439
+ const MAX_TASK_MILLIS = 3000;
440
+
441
+ /**
442
+ * @typedef VFSOptions
443
+ * @property {"default"|"strict"|"relaxed"} [durability]
444
+ * @property {"deferred"|"manual"} [purge]
445
+ * @property {number} [purgeAtLeast]
446
+ */
447
+
448
+ /** @type {VFSOptions} */
449
+ const DEFAULT_OPTIONS = {
450
+ durability: "default",
451
+ purge: "deferred",
452
+ purgeAtLeast: 16
453
+ };
454
+
455
+ function log(...args) {
456
+ // console.debug(...args);
457
+ }
458
+
459
+ /**
460
+ * @typedef FileBlock IndexedDB object with key [path, offset, version]
461
+ * @property {string} path
462
+ * @property {number} offset negative of position in file
463
+ * @property {number} version
464
+ * @property {Uint8Array} data
465
+ *
466
+ * @property {number} [fileSize] Only present on block 0
467
+ */
468
+
469
+ /**
470
+ * @typedef OpenedFileEntry
471
+ * @property {string} path
472
+ * @property {number} flags
473
+ * @property {FileBlock} block0
474
+ * @property {boolean} isMetadataChanged
475
+ * @property {WebLocks} locks
476
+ *
477
+ * @property {Set<number>} [changedPages]
478
+ * @property {boolean} [overwrite]
479
+ */
480
+
481
+ // This sample VFS stores optionally versioned writes to IndexedDB, which
482
+ // it uses with the SQLite xFileControl() batch atomic write feature.
483
+ class IDBBatchAtomicVFS extends _VFS_js__WEBPACK_IMPORTED_MODULE_0__.Base {
484
+ #options;
485
+ /** @type {Map<number, OpenedFileEntry>} */ #mapIdToFile = new Map();
486
+
487
+ /** @type {IDBContext} */ #idb;
488
+ /** @type {Set<string>} */ #pendingPurges = new Set();
489
+
490
+ #taskTimestamp = performance.now();
491
+ #pendingAsync = new Set();
492
+
493
+ // Asyncify can grow WebAssembly memory during an asynchronous call.
494
+ // If this happens, then any array buffer arguments will be detached.
495
+ // The workaround is when finding a detached buffer, set this handler
496
+ // function to process the new buffer outside handlerAsync().
497
+ #growthHandler = null;
498
+
499
+ constructor(idbDatabaseName = 'wa-sqlite', options = DEFAULT_OPTIONS) {
500
+ super();
501
+ this.name = idbDatabaseName;
502
+ this.#options = Object.assign({}, DEFAULT_OPTIONS, options);
503
+ this.#idb = new _IDBContext_js__WEBPACK_IMPORTED_MODULE_2__.IDBContext(openDatabase(idbDatabaseName), {
504
+ durability: this.#options.durability
505
+ });
506
+ }
507
+
508
+ async close() {
509
+ for (const fileId of this.#mapIdToFile.keys()) {
510
+ await this.xClose(fileId);
511
+ }
512
+
513
+ await this.#idb?.close();
514
+ this.#idb = null;
515
+ }
516
+
517
+ /**
518
+ * @param {string?} name
519
+ * @param {number} fileId
520
+ * @param {number} flags
521
+ * @param {DataView} pOutFlags
522
+ * @returns {number}
523
+ */
524
+ xOpen(name, fileId, flags, pOutFlags) {
525
+ const result = this.handleAsync(async () => {
526
+ if (name === null) name = `null_${fileId}`;
527
+ log(`xOpen ${name} 0x${fileId.toString(16)} 0x${flags.toString(16)}`);
528
+
529
+ try {
530
+ // Filenames can be URLs, possibly with query parameters.
531
+ const url = new URL(name, 'http://localhost/');
532
+ /** @type {OpenedFileEntry} */ const file = {
533
+ path: url.pathname,
534
+ flags,
535
+ block0: null,
536
+ isMetadataChanged: true,
537
+ locks: new _WebLocks_js__WEBPACK_IMPORTED_MODULE_1__.WebLocksExclusive(url.pathname)
538
+ };
539
+ this.#mapIdToFile.set(fileId, file);
540
+
541
+ // Read the first block, which also contains the file metadata.
542
+ await this.#idb.run('readwrite', async ({blocks}) => {
543
+ file.block0 = await blocks.get(this.#bound(file, 0));
544
+ if (!file.block0) {
545
+ if (flags & _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_CREATE) {
546
+ file.block0 = {
547
+ path: file.path,
548
+ offset: 0,
549
+ version: 0,
550
+ data: new Uint8Array(0),
551
+ fileSize: 0
552
+ };
553
+ blocks.put(file.block0);
554
+ } else {
555
+ throw new Error(`file not found: ${file.path}`);
556
+ }
557
+ }
558
+ });
559
+
560
+ // @ts-ignore
561
+ if (pOutFlags.buffer.detached || !pOutFlags.buffer.byteLength) {
562
+ pOutFlags = new DataView(new ArrayBuffer(4));
563
+ this.#growthHandler = (pOutFlagsNew) => {
564
+ pOutFlagsNew.setInt32(0, pOutFlags.getInt32(0, true), true);
565
+ };
566
+ }
567
+ pOutFlags.setInt32(0, flags & _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_READONLY, true);
568
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
569
+ } catch (e) {
570
+ console.error(e);
571
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_CANTOPEN;
572
+ }
573
+ });
574
+
575
+ this.#growthHandler?.(pOutFlags);
576
+ this.#growthHandler = null;
577
+ return result;
578
+ }
579
+
580
+ /**
581
+ * @param {number} fileId
582
+ * @returns {number}
583
+ */
584
+ xClose(fileId) {
585
+ return this.handleAsync(async () => {
586
+ try {
587
+ const file = this.#mapIdToFile.get(fileId);
588
+ if (file) {
589
+ log(`xClose ${file.path}`);
590
+
591
+ this.#mapIdToFile.delete(fileId);
592
+ if (file.flags & _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_DELETEONCLOSE) {
593
+ this.#idb.run('readwrite', ({blocks}) => {
594
+ blocks.delete(IDBKeyRange.bound([file.path], [file.path, []]));
595
+ });
596
+ }
597
+ }
598
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
599
+ } catch (e) {
600
+ console.error(e);
601
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
602
+ }
603
+ });
604
+ }
605
+
606
+ /**
607
+ * @param {number} fileId
608
+ * @param {Uint8Array} pData
609
+ * @param {number} iOffset
610
+ * @returns {number}
611
+ */
612
+ xRead(fileId, pData, iOffset) {
613
+ const byteLength = pData.byteLength;
614
+ const result = this.handleAsync(async () => {
615
+ const file = this.#mapIdToFile.get(fileId);
616
+ log(`xRead ${file.path} ${pData.byteLength} ${iOffset}`);
617
+
618
+ try {
619
+ // Read as many blocks as necessary to satisfy the read request.
620
+ // Usually a read fits within a single write but there is at least
621
+ // one case - rollback after journal spill - where reads cross
622
+ // write boundaries so we have to allow for that.
623
+ const result = await this.#idb.run('readonly', async ({blocks}) => {
624
+ // @ts-ignore
625
+ if (pData.buffer.detached || !pData.buffer.byteLength) {
626
+ // WebAssembly memory has grown, invalidating our buffer. Use
627
+ // a temporary buffer and copy after this asynchronous call
628
+ // completes.
629
+ pData = new Uint8Array(byteLength);
630
+ this.#growthHandler = (pDataNew) => pDataNew.set(pData);
631
+ }
632
+
633
+ let pDataOffset = 0;
634
+ while (pDataOffset < pData.byteLength) {
635
+ // Fetch the IndexedDB block for this file location.
636
+ const fileOffset = iOffset + pDataOffset;
637
+ /** @type {FileBlock} */
638
+ const block = fileOffset < file.block0.data.byteLength ?
639
+ file.block0 :
640
+ await blocks.get(this.#bound(file, -fileOffset));
641
+
642
+ if (!block || block.data.byteLength - block.offset <= fileOffset) {
643
+ pData.fill(0, pDataOffset);
644
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_SHORT_READ;
645
+ }
646
+
647
+ const buffer = pData.subarray(pDataOffset);
648
+ const blockOffset = fileOffset + block.offset;
649
+ const nBytesToCopy = Math.min(
650
+ Math.max(block.data.byteLength - blockOffset, 0), // source bytes
651
+ buffer.byteLength); // destination bytes
652
+ buffer.set(block.data.subarray(blockOffset, blockOffset + nBytesToCopy));
653
+ pDataOffset += nBytesToCopy;
654
+ }
655
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
656
+ });
657
+ return result;
658
+ } catch (e) {
659
+ console.error(e);
660
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
661
+ }
662
+ });
663
+
664
+ this.#growthHandler?.(pData);
665
+ this.#growthHandler = null;
666
+ return result;
667
+ }
668
+
669
+ /**
670
+ * @param {number} fileId
671
+ * @param {Uint8Array} pData
672
+ * @param {number} iOffset
673
+ * @returns {number}
674
+ */
675
+ xWrite(fileId, pData, iOffset) {
676
+ // Handle asynchronously every MAX_TASK_MILLIS milliseconds. This is
677
+ // tricky because Asyncify calls asynchronous methods twice: once
678
+ // to initiate the call and unwinds the stack, then rewinds the
679
+ // stack and calls again to retrieve the completed result.
680
+ const rewound = this.#pendingAsync.has(fileId);
681
+ if (rewound || performance.now() - this.#taskTimestamp > MAX_TASK_MILLIS) {
682
+ const result = this.handleAsync(async () => {
683
+ if (this.handleAsync !== super.handleAsync) {
684
+ this.#pendingAsync.add(fileId);
685
+ }
686
+ await new Promise(resolve => setTimeout(resolve));
687
+
688
+ const result = this.#xWriteHelper(fileId, pData.slice(), iOffset);
689
+ this.#taskTimestamp = performance.now();
690
+ return result;
691
+ });
692
+
693
+ if (rewound) this.#pendingAsync.delete(fileId);
694
+ return result;
695
+ }
696
+ return this.#xWriteHelper(fileId, pData, iOffset);
697
+ }
698
+
699
+ /**
700
+ * @param {number} fileId
701
+ * @param {Uint8Array} pData
702
+ * @param {number} iOffset
703
+ * @returns {number}
704
+ */
705
+ #xWriteHelper(fileId, pData, iOffset) {
706
+ const file = this.#mapIdToFile.get(fileId);
707
+ log(`xWrite ${file.path} ${pData.byteLength} ${iOffset}`);
708
+
709
+ try {
710
+ // Update file size if appending.
711
+ const prevFileSize = file.block0.fileSize;
712
+ if (file.block0.fileSize < iOffset + pData.byteLength) {
713
+ file.block0.fileSize = iOffset + pData.byteLength;
714
+ file.isMetadataChanged = true;
715
+ }
716
+
717
+ // Convert the write directly into an IndexedDB object. Our assumption
718
+ // is that SQLite will only overwrite data with an xWrite of the same
719
+ // offset and size unless the database page size changes, except when
720
+ // changing database page size which is handled by #reblockIfNeeded().
721
+ const block = iOffset === 0 ? file.block0 : {
722
+ path: file.path,
723
+ offset: -iOffset,
724
+ version: file.block0.version,
725
+ data: null
726
+ };
727
+ block.data = pData.slice();
728
+
729
+ if (file.changedPages) {
730
+ // This write is part of a batch atomic write. All writes in the
731
+ // batch have a new version, so update the changed list to allow
732
+ // old versions to be eventually deleted.
733
+ if (prevFileSize === file.block0.fileSize) {
734
+ file.changedPages.add(-iOffset);
735
+ }
736
+
737
+ // Defer writing block 0 to IndexedDB until batch commit.
738
+ if (iOffset !== 0) {
739
+ this.#idb.run('readwrite', ({blocks}) => blocks.put(block));
740
+ }
741
+ } else {
742
+ // Not a batch atomic write so write through.
743
+ this.#idb.run('readwrite', ({blocks}) => blocks.put(block));
744
+ }
745
+
746
+ // Clear dirty flag if page 0 was written.
747
+ file.isMetadataChanged = iOffset === 0 ? false : file.isMetadataChanged;
748
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
749
+ } catch (e) {
750
+ console.error(e);
751
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
752
+ }
753
+ }
754
+
755
+ /**
756
+ * @param {number} fileId
757
+ * @param {number} iSize
758
+ * @returns {number}
759
+ */
760
+ xTruncate(fileId, iSize) {
761
+ const file = this.#mapIdToFile.get(fileId);
762
+ log(`xTruncate ${file.path} ${iSize}`);
763
+
764
+ try {
765
+ Object.assign(file.block0, {
766
+ fileSize: iSize,
767
+ data: file.block0.data.slice(0, iSize)
768
+ });
769
+
770
+ // Delete all blocks beyond the file size and update metadata.
771
+ // This is never called within a transaction.
772
+ const block0 = Object.assign({}, file.block0);
773
+ this.#idb.run('readwrite', ({blocks})=> {
774
+ blocks.delete(this.#bound(file, -Infinity, -iSize));
775
+ blocks.put(block0);
776
+ });
777
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
778
+ } catch (e) {
779
+ console.error(e);
780
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
781
+ }
782
+ }
783
+
784
+ /**
785
+ * @param {number} fileId
786
+ * @param {number} flags
787
+ * @returns {number}
788
+ */
789
+ xSync(fileId, flags) {
790
+ // Skip IndexedDB sync if durability is relaxed and the last
791
+ // sync was recent enough.
792
+ const rewound = this.#pendingAsync.has(fileId);
793
+ if (rewound || this.#options.durability !== 'relaxed' ||
794
+ performance.now() - this.#taskTimestamp > MAX_TASK_MILLIS) {
795
+ const result = this.handleAsync(async () => {
796
+ if (this.handleAsync !== super.handleAsync) {
797
+ this.#pendingAsync.add(fileId);
798
+ }
799
+
800
+ const result = await this.#xSyncHelper(fileId, flags);
801
+ this.#taskTimestamp = performance.now();
802
+ return result;
803
+ });
804
+
805
+ if (rewound) this.#pendingAsync.delete(fileId);
806
+ return result;
807
+ }
808
+
809
+ const file = this.#mapIdToFile.get(fileId);
810
+ log(`xSync ${file.path} ${flags}`);
811
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
812
+ }
813
+
814
+ /**
815
+ * @param {number} fileId
816
+ * @param {number} flags
817
+ * @returns {Promise<number>}
818
+ */
819
+ async #xSyncHelper(fileId, flags) {
820
+ const file = this.#mapIdToFile.get(fileId);
821
+ log(`xSync ${file.path} ${flags}`);
822
+ try {
823
+ if (file.isMetadataChanged) {
824
+ // Metadata has changed so write block 0 to IndexedDB.
825
+ this.#idb.run('readwrite', async ({blocks}) => {
826
+ await blocks.put(file.block0);
827
+ });
828
+ file.isMetadataChanged = false;
829
+ }
830
+ await this.#idb.sync();
831
+ } catch (e) {
832
+ console.error(e);
833
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
834
+ }
835
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
836
+ }
837
+
838
+ /**
839
+ * @param {number} fileId
840
+ * @param {DataView} pSize64
841
+ * @returns {number}
842
+ */
843
+ xFileSize(fileId, pSize64) {
844
+ const file = this.#mapIdToFile.get(fileId);
845
+ log(`xFileSize ${file.path}`);
846
+
847
+ pSize64.setBigInt64(0, BigInt(file.block0.fileSize), true)
848
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
849
+ }
850
+
851
+ /**
852
+ * @param {number} fileId
853
+ * @param {number} flags
854
+ * @returns {number}
855
+ */
856
+ xLock(fileId, flags) {
857
+ return this.handleAsync(async () => {
858
+ const file = this.#mapIdToFile.get(fileId);
859
+ log(`xLock ${file.path} ${flags}`);
860
+
861
+ try {
862
+ // Acquire the lock.
863
+ const result = await file.locks.lock(flags);
864
+ if (result === _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK && file.locks.state === _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_SHARED) {
865
+ // Update block 0 in case another connection changed it.
866
+ file.block0 = await this.#idb.run('readonly', ({blocks}) => {
867
+ return blocks.get(this.#bound(file, 0));
868
+ });
869
+ }
870
+ return result;
871
+ } catch (e) {
872
+ console.error(e);
873
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
874
+ }
875
+ });
876
+ }
877
+
878
+ /**
879
+ * @param {number} fileId
880
+ * @param {number} flags
881
+ * @returns {number}
882
+ */
883
+ xUnlock(fileId, flags) {
884
+ return this.handleAsync(async () => {
885
+ const file = this.#mapIdToFile.get(fileId);
886
+ log(`xUnlock ${file.path} ${flags}`);
887
+
888
+ try {
889
+ return file.locks.unlock(flags);
890
+ } catch(e) {
891
+ console.error(e);
892
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
893
+ }
894
+ });
895
+ }
896
+
897
+ /**
898
+ * @param {number} fileId
899
+ * @param {DataView} pResOut
900
+ * @returns {number}
901
+ */
902
+ xCheckReservedLock(fileId, pResOut) {
903
+ const result = this.handleAsync(async () => {
904
+ const file = this.#mapIdToFile.get(fileId);
905
+ log(`xCheckReservedLock ${file.path}`);
906
+
907
+ const isReserved = await file.locks.isSomewhereReserved();
908
+ function setOutput(pResOut) {
909
+ };
910
+
911
+ // @ts-ignore
912
+ if (pResOut.buffer.detached || !pResOut.buffer.byteLength) {
913
+ pResOut = new DataView(new ArrayBuffer(4));
914
+ this.#growthHandler = (pResOutNew) => {
915
+ pResOutNew.setInt32(0, pResOut.getInt32(0, true), true);
916
+ };
917
+ }
918
+ pResOut.setInt32(0, isReserved ? 1 : 0, true);
919
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
920
+ });
921
+
922
+ this.#growthHandler?.(pResOut);
923
+ this.#growthHandler = null;
924
+ return result;
925
+ }
926
+
927
+ /**
928
+ * @param {number} fileId
929
+ * @returns {number}
930
+ */
931
+ xSectorSize(fileId) {
932
+ log('xSectorSize');
933
+ return SECTOR_SIZE;
934
+ }
935
+
936
+ /**
937
+ * @param {number} fileId
938
+ * @returns {number}
939
+ */
940
+ xDeviceCharacteristics(fileId) {
941
+ log('xDeviceCharacteristics');
942
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_BATCH_ATOMIC |
943
+ _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_SAFE_APPEND |
944
+ _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_SEQUENTIAL |
945
+ _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN;
946
+ }
947
+
948
+ /**
949
+ * @param {number} fileId
950
+ * @param {number} op
951
+ * @param {DataView} pArg
952
+ * @returns {number}
953
+ */
954
+ xFileControl(fileId, op, pArg) {
955
+ const file = this.#mapIdToFile.get(fileId);
956
+ log(`xFileControl ${file.path} ${op}`);
957
+
958
+ switch (op) {
959
+ case 11: //SQLITE_FCNTL_OVERWRITE
960
+ // This called on VACUUM. Set a flag so we know whether to check
961
+ // later if the page size changed.
962
+ file.overwrite = true;
963
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
964
+
965
+ case 21: // SQLITE_FCNTL_SYNC
966
+ // This is called at the end of each database transaction, whether
967
+ // it is batch atomic or not. Handle page size changes here.
968
+ if (file.overwrite) {
969
+ // As an optimization we only check for and handle a page file
970
+ // changes if we know a VACUUM has been done because handleAsync()
971
+ // has to unwind and rewind the stack. We must be sure to follow
972
+ // the same conditional path in both calls.
973
+ try {
974
+ return this.handleAsync(async () => {
975
+ await this.#reblockIfNeeded(file);
976
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
977
+ });
978
+ } catch (e) {
979
+ console.error(e);
980
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
981
+ }
982
+ }
983
+
984
+ if (file.isMetadataChanged) {
985
+ // Metadata has changed so write block 0 to IndexedDB.
986
+ try {
987
+ this.#idb.run('readwrite', async ({blocks}) => {
988
+ await blocks.put(file.block0);
989
+ });
990
+ file.isMetadataChanged = false;
991
+ } catch (e) {
992
+ console.error(e);
993
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
994
+ }
995
+ }
996
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
997
+
998
+ case 22: // SQLITE_FCNTL_COMMIT_PHASETWO
999
+ // This is called after a commit is completed.
1000
+ file.overwrite = false;
1001
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1002
+
1003
+ case 31: // SQLITE_FCNTL_BEGIN_ATOMIC_WRITE
1004
+ return this.handleAsync(async () => {
1005
+ try {
1006
+ // Prepare a new version for IndexedDB blocks.
1007
+ file.block0.version--;
1008
+ file.changedPages = new Set();
1009
+
1010
+ // Clear blocks from abandoned transactions that would conflict
1011
+ // with the new transaction.
1012
+ this.#idb.run('readwrite', async ({blocks}) => {
1013
+ const keys = await blocks.index('version').getAllKeys(IDBKeyRange.bound(
1014
+ [file.path],
1015
+ [file.path, file.block0.version]));
1016
+ for (const key of keys) {
1017
+ blocks.delete(key);
1018
+ }
1019
+ });
1020
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1021
+ } catch (e) {
1022
+ console.error(e);
1023
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
1024
+ }
1025
+ });
1026
+
1027
+ case 32: // SQLITE_FCNTL_COMMIT_ATOMIC_WRITE
1028
+ try {
1029
+ const block0 = Object.assign({}, file.block0);
1030
+ block0.data = block0.data.slice();
1031
+ const changedPages = file.changedPages;
1032
+ file.changedPages = null;
1033
+ file.isMetadataChanged = false;
1034
+ this.#idb.run('readwrite', async ({blocks})=> {
1035
+ // Write block 0 to commit the new version.
1036
+ blocks.put(block0);
1037
+
1038
+ // Blocks to purge are saved in a special IndexedDB object with
1039
+ // an "index" of "purge". Add pages changed by this transaction.
1040
+ const purgeBlock = await blocks.get([file.path, 'purge', 0]) ?? {
1041
+ path: file.path,
1042
+ offset: 'purge',
1043
+ version: 0,
1044
+ data: new Map(),
1045
+ count: 0
1046
+ };
1047
+
1048
+ purgeBlock.count += changedPages.size;
1049
+ for (const pageIndex of changedPages) {
1050
+ purgeBlock.data.set(pageIndex, block0.version);
1051
+ }
1052
+
1053
+ blocks.put(purgeBlock);
1054
+ this.#maybePurge(file.path, purgeBlock.count);
1055
+ });
1056
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1057
+ } catch (e) {
1058
+ console.error(e);
1059
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
1060
+ }
1061
+
1062
+ case 33: // SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE
1063
+ return this.handleAsync(async () => {
1064
+ try {
1065
+ // Restore original state. Objects for the abandoned version will
1066
+ // be left in IndexedDB to be removed by the next atomic write
1067
+ // transaction.
1068
+ file.changedPages = null;
1069
+ file.isMetadataChanged = false;
1070
+ file.block0 = await this.#idb.run('readonly', ({blocks}) => {
1071
+ return blocks.get([file.path, 0, file.block0.version + 1]);
1072
+ });
1073
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1074
+ } catch (e) {
1075
+ console.error(e);
1076
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
1077
+ }
1078
+ });
1079
+
1080
+ default:
1081
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOTFOUND;
1082
+ }
1083
+ }
1084
+
1085
+ /**
1086
+ * @param {string} name
1087
+ * @param {number} flags
1088
+ * @param {DataView} pResOut
1089
+ * @returns {number}
1090
+ */
1091
+ xAccess(name, flags, pResOut) {
1092
+ const result = this.handleAsync(async () => {
1093
+ try {
1094
+ const path = new URL(name, 'file://localhost/').pathname;
1095
+ log(`xAccess ${path} ${flags}`);
1096
+
1097
+ // Check if block 0 exists.
1098
+ const key = await this.#idb.run('readonly', ({blocks}) => {
1099
+ return blocks.getKey(this.#bound({path}, 0));
1100
+ });
1101
+
1102
+ // @ts-ignore
1103
+ if (pResOut.buffer.detached || !pResOut.buffer.byteLength) {
1104
+ pResOut = new DataView(new ArrayBuffer(4));
1105
+ this.#growthHandler = (pResOutNew) => {
1106
+ pResOutNew.setInt32(0, pResOut.getInt32(0, true), true);
1107
+ }
1108
+ }
1109
+ pResOut.setInt32(0, key ? 1 : 0, true);
1110
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1111
+ } catch (e) {
1112
+ console.error(e);
1113
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
1114
+ }
1115
+ });
1116
+
1117
+ this.#growthHandler?.(pResOut);
1118
+ this.#growthHandler = null;
1119
+ return result;
1120
+ }
1121
+
1122
+ /**
1123
+ * @param {string} name
1124
+ * @param {number} syncDir
1125
+ * @returns {number}
1126
+ */
1127
+ xDelete(name, syncDir) {
1128
+ return this.handleAsync(async () => {
1129
+ const path = new URL(name, 'file://localhost/').pathname;
1130
+ log(`xDelete ${path} ${syncDir}`);
1131
+
1132
+ try {
1133
+ this.#idb.run('readwrite', ({blocks}) => {
1134
+ return blocks.delete(IDBKeyRange.bound([path], [path, []]));
1135
+ });
1136
+ if (syncDir) {
1137
+ await this.#idb.sync();
1138
+ }
1139
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1140
+ } catch (e) {
1141
+ console.error(e);
1142
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR;
1143
+ }
1144
+ });
1145
+ }
1146
+
1147
+ /**
1148
+ * Purge obsolete blocks from a database file.
1149
+ * @param {string} path
1150
+ */
1151
+ async purge(path) {
1152
+ const start = Date.now();
1153
+ await this.#idb.run('readwrite', async ({blocks}) => {
1154
+ const purgeBlock = await blocks.get([path, 'purge', 0]);
1155
+ if (purgeBlock) {
1156
+ for (const [pageOffset, version] of purgeBlock.data) {
1157
+ blocks.delete(IDBKeyRange.bound(
1158
+ [path, pageOffset, version],
1159
+ [path, pageOffset, Infinity],
1160
+ true, false));
1161
+ }
1162
+ await blocks.delete([path, 'purge', 0]);
1163
+ }
1164
+ log(`purge ${path} ${purgeBlock?.data.size ?? 0} pages in ${Date.now() - start} ms`);
1165
+ });
1166
+ }
1167
+
1168
+ /**
1169
+ * Conditionally schedule a purge task.
1170
+ * @param {string} path
1171
+ * @param {number} nPages
1172
+ */
1173
+ #maybePurge(path, nPages) {
1174
+ if (this.#options.purge === 'manual' ||
1175
+ this.#pendingPurges.has(path) ||
1176
+ nPages < this.#options.purgeAtLeast) {
1177
+ // No purge needed.
1178
+ return;
1179
+ }
1180
+
1181
+ if (globalThis.requestIdleCallback) {
1182
+ globalThis.requestIdleCallback(() => {
1183
+ this.purge(path);
1184
+ this.#pendingPurges.delete(path)
1185
+ });
1186
+ } else {
1187
+ setTimeout(() => {
1188
+ this.purge(path);
1189
+ this.#pendingPurges.delete(path)
1190
+ });
1191
+ }
1192
+ this.#pendingPurges.add(path);
1193
+ }
1194
+
1195
+ #bound(file, begin, end = 0) {
1196
+ // Fetch newest block 0. For other blocks, use block 0 version.
1197
+ const version = !begin || -begin < file.block0.data.length ?
1198
+ -Infinity :
1199
+ file.block0.version;
1200
+ return IDBKeyRange.bound(
1201
+ [file.path, begin, version],
1202
+ [file.path, end, Infinity]);
1203
+ }
1204
+
1205
+ // The database page size can be changed with PRAGMA page_size and VACUUM.
1206
+ // The updated file will be overwritten with a regular transaction using
1207
+ // the old page size. After that it will be read and written using the
1208
+ // new page size, so the IndexedDB objects must be combined or split
1209
+ // appropriately.
1210
+ async #reblockIfNeeded(file) {
1211
+ const oldPageSize = file.block0.data.length;
1212
+ if (oldPageSize < 18) return; // no page size defined
1213
+
1214
+ const view = new DataView(file.block0.data.buffer, file.block0.data.byteOffset);
1215
+ let newPageSize = view.getUint16(16);
1216
+ if (newPageSize === 1) newPageSize = 65536;
1217
+ if (newPageSize === oldPageSize) return; // no page size change
1218
+
1219
+ const maxPageSize = Math.max(oldPageSize, newPageSize);
1220
+ const nOldPages = maxPageSize / oldPageSize;
1221
+ const nNewPages = maxPageSize / newPageSize;
1222
+
1223
+ const newPageCount = view.getUint32(28);
1224
+ const fileSize = newPageCount * newPageSize;
1225
+
1226
+ const version = file.block0.version;
1227
+ await this.#idb.run('readwrite', async ({blocks}) => {
1228
+ // When the block size changes, the entire file is rewritten. Delete
1229
+ // all blocks older than block 0 to leave a single version at every
1230
+ // offset.
1231
+ const keys = await blocks.index('version').getAllKeys(IDBKeyRange.bound(
1232
+ [file.path, version + 1],
1233
+ [file.path, Infinity]
1234
+ ));
1235
+ for (const key of keys) {
1236
+ blocks.delete(key);
1237
+ }
1238
+ blocks.delete([file.path, 'purge', 0]);
1239
+
1240
+ // Do the conversion in chunks of the larger of the page sizes.
1241
+ for (let iOffset = 0; iOffset < fileSize; iOffset += maxPageSize) {
1242
+ // Fetch nOldPages. They can be fetched in one request because
1243
+ // there is now a single version in the file.
1244
+ const oldPages = await blocks.getAll(
1245
+ IDBKeyRange.lowerBound([file.path, -(iOffset + maxPageSize), Infinity]),
1246
+ nOldPages);
1247
+ for (const oldPage of oldPages) {
1248
+ blocks.delete([oldPage.path, oldPage.offset, oldPage.version]);
1249
+ }
1250
+
1251
+ // Convert to new pages.
1252
+ if (nNewPages === 1) {
1253
+ // Combine nOldPages old pages into a new page.
1254
+ const buffer = new Uint8Array(newPageSize);
1255
+ for (const oldPage of oldPages) {
1256
+ buffer.set(oldPage.data, -(iOffset + oldPage.offset));
1257
+ }
1258
+ const newPage = {
1259
+ path: file.path,
1260
+ offset: -iOffset,
1261
+ version,
1262
+ data: buffer
1263
+ };
1264
+ if (newPage.offset === 0) {
1265
+ newPage.fileSize = fileSize;
1266
+ file.block0 = newPage;
1267
+ }
1268
+ blocks.put(newPage);
1269
+ } else {
1270
+ // Split an old page into nNewPages new pages.
1271
+ const oldPage = oldPages[0];
1272
+ for (let i = 0; i < nNewPages; ++i) {
1273
+ const offset = -(iOffset + i * newPageSize);
1274
+ if (-offset >= fileSize) break;
1275
+ const newPage = {
1276
+ path: oldPage.path,
1277
+ offset,
1278
+ version,
1279
+ data: oldPage.data.subarray(i * newPageSize, (i + 1) * newPageSize)
1280
+ }
1281
+ if (newPage.offset === 0) {
1282
+ newPage.fileSize = fileSize;
1283
+ file.block0 = newPage;
1284
+ }
1285
+ blocks.put(newPage);
1286
+ }
1287
+ }
1288
+ }
1289
+ });
1290
+ }
1291
+ }
1292
+
1293
+ function openDatabase(idbDatabaseName) {
1294
+ return new Promise((resolve, reject) => {
1295
+ const request = globalThis.indexedDB.open(idbDatabaseName, 5);
1296
+ request.addEventListener('upgradeneeded', function() {
1297
+ const blocks = request.result.createObjectStore('blocks', {
1298
+ keyPath: ['path', 'offset', 'version']
1299
+ });
1300
+ blocks.createIndex('version', ['path', 'version']);
1301
+ });
1302
+ request.addEventListener('success', () => {
1303
+ resolve(request.result);
1304
+ });
1305
+ request.addEventListener('error', () => {
1306
+ reject(request.error);
1307
+ });
1308
+ });
1309
+ }
1310
+
1311
+ /***/ }),
1312
+
1313
+ /***/ "../../node_modules/@journeyapps/wa-sqlite/src/examples/IDBContext.js":
1314
+ /*!****************************************************************************!*\
1315
+ !*** ../../node_modules/@journeyapps/wa-sqlite/src/examples/IDBContext.js ***!
1316
+ \****************************************************************************/
1317
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1318
+
1319
+ __webpack_require__.r(__webpack_exports__);
1320
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1321
+ /* harmony export */ IDBContext: () => (/* binding */ IDBContext)
1322
+ /* harmony export */ });
1323
+ // Copyright 2022 Roy T. Hashimoto. All Rights Reserved.
1324
+
1325
+ // IndexedDB transactions older than this will be replaced.
1326
+ const MAX_TRANSACTION_LIFETIME_MILLIS = 5_000;
1327
+
1328
+ // For debugging.
1329
+ let nextTxId = 0;
1330
+ const mapTxToId = new WeakMap();
1331
+ function log(...args) {
1332
+ // console.debug(...args);
1333
+ }
1334
+
1335
+ // This class manages IDBTransaction and IDBRequest instances. It tries
1336
+ // to reuse transactions to minimize transaction overhead.
1337
+ class IDBContext {
1338
+ /** @type {IDBDatabase} */ #db;
1339
+ /** @type {Promise<IDBDatabase>} */ #dbReady;
1340
+ #txOptions;
1341
+
1342
+ /** @type {IDBTransaction} */ #tx = null;
1343
+ #txTimestamp = 0;
1344
+ #runChain = Promise.resolve();
1345
+ #putChain = Promise.resolve();
1346
+
1347
+ /**
1348
+ * @param {IDBDatabase|Promise<IDBDatabase>} idbDatabase
1349
+ */
1350
+ constructor(idbDatabase, txOptions = { durability: 'default' }) {
1351
+ this.#dbReady = Promise.resolve(idbDatabase).then(db => this.#db = db);
1352
+ this.#txOptions = txOptions;
1353
+ }
1354
+
1355
+ async close() {
1356
+ const db = this.#db ?? await this.#dbReady;
1357
+ await this.#runChain;
1358
+ await this.sync();
1359
+ db.close();
1360
+ }
1361
+
1362
+ /**
1363
+ * Run a function with the provided object stores. The function
1364
+ * should be idempotent in case it is passed an expired transaction.
1365
+ * @param {IDBTransactionMode} mode
1366
+ * @param {(stores: Object.<string, ObjectStore>) => any} f
1367
+ */
1368
+ async run(mode, f) {
1369
+ // Ensure that functions run sequentially.
1370
+ const result = this.#runChain.then(() => this.#run(mode, f));
1371
+ this.#runChain = result.catch(() => {});
1372
+ return result;
1373
+ }
1374
+
1375
+ /**
1376
+ * @param {IDBTransactionMode} mode
1377
+ * @param {(stores: Object.<string, ObjectStore>) => any} f
1378
+ * @returns
1379
+ */
1380
+ async #run(mode, f) {
1381
+ const db = this.#db ?? await this.#dbReady;
1382
+ if (mode === 'readwrite' && this.#tx?.mode === 'readonly') {
1383
+ // Mode requires a new transaction.
1384
+ this.#tx = null;
1385
+ } else if (performance.now() - this.#txTimestamp > MAX_TRANSACTION_LIFETIME_MILLIS) {
1386
+ // Chrome times out transactions after 60 seconds so refresh preemptively.
1387
+ try {
1388
+ this.#tx?.commit();
1389
+ } catch (e) {
1390
+ // Explicit commit can fail but this can be ignored if it will
1391
+ // auto-commit anyway.
1392
+ if (e.name !== 'InvalidStateError') throw e;
1393
+ }
1394
+
1395
+ // Skip to the next task to allow processing.
1396
+ await new Promise(resolve => setTimeout(resolve));
1397
+ this.#tx = null;
1398
+ }
1399
+
1400
+ // Run the user function with a retry in case the transaction is invalid.
1401
+ for (let i = 0; i < 2; ++i) {
1402
+ if (!this.#tx) {
1403
+ // @ts-ignore
1404
+ this.#tx = db.transaction(db.objectStoreNames, mode, this.#txOptions);
1405
+ const timestamp = this.#txTimestamp = performance.now();
1406
+
1407
+ // Chain the result of every transaction. If any transaction is
1408
+ // aborted then the next sync() call will throw.
1409
+ this.#putChain = this.#putChain.then(() => {
1410
+ return new Promise((resolve, reject) => {
1411
+ this.#tx.addEventListener('complete', event => {
1412
+ resolve();
1413
+ if (this.#tx === event.target) {
1414
+ this.#tx = null;
1415
+ }
1416
+ log(`transaction ${mapTxToId.get(event.target)} complete`);
1417
+ });
1418
+ this.#tx.addEventListener('abort', event => {
1419
+ console.warn('tx abort', (performance.now() - timestamp)/1000);
1420
+ // @ts-ignore
1421
+ const e = event.target.error;
1422
+ reject(e);
1423
+ if (this.#tx === event.target) {
1424
+ this.#tx = null;
1425
+ }
1426
+ log(`transaction ${mapTxToId.get(event.target)} aborted`, e);
1427
+ });
1428
+ });
1429
+ });
1430
+
1431
+ log(`new transaction ${nextTxId} ${mode}`);
1432
+ mapTxToId.set(this.#tx, nextTxId++);
1433
+ }
1434
+
1435
+ try {
1436
+ const stores = Object.fromEntries(Array.from(db.objectStoreNames, name => {
1437
+ return [name, new ObjectStore(this.#tx.objectStore(name))];
1438
+ }));
1439
+ return await f(stores);
1440
+ } catch (e) {
1441
+ this.#tx = null;
1442
+ if (i) throw e;
1443
+ // console.warn('retrying with new transaction');
1444
+ }
1445
+ }
1446
+ }
1447
+
1448
+ async sync() {
1449
+ // Wait until all transactions since the previous sync have committed.
1450
+ // Throw if any transaction failed.
1451
+ await this.#runChain;
1452
+ await this.#putChain;
1453
+ this.#putChain = Promise.resolve();
1454
+ }
1455
+ }
1456
+
1457
+ /**
1458
+ * Helper to convert IDBRequest to Promise.
1459
+ * @param {IDBRequest} request
1460
+ * @returns {Promise}
1461
+ */
1462
+ function wrapRequest(request) {
1463
+ return new Promise((resolve, reject) => {
1464
+ request.addEventListener('success', () => resolve(request.result));
1465
+ request.addEventListener('error', () => reject(request.error));
1466
+ });
1467
+ }
1468
+
1469
+ // IDBObjectStore wrapper passed to IDBContext run functions.
1470
+ class ObjectStore {
1471
+ #objectStore;
1472
+
1473
+ /**
1474
+ * @param {IDBObjectStore} objectStore
1475
+ */
1476
+ constructor(objectStore) {
1477
+ this.#objectStore = objectStore;
1478
+ }
1479
+
1480
+ /**
1481
+ * @param {IDBValidKey|IDBKeyRange} query
1482
+ * @returns {Promise}
1483
+ */
1484
+ get(query) {
1485
+ log(`get ${this.#objectStore.name}`, query);
1486
+ const request = this.#objectStore.get(query);
1487
+ return wrapRequest(request);
1488
+ }
1489
+
1490
+ /**
1491
+ * @param {IDBValidKey|IDBKeyRange} query
1492
+ * @param {number} [count]
1493
+ * @returns {Promise}
1494
+ */
1495
+ getAll(query, count) {
1496
+ log(`getAll ${this.#objectStore.name}`, query, count);
1497
+ const request = this.#objectStore.getAll(query, count);
1498
+ return wrapRequest(request);
1499
+ }
1500
+
1501
+ /**
1502
+ * @param {IDBValidKey|IDBKeyRange} query
1503
+ * @returns {Promise<IDBValidKey>}
1504
+ */
1505
+ getKey(query) {
1506
+ log(`getKey ${this.#objectStore.name}`, query);
1507
+ const request = this.#objectStore.getKey(query);
1508
+ return wrapRequest(request);
1509
+ }
1510
+
1511
+ /**
1512
+ * @param {IDBValidKey|IDBKeyRange} query
1513
+ * @param {number} [count]
1514
+ * @returns {Promise}
1515
+ */
1516
+ getAllKeys(query, count) {
1517
+ log(`getAllKeys ${this.#objectStore.name}`, query, count);
1518
+ const request = this.#objectStore.getAllKeys(query, count);
1519
+ return wrapRequest(request);
1520
+ }
1521
+
1522
+ /**
1523
+ * @param {any} value
1524
+ * @param {IDBValidKey} [key]
1525
+ * @returns {Promise}
1526
+ */
1527
+ put(value, key) {
1528
+ log(`put ${this.#objectStore.name}`, value, key);
1529
+ const request = this.#objectStore.put(value, key);
1530
+ return wrapRequest(request);
1531
+ }
1532
+
1533
+ /**
1534
+ * @param {IDBValidKey|IDBKeyRange} query
1535
+ * @returns {Promise}
1536
+ */
1537
+ delete(query) {
1538
+ log(`delete ${this.#objectStore.name}`, query);
1539
+ const request = this.#objectStore.delete(query);
1540
+ return wrapRequest(request);
1541
+ }
1542
+
1543
+ clear() {
1544
+ log(`clear ${this.#objectStore.name}`);
1545
+ const request = this.#objectStore.clear();
1546
+ return wrapRequest(request);
1547
+ }
1548
+
1549
+ index(name) {
1550
+ return new Index(this.#objectStore.index(name));
1551
+ }
1552
+ }
1553
+
1554
+ class Index {
1555
+ /** @type {IDBIndex} */ #index;
1556
+
1557
+ /**
1558
+ * @param {IDBIndex} index
1559
+ */
1560
+ constructor(index) {
1561
+ this.#index = index;
1562
+ }
1563
+
1564
+ /**
1565
+ * @param {IDBValidKey|IDBKeyRange} query
1566
+ * @param {number} [count]
1567
+ * @returns {Promise<IDBValidKey[]>}
1568
+ */
1569
+ getAllKeys(query, count) {
1570
+ log(`IDBIndex.getAllKeys ${this.#index.objectStore.name}<${this.#index.name}>`, query, count);
1571
+ const request = this.#index.getAllKeys(query, count);
1572
+ return wrapRequest(request);
1573
+ }
1574
+ }
1575
+
1576
+ /***/ }),
1577
+
1578
+ /***/ "../../node_modules/@journeyapps/wa-sqlite/src/examples/WebLocks.js":
1579
+ /*!**************************************************************************!*\
1580
+ !*** ../../node_modules/@journeyapps/wa-sqlite/src/examples/WebLocks.js ***!
1581
+ \**************************************************************************/
1582
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1583
+
1584
+ __webpack_require__.r(__webpack_exports__);
1585
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1586
+ /* harmony export */ WebLocksBase: () => (/* binding */ WebLocksBase),
1587
+ /* harmony export */ WebLocksExclusive: () => (/* binding */ WebLocksExclusive),
1588
+ /* harmony export */ WebLocksShared: () => (/* binding */ WebLocksShared)
1589
+ /* harmony export */ });
1590
+ /* harmony import */ var _VFS_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../VFS.js */ "../../node_modules/@journeyapps/wa-sqlite/src/VFS.js");
1591
+ // Copyright 2022 Roy T. Hashimoto. All Rights Reserved.
1592
+
1593
+
1594
+ const LOCK_TYPE_MASK =
1595
+ _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_NONE |
1596
+ _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_SHARED |
1597
+ _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_RESERVED |
1598
+ _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_PENDING |
1599
+ _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_EXCLUSIVE;
1600
+
1601
+ class WebLocksBase {
1602
+ get state() { return this.#state; }
1603
+ #state = _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_NONE;
1604
+
1605
+ timeoutMillis = 0;
1606
+
1607
+ /** @type {Map<string, (value: any) => void>} */ #releasers = new Map();
1608
+ /** @type {Promise<0|5|3850>} */ #pending = Promise.resolve(0);
1609
+
1610
+ /**
1611
+ * @param {number} flags
1612
+ * @returns {Promise<0|5|3850>} SQLITE_OK, SQLITE_BUSY, SQLITE_IOERR_LOCK
1613
+ */
1614
+ async lock(flags) {
1615
+ return this.#apply(this.#lock, flags);
1616
+ }
1617
+
1618
+ /**
1619
+ * @param {number} flags
1620
+ * @returns {Promise<0|5|3850>} SQLITE_OK, SQLITE_IOERR_LOCK
1621
+ */
1622
+ async unlock(flags) {
1623
+ return this.#apply(this.#unlock, flags);
1624
+ }
1625
+
1626
+ /**
1627
+ * @returns {Promise<boolean>}
1628
+ */
1629
+ async isSomewhereReserved() {
1630
+ throw new Error('unimplemented');
1631
+ }
1632
+
1633
+ /**
1634
+ *
1635
+ * @param {(targetState: number) => void} method
1636
+ * @param {number} flags
1637
+ */
1638
+ async #apply(method, flags) {
1639
+ const targetState = flags & LOCK_TYPE_MASK;
1640
+ try {
1641
+ // Force locks and unlocks to run sequentially. This allows not
1642
+ // waiting for unlocks to complete.
1643
+ const call = () => method.call(this, targetState);
1644
+ await (this.#pending = this.#pending.then(call, call));
1645
+ this.#state = targetState;
1646
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1647
+ } catch (e) {
1648
+ if (e.name === 'AbortError') {
1649
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BUSY;
1650
+ }
1651
+ console.error(e);
1652
+ return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_IOERR_LOCK;
1653
+ }
1654
+ }
1655
+
1656
+ async #lock(targetState) {
1657
+ if (targetState === this.#state) return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1658
+ switch (this.#state) {
1659
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_NONE:
1660
+ switch (targetState) {
1661
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_SHARED:
1662
+ return this._NONEtoSHARED();
1663
+ default:
1664
+ throw new Error(`unexpected transition ${this.#state} -> ${targetState}`);
1665
+ }
1666
+
1667
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_SHARED:
1668
+ switch (targetState) {
1669
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_RESERVED:
1670
+ return this._SHAREDtoRESERVED();
1671
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_EXCLUSIVE:
1672
+ return this._SHAREDtoEXCLUSIVE();
1673
+ default:
1674
+ throw new Error(`unexpected transition ${this.#state} -> ${targetState}`);
1675
+ }
1676
+
1677
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_RESERVED:
1678
+ switch (targetState) {
1679
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_EXCLUSIVE:
1680
+ return this._RESERVEDtoEXCLUSIVE();
1681
+ default:
1682
+ throw new Error(`unexpected transition ${this.#state} -> ${targetState}`);
1683
+ }
1684
+
1685
+ default:
1686
+ throw new Error(`unexpected transition ${this.#state} -> ${targetState}`);
1687
+ }
1688
+ }
1689
+
1690
+ async #unlock(targetState) {
1691
+ if (targetState === this.#state) return _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1692
+ switch (this.#state) {
1693
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_EXCLUSIVE:
1694
+ switch (targetState) {
1695
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_SHARED:
1696
+ return this._EXCLUSIVEtoSHARED();
1697
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_NONE:
1698
+ return this._EXCLUSIVEtoNONE();
1699
+ default:
1700
+ throw new Error(`unexpected transition ${this.#state} -> ${targetState}`);
1701
+ }
1702
+
1703
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_RESERVED:
1704
+ switch (targetState) {
1705
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_SHARED:
1706
+ return this._RESERVEDtoSHARED();
1707
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_NONE:
1708
+ return this._RESERVEDtoNONE();
1709
+ default:
1710
+ throw new Error(`unexpected transition ${this.#state} -> ${targetState}`);
1711
+ }
1712
+
1713
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_SHARED:
1714
+ switch (targetState) {
1715
+ case _VFS_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_LOCK_NONE:
1716
+ return this._SHAREDtoNONE();
1717
+ default:
1718
+ throw new Error(`unexpected transition ${this.#state} -> ${targetState}`);
1719
+ }
1720
+
1721
+ default:
1722
+ throw new Error(`unexpected transition ${this.#state} -> ${targetState}`);
1723
+ }
1724
+ }
1725
+
1726
+ async _NONEtoSHARED() {
1727
+ }
1728
+
1729
+ async _SHAREDtoEXCLUSIVE() {
1730
+ await this._SHAREDtoRESERVED();
1731
+ await this._RESERVEDtoEXCLUSIVE();
1732
+ }
1733
+
1734
+ async _SHAREDtoRESERVED() {
1735
+ }
1736
+
1737
+ async _RESERVEDtoEXCLUSIVE() {
1738
+ }
1739
+
1740
+ async _EXCLUSIVEtoRESERVED() {
1741
+ }
1742
+
1743
+ async _EXCLUSIVEtoSHARED() {
1744
+ await this._EXCLUSIVEtoRESERVED();
1745
+ await this._RESERVEDtoSHARED();
1746
+ }
1747
+
1748
+ async _EXCLUSIVEtoNONE() {
1749
+ await this._EXCLUSIVEtoRESERVED();
1750
+ await this._RESERVEDtoSHARED();
1751
+ await this._SHAREDtoNONE();
1752
+ }
1753
+
1754
+ async _RESERVEDtoSHARED() {
1755
+ }
1756
+
1757
+ async _RESERVEDtoNONE() {
1758
+ await this._RESERVEDtoSHARED();
1759
+ await this._SHAREDtoNONE();
1760
+ }
1761
+
1762
+ async _SHAREDtoNONE() {
1763
+ }
1764
+
1765
+ /**
1766
+ * @param {string} lockName
1767
+ * @param {LockOptions} options
1768
+ * @returns {Promise<?Lock>}
1769
+ */
1770
+ _acquireWebLock(lockName, options) {
1771
+ return new Promise(async (resolve, reject) => {
1772
+ try {
1773
+ await navigator.locks.request(lockName, options, lock => {
1774
+ resolve(lock);
1775
+ if (lock) {
1776
+ return new Promise(release => this.#releasers.set(lockName, release));
1777
+ }
1778
+ });
1779
+ } catch(e) {
1780
+ reject(e);
1781
+ }
1782
+ });
1783
+ }
1784
+
1785
+ /**
1786
+ * @param {string} lockName
1787
+ */
1788
+ _releaseWebLock(lockName) {
1789
+ this.#releasers.get(lockName)?.();
1790
+ this.#releasers.delete(lockName);
1791
+ }
1792
+
1793
+ /**
1794
+ * @param {string} lockName
1795
+ */
1796
+ async _pollWebLock(lockName) {
1797
+ const query = await navigator.locks.query();
1798
+ return query.held.find(({name}) => name === lockName)?.mode;
1799
+ }
1800
+
1801
+ /**
1802
+ * @returns {?AbortSignal}
1803
+ */
1804
+ _getTimeoutSignal() {
1805
+ if (this.timeoutMillis) {
1806
+ const abortController = new AbortController();
1807
+ setTimeout(() => abortController.abort(), this.timeoutMillis);
1808
+ return abortController.signal;
1809
+ }
1810
+ return undefined;
1811
+ }
1812
+ }
1813
+
1814
+ class WebLocksExclusive extends WebLocksBase {
1815
+ /**
1816
+ * @param {string} name
1817
+ */
1818
+ constructor(name) {
1819
+ super();
1820
+ this._lockName = name + '-outer';
1821
+ this._reservedName = name + '-reserved';
1822
+ }
1823
+
1824
+ async isSomewhereReserved() {
1825
+ const mode = await this._pollWebLock(this._reservedName);
1826
+ return mode === 'exclusive';
1827
+ }
1828
+
1829
+ async _NONEtoSHARED() {
1830
+ await this._acquireWebLock(this._lockName, {
1831
+ mode: 'exclusive',
1832
+ signal: this._getTimeoutSignal()
1833
+ });
1834
+ }
1835
+
1836
+ async _SHAREDtoRESERVED() {
1837
+ await this._acquireWebLock(this._reservedName, {
1838
+ mode: 'exclusive',
1839
+ signal: this._getTimeoutSignal()
1840
+ });
1841
+ }
1842
+
1843
+ async _RESERVEDtoSHARED() {
1844
+ this._releaseWebLock(this._reservedName);
1845
+ }
1846
+
1847
+ async _SHAREDtoNONE() {
1848
+ this._releaseWebLock(this._lockName);
1849
+ }
1850
+ }
1851
+
1852
+ class WebLocksShared extends WebLocksBase {
1853
+ maxRetryMillis = 1000;
1854
+
1855
+ /**
1856
+ * @param {string} name
1857
+ */
1858
+ constructor(name) {
1859
+ super();
1860
+ this._outerName = name + '-outer';
1861
+ this._innerName = name + '-inner';
1862
+ }
1863
+
1864
+ async isSomewhereReserved() {
1865
+ const mode = await this._pollWebLock(this._outerName);
1866
+ return mode === 'exclusive';
1867
+ }
1868
+
1869
+ async _NONEtoSHARED() {
1870
+ await this._acquireWebLock(this._outerName, {
1871
+ mode: 'shared',
1872
+ signal: this._getTimeoutSignal()
1873
+ });
1874
+ await this._acquireWebLock(this._innerName, {
1875
+ mode: 'shared',
1876
+ signal: this._getTimeoutSignal()
1877
+ });
1878
+ this._releaseWebLock(this._outerName);
1879
+ }
1880
+
1881
+ async _SHAREDtoRESERVED() {
1882
+ let timeoutMillis = 1;
1883
+ while (true) {
1884
+ // Attempt to get the outer lock without blocking.
1885
+ const isLocked = await this._acquireWebLock(this._outerName, {
1886
+ mode: 'exclusive',
1887
+ ifAvailable: true
1888
+ });
1889
+ if (isLocked) break;
1890
+
1891
+ if (await this.isSomewhereReserved()) {
1892
+ // Someone else has a reserved lock so retry cannot succeed.
1893
+ throw new DOMException('', 'AbortError');
1894
+ }
1895
+
1896
+ await new Promise(resolve => setTimeout(resolve, timeoutMillis));
1897
+ timeoutMillis = Math.min(2 * timeoutMillis, this.maxRetryMillis);
1898
+ }
1899
+ this._releaseWebLock(this._innerName);
1900
+ }
1901
+
1902
+ async _RESERVEDtoEXCLUSIVE() {
1903
+ await this._acquireWebLock(this._innerName, {
1904
+ mode: 'exclusive',
1905
+ signal: this._getTimeoutSignal()
1906
+ });
1907
+ }
1908
+
1909
+ async _EXCLUSIVEtoRESERVED() {
1910
+ this._releaseWebLock(this._innerName);
1911
+ }
1912
+
1913
+ async _RESERVEDtoSHARED() {
1914
+ await this._acquireWebLock(this._innerName, { mode: 'shared' });
1915
+ this._releaseWebLock(this._outerName);
1916
+ }
1917
+
1918
+ async _SHAREDtoNONE() {
1919
+ this._releaseWebLock(this._innerName);
1920
+ }
1921
+ }
1922
+
1923
+ /***/ })
1924
+
1925
+ }]);
1926
+ //# sourceMappingURL=node_modules_journeyapps_wa-sqlite_src_examples_IDBBatchAtomicVFS_js.umd.js.map