@agentshouse/mdruntime 0.1.0-c806ecaf4afed → 0.1.0-c80bb5b77602a
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 +109 -24
- 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 +2 -7
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +347 -0
- package/dist/binary.d.ts +6 -2
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +10 -3
- package/dist/change.d.ts +6 -2
- 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 +2 -4
- package/dist/client.d.ts +20 -14
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +28 -56
- 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 +21 -11
- 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 -10
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +18 -8
- 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 +22 -11
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +258 -188
- package/dist/declaration.js +1 -1
- 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 +14 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +45 -16
- 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 +7 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +76 -30
- package/dist/house-query.d.ts +18 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +54 -0
- package/dist/index.d.ts +17 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -5
- 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 +7 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +46 -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 +19 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +167 -33
- package/dist/memory.d.ts +7 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +63 -19
- package/dist/messages.d.ts +17 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +29 -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/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- 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 +24 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +33 -3
- package/dist/overlay.d.ts +7 -4
- 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 +33 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +198 -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/query.d.ts +2 -2
- package/dist/questions.d.ts +1 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -8
- 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 +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +162 -37
- 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 +20 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +17 -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/reference-forms.d.ts +4 -0
- package/dist/reference-forms.d.ts.map +1 -0
- package/dist/reference-forms.js +74 -0
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- 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 +4 -4
- 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 +258 -32
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +11 -6
- 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 +8 -7
- 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 +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +105 -124
- package/dist/saves.d.ts +4 -2
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +65 -21
- 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 +7 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +15 -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 +32 -14
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +185 -49
- package/dist/surface.d.ts +14 -8
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +59 -27
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +76 -40
- package/dist/tables.d.ts +17 -52
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +87 -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 +38 -15
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +20 -13
- 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/overlay.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { apply, create,
|
|
1
|
+
import { apply, create, documentValue, parse, serialize, TYPE_FIELD, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { definitionsAt } from './collection.js';
|
|
3
|
+
import { isPart, } from './change.js';
|
|
3
4
|
import { drafted, entriesIn, settling } from './shared.js';
|
|
4
5
|
import { ROW_WEIGHT } from './turn.js';
|
|
5
6
|
export function* acceptedBinaries(files) {
|
|
@@ -25,9 +26,6 @@ export function sameChange(left, right) {
|
|
|
25
26
|
left.author?.id === right.author?.id &&
|
|
26
27
|
left.author?.name === right.author?.name);
|
|
27
28
|
}
|
|
28
|
-
function isPart(change) {
|
|
29
|
-
return change.kind === 'field' || change.kind === 'section' || change.kind === 'preamble';
|
|
30
|
-
}
|
|
31
29
|
function at(path, name) {
|
|
32
30
|
return `${path} ${name}`;
|
|
33
31
|
}
|
|
@@ -53,13 +51,12 @@ function* priorsOf(preconditions) {
|
|
|
53
51
|
preamble: (path) => preambles.get(path) ?? '',
|
|
54
52
|
};
|
|
55
53
|
}
|
|
56
|
-
function
|
|
54
|
+
export function composed(path, fields, sections, composition) {
|
|
57
55
|
const declared = fields[TYPE_FIELD];
|
|
58
56
|
const type = typeof declared === 'string' && declared !== '' ? declared : undefined;
|
|
59
57
|
const definition = definitionsAt(composition, path)(type);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
...Object.entries(fields).flatMap(([name, value]) => (name !== TYPE_FIELD || type === undefined) && frontmatterValue(value)
|
|
58
|
+
return apply(create(type, definition), [
|
|
59
|
+
...Object.entries(fields).flatMap(([name, value]) => (name !== TYPE_FIELD || type === undefined) && documentValue(value)
|
|
63
60
|
? [{ kind: 'field', name, value, prior: undefined }]
|
|
64
61
|
: []),
|
|
65
62
|
...Object.entries(sections).map(([name, value]) => ({
|
|
@@ -69,7 +66,12 @@ function compose(path, fields, sections, composition) {
|
|
|
69
66
|
prior: undefined,
|
|
70
67
|
})),
|
|
71
68
|
], definition);
|
|
72
|
-
|
|
69
|
+
}
|
|
70
|
+
export function compose(path, fields, sections, composition) {
|
|
71
|
+
const next = composed(path, fields, sections, composition);
|
|
72
|
+
if (next.outcome !== 'applied')
|
|
73
|
+
throw new Error(`the creation of ${path} writes no document`);
|
|
74
|
+
return serialize(next.document);
|
|
73
75
|
}
|
|
74
76
|
function edited(change, priors) {
|
|
75
77
|
if (change.kind === 'field')
|
package/dist/parts.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { type Part
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly next: string | null;
|
|
6
|
-
readonly activity: string | null;
|
|
7
|
-
};
|
|
8
|
-
export declare function counted(count: number): string;
|
|
1
|
+
import { type Part } from '@agentshouse/session-content';
|
|
2
|
+
export declare const WORKING = "Working";
|
|
3
|
+
export declare function linesWords(added: number, removed: number): string;
|
|
4
|
+
export declare function turnLine(parts: readonly Part[], lead: string | null): string | null;
|
|
9
5
|
export declare function runningLine(parts: readonly Part[]): string | null;
|
|
10
|
-
export declare function workOf(state: SessionState | null): readonly ChatWork[];
|
|
11
6
|
//# sourceMappingURL=parts.d.ts.map
|
package/dist/parts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../src/parts.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../src/parts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAGrE,eAAO,MAAM,OAAO,YAAY,CAAC;AAOjC,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAMD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAenF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,MAAM,GAAG,IAAI,CAIjE"}
|
package/dist/parts.js
CHANGED
|
@@ -1,21 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { turnCounts } from '@agentshouse/session-content';
|
|
2
2
|
import { excerpt } from './read.js';
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export const WORKING = 'Working';
|
|
4
|
+
function said(count, one, many) {
|
|
5
|
+
if (count === 0)
|
|
6
|
+
return null;
|
|
7
|
+
return count === 1 ? one : many(count);
|
|
8
|
+
}
|
|
9
|
+
export function linesWords(added, removed) {
|
|
10
|
+
return `+${added} −${removed}`;
|
|
11
|
+
}
|
|
12
|
+
function capitalized(words) {
|
|
13
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
14
|
+
}
|
|
15
|
+
export function turnLine(parts, lead) {
|
|
16
|
+
const counts = turnCounts(parts);
|
|
17
|
+
const kinds = [
|
|
18
|
+
said(counts.commands, 'ran 1 command', (count) => `ran ${count} commands`),
|
|
19
|
+
said(counts.edited, 'edited 1 file', (count) => `edited ${count} files`),
|
|
20
|
+
said(counts.other, 'made 1 other call', (count) => `made ${count} other calls`),
|
|
21
|
+
].filter((one) => one !== null);
|
|
22
|
+
if (kinds.length === 0)
|
|
23
|
+
return null;
|
|
24
|
+
const changed = counts.added === 0 && counts.removed === 0 ? null : linesWords(counts.added, counts.removed);
|
|
25
|
+
const failed = counts.failed === 0 ? null : `${counts.failed} failed`;
|
|
26
|
+
const words = kinds.join(' · ');
|
|
27
|
+
return [lead === null ? capitalized(words) : `${lead} · ${words}`, changed, failed]
|
|
28
|
+
.filter((one) => one !== null)
|
|
29
|
+
.join(' · ');
|
|
5
30
|
}
|
|
6
31
|
export function runningLine(parts) {
|
|
7
|
-
const
|
|
8
|
-
const note = newest.find((part) => part.type === 'text' && part.text.trim() !== '');
|
|
32
|
+
const note = [...parts].reverse().find((part) => part.type === 'text' && part.text.trim() !== '');
|
|
9
33
|
if (note?.type === 'text')
|
|
10
34
|
return excerpt(note.text);
|
|
11
|
-
|
|
12
|
-
return call?.type === 'call' && call.line !== '' ? call.line : null;
|
|
13
|
-
}
|
|
14
|
-
export function workOf(state) {
|
|
15
|
-
return (state?.running ?? []).map(({ kind, label, progress, next }) => ({
|
|
16
|
-
kind: kind === 'subagent' || kind === 'schedule' ? kind : 'job',
|
|
17
|
-
title: label,
|
|
18
|
-
next,
|
|
19
|
-
activity: progress,
|
|
20
|
-
}));
|
|
35
|
+
return turnLine(parts, null);
|
|
21
36
|
}
|
package/dist/preparation.d.ts
CHANGED
|
@@ -1,20 +1,46 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type InstallShare } from './install.js';
|
|
2
|
+
import { type ReadinessChange } from './observation.js';
|
|
2
3
|
import { type PortReach } from './reach.js';
|
|
3
|
-
import { type CodeAvailability, type ConnectionAvailability, type Readiness } from './readiness.js';
|
|
4
|
+
import { type CodeAvailability, type ConnectionAvailability, type FirstTier, type Readiness, type RoomCoverage } from './readiness.js';
|
|
4
5
|
import type { Runtime } from './runtime.js';
|
|
5
6
|
export type ReadinessPort = {
|
|
6
7
|
readonly target: string;
|
|
7
8
|
readonly code: CodeAvailability;
|
|
9
|
+
readonly first: FirstTier | null;
|
|
10
|
+
readonly inboxed: readonly string[] | null;
|
|
8
11
|
};
|
|
12
|
+
export type ReadinessMessage = Readiness | ReadinessChange;
|
|
9
13
|
export type ReadinessWatch = {
|
|
10
14
|
readonly port: ReadinessPort;
|
|
11
15
|
readonly reach: PortReach | null;
|
|
12
|
-
readonly deliver: (readiness:
|
|
16
|
+
readonly deliver: (readiness: ReadinessMessage) => void;
|
|
17
|
+
};
|
|
18
|
+
type Share = InstallShare & {
|
|
19
|
+
readonly coverage: RoomCoverage;
|
|
20
|
+
};
|
|
21
|
+
type Settled = {
|
|
22
|
+
acquiring: number;
|
|
23
|
+
unsettled: number;
|
|
24
|
+
};
|
|
25
|
+
type Totals = Settled & {
|
|
26
|
+
installing: number;
|
|
27
|
+
downloading: number;
|
|
28
|
+
done: number;
|
|
29
|
+
total: number;
|
|
30
|
+
};
|
|
31
|
+
export type ReadinessShowing = {
|
|
32
|
+
readonly listing: number;
|
|
33
|
+
readonly roomsListed: boolean;
|
|
34
|
+
readonly named: ReadonlySet<string> | null;
|
|
35
|
+
readonly rooms: Map<string, Share>;
|
|
36
|
+
readonly first: Map<string, string>;
|
|
37
|
+
readonly totals: Totals;
|
|
38
|
+
shown: string;
|
|
13
39
|
};
|
|
14
40
|
export declare function prepare(runtime: Runtime, locators?: readonly string[]): void;
|
|
15
|
-
export declare function roomsOfReach(reach: PlanReach): ReadonlySet<string>;
|
|
16
41
|
export declare function connectionNow(runtime: Runtime): Promise<ConnectionAvailability>;
|
|
17
|
-
export declare function deliverOwedReadiness(runtime: Runtime, owed: readonly ReadinessWatch[]): Promise<void>;
|
|
18
|
-
export declare function watchReadiness({ store }: Runtime, port: ReadinessPort, reach: PortReach | null, deliver: (readiness:
|
|
19
|
-
export declare function filled(
|
|
42
|
+
export declare function deliverOwedReadiness(runtime: Runtime, owed: readonly ReadinessWatch[], touched: ReadonlySet<string> | null): Promise<void>;
|
|
43
|
+
export declare function watchReadiness({ store }: Runtime, port: ReadinessPort, reach: PortReach | null, deliver: (readiness: ReadinessMessage) => void): () => void;
|
|
44
|
+
export declare function filled({ store, socket }: Runtime): void;
|
|
45
|
+
export {};
|
|
20
46
|
//# sourceMappingURL=preparation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preparation.d.ts","sourceRoot":"","sources":["../src/preparation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"preparation.d.ts","sourceRoot":"","sources":["../src/preparation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgC,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE/E,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAa,KAAK,SAAS,E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Q,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAwCF,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,GAAE,SAAS,MAAM,EAAO,QA4BzE;AAqGD,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAOrF;AA8MD,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,SAAS,cAAc,EAAE,EAC/B,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,iBAKpC;AAED,wBAAgB,cAAc,CAC5B,EAAE,KAAK,EAAE,EAAE,OAAO,EAClB,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,OAAO,EAAE,CAAC,SAAS,EAAE,gBAAgB,KAAK,IAAI,GAC7C,MAAM,IAAI,CAWZ;AAED,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,QAGhD"}
|
package/dist/preparation.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { changeSet } from './change-set.js';
|
|
2
2
|
import { uncaught } from './failure.js';
|
|
3
|
-
import { installationOf } from './install.js';
|
|
4
|
-
import { listedLocators } from './listing.js';
|
|
3
|
+
import { installationOf, installShare } from './install.js';
|
|
4
|
+
import { listedLocators, listedOrHeld } from './listing.js';
|
|
5
|
+
import { keyedAt, keyedChange, unchanged, } from './observation.js';
|
|
5
6
|
import { planReach } from './reach.js';
|
|
6
|
-
import { readinessOf, } from './readiness.js';
|
|
7
|
-
import {
|
|
7
|
+
import { COMPLETE_ROOMS, readinessOf, } from './readiness.js';
|
|
8
|
+
import { roomsOfReach } from './rows.js';
|
|
8
9
|
import { recoverReads } from './shown.js';
|
|
9
10
|
import { yielded } from './turn.js';
|
|
10
11
|
async function prepareReplica(runtime, locator) {
|
|
@@ -23,8 +24,8 @@ async function prepareReplica(runtime, locator) {
|
|
|
23
24
|
if ((await store.rooms([locator])).get(locator)?.record.key !== key)
|
|
24
25
|
continue;
|
|
25
26
|
store.changed(changeSet(locator, { documents: null }));
|
|
26
|
-
recoverReads(runtime);
|
|
27
|
-
store.readiness.queue();
|
|
27
|
+
recoverReads(runtime, [locator]);
|
|
28
|
+
store.readiness.queue([locator]);
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -33,14 +34,13 @@ async function unprepared({ store }) {
|
|
|
33
34
|
const { unpreparedDemand, unpreparable } = store.device.now();
|
|
34
35
|
return [...unpreparedDemand, ...held.keys()].find((locator) => !(held.get(locator)?.indexed ?? false) && !unpreparable.has(locator));
|
|
35
36
|
}
|
|
36
|
-
function unpreparedBy({ store
|
|
37
|
+
function unpreparedBy({ store }, locator) {
|
|
37
38
|
const { unpreparable } = store.device.now();
|
|
38
39
|
store.device.set({ unpreparable: new Set([...unpreparable, locator]) });
|
|
39
|
-
|
|
40
|
-
store.readiness.queue();
|
|
40
|
+
store.readiness.queue([locator]);
|
|
41
41
|
}
|
|
42
42
|
export function prepare(runtime, locators = []) {
|
|
43
|
-
const { store, socket
|
|
43
|
+
const { store, socket } = runtime;
|
|
44
44
|
const { device } = store;
|
|
45
45
|
if (locators.length > 0) {
|
|
46
46
|
device.set({ unpreparedDemand: new Set([...device.now().unpreparedDemand, ...locators]) });
|
|
@@ -57,11 +57,10 @@ export function prepare(runtime, locators = []) {
|
|
|
57
57
|
const demand = new Set(device.now().unpreparedDemand);
|
|
58
58
|
demand.delete(waiting);
|
|
59
59
|
device.set({ unpreparedDemand: demand });
|
|
60
|
-
await prepareReplica(runtime, waiting).catch((
|
|
60
|
+
await prepareReplica(runtime, waiting).catch(() => unpreparedBy(runtime, waiting));
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
catch (error) {
|
|
64
|
-
journal.record('preparation failed');
|
|
65
64
|
uncaught(error);
|
|
66
65
|
}
|
|
67
66
|
finally {
|
|
@@ -69,19 +68,16 @@ export function prepare(runtime, locators = []) {
|
|
|
69
68
|
}
|
|
70
69
|
})();
|
|
71
70
|
}
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
function requires(runtime, named, held, room) {
|
|
72
|
+
const listed = listedOrHeld(runtime, held, room);
|
|
73
|
+
if (named === null)
|
|
74
|
+
return listed;
|
|
75
|
+
return named.has(room) && (!runtime.socket.session.now().roomsListed || listed);
|
|
74
76
|
}
|
|
75
|
-
function requiredRooms(runtime,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (reach === null)
|
|
80
|
-
return { listed: roomsListed, rooms: [...listed].sort() };
|
|
81
|
-
const named = [...roomsOfReach(reach)].sort();
|
|
82
|
-
if (roomsListed)
|
|
83
|
-
return { listed: true, rooms: named.filter((room) => listed.has(room)) };
|
|
84
|
-
return { listed: named.every((room) => held.has(room)), rooms: named };
|
|
77
|
+
function requiredRooms(runtime, named, held) {
|
|
78
|
+
return [...(named ?? listedLocators(runtime, held))]
|
|
79
|
+
.filter((room) => requires(runtime, named, held, room))
|
|
80
|
+
.sort();
|
|
85
81
|
}
|
|
86
82
|
function roomState({ socket, presence }, locator, held) {
|
|
87
83
|
if (socket.session.now().roomsListed &&
|
|
@@ -102,6 +98,41 @@ function conversationCoverage({ socket, conversations }, reach) {
|
|
|
102
98
|
return 'acquiring';
|
|
103
99
|
return 'complete';
|
|
104
100
|
}
|
|
101
|
+
function listCoverage({ socket, conversations }, first) {
|
|
102
|
+
if (!first.conversations || socket.conversations() === undefined)
|
|
103
|
+
return 'undeclared';
|
|
104
|
+
return conversations.listHeld() ? 'complete' : 'acquiring';
|
|
105
|
+
}
|
|
106
|
+
function tierOf(roomsListed, named, { acquiring, unsettled }, conversations) {
|
|
107
|
+
return { listed: roomsListed || (named && acquiring === 0), unsettled, conversations };
|
|
108
|
+
}
|
|
109
|
+
function placed({ presence }, tier, first, room, held) {
|
|
110
|
+
if (tier === null)
|
|
111
|
+
return;
|
|
112
|
+
const handle = presence.room(room)?.handle ?? held.get(room)?.handle;
|
|
113
|
+
if (handle !== undefined && tier.handles.includes(handle))
|
|
114
|
+
first.set(handle, room);
|
|
115
|
+
}
|
|
116
|
+
function firstOf(runtime, tier, inboxed, { roomsListed, rooms, first }) {
|
|
117
|
+
const settled = { acquiring: 0, unsettled: 0 };
|
|
118
|
+
const counted = (room) => {
|
|
119
|
+
const share = room === undefined ? undefined : rooms.get(room);
|
|
120
|
+
if (share !== undefined)
|
|
121
|
+
settledBy(settled, share.coverage.state, 1);
|
|
122
|
+
else if (!roomsListed)
|
|
123
|
+
settledBy(settled, 'acquiring', 1);
|
|
124
|
+
};
|
|
125
|
+
for (const handle of tier.handles)
|
|
126
|
+
counted(first.get(handle));
|
|
127
|
+
if (tier.inboxes) {
|
|
128
|
+
if (inboxed === null)
|
|
129
|
+
settledBy(settled, 'acquiring', 1);
|
|
130
|
+
else
|
|
131
|
+
for (const room of inboxed)
|
|
132
|
+
counted(room);
|
|
133
|
+
}
|
|
134
|
+
return tierOf(roomsListed, true, settled, listCoverage(runtime, tier));
|
|
135
|
+
}
|
|
105
136
|
function connectionOf({ socket }, lastCompleted) {
|
|
106
137
|
if (socket.isOpen())
|
|
107
138
|
return 'connected';
|
|
@@ -114,31 +145,103 @@ export async function connectionNow(runtime) {
|
|
|
114
145
|
if (socket.isOpen() || socket.session.now().moving.providerUnreachable || socket.streamed) {
|
|
115
146
|
return connectionOf(runtime, null);
|
|
116
147
|
}
|
|
117
|
-
|
|
148
|
+
if (!store.needed())
|
|
149
|
+
return connectionOf(runtime, socket.session.now().lastCompleted);
|
|
150
|
+
return connectionOf(runtime, (await (await store.open()).facts(['lastCompleted'])).lastCompleted);
|
|
118
151
|
}
|
|
119
|
-
async function readinessHeld({ store }) {
|
|
152
|
+
async function readinessHeld({ store, socket }) {
|
|
153
|
+
if (!store.needed()) {
|
|
154
|
+
return {
|
|
155
|
+
held: new Map(),
|
|
156
|
+
facts: { lastCompleted: socket.session.now().lastCompleted, targets: {} },
|
|
157
|
+
};
|
|
158
|
+
}
|
|
120
159
|
const local = await store.open();
|
|
121
|
-
const [held, facts] = await Promise.all([
|
|
160
|
+
const [held, facts] = await Promise.all([
|
|
161
|
+
store.covering(),
|
|
162
|
+
local.facts(['lastCompleted', 'targets']),
|
|
163
|
+
]);
|
|
122
164
|
return { held: held.rooms, facts };
|
|
123
165
|
}
|
|
124
|
-
function
|
|
125
|
-
const {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
166
|
+
function shareOf(runtime, room, held) {
|
|
167
|
+
const coverage = Object.freeze({ room, state: roomState(runtime, room, held) });
|
|
168
|
+
return { ...installShare(runtime.store, coverage, held), coverage };
|
|
169
|
+
}
|
|
170
|
+
function sameState(was, now) {
|
|
171
|
+
return was.coverage.state === now.coverage.state;
|
|
172
|
+
}
|
|
173
|
+
function coverageOf(change) {
|
|
174
|
+
return {
|
|
175
|
+
...change,
|
|
176
|
+
changed: change.changed.map(([room, share]) => [room, share.coverage]),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function settledBy(settled, state, sign) {
|
|
180
|
+
settled.acquiring += state === 'acquiring' ? sign : 0;
|
|
181
|
+
settled.unsettled += COMPLETE_ROOMS.has(state) ? 0 : sign;
|
|
182
|
+
}
|
|
183
|
+
function counted(totals, share, sign) {
|
|
184
|
+
totals.installing += share.installing ? sign : 0;
|
|
185
|
+
totals.downloading += share.downloading ? sign : 0;
|
|
186
|
+
settledBy(totals, share.coverage.state, sign);
|
|
187
|
+
totals.done += sign * share.bytes.done;
|
|
188
|
+
totals.total += sign * share.bytes.total;
|
|
189
|
+
}
|
|
190
|
+
function showingOf(runtime, { port, reach }, held) {
|
|
191
|
+
const planned = planReach(reach);
|
|
192
|
+
const named = planned === null ? null : roomsOfReach(planned);
|
|
193
|
+
const totals = { installing: 0, downloading: 0, acquiring: 0, unsettled: 0, done: 0, total: 0 };
|
|
194
|
+
const rooms = new Map();
|
|
195
|
+
const first = new Map();
|
|
196
|
+
for (const room of requiredRooms(runtime, named, held)) {
|
|
197
|
+
const share = shareOf(runtime, room, held);
|
|
198
|
+
rooms.set(room, share);
|
|
199
|
+
placed(runtime, port.first, first, room, held);
|
|
200
|
+
counted(totals, share, 1);
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
listing: runtime.presence.listing(),
|
|
204
|
+
roomsListed: runtime.socket.session.now().roomsListed,
|
|
205
|
+
named,
|
|
206
|
+
rooms,
|
|
207
|
+
first,
|
|
208
|
+
totals,
|
|
209
|
+
shown: '',
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function moved(runtime, { port }, showing, held, touched) {
|
|
213
|
+
const at = new Map();
|
|
214
|
+
for (const room of touched) {
|
|
215
|
+
at.set(room, requires(runtime, showing.named, held, room) ? shareOf(runtime, room, held) : null);
|
|
216
|
+
}
|
|
217
|
+
const change = keyedAt(showing.rooms, at, sameState);
|
|
218
|
+
if (change === null || change.removed.length > 0)
|
|
219
|
+
return null;
|
|
220
|
+
for (const [room, share] of at) {
|
|
221
|
+
if (share === null)
|
|
222
|
+
continue;
|
|
223
|
+
counted(showing.totals, showing.rooms.get(room), -1);
|
|
224
|
+
counted(showing.totals, share, 1);
|
|
225
|
+
showing.rooms.set(room, share);
|
|
226
|
+
placed(runtime, port.first, showing.first, room, held);
|
|
227
|
+
}
|
|
228
|
+
return change;
|
|
229
|
+
}
|
|
230
|
+
function preparingIn(runtime, showing, rooms) {
|
|
231
|
+
const { unpreparable } = runtime.store.device.now();
|
|
232
|
+
const preparing = [...rooms].filter((room) => showing.rooms.get(room)?.coverage.state === 'preparing' && !unpreparable.has(room));
|
|
132
233
|
if (preparing.length > 0)
|
|
133
234
|
prepare(runtime, preparing);
|
|
134
|
-
|
|
235
|
+
}
|
|
236
|
+
function shownOf(runtime, { port, reach }, showing, { facts }) {
|
|
237
|
+
const { store, socket } = runtime;
|
|
238
|
+
const { persistence, storageLoss } = store.device.now();
|
|
239
|
+
const { named, totals, roomsListed } = showing;
|
|
240
|
+
const coverage = tierOf(roomsListed, named !== null, totals, conversationCoverage(runtime, reach));
|
|
135
241
|
return readinessOf({
|
|
136
242
|
code: port.code,
|
|
137
|
-
coverage
|
|
138
|
-
|
|
139
|
-
rooms: coverage,
|
|
140
|
-
conversations: conversationCoverage(runtime, reach),
|
|
141
|
-
},
|
|
243
|
+
coverage,
|
|
244
|
+
first: port.first === null ? coverage : firstOf(runtime, port.first, port.inboxed, showing),
|
|
142
245
|
persistence,
|
|
143
246
|
connection: connectionOf(runtime, facts.lastCompleted),
|
|
144
247
|
house: socket.session.now().refusal !== null
|
|
@@ -147,87 +250,95 @@ function readinessFor(runtime, port, reach, { held, facts }) {
|
|
|
147
250
|
? 'write-halted'
|
|
148
251
|
: 'open',
|
|
149
252
|
space: store.space.full() ? 'full' : null,
|
|
150
|
-
installation: installationOf(
|
|
253
|
+
installation: installationOf(totals.installing, totals.downloading, {
|
|
254
|
+
done: totals.done,
|
|
255
|
+
total: totals.total,
|
|
256
|
+
}),
|
|
151
257
|
lost: storageLoss !== null,
|
|
152
|
-
established: facts.targets[port.target]?.established === true
|
|
153
|
-
(heldWhenOpened && usableWhenHeld.includes(port.target)),
|
|
258
|
+
established: facts.targets[port.target]?.established === true,
|
|
154
259
|
});
|
|
155
260
|
}
|
|
156
|
-
function establish(
|
|
157
|
-
const { store, journal } = runtime;
|
|
261
|
+
function establish({ store }, name) {
|
|
158
262
|
const { device } = store;
|
|
159
|
-
if (device.now().establishing.has(name))
|
|
263
|
+
if (device.now().establishing.has(name) || !store.needed())
|
|
160
264
|
return;
|
|
161
265
|
device.set({ establishing: new Set([...device.now().establishing, name]) });
|
|
162
266
|
void store
|
|
163
267
|
.durably(async (local) => {
|
|
164
|
-
const { targets } = await local.facts();
|
|
268
|
+
const { targets } = await local.facts(['targets']);
|
|
165
269
|
await local.fact('targets', { ...targets, [name]: { established: true } });
|
|
166
270
|
})
|
|
167
|
-
.then(() =>
|
|
168
|
-
store.readiness.queue();
|
|
169
|
-
void probeEachMinute(runtime);
|
|
170
|
-
}, (error) => {
|
|
171
|
-
journal.record(`target record failed ${name}`);
|
|
172
|
-
uncaught(error);
|
|
173
|
-
})
|
|
271
|
+
.then(() => store.readiness.queue([]), uncaught)
|
|
174
272
|
.finally(() => {
|
|
175
273
|
const establishing = new Set(device.now().establishing);
|
|
176
274
|
establishing.delete(name);
|
|
177
275
|
device.set({ establishing });
|
|
178
276
|
});
|
|
179
277
|
}
|
|
180
|
-
function deliverReadiness(runtime, watch, held) {
|
|
181
|
-
|
|
278
|
+
function deliverReadiness(runtime, watch, held, touched) {
|
|
279
|
+
const { readiness } = runtime.store;
|
|
280
|
+
if (!readiness.held(watch))
|
|
182
281
|
return;
|
|
183
|
-
const
|
|
184
|
-
|
|
282
|
+
const kept = readiness.kept(watch);
|
|
283
|
+
const patched = kept === undefined ||
|
|
284
|
+
touched === null ||
|
|
285
|
+
kept.listing !== runtime.presence.listing() ||
|
|
286
|
+
kept.roomsListed !== runtime.socket.session.now().roomsListed
|
|
287
|
+
? null
|
|
288
|
+
: moved(runtime, watch, kept, held.held, touched);
|
|
289
|
+
const showing = patched === null ? showingOf(runtime, watch, held.held) : kept;
|
|
290
|
+
preparingIn(runtime, showing, patched === null ? showing.rooms.keys() : touched);
|
|
291
|
+
const shown = shownOf(runtime, watch, showing, held);
|
|
292
|
+
if (shown.usable)
|
|
293
|
+
probeEachMinute(runtime);
|
|
294
|
+
if (shown.ready && held.facts.targets[watch.port.target]?.established !== true) {
|
|
185
295
|
establish(runtime, watch.port.target);
|
|
186
296
|
}
|
|
187
|
-
|
|
297
|
+
const text = JSON.stringify(shown);
|
|
298
|
+
const before = kept?.shown;
|
|
299
|
+
showing.shown = text;
|
|
300
|
+
readiness.keep(watch, showing);
|
|
301
|
+
if (kept === undefined) {
|
|
302
|
+
watch.deliver({
|
|
303
|
+
...shown,
|
|
304
|
+
coverage: {
|
|
305
|
+
...shown.coverage,
|
|
306
|
+
rooms: [...showing.rooms.values()].map(({ coverage }) => coverage),
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
const rooms = coverageOf(patched ??
|
|
312
|
+
keyedChange(kept.rooms, [...showing.rooms.keys()], [...showing.rooms.values()], sameState));
|
|
313
|
+
if (text === before && unchanged(rooms))
|
|
188
314
|
return;
|
|
189
|
-
watch.deliver(
|
|
315
|
+
watch.deliver({ shown, rooms });
|
|
190
316
|
}
|
|
191
|
-
export async function deliverOwedReadiness(runtime, owed) {
|
|
317
|
+
export async function deliverOwedReadiness(runtime, owed, touched) {
|
|
192
318
|
const held = await readinessHeld(runtime);
|
|
193
319
|
if (runtime.socket.closed())
|
|
194
320
|
return;
|
|
195
321
|
for (const watch of owed)
|
|
196
|
-
deliverReadiness(runtime, watch, held);
|
|
322
|
+
deliverReadiness(runtime, watch, held, touched);
|
|
197
323
|
}
|
|
198
324
|
export function watchReadiness({ store }, port, reach, deliver) {
|
|
199
325
|
const watch = { port, reach, deliver };
|
|
200
326
|
const stop = store.readiness.add(watch);
|
|
201
|
-
|
|
327
|
+
if (!store.needed())
|
|
328
|
+
store.readiness.owe([watch]);
|
|
329
|
+
else {
|
|
330
|
+
void store.open().then(() => store.readiness.owe([watch]), () => store.readiness.owe([watch]));
|
|
331
|
+
}
|
|
202
332
|
return stop;
|
|
203
333
|
}
|
|
204
|
-
export function filled(
|
|
205
|
-
const { store, socket, journal } = runtime;
|
|
334
|
+
export function filled({ store, socket }) {
|
|
206
335
|
if (socket.closed() || !store.space.fill())
|
|
207
336
|
return;
|
|
208
|
-
|
|
209
|
-
store.readiness.queue();
|
|
210
|
-
void probeEachMinute(runtime);
|
|
211
|
-
}
|
|
212
|
-
async function installedTarget({ store }) {
|
|
213
|
-
if (store.device.now().heldWhenOpened)
|
|
214
|
-
return true;
|
|
215
|
-
const { targets } = await (await store.open()).facts();
|
|
216
|
-
return Object.values(targets).some((target) => target.established);
|
|
337
|
+
store.readiness.queue([]);
|
|
217
338
|
}
|
|
218
|
-
|
|
219
|
-
const { store, socket } = runtime;
|
|
339
|
+
function probeEachMinute({ store, socket }) {
|
|
220
340
|
const { space } = store;
|
|
221
|
-
|
|
222
|
-
if (idle())
|
|
223
|
-
return;
|
|
224
|
-
const installed = await installedTarget(runtime).catch((error) => {
|
|
225
|
-
uncaught(error);
|
|
226
|
-
return false;
|
|
227
|
-
});
|
|
228
|
-
if (!installed)
|
|
229
|
-
return;
|
|
230
|
-
if (idle())
|
|
341
|
+
if (!space.full() || space.probing() || socket.closed())
|
|
231
342
|
return;
|
|
232
343
|
space.probeEachMinute();
|
|
233
344
|
}
|
package/dist/presence.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ type Standing = {
|
|
|
9
9
|
readonly repairing: boolean;
|
|
10
10
|
readonly reloadDue: boolean;
|
|
11
11
|
};
|
|
12
|
+
export declare function lockingMode(mode: string | undefined): boolean;
|
|
12
13
|
type Listing = {
|
|
13
14
|
readonly whole: boolean;
|
|
14
15
|
readonly live: boolean;
|
|
@@ -25,7 +26,10 @@ export type Presence = {
|
|
|
25
26
|
modelled(locator: string, model: ModelState | null): void;
|
|
26
27
|
installed(locator: string, bootstrapped: boolean): void;
|
|
27
28
|
locked(locator: string, stored: () => Promise<string | null>): Promise<boolean>;
|
|
28
|
-
lockedAmong(stored: ReadonlyMap<string,
|
|
29
|
+
lockedAmong(stored: ReadonlyMap<string, {
|
|
30
|
+
readonly offline: string;
|
|
31
|
+
}>, locking: ReadonlySet<string>): readonly string[];
|
|
32
|
+
lockedAs(locator: string, mode: string | undefined): boolean;
|
|
29
33
|
connectionLost(lapsed: () => void): void;
|
|
30
34
|
connectionLive(): void;
|
|
31
35
|
lapse(): void;
|
|
@@ -41,12 +45,14 @@ export type Presence = {
|
|
|
41
45
|
writing(locator: string): boolean;
|
|
42
46
|
unwritten(locator: string): void;
|
|
43
47
|
lost(locator: string): boolean;
|
|
48
|
+
losing(): boolean;
|
|
49
|
+
listing(): number;
|
|
44
50
|
losses(): number;
|
|
45
51
|
lostSince(locator: string, losses: number): boolean;
|
|
46
52
|
liftable(locator: string, discovery: number): boolean;
|
|
47
53
|
lift(locator: string, discovery: number, unfenced: boolean): void;
|
|
48
54
|
close(): void;
|
|
49
55
|
};
|
|
50
|
-
export declare function createPresence(): Presence;
|
|
56
|
+
export declare function createPresence(notReadyWaitMs: (asked: number) => number): Presence;
|
|
51
57
|
export {};
|
|
52
58
|
//# sourceMappingURL=presence.d.ts.map
|
package/dist/presence.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,KAAK,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEzD,KAAK,QAAQ,GAAG;IACd,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B,CAAC;
|
|
1
|
+
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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