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

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/types/client.d.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  import { ClientConnection, SocketFactory } from './connection.js';
2
2
  import { HttpTransport } from './http.js';
3
- import { AppInfo, CheckRequest, CheckResult, ConfigList, DashboardResponse, Recording, ScenarioList, SessionSummary } from './protocol.js';
3
+ import { AppInfo, CheckRequest, CheckTextRequest, ConfigText, DescribeRequest, CheckResult, ConfigList, Connections, ConnectionsRequest, DashboardResponse, Recording, SaveConfigRequest, SavedConfig, ScenarioList, SessionSummary } from './protocol.js';
4
4
  import { ClientRun } from './run.js';
5
5
  import { ClientSession } from './session.js';
6
6
  import { ClientTime } from './time.js';
7
7
  import { ClientVariables } from './variables.js';
8
- import { Readable } from './values.js';
9
- /** Limits used while they are unknown (before the api/app answer). The same as the launcher's and server's defaults. */
8
+ import { ErrorSink, Readable } from './values.js';
9
+ /**
10
+ * Limits used while they are unknown (before the api/app answer). The same as the launcher's and server's defaults.
11
+ * During a run, the ranges of step and speed are the launcher's (`allowed.step`, `allowed.speed` of its state;
12
+ * `controls` of connect() carries them); the ones here are for choosing the speed of a run that has not started.
13
+ */
10
14
  export declare const DEFAULT_LIMITS: AppInfo['limits'];
11
15
  /** Options of createClient. */
