@powersync/web 0.0.0-dev-20251201150812 → 0.0.0-dev-20251209082930

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 (47) hide show
  1. package/dist/0b19af1befc07ce338dd.wasm +0 -0
  2. package/dist/2632c3bda9473da74fd5.wasm +0 -0
  3. package/dist/64f5351ba3784bfe2f3e.wasm +0 -0
  4. package/dist/9318ca94aac4d0fe0135.wasm +0 -0
  5. package/dist/index.umd.js +219 -115
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/worker/SharedSyncImplementation.umd.js +164 -109
  8. package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
  9. package/dist/worker/WASQLiteDB.umd.js +24 -12
  10. package/dist/worker/WASQLiteDB.umd.js.map +1 -1
  11. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite-async_mjs.umd.js +16 -3
  12. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite-async_mjs.umd.js.map +1 -1
  13. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite_mjs.umd.js +16 -3
  14. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite_mjs.umd.js.map +1 -1
  15. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite-async_mjs.umd.js +16 -3
  16. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite-async_mjs.umd.js.map +1 -1
  17. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js +16 -3
  18. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js.map +1 -1
  19. package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_OPFSCoopSyncVFS_js.umd.js +18 -11
  20. package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_OPFSCoopSyncVFS_js.umd.js.map +1 -1
  21. package/lib/package.json +2 -2
  22. package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.d.ts +4 -1
  23. package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.js +60 -29
  24. package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js +11 -2
  25. package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.d.ts +1 -1
  26. package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js +2 -2
  27. package/lib/src/worker/sync/SharedSyncImplementation.js +80 -68
  28. package/lib/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +5 -5
  30. package/src/db/adapters/LockedAsyncDatabaseAdapter.ts +79 -48
  31. package/src/db/adapters/wa-sqlite/WASQLiteConnection.ts +11 -3
  32. package/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.ts +3 -3
  33. package/src/worker/db/WASQLiteDB.worker.ts +0 -1
  34. package/src/worker/sync/SharedSyncImplementation.ts +89 -74
  35. package/dist/1807036ae51c10ee4d23.wasm +0 -0
  36. package/dist/307d8ce2280e3bae09d5.wasm +0 -0
  37. package/dist/cd8b9e8f4c87bf81c169.wasm +0 -0
  38. package/dist/e797080f5ed0b5324166.wasm +0 -0
  39. package/lib/src/worker/sync/MockSyncService.d.ts +0 -2
  40. package/lib/src/worker/sync/MockSyncService.js +0 -3
  41. package/lib/src/worker/sync/MockSyncServiceTypes.d.ts +0 -101
  42. package/lib/src/worker/sync/MockSyncServiceTypes.js +0 -1
  43. package/lib/src/worker/sync/MockSyncServiceWorker.d.ts +0 -56
  44. package/lib/src/worker/sync/MockSyncServiceWorker.js +0 -369
  45. package/src/worker/sync/MockSyncService.ts +0 -3
  46. package/src/worker/sync/MockSyncServiceTypes.ts +0 -71
  47. package/src/worker/sync/MockSyncServiceWorker.ts +0 -406
@@ -1147,8 +1147,11 @@ function Factory(Module) {
1147
1147
  // Wait for all pending retry operations to complete. This is
1148
1148
  // normally empty on the first loop iteration.
1149
1149
  if (Module.retryOps.length) {
1150
- await Promise.all(Module.retryOps);
1151
- Module.retryOps = [];
1150
+ try {
1151
+ await Promise.all(Module.retryOps);
1152
+ } finally {
1153
+ Module.retryOps = [];
1154
+ }
1152
1155
  }
1153
1156
 
1154
1157
  rc = await f();
@@ -14673,7 +14676,7 @@ The next upload iteration will be delayed.`);
14673
14676
  uploadError: ex
14674
14677
  }
14675
14678
  });
14676
- await this.delayRetry(controller.signal, this.options.crudUploadThrottleMs);
14679
+ await this.delayRetry(controller.signal);
14677
14680
  if (!this.isConnected) {
14678
14681
  // Exit the upload loop if the sync stream is no longer connected
14679
14682
  break;
@@ -15384,14 +15387,14 @@ The next upload iteration will be delayed.`);
15384
15387
  // trigger this for all updates
