dexie-cloud-addon 4.0.1-beta.58 → 4.0.1-rc.2

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.0.1-beta.58, Tue Feb 20 2024
11
+ * Version 4.0.1-rc.2, Wed Mar 20 2024
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -53,6 +53,18 @@
53
53
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
54
54
  }
55
55
 
56
+ function __rest(s, e) {
57
+ var t = {};
58
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
59
+ t[p] = s[p];
60
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
61
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
62
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
63
+ t[p[i]] = s[p[i]];
64
+ }
65
+ return t;
66
+ }
67
+
56
68
  function __awaiter(thisArg, _arguments, P, generator) {
57
69
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
58
70
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -3164,7 +3176,7 @@
3164
3176
  this.v = value;
3165
3177
  }
3166
3178
  }
3167
- const defs = Object.assign(Object.assign({}, undefinedDef), (hasBigIntSupport
3179
+ const defs = Object.assign(Object.assign(Object.assign({}, undefinedDef), (hasBigIntSupport
3168
3180
  ? {}
3169
3181
  : {
3170
3182
  bigint: {
@@ -3174,7 +3186,16 @@
3174
3186
  },
3175
3187
  revive: ({ v, }) => new FakeBigInt(v)
3176
3188
  }
3177
- }));
3189
+ })), { PropModification: {
3190
+ test: (val) => val instanceof Dexie.PropModification,
3191
+ replace: (propModification) => {
3192
+ return Object.assign({ $t: 'PropModification' }, propModification);
3193
+ },
3194
+ revive: (_a) => {
3195
+ var propModification = __rest(_a, ["$t"]);
3196
+ return new Dexie.PropModification(propModification);
3197
+ }
3198
+ } });
3178
3199
  const TSON = TypesonSimplified(builtin, defs);
3179
3200
  const BISON = Bison(defs);
3180
3201
 
@@ -4394,16 +4415,11 @@
4394
4415
  const origUserId = currentUser.userId;
4395
4416
  if (currentUser.isLoggedIn && (!hints || (!hints.email && !hints.userId))) {
4396
4417
  const licenseStatus = ((_a = currentUser.license) === null || _a === void 0 ? void 0 : _a.status) || 'ok';
4397
- if (licenseStatus === 'ok' &&
4398
- currentUser.accessToken &&
4399
- (!currentUser.accessTokenExpiration ||
4400
- currentUser.accessTokenExpiration.getTime() > Date.now())) {
4418
+ if (licenseStatus === 'ok' && currentUser.accessToken && (!currentUser.accessTokenExpiration || currentUser.accessTokenExpiration.getTime() > Date.now())) {
4401
4419
  // Already authenticated according to given hints. And license is valid.
4402
4420
  return false;
4403
4421
  }
4404
- if (currentUser.refreshToken &&
4405
- (!currentUser.refreshTokenExpiration ||
4406
- currentUser.refreshTokenExpiration.getTime() > Date.now())) {
4422
+ if (currentUser.refreshToken && (!currentUser.refreshTokenExpiration || currentUser.refreshTokenExpiration.getTime() > Date.now())) {
4407
4423
  // Refresh the token
4408
4424
  yield loadAccessToken(db);
4409
4425
  return false;
@@ -4415,8 +4431,7 @@
4415
4431
  lastLogin: new Date(0),
4416
4432
  });
4417
4433
  yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
4418
- if (origUserId !== UNAUTHORIZED_USER.userId &&
4419
- context.userId !== origUserId) {
4434
+ if (origUserId !== UNAUTHORIZED_USER.userId && context.userId !== origUserId) {
4420
4435
  // User was logged in before, but now logged in as another user.
4421
4436
  yield logout(db);
4422
4437
  }
@@ -4435,7 +4450,7 @@
4435
4450
  yield setCurrentUser(db, context);
4436
4451
  // Make sure to resync as the new login will be authorized
4437
4452
  // for new realms.
4438
- triggerSync(db, 'pull');
4453
+ triggerSync(db, "pull");
4439
4454
  return context.userId !== origUserId;
4440
4455
  });
4441
4456
  }
@@ -5418,10 +5433,11 @@
5418
5433
  }
5419
5434
  return new rxjs.BehaviorSubject([userLogin, syncState]);
5420
5435
  }), switchMap(([userLogin, syncState]) => __awaiter(this, void 0, void 0, function* () { return [userLogin, yield computeRealmSetHash(syncState)]; })), distinctUntilChanged(([prevUser, prevHash], [currUser, currHash]) => prevUser === currUser && prevHash === currHash), switchMap(([userLogin, realmSetHash]) => {
5436
+ var _a;
5421
5437
  // Let server end query changes from last entry of same client-ID and forward.
5422
5438
  // If no new entries, server won't bother the client. If new entries, server sends only those
5423
5439
  // and the baseRev of the last from same client-ID.
5424
- if (userLogin) {
5440
+ if (userLogin && ((_a = db.cloud.persistedSyncState) === null || _a === void 0 ? void 0 : _a.value)) {
5425
5441
  return new WSObservable(db.cloud.options.databaseUrl, db.cloud.persistedSyncState.value.serverRevision, realmSetHash, db.cloud.persistedSyncState.value.clientIdentity, messageProducer, db.cloud.webSocketStatus, userLogin.accessToken, userLogin.accessTokenExpiration);
5426
5442
  }
5427
5443
  else {
@@ -6266,7 +6282,7 @@
6266
6282
  const syncComplete = new rxjs.Subject();
6267
6283
  dexie.cloud = {
6268
6284
  // @ts-ignore
6269
- version: "4.0.1-beta.58",
6285
+ version: "4.0.1-rc.2",
6270
6286
  options: Object.assign({}, DEFAULT_OPTIONS),
6271
6287
  schema: null,
6272
6288
  get currentUserId() {
@@ -6497,10 +6513,7 @@
6497
6513
  // HERE: If requireAuth, do athentication now.
6498
6514
  let changedUser = false;
6499
6515
  if ((_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth) {
6500
- const user = yield db.getCurrentUser();
6501
- if (!user.isLoggedIn) {
6502
- changedUser = yield login(db);
6503
- }
6516
+ changedUser = yield login(db);
6504
6517
  }
6505
6518
  if (localSyncWorker)
6506
6519
  localSyncWorker.stop();
@@ -6546,7 +6559,7 @@
6546
6559
  }
6547
6560
  }
6548
6561
  // @ts-ignore
6549
- dexieCloud.version = "4.0.1-beta.58";
6562
+ dexieCloud.version = "4.0.1-rc.2";
6550
6563
  Dexie.Cloud = dexieCloud;
6551
6564
 
6552
6565
  // In case the SW lives for a while, let it reuse already opened connections: