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
|
@@ -1539,9 +1539,19 @@ function encodeIdsForServer(schema, currentUser, changes) {
|
|
|
1539
1539
|
const mutClone = changeClone.muts[mutIndex];
|
|
1540
1540
|
const rewrittenKey = JSON.stringify(key);
|
|
1541
1541
|
mutClone.keys[keyIndex] = rewrittenKey;
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1542
|
+
/* Bug (#1777)
|
|
1543
|
+
We should not rewrite values. It will fail because the key is array and the value is string.
|
|
1544
|
+
Only the keys should be rewritten and it's already done on the server.
|
|
1545
|
+
We should take another round of revieweing how key transformations are being done between
|
|
1546
|
+
client and server and let the server do the key transformations entirely instead now that
|
|
1547
|
+
we have the primary key schema on the server making it possible to do so.
|
|
1548
|
+
if (rewriteValues) {
|
|
1549
|
+
Dexie.setByKeyPath(
|
|
1550
|
+
(mutClone as DBInsertOperation).values[keyIndex],
|
|
1551
|
+
primaryKey.keyPath!,
|
|
1552
|
+
rewrittenKey
|
|
1553
|
+
);
|
|
1554
|
+
}*/
|
|
1545
1555
|
}
|
|
1546
1556
|
else if (key[0] === '#') {
|
|
1547
1557
|
// Private ID - translate!
|
|
@@ -1848,7 +1858,7 @@ function sync(db, options, schema, syncOptions) {
|
|
|
1848
1858
|
});
|
|
1849
1859
|
db.syncStateChangedEvent.next({
|
|
1850
1860
|
phase: isOnline ? 'error' : 'offline',
|
|
1851
|
-
error,
|
|
1861
|
+
error: new Error('' + (error === null || error === void 0 ? void 0 : error.message) || error),
|
|
1852
1862
|
});
|
|
1853
1863
|
return Promise.reject(error);
|
|
1854
1864
|
}));
|
|
@@ -2664,14 +2674,17 @@ const DISABLE_SERVICEWORKER_STRATEGY = (isSafari && safariVersion <= 605) || //
|
|
|
2664
2674
|
*/
|
|
2665
2675
|
function dbOnClosed(db, handler) {
|
|
2666
2676
|
db.on.close.subscribe(handler);
|
|
2667
|
-
|
|
2668
|
-
|
|
2677
|
+
// @ts-ignore
|
|
2678
|
+
const origClose = db._close;
|
|
2679
|
+
// @ts-ignore
|
|
2680
|
+
db._close = function () {
|
|
2669
2681
|
origClose.call(this);
|
|
2670
2682
|
handler();
|
|
2671
2683
|
};
|
|
2672
2684
|
return () => {
|
|
2673
2685
|
db.on.close.unsubscribe(handler);
|
|
2674
|
-
|
|
2686
|
+
// @ts-ignore
|
|
2687
|
+
db._close = origClose;
|
|
2675
2688
|
};
|
|
2676
2689
|
}
|
|
2677
2690
|
|
|
@@ -3580,13 +3593,17 @@ function connectWebSocket(db) {
|
|
|
3580
3593
|
return db.cloud.persistedSyncState.pipe(filter((syncState) => (syncState === null || syncState === void 0 ? void 0 : syncState.realms.includes(userLogin.userId)) || false), take(1), map((syncState) => [userLogin, syncState]));
|
|
3581
3594
|
}
|
|
3582
3595
|
return new BehaviorSubject([userLogin, syncState]);
|
|
3583
|
-
}), switchMap(([userLogin, syncState]) => __awaiter(this, void 0, void 0, function* () { return [userLogin, yield computeRealmSetHash(syncState)]; })), switchMap(([userLogin, realmSetHash]) =>
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3596
|
+
}), switchMap(([userLogin, syncState]) => __awaiter(this, void 0, void 0, function* () { return [userLogin, yield computeRealmSetHash(syncState)]; })), distinctUntilChanged(([prevUser, prevHash], [currUser, currHash]) => prevUser === currUser && prevHash === currHash), switchMap(([userLogin, realmSetHash]) => {
|
|
3597
|
+
// Let server end query changes from last entry of same client-ID and forward.
|
|
3598
|
+
// If no new entries, server won't bother the client. If new entries, server sends only those
|
|
3599
|
+
// and the baseRev of the last from same client-ID.
|
|
3600
|
+
if (userLogin) {
|
|
3601
|
+
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);
|
|
3602
|
+
}
|
|
3603
|
+
else {
|
|
3604
|
+
return from([]);
|
|
3605
|
+
}
|
|
3606
|
+
}), catchError((error) => {
|
|
3590
3607
|
if ((error === null || error === void 0 ? void 0 : error.name) === 'TokenExpiredError') {
|
|
3591
3608
|
console.debug('WebSocket observable: Token expired. Refreshing token...');
|
|
3592
3609
|
return of(true).pipe(switchMap(() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3608,15 +3625,19 @@ function connectWebSocket(db) {
|
|
|
3608
3625
|
return from(waitAndReconnectWhenUserDoesSomething(error)).pipe(switchMap(() => createObservable()));
|
|
3609
3626
|
}));
|
|
3610
3627
|
}
|
|
3611
|
-
return createObservable().subscribe(
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3628
|
+
return createObservable().subscribe({
|
|
3629
|
+
next: (msg) => {
|
|
3630
|
+
if (msg) {
|
|
3631
|
+
console.debug('WS got message', msg);
|
|
3632
|
+
db.messageConsumer.enqueue(msg);
|
|
3633
|
+
}
|
|
3634
|
+
},
|
|
3635
|
+
error: (error) => {
|
|
3636
|
+
console.error('WS got error', error);
|
|
3637
|
+
},
|
|
3638
|
+
complete: () => {
|
|
3639
|
+
console.debug('WS observable completed');
|
|
3640
|
+
},
|
|
3620
3641
|
});
|
|
3621
3642
|
}
|
|
3622
3643
|
|
|
@@ -4444,7 +4465,7 @@ function dexieCloud(dexie) {
|
|
|
4444
4465
|
});
|
|
4445
4466
|
const syncComplete = new Subject();
|
|
4446
4467
|
dexie.cloud = {
|
|
4447
|
-
version: '4.0.1-beta.
|
|
4468
|
+
version: '4.0.1-beta.46',
|
|
4448
4469
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
4449
4470
|
schema: null,
|
|
4450
4471
|
get currentUserId() {
|
|
@@ -4705,7 +4726,7 @@ function dexieCloud(dexie) {
|
|
|
4705
4726
|
});
|
|
4706
4727
|
}
|
|
4707
4728
|
}
|
|
4708
|
-
dexieCloud.version = '4.0.1-beta.
|
|
4729
|
+
dexieCloud.version = '4.0.1-beta.46';
|
|
4709
4730
|
Dexie.Cloud = dexieCloud;
|
|
4710
4731
|
|
|
4711
4732
|
// In case the SW lives for a while, let it reuse already opened connections:
|