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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/index.umd.js +64 -4091
  2. package/dist/index.umd.js.map +1 -1
  3. package/dist/worker/SharedSyncImplementation.umd.js +350 -405
  4. package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
  5. package/dist/worker/WASQLiteDB.umd.js +351 -406
  6. package/dist/worker/WASQLiteDB.umd.js.map +1 -1
  7. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-b9c070.umd.js +31 -0
  8. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-b9c070.umd.js.map +1 -0
  9. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-c99c07.umd.js +31 -0
  10. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-c99c07.umd.js.map +1 -0
  11. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-cc5fcc.umd.js +31 -0
  12. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-cc5fcc.umd.js.map +1 -0
  13. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js +31 -0
  14. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js.map +1 -0
  15. package/dist/worker/{node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--1787c2.umd.js → node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-0df390.umd.js} +24 -24
  16. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-0df390.umd.js.map +1 -0
  17. package/dist/worker/{node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--a6ce73.umd.js → node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-151024.umd.js} +18 -18
  18. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-151024.umd.js.map +1 -0
  19. package/dist/worker/{node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--0e69f0.umd.js → node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-c01ef0.umd.js} +20 -20
  20. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-c01ef0.umd.js.map +1 -0
  21. package/lib/package.json +1 -1
  22. package/lib/src/db/adapters/wa-sqlite/InternalWASQLiteDBAdapter.js +2 -4
  23. package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.d.ts +1 -10
  24. package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js +21 -36
  25. package/lib/src/worker/db/open-worker-database.js +2 -2
  26. package/lib/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +5 -5
  28. package/src/db/adapters/wa-sqlite/InternalWASQLiteDBAdapter.ts +3 -4
  29. package/src/db/adapters/wa-sqlite/WASQLiteConnection.ts +19 -41
  30. package/src/worker/db/open-worker-database.ts +2 -2
  31. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--0e69f0.umd.js.map +0 -1
  32. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--1787c2.umd.js.map +0 -1
  33. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--24f702.umd.js +0 -3494
  34. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--24f702.umd.js.map +0 -1
  35. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--4e15a2.umd.js +0 -31
  36. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--4e15a2.umd.js.map +0 -1
  37. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--7ba318.umd.js +0 -31
  38. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--7ba318.umd.js.map +0 -1
  39. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--919198.umd.js +0 -31
  40. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--919198.umd.js.map +0 -1
  41. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--997c14.umd.js +0 -31
  42. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--997c14.umd.js.map +0 -1
  43. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--a6ce73.umd.js.map +0 -1
@@ -695,10 +695,10 @@ function generateUUID() {
695
695
 
696
696
  /***/ },
697
697
 
698
- /***/ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js"
699
- /*!**************************************************************************************************************************************!*\
700
- !*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js ***!
701
- \**************************************************************************************************************************************/
698
+ /***/ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.5.0/node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js"
699
+ /*!*******************************************************************************************************************!*\
700
+ !*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.5.0/node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js ***!
701
+ \*******************************************************************************************************************/
702
702
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
703
703
 
704
704
  __webpack_require__.r(__webpack_exports__);
@@ -938,7 +938,7 @@ __webpack_require__.r(__webpack_exports__);
938
938
  /* harmony export */ SQLITE_WARNING: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_WARNING),
939
939
  /* harmony export */ SQLiteError: () => (/* binding */ SQLiteError)
940
940
  /* harmony export */ });
941
- /* harmony import */ var _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sqlite-constants.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js");
941
+ /* harmony import */ var _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sqlite-constants.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.5.0/node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js");
942
942
  // Copyright 2021 Roy T. Hashimoto. All Rights Reserved.
943
943
 
944
944
 
@@ -948,8 +948,8 @@ __webpack_require__.r(__webpack_exports__);
948
948
  * Need to have a serializer for bigint
949
949
  * https://github.com/GoogleChromeLabs/jsbi/issues/30
950
950
  */
