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
|
*
|
|
@@ -3143,7 +3143,7 @@
|
|
|
3143
3143
|
},
|
|
3144
3144
|
};
|
|
3145
3145
|
|
|
3146
|
-
const bigIntDef = {
|
|
3146
|
+
const bigIntDef$1 = {
|
|
3147
3147
|
bigint: {
|
|
3148
3148
|
replace: (realVal) => {
|
|
3149
3149
|
return { $t: "bigint", v: "" + realVal };
|
|
@@ -3386,7 +3386,7 @@
|
|
|
3386
3386
|
|
|
3387
3387
|
const builtin = {
|
|
3388
3388
|
...numberDef,
|
|
3389
|
-
...bigIntDef,
|
|
3389
|
+
...bigIntDef$1,
|
|
3390
3390
|
...DateDef,
|
|
3391
3391
|
...SetDef,
|
|
3392
3392
|
...MapDef,
|
|
@@ -3496,7 +3496,7 @@
|
|
|
3496
3496
|
this.v = value;
|
|
3497
3497
|
}
|
|
3498
3498
|
}
|
|
3499
|
-
const
|
|
3499
|
+
const bigIntDef = hasBigIntSupport
|
|
3500
3500
|
? {}
|
|
3501
3501
|
: {
|
|
3502
3502
|
bigint: {
|
|
@@ -3504,17 +3504,19 @@
|
|
|
3504
3504
|
replace: (fakeBigInt) => {
|
|
3505
3505
|
return Object.assign({ $t: 'bigint' }, fakeBigInt);
|
|
3506
3506
|
},
|
|
3507
|
-
revive: ({ v
|
|
3508
|
-
}
|
|
3509
|
-
}
|
|
3507
|
+
revive: ({ v }) => new FakeBigInt(v),
|
|
3508
|
+
},
|
|
3509
|
+
};
|
|
3510
|
+
const defs = Object.assign(Object.assign(Object.assign({}, undefinedDef), bigIntDef), { PropModification: {
|
|
3510
3511
|
test: (val) => val instanceof Dexie.PropModification,
|
|
3511
3512
|
replace: (propModification) => {
|
|
3512
|
-
return Object.assign({ $t: 'PropModification' }, propModification);
|
|
3513
|
+
return Object.assign({ $t: 'PropModification' }, propModification['@@propmod']);
|
|
3513
3514
|
},
|
|
3514
3515
|
revive: (_a) => {
|
|
3515
|
-
var
|
|
3516
|
-
|
|
3517
|
-
|
|
3516
|
+
var propModSpec = __rest(_a, ["$t"]) // keep the rest
|
|
3517
|
+
;
|
|
3518
|
+
return new Dexie.PropModification(propModSpec);
|
|
3519
|
+
},
|
|
3518
3520
|
} });
|
|
3519
3521
|
const TSON = TypesonSimplified(builtin, defs);
|
|
3520
3522
|
const BISON = Bison(defs);
|
|
@@ -4159,13 +4161,15 @@
|
|
|
4159
4161
|
return toDBOperationSet(changes);
|
|
4160
4162
|
}
|
|
4161
4163
|
|
|
4164
|
+
const LIMIT_NUM_MESSAGES_PER_TIME = 10; // Allow a maximum of 10 messages per...
|
|
4165
|
+
const TIME_WINDOW = 10000; // ...10 seconds.
|
|
4166
|
+
const PAUSE_PERIOD = 1000; // Pause for 1 second if reached
|
|
4162
4167
|
function MessagesFromServerConsumer(db) {
|
|
4163
4168
|
const queue = [];
|
|
4164
4169
|
const readyToServe = new rxjs.BehaviorSubject(true);
|
|
4165
4170
|
const event = new rxjs.BehaviorSubject(null);
|
|
4166
4171
|
let isWorking = false;
|
|
4167
|
-
let
|
|
4168
|
-
let loopDetection = [0, 0, 0, 0, 0, 0, 0, 0, 0, Date.now()];
|
|
4172
|
+
let loopDetection = new Array(LIMIT_NUM_MESSAGES_PER_TIME).fill(0);
|
|
4169
4173
|
event.subscribe(() => __awaiter(this, void 0, void 0, function* () {
|
|
4170
4174
|
if (isWorking)
|
|
4171
4175
|
return;
|
|
@@ -4179,20 +4183,11 @@
|
|
|
4179
4183
|
}
|
|
4180
4184
|
finally {
|
|
4181
4185
|
if (loopDetection[loopDetection.length - 1] - loopDetection[0] <
|
|
4182
|
-
|
|
4186
|
+
TIME_WINDOW) {
|
|
4183
4187
|
// Ten loops within 10 seconds. Slow down!
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
loopWarning = Date.now() + 60000;
|
|
4188
|
-
yield new Promise((resolve) => setTimeout(resolve, 60000));
|
|
4189
|
-
}
|
|
4190
|
-
else {
|
|
4191
|
-
// This is a one-time event. Just pause 10 seconds.
|
|
4192
|
-
console.warn(`Slowing down websocket loop for 10 seconds`);
|
|
4193
|
-
loopWarning = Date.now() + 10000;
|
|
4194
|
-
yield new Promise((resolve) => setTimeout(resolve, 10000));
|
|
4195
|
-
}
|
|
4188
|
+
// This is a one-time event. Just pause 10 seconds.
|
|
4189
|
+
console.warn(`Slowing down websocket loop for ${PAUSE_PERIOD} milliseconds`);
|
|
4190
|
+
yield new Promise((resolve) => setTimeout(resolve, PAUSE_PERIOD));
|
|
4196
4191
|
}
|
|
4197
4192
|
isWorking = false;
|
|
4198
4193
|
readyToServe.next(true);
|
|
@@ -6320,7 +6315,7 @@
|
|
|
6320
6315
|
const syncComplete = new rxjs.Subject();
|
|
6321
6316
|
dexie.cloud = {
|
|
6322
6317
|
// @ts-ignore
|
|
6323
|
-
version: "4.0.
|
|
6318
|
+
version: "4.0.11",
|
|
6324
6319
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
6325
6320
|
schema: null,
|
|
6326
6321
|
get currentUserId() {
|
|
@@ -6547,8 +6542,19 @@
|
|
|
6547
6542
|
// HERE: If requireAuth, do athentication now.
|
|
6548
6543
|
let changedUser = false;
|
|
6549
6544
|
const user = yield db.getCurrentUser();
|
|
6550
|
-
|
|
6551
|
-
|
|
6545
|
+
const requireAuth = (_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth;
|
|
6546
|
+
if (requireAuth) {
|
|
6547
|
+
if (typeof requireAuth === 'object') {
|
|
6548
|
+
// requireAuth contains login hints. Check if we already fulfil it:
|
|
6549
|
+
if (!user.isLoggedIn ||
|
|
6550
|
+
(requireAuth.userId && user.userId !== requireAuth.userId) ||
|
|
6551
|
+
(requireAuth.email && user.email !== requireAuth.email)) {
|
|
6552
|
+
// If not, login the configured user:
|
|
6553
|
+
changedUser = yield login(db, requireAuth);
|
|
6554
|
+
}
|
|
6555
|
+
}
|
|
6556
|
+
else if (!user.isLoggedIn) {
|
|
6557
|
+
// requireAuth is true and user is not logged in
|
|
6552
6558
|
changedUser = yield login(db);
|
|
6553
6559
|
}
|
|
6554
6560
|
}
|
|
@@ -6604,7 +6610,7 @@
|
|
|
6604
6610
|
}
|
|
6605
6611
|
}
|
|
6606
6612
|
// @ts-ignore
|
|
6607
|
-
dexieCloud.version = "4.0.
|
|
6613
|
+
dexieCloud.version = "4.0.11";
|
|
6608
6614
|
Dexie.Cloud = dexieCloud;
|
|
6609
6615
|
|
|
6610
6616
|
exports.default = dexieCloud;
|