@agentshouse/mdruntime 0.1.0-c069136dcb4e8 → 0.1.0-c076b00ebf42a
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 +21 -19
- package/dist/acceptance.d.ts +3 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +299 -0
- 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 +26 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +302 -0
- package/dist/adapter.d.ts +108 -85
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -11
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +20 -60
- package/dist/bootstrap.d.ts +9 -5
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +204 -85
- 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 +3 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +11 -0
- package/dist/client.d.ts +29 -22
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +36 -20
- package/dist/collection.d.ts +26 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +19 -2
- package/dist/compile.d.ts +8 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +286 -336
- package/dist/connection.d.ts +5 -142
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +110 -4970
- 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 +150 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +259 -0
- package/dist/conversation-row.d.ts +35 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +55 -0
- package/dist/conversation.d.ts +65 -44
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +999 -881
- 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 +150 -0
- package/dist/durability.d.ts +19 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +4 -0
- package/dist/entry.d.ts +2 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +18 -8
- 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 +49 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +199 -0
- 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 +21 -7
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +77 -41
- 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 +34 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -5
- package/dist/install.d.ts +60 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +537 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +278 -0
- package/dist/listing.d.ts +52 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +152 -0
- package/dist/live.d.ts +9 -6
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +118 -36
- package/dist/locks.d.ts +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +32 -0
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +49 -0
- 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 +15 -6
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +178 -89
- package/dist/messages.d.ts +35 -5
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +108 -36
- package/dist/model.d.ts +2 -10
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -14
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +153 -0
- package/dist/observation.d.ts +28 -13
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +185 -81
- 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 +53 -0
- package/dist/outcome.d.ts +11 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +26 -2
- package/dist/overlay.d.ts +6 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +47 -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 +4 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +13 -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 +41 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +314 -0
- package/dist/presence.d.ts +58 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +233 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +308 -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 +29 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +115 -0
- 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 +16 -15
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +248 -147
- package/dist/react.d.ts +17 -3
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -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 +9 -6
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +3 -5
- package/dist/reads.d.ts +39 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +178 -0
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +38 -8
- package/dist/refresh.d.ts +2 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +31 -3
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +55 -0
- package/dist/replica.d.ts +11 -16
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +64 -30
- 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 +7 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +113 -111
- 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 +16 -22
- 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 +42 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +344 -174
- package/dist/saves.d.ts +32 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +409 -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 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +33 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +309 -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 +28 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +103 -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 +164 -0
- package/dist/source.d.ts +54 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +82 -0
- package/dist/status.d.ts +0 -2
- 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 +40 -0
- package/dist/store/readiness.d.ts +11 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +68 -0
- package/dist/store/records.d.ts +217 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +464 -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/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/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 +113 -144
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +171 -364
- package/dist/stored.d.ts +72 -35
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +340 -197
- package/dist/surface.d.ts +89 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +222 -0
- package/dist/sync.d.ts +19 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +535 -0
- package/dist/tables.d.ts +124 -30
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +242 -62
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +128 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +9 -12
- 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 +58 -9
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +21 -5
- 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/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/log.d.ts +0 -5
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -156
package/dist/observation.js
CHANGED
|
@@ -6,49 +6,165 @@ export function rowsOf(result) {
|
|
|
6
6
|
export function whole(message) {
|
|
7
7
|
return 'result' in message;
|
|
8
8
|
}
|
|
9
|
-
export function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const kept =
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
export function pendingChange(message) {
|
|
10
|
+
return 'pending' in message;
|
|
11
|
+
}
|
|
12
|
+
export function unchanged(change) {
|
|
13
|
+
return change.changed.length === 0 && change.removed.length === 0 && change.order === null;
|
|
14
|
+
}
|
|
15
|
+
export function keyedChange(held, keys, rows, same) {
|
|
16
|
+
const present = new Set(keys);
|
|
17
|
+
const changed = keys.flatMap((key, at) => {
|
|
18
|
+
const was = held.get(key);
|
|
19
|
+
return was !== undefined && same(was, rows[at]) ? [] : [[key, rows[at]]];
|
|
20
|
+
});
|
|
21
|
+
const removed = [];
|
|
22
|
+
const kept = [];
|
|
23
|
+
for (const key of held.keys())
|
|
24
|
+
(present.has(key) ? kept : removed).push(key);
|
|
25
|
+
const moved = kept.length !== keys.length || kept.some((key, at) => keys[at] !== key);
|
|
26
|
+
return { changed, removed, order: moved ? keys : null };
|
|
27
|
+
}
|
|
28
|
+
export function keyedAt(held, at, same) {
|
|
29
|
+
const changed = [];
|
|
30
|
+
const removed = [];
|
|
31
|
+
for (const [key, now] of at) {
|
|
32
|
+
const was = held.get(key);
|
|
33
|
+
if (was === undefined) {
|
|
34
|
+
if (now !== null)
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
else if (now === null)
|
|
38
|
+
removed.push(key);
|
|
39
|
+
else if (!same(was, now))
|
|
40
|
+
changed.push([key, now]);
|
|
41
|
+
}
|
|
42
|
+
return { changed, removed, order: null };
|
|
43
|
+
}
|
|
44
|
+
export function keyedInto(held, change) {
|
|
45
|
+
for (const key of change.removed)
|
|
46
|
+
held.delete(key);
|
|
47
|
+
for (const [key, row] of change.changed)
|
|
48
|
+
held.set(key, row);
|
|
49
|
+
if (change.order === null)
|
|
50
|
+
return;
|
|
51
|
+
const placed = change.order.map((key) => [key, held.get(key)]);
|
|
52
|
+
held.clear();
|
|
53
|
+
for (const [key, row] of placed)
|
|
54
|
+
held.set(key, row);
|
|
55
|
+
}
|
|
56
|
+
export function samePending(was, now) {
|
|
57
|
+
return was.awaits === now.awaits;
|
|
58
|
+
}
|
|
59
|
+
function keyedRows(keys, rows) {
|
|
60
|
+
const held = new Map(keys.map((key, at) => [key, rows[at]]));
|
|
61
|
+
let shown = rows;
|
|
62
|
+
return {
|
|
63
|
+
rows: () => shown,
|
|
64
|
+
apply(change) {
|
|
65
|
+
if (unchanged(change))
|
|
66
|
+
return shown;
|
|
67
|
+
keyedInto(held, change);
|
|
68
|
+
shown = [...held.values()];
|
|
69
|
+
return shown;
|
|
70
|
+
},
|
|
29
71
|
};
|
|
72
|
+
}
|
|
73
|
+
function located(rooms) {
|
|
74
|
+
return keyedRows(rooms.map(({ locator }) => locator), rooms);
|
|
75
|
+
}
|
|
76
|
+
function keyedRooms(first) {
|
|
77
|
+
let held = located(first);
|
|
78
|
+
return {
|
|
79
|
+
value: first,
|
|
80
|
+
next(message) {
|
|
81
|
+
if (!Array.isArray(message))
|
|
82
|
+
return held.apply(message);
|
|
83
|
+
held = located(message);
|
|
84
|
+
return held.rows();
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function covered(readiness) {
|
|
89
|
+
return keyedRows(readiness.coverage.rooms.map(({ room }) => room), readiness.coverage.rooms);
|
|
90
|
+
}
|
|
91
|
+
function keyedReadiness(first) {
|
|
92
|
+
let held = covered(first);
|
|
30
93
|
return {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
94
|
+
value: first,
|
|
95
|
+
next(message) {
|
|
96
|
+
if (!('shown' in message)) {
|
|
97
|
+
held = covered(message);
|
|
98
|
+
return message;
|
|
99
|
+
}
|
|
100
|
+
const { shown, rooms } = message;
|
|
101
|
+
return { ...shown, coverage: { ...shown.coverage, rooms: held.apply(rooms) } };
|
|
102
|
+
},
|
|
35
103
|
};
|
|
36
104
|
}
|
|
105
|
+
function awaiting(pending) {
|
|
106
|
+
return keyedRows(pending.map(({ room }) => room), pending);
|
|
107
|
+
}
|
|
37
108
|
function keyedResult(first) {
|
|
38
|
-
let
|
|
109
|
+
let result = first.result;
|
|
110
|
+
let rows = keyedRows([], []);
|
|
111
|
+
let pending = awaiting([]);
|
|
112
|
+
const take = ({ result: next, keys }) => {
|
|
113
|
+
result = next;
|
|
114
|
+
if ('pending' in next)
|
|
115
|
+
pending = awaiting(next.pending);
|
|
116
|
+
else
|
|
117
|
+
rows = keyedRows(keys, rowsOf(next));
|
|
118
|
+
return result;
|
|
119
|
+
};
|
|
120
|
+
take(first);
|
|
39
121
|
return {
|
|
40
122
|
value: first.result,
|
|
41
123
|
next(message) {
|
|
42
|
-
|
|
43
|
-
|
|
124
|
+
const asked = message;
|
|
125
|
+
if (whole(asked))
|
|
126
|
+
return take(asked);
|
|
127
|
+
if (pendingChange(asked)) {
|
|
128
|
+
if ('pending' in result)
|
|
129
|
+
result = { pending: pending.apply(asked.pending) };
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
if ('pending' in result)
|
|
133
|
+
return result;
|
|
134
|
+
const kept = rows.apply(asked);
|
|
135
|
+
const coverage = asked.coverage ?? result.coverage;
|
|
136
|
+
const next = asked.next === undefined ? result.next : (asked.next ?? undefined);
|
|
137
|
+
const total = asked.total ?? result.total;
|
|
138
|
+
const window = {
|
|
139
|
+
...(next === undefined ? {} : { next }),
|
|
140
|
+
...(total === undefined ? {} : { total }),
|
|
141
|
+
};
|
|
142
|
+
result =
|
|
143
|
+
'groups' in result
|
|
144
|
+
? { groups: kept, coverage, ...window }
|
|
145
|
+
: { documents: kept, coverage, ...window };
|
|
146
|
+
return result;
|
|
44
147
|
},
|
|
45
148
|
};
|
|
46
149
|
}
|
|
150
|
+
const FOLDS = {
|
|
151
|
+
query: (first) => keyedResult(first),
|
|
152
|
+
rooms: (first) => keyedRooms(first),
|
|
153
|
+
readiness: (first) => keyedReadiness(first),
|
|
154
|
+
};
|
|
155
|
+
const WHOLE = {
|
|
156
|
+
query: (message) => whole(message),
|
|
157
|
+
rooms: (message) => Array.isArray(message),
|
|
158
|
+
readiness: (message) => !('shown' in message),
|
|
159
|
+
};
|
|
160
|
+
export function replaces(topic, message) {
|
|
161
|
+
return WHOLE[topic]?.(message) ?? true;
|
|
162
|
+
}
|
|
47
163
|
function replaced(first) {
|
|
48
164
|
return { value: first, next: (message) => message };
|
|
49
165
|
}
|
|
50
|
-
export function observed(first, stop,
|
|
51
|
-
const reducer =
|
|
166
|
+
export function observed(first, stop, topic) {
|
|
167
|
+
const reducer = (FOLDS[topic] ?? replaced)(first);
|
|
52
168
|
let value = reducer.value;
|
|
53
169
|
let open = true;
|
|
54
170
|
const listeners = new Set();
|
|
@@ -86,29 +202,29 @@ export function observed(first, stop, keyed) {
|
|
|
86
202
|
end,
|
|
87
203
|
};
|
|
88
204
|
}
|
|
89
|
-
export function opened(watch,
|
|
205
|
+
export function opened(watch, topic) {
|
|
90
206
|
return new Promise((resolve, reject) => {
|
|
91
207
|
let handle;
|
|
92
208
|
let stop = () => { };
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
209
|
+
stop = watch((message) => {
|
|
210
|
+
if (handle !== undefined) {
|
|
211
|
+
handle.receive(message);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
handle = observed(message, () => stop(), topic);
|
|
215
|
+
resolve(handle.observation);
|
|
216
|
+
}, (error) => {
|
|
217
|
+
if (handle !== undefined)
|
|
218
|
+
return;
|
|
219
|
+
stop();
|
|
104
220
|
reject(error);
|
|
105
|
-
}
|
|
221
|
+
});
|
|
106
222
|
});
|
|
107
223
|
}
|
|
108
224
|
export function observing(watch) {
|
|
109
|
-
return (topic, ...input) => opened((deliver) => watch(topic, input, (message) => {
|
|
225
|
+
return (topic, ...input) => opened((deliver, fail) => watch(topic, input, (message) => {
|
|
110
226
|
deliver(structuredClone(message));
|
|
111
|
-
}), topic
|
|
227
|
+
}, fail), topic);
|
|
112
228
|
}
|
|
113
229
|
export function hashed(text) {
|
|
114
230
|
let first = 0xdeadbeef;
|
|
@@ -129,10 +245,9 @@ function rowDigest(row) {
|
|
|
129
245
|
}
|
|
130
246
|
export function digestOf({ result, keys }) {
|
|
131
247
|
if ('pending' in result)
|
|
132
|
-
return { pending:
|
|
248
|
+
return { pending: new Map(result.pending.map((room) => [room.room, room])) };
|
|
133
249
|
const rows = rowsOf(result);
|
|
134
250
|
return {
|
|
135
|
-
keys,
|
|
136
251
|
rows: new Map(keys.map((key, index) => [key, rowDigest(rows[index])])),
|
|
137
252
|
coverage: JSON.stringify(result.coverage),
|
|
138
253
|
next: result.next,
|
|
@@ -140,16 +255,22 @@ export function digestOf({ result, keys }) {
|
|
|
140
255
|
};
|
|
141
256
|
}
|
|
142
257
|
export function digestApplied(digest, message) {
|
|
143
|
-
if (whole(message)
|
|
144
|
-
return
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
258
|
+
if (whole(message))
|
|
259
|
+
return digestOf(message);
|
|
260
|
+
if (pendingChange(message)) {
|
|
261
|
+
if ('pending' in digest)
|
|
262
|
+
keyedInto(digest.pending, message.pending);
|
|
263
|
+
return digest;
|
|
264
|
+
}
|
|
265
|
+
if ('pending' in digest)
|
|
266
|
+
return digest;
|
|
267
|
+
keyedInto(digest.rows, {
|
|
268
|
+
changed: message.changed.map(([key, row]) => [key, rowDigest(row)]),
|
|
269
|
+
removed: message.removed,
|
|
270
|
+
order: message.order,
|
|
271
|
+
});
|
|
150
272
|
return {
|
|
151
|
-
|
|
152
|
-
rows,
|
|
273
|
+
rows: digest.rows,
|
|
153
274
|
coverage: message.coverage === undefined ? digest.coverage : JSON.stringify(message.coverage),
|
|
154
275
|
next: message.next === undefined ? digest.next : (message.next ?? undefined),
|
|
155
276
|
total: message.total ?? digest.total,
|
|
@@ -157,35 +278,18 @@ export function digestApplied(digest, message) {
|
|
|
157
278
|
}
|
|
158
279
|
export function changeOf(previous, next) {
|
|
159
280
|
const after = next.result;
|
|
160
|
-
if ('pending' in previous
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
: next;
|
|
281
|
+
if ('pending' in previous && 'pending' in after) {
|
|
282
|
+
const pending = keyedChange(previous.pending, after.pending.map(({ room }) => room), after.pending, samePending);
|
|
283
|
+
return unchanged(pending) ? null : { pending };
|
|
164
284
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
const row = later[index];
|
|
170
|
-
if (previous.rows.get(key) !== rowDigest(row))
|
|
171
|
-
changed.push([key, row]);
|
|
172
|
-
});
|
|
173
|
-
const removed = previous.keys.filter((key) => !present.has(key));
|
|
174
|
-
const kept = previous.keys.filter((key) => present.has(key));
|
|
175
|
-
const moved = kept.length !== next.keys.length || kept.some((key, index) => next.keys[index] !== key);
|
|
176
|
-
const coverage = JSON.stringify(after.coverage);
|
|
177
|
-
const covered = previous.coverage !== coverage;
|
|
285
|
+
if ('pending' in previous || 'pending' in after)
|
|
286
|
+
return next;
|
|
287
|
+
const rows = keyedChange(previous.rows, next.keys, rowsOf(after), (was, row) => was === rowDigest(row));
|
|
288
|
+
const covered = previous.coverage !== JSON.stringify(after.coverage);
|
|
178
289
|
const framing = reframed(previous, after);
|
|
179
|
-
if (
|
|
290
|
+
if (unchanged(rows) && !covered && framing === null)
|
|
180
291
|
return null;
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
changed,
|
|
184
|
-
removed,
|
|
185
|
-
order: moved ? next.keys : null,
|
|
186
|
-
...(covered ? { coverage: after.coverage } : {}),
|
|
187
|
-
...framing,
|
|
188
|
-
};
|
|
292
|
+
return { ...rows, ...(covered ? { coverage: after.coverage } : {}), ...framing };
|
|
189
293
|
}
|
|
190
294
|
function reframed(before, after) {
|
|
191
295
|
const next = before.next === after.next ? {} : { next: after.next ?? null };
|
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,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ACxB,IAAI,CAAC,IAAI,EAAE,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',
|
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { conversationsOpened } from './conversation.js';
|
|
2
|
+
import { detectStorageLoss, nextGeneration, refusedForSpace } from './durability.js';
|
|
3
|
+
import { uncaught } from './failure.js';
|
|
4
|
+
import { sweep } from './install.js';
|
|
5
|
+
import { eraseFenced } from './lost.js';
|
|
6
|
+
import { prepare } from './preparation.js';
|
|
7
|
+
import { unpair } from './queue.js';
|
|
8
|
+
import { emitRooms, emitStorageLoss, statusShown } from './shown.js';
|
|
9
|
+
export async function open(runtime, opened) {
|
|
10
|
+
const { store, socket, shell, conversations, build, usableWhenHeld } = runtime;
|
|
11
|
+
if (socket.closed())
|
|
12
|
+
throw new Error('runtime closed');
|
|
13
|
+
const interrupted = await opened.fences();
|
|
14
|
+
const kept = shell.generation;
|
|
15
|
+
const storedGeneration = await opened.generation();
|
|
16
|
+
const loss = detectStorageLoss(storedGeneration, kept);
|
|
17
|
+
const generation = nextGeneration(storedGeneration, kept);
|
|
18
|
+
if (generation !== storedGeneration)
|
|
19
|
+
await opened.rememberGeneration(generation);
|
|
20
|
+
if (generation !== kept)
|
|
21
|
+
await shell.keepGeneration(generation);
|
|
22
|
+
if (loss !== null) {
|
|
23
|
+
store.device.set({ storageLoss: loss });
|
|
24
|
+
emitStorageLoss(runtime);
|
|
25
|
+
}
|
|
26
|
+
const held = await opened.opened();
|
|
27
|
+
store.device.set({
|
|
28
|
+
heldWhenOpened: usableWhenHeld.length > 0 && (await opened.covering()).rooms.size > 0,
|
|
29
|
+
});
|
|
30
|
+
try {
|
|
31
|
+
await opened.demote();
|
|
32
|
+
await store.ask({ kind: 'read.builds', build });
|
|
33
|
+
for (const key of held.orphans)
|
|
34
|
+
await opened.release(key);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (!refusedForSpace(error))
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
if (held.erasing || held.orphans.length > 0)
|
|
41
|
+
queueMicrotask(() => sweep(runtime));
|
|
42
|
+
await conversationsOpened(conversations, opened);
|
|
43
|
+
if (interrupted.length > 0) {
|
|
44
|
+
queueMicrotask(() => {
|
|
45
|
+
void eraseFenced(runtime, interrupted).catch(uncaught);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
statusShown(runtime);
|
|
49
|
+
prepare(runtime);
|
|
50
|
+
emitRooms(runtime);
|
|
51
|
+
void unpair(runtime).catch(uncaught);
|
|
52
|
+
return opened;
|
|
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;
|
|
@@ -65,6 +72,7 @@ export type Offline = {
|
|
|
65
72
|
readonly kind: 'offline';
|
|
66
73
|
};
|
|
67
74
|
export declare const OFFLINE: Offline;
|
|
75
|
+
export declare function answeredResult(value: unknown): boolean;
|
|
68
76
|
export declare const UNCERTAIN: Failure;
|
|
69
77
|
export declare function undeclared(name: string): CallResult;
|
|
70
78
|
export declare function failure(result: AdapterFailure): Failure;
|
|
@@ -81,5 +89,7 @@ export type QueueEntry = {
|
|
|
81
89
|
} & (Submission | {
|
|
82
90
|
readonly state: 'local';
|
|
83
91
|
});
|
|
92
|
+
export declare const UNANSWERED: ActionResult;
|
|
93
|
+
export declare function handedOutcome(retries: Retries, attempt: Attempt | undefined, result: ActionResult): CallResult;
|
|
84
94
|
export {};
|
|
85
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
|
+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,OAAO,CAEtD;AAED,eAAO,MAAM,SAAS,EAAE,OAKvB,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAEnD;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAiBvD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAE7D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAIlE;AAED,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,WAAW,CAAA;CAAE,GAC3C;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA;CAAE,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);
|
|
@@ -44,6 +51,9 @@ export function lockedRoom(locator) {
|
|
|
44
51
|
return { kind: ROOM_LOCKED, locator, code: ROOM_LOCKED, fields: {}, retryable: true };
|
|
45
52
|
}
|
|
46
53
|
export const OFFLINE = { kind: 'offline' };
|
|
54
|
+
export function answeredResult(value) {
|
|
55
|
+
return typeof value === 'object' && value !== null && !('pending' in value);
|
|
56
|
+
}
|
|
47
57
|
export const UNCERTAIN = {
|
|
48
58
|
kind: 'transport-uncertainty',
|
|
49
59
|
code: 'transport-uncertainty',
|
|
@@ -79,3 +89,17 @@ export function historyAnswer(result) {
|
|
|
79
89
|
? result
|
|
80
90
|
: failure(result);
|
|
81
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,8 +1,11 @@
|
|
|
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>>;
|
|
5
7
|
fileIds: Readonly<Record<string, string>>;
|
|
8
|
+
created: Readonly<Record<string, string>>;
|
|
6
9
|
changes: Readonly<Record<string, HeadChange>>;
|
|
7
10
|
};
|
|
8
11
|
export type HeldBinary = ({
|
|
@@ -21,5 +24,7 @@ export type Layer = Heads & {
|
|
|
21
24
|
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
|
|
22
25
|
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
23
26
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
24
|
-
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>;
|
|
25
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":[],"m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