@agentshouse/mdruntime 0.1.0-c806ecaf4afed → 0.1.0-c83bc1fac9b35
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.map +1 -1
- package/dist/acceptance.js +15 -24
- package/dist/act-lanes.d.ts +11 -14
- package/dist/act-lanes.d.ts.map +1 -1
- package/dist/act-lanes.js +53 -5
- package/dist/actions.d.ts +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +138 -68
- package/dist/adapter.d.ts +86 -14
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +0 -5
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +345 -0
- package/dist/change.d.ts +4 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +3 -0
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +0 -2
- package/dist/client.d.ts +14 -11
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +18 -46
- package/dist/collection.d.ts +5 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +16 -8
- package/dist/column.d.ts +5 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/column.js +9 -0
- package/dist/compile.d.ts +2 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +17 -5
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +21 -16
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +23 -7
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +18 -6
- package/dist/conversation-row.d.ts +8 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +20 -7
- package/dist/conversation.d.ts +20 -7
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +238 -174
- package/dist/discovery.d.ts +3 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +36 -9
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +5 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +5 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +23 -12
- package/dist/expectation.d.ts +25 -14
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +51 -20
- package/dist/failure.d.ts +2 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +4 -2
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- package/dist/host.d.ts +6 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +50 -16
- package/dist/house-query.d.ts +21 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +41 -0
- package/dist/index.d.ts +14 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/install.d.ts +10 -4
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +45 -46
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +50 -32
- package/dist/listing.d.ts +24 -12
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +50 -21
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +71 -30
- package/dist/loaded.d.ts +5 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +40 -0
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +4 -3
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +2 -3
- package/dist/media.d.ts +18 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +102 -24
- package/dist/memory.d.ts +5 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +58 -14
- package/dist/messages.d.ts +12 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +24 -10
- package/dist/modal.d.ts +2 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +11 -0
- package/dist/model.d.ts +4 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +5 -8
- package/dist/observation.d.ts +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +206 -69
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +20 -10
- package/dist/outcome.d.ts +13 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +32 -2
- package/dist/overlay.d.ts +4 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +11 -9
- package/dist/parts.d.ts +4 -9
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +30 -15
- package/dist/preparation.d.ts +32 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +189 -87
- package/dist/presence.d.ts +8 -2
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +24 -13
- package/dist/queries.d.ts +2 -2
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +81 -64
- package/dist/questions.d.ts +1 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +1 -7
- package/dist/queue.d.ts +2 -2
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +73 -48
- package/dist/reach.d.ts +14 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +142 -30
- package/dist/react.d.ts +10 -11
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +22 -4
- package/dist/readiness.d.ts +16 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +10 -10
- package/dist/reads.d.ts +4 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +7 -3
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +1 -3
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +2 -2
- package/dist/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 +30 -5
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +253 -30
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +5 -2
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +2 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +6 -6
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +5 -4
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +1 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +105 -124
- package/dist/saves.d.ts +2 -0
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +42 -18
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -2
- package/dist/shown.d.ts +5 -2
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +79 -43
- 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 +4 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +4 -3
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +4 -9
- package/dist/source.d.ts +5 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +13 -2
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +20 -5
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +60 -22
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store.d.ts +17 -10
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +18 -6
- package/dist/stored.d.ts +25 -13
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +80 -27
- package/dist/surface.d.ts +12 -6
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +58 -26
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +75 -39
- package/dist/tables.d.ts +16 -52
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +86 -324
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +1 -2
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +3 -9
- package/dist/wire.d.ts +33 -10
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +15 -8
- package/package.json +3 -3
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
package/dist/shown.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { changeSet, mergeChangeSets } from './change-set.js';
|
|
2
2
|
import { conversationsChanged, conversationsLearned } from './conversation.js';
|
|
3
|
-
import {
|
|
3
|
+
import { lossStated } from './durability.js';
|
|
4
|
+
import { listedEntries, listingNow, shownChange, shownRooms } from './listing.js';
|
|
4
5
|
import { emitPresentation, publishRoomDrafts } from './room-drafts.js';
|
|
5
6
|
import { same } from './status.js';
|
|
6
7
|
export const ROOMS_TOPIC = 'rooms';
|
|
@@ -9,11 +10,20 @@ export const REFUSAL_TOPIC = 'connection-refusal';
|
|
|
9
10
|
export const STORAGE_LOSS_TOPIC = 'storage-loss';
|
|
10
11
|
export const SERVICE_MODE_TOPIC = 'service-mode';
|
|
11
12
|
export const MEMBER_TOPIC = 'member';
|
|
13
|
+
export const TIME_ZONE_TOPIC = 'time-zone';
|
|
12
14
|
export const AUTHORITY_TOPIC = 'authority-changes';
|
|
13
15
|
export const LOCKS_TOPIC = 'locks';
|
|
14
16
|
export const queueTopic = (locator) => `queue\u0000${locator}`;
|
|
15
|
-
async function attended({ store, localSaves }) {
|
|
16
|
-
const held =
|
|
17
|
+
async function attended({ store, socket, localSaves }) {
|
|
18
|
+
const held = store.needed()
|
|
19
|
+
? await store.status()
|
|
20
|
+
: {
|
|
21
|
+
queued: [],
|
|
22
|
+
lastCompleted: socket.session.now().lastCompleted,
|
|
23
|
+
unsent: [],
|
|
24
|
+
resets: [],
|
|
25
|
+
returned: [],
|
|
26
|
+
};
|
|
17
27
|
const attentionRequired = held.returned.flatMap((record) => record.returned === null
|
|
18
28
|
? []
|
|
19
29
|
: [{ room: record.locator, path: record.path, returned: structuredClone(record.returned) }]);
|
|
@@ -41,15 +51,15 @@ async function attended({ store, localSaves }) {
|
|
|
41
51
|
};
|
|
42
52
|
}
|
|
43
53
|
async function queuedWork({ store, localSaves }) {
|
|
44
|
-
return !localSaves && (await store.queued()).length > 0;
|
|
54
|
+
return !localSaves && store.needed() && (await store.queued()).length > 0;
|
|
45
55
|
}
|
|
46
|
-
export function recoverReads({ liveQueries, figures }) {
|
|
47
|
-
liveQueries.recover();
|
|
56
|
+
export function recoverReads({ liveQueries, figures }, locators) {
|
|
57
|
+
liveQueries.recover(locators);
|
|
48
58
|
figures.recover();
|
|
49
59
|
}
|
|
50
60
|
export function emitRooms(runtime, changed) {
|
|
51
|
-
recoverReads(runtime);
|
|
52
|
-
runtime.store.readiness.queue();
|
|
61
|
+
recoverReads(runtime, changed);
|
|
62
|
+
runtime.store.readiness.queue(changed);
|
|
53
63
|
return changed === undefined
|
|
54
64
|
? publishRooms(runtime, 'all')
|
|
55
65
|
: publishRooms(runtime, 'changed', changed);
|
|
@@ -74,51 +84,58 @@ function roomsOwedWith(held, mode, touched) {
|
|
|
74
84
|
}
|
|
75
85
|
return held;
|
|
76
86
|
}
|
|
87
|
+
async function patchedRooms(runtime, owed) {
|
|
88
|
+
const { store } = runtime;
|
|
89
|
+
const touched = [...new Set([...owed.changed, ...owed.counted])];
|
|
90
|
+
const entries = await listedEntries(runtime, touched);
|
|
91
|
+
const shown = store.roomsShown.now();
|
|
92
|
+
if (entries === null || shown === null)
|
|
93
|
+
return false;
|
|
94
|
+
if (runtime.socket.closed())
|
|
95
|
+
return true;
|
|
96
|
+
const moved = entries.filter(({ locator, documents }) => owed.changed.has(locator) || shown.get(locator)?.documents !== documents);
|
|
97
|
+
const counted = moved.flatMap(({ locator }) => (owed.changed.has(locator) ? [] : [locator]));
|
|
98
|
+
if (counted.length > 0) {
|
|
99
|
+
recoverReads(runtime, counted);
|
|
100
|
+
store.readiness.queue(counted);
|
|
101
|
+
}
|
|
102
|
+
store.roomsShown.patch(moved);
|
|
103
|
+
if (moved.length === 0)
|
|
104
|
+
return true;
|
|
105
|
+
const change = shownChange(runtime, moved);
|
|
106
|
+
for (const watcher of store.watching(ROOMS_TOPIC, 'ready'))
|
|
107
|
+
watcher.answer(change);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
77
110
|
async function deliverRooms(runtime, owed) {
|
|
78
111
|
const { store, socket } = runtime;
|
|
79
112
|
const waiting = () => store.watching(ROOMS_TOPIC, 'waiting');
|
|
80
113
|
if (socket.closed() || store.watching(ROOMS_TOPIC).length === 0)
|
|
81
114
|
return;
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (
|
|
115
|
+
const touched = owed.changed.size > 0 || owed.counted.size > 0;
|
|
116
|
+
if (!owed.all && touched && waiting().length === 0 && (await patchedRooms(runtime, owed)))
|
|
117
|
+
return;
|
|
118
|
+
if (touched)
|
|
86
119
|
owed.all = true;
|
|
87
|
-
|
|
88
|
-
const held = await store.covering();
|
|
89
|
-
const { roomsShown } = store.device.now();
|
|
90
|
-
owed.all = [...owed.counted].some((locator) => held.rooms.has(locator) &&
|
|
91
|
-
roomsShown?.get(locator)?.documents !== held.rooms.get(locator).documents);
|
|
92
|
-
if (owed.all) {
|
|
93
|
-
recoverReads(runtime);
|
|
94
|
-
store.readiness.queue();
|
|
95
|
-
}
|
|
96
|
-
else if (waiting().length === 0)
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const listing = patched ?? (await listingNow(runtime));
|
|
120
|
+
const listing = await listingNow(runtime);
|
|
100
121
|
if (socket.closed())
|
|
101
122
|
return;
|
|
102
123
|
const { roomsListed, refusal, moving } = socket.session.now();
|
|
103
124
|
const joining = waiting().length > 0 &&
|
|
104
125
|
(roomsListed || listing.size > 0 || refusal !== null || moving.providerUnreachable);
|
|
105
|
-
if (!owed.all &&
|
|
126
|
+
if (!owed.all && !joining)
|
|
106
127
|
return;
|
|
107
128
|
const value = shownRooms(runtime, listing);
|
|
108
|
-
const
|
|
129
|
+
const shown = store.roomsShown.now();
|
|
109
130
|
const moved = owed.all ||
|
|
110
|
-
|
|
111
|
-
(roomsShown !== null &&
|
|
112
|
-
JSON.stringify(shownRooms(runtime, roomsShown)) !== JSON.stringify(value));
|
|
131
|
+
(shown !== null && JSON.stringify(shownRooms(runtime, shown)) !== JSON.stringify(value));
|
|
113
132
|
if (moved)
|
|
114
133
|
for (const watcher of store.watching(ROOMS_TOPIC, 'ready'))
|
|
115
134
|
watcher.answer(value);
|
|
116
135
|
if (joining)
|
|
117
136
|
for (const watcher of waiting())
|
|
118
137
|
watcher.answer(value);
|
|
119
|
-
store.
|
|
120
|
-
roomsShown: store.watching(ROOMS_TOPIC, 'ready').length === 0 ? null : listing,
|
|
121
|
-
});
|
|
138
|
+
store.roomsShown.show(store.watching(ROOMS_TOPIC, 'ready').length === 0 ? null : listing);
|
|
122
139
|
}
|
|
123
140
|
function publishRooms(runtime, mode, touched = []) {
|
|
124
141
|
if (runtime.socket.closed())
|
|
@@ -127,17 +144,24 @@ function publishRooms(runtime, mode, touched = []) {
|
|
|
127
144
|
}
|
|
128
145
|
export function emitRefusal(runtime) {
|
|
129
146
|
const { store, socket } = runtime;
|
|
130
|
-
store.readiness.queue();
|
|
147
|
+
store.readiness.queue([]);
|
|
131
148
|
store.tell(REFUSAL_TOPIC, socket.session.now().refusal);
|
|
132
149
|
emitKnownRooms(runtime);
|
|
133
150
|
}
|
|
134
|
-
export function
|
|
135
|
-
store.
|
|
136
|
-
|
|
151
|
+
export function storageLossNow({ store }) {
|
|
152
|
+
const { persistence, storageLoss } = store.device.now();
|
|
153
|
+
return lossStated(persistence, storageLoss);
|
|
154
|
+
}
|
|
155
|
+
export function emitStorageLoss(runtime) {
|
|
156
|
+
runtime.store.readiness.queue([]);
|
|
157
|
+
runtime.store.tell(STORAGE_LOSS_TOPIC, storageLossNow(runtime));
|
|
137
158
|
}
|
|
138
159
|
export function emitMember({ store }, member) {
|
|
139
160
|
store.tell(MEMBER_TOPIC, member);
|
|
140
161
|
}
|
|
162
|
+
export function emitTimeZone({ store }, zone) {
|
|
163
|
+
store.tell(TIME_ZONE_TOPIC, zone);
|
|
164
|
+
}
|
|
141
165
|
async function deliverStatus(runtime, owed) {
|
|
142
166
|
const { store, socket } = runtime;
|
|
143
167
|
const held = await attended(runtime);
|
|
@@ -159,13 +183,16 @@ async function deliverStatus(runtime, owed) {
|
|
|
159
183
|
store.tell(STATUS_TOPIC, next);
|
|
160
184
|
}
|
|
161
185
|
}
|
|
186
|
+
function conversationsCurrent({ conversations }) {
|
|
187
|
+
return conversations.listed() && conversations.current();
|
|
188
|
+
}
|
|
162
189
|
export function show(runtime) {
|
|
163
|
-
const { store, socket
|
|
190
|
+
const { store, socket } = runtime;
|
|
164
191
|
if (socket.closed())
|
|
165
192
|
return Promise.resolve();
|
|
166
|
-
store.readiness.queue();
|
|
193
|
+
store.readiness.queue([]);
|
|
167
194
|
emitKnownRooms(runtime);
|
|
168
|
-
const moved = { moving: socket.session.now().moving, current:
|
|
195
|
+
const moved = { moving: socket.session.now().moving, current: conversationsCurrent(runtime) };
|
|
169
196
|
return store.owing(STATUS_TOPIC, (held) => {
|
|
170
197
|
if (held === undefined)
|
|
171
198
|
return [moved];
|
|
@@ -247,6 +274,8 @@ export function publishChangeSet(runtime, set) {
|
|
|
247
274
|
}
|
|
248
275
|
export async function submissionDue(runtime, locators) {
|
|
249
276
|
const { store } = runtime;
|
|
277
|
+
if (!store.needed())
|
|
278
|
+
return;
|
|
250
279
|
const due = (await store.queued()).filter((locator) => locators === undefined || locators.includes(locator));
|
|
251
280
|
if (due.length === 0)
|
|
252
281
|
return;
|
|
@@ -254,14 +283,18 @@ export async function submissionDue(runtime, locators) {
|
|
|
254
283
|
}
|
|
255
284
|
export function roomUnreadable(runtime, locator) {
|
|
256
285
|
runtime.presence.refused(locator, null);
|
|
257
|
-
emitRooms(runtime);
|
|
286
|
+
emitRooms(runtime, [locator]);
|
|
258
287
|
}
|
|
259
288
|
export async function rest(runtime, progress, live = () => !runtime.socket.closed()) {
|
|
260
289
|
const { store, socket, presence } = runtime;
|
|
261
290
|
const { session, lanes } = socket;
|
|
262
291
|
if (!live())
|
|
263
292
|
return;
|
|
264
|
-
const settled = () => session.now().complete &&
|
|
293
|
+
const settled = () => session.now().complete &&
|
|
294
|
+
lanes.roomWork() === 0 &&
|
|
295
|
+
!socket.naming() &&
|
|
296
|
+
presence.settled() &&
|
|
297
|
+
conversationsCurrent(runtime);
|
|
265
298
|
let synced = settled();
|
|
266
299
|
if (synced && !session.now().recorded) {
|
|
267
300
|
const queued = await queuedWork(runtime).catch(() => true);
|
|
@@ -272,7 +305,10 @@ export async function rest(runtime, progress, live = () => !runtime.socket.close
|
|
|
272
305
|
if (synced && !session.now().recorded) {
|
|
273
306
|
const completedAt = new Date().toISOString();
|
|
274
307
|
try {
|
|
275
|
-
|
|
308
|
+
if (store.needed())
|
|
309
|
+
await (await store.open()).fact('lastCompleted', completedAt);
|
|
310
|
+
else
|
|
311
|
+
session.set({ lastCompleted: completedAt });
|
|
276
312
|
if (!live())
|
|
277
313
|
return;
|
|
278
314
|
session.set({ recorded: true });
|
package/dist/socket/lanes.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import type { CallResult } from '../outcome.js';
|
|
1
2
|
export type Live = () => boolean;
|
|
3
|
+
export type KeptSender = {
|
|
4
|
+
next(): Promise<CallResult>;
|
|
5
|
+
};
|
|
2
6
|
type LaneRules = {
|
|
3
7
|
generation(): number;
|
|
4
8
|
continuing(): boolean;
|
|
5
9
|
stopping(): boolean;
|
|
10
|
+
failed(locator: string, error: unknown): void;
|
|
6
11
|
};
|
|
7
12
|
export type Lanes = {
|
|
8
13
|
task(lane: string, work: (live: Live) => Promise<void>): Promise<void>;
|
|
@@ -11,10 +16,13 @@ export type Lanes = {
|
|
|
11
16
|
roomWork(): number;
|
|
12
17
|
current(): Promise<unknown>;
|
|
13
18
|
finished(): Promise<unknown>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
sender(operation: string): KeptSender | undefined;
|
|
20
|
+
sending(operation: string, sender: KeptSender): void;
|
|
21
|
+
sent(operation: string, sender: KeptSender): void;
|
|
22
|
+
settled(operation: string): Promise<void>;
|
|
23
|
+
settle(operation: string, lost: boolean): void;
|
|
24
|
+
unclaimed(operation: string): boolean;
|
|
17
25
|
};
|
|
18
|
-
export declare function createLanes({ generation, continuing, stopping }: LaneRules): Lanes;
|
|
26
|
+
export declare function createLanes({ generation, continuing, stopping, failed }: LaneRules): Lanes;
|
|
19
27
|
export {};
|
|
20
28
|
//# sourceMappingURL=lanes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lanes.d.ts","sourceRoot":"","sources":["../../src/socket/lanes.ts"],"names":[],"mappings":"AAAA,MAA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M,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACrD,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAClD,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/C,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CACvC,CAAC;AAIF,wBAAgB,WAAW,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,GAAG,KAAK,CAqG1F"}
|
package/dist/socket/lanes.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
const ROOM_READS = 256;
|
|
2
|
-
export function createLanes({ generation, continuing, stopping }) {
|
|
2
|
+
export function createLanes({ generation, continuing, stopping, failed }) {
|
|
3
3
|
const lanes = new Map();
|
|
4
4
|
const roomLanes = new Map();
|
|
5
5
|
const roomReads = { free: ROOM_READS, waiting: [] };
|
|
6
6
|
const working = new Set();
|
|
7
|
-
const
|
|
7
|
+
const senders = new Map();
|
|
8
|
+
const settlements = new Map();
|
|
9
|
+
const unclaimed = new Set();
|
|
8
10
|
let roomWork = 0;
|
|
9
11
|
async function admittedRead(work) {
|
|
10
12
|
while (roomReads.free === 0) {
|
|
@@ -59,19 +61,43 @@ export function createLanes({ generation, continuing, stopping }) {
|
|
|
59
61
|
roomTask(locator, work) {
|
|
60
62
|
if (stopping())
|
|
61
63
|
return Promise.resolve();
|
|
62
|
-
return inRoom(locator, (live) => admittedRead(() => work(live))).catch(() =>
|
|
64
|
+
return inRoom(locator, (live) => admittedRead(() => work(live))).catch((error) => {
|
|
65
|
+
if (!stopping())
|
|
66
|
+
failed(locator, error);
|
|
67
|
+
});
|
|
63
68
|
},
|
|
64
69
|
roomWork: () => roomWork,
|
|
65
70
|
current: () => Promise.all([...lanes.values()]
|
|
66
71
|
.filter((held) => held.generation === generation())
|
|
67
72
|
.map((held) => held.chain)),
|
|
68
73
|
finished: () => Promise.all(working),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
sender: (operation) => senders.get(operation),
|
|
75
|
+
sending(operation, sender) {
|
|
76
|
+
senders.set(operation, sender);
|
|
72
77
|
},
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
sent(operation, sender) {
|
|
79
|
+
if (senders.get(operation) === sender)
|
|
80
|
+
senders.delete(operation);
|
|
75
81
|
},
|
|
82
|
+
settled(operation) {
|
|
83
|
+
if (unclaimed.delete(operation))
|
|
84
|
+
return Promise.resolve();
|
|
85
|
+
return new Promise((settle) => {
|
|
86
|
+
const earlier = settlements.get(operation);
|
|
87
|
+
settlements.set(operation, () => {
|
|
88
|
+
earlier?.();
|
|
89
|
+
settle();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
settle(operation, lost) {
|
|
94
|
+
const settle = settlements.get(operation);
|
|
95
|
+
settlements.delete(operation);
|
|
96
|
+
if (settle !== undefined)
|
|
97
|
+
settle();
|
|
98
|
+
else if (lost)
|
|
99
|
+
unclaimed.add(operation);
|
|
100
|
+
},
|
|
101
|
+
unclaimed: (operation) => unclaimed.has(operation),
|
|
76
102
|
};
|
|
77
103
|
}
|
package/dist/socket/session.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Authorization, ProviderRefusal, ServiceMode } from '../adapter.js';
|
|
1
|
+
import type { Authorization, Discovery, ProviderRefusal, QueriedRoom, ServiceMode } from '../adapter.js';
|
|
2
2
|
import { type Cell } from '../cell.js';
|
|
3
3
|
import type { Open } from '../open.js';
|
|
4
4
|
import type { CycleProgress, SyncStatus } from '../status.js';
|
|
@@ -23,6 +23,9 @@ export type Session = {
|
|
|
23
23
|
readonly discoveries: number;
|
|
24
24
|
readonly roomsNamed: boolean;
|
|
25
25
|
readonly roomsListed: boolean;
|
|
26
|
+
readonly queriesOnly: readonly QueriedRoom[];
|
|
27
|
+
readonly unstored: Discovery | null;
|
|
28
|
+
readonly lastCompleted: string | null;
|
|
26
29
|
readonly serviceMode: ServiceMode;
|
|
27
30
|
readonly haltedRefusal: boolean;
|
|
28
31
|
readonly openSignals: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/socket/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/socket/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,EACX,WAAW,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,MAAM,aAAa,GAAG,4BAA4B,GAAG,uBAAuB,CAAC;AAEnF,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;AAExD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,sBAAsB,EAAE,OAAO,CAAC;IAChC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,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from './adapter.js';
|
|
2
2
|
import type { Reads } from './bootstrap.js';
|
|
3
3
|
import type { Cell } from './cell.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Retries } from './retried.js';
|
|
5
5
|
import { type Admission } from './socket/admission.js';
|
|
6
6
|
import { type Answers } from './socket/answers.js';
|
|
7
7
|
import { type Lanes } from './socket/lanes.js';
|
|
8
8
|
import { type Session } from './socket/session.js';
|
|
9
|
-
export type { Live } from './socket/lanes.js';
|
|
9
|
+
export type { KeptSender, Live } from './socket/lanes.js';
|
|
10
10
|
export type { ConnectionRefusal, ConnectionRefusalCode, Moving, RefusalReason, } from './socket/session.js';
|
|
11
11
|
type SocketEvent = {
|
|
12
12
|
readonly kind: 'opened';
|
|
@@ -31,6 +31,7 @@ export type RuntimeSocket = Admission & Answers & {
|
|
|
31
31
|
readonly firstDiscovery: Promise<void>;
|
|
32
32
|
conversations(): Adapter['conversations'];
|
|
33
33
|
search(): Adapter['search'];
|
|
34
|
+
queryHouse(): Adapter['queryHouse'];
|
|
34
35
|
discover(authorized: Authorization): ReturnType<NonNullable<Adapter['discover']>> | undefined;
|
|
35
36
|
follows: Adapter['follows'];
|
|
36
37
|
mutate: Adapter['mutate'];
|
|
@@ -63,5 +64,5 @@ export type RuntimeSocket = Admission & Answers & {
|
|
|
63
64
|
abortReads(): void;
|
|
64
65
|
stopReads(): void;
|
|
65
66
|
};
|
|
66
|
-
export declare function createSocket(adapter: Adapter,
|
|
67
|
+
export declare function createSocket(adapter: Adapter, retries: Retries, authorization: Authorization | undefined): RuntimeSocket;
|
|
67
68
|
//# sourceMappingURL=socket.d.ts.map
|
package/dist/socket.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../src/socket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,QAAQ,EACR,eAAe,EACf,WAAW,EACZ,MAA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AC,MAAM,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,IAAI,CAAC;IACpD,oBAAoB,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,IAAI,CAAC;IACvE,kBAAkB,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,GAAG,IAAI,CAAC;IAC9D,KAAK,IAAI,IAAI,CAAC;IACd,cAAc,IAAI,IAAI,CAAC;IACvB,WAAW,IAAI,IAAI,CAAC;IACpB,MAAM,IAAI,OAAO,CAAC;IAClB,QAAQ,IAAI,OAAO,CAAC;IACpB,UAAU,IAAI,OAAO,CAAC;IACtB,OAAO,IAAI,OAAO,CAAC;IACnB,UAAU,IAAI,OAAO,CAAC;IACtB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IACpC,MAAM,IAAI,OAAO,CAAC;IAClB,WAAW,IAAI,OAAO,CAAC;IACvB,QAAQ,IAAI,OAAO,CAAC;IACpB,UAAU,IAAI,MAAM,CAAC;IACrB,MAAM,IAAI,OAAO,CAAC;IAClB,IAAI,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,IAAI,CAAC;IACvC,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,KAAK,IAAI,IAAI,CAAC;IACd,UAAU,IAAI,IAAI,CAAC;IACnB,SAAS,IAAI,IAAI,CAAC;CACnB,CAAC;AAEJ,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,aAAa,CAyJf"}
|
package/dist/socket.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createAnswers } from './socket/answers.js';
|
|
|
3
3
|
import { createLanes } from './socket/lanes.js';
|
|
4
4
|
import { createReads } from './socket/reads.js';
|
|
5
5
|
import { createSession } from './socket/session.js';
|
|
6
|
-
export function createSocket(adapter,
|
|
6
|
+
export function createSocket(adapter, retries, authorization) {
|
|
7
7
|
const held = createReads(adapter);
|
|
8
8
|
const admission = createAdmission();
|
|
9
9
|
const answers = createAnswers();
|
|
@@ -71,11 +71,13 @@ export function createSocket(adapter, journal, authorization) {
|
|
|
71
71
|
generation: () => generation,
|
|
72
72
|
continuing,
|
|
73
73
|
stopping: () => session.now().stopping,
|
|
74
|
+
failed: (locator, error) => retries.failed('download', locator, error),
|
|
74
75
|
}),
|
|
75
76
|
ready,
|
|
76
77
|
firstDiscovery,
|
|
77
78
|
conversations: () => adapter.conversations,
|
|
78
79
|
search: () => adapter.search,
|
|
80
|
+
queryHouse: () => adapter.queryHouse,
|
|
79
81
|
discover: (authorized) => adapter.discover?.(authorized),
|
|
80
82
|
follows: (locator, roomVersion, next) => adapter.follows(locator, roomVersion, next),
|
|
81
83
|
mutate: (authorized, request, keepUpload) => adapter.mutate(authorized, request, keepUpload),
|
|
@@ -87,14 +89,7 @@ export function createSocket(adapter, journal, authorization) {
|
|
|
87
89
|
async authorize() {
|
|
88
90
|
if (session.now().authorization !== undefined)
|
|
89
91
|
return;
|
|
90
|
-
|
|
91
|
-
session.set({ authorization: await adapter.authorize() });
|
|
92
|
-
journal.record('connection authorize');
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
journal.record('connection authorize transport-uncertainty');
|
|
96
|
-
throw error;
|
|
97
|
-
}
|
|
92
|
+
session.set({ authorization: await adapter.authorize() });
|
|
98
93
|
},
|
|
99
94
|
observe(listen) {
|
|
100
95
|
const stream = adapter.roomStream;
|
package/dist/source.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type RequestAnswer = 'at_once' | 'ask_me' | 'off';
|
|
1
2
|
export type HouseSource = {
|
|
2
3
|
readonly kind: 'request';
|
|
3
4
|
readonly request: string;
|
|
@@ -8,8 +9,12 @@ export type HouseSource = {
|
|
|
8
9
|
};
|
|
9
10
|
readonly room: {
|
|
10
11
|
readonly ref: string;
|
|
12
|
+
readonly handle: string;
|
|
11
13
|
readonly name: string;
|
|
12
14
|
};
|
|
15
|
+
readonly sent: string;
|
|
16
|
+
readonly instruction: string | null;
|
|
17
|
+
readonly answer: RequestAnswer | null;
|
|
13
18
|
readonly approved: string | null;
|
|
14
19
|
} | {
|
|
15
20
|
readonly kind: 'mail';
|
|
@@ -45,13 +50,6 @@ export type ChatRequest = {
|
|
|
45
50
|
readonly room: string;
|
|
46
51
|
readonly message?: string;
|
|
47
52
|
};
|
|
48
|
-
export type ChatRoomRequest = {
|
|
49
|
-
readonly request: string;
|
|
50
|
-
readonly room: {
|
|
51
|
-
readonly ref: string;
|
|
52
|
-
readonly name: string;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
53
|
type RequestAgentFunction = {
|
|
56
54
|
readonly name: string;
|
|
57
55
|
readonly version: number;
|
package/dist/source.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GACnB;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,aAAa,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACpD,QAAQ,CAAC,SAAS,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IACtE,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;AAIzD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EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAChE,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAElF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AA+ChF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CA6ClF"}
|
package/dist/source.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { record, text } from './read.js';
|
|
2
|
+
const ANSWERS = ['at_once', 'ask_me', 'off'];
|
|
2
3
|
function agentFunctionOf(value) {
|
|
3
4
|
if (value === null)
|
|
4
5
|
return null;
|
|
@@ -7,6 +8,9 @@ function agentFunctionOf(value) {
|
|
|
7
8
|
const version = agentFunction.version;
|
|
8
9
|
return name === null || typeof version !== 'number' ? undefined : { name, version };
|
|
9
10
|
}
|
|
11
|
+
function answerOf(value) {
|
|
12
|
+
return ANSWERS.find((one) => one === value) ?? null;
|
|
13
|
+
}
|
|
10
14
|
function requestOf(source) {
|
|
11
15
|
const request = text(source, 'request');
|
|
12
16
|
const agentFunction = agentFunctionOf(source.agent_function);
|
|
@@ -14,19 +18,26 @@ function requestOf(source) {
|
|
|
14
18
|
const by = text(requester, 'name');
|
|
15
19
|
const room = record(source.room);
|
|
16
20
|
const ref = text(room, 'ref');
|
|
21
|
+
const handle = text(room, 'handle');
|
|
17
22
|
const called = text(room, 'name');
|
|
23
|
+
const sent = typeof source.sent === 'string' ? source.sent : null;
|
|
18
24
|
if (request === null ||
|
|
19
25
|
agentFunction === undefined ||
|
|
20
26
|
by === null ||
|
|
21
27
|
ref === null ||
|
|
22
|
-
|
|
28
|
+
handle === null ||
|
|
29
|
+
called === null ||
|
|
30
|
+
sent === null)
|
|
23
31
|
return null;
|
|
24
32
|
return {
|
|
25
33
|
kind: 'request',
|
|
26
34
|
request,
|
|
27
35
|
agentFunction,
|
|
28
36
|
requester: { name: by, room: text(requester, 'room') !== null },
|
|
29
|
-
room: { ref, name: called },
|
|
37
|
+
room: { ref, handle, name: called },
|
|
38
|
+
sent,
|
|
39
|
+
instruction: text(source, 'instruction'),
|
|
40
|
+
answer: answerOf(source.answer),
|
|
30
41
|
approved: text(source, 'approved_at'),
|
|
31
42
|
};
|
|
32
43
|
}
|
package/dist/store/installs.d.ts
CHANGED
|
@@ -21,9 +21,9 @@ export declare const NO_INSTALL: RoomInstall;
|
|
|
21
21
|
export type Installs = {
|
|
22
22
|
of(locator: string): RoomInstall;
|
|
23
23
|
change(locator: string, next: (held: RoomInstall) => RoomInstall): void;
|
|
24
|
-
underway(): ReadonlySet<string>;
|
|
24
|
+
underway(among: readonly string[] | null): ReadonlySet<string>;
|
|
25
25
|
transferring(): readonly string[];
|
|
26
|
-
|
|
26
|
+
arrivalsDue(locator: string, now: number, everyMs: number): readonly string[];
|
|
27
27
|
};
|
|
28
28
|
export declare function createInstal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MAAM,CAAC,CAAC;IAC/D,YAAY,IAAI,SAAS,MAAM,EAAE,CAAC;IAClC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;CAC/E,CAAC;AAEF,wBAAgB,cAAc,IAAI,QAAQ,CA8BzC"}
|
package/dist/store/installs.js
CHANGED
|
@@ -14,6 +14,7 @@ export const NO_INSTALL = {
|
|
|
14
14
|
export function createInstalls() {
|
|
15
15
|
const rooms = new Map();
|
|
16
16
|
let arrivalReported = 0;
|
|
17
|
+
const arrived = new Set();
|
|
17
18
|
function matching(held) {
|
|
18
19
|
return [...rooms].filter(([, room]) => held(room)).map(([locator]) => locator);
|
|
19
20
|
}
|
|
@@ -22,13 +23,18 @@ export function createInstalls() {
|
|
|
22
23
|
change(locator, next) {
|
|
23
24
|
rooms.set(locator, next(rooms.get(locator) ?? NO_INSTALL));
|
|
24
25
|
},
|
|
25
|
-
underway: () => new Set(
|
|
26
|
+
underway: (among) => new Set(among === null
|
|
27
|
+
? matching(({ installing }) => installing)
|
|
28
|
+
: among.filter((locator) => rooms.get(locator)?.installing === true)),
|
|
26
29
|
transferring: () => matching(({ transfer }) => transfer !== null),
|
|
27
|
-
|
|
30
|
+
arrivalsDue(locator, now, everyMs) {
|
|
31
|
+
arrived.add(locator);
|
|
28
32
|
if (now - arrivalReported < everyMs)
|
|
29
|
-
return
|
|
33
|
+
return [];
|
|
30
34
|
arrivalReported = now;
|
|
31
|
-
|
|
35
|
+
const due = [...arrived];
|
|
36
|
+
arrived.clear();
|
|
37
|
+
return due;
|
|
32
38
|
},
|
|
33
39
|
};
|
|
34
40
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export type ReadinessQueue<W> = {
|
|
1
|
+
export type ReadinessQueue<W, S> = {
|
|
2
2
|
add(watch: W): () => void;
|
|
3
3
|
held(watch: W): boolean;
|
|
4
|
-
|
|
4
|
+
kept(watch: W): S | undefined;
|
|
5
|
+
keep(watch: W, shown: S): void;
|
|
5
6
|
owe(watches: readonly W[]): void;
|
|
6
|
-
queue(): void;
|
|
7
|
+
queue(rooms?: readonly string[]): void;
|
|
7
8
|
close(): void;
|
|
8
9
|
};
|
|
9
|
-
export declare function createReadinessQueue<W>(deliver: (owed: readonly W[]) => Promise<void>, unpublished: (error: unknown) => void): ReadinessQueue<W>;
|
|
10
|
+
export declare function createReadinessQueue<W, S>(deliver: (owed: readonly W[], rooms: ReadonlySet<string> | null) => Promise<void>, unpublished: (error: unknown) => void): ReadinessQueue<W, S>;
|
|
10
11
|
//# sourceMappingURL=readiness.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../../src/store/readiness.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;
|
|
1
|
+
{"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../../src/store/readiness.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,IAAI;IACjC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,IAAI,CAAC;IAC1B,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;IACxB,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC9B,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAC/B,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC;IACjC,KAAK,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IACvC,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAWF,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,CAAC,EACvC,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,EACjF,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACpC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAwDtB"}
|