@agentshouse/mdruntime 0.1.0-c0136de3edfbe → 0.1.0-c01d4615bfe46
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 +16 -15
- package/dist/acceptance.d.ts +0 -3
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +74 -164
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +122 -68
- package/dist/adapter.d.ts +49 -55
- 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/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -18
- 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.map +1 -1
- package/dist/change.js +4 -2
- package/dist/chat-types.d.ts +2 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +11 -2
- package/dist/client.d.ts +13 -19
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +35 -19
- package/dist/collection.d.ts +22 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +12 -2
- package/dist/compile.d.ts +2 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +31 -24
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +32 -24
- package/dist/conversation-live.d.ts +147 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +258 -0
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +7 -1
- package/dist/conversation.d.ts +52 -44
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +956 -1029
- 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.map +1 -1
- package/dist/discovery.js +19 -44
- package/dist/durability.d.ts +13 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +4 -0
- package/dist/entry.js +1 -1
- package/dist/expectation.d.ts +26 -13
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +72 -19
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -0
- package/dist/figures.d.ts +1 -0
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +2 -2
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +2 -1
- 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 +18 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +46 -11
- package/dist/index.d.ts +17 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -6
- package/dist/install.d.ts +2 -4
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +53 -83
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +45 -35
- package/dist/listing.d.ts +6 -11
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +25 -61
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +3 -3
- package/dist/locks.d.ts +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +10 -39
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +10 -22
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +10 -13
- package/dist/memory.d.ts +7 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +58 -27
- package/dist/messages.d.ts +10 -6
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +26 -36
- package/dist/model.d.ts +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -5
- package/dist/models.d.ts +4 -8
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +95 -135
- package/dist/observation.d.ts +3 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +22 -21
- 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.map +1 -1
- package/dist/opening.js +7 -10
- package/dist/outcome.d.ts +10 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +23 -2
- package/dist/overlay.d.ts +5 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +36 -21
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +3 -58
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +10 -115
- 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.map +1 -1
- package/dist/preparation.js +25 -24
- 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 +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +24 -14
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +2 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -6
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +450 -0
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +68 -23
- package/dist/react.d.ts +11 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/readiness.d.ts +1 -2
- package/dist/readiness.d.ts.map +1 -1
- package/dist/reads.d.ts +4 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +47 -5
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +29 -7
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +5 -6
- package/dist/replica.d.ts +5 -10
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +15 -16
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +4 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +48 -59
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +17 -16
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -4
- package/dist/runtime.d.ts +11 -19
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +42 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +333 -163
- package/dist/saves.d.ts +2 -40
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +109 -703
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -3
- package/dist/shared.d.ts +1 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +6 -4
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +43 -35
- package/dist/socket/lanes.d.ts +12 -4
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +34 -8
- package/dist/socket/session.d.ts +0 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket.d.ts +3 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +5 -16
- package/dist/source.d.ts +0 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +5 -4
- package/dist/store/records.d.ts +11 -8
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +43 -12
- package/dist/store/space.d.ts +1 -1
- package/dist/store/space.d.ts.map +1 -1
- package/dist/store/space.js +0 -2
- package/dist/store/watchers.js +1 -2
- package/dist/store.d.ts +12 -7
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +38 -13
- package/dist/stored.d.ts +2 -1
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +27 -15
- package/dist/surface.d.ts +7 -4
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +30 -25
- package/dist/sync.d.ts +0 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +93 -89
- package/dist/tables.d.ts +19 -11
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +58 -21
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +6 -7
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +2 -2
- package/dist/wire.d.ts +53 -7
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +17 -4
- package/package.json +3 -2
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/socket/rooms.d.ts +0 -43
- package/dist/socket/rooms.d.ts.map +0 -1
- package/dist/socket/rooms.js +0 -90
- package/dist/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
package/dist/models.js
CHANGED
|
@@ -1,193 +1,153 @@
|
|
|
1
|
+
import { equalValue } from '@agentshouse/mdmodel';
|
|
1
2
|
import { changeSet } from './change-set.js';
|
|
2
3
|
import { composedOf } from './collection.js';
|
|
3
|
-
import {
|
|
4
|
+
import { declared, sameDeclaration } from './declaration.js';
|
|
5
|
+
import { uncaught } from './failure.js';
|
|
6
|
+
import { declarationOf, listedLocators } from './listing.js';
|
|
4
7
|
import { loseRooms } from './lost.js';
|
|
5
8
|
import { NO_MODEL } from './model.js';
|
|
9
|
+
import { settle } from './queue.js';
|
|
6
10
|
import { storedRecord } from './replica.js';
|
|
7
|
-
import { overlayDiff, preparedAfter, replayed, sliceAt } from './saves.js';
|
|
8
11
|
import { emitRooms } from './shown.js';
|
|
9
|
-
|
|
10
|
-
return
|
|
11
|
-
(JSON.stringify(held.operations) === JSON.stringify(room.operations) &&
|
|
12
|
-
JSON.stringify(held.replica) === JSON.stringify(room.replica) &&
|
|
13
|
-
JSON.stringify(held.providerOwnedPaths) === JSON.stringify(room.providerOwnedPaths) &&
|
|
14
|
-
JSON.stringify(held.typedSelection) === JSON.stringify(room.typedSelection ?? null)));
|
|
12
|
+
function declaredAsHeld(held, declaration) {
|
|
13
|
+
return held === undefined || sameDeclaration(held.declaration, declaration);
|
|
15
14
|
}
|
|
16
15
|
export function revoked(model) {
|
|
17
16
|
return model?.status === 'unavailable' && model.reason === 'revoked';
|
|
18
17
|
}
|
|
19
|
-
function unheldModelOf({
|
|
20
|
-
return
|
|
18
|
+
function unheldModelOf({ presence }, locator) {
|
|
19
|
+
return presence.unheldModel(locator) ?? NO_MODEL;
|
|
21
20
|
}
|
|
22
|
-
|
|
21
|
+
async function modelNow(runtime, locator) {
|
|
22
|
+
return (await runtime.store.record(locator))?.model ?? unheldModelOf(runtime, locator);
|
|
23
|
+
}
|
|
24
|
+
function restands(held, model, declaration) {
|
|
25
|
+
return (JSON.stringify(held.model) !== JSON.stringify(model) ||
|
|
26
|
+
!equalValue(held.declaration.typedSelection, declaration.typedSelection));
|
|
27
|
+
}
|
|
28
|
+
function recordAlone(store, record) {
|
|
29
|
+
return {
|
|
30
|
+
locator: record.locator,
|
|
31
|
+
key: record.key,
|
|
32
|
+
record: storedRecord(record),
|
|
33
|
+
composed: composedOf(store.composed(record)),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function unheld(runtime, locator, model) {
|
|
37
|
+
runtime.presence.modelled(locator, model);
|
|
38
|
+
emitRooms(runtime);
|
|
39
|
+
}
|
|
40
|
+
function recorded(runtime, locator, declaration, model) {
|
|
23
41
|
const { store, socket } = runtime;
|
|
24
|
-
|
|
25
|
-
if (held === undefined || (held.name === room.name && held.handle === room.handle))
|
|
26
|
-
return;
|
|
27
|
-
await store.exclusive(async () => {
|
|
42
|
+
return store.exclusive(async () => {
|
|
28
43
|
if (!socket.continuing())
|
|
29
44
|
return;
|
|
30
|
-
const current = await store.record(
|
|
31
|
-
if (current === undefined)
|
|
45
|
+
const current = await store.record(locator);
|
|
46
|
+
if (current === undefined) {
|
|
47
|
+
unheld(runtime, locator, model);
|
|
32
48
|
return;
|
|
33
|
-
|
|
34
|
-
await
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
composed: composedOf(store.composed(record)),
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
});
|
|
44
|
-
emitRooms(runtime);
|
|
49
|
+
}
|
|
50
|
+
const answer = await (await store.open()).commit({ rooms: [recordAlone(store, { ...current, declaration, model })] });
|
|
51
|
+
void store.changed(changeSet(locator, {
|
|
52
|
+
documents: answer.changed[locator] ?? [],
|
|
53
|
+
room: true,
|
|
54
|
+
unindexed: answer.indexed[locator] === false,
|
|
55
|
+
}));
|
|
45
56
|
});
|
|
46
57
|
}
|
|
47
|
-
async function
|
|
48
|
-
return (await runtime.store.record(locator))?.model ?? unheldModelOf(runtime, locator);
|
|
49
|
-
}
|
|
50
|
-
export async function retainModel(runtime, local, room, given) {
|
|
58
|
+
export async function retainModel(runtime, locator, declaration, given, refused) {
|
|
51
59
|
const { store, socket } = runtime;
|
|
52
|
-
const held = await store.record(
|
|
53
|
-
const previous = held?.model ?? unheldModelOf(runtime,
|
|
60
|
+
const held = await store.record(locator);
|
|
61
|
+
const previous = held?.model ?? unheldModelOf(runtime, locator);
|
|
54
62
|
const next = given ?? previous;
|
|
55
|
-
if (JSON.stringify(previous) === JSON.stringify(next) && declaredAsHeld(held,
|
|
63
|
+
if (JSON.stringify(previous) === JSON.stringify(next) && declaredAsHeld(held, declaration))
|
|
64
|
+
return;
|
|
65
|
+
if (held !== undefined && !restands(held, next, declaration)) {
|
|
66
|
+
await recorded(runtime, locator, declaration, next);
|
|
56
67
|
return;
|
|
57
|
-
|
|
68
|
+
}
|
|
69
|
+
await settle(runtime, [locator], async (works) => {
|
|
58
70
|
if (!socket.continuing())
|
|
59
|
-
return;
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const record = {
|
|
65
|
-
...current.record,
|
|
66
|
-
name: room.name,
|
|
67
|
-
handle: room.handle,
|
|
68
|
-
operations: room.operations,
|
|
69
|
-
replica: room.replica,
|
|
70
|
-
providerOwnedPaths: room.providerOwnedPaths,
|
|
71
|
-
typedSelection: room.typedSelection ?? null,
|
|
72
|
-
model: next,
|
|
73
|
-
};
|
|
74
|
-
const confirmedLayer = await sliceAt(store, record, 'confirmed', current.queue, current.overlaid);
|
|
75
|
-
const replayedLayer = await replayed(store, record, confirmedLayer, current.queue);
|
|
76
|
-
const diff = await overlayDiff(record, current, replayedLayer.visible, replayedLayer.touched);
|
|
77
|
-
const answer = await local.commit({
|
|
78
|
-
rooms: [
|
|
79
|
-
{
|
|
80
|
-
locator: room.locator,
|
|
81
|
-
key: record.key,
|
|
82
|
-
record: storedRecord(record),
|
|
83
|
-
roots: record.typedSelection?.roots ?? [],
|
|
84
|
-
composed: composedOf(store.composed(record)),
|
|
85
|
-
overlay: diff.overlay,
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
});
|
|
89
|
-
preparedAfter(runtime, room.locator, answer);
|
|
90
|
-
changed = changeSet(room.locator, {
|
|
91
|
-
documents: answer.changed[room.locator] ?? [],
|
|
92
|
-
room: true,
|
|
93
|
-
});
|
|
71
|
+
return [];
|
|
72
|
+
const current = works.get(locator)?.replica;
|
|
73
|
+
if (current === undefined) {
|
|
74
|
+
unheld(runtime, locator, next);
|
|
75
|
+
return [];
|
|
94
76
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
77
|
+
return [
|
|
78
|
+
{
|
|
79
|
+
locator,
|
|
80
|
+
record: { ...current.record, declaration, model: next },
|
|
81
|
+
...(refused === undefined ? {} : { refused }),
|
|
82
|
+
},
|
|
83
|
+
];
|
|
102
84
|
});
|
|
103
85
|
}
|
|
104
|
-
export async function scoped(runtime, result,
|
|
105
|
-
const { socket,
|
|
86
|
+
export async function scoped(runtime, result, locator, declaration) {
|
|
87
|
+
const { socket, presence } = runtime;
|
|
106
88
|
if (result.scope === 'content' && !result.retryable) {
|
|
107
|
-
|
|
108
|
-
await loseRooms(runtime, [room.locator]);
|
|
89
|
+
await loseRooms(runtime, [locator]);
|
|
109
90
|
return;
|
|
110
91
|
}
|
|
111
|
-
|
|
112
|
-
refusal: { code: result.code, fields: result.fields, retryable: result.retryable },
|
|
113
|
-
});
|
|
114
|
-
let scopedAway = room;
|
|
92
|
+
presence.refused(locator, result);
|
|
115
93
|
if (result.scope === 'model')
|
|
116
|
-
await retainModel(runtime,
|
|
117
|
-
status: 'unavailable',
|
|
118
|
-
reason: 'not-readable',
|
|
119
|
-
});
|
|
120
|
-
else if (result.scope !== 'operation') {
|
|
121
|
-
socket.rooms.stand(room.locator, { unreadable: true });
|
|
122
|
-
scopedAway = { ...room, replica: { ...room.replica, admission: 'unavailable' } };
|
|
123
|
-
await retainModel(runtime, local, scopedAway, null);
|
|
124
|
-
}
|
|
94
|
+
await retainModel(runtime, locator, declaration, { status: 'unavailable', reason: 'not-readable' }, true);
|
|
125
95
|
if (!socket.continuing())
|
|
126
96
|
return;
|
|
127
|
-
list(runtime, scopedAway, admitted(runtime, scopedAway));
|
|
128
97
|
emitRooms(runtime);
|
|
129
|
-
journal.record(`scoped refusal ${room.locator} ${result.scope} ${result.code}`);
|
|
130
98
|
}
|
|
131
99
|
export async function settleModels(runtime, held, status, local) {
|
|
132
|
-
const { store, socket,
|
|
100
|
+
const { store, socket, presence } = runtime;
|
|
133
101
|
const owed = (model) => model.status !== 'unavailable' && model.status !== status;
|
|
134
102
|
const declaredAnew = await store.exclusive(async () => {
|
|
135
103
|
if (!socket.continuing())
|
|
136
104
|
return [];
|
|
137
|
-
const stored = await store.rooms(held.
|
|
138
|
-
const unchanged = held.filter((
|
|
139
|
-
const record = stored.get(
|
|
140
|
-
return (owed(record?.model ?? unheldModelOf(runtime,
|
|
105
|
+
const stored = await store.rooms([...held.keys()]);
|
|
106
|
+
const unchanged = [...held].filter(([locator, declaration]) => {
|
|
107
|
+
const record = stored.get(locator)?.record;
|
|
108
|
+
return (owed(record?.model ?? unheldModelOf(runtime, locator)) &&
|
|
109
|
+
declaredAsHeld(record, declaration));
|
|
141
110
|
});
|
|
142
|
-
const records = unchanged.flatMap((
|
|
143
|
-
const record = stored.get(
|
|
111
|
+
const records = unchanged.flatMap(([locator]) => {
|
|
112
|
+
const record = stored.get(locator)?.record;
|
|
144
113
|
return record === undefined
|
|
145
114
|
? []
|
|
146
115
|
: [{ ...record, model: { ...record.model, status } }];
|
|
147
116
|
});
|
|
148
117
|
if (records.length > 0) {
|
|
149
118
|
try {
|
|
150
|
-
await local.commit({
|
|
151
|
-
rooms: records.map((record) => ({
|
|
152
|
-
locator: record.locator,
|
|
153
|
-
key: record.key,
|
|
154
|
-
record: storedRecord(record),
|
|
155
|
-
composed: composedOf(store.composed(record)),
|
|
156
|
-
})),
|
|
157
|
-
});
|
|
119
|
+
await local.commit({ rooms: records.map((record) => recordAlone(store, record)) });
|
|
158
120
|
}
|
|
159
|
-
catch {
|
|
160
|
-
|
|
121
|
+
catch (error) {
|
|
122
|
+
uncaught(error);
|
|
161
123
|
}
|
|
162
124
|
}
|
|
163
|
-
for (const
|
|
164
|
-
const
|
|
165
|
-
if (!stored.has(
|
|
166
|
-
|
|
167
|
-
unheldModel: { ...unheldModel, status },
|
|
168
|
-
});
|
|
125
|
+
for (const [locator] of unchanged) {
|
|
126
|
+
const unheldModel = presence.unheldModel(locator);
|
|
127
|
+
if (!stored.has(locator) && unheldModel !== null) {
|
|
128
|
+
presence.modelled(locator, { ...unheldModel, status });
|
|
169
129
|
}
|
|
170
|
-
list(runtime, room, admitted(runtime, room));
|
|
171
130
|
}
|
|
172
131
|
if (unchanged.length > 0)
|
|
173
132
|
emitRooms(runtime);
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
});
|
|
133
|
+
const kept = new Set(unchanged.map(([locator]) => locator));
|
|
134
|
+
return [...held].filter(([locator]) => !kept.has(locator) &&
|
|
135
|
+
owed(stored.get(locator)?.record.model ?? unheldModelOf(runtime, locator)));
|
|
178
136
|
});
|
|
179
|
-
for (const
|
|
180
|
-
const model = await modelNow(runtime,
|
|
137
|
+
for (const [locator, declaration] of declaredAnew) {
|
|
138
|
+
const model = await modelNow(runtime, locator);
|
|
181
139
|
if (owed(model))
|
|
182
|
-
await retainModel(runtime,
|
|
140
|
+
await retainModel(runtime, locator, declaration, { ...model, status });
|
|
183
141
|
}
|
|
184
142
|
}
|
|
185
143
|
export async function cachedModels(runtime, local) {
|
|
186
|
-
const { store,
|
|
144
|
+
const { store, presence } = runtime;
|
|
187
145
|
const held = await store.rooms();
|
|
188
|
-
await settleModels(runtime, listedLocators(runtime, held).flatMap((locator) => {
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
146
|
+
await settleModels(runtime, new Map(listedLocators(runtime, held).flatMap((locator) => {
|
|
147
|
+
const discovered = presence.room(locator);
|
|
148
|
+
const declaration = discovered === undefined
|
|
149
|
+
? declarationOf(runtime, locator, held.get(locator))?.room
|
|
150
|
+
: declared(discovered);
|
|
151
|
+
return declaration === undefined ? [] : [[locator, declaration]];
|
|
152
|
+
})), 'cached', local);
|
|
193
153
|
}
|
package/dist/observation.d.ts
CHANGED
|
@@ -25,9 +25,10 @@ export type Observed = {
|
|
|
25
25
|
};
|
|
26
26
|
export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
|
|
27
27
|
export declare function whole(message: QueryMessage): message is KeyedResult;
|
|
28
|
+
export declare function replaces(topic: string, message: unknown): boolean;
|
|
28
29
|
export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
|
|
29
|
-
export declare function observed(first: unknown, stop: () => void,
|
|
30
|
-
export declare function opened(watch: (deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void,
|
|
30
|
+
export declare function observed(first: unknown, stop: () => void, topic: string): Observed;
|
|
31
|
+
export declare function opened(watch: (deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void, topic: string): Promise<Observation<unknown>>;
|
|
31
32
|
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
32
33
|
export type Digest = {
|
|
33
34
|
readonly pending: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,IAAI,CAAC,CAAC;IACb,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACpD,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC;IACpE,OAAO,EAAE,SAAS,MAAM,E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ist/observation.js
CHANGED
|
@@ -6,6 +6,12 @@ export function rowsOf(result) {
|
|
|
6
6
|
export function whole(message) {
|
|
7
7
|
return 'result' in message;
|
|
8
8
|
}
|
|
9
|
+
function folds(topic) {
|
|
10
|
+
return topic === 'query';
|
|
11
|
+
}
|
|
12
|
+
export function replaces(topic, message) {
|
|
13
|
+
return !folds(topic) || whole(message);
|
|
14
|
+
}
|
|
9
15
|
export function applied(keyed, message) {
|
|
10
16
|
if (whole(message))
|
|
11
17
|
return message;
|
|
@@ -47,8 +53,8 @@ function keyedResult(first) {
|
|
|
47
53
|
function replaced(first) {
|
|
48
54
|
return { value: first, next: (message) => message };
|
|
49
55
|
}
|
|
50
|
-
export function observed(first, stop,
|
|
51
|
-
const reducer =
|
|
56
|
+
export function observed(first, stop, topic) {
|
|
57
|
+
const reducer = folds(topic) ? keyedResult(first) : replaced(first);
|
|
52
58
|
let value = reducer.value;
|
|
53
59
|
let open = true;
|
|
54
60
|
const listeners = new Set();
|
|
@@ -86,34 +92,29 @@ export function observed(first, stop, keyed) {
|
|
|
86
92
|
end,
|
|
87
93
|
};
|
|
88
94
|
}
|
|
89
|
-
export function opened(watch,
|
|
95
|
+
export function opened(watch, topic) {
|
|
90
96
|
return new Promise((resolve, reject) => {
|
|
91
97
|
let handle;
|
|
92
98
|
let stop = () => { };
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
stop();
|
|
105
|
-
reject(error);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
catch (error) {
|
|
99
|
+
stop = watch((message) => {
|
|
100
|
+
if (handle !== undefined) {
|
|
101
|
+
handle.receive(message);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
handle = observed(message, () => stop(), topic);
|
|
105
|
+
resolve(handle.observation);
|
|
106
|
+
}, (error) => {
|
|
107
|
+
if (handle !== undefined)
|
|
108
|
+
return;
|
|
109
|
+
stop();
|
|
109
110
|
reject(error);
|
|
110
|
-
}
|
|
111
|
+
});
|
|
111
112
|
});
|
|
112
113
|
}
|
|
113
114
|
export function observing(watch) {
|
|
114
115
|
return (topic, ...input) => opened((deliver, fail) => watch(topic, input, (message) => {
|
|
115
116
|
deliver(structuredClone(message));
|
|
116
|
-
}, fail), topic
|
|
117
|
+
}, fail), topic);
|
|
117
118
|
}
|
|
118
119
|
export function hashed(text) {
|
|
119
120
|
let first = 0xdeadbeef;
|
package/dist/opened.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ export type OpenedFiles = {
|
|
|
18
18
|
find(name: OpenedName): Promise<KeptBinary | null>;
|
|
19
19
|
fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
|
|
20
20
|
};
|
|
21
|
-
export declare function openedFiles(database: RuntimeDatabase,
|
|
21
|
+
export declare function openedFiles(database: RuntimeDatabase, lost: (locator: string) => boolean): OpenedFiles;
|
|
22
22
|
//# sourceMappingURL=opened.d.ts.map
|
package/dist/opened.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opened.d.ts","sourceRoot":"","sources":["../src/opened.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAErF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,C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AE,UAAU,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACnD,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACjF,CAAC;AAsBF,wBAAgB,WAAW,CACzB,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,GACjC,WAAW,CAsFb"}
|
package/dist/opened.js
CHANGED
|
@@ -20,7 +20,7 @@ function taken(chunks, size) {
|
|
|
20
20
|
}
|
|
21
21
|
return part;
|
|
22
22
|
}
|
|
23
|
-
export function openedFiles(database,
|
|
23
|
+
export function openedFiles(database, lost) {
|
|
24
24
|
const fetching = new Map();
|
|
25
25
|
async function find(name) {
|
|
26
26
|
const held = await database.ask({ kind: 'opened.find', ...name });
|
|
@@ -36,14 +36,14 @@ export function openedFiles(database, fenced) {
|
|
|
36
36
|
let part = 0;
|
|
37
37
|
const write = async (bytes) => {
|
|
38
38
|
if (!(await database.ask({ kind: 'opened.part', key, part, bytes }))) {
|
|
39
|
-
throw new Error(
|
|
39
|
+
throw new Error();
|
|
40
40
|
}
|
|
41
41
|
part += 1;
|
|
42
42
|
};
|
|
43
43
|
try {
|
|
44
|
-
if (
|
|
44
|
+
if (lost(name.locator) ||
|
|
45
45
|
!(await database.ask({ kind: 'opened.begin', key, ...name, mediaType }))) {
|
|
46
|
-
throw new Error(
|
|
46
|
+
throw new Error();
|
|
47
47
|
}
|
|
48
48
|
for (;;) {
|
|
49
49
|
const read = await reader.read();
|
|
@@ -61,7 +61,7 @@ export function openedFiles(database, fenced) {
|
|
|
61
61
|
await write(taken(chunks, held));
|
|
62
62
|
const received = hashed.hex();
|
|
63
63
|
if (sha256 !== undefined && sha256 !== received) {
|
|
64
|
-
throw new Error(
|
|
64
|
+
throw new Error();
|
|
65
65
|
}
|
|
66
66
|
const whole = await database.ask({
|
|
67
67
|
kind: 'opened.keep',
|
package/dist/opening.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAqCxF"}
|
package/dist/opening.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { conversationsOpened } from './conversation.js';
|
|
1
2
|
import { detectStorageLoss, nextGeneration, refusedForSpace } from './durability.js';
|
|
3
|
+
import { uncaught } from './failure.js';
|
|
2
4
|
import { sweep } from './install.js';
|
|
3
5
|
import { eraseFenced } from './lost.js';
|
|
4
6
|
import { prepare } from './preparation.js';
|
|
7
|
+
import { unpair } from './queue.js';
|
|
5
8
|
import { emitRooms, emitStorageLoss, statusShown } from './shown.js';
|
|
6
9
|
export async function open(runtime, opened) {
|
|
7
|
-
const { store, socket,
|
|
10
|
+
const { store, socket, shell, conversations, build, usableWhenHeld } = runtime;
|
|
8
11
|
if (socket.closed())
|
|
9
12
|
throw new Error('runtime closed');
|
|
10
13
|
const interrupted = await opened.fences();
|
|
@@ -36,21 +39,15 @@ export async function open(runtime, opened) {
|
|
|
36
39
|
}
|
|
37
40
|
if (held.erasing || held.orphans.length > 0)
|
|
38
41
|
queueMicrotask(() => sweep(runtime));
|
|
39
|
-
await conversations
|
|
42
|
+
await conversationsOpened(conversations, opened);
|
|
40
43
|
if (interrupted.length > 0) {
|
|
41
44
|
queueMicrotask(() => {
|
|
42
|
-
void eraseFenced(runtime, interrupted).catch(
|
|
43
|
-
journal.record('erasure failed');
|
|
44
|
-
});
|
|
45
|
+
void eraseFenced(runtime, interrupted).catch(uncaught);
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
48
|
statusShown(runtime);
|
|
48
49
|
prepare(runtime);
|
|
49
50
|
emitRooms(runtime);
|
|
50
|
-
void
|
|
51
|
-
.exclusive(() => runtime.unpair(opened))
|
|
52
|
-
.catch(() => {
|
|
53
|
-
journal.record('unpair failed');
|
|
54
|
-
});
|
|
51
|
+
void unpair(runtime).catch(uncaught);
|
|
55
52
|
return opened;
|
|
56
53
|
}
|
package/dist/outcome.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ActionResult, AdapterFailure, AttachResult, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
|
+
import type { Attempt, Retries } from './retried.js';
|
|
3
4
|
import type { KeptBinary, KeptResult } from './opened.js';
|
|
4
5
|
type Refused<Kind extends string> = ProviderRefusal & {
|
|
5
6
|
kind: Kind;
|
|
@@ -13,7 +14,9 @@ export type CallResult = {
|
|
|
13
14
|
kind: 'action';
|
|
14
15
|
result: unknown;
|
|
15
16
|
at?: RoomVersionAt;
|
|
16
|
-
} | Refused<'rejected'>
|
|
17
|
+
} | (Refused<'rejected'> & {
|
|
18
|
+
reset?: string;
|
|
19
|
+
}) | Refused<'undeclared'> | Failure;
|
|
17
20
|
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
18
21
|
kind: Failure['kind'];
|
|
19
22
|
}> | Failure;
|
|
@@ -54,6 +57,10 @@ export declare const UNREADABLE: Refused<'unreadable'>;
|
|
|
54
57
|
export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
55
58
|
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
56
59
|
export declare function absentBinary(path: string): Refused<'absent'>;
|
|
60
|
+
export declare function declaredType(blob: Blob): string;
|
|
61
|
+
export declare function blobOf(binary: Extract<BinaryAnswer, {
|
|
62
|
+
kind: 'binary';
|
|
63
|
+
}>): Promise<Blob>;
|
|
57
64
|
export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
|
|
58
65
|
export declare function binaryLinkAnswer(result: BinaryLinkResult, held?: string): BinaryLinkAnswer;
|
|
59
66
|
export declare function attachAnswer(result: AttachResult): AttachAnswer;
|
|
@@ -82,5 +89,7 @@ export type QueueEntry = {
|
|
|
82
89
|
} & (Submission | {
|
|
83
90
|
readonly state: 'local';
|
|
84
91
|
});
|
|
92
|
+
export declare const UNANSWERED: ActionResult;
|
|
93
|
+
export declare function handedOutcome(retries: Retries, attempt: Attempt | undefined, result: ActionResult): CallResult;
|
|
85
94
|
export {};
|
|
86
95
|
//# sourceMappingURL=outcome.d.ts.map
|
package/dist/outcome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D,KAAK,OAAO,CAAC,IAAI,SAAS,MAAM,IAAI,eAAe,GAAG;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAErE,MAAM,MAAM,OAAO,GACf,OAAO,CAAC,uBAAuB,CAAC,GAChC,OAAO,CAAC,uBAAuB,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E,GAAG,CACvD,UAAU,GACV;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAC9B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,YAAgD,CAAC;AAE1E,wBAAgB,aAAa,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,MAAM,EAAE,YAAY,GACnB,UAAU,CAUZ"}
|
package/dist/outcome.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MEDIA_TYPES } from '@agentshouse/mdmodel';
|
|
2
|
+
import { refusalError } from './failure.js';
|
|
1
3
|
export const UNREADABLE = {
|
|
2
4
|
kind: 'unreadable',
|
|
3
5
|
code: 'room-not-readable',
|
|
@@ -19,17 +21,22 @@ export const ABSENT_TARGET = {
|
|
|
19
21
|
export function absentBinary(path) {
|
|
20
22
|
return { kind: 'absent', code: 'binary-file-absent', fields: { path }, retryable: false };
|
|
21
23
|
}
|
|
24
|
+
export function declaredType(blob) {
|
|
25
|
+
return blob.type === '' ? MEDIA_TYPES.octetStream : blob.type;
|
|
26
|
+
}
|
|
27
|
+
export function blobOf(binary) {
|
|
28
|
+
return new Response(binary.stream, { headers: { 'content-type': binary.mediaType } }).blob();
|
|
29
|
+
}
|
|
22
30
|
export function binaryAnswer(result) {
|
|
23
31
|
return result.kind === 'binary' || result.kind === 'rejected' ? result : failure(result);
|
|
24
32
|
}
|
|
25
|
-
const OCTET_STREAM = 'application/octet-stream';
|
|
26
33
|
export function binaryLinkAnswer(result, held) {
|
|
27
34
|
if (result.kind === 'link') {
|
|
28
35
|
return {
|
|
29
36
|
kind: 'link',
|
|
30
37
|
url: result.url,
|
|
31
38
|
name: result.name,
|
|
32
|
-
mediaType: result.mediaType ?? held ??
|
|
39
|
+
mediaType: result.mediaType ?? held ?? MEDIA_TYPES.octetStream,
|
|
33
40
|
};
|
|
34
41
|
}
|
|
35
42
|
return result.kind === 'rejected' ? result : failure(result);
|
|
@@ -82,3 +89,17 @@ export function historyAnswer(result) {
|
|
|
82
89
|
? result
|
|
83
90
|
: failure(result);
|
|
84
91
|
}
|
|
92
|
+
export const UNANSWERED = { kind: 'transport-uncertainty' };
|
|
93
|
+
export function handedOutcome(retries, attempt, result) {
|
|
94
|
+
if (attempt !== undefined) {
|
|
95
|
+
const { step, instance } = attempt;
|
|
96
|
+
if (result.kind === 'action')
|
|
97
|
+
retries.succeeded(step, instance);
|
|
98
|
+
else if (result.kind === 'transport-uncertainty')
|
|
99
|
+
retries.uncertain(step, instance, result);
|
|
100
|
+
else if (result.kind === 'rejected' && result.retryable) {
|
|
101
|
+
retries.failed(step, instance, refusalError(result));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return calledResult(result);
|
|
105
|
+
}
|
package/dist/overlay.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { type ApplyResult } from '@agentshouse/mdmodel';
|
|
1
2
|
import type { BinaryFile, HeadChange } from './adapter.js';
|
|
3
|
+
import { type Composition } from './collection.js';
|
|
2
4
|
import type { ChangeBatch } from './change.js';
|
|
3
5
|
export type Heads = {
|
|
4
6
|
revisions: Readonly<Record<string, string>>;
|
|
@@ -22,5 +24,7 @@ export type Layer = Heads & {
|
|
|
22
24
|
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
|
|
23
25
|
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
24
26
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
25
|
-
export declare function
|
|
27
|
+
export declare function composed(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): ApplyResult;
|
|
28
|
+
export declare function compose(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): string;
|
|
29
|
+
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], composition: Composition, unapplied?: () => void): Generator<number, Layer, void>;
|
|
26
30
|
//# sourceMappingURL=overlay.d.ts.map
|
package/dist/overlay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAU,WAAW,EAAgB,MAAM,aAAa,CAAC;AAIrE,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GAAG,UAAU,CAAC,GAC7C;IACE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEN,MAAM,MAAM,KAAK,GAAG,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