951
- if (typeof BigInt.prototype["toJSON"] == "undefined") {
952
- BigInt.prototype["toJSON"] = function () {
951
+ if (typeof BigInt.prototype['toJSON'] == 'undefined') {
952
+ BigInt.prototype['toJSON'] = function() {
953
953
  return this.toString();
954
954
  };
955
955
  }
@@ -957,7 +957,7 @@ if (typeof BigInt.prototype["toJSON"] == "undefined") {
957
957
  const MAX_INT64 = 0x7fffffffffffffffn;
958
958
  const MIN_INT64 = -0x8000000000000000n;
959
959
 
960
- const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
960
+ const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;
961
961
 
962
962
  class SQLiteError extends Error {
963
963
  constructor(message, code) {
@@ -968,6 +968,7 @@ class SQLiteError extends Error {
968
968
 
969
969
  const async = true;
970
970
 
971
+
971
972
  /**
972
973
  * Builds a Javascript API from the Emscripten module. This API is still
973
974
  * low-level and closely corresponds to the C API exported by the module,
@@ -979,7 +980,6 @@ function Factory(Module) {
979
980
  /** @type {SQLiteAPI} */ const sqlite3 = {};
980
981
 
981
982
  Module.retryOps = [];
982
- Module.pendingOps = [];
983
983
  const sqliteFreeAddress = Module._getSqliteFree();
984
984
 
985
985
  // Allocate some space for 32-bit returned values.
@@ -990,7 +990,7 @@ function Factory(Module) {
990
990
  // Convert a JS string to a C string. sqlite3_malloc is used to allocate
991
991
  // memory (use sqlite3_free to deallocate).
992
992
  function createUTF8(s) {
993
- if (typeof s !== "string") return 0;
993
+ if (typeof s !== 'string') return 0;
994
994
  const utf8 = textEncoder.encode(s);
995
995
  const zts = Module._sqlite3_malloc(utf8.byteLength + 1);
996
996
  Module.HEAPU8.set(utf8, zts);
@@ -1021,11 +1021,11 @@ function Factory(Module) {
1021
1021
  * @param {number} hi32
1022
1022
  * @returns {number|bigint}
1023
1023
  */
1024
- const cvt32x2AsSafe = (function () {
1024
+ const cvt32x2AsSafe = (function() {
1025
1025
  const hiMax = BigInt(Number.MAX_SAFE_INTEGER) >> 32n;
1026
1026
  const hiMin = BigInt(Number.MIN_SAFE_INTEGER) >> 32n;
1027
1027
 
1028
- return function (lo32, hi32) {
1028
+ return function(lo32, hi32) {
1029
1029
  if (hi32 > hiMax || hi32 < hiMin) {
1030
1030
  // Can't be expressed as a Number so use BigInt.
1031
1031
  return cvt32x2ToBigInt(lo32, hi32);
@@ -1041,18 +1041,18 @@ function Factory(Module) {
1041
1041
  const databases = new Set();
1042
1042
  function verifyDatabase(db) {
1043
1043
  if (!databases.has(db)) {
1044
- throw new SQLiteError("not a database", _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_MISUSE);
1044
+ throw new SQLiteError('not a database', _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_MISUSE);
1045
1045
  }
1046
1046
  }
1047
1047
 
1048
1048
  const mapStmtToDB = new Map();
1049
1049
  function verifyStatement(stmt) {
1050
1050
  if (!mapStmtToDB.has(stmt)) {
1051
- throw new SQLiteError("not a statement", _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_MISUSE);
1051
+ throw new SQLiteError('not a statement', _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_MISUSE);
1052
1052
  }
1053
1053
  }
1054
1054
 
1055
- sqlite3.bind_collection = function (stmt, bindings) {
1055
+ sqlite3.bind_collection = function(stmt, bindings) {
1056
1056
  verifyStatement(stmt);
1057
1057
  const isArray = Array.isArray(bindings);
1058
1058
  const nBindings = sqlite3.bind_parameter_count(stmt);
@@ -1066,16 +1066,16 @@ function Factory(Module) {
1066
1066
  return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1067
1067
  };
1068
1068
 
1069
- sqlite3.bind = function (stmt, i, value) {
1069
+ sqlite3.bind = function(stmt, i, value) {
1070
1070
  verifyStatement(stmt);
1071
1071
  switch (typeof value) {
1072
- case "number":
1072
+ case 'number':
1073
1073
  if (value === (value | 0)) {
1074
1074
  return sqlite3.bind_int(stmt, i, value);
1075
1075
  } else {
1076
1076
  return sqlite3.bind_double(stmt, i, value);
1077
1077
  }
1078
- case "string":
1078
+ case 'string':
1079
1079
  return sqlite3.bind_text(stmt, i, value);
1080
1080
  case "boolean":
1081
1081
  return sqlite3.bind_int(stmt, i, value ? 1 : 0);
@@ -1084,22 +1084,22 @@ function Factory(Module) {
1084
1084
  return sqlite3.bind_blob(stmt, i, value);
1085
1085
  } else if (value === null) {
1086
1086
  return sqlite3.bind_null(stmt, i);
1087
- } else if (typeof value === "bigint") {
1087
+ } else if (typeof value === 'bigint') {
1088
1088
  return sqlite3.bind_int64(stmt, i, value);
1089
1089
  } else if (value === undefined) {
1090
1090
  // Existing binding (or NULL) will be used.
1091
1091
  return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_NOTICE;
1092
1092
  } else {
1093
- console.warn("unknown binding converted to null", value);
1093
+ console.warn('unknown binding converted to null', value);
1094
1094
  return sqlite3.bind_null(stmt, i);
1095
1095
  }
1096
1096
  }
1097
1097
  };
1098
1098
 
1099
- sqlite3.bind_blob = (function () {
1100
- const fname = "sqlite3_bind_blob";
1101
- const f = Module.cwrap(fname, ...decl("nnnnn:n"));
1102
- return function (stmt, i, value) {
1099
+ sqlite3.bind_blob = (function() {
1100
+ const fname = 'sqlite3_bind_blob';
1101
+ const f = Module.cwrap(fname, ...decl('nnnnn:n'));
1102
+ return function(stmt, i, value) {
1103
1103
  verifyStatement(stmt);
1104
1104
  // @ts-ignore
1105
1105
  const byteLength = value.byteLength ?? value.length;
@@ -1110,30 +1110,30 @@ function Factory(Module) {
1110
1110
  };
1111
1111
  })();
1112
1112
 
1113
- sqlite3.bind_parameter_count = (function () {
1114
- const fname = "sqlite3_bind_parameter_count";
1115
- const f = Module.cwrap(fname, ...decl("n:n"));
1116
- return function (stmt) {
1113
+ sqlite3.bind_parameter_count = (function() {
1114
+ const fname = 'sqlite3_bind_parameter_count';
1115
+ const f = Module.cwrap(fname, ...decl('n:n'));
1116
+ return function(stmt) {
1117
1117
  verifyStatement(stmt);
1118
1118
  const result = f(stmt);
1119
1119
  return result;
1120
1120
  };
1121
1121
  })();
1122
1122
 
1123
- sqlite3.bind_double = (function () {
1124
- const fname = "sqlite3_bind_double";
1125
- const f = Module.cwrap(fname, ...decl("nnn:n"));
1126
- return function (stmt, i, value) {
1123
+ sqlite3.bind_double = (function() {
1124
+ const fname = 'sqlite3_bind_double';
1125
+ const f = Module.cwrap(fname, ...decl('nnn:n'));
1126
+ return function(stmt, i, value) {
1127
1127
  verifyStatement(stmt);
1128
1128
  const result = f(stmt, i, value);
1129
1129
  return check(fname, result, mapStmtToDB.get(stmt));
1130
1130
  };
1131
1131
  })();
1132
1132
 
1133
- sqlite3.bind_int = (function () {
1134
- const fname = "sqlite3_bind_int";
1135
- const f = Module.cwrap(fname, ...decl("nnn:n"));
1136
- return function (stmt, i, value) {
1133
+ sqlite3.bind_int = (function() {
1134
+ const fname = 'sqlite3_bind_int';
1135
+ const f = Module.cwrap(fname, ...decl('nnn:n'));
1136
+ return function(stmt, i, value) {
1137
1137
  verifyStatement(stmt);
1138
1138
  if (value > 0x7fffffff || value < -0x80000000) return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_RANGE;
1139
1139
 
@@ -1142,10 +1142,10 @@ function Factory(Module) {
1142
1142
  };
1143
1143
  })();
1144
1144
 
1145
- sqlite3.bind_int64 = (function () {
1146
- const fname = "sqlite3_bind_int64";
1147
- const f = Module.cwrap(fname, ...decl("nnnn:n"));
1148
- return function (stmt, i, value) {
1145
+ sqlite3.bind_int64 = (function() {
1146
+ const fname = 'sqlite3_bind_int64';
1147
+ const f = Module.cwrap(fname, ...decl('nnnn:n'));
1148
+ return function(stmt, i, value) {
1149
1149
  verifyStatement(stmt);
1150
1150
  if (value > MAX_INT64 || value < MIN_INT64) return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_RANGE;
1151
1151
 
@@ -1156,30 +1156,30 @@ function Factory(Module) {
1156
1156
  };
1157
1157
  })();
1158
1158
 
1159
- sqlite3.bind_null = (function () {
1160
- const fname = "sqlite3_bind_null";
1161
- const f = Module.cwrap(fname, ...decl("nn:n"));
1162
- return function (stmt, i) {
1159
+ sqlite3.bind_null = (function() {
1160
+ const fname = 'sqlite3_bind_null';
1161
+ const f = Module.cwrap(fname, ...decl('nn:n'));
1162
+ return function(stmt, i) {
1163
1163
  verifyStatement(stmt);
1164
1164
  const result = f(stmt, i);
1165
1165
  return check(fname, result, mapStmtToDB.get(stmt));
1166
1166
  };
1167
1167
  })();
1168
1168
 
1169
- sqlite3.bind_parameter_name = (function () {
1170
- const fname = "sqlite3_bind_parameter_name";
1171
- const f = Module.cwrap(fname, ...decl("n:s"));
1172
- return function (stmt, i) {
1169
+ sqlite3.bind_parameter_name = (function() {
1170
+ const fname = 'sqlite3_bind_parameter_name';
1171
+ const f = Module.cwrap(fname, ...decl('n:s'));
1172
+ return function(stmt, i) {
1173
1173
  verifyStatement(stmt);
1174
1174
  const result = f(stmt, i);
1175
1175
  return result;
1176
1176
  };
1177
1177
  })();
1178
1178
 
1179
- sqlite3.bind_text = (function () {
1180
- const fname = "sqlite3_bind_text";
1181
- const f = Module.cwrap(fname, ...decl("nnnnn:n"));
1182
- return function (stmt, i, value) {
1179
+ sqlite3.bind_text = (function() {
1180
+ const fname = 'sqlite3_bind_text';
1181
+ const f = Module.cwrap(fname, ...decl('nnnnn:n'));
1182
+ return function(stmt, i, value) {
1183
1183
  verifyStatement(stmt);
1184
1184
  const ptr = createUTF8(value);
1185
1185
  const result = f(stmt, i, ptr, -1, sqliteFreeAddress);
@@ -1187,41 +1187,41 @@ function Factory(Module) {
1187
1187
  };
1188
1188
  })();
1189
1189
 
1190
- sqlite3.changes = (function () {
1191
- const fname = "sqlite3_changes";
1192
- const f = Module.cwrap(fname, ...decl("n:n"));
1193
- return function (db) {
1190
+ sqlite3.changes = (function() {
1191
+ const fname = 'sqlite3_changes';
1192
+ const f = Module.cwrap(fname, ...decl('n:n'));
1193
+ return function(db) {
1194
1194
  verifyDatabase(db);
1195
1195
  const result = f(db);
1196
1196
  return result;
1197
1197
  };
1198
1198
  })();
1199
1199
 
1200
- sqlite3.clear_bindings = (function () {
1201
- const fname = "sqlite3_clear_bindings";
1202
- const f = Module.cwrap(fname, ...decl("n:n"));
1203
- return function (stmt) {
1200
+ sqlite3.clear_bindings = (function() {
1201
+ const fname = 'sqlite3_clear_bindings';
1202
+ const f = Module.cwrap(fname, ...decl('n:n'));
1203
+ return function(stmt) {
1204
1204
  verifyStatement(stmt);
1205
1205
  const result = f(stmt);
1206
1206
  return check(fname, result, mapStmtToDB.get(stmt));
1207
1207
  };
1208
1208
  })();
1209
1209
 
1210
- sqlite3.last_insert_id = (function () {
1211
- const fname = "sqlite3_last_insert_rowid";
1212
- const f = Module.cwrap(fname, ...decl("n:n"));
1213
- return function (db) {
1210
+ sqlite3.last_insert_id = (function() {
1211
+ const fname = 'sqlite3_last_insert_rowid';
1212
+ const f = Module.cwrap(fname, ...decl('n:n'));
1213
+ return function(db) {
1214
1214
  verifyDatabase(db);
1215
1215
  const result = f(db);
1216
1216
  // trace(fname, result);
1217
1217
  return result;
1218
1218
  };
1219
1219
  })();
1220
-
1221
- sqlite3.close = (function () {
1222
- const fname = "sqlite3_close";
1223
- const f = Module.cwrap(fname, ...decl("n:n"), { async });
1224
- return async function (db) {
1220
+
1221
+ sqlite3.close = (function() {
1222
+ const fname = 'sqlite3_close';
1223
+ const f = Module.cwrap(fname, ...decl('n:n'), { async });
1224
+ return async function(db) {
1225
1225
  verifyDatabase(db);
1226
1226
  const result = await f(db);
1227
1227
  databases.delete(db);
@@ -1229,7 +1229,7 @@ function Factory(Module) {
1229
1229
  };
1230
1230
  })();
1231
1231
 
1232
- sqlite3.column = function (stmt, iCol) {
1232
+ sqlite3.column = function(stmt, iCol) {
1233
1233
  verifyStatement(stmt);
1234
1234
  const type = sqlite3.column_type(stmt, iCol);
1235
1235
  switch (type) {
@@ -1246,14 +1246,14 @@ function Factory(Module) {
1246
1246
  case _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_TEXT:
1247
1247
  return sqlite3.column_text(stmt, iCol);
1248
1248
  default:
1249
- throw new SQLiteError("unknown type", type);
1249
+ throw new SQLiteError('unknown type', type);
1250
1250
  }
1251
1251
  };
1252
1252
 
1253
- sqlite3.column_blob = (function () {
1254
- const fname = "sqlite3_column_blob";
1255
- const f = Module.cwrap(fname, ...decl("nn:n"));
1256
- return function (stmt, iCol) {
1253
+ sqlite3.column_blob = (function() {
1254
+ const fname = 'sqlite3_column_blob';
1255
+ const f = Module.cwrap(fname, ...decl('nn:n'));
1256
+ return function(stmt, iCol) {
1257
1257
  verifyStatement(stmt);
1258
1258
  const nBytes = sqlite3.column_bytes(stmt, iCol);
1259
1259
  const address = f(stmt, iCol);
@@ -1262,52 +1262,52 @@ function Factory(Module) {
1262
1262
  };
1263
1263
  })();
1264
1264
 
1265
- sqlite3.column_bytes = (function () {
1266
- const fname = "sqlite3_column_bytes";
1267
- const f = Module.cwrap(fname, ...decl("nn:n"));
1268
- return function (stmt, iCol) {
1265
+ sqlite3.column_bytes = (function() {
1266
+ const fname = 'sqlite3_column_bytes';
1267
+ const f = Module.cwrap(fname, ...decl('nn:n'));
1268
+ return function(stmt, iCol) {
1269
1269
  verifyStatement(stmt);
1270
1270
  const result = f(stmt, iCol);
1271
1271
  return result;
1272
1272
  };
1273
1273
  })();
1274
1274
 
1275
- sqlite3.column_count = (function () {
1276
- const fname = "sqlite3_column_count";
1277
- const f = Module.cwrap(fname, ...decl("n:n"));
1278
- return function (stmt) {
1275
+ sqlite3.column_count = (function() {
1276
+ const fname = 'sqlite3_column_count';
1277
+ const f = Module.cwrap(fname, ...decl('n:n'));
1278
+ return function(stmt) {
1279
1279
  verifyStatement(stmt);
1280
1280
  const result = f(stmt);
1281
1281
  return result;
1282
1282
  };
1283
1283
  })();
1284
1284
 
1285
- sqlite3.column_double = (function () {
1286
- const fname = "sqlite3_column_double";
1287
- const f = Module.cwrap(fname, ...decl("nn:n"));
1288
- return function (stmt, iCol) {
1285
+ sqlite3.column_double = (function() {
1286
+ const fname = 'sqlite3_column_double';
1287
+ const f = Module.cwrap(fname, ...decl('nn:n'));
1288
+ return function(stmt, iCol) {
1289
1289
  verifyStatement(stmt);
1290
1290
  const result = f(stmt, iCol);
1291
1291
  return result;
1292
1292
  };
1293
1293
  })();
1294
1294
 
1295
- sqlite3.column_int = (function () {
1295
+ sqlite3.column_int = (function() {
1296
1296
  // Retrieve int64 but use only the lower 32 bits. The upper 32-bits are
1297
1297
  // accessible with Module.getTempRet0().
1298
- const fname = "sqlite3_column_int64";
1299
- const f = Module.cwrap(fname, ...decl("nn:n"));
1300
- return function (stmt, iCol) {
1298
+ const fname = 'sqlite3_column_int64';
1299
+ const f = Module.cwrap(fname, ...decl('nn:n'));
1300
+ return function(stmt, iCol) {
1301
1301
  verifyStatement(stmt);
1302
1302
  const result = f(stmt, iCol);
1303
1303
  return result;
1304
1304
  };
1305
1305
  })();
1306
1306
 
1307
- sqlite3.column_int64 = (function () {
1308
- const fname = "sqlite3_column_int64";
1309
- const f = Module.cwrap(fname, ...decl("nn:n"));
1310
- return function (stmt, iCol) {
1307
+ sqlite3.column_int64 = (function() {
1308
+ const fname = 'sqlite3_column_int64';
1309
+ const f = Module.cwrap(fname, ...decl('nn:n'));
1310
+ return function(stmt, iCol) {
1311
1311
  verifyStatement(stmt);
1312
1312
  const lo32 = f(stmt, iCol);
1313
1313
  const hi32 = Module.getTempRet0();
@@ -1316,17 +1316,17 @@ function Factory(Module) {
1316
1316
  };
1317
1317
  })();
1318
1318
 
1319
- sqlite3.column_name = (function () {
1320
- const fname = "sqlite3_column_name";
1321
- const f = Module.cwrap(fname, ...decl("nn:s"));
1322
- return function (stmt, iCol) {
1319
+ sqlite3.column_name = (function() {
1320
+ const fname = 'sqlite3_column_name';
1321
+ const f = Module.cwrap(fname, ...decl('nn:s'));
1322
+ return function(stmt, iCol) {
1323
1323
  verifyStatement(stmt);
1324
1324
  const result = f(stmt, iCol);
1325
1325
  return result;
1326
1326
  };
1327
1327
  })();
1328
1328
 
1329
- sqlite3.column_names = function (stmt) {
1329
+ sqlite3.column_names = function(stmt) {
1330
1330
  const columns = [];
1331
1331
  const nColumns = sqlite3.column_count(stmt);
1332
1332
  for (let i = 0; i < nColumns; ++i) {
@@ -1335,45 +1335,34 @@ function Factory(Module) {
1335
1335
  return columns;
1336
1336
  };
1337
1337
 
1338
- sqlite3.column_text = (function () {
1339
- const fname = "sqlite3_column_text";
1340
- const f = Module.cwrap(fname, ...decl("nn:s"));
1341
- return function (stmt, iCol) {
1338
+ sqlite3.column_text = (function() {
1339
+ const fname = 'sqlite3_column_text';
1340
+ const f = Module.cwrap(fname, ...decl('nn:s'));
1341
+ return function(stmt, iCol) {
1342
1342
  verifyStatement(stmt);
1343
1343
  const result = f(stmt, iCol);
1344
1344
  return result;
1345
1345
  };
1346
1346
  })();
1347
1347
 
1348
- sqlite3.column_type = (function () {
1349
- const fname = "sqlite3_column_type";
1350
- const f = Module.cwrap(fname, ...decl("nn:n"));
1351
- return function (stmt, iCol) {
1348
+ sqlite3.column_type = (function() {
1349
+ const fname = 'sqlite3_column_type';
1350
+ const f = Module.cwrap(fname, ...decl('nn:n'));
1351
+ return function(stmt, iCol) {
1352
1352
  verifyStatement(stmt);
1353
1353
  const result = f(stmt, iCol);
1354
1354
  return result;
1355
1355
  };
1356
1356
  })();
1357
1357
 
1358
- sqlite3.create_function = function (
1359
- db,
1360
- zFunctionName,
1361
- nArg,
1362
- eTextRep,
1363
- pApp,
1364
- xFunc,
1365
- xStep,
1366
- xFinal,
1367
- ) {
1358
+ sqlite3.create_function = function(db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal) {
1368
1359
  verifyDatabase(db);
1369
-
1360
+
1370
1361
  // Convert SQLite callback arguments to JavaScript-friendly arguments.
1371
1362
  function adapt(f) {
1372
- return f instanceof AsyncFunction
1373
- ? async (ctx, n, values) =>
1374
- f(ctx, Module.HEAP32.subarray(values / 4, values / 4 + n))
1375
- : (ctx, n, values) =>
1376
- f(ctx, Module.HEAP32.subarray(values / 4, values / 4 + n));
1363
+ return f instanceof AsyncFunction ?
1364
+ (async (ctx, n, values) => f(ctx, Module.HEAP32.subarray(values / 4, values / 4 + n))) :
1365
+ ((ctx, n, values) => f(ctx, Module.HEAP32.subarray(values / 4, values / 4 + n)));
1377
1366
  }
1378
1367
 
1379
1368
  const result = Module.create_function(
@@ -1384,22 +1373,21 @@ function Factory(Module) {
1384
1373
  pApp,
1385
1374
  xFunc && adapt(xFunc),
1386
1375
  xStep && adapt(xStep),
1387
- xFinal,
1388
- );
1389
- return check("sqlite3_create_function", result, db);
1376
+ xFinal);
1377
+ return check('sqlite3_create_function', result, db);
1390
1378
  };
1391
1379
 
1392
- sqlite3.data_count = (function () {
1393
- const fname = "sqlite3_data_count";
1394
- const f = Module.cwrap(fname, ...decl("n:n"));
1395
- return function (stmt) {
1380
+ sqlite3.data_count = (function() {
1381
+ const fname = 'sqlite3_data_count';
1382
+ const f = Module.cwrap(fname, ...decl('n:n'));
1383
+ return function(stmt) {
1396
1384
  verifyStatement(stmt);
1397
1385
  const result = f(stmt);
1398
1386
  return result;
1399
1387
  };
1400
1388
  })();
1401
1389
 
1402
- sqlite3.exec = async function (db, sql, callback) {
1390
+ sqlite3.exec = async function(db, sql, callback) {
1403
1391
  for await (const stmt of sqlite3.statements(db, sql)) {
1404
1392
  let columns;
1405
1393
  while ((await sqlite3.step(stmt)) === _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ROW) {
@@ -1413,12 +1401,12 @@ function Factory(Module) {
1413
1401
  return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK;
1414
1402
  };
1415
1403
 
1416
- sqlite3.finalize = (function () {
1417
- const fname = "sqlite3_finalize";
1418
- const f = Module.cwrap(fname, ...decl("n:n"), { async });
1419
- return async function (stmt) {
1404
+ sqlite3.finalize = (function() {
1405
+ const fname = 'sqlite3_finalize';
1406
+ const f = Module.cwrap(fname, ...decl('n:n'), { async });
1407
+ return async function(stmt) {
1420
1408
  const result = await f(stmt);
1421
- mapStmtToDB.delete(stmt);
1409
+ mapStmtToDB.delete(stmt)
1422
1410
 
1423
1411
  // Don't throw on error here. Typically the error has already been
1424
1412
  // thrown and finalize() is part of the cleanup.
@@ -1426,56 +1414,56 @@ function Factory(Module) {
1426
1414
  };
1427
1415
  })();
1428
1416
 
1429
- sqlite3.get_autocommit = (function () {
1430
- const fname = "sqlite3_get_autocommit";
1431
- const f = Module.cwrap(fname, ...decl("n:n"));
1432
- return function (db) {
1417
+ sqlite3.get_autocommit = (function() {
1418
+ const fname = 'sqlite3_get_autocommit';
1419
+ const f = Module.cwrap(fname, ...decl('n:n'));
1420
+ return function(db) {
1433
1421
  const result = f(db);
1434
1422
  return result;
1435
1423
  };
1436
1424
  })();
1437
1425
 
1438
- sqlite3.libversion = (function () {
1439
- const fname = "sqlite3_libversion";
1440
- const f = Module.cwrap(fname, ...decl(":s"));
1441
- return function () {
1426
+ sqlite3.libversion = (function() {
1427
+ const fname = 'sqlite3_libversion';
1428
+ const f = Module.cwrap(fname, ...decl(':s'));
1429
+ return function() {
1442
1430
  const result = f();
1443
1431
  return result;
1444
1432
  };
1445
1433
  })();
1446
1434
 
1447
- sqlite3.libversion_number = (function () {
1448
- const fname = "sqlite3_libversion_number";
1449
- const f = Module.cwrap(fname, ...decl(":n"));
1450
- return function () {
1435
+ sqlite3.libversion_number = (function() {
1436
+ const fname = 'sqlite3_libversion_number';
1437
+ const f = Module.cwrap(fname, ...decl(':n'));
1438
+ return function() {
1451
1439
  const result = f();
1452
1440
  return result;
1453
1441
  };
1454
1442
  })();
1455
1443
 
1456
- sqlite3.limit = (function () {
1457
- const fname = "sqlite3_limit";
1458
- const f = Module.cwrap(fname, ...decl("nnn:n"));
1459
- return function (db, id, newVal) {
1444
+ sqlite3.limit = (function() {
1445
+ const fname = 'sqlite3_limit';
1446
+ const f = Module.cwrap(fname, ...decl('nnn:n'));
1447
+ return function(db, id, newVal) {
1460
1448
  const result = f(db, id, newVal);
1461
1449
  return result;
1462
1450
  };
1463
1451
  })();
1464
1452
 
1465
- sqlite3.open_v2 = (function () {
1466
- const fname = "sqlite3_open_v2";
1467
- const f = Module.cwrap(fname, ...decl("snnn:n"), { async });
1468
- return async function (zFilename, flags, zVfs) {
1453
+ sqlite3.open_v2 = (function() {
1454
+ const fname = 'sqlite3_open_v2';
1455
+ const f = Module.cwrap(fname, ...decl('snnn:n'), { async });
1456
+ return async function(zFilename, flags, zVfs) {
1469
1457
  flags = flags || _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_CREATE | _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OPEN_READWRITE;
1470
1458
  zVfs = createUTF8(zVfs);
1471
1459
  try {
1472
1460
  // Allow retry operations.
1473
1461
  const rc = await retry(() => f(zFilename, tmpPtr[0], flags, zVfs));
1474
1462
 
1475
- const db = Module.getValue(tmpPtr[0], "*");
1463
+ const db = Module.getValue(tmpPtr[0], '*');
1476
1464
  databases.add(db);
1477
1465
 
1478
- Module.ccall("RegisterExtensionFunctions", "number", ["number"], [db]);
1466
+ Module.ccall('RegisterExtensionFunctions', 'number', ['number'], [db]);
1479
1467
  check(fname, rc);
1480
1468
  return db;
1481
1469
  } finally {
@@ -1484,31 +1472,31 @@ function Factory(Module) {
1484
1472
  };
1485
1473
  })();
1486
1474
 
1487
- sqlite3.progress_handler = function (db, nProgressOps, handler, userData) {
1475
+ sqlite3.progress_handler = function(db, nProgressOps, handler, userData) {
1488
1476
  verifyDatabase(db);
1489
1477
  Module.progress_handler(db, nProgressOps, handler, userData);
1490
- };
1478
+ };;
1491
1479
 
1492
- sqlite3.reset = (function () {
1493
- const fname = "sqlite3_reset";
1494
- const f = Module.cwrap(fname, ...decl("n:n"), { async });
1495
- return async function (stmt) {
1480
+ sqlite3.reset = (function() {
1481
+ const fname = 'sqlite3_reset';
1482
+ const f = Module.cwrap(fname, ...decl('n:n'), { async });
1483
+ return async function(stmt) {
1496
1484
  verifyStatement(stmt);
1497
1485
  const result = await f(stmt);
1498
1486
  return check(fname, result, mapStmtToDB.get(stmt));
1499
1487
  };
1500
1488
  })();
1501
1489
 
1502
- sqlite3.result = function (context, value) {
1490
+ sqlite3.result = function(context, value) {
1503
1491
  switch (typeof value) {
1504
- case "number":
1492
+ case 'number':
1505
1493
  if (value === (value | 0)) {
1506
1494
  sqlite3.result_int(context, value);
1507
1495
  } else {
1508
1496
  sqlite3.result_double(context, value);
1509
1497
  }
1510
1498
  break;
1511
- case "string":
1499
+ case 'string':
1512
1500
  sqlite3.result_text(context, value);
1513
1501
  break;
1514
1502
  default:
@@ -1516,20 +1504,20 @@ function Factory(Module) {
1516
1504
  sqlite3.result_blob(context, value);
1517
1505
  } else if (value === null) {
1518
1506
  sqlite3.result_null(context);
1519
- } else if (typeof value === "bigint") {
1507
+ } else if (typeof value === 'bigint') {
1520
1508
  return sqlite3.result_int64(context, value);
1521
1509
  } else {
1522
- console.warn("unknown result converted to null", value);
1510
+ console.warn('unknown result converted to null', value);
1523
1511
  sqlite3.result_null(context);
1524
1512
  }
1525
1513
  break;
1526
1514
  }
1527
1515
  };
1528
1516
 
1529
- sqlite3.result_blob = (function () {
1530
- const fname = "sqlite3_result_blob";
1531
- const f = Module.cwrap(fname, ...decl("nnnn:n"));
1532
- return function (context, value) {
1517
+ sqlite3.result_blob = (function() {
1518
+ const fname = 'sqlite3_result_blob';
1519
+ const f = Module.cwrap(fname, ...decl('nnnn:n'));
1520
+ return function(context, value) {
1533
1521
  // @ts-ignore
1534
1522
  const byteLength = value.byteLength ?? value.length;
1535
1523
  const ptr = Module._sqlite3_malloc(byteLength);
@@ -1538,26 +1526,26 @@ function Factory(Module) {
1538
1526
  };
1539
1527
  })();
1540
1528
 
1541
- sqlite3.result_double = (function () {
1542
- const fname = "sqlite3_result_double";
1543
- const f = Module.cwrap(fname, ...decl("nn:n"));
1544
- return function (context, value) {
1529
+ sqlite3.result_double = (function() {
1530
+ const fname = 'sqlite3_result_double';
1531
+ const f = Module.cwrap(fname, ...decl('nn:n'));
1532
+ return function(context, value) {
1545
1533
  f(context, value); // void return
1546
1534
  };
1547
1535
  })();
1548
1536
 
1549
- sqlite3.result_int = (function () {
1550
- const fname = "sqlite3_result_int";
1551
- const f = Module.cwrap(fname, ...decl("nn:n"));
1552
- return function (context, value) {
1537
+ sqlite3.result_int = (function() {
1538
+ const fname = 'sqlite3_result_int';
1539
+ const f = Module.cwrap(fname, ...decl('nn:n'));
1540
+ return function(context, value) {
1553
1541
  f(context, value); // void return
1554
1542
  };
1555
1543
  })();
1556
1544
 
1557
- sqlite3.result_int64 = (function () {
1558
- const fname = "sqlite3_result_int64";
1559
- const f = Module.cwrap(fname, ...decl("nnn:n"));
1560
- return function (context, value) {
1545
+ sqlite3.result_int64 = (function() {
1546
+ const fname = 'sqlite3_result_int64';
1547
+ const f = Module.cwrap(fname, ...decl('nnn:n'));
1548
+ return function(context, value) {
1561
1549
  if (value > MAX_INT64 || value < MIN_INT64) return _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_RANGE;
1562
1550
 
1563
1551
  const lo32 = value & 0xffffffffn;
@@ -1566,24 +1554,24 @@ function Factory(Module) {
1566
1554
  };
1567
1555
  })();
1568
1556
 
1569
- sqlite3.result_null = (function () {
1570
- const fname = "sqlite3_result_null";
1571
- const f = Module.cwrap(fname, ...decl("n:n"));
1572
- return function (context) {
1557
+ sqlite3.result_null = (function() {
1558
+ const fname = 'sqlite3_result_null';
1559
+ const f = Module.cwrap(fname, ...decl('n:n'));
1560
+ return function(context) {
1573
1561
  f(context); // void return
1574
1562
  };
1575
1563
  })();
1576
1564
 
1577
- sqlite3.result_text = (function () {
1578
- const fname = "sqlite3_result_text";
1579
- const f = Module.cwrap(fname, ...decl("nnnn:n"));
1580
- return function (context, value) {
1565
+ sqlite3.result_text = (function() {
1566
+ const fname = 'sqlite3_result_text';
1567
+ const f = Module.cwrap(fname, ...decl('nnnn:n'));
1568
+ return function(context, value) {
1581
1569
  const ptr = createUTF8(value);
1582
1570
  f(context, ptr, -1, sqliteFreeAddress); // void return
1583
1571
  };
1584
1572
  })();
1585
1573
 
1586
- sqlite3.row = function (stmt) {
1574
+ sqlite3.row = function(stmt) {
1587
1575
  const row = [];
1588
1576
  const nColumns = sqlite3.data_count(stmt);
1589
1577
  for (let i = 0; i < nColumns; ++i) {
@@ -1597,7 +1585,7 @@ function Factory(Module) {
1597
1585
  return row;
1598
1586
  };
1599
1587
 
1600
- sqlite3.set_authorizer = function (db, xAuth, pApp) {
1588
+ sqlite3.set_authorizer = function(db, xAuth, pApp) {
1601
1589
  verifyDatabase(db);
1602
1590
 
1603
1591
  // Convert SQLite callback arguments to JavaScript-friendly arguments.
@@ -1608,40 +1596,37 @@ function Factory(Module) {
1608
1596
  Module.UTF8ToString(p3),
1609
1597
  Module.UTF8ToString(p4),
1610
1598
  Module.UTF8ToString(p5),
1611
- Module.UTF8ToString(p6),
1599
+ Module.UTF8ToString(p6)
1612
1600
  ];
1613
- }
1601
+ };
1614
1602
  function adapt(f) {
1615
- return f instanceof AsyncFunction
1616
- ? async (_, iAction, p3, p4, p5, p6) =>
1617
- f(...cvtArgs(_, iAction, p3, p4, p5, p6))
1618
- : (_, iAction, p3, p4, p5, p6) =>
1619
- f(...cvtArgs(_, iAction, p3, p4, p5, p6));
1603
+ return f instanceof AsyncFunction ?
1604
+ (async (_, iAction, p3, p4, p5, p6) => f(...cvtArgs(_, iAction, p3, p4, p5, p6))) :
1605
+ ((_, iAction, p3, p4, p5, p6) => f(...cvtArgs(_, iAction, p3, p4, p5, p6)));
1620
1606
  }
1621
1607
 
1622
1608
  const result = Module.set_authorizer(db, adapt(xAuth), pApp);
1623
- return check("sqlite3_set_authorizer", result, db);
1609
+ return check('sqlite3_set_authorizer', result, db);
1624
1610
  };
1625
1611
 
1626
- sqlite3.sql = (function () {
1627
- const fname = "sqlite3_sql";
1628
- const f = Module.cwrap(fname, ...decl("n:s"));
1629
- return function (stmt) {
1612
+ sqlite3.sql = (function() {
1613
+ const fname = 'sqlite3_sql';
1614
+ const f = Module.cwrap(fname, ...decl('n:s'));
1615
+ return function(stmt) {
1630
1616
  verifyStatement(stmt);
1631
1617
  const result = f(stmt);
1632
1618
  return result;
1633
1619
  };
1634
1620
  })();
1635
1621
 
1636
- sqlite3.statements = function (db, sql, options = {}) {
1622
+ sqlite3.statements = function(db, sql, options = {}) {
1637
1623
  const prepare = Module.cwrap(
1638
- "sqlite3_prepare_v3",
1639
- "number",
1640
- ["number", "number", "number", "number", "number", "number"],
1641
- { async: true },
1642
- );
1624
+ 'sqlite3_prepare_v3',
1625
+ 'number',
1626
+ ['number', 'number', 'number', 'number', 'number', 'number'],
1627
+ { async: true });
1643
1628
 
1644
- return (async function* () {
1629
+ return (async function*() {
1645
1630
  const onFinally = [];
1646
1631
  try {
1647
1632
  // Encode SQL string to UTF-8.
@@ -1656,7 +1641,7 @@ function Factory(Module) {
1656
1641
  onFinally.push(() => Module._sqlite3_free(pzHead));
1657
1642
  Module.HEAPU8.set(utf8, pzHead);
1658
1643
  Module.HEAPU8[pzEnd - 1] = 0;
1659
-
1644
+
1660
1645
  // Use extra space for the statement handle and SQL tail pointer.
1661
1646
  const pStmt = pzHead + allocSize - 8;
1662
1647
  const pzTail = pzHead + allocSize - 4;
@@ -1670,16 +1655,16 @@ function Factory(Module) {
1670
1655
  stmt = 0;
1671
1656
  }
1672
1657
  onFinally.push(maybeFinalize);
1673
-
1658
+
1674
1659
  // Loop over statements.
1675
- Module.setValue(pzTail, pzHead, "*");
1660
+ Module.setValue(pzTail, pzHead, '*');
1676
1661
  do {
1677
1662
  // Reclaim resources for the previous iteration.
1678
1663
  maybeFinalize();
1679
1664
 
1680
1665
  // Call sqlite3_prepare_v3() for the next statement.
1681
1666
  // Allow retry operations.
1682
- const zTail = Module.getValue(pzTail, "*");
1667
+ const zTail = Module.getValue(pzTail, '*');
1683
1668
  const rc = await retry(() => {
1684
1669
  return prepare(
1685
1670
  db,
@@ -1687,15 +1672,14 @@ function Factory(Module) {
1687
1672
  pzEnd - pzTail,
1688
1673
  options.flags || 0,
1689
1674
  pStmt,
1690
- pzTail,
1691
- );
1675
+ pzTail);
1692
1676
  });
1693
1677
 
1694
1678
  if (rc !== _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK) {
1695
- check("sqlite3_prepare_v3", rc, db);
1679
+ check('sqlite3_prepare_v3', rc, db);
1696
1680
  }
1697
-
1698
- stmt = Module.getValue(pStmt, "*");
1681
+
1682
+ stmt = Module.getValue(pStmt, '*');
1699
1683
  if (stmt) {
1700
1684
  mapStmtToDB.set(stmt, db);
1701
1685
  yield stmt;
@@ -1709,28 +1693,25 @@ function Factory(Module) {
1709
1693
  })();
1710
1694
  };
1711
1695
 
1712
- sqlite3.step = (function () {
1713
- const fname = "sqlite3_step";
1714
- const f = Module.cwrap(fname, ...decl("n:n"), { async });
1715
- return async function (stmt) {
1696
+ sqlite3.step = (function() {
1697
+ const fname = 'sqlite3_step';
1698
+ const f = Module.cwrap(fname, ...decl('n:n'), { async });
1699
+ return async function(stmt) {
1716
1700
  verifyStatement(stmt);
1717
1701
 
1718
1702
  // Allow retry operations.
1719
1703
  const rc = await retry(() => f(stmt));
1720
1704
 
1721
- return check(fname, rc, mapStmtToDB.get(stmt), [
1722
- _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ROW,
1723
- _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DONE,
1724
- ]);
1705
+ return check(fname, rc, mapStmtToDB.get(stmt), [_sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ROW, _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_DONE]);
1725
1706
  };
1726
1707
  })();
1727
1708
 
1728
- sqlite3.commit_hook = function (db, xCommitHook) {
1709
+ sqlite3.commit_hook = function(db, xCommitHook) {
1729
1710
  verifyDatabase(db);
1730
1711
  Module.commit_hook(db, xCommitHook);
1731
1712
  };
1732
1713
 
1733
- sqlite3.update_hook = function (db, xUpdateHook) {
1714
+ sqlite3.update_hook = function(db, xUpdateHook) {
1734
1715
  verifyDatabase(db);
1735
1716
 
1736
1717
  // Convert SQLite callback arguments to JavaScript-friendly arguments.
@@ -1739,21 +1720,19 @@ function Factory(Module) {
1739
1720
  iUpdateType,
1740
1721
  Module.UTF8ToString(dbName),
1741
1722
  Module.UTF8ToString(tblName),
1742
- cvt32x2ToBigInt(lo32, hi32),
1723
+ cvt32x2ToBigInt(lo32, hi32)
1743
1724
  ];
1744
- }
1725
+ };
1745
1726
  function adapt(f) {
1746
- return f instanceof AsyncFunction
1747
- ? async (iUpdateType, dbName, tblName, lo32, hi32) =>
1748
- f(...cvtArgs(iUpdateType, dbName, tblName, lo32, hi32))
1749
- : (iUpdateType, dbName, tblName, lo32, hi32) =>
1750
- f(...cvtArgs(iUpdateType, dbName, tblName, lo32, hi32));
1727
+ return f instanceof AsyncFunction ?
1728
+ (async (iUpdateType, dbName, tblName, lo32, hi32) => f(...cvtArgs(iUpdateType, dbName, tblName, lo32, hi32))) :
1729
+ ((iUpdateType, dbName, tblName, lo32, hi32) => f(...cvtArgs(iUpdateType, dbName, tblName, lo32, hi32)));
1751
1730
  }
1752
1731
 
1753
1732
  Module.update_hook(db, adapt(xUpdateHook));
1754
- };
1733
+ };;
1755
1734
 
1756
- sqlite3.value = function (pValue) {
1735
+ sqlite3.value = function(pValue) {
1757
1736
  const type = sqlite3.value_type(pValue);
1758
1737
  switch (type) {
1759
1738
  case _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_BLOB:
@@ -1769,14 +1748,14 @@ function Factory(Module) {
1769
1748
  case _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_TEXT:
1770
1749
  return sqlite3.value_text(pValue);
1771
1750
  default:
1772
- throw new SQLiteError("unknown type", type);
1751
+ throw new SQLiteError('unknown type', type);
1773
1752
  }
1774
1753
  };
1775
1754
 
1776
- sqlite3.value_blob = (function () {
1777
- const fname = "sqlite3_value_blob";
1778
- const f = Module.cwrap(fname, ...decl("n:n"));
1779
- return function (pValue) {
1755
+ sqlite3.value_blob = (function() {
1756
+ const fname = 'sqlite3_value_blob';
1757
+ const f = Module.cwrap(fname, ...decl('n:n'));
1758
+ return function(pValue) {
1780
1759
  const nBytes = sqlite3.value_bytes(pValue);
1781
1760
  const address = f(pValue);
1782
1761
  const result = Module.HEAPU8.subarray(address, address + nBytes);
@@ -1784,37 +1763,37 @@ function Factory(Module) {
1784
1763
  };
1785
1764
  })();
1786
1765
 
1787
- sqlite3.value_bytes = (function () {
1788
- const fname = "sqlite3_value_bytes";
1789
- const f = Module.cwrap(fname, ...decl("n:n"));
1790
- return function (pValue) {
1766
+ sqlite3.value_bytes = (function() {
1767
+ const fname = 'sqlite3_value_bytes';
1768
+ const f = Module.cwrap(fname, ...decl('n:n'));
1769
+ return function(pValue) {
1791
1770
  const result = f(pValue);
1792
1771
  return result;
1793
1772
  };
1794
1773
  })();
1795
1774
 
1796
- sqlite3.value_double = (function () {
1797
- const fname = "sqlite3_value_double";
1798
- const f = Module.cwrap(fname, ...decl("n:n"));
1799
- return function (pValue) {
1775
+ sqlite3.value_double = (function() {
1776
+ const fname = 'sqlite3_value_double';
1777
+ const f = Module.cwrap(fname, ...decl('n:n'));
1778
+ return function(pValue) {
1800
1779
  const result = f(pValue);
1801
1780
  return result;
1802
1781
  };
1803
1782
  })();
1804
1783
 
1805
- sqlite3.value_int = (function () {
1806
- const fname = "sqlite3_value_int64";
1807
- const f = Module.cwrap(fname, ...decl("n:n"));
1808
- return function (pValue) {
1784
+ sqlite3.value_int = (function() {
1785
+ const fname = 'sqlite3_value_int64';
1786
+ const f = Module.cwrap(fname, ...decl('n:n'));
1787
+ return function(pValue) {
1809
1788
  const result = f(pValue);
1810
1789
  return result;
1811
1790
  };
1812
1791
  })();
1813
1792
 
1814
- sqlite3.value_int64 = (function () {
1815
- const fname = "sqlite3_value_int64";
1816
- const f = Module.cwrap(fname, ...decl("n:n"));
1817
- return function (pValue) {
1793
+ sqlite3.value_int64 = (function() {
1794
+ const fname = 'sqlite3_value_int64';
1795
+ const f = Module.cwrap(fname, ...decl('n:n'));
1796
+ return function(pValue) {
1818
1797
  const lo32 = f(pValue);
1819
1798
  const hi32 = Module.getTempRet0();
1820
1799
  const result = cvt32x2ToBigInt(lo32, hi32);
@@ -1822,34 +1801,32 @@ function Factory(Module) {
1822
1801
  };
1823
1802
  })();
1824
1803
 
1825
- sqlite3.value_text = (function () {
1826
- const fname = "sqlite3_value_text";
1827
- const f = Module.cwrap(fname, ...decl("n:s"));
1828
- return function (pValue) {
1804
+ sqlite3.value_text = (function() {
1805
+ const fname = 'sqlite3_value_text';
1806
+ const f = Module.cwrap(fname, ...decl('n:s'));
1807
+ return function(pValue) {
1829
1808
  const result = f(pValue);
1830
1809
  return result;
1831
1810
  };
1832
1811
  })();
1833
1812
 
1834
- sqlite3.value_type = (function () {
1835
- const fname = "sqlite3_value_type";
1836
- const f = Module.cwrap(fname, ...decl("n:n"));
1837
- return function (pValue) {
1813
+ sqlite3.value_type = (function() {
1814
+ const fname = 'sqlite3_value_type';
1815
+ const f = Module.cwrap(fname, ...decl('n:n'));
1816
+ return function(pValue) {
1838
1817
  const result = f(pValue);
1839
1818
  return result;
1840
1819
  };
1841
1820
  })();
1842
1821
 
1843
- sqlite3.vfs_register = function (vfs, makeDefault) {
1822
+ sqlite3.vfs_register = function(vfs, makeDefault) {
1844
1823
  const result = Module.vfs_register(vfs, makeDefault);
1845
- return check("sqlite3_vfs_register", result);
1824
+ return check('sqlite3_vfs_register', result);
1846
1825
  };
1847
1826
 
1848
1827
  function check(fname, result, db = null, allowed = [_sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK]) {
1849
1828
  if (allowed.includes(result)) return result;
1850
- const message = db
1851
- ? Module.ccall("sqlite3_errmsg", "string", ["number"], [db])
1852
- : fname;
1829
+ const message = db ? Module.ccall('sqlite3_errmsg', 'string', ['number'], [db]) : fname;
1853
1830
  throw new SQLiteError(message, result);
1854
1831
  }
1855
1832
 
@@ -1858,7 +1835,7 @@ function Factory(Module) {
1858
1835
  // succeed.
1859
1836
  async function retry(f) {
1860
1837
  let rc;
1861
- for (let retryCount = 0; retryCount < 2; ++retryCount) {
1838
+ do {
1862
1839
  // Wait for all pending retry operations to complete. This is
1863
1840
  // normally empty on the first loop iteration.
1864
1841
  if (Module.retryOps.length) {
@@ -1868,22 +1845,11 @@ function Factory(Module) {
1868
1845
  Module.retryOps = [];
1869
1846
  }
1870
1847
  }
1871
-
1848
+
1872
1849
  rc = await f();
1873
- if (rc === _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_OK || Module.retryOps.length === 0) {
1874
- if (Module.pendingOps.length) {
1875
- try {
1876
- await Promise.all(Module.pendingOps);
1877
- } catch (e) {
1878
- console.error("Error in pendingOps:", e);
1879
- return e.code || _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_ERROR;
1880
- } finally {
1881
- Module.pendingOps = [];
1882
- }
1883
- }
1884
- return rc;
1885
- }
1886
- }
1850
+
1851
+ // Retry on failure with new pending retry operations.
1852
+ } while (rc && Module.retryOps.length);
1887
1853
  return rc;
1888
1854
  }
1889
1855
 
@@ -1895,13 +1861,13 @@ function decl(s) {
1895
1861
  const result = [];
1896
1862
  const m = s.match(/([ns@]*):([nsv@])/);
1897
1863
  switch (m[2]) {
1898
- case "n":
1899
- result.push("number");
1864
+ case 'n':
1865
+ result.push('number');
1900
1866
  break;
1901
- case "s":
1902
- result.push("string");
1867
+ case 's':
1868
+ result.push('string');
1903
1869
  break;
1904
- case "v":
1870
+ case 'v':
1905
1871
  result.push(null);
1906
1872
  break;
1907
1873
  }
@@ -1909,11 +1875,11 @@ function decl(s) {
1909
1875
  const args = [];
1910
1876
  for (let c of m[1]) {
1911
1877
  switch (c) {
1912
- case "n":
1913
- args.push("number");
1878
+ case 'n':
1879
+ args.push('number');
1914
1880
  break;
1915
- case "s":
1916
- args.push("string");
1881
+ case 's':
1882
+ args.push('string');
1917
1883
  break;
1918
1884
  }
1919
1885
  }
@@ -1924,10 +1890,10 @@ function decl(s) {
1924
1890
 
1925
1891
  /***/ },
1926
1892
 
1927
- /***/ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js"
1928
- /*!********************************************************************************************************************************************!*\
1929
- !*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js ***!
1930
- \********************************************************************************************************************************************/
1893
+ /***/ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.5.0/node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js"
1894
+ /*!*************************************************************************************************************************!*\
1895
+ !*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.5.0/node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js ***!
1896
+ \*************************************************************************************************************************/
1931
1897
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1932
1898
 
1933
1899
  __webpack_require__.r(__webpack_exports__);
@@ -2457,10 +2423,9 @@ __webpack_require__.r(__webpack_exports__);
2457
2423
  /* harmony export */ MultiCipherSyncWASQLiteModuleFactory: () => (/* binding */ MultiCipherSyncWASQLiteModuleFactory),
2458
2424
  /* harmony export */ SyncWASQLiteModuleFactory: () => (/* binding */ SyncWASQLiteModuleFactory),
2459
2425
  /* harmony export */ WASQLiteVFS: () => (/* binding */ WASQLiteVFS),
2460
- /* harmony export */ WASqliteConnection: () => (/* binding */ WASqliteConnection),
2461
- /* harmony export */ needsDedicatedWorker: () => (/* binding */ needsDedicatedWorker)
2426
+ /* harmony export */ WASqliteConnection: () => (/* binding */ WASqliteConnection)
2462
2427
  /* harmony export */ });
2463
- /* harmony import */ var _journeyapps_wa_sqlite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @journeyapps/wa-sqlite */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js");
2428
+ /* harmony import */ var _journeyapps_wa_sqlite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @journeyapps/wa-sqlite */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.5.0/node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js");
2464
2429
  /* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
2465
2430
  /* harmony import */ var async_mutex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! async-mutex */ "../../node_modules/.pnpm/async-mutex@0.5.0/node_modules/async-mutex/index.mjs");
2466
2431
 
@@ -2474,48 +2439,33 @@ var WASQLiteVFS;
2474
2439
  WASQLiteVFS["IDBBatchAtomicVFS"] = "IDBBatchAtomicVFS";
2475
2440
  WASQLiteVFS["OPFSCoopSyncVFS"] = "OPFSCoopSyncVFS";
2476
2441
  WASQLiteVFS["AccessHandlePoolVFS"] = "AccessHandlePoolVFS";
2477
- WASQLiteVFS["OPFSWriteAheadVFS"] = "OPFSWriteAheadVFS";
2478
2442
  })(WASQLiteVFS || (WASQLiteVFS = {}));
2479
- /**
2480
- * Whether the given `vfs` needs to be hosted by a dedicated worker.
2481
- */
2482
- function needsDedicatedWorker(vfs) {
2483
- vfs == WASQLiteVFS.AccessHandlePoolVFS || vfs == WASQLiteVFS.OPFSCoopSyncVFS;
2484
- switch (vfs) {
2485
- case WASQLiteVFS.OPFSCoopSyncVFS:
2486
- case WASQLiteVFS.AccessHandlePoolVFS:
2487
- case WASQLiteVFS.OPFSWriteAheadVFS:
2488
- return true;
2489
- default:
2490
- return false;
2491
- }
2492
- }
2493
2443
  /**
2494
2444
  * @internal
2495
2445
  */
2496
2446
  const AsyncWASQLiteModuleFactory = async () => {
2497
- const { default: factory } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--7ba318").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/dist/wa-sqlite-async.mjs */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/dist/wa-sqlite-async.mjs"));
2447
+ const { default: factory } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-cc5fcc").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/dist/wa-sqlite-async.mjs */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.5.0/node_modules/@journeyapps/wa-sqlite/dist/wa-sqlite-async.mjs"));
2498
2448
  return factory();
2499
2449
  };
2500
2450
  /**
2501
2451
  * @internal
2502
2452
  */
2503
2453
  const MultiCipherAsyncWASQLiteModuleFactory = async () => {
2504
- const { default: factory } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--919198").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/dist/mc-wa-sqlite-async.mjs */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/dist/mc-wa-sqlite-async.mjs"));
2454
+ const { default: factory } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-c99c07").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/dist/mc-wa-sqlite-async.mjs */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.5.0/node_modules/@journeyapps/wa-sqlite/dist/mc-wa-sqlite-async.mjs"));
2505
2455
  return factory();
2506
2456
  };
2507
2457
  /**
2508
2458
  * @internal
2509
2459
  */
2510
2460
  const SyncWASQLiteModuleFactory = async () => {
2511
- const { default: factory } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--4e15a2").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/dist/wa-sqlite.mjs */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/dist/wa-sqlite.mjs"));
2461
+ const { default: factory } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/dist/wa-sqlite.mjs */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.5.0/node_modules/@journeyapps/wa-sqlite/dist/wa-sqlite.mjs"));
2512
2462
  return factory();
2513
2463
  };
2514
2464
  /**
2515
2465
  * @internal
2516
2466
  */
2517
2467
  const MultiCipherSyncWASQLiteModuleFactory = async () => {
2518
- const { default: factory } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--997c14").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/dist/mc-wa-sqlite.mjs */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/dist/mc-wa-sqlite.mjs"));
2468
+ const { default: factory } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-b9c070").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/dist/mc-wa-sqlite.mjs */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.5.0/node_modules/@journeyapps/wa-sqlite/dist/mc-wa-sqlite.mjs"));
2519
2469
  return factory();
2520
2470
  };
2521
2471
  /**
@@ -2523,8 +2473,14 @@ const MultiCipherSyncWASQLiteModuleFactory = async () => {
2523
2473
  */
2524
2474
  const DEFAULT_MODULE_FACTORIES = {
2525
2475
  [WASQLiteVFS.IDBBatchAtomicVFS]: async (options) => {
2526
- const module = await loadModule(true, options);
2527
- const { IDBBatchAtomicVFS } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--1787c2").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js"));
2476
+ let module;
2477
+ if (options.encryptionKey) {
2478
+ module = await MultiCipherAsyncWASQLiteModuleFactory();
2479
+ }
2480
+ else {
2481
+ module = await AsyncWASQLiteModuleFactory();
2482
+ }
2483
+ const { IDBBatchAtomicVFS } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-0df390").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.5.0/node_modules/@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js"));
2528
2484
  return {
2529
2485
  module,
2530
2486
  // @ts-expect-error The types for this static method are missing upstream
@@ -2532,43 +2488,37 @@ const DEFAULT_MODULE_FACTORIES = {
2532
2488
  };
2533
2489
  },
2534
2490
  [WASQLiteVFS.AccessHandlePoolVFS]: async (options) => {
2535
- const module = await loadModule(false, options);
2491
+ let module;
2492
+ if (options.encryptionKey) {
2493
+ module = await MultiCipherSyncWASQLiteModuleFactory();
2494
+ }
2495
+ else {
2496
+ module = await SyncWASQLiteModuleFactory();
2497
+ }
2536
2498
  // @ts-expect-error The types for this static method are missing upstream
2537
- const { AccessHandlePoolVFS } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--a6ce73").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/src/examples/AccessHandlePoolVFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/AccessHandlePoolVFS.js"));
2499
+ const { AccessHandlePoolVFS } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-151024").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/src/examples/AccessHandlePoolVFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.5.0/node_modules/@journeyapps/wa-sqlite/src/examples/AccessHandlePoolVFS.js"));
2538
2500
  return {
2539
2501
  module,
2540
2502
  vfs: await AccessHandlePoolVFS.create(options.dbFileName, module)
2541
2503
  };
2542
2504
  },
2543
2505
  [WASQLiteVFS.OPFSCoopSyncVFS]: async (options) => {
2544
- const module = await loadModule(false, options);
2506
+ let module;
2507
+ if (options.encryptionKey) {
2508
+ module = await MultiCipherSyncWASQLiteModuleFactory();
2509
+ }
2510
+ else {
2511
+ module = await SyncWASQLiteModuleFactory();
2512
+ }
2545
2513
  // @ts-expect-error The types for this static method are missing upstream
2546
- const { OPFSCoopSyncVFS } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--0e69f0").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/src/examples/OPFSCoopSyncVFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/OPFSCoopSyncVFS.js"));
2514
+ const { OPFSCoopSyncVFS } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-c01ef0").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/src/examples/OPFSCoopSyncVFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.5.0/node_modules/@journeyapps/wa-sqlite/src/examples/OPFSCoopSyncVFS.js"));
2547
2515
  const vfs = await OPFSCoopSyncVFS.create(options.dbFileName, module);
2548
2516
  return {
2549
2517
  module,
2550
2518
  vfs
2551
2519
  };
2552
- },
2553
- [WASQLiteVFS.OPFSWriteAheadVFS]: async (options) => {
2554
- const module = await loadModule(false, options);
2555
- // @ts-expect-error The types for this static method are missing upstream
2556
- const { OPFSWriteAheadVFS } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_0_0_0-dev-20260226145021_node_modules_journeyapps_wa--24f702").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/src/examples/OPFSWriteAheadVFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/examples/OPFSWriteAheadVFS.js"));
2557
- const vfs = await OPFSWriteAheadVFS.create(options.dbFileName, module, {
2558
- // TODO: The asyncErrorHandler callback might be interesting to handle IDB failures, but it's not clear how we'd
2559
- // do that from here.
2560
- });
2561
- return { module, vfs };
2562
2520
  }
2563
2521
  };
2564
- async function loadModule(async, options) {
2565
- if (async) {
2566
- return await (options.encryptionKey ? MultiCipherAsyncWASQLiteModuleFactory() : AsyncWASQLiteModuleFactory());
2567
- }
2568
- else {
2569
- return await (options.encryptionKey ? MultiCipherSyncWASQLiteModuleFactory() : SyncWASQLiteModuleFactory());
2570
- }
2571
- }
2572
2522
  /**
2573
2523
  * @internal
2574
2524
  * WA-SQLite connection which directly interfaces with WA-SQLite.
@@ -3106,7 +3056,6 @@ __webpack_require__.r(__webpack_exports__);
3106
3056
  /* harmony export */ OplogEntry: () => (/* binding */ OplogEntry),
3107
3057
  /* harmony export */ PSInternalTable: () => (/* binding */ PSInternalTable),
3108
3058
  /* harmony export */ PowerSyncControlCommand: () => (/* binding */ PowerSyncControlCommand),
3109
- /* harmony export */ RawTable: () => (/* binding */ RawTable),
3110
3059
  /* harmony export */ RowUpdateType: () => (/* binding */ RowUpdateType),
3111
3060
  /* harmony export */ Schema: () => (/* binding */ Schema),
3112
3061
  /* harmony export */ SqliteBucketStorage: () => (/* binding */ SqliteBucketStorage),
@@ -3252,6 +3201,21 @@ class Index {
3252
3201
  }
3253
3202
  }
3254
3203
 
3204
+ /**
3205
+ * @internal Not exported from `index.ts`.
3206
+ */
3207
+ function encodeTableOptions(options) {
3208
+ const trackPrevious = options.trackPrevious;
3209
+ return {
3210
+ local_only: options.localOnly,
3211
+ insert_only: options.insertOnly,
3212
+ include_old: trackPrevious && (trackPrevious.columns ?? true),
3213
+ include_old_only_when_changed: typeof trackPrevious == 'object' && trackPrevious.onlyWhenChanged == true,
3214
+ include_metadata: options.trackMetadata,
3215
+ ignore_empty_update: options.ignoreEmptyUpdates
3216
+ };
3217
+ }
3218
+
3255
3219
  const DEFAULT_TABLE_OPTIONS = {
3256
3220
  indexes: [],
3257
3221
  insertOnly: false,
@@ -3441,18 +3405,12 @@ class Table {
3441
3405
  }
3442
3406
  }
3443
3407
  toJSON() {
3444
- const trackPrevious = this.trackPrevious;
3445
3408
  return {
3446
3409
  name: this.name,
3447
3410
  view_name: this.viewName,
3448
- local_only: this.localOnly,
3449
- insert_only: this.insertOnly,
3450
- include_old: trackPrevious && (trackPrevious.columns ?? true),
3451
- include_old_only_when_changed: typeof trackPrevious == 'object' && trackPrevious.onlyWhenChanged == true,
3452
- include_metadata: this.trackMetadata,
3453
- ignore_empty_update: this.ignoreEmptyUpdates,
3454
3411
  columns: this.columns.map((c) => c.toJSON()),
3455
- indexes: this.indexes.map((e) => e.toJSON(this))
3412
+ indexes: this.indexes.map((e) => e.toJSON(this)),
3413
+ ...encodeTableOptions(this)
3456
3414
  };
3457
3415
  }
3458
3416
  }
@@ -15630,7 +15588,7 @@ class TriggerManagerImpl {
15630
15588
  }
15631
15589
  async createDiffTrigger(options) {
15632
15590
  await this.db.waitForReady();
15633
- const { source, destination, columns, when, hooks,
15591
+ const { source, destination, columns, when, hooks, persistDestination = false,
15634
15592
  // Fall back to the provided default if not given on this level
15635
15593
  useStorage = this.defaultConfig.useStorageByDefault } = options;
15636
15594
  const operations = Object.keys(when);
@@ -15685,11 +15643,13 @@ class TriggerManagerImpl {
15685
15643
  * we need to ensure we can cleanup the created resources.
15686
15644
  * We unfortunately cannot rely on transaction rollback.
15687
15645
  */
15688
- const cleanup = async () => {
15646
+ const cleanup = async (force) => {
15689
15647
  disposeWarningListener();
15690
15648
  return this.db.writeLock(async (tx) => {
15691
15649
  await this.removeTriggers(tx, triggerIds);
15692
- await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
15650
+ if (!persistDestination || force) {
15651
+ await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
15652
+ }
15693
15653
  await releaseStorageClaim?.();
15694
15654
  });
15695
15655
  };
@@ -15697,7 +15657,7 @@ class TriggerManagerImpl {
15697
15657
  // Allow user code to execute in this lock context before the trigger is created.
15698
15658
  await hooks?.beforeCreate?.(tx);
15699
15659
  await tx.execute(/* sql */ `
15700
- CREATE ${tableTriggerTypeClause} TABLE ${destination} (
15660
+ CREATE ${tableTriggerTypeClause} TABLE ${persistDestination ? 'IF NOT EXISTS ' : ''}${destination} (
15701
15661
  operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
15702
15662
  id TEXT,
15703
15663
  operation TEXT,
@@ -16173,11 +16133,7 @@ class AbstractPowerSyncDatabase extends BaseObserver {
16173
16133
  this.logger.warn('Schema validation failed. Unexpected behaviour could occur', ex);
16174
16134
  }
16175
16135
  this._schema = schema;
16176
- // powersync_replace_schema starts a transaction internally, but we can be more efficient by using BEGIN EXCLUSIVE
16177
- // on some DB adapters.
16178
- this.database.writeTransaction((tx) => {
16179
- return tx.execute('SELECT powersync_replace_schema(?)', [JSON.stringify(this.schema.toJSON())]);
16180
- });
16136
+ await this.database.execute('SELECT powersync_replace_schema(?)', [JSON.stringify(this.schema.toJSON())]);
16181
16137
  await this.database.refreshSchema();
16182
16138
  this.iterateListeners(async (cb) => cb.schemaChanged?.(schema));
16183
16139
  }
@@ -17282,39 +17238,6 @@ class ConnectionClosedError extends Error {
17282
17238
  }
17283
17239
  }
17284
17240
 
17285
- /**
17286
- * Instructs PowerSync to sync data into a "raw" table.
17287
- *
17288
- * Since raw tables are not backed by JSON, running complex queries on them may be more efficient. Further, they allow
17289
- * using client-side table and column constraints.
17290
- *
17291
- * To collect local writes to raw tables with PowerSync, custom triggers are required. See
17292
- * {@link https://docs.powersync.com/usage/use-case-examples/raw-tables the documentation} for details and an example on
17293
- * using raw tables.
17294
- *
17295
- * Note that raw tables are only supported when using the new `SyncClientImplementation.rust` sync client.
17296
- *
17297
- * @experimental Please note that this feature is experimental at the moment, and not covered by PowerSync semver or
17298
- * stability guarantees.
17299
- */
17300
- class RawTable {
17301
- /**
17302
- * The name of the table.
17303
- *
17304
- * This does not have to match the actual table name in the schema - {@link put} and {@link delete} are free to use
17305
- * another table. Instead, this name is used by the sync client to recognize that operations on this table (as it
17306
- * appears in the source / backend database) are to be handled specially.
17307
- */
17308
- name;
17309
- put;
17310
- delete;
17311
- constructor(name, type) {
17312
- this.name = name;
17313
- this.put = type.put;
17314
- this.delete = type.delete;
17315
- }
17316
- }
17317
-
17318
17241
  /**
17319
17242
  * A schema is a collection of tables. It is used to define the structure of a database.
17320
17243
  */
@@ -17359,7 +17282,7 @@ class Schema {
17359
17282
  */
17360
17283
  withRawTables(tables) {
17361
17284
  for (const [name, rawTableDefinition] of Object.entries(tables)) {
17362
- this.rawTables.push(new RawTable(name, rawTableDefinition));
17285
+ this.rawTables.push({ name, ...rawTableDefinition });
17363
17286
  }
17364
17287
  }
17365
17288
  validate() {
@@ -17370,8 +17293,30 @@ class Schema {
17370
17293
  toJSON() {
17371
17294
  return {
17372
17295
  tables: this.tables.map((t) => t.toJSON()),
17373
- raw_tables: this.rawTables
17296
+ raw_tables: this.rawTables.map(Schema.rawTableToJson)
17297
+ };
17298
+ }
17299
+ /**
17300
+ * Returns a representation of the raw table that is understood by the PowerSync SQLite core extension.
17301
+ *
17302
+ * The output of this can be passed through `JSON.serialize` and then used in `powersync_create_raw_table_crud_trigger`
17303
+ * to define triggers for this table.
17304
+ */
17305
+ static rawTableToJson(table) {
17306
+ const serialized = {
17307
+ name: table.name,
17308
+ put: table.put,
17309
+ delete: table.delete,
17310
+ clear: table.clear
17374
17311
  };
17312
+ if ('schema' in table) {
17313
+ // We have schema options, those are flattened into the outer JSON object for the core extension.
17314
+ const schema = table.schema;
17315
+ serialized.table_name = schema.tableName ?? table.name;
17316
+ serialized.synced_columns = schema.syncedColumns;
17317
+ Object.assign(serialized, encodeTableOptions(table.schema));
17318
+ }
17319
+ return serialized;
17375
17320
  }
17376
17321
  }
17377
17322
 
@@ -17706,7 +17651,7 @@ var __webpack_exports__ = {};
17706
17651
  !*** ./lib/src/worker/db/WASQLiteDB.worker.js ***!
17707
17652
  \************************************************/
17708
17653
  __webpack_require__.r(__webpack_exports__);
17709
- /* harmony import */ var _journeyapps_wa_sqlite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @journeyapps/wa-sqlite */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@0.0.0-dev-20260226145021/node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js");
17654
+ /* harmony import */ var _journeyapps_wa_sqlite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @journeyapps/wa-sqlite */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.5.0/node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js");
17710
17655
  /* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
17711
17656
  /* harmony import */ var comlink__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! comlink */ "../../node_modules/.pnpm/comlink@4.4.2/node_modules/comlink/dist/esm/comlink.mjs");
17712
17657
  /* harmony import */ var _shared_navigator_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../shared/navigator.js */ "./lib/src/shared/navigator.js");