@agentshouse/mdruntime 0.1.0-cba6f2439bb25 → 0.1.0-cbbae1fff01c6
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 +10 -10
- package/dist/acceptance.d.ts +3 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +308 -0
- package/dist/actions.d.ts +20 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +251 -0
- package/dist/adapter.d.ts +95 -103
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +21 -56
- package/dist/bootstrap.d.ts +12 -11
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +213 -89
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- package/dist/chain.d.ts +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts +1 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -2
- package/dist/chat-types.d.ts +5 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +13 -0
- package/dist/client.d.ts +24 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +9 -5
- package/dist/collection.d.ts +23 -7
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +13 -19
- package/dist/compile.d.ts +6 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +272 -332
- package/dist/connection.d.ts +5 -143
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +105 -5253
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation-live.d.ts +135 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +247 -0
- package/dist/conversation-row.d.ts +33 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +53 -0
- package/dist/conversation.d.ts +41 -47
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +874 -911
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +148 -0
- package/dist/durability.d.ts +15 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +2 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +17 -7
- package/dist/expectation.d.ts +4 -2
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +33 -11
- package/dist/failure.d.ts +1 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -0
- package/dist/figures.d.ts +49 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +197 -0
- package/dist/holdings.d.ts +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +20 -8
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +44 -34
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +28 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/install.d.ts +54 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +538 -0
- package/dist/job.d.ts +5 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +7 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +272 -0
- package/dist/listing.d.ts +48 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +139 -0
- package/dist/live.d.ts +5 -4
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +64 -23
- package/dist/locks.d.ts +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +33 -0
- package/dist/log.d.ts +1 -0
- package/dist/log.d.ts.map +1 -1
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +50 -0
- package/dist/media.d.ts +2 -2
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +22 -12
- package/dist/memory.d.ts +14 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +177 -85
- package/dist/messages.d.ts +24 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +89 -31
- package/dist/model.d.ts +2 -11
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -23
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +156 -0
- package/dist/observation.d.ts +2 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +14 -14
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +59 -0
- package/dist/outcome.d.ts +4 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +3 -0
- package/dist/overlay.d.ts +3 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +43 -21
- package/dist/parts.d.ts +11 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +21 -0
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts +20 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +233 -0
- package/dist/presence.d.ts +52 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +220 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +270 -0
- package/dist/query.d.ts +14 -210
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/questions.d.ts +34 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +122 -0
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +455 -0
- package/dist/reach.d.ts +15 -13
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +187 -140
- package/dist/react.d.ts +14 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +10 -1
- package/dist/read.d.ts +7 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +17 -0
- package/dist/readiness.d.ts +2 -16
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +4 -10
- package/dist/reads.d.ts +36 -10
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +160 -77
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +35 -1
- package/dist/refresh.d.ts +7 -5
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +35 -7
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +57 -0
- package/dist/replica.d.ts +11 -17
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +64 -34
- package/dist/room-draft.d.ts +7 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +100 -103
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +217 -0
- package/dist/rows.d.ts +14 -21
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +49 -186
- package/dist/runtime.d.ts +34 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +41 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +239 -116
- package/dist/saves.d.ts +32 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +413 -0
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +71 -1
- package/dist/shared.d.ts +1 -7
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -105
- package/dist/shown.d.ts +32 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +290 -0
- package/dist/socket/admission.d.ts +7 -0
- package/dist/socket/admission.d.ts.map +1 -0
- package/dist/socket/admission.js +39 -0
- package/dist/socket/answers.d.ts +6 -0
- package/dist/socket/answers.d.ts.map +1 -0
- package/dist/socket/answers.js +20 -0
- package/dist/socket/lanes.d.ts +20 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +77 -0
- package/dist/socket/reads.d.ts +10 -0
- package/dist/socket/reads.d.ts.map +1 -0
- package/dist/socket/reads.js +31 -0
- package/dist/socket/session.d.ts +38 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +23 -0
- package/dist/socket.d.ts +67 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +170 -0
- package/dist/source.d.ts +61 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +82 -0
- package/dist/status.d.ts +0 -6
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -6
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +34 -0
- package/dist/store/readiness.d.ts +10 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +52 -0
- package/dist/store/records.d.ts +210 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +428 -0
- package/dist/store/room-held.d.ts +8 -0
- package/dist/store/room-held.d.ts.map +1 -0
- package/dist/store/room-held.js +17 -0
- package/dist/store/space.d.ts +11 -0
- package/dist/store/space.d.ts.map +1 -0
- package/dist/store/space.js +41 -0
- package/dist/store/watchers.d.ts +17 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +56 -0
- package/dist/store/writes.d.ts +24 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +125 -0
- package/dist/store.d.ts +110 -157
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +162 -394
- package/dist/stored.d.ts +59 -38
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +287 -206
- package/dist/surface.d.ts +88 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +223 -0
- package/dist/sync.d.ts +19 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +521 -0
- package/dist/tables.d.ts +116 -56
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +214 -98
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +129 -0
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/validation.d.ts +3 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +42 -100
- package/dist/windows.d.ts +1 -12
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +2 -75
- package/dist/wire.d.ts +21 -9
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +10 -4
- package/package.json +3 -2
- package/dist/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
- package/dist/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -370
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -156
package/dist/reach.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { selected } from './collection.js';
|
|
1
2
|
import { unheldView } from './conversation.js';
|
|
2
3
|
import { modelTypes, NO_MODEL } from './model.js';
|
|
3
4
|
import { changeOf, digestApplied, digestOf, observing, } from './observation.js';
|
|
4
|
-
import { runtimeError } from './failure.js';
|
|
5
|
+
import { runtimeError, uncaught } from './failure.js';
|
|
5
6
|
import { failure, lockedRoom, ROOM_LOCKED, undeclared, UNREADABLE, } from './outcome.js';
|
|
6
7
|
import { beneath } from './paths.js';
|
|
7
8
|
import { moveTarget, readParts, staleWrite, } from './room-draft.js';
|
|
8
9
|
import { documentKey } from './rows.js';
|
|
9
|
-
import { undeclaredSearch } from './search.js';
|
|
10
10
|
const UNHELD_TYPES = { collection: modelTypes(NO_MODEL), typedSelection: null };
|
|
11
11
|
function unconversed(name) {
|
|
12
12
|
return () => Promise.resolve(undeclared(name));
|
|
@@ -14,13 +14,12 @@ function unconversed(name) {
|
|
|
14
14
|
const NO_CONVERSATION = {
|
|
15
15
|
list: () => Promise.resolve([]),
|
|
16
16
|
read: (conversation) => Promise.resolve(unheldView(conversation)),
|
|
17
|
-
create: unconversed('
|
|
18
|
-
send: unconversed('
|
|
19
|
-
answer: unconversed('
|
|
20
|
-
interrupt: unconversed('
|
|
21
|
-
kill: unconversed('
|
|
22
|
-
|
|
23
|
-
delete: unconversed('conversation.delete'),
|
|
17
|
+
create: unconversed('conversations/create'),
|
|
18
|
+
send: unconversed('conversations/send'),
|
|
19
|
+
answer: unconversed('conversations/interaction/answer'),
|
|
20
|
+
interrupt: unconversed('conversations/interrupt'),
|
|
21
|
+
kill: unconversed('conversations/kill'),
|
|
22
|
+
delete: unconversed('conversations/delete'),
|
|
24
23
|
};
|
|
25
24
|
const NO_CHAT_DRAFT = {
|
|
26
25
|
write: () => Promise.resolve(),
|
|
@@ -30,17 +29,15 @@ const NO_CHAT_DRAFT = {
|
|
|
30
29
|
function areasOf(reach) {
|
|
31
30
|
return reach.areas ?? [];
|
|
32
31
|
}
|
|
33
|
-
function typedAreas(reach, room) {
|
|
34
|
-
return areasOf(reach).filter((area) => area.room === room && area.types.length > 0);
|
|
35
|
-
}
|
|
36
32
|
function fenced(reach, room, path) {
|
|
37
|
-
return areasOf(reach).some((area) => area.room === room &&
|
|
33
|
+
return areasOf(reach).some((area) => area.room === room &&
|
|
34
|
+
beneath(area.path, path) &&
|
|
35
|
+
!area.open.some((open) => beneath(open, path)));
|
|
38
36
|
}
|
|
39
37
|
export function holds(reach, room) {
|
|
40
38
|
return (reach === null ||
|
|
41
39
|
reach.rooms.includes(room) ||
|
|
42
|
-
reach.documents.some((document) => document.room === room)
|
|
43
|
-
typedAreas(reach, room).length > 0);
|
|
40
|
+
reach.documents.some((document) => document.room === room));
|
|
44
41
|
}
|
|
45
42
|
function wholly(reach, room) {
|
|
46
43
|
return reach === null || reach.rooms.includes(room);
|
|
@@ -49,14 +46,11 @@ export function governs(reach, room) {
|
|
|
49
46
|
if (wholly(reach, room.locator)) {
|
|
50
47
|
return { collection: true, selection: room.typedSelection !== null };
|
|
51
48
|
}
|
|
52
|
-
const
|
|
53
|
-
const paths =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
...typedAreas(reach, room.locator).map(({ path }) => path),
|
|
58
|
-
];
|
|
59
|
-
return { collection: paths.some((path) => !selected(path)), selection: paths.some(selected) };
|
|
49
|
+
const within = (path) => selected({ selection: room.typedSelection }, path);
|
|
50
|
+
const paths = reach.documents
|
|
51
|
+
.filter((document) => document.room === room.locator)
|
|
52
|
+
.map(({ path }) => path);
|
|
53
|
+
return { collection: paths.some((path) => !within(path)), selection: paths.some(within) };
|
|
60
54
|
}
|
|
61
55
|
function covers(reach, room, path) {
|
|
62
56
|
return (reach === null ||
|
|
@@ -76,7 +70,7 @@ export function planReach(reach) {
|
|
|
76
70
|
...new Set(reach.documents.map(({ room, path }) => documentKey(room, path))),
|
|
77
71
|
].sort(),
|
|
78
72
|
areas: areasOf(reach)
|
|
79
|
-
.map(({ room, path,
|
|
73
|
+
.map(({ room, path, open }) => ({ room, path, open: [...new Set(open)].sort() }))
|
|
80
74
|
.sort((left, right) => documentKey(left.room, left.path) < documentKey(right.room, right.path) ? -1 : 1),
|
|
81
75
|
};
|
|
82
76
|
}
|
|
@@ -126,7 +120,7 @@ function savedWithin(reach, room, result) {
|
|
|
126
120
|
function statusWithin(reach, status) {
|
|
127
121
|
return {
|
|
128
122
|
...status,
|
|
129
|
-
attentionRequired: status.attentionRequired.filter((entry) =>
|
|
123
|
+
attentionRequired: status.attentionRequired.filter((entry) => covers(reach, entry.room, entry.path)),
|
|
130
124
|
unsent: status.unsent.filter((change) => covers(reach, change.room, change.path)),
|
|
131
125
|
};
|
|
132
126
|
}
|
|
@@ -144,13 +138,13 @@ function queueWithin(reach, room, entries) {
|
|
|
144
138
|
});
|
|
145
139
|
}
|
|
146
140
|
function unreached(room) {
|
|
147
|
-
return runtimeError('room
|
|
141
|
+
return runtimeError('unknown-room', `Unknown Room ${room}`);
|
|
148
142
|
}
|
|
149
143
|
function lockedError(room) {
|
|
150
144
|
return runtimeError(ROOM_LOCKED, `${room} is locked until House confirms its access`, true);
|
|
151
145
|
}
|
|
152
146
|
function deviceUnreached() {
|
|
153
|
-
return runtimeError('device-unreached', 'Only the panel
|
|
147
|
+
return runtimeError('device-unreached', 'Only the panel reaches this device');
|
|
154
148
|
}
|
|
155
149
|
const ATTACH_REQUIRED = 'attach-required';
|
|
156
150
|
function attachRequired() {
|
|
@@ -159,10 +153,9 @@ function attachRequired() {
|
|
|
159
153
|
function carriesFile(parts) {
|
|
160
154
|
return parts !== null && typeof parts === 'object' && Object.hasOwn(parts, 'file');
|
|
161
155
|
}
|
|
162
|
-
export function narrowed(runtime, given,
|
|
156
|
+
export function narrowed(runtime, given, port) {
|
|
163
157
|
const { md, watch } = runtime;
|
|
164
158
|
let reach = given;
|
|
165
|
-
let port = told;
|
|
166
159
|
const open = new Set();
|
|
167
160
|
function following(begin, locking = false) {
|
|
168
161
|
let stop = begin();
|
|
@@ -178,70 +171,127 @@ export function narrowed(runtime, given, told) {
|
|
|
178
171
|
stop();
|
|
179
172
|
};
|
|
180
173
|
}
|
|
181
|
-
const unlocking = (rooms) => {
|
|
182
|
-
const
|
|
183
|
-
return
|
|
184
|
-
|
|
185
|
-
|
|
174
|
+
const unlocking = (rooms, locked) => {
|
|
175
|
+
const held = (rooms ?? []).filter((room) => locked.includes(room));
|
|
176
|
+
return held.length === 0 ? null : { pending: held.map((room) => ({ room, awaits: 'unlock' })) };
|
|
177
|
+
};
|
|
178
|
+
const unlocked = (entries, locked) => entries.filter((entry) => !locked.includes(entry.room));
|
|
179
|
+
const intoLocked = async (held) => {
|
|
180
|
+
for (const move of held) {
|
|
181
|
+
if (move?.room !== undefined && (await runtime.locked(move.room)))
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
return false;
|
|
186
185
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
function ordered(deliver) {
|
|
187
|
+
let open = true;
|
|
188
|
+
let shown = Promise.resolve();
|
|
189
|
+
return {
|
|
190
|
+
push(making) {
|
|
191
|
+
shown = shown.then(() => making.then((value) => {
|
|
192
|
+
if (open)
|
|
193
|
+
deliver(value);
|
|
194
|
+
}, uncaught), uncaught);
|
|
195
|
+
},
|
|
196
|
+
stop() {
|
|
197
|
+
open = false;
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function unlockedWatch(topic, input, deliver, fail, within) {
|
|
202
|
+
const shown = ordered(deliver);
|
|
203
|
+
const stop = watch(topic, input, (message) => {
|
|
204
|
+
shown.push(runtime.lockedRooms().then((locked) => within(message, locked)));
|
|
205
|
+
}, fail);
|
|
206
|
+
return () => {
|
|
207
|
+
shown.stop();
|
|
208
|
+
stop();
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function lockedFirst(room, start, shut) {
|
|
212
|
+
let open = true;
|
|
213
|
+
let stop = () => { };
|
|
214
|
+
void (async () => {
|
|
215
|
+
const closed = !holds(reach, room) || (await runtime.locked(room));
|
|
216
|
+
if (!open)
|
|
217
|
+
return;
|
|
218
|
+
if (closed)
|
|
219
|
+
shut();
|
|
220
|
+
else
|
|
221
|
+
stop = start();
|
|
222
|
+
})();
|
|
223
|
+
return () => {
|
|
224
|
+
open = false;
|
|
225
|
+
stop();
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
const within = (topic, input, deliver, fail) => {
|
|
229
|
+
if (topic === 'read' && reach !== null) {
|
|
230
|
+
fail(deviceUnreached());
|
|
231
|
+
return () => { };
|
|
232
|
+
}
|
|
190
233
|
if (topic === 'rooms') {
|
|
191
|
-
return following(() => watch(topic, input, (rooms) => deliver(roomsWithin(reach, rooms))));
|
|
234
|
+
return following(() => watch(topic, input, (rooms) => deliver(roomsWithin(reach, rooms)), fail));
|
|
192
235
|
}
|
|
193
236
|
if (topic === 'readiness') {
|
|
194
237
|
return following(() => runtime.watchReadiness(port, reach, deliver));
|
|
195
238
|
}
|
|
196
239
|
if (topic === 'sync-status') {
|
|
197
|
-
return following(() =>
|
|
198
|
-
const
|
|
199
|
-
|
|
240
|
+
return following(() => unlockedWatch(topic, input, deliver, fail, (status, locked) => {
|
|
241
|
+
const shown = statusWithin(reach, status);
|
|
242
|
+
return { ...shown, attentionRequired: unlocked(shown.attentionRequired, locked) };
|
|
200
243
|
}), true);
|
|
201
244
|
}
|
|
202
245
|
if (topic === 'room-drafts') {
|
|
203
|
-
return following(() =>
|
|
246
|
+
return following(() => unlockedWatch(topic, input, deliver, fail, (drafts, locked) => unlocked(draftsWithin(reach, drafts), locked)), true);
|
|
204
247
|
}
|
|
205
248
|
if (topic === 'queue') {
|
|
206
249
|
const room = input[0];
|
|
207
|
-
return following(() =>
|
|
208
|
-
if (!holds(reach, room) || runtime.locked(room)) {
|
|
209
|
-
deliver([]);
|
|
210
|
-
return () => { };
|
|
211
|
-
}
|
|
212
|
-
return watch(topic, input, (entries) => deliver(queueWithin(reach, room, entries)));
|
|
213
|
-
}, true);
|
|
250
|
+
return following(() => lockedFirst(room, () => watch(topic, input, (entries) => deliver(queueWithin(reach, room, entries)), fail), () => deliver([])), true);
|
|
214
251
|
}
|
|
215
252
|
if (topic === 'query') {
|
|
216
|
-
const
|
|
253
|
+
const planning = runtime.plan(input[0], reach);
|
|
217
254
|
let held = null;
|
|
218
255
|
return following(() => {
|
|
219
|
-
const locked = unlocking(plan.rooms);
|
|
220
|
-
if (locked !== null) {
|
|
221
|
-
const answer = { result: locked, keys: [] };
|
|
222
|
-
if (held === null || changeOf(held, answer) !== null)
|
|
223
|
-
deliver(answer);
|
|
224
|
-
held = digestOf(answer);
|
|
225
|
-
return () => { };
|
|
226
|
-
}
|
|
227
|
-
let first = true;
|
|
228
256
|
let open = true;
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
257
|
+
let stop = () => { };
|
|
258
|
+
void (async () => {
|
|
259
|
+
const plan = await planning;
|
|
260
|
+
const locked = await runtime.lockedRooms();
|
|
261
|
+
if (!open)
|
|
262
|
+
return;
|
|
263
|
+
const pending = unlocking(plan.rooms, locked);
|
|
264
|
+
if (pending !== null) {
|
|
265
|
+
const answer = { result: pending, keys: [] };
|
|
266
|
+
if (held === null || changeOf(held, answer) !== null)
|
|
267
|
+
deliver(answer);
|
|
268
|
+
held = digestOf(answer);
|
|
233
269
|
return;
|
|
234
270
|
}
|
|
235
|
-
first =
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
271
|
+
let first = true;
|
|
272
|
+
const heard = (message) => {
|
|
273
|
+
if (!first) {
|
|
274
|
+
held = digestApplied(held, message);
|
|
275
|
+
deliver(message);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
first = false;
|
|
279
|
+
const change = held === null ? message : changeOf(held, message);
|
|
280
|
+
held = digestOf(message);
|
|
281
|
+
if (change !== null)
|
|
282
|
+
deliver(change);
|
|
283
|
+
};
|
|
284
|
+
const current = { ...plan, reach: planReach(reach), locked };
|
|
285
|
+
stop = runtime.watchPlan(current, (message) => {
|
|
286
|
+
if (open)
|
|
287
|
+
heard(message);
|
|
288
|
+
}, (error) => {
|
|
289
|
+
if (open)
|
|
290
|
+
fail(error);
|
|
291
|
+
});
|
|
292
|
+
})().catch((error) => {
|
|
243
293
|
if (open)
|
|
244
|
-
|
|
294
|
+
fail(error);
|
|
245
295
|
});
|
|
246
296
|
return () => {
|
|
247
297
|
open = false;
|
|
@@ -252,7 +302,7 @@ export function narrowed(runtime, given, told) {
|
|
|
252
302
|
if (topic === 'conversation') {
|
|
253
303
|
return following(() => {
|
|
254
304
|
if (conversing(reach))
|
|
255
|
-
return watch(topic, input, deliver);
|
|
305
|
+
return watch(topic, input, deliver, fail);
|
|
256
306
|
deliver(unheldView(input[0]));
|
|
257
307
|
return () => { };
|
|
258
308
|
});
|
|
@@ -260,12 +310,18 @@ export function narrowed(runtime, given, told) {
|
|
|
260
310
|
if (topic === 'conversations' || topic === 'agents') {
|
|
261
311
|
return following(() => {
|
|
262
312
|
if (conversing(reach))
|
|
263
|
-
return watch(topic, input, deliver);
|
|
313
|
+
return watch(topic, input, deliver, fail);
|
|
264
314
|
deliver([]);
|
|
265
315
|
return () => { };
|
|
266
316
|
});
|
|
267
317
|
}
|
|
268
|
-
|
|
318
|
+
if (topic === 'figures' || topic === 'holdings') {
|
|
319
|
+
if (reach === null)
|
|
320
|
+
return watch(topic, input, deliver, fail);
|
|
321
|
+
fail(deviceUnreached());
|
|
322
|
+
return () => { };
|
|
323
|
+
}
|
|
324
|
+
return watch(topic, input, deliver, fail);
|
|
269
325
|
};
|
|
270
326
|
const files = new Map();
|
|
271
327
|
let handed = 0;
|
|
@@ -283,33 +339,33 @@ export function narrowed(runtime, given, told) {
|
|
|
283
339
|
const view = {
|
|
284
340
|
...md,
|
|
285
341
|
rooms: () => md.rooms().then((rooms) => roomsWithin(reach, rooms)),
|
|
286
|
-
query: ((input) => {
|
|
287
|
-
const plan = runtime.plan(input, reach);
|
|
288
|
-
|
|
342
|
+
query: (async (input) => {
|
|
343
|
+
const plan = await runtime.plan(input, reach);
|
|
344
|
+
const locked = await runtime.lockedRooms();
|
|
345
|
+
return unlocking(plan.rooms, locked) ?? runtime.query({ ...plan, locked });
|
|
289
346
|
}),
|
|
290
|
-
search: (input) =>
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
types(room) {
|
|
294
|
-
if (holds(reach, room) && runtime.locked(room))
|
|
347
|
+
search: (input) => runtime.search(input, reach),
|
|
348
|
+
async types(room) {
|
|
349
|
+
if (holds(reach, room) && (await runtime.locked(room)))
|
|
295
350
|
throw lockedError(room);
|
|
296
351
|
if (wholly(reach, room))
|
|
297
352
|
return md.types(room);
|
|
298
353
|
if (!holds(reach, room))
|
|
299
354
|
return structuredClone(UNHELD_TYPES);
|
|
300
|
-
return typesWithin(reach, runtime.room(room), md.types(room));
|
|
355
|
+
return typesWithin(reach, await runtime.room(room), await md.types(room));
|
|
301
356
|
},
|
|
302
357
|
async save(room, roomDrafts, writtenBy) {
|
|
303
358
|
if (!holds(reach, room))
|
|
304
359
|
throw unreached(room);
|
|
305
|
-
if (runtime.locked(room))
|
|
360
|
+
if (await runtime.locked(room)) {
|
|
306
361
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
362
|
+
}
|
|
307
363
|
const held = (await Promise.all(roomDrafts.map(({ path }) => md.roomDraft.read(room, path)))).map((draft) => draft?.parts.move);
|
|
308
364
|
const outside = roomDrafts.find(({ path }, at) => !covers(reach, room, path) || !moves(reach, room, held[at]));
|
|
309
365
|
if (outside !== undefined) {
|
|
310
366
|
return { outcome: 'refused', code: 'stale', retryable: false, file: outside.path };
|
|
311
367
|
}
|
|
312
|
-
if (intoLocked(held))
|
|
368
|
+
if (await intoLocked(held))
|
|
313
369
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
314
370
|
return savedWithin(reach, room, await md.save(room, roomDrafts, writtenBy));
|
|
315
371
|
},
|
|
@@ -320,47 +376,48 @@ export function narrowed(runtime, given, told) {
|
|
|
320
376
|
if (filed !== undefined) {
|
|
321
377
|
return { outcome: 'refused', code: ATTACH_REQUIRED, retryable: false, file: filed.path };
|
|
322
378
|
}
|
|
323
|
-
if (runtime.locked(room))
|
|
379
|
+
if (await runtime.locked(room)) {
|
|
324
380
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
325
|
-
|
|
381
|
+
}
|
|
382
|
+
const held = parts.map(({ path, parts: one }) => readParts(one, path).move);
|
|
326
383
|
if (parts.some(({ path }, at) => !covers(reach, room, path) || !moves(reach, room, held[at]))) {
|
|
327
384
|
throw unreached(room);
|
|
328
385
|
}
|
|
329
|
-
if (intoLocked(held))
|
|
386
|
+
if (await intoLocked(held))
|
|
330
387
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
331
388
|
return savedWithin(reach, room, await md.saveParts(room, parts, writtenBy));
|
|
332
389
|
},
|
|
333
|
-
resolve(room, path, destination) {
|
|
334
|
-
const at = runtime.located(room, path, destination);
|
|
390
|
+
async resolve(room, path, destination) {
|
|
391
|
+
const at = await runtime.located(room, path, destination);
|
|
335
392
|
return at !== null && !covers(reach, at.room, at.path)
|
|
336
|
-
?
|
|
393
|
+
? UNREADABLE
|
|
337
394
|
: md.resolve(room, path, destination);
|
|
338
395
|
},
|
|
339
|
-
history: (room, path, query) => !covers(reach, room, path)
|
|
340
|
-
?
|
|
341
|
-
: runtime.locked(room)
|
|
342
|
-
?
|
|
396
|
+
history: async (room, path, query) => !covers(reach, room, path)
|
|
397
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
398
|
+
: (await runtime.locked(room))
|
|
399
|
+
? lockedRoom(room)
|
|
343
400
|
: md.history(room, path, query),
|
|
344
401
|
binaryFile: {
|
|
345
|
-
read: (room, path, revision) => !covers(reach, room, path)
|
|
346
|
-
?
|
|
347
|
-
: runtime.locked(room)
|
|
348
|
-
?
|
|
402
|
+
read: async (room, path, revision) => !covers(reach, room, path)
|
|
403
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
404
|
+
: (await runtime.locked(room))
|
|
405
|
+
? lockedRoom(room)
|
|
349
406
|
: hand(md.binaryFile.read(room, path, revision)),
|
|
350
|
-
link: (room, path, revision) => !covers(reach, room, path)
|
|
351
|
-
?
|
|
352
|
-
: runtime.locked(room)
|
|
353
|
-
?
|
|
407
|
+
link: async (room, path, revision) => !covers(reach, room, path)
|
|
408
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
409
|
+
: (await runtime.locked(room))
|
|
410
|
+
? lockedRoom(room)
|
|
354
411
|
: md.binaryFile.link(room, path, revision),
|
|
355
|
-
show: (room, path, revision) => !covers(reach, room, path)
|
|
356
|
-
?
|
|
357
|
-
: runtime.locked(room)
|
|
358
|
-
?
|
|
412
|
+
show: async (room, path, revision) => !covers(reach, room, path)
|
|
413
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
414
|
+
: (await runtime.locked(room))
|
|
415
|
+
? lockedRoom(room)
|
|
359
416
|
: hand(md.binaryFile.show(room, path, revision)),
|
|
360
|
-
attach: (room, file) => !wholly(reach, room)
|
|
361
|
-
?
|
|
362
|
-
: runtime.locked(room)
|
|
363
|
-
?
|
|
417
|
+
attach: async (room, file) => !wholly(reach, room)
|
|
418
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
419
|
+
: (await runtime.locked(room))
|
|
420
|
+
? lockedRoom(room)
|
|
364
421
|
: md.binaryFile.attach(room, file),
|
|
365
422
|
async part(file, part) {
|
|
366
423
|
const key = files.get(file);
|
|
@@ -373,42 +430,38 @@ export function narrowed(runtime, given, told) {
|
|
|
373
430
|
},
|
|
374
431
|
},
|
|
375
432
|
reached: async (room, roomVersion, path) => (path === undefined ? wholly(reach, room) : covers(reach, room, path)) &&
|
|
376
|
-
!runtime.locked(room) &&
|
|
433
|
+
!(await runtime.locked(room)) &&
|
|
377
434
|
(await md.reached(room, roomVersion, path)),
|
|
378
435
|
log: () => (reach === null ? md.log() : ''),
|
|
379
436
|
cleanUp: () => (reach === null ? md.cleanUp() : Promise.reject(deviceUnreached())),
|
|
437
|
+
unsent: () => (reach === null ? md.unsent() : Promise.reject(deviceUnreached())),
|
|
438
|
+
reset: () => (reach === null ? md.reset() : Promise.reject(deviceUnreached())),
|
|
439
|
+
readAgain: () => (reach === null ? md.readAgain() : Promise.reject(deviceUnreached())),
|
|
380
440
|
roomDraft: {
|
|
381
|
-
list: () => md.roomDraft.list()
|
|
441
|
+
list: async () => unlocked(draftsWithin(reach, await md.roomDraft.list()), await runtime.lockedRooms()),
|
|
382
442
|
async read(room, path) {
|
|
383
443
|
if (!covers(reach, room, path))
|
|
384
444
|
return null;
|
|
385
|
-
if (runtime.locked(room))
|
|
445
|
+
if (await runtime.locked(room))
|
|
386
446
|
throw lockedError(room);
|
|
387
447
|
return shownDraft(reach, await md.roomDraft.read(room, path));
|
|
388
448
|
},
|
|
389
|
-
write(room, path, revision, parts, next) {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
catch (error) {
|
|
402
|
-
return Promise.reject(error);
|
|
403
|
-
}
|
|
404
|
-
return md.roomDraft
|
|
405
|
-
.write(room, path, revision, parts, next)
|
|
406
|
-
.then((written) => writeWithin(reach, written));
|
|
449
|
+
async write(room, path, revision, parts, next) {
|
|
450
|
+
if (reach !== null && carriesFile(parts))
|
|
451
|
+
throw attachRequired();
|
|
452
|
+
const move = readParts(parts, path).move;
|
|
453
|
+
if (!covers(reach, room, path) || !moves(reach, room, move))
|
|
454
|
+
throw unreached(room);
|
|
455
|
+
if (await runtime.locked(room))
|
|
456
|
+
throw lockedError(room);
|
|
457
|
+
if (await intoLocked([move]))
|
|
458
|
+
throw lockedError(move.room);
|
|
459
|
+
return writeWithin(reach, await md.roomDraft.write(room, path, revision, parts, next));
|
|
407
460
|
},
|
|
408
461
|
async discard(room, path, revision) {
|
|
409
462
|
if (!covers(reach, room, path))
|
|
410
463
|
return staleWrite(null);
|
|
411
|
-
if (runtime.locked(room))
|
|
464
|
+
if (await runtime.locked(room))
|
|
412
465
|
throw lockedError(room);
|
|
413
466
|
return writeWithin(reach, await md.roomDraft.discard(room, path, revision));
|
|
414
467
|
},
|
|
@@ -421,7 +474,6 @@ export function narrowed(runtime, given, told) {
|
|
|
421
474
|
answer: (id, answer) => conversation().answer(id, answer),
|
|
422
475
|
interrupt: (id) => conversation().interrupt(id),
|
|
423
476
|
kill: (id) => conversation().kill(id),
|
|
424
|
-
cancel: (id, turn) => conversation().cancel(id, turn),
|
|
425
477
|
delete: (id) => conversation().delete(id),
|
|
426
478
|
},
|
|
427
479
|
chatDraft: {
|
|
@@ -439,10 +491,5 @@ export function narrowed(runtime, given, told) {
|
|
|
439
491
|
for (const restart of [...open])
|
|
440
492
|
restart();
|
|
441
493
|
},
|
|
442
|
-
facts(next) {
|
|
443
|
-
port = next;
|
|
444
|
-
for (const restart of [...open])
|
|
445
|
-
restart();
|
|
446
|
-
},
|
|
447
494
|
};
|
|
448
495
|
}
|
package/dist/react.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
|
|
1
2
|
import type { MdRuntimeClient } from './client.js';
|
|
2
|
-
import type { AppRoom
|
|
3
|
+
import type { AppRoom } from './listing.js';
|
|
4
|
+
import type { ConnectionRefusal } from './socket.js';
|
|
5
|
+
import type { SavedRoomDraft, SaveResult } from './saves.js';
|
|
3
6
|
import type { Member, ServiceMode } from './adapter.js';
|
|
4
7
|
import type { ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
5
8
|
import { type RuntimeError } from './failure.js';
|
|
9
|
+
import type { FiguresResult } from './figures.js';
|
|
10
|
+
import type { Holdings } from './holdings.js';
|
|
11
|
+
import type { Expecting } from './expectation.js';
|
|
6
12
|
import type { QueueEntry } from './outcome.js';
|
|
7
|
-
import type {
|
|
13
|
+
import type { DocumentResult, GroupResult, PendingResult } from './query.js';
|
|
8
14
|
import type { Readiness } from './readiness.js';
|
|
9
15
|
import type { RoomDraft, RoomDraftParts } from './room-draft.js';
|
|
10
16
|
import type { SyncStatus } from './status.js';
|
|
@@ -23,6 +29,7 @@ export declare function useObserve(client: Client, topic: 'storage-loss'): Obser
|
|
|
23
29
|
export declare function useObserve(client: Client, topic: 'sync-status'): Observed<SyncStatus>;
|
|
24
30
|
export declare function useObserve(client: Client, topic: 'service-mode'): Observed<ServiceMode>;
|
|
25
31
|
export declare function useObserve(client: Client, topic: 'member'): Observed<Member | null>;
|
|
32
|
+
export declare function useObserve(client: Client, topic: 'authority-changes'): Observed<number>;
|
|
26
33
|
export declare function useObserve(client: Client, topic: 'query', query: DocumentQuery): Observed<DocumentResult | PendingResult>;
|
|
27
34
|
export declare function useObserve(client: Client, topic: 'query', query: GroupQuery): Observed<GroupResult | PendingResult>;
|
|
28
35
|
export declare function useObserve(client: Client, topic: 'queue', locator: string): Observed<readonly QueueEntry[]>;
|
|
@@ -31,6 +38,11 @@ export declare function useObserve(client: Client, topic: 'presentation'): Obser
|
|
|
31
38
|
export declare function useObserve(client: Client, topic: 'conversation', conversation: string, options: ConversationOptions): Observed<ConversationView>;
|
|
32
39
|
export declare function useObserve(client: Client, topic: 'conversations'): Observed<readonly ConversationEntry[]>;
|
|
33
40
|
export declare function useObserve(client: Client, topic: 'agents'): Observed<readonly ConversationAgent[]>;
|
|
41
|
+
export declare function useObserve(client: Client, topic: 'figures'): Observed<FiguresResult>;
|
|
42
|
+
export declare function useObserve(client: Client, topic: 'holdings'): Observed<Holdings>;
|
|
43
|
+
export declare function useReading<E extends {
|
|
44
|
+
readonly key: string;
|
|
45
|
+
}>(store: Pick<Expecting<E>, 'reads' | 'heard' | 'left'>, asks: (one: E) => boolean, shown: ((one: E) => boolean) | null): void;
|
|
34
46
|
export type Saving = {
|
|
35
47
|
readonly busy: boolean;
|
|
36
48
|
readonly outcome: SaveResult | null;
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"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U,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAsClF,wBAAgB,UAAU,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAC3D,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC,EACrD,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,EACzB,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,IAAI,GAClC,IAAI,CAON;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IACtC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACpF,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,cAAc,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACvF,CAAC;AAMF,wBAAgB,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CA8BvD"}
|
package/dist/react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
|
|
2
2
|
import { failed } from './failure.js';
|
|
3
3
|
const LOADING = { state: 'loading' };
|
|
4
4
|
export function useObserve(client, topic, ...input) {
|
|
@@ -32,6 +32,15 @@ export function useObserve(client, topic, ...input) {
|
|
|
32
32
|
}, [client, key]);
|
|
33
33
|
return held !== null && held.client === client && held.key === key ? held.observed : LOADING;
|
|
34
34
|
}
|
|
35
|
+
export function useReading(store, asks, shown) {
|
|
36
|
+
const reader = useId();
|
|
37
|
+
useLayoutEffect(() => store.reads(reader, asks), [store, reader, asks]);
|
|
38
|
+
useLayoutEffect(() => () => store.left(reader), [store, reader]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (shown !== null)
|
|
41
|
+
store.heard(reader, shown);
|
|
42
|
+
}, [store, reader, shown]);
|
|
43
|
+
}
|
|
35
44
|
const IDLE = { busy: false, outcome: null, failure: null };
|
|
36
45
|
export function useSave(client) {
|
|
37
46
|
const [state, setState] = useState(IDLE);
|
package/dist/read.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type Fields = Readonly<Record<string, unknown>>;
|
|
2
|
+
export declare const EXCERPT = 512;
|
|
3
|
+
export declare function excerpt(said: string): string;
|
|
4
|
+
export declare function record(entry: unknown): Fields;
|
|
5
|
+
export declare function text(fields: Fields, name: string): string | null;
|
|
6
|
+
export declare function list(fields: Fields, name: string): readonly unknown[];
|
|
7
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEvD,eAAO,MAAM,OAAO,MAAM,CAAC;AAE3B,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAI7C;AAED,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGhE;AAED,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,OAAO,EAAE,CAGrE"}
|
package/dist/read.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const EXCERPT = 512;
|
|
2
|
+
export function excerpt(said) {
|
|
3
|
+
return [...said.slice(0, EXCERPT * 2)].slice(0, EXCERPT).join('');
|
|
4
|
+
}
|
|
5
|
+
export function record(entry) {
|
|
6
|
+
return typeof entry === 'object' && entry !== null && !Array.isArray(entry)
|
|
7
|
+
? entry
|
|
8
|
+
: {};
|
|
9
|
+
}
|
|
10
|
+
export function text(fields, name) {
|
|
11
|
+
const value = fields[name];
|
|
12
|
+
return typeof value === 'string' && value !== '' ? value : null;
|
|
13
|
+
}
|
|
14
|
+
export function list(fields, name) {
|
|
15
|
+
const value = fields[name];
|
|
16
|
+
return Array.isArray(value) ? value : [];
|
|
17
|
+
}
|