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
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* ==========================================================================
|
|
10
10
|
*
|
|
11
|
-
* Version 4.0.1-beta.
|
|
11
|
+
* Version 4.0.1-beta.46, Sat Aug 05 2023
|
|
12
12
|
*
|
|
13
13
|
* https://dexie.org
|
|
14
14
|
*
|
|
@@ -3406,9 +3406,19 @@ function encodeIdsForServer(schema, currentUser, changes) {
|
|
|
3406
3406
|
const mutClone = changeClone.muts[mutIndex];
|
|
3407
3407
|
const rewrittenKey = JSON.stringify(key);
|
|
3408
3408
|
mutClone.keys[keyIndex] = rewrittenKey;
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3409
|
+
/* Bug (#1777)
|
|
3410
|
+
We should not rewrite values. It will fail because the key is array and the value is string.
|
|
3411
|
+
Only the keys should be rewritten and it's already done on the server.
|
|
3412
|
+
We should take another round of revieweing how key transformations are being done between
|
|
3413
|
+
client and server and let the server do the key transformations entirely instead now that
|
|
3414
|
+
we have the primary key schema on the server making it possible to do so.
|
|
3415
|
+
if (rewriteValues) {
|
|
3416
|
+
Dexie.setByKeyPath(
|
|
3417
|
+
(mutClone as DBInsertOperation).values[keyIndex],
|
|
3418
|
+
primaryKey.keyPath!,
|
|
3419
|
+
rewrittenKey
|
|
3420
|
+
);
|
|
3421
|
+
}*/
|
|
3412
3422
|
}
|
|
3413
3423
|
else if (key[0] === '#') {
|
|
3414
3424
|
// Private ID - translate!
|
|
@@ -3715,7 +3725,7 @@ function sync(db, options, schema, syncOptions) {
|
|
|
3715
3725
|
});
|
|
3716
3726
|
db.syncStateChangedEvent.next({
|
|
3717
3727
|
phase: isOnline ? 'error' : 'offline',
|
|
3718
|
-
error,
|
|
3728
|
+
error: new Error('' + (error === null || error === void 0 ? void 0 : error.message) || error),
|
|
3719
3729
|
});
|
|
3720
3730
|
return Promise.reject(error);
|
|
3721
3731
|
}));
|
|
@@ -4302,14 +4312,17 @@ const DISABLE_SERVICEWORKER_STRATEGY = (isSafari && safariVersion <= 605) || //
|
|
|
4302
4312
|
*/
|
|
4303
4313
|
function dbOnClosed(db, handler) {
|
|
4304
4314
|
db.on.close.subscribe(handler);
|
|
4305
|
-
|
|
4306
|
-
|
|
4315
|
+
// @ts-ignore
|
|
4316
|
+
const origClose = db._close;
|
|
4317
|
+
// @ts-ignore
|
|
4318
|
+
db._close = function () {
|
|
4307
4319
|
origClose.call(this);
|
|
4308
4320
|
handler();
|
|
4309
4321
|
};
|
|
4310
4322
|
return () => {
|
|
4311
4323
|
db.on.close.unsubscribe(handler);
|
|
4312
|
-
|
|
4324
|
+
// @ts-ignore
|
|
4325
|
+
db._close = origClose;
|
|
4313
4326
|
};
|
|
4314
4327
|
}
|
|
4315
4328
|
|
|
@@ -5218,13 +5231,17 @@ function connectWebSocket(db) {
|
|
|
5218
5231
|
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]));
|
|
5219
5232
|
}
|
|
5220
5233
|
return new BehaviorSubject([userLogin, syncState]);
|
|
5221
|
-
}), switchMap(([userLogin, syncState]) => __awaiter(this, void 0, void 0, function* () { return [userLogin, yield computeRealmSetHash(syncState)]; })), switchMap(([userLogin, realmSetHash]) =>
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5234
|
+
}), 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]) => {
|
|
5235
|
+
// Let server end query changes from last entry of same client-ID and forward.
|
|
5236
|
+
// If no new entries, server won't bother the client. If new entries, server sends only those
|
|
5237
|
+
// and the baseRev of the last from same client-ID.
|
|
5238
|
+
if (userLogin) {
|
|
5239
|
+
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);
|
|
5240
|
+
}
|
|
5241
|
+
else {
|
|
5242
|
+
return from$1([]);
|
|
5243
|
+
}
|
|
5244
|
+
}), catchError((error) => {
|
|
5228
5245
|
if ((error === null || error === void 0 ? void 0 : error.name) === 'TokenExpiredError') {
|
|
5229
5246
|
console.debug('WebSocket observable: Token expired. Refreshing token...');
|
|
5230
5247
|
return of(true).pipe(switchMap(() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -5246,15 +5263,19 @@ function connectWebSocket(db) {
|
|
|
5246
5263
|
return from$1(waitAndReconnectWhenUserDoesSomething(error)).pipe(switchMap(() => createObservable()));
|
|
5247
5264
|
}));
|
|
5248
5265
|
}
|
|
5249
|
-
return createObservable().subscribe(
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5266
|
+
return createObservable().subscribe({
|
|
5267
|
+
next: (msg) => {
|
|
5268
|
+
if (msg) {
|
|
5269
|
+
console.debug('WS got message', msg);
|
|
5270
|
+
db.messageConsumer.enqueue(msg);
|
|
5271
|
+
}
|
|
5272
|
+
},
|
|
5273
|
+
error: (error) => {
|
|
5274
|
+
console.error('WS got error', error);
|
|
5275
|
+
},
|
|
5276
|
+
complete: () => {
|
|
5277
|
+
console.debug('WS observable completed');
|
|
5278
|
+
},
|
|
5258
5279
|
});
|
|
5259
5280
|
}
|
|
5260
5281
|
|
|
@@ -6089,7 +6110,7 @@ function dexieCloud(dexie) {
|
|
|
6089
6110
|
});
|
|
6090
6111
|
const syncComplete = new Subject();
|
|
6091
6112
|
dexie.cloud = {
|
|
6092
|
-
version: '4.0.1-beta.
|
|
6113
|
+
version: '4.0.1-beta.46',
|
|
6093
6114
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
6094
6115
|
schema: null,
|
|
6095
6116
|
get currentUserId() {
|
|
@@ -6350,7 +6371,7 @@ function dexieCloud(dexie) {
|
|
|
6350
6371
|
});
|
|
6351
6372
|
}
|
|
6352
6373
|
}
|
|
6353
|
-
dexieCloud.version = '4.0.1-beta.
|
|
6374
|
+
dexieCloud.version = '4.0.1-beta.46';
|
|
6354
6375
|
Dexie.Cloud = dexieCloud;
|
|
6355
6376
|
|
|
6356
6377
|
export { dexieCloud as default, dexieCloud, getTiedObjectId, getTiedRealmId };
|