dexie-cloud-addon 4.4.1 → 4.4.3

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.
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ==========================================================================
10
10
  *
11
- * Version 4.4.1, Thu Mar 19 2026
11
+ * Version 4.4.3, Sat Mar 21 2026
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -13558,7 +13558,7 @@
13558
13558
  *
13559
13559
  * ==========================================================================
13560
13560
  *
13561
- * Version 4.4.0, Thu Mar 19 2026
13561
+ * Version 4.4.0, Sat Mar 21 2026
13562
13562
  *
13563
13563
  * https://dexie.org
13564
13564
  *
@@ -15028,13 +15028,13 @@
15028
15028
  //triggerSync(db, 'pull');
15029
15029
  yield db.cloud.sync({ purpose: 'pull', wait: true });
15030
15030
  break;
15031
- case 'changes':
15031
+ case 'changes': {
15032
15032
  console.debug('changes');
15033
15033
  if (((_f = db.cloud.syncState.value) === null || _f === void 0 ? void 0 : _f.phase) === 'error') {
15034
15034
  triggerSync(db, 'pull');
15035
15035
  break;
15036
15036
  }
15037
- yield db.transaction('rw', db.dx.tables, (tx) => __awaiter(this, void 0, void 0, function* () {
15037
+ const didApplyChanges = yield db.transaction('rw', db.dx.tables, (tx) => __awaiter(this, void 0, void 0, function* () {
15038
15038
  // @ts-ignore
15039
15039
  tx.idbtrans.disableChangeTracking = true;
15040
15040
  // @ts-ignore
@@ -15051,7 +15051,7 @@
15051
15051
  schema,
15052
15052
  currentUser,
15053
15053
  });
15054
- return; // Initial sync must have taken place - otherwise, ignore this.
15054
+ return false; // Initial sync must have taken place - otherwise, ignore this.
15055
15055
  }
15056
15056
  // Verify again in ACID tx that we're on same server revision.
15057
15057
  if (msg.baseRev !== syncState.serverRevision) {
@@ -15072,7 +15072,7 @@
15072
15072
  // If we don't do a sync request now, we could stuck in an endless loop.
15073
15073
  triggerSync(db, 'pull');
15074
15074
  }
15075
- return; // Ignore message
15075
+ return false; // Ignore message
15076
15076
  }
15077
15077
  // Verify also that the message is based on the exact same set of realms
15078
15078
  const ourRealmSetHash = yield Dexie.waitFor(
@@ -15084,7 +15084,7 @@
15084
15084
  triggerSync(db, 'pull');
15085
15085
  // The message isn't based on the same realms.
15086
15086
  // Trigger a sync instead to resolve all things up.
15087
- return;
15087
+ return false;
15088
15088
  }
15089
15089
  // Get clientChanges
15090
15090
  let clientChanges = [];
@@ -15114,9 +15114,17 @@
15114
15114
  //
15115
15115
  console.debug('Updating syncState', syncState);
15116
15116
  yield db.$syncState.put(syncState, 'syncState');
15117
+ return true;
15117
15118
  }));
15118
15119
  console.debug('msg queue: done with rw transaction');
15120
+ // Trigger eager blob download for any BlobRefs received via WebSocket.
15121
+ // This mirrors the behavior after normal HTTP sync (syncCompleteEvent).
15122
+ // Only emit if changes were actually applied (not on early returns).
15123
+ if (didApplyChanges && msg.changes.length > 0) {
15124
+ db.syncCompleteEvent.next();
15125
+ }
15119
15126
  break;
15127
+ }
15120
15128
  }
15121
15129
  }
15122
15130
  catch (error) {
@@ -16888,7 +16896,7 @@
16888
16896
  return {
16889
16897
  stack: 'dbcore',
16890
16898
  name: 'blobResolve',
16891
- level: -2, // Run below other middlewares and after sync and caching middlewares
16899
+ level: 2, // Run above cache (0) and other middlewares (1) to resolve BlobRefs from cached data
16892
16900
  create(downlevelDatabase) {
16893
16901
  // Create a single queue instance for this database
16894
16902
  const blobSavingQueue = new BlobSavingQueue(db);
@@ -17727,7 +17735,7 @@
17727
17735
  const searchParams = new URLSearchParams();
17728
17736
  if (this.subscriber.closed)
17729
17737
  return;
17730
- searchParams.set('v', '2');
17738
+ searchParams.set('v', '3'); // v3 = supports BlobRef (blob offloading)
17731
17739
  if (this.rev)
17732
17740
  searchParams.set('rev', this.rev);
17733
17741
  if (this.yrev)
@@ -19324,7 +19332,7 @@
19324
19332
  const downloading$ = createDownloadingState();
19325
19333
  dexie.cloud = {
19326
19334
  // @ts-ignore
19327
- version: "4.4.1",
19335
+ version: "4.4.3",
19328
19336
  options: Object.assign({}, DEFAULT_OPTIONS),
19329
19337
  schema: null,
19330
19338
  get currentUserId() {
@@ -19353,14 +19361,17 @@
19353
19361
  roles: getGlobalRolesObservable(dexie),
19354
19362
  configure(options) {
19355
19363
  // Validate maxStringLength — Infinity disables offloading, otherwise must be
19356
- // a finite positive number not exceeding the server limit (32768).
19364
+ // a finite number between 100 and the server limit (32768).
19365
+ // Minimum 100 prevents accidental offloading of primary keys and short strings
19366
+ // that would break sync.
19367
+ const MIN_STRING_LENGTH = 100;
19357
19368
  const MAX_SERVER_STRING_LENGTH = 32768;
19358
19369
  if (options.maxStringLength !== undefined &&
19359
19370
  options.maxStringLength !== Infinity &&
19360
19371
  (!Number.isFinite(options.maxStringLength) ||
19361
- options.maxStringLength < 0 ||
19372
+ options.maxStringLength < MIN_STRING_LENGTH ||
19362
19373
  options.maxStringLength > MAX_SERVER_STRING_LENGTH)) {
19363
- throw new Error(`maxStringLength must be Infinity or a finite number in [0, ${MAX_SERVER_STRING_LENGTH}]. Got: ${options.maxStringLength}`);
19374
+ throw new Error(`maxStringLength must be Infinity or a finite number in [${MIN_STRING_LENGTH}, ${MAX_SERVER_STRING_LENGTH}]. Got: ${options.maxStringLength}`);
19364
19375
  }
19365
19376
  options = dexie.cloud.options = Object.assign(Object.assign({}, dexie.cloud.options), options);
19366
19377
  configuredProgramatically = true;
@@ -19748,7 +19759,7 @@
19748
19759
  }
19749
19760
  }
19750
19761
  // @ts-ignore
19751
- dexieCloud.version = "4.4.1";
19762
+ dexieCloud.version = "4.4.3";
19752
19763
  Dexie.Cloud = dexieCloud;
19753
19764
 
19754
19765
  // In case the SW lives for a while, let it reuse already opened connections: