dexie-cloud-addon 4.0.7 → 4.0.11
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/DexieCloudOptions.d.ts +3 -2
- package/dist/modern/dexie-cloud-addon.js +36 -30
- 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 +36 -30
- 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/DexieCloudOptions.d.ts +3 -2
- package/dist/umd/dexie-cloud-addon.js +36 -30
- 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 +36 -30
- 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 +2 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { TokenFinalResponse } from 'dexie-cloud-common';
|
|
1
|
+
import type { TokenFinalResponse } from 'dexie-cloud-common';
|
|
2
|
+
import type { LoginHints } from './DexieCloudAPI';
|
|
2
3
|
export interface PeriodicSyncOptions {
|
|
3
4
|
minInterval?: number;
|
|
4
5
|
}
|
|
5
6
|
export interface DexieCloudOptions {
|
|
6
7
|
databaseUrl: string;
|
|
7
|
-
requireAuth?: boolean;
|
|
8
|
+
requireAuth?: boolean | LoginHints;
|
|
8
9
|
tryUseServiceWorker?: boolean;
|
|
9
10
|
periodicSync?: PeriodicSyncOptions;
|
|
10
11
|
customLoginGui?: boolean;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* ==========================================================================
|
|
10
10
|
*
|
|
11
|
-
* Version 4.0.
|
|
11
|
+
* Version 4.0.11, Wed Jan 15 2025
|
|
12
12
|
*
|
|
13
13
|
* https://dexie.org
|
|
14
14
|
*
|
|
@@ -3140,7 +3140,7 @@ var numberDef = {
|
|
|
3140
3140
|
},
|
|
3141
3141
|
};
|
|
3142
3142
|
|
|
3143
|
-
const bigIntDef = {
|
|
3143
|
+
const bigIntDef$1 = {
|
|
3144
3144
|
bigint: {
|
|
3145
3145
|
replace: (realVal) => {
|
|
3146
3146
|
return { $t: "bigint", v: "" + realVal };
|
|
@@ -3383,7 +3383,7 @@ var BlobDef = {
|
|
|
3383
3383
|
|
|
3384
3384
|
const builtin = {
|
|
3385
3385
|
...numberDef,
|
|
3386
|
-
...bigIntDef,
|
|
3386
|
+
...bigIntDef$1,
|
|
3387
3387
|
...DateDef,
|
|
3388
3388
|
...SetDef,
|
|
3389
3389
|
...MapDef,
|
|
@@ -3493,7 +3493,7 @@ class FakeBigInt {
|
|
|
3493
3493
|
this.v = value;
|
|
3494
3494
|
}
|
|
3495
3495
|
}
|
|
3496
|
-
const
|
|
3496
|
+
const bigIntDef = hasBigIntSupport
|
|
3497
3497
|
? {}
|
|
3498
3498
|
: {
|
|
3499
3499
|
bigint: {
|
|
@@ -3501,17 +3501,19 @@ const defs = Object.assign(Object.assign(Object.assign({}, undefinedDef), (hasBi
|
|
|
3501
3501
|
replace: (fakeBigInt) => {
|
|
3502
3502
|
return Object.assign({ $t: 'bigint' }, fakeBigInt);
|
|
3503
3503
|
},
|
|
3504
|
-
revive: ({ v
|
|
3505
|
-
}
|
|
3506
|
-
}
|
|
3504
|
+
revive: ({ v }) => new FakeBigInt(v),
|
|
3505
|
+
},
|
|
3506
|
+
};
|
|
3507
|
+
const defs = Object.assign(Object.assign(Object.assign({}, undefinedDef), bigIntDef), { PropModification: {
|
|
3507
3508
|
test: (val) => val instanceof PropModification,
|
|
3508
3509
|
replace: (propModification) => {
|
|
3509
|
-
return Object.assign({ $t: 'PropModification' }, propModification);
|
|
3510
|
+
return Object.assign({ $t: 'PropModification' }, propModification['@@propmod']);
|
|
3510
3511
|
},
|
|
3511
3512
|
revive: (_a) => {
|
|
3512
|
-
var
|
|
3513
|
-
|
|
3514
|
-
|
|
3513
|
+
var propModSpec = __rest(_a, ["$t"]) // keep the rest
|
|
3514
|
+
;
|
|
3515
|
+
return new PropModification(propModSpec);
|
|
3516
|
+
},
|
|
3515
3517
|
} });
|
|
3516
3518
|
const TSON = TypesonSimplified(builtin, defs);
|
|
3517
3519
|
const BISON = Bison(defs);
|
|
@@ -4156,13 +4158,15 @@ function filterServerChangesThroughAddedClientChanges(serverChanges, addedClient
|
|
|
4156
4158
|
return toDBOperationSet(changes);
|
|
4157
4159
|
}
|
|
4158
4160
|
|
|
4161
|
+
const LIMIT_NUM_MESSAGES_PER_TIME = 10; // Allow a maximum of 10 messages per...
|
|
4162
|
+
const TIME_WINDOW = 10000; // ...10 seconds.
|
|
4163
|
+
const PAUSE_PERIOD = 1000; // Pause for 1 second if reached
|
|
4159
4164
|
function MessagesFromServerConsumer(db) {
|
|
4160
4165
|
const queue = [];
|
|
4161
4166
|
const readyToServe = new BehaviorSubject(true);
|
|
4162
4167
|
const event = new BehaviorSubject(null);
|
|
4163
4168
|
let isWorking = false;
|
|
4164
|
-
let
|
|
4165
|
-
let loopDetection = [0, 0, 0, 0, 0, 0, 0, 0, 0, Date.now()];
|
|
4169
|
+
let loopDetection = new Array(LIMIT_NUM_MESSAGES_PER_TIME).fill(0);
|
|
4166
4170
|
event.subscribe(() => __awaiter(this, void 0, void 0, function* () {
|
|
4167
4171
|
if (isWorking)
|
|
4168
4172
|
return;
|
|
@@ -4176,20 +4180,11 @@ function MessagesFromServerConsumer(db) {
|
|
|
4176
4180
|
}
|
|
4177
4181
|
finally {
|
|
4178
4182
|
if (loopDetection[loopDetection.length - 1] - loopDetection[0] <
|
|
4179
|
-
|
|
4183
|
+
TIME_WINDOW) {
|
|
4180
4184
|
// Ten loops within 10 seconds. Slow down!
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
loopWarning = Date.now() + 60000;
|
|
4185
|
-
yield new Promise((resolve) => setTimeout(resolve, 60000));
|
|
4186
|
-
}
|
|
4187
|
-
else {
|
|
4188
|
-
// This is a one-time event. Just pause 10 seconds.
|
|
4189
|
-
console.warn(`Slowing down websocket loop for 10 seconds`);
|
|
4190
|
-
loopWarning = Date.now() + 10000;
|
|
4191
|
-
yield new Promise((resolve) => setTimeout(resolve, 10000));
|
|
4192
|
-
}
|
|
4185
|
+
// This is a one-time event. Just pause 10 seconds.
|
|
4186
|
+
console.warn(`Slowing down websocket loop for ${PAUSE_PERIOD} milliseconds`);
|
|
4187
|
+
yield new Promise((resolve) => setTimeout(resolve, PAUSE_PERIOD));
|
|
4193
4188
|
}
|
|
4194
4189
|
isWorking = false;
|
|
4195
4190
|
readyToServe.next(true);
|
|
@@ -6317,7 +6312,7 @@ function dexieCloud(dexie) {
|
|
|
6317
6312
|
const syncComplete = new Subject();
|
|
6318
6313
|
dexie.cloud = {
|
|
6319
6314
|
// @ts-ignore
|
|
6320
|
-
version: "4.0.
|
|
6315
|
+
version: "4.0.11",
|
|
6321
6316
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
6322
6317
|
schema: null,
|
|
6323
6318
|
get currentUserId() {
|
|
@@ -6544,8 +6539,19 @@ function dexieCloud(dexie) {
|
|
|
6544
6539
|
// HERE: If requireAuth, do athentication now.
|
|
6545
6540
|
let changedUser = false;
|
|
6546
6541
|
const user = yield db.getCurrentUser();
|
|
6547
|
-
|
|
6548
|
-
|
|
6542
|
+
const requireAuth = (_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth;
|
|
6543
|
+
if (requireAuth) {
|
|
6544
|
+
if (typeof requireAuth === 'object') {
|
|
6545
|
+
// requireAuth contains login hints. Check if we already fulfil it:
|
|
6546
|
+
if (!user.isLoggedIn ||
|
|
6547
|
+
(requireAuth.userId && user.userId !== requireAuth.userId) ||
|
|
6548
|
+
(requireAuth.email && user.email !== requireAuth.email)) {
|
|
6549
|
+
// If not, login the configured user:
|
|
6550
|
+
changedUser = yield login(db, requireAuth);
|
|
6551
|
+
}
|
|
6552
|
+
}
|
|
6553
|
+
else if (!user.isLoggedIn) {
|
|
6554
|
+
// requireAuth is true and user is not logged in
|
|
6549
6555
|
changedUser = yield login(db);
|
|
6550
6556
|
}
|
|
6551
6557
|
}
|
|
@@ -6601,7 +6607,7 @@ function dexieCloud(dexie) {
|
|
|
6601
6607
|
}
|
|
6602
6608
|
}
|
|
6603
6609
|
// @ts-ignore
|
|
6604
|
-
dexieCloud.version = "4.0.
|
|
6610
|
+
dexieCloud.version = "4.0.11";
|
|
6605
6611
|
Dexie.Cloud = dexieCloud;
|
|
6606
6612
|
|
|
6607
6613
|
export { dexieCloud as default, dexieCloud, getTiedObjectId, getTiedRealmId, resolveText };
|