@vehicle-sil/gui-client 0.1.0 → 0.2.0-rc.2

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.
Files changed (39) hide show
  1. package/README.ja.md +412 -96
  2. package/README.md +403 -89
  3. package/dist/elements.js +872 -0
  4. package/dist/index.js +2869 -259
  5. package/package.json +20 -2
  6. package/timeline/vehicle-sil-timeline.d.ts +108 -0
  7. package/timeline/vehicle-sil-timeline.js +4577 -0
  8. package/timeline/vehicle-sil-timeline.mjs +4579 -0
  9. package/types/client.d.ts +47 -7
  10. package/types/connection.d.ts +4 -0
  11. package/types/elements/index.d.ts +25 -0
  12. package/types/elements/outside-parts.d.ts +20 -0
  13. package/types/elements/page-intent.d.ts +10 -0
  14. package/types/elements/part.d.ts +48 -0
  15. package/types/elements/reasons.d.ts +12 -0
  16. package/types/elements/run-parts.d.ts +21 -0
  17. package/types/elements/scenario-parts.d.ts +18 -0
  18. package/types/elements/variable-parts.d.ts +28 -0
  19. package/types/front-actions.d.ts +130 -0
  20. package/types/front-compose.d.ts +61 -0
  21. package/types/front-outside.d.ts +19 -0
  22. package/types/front-types.d.ts +360 -0
  23. package/types/front-variable.d.ts +28 -0
  24. package/types/front.d.ts +50 -0
  25. package/types/index.d.ts +13 -5
  26. package/types/protocol/launcher.d.ts +581 -0
  27. package/types/protocol/read.d.ts +72 -0
  28. package/types/protocol/server.d.ts +780 -0
  29. package/types/protocol.d.ts +10 -972
  30. package/types/run.d.ts +21 -6
  31. package/types/session-state.d.ts +66 -10
  32. package/types/session.d.ts +48 -2
  33. package/types/time.d.ts +16 -45
  34. package/types/values.d.ts +2 -0
  35. package/types/variable-binding.d.ts +20 -5
  36. package/types/variable-editor.d.ts +25 -0
  37. package/types/variable-state.d.ts +12 -6
  38. package/types/variables.d.ts +36 -4
  39. package/types/waveforms.d.ts +14 -0
