dexie-cloud-addon 4.0.6 → 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 +27 -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 +27 -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 +27 -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 +27 -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
|
*
|
|
@@ -3853,13 +3853,15 @@
|
|
|
3853
3853
|
return toDBOperationSet(changes);
|
|
3854
3854
|
}
|
|
3855
3855
|
|
|
3856
|
+
const LIMIT_NUM_MESSAGES_PER_TIME = 10; // Allow a maximum of 10 messages per...
|
|
3857
|
+
const TIME_WINDOW = 10000; // ...10 seconds.
|
|
3858
|
+
const PAUSE_PERIOD = 1000; // Pause for 1 second if reached
|
|
3856
3859
|
function MessagesFromServerConsumer(db) {
|
|
3857
3860
|
const queue = [];
|
|
3858
3861
|
const readyToServe = new rxjs.BehaviorSubject(true);
|
|
3859
3862
|
const event = new rxjs.BehaviorSubject(null);
|
|
3860
3863
|
let isWorking = false;
|
|
3861
|
-
let
|
|
3862
|
-
let loopDetection = [0, 0, 0, 0, 0, 0, 0, 0, 0, Date.now()];
|
|
3864
|
+
let loopDetection = new Array(LIMIT_NUM_MESSAGES_PER_TIME).fill(0);
|
|
3863
3865
|
event.subscribe(() => __awaiter(this, void 0, void 0, function* () {
|
|
3864
3866
|
if (isWorking)
|
|
3865
3867
|
return;
|
|
@@ -3873,20 +3875,11 @@
|
|
|
3873
3875
|
}
|
|
3874
3876
|
finally {
|
|
3875
3877
|
if (loopDetection[loopDetection.length - 1] - loopDetection[0] <
|
|
3876
|
-
|
|
3878
|
+
TIME_WINDOW) {
|
|
3877
3879
|
// Ten loops within 10 seconds. Slow down!
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
loopWarning = Date.now() + 60000;
|
|
3882
|
-
yield new Promise((resolve) => setTimeout(resolve, 60000));
|
|
3883
|
-
}
|
|
3884
|
-
else {
|
|
3885
|
-
// This is a one-time event. Just pause 10 seconds.
|
|
3886
|
-
console.warn(`Slowing down websocket loop for 10 seconds`);
|
|
3887
|
-
loopWarning = Date.now() + 10000;
|
|
3888
|
-
yield new Promise((resolve) => setTimeout(resolve, 10000));
|
|
3889
|
-
}
|
|
3880
|
+
// This is a one-time event. Just pause 10 seconds.
|
|
3881
|
+
console.warn(`Slowing down websocket loop for ${PAUSE_PERIOD} milliseconds`);
|
|
3882
|
+
yield new Promise((resolve) => setTimeout(resolve, PAUSE_PERIOD));
|
|
3890
3883
|
}
|
|
3891
3884
|
isWorking = false;
|
|
3892
3885
|
readyToServe.next(true);
|
|
@@ -5028,6 +5021,9 @@
|
|
|
5028
5021
|
txid,
|
|
5029
5022
|
userId,
|
|
5030
5023
|
};
|
|
5024
|
+
if ('isAdditionalChunk' in req && req.isAdditionalChunk) {
|
|
5025
|
+
mut.isAdditionalChunk = true;
|
|
5026
|
+
}
|
|
5031
5027
|
return keys.length > 0 || ('criteria' in req && req.criteria)
|
|
5032
5028
|
? mutsTable
|
|
5033
5029
|
.mutate({ type: 'add', trans, values: [mut] }) // Log entry
|
|
@@ -6310,7 +6306,7 @@
|
|
|
6310
6306
|
const syncComplete = new rxjs.Subject();
|
|
6311
6307
|
dexie.cloud = {
|
|
6312
6308
|
// @ts-ignore
|
|
6313
|
-
version: "4.0.
|
|
6309
|
+
version: "4.0.8",
|
|
6314
6310
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
6315
6311
|
schema: null,
|
|
6316
6312
|
get currentUserId() {
|
|
@@ -6537,8 +6533,19 @@
|
|
|
6537
6533
|
// HERE: If requireAuth, do athentication now.
|
|
6538
6534
|
let changedUser = false;
|
|
6539
6535
|
const user = yield db.getCurrentUser();
|
|
6540
|
-
|
|
6541
|
-
|
|
6536
|
+
const requireAuth = (_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth;
|
|
6537
|
+
if (requireAuth) {
|
|
6538
|
+
if (typeof requireAuth === 'object') {
|
|
6539
|
+
// requireAuth contains login hints. Check if we already fulfil it:
|
|
6540
|
+
if (!user.isLoggedIn ||
|
|
6541
|
+
(requireAuth.userId && user.userId !== requireAuth.userId) ||
|
|
6542
|
+
(requireAuth.email && user.email !== requireAuth.email)) {
|
|
6543
|
+
// If not, login the configured user:
|
|
6544
|
+
changedUser = yield login(db, requireAuth);
|
|
6545
|
+
}
|
|
6546
|
+
}
|
|
6547
|
+
else if (!user.isLoggedIn) {
|
|
6548
|
+
// requireAuth is true and user is not logged in
|
|
6542
6549
|
changedUser = yield login(db);
|
|
6543
6550
|
}
|
|
6544
6551
|
}
|
|
@@ -6594,7 +6601,7 @@
|
|
|
6594
6601
|
}
|
|
6595
6602
|
}
|
|
6596
6603
|
// @ts-ignore
|
|
6597
|
-
dexieCloud.version = "4.0.
|
|
6604
|
+
dexieCloud.version = "4.0.8";
|
|
6598
6605
|
Dexie.Cloud = dexieCloud;
|
|
6599
6606
|
|
|
6600
6607
|
// In case the SW lives for a while, let it reuse already opened connections:
|