dexie-cloud-addon 4.0.4 → 4.0.5
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/dexie-cloud-addon.js +22 -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 +23 -21
- 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/dexie-cloud-addon.js +22 -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 +22 -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.5, Sat May 04 2024
|
|
12
12
|
*
|
|
13
13
|
* https://dexie.org
|
|
14
14
|
*
|
|
@@ -4212,9 +4212,7 @@
|
|
|
4212
4212
|
// If the sync worker or service worker is syncing, wait 'til thei're done.
|
|
4213
4213
|
// It's no need to have two channels at the same time - even though it wouldnt
|
|
4214
4214
|
// be a problem - this is an optimization.
|
|
4215
|
-
yield db.cloud.syncState
|
|
4216
|
-
.pipe(filter(({ phase }) => phase === 'in-sync' || phase === 'error'), take(1))
|
|
4217
|
-
.toPromise();
|
|
4215
|
+
yield rxjs.firstValueFrom(db.cloud.syncState.pipe(filter(({ phase }) => phase === 'in-sync' || phase === 'error')));
|
|
4218
4216
|
console.debug('processing msg', msg);
|
|
4219
4217
|
const persistedSyncState = db.cloud.persistedSyncState.value;
|
|
4220
4218
|
//syncState.
|
|
@@ -5417,7 +5415,7 @@
|
|
|
5417
5415
|
yield sleep(3000);
|
|
5418
5416
|
// Wait til user does something (move mouse, tap, scroll, click etc)
|
|
5419
5417
|
console.debug('waiting for someone to do something');
|
|
5420
|
-
yield
|
|
5418
|
+
yield rxjs.firstValueFrom(userDoesSomething);
|
|
5421
5419
|
console.debug('someone did something!');
|
|
5422
5420
|
});
|
|
5423
5421
|
}
|
|
@@ -6315,7 +6313,7 @@
|
|
|
6315
6313
|
const syncComplete = new rxjs.Subject();
|
|
6316
6314
|
dexie.cloud = {
|
|
6317
6315
|
// @ts-ignore
|
|
6318
|
-
version: "4.0.
|
|
6316
|
+
version: "4.0.5",
|
|
6319
6317
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
6320
6318
|
schema: null,
|
|
6321
6319
|
get currentUserId() {
|
|
@@ -6373,10 +6371,8 @@
|
|
|
6373
6371
|
const syncState = db.cloud.persistedSyncState.value;
|
|
6374
6372
|
triggerSync(db, purpose);
|
|
6375
6373
|
if (wait) {
|
|
6376
|
-
const newSyncState = yield db.cloud.persistedSyncState
|
|
6377
|
-
|
|
6378
|
-
(!syncState || newSyncState.timestamp > syncState.timestamp)), take(1))
|
|
6379
|
-
.toPromise();
|
|
6374
|
+
const newSyncState = yield rxjs.firstValueFrom(db.cloud.persistedSyncState.pipe(filter((newSyncState) => (newSyncState === null || newSyncState === void 0 ? void 0 : newSyncState.timestamp) != null &&
|
|
6375
|
+
(!syncState || newSyncState.timestamp > syncState.timestamp))));
|
|
6380
6376
|
if (newSyncState === null || newSyncState === void 0 ? void 0 : newSyncState.error) {
|
|
6381
6377
|
throw new Error(`Sync error: ` + newSyncState.error);
|
|
6382
6378
|
}
|
|
@@ -6387,16 +6383,14 @@
|
|
|
6387
6383
|
triggerSync(db, purpose);
|
|
6388
6384
|
if (wait) {
|
|
6389
6385
|
console.debug('db.cloud.login() is waiting for sync completion...');
|
|
6390
|
-
yield rxjs.from(Dexie.liveQuery(() => __awaiter(this, void 0, void 0, function* () {
|
|
6386
|
+
yield rxjs.firstValueFrom(rxjs.from(Dexie.liveQuery(() => __awaiter(this, void 0, void 0, function* () {
|
|
6391
6387
|
const syncNeeded = yield isSyncNeeded(db);
|
|
6392
6388
|
const newSyncState = yield db.getPersistedSyncState();
|
|
6393
6389
|
if ((newSyncState === null || newSyncState === void 0 ? void 0 : newSyncState.timestamp) !== (syncState === null || syncState === void 0 ? void 0 : syncState.timestamp) &&
|
|
6394
6390
|
(newSyncState === null || newSyncState === void 0 ? void 0 : newSyncState.error))
|
|
6395
6391
|
throw new Error(`Sync error: ` + newSyncState.error);
|
|
6396
6392
|
return syncNeeded;
|
|
6397
|
-
})))
|
|
6398
|
-
.pipe(filter((isNeeded) => !isNeeded), take(1))
|
|
6399
|
-
.toPromise();
|
|
6393
|
+
}))).pipe(filter((isNeeded) => !isNeeded)));
|
|
6400
6394
|
console.debug('Done waiting for sync completion because we have nothing to push anymore');
|
|
6401
6395
|
}
|
|
6402
6396
|
}
|
|
@@ -6445,7 +6439,7 @@
|
|
|
6445
6439
|
const swRegistrations = 'serviceWorker' in navigator
|
|
6446
6440
|
? yield navigator.serviceWorker.getRegistrations()
|
|
6447
6441
|
: [];
|
|
6448
|
-
const initiallySynced = yield db.transaction('rw', db.$syncState, () => __awaiter(this, void 0, void 0, function* () {
|
|
6442
|
+
const [initiallySynced, lastSyncedRealms] = yield db.transaction('rw', db.$syncState, () => __awaiter(this, void 0, void 0, function* () {
|
|
6449
6443
|
var _h, _j;
|
|
6450
6444
|
const { options, schema } = db.cloud;
|
|
6451
6445
|
const [persistedOptions, persistedSchema, persistedSyncState] = yield Promise.all([
|
|
@@ -6518,7 +6512,7 @@
|
|
|
6518
6512
|
// Let's assign all props as the newPersistedSchems should be what we should be working with.
|
|
6519
6513
|
Object.assign(schema, newPersistedSchema);
|
|
6520
6514
|
}
|
|
6521
|
-
return persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.initiallySynced;
|
|
6515
|
+
return [persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.initiallySynced, persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms];
|
|
6522
6516
|
}));
|
|
6523
6517
|
if (initiallySynced) {
|
|
6524
6518
|
db.setInitiallySynced(true);
|
|
@@ -6538,19 +6532,27 @@
|
|
|
6538
6532
|
// with things from the database and not just the default values.
|
|
6539
6533
|
// This is so that when db.open() completes, user should be safe
|
|
6540
6534
|
// to subscribe to these observables and get actual data.
|
|
6541
|
-
yield rxjs.combineLatest([
|
|
6535
|
+
yield rxjs.firstValueFrom(rxjs.combineLatest([
|
|
6542
6536
|
currentUserEmitter.pipe(skip(1), take(1)),
|
|
6543
6537
|
db.cloud.persistedSyncState.pipe(skip(1), take(1)),
|
|
6544
|
-
])
|
|
6538
|
+
]));
|
|
6545
6539
|
}
|
|
6546
6540
|
// HERE: If requireAuth, do athentication now.
|
|
6547
6541
|
let changedUser = false;
|
|
6542
|
+
const user = yield db.getCurrentUser();
|
|
6548
6543
|
if ((_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth) {
|
|
6549
|
-
const user = yield db.getCurrentUser();
|
|
6550
6544
|
if (!user.isLoggedIn) {
|
|
6551
6545
|
changedUser = yield login(db);
|
|
6552
6546
|
}
|
|
6553
6547
|
}
|
|
6548
|
+
if (user.isLoggedIn && (!lastSyncedRealms || !lastSyncedRealms.includes(user.userId))) {
|
|
6549
|
+
// User has been logged in but this is not reflected in the sync state.
|
|
6550
|
+
// This can happen if page is reloaded after login but before the sync call following
|
|
6551
|
+
// the login was complete.
|
|
6552
|
+
// The user is to be viewed as changed becuase current syncState does not reflect the presence
|
|
6553
|
+
// of the logged-in user.
|
|
6554
|
+
changedUser = true; // Set changedUser to true to trigger a pull-sync later down.
|
|
6555
|
+
}
|
|
6554
6556
|
if (localSyncWorker)
|
|
6555
6557
|
localSyncWorker.stop();
|
|
6556
6558
|
localSyncWorker = null;
|
|
@@ -6595,7 +6597,7 @@
|
|
|
6595
6597
|
}
|
|
6596
6598
|
}
|
|
6597
6599
|
// @ts-ignore
|
|
6598
|
-
dexieCloud.version = "4.0.
|
|
6600
|
+
dexieCloud.version = "4.0.5";
|
|
6599
6601
|
Dexie.Cloud = dexieCloud;
|
|
6600
6602
|
|
|
6601
6603
|
exports.default = dexieCloud;
|