@@ -0,0 +1,360 @@
1
+ import type { GuiClient } from './client.js';
2
+ import type { CheckResult, ConfigText, SavedConfig, Finding, OutsideState, RunEnd, ScenarioFile, ScenarioStatus, ScenarioStep } from './protocol.js';
3
+ import type { ValueCondition, WriteBlock, WriteStatus } from './variable-state.js';
4
+ import type { VariableRef, VariableValue } from './variables.js';
5
+ import type { Readable } from './values.js';
6
+ import type { Reason } from './session-state.js';
7
+ /** A reason: a code that stays the same and one English sentence (defined with the session copy, which reads them too). */
8
+ export type { Reason };
9
+ /** How the page stands with the GUI server. */
10
+ export type Link = 'connecting' | 'online' | 'offline' | 'rejected' | 'incompatible';
11
+ /**
12
+ * Where the run stands. `starting`: a start is on its way (this page's or another page's) or the launcher has not
13
+ * begun; `waiting`: the launcher waits for the participants to join (phase `waiting`; a run held before the first step with start_paused is `paused`); `ended`: the
14
+ * run has a result; `crashed`: the launcher ended without one.
15
+ */
16
+ export type RunState = 'none' | 'starting' | 'waiting' | 'running' | 'paused' | 'stopping' | 'ended' | 'crashed';
17
+ /**
18
+ * How a run ended, as the launcher's result says (`end`). `crashed` is the client's own: the launcher ended without
19
+ * writing a result. A launcher newer than this library may write a value that is not listed.
20
+ */
21
+ export type EndKind = RunEnd | 'crashed';
22
+ /** The result of the last run. */
23
+ export interface FrontResult {
24
+ /** null when nothing was started: the check failed, or the file or the command line could not be used. */
25
+ end: EndKind | null;
26
+ /** The scenario's verdict (null for a run without a scenario). */
27
+ scenario: ScenarioStatus | null;
28
+ /**
29
+ * Whether the run succeeded, as the launcher's result says (`ok`: its exit code is 0). A stop by the operator is a
30
+ * success, unless it cut a scenario short (the scenario has no verdict then).
31
+ */
32
+ ok: boolean;
33
+ /** One English sentence for a person, as the launcher wrote it. */
34
+ message: string;
35
+ }
36
+ /** What a screen shows as the state (discrete values only; the time is in `clock`). */
37
+ export interface FrontStatus {
38
+ link: Link;
39
+ run: RunState;
40
+ /** The configuration file of the run (the last one if none is running); the start-up file when there has been no run. */
41
+ file: string | null;
42
+ /** Set while `run` is `ended` or `crashed`. */
43
+ result: FrontResult | null;
44
+ /** The one problem to tell the user now (null if none). The connection comes first; then the newer of the launcher's crash, the last action's failure and a failed run. */
45
+ problem: Reason | null;
46
+ }
47
+ /** Whether the run keeps to its speed. */
48
+ export type Pacing = 'not-paced' | 'on-time' | 'late';
49
+ /** Time and speed (changes often, so it is apart from `status`). */
50
+ export interface FrontClock {
51
+ /** Virtual time (ms); null until the first time event. */
52
+ sim_ms: number | null;
53
+ /** The speed that was asked for. */
54
+ speed: number | 'max' | null;
55
+ /** The speed over about the last second; null while paused or just started. */
56
+ actual_speed: number | null;
57
+ pacing: Pacing;
58
+ }
59
+ /** Whether one operation can be used now. `ok` is for a button: it is false also when the operation would change nothing. */
60
+ export interface Control {
61
+ ok: boolean;
62
+ /** Why not (null if ok). */
63
+ reason: Reason | null;
64
+ /** The operation is accepted, but something is worth knowing first (null if none). */
65
+ caution: Reason | null;
66
+ }
67
+ /** What each operation can do now. Built from the launcher's `state` and the GUI server's `allowed`. */
68
+ export interface FrontControls {
69
+ start: Control;
70
+ stop: Control;
71
+ force_stop: Control;
72
+ pause: Control;
73
+ resume: Control;
74
+ step: Control & {
75
+ min_ms: number;
76
+ max_ms: number;
77
+ };
78
+ run_until: Control;
79
+ /** `fastest`: whether the speed `'max'` is accepted besides the numbers from `min` to `max`. */
80
+ speed: Control & {
81
+ min: number;
82
+ max: number;
83
+ fastest: boolean;
84
+ };
85
+ /**
86
+ * `saveConfig()`, from the GUI server's `allowed.save` (`save-disabled`: started with `--no-save`). `caution`
87
+ * `command-changes-allowed`: the server also saves edits that change the commands that run, and new files; show it
88
+ * near the save button. Whether one edit is saved is the server's answer to it, not this.
89
+ */
90
+ save: Control;
91
+ }
92
+ /** The operations that have a control. */
93
+ export type OperationName = keyof FrontControls;
94
+ /** The progress of the scenario of the run. */
95
+ export interface FrontScenario {
96
+ file: string;
97
+ name: string | null;
98
+ status: ScenarioStatus | null;
99
+ steps: readonly ScenarioStep[];
100
+ /** Where the server serves the timeline of the run (null until the run has ended with one). */
101
+ timeline_url: string | null;
102
+ }
103
+ /**
104
+ * An action that did not go through. `refused`: the owner said no (nothing happened). `unknown`: it may have been
105
+ * done (no answer, an answer that cannot be tied to the command, interrupted before it arrived): look at `status` and
106
+ * `clock` before sending it again.
107
+ */
108
+ export declare class ActionError extends Error {
109
+ /** A code that stays the same: the owner's `reason` (`not-paused`, `check-failed`, ...) or the client's (`busy`, `no-answer`, `interrupted`, `timeout`, ...). */
110
+ readonly code: string;
111
+ readonly outcome: 'refused' | 'unknown';
112
+ /** For `check-failed`: the findings of the check that refused the start. */
113
+ readonly findings: readonly Finding[];
114
+ constructor(
115
+ /** A code that stays the same: the owner's `reason` (`not-paused`, `check-failed`, ...) or the client's (`busy`, `no-answer`, `interrupted`, `timeout`, ...). */
116
+ code: string, message: string, outcome: 'refused' | 'unknown',
117
+ /** For `check-failed`: the findings of the check that refused the start. */
118
+ findings?: readonly Finding[]);
119
+ }
120
+ /**
121
+ * What a start asks for: the keys of the request file (`schema/run-request.schema.json`), with its names and value
122
+ * forms. A choice that is not made is left out of the object: there is no null.
123
+ */
124
+ export interface Intent {
125
+ /** The format of the request file: 1, or left out (the client adds none). */
126
+ vehicle_sil_run_request?: 1;
127
+ disable?: string[];
128
+ enable?: string[];
129
+ manual?: string[];
130
+ /**
131
+ * A `path` of `scenarios()` (relative to the root of the GUI server, as the list gives it; the server turns it into
132
+ * the path the request file needs, which is relative to the configuration file's directory). Do not compose it.
133
+ */
134
+ scenario?: string;
135
+ variant?: string;
136
+ params?: Record<string, string | number | boolean>;
137
+ speed?: number | 'max';
138
+ start_paused?: boolean;
139
+ /** Exact virtual time at which to stop. Omit for no automatic stop. */
140
+ stop_at_ms?: number;
141
+ /** Wall-clock milliseconds of lateness before a paced step counts as late. */
142
+ late_tolerance_ms?: number;
143
+ strict?: boolean;
144
+ /**
145
+ * Network name to where it is connected outside the simulation: a `value` that `connections()` gave with `usable`
146
+ * true, as written there, or `'none'` (SIL Kit only; the same as leaving the network out). The server refuses a value
147
+ * that its last list of that network did not give (`target-not-listed`).
148
+ */
149
+ connect?: Record<string, string>;
150
+ /** A run connected outside keeps real time (`realtime`, the launcher's default) unless `free` is chosen. */
151
+ time_policy?: 'realtime' | 'free';
152
+ }
153
+ /** A place where a network can be connected, as the bridge of one backend listed it. */
154
+ export interface ConnectTarget {
155
+ /** The bridge's backend (`packet`, `tap`, `socketcan`, `npcap`, ...); null if the list did not say. */
156
+ backend: string | null;
157
+ /** What `connect` gives the network. */
158
+ value: string;
159
+ label: string;
160
+ /** One English line from the bridge (state, and a device in use by another bridge). */
161
+ detail: string;
162
+ /** false: it cannot be chosen; `reason` says why. */
163
+ usable: boolean;
164
+ reason: string | null;
165
+ }
166
+ /** A backend whose bridge could not list (it is missing on this computer, or it failed). */
167
+ export interface ConnectListError {
168
+ backend: string | null;
169
+ /** The launcher's English sentence. */
170
+ error: string;
171
+ }
172
+ /** One entry of `connections()`: a target, or a backend that has no list. */
173
+ export type ConnectEntry = ConnectTarget | ConnectListError;
174
+ /**
175
+ * A network connected outside the simulation in the run (`outside[]` of the launcher's `state`), with the counts of its
176
+ * `outside` events.
177
+ */
178
+ export interface Outside {
179
+ network: string;
180
+ target: string | null;
181
+ /** The bridge (`bridge.<network>`). */
182
+ participant: string | null;
183
+ /** Ethernet: `up`, `down` or `unknown` (null before the bridge has said). */
184
+ link: OutsideState['link'];
185
+ /** CAN: `active`, `passive`, `bus-off` or `unknown` (null for Ethernet, or before the bridge has said). */
186
+ bus: OutsideState['bus'];
187
+ /** `ok`, `interrupted` or `degraded`. */
188
+ condition: OutsideState['condition'];
189
+ /** Codes, in the launcher's order (empty when the condition is ok). */
190
+ reasons: readonly string[];
191
+ /** Frames went to the bus and nothing came back for 10 s (apart from `condition`, which can still be `ok`). */
192
+ nothing_received: boolean;
193
+ /** Frames the bridge sent to the bus so far; null until an `outside` event has arrived on this page. */
194
+ to_outside: number | null;
195
+ /** Frames that came from a device on the bus so far; null until an `outside` event has arrived on this page. */
196
+ from_outside: number | null;
197
+ }
198
+ /** Operations of the run. Each resolves when the server has taken the request; whether the run began is `status.run`. */
199
+ export interface FrontRun {
200
+ /** Starts a run of `file` (default: the start-up file). Rejects with `check-failed` and the findings if the check refuses it. */
201
+ start(intent?: Intent, options?: {
202
+ file?: string;
203
+ }): Promise<void>;
204
+ /** Stops in order. Works whatever the state of the connection (the request is sent if the network is up). */
205
+ stop(): Promise<void>;
206
+ /** Stops without waiting for the participants. */
207
+ forceStop(target?: {
208
+ session: number;
209
+ instance: string;
210
+ }): Promise<void>;
211
+ }
212
+ /**
213
+ * Time operations. `pause`, `resume` and `setSpeed` resolve when the launcher has answered; `step` and `runUntil`
214
+ * resolve when time has arrived and the run is paused again (read `clock` after `await`). Another command sent before
215
+ * it arrives (from this page, another page or stdin) rejects it with `interrupted`.
216
+ */
217
+ export interface FrontTime {
218
+ pause(): Promise<void>;
219
+ resume(): Promise<void>;
220
+ step(ms: number): Promise<void>;
221
+ setSpeed(value: number | 'max'): Promise<void>;
222
+ runUntil(ms: number): Promise<void>;
223
+ }
224
+ /** What a screen shows for one variable. */
225
+ export interface VariableView {
226
+ value: VariableValue;
227
+ /** The value as text (an enum shows its item's name). Empty while there is no value. */
228
+ text: string;
229
+ unit: string;
230
+ min: number | null;
231
+ max: number | null;
232
+ step: number | null;
233
+ /** Virtual time of the step that read the value (ms). */
234
+ sim_ms: number | null;
235
+ /** The value may be out of date. */
236
+ stale: boolean;
237
+ /** One English sentence when the value is not a live one (waiting, paused, stale, ended, ...); null while live. */
238
+ note: string | null;
239
+ /**
240
+ * Whether the ECU uses the variable now (information only: `can_write`, `why`, `note` and `condition` do not look at
241
+ * it). `active` from a server that does not say; `unknown` while the ECU has not said or the variable is not in the run.
242
+ */
243
+ availability: 'unknown' | 'active' | 'inactive';
244
+ /** Whether it can be written: the variable's own conditions and what the launcher accepts (`state.allowed.write`). */
245
+ can_write: boolean;
246
+ /** Why the variable cannot be written (null if it can). */
247
+ why: Reason | null;
248
+ /** A write is on its way. */
249
+ writing: boolean;
250
+ /** Why the last write of this page did not go through (null if none). */
251
+ problem: Reason | null;
252
+ condition: ValueCondition;
253
+ block: WriteBlock | null;
254
+ write_status: WriteStatus;
255
+ }
256
+ /**
257
+ * A variable. Values arrive while someone subscribes (the first subscription asks the server for them, the last
258
+ * unsubscribe stops it: there is no close()). `write` needs no subscription.
259
+ */
260
+ export interface FrontVariable extends Readable<VariableView> {
261
+ /** Resolves when the value has been applied in an ECU step. Rejects with an ActionError (`no-answer` is `unknown`: it is not sent again). */
262
+ write(value: number | boolean | string): Promise<void>;
263
+ }
264
+ /** The front door: `connect()` returns it. */
265
+ export interface Front {
266
+ /** The client of the same connection (events, logs, findings, participants, the write trail). */
267
+ readonly low: GuiClient;
268
+ readonly status: Readable<FrontStatus>;
269
+ readonly clock: Readable<FrontClock>;
270
+ readonly controls: Readable<FrontControls>;
271
+ readonly scenario: Readable<FrontScenario | null>;
272
+ readonly run: FrontRun;
273
+ readonly time: FrontTime;
274
+ /**
275
+ * The networks of the run that the start's `connect` connected outside (empty when there are none, when no run is
276
+ * going, and in a run that a `role: bridge` participant of the file connects: do not read "connected or not" from it).
277
+ * Changes as the launcher's `state` and `outside` events arrive.
278
+ */
279
+ readonly outside: Readable<readonly Outside[]>;
280
+ /**
281
+ * Where `network` of `file` (default: the start-up file, as for `run.start`) can be connected on the computer of the
282
+ * GUI server: the entries of every backend, in the launcher's order. It starts that network's bridge to list it (on
283
+ * Windows, Npcap may ask to raise the rights): call it when the user opens the choice, not when the page opens. A
284
+ * backend that cannot list is an entry with `error`, not a failure. Rejects with an ActionError (`check-busy`,
285
+ * `unknown-network`, ...).
286
+ */
287
+ connections(request: {
288
+ network: string;
289
+ }, options?: {
290
+ file?: string;
291
+ }): Promise<ConnectEntry[]>;
292
+ /**
293
+ * The scenario files next to `file` (default: the start-up file, as for `run.start` and `connections()`; pass the
294
+ * same `file` to this and to `run.start` when a run uses another file), as the list that
295
+ * `client.low.scenarios(file)` gives, without its directory. Give `path` of an entry as `intent.scenario`. Rejects
296
+ * with an ActionError (`no-file` when there is no file to ask for, and the server's code otherwise).
297
+ */
298
+ scenarios(options?: {
299
+ file?: string;
300
+ }): Promise<ScenarioFile[]>;
301
+ /**
302
+ * Checks what `intent` would start, without starting it (`POST api/check`), and returns the launcher's check result
303
+ * (`findings`; `time_lock` and `networks[].outside` are in `raw`). Rejects with an ActionError (`target-not-listed`,
304
+ * `check-busy`, `unknown-field`, ...); a failure is not put into `status.problem`. It sends one check at a time (the
305
+ * next after the answer to the one before), and a check of the same intent and file as one that waits or is on its
306
+ * way shares it (`fresh`: only one that waits, so that the answer reads the file as it is now). A check that waits is
307
+ * not sent when `signal` has aborted for every caller of it (it rejects with the signal's reason), nor after
308
+ * `close()` (`closed`).
309
+ *
310
+ * With `text`, it checks that text as the content of `file` (a text that is not saved yet; no process starts). The
311
+ * intent then takes only `variant`, `strict` and `vehicle_sil_run_request` (another field is `unknown-field`). A check of a text is never
312
+ * shared with another check, and its answer is the caller's alone: the parts of the page do not see it.
313
+ */
314
+ check(intent: Pick<Intent, 'vehicle_sil_run_request' | 'variant' | 'strict'>, options: {
315
+ file?: string;
316
+ text: string;
317
+ signal?: AbortSignal;
318
+ }): Promise<CheckResult>;
319
+ check(intent?: Intent, options?: {
320
+ file?: string;
321
+ signal?: AbortSignal;
322
+ fresh?: boolean;
323
+ }): Promise<CheckResult>;
324
+ /**
325
+ * Reads the text of a configuration file as it is saved (`GET api/config`), with the SHA-256 of its bytes (`stamp`).
326
+ * `file` defaults to the start-up file (`no-file` if there is none). Rejects with an ActionError
327
+ * (`not-a-configuration`, `config-too-large`, `config-unreadable`, ...); a failure is not put into `status.problem`.
328
+ */
329
+ readConfig(options?: {
330
+ file?: string;
331
+ }): Promise<ConfigText>;
332
+ /**
333
+ * Describes the participants of the saved `file` again (`POST api/describe`: after an executable was built again),
334
+ * so that the checks of a text compare them, and returns that check as `check()` does. The answer is the caller's
335
+ * alone: it does not change what the parts of the page show. A describe of the same file and variant that waits or is on its way is shared. Rejects with an ActionError (`check-busy`,
336
+ * `check-timeout`, ...); a failure is not put into `status.problem`.
337
+ */
338
+ describeAgain(options?: {
339
+ file?: string;
340
+ variant?: string;
341
+ }): Promise<CheckResult>;
342
+ /**
343
+ * Saves `text` as the content of `file` (`POST api/config`), with the `stamp` that `readConfig()` gave (null: a new
344
+ * file), and resolves with the stamp of the saved content. By default the server saves only an edit that keeps the
345
+ * commands that run, as the launcher's check of the text says (`controls.save` tells what applies). `file` defaults
346
+ * to the start-up file (`no-file` if there is none). Rejects with an ActionError: `save-disabled`,
347
+ * `commands-changed` (`findings` are the launcher's; also a new file, `stamp` null, to a server started without
348
+ * `--allow-command-changes`), `config-changed` (read the file again and make the edit on
349
+ * that text), `config-busy`, `config-unreadable`, `text-too-large`, ...; a failure is not put into `status.problem`.
350
+ */
351
+ saveConfig(options: {
352
+ file?: string;
353
+ text: string;
354
+ stamp: string | null;
355
+ }): Promise<SavedConfig>;
356
+ /** A variable by `"Peer.variable"` (cut at the first dot) or `{peer, name}` (for a peer whose name has a dot). */
357
+ variable(ref: string | VariableRef): FrontVariable;
358
+ /** Disconnects and fails what is waiting. A connection that `connect()` shares is made again by the next `connect()`. */
359
+ close(): void;
360
+ }
@@ -0,0 +1,28 @@
1
+ import type { GuiClient } from './client.js';
2
+ import { ActionError, Control, FrontVariable, Reason, VariableView } from './front-types.js';
3
+ import type { BoundVariable } from './variable-binding.js';
4
+ import type { ValueCondition } from './variable-state.js';
5
+ import { Readable } from './values.js';
6
+ import { VariableRef } from './variables.js';
7
+ /** The sentence for a value that is not a live one (null while it is live). */
8
+ export declare function noteOf(condition: ValueCondition): string | null;
9
+ /** Split `"Peer.variable"` at the first dot (as the scenario files do); an object is taken as it is. */
10
+ export declare function refOf(ref: string | VariableRef): VariableRef;
11
+ interface Track {
12
+ writing: boolean;
13
+ problem: Reason | null;
14
+ }
15
+ /**
16
+ * `launcher` is what the launcher accepts for a write now (`state.allowed.write`, with the connection and the run). The
17
+ * variable's own reason (it is an output, the ECU is not connected, ...) comes first; otherwise the launcher's, as
18
+ * `bind` reports it (`block` `launcher`) or as `launcher` has it.
19
+ */
20
+ export declare function viewOf(bound: BoundVariable, track: Track, launcher: Control): VariableView;
21
+ /** A write that failed, as an ActionError (`no-answer` and `closed` may have been applied: `unknown`). */
22
+ export declare function writeFailure(error: unknown): ActionError;
23
+ export declare function makeVariable(low: GuiClient, ref: VariableRef,
24
+ /** Refuses a write the client must not send (the connection is refused, or the versions differ). */
25
+ refuse: () => ActionError | null,
26
+ /** What the launcher accepts for a write (see `viewOf`). */
27
+ launcher: Readable<Control>): FrontVariable;
28
+ export {};
@@ -0,0 +1,50 @@
1
+ import { ClientOptions } from './client.js';
2
+ import type { HttpTransport } from './http.js';
3
+ import type { SocketFactory } from './connection.js';
4
+ import { Front } from './front-types.js';
5
+ import { ErrorSink, Readable } from './values.js';
6
+ /** Options of `connect()`. In the browser, call it without options (the page's own server and token are used). */
7
+ export interface ConnectOptions {
8
+ /** URL of the GUI server (what the server printed, without `#token=...`). */
9
+ base_url: string;
10
+ /** The token (what follows `#token=`). A function is called each time the token is used. */
11
+ token: string | (() => string | null);
12
+ /** Origin to send (Node sends the origin of `base_url` if omitted). */
13
+ origin?: string;
14
+ /** HTTP transport (default: fetch). For tests. */
15
+ http?: HttpTransport;
16
+ /** Function that opens the WebSocket (default: the platform's). For tests. */
17
+ socket?: SocketFactory;
18
+ /** How long to wait for the launcher's answer to a time command (ms; default 5000). */
19
+ answer_timeout_ms?: number;
20
+ /** Receives what subscribers threw (default: console.error). */
21
+ on_error?: ErrorSink;
22
+ }
23
+ /**
24
+ * Makes the front door without connecting and without waiting for the server (as `createClient` does for the client
25
+ * below it). For an app that must show its screens before the server answers, and while it cannot be reached: it calls
26
+ * `front.low.connect()` and `front.low.loadApp()` itself, and reads `status` (the connection, `rejected`, `incompatible`)
27
+ * meanwhile. Until `loadApp()` has answered, the front knows no start-up file, and the ranges in `controls` are the
28
+ * defaults (`DEFAULT_LIMITS`).
29
+ * Most code wants `connect()`.
30
+ */
31
+ export declare function createFront(options: ClientOptions): Front;
32
+ /**
33
+ * Connects to the GUI server and returns the front door. Without options (in the browser) it connects once and returns
34
+ * the same connection to every caller: the parts of a page share it. With options it makes a connection of its own
35
+ * (close it with `close()`). A failure to connect is not remembered: the next call connects again.
36
+ */
37
+ export declare function connect(options?: ConnectOptions): Promise<Front>;
38
+ /** Calls `fn` now and each time the value changes. Returns the function that stops it. */
39
+ export declare function watch<T>(source: Readable<T>, fn: (value: T) => void): () => void;
40
+ export declare function watch<T extends unknown[]>(sources: {
41
+ [K in keyof T]: Readable<T[K]>;
42
+ }, fn: (...values: T) => void): () => void;
43
+ /**
44
+ * Resolves with the first value that satisfies `test` (the current one counts). Rejects with an ActionError `timeout`
45
+ * after `timeout_ms`, or `aborted` when `signal` aborts (`unknown`: the thing waited for may still happen).
46
+ */
47
+ export declare function until<T>(source: Readable<T>, test: (value: T) => boolean, options?: {
48
+ timeout_ms?: number;
49
+ signal?: AbortSignal;
50
+ }): Promise<T>;
package/types/index.d.ts CHANGED
@@ -4,7 +4,11 @@ export type { ClientConnection, CloseInfo, ConnectionState } from './connection.
4
4
  export type { ClientSession, Notice } from './session.js';
