dexie-cloud-addon 4.0.1-beta.44 → 4.0.1-beta.46
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 +47 -26
- 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 +46 -25
- 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 +47 -26
- 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 +46 -25
- 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
|
@@ -1545,9 +1545,19 @@
|
|
|
1545
1545
|
const mutClone = changeClone.muts[mutIndex];
|
|
1546
1546
|
const rewrittenKey = JSON.stringify(key);
|
|
1547
1547
|
mutClone.keys[keyIndex] = rewrittenKey;
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1548
|
+
/* Bug (#1777)
|
|
1549
|
+
We should not rewrite values. It will fail because the key is array and the value is string.
|
|
1550
|
+
Only the keys should be rewritten and it's already done on the server.
|
|
1551
|
+
We should take another round of revieweing how key transformations are being done between
|
|
1552
|
+
client and server and let the server do the key transformations entirely instead now that
|
|
1553
|
+
we have the primary key schema on the server making it possible to do so.
|
|
1554
|
+
if (rewriteValues) {
|
|
1555
|
+
Dexie.setByKeyPath(
|
|
1556
|
+
(mutClone as DBInsertOperation).values[keyIndex],
|
|
1557
|
+
primaryKey.keyPath!,
|
|
1558
|
+
rewrittenKey
|
|
1559
|
+
);
|
|
1560
|
+
}*/
|
|
1551
1561
|
}
|
|
1552
1562
|
else if (key[0] === '#') {
|
|
1553
1563
|
// Private ID - translate!
|
|
@@ -1854,7 +1864,7 @@
|
|
|
1854
1864
|
});
|
|
1855
1865
|
db.syncStateChangedEvent.next({
|
|
1856
1866
|
phase: isOnline ? 'error' : 'offline',
|
|
1857
|
-
error,
|
|
1867
|
+
error: new Error('' + (error === null || error === void 0 ? void 0 : error.message) || error),
|
|
1858
1868
|
});
|
|
1859
1869
|
return Promise.reject(error);
|
|
1860
1870
|
}));
|
|
@@ -2670,14 +2680,17 @@
|
|
|
2670
2680
|
*/
|
|
2671
2681
|
function dbOnClosed(db, handler) {
|
|
2672
2682
|
db.on.close.subscribe(handler);
|
|
2673
|
-
|
|
2674
|
-
|
|
2683
|
+
// @ts-ignore
|
|
2684
|
+
const origClose = db._close;
|
|
2685
|
+
// @ts-ignore
|
|
2686
|
+
db._close = function () {
|
|
2675
2687
|
origClose.call(this);
|
|
2676
2688
|
handler();
|
|
2677
2689
|
};
|
|
2678
2690
|
return () => {
|
|
2679
2691
|
db.on.close.unsubscribe(handler);
|
|
2680
|
-
|
|
2692
|
+
// @ts-ignore
|
|
2693
|
+
db._close = origClose;
|
|
2681
2694
|
};
|
|
2682
2695
|
}
|
|
2683
2696
|
|
|
@@ -3586,13 +3599,17 @@
|
|
|
3586
3599
|
return db.cloud.persistedSyncState.pipe(operators.filter((syncState) => (syncState === null || syncState === void 0 ? void 0 : syncState.realms.includes(userLogin.userId)) || false), operators.take(1), operators.map((syncState) => [userLogin, syncState]));
|
|
3587
3600
|
}
|
|
3588
3601
|
return new rxjs.BehaviorSubject([userLogin, syncState]);
|
|
3589
|
-
}), operators.switchMap(([userLogin, syncState]) => __awaiter(this, void 0, void 0, function* () { return [userLogin, yield computeRealmSetHash(syncState)]; })), operators.switchMap(([userLogin, realmSetHash]) =>
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3602
|
+
}), operators.switchMap(([userLogin, syncState]) => __awaiter(this, void 0, void 0, function* () { return [userLogin, yield computeRealmSetHash(syncState)]; })), operators.distinctUntilChanged(([prevUser, prevHash], [currUser, currHash]) => prevUser === currUser && prevHash === currHash), operators.switchMap(([userLogin, realmSetHash]) => {
|
|
3603
|
+
// Let server end query changes from last entry of same client-ID and forward.
|
|
3604
|
+
// If no new entries, server won't bother the client. If new entries, server sends only those
|
|
3605
|
+
// and the baseRev of the last from same client-ID.
|
|
3606
|
+
if (userLogin) {
|
|
3607
|
+
return new WSObservable(db.cloud.options.databaseUrl, db.cloud.persistedSyncState.value.serverRevision, realmSetHash, db.cloud.persistedSyncState.value.clientIdentity, messageProducer, db.cloud.webSocketStatus, userLogin.accessToken, userLogin.accessTokenExpiration);
|
|
3608
|
+
}
|
|
3609
|
+
else {
|
|
3610
|
+
return rxjs.from([]);
|
|
3611
|
+
}
|
|
3612
|
+
}), operators.catchError((error) => {
|
|
3596
3613
|
if ((error === null || error === void 0 ? void 0 : error.name) === 'TokenExpiredError') {
|
|
3597
3614
|
console.debug('WebSocket observable: Token expired. Refreshing token...');
|
|
3598
3615
|
return rxjs.of(true).pipe(operators.switchMap(() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3614,15 +3631,19 @@
|
|
|
3614
3631
|
return rxjs.from(waitAndReconnectWhenUserDoesSomething(error)).pipe(operators.switchMap(() => createObservable()));
|
|
3615
3632
|
}));
|
|
3616
3633
|
}
|
|
3617
|
-
return createObservable().subscribe(
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3634
|
+
return createObservable().subscribe({
|
|
3635
|
+
next: (msg) => {
|
|
3636
|
+
if (msg) {
|
|
3637
|
+
console.debug('WS got message', msg);
|
|
3638
|
+
db.messageConsumer.enqueue(msg);
|
|
3639
|
+
}
|
|
3640
|
+
},
|
|
3641
|
+
error: (error) => {
|
|
3642
|
+
console.error('WS got error', error);
|
|
3643
|
+
},
|
|
3644
|
+
complete: () => {
|
|
3645
|
+
console.debug('WS observable completed');
|
|
3646
|
+
},
|
|
3626
3647
|
});
|
|
3627
3648
|
}
|
|
3628
3649
|
|
|
@@ -4450,7 +4471,7 @@
|
|
|
4450
4471
|
});
|
|
4451
4472
|
const syncComplete = new rxjs.Subject();
|
|
4452
4473
|
dexie.cloud = {
|
|
4453
|
-
version: '4.0.1-beta.
|
|
4474
|
+
version: '4.0.1-beta.46',
|
|
4454
4475
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
4455
4476
|
schema: null,
|
|
4456
4477
|
get currentUserId() {
|
|
@@ -4711,7 +4732,7 @@
|
|
|
4711
4732
|
});
|
|
4712
4733
|
}
|
|
4713
4734
|
}
|
|
4714
|
-
dexieCloud.version = '4.0.1-beta.
|
|
4735
|
+
dexieCloud.version = '4.0.1-beta.46';
|
|
4715
4736
|
Dexie__default["default"].Cloud = dexieCloud;
|
|
4716
4737
|
|
|
4717
4738
|
// In case the SW lives for a while, let it reuse already opened connections:
|