@vibes.diy/vibe-runtime 14.3.344 → 14.3.345
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/package.json +4 -4
- package/sync-engine.js +4 -3
- package/write-receipts.d.ts +2 -0
- package/write-receipts.js +9 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibes.diy/vibe-runtime",
|
|
3
|
-
"version": "14.3.
|
|
3
|
+
"version": "14.3.345",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@adviser/cement": "~0.5.37",
|
|
39
|
-
"@vibes.diy/api-types": "14.3.
|
|
40
|
-
"@vibes.diy/base": "14.3.
|
|
41
|
-
"@vibes.diy/vibe-types": "14.3.
|
|
39
|
+
"@vibes.diy/api-types": "14.3.345",
|
|
40
|
+
"@vibes.diy/base": "14.3.345",
|
|
41
|
+
"@vibes.diy/vibe-types": "14.3.345",
|
|
42
42
|
"arktype": "~2.2.9",
|
|
43
43
|
"charwise": "~3.0.1",
|
|
44
44
|
"es-module-lexer": "~3.0.4",
|
package/sync-engine.js
CHANGED
|
@@ -526,10 +526,11 @@ export class SyncEngine {
|
|
|
526
526
|
}
|
|
527
527
|
const push = res.Ok();
|
|
528
528
|
const accepted = new Map(push.accepted.map((a) => [a.docId, a.seq]));
|
|
529
|
+
const unchanged = new Set(push.accepted.filter((a) => a.unchanged === true).map((a) => a.docId));
|
|
529
530
|
const rejected = new Map((push.rejected ?? []).map((r) => [r.docId, r]));
|
|
530
531
|
const release = this.store.receipts.holdNotifications();
|
|
531
532
|
const rVerdicts = await exception2Result(async () => {
|
|
532
|
-
const applied = await this.applyVerdicts({ writes, idsByDoc, opIdsByDoc, accepted, rejected });
|
|
533
|
+
const applied = await this.applyVerdicts({ writes, idsByDoc, opIdsByDoc, accepted, unchanged, rejected });
|
|
533
534
|
if (applied !== undefined && applied.dequeueIds.length > 0)
|
|
534
535
|
await this.store.dequeuePush(applied.dequeueIds);
|
|
535
536
|
if (applied !== undefined)
|
|
@@ -559,7 +560,7 @@ export class SyncEngine {
|
|
|
559
560
|
this.schedulePushRetry();
|
|
560
561
|
}
|
|
561
562
|
async applyVerdicts(args) {
|
|
562
|
-
const { writes, idsByDoc, opIdsByDoc, accepted, rejected } = args;
|
|
563
|
+
const { writes, idsByDoc, opIdsByDoc, accepted, unchanged, rejected } = args;
|
|
563
564
|
const dequeueIds = [];
|
|
564
565
|
const acceptedDocIds = [];
|
|
565
566
|
let refusedAny = false;
|
|
@@ -572,7 +573,7 @@ export class SyncEngine {
|
|
|
572
573
|
await this.store.recordAccepted(docId, seq);
|
|
573
574
|
if (this.stopped)
|
|
574
575
|
return undefined;
|
|
575
|
-
this.store.receipts.accept({ docId, opIds, seq });
|
|
576
|
+
this.store.receipts.accept({ docId, opIds, seq, ...(unchanged.has(docId) ? { unchanged: true } : {}) });
|
|
576
577
|
dequeueIds.push(...ids);
|
|
577
578
|
acceptedDocIds.push(docId);
|
|
578
579
|
this.retryDocIds.delete(docId);
|
package/write-receipts.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface OpSettle {
|
|
|
14
14
|
readonly opId: string;
|
|
15
15
|
readonly docId: string;
|
|
16
16
|
readonly state: WriteSyncState;
|
|
17
|
+
readonly unchanged?: true;
|
|
17
18
|
}
|
|
18
19
|
export declare function isTerminalWriteStatus(status: WriteSyncStatus): boolean;
|
|
19
20
|
export declare function staticWriteSync(state: WriteSyncState): WriteSync;
|
|
@@ -36,6 +37,7 @@ export declare class WriteReceipts {
|
|
|
36
37
|
readonly docId: string;
|
|
37
38
|
readonly opIds: readonly (string | undefined)[];
|
|
38
39
|
readonly seq?: number;
|
|
40
|
+
readonly unchanged?: true;
|
|
39
41
|
}): void;
|
|
40
42
|
refuse(args: {
|
|
41
43
|
readonly docId: string;
|
package/write-receipts.js
CHANGED
|
@@ -71,6 +71,9 @@ export class WriteReceipts {
|
|
|
71
71
|
if (known.length === 0)
|
|
72
72
|
return;
|
|
73
73
|
const last = known[known.length - 1];
|
|
74
|
+
const lastRec = this.ops.get(last);
|
|
75
|
+
if (args.unchanged === true && lastRec !== undefined)
|
|
76
|
+
lastRec.unchanged = true;
|
|
74
77
|
const changed = new Set();
|
|
75
78
|
for (const id of known) {
|
|
76
79
|
const docId = this.settle(id, id === last
|
|
@@ -244,7 +247,12 @@ export class WriteReceipts {
|
|
|
244
247
|
const snap = snapshotOf(rec);
|
|
245
248
|
for (const fn of [...rec.listeners])
|
|
246
249
|
exception2Result(() => fn(snap));
|
|
247
|
-
const event = {
|
|
250
|
+
const event = {
|
|
251
|
+
opId: rec.opId,
|
|
252
|
+
docId: rec.docId,
|
|
253
|
+
state: stateOnly(rec.state),
|
|
254
|
+
...(rec.unchanged === true && rec.state.status === "accepted" ? { unchanged: true } : {}),
|
|
255
|
+
};
|
|
248
256
|
if (this.holdDepth > 0) {
|
|
249
257
|
this.pendingOps.push(event);
|
|
250
258
|
return;
|