@powersync/web 1.37.2 → 1.38.1

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 (76) hide show
  1. package/dist/2075a31bb151adbb9767.wasm +0 -0
  2. package/dist/3322bc84de986b63c2cd.wasm +0 -0
  3. package/dist/8e97452e297be23b5e50.wasm +0 -0
  4. package/dist/fbc178b70d530e8ce02b.wasm +0 -0
  5. package/dist/index.umd.js +4289 -4786
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/worker/SharedSyncImplementation.umd.js +171 -900
  8. package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
  9. package/dist/worker/WASQLiteDB.umd.js +233 -839
  10. package/dist/worker/WASQLiteDB.umd.js.map +1 -1
  11. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-9af0a7.umd.js +31 -0
  12. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-9af0a7.umd.js.map +1 -0
  13. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-bbf5a9.umd.js +31 -0
  14. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-bbf5a9.umd.js.map +1 -0
  15. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-c26e0f.umd.js +31 -0
  16. package/dist/worker/{node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-cc5fcc.umd.js.map → node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-c26e0f.umd.js.map} +1 -1
  17. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js +31 -0
  18. package/dist/worker/{node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js.map → node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js.map} +1 -1
  19. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-2fb422.umd.js +3562 -0
  20. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-2fb422.umd.js.map +1 -0
  21. package/dist/worker/{node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-0df390.umd.js → node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-96fb23.umd.js} +16 -16
  22. package/dist/worker/{node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-0df390.umd.js.map → node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-96fb23.umd.js.map} +1 -1
  23. package/dist/worker/{node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-151024.umd.js → node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-c89911.umd.js} +12 -12
  24. package/dist/worker/{node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-151024.umd.js.map → node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-c89911.umd.js.map} +1 -1
  25. package/dist/worker/{node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-c01ef0.umd.js → node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-ec4eb1.umd.js} +14 -14
  26. package/dist/worker/{node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_src_examples-c01ef0.umd.js.map → node_modules_pnpm_journeyapps_wa-sqlite_1_7_0_node_modules_journeyapps_wa-sqlite_src_examples-ec4eb1.umd.js.map} +1 -1
  27. package/lib/package.json +4 -7
  28. package/lib/src/db/PowerSyncDatabase.d.ts +1 -1
  29. package/lib/src/db/PowerSyncDatabase.js +0 -8
  30. package/lib/src/db/adapters/AsyncWebAdapter.d.ts +13 -3
  31. package/lib/src/db/adapters/AsyncWebAdapter.js +115 -21
  32. package/lib/src/db/adapters/wa-sqlite/DatabaseServer.js +1 -2
  33. package/lib/src/db/adapters/wa-sqlite/RawSqliteConnection.js +1 -1
  34. package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.d.ts +16 -2
  35. package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js +60 -38
  36. package/lib/src/db/adapters/wa-sqlite/vfs.d.ts +7 -18
  37. package/lib/src/db/adapters/wa-sqlite/vfs.js +34 -49
  38. package/lib/src/db/sync/SSRWebStreamingSyncImplementation.d.ts +4 -0
  39. package/lib/src/db/sync/SSRWebStreamingSyncImplementation.js +4 -0
  40. package/lib/src/db/sync/SharedWebStreamingSyncImplementation.d.ts +0 -1
  41. package/lib/src/db/sync/SharedWebStreamingSyncImplementation.js +0 -3
  42. package/lib/src/db/sync/WebRemote.d.ts +1 -3
  43. package/lib/src/db/sync/WebRemote.js +0 -12
  44. package/lib/src/worker/db/MultiDatabaseServer.js +4 -1
  45. package/lib/src/worker/db/open-worker-database.js +2 -2
  46. package/lib/src/worker/sync/SharedSyncImplementation.d.ts +0 -2
  47. package/lib/src/worker/sync/SharedSyncImplementation.js +4 -16
  48. package/lib/src/worker/sync/WorkerClient.d.ts +0 -1
  49. package/lib/src/worker/sync/WorkerClient.js +0 -3
  50. package/lib/tsconfig.tsbuildinfo +1 -1
  51. package/package.json +5 -8
  52. package/src/db/PowerSyncDatabase.ts +1 -9
  53. package/src/db/adapters/AsyncWebAdapter.ts +138 -22
  54. package/src/db/adapters/wa-sqlite/DatabaseServer.ts +4 -2
  55. package/src/db/adapters/wa-sqlite/RawSqliteConnection.ts +4 -1
  56. package/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.ts +89 -44
  57. package/src/db/adapters/wa-sqlite/vfs.ts +33 -49
  58. package/src/db/sync/SSRWebStreamingSyncImplementation.ts +5 -0
  59. package/src/db/sync/SharedWebStreamingSyncImplementation.ts +0 -4
  60. package/src/db/sync/WebRemote.ts +0 -16
  61. package/src/worker/db/MultiDatabaseServer.ts +4 -1
  62. package/src/worker/db/open-worker-database.ts +2 -2
  63. package/src/worker/sync/SharedSyncImplementation.ts +4 -18
  64. package/src/worker/sync/WorkerClient.ts +0 -4
  65. package/dist/26d61ca9f5694d064635.wasm +0 -0
  66. package/dist/b4c6283dc473b6b3fd24.wasm +0 -0
  67. package/dist/c78985091a0b22aaef03.wasm +0 -0
  68. package/dist/ca59e199e1138b553fad.wasm +0 -0
  69. package/dist/worker/node_modules_pnpm_bson_6_10_4_node_modules_bson_lib_bson_mjs.umd.js +0 -4646
  70. package/dist/worker/node_modules_pnpm_bson_6_10_4_node_modules_bson_lib_bson_mjs.umd.js.map +0 -1
  71. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-b9c070.umd.js +0 -31
  72. 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 +0 -1
  73. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-c99c07.umd.js +0 -31
  74. 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 +0 -1
  75. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-cc5fcc.umd.js +0 -31
  76. package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_5_0_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js +0 -31
@@ -652,7 +652,6 @@ class WebFetchProvider extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.Fe
652
652
  class WebRemote extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.AbstractRemote {
653
653
  connector;
654
654
  logger;
655
- _bson;
656
655
  constructor(connector, logger = _powersync_common__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_REMOTE_LOGGER, options) {
657
656
  super(connector, logger, {
658
657
  ...(options ?? {}),
@@ -671,17 +670,6 @@ class WebRemote extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.AbstractR
671
670
  }
672
671
  return ua.join(' ');
673
672
  }
674
- async getBSON() {
675
- if (this._bson) {
676
- return this._bson;
677
- }
678
- /**
679
- * Dynamic import to be used only when needed.
680
- */
681
- const { BSON } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_bson_6_10_4_node_modules_bson_lib_bson_mjs").then(__webpack_require__.bind(__webpack_require__, /*! bson */ "../../node_modules/.pnpm/bson@6.10.4/node_modules/bson/lib/bson.mjs"));
682
- this._bson = BSON;
683
- return this._bson;
684
- }
685
673
  }
686
674
 
687
675
 
@@ -1100,9 +1088,6 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
1100
1088
  logger: this.logger
1101
1089
  });
1102
1090
  }
1103
- get lastSyncedAt() {
1104
- return this.connectionManager.syncStreamImplementation?.lastSyncedAt;
1105
- }
1106
1091
  get isConnected() {
1107
1092
  return this.connectionManager.syncStreamImplementation?.isConnected ?? false;
1108
1093
  }
@@ -1268,11 +1253,6 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
1268
1253
  sync.triggerCrudUpload();
1269
1254
  });
1270
1255
  }
