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
|
@@ -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
|
*
|
|
@@ -2827,7 +2827,7 @@
|
|
|
2827
2827
|
},
|
|
2828
2828
|
};
|
|
2829
2829
|
|
|
2830
|
-
const bigIntDef = {
|
|
2830
|
+
const bigIntDef$1 = {
|
|
2831
2831
|
bigint: {
|
|
2832
2832
|
replace: (realVal) => {
|
|
2833
2833
|
return { $t: "bigint", v: "" + realVal };
|
|
@@ -3070,7 +3070,7 @@
|
|
|
3070
3070
|
|
|
3071
3071
|
const builtin = {
|
|
3072
3072
|
...numberDef,
|
|
3073
|
-
...bigIntDef,
|
|
3073
|
+
...bigIntDef$1,
|
|
3074
3074
|
...DateDef,
|
|
3075
3075
|
...SetDef,
|
|
3076
3076
|
...MapDef,
|
|
@@ -3180,7 +3180,7 @@
|
|
|
3180
3180
|
this.v = value;
|
|
3181
3181
|
}
|
|
3182
3182
|
}
|
|
3183
|
-
const
|
|
3183
|
+
const bigIntDef = hasBigIntSupport
|
|
3184
3184
|
? {}
|
|
3185
3185
|
: {
|
|
3186
3186
|
bigint: {
|
|
@@ -3188,17 +3188,19 @@
|
|
|
3188
3188
|
replace: (fakeBigInt) => {
|
|
3189
3189
|
return Object.assign({ $t: 'bigint' }, fakeBigInt);
|
|
3190
3190
|
},
|
|
3191
|
-
revive: ({ v
|
|
3192
|
-
}
|
|
3193
|
-
}
|
|
3191
|
+
revive: ({ v }) => new FakeBigInt(v),
|
|
3192
|
+
},
|
|
3193
|
+
};
|
|
3194
|
+
const defs = Object.assign(Object.assign(Object.assign({}, undefinedDef), bigIntDef), { PropModification: {
|
|
3194
3195
|
test: (val) => val instanceof Dexie.PropModification,
|
|
3195
3196
|
replace: (propModification) => {
|
|
3196
|
-
return Object.assign({ $t: 'PropModification' }, propModification);
|
|
3197
|
+
return Object.assign({ $t: 'PropModification' }, propModification['@@propmod']);
|
|
3197
3198
|
},
|
|
3198
3199
|
revive: (_a) => {
|
|
3199
|
-
var
|
|
3200
|
-
|
|
3201
|
-
|
|
3200
|
+
var propModSpec = __rest(_a, ["$t"]) // keep the rest
|
|
3201
|
+
;
|
|
3202
|
+
return new Dexie.PropModification(propModSpec);
|
|
3203
|
+
},
|
|
3202
3204
|
} });
|
|
3203
3205
|
const TSON = TypesonSimplified(builtin, defs);
|
|
3204
3206
|
const BISON = Bison(defs);
|
|
@@ -3853,13 +3855,15 @@
|
|
|
3853
3855
|
return toDBOperationSet(changes);
|
|
3854
3856
|
}
|
|
3855
3857
|
|
|
3858
|
+
const LIMIT_NUM_MESSAGES_PER_TIME = 10; // Allow a maximum of 10 messages per...
|
|
3859
|
+
const TIME_WINDOW = 10000; // ...10 seconds.
|
|
3860
|
+
const PAUSE_PERIOD = 1000; // Pause for 1 second if reached
|
|
3856
3861
|
function MessagesFromServerConsumer(db) {
|
|
3857
3862
|
const queue = [];
|
|
3858
3863
|
const readyToServe = new rxjs.BehaviorSubject(true);
|
|
3859
3864
|
const event = new rxjs.BehaviorSubject(null);
|
|
3860
3865
|
let isWorking = false;
|
|
3861
|
-
let
|
|
3862
|
-
let loopDetection = [0, 0, 0, 0, 0, 0, 0, 0, 0, Date.now()];
|
|
3866
|
+
let loopDetection = new Array(LIMIT_NUM_MESSAGES_PER_TIME).fill(0);
|
|
3863
3867
|
event.subscribe(() => __awaiter(this, void 0, void 0, function* () {
|
|
3864
3868
|
if (isWorking)
|
|
3865
3869
|
return;
|
|
@@ -3873,20 +3877,11 @@
|
|
|
3873
3877
|
}
|
|
3874
3878
|
finally {
|
|
3875
3879
|
if (loopDetection[loopDetection.length - 1] - loopDetection[0] <
|
|
3876
|
-
|
|
3880
|
+
TIME_WINDOW) {
|
|
3877
3881
|
// 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
|
-
}
|
|
3882
|
+
// This is a one-time event. Just pause 10 seconds.
|
|
3883
|
+
console.warn(`Slowing down websocket loop for ${PAUSE_PERIOD} milliseconds`);
|
|
3884
|
+
yield new Promise((resolve) => setTimeout(resolve, PAUSE_PERIOD));
|
|
3890
3885
|
}
|
|
3891
3886
|
isWorking = false;
|
|
3892
3887
|
readyToServe.next(true);
|
|
@@ -6313,7 +6308,7 @@
|
|
|
6313
6308
|
const syncComplete = new rxjs.Subject();
|
|
6314
6309
|
dexie.cloud = {
|
|
6315
6310
|
// @ts-ignore
|
|
6316
|
-
version: "4.0.
|
|
6311
|
+
version: "4.0.11",
|
|
6317
6312
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
6318
6313
|
schema: null,
|
|
6319
6314
|
get currentUserId() {
|
|
@@ -6540,8 +6535,19 @@
|
|
|
6540
6535
|
// HERE: If requireAuth, do athentication now.
|
|
6541
6536
|
let changedUser = false;
|
|
6542
6537
|
const user = yield db.getCurrentUser();
|
|
6543
|
-
|
|
6544
|
-
|
|
6538
|
+
const requireAuth = (_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth;
|
|
6539
|
+
if (requireAuth) {
|
|
6540
|
+
if (typeof requireAuth === 'object') {
|
|
6541
|
+
// requireAuth contains login hints. Check if we already fulfil it:
|
|
6542
|
+
if (!user.isLoggedIn ||
|
|
6543
|
+
(requireAuth.userId && user.userId !== requireAuth.userId) ||
|
|
6544
|
+
(requireAuth.email && user.email !== requireAuth.email)) {
|
|
6545
|
+
// If not, login the configured user:
|
|
6546
|
+
changedUser = yield login(db, requireAuth);
|
|
6547
|
+
}
|
|
6548
|
+
}
|
|
6549
|
+
else if (!user.isLoggedIn) {
|
|
6550
|
+
// requireAuth is true and user is not logged in
|
|
6545
6551
|
changedUser = yield login(db);
|
|
6546
6552
|
}
|
|
6547
6553
|
}
|
|
@@ -6597,7 +6603,7 @@
|
|
|
6597
6603
|
}
|
|
6598
6604
|
}
|
|
6599
6605
|
// @ts-ignore
|
|
6600
|
-
dexieCloud.version = "4.0.
|
|
6606
|
+
dexieCloud.version = "4.0.11";
|
|
6601
6607
|
Dexie.Cloud = dexieCloud;
|
|
6602
6608
|
|
|
6603
6609
|
// In case the SW lives for a while, let it reuse already opened connections:
|