dexie-cloud-addon 4.1.0-alpha.20 → 4.1.0-alpha.21
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 +42 -12
- 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 +42 -12
- 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/modern/yjs/applyYMessages.d.ts +4 -1
- package/dist/umd/dexie-cloud-addon.js +42 -12
- 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 +42 -12
- 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/dist/umd/yjs/applyYMessages.d.ts +4 -1
- package/package.json +2 -2
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* ==========================================================================
|
|
10
10
|
*
|
|
11
|
-
* Version 4.1.0-alpha.
|
|
11
|
+
* Version 4.1.0-alpha.21, Mon Nov 18 2024
|
|
12
12
|
*
|
|
13
13
|
* https://dexie.org
|
|
14
14
|
*
|
|
@@ -2754,13 +2754,17 @@ const writeAny = (encoder, data) => {
|
|
|
2754
2754
|
function encodeYMessage(msg) {
|
|
2755
2755
|
const encoder = new Encoder();
|
|
2756
2756
|
writeVarString(encoder, msg.type);
|
|
2757
|
-
|
|
2758
|
-
|
|
2757
|
+
if ('table' in msg)
|
|
2758
|
+
writeVarString(encoder, msg.table);
|
|
2759
|
+
if ('prop' in msg)
|
|
2760
|
+
writeVarString(encoder, msg.prop);
|
|
2759
2761
|
switch (msg.type) {
|
|
2760
2762
|
case 'u-ack':
|
|
2761
2763
|
case 'u-reject':
|
|
2762
2764
|
writeBigUint64(encoder, BigInt(msg.i));
|
|
2763
2765
|
break;
|
|
2766
|
+
case 'outdated-server-rev':
|
|
2767
|
+
break;
|
|
2764
2768
|
default:
|
|
2765
2769
|
writeAny(encoder, msg.k);
|
|
2766
2770
|
switch (msg.type) {
|
|
@@ -3104,6 +3108,9 @@ const readAny = decoder => readAnyLookupTable[127 - readUint8(decoder)](decoder)
|
|
|
3104
3108
|
function decodeYMessage(a) {
|
|
3105
3109
|
const decoder = new Decoder(a);
|
|
3106
3110
|
const type = readVarString(decoder);
|
|
3111
|
+
if (type === 'outdated-server-rev') {
|
|
3112
|
+
return { type };
|
|
3113
|
+
}
|
|
3107
3114
|
const table = readVarString(decoder);
|
|
3108
3115
|
const prop = readVarString(decoder);
|
|
3109
3116
|
switch (type) {
|
|
@@ -4754,12 +4761,13 @@ function getUpdatesTable(db, table, ydocProp) {
|
|
|
4754
4761
|
function applyYServerMessages(yMessages, db) {
|
|
4755
4762
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4756
4763
|
var _a;
|
|
4757
|
-
const
|
|
4764
|
+
const receivedUntils = {};
|
|
4765
|
+
let resyncNeeded = false;
|
|
4758
4766
|
for (const m of yMessages) {
|
|
4759
4767
|
switch (m.type) {
|
|
4760
4768
|
case 'u-s': {
|
|
4761
4769
|
const utbl = getUpdatesTable(db, m.table, m.prop);
|
|
4762
|
-
|
|
4770
|
+
receivedUntils[utbl.name] = yield utbl.add({
|
|
4763
4771
|
k: m.k,
|
|
4764
4772
|
u: m.u,
|
|
4765
4773
|
});
|
|
@@ -4788,13 +4796,13 @@ function applyYServerMessages(yMessages, db) {
|
|
|
4788
4796
|
// and destroy it's open document if there is one.
|
|
4789
4797
|
const primaryKey = (_a = (yield utbl.get(m.i))) === null || _a === void 0 ? void 0 : _a.k;
|
|
4790
4798
|
if (primaryKey != null) {
|
|
4791
|
-
yield db.transaction('rw', utbl, tx => {
|
|
4799
|
+
yield db.transaction('rw', utbl, (tx) => {
|
|
4792
4800
|
// @ts-ignore
|
|
4793
4801
|
tx.idbtrans._rejecting_y_ypdate = true; // Inform ydoc triggers that we delete because of a rejection and not GC
|
|
4794
4802
|
return utbl
|
|
4795
4803
|
.where('i')
|
|
4796
4804
|
.aboveOrEqual(m.i)
|
|
4797
|
-
.filter(u => cmp(u.k, primaryKey) === 0 && ((u.f || 0) & 1) === 1)
|
|
4805
|
+
.filter((u) => cmp(u.k, primaryKey) === 0 && ((u.f || 0) & 1) === 1)
|
|
4798
4806
|
.delete();
|
|
4799
4807
|
});
|
|
4800
4808
|
// Destroy active doc
|
|
@@ -4811,9 +4819,15 @@ function applyYServerMessages(yMessages, db) {
|
|
|
4811
4819
|
}
|
|
4812
4820
|
break;
|
|
4813
4821
|
}
|
|
4822
|
+
case 'outdated-server-rev':
|
|
4823
|
+
resyncNeeded = true;
|
|
4824
|
+
break;
|
|
4814
4825
|
}
|
|
4815
4826
|
}
|
|
4816
|
-
return
|
|
4827
|
+
return {
|
|
4828
|
+
receivedUntils,
|
|
4829
|
+
resyncNeeded,
|
|
4830
|
+
};
|
|
4817
4831
|
});
|
|
4818
4832
|
}
|
|
4819
4833
|
|
|
@@ -5220,11 +5234,14 @@ function _sync(db_1, options_1, schema_1) {
|
|
|
5220
5234
|
//
|
|
5221
5235
|
// apply yMessages
|
|
5222
5236
|
//
|
|
5223
|
-
const receivedUntils = yield applyYServerMessages(res.yMessages, db);
|
|
5237
|
+
const { receivedUntils, resyncNeeded } = yield applyYServerMessages(res.yMessages, db);
|
|
5224
5238
|
//
|
|
5225
5239
|
// update Y SyncStates
|
|
5226
5240
|
//
|
|
5227
5241
|
yield updateYSyncStates(lastUpdateIds, receivedUntils, db, res.serverRevision);
|
|
5242
|
+
if (resyncNeeded) {
|
|
5243
|
+
newSyncState.yDownloadedRealms = {}; // Will trigger a full download of Y-documents below...
|
|
5244
|
+
}
|
|
5228
5245
|
}
|
|
5229
5246
|
//
|
|
5230
5247
|
// Update regular syncState
|
|
@@ -6979,6 +6996,10 @@ class WSConnection extends Subscription$1 {
|
|
|
6979
6996
|
else if (msg.type === 'u-ack' || msg.type === 'u-reject' || msg.type === 'u-s' || msg.type === 'in-sync') {
|
|
6980
6997
|
applyYServerMessages([msg], this.db);
|
|
6981
6998
|
}
|
|
6999
|
+
else if (msg.type === 'outdated-server-rev') {
|
|
7000
|
+
// Won't happen but need this for typing.
|
|
7001
|
+
throw new Error('Outdated server revision not expected over WebSocket - only in sync using fetch()');
|
|
7002
|
+
}
|
|
6982
7003
|
else if (msg.type !== 'pong') {
|
|
6983
7004
|
this.subscriber.next(msg);
|
|
6984
7005
|
}
|
|
@@ -7021,12 +7042,19 @@ class WSConnection extends Subscription$1 {
|
|
|
7021
7042
|
else {
|
|
7022
7043
|
// If it's not a "ready" message, it's an YMessage.
|
|
7023
7044
|
// YMessages can be sent binary encoded.
|
|
7045
|
+
if (msg.type === 'u-c') {
|
|
7046
|
+
console.log("u-c:B", ++gotClientUpdateB);
|
|
7047
|
+
}
|
|
7024
7048
|
(_b = this.ws) === null || _b === void 0 ? void 0 : _b.send(encodeYMessage(msg));
|
|
7025
7049
|
}
|
|
7026
7050
|
}
|
|
7027
7051
|
}));
|
|
7028
7052
|
if (this.user.isLoggedIn && !isEagerSyncDisabled(this.db)) {
|
|
7029
|
-
this.subscriptions.add(createYClientUpdateObservable(this.db).
|
|
7053
|
+
this.subscriptions.add(createYClientUpdateObservable(this.db).pipe(tap$1((msg) => {
|
|
7054
|
+
if (msg.type === 'u-c') {
|
|
7055
|
+
console.log("u-c:A", ++gotClientUpdateA, msg.i);
|
|
7056
|
+
}
|
|
7057
|
+
})).subscribe(this.db.messageProducer));
|
|
7030
7058
|
}
|
|
7031
7059
|
}
|
|
7032
7060
|
catch (error) {
|
|
@@ -7035,6 +7063,8 @@ class WSConnection extends Subscription$1 {
|
|
|
7035
7063
|
});
|
|
7036
7064
|
}
|
|
7037
7065
|
}
|
|
7066
|
+
let gotClientUpdateA = 0;
|
|
7067
|
+
let gotClientUpdateB = 0;
|
|
7038
7068
|
|
|
7039
7069
|
class InvalidLicenseError extends Error {
|
|
7040
7070
|
constructor(license) {
|
|
@@ -8090,7 +8120,7 @@ function dexieCloud(dexie) {
|
|
|
8090
8120
|
const syncComplete = new Subject();
|
|
8091
8121
|
dexie.cloud = {
|
|
8092
8122
|
// @ts-ignore
|
|
8093
|
-
version: "4.1.0-alpha.
|
|
8123
|
+
version: "4.1.0-alpha.21",
|
|
8094
8124
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
8095
8125
|
schema: null,
|
|
8096
8126
|
get currentUserId() {
|
|
@@ -8392,7 +8422,7 @@ function dexieCloud(dexie) {
|
|
|
8392
8422
|
}
|
|
8393
8423
|
}
|
|
8394
8424
|
// @ts-ignore
|
|
8395
|
-
dexieCloud.version = "4.1.0-alpha.
|
|
8425
|
+
dexieCloud.version = "4.1.0-alpha.21";
|
|
8396
8426
|
Dexie.Cloud = dexieCloud;
|
|
8397
8427
|
|
|
8398
8428
|
// In case the SW lives for a while, let it reuse already opened connections:
|