1271
- async hasCompletedSync() {
1272
- return this.withSyncImplementation(async (sync) => {
1273
- return sync.hasCompletedSync();
1274
- });
1275
- }
1276
1256
  async getWriteCheckpoint() {
1277
1257
  return this.withSyncImplementation(async (sync) => {
1278
1258
  return sync.getWriteCheckpoint();
@@ -1490,14 +1470,10 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
1490
1470
  // We can poke the crud in case we missed any updates.
1491
1471
  const impl = sharedSync.connectionManager.syncStreamImplementation;
1492
1472
  impl?.triggerCrudUpload();
1493
- /**
1494
- * FIXME or IMPROVE ME
1495
- * The Rust client implementation stores sync state on the connection level.
1496
- * Reopening the database causes a state machine error which should cause the
1497
- * StreamingSyncImplementation to reconnect. It would be nicer if we could trigger
1498
- * this reconnect earlier.
1499
- * This reconnect is not required for IndexedDB.
1500
- */
1473
+ // The Rust client implementation stores sync state on the connection level. Reopening the database causes a
1474
+ // disruption of the connection state and forces us to reconnect. We want to do that as soon as possible to
1475
+ // minimize downtime.
1476
+ impl?.markConnectionMayHaveChanged();
1501
1477
  }
1502
1478
  }
1503
1479
  async readLock(fn, options) {
@@ -1640,9 +1616,6 @@ class WorkerClient {
1640
1616
  getWriteCheckpoint() {
1641
1617
  return this.sync.getWriteCheckpoint();
1642
1618
  }
1643
- hasCompletedSync() {
1644
- return this.sync.hasCompletedSync();
1645
- }
1646
1619
  connect(options) {
1647
1620
  return this.sync.connect(options);
1648
1621
  }
@@ -1726,9 +1699,6 @@ __webpack_require__.r(__webpack_exports__);
1726
1699
  /* harmony export */ MEMORY_TRIGGER_CLAIM_MANAGER: () => (/* binding */ MEMORY_TRIGGER_CLAIM_MANAGER),
1727
1700
  /* harmony export */ Mutex: () => (/* binding */ Mutex),
1728
1701
  /* harmony export */ OnChangeQueryProcessor: () => (/* binding */ OnChangeQueryProcessor),
1729
- /* harmony export */ OpType: () => (/* binding */ OpType),
1730
- /* harmony export */ OpTypeEnum: () => (/* binding */ OpTypeEnum),
1731
- /* harmony export */ OplogEntry: () => (/* binding */ OplogEntry),
1732
1702
  /* harmony export */ PSInternalTable: () => (/* binding */ PSInternalTable),
1733
1703
  /* harmony export */ PowerSyncControlCommand: () => (/* binding */ PowerSyncControlCommand),
1734
1704
  /* harmony export */ RowUpdateType: () => (/* binding */ RowUpdateType),
@@ -1736,8 +1706,6 @@ __webpack_require__.r(__webpack_exports__);
1736
1706
  /* harmony export */ Semaphore: () => (/* binding */ Semaphore),
1737
1707
  /* harmony export */ SqliteBucketStorage: () => (/* binding */ SqliteBucketStorage),
1738
1708
  /* harmony export */ SyncClientImplementation: () => (/* binding */ SyncClientImplementation),
1739
- /* harmony export */ SyncDataBatch: () => (/* binding */ SyncDataBatch),
1740
- /* harmony export */ SyncDataBucket: () => (/* binding */ SyncDataBucket),
1741
1709
  /* harmony export */ SyncProgress: () => (/* binding */ SyncProgress),
1742
1710
  /* harmony export */ SyncStatus: () => (/* binding */ SyncStatus),
1743
1711
  /* harmony export */ SyncStreamConnectionMethod: () => (/* binding */ SyncStreamConnectionMethod),
@@ -1755,18 +1723,10 @@ __webpack_require__.r(__webpack_exports__);
1755
1723
  /* harmony export */ createLogger: () => (/* binding */ createLogger),
1756
1724
  /* harmony export */ extractTableUpdates: () => (/* binding */ extractTableUpdates),
1757
1725
  /* harmony export */ isBatchedUpdateNotification: () => (/* binding */ isBatchedUpdateNotification),
1758
- /* harmony export */ isContinueCheckpointRequest: () => (/* binding */ isContinueCheckpointRequest),
1759
1726
  /* harmony export */ isDBAdapter: () => (/* binding */ isDBAdapter),
1760
1727
  /* harmony export */ isPowerSyncDatabaseOptionsWithSettings: () => (/* binding */ isPowerSyncDatabaseOptionsWithSettings),
1761
1728
  /* harmony export */ isSQLOpenFactory: () => (/* binding */ isSQLOpenFactory),
1762
1729
  /* harmony export */ isSQLOpenOptions: () => (/* binding */ isSQLOpenOptions),
1763
- /* harmony export */ isStreamingKeepalive: () => (/* binding */ isStreamingKeepalive),
1764
- /* harmony export */ isStreamingSyncCheckpoint: () => (/* binding */ isStreamingSyncCheckpoint),
1765
- /* harmony export */ isStreamingSyncCheckpointComplete: () => (/* binding */ isStreamingSyncCheckpointComplete),
1766
- /* harmony export */ isStreamingSyncCheckpointDiff: () => (/* binding */ isStreamingSyncCheckpointDiff),
1767
- /* harmony export */ isStreamingSyncCheckpointPartiallyComplete: () => (/* binding */ isStreamingSyncCheckpointPartiallyComplete),
1768
- /* harmony export */ isStreamingSyncData: () => (/* binding */ isStreamingSyncData),
1769
- /* harmony export */ isSyncNewCheckpointRequest: () => (/* binding */ isSyncNewCheckpointRequest),
1770
1730
  /* harmony export */ parseQuery: () => (/* binding */ parseQuery),
1771
1731
  /* harmony export */ runOnSchemaChange: () => (/* binding */ runOnSchemaChange),
1772
1732
  /* harmony export */ sanitizeSQL: () => (/* binding */ sanitizeSQL),
@@ -3744,8 +3704,15 @@ class BaseTransaction {
3744
3704
  class TransactionImplementation extends DBGetUtilsDefaultMixin(BaseTransaction) {
3745
3705
  static async runWith(ctx, fn) {
3746
3706
  let tx = new TransactionImplementation(ctx);
3707
+ // For write transactions, use BEGIN IMMEDIATE to immediately obtain a write lock on the database (instead of doing
3708
+ // that on the first statement). If we have a genuine read-only connection, we also use BEGIN IMMEDIATE there: In
3709
+ // WAL mode, that ensures we pin the current state of the database (instead of the state at the first statement in
3710
+ // the transaction). But if we have a "fake" read-only connection implemented through `pragma query_only = true`, we
3711
+ // can't use this trick because it would attempt to lock the connection. So there, we use a regular `BEGIN`
3712
+ // statement.
3713
+ const useBeginImmediate = ctx.connectionType != 'queryOnly';
3747
3714
  try {
3748
- await ctx.execute('BEGIN IMMEDIATE');
3715
+ await ctx.execute(useBeginImmediate ? 'BEGIN IMMEDIATE' : 'BEGIN');
3749
3716
  const result = await fn(tx);
3750
3717
  await tx.commit();
3751
3718
  return result;
@@ -3904,16 +3871,12 @@ class SyncStatus {
3904
3871
  *
3905
3872
  * This returns null when the database is currently being opened and we don't have reliable information about all
3906
3873
  * included streams yet.
3907
- *
3908
- * @experimental Sync streams are currently in alpha.
3909
3874
  */
3910
3875
  get syncStreams() {
3911
3876
  return this.options.dataFlow?.internalStreamSubscriptions?.map((core) => new SyncStreamStatusView(this, core));
3912
3877
  }
3913
3878
  /**
3914
3879
  * If the `stream` appears in {@link syncStreams}, returns the current status for that stream.
3915
- *
3916
- * @experimental Sync streams are currently in alpha.
3917
3880
  */
3918
3881
  forStream(stream) {
3919
3882
  const asJson = JSON.stringify(stream.parameters);
@@ -4496,7 +4459,7 @@ class SyncStreamSubscriptionHandle {
4496
4459
  constructor(subscription) {
4497
4460
  this.subscription = subscription;
4498
4461
  subscription.refcount++;
4499
- _finalizer?.register(this, subscription);
4462
+ _finalizer?.register(this, subscription, this);
4500
4463
  }
4501
4464
  get name() {
4502
4465
  return this.subscription.name;
@@ -5085,6 +5048,10 @@ var PowerSyncControlCommand;
5085
5048
  PowerSyncControlCommand["NOTIFY_TOKEN_REFRESHED"] = "refreshed_token";
5086
5049
  PowerSyncControlCommand["NOTIFY_CRUD_UPLOAD_COMPLETED"] = "completed_upload";
5087
5050
  PowerSyncControlCommand["UPDATE_SUBSCRIPTIONS"] = "update_subscriptions";
5051
+ /**
5052
+ * An `established` or `end` event for response streams.
5053
+ */
5054
+ PowerSyncControlCommand["CONNECTION_STATE"] = "connection";
5088
5055
  })(PowerSyncControlCommand || (PowerSyncControlCommand = {}));
5089
5056
 
5090
5057
  /**
@@ -5266,103 +5233,6 @@ class AbortOperation extends Error {
5266
5233
  }
5267
5234
  }
5268
5235
 
5269
- var OpTypeEnum;
5270
- (function (OpTypeEnum) {
5271
- OpTypeEnum[OpTypeEnum["CLEAR"] = 1] = "CLEAR";
5272
- OpTypeEnum[OpTypeEnum["MOVE"] = 2] = "MOVE";
5273
- OpTypeEnum[OpTypeEnum["PUT"] = 3] = "PUT";
5274
- OpTypeEnum[OpTypeEnum["REMOVE"] = 4] = "REMOVE";
5275
- })(OpTypeEnum || (OpTypeEnum = {}));
5276
- /**
5277
- * Used internally for sync buckets.
5278
- */
5279
- class OpType {
5280
- value;
5281
- static fromJSON(jsonValue) {
5282
- return new OpType(OpTypeEnum[jsonValue]);
5283
- }
5284
- constructor(value) {
5285
- this.value = value;
5286
- }
5287
- toJSON() {
5288
- return Object.entries(OpTypeEnum).find(([, value]) => value === this.value)[0];
5289
- }
5290
- }
5291
-
5292
- class OplogEntry {
5293
- op_id;
5294
- op;
5295
- checksum;
5296
- subkey;
5297
- object_type;
5298
- object_id;
5299
- data;
5300
- static fromRow(row) {
5301
- return new OplogEntry(row.op_id, OpType.fromJSON(row.op), row.checksum, row.subkey, row.object_type, row.object_id, row.data);
5302
- }
5303
- constructor(op_id, op, checksum, subkey, object_type, object_id, data) {
5304
- this.op_id = op_id;
5305
- this.op = op;
5306
- this.checksum = checksum;
5307
- this.subkey = subkey;
5308
- this.object_type = object_type;
5309
- this.object_id = object_id;
5310
- this.data = data;
5311
- }
5312
- toJSON(fixedKeyEncoding = false) {
5313
- return {
5314
- op_id: this.op_id,
5315
- op: this.op.toJSON(),
5316
- object_type: this.object_type,
5317
- object_id: this.object_id,
5318
- checksum: this.checksum,
5319
- data: this.data,
5320
- // Older versions of the JS SDK used to always JSON.stringify here. That has always been wrong,
5321
- // but we need to migrate gradually to not break existing databases.
5322
- subkey: fixedKeyEncoding ? this.subkey : JSON.stringify(this.subkey)
5323
- };
5324
- }
5325
- }
5326
-
5327
- class SyncDataBucket {
5328
- bucket;
5329
- data;
5330
- has_more;
5331
- after;
5332
- next_after;
5333
- static fromRow(row) {
5334
- return new SyncDataBucket(row.bucket, row.data.map((entry) => OplogEntry.fromRow(entry)), row.has_more ?? false, row.after, row.next_after);
5335
- }
5336
- constructor(bucket, data,
5337
- /**
5338
- * True if the response does not contain all the data for this bucket, and another request must be made.
5339
- */
5340
- has_more,
5341
- /**
5342
- * The `after` specified in the request.
5343
- */
5344
- after,
5345
- /**
5346
- * Use this for the next request.
5347
- */
5348
- next_after) {
5349
- this.bucket = bucket;
5350
- this.data = data;
5351
- this.has_more = has_more;
5352
- this.after = after;
5353
- this.next_after = next_after;
5354
- }
5355
- toJSON(fixedKeyEncoding = false) {
5356
- return {
5357
- bucket: this.bucket,
5358
- has_more: this.has_more,
5359
- after: this.after,
5360
- next_after: this.next_after,
5361
- data: this.data.map((entry) => entry.toJSON(fixedKeyEncoding))
5362
- };
5363
- }
5364
- }
5365
-
5366
5236
  var buffer = {};
5367
5237
 
5368
5238
  var base64Js = {};
@@ -12518,7 +12388,7 @@ function requireDist () {
12518
12388
 
12519
12389
  var distExports = requireDist();
12520
12390
 
12521
- var version = "1.52.0";
12391
+ var version = "1.53.1";
12522
12392
  var PACKAGE = {
12523
12393
  version: version};
12524
12394
 
@@ -12688,22 +12558,6 @@ const doneResult = { done: true, value: undefined };
12688
12558
  function valueResult(value) {
12689
12559
  return { done: false, value };
12690
12560
  }
12691
- /**
12692
- * A variant of {@link Array.map} for async iterators.
12693
- */
12694
- function map(source, map) {
12695
- return {
12696
- next: async () => {
12697
- const value = await source.next();
12698
- if (value.done) {
12699
- return value;
12700
- }
12701
- else {
12702
- return { value: map(value.value) };
12703
- }
12704
- }
12705
- };
12706
- }
12707
12561
  /**
12708
12562
  * Expands a source async iterator by allowing to inject events asynchronously.
12709
12563
  *
@@ -12718,6 +12572,7 @@ function injectable(source) {
12718
12572
  let waiter = undefined; // An active, waiting next() call.
12719
12573
  // A pending upstream event that couldn't be dispatched because inject() has been called before it was resolved.
12720
12574
  let pendingSourceEvent = null;
12575
+ let sourceFetchInFlight = false;
12721
12576
  let pendingInjectedEvents = [];
12722
12577
  const consumeWaiter = () => {
12723
12578
  const pending = waiter;
@@ -12726,6 +12581,7 @@ function injectable(source) {
12726
12581
  };
12727
12582
  const fetchFromSource = () => {
12728
12583
  const resolveWaiter = (propagate) => {
12584
+ sourceFetchInFlight = false;
12729
12585
  const active = consumeWaiter();
12730
12586
  if (active) {
12731
12587
  propagate(active);
@@ -12734,6 +12590,7 @@ function injectable(source) {
12734
12590
  pendingSourceEvent = propagate;
12735
12591
  }
12736
12592
  };
12593
+ sourceFetchInFlight = true;
12737
12594
  const nextFromSource = source.next();
12738
12595
  nextFromSource.then((value) => {
12739
12596
  sourceIsDone = value.done == true;
@@ -12760,7 +12617,9 @@ function injectable(source) {
12760
12617
  }
12761
12618
  // Nothing pending? Fetch from source
12762
12619
  waiter = { resolve, reject };
12763
- return fetchFromSource();
12620
+ if (!sourceFetchInFlight) {
12621
+ fetchFromSource();
12622
+ }
12764
12623
  });
12765
12624
  },
12766
12625
  inject: (event) => {
@@ -13075,22 +12934,12 @@ class AbstractRemote {
13075
12934
  * Returns a data stream of sync line data, fetched via RSocket-over-WebSocket.
13076
12935
  *
13077
12936
  * The only mechanism to abort the returned stream is to use the abort signal in {@link SocketSyncStreamOptions}.
13078
- *
13079
- * @param bson A BSON encoder and decoder. When set, the data stream will be requested with a BSON payload
13080
- * (required for compatibility with older sync services).
13081
12937
  */
13082
- async socketStreamRaw(options, bson) {
12938
+ async socketStreamRaw(options) {
13083
12939
  const { path, fetchStrategy = FetchStrategy.Buffered } = options;
13084
- const mimeType = bson == null ? 'application/json' : 'application/bson';
12940
+ const mimeType = 'application/json';
13085
12941
  function toBuffer(js) {
13086
- let contents;
13087
- if (bson != null) {
13088
- contents = bson.serialize(js);
13089
- }
13090
- else {
13091
- contents = JSON.stringify(js);
13092
- }
13093
- return bufferExports.Buffer.from(contents);
12942
+ return bufferExports.Buffer.from(JSON.stringify(js));
13094
12943
  }
13095
12944
  const syncQueueRequestSize = fetchStrategy == FetchStrategy.Buffered ? 10 : 1;
13096
12945
  const request = await this.buildRequest(path);
@@ -13391,31 +13240,8 @@ function coreStatusToJs(status) {
13391
13240
  priorityStatusEntries: status.priority_status.map(priorityToJs)
13392
13241
  };
13393
13242
  }
13394
-
13395
- function isStreamingSyncData(line) {
13396
- return line.data != null;
13397
- }
13398
- function isStreamingKeepalive(line) {
13399
- return line.token_expires_in != null;
13400
- }
13401
- function isStreamingSyncCheckpoint(line) {
13402
- return line.checkpoint != null;
13403
- }
13404
- function isStreamingSyncCheckpointComplete(line) {
13405
- return line.checkpoint_complete != null;
13406
- }
13407
- function isStreamingSyncCheckpointPartiallyComplete(line) {
13408
- return line.partial_checkpoint_complete != null;
13409
- }
13410
- function isStreamingSyncCheckpointDiff(line) {
13411
- return line.checkpoint_diff != null;
13412
- }
13413
- function isContinueCheckpointRequest(request) {
13414
- return (Array.isArray(request.buckets) &&
13415
- typeof request.checkpoint_token == 'string');
13416
- }
13417
- function isSyncNewCheckpointRequest(request) {
13418
- return typeof request.request_checkpoint == 'object';
13243
+ function isInterruptingInstruction(instruction) {
13244
+ return 'EstablishSyncStream' in instruction || 'CloseSyncStream' in instruction;
13419
13245
  }
13420
13246
 
13421
13247
  var LockType;
@@ -13430,35 +13256,21 @@ var SyncStreamConnectionMethod;
13430
13256
  })(SyncStreamConnectionMethod || (SyncStreamConnectionMethod = {}));
13431
13257
  var SyncClientImplementation;
13432
13258
  (function (SyncClientImplementation) {
13433
- /**
13434
- * Decodes and handles sync lines received from the sync service in JavaScript.
13435
- *
13436
- * This is the default option.
13437
- *
13438
- * @deprecated We recommend the {@link RUST} client implementation for all apps. If you have issues with
13439
- * the Rust client, please file an issue or reach out to us. The JavaScript client will be removed in a future
13440
- * version of the PowerSync SDK.
13441
- */
13442
- SyncClientImplementation["JAVASCRIPT"] = "js";
13443
13259
  /**
13444
13260
  * This implementation offloads the sync line decoding and handling into the PowerSync
13445
13261
  * core extension.
13446
13262
  *
13447
- * This option is more performant than the {@link JAVASCRIPT} client, enabled by default and the
13448
- * recommended client implementation for all apps.
13263
+ * This is the only option, as an older JavaScript client implementation has been removed from the SDK.
13449
13264
  *
13450
13265
  * ## Compatibility warning
13451
13266
  *
13452
13267
  * The Rust sync client stores sync data in a format that is slightly different than the one used
13453
- * by the old {@link JAVASCRIPT} implementation. When adopting the {@link RUST} client on existing
13454
- * databases, the PowerSync SDK will migrate the format automatically.
13455
- * Further, the {@link JAVASCRIPT} client in recent versions of the PowerSync JS SDK (starting from
13456
- * the version introducing {@link RUST} as an option) also supports the new format, so you can switch
13457
- * back to {@link JAVASCRIPT} later.
13268
+ * by the old JavaScript client. When adopting the {@link RUST} client on existing databases, the PowerSync SDK will
13269
+ * migrate the format automatically.
13458
13270
  *
13459
- * __However__: Upgrading the SDK version, then adopting {@link RUST} as a sync client and later
13460
- * downgrading the SDK to an older version (necessarily using the JavaScript-based implementation then)
13461
- * can lead to sync issues.
13271
+ * SDK versions supporting both the JavaScript and the Rust client support both formats with the JavaScript client
13272
+ * implementaiton. However, downgrading to an SDK version that only supports the JavaScript client would not be
13273
+ * possible anymore. Problematic SDK versions have been released before 2025-06-09.
13462
13274
  */
13463
13275
  SyncClientImplementation["RUST"] = "rust";
13464
13276
  })(SyncClientImplementation || (SyncClientImplementation = {}));
@@ -13481,13 +13293,7 @@ const DEFAULT_STREAM_CONNECTION_OPTIONS = {
13481
13293
  serializedSchema: undefined,
13482
13294
  includeDefaultStreams: true
13483
13295
  };
13484
- // The priority we assume when we receive checkpoint lines where no priority is set.
13485
- // This is the default priority used by the sync service, but can be set to an arbitrary
13486
- // value since sync services without priorities also won't send partial sync completion
13487
- // messages.
13488
- const FALLBACK_PRIORITY = 3;
13489
13296
  class AbstractStreamingSyncImplementation extends BaseObserver {
13490
- _lastSyncedAt;
13491
13297
  options;
13492
13298
  abortController;
13493
13299
  // In rare cases, mostly for tests, uploads can be triggered without being properly connected.
@@ -13497,6 +13303,7 @@ class AbstractStreamingSyncImplementation extends BaseObserver {
13497
13303
  streamingSyncPromise;
13498
13304
  logger;
13499
13305
  activeStreams;
13306
+ connectionMayHaveChanged = false;
13500
13307
  isUploadingCrud = false;
13501
13308
  notifyCompletedUploads;
13502
13309
  handleActiveStreamsChange;
@@ -13576,9 +13383,6 @@ class AbstractStreamingSyncImplementation extends BaseObserver {
13576
13383
  this.crudUpdateListener = undefined;
13577
13384
  this.uploadAbortController?.abort();
13578
13385
  }
13579
- async hasCompletedSync() {
13580
- return this.options.adapter.hasCompletedSync();
13581
- }
13582
13386
  async getWriteCheckpoint() {
13583
13387
  const clientId = await this.options.adapter.getClientId();
13584
13388
  let path = `/write-checkpoint2.json?client_id=${clientId}`;
@@ -13660,7 +13464,7 @@ The next upload iteration will be delayed.`);
13660
13464
  });
13661
13465
  }
13662
13466
  }
13663
- this.uploadAbortController = null;
13467
+ this.uploadAbortController = undefined;
13664
13468
  }
13665
13469
  });
13666
13470
  }
@@ -13776,6 +13580,11 @@ The next upload iteration will be delayed.`);
13776
13580
  shouldDelayRetry = false;
13777
13581
  // A disconnect was requested, we should not delay since there is no explicit retry
13778
13582
  }
13583
+ else if (this.connectionMayHaveChanged && ex.message?.indexOf('No iteration is active') >= 0) {
13584
+ this.connectionMayHaveChanged = false;
13585
+ this.logger.info('Sync error after changed connection, retrying immediately');
13586
+ shouldDelayRetry = false;
13587
+ }
13779
13588
  else {
13780
13589
  this.logger.error(ex);
13781
13590
  }
@@ -13806,17 +13615,14 @@ The next upload iteration will be delayed.`);
13806
13615
  // Mark as disconnected if here
13807
13616
  this.updateSyncStatus({ connected: false, connecting: false });
13808
13617
  }
13809
- async collectLocalBucketState() {
13810
- const bucketEntries = await this.options.adapter.getBucketStates();
13811
- const req = bucketEntries.map((entry) => ({
13812
- name: entry.bucket,
13813
- after: entry.op_id
13814
- }));
13815
- const localDescriptions = new Map();
13816
- for (const entry of bucketEntries) {
13817
- localDescriptions.set(entry.bucket, null);
13818
- }
13819
- return [req, localDescriptions];
13618
+ markConnectionMayHaveChanged() {
13619
+ // By setting this field, we'll immediately retry if the next sync event causes an error triggered by us not having
13620
+ // an active sync iteration on the connection in use.
13621
+ this.connectionMayHaveChanged = true;
13622
+ // This triggers a `powersync_control` invocation if a sync iteration is currently active. This is a cheap call to
13623
+ // make when no subscriptions have actually changed, we're mainly interested in this immediately throwing if no
13624
+ // iteration is active. That allows us to reconnect ASAP, instead of having to wait for the next sync line.
13625
+ this.handleActiveStreamsChange?.();
13820
13626
  }
13821
13627
  /**
13822
13628
  * Older versions of the JS SDK used to encode subkeys as JSON in {@link OplogEntry.toJSON}.
@@ -13857,328 +13663,98 @@ The next upload iteration will be delayed.`);
13857
13663
  if (invalidMetadata.length > 0) {
13858
13664
  throw new Error(`Invalid appMetadata provided. Only string values are allowed. Invalid values: ${invalidMetadata.map(([key, value]) => `${key}: ${value}`).join(', ')}`);
13859
13665
  }
13860
- const clientImplementation = resolvedOptions.clientImplementation;
13861
- this.updateSyncStatus({ clientImplementation });
13862
- if (clientImplementation == SyncClientImplementation.JAVASCRIPT) {
13863
- await this.legacyStreamingSyncIteration(signal, resolvedOptions);
13864
- return null;
13865
- }
13866
- else {
13867
- await this.requireKeyFormat(true);
13868
- return await this.rustSyncIteration(signal, resolvedOptions);
13869
- }
13666
+ await this.requireKeyFormat(true);
13667
+ return await this.rustSyncIteration(signal, resolvedOptions);
13870
13668
  }
13871
13669
  });
13872
13670
  }
13873
- async receiveSyncLines(data) {
13874
- const { options, connection, bson } = data;
13671
+ receiveSyncLines(data) {
13672
+ const { options, connection } = data;
13875
13673
  const remote = this.options.remote;
13876
- if (connection.connectionMethod == SyncStreamConnectionMethod.HTTP) {
13877
- return await remote.fetchStream(options);
13878
- }
13879
- else {
13880
- return await this.options.remote.socketStreamRaw({
13881
- ...options,
13882
- ...{ fetchStrategy: connection.fetchStrategy }
13883
- }, bson);
13884
- }
13885
- }
13886
- async legacyStreamingSyncIteration(signal, resolvedOptions) {
13887
- const rawTables = resolvedOptions.serializedSchema?.raw_tables;
13888
- if (rawTables != null && rawTables.length) {
13889
- this.logger.warn('Raw tables require the Rust-based sync client. The JS client will ignore them.');
13890
- }
13891
- if (this.activeStreams.length) {
13892
- this.logger.error('Sync streams require `clientImplementation: SyncClientImplementation.RUST` when connecting.');
13893
- }
13894
- this.logger.debug('Streaming sync iteration started');
13895
- this.options.adapter.startSession();
13896
- let [req, bucketMap] = await this.collectLocalBucketState();
13897
- let targetCheckpoint = null;
13898
- // A checkpoint that has been validated but not applied (e.g. due to pending local writes)
13899
- let pendingValidatedCheckpoint = null;
13900
- const clientId = await this.options.adapter.getClientId();
13901
- const usingFixedKeyFormat = await this.requireKeyFormat(false);
13902
- this.logger.debug('Requesting stream from server');
13903
- const syncOptions = {
13904
- path: '/sync/stream',
13905
- abortSignal: signal,
13906
- data: {
13907
- buckets: req,
13908
- include_checksum: true,
13909
- raw_data: true,
13910
- parameters: resolvedOptions.params,
13911
- app_metadata: resolvedOptions.appMetadata,
13912
- client_id: clientId
13913
- }
13914
- };
13915
- const bson = await this.options.remote.getBSON();
13916
- const source = await this.receiveSyncLines({
13917
- options: syncOptions,
13918
- connection: resolvedOptions,
13919
- bson
13920
- });
13921
- const stream = injectable(map(source, (line) => {
13922
- if (typeof line == 'string') {
13923
- return JSON.parse(line);
13674
+ const openInner = async () => {
13675
+ if (connection.connectionMethod == SyncStreamConnectionMethod.HTTP) {
13676
+ return await remote.fetchStream(options);
13924
13677
  }
13925
13678
  else {
13926
- return bson.deserialize(line);
13679
+ return await this.options.remote.socketStreamRaw({
13680
+ ...options,
13681
+ ...{ fetchStrategy: connection.fetchStrategy }
13682
+ });
13927
13683
  }
13928
- }));
13929
- this.logger.debug('Stream established. Processing events');
13930
- this.notifyCompletedUploads = () => {
13931
- stream.inject({ crud_upload_completed: null });
13932
13684
  };
13933
- while (true) {
13934
- const { value: line, done } = await stream.next();
13935
- if (done) {
13936
- // The stream has closed while waiting
13937
- return;
13938
- }
13939
- if ('crud_upload_completed' in line) {
13940
- if (pendingValidatedCheckpoint != null) {
13941
- const { applied, endIteration } = await this.applyCheckpoint(pendingValidatedCheckpoint);
13942
- if (applied) {
13943
- pendingValidatedCheckpoint = null;
13944
- }
13945
- else if (endIteration) {
13946
- break;
13947
- }
13685
+ let inner;
13686
+ let done = false;
13687
+ return {
13688
+ async next() {
13689
+ if (done) {
13690
+ return doneResult;
13948
13691
  }
13949
- continue;
13950
- }
13951
- // A connection is active and messages are being received
13952
- if (!this.syncStatus.connected) {
13953
- // There is a connection now
13954
- Promise.resolve().then(() => this.triggerCrudUpload());
13955
- this.updateSyncStatus({
13956
- connected: true
13957
- });
13958
- }
13959
- if (isStreamingSyncCheckpoint(line)) {
13960
- targetCheckpoint = line.checkpoint;
13961
- // New checkpoint - existing validated checkpoint is no longer valid
13962
- pendingValidatedCheckpoint = null;
13963
- const bucketsToDelete = new Set(bucketMap.keys());
13964
- const newBuckets = new Map();
13965
- for (const checksum of line.checkpoint.buckets) {
13966
- newBuckets.set(checksum.bucket, {
13967
- name: checksum.bucket,
13968
- priority: checksum.priority ?? FALLBACK_PRIORITY
13692
+ else if (inner == null) {
13693
+ inner = await openInner();
13694
+ // We're connected here, so we can tell the core extension about it.
13695
+ return valueResult({
13696
+ command: PowerSyncControlCommand.CONNECTION_STATE,
13697
+ payload: 'established'
13969
13698
  });
13970
- bucketsToDelete.delete(checksum.bucket);
13971
- }
13972
- if (bucketsToDelete.size > 0) {
13973
- this.logger.debug('Removing buckets', [...bucketsToDelete]);
13974
13699
  }
13975
- bucketMap = newBuckets;
13976
- await this.options.adapter.removeBuckets([...bucketsToDelete]);
13977
- await this.options.adapter.setTargetCheckpoint(targetCheckpoint);
13978
- await this.updateSyncStatusForStartingCheckpoint(targetCheckpoint);
13979
- }
13980
- else if (isStreamingSyncCheckpointComplete(line)) {
13981
- const result = await this.applyCheckpoint(targetCheckpoint);
13982
- if (result.endIteration) {
13983
- return;
13984
- }
13985
- else if (!result.applied) {
13986
- // "Could not apply checkpoint due to local data". We need to retry after
13987
- // finishing uploads.
13988
- pendingValidatedCheckpoint = targetCheckpoint;
13989
- }
13990
- else {
13991
- // Nothing to retry later. This would likely already be null from the last
13992
- // checksum or checksum_diff operation, but we make sure.
13993
- pendingValidatedCheckpoint = null;
13994
- }
13995
- }
13996
- else if (isStreamingSyncCheckpointPartiallyComplete(line)) {
13997
- const priority = line.partial_checkpoint_complete.priority;
13998
- this.logger.debug('Partial checkpoint complete', priority);
13999
- const result = await this.options.adapter.syncLocalDatabase(targetCheckpoint, priority);
14000
- if (!result.checkpointValid) {
14001
- // This means checksums failed. Start again with a new checkpoint.
14002
- // TODO: better back-off
14003
- await new Promise((resolve) => setTimeout(resolve, 50));
14004
- return;
14005
- }
14006
- else if (!result.ready) ;
14007
13700
  else {
14008
- // We'll keep on downloading, but can report that this priority is synced now.
14009
- this.logger.debug('partial checkpoint validation succeeded');
14010
- // All states with a higher priority can be deleted since this partial sync includes them.
14011
- const priorityStates = this.syncStatus.priorityStatusEntries.filter((s) => s.priority <= priority);
14012
- priorityStates.push({
14013
- priority,
14014
- lastSyncedAt: new Date(),
14015
- hasSynced: true
14016
- });
14017
- this.updateSyncStatus({
14018
- connected: true,
14019
- priorityStatusEntries: priorityStates
14020
- });
14021
- }
14022
- }
14023
- else if (isStreamingSyncCheckpointDiff(line)) {
14024
- // TODO: It may be faster to just keep track of the diff, instead of the entire checkpoint
14025
- if (targetCheckpoint == null) {
14026
- throw new Error('Checkpoint diff without previous checkpoint');
14027
- }
14028
- // New checkpoint - existing validated checkpoint is no longer valid
14029
- pendingValidatedCheckpoint = null;
14030
- const diff = line.checkpoint_diff;
14031
- const newBuckets = new Map();
14032
- for (const checksum of targetCheckpoint.buckets) {
14033
- newBuckets.set(checksum.bucket, checksum);
14034
- }
14035
- for (const checksum of diff.updated_buckets) {
14036
- newBuckets.set(checksum.bucket, checksum);
14037
- }
14038
- for (const bucket of diff.removed_buckets) {
14039
- newBuckets.delete(bucket);
14040
- }
14041
- const newCheckpoint = {
14042
- last_op_id: diff.last_op_id,
14043
- buckets: [...newBuckets.values()],
14044
- write_checkpoint: diff.write_checkpoint
14045
- };
14046
- targetCheckpoint = newCheckpoint;
14047
- await this.updateSyncStatusForStartingCheckpoint(targetCheckpoint);
14048
- bucketMap = new Map();
14049
- newBuckets.forEach((checksum, name) => bucketMap.set(name, {
14050
- name: checksum.bucket,
14051
- priority: checksum.priority ?? FALLBACK_PRIORITY
14052
- }));
14053
- const bucketsToDelete = diff.removed_buckets;
14054
- if (bucketsToDelete.length > 0) {
14055
- this.logger.debug('Remove buckets', bucketsToDelete);
14056
- }
14057
- await this.options.adapter.removeBuckets(bucketsToDelete);
14058
- await this.options.adapter.setTargetCheckpoint(targetCheckpoint);
14059
- }
14060
- else if (isStreamingSyncData(line)) {
14061
- const { data } = line;
14062
- const previousProgress = this.syncStatus.dataFlowStatus.downloadProgress;
14063
- let updatedProgress = null;
14064
- if (previousProgress) {
14065
- updatedProgress = { ...previousProgress };
14066
- const progressForBucket = updatedProgress[data.bucket];
14067
- if (progressForBucket) {
14068
- updatedProgress[data.bucket] = {
14069
- ...progressForBucket,
14070
- since_last: progressForBucket.since_last + data.data.length
14071
- };
13701
+ const event = await inner.next();
13702
+ if (event.done) {
13703
+ done = true;
13704
+ return valueResult({ command: PowerSyncControlCommand.CONNECTION_STATE, payload: 'end' });
14072
13705
  }
14073
- }
14074
- this.updateSyncStatus({
14075
- dataFlow: {
14076
- downloading: true,
14077
- downloadProgress: updatedProgress
13706
+ else {
13707
+ return valueResult({
13708
+ command: typeof event.value == 'string'
13709
+ ? PowerSyncControlCommand.PROCESS_TEXT_LINE
13710
+ : PowerSyncControlCommand.PROCESS_BSON_LINE,
13711
+ payload: event.value
13712
+ });
14078
13713
  }
14079
- });
14080
- await this.options.adapter.saveSyncData({ buckets: [SyncDataBucket.fromRow(data)] }, usingFixedKeyFormat);
14081
- }
14082
- else if (isStreamingKeepalive(line)) {
14083
- const remaining_seconds = line.token_expires_in;
14084
- if (remaining_seconds == 0) {
14085
- // Connection would be closed automatically right after this
14086
- this.logger.debug('Token expiring; reconnect');
14087
- /**
14088
- * For a rare case where the backend connector does not update the token
14089
- * (uses the same one), this should have some delay.
14090
- */
14091
- await this.delayRetry();
14092
- return;
14093
- }
14094
- else if (remaining_seconds < 30) {
14095
- this.logger.debug('Token will expire soon; reconnect');
14096
- // Pre-emptively refresh the token
14097
- this.options.remote.invalidateCredentials();
14098
- return;
14099
13714
  }
14100
- this.triggerCrudUpload();
14101
- }
14102
- else {
14103
- this.logger.debug('Received unknown sync line', line);
14104
13715
  }
14105
- }
14106
- this.logger.debug('Stream input empty');
14107
- // Connection closed. Likely due to auth issue.
14108
- return;
13716
+ };
14109
13717
  }
14110
13718
  async rustSyncIteration(signal, resolvedOptions) {
14111
13719
  const syncImplementation = this;
14112
13720
  const adapter = this.options.adapter;
14113
13721
  const remote = this.options.remote;
14114
- const controller = new AbortController();
14115
- const abort = () => {
14116
- return controller.abort(signal.reason);
14117
- };
14118
- signal.addEventListener('abort', abort);
14119
- let receivingLines = null;
14120
- let hadSyncLine = false;
14121
13722
  let hideDisconnectOnRestart = false;
13723
+ let notifyTokenRefreshed;
14122
13724
  if (signal.aborted) {
14123
13725
  throw new AbortOperation('Connection request has been aborted');
14124
13726
  }
14125
- // Pending sync lines received from the service, as well as local events that trigger a powersync_control
14126
- // invocation (local events include refreshed tokens and completed uploads).
14127
- // This is a single data stream so that we can handle all control calls from a single place.
14128
- let controlInvocations = null;
14129
- async function connect(instr) {
14130
- const syncOptions = {
14131
- path: '/sync/stream',
14132
- abortSignal: controller.signal,
14133
- data: instr.request
13727
+ function startCommand() {
13728
+ const options = {
13729
+ parameters: resolvedOptions.params,
13730
+ app_metadata: resolvedOptions.appMetadata,
13731
+ active_streams: syncImplementation.activeStreams,
13732
+ include_defaults: resolvedOptions.includeDefaultStreams
14134
13733
  };
14135
- controlInvocations = injectable(map(await syncImplementation.receiveSyncLines({
14136
- options: syncOptions,
14137
- connection: resolvedOptions
14138
- }), (line) => {
14139
- if (typeof line == 'string') {
14140
- return {
14141
- command: PowerSyncControlCommand.PROCESS_TEXT_LINE,
14142
- payload: line
14143
- };
14144
- }
14145
- else {
14146
- return {
14147
- command: PowerSyncControlCommand.PROCESS_BSON_LINE,
14148
- payload: line
14149
- };
14150
- }
14151
- }));
14152
- // The rust client will set connected: true after the first sync line because that's when it gets invoked, but
14153
- // we're already connected here and can report that.
14154
- syncImplementation.updateSyncStatus({ connected: true });
14155
- try {
14156
- while (true) {
14157
- let event = await controlInvocations.next();
14158
- if (event.done) {
14159
- break;
14160
- }
14161
- const line = event.value;
14162
- await control(line.command, line.payload);
14163
- if (!hadSyncLine) {
14164
- syncImplementation.triggerCrudUpload();
14165
- hadSyncLine = true;
14166
- }
14167
- }
14168
- }
14169
- finally {
14170
- abort();
14171
- signal.removeEventListener('abort', abort);
13734
+ if (resolvedOptions.serializedSchema) {
13735
+ options.schema = resolvedOptions.serializedSchema;
14172
13736
  }
13737
+ return invokePowerSyncControl(PowerSyncControlCommand.START, JSON.stringify(options));
14173
13738
  }
14174
13739
  async function stop() {
14175
- await control(PowerSyncControlCommand.STOP);
13740
+ const instructions = await invokePowerSyncControl(PowerSyncControlCommand.STOP);
13741
+ for (const instruction of instructions) {
13742
+ // We don't need to handle interrupting instructions since we're unconditionally ending the sync iteration at
13743
+ // this point.
13744
+ if (isInterruptingInstruction(instruction))
13745
+ continue;
13746
+ await handleInstruction(instruction);
13747
+ }
14176
13748
  }
14177
- async function control(op, payload) {
13749
+ async function invokePowerSyncControl(op, payload) {
14178
13750
  const rawResponse = await adapter.control(op, payload ?? null);
14179
13751
  const logger = syncImplementation.logger;
14180
13752
  logger.trace('powersync_control', op, payload == null || typeof payload == 'string' ? payload : '<bytes>', rawResponse);
14181
- await handleInstructions(JSON.parse(rawResponse));
13753
+ if (op != PowerSyncControlCommand.STOP) {
13754
+ // Evidently we have a working connection here, otherwise powersync_control would have failed.
13755
+ syncImplementation.connectionMayHaveChanged = false;
13756
+ }
13757
+ return JSON.parse(rawResponse);
14182
13758
  }
14183
13759
  async function handleInstruction(instruction) {
14184
13760
  if ('LogLine' in instruction) {
@@ -14197,13 +13773,6 @@ The next upload iteration will be delayed.`);
14197
13773
  else if ('UpdateSyncStatus' in instruction) {
14198
13774
  syncImplementation.updateSyncStatus(coreStatusToJs(instruction.UpdateSyncStatus.status));
14199
13775
  }
14200
- else if ('EstablishSyncStream' in instruction) {
14201
- if (receivingLines != null) {
14202
- // Already connected, this shouldn't happen during a single iteration.
14203
- throw 'Unexpected request to establish sync stream, already connected';
14204
- }
14205
- receivingLines = connect(instruction.EstablishSyncStream);
14206
- }
14207
13776
  else if ('FetchCredentials' in instruction) {
14208
13777
  if (instruction.FetchCredentials.did_expire) {
14209
13778
  remote.invalidateCredentials();
@@ -14212,16 +13781,12 @@ The next upload iteration will be delayed.`);
14212
13781
  remote.invalidateCredentials();
14213
13782
  // Restart iteration after the credentials have been refreshed.
14214
13783
  remote.fetchCredentials().then((_) => {
14215
- controlInvocations?.inject({ command: PowerSyncControlCommand.NOTIFY_TOKEN_REFRESHED });
13784
+ notifyTokenRefreshed?.();
14216
13785
  }, (err) => {
14217
13786
  syncImplementation.logger.warn('Could not prefetch credentials', err);
14218
13787
  });
14219
13788
  }
14220
13789
  }
14221
- else if ('CloseSyncStream' in instruction) {
14222
- controller.abort();
14223
- hideDisconnectOnRestart = instruction.CloseSyncStream.hide_disconnect;
14224
- }
14225
13790
  else if ('FlushFileSystem' in instruction) ;
14226
13791
  else if ('DidCompleteSync' in instruction) {
14227
13792
  syncImplementation.updateSyncStatus({
@@ -14231,101 +13796,83 @@ The next upload iteration will be delayed.`);
14231
13796
  });
14232
13797
  }
14233
13798
  }
14234
- async function handleInstructions(instructions) {
14235
- for (const instr of instructions) {
14236
- await handleInstruction(instr);
14237
- }
14238
- }
14239
13799
  try {
14240
- const options = {
14241
- parameters: resolvedOptions.params,
14242
- app_metadata: resolvedOptions.appMetadata,
14243
- active_streams: this.activeStreams,
14244
- include_defaults: resolvedOptions.includeDefaultStreams
14245
- };
14246
- if (resolvedOptions.serializedSchema) {
14247
- options.schema = resolvedOptions.serializedSchema;
13800
+ const defaultResult = { immediateRestart: false };
13801
+ // Pending sync lines received from the service, as well as local events that trigger a powersync_control
13802
+ // invocation (local events include refreshed tokens and completed uploads).
13803
+ // This is a single data stream so that we can handle all control calls from a single place.
13804
+ let controlInvocations = null;
13805
+ for (const startInstruction of await startCommand()) {
13806
+ if ('EstablishSyncStream' in startInstruction) {
13807
+ const syncOptions = {
13808
+ path: '/sync/stream',
13809
+ abortSignal: signal,
13810
+ data: startInstruction.EstablishSyncStream.request
13811
+ };
13812
+ controlInvocations = injectable(syncImplementation.receiveSyncLines({
13813
+ options: syncOptions,
13814
+ connection: resolvedOptions
13815
+ }));
13816
+ }
13817
+ else if ('CloseSyncStream' in startInstruction) {
13818
+ return defaultResult;
13819
+ }
13820
+ else {
13821
+ await handleInstruction(startInstruction);
13822
+ }
14248
13823
  }
14249
- await control(PowerSyncControlCommand.START, JSON.stringify(options));
13824
+ if (controlInvocations == null)
13825
+ return defaultResult;
14250
13826
  this.notifyCompletedUploads = () => {
14251
- controlInvocations?.inject({ command: PowerSyncControlCommand.NOTIFY_CRUD_UPLOAD_COMPLETED });
13827
+ controlInvocations.inject({ command: PowerSyncControlCommand.NOTIFY_CRUD_UPLOAD_COMPLETED });
14252
13828
  };
14253
13829
  this.handleActiveStreamsChange = () => {
14254
- controlInvocations?.inject({
13830
+ controlInvocations.inject({
14255
13831
  command: PowerSyncControlCommand.UPDATE_SUBSCRIPTIONS,
14256
13832
  payload: JSON.stringify(this.activeStreams)
14257
13833
  });
14258
13834
  };
14259
- await receivingLines;
13835
+ notifyTokenRefreshed = () => {
13836
+ controlInvocations.inject({
13837
+ command: PowerSyncControlCommand.NOTIFY_TOKEN_REFRESHED
13838
+ });
13839
+ };
13840
+ let hadSyncLine = false;
13841
+ loop: while (true) {
13842
+ const { done, value } = await controlInvocations.next();
13843
+ if (done)
13844
+ break;
13845
+ if (!hadSyncLine) {
13846
+ // Trigger a local CRUD upload when the first sync line has been received, this allows uploading local changes
13847
+ // that have been made while offline or disconnected.
13848
+ if (value.command == PowerSyncControlCommand.PROCESS_TEXT_LINE ||
13849
+ value.command == PowerSyncControlCommand.PROCESS_BSON_LINE) {
13850
+ hadSyncLine = true;
13851
+ this.triggerCrudUpload?.();
13852
+ }
13853
+ }
13854
+ const instructions = await invokePowerSyncControl(value.command, value.payload);
13855
+ for (const instruction of instructions) {
13856
+ if ('EstablishSyncStream' in instruction) {
13857
+ throw new Error('Received EstablishSyncStream while already connected.');
13858
+ }
13859
+ else if ('CloseSyncStream' in instruction) {
13860
+ hideDisconnectOnRestart = instruction.CloseSyncStream.hide_disconnect;
13861
+ break loop;
13862
+ }
13863
+ else {
13864
+ await handleInstruction(instruction);
13865
+ }
13866
+ }
13867
+ }
14260
13868
  }
14261
13869
  finally {
14262
13870
  this.notifyCompletedUploads = this.handleActiveStreamsChange = undefined;
13871
+ notifyTokenRefreshed = undefined;
14263
13872
  await stop();
14264
13873
  }
14265
13874
  return { immediateRestart: hideDisconnectOnRestart };
14266
13875
  }
14267
- async updateSyncStatusForStartingCheckpoint(checkpoint) {
14268
- const localProgress = await this.options.adapter.getBucketOperationProgress();
14269
- const progress = {};
14270
- let invalidated = false;
14271
- for (const bucket of checkpoint.buckets) {
14272
- const savedProgress = localProgress[bucket.bucket];
14273
- const atLast = savedProgress?.atLast ?? 0;
14274
- const sinceLast = savedProgress?.sinceLast ?? 0;
14275
- progress[bucket.bucket] = {
14276
- // The fallback priority doesn't matter here, but 3 is the one newer versions of the sync service
14277
- // will use by default.
14278
- priority: bucket.priority ?? 3,
14279
- at_last: atLast,
14280
- since_last: sinceLast,
14281
- target_count: bucket.count ?? 0
14282
- };
14283
- if (bucket.count != null && bucket.count < atLast + sinceLast) {
14284
- // Either due to a defrag / sync rule deploy or a compaction operation, the size
14285
- // of the bucket shrank so much that the local ops exceed the ops in the updated
14286
- // bucket. We can't prossibly report progress in this case (it would overshoot 100%).
14287
- invalidated = true;
14288
- }
14289
- }
14290
- if (invalidated) {
14291
- for (const bucket in progress) {
14292
- const bucketProgress = progress[bucket];
14293
- bucketProgress.at_last = 0;
14294
- bucketProgress.since_last = 0;
14295
- }
14296
- }
14297
- this.updateSyncStatus({
14298
- dataFlow: {
14299
- downloading: true,
14300
- downloadProgress: progress
14301
- }
14302
- });
14303
- }
14304
- async applyCheckpoint(checkpoint) {
14305
- let result = await this.options.adapter.syncLocalDatabase(checkpoint);
14306
- if (!result.checkpointValid) {
14307
- this.logger.debug(`Checksum mismatch in checkpoint ${checkpoint.last_op_id}, will reconnect`);
14308
- // This means checksums failed. Start again with a new checkpoint.
14309
- // TODO: better back-off
14310
- await new Promise((resolve) => setTimeout(resolve, 50));
14311
- return { applied: false, endIteration: true };
14312
- }
14313
- else if (!result.ready) {
14314
- this.logger.debug(`Could not apply checkpoint ${checkpoint.last_op_id} due to local data. We will retry applying the checkpoint after that upload is completed.`);
14315
- return { applied: false, endIteration: false };
14316
- }
14317
- this.logger.debug(`Applied checkpoint ${checkpoint.last_op_id}`, checkpoint);
14318
- this.updateSyncStatus({
14319
- connected: true,
14320
- lastSyncedAt: new Date(),
14321
- dataFlow: {
14322
- downloading: false,
14323
- downloadProgress: null,
14324
- downloadError: undefined
14325
- }
14326
- });
14327
- return { applied: true, endIteration: false };
14328
- }
14329
13876
  updateSyncStatus(options) {
14330
13877
  const updatedStatus = new SyncStatus({
14331
13878
  connected: options.connected ?? this.syncStatus.connected,
@@ -15864,14 +15411,12 @@ class SqliteBucketStorage extends BaseObserver {
15864
15411
  db;
15865
15412
  logger;
15866
15413
  tableNames;
15867
- _hasCompletedSync;
15868
15414
  updateListener;
15869
15415
  _clientId;
15870
15416
  constructor(db, logger = Logger.get('SqliteBucketStorage')) {
15871
15417
  super();
15872
15418
  this.db = db;
15873
15419
  this.logger = logger;
15874
- this._hasCompletedSync = false;
15875
15420
  this.tableNames = new Set();
15876
15421
  this.updateListener = db.registerListener({
15877
15422
  tablesUpdated: (update) => {
@@ -15883,7 +15428,6 @@ class SqliteBucketStorage extends BaseObserver {
15883
15428
  });
15884
15429
  }
15885
15430
  async init() {
15886
- this._hasCompletedSync = false;
15887
15431
  const existingTableRows = await this.db.getAll(`SELECT name FROM sqlite_master WHERE type='table' AND name GLOB 'ps_data_*'`);
15888
15432
  for (const row of existingTableRows ?? []) {
15889
15433
  this.tableNames.add(row.name);
@@ -15905,156 +15449,6 @@ class SqliteBucketStorage extends BaseObserver {
15905
15449
  getMaxOpId() {
15906
15450
  return MAX_OP_ID;
15907
15451
  }
15908
- /**
15909
- * Reset any caches.
15910
- */
15911
- startSession() { }
15912
- async getBucketStates() {
15913
- const result = await this.db.getAll("SELECT name as bucket, cast(last_op as TEXT) as op_id FROM ps_buckets WHERE pending_delete = 0 AND name != '$local'");
15914
- return result;
15915
- }
15916
- async getBucketOperationProgress() {
15917
- const rows = await this.db.getAll('SELECT name, count_at_last, count_since_last FROM ps_buckets');
15918
- return Object.fromEntries(rows.map((r) => [r.name, { atLast: r.count_at_last, sinceLast: r.count_since_last }]));
15919
- }
15920
- async saveSyncData(batch, fixedKeyFormat = false) {
15921
- await this.writeTransaction(async (tx) => {
15922
- for (const b of batch.buckets) {
15923
- await tx.execute('INSERT INTO powersync_operations(op, data) VALUES(?, ?)', [
15924
- 'save',
15925
- JSON.stringify({ buckets: [b.toJSON(fixedKeyFormat)] })
15926
- ]);
15927
- this.logger.debug(`Saved batch of data for bucket: ${b.bucket}, operations: ${b.data.length}`);
15928
- }
15929
- });
15930
- }
15931
- async removeBuckets(buckets) {
15932
- for (const bucket of buckets) {
15933
- await this.deleteBucket(bucket);
15934
- }
15935
- }
15936
- /**
15937
- * Mark a bucket for deletion.
15938
- */
15939
- async deleteBucket(bucket) {
15940
- await this.writeTransaction(async (tx) => {
15941
- await tx.execute('INSERT INTO powersync_operations(op, data) VALUES(?, ?)', ['delete_bucket', bucket]);
15942
- });
15943
- this.logger.debug(`Done deleting bucket ${bucket}`);
15944
- }
15945
- async hasCompletedSync() {
15946
- if (this._hasCompletedSync) {
15947
- return true;
15948
- }
15949
- const r = await this.db.get(`SELECT powersync_last_synced_at() as synced_at`);
15950
- const completed = r.synced_at != null;
15951
- if (completed) {
15952
- this._hasCompletedSync = true;
15953
- }
15954
- return completed;
15955
- }
15956
- async syncLocalDatabase(checkpoint, priority) {
15957
- const r = await this.validateChecksums(checkpoint, priority);
15958
- if (!r.checkpointValid) {
15959
- this.logger.error('Checksums failed for', r.checkpointFailures);
15960
- for (const b of r.checkpointFailures ?? []) {
15961
- await this.deleteBucket(b);
15962
- }
15963
- return { ready: false, checkpointValid: false, checkpointFailures: r.checkpointFailures };
15964
- }
15965
- if (priority == null) {
15966
- this.logger.debug(`Validated checksums checkpoint ${checkpoint.last_op_id}`);
15967
- }
15968
- else {
15969
- this.logger.debug(`Validated checksums for partial checkpoint ${checkpoint.last_op_id}, priority ${priority}`);
15970
- }
15971
- let buckets = checkpoint.buckets;
15972
- if (priority !== undefined) {
15973
- buckets = buckets.filter((b) => hasMatchingPriority(priority, b));
15974
- }
15975
- const bucketNames = buckets.map((b) => b.bucket);
15976
- await this.writeTransaction(async (tx) => {
15977
- await tx.execute(`UPDATE ps_buckets SET last_op = ? WHERE name IN (SELECT json_each.value FROM json_each(?))`, [
15978
- checkpoint.last_op_id,
15979
- JSON.stringify(bucketNames)
15980
- ]);
15981
- if (priority == null && checkpoint.write_checkpoint) {
15982
- await tx.execute("UPDATE ps_buckets SET last_op = ? WHERE name = '$local'", [checkpoint.write_checkpoint]);
15983
- }
15984
- });
15985
- const valid = await this.updateObjectsFromBuckets(checkpoint, priority);
15986
- if (!valid) {
15987
- return { ready: false, checkpointValid: true };
15988
- }
15989
- return {
15990
- ready: true,
15991
- checkpointValid: true
15992
- };
15993
- }
15994
- /**
15995
- * Atomically update the local state to the current checkpoint.
15996
- *
15997
- * This includes creating new tables, dropping old tables, and copying data over from the oplog.
15998
- */
15999
- async updateObjectsFromBuckets(checkpoint, priority) {
16000
- let arg = '';
16001
- if (priority !== undefined) {
16002
- const affectedBuckets = [];
16003
- for (const desc of checkpoint.buckets) {
16004
- if (hasMatchingPriority(priority, desc)) {
16005
- affectedBuckets.push(desc.bucket);
16006
- }
16007
- }
16008
- arg = JSON.stringify({ priority, buckets: affectedBuckets });
16009
- }
16010
- return this.writeTransaction(async (tx) => {
16011
- const { insertId: result } = await tx.execute('INSERT INTO powersync_operations(op, data) VALUES(?, ?)', [
16012
- 'sync_local',
16013
- arg
16014
- ]);
16015
- if (result == 1) {
16016
- if (priority == null) {
16017
- const bucketToCount = Object.fromEntries(checkpoint.buckets.map((b) => [b.bucket, b.count]));
16018
- // The two parameters could be replaced with one, but: https://github.com/powersync-ja/better-sqlite3/pull/6
16019
- const jsonBucketCount = JSON.stringify(bucketToCount);
16020
- await tx.execute("UPDATE ps_buckets SET count_since_last = 0, count_at_last = ?->name WHERE name != '$local' AND ?->name IS NOT NULL", [jsonBucketCount, jsonBucketCount]);
16021
- }
16022
- return true;
16023
- }
16024
- else {
16025
- return false;
16026
- }
16027
- });
16028
- }
16029
- async validateChecksums(checkpoint, priority) {
16030
- if (priority !== undefined) {
16031
- // Only validate the buckets within the priority we care about
16032
- const newBuckets = checkpoint.buckets.filter((cs) => hasMatchingPriority(priority, cs));
16033
- checkpoint = { ...checkpoint, buckets: newBuckets };
16034
- }
16035
- const rs = await this.db.execute('SELECT powersync_validate_checkpoint(?) as result', [
16036
- JSON.stringify({ ...checkpoint })
16037
- ]);
16038
- const resultItem = rs.rows?.item(0);
16039
- if (!resultItem) {
16040
- return {
16041
- checkpointValid: false,
16042
- ready: false,
16043
- checkpointFailures: []
16044
- };
16045
- }
16046
- const result = JSON.parse(resultItem['result']);
16047
- if (result['valid']) {
16048
- return { ready: true, checkpointValid: true };
16049
- }
16050
- else {
16051
- return {
16052
- checkpointValid: false,
16053
- ready: false,
16054
- checkpointFailures: result['failed_buckets']
16055
- };
16056
- }
16057
- }
16058
15452
  async updateLocalTarget(cb) {
16059
15453
  const rs1 = await this.db.getAll("SELECT target_op FROM ps_buckets WHERE name = '$local' AND target_op = CAST(? as INTEGER)", [MAX_OP_ID]);
16060
15454
  if (!rs1.length) {
@@ -16145,12 +15539,6 @@ class SqliteBucketStorage extends BaseObserver {
16145
15539
  async writeTransaction(callback, options) {
16146
15540
  return this.db.writeTransaction(callback, options);
16147
15541
  }
16148
- /**
16149
- * Set a target checkpoint.
16150
- */
16151
- async setTargetCheckpoint(checkpoint) {
16152
- // No-op for now
16153
- }
16154
15542
  async control(op, payload) {
16155
15543
  return await this.writeTransaction(async (tx) => {
16156
15544
  const [[raw]] = await tx.executeRaw('SELECT powersync_control(?, ?)', [op, payload]);
@@ -16174,20 +15562,6 @@ class SqliteBucketStorage extends BaseObserver {
16174
15562
  }
16175
15563
  static _subkeyMigrationKey = 'powersync_js_migrated_subkeys';
16176
15564
  }
16177
- function hasMatchingPriority(priority, bucket) {
16178
- return bucket.priority != null && bucket.priority <= priority;
16179
- }
16180
-
16181
- // TODO JSON
16182
- class SyncDataBatch {
16183
- buckets;
16184
- static fromJSON(json) {
16185
- return new SyncDataBatch(json.buckets.map((bucket) => SyncDataBucket.fromRow(bucket)));
16186
- }
16187
- constructor(buckets) {
16188
- this.buckets = buckets;
16189
- }
16190
- }
16191
15565
 
16192
15566
  /**
16193
15567
  * Thrown when an underlying database connection is closed.
@@ -16247,10 +15621,8 @@ class Schema {
16247
15621
  * developer instead of automatically by PowerSync.
16248
15622
  * Since raw tables are not backed by JSON, running complex queries on them may be more efficient. Further, they allow
16249
15623
  * using client-side table and column constraints.
16250
- * Note that raw tables are only supported when using the new `SyncClientImplementation.rust` sync client.
16251
15624
  *
16252
15625
  * @param tables An object of (table name, raw table definition) entries.
16253
- * @experimental Note that the raw tables API is still experimental and may change in the future.
16254
15626
  */
16255
15627
  withRawTables(tables) {
16256
15628
  for (const [name, rawTableDefinition] of Object.entries(tables)) {
@@ -16485,9 +15857,6 @@ const parseQuery = (query, parameters) => {
16485
15857
  /******/ return module.exports;
16486
15858
  /******/ }
16487
15859
  /******/
16488
- /******/ // expose the modules object (__webpack_modules__)
16489
- /******/ __webpack_require__.m = __webpack_modules__;
16490
- /******/
16491
15860
  /************************************************************************/
16492
15861
  /******/ /* webpack/runtime/define property getters */
16493
15862
  /******/ (() => {
@@ -16501,40 +15870,6 @@ const parseQuery = (query, parameters) => {
16501
15870
  /******/ };
16502
15871
  /******/ })();
16503
15872
  /******/
16504
- /******/ /* webpack/runtime/ensure chunk */
16505
- /******/ (() => {
16506
- /******/ __webpack_require__.f = {};
16507
- /******/ // This file contains only the entry chunk.
16508
- /******/ // The chunk loading function for additional chunks
16509
- /******/ __webpack_require__.e = (chunkId) => {
16510
- /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
16511
- /******/ __webpack_require__.f[key](chunkId, promises);
16512
- /******/ return promises;
16513
- /******/ }, []));
16514
- /******/ };
16515
- /******/ })();
16516
- /******/
16517
- /******/ /* webpack/runtime/get javascript chunk filename */
16518
- /******/ (() => {
16519
- /******/ // This function allow to reference async chunks
16520
- /******/ __webpack_require__.u = (chunkId) => {
16521
- /******/ // return url for filenames based on template
16522
- /******/ return "worker/" + chunkId + ".umd.js";
16523
- /******/ };
16524
- /******/ })();
16525
- /******/
16526
- /******/ /* webpack/runtime/global */
16527
- /******/ (() => {
16528
- /******/ __webpack_require__.g = (function() {
16529
- /******/ if (typeof globalThis === 'object') return globalThis;
16530
- /******/ try {
16531
- /******/ return this || new Function('return this')();
16532
- /******/ } catch (e) {
16533
- /******/ if (typeof window === 'object') return window;
16534
- /******/ }
16535
- /******/ })();
16536
- /******/ })();
16537
- /******/
16538
15873
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
16539
15874
  /******/ (() => {
16540
15875
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
@@ -16551,70 +15886,6 @@ const parseQuery = (query, parameters) => {
16551
15886
  /******/ };
16552
15887
  /******/ })();
16553
15888
  /******/
16554
- /******/ /* webpack/runtime/publicPath */
16555
- /******/ (() => {
16556
- /******/ var scriptUrl;
16557
- /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
16558
- /******/ var document = __webpack_require__.g.document;
16559
- /******/ if (!scriptUrl && document) {
16560
- /******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
16561
- /******/ scriptUrl = document.currentScript.src;
16562
- /******/ if (!scriptUrl) {
16563
- /******/ var scripts = document.getElementsByTagName("script");
16564
- /******/ if(scripts.length) {
16565
- /******/ var i = scripts.length - 1;
16566
- /******/ while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
16567
- /******/ }
16568
- /******/ }
16569
- /******/ }
16570
- /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
16571
- /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
16572
- /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
16573
- /******/ scriptUrl = scriptUrl.replace(/^blob:/, "").replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
16574
- /******/ __webpack_require__.p = scriptUrl + "../";
16575
- /******/ })();
16576
- /******/
16577
- /******/ /* webpack/runtime/importScripts chunk loading */
16578
- /******/ (() => {
16579
- /******/ // no baseURI
16580
- /******/
16581
- /******/ // object to store loaded chunks
16582
- /******/ // "1" means "already loaded"
16583
- /******/ var installedChunks = {
16584
- /******/ "SharedSyncImplementation": 1
16585
- /******/ };
16586
- /******/
16587
- /******/ // importScripts chunk loading
16588
- /******/ var installChunk = (data) => {
16589
- /******/ var [chunkIds, moreModules, runtime] = data;
16590
- /******/ for(var moduleId in moreModules) {
16591
- /******/ if(__webpack_require__.o(moreModules, moduleId)) {
16592
- /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
16593
- /******/ }
16594
- /******/ }
16595
- /******/ if(runtime) runtime(__webpack_require__);
16596
- /******/ while(chunkIds.length)
16597
- /******/ installedChunks[chunkIds.pop()] = 1;
16598
- /******/ parentChunkLoadingFunction(data);
16599
- /******/ };
16600
- /******/ __webpack_require__.f.i = (chunkId, promises) => {
16601
- /******/ // "1" is the signal for "already loaded"
16602
- /******/ if(!installedChunks[chunkId]) {
16603
- /******/ if(true) { // all chunks have JS
16604
- /******/ importScripts(__webpack_require__.p + __webpack_require__.u(chunkId));
16605
- /******/ }
16606
- /******/ }
16607
- /******/ };
16608
- /******/
16609
- /******/ var chunkLoadingGlobal = self["webpackChunksdk_web"] = self["webpackChunksdk_web"] || [];
16610
- /******/ var parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);
16611
- /******/ chunkLoadingGlobal.push = installChunk;
16612
- /******/
16613
- /******/ // no HMR
16614
- /******/
16615
- /******/ // no HMR manifest
16616
- /******/ })();
16617
- /******/
16618
15889
  /************************************************************************/
16619
15890
  var __webpack_exports__ = {};
16620
15891
  // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.