dexie-cloud-addon 4.0.1-beta.39 → 4.0.1-beta.41
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 +31 -22
- 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 +30 -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/types/WSObservable.d.ts +1 -0
- package/dist/types/types/TXExpandos.d.ts +1 -0
- package/dist/umd/dexie-cloud-addon.js +31 -22
- 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 +30 -21
- 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 +2 -2
|
@@ -2140,7 +2140,7 @@ function MessagesFromServerConsumer(db) {
|
|
|
2140
2140
|
event.next(null);
|
|
2141
2141
|
}
|
|
2142
2142
|
function consumeQueue() {
|
|
2143
|
-
var _a, _b, _c;
|
|
2143
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2144
2144
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2145
2145
|
while (queue.length > 0) {
|
|
2146
2146
|
const msg = queue.shift();
|
|
@@ -2172,29 +2172,32 @@ function MessagesFromServerConsumer(db) {
|
|
|
2172
2172
|
// new token. So we don't need to do anything more here.
|
|
2173
2173
|
break;
|
|
2174
2174
|
case 'realm-added':
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2175
|
+
if (!((_a = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _a === void 0 ? void 0 : _a.includes(msg.realm)) &&
|
|
2176
|
+
!((_b = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.inviteRealms) === null || _b === void 0 ? void 0 : _b.includes(msg.realm))) {
|
|
2177
|
+
yield db.cloud.sync({ purpose: 'pull', wait: true });
|
|
2178
|
+
//triggerSync(db, 'pull');
|
|
2179
|
+
}
|
|
2178
2180
|
break;
|
|
2179
2181
|
case 'realm-accepted':
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2182
|
+
if (!((_c = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _c === void 0 ? void 0 : _c.includes(msg.realm))) {
|
|
2183
|
+
yield db.cloud.sync({ purpose: 'pull', wait: true });
|
|
2184
|
+
//triggerSync(db, 'pull');
|
|
2185
|
+
}
|
|
2183
2186
|
break;
|
|
2184
2187
|
case 'realm-removed':
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
(
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
//}
|
|
2188
|
+
if (((_d = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _d === void 0 ? void 0 : _d.includes(msg.realm)) ||
|
|
2189
|
+
((_e = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.inviteRealms) === null || _e === void 0 ? void 0 : _e.includes(msg.realm))) {
|
|
2190
|
+
yield db.cloud.sync({ purpose: 'pull', wait: true });
|
|
2191
|
+
//triggerSync(db, 'pull');
|
|
2192
|
+
}
|
|
2191
2193
|
break;
|
|
2192
2194
|
case 'realms-changed':
|
|
2193
|
-
triggerSync(db, 'pull');
|
|
2195
|
+
//triggerSync(db, 'pull');
|
|
2196
|
+
yield db.cloud.sync({ purpose: 'pull', wait: true });
|
|
2194
2197
|
break;
|
|
2195
2198
|
case 'changes':
|
|
2196
2199
|
console.debug('changes');
|
|
2197
|
-
if (((
|
|
2200
|
+
if (((_f = db.cloud.syncState.value) === null || _f === void 0 ? void 0 : _f.phase) === 'error') {
|
|
2198
2201
|
triggerSync(db, 'pull');
|
|
2199
2202
|
break;
|
|
2200
2203
|
}
|
|
@@ -2996,6 +2999,7 @@ function createMutationTrackingMiddleware({ currentUserObservable, db }) {
|
|
|
2996
2999
|
if (mode === 'readwrite') {
|
|
2997
3000
|
// Give each transaction a globally unique id.
|
|
2998
3001
|
tx.txid = randomString$1(16);
|
|
3002
|
+
tx.opCount = 0;
|
|
2999
3003
|
// Introduce the concept of current user that lasts through the entire transaction.
|
|
3000
3004
|
// This is important because the tracked mutations must be connected to the user.
|
|
3001
3005
|
tx.currentUser = currentUserObservable.value;
|
|
@@ -3102,6 +3106,7 @@ function createMutationTrackingMiddleware({ currentUserObservable, db }) {
|
|
|
3102
3106
|
trans.mutationsAdded = true;
|
|
3103
3107
|
const { txid, currentUser: { userId } } = trans;
|
|
3104
3108
|
const { type } = req;
|
|
3109
|
+
const opNo = ++trans.opCount;
|
|
3105
3110
|
return table.mutate(req).then((res) => {
|
|
3106
3111
|
const { numFailures: hasFailures, failures } = res;
|
|
3107
3112
|
let keys = type === 'delete' ? req.keys : res.results;
|
|
@@ -3116,6 +3121,7 @@ function createMutationTrackingMiddleware({ currentUserObservable, db }) {
|
|
|
3116
3121
|
? {
|
|
3117
3122
|
type: 'delete',
|
|
3118
3123
|
ts,
|
|
3124
|
+
opNo,
|
|
3119
3125
|
keys,
|
|
3120
3126
|
criteria: req.criteria,
|
|
3121
3127
|
txid,
|
|
@@ -3548,10 +3554,13 @@ function connectWebSocket(db) {
|
|
|
3548
3554
|
const messageProducer = db.messageConsumer.readyToServe.pipe(filter((isReady) => isReady), // When consumer is ready for new messages, produce such a message to inform server about it
|
|
3549
3555
|
switchMap(() => db.getPersistedSyncState()), // We need the info on which server revision we are at:
|
|
3550
3556
|
filter((syncState) => syncState && syncState.serverRevision), // We wont send anything to server before inital sync has taken place
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3557
|
+
switchMap((syncState) => __awaiter(this, void 0, void 0, function* () {
|
|
3558
|
+
return ({
|
|
3559
|
+
// Produce the message to trigger server to send us new messages to consume:
|
|
3560
|
+
type: 'ready',
|
|
3561
|
+
rev: syncState.serverRevision,
|
|
3562
|
+
realmSetHash: yield computeRealmSetHash(syncState)
|
|
3563
|
+
});
|
|
3555
3564
|
})));
|
|
3556
3565
|
function createObservable() {
|
|
3557
3566
|
return db.cloud.persistedSyncState.pipe(filter((syncState) => syncState === null || syncState === void 0 ? void 0 : syncState.serverRevision), // Don't connect before there's no initial sync performed.
|
|
@@ -4428,7 +4437,7 @@ function dexieCloud(dexie) {
|
|
|
4428
4437
|
});
|
|
4429
4438
|
const syncComplete = new Subject();
|
|
4430
4439
|
dexie.cloud = {
|
|
4431
|
-
version: '4.0.1-beta.
|
|
4440
|
+
version: '4.0.1-beta.41',
|
|
4432
4441
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
4433
4442
|
schema: null,
|
|
4434
4443
|
get currentUserId() {
|
|
@@ -4689,7 +4698,7 @@ function dexieCloud(dexie) {
|
|
|
4689
4698
|
});
|
|
4690
4699
|
}
|
|
4691
4700
|
}
|
|
4692
|
-
dexieCloud.version = '4.0.1-beta.
|
|
4701
|
+
dexieCloud.version = '4.0.1-beta.41';
|
|
4693
4702
|
Dexie.Cloud = dexieCloud;
|
|
4694
4703
|
|
|
4695
4704
|
// In case the SW lives for a while, let it reuse already opened connections:
|