@absolutejs/sync 2.0.1 → 2.2.0
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/engine/collection.d.ts +14 -1
- package/dist/engine/devtools.d.ts +15 -0
- package/dist/engine/index.js +26 -2
- package/dist/engine/index.js.map +4 -4
- package/dist/index.js +26 -2
- package/dist/index.js.map +3 -3
- package/dist/testing.js +26 -2
- package/dist/testing.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1375,6 +1375,9 @@ var createSyncEngine = (options = {}) => {
|
|
|
1375
1375
|
let mutationsFailed = 0;
|
|
1376
1376
|
let mutationsRetried = 0;
|
|
1377
1377
|
let mutationsInFlight = 0;
|
|
1378
|
+
let connectedSources = 0;
|
|
1379
|
+
let sourceChangesReceived = 0;
|
|
1380
|
+
let sourceLastChangeAt = null;
|
|
1378
1381
|
const mutationWaiters = [];
|
|
1379
1382
|
let mutationsQueued = 0;
|
|
1380
1383
|
const activeFences = new Set;
|
|
@@ -1560,6 +1563,9 @@ var createSyncEngine = (options = {}) => {
|
|
|
1560
1563
|
return subscription.view.reset(await subscription.rehydrate());
|
|
1561
1564
|
}
|
|
1562
1565
|
}
|
|
1566
|
+
if (subscription.affects && !subscription.affects(change)) {
|
|
1567
|
+
return EMPTY_DIFF;
|
|
1568
|
+
}
|
|
1563
1569
|
return subscription.view.reset(await subscription.rehydrate());
|
|
1564
1570
|
};
|
|
1565
1571
|
const subscriptionsForTable = function* (table) {
|
|
@@ -2352,6 +2358,7 @@ var createSyncEngine = (options = {}) => {
|
|
|
2352
2358
|
return readRule ? rows.filter((row) => readRule(ctx, row)) : rows;
|
|
2353
2359
|
};
|
|
2354
2360
|
const incremental = match !== undefined && tables.length === 1;
|
|
2361
|
+
const boundAffects = !incremental && definition.affects ? (change) => definition.affects(change, params, ctx) : undefined;
|
|
2355
2362
|
const boundMatch = incremental ? (row) => match(row, params, ctx) && (readRule ? readRule(ctx, row) : true) : () => true;
|
|
2356
2363
|
const view = createMaterializedView({
|
|
2357
2364
|
key,
|
|
@@ -2366,6 +2373,7 @@ var createSyncEngine = (options = {}) => {
|
|
|
2366
2373
|
view,
|
|
2367
2374
|
incremental,
|
|
2368
2375
|
rehydrate,
|
|
2376
|
+
...boundAffects ? { affects: boundAffects } : {},
|
|
2369
2377
|
key,
|
|
2370
2378
|
onDiff: typedOnDiff
|
|
2371
2379
|
};
|
|
@@ -2428,8 +2436,18 @@ var createSyncEngine = (options = {}) => {
|
|
|
2428
2436
|
},
|
|
2429
2437
|
applyChange: (table, change) => applyChange(table, change),
|
|
2430
2438
|
connectSource: async (source) => {
|
|
2431
|
-
await source.start((table, change) =>
|
|
2439
|
+
await source.start((table, change) => {
|
|
2440
|
+
sourceChangesReceived += 1;
|
|
2441
|
+
sourceLastChangeAt = Date.now();
|
|
2442
|
+
return applyChange(table, change);
|
|
2443
|
+
});
|
|
2444
|
+
connectedSources += 1;
|
|
2445
|
+
let stopped = false;
|
|
2432
2446
|
return async () => {
|
|
2447
|
+
if (!stopped) {
|
|
2448
|
+
stopped = true;
|
|
2449
|
+
connectedSources -= 1;
|
|
2450
|
+
}
|
|
2433
2451
|
await source.stop();
|
|
2434
2452
|
};
|
|
2435
2453
|
},
|
|
@@ -2990,6 +3008,12 @@ var createSyncEngine = (options = {}) => {
|
|
|
2990
3008
|
schedules: {
|
|
2991
3009
|
registered: schedules.size
|
|
2992
3010
|
},
|
|
3011
|
+
source: {
|
|
3012
|
+
changesReceived: sourceChangesReceived,
|
|
3013
|
+
connected: connectedSources,
|
|
3014
|
+
lastChangeAgeMs: sourceLastChangeAt === null ? null : now - sourceLastChangeAt,
|
|
3015
|
+
lastChangeAt: sourceLastChangeAt
|
|
3016
|
+
},
|
|
2993
3017
|
subscriptions: {
|
|
2994
3018
|
byCollection,
|
|
2995
3019
|
byTenant: Object.fromEntries(subscriptionsByTenant),
|
|
@@ -3486,5 +3510,5 @@ export {
|
|
|
3486
3510
|
createPresenceHub
|
|
3487
3511
|
};
|
|
3488
3512
|
|
|
3489
|
-
//# debugId=
|
|
3513
|
+
//# debugId=118C044CD5328F8B64756E2164756E21
|
|
3490
3514
|
//# sourceMappingURL=index.js.map
|