5
5
  export type { ClientRun, StopAction } from './run.js';
6
6
  export type { ClientTime, Lateness, NotSentReason, SendResult, TimeFailure, TimeState, } from './time.js';
7
- export { ANSWER_TIMEOUT_MS, FEATURE_SPEED, FEATURE_START_PAUSED, FEATURE_TIME_COMMANDS, } from './time.js';
7
+ export { ANSWER_TIMEOUT_MS } from './time.js';
8
+ export { connect, createFront, until, watch } from './front.js';
9
+ export type { ConnectOptions } from './front.js';
10
+ export { ActionError } from './front-types.js';
11
+ export type { ConnectEntry, ConnectListError, ConnectTarget, Control, EndKind, Front, FrontClock, FrontControls, FrontResult, FrontRun, FrontScenario, FrontStatus, FrontTime, FrontVariable, Intent, Link, OperationName, Outside, Pacing, Reason, RunState, VariableView, } from './front-types.js';
8
12
  export { TOKEN_STORAGE_KEY, takeToken } from './token.js';
9
13
  export type { TokenPlace } from './token.js';
10
14
  export { HISTORY_MAX, HISTORY_TOTAL_MAX, OPERATIONS_KEPT, WATCH_PERIODS_MS, WATCH_PERIOD_MS, WRITE_TIMEOUT_MS, WriteError, } from './variables.js';
