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
|
*
|
|
@@ -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);
|
|
@@ -5025,6 +5018,9 @@ function createMutationTrackingMiddleware({ currentUserObservable, db, }) {
|
|
|
5025
5018
|
txid,
|
|
5026
5019
|
userId,
|
|
5027
5020
|
};
|
|
5021
|
+
if ('isAdditionalChunk' in req && req.isAdditionalChunk) {
|
|
5022
|
+
mut.isAdditionalChunk = true;
|
|
5023
|
+
}
|
|
5028
5024
|
return keys.length > 0 || ('criteria' in req && req.criteria)
|
|
5029
5025
|
? mutsTable
|
|
5030
5026
|
.mutate({ type: 'add', trans, values: [mut] }) // Log entry
|
|
@@ -6307,7 +6303,7 @@ function dexieCloud(dexie) {
|
|
|
6307
6303
|
const syncComplete = new Subject();
|
|
6308
6304
|
dexie.cloud = {
|
|
6309
6305
|
// @ts-ignore
|
|
6310
|
-
version: "4.0.
|
|
6306
|
+
version: "4.0.8",
|
|
6311
6307
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
6312
6308
|
schema: null,
|
|
6313
6309
|
get currentUserId() {
|
|
@@ -6534,8 +6530,19 @@ function dexieCloud(dexie) {
|
|
|
6534
6530
|
// HERE: If requireAuth, do athentication now.
|
|
6535
6531
|
let changedUser = false;
|
|
6536
6532
|
const user = yield db.getCurrentUser();
|
|
6537
|
-
|
|
6538
|
-
|
|
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
|
|
6539
6546
|
changedUser = yield login(db);
|
|
6540
6547
|
}
|
|
6541
6548
|
}
|
|
@@ -6591,7 +6598,7 @@ function dexieCloud(dexie) {
|
|
|
6591
6598
|
}
|
|
6592
6599
|
}
|
|
6593
6600
|
// @ts-ignore
|
|
6594
|
-
dexieCloud.version = "4.0.
|
|
6601
|
+
dexieCloud.version = "4.0.8";
|
|
6595
6602
|
Dexie.Cloud = dexieCloud;
|
|
6596
6603
|
|
|
6597
6604
|
// In case the SW lives for a while, let it reuse already opened connections:
|