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.
- package/dist/modern/dexie-cloud-addon.js +34 -21
- package/dist/modern/dexie-cloud-addon.js.map +1 -1
- package/dist/modern/dexie-cloud-addon.min.js +1 -1
- package/dist/modern/dexie-cloud-addon.min.js.map +1 -1
- package/dist/modern/service-worker.js +34 -21
- package/dist/modern/service-worker.js.map +1 -1
- package/dist/modern/service-worker.min.js +1 -1
- package/dist/modern/service-worker.min.js.map +1 -1
- package/dist/umd/dexie-cloud-addon.js +33 -20
- package/dist/umd/dexie-cloud-addon.js.map +1 -1
- package/dist/umd/dexie-cloud-addon.min.js +1 -1
- package/dist/umd/dexie-cloud-addon.min.js.map +1 -1
- package/dist/umd/service-worker.js +33 -20
- package/dist/umd/service-worker.js.map +1 -1
- package/dist/umd/service-worker.min.js +1 -1
- package/dist/umd/service-worker.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* ==========================================================================
|
|
10
10
|
*
|
|
11
|
-
* Version 4.0.1-
|
|
11
|
+
* Version 4.0.1-rc.2, Wed Mar 20 2024
|
|
12
12
|
*
|
|
13
13
|
* https://dexie.org
|
|
14
14
|
*
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import Dexie, { cmp, liveQuery } from 'dexie';
|
|
19
|
+
import Dexie, { PropModification, cmp, liveQuery } from 'dexie';
|
|
20
20
|
import { Observable as Observable$1, BehaviorSubject, Subject, firstValueFrom, from as from$1, filter as filter$1, fromEvent, of, merge, Subscription as Subscription$1, throwError, combineLatest, map as map$1, share, timer as timer$1 } from 'rxjs';
|
|
21
21
|
|
|
22
22
|
/******************************************************************************
|
|
@@ -50,6 +50,18 @@ function __extends(d, b) {
|
|
|
50
50
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
function __rest(s, e) {
|
|
54
|
+
var t = {};
|
|
55
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
56
|
+
t[p] = s[p];
|
|
57
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
58
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
59
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
60
|
+
t[p[i]] = s[p[i]];
|
|
61
|
+
}
|
|
62
|
+
return t;
|
|
63
|
+
}
|
|
64
|
+
|
|
53
65
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
54
66
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
55
67
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -3161,7 +3173,7 @@ class FakeBigInt {
|
|
|
3161
3173
|
this.v = value;
|
|
3162
3174
|
}
|
|
3163
3175
|
}
|
|
3164
|
-
const defs = Object.assign(Object.assign({}, undefinedDef), (hasBigIntSupport
|
|
3176
|
+
const defs = Object.assign(Object.assign(Object.assign({}, undefinedDef), (hasBigIntSupport
|
|
3165
3177
|
? {}
|
|
3166
3178
|
: {
|
|
3167
3179
|
bigint: {
|
|
@@ -3171,7 +3183,16 @@ const defs = Object.assign(Object.assign({}, undefinedDef), (hasBigIntSupport
|
|
|
3171
3183
|
},
|
|
3172
3184
|
revive: ({ v, }) => new FakeBigInt(v)
|
|
3173
3185
|
}
|
|
3174
|
-
}))
|
|
3186
|
+
})), { PropModification: {
|
|
3187
|
+
test: (val) => val instanceof PropModification,
|
|
3188
|
+
replace: (propModification) => {
|
|
3189
|
+
return Object.assign({ $t: 'PropModification' }, propModification);
|
|
3190
|
+
},
|
|
3191
|
+
revive: (_a) => {
|
|
3192
|
+
var propModification = __rest(_a, ["$t"]);
|
|
3193
|
+
return new PropModification(propModification);
|
|
3194
|
+
}
|
|
3195
|
+
} });
|
|
3175
3196
|
const TSON = TypesonSimplified(builtin, defs);
|
|
3176
3197
|
const BISON = Bison(defs);
|
|
3177
3198
|
|
|
@@ -4391,16 +4412,11 @@ function login(db, hints) {
|
|
|
4391
4412
|
const origUserId = currentUser.userId;
|
|
4392
4413
|
if (currentUser.isLoggedIn && (!hints || (!hints.email && !hints.userId))) {
|
|
4393
4414
|
const licenseStatus = ((_a = currentUser.license) === null || _a === void 0 ? void 0 : _a.status) || 'ok';
|
|
4394
|
-
if (licenseStatus === 'ok' &&
|
|
4395
|
-
currentUser.accessToken &&
|
|
4396
|
-
(!currentUser.accessTokenExpiration ||
|
|
4397
|
-
currentUser.accessTokenExpiration.getTime() > Date.now())) {
|
|
4415
|
+
if (licenseStatus === 'ok' && currentUser.accessToken && (!currentUser.accessTokenExpiration || currentUser.accessTokenExpiration.getTime() > Date.now())) {
|
|
4398
4416
|
// Already authenticated according to given hints. And license is valid.
|
|
4399
4417
|
return false;
|
|
4400
4418
|
}
|
|
4401
|
-
if (currentUser.refreshToken &&
|
|
4402
|
-
(!currentUser.refreshTokenExpiration ||
|
|
4403
|
-
currentUser.refreshTokenExpiration.getTime() > Date.now())) {
|
|
4419
|
+
if (currentUser.refreshToken && (!currentUser.refreshTokenExpiration || currentUser.refreshTokenExpiration.getTime() > Date.now())) {
|
|
4404
4420
|
// Refresh the token
|
|
4405
4421
|
yield loadAccessToken(db);
|
|
4406
4422
|
return false;
|
|
@@ -4412,8 +4428,7 @@ function login(db, hints) {
|
|
|
4412
4428
|
lastLogin: new Date(0),
|
|
4413
4429
|
});
|
|
4414
4430
|
yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
|
|
4415
|
-
if (origUserId !== UNAUTHORIZED_USER.userId &&
|
|
4416
|
-
context.userId !== origUserId) {
|
|
4431
|
+
if (origUserId !== UNAUTHORIZED_USER.userId && context.userId !== origUserId) {
|
|
4417
4432
|
// User was logged in before, but now logged in as another user.
|
|
4418
4433
|
yield logout(db);
|
|
4419
4434
|
}
|
|
@@ -4432,7 +4447,7 @@ function login(db, hints) {
|
|
|
4432
4447
|
yield setCurrentUser(db, context);
|
|
4433
4448
|
// Make sure to resync as the new login will be authorized
|
|
4434
4449
|
// for new realms.
|
|
4435
|
-
triggerSync(db,
|
|
4450
|
+
triggerSync(db, "pull");
|
|
4436
4451
|
return context.userId !== origUserId;
|
|
4437
4452
|
});
|
|
4438
4453
|
}
|
|
@@ -5415,10 +5430,11 @@ function connectWebSocket(db) {
|
|
|
5415
5430
|
}
|
|
5416
5431
|
return new BehaviorSubject([userLogin, syncState]);
|
|
5417
5432
|
}), 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]) => {
|
|
5433
|
+
var _a;
|
|
5418
5434
|
// Let server end query changes from last entry of same client-ID and forward.
|
|
5419
5435
|
// If no new entries, server won't bother the client. If new entries, server sends only those
|
|
5420
5436
|
// and the baseRev of the last from same client-ID.
|
|
5421
|
-
if (userLogin) {
|
|
5437
|
+
if (userLogin && ((_a = db.cloud.persistedSyncState) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
5422
5438
|
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);
|
|
5423
5439
|
}
|
|
5424
5440
|
else {
|
|
@@ -6263,7 +6279,7 @@ function dexieCloud(dexie) {
|
|
|
6263
6279
|
const syncComplete = new Subject();
|
|
6264
6280
|
dexie.cloud = {
|
|
6265
6281
|
// @ts-ignore
|
|
6266
|
-
version: "4.0.1-
|
|
6282
|
+
version: "4.0.1-rc.2",
|
|
6267
6283
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
6268
6284
|
schema: null,
|
|
6269
6285
|
get currentUserId() {
|
|
@@ -6494,10 +6510,7 @@ function dexieCloud(dexie) {
|
|
|
6494
6510
|
// HERE: If requireAuth, do athentication now.
|
|
6495
6511
|
let changedUser = false;
|
|
6496
6512
|
if ((_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth) {
|
|
6497
|
-
|
|
6498
|
-
if (!user.isLoggedIn) {
|
|
6499
|
-
changedUser = yield login(db);
|
|
6500
|
-
}
|
|
6513
|
+
changedUser = yield login(db);
|
|
6501
6514
|
}
|
|
6502
6515
|
if (localSyncWorker)
|
|
6503
6516
|
localSyncWorker.stop();
|
|
@@ -6543,7 +6556,7 @@ function dexieCloud(dexie) {
|
|
|
6543
6556
|
}
|
|
6544
6557
|
}
|
|
6545
6558
|
// @ts-ignore
|
|
6546
|
-
dexieCloud.version = "4.0.1-
|
|
6559
|
+
dexieCloud.version = "4.0.1-rc.2";
|
|
6547
6560
|
Dexie.Cloud = dexieCloud;
|
|
6548
6561
|
|
|
6549
6562
|
// In case the SW lives for a while, let it reuse already opened connections:
|