@agentshouse/mdruntime 0.1.0-cb4f25b82f4b6 → 0.1.0-cb7492ce29103
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 +6 -5
- package/dist/acceptance.js +1 -1
- package/dist/adapter.d.ts +55 -9
- 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/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 +5 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -6
- package/dist/collection.d.ts +4 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +7 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +2 -3
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +6 -4
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +13 -6
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +11 -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 +8 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +145 -118
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +4 -2
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +2 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +13 -8
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/install.d.ts +8 -2
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +40 -33
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +14 -9
- package/dist/listing.d.ts +7 -3
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +26 -13
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +71 -30
- package/dist/loaded.d.ts +5 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +40 -0
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +2 -2
- package/dist/lost.js +1 -1
- package/dist/media.d.ts +5 -0
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +65 -14
- package/dist/memory.d.ts +3 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +17 -8
- package/dist/messages.d.ts +3 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +4 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +3 -3
- package/dist/observation.d.ts +24 -10
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +167 -69
- package/dist/outcome.d.ts +4 -0
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +8 -2
- package/dist/overlay.d.ts +1 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +3 -5
- package/dist/preparation.d.ts +27 -6
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +131 -44
- package/dist/presence.d.ts +8 -2
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +24 -13
- package/dist/queries.d.ts +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +43 -17
- package/dist/questions.d.ts +1 -0
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +1 -0
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +51 -21
- package/dist/reach.d.ts +2 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +20 -7
- package/dist/react.d.ts +3 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +8 -2
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +3 -5
- package/dist/reads.d.ts +1 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +2 -2
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +2 -2
- package/dist/room-draft.d.ts +28 -3
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +230 -12
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +5 -2
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +2 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +6 -6
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +17 -86
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +23 -7
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -2
- package/dist/shown.d.ts +1 -1
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +41 -34
- package/dist/source.d.ts +5 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +13 -2
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +5 -1
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +46 -19
- 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 +12 -8
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +8 -4
- package/dist/stored.d.ts +23 -13
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +72 -18
- package/dist/surface.d.ts +4 -2
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +7 -2
- package/dist/sync.d.ts +1 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +6 -5
- package/dist/tables.d.ts +8 -4
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +2 -5
- 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 +2 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { heldFacts } from './conversation-row.js';
|
|
2
2
|
export { PAGE_METADATA_WORDS } from './page-metadata.js';
|
|
3
3
|
export { writeRule } from './declaration.js';
|
|
4
|
+
export { blobOf, declaredType } from './outcome.js';
|
|
4
5
|
export { refusalError } from './failure.js';
|
|
5
|
-
export {
|
|
6
|
+
export { keptFile, keptLines } from './chat-types.js';
|
|
6
7
|
export { FIGURES_DAY_MS } from './figures.js';
|
|
7
8
|
export { departure } from './change.js';
|
|
8
9
|
export { definitionsIn, selected } from './collection.js';
|
package/dist/install.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AdapterFailure, Authorization, DiscoveredRoom, NotReady, RetryableRefusal } from './adapter.js';
|
|
2
2
|
import { type Reads } from './bootstrap.js';
|
|
3
|
-
import type { Installation, RoomCoverage } from './readiness.js';
|
|
3
|
+
import type { Installation, InstallationAmount, RoomCoverage } from './readiness.js';
|
|
4
4
|
import { advancement, type Refresher } from './refresh.js';
|
|
5
5
|
import type { ReplicaRecord } from './replica.js';
|
|
6
6
|
import type { Runtime } from './runtime.js';
|
|
@@ -33,7 +33,13 @@ type Refreshed = {
|
|
|
33
33
|
kind: 'advanced';
|
|
34
34
|
}>;
|
|
35
35
|
export declare const ERASE_BATCH = 512;
|
|
36
|
-
export
|
|
36
|
+
export type InstallShare = {
|
|
37
|
+
readonly installing: boolean;
|
|
38
|
+
readonly downloading: boolean;
|
|
39
|
+
readonly bytes: InstallationAmount;
|
|
40
|
+
};
|
|
41
|
+
export declare function installShare(store: Store, { room, state }: RoomCoverage, held: ReadonlyMap<string, CoveredRoom>): InstallShare;
|
|
42
|
+
export declare function installationOf(installing: number, downloading: number, bytes: InstallationAmount): Installation;
|
|
37
43
|
export declare function roomInFlight(store: Store, locator: string): boolean;
|
|
38
44
|
export declare function sweep({ store, socket }: Runtime): void;
|
|
39
45
|
export declare function caughtUpTo(runtime: Runtime, locator: string): void;
|
package/dist/install.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,QAAQ,EACR,gBAAgB,EAEjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAkC,KAAK,KAAK,EAAgB,MAAM,gBAAgB,CAAC;AAO1F,OAAO,KAAK,EACV,YAAY,
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,QAAQ,EACR,gBAAgB,EAEjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAkC,KAAK,KAAK,EAAgB,MAAM,gBAAgB,CAAC;AAO1F,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAElB,YAAY,EACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAmB,MAAM,cAAc,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,KAAK,YAAY,EACjB,KAAK,KAAK,EAGX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAe,KAAK,WAAW,EAAE,MA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EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAG/F;AAED,wBAAsB,YAAY,CAChC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAC1B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CAUlB;AAiFD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,aAAa,EACzB,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,IAAI,EACd,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,SAAS,GACjB,OAAO,CAAC,SAAS,CAAC,CA0CpB;AA8ID,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,aAAa,EACzB,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,IAAI,EACd,KAAK,EAAE,aAAa,GAAG,SAAS,EAChC,IAAI,GAAE,KAA4B,EAClC,MAAM,CAAC,EAAE,MAAM;mBA6BI,uBAAuB;6DAa3C;AAED,wBAAgB,OAAO,CACrB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,OAAO,CAAC,CAmElB"}
|
package/dist/install.js
CHANGED
|
@@ -79,28 +79,32 @@ function batchEnd(entries, from, bytes) {
|
|
|
79
79
|
}
|
|
80
80
|
return end;
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
bytes
|
|
99
|
-
|
|
100
|
-
|
|
82
|
+
const UNSHARED = {
|
|
83
|
+
installing: false,
|
|
84
|
+
downloading: false,
|
|
85
|
+
bytes: { done: 0, total: 0 },
|
|
86
|
+
};
|
|
87
|
+
export function installShare(store, { room, state }, held) {
|
|
88
|
+
if (state === 'unadmitted')
|
|
89
|
+
return UNSHARED;
|
|
90
|
+
const install = store.installs.of(room);
|
|
91
|
+
const underway = state === 'acquiring' || (install.installing && state !== 'complete');
|
|
92
|
+
const kept = underway ? NOTHING_HELD.bytes : (held.get(room)?.bytes ?? NOTHING_HELD.bytes);
|
|
93
|
+
const now = amountOf(install, kept);
|
|
94
|
+
const earlier = underway ? install.startedOver : null;
|
|
95
|
+
return {
|
|
96
|
+
installing: underway,
|
|
97
|
+
downloading: underway && (install.streaming || install.arrived === null),
|
|
98
|
+
bytes: {
|
|
99
|
+
done: Math.max(now.done, earlier?.done ?? 0),
|
|
100
|
+
total: Math.max(now.total, earlier?.total ?? 0),
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export function installationOf(installing, downloading, bytes) {
|
|
101
105
|
const step = installing === 0
|
|
102
106
|
? null
|
|
103
|
-
: downloading
|
|
107
|
+
: downloading > 0
|
|
104
108
|
? 'downloading'
|
|
105
109
|
: bytes.done < bytes.total
|
|
106
110
|
? 'writing'
|
|
@@ -113,13 +117,13 @@ export function roomInFlight(store, locator) {
|
|
|
113
117
|
}
|
|
114
118
|
function installing(runtime, locator) {
|
|
115
119
|
runtime.store.installs.change(locator, (held) => ({ ...held, installing: true }));
|
|
116
|
-
runtime.store.readiness.queue();
|
|
120
|
+
runtime.store.readiness.queue([locator]);
|
|
117
121
|
}
|
|
118
122
|
function installed(runtime, locator) {
|
|
119
123
|
if (!runtime.store.installs.of(locator).installing)
|
|
120
124
|
return;
|
|
121
125
|
runtime.store.installs.change(locator, (held) => ({ ...held, installing: false }));
|
|
122
|
-
runtime.store.readiness.queue();
|
|
126
|
+
runtime.store.readiness.queue([locator]);
|
|
123
127
|
}
|
|
124
128
|
export function sweep({ store, socket }) {
|
|
125
129
|
if (store.device.now().sweeping || socket.closed())
|
|
@@ -143,7 +147,7 @@ export function caughtUpTo(runtime, locator) {
|
|
|
143
147
|
if (!runtime.store.installs.of(locator).catching)
|
|
144
148
|
return;
|
|
145
149
|
runtime.store.installs.change(locator, (held) => ({ ...held, catching: false }));
|
|
146
|
-
recoverReads(runtime);
|
|
150
|
+
recoverReads(runtime, [locator]);
|
|
147
151
|
}
|
|
148
152
|
export function catching(store, locator) {
|
|
149
153
|
store.installs.change(locator, (held) => ({ ...held, catching: true }));
|
|
@@ -294,7 +298,8 @@ export async function pullRefresh(runtime, authorized, record, liveness, hold, r
|
|
|
294
298
|
async function abandoned(runtime, local, locator) {
|
|
295
299
|
await local.abandon(locator);
|
|
296
300
|
runtime.store.installs.change(locator, (held) => transferGone(setBack(held)));
|
|
297
|
-
recoverReads(runtime);
|
|
301
|
+
recoverReads(runtime, [locator]);
|
|
302
|
+
runtime.store.readiness.queue([locator]);
|
|
298
303
|
sweep(runtime);
|
|
299
304
|
}
|
|
300
305
|
function staging(runtime, local, liveness, unheld) {
|
|
@@ -308,7 +313,7 @@ function staging(runtime, local, liveness, unheld) {
|
|
|
308
313
|
if (done === null)
|
|
309
314
|
return false;
|
|
310
315
|
store.installs.change(locator, (held) => built(held, done.done, done.text));
|
|
311
|
-
runtime.store.readiness.queue();
|
|
316
|
+
runtime.store.readiness.queue([locator]);
|
|
312
317
|
if (done.done)
|
|
313
318
|
return true;
|
|
314
319
|
}
|
|
@@ -332,9 +337,9 @@ function staging(runtime, local, liveness, unheld) {
|
|
|
332
337
|
arrived: bytes,
|
|
333
338
|
streaming: true,
|
|
334
339
|
}));
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
340
|
+
const due = store.installs.arrivalsDue(locator, performance.now(), ARRIVAL_REPORT_MS);
|
|
341
|
+
if (due.length > 0)
|
|
342
|
+
runtime.store.readiness.queue(due);
|
|
338
343
|
},
|
|
339
344
|
end() {
|
|
340
345
|
if (ended)
|
|
@@ -343,7 +348,7 @@ function staging(runtime, local, liveness, unheld) {
|
|
|
343
348
|
if (!store.installs.of(locator).streaming)
|
|
344
349
|
return;
|
|
345
350
|
store.installs.change(locator, (held) => ({ ...held, streaming: false }));
|
|
346
|
-
runtime.store.readiness.queue();
|
|
351
|
+
runtime.store.readiness.queue([locator]);
|
|
347
352
|
},
|
|
348
353
|
};
|
|
349
354
|
},
|
|
@@ -371,7 +376,7 @@ function staging(runtime, local, liveness, unheld) {
|
|
|
371
376
|
underived: owed,
|
|
372
377
|
}));
|
|
373
378
|
installing(runtime, locator);
|
|
374
|
-
recoverReads(runtime);
|
|
379
|
+
recoverReads(runtime, [locator]);
|
|
375
380
|
if (owed < store.deriveBytes())
|
|
376
381
|
return held;
|
|
377
382
|
return (await derived(locator, key, composition)) ? held : null;
|
|
@@ -406,7 +411,8 @@ function staging(runtime, local, liveness, unheld) {
|
|
|
406
411
|
done: { bytes },
|
|
407
412
|
};
|
|
408
413
|
store.installs.change(locator, (room) => ({ ...room, transfer: held }));
|
|
409
|
-
recoverReads(runtime);
|
|
414
|
+
recoverReads(runtime, [locator]);
|
|
415
|
+
store.readiness.queue([locator]);
|
|
410
416
|
return { record: held, staged: parted };
|
|
411
417
|
},
|
|
412
418
|
derive: derived,
|
|
@@ -422,7 +428,8 @@ function staging(runtime, local, liveness, unheld) {
|
|
|
422
428
|
if (!liveness())
|
|
423
429
|
return;
|
|
424
430
|
store.installs.change(locator, (held) => transferGone(setBack(held)));
|
|
425
|
-
recoverReads(runtime);
|
|
431
|
+
recoverReads(runtime, [locator]);
|
|
432
|
+
store.readiness.queue([locator]);
|
|
426
433
|
},
|
|
427
434
|
release: (key) => store.exclusive(async () => {
|
|
428
435
|
await local.release(key);
|
|
@@ -436,7 +443,7 @@ export async function pullBootstrap(runtime, authorized, room, local, liveness,
|
|
|
436
443
|
const { store } = runtime;
|
|
437
444
|
if (prior !== undefined) {
|
|
438
445
|
catching(store, room.locator);
|
|
439
|
-
recoverReads(runtime);
|
|
446
|
+
recoverReads(runtime, [room.locator]);
|
|
440
447
|
}
|
|
441
448
|
try {
|
|
442
449
|
const result = await bootstrapRoom(from, authorized, room, {
|
package/dist/lifecycle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAoO5C,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,QAOhD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,QAQ1C;AAED,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,MAAM,EACN,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,WAAW,EACX,OAAO,GACR,EAAE,OAAO,QAST;AAED,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,iBAS1C;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,QA2CtE"}
|
package/dist/lifecycle.js
CHANGED
|
@@ -6,6 +6,7 @@ import { connectionLost } from './locks.js';
|
|
|
6
6
|
import { fenceLive } from './lost.js';
|
|
7
7
|
import { cachedModels, revoked, settleModels } from './models.js';
|
|
8
8
|
import { refuse } from './refusal.js';
|
|
9
|
+
import { roomsListed } from './room-list.js';
|
|
9
10
|
import { moveTo, recoverReads, rest, SERVICE_MODE_TOPIC, show, submissionDue, transferring, } from './shown.js';
|
|
10
11
|
import { applyRoom, changeAuthority, countAuthorityChange, finishOpening, loadRoom, OPENING_LANE, reload, resynchronize, sync, } from './sync.js';
|
|
11
12
|
const CONVERSATION_LANE = 'conversations';
|
|
@@ -52,13 +53,13 @@ function owedReloads(runtime, expired, held) {
|
|
|
52
53
|
.map((room) => room.locator);
|
|
53
54
|
for (const locator of reloading)
|
|
54
55
|
catching(store, locator);
|
|
55
|
-
recoverReads(runtime);
|
|
56
|
+
recoverReads(runtime, reloading);
|
|
56
57
|
return reloading;
|
|
57
58
|
}
|
|
58
|
-
async function reloadNow(runtime, replacing, progress, held, installing) {
|
|
59
|
+
async function reloadNow(runtime, among, replacing, progress, held, installing) {
|
|
59
60
|
const { store, socket, presence } = runtime;
|
|
60
61
|
const { lanes } = socket;
|
|
61
|
-
const discovered = presence.rooms();
|
|
62
|
+
const discovered = among === null ? presence.rooms() : among.flatMap((locator) => presence.room(locator) ?? []);
|
|
62
63
|
const reloaded = discovered.filter((room) => held.has(room.locator) && !installing.has(room.locator) && replacing(room));
|
|
63
64
|
const acquired = discovered.filter((room) => (!held.has(room.locator) || installing.has(room.locator)) &&
|
|
64
65
|
room.replica.admission === 'admitted' &&
|
|
@@ -96,12 +97,13 @@ function caughtUpRooms(runtime, expired) {
|
|
|
96
97
|
socket.named();
|
|
97
98
|
const cycle = progress ?? { complete: true, reachable: true };
|
|
98
99
|
replaced(store, expired);
|
|
99
|
-
const
|
|
100
|
-
const
|
|
100
|
+
const among = progress === null ? expired : null;
|
|
101
|
+
const installing = store.installs.underway(among);
|
|
102
|
+
const held = among === null ? store.rooms() : store.rooms(among);
|
|
101
103
|
const reloading = progress === null
|
|
102
104
|
? Promise.resolve([])
|
|
103
105
|
: held.then((stored) => owedReloads(runtime, expired, stored));
|
|
104
|
-
const replacing = Promise.all([held, reloading]).then(([stored, owed]) => reloadNow(runtime, (room) => expired.includes(room.locator) || owed.includes(room.locator), cycle, stored, installing));
|
|
106
|
+
const replacing = Promise.all([held, reloading]).then(([stored, owed]) => reloadNow(runtime, among, (room) => expired.includes(room.locator) || owed.includes(room.locator), cycle, stored, installing));
|
|
105
107
|
return socket.lanes.task(OPENING_LANE, async (live) => {
|
|
106
108
|
if (!live())
|
|
107
109
|
return;
|
|
@@ -147,7 +149,7 @@ function signalled(runtime, mode) {
|
|
|
147
149
|
session.set({ haltedRefusal: false });
|
|
148
150
|
if (mode !== serviceMode) {
|
|
149
151
|
session.set({ serviceMode: mode });
|
|
150
|
-
store.readiness.queue();
|
|
152
|
+
store.readiness.queue([]);
|
|
151
153
|
store.tell(SERVICE_MODE_TOPIC, mode);
|
|
152
154
|
}
|
|
153
155
|
if (releasing)
|
|
@@ -227,7 +229,7 @@ export function start(runtime, signal) {
|
|
|
227
229
|
socket.observeServiceMode((mode) => signalled(runtime, mode));
|
|
228
230
|
socket.observeConversations((event) => {
|
|
229
231
|
if (event.kind === 'list' || event.kind === 'listed' || event.kind === 'unlisted')
|
|
230
|
-
store.readiness.queue();
|
|
232
|
+
store.readiness.queue([]);
|
|
231
233
|
receiveConversationEvent(conversations, event);
|
|
232
234
|
if (event.kind !== 'gap' || conversations.current())
|
|
233
235
|
return;
|
|
@@ -245,8 +247,9 @@ export function start(runtime, signal) {
|
|
|
245
247
|
recovery.resume();
|
|
246
248
|
}
|
|
247
249
|
else if (event.kind === 'discovered') {
|
|
250
|
+
const listed = roomsListed(runtime, event.discovery.roomList);
|
|
248
251
|
if (event.missed)
|
|
249
|
-
countAuthorityChange(runtime);
|
|
252
|
+
countAuthorityChange(runtime, listed);
|
|
250
253
|
void sync(runtime, 'opened', event.discovery);
|
|
251
254
|
}
|
|
252
255
|
else if (event.kind === 'closed') {
|
|
@@ -254,6 +257,8 @@ export function start(runtime, signal) {
|
|
|
254
257
|
}
|
|
255
258
|
else if (event.kind === 'caught-up')
|
|
256
259
|
void caughtUpRooms(runtime, event.expired);
|
|
260
|
+
else if (event.kind === 'reported')
|
|
261
|
+
lastAnswers.again();
|
|
257
262
|
else if (event.kind === 'authority-changed') {
|
|
258
263
|
if (socket.isAnnounced() && socket.isOpen())
|
|
259
264
|
fenceLive(runtime, event.left);
|
package/dist/listing.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { HeldRooms } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { DiscoveredRoom, HeldRoom, OperationScopes, ProviderRefusal, ReplicaAdmission, RoomDeclaration } from './adapter.js';
|
|
3
3
|
import type { Composition } from './collection.js';
|
|
4
|
+
import type { KeyedChange } from './observation.js';
|
|
4
5
|
import { type ModelState, type TypesResult } from './model.js';
|
|
5
6
|
import { type PortReach } from './reach.js';
|
|
6
7
|
import type { ReplicaRecord } from './replica.js';
|
|
@@ -27,10 +28,11 @@ export type AppRoom = {
|
|
|
27
28
|
locked: boolean;
|
|
28
29
|
};
|
|
29
30
|
type ListedRoom = Omit<AppRoom, 'documents' | 'locked'>;
|
|
30
|
-
type ListedEntry = ListedRoom & {
|
|
31
|
+
export type ListedEntry = ListedRoom & {
|
|
31
32
|
readonly documents: number;
|
|
32
33
|
};
|
|
33
34
|
export type Listing = ReadonlyMap<string, ListedEntry>;
|
|
35
|
+
export type RoomsChange = KeyedChange<string, AppRoom>;
|
|
34
36
|
export declare function modelIn({ socket, presence }: Runtime, locator: string, stored: Stored | undefined): ModelState;
|
|
35
37
|
export declare function compositionFor(runtime: Runtime, record: ReplicaRecord): Composition;
|
|
36
38
|
export declare function declarationOf({ presence }: Runtime, locator: string, stored: Stored | undefined): {
|
|
@@ -38,9 +40,11 @@ export declare function declarationOf({ presence }: Runtime, locator: string, st
|
|
|
38
40
|
readonly available: boolean;
|
|
39
41
|
} | undefined;
|
|
40
42
|
export declare function listedLocators({ presence }: Runtime, held: ReadonlyMap<string, unknown>): string[];
|
|
41
|
-
export declare function
|
|
43
|
+
export declare function listedOrHeld({ presence }: Runtime, held: ReadonlyMap<string, unknown>, locator: string): boolean;
|
|
44
|
+
export declare function listedEntries(runtime: Runtime, touched: readonly string[]): Promise<readonly ListedEntry[] | null>;
|
|
42
45
|
export declare function listingNow(runtime: Runtime): Promise<Listing>;
|
|
43
|
-
export declare function shownRooms(
|
|
46
|
+
export declare function shownRooms(runtime: Runtime, listing: Listing): readonly AppRoom[];
|
|
47
|
+
export declare function shownChange(runtime: Runtime, entries: readonly ListedEntry[]): RoomsChange;
|
|
44
48
|
export declare function roomFacts(runtime: Runtime, reach?: PortReach | null): Promise<HeldRooms>;
|
|
45
49
|
export declare function heldRooms({ store }: Runtime, listed: readonly DiscoveredRoom[]): Promise<HeldRoom[]>;
|
|
46
50
|
export declare function name(runtime: Runtime, locator: string): Promise<void>;
|
package/dist/listing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listing.d.ts","sourceRoot":"","sources":["../src/listing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EACV,cAAc,EACd,QAAQ,EACR,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"listing.d.ts","sourceRoot":"","sources":["../src/listing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EACV,cAAc,EACd,QAAQ,EACR,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAwB,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,M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EAAE,MAAM,iBAO3D"}
|
package/dist/listing.js
CHANGED
|
@@ -26,6 +26,9 @@ export function listedLocators({ presence }, held) {
|
|
|
26
26
|
const listed = presence.rooms().map(({ locator }) => locator);
|
|
27
27
|
return [...new Set([...listed, ...held.keys()])];
|
|
28
28
|
}
|
|
29
|
+
export function listedOrHeld({ presence }, held, locator) {
|
|
30
|
+
return presence.room(locator) !== undefined || held.has(locator);
|
|
31
|
+
}
|
|
29
32
|
function selectionModel({ socket, builtIn }) {
|
|
30
33
|
return socket.session.now().refusal?.code === 'revoked-authorization'
|
|
31
34
|
? { status: 'unavailable', reason: 'revoked' }
|
|
@@ -64,27 +67,27 @@ function listingOf(runtime, held) {
|
|
|
64
67
|
}
|
|
65
68
|
return listing;
|
|
66
69
|
}
|
|
67
|
-
export async function
|
|
70
|
+
export async function listedEntries(runtime, touched) {
|
|
68
71
|
const { store } = runtime;
|
|
69
|
-
|
|
70
|
-
if (roomsShown === null)
|
|
72
|
+
if (store.roomsShown.now() === null)
|
|
71
73
|
return null;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
if (touched.length === 0)
|
|
75
|
+
return [];
|
|
76
|
+
const held = await store.rooms(touched);
|
|
77
|
+
const entries = [];
|
|
78
|
+
for (const locator of touched) {
|
|
75
79
|
const room = listedRoom(runtime, locator, held.get(locator));
|
|
76
|
-
if (room === undefined ||
|
|
80
|
+
if (room === undefined || store.roomsShown.now()?.has(locator) !== true)
|
|
77
81
|
return null;
|
|
78
|
-
|
|
82
|
+
entries.push(room);
|
|
79
83
|
}
|
|
80
|
-
return
|
|
84
|
+
return entries;
|
|
81
85
|
}
|
|
82
86
|
export async function listingNow(runtime) {
|
|
83
87
|
return listingOf(runtime, await runtime.store.rooms());
|
|
84
88
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return structuredClone([...listing.values()].map(({ documents, ...room }) => locked.has(room.locator)
|
|
89
|
+
function shownRoom({ presence }, { documents, ...room }) {
|
|
90
|
+
return presence.lockedAs(room.locator, room.replica.offline)
|
|
88
91
|
? {
|
|
89
92
|
...room,
|
|
90
93
|
model: modelTypes(NO_MODEL),
|
|
@@ -92,7 +95,17 @@ export function shownRooms({ presence }, listing) {
|
|
|
92
95
|
documents: 0,
|
|
93
96
|
locked: true,
|
|
94
97
|
}
|
|
95
|
-
: { ...room, documents, locked: false }
|
|
98
|
+
: { ...room, documents, locked: false };
|
|
99
|
+
}
|
|
100
|
+
export function shownRooms(runtime, listing) {
|
|
101
|
+
return structuredClone([...listing.values()].map((entry) => shownRoom(runtime, entry)));
|
|
102
|
+
}
|
|
103
|
+
export function shownChange(runtime, entries) {
|
|
104
|
+
return {
|
|
105
|
+
changed: structuredClone(entries.map((entry) => [entry.locator, shownRoom(runtime, entry)])),
|
|
106
|
+
removed: [],
|
|
107
|
+
order: null,
|
|
108
|
+
};
|
|
96
109
|
}
|
|
97
110
|
export async function roomFacts(runtime, reach = null) {
|
|
98
111
|
const { store, socket, builtIn } = runtime;
|
package/dist/live.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChangeSet } from './change-set.js';
|
|
2
2
|
import { type KeyedResult, type QueryMessage } from './observation.js';
|
|
3
|
-
import type { PendingResult, Plan, QueryCoverage } from './query.js';
|
|
3
|
+
import type { PendingResult, PendingRoom, Plan, QueryCoverage } from './query.js';
|
|
4
4
|
import type { Fail } from './reach.js';
|
|
5
5
|
import type { QueryRoom } from './tables.js';
|
|
6
6
|
export type Cover = {
|
|
@@ -11,13 +11,15 @@ export type Ran = KeyedResult & {
|
|
|
11
11
|
readonly current: () => boolean;
|
|
12
12
|
};
|
|
13
13
|
export type Run = (plan: Plan, cover: () => Promise<Cover>) => Promise<Ran>;
|
|
14
|
+
export type PendingAt<H> = (held: H, rooms: readonly string[]) => ReadonlyMap<string, PendingRoom | null> | null;
|
|
14
15
|
type Listener = (message: QueryMessage) => void;
|
|
15
16
|
export type LiveQueries<H> = {
|
|
16
17
|
touched(set: ChangeSet): void;
|
|
17
|
-
recover(): void;
|
|
18
|
-
watch(plan: Plan, identity: string, cover: (held: H) => Cover, deliver: Listener, failed: Fail): () => void;
|
|
18
|
+
recover(locators?: readonly string[]): void;
|
|
19
|
+
watch(plan: Plan, identity: string, cover: (held: H) => Cover, pendingAt: PendingAt<H>, deliver: Listener, failed: Fail): () => void;
|
|
19
20
|
close(): void;
|
|
20
21
|
};
|
|
22
|
+
export declare function readerOf(plan: Plan): (locator: string) => boolean;
|
|
21
23
|
export declare function createLiveQueries<H>(run: Run, holding: () => Promise<H>): LiveQueries<H>;
|
|
22
24
|
export {};
|
|
23
25
|
//# sourceMappingURL=live.d.ts.map
|
package/dist/live.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../src/live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../src/live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAQL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAA;CAAE,GAAG,aAAa,CAAC;AAE7F,MAAM,MAAM,GAAG,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAA;CAAE,CAAC;AAEpE,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAE5E,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CACzB,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,SAAS,MAAM,EAAE,KACrB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;AAEpD,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;AAiBhD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAC5C,KAAK,CACH,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,EACzB,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EACvB,OAAO,EAAE,QAAQ,EACjB,MAAM,EAAE,IAAI,GACX,MAAM,IAAI,CAAC;IACd,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAWF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAQjE;AAeD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CA4JxF"}
|
package/dist/live.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import { changeOf, digestOf, } from './observation.js';
|
|
1
|
+
import { changeOf, digestOf, keyedAt, keyedInto, samePending, unchanged, } from './observation.js';
|
|
2
2
|
import { uncaught } from './failure.js';
|
|
3
|
-
import {
|
|
3
|
+
import { roomsOfReach } from './rows.js';
|
|
4
4
|
function narrowed(plan) {
|
|
5
5
|
return (plan.paths !== null &&
|
|
6
6
|
plan.hop === null &&
|
|
7
7
|
plan.backlinks === null &&
|
|
8
8
|
!(plan.shape.kind === 'documents' && plan.shape.backlinks));
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return (plan.reach.rooms.includes(locator) ||
|
|
18
|
-
plan.reach.documents.some((document) => roomOfKey(document) === locator));
|
|
10
|
+
export function readerOf(plan) {
|
|
11
|
+
const locked = new Set(plan.locked);
|
|
12
|
+
const named = plan.rooms === null ? null : new Set(plan.rooms);
|
|
13
|
+
const reached = plan.reach === null ? null : roomsOfReach(plan.reach);
|
|
14
|
+
return (locator) => !locked.has(locator) &&
|
|
15
|
+
(named === null || named.has(locator)) &&
|
|
16
|
+
(reached === null || reached.has(locator));
|
|
19
17
|
}
|
|
20
|
-
function affected(plan, set) {
|
|
21
|
-
if (set.rooms.some(
|
|
18
|
+
function affected({ plan, reads }, set) {
|
|
19
|
+
if (set.rooms.some(reads))
|
|
22
20
|
return true;
|
|
23
21
|
const paths = narrowed(plan) ? new Set(plan.paths) : null;
|
|
24
|
-
return set.documents.some(({ locator, path }) => reads(
|
|
22
|
+
return set.documents.some(({ locator, path }) => reads(locator) && (paths === null || path === null || paths.has(path)));
|
|
25
23
|
}
|
|
26
24
|
function shown(entry, held) {
|
|
27
25
|
const cover = entry.cover(held);
|
|
@@ -30,11 +28,13 @@ function shown(entry, held) {
|
|
|
30
28
|
export function createLiveQueries(run, holding) {
|
|
31
29
|
const entries = new Map();
|
|
32
30
|
let closed = false;
|
|
33
|
-
let
|
|
34
|
-
let
|
|
31
|
+
let recoveringNow = false;
|
|
32
|
+
let recoveringAll = false;
|
|
33
|
+
const recovering = new Set();
|
|
35
34
|
function deliver(entry, next) {
|
|
36
35
|
const previous = entry.digest;
|
|
37
36
|
entry.digest = digestOf(next);
|
|
37
|
+
entry.pending = 'pending' in entry.digest ? entry.digest.pending : null;
|
|
38
38
|
entry.covered = JSON.stringify('pending' in next.result ? next.result : next.result.coverage);
|
|
39
39
|
const change = previous === undefined ? null : changeOf(previous, next);
|
|
40
40
|
if (change !== null) {
|
|
@@ -87,58 +87,99 @@ export function createLiveQueries(run, holding) {
|
|
|
87
87
|
}
|
|
88
88
|
})();
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return;
|
|
90
|
+
function pendingMoved(entry, held, rooms) {
|
|
91
|
+
const { pending } = entry;
|
|
92
|
+
if (pending === null || pending.size === 0 || entry.running || entry.fresh.size > 0) {
|
|
93
|
+
return false;
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
const at = entry.pendingAt(held, rooms);
|
|
96
|
+
const change = at === null ? null : keyedAt(pending, at, samePending);
|
|
97
|
+
if (change === null || change.removed.length === pending.size)
|
|
98
|
+
return false;
|
|
99
|
+
keyedInto(pending, change);
|
|
100
|
+
entry.covered = '';
|
|
101
|
+
if (unchanged(change))
|
|
102
|
+
return true;
|
|
103
|
+
for (const listener of entry.ready)
|
|
104
|
+
listener({ pending: change });
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
function recovered(locators) {
|
|
108
|
+
if (locators === undefined)
|
|
109
|
+
recoveringAll = true;
|
|
110
|
+
else
|
|
111
|
+
for (const locator of locators)
|
|
112
|
+
recovering.add(locator);
|
|
113
|
+
if (recoveringNow)
|
|
114
|
+
return;
|
|
115
|
+
recoveringNow = true;
|
|
96
116
|
void (async () => {
|
|
97
117
|
try {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
118
|
+
while ((recoveringAll || recovering.size > 0) && !closed) {
|
|
119
|
+
const all = recoveringAll;
|
|
120
|
+
const touched = [...recovering];
|
|
121
|
+
recoveringAll = false;
|
|
122
|
+
recovering.clear();
|
|
123
|
+
const reached = [...entries.values()].filter((entry) => all || touched.some(entry.reads));
|
|
124
|
+
for (const entry of reached) {
|
|
101
125
|
if (entry.running)
|
|
102
126
|
entry.dirty = true;
|
|
103
127
|
}
|
|
104
|
-
const waiting =
|
|
105
|
-
if (waiting.length === 0
|
|
128
|
+
const waiting = reached.filter((entry) => !entry.running);
|
|
129
|
+
if (waiting.length === 0)
|
|
106
130
|
continue;
|
|
107
131
|
const held = await holding();
|
|
108
132
|
for (const entry of waiting) {
|
|
109
133
|
if (entry.running)
|
|
110
134
|
continue;
|
|
135
|
+
const read = all ? [] : touched.filter(entry.reads);
|
|
136
|
+
if (read.length > 0 && pendingMoved(entry, held, read))
|
|
137
|
+
continue;
|
|
111
138
|
if (entry.digest === undefined || shown(entry, held) !== entry.covered)
|
|
112
139
|
schedule(entry);
|
|
113
140
|
}
|
|
114
|
-
}
|
|
141
|
+
}
|
|
115
142
|
}
|
|
116
143
|
catch (error) {
|
|
117
144
|
uncaught(error);
|
|
118
145
|
}
|
|
119
146
|
finally {
|
|
120
|
-
|
|
147
|
+
recoveringNow = false;
|
|
121
148
|
}
|
|
122
149
|
})();
|
|
123
150
|
}
|
|
124
151
|
return {
|
|
125
152
|
touched(set) {
|
|
153
|
+
const pending = new Set();
|
|
126
154
|
for (const entry of entries.values()) {
|
|
127
|
-
if (affected(entry
|
|
155
|
+
if (!affected(entry, set))
|
|
156
|
+
continue;
|
|
157
|
+
if (entry.pending === null || entry.running) {
|
|
128
158
|
schedule(entry);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
for (const locator of set.rooms)
|
|
162
|
+
pending.add(locator);
|
|
163
|
+
for (const { locator } of set.documents)
|
|
164
|
+
pending.add(locator);
|
|
129
165
|
}
|
|
166
|
+
if (pending.size > 0)
|
|
167
|
+
recovered([...pending]);
|
|
130
168
|
},
|
|
131
169
|
recover: recovered,
|
|
132
|
-
watch(plan, identity, cover, listener, failed) {
|
|
170
|
+
watch(plan, identity, cover, pendingAt, listener, failed) {
|
|
133
171
|
let entry = entries.get(identity);
|
|
134
172
|
if (entry === undefined) {
|
|
135
173
|
entry = {
|
|
136
174
|
plan,
|
|
175
|
+
reads: readerOf(plan),
|
|
137
176
|
cover,
|
|
177
|
+
pendingAt,
|
|
138
178
|
listeners: new Set(),
|
|
139
179
|
fresh: new Map(),
|
|
140
180
|
ready: new Set(),
|
|
141
181
|
digest: undefined,
|
|
182
|
+
pending: null,
|
|
142
183
|
covered: '',
|
|
143
184
|
dirty: false,
|
|
144
185
|
running: false,
|
package/dist/loaded.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BuildFile } from './client.js';
|
|
2
|
+
export declare function parsed(file: Blob | null): Promise<unknown>;
|
|
3
|
+
export declare function perBuild<T>(buildFile: BuildFile, key: string, make: () => Promise<T>): Promise<T>;
|
|
4
|
+
export declare function loaded<T>(buildFile: BuildFile, name: string, read?: (file: Blob | null) => Promise<unknown>): Promise<T | null>;
|
|
5
|
+
//# sourceMappingURL=loaded.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loaded.d.ts","sourceRoot":"","sources":["../src/loaded.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAc7C,wBAAsB,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAEhE;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAYjG;AAED,wBAAgB,MAAM,CAAC,CAAC,EACtB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,OAAO,CAAC,OAAO,CAAY,GACvD,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAEnB"}
|