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) {
@@ -2605,16 +2617,11 @@
2605
2617
  const origUserId = currentUser.userId;
2606
2618
  if (currentUser.isLoggedIn && (!hints || (!hints.email && !hints.userId))) {
2607
2619
  const licenseStatus = ((_a = currentUser.license) === null || _a === void 0 ? void 0 : _a.status) || 'ok';
2608
- if (licenseStatus === 'ok' &&
2609
- currentUser.accessToken &&
2610
- (!currentUser.accessTokenExpiration ||
2611
- currentUser.accessTokenExpiration.getTime() > Date.now())) {
2620
+ if (licenseStatus === 'ok' && currentUser.accessToken && (!currentUser.accessTokenExpiration || currentUser.accessTokenExpiration.getTime() > Date.now())) {
2612
2621
  // Already authenticated according to given hints. And license is valid.
2613
2622
  return false;
2614
2623
  }
2615
- if (currentUser.refreshToken &&
2616
- (!currentUser.refreshTokenExpiration ||
2617
- currentUser.refreshTokenExpiration.getTime() > Date.now())) {
2624
+ if (currentUser.refreshToken && (!currentUser.refreshTokenExpiration || currentUser.refreshTokenExpiration.getTime() > Date.now())) {
2618
2625
  // Refresh the token
2619
2626
  yield loadAccessToken(db);
2620
2627
  return false;
@@ -2626,8 +2633,7 @@
2626
2633
  lastLogin: new Date(0),
2627
2634
  });
2628
2635
  yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
2629
- if (origUserId !== UNAUTHORIZED_USER.userId &&
2630
- context.userId !== origUserId) {
2636
+ if (origUserId !== UNAUTHORIZED_USER.userId && context.userId !== origUserId) {
2631
2637
  // User was logged in before, but now logged in as another user.
2632
2638
  yield logout(db);
2633
2639
  }
@@ -2646,7 +2652,7 @@
2646
2652
  yield setCurrentUser(db, context);
2647
2653
  // Make sure to resync as the new login will be authorized
2648
2654
  // for new realms.
2649
- triggerSync(db, 'pull');
2655
+ triggerSync(db, "pull");
2650
2656
  return context.userId !== origUserId;
2651
2657
  });
2652
2658
  }
@@ -3470,7 +3476,7 @@
3470
3476
  this.v = value;
3471
3477
  }
3472
3478
  }
3473
- const defs = Object.assign(Object.assign({}, undefinedDef), (hasBigIntSupport
3479
+ const defs = Object.assign(Object.assign(Object.assign({}, undefinedDef), (hasBigIntSupport
3474
3480
  ? {}
3475
3481
  : {
3476
3482
  bigint: {
@@ -3480,7 +3486,16 @@
3480
3486
  },
3481
3487
  revive: ({ v, }) => new FakeBigInt(v)
3482
3488
  }
3483
- }));
3489
+ })), { PropModification: {
3490
+ test: (val) => val instanceof Dexie.PropModification,
3491
+ replace: (propModification) => {
3492
+ return Object.assign({ $t: 'PropModification' }, propModification);
3493
+ },
3494
+ revive: (_a) => {
3495
+ var propModification = __rest(_a, ["$t"]);
3496
+ return new Dexie.PropModification(propModification);
3497
+ }
3498
+ } });
3484
3499
  const TSON = TypesonSimplified(builtin, defs);
3485
3500
  const BISON = Bison(defs);
3486
3501
 
@@ -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 {
@@ -6273,7 +6289,7 @@
6273
6289
  const syncComplete = new rxjs.Subject();
6274
6290
  dexie.cloud = {
6275
6291
  // @ts-ignore
6276
- version: "4.0.1-beta.58",
6292
+ version: "4.0.1-rc.2",
6277
6293
  options: Object.assign({}, DEFAULT_OPTIONS),
6278
6294
  schema: null,
6279
6295
  get currentUserId() {
@@ -6504,10 +6520,7 @@
6504
6520
  // HERE: If requireAuth, do athentication now.
6505
6521
  let changedUser = false;
6506
6522
  if ((_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth) {
6507
- const user = yield db.getCurrentUser();
6508
- if (!user.isLoggedIn) {
6509
- changedUser = yield login(db);
6510
- }
6523
+ changedUser = yield login(db);
6511
6524
  }
6512
6525
  if (localSyncWorker)
6513
6526
  localSyncWorker.stop();
@@ -6553,7 +6566,7 @@
6553
6566
  }
6554
6567
  }
6555
6568
  // @ts-ignore
6556
- dexieCloud.version = "4.0.1-beta.58";
6569
+ dexieCloud.version = "4.0.1-rc.2";
6557
6570
  Dexie.Cloud = dexieCloud;
6558
6571
 
6559
6572
  exports.default = dexieCloud;