@vehicle-sil/gui-client 0.4.0-rc.1 → 0.5.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/README.ja.md +68 -54
- package/README.md +68 -54
- package/dist/index.js +347 -89
- package/package.json +1 -1
- package/types/client.d.ts +16 -8
- package/types/front-types.d.ts +8 -2
- package/types/front.d.ts +2 -2
- package/types/http.d.ts +4 -2
- package/types/index.d.ts +2 -2
- package/types/protocol/launcher.d.ts +17 -0
- package/types/protocol/server.d.ts +8 -0
- package/types/session-state.d.ts +8 -0
- package/types/session.d.ts +8 -2
- package/types/time.d.ts +8 -0
- package/types/variable-binding.d.ts +6 -2
- package/types/variable-state.d.ts +5 -0
- package/types/variables.d.ts +23 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vehicle-sil/gui-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Client library of the vehicle-sil GUI server: connection, run and time control, ECU variables. No dependencies; browser and Node.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/types/client.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { HttpTransport } from './http.js';
|
|
|
3
3
|
import { AppInfo, CheckRequest, CheckTextRequest, ConfigText, DescribeRequest, CheckResult, ConfigList, Connections, ConnectionsRequest, DashboardResponse, PrepareRequest, PrepareResponse, Recording, SaveConfigRequest, SavedConfig, ScenarioList } from './protocol.js';
|
|
4
4
|
import { ClientRun, RunControl } from './run.js';
|
|
5
5
|
import { ClientSession } from './session.js';
|
|
6
|
-
import { ClientTime } from './time.js';
|
|
6
|
+
import { ClientTime, SendResult } from './time.js';
|
|
7
7
|
import { ClientVariables } from './variables.js';
|
|
8
8
|
import { ErrorSink, Readable } from './values.js';
|
|
9
9
|
/**
|
|
@@ -22,11 +22,11 @@ export interface ClientOptions {
|
|
|
22
22
|
*/
|
|
23
23
|
baseUrl: string;
|
|
24
24
|
/**
|
|
25
|
-
* The token (what follows `#token=` in the URL the server printed). A function is called each time the
|
|
26
|
-
* used.
|
|
27
|
-
* reconnect (create a new client instead).
|
|
25
|
+
* The token (what follows `#token=` in the URL the server printed), if required. A function is called each time the
|
|
26
|
+
* token is used. Omit or return null when connecting to a server started with `--no-auth`. Switching to another
|
|
27
|
+
* token after a refusal does not reconnect (create a new client instead).
|
|
28
28
|
*/
|
|
29
|
-
token
|
|
29
|
+
token?: string | null | (() => string | null);
|
|
30
30
|
/**
|
|
31
31
|
* Origin to send with POST and the WebSocket handshake. Not needed in browsers, which add it themselves. In Node,
|
|
32
32
|
* the origin of baseUrl is sent if omitted (the server accepts only its own origin). Do not pass it in a Web Worker
|
|
@@ -74,7 +74,7 @@ export interface GuiClient {
|
|
|
74
74
|
readonly app: Readable<AppInfo | null>;
|
|
75
75
|
/** Speed range and the limits of stepping and checks (the limits of app; DEFAULT_LIMITS until then). */
|
|
76
76
|
readonly limits: Readable<AppInfo['limits']>;
|
|
77
|
-
/** Connects through WebSocket (does nothing
|
|
77
|
+
/** Connects through WebSocket (does nothing after a refusal or after a version mismatch). */
|
|
78
78
|
connect(): void;
|
|
79
79
|
/** Disconnects and stops pending timers. */
|
|
80
80
|
close(): void;
|
|
@@ -138,10 +138,18 @@ export declare function isNode(runtime?: object): boolean;
|
|
|
138
138
|
/** Default Origin outside the browser: the server's own origin on Node, none elsewhere. */
|
|
139
139
|
export declare function defaultOrigin(baseUrl: string, runtime?: object): string | undefined;
|
|
140
140
|
/** Creates a client for the GUI server. Creating it does not connect (call connect()). */
|
|
141
|
-
export declare function createClient(options: ClientOptions): GuiClient
|
|
141
|
+
export declare function createClient(options: ClientOptions): GuiClient & {
|
|
142
|
+
readonly time: ClientTime & {
|
|
143
|
+
runUntil(atMs: number): SendResult;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
142
146
|
/** What the front (front.ts) needs besides the client: the transport and the error sink. */
|
|
143
147
|
export interface ClientParts {
|
|
144
|
-
client: GuiClient
|
|
148
|
+
client: GuiClient & {
|
|
149
|
+
readonly time: ClientTime & {
|
|
150
|
+
runUntil(atMs: number): SendResult;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
145
153
|
http: HttpTransport;
|
|
146
154
|
onError: ErrorSink;
|
|
147
155
|
runControl: RunControl;
|
package/types/front-types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GuiClient } from './client.js';
|
|
2
2
|
import type { RunTarget } from './session.js';
|
|
3
|
-
import type { CheckResult, ConfigList, ConfigText, SavedConfig, Finding, OutsideState, Recording, RunAck, RunEnd, RuntimeStatus, ScenarioFile, ScenarioStatus, ScenarioStep } from './protocol.js';
|
|
3
|
+
import type { AfterScenario, CheckResult, ConfigList, ConfigText, SavedConfig, Finding, OutsideState, Recording, RunAck, RunEnd, RuntimeStatus, ScenarioFile, ScenarioStatus, ScenarioStep } from './protocol.js';
|
|
4
4
|
import type { ValueCondition, WriteBlock, WriteStatus } from './variable-state.js';
|
|
5
5
|
import type { VariableRef, VariableValue } from './variables.js';
|
|
6
6
|
import type { Readable } from './values.js';
|
|
@@ -97,6 +97,8 @@ export interface FrontScenario {
|
|
|
97
97
|
file: string;
|
|
98
98
|
name: string | null;
|
|
99
99
|
status: ScenarioStatus | null;
|
|
100
|
+
handed_over: boolean;
|
|
101
|
+
over_at_ms: number | null;
|
|
100
102
|
steps: readonly ScenarioStep[];
|
|
101
103
|
/** Where the server serves the timeline of the run (null until the run has ended with one). */
|
|
102
104
|
timeline_url: string | null;
|
|
@@ -133,6 +135,8 @@ export interface Intent {
|
|
|
133
135
|
* the path the request file needs, which is relative to the configuration file's directory). Do not compose it.
|
|
134
136
|
*/
|
|
135
137
|
scenario?: string;
|
|
138
|
+
/** What to do once the scenario passes (`stop`, or `pause` to hand over to manual control). */
|
|
139
|
+
after_scenario?: AfterScenario;
|
|
136
140
|
variant?: string;
|
|
137
141
|
params?: Record<string, string | number | boolean>;
|
|
138
142
|
speed?: number | 'max';
|
|
@@ -259,7 +263,9 @@ export interface VariableView {
|
|
|
259
263
|
*/
|
|
260
264
|
export interface FrontVariable extends Readable<VariableView> {
|
|
261
265
|
/** 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
|
|
266
|
+
write(value: number | boolean | string, options?: {
|
|
267
|
+
keepalive?: boolean;
|
|
268
|
+
}): Promise<void>;
|
|
263
269
|
}
|
|
264
270
|
/** The front door: `connect()` returns it. */
|
|
265
271
|
export interface Front {
|
package/types/front.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ import { ErrorSink, Readable } from './values.js';
|
|
|
7
7
|
export interface ConnectOptions {
|
|
8
8
|
/** URL of the GUI server (what the server printed, without `#token=...`). */
|
|
9
9
|
base_url: string;
|
|
10
|
-
/** The token (what follows `#token=`). A function is called each time the token is used. */
|
|
11
|
-
token
|
|
10
|
+
/** The token (what follows `#token=`), if required. A function is called each time the token is used. */
|
|
11
|
+
token?: string | null | (() => string | null);
|
|
12
12
|
/** Origin to send (Node sends the origin of `base_url` if omitted). */
|
|
13
13
|
origin?: string;
|
|
14
14
|
/** HTTP transport (default: fetch). For tests. */
|
package/types/http.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export interface HttpRequest {
|
|
|
7
7
|
body?: unknown;
|
|
8
8
|
/** How long to wait for the answer (ms). Omitted: the transport's default (DEFAULT_TIMEOUT_MS for fetchTransport). */
|
|
9
9
|
timeoutMs?: number;
|
|
10
|
+
/** Forwarded to fetch() as `keepalive` so a request sent during `pagehide` can outlive the page. */
|
|
11
|
+
keepalive?: boolean;
|
|
10
12
|
}
|
|
11
13
|
/** Default time to wait for an answer (ms). A check (`api/check`) waits for the server's check limit plus this. */
|
|
12
14
|
export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
@@ -52,8 +54,8 @@ export declare function errorMessage(error: unknown): string;
|
|
|
52
54
|
export interface FetchTransportOptions {
|
|
53
55
|
/** URL of the server (`http://127.0.0.1:<port>/`). Request paths are relative to it. */
|
|
54
56
|
baseUrl: string;
|
|
55
|
-
/** The token (what follows `#token=` in the URL the server printed). A function is called for each request. */
|
|
56
|
-
token
|
|
57
|
+
/** The token (what follows `#token=` in the URL the server printed), if required. A function is called for each request. */
|
|
58
|
+
token?: string | null | (() => string | null);
|
|
57
59
|
/**
|
|
58
60
|
* Origin to send with POST. Browsers add it themselves (a value given here is not used). Outside the browser (Node
|
|
59
61
|
* and so on), pass the server's own origin (the origin of baseUrl).
|
package/types/index.d.ts
CHANGED
|
@@ -22,10 +22,10 @@ export { BATCH_MS, TRY_AGAIN_LATER, webSocketFactory } from './connection.js';
|
|
|
22
22
|
export type { SocketFactory, SocketHandlers, SocketLike } from './connection.js';
|
|
23
23
|
export { DEFAULT_TIMEOUT_MS, HttpError, errorMessage, fetchTransport } from './http.js';
|
|
24
24
|
export type { FetchTransportOptions, HttpOutcome, HttpRequest, HttpTransport } from './http.js';
|
|
25
|
-
export { isHolding, isLauncherAlive, isLauncherFinishing, isRunActive, isSessionRunning, launcherAnswer, phaseIndex, runOutcome, } from './session-state.js';
|
|
25
|
+
export { isHolding, isLauncherAlive, isLauncherFinishing, isRunActive, isScenarioHandedOver, isScenarioRunning, isSessionRunning, launcherAnswer, phaseIndex, runOutcome, } from './session-state.js';
|
|
26
26
|
export type { CommandView, LauncherAnswer, LauncherView, LogLine, LogSource, ParticipantView, RunOutcome, ScenarioView, SessionView, TimeView, } from './session-state.js';
|
|
27
27
|
export { PHASES, PROTOCOL_VERSION, ProtocolError, readAppInfo, readCheckResponse, readConfigList, readConfigText, readSavedConfig, readConnections, readDashboardResponse, readPrepareResponse, readRecording, readRunResponse, readRuntimeStatus, readScenarioList, readServerMessage, readSessionAllowed, readSessionResponse, readSessionRuntime, 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, LauncherMode, LogCounts, Open, OutsideState, ParticipantRole, ParticipantState, Phase, PrepareRequest, PrepareResponse, Recording, Replay, RunAck, RunParticipant, RunRequest, RunResult, RunEnd, RunResultName, RunTiming, RunTraffic, RuntimeMode, RuntimeState, RuntimeStatus, ScenarioFile, ScenarioList, ScenarioResult, ScenarioStatus, ScenarioStep, ScenarioStepStatus, ServerAllowed, ServerAllowedItem, ServerSaveItem, ServerMessage, ServerProblem, SessionSummary, Severity, Speed, StateReport, StopRequest, StopSessionRequestBody, SummaryCommand, SummaryLauncher, SummaryParticipant, SummaryScenario, SummaryState, TimeAnswer, TimeCommand, TimeCommandName, TimeReport, TrafficNetwork, TrafficParticipant, TrafficUnplaced, ValuesMessage, Variable, VariableSummary, VariablesSummary, OperationReport, VariableAvailability, WatchMessage, WriteAnswer, } from './protocol.js';
|
|
28
|
+
export type { AfterScenario, 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, LauncherMode, LogCounts, Open, OutsideState, ParticipantRole, ParticipantState, Phase, PrepareRequest, PrepareResponse, Recording, Replay, RunAck, RunParticipant, RunRequest, RunResult, RunEnd, RunResultName, RunTiming, RunTraffic, RuntimeMode, RuntimeState, RuntimeStatus, ScenarioFile, ScenarioList, ScenarioResult, ScenarioStatus, ScenarioStep, ScenarioStepStatus, ServerAllowed, ServerAllowedItem, ServerSaveItem, ServerMessage, ServerProblem, SessionSummary, Severity, Speed, StateReport, StopRequest, 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
29
|
export { createWaveforms } from './waveforms.js';
|
|
30
30
|
export type { Waveforms, WaveformSeries } from './waveforms.js';
|
|
31
31
|
export { createVariableEditor } from './variable-editor.js';
|
|
@@ -55,6 +55,15 @@ export interface Variable extends FromLauncher {
|
|
|
55
55
|
unit: string;
|
|
56
56
|
min: number | null;
|
|
57
57
|
max: number | null;
|
|
58
|
+
/** Suggested increment for editing (not enforced). null if not set or from an older launcher. */
|
|
59
|
+
step?: number | null;
|
|
60
|
+
/** Description of the variable (empty string when absent or from an older launcher). */
|
|
61
|
+
description?: string | null;
|
|
62
|
+
/** Enum items (`[]` for non-enums or when absent from an older launcher; null if explicitly null). */
|
|
63
|
+
items?: (FromLauncher & {
|
|
64
|
+
name: string;
|
|
65
|
+
value: number;
|
|
66
|
+
})[] | null;
|
|
58
67
|
/**
|
|
59
68
|
* true for a variable vehicle-sil adds to every ECU (`ecu.connected` and so on), false for a variable the ECU
|
|
60
69
|
* declared. null from an older launcher that does not write it.
|
|
@@ -98,6 +107,8 @@ export interface CheckScenario extends FromLauncher {
|
|
|
98
107
|
name: string | null;
|
|
99
108
|
/** Number of steps. */
|
|
100
109
|
steps: number;
|
|
110
|
+
/** Virtual end time from the scenario file (`end_ms`), or null if omitted. */
|
|
111
|
+
end_ms?: number | null;
|
|
101
112
|
}
|
|
102
113
|
/** `scenario` of the run result (only with `--scenario`). */
|
|
103
114
|
export interface ScenarioResult extends FromLauncher {
|
|
@@ -106,6 +117,8 @@ export interface ScenarioResult extends FromLauncher {
|
|
|
106
117
|
status: ScenarioStatus;
|
|
107
118
|
/** The controller step at which the scenario ended (passed and failed; null otherwise). */
|
|
108
119
|
over_at_ms: number | null;
|
|
120
|
+
/** Virtual end time from the scenario file (`end_ms`), or null if omitted. */
|
|
121
|
+
end_ms?: number | null;
|
|
109
122
|
steps: ScenarioStep[];
|
|
110
123
|
}
|
|
111
124
|
export type CheckStatus = Open<'described' | 'not_described' | 'not_checked' | 'failed' | 'skipped' | 'disabled'>;
|
|
@@ -560,6 +573,10 @@ export interface StateReport {
|
|
|
560
573
|
} | null;
|
|
561
574
|
/** Whether the run plays a scenario. */
|
|
562
575
|
scenario: boolean | null;
|
|
576
|
+
/** Whether the scenario has passed and handed over to manual control. */
|
|
577
|
+
handed_over?: boolean;
|
|
578
|
+
/** Virtual time (ms) at which the scenario completed and handed over, or null. */
|
|
579
|
+
scenario_over_at_ms?: number | null;
|
|
563
580
|
/** The operations: pause, resume, step, speed, run_until, stop, write. */
|
|
564
581
|
allowed: Record<string, LauncherAllowedItem>;
|
|
565
582
|
/**
|
|
@@ -84,6 +84,8 @@ export interface ConfigList {
|
|
|
84
84
|
truncated: boolean;
|
|
85
85
|
}
|
|
86
86
|
export declare const readConfigList: (value: unknown) => ConfigList;
|
|
87
|
+
/** What the launcher does once a scenario passes. */
|
|
88
|
+
export type AfterScenario = 'stop' | 'pause';
|
|
87
89
|
/**
|
|
88
90
|
* Body of POST api/check: `file` (this server's field) and the keys of the request file that the launcher reads
|
|
89
91
|
* (`schema/run-request.schema.json`), with the same names and value forms. A key that is not wanted is left out: there
|
|
@@ -102,6 +104,8 @@ export interface CheckRequest {
|
|
|
102
104
|
manual?: string[];
|
|
103
105
|
/** The scenario (`path` from `GET api/scenarios`; only one in the list for that configuration file). */
|
|
104
106
|
scenario?: string;
|
|
107
|
+
/** What to do after the scenario passes (`stop`, or `pause` to hand over to manual control). */
|
|
108
|
+
after_scenario?: AfterScenario;
|
|
105
109
|
/** The variant of the configuration file. */
|
|
106
110
|
variant?: string;
|
|
107
111
|
/** Values of the scenario's parameters (name to value); used only when a scenario runs. */
|
|
@@ -203,6 +207,8 @@ export interface Recording {
|
|
|
203
207
|
omitted: number;
|
|
204
208
|
/** Number of steps (`set`) in the YAML. */
|
|
205
209
|
steps: number;
|
|
210
|
+
/** Finalized end virtual time (ms) of the run once ended, or null while running / unavailable. */
|
|
211
|
+
end_ms: number | null;
|
|
206
212
|
/** Scenario YAML. null while no write has been applied yet. */
|
|
207
213
|
yaml: string | null;
|
|
208
214
|
}
|
|
@@ -412,6 +418,8 @@ export interface SummaryScenario {
|
|
|
412
418
|
/** status of the result (null until there is a result). */
|
|
413
419
|
status: ScenarioStatus | null;
|
|
414
420
|
over_at_ms: number | null;
|
|
421
|
+
/** Whether the scenario passed and handed over to manual control. */
|
|
422
|
+
handed_over?: boolean;
|
|
415
423
|
/**
|
|
416
424
|
* Where the server serves the run's timeline file (`api/timeline/<session id>`, relative to the server's URL; needs
|
|
417
425
|
* the token): set at the end of a run whose launcher wrote one, else null.
|
package/types/session-state.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export declare const MAX_FINDINGS = 500;
|
|
|
32
32
|
export interface LogLine {
|
|
33
33
|
/** seq of the event. A marker for dropped lines has the seq of the line before it + 0.5 (markers may share a seq). */
|
|
34
34
|
seq: number;
|
|
35
|
+
/** Real time since the launcher started (ms, from `event.t_ms`; null when absent or on server-dropped markers). */
|
|
36
|
+
tMs?: number | null;
|
|
35
37
|
/** Key the screen tells lines apart by (unique within the session, markers included). */
|
|
36
38
|
key: string;
|
|
37
39
|
/** The participant name, or `vehicle_sil_launch`. */
|
|
@@ -160,6 +162,8 @@ export interface ScenarioView {
|
|
|
160
162
|
stepsOmitted: number;
|
|
161
163
|
/** Result of the scenario (passed, failed, incomplete, not_run). null until there is a result. */
|
|
162
164
|
status: ScenarioStatus | null;
|
|
165
|
+
/** Whether the scenario passed and handed over to manual control. */
|
|
166
|
+
handedOver: boolean;
|
|
163
167
|
/** Virtual time at which the scenario ended. */
|
|
164
168
|
overAtMs: number | null;
|
|
165
169
|
/**
|
|
@@ -271,6 +275,10 @@ export declare function isLauncherAlive(session: SessionView | SessionSummary |
|
|
|
271
275
|
* events, and a variable written is applied in the step at time 0.
|
|
272
276
|
*/
|
|
273
277
|
export declare function isHolding(session: SessionView | null): boolean;
|
|
278
|
+
/** Whether the run's scenario has passed and handed over to manual control. */
|
|
279
|
+
export declare function isScenarioHandedOver(session: SessionView | SessionSummary | null | undefined): boolean;
|
|
280
|
+
/** Whether the run's scenario is still actively executing (not handed over and no verdict yet). */
|
|
281
|
+
export declare function isScenarioRunning(session: SessionView | SessionSummary | null | undefined): boolean;
|
|
274
282
|
export declare function runOutcome(session: SessionView): RunOutcome;
|
|
275
283
|
/** Builds a session from the server's summary (hello, a new session). The log arrives in the resend that follows. */
|
|
276
284
|
export declare function sessionFromSummary(summary: SessionSummary): SessionView;
|
package/types/session.d.ts
CHANGED
|
@@ -95,13 +95,15 @@ export declare class SessionFeed implements ClientSession {
|
|
|
95
95
|
private readonly connection;
|
|
96
96
|
private readonly onError;
|
|
97
97
|
private readonly onInstance?;
|
|
98
|
+
private readonly hooks?;
|
|
98
99
|
private readonly rawListeners;
|
|
99
100
|
private instanceId;
|
|
100
101
|
private lastStreamSeq;
|
|
101
102
|
private resyncing;
|
|
103
|
+
private syncedFlag;
|
|
102
104
|
private stopTarget;
|
|
103
105
|
private readonly current;
|
|
104
|
-
private readonly
|
|
106
|
+
private readonly readyValue;
|
|
105
107
|
private readonly allowedValue;
|
|
106
108
|
private readonly runtimeValue;
|
|
107
109
|
private readonly receivedAt;
|
|
@@ -119,9 +121,13 @@ export declare class SessionFeed implements ClientSession {
|
|
|
119
121
|
readonly notices: Readable<readonly Notice[]>;
|
|
120
122
|
readonly rejected: Readable<boolean>;
|
|
121
123
|
readonly incompatible: Readable<string | null>;
|
|
122
|
-
constructor(connection: Connection, onError?: ErrorSink, onInstance?: ((instance: string) => void) | undefined
|
|
124
|
+
constructor(connection: Connection, onError?: ErrorSink, onInstance?: ((instance: string) => void) | undefined, hooks?: {
|
|
125
|
+
beforeRunSwitch?: (beforeBatch: readonly unknown[], skippedBatch: readonly unknown[], current: () => boolean) => void;
|
|
126
|
+
stageRunSwitch?: (instance: string | null, sessionId: string | null, instanceChanged: boolean) => () => void;
|
|
127
|
+
} | undefined);
|
|
123
128
|
/** Refused, or the versions differ: never connect again (set before the readable values and before disconnecting). */
|
|
124
129
|
get stopped(): boolean;
|
|
130
|
+
private setSyncedDeferred;
|
|
125
131
|
/**
|
|
126
132
|
* Fields to add to the authentication message: where in the stream it holds the server should resend from. Called
|
|
127
133
|
* on every connect (after the call, the copy is not in sync until hello and the resent events have arrived). Used
|
package/types/time.d.ts
CHANGED
|
@@ -77,6 +77,10 @@ export interface ClientTime {
|
|
|
77
77
|
* While paused, advances virtual time by ms and pauses again (the launcher rounds up to a multiple of the time step).
|
|
78
78
|
*/
|
|
79
79
|
step(ms: number): SendResult;
|
|
80
|
+
/**
|
|
81
|
+
* Advances virtual time until atMs and pauses there (the launcher rounds up to a multiple of the time step).
|
|
82
|
+
*/
|
|
83
|
+
runUntil?(atMs: number): SendResult;
|
|
80
84
|
/** Changes the speed (a pause stays in effect). */
|
|
81
85
|
setSpeed(value: number | 'max'): SendResult;
|
|
82
86
|
/**
|
|
@@ -118,6 +122,10 @@ export declare class TimeControl implements ClientTime {
|
|
|
118
122
|
* While paused, advances virtual time by ms and pauses again (the launcher rounds up to a multiple of the time step).
|
|
119
123
|
*/
|
|
120
124
|
step(ms: number): SendResult;
|
|
125
|
+
/**
|
|
126
|
+
* Advances virtual time until atMs and pauses there (the launcher rounds up to a multiple of the time step).
|
|
127
|
+
*/
|
|
128
|
+
runUntil(atMs: number): SendResult;
|
|
121
129
|
/** Changes the speed (a pause stays in effect). */
|
|
122
130
|
setSpeed(value: number | 'max'): SendResult;
|
|
123
131
|
/**
|
|
@@ -110,8 +110,12 @@ export interface BindingSources {
|
|
|
110
110
|
readonly state: Readable<VariablesState>;
|
|
111
111
|
watch(variables: readonly VariableRef[], options?: WatchOptions): VariableWatch;
|
|
112
112
|
write(writes: Record<string, Record<string, number | boolean | string>>, options?: WriteOptions): Promise<OperationView>;
|
|
113
|
+
isStale?(ref: VariableRef): boolean;
|
|
114
|
+
runEpoch?(): number;
|
|
113
115
|
};
|
|
114
116
|
readonly connection: Readable<ConnectionState>;
|
|
117
|
+
/** Optional session sync readiness (`session.ready`). Falls back to `connection === 'open'` when omitted. */
|
|
118
|
+
readonly ready?: Readable<boolean>;
|
|
115
119
|
readonly connectionEpoch: () => number;
|
|
116
120
|
readonly session: Readable<SessionView | null>;
|
|
117
121
|
readonly onError: ErrorSink;
|
|
@@ -125,7 +129,7 @@ export interface BindingSources {
|
|
|
125
129
|
export declare class VariableBinder {
|
|
126
130
|
readonly sources: BindingSources;
|
|
127
131
|
private entries;
|
|
128
|
-
private
|
|
132
|
+
private entriesKey;
|
|
129
133
|
/** Per variable, the functions to call when the write status changes (the binds listen). */
|
|
130
134
|
private readonly listeners;
|
|
131
135
|
/** Lookup table of the list (rebuilt when peers change). */
|
|
@@ -140,7 +144,7 @@ export declare class VariableBinder {
|
|
|
140
144
|
find(ref: VariableRef): VariableInfo | undefined;
|
|
141
145
|
/** Whether that participant is connected to the Control Server now. */
|
|
142
146
|
peerConnected(peer: string): boolean;
|
|
143
|
-
/** Whether the connection between the client and the GUI server is open. */
|
|
147
|
+
/** Whether the connection between the client and the GUI server is open and synced. */
|
|
144
148
|
connected(): boolean;
|
|
145
149
|
/**
|
|
146
150
|
* Why the variable cannot be written now (null if it can). Only the widget-independent reasons (Binding adds range
|
|
@@ -48,6 +48,11 @@ export interface ConditionInput {
|
|
|
48
48
|
* last ones read.
|
|
49
49
|
*/
|
|
50
50
|
readFailing?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The cached value was kept across a reconnect to the same run and has not yet been refreshed by a post-reconnect
|
|
53
|
+
* `values` sample.
|
|
54
|
+
*/
|
|
55
|
+
awaitingRefresh?: boolean;
|
|
51
56
|
}
|
|
52
57
|
/** Decides the state of the value. */
|
|
53
58
|
export declare function valueCondition(input: ConditionInput): ValueCondition;
|
package/types/variables.d.ts
CHANGED
|
@@ -180,6 +180,11 @@ export interface WriteOptions {
|
|
|
180
180
|
session: string;
|
|
181
181
|
seq: number;
|
|
182
182
|
}) => void;
|
|
183
|
+
/**
|
|
184
|
+
* Forwarded to the HTTP transport (`HttpRequest.keepalive` -> `fetch(..., { keepalive })`). Set `true` for a
|
|
185
|
+
* release write sent from a browser `pagehide` handler so the request can finish as the page unloads.
|
|
186
|
+
*/
|
|
187
|
+
keepalive?: boolean;
|
|
183
188
|
}
|
|
184
189
|
/**
|
|
185
190
|
* A write that went wrong.
|
|
@@ -301,11 +306,14 @@ export declare class VariablesFeed implements Omit<ClientVariables, 'bind'> {
|
|
|
301
306
|
/** Limits (from limits of api/app; the defaults until then). */
|
|
302
307
|
private readonly limits;
|
|
303
308
|
private instanceId;
|
|
309
|
+
private epoch;
|
|
304
310
|
private readonly stateValue;
|
|
305
311
|
private readonly operationsValue;
|
|
306
312
|
private readonly handles;
|
|
307
313
|
private readonly buckets;
|
|
308
314
|
private readonly readings;
|
|
315
|
+
/** Cached keys kept across a reconnect until a post-reconnect `values` sample arrives. */
|
|
316
|
+
private readonly awaitingRefresh;
|
|
309
317
|
private readonly histories;
|
|
310
318
|
private readonly pending;
|
|
311
319
|
/** Variables someone watches (null: a watch observes all). */
|
|
@@ -334,6 +342,17 @@ export declare class VariablesFeed implements Omit<ClientVariables, 'bind'> {
|
|
|
334
342
|
/** The client was closed: fail the pending writes (including those waiting for the HTTP answer). Watches stay. */
|
|
335
343
|
dispose(): void;
|
|
336
344
|
onInstance(instance: string): void;
|
|
345
|
+
/**
|
|
346
|
+
* Applies messages belonging to the previous session (`beforeBatch`) while `SessionFeed`
|
|
347
|
+
* still holds that session, and processes connection-level resyncs/watch errors across any
|
|
348
|
+
* superseded intermediate runs (`skippedBatch`) before `SessionFeed` commits the final run.
|
|
349
|
+
*/
|
|
350
|
+
beforeRunSwitch(beforeBatch: readonly unknown[], skippedBatch: readonly unknown[], current?: () => boolean): void;
|
|
351
|
+
/**
|
|
352
|
+
* Clears the previous run's observable variable state synchronously before `SessionFeed`
|
|
353
|
+
* notifies `session` subscribers of a new run, returning the deferred variable notifications.
|
|
354
|
+
*/
|
|
355
|
+
stageRunSwitch(instance: string | null, sessionId: string | null, instanceChanged: boolean): () => void;
|
|
337
356
|
private receive;
|
|
338
357
|
/** Returns whether any state changed. Only the availability table changes: `peers` keeps its identity. */
|
|
339
358
|
private takeAvailability;
|
|
@@ -349,6 +368,7 @@ export declare class VariablesFeed implements Omit<ClientVariables, 'bind'> {
|
|
|
349
368
|
* waiting for the previous run's result are failed, since the result will not come.
|
|
350
369
|
*/
|
|
351
370
|
private enter;
|
|
371
|
+
private prepareEnter;
|
|
352
372
|
private takeValues;
|
|
353
373
|
/** Rebuilds values of the watches that observe the changed variables (all watches if touched is null). */
|
|
354
374
|
private publish;
|
|
@@ -364,6 +384,8 @@ export declare class VariablesFeed implements Omit<ClientVariables, 'bind'> {
|
|
|
364
384
|
private settle;
|
|
365
385
|
write(writes: Record<string, Record<string, number | boolean | string>>, options?: WriteOptions): Promise<OperationView>;
|
|
366
386
|
watch(variables: readonly VariableRef[] | 'all', options?: WatchOptions): VariableWatch;
|
|
387
|
+
isStale(ref: VariableRef): boolean;
|
|
388
|
+
runEpoch(): number;
|
|
367
389
|
/**
|
|
368
390
|
* Turns a requested interval into the longest of WATCH_PERIODS_MS that is not longer, kept within the server's range
|
|
369
391
|
* (lower and upper limit).
|
|
@@ -380,5 +402,6 @@ export declare class VariablesFeed implements Omit<ClientVariables, 'bind'> {
|
|
|
380
402
|
private watchMessage;
|
|
381
403
|
/** After watches were added or removed, brings the server subscriptions in line, once for all changes. */
|
|
382
404
|
private queueSync;
|
|
405
|
+
private resyncWatches;
|
|
383
406
|
private sync;
|
|
384
407
|
}
|