@agentshouse/mdruntime 0.1.0-cf281e8224a5d → 0.1.0-cf2df0bba5020
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 +0 -3
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +72 -158
- 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 +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +142 -72
- package/dist/adapter.d.ts +129 -63
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +0 -5
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +345 -0
- package/dist/binary.d.ts +4 -0
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +9 -2
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -19
- 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 +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 +2 -4
- package/dist/client.d.ts +21 -22
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +45 -60
- package/dist/collection.d.ts +26 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +28 -10
- 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 +20 -10
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +35 -26
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +28 -15
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +25 -14
- 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 +39 -16
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +340 -243
- 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 +3 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +47 -47
- 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 +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +8 -0
- 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 +24 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +98 -22
- 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 +21 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -8
- package/dist/install.d.ts +10 -6
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +92 -109
- package/dist/lifecycle.d.ts +2 -2
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +75 -53
- package/dist/listing.d.ts +29 -22
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +71 -79
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +74 -31
- 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 +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +12 -39
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +11 -23
- 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 +9 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +93 -32
- package/dist/messages.d.ts +17 -6
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +34 -27
- 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 -3
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -5
- package/dist/models.d.ts +4 -8
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +97 -139
- 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/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +2 -2
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +22 -10
- package/dist/outcome.d.ts +24 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +32 -2
- package/dist/overlay.d.ts +6 -2
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +37 -24
- 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 +5 -59
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +32 -122
- package/dist/preparation.d.ts +33 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +210 -92
- package/dist/presence.d.ts +58 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +231 -0
- package/dist/queries.d.ts +2 -2
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +85 -70
- 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 +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +480 -0
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +177 -33
- package/dist/react.d.ts +11 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +28 -5
- 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 +11 -4
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +5 -5
- package/dist/replica.d.ts +5 -11
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +14 -16
- 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 +275 -65
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +14 -9
- 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 +9 -10
- 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 +11 -19
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +43 -90
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +326 -223
- package/dist/saves.d.ts +4 -40
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +164 -712
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +4 -4
- package/dist/shown.d.ts +9 -5
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +94 -60
- 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 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +4 -14
- 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 +21 -6
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +59 -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 +25 -15
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +50 -18
- package/dist/stored.d.ts +32 -14
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +187 -51
- package/dist/surface.d.ts +12 -6
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +66 -34
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +126 -101
- package/dist/tables.d.ts +16 -56
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +86 -327
- 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 +4 -10
- package/dist/wire.d.ts +66 -7
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +25 -9
- 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/job.d.ts +0 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/socket/rooms.d.ts +0 -44
- package/dist/socket/rooms.d.ts.map +0 -1
- package/dist/socket/rooms.js +0 -90
- package/dist/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
package/dist/name.js
CHANGED
|
@@ -97,22 +97,18 @@ function lowerLetterOf(character) {
|
|
|
97
97
|
function codePoint(character) {
|
|
98
98
|
return WORDLIKE.test(character) ? `-u${character.codePointAt(0)?.toString(16) ?? ''}-` : '-';
|
|
99
99
|
}
|
|
100
|
-
function latin(text
|
|
100
|
+
function latin(text) {
|
|
101
101
|
return [...text]
|
|
102
102
|
.map((character) => {
|
|
103
103
|
if ((character.codePointAt(0) ?? 0) < 0x80)
|
|
104
104
|
return character;
|
|
105
105
|
const lower = character.toLowerCase();
|
|
106
|
-
|
|
107
|
-
return lower === character ? letter : `${letter.charAt(0).toUpperCase()}${letter.slice(1)}`;
|
|
106
|
+
return lowerLetterOf(lower) ?? codePoint(lower);
|
|
108
107
|
})
|
|
109
108
|
.join('');
|
|
110
109
|
}
|
|
111
|
-
export function transliterated(text) {
|
|
112
|
-
return latin(text, () => '-');
|
|
113
|
-
}
|
|
114
110
|
export function nameFrom(title) {
|
|
115
|
-
return latin(title
|
|
111
|
+
return latin(title)
|
|
116
112
|
.toLowerCase()
|
|
117
113
|
.replace(/[^a-z0-9]+/g, '-')
|
|
118
114
|
.replace(/^-+|-+$/g, '');
|
package/dist/observation.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
|
|
1
|
+
import type { PendingRoom, QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
|
|
2
|
+
import type { ReadinessShown, RoomCoverage } from './readiness.js';
|
|
3
|
+
import type { AppRoom, ListedRooms } from './listing.js';
|
|
2
4
|
export type Observation<T> = {
|
|
3
5
|
current(): T;
|
|
4
6
|
subscribe(listener: (value: T) => void): () => void;
|
|
@@ -9,15 +11,24 @@ export type KeyedResult = {
|
|
|
9
11
|
result: QueryResult;
|
|
10
12
|
keys: readonly RowKey[];
|
|
11
13
|
};
|
|
12
|
-
export type
|
|
13
|
-
changed: readonly (readonly [
|
|
14
|
-
removed: readonly
|
|
15
|
-
order: readonly
|
|
14
|
+
export type KeyedChange<K, T> = {
|
|
15
|
+
readonly changed: readonly (readonly [K, T])[];
|
|
16
|
+
readonly removed: readonly K[];
|
|
17
|
+
readonly order: readonly K[] | null;
|
|
18
|
+
};
|
|
19
|
+
export type QueryChange = KeyedChange<RowKey, QueryDocument | QueryGroup> & {
|
|
16
20
|
coverage?: QueryCoverage;
|
|
17
21
|
next?: string | null;
|
|
18
22
|
total?: number;
|
|
19
23
|
};
|
|
20
|
-
export type
|
|
24
|
+
export type ReadinessChange = {
|
|
25
|
+
readonly shown: ReadinessShown;
|
|
26
|
+
readonly rooms: KeyedChange<string, RoomCoverage>;
|
|
27
|
+
};
|
|
28
|
+
export type PendingChange = {
|
|
29
|
+
readonly pending: KeyedChange<string, PendingRoom>;
|
|
30
|
+
};
|
|
31
|
+
export type QueryMessage = KeyedResult | QueryChange | PendingChange;
|
|
21
32
|
export type Observed = {
|
|
22
33
|
observation: Observation<unknown>;
|
|
23
34
|
receive(message: unknown): void;
|
|
@@ -25,15 +36,21 @@ export type Observed = {
|
|
|
25
36
|
};
|
|
26
37
|
export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
|
|
27
38
|
export declare function whole(message: QueryMessage): message is KeyedResult;
|
|
28
|
-
export declare function
|
|
29
|
-
export declare function
|
|
30
|
-
export declare function
|
|
39
|
+
export declare function pendingChange(message: QueryMessage): message is PendingChange;
|
|
40
|
+
export declare function unchanged(change: KeyedChange<unknown, unknown>): boolean;
|
|
41
|
+
export declare function keyedChange<K, H, T>(held: ReadonlyMap<K, H>, keys: readonly K[], rows: readonly T[], same: (was: H, now: T) => boolean): KeyedChange<K, T>;
|
|
42
|
+
export declare function keyedAt<K, H, T>(held: ReadonlyMap<K, H>, at: ReadonlyMap<K, T | null>, same: (was: H, now: T) => boolean): KeyedChange<K, T> | null;
|
|
43
|
+
export declare function keyedInto<K, T>(held: Map<K, T>, change: KeyedChange<K, T>): void;
|
|
44
|
+
export declare function samePending(was: PendingRoom, now: PendingRoom): boolean;
|
|
45
|
+
export declare function appRooms({ rooms, models }: ListedRooms): readonly AppRoom[];
|
|
46
|
+
export declare function replaces(topic: string, message: unknown): boolean;
|
|
47
|
+
export declare function observed(first: unknown, stop: () => void, topic: string): Observed;
|
|
48
|
+
export declare function opened(watch: (deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void, topic: string): Promise<Observation<unknown>>;
|
|
31
49
|
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
32
50
|
export type Digest = {
|
|
33
|
-
readonly pending: string
|
|
51
|
+
readonly pending: Map<string, PendingRoom>;
|
|
34
52
|
} | {
|
|
35
|
-
readonly
|
|
36
|
-
readonly rows: ReadonlyMap<RowKey, number>;
|
|
53
|
+
readonly rows: Map<RowKey, number>;
|
|
37
54
|
readonly coverage: string;
|
|
38
55
|
readonly next: string | undefined;
|
|
39
56
|
readonly total: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"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"}
|
package/dist/observation.js
CHANGED
|
@@ -6,49 +6,198 @@ export function rowsOf(result) {
|
|
|
6
6
|
export function whole(message) {
|
|
7
7
|
return 'result' in message;
|
|
8
8
|
}
|
|
9
|
-
export function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const kept =
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
export function pendingChange(message) {
|
|
10
|
+
return 'pending' in message;
|
|
11
|
+
}
|
|
12
|
+
export function unchanged(change) {
|
|
13
|
+
return change.changed.length === 0 && change.removed.length === 0 && change.order === null;
|
|
14
|
+
}
|
|
15
|
+
export function keyedChange(held, keys, rows, same) {
|
|
16
|
+
const present = new Set(keys);
|
|
17
|
+
const changed = keys.flatMap((key, at) => {
|
|
18
|
+
const was = held.get(key);
|
|
19
|
+
return was !== undefined && same(was, rows[at]) ? [] : [[key, rows[at]]];
|
|
20
|
+
});
|
|
21
|
+
const removed = [];
|
|
22
|
+
const kept = [];
|
|
23
|
+
for (const key of held.keys())
|
|
24
|
+
(present.has(key) ? kept : removed).push(key);
|
|
25
|
+
const moved = kept.length !== keys.length || kept.some((key, at) => keys[at] !== key);
|
|
26
|
+
return { changed, removed, order: moved ? keys : null };
|
|
27
|
+
}
|
|
28
|
+
export function keyedAt(held, at, same) {
|
|
29
|
+
const changed = [];
|
|
30
|
+
const removed = [];
|
|
31
|
+
for (const [key, now] of at) {
|
|
32
|
+
const was = held.get(key);
|
|
33
|
+
if (was === undefined) {
|
|
34
|
+
if (now !== null)
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
else if (now === null)
|
|
38
|
+
removed.push(key);
|
|
39
|
+
else if (!same(was, now))
|
|
40
|
+
changed.push([key, now]);
|
|
41
|
+
}
|
|
42
|
+
return { changed, removed, order: null };
|
|
43
|
+
}
|
|
44
|
+
export function keyedInto(held, change) {
|
|
45
|
+
for (const key of change.removed)
|
|
46
|
+
held.delete(key);
|
|
47
|
+
for (const [key, row] of change.changed)
|
|
48
|
+
held.set(key, row);
|
|
49
|
+
if (change.order === null)
|
|
50
|
+
return;
|
|
51
|
+
const placed = change.order.map((key) => [key, held.get(key)]);
|
|
52
|
+
held.clear();
|
|
53
|
+
for (const [key, row] of placed)
|
|
54
|
+
held.set(key, row);
|
|
55
|
+
}
|
|
56
|
+
export function samePending(was, now) {
|
|
57
|
+
return was.awaits === now.awaits;
|
|
58
|
+
}
|
|
59
|
+
function keyedRows(keys, rows) {
|
|
60
|
+
const held = new Map(keys.map((key, at) => [key, rows[at]]));
|
|
61
|
+
let shown = rows;
|
|
62
|
+
return {
|
|
63
|
+
rows: () => shown,
|
|
64
|
+
apply(change) {
|
|
65
|
+
if (unchanged(change))
|
|
66
|
+
return shown;
|
|
67
|
+
keyedInto(held, change);
|
|
68
|
+
shown = [...held.values()];
|
|
69
|
+
return shown;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function heldModels(held, sent) {
|
|
74
|
+
return new Map(Object.entries(sent).map(([key, types]) => [key, held.get(key) ?? types]));
|
|
75
|
+
}
|
|
76
|
+
function namedModels(models, rooms) {
|
|
77
|
+
const named = new Set(rooms.flatMap(({ model, typedSelection }) => [model.types, typedSelection?.model.types]));
|
|
78
|
+
return new Map([...models].filter(([, types]) => named.has(types)));
|
|
79
|
+
}
|
|
80
|
+
function typed(model, models) {
|
|
81
|
+
return model.types === null ? model : { ...model, types: models.get(model.types) };
|
|
82
|
+
}
|
|
83
|
+
function appRoom({ model, typedSelection, ...room }, models) {
|
|
84
|
+
return {
|
|
85
|
+
...room,
|
|
86
|
+
model: typed(model, models),
|
|
87
|
+
typedSelection: typedSelection === null
|
|
88
|
+
? null
|
|
89
|
+
: { roots: typedSelection.roots, model: typed(typedSelection.model, models) },
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export function appRooms({ rooms, models }) {
|
|
93
|
+
const held = heldModels(new Map(), models);
|
|
94
|
+
return rooms.map((room) => appRoom(room, held));
|
|
95
|
+
}
|
|
96
|
+
function keyedRooms(first) {
|
|
97
|
+
let models = new Map();
|
|
98
|
+
let held = keyedRows([], []);
|
|
99
|
+
const whole = (listed) => {
|
|
100
|
+
models = heldModels(models, listed.models);
|
|
101
|
+
held = keyedRows(listed.rooms.map(({ locator }) => locator), listed.rooms.map((room) => appRoom(room, models)));
|
|
102
|
+
return held.rows();
|
|
103
|
+
};
|
|
104
|
+
return {
|
|
105
|
+
value: whole(first),
|
|
106
|
+
next(message) {
|
|
107
|
+
if ('rooms' in message)
|
|
108
|
+
return whole(message);
|
|
109
|
+
const change = message;
|
|
110
|
+
const sent = heldModels(models, change.models);
|
|
111
|
+
const rows = held.apply({
|
|
112
|
+
changed: change.changed.map(([locator, room]) => [locator, appRoom(room, sent)]),
|
|
113
|
+
removed: change.removed,
|
|
114
|
+
order: change.order,
|
|
115
|
+
});
|
|
116
|
+
models = namedModels(new Map([...models, ...sent]), rows);
|
|
117
|
+
return rows;
|
|
118
|
+
},
|
|
29
119
|
};
|
|
120
|
+
}
|
|
121
|
+
function covered(readiness) {
|
|
122
|
+
return keyedRows(readiness.coverage.rooms.map(({ room }) => room), readiness.coverage.rooms);
|
|
123
|
+
}
|
|
124
|
+
function keyedReadiness(first) {
|
|
125
|
+
let held = covered(first);
|
|
30
126
|
return {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
127
|
+
value: first,
|
|
128
|
+
next(message) {
|
|
129
|
+
if (!('shown' in message)) {
|
|
130
|
+
held = covered(message);
|
|
131
|
+
return message;
|
|
132
|
+
}
|
|
133
|
+
const { shown, rooms } = message;
|
|
134
|
+
return { ...shown, coverage: { ...shown.coverage, rooms: held.apply(rooms) } };
|
|
135
|
+
},
|
|
35
136
|
};
|
|
36
137
|
}
|
|
138
|
+
function awaiting(pending) {
|
|
139
|
+
return keyedRows(pending.map(({ room }) => room), pending);
|
|
140
|
+
}
|
|
37
141
|
function keyedResult(first) {
|
|
38
|
-
let
|
|
142
|
+
let result = first.result;
|
|
143
|
+
let rows = keyedRows([], []);
|
|
144
|
+
let pending = awaiting([]);
|
|
145
|
+
const take = ({ result: next, keys }) => {
|
|
146
|
+
result = next;
|
|
147
|
+
if ('pending' in next)
|
|
148
|
+
pending = awaiting(next.pending);
|
|
149
|
+
else
|
|
150
|
+
rows = keyedRows(keys, rowsOf(next));
|
|
151
|
+
return result;
|
|
152
|
+
};
|
|
153
|
+
take(first);
|
|
39
154
|
return {
|
|
40
155
|
value: first.result,
|
|
41
156
|
next(message) {
|
|
42
|
-
|
|
43
|
-
|
|
157
|
+
const asked = message;
|
|
158
|
+
if (whole(asked))
|
|
159
|
+
return take(asked);
|
|
160
|
+
if (pendingChange(asked)) {
|
|
161
|
+
if ('pending' in result)
|
|
162
|
+
result = { pending: pending.apply(asked.pending) };
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
if ('pending' in result)
|
|
166
|
+
return result;
|
|
167
|
+
const kept = rows.apply(asked);
|
|
168
|
+
const coverage = asked.coverage ?? result.coverage;
|
|
169
|
+
const next = asked.next === undefined ? result.next : (asked.next ?? undefined);
|
|
170
|
+
const total = asked.total ?? result.total;
|
|
171
|
+
const window = {
|
|
172
|
+
...(next === undefined ? {} : { next }),
|
|
173
|
+
...(total === undefined ? {} : { total }),
|
|
174
|
+
};
|
|
175
|
+
result =
|
|
176
|
+
'groups' in result
|
|
177
|
+
? { groups: kept, coverage, ...window }
|
|
178
|
+
: { documents: kept, coverage, ...window };
|
|
179
|
+
return result;
|
|
44
180
|
},
|
|
45
181
|
};
|
|
46
182
|
}
|
|
183
|
+
const FOLDS = {
|
|
184
|
+
query: (first) => keyedResult(first),
|
|
185
|
+
rooms: (first) => keyedRooms(first),
|
|
186
|
+
readiness: (first) => keyedReadiness(first),
|
|
187
|
+
};
|
|
188
|
+
const WHOLE = {
|
|
189
|
+
query: (message) => whole(message),
|
|
190
|
+
rooms: (message) => 'rooms' in message,
|
|
191
|
+
readiness: (message) => !('shown' in message),
|
|
192
|
+
};
|
|
193
|
+
export function replaces(topic, message) {
|
|
194
|
+
return WHOLE[topic]?.(message) ?? true;
|
|
195
|
+
}
|
|
47
196
|
function replaced(first) {
|
|
48
197
|
return { value: first, next: (message) => message };
|
|
49
198
|
}
|
|
50
|
-
export function observed(first, stop,
|
|
51
|
-
const reducer =
|
|
199
|
+
export function observed(first, stop, topic) {
|
|
200
|
+
const reducer = (FOLDS[topic] ?? replaced)(first);
|
|
52
201
|
let value = reducer.value;
|
|
53
202
|
let open = true;
|
|
54
203
|
const listeners = new Set();
|
|
@@ -86,7 +235,7 @@ export function observed(first, stop, keyed) {
|
|
|
86
235
|
end,
|
|
87
236
|
};
|
|
88
237
|
}
|
|
89
|
-
export function opened(watch,
|
|
238
|
+
export function opened(watch, topic) {
|
|
90
239
|
return new Promise((resolve, reject) => {
|
|
91
240
|
let handle;
|
|
92
241
|
let stop = () => { };
|
|
@@ -95,7 +244,7 @@ export function opened(watch, keyed) {
|
|
|
95
244
|
handle.receive(message);
|
|
96
245
|
return;
|
|
97
246
|
}
|
|
98
|
-
handle = observed(message, () => stop(),
|
|
247
|
+
handle = observed(message, () => stop(), topic);
|
|
99
248
|
resolve(handle.observation);
|
|
100
249
|
}, (error) => {
|
|
101
250
|
if (handle !== undefined)
|
|
@@ -108,7 +257,7 @@ export function opened(watch, keyed) {
|
|
|
108
257
|
export function observing(watch) {
|
|
109
258
|
return (topic, ...input) => opened((deliver, fail) => watch(topic, input, (message) => {
|
|
110
259
|
deliver(structuredClone(message));
|
|
111
|
-
}, fail), topic
|
|
260
|
+
}, fail), topic);
|
|
112
261
|
}
|
|
113
262
|
export function hashed(text) {
|
|
114
263
|
let first = 0xdeadbeef;
|
|
@@ -129,10 +278,9 @@ function rowDigest(row) {
|
|
|
129
278
|
}
|
|
130
279
|
export function digestOf({ result, keys }) {
|
|
131
280
|
if ('pending' in result)
|
|
132
|
-
return { pending:
|
|
281
|
+
return { pending: new Map(result.pending.map((room) => [room.room, room])) };
|
|
133
282
|
const rows = rowsOf(result);
|
|
134
283
|
return {
|
|
135
|
-
keys,
|
|
136
284
|
rows: new Map(keys.map((key, index) => [key, rowDigest(rows[index])])),
|
|
137
285
|
coverage: JSON.stringify(result.coverage),
|
|
138
286
|
next: result.next,
|
|
@@ -140,16 +288,22 @@ export function digestOf({ result, keys }) {
|
|
|
140
288
|
};
|
|
141
289
|
}
|
|
142
290
|
export function digestApplied(digest, message) {
|
|
143
|
-
if (whole(message)
|
|
144
|
-
return
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
291
|
+
if (whole(message))
|
|
292
|
+
return digestOf(message);
|
|
293
|
+
if (pendingChange(message)) {
|
|
294
|
+
if ('pending' in digest)
|
|
295
|
+
keyedInto(digest.pending, message.pending);
|
|
296
|
+
return digest;
|
|
297
|
+
}
|
|
298
|
+
if ('pending' in digest)
|
|
299
|
+
return digest;
|
|
300
|
+
keyedInto(digest.rows, {
|
|
301
|
+
changed: message.changed.map(([key, row]) => [key, rowDigest(row)]),
|
|
302
|
+
removed: message.removed,
|
|
303
|
+
order: message.order,
|
|
304
|
+
});
|
|
150
305
|
return {
|
|
151
|
-
|
|
152
|
-
rows,
|
|
306
|
+
rows: digest.rows,
|
|
153
307
|
coverage: message.coverage === undefined ? digest.coverage : JSON.stringify(message.coverage),
|
|
154
308
|
next: message.next === undefined ? digest.next : (message.next ?? undefined),
|
|
155
309
|
total: message.total ?? digest.total,
|
|
@@ -157,35 +311,18 @@ export function digestApplied(digest, message) {
|
|
|
157
311
|
}
|
|
158
312
|
export function changeOf(previous, next) {
|
|
159
313
|
const after = next.result;
|
|
160
|
-
if ('pending' in previous
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
: next;
|
|
314
|
+
if ('pending' in previous && 'pending' in after) {
|
|
315
|
+
const pending = keyedChange(previous.pending, after.pending.map(({ room }) => room), after.pending, samePending);
|
|
316
|
+
return unchanged(pending) ? null : { pending };
|
|
164
317
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
const row = later[index];
|
|
170
|
-
if (previous.rows.get(key) !== rowDigest(row))
|
|
171
|
-
changed.push([key, row]);
|
|
172
|
-
});
|
|
173
|
-
const removed = previous.keys.filter((key) => !present.has(key));
|
|
174
|
-
const kept = previous.keys.filter((key) => present.has(key));
|
|
175
|
-
const moved = kept.length !== next.keys.length || kept.some((key, index) => next.keys[index] !== key);
|
|
176
|
-
const coverage = JSON.stringify(after.coverage);
|
|
177
|
-
const covered = previous.coverage !== coverage;
|
|
318
|
+
if ('pending' in previous || 'pending' in after)
|
|
319
|
+
return next;
|
|
320
|
+
const rows = keyedChange(previous.rows, next.keys, rowsOf(after), (was, row) => was === rowDigest(row));
|
|
321
|
+
const covered = previous.coverage !== JSON.stringify(after.coverage);
|
|
178
322
|
const framing = reframed(previous, after);
|
|
179
|
-
if (
|
|
323
|
+
if (unchanged(rows) && !covered && framing === null)
|
|
180
324
|
return null;
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
changed,
|
|
184
|
-
removed,
|
|
185
|
-
order: moved ? next.keys : null,
|
|
186
|
-
...(covered ? { coverage: after.coverage } : {}),
|
|
187
|
-
...framing,
|
|
188
|
-
};
|
|
325
|
+
return { ...rows, ...(covered ? { coverage: after.coverage } : {}), ...framing };
|
|
189
326
|
}
|
|
190
327
|
function reframed(before, after) {
|
|
191
328
|
const next = before.next === after.next ? {} : { next: after.next ?? null };
|
package/dist/online.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Authorization } from './adapter.js';
|
|
2
|
+
import type { Runtime } from './runtime.js';
|
|
3
|
+
export declare function offline(runtime: Runtime): Promise<boolean>;
|
|
4
|
+
export declare function askedOnline<T extends {
|
|
5
|
+
readonly kind: string;
|
|
6
|
+
}>(runtime: Runtime, ask: (authorization: Authorization) => Promise<T>): Promise<T | null>;
|
|
7
|
+
//# sourceMappingURL=online.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"online.d.ts","sourceRoot":"","sources":["../src/online.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,wBAAsB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAOhE;AAED,wBAAsB,WAAW,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACnE,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,GAChD,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAgBnB"}
|
package/dist/online.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { connectionNow } from './preparation.js';
|
|
2
|
+
import { refuse } from './refusal.js';
|
|
3
|
+
export async function offline(runtime) {
|
|
4
|
+
const { socket } = runtime;
|
|
5
|
+
return (socket.closed() ||
|
|
6
|
+
socket.session.now().refusal !== null ||
|
|
7
|
+
(await connectionNow(runtime)) !== 'connected');
|
|
8
|
+
}
|
|
9
|
+
export async function askedOnline(runtime, ask) {
|
|
10
|
+
const { socket } = runtime;
|
|
11
|
+
try {
|
|
12
|
+
await socket.authorize();
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const { closed, authorization, refusal } = socket.session.now();
|
|
18
|
+
if (closed || authorization === undefined || refusal !== null)
|
|
19
|
+
return null;
|
|
20
|
+
try {
|
|
21
|
+
const answer = await ask(authorization);
|
|
22
|
+
if (answer.kind === 'revoked-authorization')
|
|
23
|
+
await refuse(runtime, 'revoked-authorization');
|
|
24
|
+
return answer;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
package/dist/opened.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ export type OpenedFiles = {
|
|
|
18
18
|
find(name: OpenedName): Promise<KeptBinary | null>;
|
|
19
19
|
fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
|
|
20
20
|
};
|
|
21
|
-
export declare function openedFiles(database: RuntimeDatabase,
|
|
21
|
+
export declare function openedFiles(database: RuntimeDatabase, lost: (locator: string) => boolean): OpenedFiles;
|
|
22
22
|
//# sourceMappingURL=opened.d.ts.map
|
package/dist/opened.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opened.d.ts","sourceRoot":"","sources":["../src/opened.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAErF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAEhF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACnD,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACjF,CAAC;AAsBF,wBAAgB,WAAW,CACzB,QAAQ,EAAE,eAAe,EACzB,
|
|
1
|
+
{"version":3,"file":"opened.d.ts","sourceRoot":"","sources":["../src/opened.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAErF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAEhF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACnD,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACjF,CAAC;AAsBF,wBAAgB,WAAW,CACzB,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,GACjC,WAAW,CAsFb"}
|
package/dist/opened.js
CHANGED
|
@@ -20,7 +20,7 @@ function taken(chunks, size) {
|
|
|
20
20
|
}
|
|
21
21
|
return part;
|
|
22
22
|
}
|
|
23
|
-
export function openedFiles(database,
|
|
23
|
+
export function openedFiles(database, lost) {
|
|
24
24
|
const fetching = new Map();
|
|
25
25
|
async function find(name) {
|
|
26
26
|
const held = await database.ask({ kind: 'opened.find', ...name });
|
|
@@ -41,7 +41,7 @@ export function openedFiles(database, fenced) {
|
|
|
41
41
|
part += 1;
|
|
42
42
|
};
|
|
43
43
|
try {
|
|
44
|
-
if (
|
|
44
|
+
if (lost(name.locator) ||
|
|
45
45
|
!(await database.ask({ kind: 'opened.begin', key, ...name, mediaType }))) {
|
|
46
46
|
throw new Error();
|
|
47
47
|
}
|
package/dist/opening.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAsCxF"}
|
package/dist/opening.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { conversationsOpened } from './conversation.js';
|
|
2
2
|
import { detectStorageLoss, nextGeneration, refusedForSpace } from './durability.js';
|
|
3
|
+
import { uncaught } from './failure.js';
|
|
3
4
|
import { sweep } from './install.js';
|
|
4
5
|
import { eraseFenced } from './lost.js';
|
|
5
6
|
import { prepare } from './preparation.js';
|
|
7
|
+
import { unpair } from './queue.js';
|
|
6
8
|
import { emitRooms, emitStorageLoss, statusShown } from './shown.js';
|
|
7
9
|
export async function open(runtime, opened) {
|
|
8
|
-
const { store, socket,
|
|
10
|
+
const { store, socket, shell, conversations, build } = runtime;
|
|
9
11
|
if (socket.closed())
|
|
10
12
|
throw new Error('runtime closed');
|
|
11
13
|
const interrupted = await opened.fences();
|
|
@@ -23,7 +25,7 @@ export async function open(runtime, opened) {
|
|
|
23
25
|
}
|
|
24
26
|
const held = await opened.opened();
|
|
25
27
|
store.device.set({
|
|
26
|
-
|
|
28
|
+
completedWhenOpened: (await opened.facts(['lastCompleted'])).lastCompleted !== null,
|
|
27
29
|
});
|
|
28
30
|
try {
|
|
29
31
|
await opened.demote();
|
|
@@ -40,18 +42,28 @@ export async function open(runtime, opened) {
|
|
|
40
42
|
await conversationsOpened(conversations, opened);
|
|
41
43
|
if (interrupted.length > 0) {
|
|
42
44
|
queueMicrotask(() => {
|
|
43
|
-
void eraseFenced(runtime, interrupted).catch(
|
|
44
|
-
journal.record('erasure failed');
|
|
45
|
-
});
|
|
45
|
+
void eraseFenced(runtime, interrupted).catch(uncaught);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
+
await factsKept(runtime, opened);
|
|
48
49
|
statusShown(runtime);
|
|
49
50
|
prepare(runtime);
|
|
50
51
|
emitRooms(runtime);
|
|
51
|
-
void
|
|
52
|
-
.exclusive(() => runtime.unpair(opened))
|
|
53
|
-
.catch(() => {
|
|
54
|
-
journal.record('unpair failed');
|
|
55
|
-
});
|
|
52
|
+
void unpair(runtime).catch(uncaught);
|
|
56
53
|
return opened;
|
|
57
54
|
}
|
|
55
|
+
async function factsKept({ socket, adopt }, opened) {
|
|
56
|
+
const { session } = socket;
|
|
57
|
+
const { unstored } = session.now();
|
|
58
|
+
if (unstored !== null) {
|
|
59
|
+
queueMicrotask(() => {
|
|
60
|
+
void adopt(unstored).catch(uncaught);
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const { capabilities, queriesOnly } = await opened.facts(['capabilities', 'queriesOnly']);
|
|
65
|
+
if (queriesOnly.length > 0 && !session.now().roomsNamed)
|
|
66
|
+
session.set({ queriesOnly });
|
|
67
|
+
if (capabilities.length > 0)
|
|
68
|
+
socket.readyFromStore();
|
|
69
|
+
}
|