@@ -18,7 +22,11 @@ export { BATCH_MS, TRY_AGAIN_LATER, webSocketFactory } from './connection.js';
18
22
  export type { SocketFactory, SocketHandlers, SocketLike } from './connection.js';
19
23
  export { DEFAULT_TIMEOUT_MS, HttpError, errorMessage, fetchTransport } from './http.js';
20
24
  export type { FetchTransportOptions, HttpOutcome, HttpRequest, HttpTransport } from './http.js';
21
- export { phaseIndex, runOutcome } from './session-state.js';
22
- export type { CommandView, LauncherView, LogLine, LogSource, ParticipantView, RunOutcome, ScenarioView, SessionView, TimeView, } from './session-state.js';
23
- export { FEATURE_SCENARIO, FEATURE_SCENARIO_CONTROL, FEATURE_MANUAL, PHASES, PROTOCOL_VERSION, ProtocolError, readAppInfo, readCheckResponse, readConfigList, readDashboardResponse, readRecording, readScenarioList, readServerMessage, readSessionResponse, readTimeResponse, readVariablesSummary, readWriteResponse, severityRank, } from './protocol.js';
24
- export type { AppInfo, AuthMessage, CheckNetwork, CheckOutcome, CheckParticipant, CheckRequest, CheckResult, CheckScenario, CheckStatus, CommandReport, ConfigFile, ConfigList, ControlLink, ControlOffer, ControlState, DashboardFile, DashboardFileError, DashboardFileItem, DashboardFileSection, DashboardPanelModule, DashboardResponse, DashboardVariable, Dropped, Finding, LauncherEvent, LogCounts, Open, ParticipantState, Phase, Recording, Replay, RunParticipant, RunRequest, RunResult, RunResultName, RunTiming, ScenarioFile, ScenarioList, ScenarioResult, ScenarioStatus, ScenarioStep, ScenarioStepStatus, ServerMessage, ServerProblem, SessionSummary, Severity, Speed, StopRequest, StopRequestBody, SummaryCommand, SummaryLauncher, SummaryParticipant, SummaryScenario, TimeAnswer, TimeCommand, TimeCommandName, TimeReport, ValuesMessage, Variable, VariableSummary, VariablesSummary, OperationReport, WatchMessage, WriteAnswer, } from './protocol.js';
25
+ export { isHolding, launcherAnswer, phaseIndex, runOutcome } from './session-state.js';
26
+ export type { CommandView, LauncherAnswer, LauncherView, LogLine, LogSource, ParticipantView, RunOutcome, ScenarioView, SessionView, TimeView, } from './session-state.js';
27
+ export { PHASES, PROTOCOL_VERSION, ProtocolError, readAppInfo, readCheckResponse, readConfigList, readConfigText, readSavedConfig, readConnections, readDashboardResponse, readRecording, readScenarioList, readServerMessage, readSessionAllowed, readSessionResponse, readTimeResponse, readVariablesSummary, readWriteResponse, severityRank, } from './protocol.js';
28
+ export type { AppInfo, AuthMessage, CheckNetwork, CheckOutcome, CheckParticipant, CheckRequest, CheckResult, CheckScenario, CheckStatus, CheckTextRequest, Caution, CommandReport, ConfigFile, ConfigList, ConfigText, SaveConfigRequest, SavedConfig, Connections, ConnectionsRequest, ControlLink, ControlOffer, ControlState, DashboardFile, DashboardFileError, DashboardFileItem, DashboardFileSection, DashboardPanelModule, DashboardResponse, DescribeRequest, DashboardVariable, Dropped, Finding, FromLauncher, LauncherAllowedItem, LauncherEvent, LauncherFields, LogCounts, Open, OutsideState, ParticipantRole, ParticipantState, Phase, Recording, Replay, RunParticipant, RunRequest, RunResult, RunEnd, RunResultName, RunTiming, RunTraffic, ScenarioFile, ScenarioList, ScenarioResult, ScenarioStatus, ScenarioStep, ScenarioStepStatus, ServerAllowed, ServerAllowedItem, ServerSaveItem, ServerMessage, ServerProblem, SessionSummary, Severity, Speed, StateReport, StopRequest, StopRequestBody, StopSessionRequestBody, SummaryCommand, SummaryLauncher, SummaryParticipant, SummaryScenario, SummaryState, TimeAnswer, TimeCommand, TimeCommandName, TimeReport, TrafficNetwork, TrafficParticipant, TrafficUnplaced, ValuesMessage, Variable, VariableSummary, VariablesSummary, OperationReport, VariableAvailability, WatchMessage, WriteAnswer, } from './protocol.js';
29
+ export { createWaveforms } from './waveforms.js';
30
+ export type { Waveforms, WaveformSeries } from './waveforms.js';
31
+ export { createVariableEditor } from './variable-editor.js';
32
+ export type { VariableEditor, VariableEditorState } from './variable-editor.js';