15385
15388
  this.iterateListeners((cb) => cb.statusUpdated?.(options));
15386
15389
  }
15387
- async delayRetry(signal, delayMs) {
15390
+ async delayRetry(signal) {
15388
15391
  return new Promise((resolve) => {
15389
15392
  if (signal?.aborted) {
15390
15393
  // If the signal is already aborted, resolve immediately
15391
15394
  resolve();
15392
15395
  return;
15393
15396
  }
15394
- const delay = delayMs ?? this.options.retryDelayMs;
15397
+ const { retryDelayMs } = this.options;
15395
15398
  let timeoutId;
15396
15399
  const endDelay = () => {
15397
15400
  resolve();
@@ -15402,7 +15405,7 @@ The next upload iteration will be delayed.`);
15402
15405
  signal?.removeEventListener('abort', endDelay);
15403
15406
  };
15404
15407
  signal?.addEventListener('abort', endDelay, { once: true });
15405
- timeoutId = setTimeout(endDelay, delay);
15408
+ timeoutId = setTimeout(endDelay, retryDelayMs);
15406
15409
  });
15407
15410
  }
15408
15411
  updateSubscriptions(subscriptions) {
@@ -15932,11 +15935,11 @@ class AbstractPowerSyncDatabase extends BaseObserver {
15932
15935
  .map((n) => parseInt(n));
15933
15936
  }
15934
15937
  catch (e) {
15935
- throw new Error(`Unsupported powersync extension version. Need >=0.4.5 <1.0.0, got: ${this.sdkVersion}. Details: ${e.message}`);
15938
+ throw new Error(`Unsupported powersync extension version. Need >=0.4.10 <1.0.0, got: ${this.sdkVersion}. Details: ${e.message}`);
15936
15939
  }
15937
- // Validate >=0.4.5 <1.0.0
15938
- if (versionInts[0] != 0 || versionInts[1] < 4 || (versionInts[1] == 4 && versionInts[2] < 5)) {
15939
- throw new Error(`Unsupported powersync extension version. Need >=0.4.5 <1.0.0, got: ${this.sdkVersion}`);
15940
+ // Validate >=0.4.10 <1.0.0
15941
+ if (versionInts[0] != 0 || versionInts[1] < 4 || (versionInts[1] == 4 && versionInts[2] < 10)) {
15942
+ throw new Error(`Unsupported powersync extension version. Need >=0.4.10 <1.0.0, got: ${this.sdkVersion}`);
15940
15943
  }
15941
15944
  }
15942
15945
  async resolveOfflineSyncStatus() {
@@ -17719,9 +17722,10 @@ const DEFAULT_MODULE_FACTORIES = {
17719
17722
  }
17720
17723
  // @ts-expect-error The types for this static method are missing upstream
17721
17724
  const { OPFSCoopSyncVFS } = await __webpack_require__.e(/*! import() */ "node_modules_journeyapps_wa-sqlite_src_examples_OPFSCoopSyncVFS_js").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/src/examples/OPFSCoopSyncVFS.js */ "../../node_modules/@journeyapps/wa-sqlite/src/examples/OPFSCoopSyncVFS.js"));
17725
+ const vfs = await OPFSCoopSyncVFS.create(options.dbFileName, module);
17722
17726
  return {
17723
17727
  module,
17724
- vfs: await OPFSCoopSyncVFS.create(options.dbFileName, module)
17728
+ vfs
17725
17729
  };
17726
17730
  }
17727
17731
  };
@@ -17947,7 +17951,15 @@ class WASqliteConnection extends _powersync_common__WEBPACK_IMPORTED_MODULE_1__.
17947
17951
  }
17948
17952
  async close() {
17949
17953
  this.broadcastChannel?.close();
17950
- await this.sqliteAPI.close(this.dbP);
17954
+ await this.acquireExecuteLock(async () => {
17955
+ /**
17956
+ * Running the close operation inside the same execute mutex prevents errors like:
17957
+ * ```
17958
+ * unable to close due to unfinalized statements or unfinished backups
17959
+ * ```
17960
+ */
17961
+ await this.sqliteAPI.close(this.dbP);
17962
+ });
17951
17963
  }
17952
17964
  async registerOnTableChange(callback) {
17953
17965
  return this.registerListener({