dexie-cloud-addon 4.0.7 → 4.0.8
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 +24 -20
- 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 +24 -20
- 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 +24 -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 +24 -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.
|
|
11
|
+
* Version 4.0.8, Tue Jun 04 2024
|
|
12
12
|
*
|
|
13
13
|
* https://dexie.org
|
|
14
14
|
*
|
|
@@ -3850,13 +3850,15 @@ function filterServerChangesThroughAddedClientChanges(serverChanges, addedClient
|
|
|
3850
3850
|
return toDBOperationSet(changes);
|
|
3851
3851
|
}
|
|
3852
3852
|
|
|
3853
|
+
const LIMIT_NUM_MESSAGES_PER_TIME = 10; // Allow a maximum of 10 messages per...
|
|
3854
|
+
const TIME_WINDOW = 10000; // ...10 seconds.
|
|
3855
|
+
const PAUSE_PERIOD = 1000; // Pause for 1 second if reached
|
|
3853
3856
|
function MessagesFromServerConsumer(db) {
|
|
3854
3857
|
const queue = [];
|
|
3855
3858
|
const readyToServe = new BehaviorSubject(true);
|
|
3856
3859
|
const event = new BehaviorSubject(null);
|
|
3857
3860
|
let isWorking = false;
|
|
3858
|
-
let
|
|
3859
|
-
let loopDetection = [0, 0, 0, 0, 0, 0, 0, 0, 0, Date.now()];
|
|
3861
|
+
let loopDetection = new Array(LIMIT_NUM_MESSAGES_PER_TIME).fill(0);
|
|
3860
3862
|
event.subscribe(() => __awaiter(this, void 0, void 0, function* () {
|
|
3861
3863
|
if (isWorking)
|
|
3862
3864
|
return;
|
|
@@ -3870,20 +3872,11 @@ function MessagesFromServerConsumer(db) {
|
|
|
3870
3872
|
}
|
|
3871
3873
|
finally {
|
|
3872
3874
|
if (loopDetection[loopDetection.length - 1] - loopDetection[0] <
|
|
3873
|
-
|
|
3875
|
+
TIME_WINDOW) {
|
|
3874
3876
|
// Ten loops within 10 seconds. Slow down!
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
loopWarning = Date.now() + 60000;
|
|
3879
|
-
yield new Promise((resolve) => setTimeout(resolve, 60000));
|
|
3880
|
-
}
|
|
3881
|
-
else {
|
|
3882
|
-
// This is a one-time event. Just pause 10 seconds.
|
|
3883
|
-
console.warn(`Slowing down websocket loop for 10 seconds`);
|
|
3884
|
-
loopWarning = Date.now() + 10000;
|
|
3885
|
-
yield new Promise((resolve) => setTimeout(resolve, 10000));
|
|
3886
|
-
}
|
|
3877
|
+
// This is a one-time event. Just pause 10 seconds.
|
|
3878
|
+
console.warn(`Slowing down websocket loop for ${PAUSE_PERIOD} milliseconds`);
|
|
3879
|
+
yield new Promise((resolve) => setTimeout(resolve, PAUSE_PERIOD));
|
|
3887
3880
|
}
|
|
3888
3881
|
isWorking = false;
|
|
3889
3882
|
readyToServe.next(true);
|
|
@@ -6310,7 +6303,7 @@ function dexieCloud(dexie) {
|
|
|
6310
6303
|
const syncComplete = new Subject();
|
|
6311
6304
|
dexie.cloud = {
|
|
6312
6305
|
// @ts-ignore
|
|
6313
|
-
version: "4.0.
|
|
6306
|
+
version: "4.0.8",
|
|
6314
6307
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
6315
6308
|
schema: null,
|
|
6316
6309
|
get currentUserId() {
|
|
@@ -6537,8 +6530,19 @@ function dexieCloud(dexie) {
|
|
|
6537
6530
|
// HERE: If requireAuth, do athentication now.
|
|
6538
6531
|
let changedUser = false;
|
|
6539
6532
|
const user = yield db.getCurrentUser();
|
|
6540
|
-
|
|
6541
|
-
|
|
6533
|
+
const requireAuth = (_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth;
|
|
6534
|
+
if (requireAuth) {
|
|
6535
|
+
if (typeof requireAuth === 'object') {
|
|
6536
|
+
// requireAuth contains login hints. Check if we already fulfil it:
|
|
6537
|
+
if (!user.isLoggedIn ||
|
|
6538
|
+
(requireAuth.userId && user.userId !== requireAuth.userId) ||
|
|
6539
|
+
(requireAuth.email && user.email !== requireAuth.email)) {
|
|
6540
|
+
// If not, login the configured user:
|
|
6541
|
+
changedUser = yield login(db, requireAuth);
|
|
6542
|
+
}
|
|
6543
|
+
}
|
|
6544
|
+
else if (!user.isLoggedIn) {
|
|
6545
|
+
// requireAuth is true and user is not logged in
|
|
6542
6546
|
changedUser = yield login(db);
|
|
6543
6547
|
}
|
|
6544
6548
|
}
|
|
@@ -6594,7 +6598,7 @@ function dexieCloud(dexie) {
|
|
|
6594
6598
|
}
|
|
6595
6599
|
}
|
|
6596
6600
|
// @ts-ignore
|
|
6597
|
-
dexieCloud.version = "4.0.
|
|
6601
|
+
dexieCloud.version = "4.0.8";
|
|
6598
6602
|
Dexie.Cloud = dexieCloud;
|
|
6599
6603
|
|
|
6600
6604
|
// In case the SW lives for a while, let it reuse already opened connections:
|