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
|
@@ -2146,7 +2146,7 @@
|
|
|
2146
2146
|
event.next(null);
|
|
2147
2147
|
}
|
|
2148
2148
|
function consumeQueue() {
|
|
2149
|
-
var _a, _b, _c;
|
|
2149
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2150
2150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2151
2151
|
while (queue.length > 0) {
|
|
2152
2152
|
const msg = queue.shift();
|
|
@@ -2178,29 +2178,32 @@
|
|
|
2178
2178
|
// new token. So we don't need to do anything more here.
|
|
2179
2179
|
break;
|
|
2180
2180
|
case 'realm-added':
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2181
|
+
if (!((_a = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _a === void 0 ? void 0 : _a.includes(msg.realm)) &&
|
|
2182
|
+
!((_b = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.inviteRealms) === null || _b === void 0 ? void 0 : _b.includes(msg.realm))) {
|
|
2183
|
+
yield db.cloud.sync({ purpose: 'pull', wait: true });
|
|
2184
|
+
//triggerSync(db, 'pull');
|
|
2185
|
+
}
|
|
2184
2186
|
break;
|
|
2185
2187
|
case 'realm-accepted':
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2188
|
+
if (!((_c = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _c === void 0 ? void 0 : _c.includes(msg.realm))) {
|
|
2189
|
+
yield db.cloud.sync({ purpose: 'pull', wait: true });
|
|
2190
|
+
//triggerSync(db, 'pull');
|
|
2191
|
+
}
|
|
2189
2192
|
break;
|
|
2190
2193
|
case 'realm-removed':
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
(
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
//}
|
|
2194
|
+
if (((_d = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.realms) === null || _d === void 0 ? void 0 : _d.includes(msg.realm)) ||
|
|
2195
|
+
((_e = persistedSyncState === null || persistedSyncState === void 0 ? void 0 : persistedSyncState.inviteRealms) === null || _e === void 0 ? void 0 : _e.includes(msg.realm))) {
|
|
2196
|
+
yield db.cloud.sync({ purpose: 'pull', wait: true });
|
|
2197
|
+
//triggerSync(db, 'pull');
|
|
2198
|
+
}
|
|
2197
2199
|
break;
|
|
2198
2200
|
case 'realms-changed':
|
|
2199
|
-
triggerSync(db, 'pull');
|
|
2201
|
+
//triggerSync(db, 'pull');
|
|
2202
|
+
yield db.cloud.sync({ purpose: 'pull', wait: true });
|
|
2200
2203
|
break;
|
|
2201
2204
|
case 'changes':
|
|
2202
2205
|
console.debug('changes');
|
|
2203
|
-
if (((
|
|
2206
|
+
if (((_f = db.cloud.syncState.value) === null || _f === void 0 ? void 0 : _f.phase) === 'error') {
|
|
2204
2207
|
triggerSync(db, 'pull');
|
|
2205
2208
|
break;
|
|
2206
2209
|
}
|
|
@@ -3002,6 +3005,7 @@
|
|
|
3002
3005
|
if (mode === 'readwrite') {
|
|
3003
3006
|
// Give each transaction a globally unique id.
|
|
3004
3007
|
tx.txid = randomString$1(16);
|
|
3008
|
+
tx.opCount = 0;
|
|
3005
3009
|
// Introduce the concept of current user that lasts through the entire transaction.
|
|
3006
3010
|
// This is important because the tracked mutations must be connected to the user.
|
|
3007
3011
|
tx.currentUser = currentUserObservable.value;
|
|
@@ -3108,6 +3112,7 @@
|
|
|
3108
3112
|
trans.mutationsAdded = true;
|
|
3109
3113
|
const { txid, currentUser: { userId } } = trans;
|
|
3110
3114
|
const { type } = req;
|
|
3115
|
+
const opNo = ++trans.opCount;
|
|
3111
3116
|
return table.mutate(req).then((res) => {
|
|
3112
3117
|
const { numFailures: hasFailures, failures } = res;
|
|
3113
3118
|
let keys = type === 'delete' ? req.keys : res.results;
|
|
@@ -3122,6 +3127,7 @@
|
|
|
3122
3127
|
? {
|
|
3123
3128
|
type: 'delete',
|
|
3124
3129
|
ts,
|
|
3130
|
+
opNo,
|
|
3125
3131
|
keys,
|
|
3126
3132
|
criteria: req.criteria,
|
|
3127
3133
|
txid,
|
|
@@ -3554,10 +3560,13 @@
|
|
|
3554
3560
|
const messageProducer = db.messageConsumer.readyToServe.pipe(operators.filter((isReady) => isReady), // When consumer is ready for new messages, produce such a message to inform server about it
|
|
3555
3561
|
operators.switchMap(() => db.getPersistedSyncState()), // We need the info on which server revision we are at:
|
|
3556
3562
|
operators.filter((syncState) => syncState && syncState.serverRevision), // We wont send anything to server before inital sync has taken place
|
|
3557
|
-
operators.
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3563
|
+
operators.switchMap((syncState) => __awaiter(this, void 0, void 0, function* () {
|
|
3564
|
+
return ({
|
|
3565
|
+
// Produce the message to trigger server to send us new messages to consume:
|
|
3566
|
+
type: 'ready',
|
|
3567
|
+
rev: syncState.serverRevision,
|
|
3568
|
+
realmSetHash: yield computeRealmSetHash(syncState)
|
|
3569
|
+
});
|
|
3561
3570
|
})));
|
|
3562
3571
|
function createObservable() {
|
|
3563
3572
|
return db.cloud.persistedSyncState.pipe(operators.filter((syncState) => syncState === null || syncState === void 0 ? void 0 : syncState.serverRevision), // Don't connect before there's no initial sync performed.
|
|
@@ -4434,7 +4443,7 @@
|
|
|
4434
4443
|
});
|
|
4435
4444
|
const syncComplete = new rxjs.Subject();
|
|
4436
4445
|
dexie.cloud = {
|
|
4437
|
-
version: '4.0.1-beta.
|
|
4446
|
+
version: '4.0.1-beta.41',
|
|
4438
4447
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
4439
4448
|
schema: null,
|
|
4440
4449
|
get currentUserId() {
|
|
@@ -4695,7 +4704,7 @@
|
|
|
4695
4704
|
});
|
|
4696
4705
|
}
|
|
4697
4706
|
}
|
|
4698
|
-
dexieCloud.version = '4.0.1-beta.
|
|
4707
|
+
dexieCloud.version = '4.0.1-beta.41';
|
|
4699
4708
|
Dexie__default["default"].Cloud = dexieCloud;
|
|
4700
4709
|
|
|
4701
4710
|
// In case the SW lives for a while, let it reuse already opened connections:
|