@agentshouse/mdruntime 0.1.0-caf080a9a9c60 → 0.1.0-cb0700ba4630b
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/README.md +18 -16
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +2 -21
- package/dist/act-lanes.d.ts +1 -0
- package/dist/act-lanes.d.ts.map +1 -1
- package/dist/act-lanes.js +53 -5
- package/dist/actions.d.ts +1 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +102 -50
- package/dist/adapter.d.ts +85 -14
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +0 -5
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +345 -0
- package/dist/change.d.ts +4 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +3 -0
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +0 -2
- package/dist/client.d.ts +14 -11
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +18 -46
- package/dist/collection.d.ts +5 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +16 -8
- package/dist/column.d.ts +5 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/column.js +9 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +2 -3
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +11 -12
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +18 -6
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +16 -6
- package/dist/conversation-row.d.ts +8 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +20 -7
- package/dist/conversation.d.ts +19 -7
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +226 -163
- package/dist/discovery.d.ts +2 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +15 -6
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +2 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +5 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +22 -11
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +4 -2
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- package/dist/host.d.ts +3 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +32 -10
- package/dist/house-query.d.ts +21 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +41 -0
- package/dist/index.d.ts +11 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/install.d.ts +9 -3
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +44 -46
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +26 -18
- package/dist/listing.d.ts +24 -12
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +50 -21
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +71 -30
- package/dist/loaded.d.ts +5 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +40 -0
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +2 -3
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +2 -3
- package/dist/media.d.ts +18 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +102 -24
- package/dist/memory.d.ts +5 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +55 -15
- package/dist/messages.d.ts +12 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +24 -10
- package/dist/modal.d.ts +2 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +11 -0
- package/dist/model.d.ts +4 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +5 -8
- package/dist/observation.d.ts +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +206 -69
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +4 -9
- package/dist/outcome.d.ts +10 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +17 -2
- package/dist/overlay.d.ts +1 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +3 -5
- package/dist/parts.d.ts +3 -0
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +31 -5
- package/dist/preparation.d.ts +27 -6
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +137 -56
- package/dist/presence.d.ts +8 -2
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +24 -13
- package/dist/queries.d.ts +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +63 -61
- package/dist/questions.d.ts +1 -0
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +1 -0
- package/dist/queue.d.ts +1 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +54 -39
- package/dist/reach.d.ts +14 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +140 -29
- package/dist/react.d.ts +6 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +9 -3
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +3 -5
- package/dist/reads.d.ts +1 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +2 -2
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +2 -1
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +1 -3
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +2 -2
- package/dist/room-draft.d.ts +28 -3
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +230 -12
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +5 -2
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +2 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +6 -6
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +1 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +17 -86
- package/dist/saves.d.ts +2 -0
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +42 -18
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -2
- package/dist/shown.d.ts +5 -2
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +62 -39
- package/dist/socket/lanes.d.ts +10 -3
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +29 -6
- package/dist/socket/session.d.ts +2 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +1 -0
- package/dist/socket.d.ts +3 -3
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +3 -9
- package/dist/source.d.ts +5 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +13 -2
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +19 -5
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +60 -22
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store.d.ts +14 -9
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +9 -4
- package/dist/stored.d.ts +24 -13
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +78 -27
- package/dist/surface.d.ts +12 -6
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +57 -25
- package/dist/sync.d.ts +3 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +27 -18
- package/dist/tables.d.ts +16 -52
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +86 -324
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +1 -2
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +3 -9
- package/dist/wire.d.ts +33 -10
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +15 -8
- package/package.json +3 -3
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
package/dist/save.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { apply, ARRAY_INDEX, ATTACHMENT, create,
|
|
2
|
-
import { immutable, leaving, queuedFile, departure, } from './change.js';
|
|
3
|
-
import { collectionOf, definitionsAt, documentsOf, governing, } from './collection.js';
|
|
1
|
+
import { apply, ARRAY_INDEX, ATTACHMENT, create, links, parse, pointerSegments, references, relative, relativize, retarget, roomReferences, serialize, target, } from '@agentshouse/mdmodel';
|
|
2
|
+
import { immutable, isPart, leaving, queuedFile, departure, } from './change.js';
|
|
3
|
+
import { collectionOf, definitionsAt, documentsOf, governing, textType, typedText, } from './collection.js';
|
|
4
4
|
import { changeBatchIdentity, roomDraftRevision } from './identity.js';
|
|
5
5
|
import { composed, overlaying } from './overlay.js';
|
|
6
6
|
import { ancestors } from './paths.js';
|
|
7
7
|
import { entriesIn, sorting } from './shared.js';
|
|
8
|
-
import { changedParts, changesOf, moveTarget, withdrawnDrafts, } from './room-draft.js';
|
|
8
|
+
import { applyParts, changedParts, changesOf, moveTarget, partsBetween, withdrawnDrafts, } from './room-draft.js';
|
|
9
9
|
import { paced, ROW_WEIGHT, stepped } from './turn.js';
|
|
10
10
|
import { validatedCollection } from './validation.js';
|
|
11
11
|
function refuse(code, file, location, line) {
|
|
@@ -52,48 +52,6 @@ function repointed(document, definition, from, to, moves, settled) {
|
|
|
52
52
|
const next = applied.document;
|
|
53
53
|
return [...names].map((name) => ({ kind: 'field', path: from, name, value: next.fields[name] }));
|
|
54
54
|
}
|
|
55
|
-
function edited(document, changes, definition) {
|
|
56
|
-
const parts = new Map();
|
|
57
|
-
for (const change of changes) {
|
|
58
|
-
if (change.kind === 'field')
|
|
59
|
-
parts.set(`field ${change.name}`, {
|
|
60
|
-
kind: 'field',
|
|
61
|
-
name: change.name,
|
|
62
|
-
value: change.value,
|
|
63
|
-
prior: document.fields[change.name],
|
|
64
|
-
});
|
|
65
|
-
if (change.kind === 'preamble')
|
|
66
|
-
parts.set('preamble', { kind: 'preamble', value: change.value, prior: document.preamble });
|
|
67
|
-
if (change.kind === 'section')
|
|
68
|
-
parts.set(`section ${change.name}`, {
|
|
69
|
-
kind: 'section',
|
|
70
|
-
name: change.name,
|
|
71
|
-
value: change.value,
|
|
72
|
-
prior: document.sections[change.name] ?? '',
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
if (parts.size === 0)
|
|
76
|
-
return document;
|
|
77
|
-
const applied = apply(document, [...parts.values()], definition);
|
|
78
|
-
return applied.outcome === 'applied' ? applied.document : document;
|
|
79
|
-
}
|
|
80
|
-
function bodies(path, before, after) {
|
|
81
|
-
const changes = [];
|
|
82
|
-
for (const [name, value] of Object.entries(after.fields)) {
|
|
83
|
-
if (equalValue(before.fields[name], value))
|
|
84
|
-
continue;
|
|
85
|
-
changes.push({ kind: 'field', path, name, value });
|
|
86
|
-
}
|
|
87
|
-
if (after.preamble !== before.preamble) {
|
|
88
|
-
changes.push({ kind: 'preamble', path, value: after.preamble });
|
|
89
|
-
}
|
|
90
|
-
for (const [name, value] of Object.entries(after.sections)) {
|
|
91
|
-
if (before.sections[name] === value)
|
|
92
|
-
continue;
|
|
93
|
-
changes.push({ kind: 'section', path, name, value });
|
|
94
|
-
}
|
|
95
|
-
return changes;
|
|
96
|
-
}
|
|
97
55
|
function relinks(path, moved, before, moves, definition) {
|
|
98
56
|
const changes = [];
|
|
99
57
|
for (const link of links(before, path)) {
|
|
@@ -116,7 +74,7 @@ function relinks(path, moved, before, moves, definition) {
|
|
|
116
74
|
if (before.type === undefined) {
|
|
117
75
|
return { kind: 'changes', changes: [{ kind: 'replace', path, content: serialize(after) }] };
|
|
118
76
|
}
|
|
119
|
-
return { kind: 'changes', changes:
|
|
77
|
+
return { kind: 'changes', changes: partsBetween(path, before, after) };
|
|
120
78
|
}
|
|
121
79
|
function partKey(change) {
|
|
122
80
|
return change.kind === 'section' || change.kind === 'field'
|
|
@@ -168,9 +126,10 @@ function* rewrites(changes, visible) {
|
|
|
168
126
|
const repointing = repointed(document, definition, path, moved, moves, settled);
|
|
169
127
|
added.push(...repointing);
|
|
170
128
|
const own = parts.get(path) ?? [];
|
|
129
|
+
const edited = applyParts(document, own.map((index) => merged[index]), definition);
|
|
171
130
|
const relinked = moved === path && own.length === 0 && cannotLink(document.content, names)
|
|
172
131
|
? { kind: 'changes', changes: [] }
|
|
173
|
-
: relinks(path, moved, edited
|
|
132
|
+
: relinks(path, moved, edited.outcome === 'applied' ? edited.document : document, moves, definition);
|
|
174
133
|
if (relinked.kind === 'refused')
|
|
175
134
|
return relinked;
|
|
176
135
|
const keyed = new Map();
|
|
@@ -248,7 +207,7 @@ function rewritten(path, document, changes, definition) {
|
|
|
248
207
|
const after = applied.document;
|
|
249
208
|
if (document.type === undefined)
|
|
250
209
|
return [{ kind: 'replace', path, content: serialize(after) }];
|
|
251
|
-
return
|
|
210
|
+
return partsBetween(path, document, after);
|
|
252
211
|
}
|
|
253
212
|
function roomPathOf(handle, path) {
|
|
254
213
|
return `/rooms/${handle}/${path}`;
|
|
@@ -458,7 +417,7 @@ function* preconditionsOf(changes, visible, bases) {
|
|
|
458
417
|
};
|
|
459
418
|
for (const change of changes) {
|
|
460
419
|
yield ROW_WEIGHT;
|
|
461
|
-
if (change
|
|
420
|
+
if (isPart(change)) {
|
|
462
421
|
const based = bases.find((base) => sameTarget(base, change));
|
|
463
422
|
if (based !== undefined) {
|
|
464
423
|
add(based);
|
|
@@ -613,9 +572,6 @@ function relativeChange(change, input) {
|
|
|
613
572
|
function unqueueable(file) {
|
|
614
573
|
return refuse('unknown-revision', file);
|
|
615
574
|
}
|
|
616
|
-
function isPart(change) {
|
|
617
|
-
return change.kind === 'field' || change.kind === 'section' || change.kind === 'preamble';
|
|
618
|
-
}
|
|
619
575
|
function touched(change) {
|
|
620
576
|
return change.kind === 'move' ? [change.path, change.to] : [change.path];
|
|
621
577
|
}
|
|
@@ -642,29 +598,7 @@ function unapplied(changes, visible, composition) {
|
|
|
642
598
|
function partsResult(content, path, changes, composition) {
|
|
643
599
|
const definitions = definitionsAt(composition, path);
|
|
644
600
|
const parsed = parse(content, path, definitions);
|
|
645
|
-
|
|
646
|
-
return null;
|
|
647
|
-
const document = parsed.document;
|
|
648
|
-
const parts = new Map();
|
|
649
|
-
for (const change of changes) {
|
|
650
|
-
if (change.kind === 'field')
|
|
651
|
-
parts.set(`field ${change.name}`, {
|
|
652
|
-
kind: 'field',
|
|
653
|
-
name: change.name,
|
|
654
|
-
value: change.value,
|
|
655
|
-
prior: document.fields[change.name],
|
|
656
|
-
});
|
|
657
|
-
else if (change.kind === 'section')
|
|
658
|
-
parts.set(`section ${change.name}`, {
|
|
659
|
-
kind: 'section',
|
|
660
|
-
name: change.name,
|
|
661
|
-
value: change.value,
|
|
662
|
-
prior: document.sections[change.name] ?? '',
|
|
663
|
-
});
|
|
664
|
-
else
|
|
665
|
-
parts.set('preamble', { kind: 'preamble', value: change.value, prior: document.preamble });
|
|
666
|
-
}
|
|
667
|
-
return apply(document, [...parts.values()], definitions(document.type));
|
|
601
|
+
return parsed.ok ? applyParts(parsed.document, changes, definitions(parsed.document.type)) : null;
|
|
668
602
|
}
|
|
669
603
|
function settledParts(changes, deferred, composition) {
|
|
670
604
|
for (const [held, parts] of deferred) {
|
|
@@ -883,11 +817,8 @@ function* limiting(queue, batch, limits, state) {
|
|
|
883
817
|
const limited = yield* exceeding(limits, batch.changes, rewritten.changes, yield* state(queue.slice(0, at + 1)));
|
|
884
818
|
return limited?.refusal ?? null;
|
|
885
819
|
}
|
|
886
|
-
function
|
|
887
|
-
|
|
888
|
-
return false;
|
|
889
|
-
const parsed = parse(content);
|
|
890
|
-
return parsed.ok && parsed.document.type !== undefined && parsed.document.type !== 'any';
|
|
820
|
+
function typedContent(content) {
|
|
821
|
+
return content !== undefined && typedText(parse(content));
|
|
891
822
|
}
|
|
892
823
|
function touchedLibrary(resulting, touched, composition) {
|
|
893
824
|
const entries = touched
|
|
@@ -907,9 +838,9 @@ function touchedLibrary(resulting, touched, composition) {
|
|
|
907
838
|
if (binaries.has(path))
|
|
908
839
|
known.set(path, { type: undefined, binary: true });
|
|
909
840
|
else if (content !== undefined && content !== null) {
|
|
910
|
-
const
|
|
911
|
-
if (
|
|
912
|
-
known.set(path, { type
|
|
841
|
+
const type = textType(parse(content, path, definitionsAt(composition, path)));
|
|
842
|
+
if (type !== undefined)
|
|
843
|
+
known.set(path, { type, binary: false });
|
|
913
844
|
await pace(content.length + ROW_WEIGHT);
|
|
914
845
|
}
|
|
915
846
|
}
|
|
@@ -927,7 +858,7 @@ async function judging(visible, resulting, composition, validate, removed, touch
|
|
|
927
858
|
for (const path of touched) {
|
|
928
859
|
const before = visible.documents[path];
|
|
929
860
|
const after = resulting.documents[path];
|
|
930
|
-
if (
|
|
861
|
+
if (typedContent(before) || typedContent(after))
|
|
931
862
|
typedPaths.push(path);
|
|
932
863
|
await pace((before?.length ?? 0) + (after?.length ?? 0) + ROW_WEIGHT);
|
|
933
864
|
}
|
|
@@ -1166,7 +1097,7 @@ function unreadable(saved, visible, composition) {
|
|
|
1166
1097
|
const path = saved.find(({ path: at, parts }) => (parts.fields !== undefined ||
|
|
1167
1098
|
parts.sections !== undefined ||
|
|
1168
1099
|
parts.preamble !== undefined) &&
|
|
1169
|
-
|
|
1100
|
+
typedContent(visible.documents[at]) &&
|
|
1170
1101
|
governing(composition, at).status === 'unavailable')?.path;
|
|
1171
1102
|
return path === undefined ? null : refuse('model-unavailable', path);
|
|
1172
1103
|
}
|
package/dist/saves.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ChangeBatch, type WrittenBy } from './change.js';
|
|
2
|
+
import type { ConversationFiles } from './conversation.js';
|
|
2
3
|
import { type AttachAnswer, type BinaryLinkAnswer, type HeldBinaryAnswer, type HeldShownAnswer } from './outcome.js';
|
|
3
4
|
import { type RoomDraftParts } from './room-draft.js';
|
|
4
5
|
import type { Runtime } from './runtime.js';
|
|
@@ -28,5 +29,6 @@ export type BinaryFileSurface = {
|
|
|
28
29
|
export declare function saveRoomDrafts(runtime: Runtime, locator: string, named: readonly SavedRoomDraft[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
|
|
29
30
|
export declare function saveParts(runtime: Runtime, locator: string, named: readonly SavedParts[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
|
|
30
31
|
export declare function batchFile(store: Store, batch: ChangeBatch): (localId: string) => Promise<Blob>;
|
|
32
|
+
export declare function conversationFiles(runtime: Runtime): ConversationFiles;
|
|
31
33
|
export declare function binaryFileSurface(runtime: Runtime): BinaryFileSurface;
|
|
32
34
|
//# sourceMappingURL=saves.d.ts.map
|
package/dist/saves.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saves.d.ts","sourceRoot":"","sources":["../src/saves.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"saves.d.ts","sourceRoot":"","sources":["../src/saves.ts"],"names":[],"mappings":"AAUA,OAAO,EAA2B,KAAK,WAAW,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AE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9E,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACxD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;CAC9D,CAAC;AAYF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,SAAS,EAAE,SAAS,GAAG,SAAS,GAC/B,OAAO,CAAC,UAAU,CAAC,CAsCrB;AAuBD,wBAAgB,SAAS,CACvB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,SAAS,EAAE,SAAS,GAAG,SAAS,GAC/B,OAAO,CAAC,UAAU,CAAC,CAyBrB;AAgOD,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAK9F;AA+PD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAKrE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAQrE"}
|
package/dist/saves.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isImageType, parse } from '@agentshouse/mdmodel';
|
|
2
2
|
import { binaryRecord } from './binary.js';
|
|
3
|
+
import { changeSet } from './change-set.js';
|
|
3
4
|
import { queuedFile } from './change.js';
|
|
4
|
-
import { available } from './collection.js';
|
|
5
|
+
import { available, textType } from './collection.js';
|
|
5
6
|
import { runtimeError } from './failure.js';
|
|
6
7
|
import { attachedFile } from './file.js';
|
|
8
|
+
import { roomDraftRevision } from './identity.js';
|
|
7
9
|
import { compositionFor } from './listing.js';
|
|
8
10
|
import { scoped } from './models.js';
|
|
9
|
-
import { absentBinary, attachAnswer, binaryAnswer, binaryLinkAnswer, failure, OFFLINE, UNCERTAIN, } from './outcome.js';
|
|
11
|
+
import { absentBinary, attachAnswer, binaryAnswer, binaryLinkAnswer, failure, linkedAnswer, OFFLINE, UNCERTAIN, } from './outcome.js';
|
|
10
12
|
import { sameBinary } from './overlay.js';
|
|
11
13
|
import { ancestors } from './paths.js';
|
|
12
14
|
import { connectionNow } from './preparation.js';
|
|
13
15
|
import { append, sliceAt, withdrawable } from './queue.js';
|
|
14
16
|
import { entryAt, replaying, slicing, } from './replica.js';
|
|
15
|
-
import { binaryBase, changesOf, held, heldFile, moveTarget, readSavedParts, } from './room-draft.js';
|
|
17
|
+
import { binaryBase, changesOf, held, heldFile, joinedOver, moveTarget, readSavedParts, } from './room-draft.js';
|
|
16
18
|
import { refuse } from './refusal.js';
|
|
17
19
|
import { visibleOf } from './room-drafts.js';
|
|
18
20
|
import { destination, planSave, } from './save.js';
|
|
@@ -43,9 +45,24 @@ export function saveRoomDrafts(runtime, locator, named, writtenBy) {
|
|
|
43
45
|
if (!saved.some((draft) => draft.path === path))
|
|
44
46
|
saved.push({ path, parts: record.parts });
|
|
45
47
|
}
|
|
46
|
-
|
|
48
|
+
const result = await loaded(runtime, locator, replica, saved, new Set(saved.map(({ path }) => path)), [], writtenBy);
|
|
49
|
+
if (result.outcome !== 'refused' || result.code !== 'changed-underneath')
|
|
50
|
+
return result;
|
|
51
|
+
return joinedUnderneath(runtime, locator, saved.map(({ path }) => drafts.get(path)), result);
|
|
47
52
|
});
|
|
48
53
|
}
|
|
54
|
+
async function joinedUnderneath({ store }, locator, records, refused) {
|
|
55
|
+
const visible = (await visibleOf(store, locator, records.map(({ path }) => path)));
|
|
56
|
+
const joined = records.flatMap((record) => {
|
|
57
|
+
const join = joinedOver(record.parts, record.marks, record.path, visible);
|
|
58
|
+
return join === null ? [] : [{ ...record, ...join, revision: roomDraftRevision() }];
|
|
59
|
+
});
|
|
60
|
+
if (joined.length === 0)
|
|
61
|
+
return refused;
|
|
62
|
+
await (await store.open()).commit({ rooms: [], writes: [{ locator, roomDrafts: joined }] });
|
|
63
|
+
await store.changed(changeSet(locator, { drafts: joined.map(({ path }) => path) }));
|
|
64
|
+
return refused;
|
|
65
|
+
}
|
|
49
66
|
export function saveParts(runtime, locator, named, writtenBy) {
|
|
50
67
|
const { store } = runtime;
|
|
51
68
|
return store.exclusive(async () => {
|
|
@@ -162,8 +179,7 @@ function lookupOf(local, key, view) {
|
|
|
162
179
|
function declaredOf(entry) {
|
|
163
180
|
if (entry.binary !== null)
|
|
164
181
|
return { type: undefined, binary: true };
|
|
165
|
-
|
|
166
|
-
return { type: read.ok ? (read.frontmatter.type ?? 'any') : undefined, binary: false };
|
|
182
|
+
return { type: textType(parse(entry.content ?? '')), binary: false };
|
|
167
183
|
}
|
|
168
184
|
function overriddenLookup(lookup, overrides) {
|
|
169
185
|
return async (paths) => {
|
|
@@ -230,7 +246,7 @@ export function batchFile(store, batch) {
|
|
|
230
246
|
};
|
|
231
247
|
}
|
|
232
248
|
async function transferBinary(runtime, request, transfer, answer) {
|
|
233
|
-
const { store, socket, presence
|
|
249
|
+
const { store, socket, presence } = runtime;
|
|
234
250
|
const { session } = socket;
|
|
235
251
|
if (socket.closed() || session.now().refusal !== null)
|
|
236
252
|
return UNCERTAIN;
|
|
@@ -247,12 +263,10 @@ async function transferBinary(runtime, request, transfer, answer) {
|
|
|
247
263
|
if (closed || authorization === undefined || refusal !== null)
|
|
248
264
|
return UNCERTAIN;
|
|
249
265
|
const since = presence.losses();
|
|
250
|
-
journal.record(`transfer binary ${request.locator} ${request.path}`);
|
|
251
266
|
try {
|
|
252
267
|
const result = await transfer(authorization);
|
|
253
268
|
const settled = result;
|
|
254
|
-
|
|
255
|
-
if (presence.lostSince(request.locator, since))
|
|
269
|
+
if (request.locator !== null && presence.lostSince(request.locator, since))
|
|
256
270
|
return failure({ kind: 'room-not-readable', locator: request.locator });
|
|
257
271
|
if (settled.kind === 'scoped-refusal') {
|
|
258
272
|
const room = await store.record(settled.locator);
|
|
@@ -264,7 +278,6 @@ async function transferBinary(runtime, request, transfer, answer) {
|
|
|
264
278
|
return answer(result);
|
|
265
279
|
}
|
|
266
280
|
catch {
|
|
267
|
-
journal.record('outcome binary transport-uncertainty');
|
|
268
281
|
return UNCERTAIN;
|
|
269
282
|
}
|
|
270
283
|
}
|
|
@@ -377,11 +390,11 @@ async function showBinaryPath(runtime, locator, path, revision) {
|
|
|
377
390
|
if (kept !== null)
|
|
378
391
|
return kept;
|
|
379
392
|
const mediaType = await heldMediaType(store, locator, path);
|
|
380
|
-
if (mediaType
|
|
393
|
+
if (mediaType !== undefined && isImageType(mediaType))
|
|
381
394
|
return fetchBinary(runtime, asked, name);
|
|
382
395
|
return linkOf(runtime, asked, revision === undefined ? mediaType : undefined);
|
|
383
396
|
}
|
|
384
|
-
async function
|
|
397
|
+
async function attachFile(runtime, locator, file, answer) {
|
|
385
398
|
const { store, socket } = runtime;
|
|
386
399
|
await socket.ready;
|
|
387
400
|
await socket.firstDiscovery;
|
|
@@ -391,16 +404,27 @@ async function attachBinary(runtime, locator, file) {
|
|
|
391
404
|
socket.session.now().refusal !== null)
|
|
392
405
|
return OFFLINE;
|
|
393
406
|
const request = await attachedFile(locator, file);
|
|
394
|
-
return transferBinary(runtime, { locator
|
|
407
|
+
return transferBinary(runtime, { locator }, async (held) => {
|
|
395
408
|
const result = await socket.attach(held, request);
|
|
396
|
-
if (result.kind === 'attached') {
|
|
409
|
+
if (result.kind === 'attached' && locator !== null) {
|
|
397
410
|
store.attached.hold(locator, result.path, {
|
|
398
411
|
revision: result.revision,
|
|
399
412
|
mediaType: request.mediaType,
|
|
400
413
|
});
|
|
401
414
|
}
|
|
402
415
|
return result;
|
|
403
|
-
},
|
|
416
|
+
}, answer);
|
|
417
|
+
}
|
|
418
|
+
async function keyedAttachment(runtime, link) {
|
|
419
|
+
await runtime.socket.ready;
|
|
420
|
+
const asked = { kind: 'key', link };
|
|
421
|
+
return transferBinary(runtime, { locator: null }, (authorization) => runtime.socket.link(authorization, asked), (result) => binaryLinkAnswer(result));
|
|
422
|
+
}
|
|
423
|
+
export function conversationFiles(runtime) {
|
|
424
|
+
return {
|
|
425
|
+
attach: (file) => attachFile(runtime, null, file, linkedAnswer),
|
|
426
|
+
attachment: (link) => keyedAttachment(runtime, link),
|
|
427
|
+
};
|
|
404
428
|
}
|
|
405
429
|
export function binaryFileSurface(runtime) {
|
|
406
430
|
return {
|
|
@@ -408,6 +432,6 @@ export function binaryFileSurface(runtime) {
|
|
|
408
432
|
read: (room, path, revision) => readBinaryPath(runtime, room, path, revision),
|
|
409
433
|
link: (room, path, revision) => linkBinaryPath(runtime, room, path, revision),
|
|
410
434
|
show: (room, path, revision) => showBinaryPath(runtime, room, path, revision),
|
|
411
|
-
attach: (room, file) =>
|
|
435
|
+
attach: (room, file) => attachFile(runtime, room, file, attachAnswer),
|
|
412
436
|
};
|
|
413
437
|
}
|
package/dist/seed.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../src/seed.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../src/seed.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAwB,KAAK,WAAW,EAAqB,MAAM,kBAAkB,CAAC;AAC7F,OAAO,KAAK,EAAE,IAAI,EAA4C,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,KAAK,EAAE,OAAO,E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dist/seed.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { queryKey } from '@agentshouse/mdmodel';
|
|
2
|
-
import { whole } from './observation.js';
|
|
2
|
+
import { pendingChange, whole } from './observation.js';
|
|
3
3
|
import { documentKey } from './rows.js';
|
|
4
4
|
const seedTopic = (key) => `seed\u0000${key}`;
|
|
5
5
|
function plain(value) {
|
|
@@ -130,7 +130,7 @@ export function watchSeeded(runtime, plan, deliver, watch) {
|
|
|
130
130
|
const watcher = store.watch(seedTopic(plan.key), shown);
|
|
131
131
|
const stop = watch((cover, held) => seedBehind(runtime, plan, cover, held), (message) => {
|
|
132
132
|
const answered = message;
|
|
133
|
-
pending = whole(answered)
|
|
133
|
+
pending = whole(answered) ? 'pending' in answered.result : pendingChange(answered);
|
|
134
134
|
if (pending && store.seeds.of(plan.key) !== undefined) {
|
|
135
135
|
shown();
|
|
136
136
|
return;
|
package/dist/shown.d.ts
CHANGED
|
@@ -10,15 +10,18 @@ export declare const REFUSAL_TOPIC = "connection-refusal";
|
|
|
10
10
|
export declare const STORAGE_LOSS_TOPIC = "storage-loss";
|
|
11
11
|
export declare const SERVICE_MODE_TOPIC = "service-mode";
|
|
12
12
|
export declare const MEMBER_TOPIC = "member";
|
|
13
|
+
export declare const TIME_ZONE_TOPIC = "time-zone";
|
|
13
14
|
export declare const AUTHORITY_TOPIC = "authority-changes";
|
|
14
15
|
export declare const LOCKS_TOPIC = "locks";
|
|
15
16
|
export declare const queueTopic: (locator: string) => string;
|
|
16
|
-
export declare function recoverReads({ liveQueries, figures }: Runtime): void;
|
|
17
|
+
export declare function recoverReads({ liveQueries, figures }: Runtime, locators?: readonly string[]): void;
|
|
17
18
|
export declare function emitRooms(runtime: Runtime, changed?: readonly string[]): Promise<void>;
|
|
18
19
|
export declare function emitKnownRooms(runtime: Runtime): void;
|
|
19
20
|
export declare function emitRefusal(runtime: Runtime): void;
|
|
20
|
-
export declare function
|
|
21
|
+
export declare function storageLossNow({ store }: Runtime): string | null;
|
|
22
|
+
export declare function emitStorageLoss(runtime: Runtime): void;
|
|
21
23
|
export declare function emitMember({ store }: Runtime, member: Member | null): void;
|
|
24
|
+
export declare function emitTimeZone({ store }: Runtime, zone: string | null): void;
|
|
22
25
|
export declare function show(runtime: Runtime): Promise<void>;
|
|
23
26
|
export declare function moveTo(runtime: Runtime, next: Moving): Promise<void>;
|
|
24
27
|
export declare function statusShown(runtime: Runtime): Promise<void>;
|
package/dist/shown.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shown.d.ts","sourceRoot":"","sources":["../src/shown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"shown.d.ts","sourceRoot":"","sources":["../src/shown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAA6B,KAAK,aAAa,EAAmB,MAAM,aAAa,CAAC;AAiB7F,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,eAAO,MAAM,YAAY,gBAAgB,CAAC;AAE1C,eAAO,MAAM,aAAa,uBAAuB,CAAC;AAElD,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C,eAAO,MAAM,eAAe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,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAGjG;AAcD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBhF;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAOjG;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAG/D;AAED,wBAAsB,IAAI,CACxB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,aAAa,GAAG,IAAI,EAC9B,IAAI,GAAE,IAAqC,iBAiC5C"}
|
package/dist/shown.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { changeSet, mergeChangeSets } from './change-set.js';
|
|
2
2
|
import { conversationsChanged, conversationsLearned } from './conversation.js';
|
|
3
|
-
import {
|
|
3
|
+
import { lossStated } from './durability.js';
|
|
4
|
+
import { listedEntries, listingNow, shownChange, shownRooms } from './listing.js';
|
|
4
5
|
import { emitPresentation, publishRoomDrafts } from './room-drafts.js';
|
|
5
6
|
import { same } from './status.js';
|
|
6
7
|
export const ROOMS_TOPIC = 'rooms';
|
|
@@ -9,6 +10,7 @@ export const REFUSAL_TOPIC = 'connection-refusal';
|
|
|
9
10
|
export const STORAGE_LOSS_TOPIC = 'storage-loss';
|
|
10
11
|
export const SERVICE_MODE_TOPIC = 'service-mode';
|
|
11
12
|
export const MEMBER_TOPIC = 'member';
|
|
13
|
+
export const TIME_ZONE_TOPIC = 'time-zone';
|
|
12
14
|
export const AUTHORITY_TOPIC = 'authority-changes';
|
|
13
15
|
export const LOCKS_TOPIC = 'locks';
|
|
14
16
|
export const queueTopic = (locator) => `queue\u0000${locator}`;
|
|
@@ -43,13 +45,13 @@ async function attended({ store, localSaves }) {
|
|
|
43
45
|
async function queuedWork({ store, localSaves }) {
|
|
44
46
|
return !localSaves && (await store.queued()).length > 0;
|
|
45
47
|
}
|
|
46
|
-
export function recoverReads({ liveQueries, figures }) {
|
|
47
|
-
liveQueries.recover();
|
|
48
|
+
export function recoverReads({ liveQueries, figures }, locators) {
|
|
49
|
+
liveQueries.recover(locators);
|
|
48
50
|
figures.recover();
|
|
49
51
|
}
|
|
50
52
|
export function emitRooms(runtime, changed) {
|
|
51
|
-
recoverReads(runtime);
|
|
52
|
-
runtime.store.readiness.queue();
|
|
53
|
+
recoverReads(runtime, changed);
|
|
54
|
+
runtime.store.readiness.queue(changed);
|
|
53
55
|
return changed === undefined
|
|
54
56
|
? publishRooms(runtime, 'all')
|
|
55
57
|
: publishRooms(runtime, 'changed', changed);
|
|
@@ -74,51 +76,58 @@ function roomsOwedWith(held, mode, touched) {
|
|
|
74
76
|
}
|
|
75
77
|
return held;
|
|
76
78
|
}
|
|
79
|
+
async function patchedRooms(runtime, owed) {
|
|
80
|
+
const { store } = runtime;
|
|
81
|
+
const touched = [...new Set([...owed.changed, ...owed.counted])];
|
|
82
|
+
const entries = await listedEntries(runtime, touched);
|
|
83
|
+
const shown = store.roomsShown.now();
|
|
84
|
+
if (entries === null || shown === null)
|
|
85
|
+
return false;
|
|
86
|
+
if (runtime.socket.closed())
|
|
87
|
+
return true;
|
|
88
|
+
const moved = entries.filter(({ locator, documents }) => owed.changed.has(locator) || shown.get(locator)?.documents !== documents);
|
|
89
|
+
const counted = moved.flatMap(({ locator }) => (owed.changed.has(locator) ? [] : [locator]));
|
|
90
|
+
if (counted.length > 0) {
|
|
91
|
+
recoverReads(runtime, counted);
|
|
92
|
+
store.readiness.queue(counted);
|
|
93
|
+
}
|
|
94
|
+
store.roomsShown.patch(moved);
|
|
95
|
+
if (moved.length === 0)
|
|
96
|
+
return true;
|
|
97
|
+
const change = shownChange(runtime, moved);
|
|
98
|
+
for (const watcher of store.watching(ROOMS_TOPIC, 'ready'))
|
|
99
|
+
watcher.answer(change);
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
77
102
|
async function deliverRooms(runtime, owed) {
|
|
78
103
|
const { store, socket } = runtime;
|
|
79
104
|
const waiting = () => store.watching(ROOMS_TOPIC, 'waiting');
|
|
80
105
|
if (socket.closed() || store.watching(ROOMS_TOPIC).length === 0)
|
|
81
106
|
return;
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (
|
|
107
|
+
const touched = owed.changed.size > 0 || owed.counted.size > 0;
|
|
108
|
+
if (!owed.all && touched && waiting().length === 0 && (await patchedRooms(runtime, owed)))
|
|
109
|
+
return;
|
|
110
|
+
if (touched)
|
|
86
111
|
owed.all = true;
|
|
87
|
-
|
|
88
|
-
const held = await store.covering();
|
|
89
|
-
const { roomsShown } = store.device.now();
|
|
90
|
-
owed.all = [...owed.counted].some((locator) => held.rooms.has(locator) &&
|
|
91
|
-
roomsShown?.get(locator)?.documents !== held.rooms.get(locator).documents);
|
|
92
|
-
if (owed.all) {
|
|
93
|
-
recoverReads(runtime);
|
|
94
|
-
store.readiness.queue();
|
|
95
|
-
}
|
|
96
|
-
else if (waiting().length === 0)
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const listing = patched ?? (await listingNow(runtime));
|
|
112
|
+
const listing = await listingNow(runtime);
|
|
100
113
|
if (socket.closed())
|
|
101
114
|
return;
|
|
102
115
|
const { roomsListed, refusal, moving } = socket.session.now();
|
|
103
116
|
const joining = waiting().length > 0 &&
|
|
104
117
|
(roomsListed || listing.size > 0 || refusal !== null || moving.providerUnreachable);
|
|
105
|
-
if (!owed.all &&
|
|
118
|
+
if (!owed.all && !joining)
|
|
106
119
|
return;
|
|
107
120
|
const value = shownRooms(runtime, listing);
|
|
108
|
-
const
|
|
121
|
+
const shown = store.roomsShown.now();
|
|
109
122
|
const moved = owed.all ||
|
|
110
|
-
|
|
111
|
-
(roomsShown !== null &&
|
|
112
|
-
JSON.stringify(shownRooms(runtime, roomsShown)) !== JSON.stringify(value));
|
|
123
|
+
(shown !== null && JSON.stringify(shownRooms(runtime, shown)) !== JSON.stringify(value));
|
|
113
124
|
if (moved)
|
|
114
125
|
for (const watcher of store.watching(ROOMS_TOPIC, 'ready'))
|
|
115
126
|
watcher.answer(value);
|
|
116
127
|
if (joining)
|
|
117
128
|
for (const watcher of waiting())
|
|
118
129
|
watcher.answer(value);
|
|
119
|
-
store.
|
|
120
|
-
roomsShown: store.watching(ROOMS_TOPIC, 'ready').length === 0 ? null : listing,
|
|
121
|
-
});
|
|
130
|
+
store.roomsShown.show(store.watching(ROOMS_TOPIC, 'ready').length === 0 ? null : listing);
|
|
122
131
|
}
|
|
123
132
|
function publishRooms(runtime, mode, touched = []) {
|
|
124
133
|
if (runtime.socket.closed())
|
|
@@ -127,17 +136,24 @@ function publishRooms(runtime, mode, touched = []) {
|
|
|
127
136
|
}
|
|
128
137
|
export function emitRefusal(runtime) {
|
|
129
138
|
const { store, socket } = runtime;
|
|
130
|
-
store.readiness.queue();
|
|
139
|
+
store.readiness.queue([]);
|
|
131
140
|
store.tell(REFUSAL_TOPIC, socket.session.now().refusal);
|
|
132
141
|
emitKnownRooms(runtime);
|
|
133
142
|
}
|
|
134
|
-
export function
|
|
135
|
-
store.
|
|
136
|
-
|
|
143
|
+
export function storageLossNow({ store }) {
|
|
144
|
+
const { persistence, storageLoss } = store.device.now();
|
|
145
|
+
return lossStated(persistence, storageLoss);
|
|
146
|
+
}
|
|
147
|
+
export function emitStorageLoss(runtime) {
|
|
148
|
+
runtime.store.readiness.queue([]);
|
|
149
|
+
runtime.store.tell(STORAGE_LOSS_TOPIC, storageLossNow(runtime));
|
|
137
150
|
}
|
|
138
151
|
export function emitMember({ store }, member) {
|
|
139
152
|
store.tell(MEMBER_TOPIC, member);
|
|
140
153
|
}
|
|
154
|
+
export function emitTimeZone({ store }, zone) {
|
|
155
|
+
store.tell(TIME_ZONE_TOPIC, zone);
|
|
156
|
+
}
|
|
141
157
|
async function deliverStatus(runtime, owed) {
|
|
142
158
|
const { store, socket } = runtime;
|
|
143
159
|
const held = await attended(runtime);
|
|
@@ -159,13 +175,16 @@ async function deliverStatus(runtime, owed) {
|
|
|
159
175
|
store.tell(STATUS_TOPIC, next);
|
|
160
176
|
}
|
|
161
177
|
}
|
|
178
|
+
function conversationsCurrent({ conversations }) {
|
|
179
|
+
return conversations.listed() && conversations.current();
|
|
180
|
+
}
|
|
162
181
|
export function show(runtime) {
|
|
163
|
-
const { store, socket
|
|
182
|
+
const { store, socket } = runtime;
|
|
164
183
|
if (socket.closed())
|
|
165
184
|
return Promise.resolve();
|
|
166
|
-
store.readiness.queue();
|
|
185
|
+
store.readiness.queue([]);
|
|
167
186
|
emitKnownRooms(runtime);
|
|
168
|
-
const moved = { moving: socket.session.now().moving, current:
|
|
187
|
+
const moved = { moving: socket.session.now().moving, current: conversationsCurrent(runtime) };
|
|
169
188
|
return store.owing(STATUS_TOPIC, (held) => {
|
|
170
189
|
if (held === undefined)
|
|
171
190
|
return [moved];
|
|
@@ -254,14 +273,18 @@ export async function submissionDue(runtime, locators) {
|
|
|
254
273
|
}
|
|
255
274
|
export function roomUnreadable(runtime, locator) {
|
|
256
275
|
runtime.presence.refused(locator, null);
|
|
257
|
-
emitRooms(runtime);
|
|
276
|
+
emitRooms(runtime, [locator]);
|
|
258
277
|
}
|
|
259
278
|
export async function rest(runtime, progress, live = () => !runtime.socket.closed()) {
|
|
260
279
|
const { store, socket, presence } = runtime;
|
|
261
280
|
const { session, lanes } = socket;
|
|
262
281
|
if (!live())
|
|
263
282
|
return;
|
|
264
|
-
const settled = () => session.now().complete &&
|
|
283
|
+
const settled = () => session.now().complete &&
|
|
284
|
+
lanes.roomWork() === 0 &&
|
|
285
|
+
!socket.naming() &&
|
|
286
|
+
presence.settled() &&
|
|
287
|
+
conversationsCurrent(runtime);
|
|
265
288
|
let synced = settled();
|
|
266
289
|
if (synced && !session.now().recorded) {
|
|
267
290
|
const queued = await queuedWork(runtime).catch(() => true);
|
package/dist/socket/lanes.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import type { CallResult } from '../outcome.js';
|
|
1
2
|
export type Live = () => boolean;
|
|
3
|
+
export type KeptSender = {
|
|
4
|
+
next(): Promise<CallResult>;
|
|
5
|
+
};
|
|
2
6
|
type LaneRules = {
|
|
3
7
|
generation(): number;
|
|
4
8
|
continuing(): boolean;
|
|
@@ -12,9 +16,12 @@ export type Lanes = {
|
|
|
12
16
|
roomWork(): number;
|
|
13
17
|
current(): Promise<unknown>;
|
|
14
18
|
finished(): Promise<unknown>;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
sender(operation: string): KeptSender | undefined;
|
|
20
|
+
sending(operation: string, sender: KeptSender): void;
|
|
21
|
+
sent(operation: string, sender: KeptSender): void;
|
|
22
|
+
settled(operation: string): Promise<void>;
|
|
23
|
+
settle(operation: string, lost: boolean): void;
|
|
24
|
+
unclaimed(operation: string): boolean;
|
|
18
25
|
};
|
|
19
26
|
export declare function createLanes({ generation, continuing, stopping, failed }: LaneRules): Lanes;
|
|
20
27
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lanes.d.ts","sourceRoot":"","sources":["../../src/socket/lanes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"lanes.d.ts","sourceRoot":"","sources":["../../src/socket/lanes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC;AAEjC,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC,CAAA;CAAE,CAAC;AAIzD,KAAK,SAAS,GAAG;IACf,UAAU,IAAI,MAAM,CAAC;IACrB,UAAU,IAAI,OAAO,CAAC;IACt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