@agentshouse/mdruntime 0.1.0-c069136dcb4e8 → 0.1.0-c076b00ebf42a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -19
- package/dist/acceptance.d.ts +3 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +299 -0
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +26 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +302 -0
- package/dist/adapter.d.ts +108 -85
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -11
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +20 -60
- package/dist/bootstrap.d.ts +9 -5
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +204 -85
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- package/dist/chain.d.ts +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts +1 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -2
- package/dist/chat-types.d.ts +3 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +11 -0
- package/dist/client.d.ts +29 -22
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +36 -20
- package/dist/collection.d.ts +26 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +19 -2
- package/dist/compile.d.ts +8 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +286 -336
- package/dist/connection.d.ts +5 -142
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +110 -4970
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation-live.d.ts +150 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +259 -0
- package/dist/conversation-row.d.ts +35 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +55 -0
- package/dist/conversation.d.ts +65 -44
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +999 -881
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +150 -0
- package/dist/durability.d.ts +19 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +4 -0
- package/dist/entry.d.ts +2 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +18 -8
- package/dist/expectation.d.ts +26 -13
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +72 -19
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -0
- package/dist/figures.d.ts +49 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +199 -0
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +2 -1
- package/dist/holdings.d.ts +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +21 -7
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +77 -41
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +34 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -5
- package/dist/install.d.ts +60 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +537 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +278 -0
- package/dist/listing.d.ts +52 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +152 -0
- package/dist/live.d.ts +9 -6
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +118 -36
- package/dist/locks.d.ts +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +32 -0
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +49 -0
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +10 -13
- package/dist/memory.d.ts +15 -6
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +178 -89
- package/dist/messages.d.ts +35 -5
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +108 -36
- package/dist/model.d.ts +2 -10
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -14
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +153 -0
- package/dist/observation.d.ts +28 -13
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +185 -81
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +53 -0
- package/dist/outcome.d.ts +11 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +26 -2
- package/dist/overlay.d.ts +6 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +47 -21
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +4 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +13 -0
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts +41 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +314 -0
- package/dist/presence.d.ts +58 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +233 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +308 -0
- package/dist/query.d.ts +14 -210
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/questions.d.ts +29 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +115 -0
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +450 -0
- package/dist/reach.d.ts +16 -15
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +248 -147
- package/dist/react.d.ts +17 -3
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/read.d.ts +7 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +17 -0
- package/dist/readiness.d.ts +9 -6
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +3 -5
- package/dist/reads.d.ts +39 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +178 -0
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +38 -8
- package/dist/refresh.d.ts +2 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +31 -3
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +55 -0
- package/dist/replica.d.ts +11 -16
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +64 -30
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +7 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +113 -111
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +217 -0
- package/dist/rows.d.ts +16 -22
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +49 -186
- package/dist/runtime.d.ts +34 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +42 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +344 -174
- package/dist/saves.d.ts +32 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +409 -0
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +71 -1
- package/dist/shared.d.ts +1 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +33 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +309 -0
- package/dist/socket/admission.d.ts +7 -0
- package/dist/socket/admission.d.ts.map +1 -0
- package/dist/socket/admission.js +39 -0
- package/dist/socket/answers.d.ts +6 -0
- package/dist/socket/answers.d.ts.map +1 -0
- package/dist/socket/answers.js +20 -0
- package/dist/socket/lanes.d.ts +28 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +103 -0
- package/dist/socket/reads.d.ts +10 -0
- package/dist/socket/reads.d.ts.map +1 -0
- package/dist/socket/reads.js +31 -0
- package/dist/socket/session.d.ts +38 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +23 -0
- package/dist/socket.d.ts +67 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +164 -0
- package/dist/source.d.ts +54 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +82 -0
- package/dist/status.d.ts +0 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -6
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +40 -0
- package/dist/store/readiness.d.ts +11 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +68 -0
- package/dist/store/records.d.ts +217 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +464 -0
- package/dist/store/room-held.d.ts +8 -0
- package/dist/store/room-held.d.ts.map +1 -0
- package/dist/store/room-held.js +17 -0
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store/space.d.ts +11 -0
- package/dist/store/space.d.ts.map +1 -0
- package/dist/store/space.js +41 -0
- package/dist/store/watchers.d.ts +17 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +56 -0
- package/dist/store/writes.d.ts +24 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +125 -0
- package/dist/store.d.ts +113 -144
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +171 -364
- package/dist/stored.d.ts +72 -35
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +340 -197
- package/dist/surface.d.ts +89 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +222 -0
- package/dist/sync.d.ts +19 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +535 -0
- package/dist/tables.d.ts +124 -30
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +242 -62
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +128 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +9 -12
- package/dist/windows.d.ts +1 -12
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +2 -75
- package/dist/wire.d.ts +58 -9
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +21 -5
- package/package.json +3 -2
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
- package/dist/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -370
- package/dist/log.d.ts +0 -5
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -156
package/dist/queue.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { MutationResult } from './adapter.js';
|
|
2
|
+
import { type ChangeBatch } from './change.js';
|
|
3
|
+
import { type HeldReplica, type ReplicaRecord, type Returned, type Slice } from './replica.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
import type { SavePlan } from './save.js';
|
|
6
|
+
import type { SaveResult } from './saves.js';
|
|
7
|
+
import type { PendingState, RoomCommit, Store, StoredFile, View, Work } from './store.js';
|
|
8
|
+
export type Queueing = Pick<Runtime, 'store' | 'localSaves'> & {
|
|
9
|
+
readonly socket: Pick<Runtime['socket'], 'continuing'>;
|
|
10
|
+
readonly presence: Pick<Runtime['presence'], 'lost' | 'unheldModel' | 'room'>;
|
|
11
|
+
};
|
|
12
|
+
export type Restand = {
|
|
13
|
+
readonly locator: string;
|
|
14
|
+
readonly record: ReplicaRecord;
|
|
15
|
+
readonly accepted?: string;
|
|
16
|
+
readonly adopted?: Returned;
|
|
17
|
+
readonly installed?: Pick<RoomCommit, 'published' | 'refreshed'>;
|
|
18
|
+
readonly refused?: true;
|
|
19
|
+
readonly after?: () => void;
|
|
20
|
+
};
|
|
21
|
+
export type Appending = {
|
|
22
|
+
readonly plan: SavePlan;
|
|
23
|
+
readonly files: readonly StoredFile[];
|
|
24
|
+
readonly held: ReadonlyMap<string, {
|
|
25
|
+
readonly replica: HeldReplica;
|
|
26
|
+
readonly confirmed: Slice;
|
|
27
|
+
}>;
|
|
28
|
+
readonly after?: () => Promise<void>;
|
|
29
|
+
};
|
|
30
|
+
type Answer = Extract<MutationResult, {
|
|
31
|
+
kind: 'conflicted' | 'rejected';
|
|
32
|
+
}>;
|
|
33
|
+
export declare function withdrawable(states: ReadonlyMap<string, PendingState>): (batch: ChangeBatch) => boolean;
|
|
34
|
+
export declare function sliceAt(store: Store, record: ReplicaRecord, view: View, queue: readonly ChangeBatch[], extra?: Iterable<string>, moved?: Iterable<string>): Promise<Slice>;
|
|
35
|
+
export declare function settle(runtime: Queueing, locators: readonly string[], decide: (held: ReadonlyMap<string, Work>) => Promise<readonly Restand[]>): Promise<void>;
|
|
36
|
+
export declare function answered(runtime: Queueing, locator: string, head: ChangeBatch, answer: Answer): Promise<void>;
|
|
37
|
+
export declare function unpair(runtime: Queueing): Promise<void>;
|
|
38
|
+
export declare function append(runtime: Queueing, appending: Appending): Promise<SaveResult>;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAmC,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAKhF,OAAO,EAUL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,KAAK,EAEX,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAGV,YAAY,EACZ,UAAU,EAEV,KAAK,EACL,UAAU,EACV,IAAI,EACJ,IAAI,EACL,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,CAAC,GAAG;IAC7D,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC;IACvD,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,MAAM,G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AAE,QAAQ,CAAC,MAAM,CAAM,EAC5B,KAAK,GAAE,QAAQ,CAAC,MAAM,CAAM,GAC3B,OAAO,CAAC,KAAK,CAAC,CAWhB;AAyaD,wBAAgB,MAAM,CACpB,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,MAAM,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,GACvE,OAAO,CAAC,IAAI,CAAC,CAoCf;AAED,wBAAgB,QAAQ,CACtB,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAiDf;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvD;AAED,wBAAsB,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CA4DzF"}
|
package/dist/queue.js
ADDED
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import { changeSet, mergeChangeSets } from './change-set.js';
|
|
2
|
+
import { leaving as leavingIn, partnerOf } from './change.js';
|
|
3
|
+
import { composedOf, definitionsAt } from './collection.js';
|
|
4
|
+
import { declared } from './declaration.js';
|
|
5
|
+
import { runtimeError } from './failure.js';
|
|
6
|
+
import { roomDraftRevision } from './identity.js';
|
|
7
|
+
import { landed, movedBy, overlayOf, replaying, slicing, slicingWith, standing, storedRecord, touchedBy, } from './replica.js';
|
|
8
|
+
import { returnedBy, returnedInto } from './room-draft.js';
|
|
9
|
+
import { documentKey } from './rows.js';
|
|
10
|
+
import { stepped } from './turn.js';
|
|
11
|
+
export function withdrawable(states) {
|
|
12
|
+
return (batch) => {
|
|
13
|
+
const state = states.get(batch.id);
|
|
14
|
+
return state !== undefined && state.submission.state !== 'submitted' && !state.lost;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export async function sliceAt(store, record, view, queue, extra = [], moved = []) {
|
|
18
|
+
const local = await store.open();
|
|
19
|
+
const needed = new Set([...touchedBy(queue), ...extra]);
|
|
20
|
+
const movedPaths = [...new Set([...movedBy(queue, record.locator), ...moved])];
|
|
21
|
+
if (movedPaths.length > 0) {
|
|
22
|
+
for (const { path } of await local.referrers(record.key, view, movedPaths)) {
|
|
23
|
+
needed.add(path);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const paths = [...needed];
|
|
27
|
+
return stepped(slicing(await local.entries(record.key, view, paths), paths));
|
|
28
|
+
}
|
|
29
|
+
async function landedWhole(store, record, batch, confirmedLayer, current) {
|
|
30
|
+
if (!landed(batch, confirmedLayer, store.composed(record), current))
|
|
31
|
+
return false;
|
|
32
|
+
const partner = partnerOf(batch, record.locator);
|
|
33
|
+
if (partner === null)
|
|
34
|
+
return true;
|
|
35
|
+
const other = await store.replica(partner);
|
|
36
|
+
const half = other?.queue.find((one) => one.id === batch.id);
|
|
37
|
+
if (other === undefined || half === undefined)
|
|
38
|
+
return false;
|
|
39
|
+
return landed(half, await sliceAt(store, other.record, 'confirmed', [half]), store.composed(other.record));
|
|
40
|
+
}
|
|
41
|
+
async function returnedDrafts(store, locator, work, leaving, composition) {
|
|
42
|
+
const written = new Map();
|
|
43
|
+
for (const { batch, returned } of leaving) {
|
|
44
|
+
if (returned === null || batch.between?.destination.room === locator)
|
|
45
|
+
continue;
|
|
46
|
+
for (const saved of work.states.get(batch.id)?.drafts ?? []) {
|
|
47
|
+
const existing = written.get(saved.path) ?? (await store.draft(locator, saved.path));
|
|
48
|
+
const parts = returnedInto(existing?.parts, saved.parts, composition === undefined ? undefined : definitionsAt(composition, saved.path));
|
|
49
|
+
written.set(saved.path, parts === null
|
|
50
|
+
? { ...existing, returned }
|
|
51
|
+
: { locator, path: saved.path, revision: roomDraftRevision(), parts, returned });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return written;
|
|
55
|
+
}
|
|
56
|
+
function unheldComposition({ store, presence }, locator) {
|
|
57
|
+
const model = presence.unheldModel(locator);
|
|
58
|
+
const listed = presence.room(locator);
|
|
59
|
+
if (model === null || listed === undefined)
|
|
60
|
+
return undefined;
|
|
61
|
+
return store.composed({ model, declaration: declared(listed) });
|
|
62
|
+
}
|
|
63
|
+
async function carriedBack(runtime, locator, unlanded, written) {
|
|
64
|
+
const { store } = runtime;
|
|
65
|
+
const back = new Map();
|
|
66
|
+
const taken = [];
|
|
67
|
+
for (const batch of unlanded) {
|
|
68
|
+
const between = batch.between;
|
|
69
|
+
if (between === undefined)
|
|
70
|
+
continue;
|
|
71
|
+
const source = between.source.room;
|
|
72
|
+
const destination = between.destination.room;
|
|
73
|
+
const local = await store.open();
|
|
74
|
+
const arrived = (await local.pending(destination, batch.id)).state?.drafts ?? [];
|
|
75
|
+
for (const { path: to } of arrived) {
|
|
76
|
+
const record = await store.draft(destination, to);
|
|
77
|
+
const path = between.moves.find((move) => move.to === to)?.path;
|
|
78
|
+
if (record === undefined || path === undefined)
|
|
79
|
+
continue;
|
|
80
|
+
const [into, key] = source === locator ? [written, path] : [back, documentKey(source, path)];
|
|
81
|
+
const existing = into.get(key) ?? (await store.draft(source, path));
|
|
82
|
+
const held = await store.record(source);
|
|
83
|
+
const composition = held === undefined ? unheldComposition(runtime, source) : store.composed(held);
|
|
84
|
+
const parts = returnedInto(existing?.parts, record.parts, composition === undefined ? undefined : definitionsAt(composition, path));
|
|
85
|
+
if (parts === null)
|
|
86
|
+
continue;
|
|
87
|
+
taken.push({ locator: destination, path: to });
|
|
88
|
+
into.set(key, {
|
|
89
|
+
locator: source,
|
|
90
|
+
path,
|
|
91
|
+
revision: roomDraftRevision(),
|
|
92
|
+
parts,
|
|
93
|
+
returned: existing?.returned ?? null,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const records = [...back.values()];
|
|
98
|
+
const elsewhere = taken.filter((one) => one.locator !== locator);
|
|
99
|
+
const rooms = new Set([...records, ...elsewhere].map((one) => one.locator));
|
|
100
|
+
return {
|
|
101
|
+
taken: taken.filter((one) => one.locator === locator).map(({ path }) => path),
|
|
102
|
+
writes: [...rooms].map((room) => ({
|
|
103
|
+
locator: room,
|
|
104
|
+
roomDrafts: records.filter((record) => record.locator === room),
|
|
105
|
+
consumedRoomDrafts: elsewhere.filter((one) => one.locator === room).map(({ path }) => path),
|
|
106
|
+
})),
|
|
107
|
+
changes: [...rooms].map((room) => changeSet(room, {
|
|
108
|
+
drafts: [...records, ...elsewhere]
|
|
109
|
+
.filter((one) => one.locator === room)
|
|
110
|
+
.map(({ path }) => path),
|
|
111
|
+
})),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function confirmedAgain(store, locator) {
|
|
115
|
+
store.installs.change(locator, (held) => ({
|
|
116
|
+
...held,
|
|
117
|
+
confirmations: held.confirmations + 1,
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
function replayed(store, record, confirmedLayer, queue) {
|
|
121
|
+
return stepped(replaying(confirmedLayer, queue, record.locator, store.composed(record)));
|
|
122
|
+
}
|
|
123
|
+
async function overlayDiff(record, before, visible, touched) {
|
|
124
|
+
const kept = before !== undefined && before.record.key === record.key ? before.overlaid : new Set();
|
|
125
|
+
return {
|
|
126
|
+
overlay: {
|
|
127
|
+
set: await stepped(overlayOf(visible, touched)),
|
|
128
|
+
cleared: [...kept].filter((path) => !touched.has(path)),
|
|
129
|
+
},
|
|
130
|
+
touched,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function unsent(state, batch, locator) {
|
|
134
|
+
if (state === undefined)
|
|
135
|
+
return false;
|
|
136
|
+
return !leavingIn(batch, locator) || withdrawable(new Map([[batch.id, state]]))(batch);
|
|
137
|
+
}
|
|
138
|
+
async function together(runtime, local, settlements) {
|
|
139
|
+
const settled = new Set(settlements.map(({ locator }) => locator));
|
|
140
|
+
const all = [...settlements];
|
|
141
|
+
for (let wave = settlements; wave.length > 0;) {
|
|
142
|
+
const partnered = new Map();
|
|
143
|
+
for (const { locator, left } of wave) {
|
|
144
|
+
for (const batch of left) {
|
|
145
|
+
const partner = partnerOf(batch, locator);
|
|
146
|
+
if (partner === null ||
|
|
147
|
+
settled.has(partner) ||
|
|
148
|
+
!unsent((await local.pending(partner, batch.id)).state, batch, partner)) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
partnered.set(partner, [...(partnered.get(partner) ?? []), batch]);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const partners = [];
|
|
155
|
+
for (const [partner, batches] of partnered) {
|
|
156
|
+
settled.add(partner);
|
|
157
|
+
partners.push(await unpairing(runtime, local, partner, batches));
|
|
158
|
+
}
|
|
159
|
+
all.push(...partners);
|
|
160
|
+
wave = partners;
|
|
161
|
+
}
|
|
162
|
+
const answer = await local.commit({
|
|
163
|
+
rooms: all.flatMap(({ commit }) => commit.rooms),
|
|
164
|
+
writes: all.flatMap(({ commit }) => commit.writes),
|
|
165
|
+
});
|
|
166
|
+
return mergeChangeSets(all.map((one) => one.apply(answer)));
|
|
167
|
+
}
|
|
168
|
+
async function settlement(runtime, local, locator, work, record, queue, settling = {}) {
|
|
169
|
+
const { store, localSaves } = runtime;
|
|
170
|
+
const before = work.replica;
|
|
171
|
+
const view = settling.view ?? 'confirmed';
|
|
172
|
+
const previousQueue = work.queue;
|
|
173
|
+
const overrides = settling.changes;
|
|
174
|
+
const read = await sliceAt(store, record, view, queue, [
|
|
175
|
+
...(before !== undefined && before.record.key === record.key ? before.overlaid : []),
|
|
176
|
+
...(overrides?.set.map(({ path }) => path) ?? []),
|
|
177
|
+
...(overrides?.removed ?? []),
|
|
178
|
+
]);
|
|
179
|
+
const confirmedLayer = overrides === undefined
|
|
180
|
+
? read
|
|
181
|
+
: await stepped(slicingWith(read, overrides.set, overrides.removed));
|
|
182
|
+
const composition = store.composed(record);
|
|
183
|
+
const shown = queue.filter((batch) => {
|
|
184
|
+
const held = store.landed.of(locator, batch.id);
|
|
185
|
+
return (held !== undefined &&
|
|
186
|
+
Object.entries(held).some(([path, revision]) => confirmedLayer.revisions[path] !== revision));
|
|
187
|
+
});
|
|
188
|
+
const unshown = queue.filter((batch) => !shown.includes(batch));
|
|
189
|
+
const { withdrawn, kept } = await stepped(standing(confirmedLayer, unshown, withdrawable(work.states), localSaves, locator, composition));
|
|
190
|
+
const founded = kept.filter((batch) => !unshown.includes(batch));
|
|
191
|
+
const queueChanged = kept.length !== previousQueue.length || founded.length > 0;
|
|
192
|
+
const unqueued = shown.map((batch) => ({ batch, landed: true }));
|
|
193
|
+
for (const batch of withdrawn) {
|
|
194
|
+
unqueued.push({ batch, landed: await landedWhole(store, record, batch, confirmedLayer) });
|
|
195
|
+
}
|
|
196
|
+
const returning = [
|
|
197
|
+
...[...unqueued].reverse().map(({ batch, landed: held }) => ({
|
|
198
|
+
batch,
|
|
199
|
+
returned: localSaves || held ? null : returnedBy(),
|
|
200
|
+
})),
|
|
201
|
+
...(settling.leaving ?? []),
|
|
202
|
+
];
|
|
203
|
+
const written = await returnedDrafts(store, locator, work, returning, composition);
|
|
204
|
+
const carried = await carriedBack(runtime, locator, [
|
|
205
|
+
...[...unqueued].reverse().flatMap(({ batch, landed: held }) => (held ? [] : [batch])),
|
|
206
|
+
...(settling.leaving ?? []).flatMap(({ batch, returned }) => returned === null ? [] : [batch]),
|
|
207
|
+
], written);
|
|
208
|
+
const replayedLayer = await replayed(store, record, confirmedLayer, kept);
|
|
209
|
+
const { overlay } = await overlayDiff(record, before, replayedLayer.visible, replayedLayer.touched);
|
|
210
|
+
const commit = {
|
|
211
|
+
rooms: [
|
|
212
|
+
{
|
|
213
|
+
locator,
|
|
214
|
+
key: record.key,
|
|
215
|
+
record: storedRecord(record),
|
|
216
|
+
roots: record.declaration.typedSelection?.roots ?? [],
|
|
217
|
+
composed: composedOf(composition),
|
|
218
|
+
...settling.commit,
|
|
219
|
+
...(overrides === undefined
|
|
220
|
+
? {}
|
|
221
|
+
: { confirmed: { set: overrides.set, removed: overrides.removed } }),
|
|
222
|
+
overlay,
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
writes: [
|
|
226
|
+
{
|
|
227
|
+
locator,
|
|
228
|
+
queue: kept,
|
|
229
|
+
stored: previousQueue,
|
|
230
|
+
founded,
|
|
231
|
+
roomDrafts: [...written.values()],
|
|
232
|
+
consumedRoomDrafts: carried.taken,
|
|
233
|
+
},
|
|
234
|
+
...carried.writes,
|
|
235
|
+
],
|
|
236
|
+
};
|
|
237
|
+
const staying = new Set(kept.map((batch) => batch.id));
|
|
238
|
+
return {
|
|
239
|
+
locator,
|
|
240
|
+
left: previousQueue.filter((batch) => !staying.has(batch.id)),
|
|
241
|
+
commit,
|
|
242
|
+
apply: (answer) => {
|
|
243
|
+
for (const batch of previousQueue) {
|
|
244
|
+
if (!staying.has(batch.id))
|
|
245
|
+
store.landed.drop(locator, batch.id);
|
|
246
|
+
}
|
|
247
|
+
const drafts = [...written.keys(), ...carried.taken];
|
|
248
|
+
const changed = answer.changed[locator];
|
|
249
|
+
if (settling.commit?.published !== undefined ||
|
|
250
|
+
settling.commit?.refreshed === true ||
|
|
251
|
+
overrides !== undefined) {
|
|
252
|
+
confirmedAgain(store, locator);
|
|
253
|
+
}
|
|
254
|
+
return mergeChangeSets([
|
|
255
|
+
changeSet(locator, {
|
|
256
|
+
documents: changed === undefined ? [] : changed,
|
|
257
|
+
room: settling.room,
|
|
258
|
+
queue: queueChanged,
|
|
259
|
+
drafts,
|
|
260
|
+
unindexed: answer.indexed[locator] === false,
|
|
261
|
+
due: kept.length > 0 && settling.refused !== true,
|
|
262
|
+
}),
|
|
263
|
+
...carried.changes,
|
|
264
|
+
]);
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
async function unpairing(runtime, local, locator, batches) {
|
|
269
|
+
const { store, localSaves } = runtime;
|
|
270
|
+
const ids = new Set(batches.map(({ id }) => id));
|
|
271
|
+
const leaving = batches.map((batch) => ({
|
|
272
|
+
batch,
|
|
273
|
+
returned: !localSaves && leavingIn(batch, locator) ? returnedBy() : null,
|
|
274
|
+
}));
|
|
275
|
+
const work = await store.work(locator);
|
|
276
|
+
const current = work.replica;
|
|
277
|
+
if (current !== undefined) {
|
|
278
|
+
return settlement(runtime, local, locator, work, current.record, current.queue.filter((one) => !ids.has(one.id)), { leaving });
|
|
279
|
+
}
|
|
280
|
+
const queue = work.queue.filter((one) => !ids.has(one.id));
|
|
281
|
+
const written = await returnedDrafts(store, locator, work, leaving, unheldComposition(runtime, locator));
|
|
282
|
+
const carried = await carriedBack(runtime, locator, leaving.flatMap(({ batch, returned }) => (returned === null ? [] : [batch])), written);
|
|
283
|
+
return {
|
|
284
|
+
locator,
|
|
285
|
+
left: batches,
|
|
286
|
+
commit: {
|
|
287
|
+
rooms: [],
|
|
288
|
+
writes: [
|
|
289
|
+
{
|
|
290
|
+
locator,
|
|
291
|
+
queue,
|
|
292
|
+
stored: work.queue,
|
|
293
|
+
roomDrafts: [...written.values()],
|
|
294
|
+
consumedRoomDrafts: carried.taken,
|
|
295
|
+
},
|
|
296
|
+
...carried.writes,
|
|
297
|
+
],
|
|
298
|
+
},
|
|
299
|
+
apply() {
|
|
300
|
+
return mergeChangeSets([
|
|
301
|
+
changeSet(locator, {
|
|
302
|
+
queue: true,
|
|
303
|
+
drafts: [...written.keys(), ...carried.taken],
|
|
304
|
+
due: queue.length > 0,
|
|
305
|
+
}),
|
|
306
|
+
...carried.changes,
|
|
307
|
+
]);
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
async function orphaned(local) {
|
|
312
|
+
const { queued, moving } = await local.moving();
|
|
313
|
+
const halves = new Map();
|
|
314
|
+
for (const { locator, batch, state } of moving) {
|
|
315
|
+
const partner = partnerOf(batch, locator);
|
|
316
|
+
if (partner === null || queued.get(partner)?.includes(batch.id) === true)
|
|
317
|
+
continue;
|
|
318
|
+
if (unsent(state, batch, locator))
|
|
319
|
+
halves.set(locator, [...(halves.get(locator) ?? []), batch]);
|
|
320
|
+
}
|
|
321
|
+
return halves;
|
|
322
|
+
}
|
|
323
|
+
async function sweep(runtime, local) {
|
|
324
|
+
if (!runtime.socket.continuing())
|
|
325
|
+
return;
|
|
326
|
+
const halves = await orphaned(local);
|
|
327
|
+
if (halves.size === 0)
|
|
328
|
+
return;
|
|
329
|
+
const settlements = [];
|
|
330
|
+
for (const [locator, batches] of halves) {
|
|
331
|
+
settlements.push(await unpairing(runtime, local, locator, batches));
|
|
332
|
+
}
|
|
333
|
+
void runtime.store.changed(await together(runtime, local, settlements));
|
|
334
|
+
}
|
|
335
|
+
async function settled(runtime, local, settlements, steps) {
|
|
336
|
+
const set = await together(runtime, local, settlements);
|
|
337
|
+
for (const step of steps)
|
|
338
|
+
step();
|
|
339
|
+
void runtime.store.changed(set);
|
|
340
|
+
await sweep(runtime, local);
|
|
341
|
+
}
|
|
342
|
+
export function settle(runtime, locators, decide) {
|
|
343
|
+
const { store } = runtime;
|
|
344
|
+
return store.exclusive(async () => {
|
|
345
|
+
const local = await store.open();
|
|
346
|
+
const held = new Map();
|
|
347
|
+
for (const locator of locators)
|
|
348
|
+
held.set(locator, await store.work(locator));
|
|
349
|
+
const decided = await decide(held);
|
|
350
|
+
if (decided.length === 0)
|
|
351
|
+
return;
|
|
352
|
+
const settlements = [];
|
|
353
|
+
for (const { locator, record, accepted, adopted, installed, refused } of decided) {
|
|
354
|
+
const work = held.get(locator) ?? (await store.work(locator));
|
|
355
|
+
settlements.push(await settlement(runtime, local, locator, work, record, work.queue.filter((batch) => batch.id !== accepted), {
|
|
356
|
+
room: true,
|
|
357
|
+
view: installed?.refreshed === true ? 'refreshed' : 'confirmed',
|
|
358
|
+
...(installed === undefined ? {} : { commit: installed }),
|
|
359
|
+
...(adopted === undefined ? {} : { changes: adopted }),
|
|
360
|
+
...(refused === undefined ? {} : { refused }),
|
|
361
|
+
}));
|
|
362
|
+
}
|
|
363
|
+
await settled(runtime, local, settlements, decided.flatMap(({ after }) => (after === undefined ? [] : [after])));
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
export function answered(runtime, locator, head, answer) {
|
|
367
|
+
const { store, socket } = runtime;
|
|
368
|
+
return store.exclusive(async () => {
|
|
369
|
+
if (!socket.continuing())
|
|
370
|
+
return;
|
|
371
|
+
const local = await store.open();
|
|
372
|
+
const work = await store.work(locator);
|
|
373
|
+
const current = work.replica;
|
|
374
|
+
if (current === undefined || !current.queue.some((batch) => batch.id === head.id))
|
|
375
|
+
return;
|
|
376
|
+
const confirmedLayer = await sliceAt(store, current.record, 'confirmed', [head]);
|
|
377
|
+
const held = answer.kind === 'conflicted' &&
|
|
378
|
+
(await landedWhole(store, current.record, head, confirmedLayer, answer.affected));
|
|
379
|
+
if (held &&
|
|
380
|
+
partnerOf(head, locator) === null &&
|
|
381
|
+
!landed(head, confirmedLayer, store.composed(current.record))) {
|
|
382
|
+
store.landed.hold(locator, head.id, Object.fromEntries([...touchedBy([head])].map((path) => [path, confirmedLayer.revisions[path]])));
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
const returned = {
|
|
386
|
+
kind: answer.kind,
|
|
387
|
+
code: answer.code,
|
|
388
|
+
fields: answer.fields,
|
|
389
|
+
retryable: answer.retryable,
|
|
390
|
+
};
|
|
391
|
+
await settled(runtime, local, [
|
|
392
|
+
await settlement(runtime, local, locator, work, current.record, current.queue.filter((batch) => batch.id !== head.id), { leaving: [{ batch: head, returned: held ? null : returned }] }),
|
|
393
|
+
], []);
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
export function unpair(runtime) {
|
|
397
|
+
return runtime.store.durably((local) => sweep(runtime, local));
|
|
398
|
+
}
|
|
399
|
+
export async function append(runtime, appending) {
|
|
400
|
+
const { plan, files, held, after } = appending;
|
|
401
|
+
if (plan.kind === 'refused')
|
|
402
|
+
return { outcome: 'refused', ...plan.refusal };
|
|
403
|
+
const { store } = runtime;
|
|
404
|
+
const local = await store.open();
|
|
405
|
+
const rooms = [];
|
|
406
|
+
const writes = [];
|
|
407
|
+
for (const { locator, queue, saved, consumed, carried } of plan.rooms) {
|
|
408
|
+
const { replica, confirmed } = held.get(locator);
|
|
409
|
+
const { record } = replica;
|
|
410
|
+
const replayedLayer = await replayed(store, record, confirmed, queue);
|
|
411
|
+
const { overlay } = await overlayDiff(record, replica, replayedLayer.visible, replayedLayer.touched);
|
|
412
|
+
rooms.push({
|
|
413
|
+
locator,
|
|
414
|
+
key: record.key,
|
|
415
|
+
roots: record.declaration.typedSelection?.roots ?? [],
|
|
416
|
+
composed: composedOf(store.composed(record)),
|
|
417
|
+
overlay,
|
|
418
|
+
});
|
|
419
|
+
writes.push({
|
|
420
|
+
locator,
|
|
421
|
+
queue,
|
|
422
|
+
stored: replica.queue,
|
|
423
|
+
saved,
|
|
424
|
+
consumedRoomDrafts: consumed,
|
|
425
|
+
roomDrafts: carried,
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
let answer;
|
|
429
|
+
try {
|
|
430
|
+
answer = await local.commit({ rooms, writes, files, whole: true });
|
|
431
|
+
}
|
|
432
|
+
catch {
|
|
433
|
+
return { outcome: 'refused', code: 'durable-write', retryable: true };
|
|
434
|
+
}
|
|
435
|
+
const lost = answer.fenced ?? plan.rooms.find(({ locator }) => runtime.presence.lost(locator))?.locator;
|
|
436
|
+
if (lost !== undefined)
|
|
437
|
+
throw runtimeError('unknown-room', `Unknown Room ${lost}`);
|
|
438
|
+
const [saving] = plan.rooms;
|
|
439
|
+
await Promise.all([
|
|
440
|
+
store.changed(mergeChangeSets(plan.rooms.map(({ locator, consumed, carried }) => changeSet(locator, {
|
|
441
|
+
documents: answer.changed[locator] ?? [],
|
|
442
|
+
queue: true,
|
|
443
|
+
drafts: [...consumed, ...carried.map(({ path }) => path)],
|
|
444
|
+
unindexed: answer.indexed[locator] === false,
|
|
445
|
+
due: locator === saving?.locator,
|
|
446
|
+
})))),
|
|
447
|
+
after?.(),
|
|
448
|
+
]);
|
|
449
|
+
return { outcome: 'saved', identifier: plan.identifier };
|
|
450
|
+
}
|
package/dist/reach.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { AppRoom
|
|
1
|
+
import type { AppRoom } from './listing.js';
|
|
2
|
+
import type { ReadinessMessage, ReadinessPort } from './preparation.js';
|
|
3
|
+
import type { MdRuntime, RuntimeTopic } from './surface.js';
|
|
2
4
|
import type { Plan, PlanReach, QueryResult } from './query.js';
|
|
3
|
-
import type {
|
|
4
|
-
import { type SearchResult } from './search.js';
|
|
5
|
+
import type { SearchResult } from './search.js';
|
|
5
6
|
export type ReachedDocument = {
|
|
6
7
|
readonly room: string;
|
|
7
8
|
readonly path: string;
|
|
@@ -9,7 +10,7 @@ export type ReachedDocument = {
|
|
|
9
10
|
export type ReachedArea = {
|
|
10
11
|
readonly room: string;
|
|
11
12
|
readonly path: string;
|
|
12
|
-
readonly
|
|
13
|
+
readonly open: readonly string[];
|
|
13
14
|
};
|
|
14
15
|
export type PortReach = {
|
|
15
16
|
readonly rooms: readonly string[];
|
|
@@ -18,26 +19,26 @@ export type PortReach = {
|
|
|
18
19
|
readonly conversations: boolean;
|
|
19
20
|
};
|
|
20
21
|
export type Deliver = (message: unknown) => void;
|
|
21
|
-
export type
|
|
22
|
+
export type Fail = (error: unknown) => void;
|
|
23
|
+
export type Watch = (topic: RuntimeTopic, input: readonly unknown[], deliver: Deliver, fail: Fail) => () => void;
|
|
22
24
|
export type RuntimeView = {
|
|
23
25
|
md: MdRuntime;
|
|
24
26
|
watch: Watch;
|
|
25
27
|
};
|
|
26
28
|
export type NarrowedView = RuntimeView & {
|
|
27
29
|
narrow(reach: PortReach | null): void;
|
|
28
|
-
facts(port: ReadinessPort): void;
|
|
29
30
|
};
|
|
30
31
|
export type Reachable = RuntimeView & {
|
|
31
|
-
plan(input: unknown, reach: PortReach | null): Plan
|
|
32
|
+
plan(input: unknown, reach: PortReach | null): Promise<Plan>;
|
|
32
33
|
query(plan: Plan): Promise<QueryResult>;
|
|
33
|
-
watchPlan(plan: Plan, deliver:
|
|
34
|
-
search(input: unknown, reach: PortReach | null
|
|
35
|
-
watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness:
|
|
36
|
-
locked(room: string): boolean
|
|
37
|
-
lockedRooms(): readonly string[]
|
|
34
|
+
watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
|
|
35
|
+
search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
|
|
36
|
+
watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: ReadinessMessage) => void): () => void;
|
|
37
|
+
locked(room: string): Promise<boolean>;
|
|
38
|
+
lockedRooms(): Promise<readonly string[]>;
|
|
38
39
|
watchLocks(notify: () => void): () => void;
|
|
39
|
-
located(room: string, path: string, destination: string): ReachedDocument | null
|
|
40
|
-
room(locator: string): AppRoom | undefined
|
|
40
|
+
located(room: string, path: string, destination: string): Promise<ReachedDocument | null>;
|
|
41
|
+
room(locator: string): Promise<AppRoom | undefined>;
|
|
41
42
|
};
|
|
42
43
|
export declare function holds(reach: PortReach | null, room: string): boolean;
|
|
43
44
|
export declare function governs(reach: PortReach | null, room: {
|
|
@@ -50,5 +51,5 @@ export declare function governs(reach: PortReach | null, room: {
|
|
|
50
51
|
readonly selection: boolean;
|
|
51
52
|
};
|
|
52
53
|
export declare function planReach(reach: PortReach | null): PlanReach | null;
|
|
53
|
-
export declare function narrowed(runtime: Reachable, given: PortReach | null,
|
|
54
|
+
export declare function narrowed(runtime: Reachable, given: PortReach | null, port: ReadinessPort): NarrowedView;
|
|
54
55
|
//# sourceMappingURL=reach.d.ts.map
|
package/dist/reach.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../src/reach.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reach.d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