@inflatable-cookie/longhorn 0.1.0
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/LICENSE +21 -0
- package/README.md +38 -0
- package/package.json +205 -0
- package/src/agent-control/index.ts +20 -0
- package/src/agent-control/inject.ts +4 -0
- package/src/agent-control/shim.ts +722 -0
- package/src/bridge/direct.ts +22 -0
- package/src/bridge/generated/fields.ts +32 -0
- package/src/bridge/generated/protocol.ts +218 -0
- package/src/bridge/generated/variant-fields.ts +10 -0
- package/src/bridge/index.ts +15 -0
- package/src/bridge/job.ts +51 -0
- package/src/bridge/loopback.ts +84 -0
- package/src/bridge/operation.ts +166 -0
- package/src/bridge/router.ts +71 -0
- package/src/bridge/runtime/connection.ts +318 -0
- package/src/bridge/runtime/policy.ts +89 -0
- package/src/bridge/runtime/retry.ts +60 -0
- package/src/bridge/runtime.ts +3 -0
- package/src/bridge/session.ts +67 -0
- package/src/bridge/stream/connection.ts +146 -0
- package/src/bridge/stream/source.ts +61 -0
- package/src/bridge/stream/tracker.ts +109 -0
- package/src/bridge/stream.ts +6 -0
- package/src/bridge/supervision.ts +204 -0
- package/src/bridge/validation/base.ts +164 -0
- package/src/bridge/validation/jobs.ts +105 -0
- package/src/bridge/validation/negotiation.ts +242 -0
- package/src/bridge/validation/operations.ts +213 -0
- package/src/bridge/validation/streams.ts +47 -0
- package/src/bridge/validation.ts +5 -0
- package/src/commands/client.ts +124 -0
- package/src/commands/controller.ts +411 -0
- package/src/commands/generated/fields.ts +43 -0
- package/src/commands/generated/protocol.ts +876 -0
- package/src/commands/generated/variant-fields.ts +88 -0
- package/src/commands/index.ts +13 -0
- package/src/commands/keyboard.ts +361 -0
- package/src/commands/ports.ts +82 -0
- package/src/commands/projectors.ts +306 -0
- package/src/commands/validation.ts +444 -0
- package/src/config/client.ts +215 -0
- package/src/config/generated/base.ts +714 -0
- package/src/config/generated/fields.ts +54 -0
- package/src/config/generated/label-template.ts +14 -0
- package/src/config/generated/labels.ts +30 -0
- package/src/config/generated/protocol.ts +3 -0
- package/src/config/generated/restore.ts +658 -0
- package/src/config/generated/variant-fields.ts +129 -0
- package/src/config/index.ts +12 -0
- package/src/config/names.ts +19 -0
- package/src/config/validation/commands.ts +155 -0
- package/src/config/validation/outcomes.ts +243 -0
- package/src/config/validation/primitives.ts +174 -0
- package/src/config/validation/projection.ts +351 -0
- package/src/config/validation.ts +7 -0
- package/src/core/connection.ts +252 -0
- package/src/core/index.ts +2 -0
- package/src/core/transport.ts +24 -0
- package/src/history/client.ts +65 -0
- package/src/history/controller.ts +385 -0
- package/src/history/direct.ts +21 -0
- package/src/history/generated/fields.ts +18 -0
- package/src/history/generated/protocol.ts +389 -0
- package/src/history/generated/variant-fields.ts +27 -0
- package/src/history/index.ts +13 -0
- package/src/history/ports.ts +31 -0
- package/src/history/serialized.ts +38 -0
- package/src/history/validation.ts +334 -0
- package/src/history-tree/client.ts +16 -0
- package/src/history-tree/controller.ts +199 -0
- package/src/history-tree/direct.ts +3 -0
- package/src/history-tree/generated/fields.ts +26 -0
- package/src/history-tree/generated/protocol.ts +711 -0
- package/src/history-tree/generated/variant-fields.ts +39 -0
- package/src/history-tree/index.ts +13 -0
- package/src/history-tree/ports.ts +43 -0
- package/src/history-tree/serialized.ts +15 -0
- package/src/history-tree/validation.ts +269 -0
- package/src/layout/generated/protocol.ts +289 -0
- package/src/layout/index.ts +4 -0
- package/src/layout/ratio.ts +22 -0
- package/src/layout/validation.ts +110 -0
- package/src/layout/visibility.ts +30 -0
- package/src/licence/client.ts +32 -0
- package/src/licence/controller.ts +301 -0
- package/src/licence/direct.ts +3 -0
- package/src/licence/generated/fields.ts +17 -0
- package/src/licence/generated/key-conformance.json +42 -0
- package/src/licence/generated/protocol.ts +249 -0
- package/src/licence/generated/variant-fields.ts +34 -0
- package/src/licence/index.ts +14 -0
- package/src/licence/key.ts +125 -0
- package/src/licence/ports.ts +39 -0
- package/src/licence/serialized.ts +13 -0
- package/src/licence/validation.ts +226 -0
- package/src/native-content/client.ts +474 -0
- package/src/native-content/direct.ts +16 -0
- package/src/native-content/generated/fields.ts +32 -0
- package/src/native-content/generated/protocol.ts +498 -0
- package/src/native-content/generated/variant-fields.ts +77 -0
- package/src/native-content/index.ts +12 -0
- package/src/native-content/ports.ts +46 -0
- package/src/native-content/serialized.ts +50 -0
- package/src/native-content/validation/base.ts +194 -0
- package/src/native-content/validation/messages.ts +192 -0
- package/src/native-content/validation/state.ts +404 -0
- package/src/native-content/validation.ts +7 -0
- package/src/notifications/client.ts +106 -0
- package/src/notifications/controller.ts +240 -0
- package/src/notifications/direct.ts +12 -0
- package/src/notifications/generated/fields.ts +19 -0
- package/src/notifications/generated/labels.ts +20 -0
- package/src/notifications/generated/protocol.ts +522 -0
- package/src/notifications/generated/variant-fields.ts +37 -0
- package/src/notifications/index.ts +16 -0
- package/src/notifications/ports.ts +22 -0
- package/src/notifications/serialized.ts +27 -0
- package/src/notifications/toast.ts +41 -0
- package/src/notifications/tone.ts +27 -0
- package/src/notifications/validation.ts +246 -0
- package/src/operation/bridge.ts +168 -0
- package/src/operation/client.ts +167 -0
- package/src/operation/controller.ts +321 -0
- package/src/operation/direct.ts +15 -0
- package/src/operation/generated/fields.ts +20 -0
- package/src/operation/generated/labels.ts +15 -0
- package/src/operation/generated/protocol.ts +762 -0
- package/src/operation/generated/variant-fields.ts +60 -0
- package/src/operation/index.ts +14 -0
- package/src/operation/ports.ts +29 -0
- package/src/operation/serialized.ts +39 -0
- package/src/operation/validation.ts +479 -0
- package/src/settings/client.ts +142 -0
- package/src/settings/connection.ts +246 -0
- package/src/settings/generated/fields.ts +34 -0
- package/src/settings/generated/protocol.ts +668 -0
- package/src/settings/generated/variant-fields.ts +26 -0
- package/src/settings/index.ts +12 -0
- package/src/settings/names.ts +8 -0
- package/src/settings/registry.ts +141 -0
- package/src/settings/validation/authority.ts +66 -0
- package/src/settings/validation/command.ts +165 -0
- package/src/settings/validation/error.ts +33 -0
- package/src/settings/validation/primitives.ts +203 -0
- package/src/settings/validation/projection.ts +50 -0
- package/src/settings/validation/registry.ts +170 -0
- package/src/settings/validation.ts +4 -0
- package/src/surface-transfer/client.ts +54 -0
- package/src/surface-transfer/generated/fields.ts +12 -0
- package/src/surface-transfer/generated/protocol.ts +61 -0
- package/src/surface-transfer/generated/variant-fields.ts +30 -0
- package/src/surface-transfer/index.ts +9 -0
- package/src/surface-transfer/validation.ts +209 -0
- package/src/surfaces/client.ts +140 -0
- package/src/surfaces/generated/fields.ts +19 -0
- package/src/surfaces/generated/protocol.ts +217 -0
- package/src/surfaces/generated/variant-fields.ts +42 -0
- package/src/surfaces/index.ts +9 -0
- package/src/surfaces/validation.ts +199 -0
- package/src/transfer/client.ts +133 -0
- package/src/transfer/connection.ts +87 -0
- package/src/transfer/generated/fields.ts +23 -0
- package/src/transfer/generated/protocol.ts +171 -0
- package/src/transfer/generated/variant-fields.ts +45 -0
- package/src/transfer/index.ts +11 -0
- package/src/transfer/payload.ts +71 -0
- package/src/transfer/validation.ts +282 -0
- package/src/update/client.ts +29 -0
- package/src/update/controller.ts +255 -0
- package/src/update/direct.ts +3 -0
- package/src/update/generated/fields.ts +14 -0
- package/src/update/generated/protocol.ts +238 -0
- package/src/update/generated/variant-fields.ts +44 -0
- package/src/update/index.ts +14 -0
- package/src/update/ports.ts +36 -0
- package/src/update/serialized.ts +12 -0
- package/src/update/validation.ts +191 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import type { Unlisten } from "./transport.ts";
|
|
2
|
+
|
|
3
|
+
export type SnapshotEventAction =
|
|
4
|
+
| { readonly kind: "ignore" }
|
|
5
|
+
| { readonly kind: "refresh" }
|
|
6
|
+
| { readonly kind: "snapshot"; readonly value: unknown };
|
|
7
|
+
|
|
8
|
+
export type ConnectionFailurePhase =
|
|
9
|
+
| "registration"
|
|
10
|
+
| "event"
|
|
11
|
+
| "snapshot"
|
|
12
|
+
| "unlisten";
|
|
13
|
+
|
|
14
|
+
export interface ConnectionFailure {
|
|
15
|
+
readonly phase: ConnectionFailurePhase;
|
|
16
|
+
readonly error: unknown;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type ConnectionFailureReporter = (
|
|
20
|
+
failure: ConnectionFailure,
|
|
21
|
+
) => void;
|
|
22
|
+
|
|
23
|
+
export interface CheckedSnapshotConnectionOptions<Snapshot> {
|
|
24
|
+
readonly listen: (
|
|
25
|
+
listener: (payload: unknown) => void,
|
|
26
|
+
) => Promise<Unlisten>;
|
|
27
|
+
readonly loadSnapshot: () => Promise<unknown>;
|
|
28
|
+
readonly validateSnapshot: (value: unknown) => Snapshot;
|
|
29
|
+
readonly handleEvent: (
|
|
30
|
+
payload: unknown,
|
|
31
|
+
current: Snapshot | undefined,
|
|
32
|
+
) => SnapshotEventAction;
|
|
33
|
+
readonly isNewer: (
|
|
34
|
+
candidate: Snapshot,
|
|
35
|
+
current: Snapshot | undefined,
|
|
36
|
+
) => boolean;
|
|
37
|
+
readonly onSnapshot?: (snapshot: Snapshot) => void;
|
|
38
|
+
readonly onFailure?: ConnectionFailureReporter;
|
|
39
|
+
readonly disposedBeforeReadyError?: () => Error;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class CheckedSnapshotConnection<Snapshot> {
|
|
43
|
+
readonly ready: Promise<Snapshot | undefined>;
|
|
44
|
+
|
|
45
|
+
readonly #options: CheckedSnapshotConnectionOptions<Snapshot>;
|
|
46
|
+
readonly #failures: ConnectionFailure[] = [];
|
|
47
|
+
#current: Snapshot | undefined;
|
|
48
|
+
#unlisten: Unlisten | undefined;
|
|
49
|
+
#cleanup: Promise<void> | undefined;
|
|
50
|
+
#pump: Promise<void> | undefined;
|
|
51
|
+
#registered = false;
|
|
52
|
+
#refreshPending = false;
|
|
53
|
+
#disposed = false;
|
|
54
|
+
|
|
55
|
+
constructor(options: CheckedSnapshotConnectionOptions<Snapshot>) {
|
|
56
|
+
this.#options = options;
|
|
57
|
+
this.ready = this.#start();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
current(): Snapshot | undefined {
|
|
61
|
+
return this.#current;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
failures(): readonly ConnectionFailure[] {
|
|
65
|
+
return [...this.#failures];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async dispose(): Promise<void> {
|
|
69
|
+
this.#disposed = true;
|
|
70
|
+
|
|
71
|
+
let cleanupError: unknown;
|
|
72
|
+
try {
|
|
73
|
+
await this.#closeListener();
|
|
74
|
+
} catch (error) {
|
|
75
|
+
cleanupError = error;
|
|
76
|
+
this.#recordFailure("unlisten", error);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let readyError: unknown;
|
|
80
|
+
try {
|
|
81
|
+
await this.ready;
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (this.#failures.some((failure) => failure.error === error)) {
|
|
84
|
+
readyError = error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (cleanupError === undefined) {
|
|
89
|
+
try {
|
|
90
|
+
await this.#closeListener();
|
|
91
|
+
} catch (error) {
|
|
92
|
+
cleanupError = error;
|
|
93
|
+
this.#recordFailure("unlisten", error);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (cleanupError !== undefined) {
|
|
98
|
+
throw cleanupError;
|
|
99
|
+
}
|
|
100
|
+
if (readyError !== undefined) {
|
|
101
|
+
throw readyError;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async #start(): Promise<Snapshot | undefined> {
|
|
106
|
+
let unlisten: Unlisten;
|
|
107
|
+
try {
|
|
108
|
+
unlisten = await this.#options.listen((payload) => {
|
|
109
|
+
this.#handleEvent(payload);
|
|
110
|
+
});
|
|
111
|
+
} catch (error) {
|
|
112
|
+
this.#recordFailure("registration", error);
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this.#unlisten = unlisten;
|
|
117
|
+
this.#registered = true;
|
|
118
|
+
|
|
119
|
+
if (this.#disposed) {
|
|
120
|
+
await this.#closeAfterFailure();
|
|
121
|
+
const disposedError = this.#options.disposedBeforeReadyError?.();
|
|
122
|
+
if (disposedError !== undefined) {
|
|
123
|
+
throw disposedError;
|
|
124
|
+
}
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
this.#refreshPending = true;
|
|
129
|
+
try {
|
|
130
|
+
await this.#synchronize();
|
|
131
|
+
} catch (error) {
|
|
132
|
+
this.#recordFailure("snapshot", error);
|
|
133
|
+
await this.#closeAfterFailure();
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (this.#disposed) {
|
|
138
|
+
await this.#closeAfterFailure();
|
|
139
|
+
const disposedError = this.#options.disposedBeforeReadyError?.();
|
|
140
|
+
if (disposedError !== undefined) {
|
|
141
|
+
throw disposedError;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return this.#current;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
#handleEvent(payload: unknown): void {
|
|
149
|
+
if (this.#disposed || this.#failures.length > 0) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
const action = this.#options.handleEvent(payload, this.#current);
|
|
155
|
+
switch (action.kind) {
|
|
156
|
+
case "ignore":
|
|
157
|
+
return;
|
|
158
|
+
case "refresh":
|
|
159
|
+
this.#refreshPending = true;
|
|
160
|
+
if (this.#registered) {
|
|
161
|
+
void this.#synchronize().catch((error) => {
|
|
162
|
+
this.#recordFailure("snapshot", error);
|
|
163
|
+
void this.#closeAfterFailure();
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return;
|
|
167
|
+
case "snapshot":
|
|
168
|
+
this.#accept(this.#options.validateSnapshot(action.value));
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
} catch (error) {
|
|
172
|
+
this.#recordFailure("event", error);
|
|
173
|
+
void this.#closeAfterFailure();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
#synchronize(): Promise<void> {
|
|
178
|
+
if (
|
|
179
|
+
!this.#registered ||
|
|
180
|
+
this.#disposed ||
|
|
181
|
+
this.#failures.length > 0
|
|
182
|
+
) {
|
|
183
|
+
return Promise.resolve();
|
|
184
|
+
}
|
|
185
|
+
this.#pump ??= Promise.resolve().then(() => this.#runPump());
|
|
186
|
+
return this.#pump;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async #runPump(): Promise<void> {
|
|
190
|
+
try {
|
|
191
|
+
while (
|
|
192
|
+
this.#refreshPending &&
|
|
193
|
+
!this.#disposed &&
|
|
194
|
+
this.#failures.length === 0
|
|
195
|
+
) {
|
|
196
|
+
this.#refreshPending = false;
|
|
197
|
+
const value = await this.#options.loadSnapshot();
|
|
198
|
+
if (this.#disposed || this.#failures.length > 0) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
this.#accept(this.#options.validateSnapshot(value));
|
|
202
|
+
}
|
|
203
|
+
} finally {
|
|
204
|
+
this.#pump = undefined;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
#accept(candidate: Snapshot): void {
|
|
209
|
+
if (!this.#options.isNewer(candidate, this.#current)) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
this.#current = candidate;
|
|
213
|
+
this.#options.onSnapshot?.(candidate);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
#recordFailure(
|
|
217
|
+
phase: ConnectionFailurePhase,
|
|
218
|
+
error: unknown,
|
|
219
|
+
): void {
|
|
220
|
+
if (
|
|
221
|
+
this.#failures.some(
|
|
222
|
+
(failure) => failure.phase === phase && failure.error === error,
|
|
223
|
+
)
|
|
224
|
+
) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const failure = { phase, error };
|
|
228
|
+
this.#failures.push(failure);
|
|
229
|
+
this.#options.onFailure?.(failure);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
async #closeAfterFailure(): Promise<void> {
|
|
233
|
+
try {
|
|
234
|
+
await this.#closeListener();
|
|
235
|
+
} catch (error) {
|
|
236
|
+
this.#recordFailure("unlisten", error);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
#closeListener(): Promise<void> {
|
|
241
|
+
if (this.#cleanup !== undefined) {
|
|
242
|
+
return this.#cleanup;
|
|
243
|
+
}
|
|
244
|
+
const unlisten = this.#unlisten;
|
|
245
|
+
if (unlisten === undefined) {
|
|
246
|
+
return Promise.resolve();
|
|
247
|
+
}
|
|
248
|
+
this.#unlisten = undefined;
|
|
249
|
+
this.#cleanup = Promise.resolve().then(() => unlisten());
|
|
250
|
+
return this.#cleanup;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type Unlisten = () => void | Promise<void>;
|
|
2
|
+
|
|
3
|
+
export interface InvokeTransport {
|
|
4
|
+
invoke(
|
|
5
|
+
command: string,
|
|
6
|
+
arguments_: Record<string, unknown>,
|
|
7
|
+
): Promise<unknown>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface EventTransport extends InvokeTransport {
|
|
11
|
+
listen(
|
|
12
|
+
event: string,
|
|
13
|
+
listener: (payload: unknown) => void,
|
|
14
|
+
): Promise<Unlisten>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isEventTransport(
|
|
18
|
+
transport: InvokeTransport,
|
|
19
|
+
): transport is EventTransport {
|
|
20
|
+
return (
|
|
21
|
+
"listen" in transport &&
|
|
22
|
+
typeof (transport as { listen?: unknown }).listen === "function"
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertValidHistoryChangedEvent,
|
|
3
|
+
assertValidHistoryNavigationCommand,
|
|
4
|
+
assertValidHistoryNavigationResult,
|
|
5
|
+
assertValidHistoryPageCommand,
|
|
6
|
+
assertValidHistoryPageSnapshot,
|
|
7
|
+
assertValidHistorySnapshot,
|
|
8
|
+
} from "./validation.ts";
|
|
9
|
+
import type {
|
|
10
|
+
HistoryChangedEvent,
|
|
11
|
+
HistoryNavigationCommand,
|
|
12
|
+
HistoryNavigationResult,
|
|
13
|
+
HistoryPageCommand,
|
|
14
|
+
HistoryPageSnapshot,
|
|
15
|
+
HistorySnapshot,
|
|
16
|
+
} from "./generated/protocol.ts";
|
|
17
|
+
import type {
|
|
18
|
+
CheckedHistoryPort,
|
|
19
|
+
HistoryPort,
|
|
20
|
+
HistoryUnlisten,
|
|
21
|
+
} from "./ports.ts";
|
|
22
|
+
|
|
23
|
+
export class HistoryClient implements CheckedHistoryPort {
|
|
24
|
+
readonly #port: HistoryPort;
|
|
25
|
+
|
|
26
|
+
constructor(port: HistoryPort) {
|
|
27
|
+
this.#port = port;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
nextPlanId(): string {
|
|
31
|
+
return this.#port.nextPlanId();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async snapshot(): Promise<HistorySnapshot> {
|
|
35
|
+
const value = await this.#port.snapshot();
|
|
36
|
+
assertValidHistorySnapshot(value);
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async page(command: HistoryPageCommand): Promise<HistoryPageSnapshot> {
|
|
41
|
+
assertValidHistoryPageCommand(command);
|
|
42
|
+
const value = await this.#port.page(command);
|
|
43
|
+
assertValidHistoryPageSnapshot(value);
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async navigate(
|
|
48
|
+
command: HistoryNavigationCommand,
|
|
49
|
+
): Promise<HistoryNavigationResult> {
|
|
50
|
+
assertValidHistoryNavigationCommand(command);
|
|
51
|
+
const value = await this.#port.navigate(command);
|
|
52
|
+
assertValidHistoryNavigationResult(value);
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async listen(
|
|
57
|
+
listener: (event: HistoryChangedEvent) => void,
|
|
58
|
+
): Promise<HistoryUnlisten> {
|
|
59
|
+
if (this.#port.listen === undefined) return () => {};
|
|
60
|
+
return this.#port.listen((value) => {
|
|
61
|
+
assertValidHistoryChangedEvent(value);
|
|
62
|
+
listener(value);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|