12
16
  export interface ClientOptions {
@@ -80,9 +84,33 @@ export interface GuiClient {
80
84
  /**
81
85
  * `POST api/check`: checks a configuration file (a failed check still gets a successful answer; its result is then
82
86
  * not passed). Waits twice the server's check limit (limits.check_timeout_s; waiting its turn, then checking) plus
83
- * the default HTTP timeout.
87
+ * the default HTTP timeout. A check of a `text` may first describe the saved file in the same turn (the server does
88
+ * it when it has no saved descriptions); the second limit covers that.
89
+ */
90
+ check(request: CheckRequest | CheckTextRequest): Promise<CheckResult>;
91
+ /**
92
+ * `GET api/config`: the text of a configuration file as it is saved, with the SHA-256 of its bytes (`stamp`).
93
+ * Rejects with an HttpError (`not-a-configuration`, `config-too-large`, `config-unreadable`, ...).
94
+ */
95
+ config(file: string): Promise<ConfigText>;
96
+ /**
97
+ * `POST api/describe`: checks the saved file and saves its participants' descriptions again (after an executable
98
+ * was built again), and returns that check. Waits in the queue of the checks, as long as `check`.
84
99
  */
85
- check(request: CheckRequest): Promise<CheckResult>;
100
+ describe(request: DescribeRequest): Promise<CheckResult>;
101
+ /**
102
+ * `POST api/config`: saves a text as a configuration file, with the `stamp` it was read with (null: a new file).
103
+ * Rejects with an HttpError (`save-disabled`, `commands-changed` (also a new file to a server started without
104
+ * `--allow-command-changes`), `config-changed`, `config-busy`,
105
+ * `config-unreadable`, `text-too-large`, ...). Waits in the queue of the checks, as long as `check`.
106
+ */
107
+ saveConfig(request: SaveConfigRequest): Promise<SavedConfig>;
108
+ /**
109
+ * `POST api/connections`: where one network of a configuration file can be connected on the computer of the GUI
110
+ * server. It starts that network's bridge to list (on Windows, Npcap may ask to raise the rights), so ask only when
111
+ * the user opens the choice. Waits in the queue of the checks, as long as `check`.
112
+ */
113
+ connections(request: ConnectionsRequest): Promise<Connections>;
86
114
  /** `GET api/session`: summary of the current session (null if none). Also applied to the session copy. */
87
115
  fetchSession(): Promise<SessionSummary | null>;
88
116
  /**
@@ -110,3 +138,11 @@ export declare function isNode(runtime?: object): boolean;
110
138
  export declare function defaultOrigin(baseUrl: string, runtime?: object): string | undefined;
111
139
  /** Creates a client for the GUI server. Creating it does not connect (call connect()). */
112
140
  export declare function createClient(options: ClientOptions): GuiClient;
141
+ /** What the front (front.ts) needs besides the client: the transport and the error sink. */
142
+ export interface ClientParts {
143
+ client: GuiClient;
144
+ http: HttpTransport;
145
+ onError: ErrorSink;
146
+ }
147
+ /** createClient, and the parts the front door is built from. */
148
+ export declare function buildClient(options: ClientOptions): ClientParts;
@@ -0,0 +1,25 @@
1
+ import { pageIntent } from './page-intent.js';
2
+ import { setReasonText } from './reasons.js';
3
+ import type { ReasonText } from './reasons.js';
4
+ import { VsilConnectElement, VsilOutsideElement } from './outside-parts.js';
5
+ import { VsilRunControlsElement, VsilStatusElement, VsilTimeControlsElement } from './run-parts.js';
6
+ import { VsilScenarioResultElement, VsilScenarioSelectElement, VsilTimelineElement } from './scenario-parts.js';
7
+ import { VsilSliderElement, VsilValueElement, VsilWriteElement } from './variable-parts.js';
8
+ export { pageIntent, setReasonText };
9
+ export type { ReasonText };
10
+ export { VsilConnectElement, VsilOutsideElement, VsilRunControlsElement, VsilScenarioResultElement, VsilScenarioSelectElement, VsilSliderElement, VsilStatusElement, VsilTimeControlsElement, VsilTimelineElement, VsilValueElement, VsilWriteElement, };
11
+ declare global {
12
+ interface HTMLElementTagNameMap {
13
+ 'vsil-status': VsilStatusElement;
14
+ 'vsil-run-controls': VsilRunControlsElement;
15
+ 'vsil-time-controls': VsilTimeControlsElement;
16
+ 'vsil-value': VsilValueElement;
17
+ 'vsil-slider': VsilSliderElement;
18
+ 'vsil-write': VsilWriteElement;
19
+ 'vsil-scenario-select': VsilScenarioSelectElement;
20
+ 'vsil-scenario-result': VsilScenarioResultElement;
21
+ 'vsil-timeline': VsilTimelineElement;
22
+ 'vsil-connect': VsilConnectElement;
23
+ 'vsil-outside': VsilOutsideElement;
24
+ }
25
+ }
@@ -0,0 +1,20 @@
1
+ import type { Front } from '../index.js';
2
+ import { Part } from './part.js';
3
+ /**
4
+ * `<vsil-connect network="N">`: where network N of the next run is connected outside the simulation. The first choice
5
+ * is SIL Kit only (`none`). The list of the GUI server's computer is asked for only when the user opens the select (a
6
+ * press, or a key other than Tab, Escape and the modifiers). When the part leaves the page, or `network` or `file`
7
+ * changes, N leaves `pageIntent.connect`: no run is connected by a choice that is not on the page. `file` names the
8
+ * configuration file that the page starts (default: the start-up file, as `run.start`).
9
+ */
10
+ export declare class VsilConnectElement extends Part {
11
+ static observedAttributes: string[];
12
+ protected draw(client: Front, root: HTMLElement, alive: () => boolean): void;
13
+ }
14
+ /**
15
+ * `<vsil-outside>`: the networks that the run connected outside (`client.outside`), one row each. Nothing is shown when
16
+ * there are none (also in a run that a `role: bridge` participant of the file connects).
17
+ */
18
+ export declare class VsilOutsideElement extends Part {
19
+ protected draw(client: Front, root: HTMLElement): void;
20
+ }
@@ -0,0 +1,10 @@
1
+ import type { Intent } from '../index.js';
2
+ type Listener = (intent: Intent) => void;
3
+ /** The page's selection for the next run (`<vsil-scenario-select>` writes it, `<vsil-run-controls>` starts with it). */
4
+ export declare const pageIntent: {
5
+ get: () => Intent;
6
+ subscribe(listener: Listener): () => void;
7
+ /** Merges `patch`; a field that is undefined or an empty string is removed. */
8
+ update(patch: Intent | { [K in keyof Intent]?: Intent[K] | ""; }): void;
9
+ };
10
+ export {};
@@ -0,0 +1,48 @@
1
+ import type { Front, OperationName } from '../index.js';
2
+ /** Creates an element with text and attributes. */
3
+ export declare function h<K extends keyof HTMLElementTagNameMap>(tag: K, attributes?: Record<string, string>, ...children: (Node | string)[]): HTMLElementTagNameMap[K];
4
+ /** Sets or removes a data attribute. */
5
+ export declare function setData(element: HTMLElement, name: string, value: string | null): void;
6
+ /** Runs an operation and drops its failure: `status.problem` (or the variable's `problem`) shows it. */
7
+ export declare function quietly(operation: () => Promise<void>): Promise<void>;
8
+ /**
9
+ * The base of the parts. Subclasses draw into `root` in `draw()` and register what to stop with `own()`.
10
+ *
11
+ * - The part draws into one `<span class="vsil">` that it adds; children the page put in the element stay.
12
+ * - It binds when it enters the document, unbinds when it leaves, and binds again when one of
13
+ * `observedAttributes` changes or `client` is set.
14
+ */
15
+ export declare abstract class Part extends HTMLElement {
16
+ #private;
17
+ static observedAttributes: string[];
18
+ /** Another connection than the page's (`connect()`). Setting it while the part is in the document binds it again. */
19
+ get client(): Front | null;
20
+ set client(value: Front | null);
21
+ constructor();
22
+ /**
23
+ * A property that the page set before this class was defined sits on the object itself and hides the accessor:
24
+ * take it off and set it again.
25
+ */
26
+ protected upgrade(name: string): void;
27
+ /** Draws and subscribes. `alive()` turns false when the part has left the document or was bound again. */
28
+ protected abstract draw(client: Front, root: HTMLElement, alive: () => boolean): void | Promise<void>;
29
+ /** Stops `stop` when the part is unbound. */
30
+ protected own(stop: () => void): void;
31
+ /** The attribute `name`, or `fallback` when it is not there. */
32
+ protected text(name: string, fallback: string): string;
33
+ connectedCallback(): void;
34
+ disconnectedCallback(): void;
35
+ attributeChangedCallback(_name: string, before: string | null, after: string | null): void;
36
+ /**
37
+ * Binds `element` to one control of `client.controls`: `aria-disabled` (the caller ignores input while it is true),
38
+ * `data-reason` and `data-caution` (the codes), and a sentence in an element that describes it (`aria-describedby`;
39
+ * returned, to be put next to `element`). A reason that only says there is nothing to do (`not-running`, `offline`)
40
+ * is in that element too, but hidden: a screen reader reads it, the page does not show it seven times.
41
+ */
42
+ protected describe(client: Front, control: OperationName, element: HTMLElement): HTMLElement;
43
+ /**
44
+ * A button bound to one control of `client.controls`. When it cannot be used it stays focusable (`aria-disabled`),
45
+ * the reason is in an element that describes it (`aria-describedby`) and its code is in `data-reason`.
46
+ */
47
+ protected button(client: Front, label: string, control: OperationName, action: () => Promise<void>): HTMLElement[];
48
+ }
@@ -0,0 +1,12 @@
1
+ import type { Reason } from '../index.js';
2
+ /** Returns the sentence to show for `reason`; null or undefined keeps the English sentence of the owner of the reason. */
3
+ export type ReasonText = (reason: Reason) => string | null | undefined;
4
+ /**
5
+ * Replaces the sentences that the parts show for reasons (`controls.*.reason`, `caution`, `status.problem`, and a
6
+ * variable's `why` and `problem`), for example to translate them: `fn` gets the reason (its `code` stays the same) and
7
+ * returns the sentence, or null to keep the English one. `null` removes it. Call it before the parts are in the page:
8
+ * a part draws the sentence again when its value changes.
9
+ */
10
+ export declare function setReasonText(fn: ReasonText | null): void;
11
+ /** The sentence for `reason`. */
12
+ export declare function reasonText(reason: Reason): string;
@@ -0,0 +1,21 @@
1
+ import type { Front, Intent } from '../index.js';
2
+ import { Part } from './part.js';
3
+ /** `<vsil-status>`: the connection, the run, the virtual time (marked when it falls behind real time) and the one problem. */
4
+ export declare class VsilStatusElement extends Part {
5
+ protected draw(client: Front, root: HTMLElement): void;
6
+ }
7
+ /** `<vsil-run-controls>`: Start (with the page's selection and the `intent` property), Stop and, after a first stop, force stop. */
8
+ export declare class VsilRunControlsElement extends Part {
9
+ #private;
10
+ static observedAttributes: string[];
11
+ /** What to start with, over what the choosing parts of the page selected. */
12
+ get intent(): Intent | null;
13
+ set intent(value: Intent | null);
14
+ constructor();
15
+ protected draw(client: Front, root: HTMLElement): void;
16
+ }
17
+ /** `<vsil-time-controls speeds="0.5 1 5 max" step-ms="10">`: pause, resume, step, run until and speed. */
18
+ export declare class VsilTimeControlsElement extends Part {
19
+ static observedAttributes: string[];
20
+ protected draw(client: Front, root: HTMLElement): void;
21
+ }
@@ -0,0 +1,18 @@
1
+ import type { Front } from '../index.js';
2
+ import { Part } from './part.js';
3
+ /** `<vsil-scenario-select>`: chooses the scenario of the next run, among the scenarios next to the run's configuration file. */
4
+ export declare class VsilScenarioSelectElement extends Part {
5
+ protected draw(client: Front, root: HTMLElement, alive: () => boolean): void;
6
+ }
7
+ /** `<vsil-scenario-result>`: the result and the steps of the run's scenario. */
8
+ export declare class VsilScenarioResultElement extends Part {
9
+ protected draw(client: Front, root: HTMLElement): void;
10
+ }
11
+ /**
12
+ * `<vsil-timeline>`: ties the `<vehicle-sil-timeline>` inside it to the timeline of the run's scenario. The page's own
13
+ * `<vehicle-sil-timeline>` (with its attributes) is used; when there is none, the part adds a default one. The part
14
+ * changes only `src` and `hidden` of it, and does not load the element's script: the page does.
15
+ */
16
+ export declare class VsilTimelineElement extends Part {
17
+ protected draw(client: Front): void;
18
+ }
@@ -0,0 +1,28 @@
1
+ import type { Front, FrontVariable, VariableView } from '../index.js';
2
+ import { Part } from './part.js';
3
+ /** A part that shows or sets the variable of its `variable` attribute (`"ECU.variable"`). */
4
+ declare abstract class VariablePart extends Part {
5
+ static observedAttributes: string[];
6
+ /** Whether the part writes (so that it says why it cannot). */
7
+ protected readonly writes: boolean;
8
+ /** Builds the controls once; returns what to do with each new view. */
9
+ protected abstract build(variable: FrontVariable, root: HTMLElement, note: HTMLElement): (view: VariableView) => void;
10
+ protected draw(client: Front, root: HTMLElement): void;
11
+ }
12
+ /** `<vsil-value variable="ECU.variable" [on="LOST" off="ok"] [no-unit]>`: the value and its unit; a bool shows as the `on` and `off` text. */
13
+ export declare class VsilValueElement extends VariablePart {
14
+ static observedAttributes: string[];
15
+ protected build(_variable: FrontVariable, root: HTMLElement, note: HTMLElement): (v: VariableView) => void;
16
+ }
17
+ /** `<vsil-slider variable="ECU.variable">`: a number in the variable's range; it is written when the knob is released. */
18
+ export declare class VsilSliderElement extends VariablePart {
19
+ protected readonly writes = true;
20
+ protected build(variable: FrontVariable, root: HTMLElement, note: HTMLElement): (v: VariableView) => void;
21
+ }
22
+ /** `<vsil-write variable="ECU.variable" value="false" label="Cut">`: writes one value when pressed (not when it already is that value). */
23
+ export declare class VsilWriteElement extends VariablePart {
24
+ static observedAttributes: string[];
25
+ protected readonly writes = true;
26
+ protected build(variable: FrontVariable, root: HTMLElement, note: HTMLElement): (v: VariableView) => void;
27
+ }
28
+ export {};
@@ -0,0 +1,122 @@
1
+ import type { GuiClient } from './client.js';
2
+ import { HttpTransport } from './http.js';
3
+ import type { FrontControls, Intent, OperationName, RunState } from './front-types.js';
4
+ import { ActionError } from './front-types.js';
5
+ import type { Snapshot } from './front-compose.js';
6
+ import type { CheckResult, ConfigText, SavedConfig } from './protocol.js';
7
+ import { ErrorSink, Readable } from './values.js';
8
+ /** A failed action, kept for `status.problem`. */
9
+ export interface Failure {
10
+ error: ActionError;
11
+ /** `status.run` when it happened: the failure goes when that changes. */
12
+ run: RunState;
13
+ /** Later is newer. */
14
+ stamp: number;
15
+ }
16
+ /** What the operations read from the rest of the front. */
17
+ export interface ActionSources {
18
+ low: GuiClient;
19
+ http: HttpTransport;
20
+ snapshot(): Snapshot;
21
+ controls(): FrontControls;
22
+ run(): RunState;
23
+ /** The start-up file (null if there is none). */
24
+ initialFile(): string | null;
25
+ /** How long to wait for the launcher's answer to a time command (ms). */
26
+ answerTimeoutMs: number;
27
+ onError: ErrorSink;
28
+ /** The next stamp (shared with the other sources of problems). */
29
+ stamp(): number;
30
+ }
31
+ /** Turns what went wrong on the way to the server into an ActionError. */
32
+ export declare function actionError(error: unknown): ActionError;
33
+ /** The refusal when there is no file to use. */
34
+ export declare const noFileError: () => ActionError;
35
+ export declare class FrontActions {
36
+ private readonly src;
37
+ private readonly busyValue;
38
+ private readonly failureValue;
39
+ private readonly waiting;
40
+ private readonly inFlight;
41
+ /** The checks not answered yet, in the order they are sent: the first is on its way, the others wait. */
42
+ private readonly checks;
43
+ /** Rejects when the client closes: a check that waits ends with it. */
44
+ private close;
45
+ private readonly closing;
46
+ private nextId;
47
+ private lastSim;
48
+ private readonly stops;
49
+ private disposed;
50
+ readonly busy: Readable<ReadonlySet<OperationName>>;
51
+ readonly failure: Readable<Failure | null>;
52
+ constructor(src: ActionSources,
53
+ /** Where the ids start (they must differ between pages that send to the same run). */
54
+ idStart?: number);
55
+ start(intent?: Intent, options?: {
56
+ file?: string;
57
+ }): Promise<void>;
58
+ /**
59
+ * Checks what `intent` would start (`api/check`). Its failure is the caller's: it is not kept for `status.problem`.
60
+ * One check at a time: a check is sent after the answer to the one before (the server runs them one at a time, and
61
+ * refuses with `check-busy` when too many wait). A check of the same request as one that waits or is on its way
62
+ * shares it (the parts and the screen of a page check the same page intent); with `fresh`, only one that waits (a
63
+ * check that the user asks for again reads the file as it is now). A check whose callers have all aborted
64
+ * (`signal`) while it waits is not sent, and neither is one that waits when the client closes (`closed`).
65
+ */
66
+ check(intent?: Intent, options?: {
67
+ file?: string;
68
+ text?: string;
69
+ signal?: AbortSignal;
70
+ fresh?: boolean;
71
+ }): Promise<CheckResult>;
72
+ /** Reads a configuration file as it is saved. Its failure is the caller's: it is not kept for `status.problem`. */
73
+ readConfig(options?: {
74
+ file?: string;
75
+ }): Promise<ConfigText>;
76
+ /** Saves a text as a configuration file. Its failure is the caller's: it is not kept for `status.problem`. */
77
+ saveConfig(options: {
78
+ file?: string;
79
+ text: string;
80
+ stamp: string | null;
81
+ }): Promise<SavedConfig>;
82
+ /** Describes the participants of the saved file again. It waits in the line of the checks; it shares only with a describe of the same file and variant. */
83
+ describeAgain(options?: {
84
+ file?: string;
85
+ variant?: string;
86
+ }): Promise<CheckResult>;
87
+ /** The line of the checks: one is sent after the answer to the one before. `key` null: nothing is shared. */
88
+ private enqueue;
89
+ /** The body of api/run and api/check for `intent`, or why it cannot be sent. */
90
+ private requestOf;
91
+ /** The body of api/check for a text: the server takes only the configuration (`variant`, `strict`), not a run's choices. */
92
+ private textRequestOf;
93
+ /** What the client refuses before it sends a start: the connection, and a start of this page still on its way. */
94
+ private refusalOfStart;
95
+ stop(): Promise<void>;
96
+ forceStop(): Promise<void>;
97
+ /** A stop asked again while its request is on its way is the same request (a double click sends nothing more). */
98
+ private once;
99
+ private guarded;
100
+ pause(): Promise<void>;
101
+ resume(): Promise<void>;
102
+ step(ms: number): Promise<void>;
103
+ setSpeed(value: number | 'max'): Promise<void>;
104
+ runUntil(ms: number): Promise<void>;
105
+ private time;
106
+ /** Ends a waiting command: with an error, or (null) as done. A command ended twice is ended once. */
107
+ private settle;
108
+ private stillSent;
109
+ private setBusy;
110
+ /** The launcher's events: an answer to a command of ours, and commands of other senders. */
111
+ private onMessages;
112
+ private answered;
113
+ /** Ends the steps and run_untils on their way (except `keep`) as interrupted. */
114
+ private interruptMoving;
115
+ /** Ends what the state of the run decides: the run is over, time has arrived, or a stop is on its way. */
116
+ private evaluate;
117
+ /** Keeps the error for `status.problem`. */
118
+ record(error: ActionError): ActionError;
119
+ private fail;
120
+ /** Stops waiting (the client closes): what is waiting ends as unknown, and a check that waits is not sent. */
121
+ dispose(): void;
122
+ }
@@ -0,0 +1,61 @@
1
+ import type { ConnectionState } from './connection.js';
2
+ import type { AppInfo, ServerAllowed } from './protocol.js';
3
+ import { SessionView } from './session-state.js';
4
+ import type { Control, FrontClock, FrontControls, FrontResult, FrontStatus, Link, OperationName, Reason, RunState } from './front-types.js';
5
+ /** Everything the composition reads. */
6
+ export interface Snapshot {
7
+ connection: ConnectionState;
8
+ /** How many times the socket closed before it opened. */
9
+ failures: number;
10
+ /** The socket was closed at least once since it last received a notification. */
11
+ closedBefore: boolean;
12
+ rejected: boolean;
13
+ /** Why the versions differ (null if they match). */
14
+ incompatible: string | null;
15
+ /** The session copy matches the server. */
16
+ ready: boolean;
17
+ session: SessionView | null;
18
+ /** What the GUI server accepts (null until it says). */
19
+ allowed: ServerAllowed | null;
20
+ limits: AppInfo['limits'];
21
+ /** Operations of this page whose request has not been answered yet. */
22
+ busy: ReadonlySet<OperationName>;
23
+ }
24
+ export declare function linkOf(s: Snapshot): Link;
25
+ export declare function runOf(s: Snapshot): RunState;
26
+ export declare function resultFor(s: Snapshot, run: RunState): FrontResult | null;
27
+ export declare function statusOf(s: Snapshot, initialFile: string | null): Omit<FrontStatus, 'problem'>;
28
+ /**
29
+ * Where virtual time is, as far as the session copy knows: the last time event, or the time the launcher's state says
30
+ * it stands still at (`paused_at_ms`), whichever is later. The state can be ahead of the time events: the launcher
31
+ * writes the time event of a standstill at its next look.
32
+ */
33
+ export declare function simMsOf(session: SessionView | null): number | null;
34
+ /**
35
+ * Where the launcher's latest state says the run stands still (`paused_at_ms`), or null: not paused, or paused but not
36
+ * yet standing at a time (a run_until to a time already passed, at the maximum speed, until the next step). A time event
37
+ * is not used: the last one can be from before the run stood still.
38
+ */
39
+ export declare function standsAt(session: SessionView | null): number | null;
40
+ /**
41
+ * Whether a step or a run_until that the launcher accepted has not been seen to arrive. It has arrived when the latest
42
+ * state says the run stands still at or after the `at_ms` of its command event (standsAt). Another command after it (a
43
+ * pause, a resume) ends the question (it is then the last command), and so does the end of the run.
44
+ */
45
+ export declare function onItsWay(session: SessionView | null): boolean;
46
+ export declare function clockOf(s: Snapshot): FrontClock;
47
+ export declare function controlsOf(s: Snapshot, run: RunState): FrontControls;
48
+ /** Whether the launcher takes a write now (`state.allowed.write` with the connection and the run). Not in `controls`: a variable says whether it can be written, and uses this. */
49
+ export declare function writeOf(s: Snapshot, run: RunState): Control;
50
+ /** What `status.problem` chooses from besides the connection. */
51
+ export interface Candidate {
52
+ /** Later is newer. */
53
+ stamp: number;
54
+ problem: Reason;
55
+ }
56
+ /** The connection's problem, if it has one (it beats every other). */
57
+ export declare function linkProblem(s: Snapshot): Reason | null;
58
+ /** The newest of the candidates (null if none). */
59
+ export declare function newest(candidates: readonly Candidate[]): Reason | null;
60
+ /** Structural equality of plain data (what the front's values are made of). */
61
+ export declare function sameData(a: unknown, b: unknown): boolean;
@@ -0,0 +1,19 @@
1
+ import type { GuiClient } from './client.js';
2
+ import type { Connections } from './protocol.js';
3
+ import type { ConnectEntry, Outside } from './front-types.js';
4
+ import { ErrorSink, Readable } from './values.js';
5
+ /**
6
+ * The entries of every backend of the answer, in its order: the targets of a backend that listed, and one entry with
7
+ * the launcher's sentence for a backend that could not (`list.error`). An error finding of the answer (a file that
8
+ * cannot be read) is an entry of its own, after them. A target without a `value` is left out.
9
+ */
10
+ export declare function entriesOf(answer: Connections): ConnectEntry[];
11
+ /**
12
+ * The rows of `front.outside`: `outside[]` of the launcher's last `state` while the launcher of the run runs, each with
13
+ * the counts of the last `outside` event of its network in that run (null until one has arrived on this page: the
14
+ * server does not send old ones again after a reconnect). Returns the value and the function that stops it.
15
+ */
16
+ export declare function outsideRows(low: GuiClient, onError: ErrorSink): {
17
+ value: Readable<readonly Outside[]>;
18
+ stop: () => void;
19
+ };