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
  *
@@ -4060,13 +4060,13 @@ function MessagesFromServerConsumer(db) {
4060
4060
  //triggerSync(db, 'pull');
4061
4061
  yield db.cloud.sync({ purpose: 'pull', wait: true });
4062
4062
  break;
4063
- case 'changes':
4063
+ case 'changes': {
4064
4064
  console.debug('changes');
4065
4065
  if (((_f = db.cloud.syncState.value) === null || _f === void 0 ? void 0 : _f.phase) === 'error') {
4066
4066
  triggerSync(db, 'pull');
4067
4067
  break;
4068
4068
  }
4069
- yield db.transaction('rw', db.dx.tables, (tx) => __awaiter(this, void 0, void 0, function* () {
4069
+ const didApplyChanges = yield db.transaction('rw', db.dx.tables, (tx) => __awaiter(this, void 0, void 0, function* () {
4070
4070
  // @ts-ignore
4071
4071
  tx.idbtrans.disableChangeTracking = true;
4072
4072
  // @ts-ignore
@@ -4083,7 +4083,7 @@ function MessagesFromServerConsumer(db) {
4083
4083
  schema,
4084
4084
  currentUser,
4085
4085
  });
4086
- return; // Initial sync must have taken place - otherwise, ignore this.
4086
+ return false; // Initial sync must have taken place - otherwise, ignore this.
4087
4087
  }
4088
4088
  // Verify again in ACID tx that we're on same server revision.
4089
4089
  if (msg.baseRev !== syncState.serverRevision) {
@@ -4104,7 +4104,7 @@ function MessagesFromServerConsumer(db) {
4104
4104
  // If we don't do a sync request now, we could stuck in an endless loop.
4105
4105
  triggerSync(db, 'pull');
4106
4106
  }
4107
- return; // Ignore message
4107
+ return false; // Ignore message
4108
4108
  }
4109
4109
  // Verify also that the message is based on the exact same set of realms
4110
4110
  const ourRealmSetHash = yield Dexie.waitFor(
@@ -4116,7 +4116,7 @@ function MessagesFromServerConsumer(db) {
4116
4116
  triggerSync(db, 'pull');
4117
4117
  // The message isn't based on the same realms.
4118
4118
  // Trigger a sync instead to resolve all things up.
4119
- return;
4119
+ return false;
4120
4120
  }
4121
4121
  // Get clientChanges
4122
4122
  let clientChanges = [];
@@ -4146,9 +4146,17 @@ function MessagesFromServerConsumer(db) {
4146
4146
  //
4147
4147
  console.debug('Updating syncState', syncState);
4148
4148
  yield db.$syncState.put(syncState, 'syncState');
4149
+ return true;
4149
4150
  }));
4150
4151
  console.debug('msg queue: done with rw transaction');
4152
+ // Trigger eager blob download for any BlobRefs received via WebSocket.
4153
+ // This mirrors the behavior after normal HTTP sync (syncCompleteEvent).
4154
+ // Only emit if changes were actually applied (not on early returns).
4155
+ if (didApplyChanges && msg.changes.length > 0) {
4156
+ db.syncCompleteEvent.next();
4157
+ }
4151
4158
  break;
4159
+ }
4152
4160
  }
4153
4161
  }
4154
4162
  catch (error) {
@@ -5920,7 +5928,7 @@ function createBlobResolveMiddleware(db) {
5920
5928
  return {
5921
5929
  stack: 'dbcore',
5922
5930
  name: 'blobResolve',
5923
- level: -2, // Run below other middlewares and after sync and caching middlewares
5931
+ level: 2, // Run above cache (0) and other middlewares (1) to resolve BlobRefs from cached data
5924
5932
  create(downlevelDatabase) {
5925
5933
  // Create a single queue instance for this database
5926
5934
  const blobSavingQueue = new BlobSavingQueue(db);
@@ -6497,7 +6505,7 @@ class WSConnection extends Subscription {
6497
6505
  const searchParams = new URLSearchParams();
6498
6506
  if (this.subscriber.closed)
6499
6507
  return;
6500
- searchParams.set('v', '2');
6508
+ searchParams.set('v', '3'); // v3 = supports BlobRef (blob offloading)
6501
6509
  if (this.rev)
6502
6510
  searchParams.set('rev', this.rev);
6503
6511
  if (this.yrev)
@@ -8094,7 +8102,7 @@ function dexieCloud(dexie) {
8094
8102
  const downloading$ = createDownloadingState();
8095
8103
  dexie.cloud = {
8096
8104
  // @ts-ignore
8097
- version: "4.4.1",
8105
+ version: "4.4.3",
8098
8106
  options: Object.assign({}, DEFAULT_OPTIONS),
8099
8107
  schema: null,
8100
8108
  get currentUserId() {
@@ -8123,14 +8131,17 @@ function dexieCloud(dexie) {
8123
8131
  roles: getGlobalRolesObservable(dexie),
8124
8132
  configure(options) {
8125
8133
  // Validate maxStringLength — Infinity disables offloading, otherwise must be
8126
- // a finite positive number not exceeding the server limit (32768).
8134
+ // a finite number between 100 and the server limit (32768).
8135
+ // Minimum 100 prevents accidental offloading of primary keys and short strings
8136
+ // that would break sync.
8137
+ const MIN_STRING_LENGTH = 100;
8127
8138
  const MAX_SERVER_STRING_LENGTH = 32768;
8128
8139
  if (options.maxStringLength !== undefined &&
8129
8140
  options.maxStringLength !== Infinity &&
8130
8141
  (!Number.isFinite(options.maxStringLength) ||
8131
- options.maxStringLength < 0 ||
8142
+ options.maxStringLength < MIN_STRING_LENGTH ||
8132
8143
  options.maxStringLength > MAX_SERVER_STRING_LENGTH)) {
8133
- throw new Error(`maxStringLength must be Infinity or a finite number in [0, ${MAX_SERVER_STRING_LENGTH}]. Got: ${options.maxStringLength}`);
8144
+ throw new Error(`maxStringLength must be Infinity or a finite number in [${MIN_STRING_LENGTH}, ${MAX_SERVER_STRING_LENGTH}]. Got: ${options.maxStringLength}`);
8134
8145
  }
8135
8146
  options = dexie.cloud.options = Object.assign(Object.assign({}, dexie.cloud.options), options);
8136
8147
  configuredProgramatically = true;
@@ -8518,7 +8529,7 @@ function dexieCloud(dexie) {
8518
8529
  }
8519
8530
  }
8520
8531
  // @ts-ignore
8521
- dexieCloud.version = "4.4.1";
8532
+ dexieCloud.version = "4.4.3";
8522
8533
  Dexie.Cloud = dexieCloud;
8523
8534
 
8524
8535
  // In case the SW lives for a while, let it reuse already opened connections: