@vehicle-sil/gui-client 0.4.0 → 0.6.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.
Files changed (37) hide show
  1. package/README.ja.md +452 -730
  2. package/README.md +452 -728
  3. package/dist/elements.js +656 -47
  4. package/dist/empty.js +2 -0
  5. package/dist/index.js +3362 -1721
  6. package/package.json +13 -1
  7. package/timeline/vehicle-sil-timeline.d.ts +76 -0
  8. package/timeline/vehicle-sil-timeline.js +817 -139
  9. package/timeline/vehicle-sil-timeline.mjs +817 -139
  10. package/types/client.d.ts +24 -3
  11. package/types/connection.d.ts +10 -2
  12. package/types/elements/contracts.d.ts +112 -0
  13. package/types/elements/index.d.ts +5 -3
  14. package/types/elements/outside-parts.d.ts +5 -0
  15. package/types/elements/page-intent.d.ts +1 -1
  16. package/types/elements/part.d.ts +11 -4
  17. package/types/elements/run-parts.d.ts +19 -0
  18. package/types/elements/scenario-parts.d.ts +5 -1
  19. package/types/elements/variable-parts.d.ts +58 -11
  20. package/types/frameworks/all-contracts.d.ts +18 -0
  21. package/types/frameworks/react.d.ts +40 -0
  22. package/types/frameworks/svelte.d.ts +22 -0
  23. package/types/frameworks/vue.d.ts +35 -0
  24. package/types/front-actions.d.ts +18 -0
  25. package/types/front-types.d.ts +67 -6
  26. package/types/front-variable.d.ts +5 -0
  27. package/types/front.d.ts +11 -24
  28. package/types/http.d.ts +4 -0
  29. package/types/index.d.ts +5 -5
  30. package/types/protocol/launcher.d.ts +87 -1
  31. package/types/protocol/server.d.ts +44 -1
  32. package/types/session-state.d.ts +15 -1
  33. package/types/session.d.ts +8 -2
  34. package/types/time.d.ts +8 -0
  35. package/types/variable-binding.d.ts +9 -3
  36. package/types/variable-state.d.ts +5 -0
  37. package/types/variables.d.ts +113 -48
@@ -1,8 +1,8 @@
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, CheckScenarioParam, ConfigList, ConfigText, SavedConfig, Finding, Open, OutsideState, Recording, RunAck, RunEnd, RuntimeStatus, ScenarioFile, ScenarioStatus, ScenarioStep } from './protocol.js';
4
4
  import type { ValueCondition, WriteBlock, WriteStatus } from './variable-state.js';
5
- import type { VariableRef, VariableValue } from './variables.js';
5
+ import type { VariableRef, VariableValue, WriteWaitOptions } from './variables.js';
6
6
  import type { Readable } from './values.js';
7
7
  import type { Reason } from './session-state.js';
8
8
  /** A reason: a code that stays the same and one English sentence (defined with the session copy, which reads them too). */
@@ -96,7 +96,13 @@ export type OperationName = keyof FrontControls;
96
96
  export interface FrontScenario {
97
97
  file: string;
98
98
  name: string | null;
99
+ /** Selected case name, if any. */
100
+ case?: string | null;
101
+ /** Resolved parameters of the scenario, if any. */
102
+ params?: readonly CheckScenarioParam[];
99
103
  status: ScenarioStatus | null;
104
+ handed_over: boolean;
105
+ over_at_ms: number | null;
100
106
  steps: readonly ScenarioStep[];
101
107
  /** Where the server serves the timeline of the run (null until the run has ended with one). */
102
108
  timeline_url: string | null;
@@ -133,6 +139,10 @@ export interface Intent {
133
139
  * the path the request file needs, which is relative to the configuration file's directory). Do not compose it.
134
140
  */
135
141
  scenario?: string;
142
+ /** The named case of the scenario (`cases:`). Requires `scenario`. */
143
+ case?: string;
144
+ /** What to do once the scenario passes (`stop`, or `pause` to hand over to manual control). */
145
+ after_scenario?: AfterScenario;
136
146
  variant?: string;
137
147
  params?: Record<string, string | number | boolean>;
138
148
  speed?: number | 'max';
@@ -149,7 +159,7 @@ export interface Intent {
149
159
  */
150
160
  connect?: Record<string, string>;
151
161
  /** A run connected outside keeps real time (`realtime`, the launcher's default) unless `free` is chosen. */
152
- time_policy?: 'realtime' | 'free';
162
+ time_policy?: Open<'realtime' | 'free'>;
153
163
  }
154
164
  /** A place where a network can be connected, as the bridge of one backend listed it. */
155
165
  export interface ConnectTarget {
@@ -253,13 +263,64 @@ export interface VariableView {
253
263
  block: WriteBlock | null;
254
264
  write_status: WriteStatus;
255
265
  }
266
+ /** Options of `variable.enqueue(value, options)` and `variable.write(value, options)`. */
267
+ export interface FrontWriteOptions {
268
+ /** Virtual time at which to apply the write (ms). Omitted: the next step of the ECU. */
269
+ atMs?: number;
270
+ /** If `atMs` cannot be met: `'reject'` (default; not applied) or `'apply'` (applied in the next step). */
271
+ late?: 'reject' | 'apply';
272
+ /** Watchdog timeout budget (ms; default `WRITE_TIMEOUT_MS`). Must be a finite number greater than 0. */
273
+ timeoutMs?: number;
274
+ /** Forwarded to `fetch(..., { keepalive })` so a release write sent on `pagehide` can outlive the page. */
275
+ keepalive?: boolean;
276
+ /** Aborts the write or wait (`ActionError('aborted', ...)`). */
277
+ signal?: AbortSignal;
278
+ }
279
+ /** Confirmed application of a variable write (`queued.applied()` / `variable.write()`). */
280
+ export interface WriteResult {
281
+ readonly session: string;
282
+ readonly seq: number;
283
+ readonly peer: string;
284
+ readonly name: string;
285
+ readonly value: number | boolean | string;
286
+ readonly appliedAtMs: number | null;
287
+ readonly late: boolean;
288
+ }
289
+ /** Handle returned once the server accepted a variable write and the ECU queued it (`variable.enqueue()`). */
290
+ export interface QueuedWrite {
291
+ readonly session: string;
292
+ readonly seq: number;
293
+ readonly peer: string;
294
+ readonly name: string;
295
+ readonly value: number | boolean | string;
296
+ /** Resolves with `WriteResult` once the ECU applies the write in a step; rejects with `ActionError` otherwise. */
297
+ applied(options?: WriteWaitOptions): Promise<WriteResult>;
298
+ }
256
299
  /**
257
300
  * 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.
301
+ * unsubscribe stops it: there is no close()). `enqueue` and `write` need no subscription.
259
302
  */
260
303
  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>;
304
+ /**
305
+ * Subscribes to changes of this variable's view. Optionally requests a polling interval (`periodMs`, finite
306
+ * `20..60_000` ms; default: the client's `watchPeriodMs`, or `WATCH_PERIOD_MS` = 100) while this subscription is
307
+ * active; the shortest active interval across all subscribers wins, and the slower interval is restored when faster
308
+ * subscribers unsubscribe. Note: latest-value polling at 20 ms does not guarantee capturing pulses shorter than 20 ms.
309
+ */
310
+ subscribe(listener: (value: VariableView) => void, options?: {
311
+ /** Requested polling interval (ms; finite `20..60_000`, rounded to `WATCH_PERIODS_MS`). */
312
+ periodMs?: number;
313
+ }): () => void;
314
+ /**
315
+ * Sends the write and resolves once the server accepted it and the ECU queued it (stages 1+2).
316
+ * Rejects immediately with an `ActionError` if refused or already terminally failed (`invalid`, `busy`, `late`, ...).
317
+ */
318
+ enqueue(value: number | boolean | string, options?: FrontWriteOptions): Promise<QueuedWrite>;
319
+ /**
320
+ * Resolves with `WriteResult` when the value has been applied in an ECU step (`enqueue(v, opts).then(q => q.applied(...))`).
321
+ * Rejects with an `ActionError` (`no-answer` is `unknown`: it is not sent again).
322
+ */
323
+ write(value: number | boolean | string, options?: FrontWriteOptions): Promise<WriteResult>;
263
324
  }
264
325
  /** The front door: `connect()` returns it. */
265
326
  export interface Front {
@@ -8,6 +8,11 @@ import { VariableRef } from './variables.js';
8
8
  export declare function noteOf(condition: ValueCondition): string | null;
9
9
  /** Split `"Peer.variable"` at the first dot (as the scenario files do); an object is taken as it is. */
10
10
  export declare function refOf(ref: string | VariableRef): VariableRef;
11
+ export declare function validateFrontWriteOptions(options: unknown): ActionError | null;
12
+ export declare function validateFrontWaitOptions(options: unknown): ActionError | null;
13
+ export declare function validateFrontSubscribeOptions(options: unknown): {
14
+ periodMs?: number;
15
+ };
11
16
  interface Track {
12
17
  writing: boolean;
13
18
  problem: Reason | null;
package/types/front.d.ts CHANGED
@@ -1,24 +1,14 @@
1
1
  import { ClientOptions } from './client.js';
2
- import type { HttpTransport } from './http.js';
3
- import type { SocketFactory } from './connection.js';
4
2
  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=`), if required. A function is called each time the token is used. */
11
- token?: string | null | (() => 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;
3
+ import { Readable } from './values.js';
4
+ /** Options of `connect()`: the same camelCase options as `createFront()` and `createClient()`. */
5
+ export type ConnectOptions = ClientOptions;
6
+ /** Options of `until()`. */
7
+ export interface UntilOptions {
8
+ /** Maximum wait duration in milliseconds before rejecting with `ActionError('timeout', ..., 'unknown')`. */
9
+ timeoutMs?: number;
10
+ /** Signal to abort the wait with `ActionError('aborted', ..., 'unknown')`. */
11
+ signal?: AbortSignal;
22
12
  }
23
13
  /**
24
14
  * Makes the front door without connecting and without waiting for the server (as `createClient` does for the client
@@ -42,9 +32,6 @@ export declare function watch<T extends unknown[]>(sources: {
42
32
  }, fn: (...values: T) => void): () => void;
43
33
  /**
44
34
  * 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).
35
+ * after `timeoutMs`, or `aborted` when `signal` aborts (`unknown`: the thing waited for may still happen).
46
36
  */
47
- export declare function until<T>(source: Readable<T>, test: (value: T) => boolean, options?: {
48
- timeout_ms?: number;
49
- signal?: AbortSignal;
50
- }): Promise<T>;
37
+ export declare function until<T>(source: Readable<T>, test: (value: T) => boolean, options?: UntilOptions): Promise<T>;
package/types/http.d.ts CHANGED
@@ -7,6 +7,10 @@ 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;
12
+ /** Aborts an in-flight request when triggered. */
13
+ signal?: AbortSignal;
10
14
  }
11
15
  /** Default time to wait for an answer (ms). A check (`api/check`) waits for the server's check limit plus this. */
12
16
  export declare const DEFAULT_TIMEOUT_MS = 30000;
package/types/index.d.ts CHANGED
@@ -6,13 +6,13 @@ export type { ClientRun, StopAction } from './run.js';
6
6
  export type { ClientTime, Lateness, NotSentReason, SendResult, TimeFailure, TimeState, } from './time.js';
7
7
  export { ANSWER_TIMEOUT_MS } from './time.js';
8
8
  export { connect, createFront, until, watch } from './front.js';
9
- export type { ConnectOptions } from './front.js';
9
+ export type { ConnectOptions, UntilOptions } from './front.js';
10
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';
11
+ export type { ConnectEntry, ConnectListError, ConnectTarget, Control, EndKind, Front, FrontClock, FrontControls, FrontResult, FrontRun, FrontScenario, FrontStatus, FrontTime, FrontVariable, FrontWriteOptions, Intent, Link, OperationName, Outside, Pacing, QueuedWrite, Reason, RunState, VariableView, WriteResult, } from './front-types.js';
12
12
  export { TOKEN_STORAGE_KEY, takeToken } from './token.js';
13
13
  export type { TokenPlace } from './token.js';
14
14
  export { HISTORY_MAX, HISTORY_TOTAL_MAX, OPERATIONS_KEPT, WATCH_PERIODS_MS, WATCH_PERIOD_MS, WRITE_TIMEOUT_MS, WriteError, } from './variables.js';
15
- export type { ClientVariables, HistoryPoint, OperationPeer, OperationView, VariableInfo, VariablePeer, VariableReading, VariableRef, VariableValue, VariableWatch, VariablesState, VariablesStatus, WatchOptions, WatchProblem, WatchValues, WriteOptions, } from './variables.js';
15
+ export type { ClientVariables, HistoryPoint, OperationPeer, OperationView, QueuedOperation, VariableInfo, VariablePeer, VariableReading, VariableRef, VariableValue, VariableWatch, VariablesState, VariablesStatus, WatchOptions, WatchProblem, WatchValues, WriteOptions, WriteWaitOptions, } from './variables.js';
16
16
  export { DROPPED_MESSAGE } from './variable-binding.js';
17
17
  export type { BindOptions, BoundVariable, VariableBinding } from './variable-binding.js';
18
18
  export { hasRange, isWriteError, valueCondition, writeBlock } from './variable-state.js';
@@ -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, CheckScenarioCaseDetail, CheckScenarioParam, CheckScenarioParamMeta, 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, ScenarioCallFrame, ScenarioFile, ScenarioList, ScenarioParamType, ScenarioParamValue, ScenarioResult, ScenarioStatus, ScenarioStep, ScenarioStepStatus, ServerAllowed, ServerAllowedItem, ServerSaveItem, ServerMessage, ServerProblem, SessionIntent, 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.
@@ -68,15 +77,54 @@ export interface Variable extends FromLauncher {
68
77
  export type ScenarioStepStatus = Open<'running' | 'passed' | 'failed' | 'unfinished' | 'not_run' | 'skipped'>;
69
78
  /** Overall result of a scenario. */
70
79
  export type ScenarioStatus = Open<'passed' | 'failed' | 'incomplete' | 'not_run'>;
80
+ /** A resolved parameter scalar in a template call-stack frame or check parameter entry. */
81
+ export type ScenarioParamValue = string | number | boolean;
82
+ /** Declared parameter type derived from template parameter definitions. */
83
+ export type ScenarioParamType = Open<'integer' | 'number' | 'boolean' | 'string'>;
84
+ /** Metadata of one named case in a multi-case scenario (`scenario.case_details[]`). */
85
+ export interface CheckScenarioCaseDetail extends FromLauncher {
86
+ name: string;
87
+ /** Variant restriction (`only:`) of the case, or null if unrestricted. */
88
+ only: string[] | null;
89
+ }
90
+ /** Parameter metadata from template definitions (`scenario.param_meta[]`). */
91
+ export interface CheckScenarioParamMeta extends FromLauncher {
92
+ name: string;
93
+ type?: ScenarioParamType | null;
94
+ values?: string[] | null;
95
+ description?: string | null;
96
+ }
97
+ /** One resolved parameter entry (`params[]` of a check or scenario result). */
98
+ export interface CheckScenarioParam extends FromLauncher {
99
+ name: string;
100
+ value: ScenarioParamValue;
101
+ from: string;
102
+ type?: ScenarioParamType | null;
103
+ values?: string[] | null;
104
+ description?: string | null;
105
+ }
106
+ /** One frame in a step's template call stack (outermost to immediate caller). */
107
+ export interface ScenarioCallFrame extends FromLauncher {
108
+ file: string | null;
109
+ line: number | null;
110
+ name: string | null;
111
+ params: Readonly<Record<string, ScenarioParamValue>>;
112
+ }
113
+ export declare const readParamScalar: Reader<ScenarioParamValue>;
114
+ export declare const readCheckScenarioParam: (value: unknown, path: string, u?: Unreadable) => CheckScenarioParam;
71
115
  /**
72
116
  * One scenario step (the `scenario_step` event, `scenario.steps[]` of the result, `scenario.steps[]` of the summary).
73
117
  */
74
118
  export interface ScenarioStep extends FromLauncher {
75
119
  /** From 1. */
76
120
  index: number;
77
- /** Line in the scenario file. */
121
+ /** Source file path when defined in another file (e.g., a template). */
122
+ file?: string | null;
123
+ /** Line in the scenario (or source) file. */
78
124
  line: number | null;
79
125
  kind: Open<'set' | 'ramp' | 'wave' | 'dither' | 'expect' | 'wait_until'>;
126
+ /** Optional human-readable step name. */
127
+ name?: string | null;
80
128
  /** Text of the step (shown in English, unchanged). */
81
129
  text: string;
82
130
  status: ScenarioStepStatus;
@@ -89,6 +137,8 @@ export interface ScenarioStep extends FromLauncher {
89
137
  /** code and text of the failure finding (shown in English, unchanged). */
90
138
  code: string | null;
91
139
  message: string | null;
140
+ /** Caller frames when expanded from templates (outermost first). */
141
+ call_stack?: ScenarioCallFrame[] | null;
92
142
  }
93
143
  export declare const readScenarioStep: (value: unknown, path: string, u?: Unreadable) => ScenarioStep;
94
144
  /** `scenario` of the check result (only with `--scenario`). */
@@ -96,16 +146,42 @@ export interface CheckScenario extends FromLauncher {
96
146
  /** The scenario file (as passed to the launcher). */
97
147
  file: string;
98
148
  name: string | null;
149
+ /** Selected case name, or null if omitted. */
150
+ case?: string | null;
151
+ /** Available case names when the scenario defines `cases:`. */
152
+ cases?: string[];
153
+ /** Case metadata including variant restrictions (`only`). */
154
+ case_details?: CheckScenarioCaseDetail[];
99
155
  /** Number of steps. */
100
156
  steps: number;
157
+ /** Variant restriction (`only:`) of the scenario, if any. */
158
+ only?: string[];
159
+ /** Resolved parameters and their provenance/metadata. */
160
+ params?: CheckScenarioParam[];
161
+ /** Template parameter metadata (including parameters missing a value). */
162
+ param_meta?: CheckScenarioParamMeta[];
163
+ /** Required parameter names that have no value yet. */
164
+ missing_params?: string[];
165
+ /** Number of skipped steps when variables are absent in the variant. */
166
+ skipped_steps?: number;
167
+ /** Number of unchecked expect steps. */
168
+ unchecked_expects?: number;
169
+ /** Virtual end time from the scenario file (`end_ms`), or null if omitted. */
170
+ end_ms?: number | null;
101
171
  }
102
172
  /** `scenario` of the run result (only with `--scenario`). */
103
173
  export interface ScenarioResult extends FromLauncher {
104
174
  file: string;
105
175
  name: string | null;
176
+ /** Selected case name, or null if omitted. */
177
+ case?: string | null;
178
+ /** Resolved parameters used by the scenario, if any. */
179
+ params?: CheckScenarioParam[];
106
180
  status: ScenarioStatus;
107
181
  /** The controller step at which the scenario ended (passed and failed; null otherwise). */
108
182
  over_at_ms: number | null;
183
+ /** Virtual end time from the scenario file (`end_ms`), or null if omitted. */
184
+ end_ms?: number | null;
109
185
  steps: ScenarioStep[];
110
186
  }
111
187
  export type CheckStatus = Open<'described' | 'not_described' | 'not_checked' | 'failed' | 'skipped' | 'disabled'>;
@@ -142,6 +218,12 @@ export type CheckOutcome = Open<'passed' | 'failed' | 'unreadable' | 'usage'>;
142
218
  export interface CheckResult extends FromLauncher {
143
219
  file: string | null;
144
220
  result: CheckOutcome;
221
+ /** Selected variant name when the configuration has variants (null on usage). */
222
+ variant?: string | null;
223
+ /** Available variant names when the configuration defines `variants:`. */
224
+ variants?: string[];
225
+ /** Configuration-level parameters, if any. */
226
+ params?: CheckScenarioParam[];
145
227
  errors: number;
146
228
  warnings: number;
147
229
  notes: number;
@@ -560,6 +642,10 @@ export interface StateReport {
560
642
  } | null;
561
643
  /** Whether the run plays a scenario. */
562
644
  scenario: boolean | null;
645
+ /** Whether the scenario has passed and handed over to manual control. */
646
+ handed_over?: boolean;
647
+ /** Virtual time (ms) at which the scenario completed and handed over, or null. */
648
+ scenario_over_at_ms?: number | null;
563
649
  /** The operations: pause, resume, step, speed, run_until, stop, write. */
564
650
  allowed: Record<string, LauncherAllowedItem>;
565
651
  /**
@@ -3,7 +3,7 @@
3
3
  * come from the launcher (check, result, events) have the shapes of launcher.ts. Rules of the parsers: read.ts.
4
4
  */
5
5
  import { Open, Reader, Unreadable } from './read.js';
6
- import { CheckResult, ControlLink, Finding, LauncherEvent, ParticipantState, Phase, RunResult, ScenarioStatus, ScenarioStep, Speed, SummaryCommand, SummaryState, TimeReport, Caution } from './launcher.js';
6
+ import { CheckResult, CheckScenarioParam, ControlLink, Finding, LauncherEvent, ParticipantState, Phase, RunResult, ScenarioParamValue, ScenarioStatus, ScenarioStep, Speed, SummaryCommand, SummaryState, TimeReport, Caution } from './launcher.js';
7
7
  /**
8
8
  * The version of the GUI server's API that this library reads (`vehicle_sil_gui` of `api/app` and `hello`). It does not
9
9
  * read a hello or an api/app of another version (their fields may mean something else). When to raise the version:
@@ -20,6 +20,10 @@ export interface ServerProblem {
20
20
  skipped?: number;
21
21
  /** For `check-failed`, the findings of the check that refused the start (`detail.findings`; unreadable ones left out). */
22
22
  findings?: Finding[];
23
+ /** For `write-timeout` and `write-failed` after an operation number was assigned (`detail.operation`). */
24
+ operation?: number;
25
+ /** Last known operation state on `write-timeout` / `write-failed` (`detail.state`, e.g. `'sent'`). */
26
+ state?: string;
23
27
  }
24
28
  /** Reads a server notice (`{code, message, detail}`). The `error` in an HTTP error has the same shape. */
25
29
  export declare const readServerProblem: Reader<ServerProblem>;
@@ -84,6 +88,8 @@ export interface ConfigList {
84
88
  truncated: boolean;
85
89
  }
86
90
  export declare const readConfigList: (value: unknown) => ConfigList;
91
+ /** What the launcher does once a scenario passes. */
92
+ export type AfterScenario = 'stop' | 'pause';
87
93
  /**
88
94
  * Body of POST api/check: `file` (this server's field) and the keys of the request file that the launcher reads
89
95
  * (`schema/run-request.schema.json`), with the same names and value forms. A key that is not wanted is left out: there
@@ -102,6 +108,10 @@ export interface CheckRequest {
102
108
  manual?: string[];
103
109
  /** The scenario (`path` from `GET api/scenarios`; only one in the list for that configuration file). */
104
110
  scenario?: string;
111
+ /** The named case of the scenario (`cases:`). Requires `scenario`. */
112
+ case?: string;
113
+ /** What to do after the scenario passes (`stop`, or `pause` to hand over to manual control). */
114
+ after_scenario?: AfterScenario;
105
115
  /** The variant of the configuration file. */
106
116
  variant?: string;
107
117
  /** Values of the scenario's parameters (name to value); used only when a scenario runs. */
@@ -203,6 +213,8 @@ export interface Recording {
203
213
  omitted: number;
204
214
  /** Number of steps (`set`) in the YAML. */
205
215
  steps: number;
216
+ /** Finalized end virtual time (ms) of the run once ended, or null while running / unavailable. */
217
+ end_ms: number | null;
206
218
  /** Scenario YAML. null while no write has been applied yet. */
207
219
  yaml: string | null;
208
220
  }
@@ -329,6 +341,27 @@ export interface LogCounts {
329
341
  kept: number;
330
342
  dropped: number;
331
343
  }
344
+ /**
345
+ * Root-relative intent of a started run (`session.intent`). Suitable for passing directly to
346
+ * `front.run.start(session.intent, { file: session.file })` to re-run with the same choices.
347
+ */
348
+ export interface SessionIntent {
349
+ disable?: string[];
350
+ enable?: string[];
351
+ manual?: string[];
352
+ scenario?: string;
353
+ case?: string;
354
+ after_scenario?: AfterScenario;
355
+ variant?: string;
356
+ params?: Record<string, ScenarioParamValue>;
357
+ speed?: number | 'max';
358
+ start_paused?: boolean;
359
+ stop_at_ms?: number;
360
+ late_tolerance_ms?: number;
361
+ strict?: boolean;
362
+ connect?: Record<string, string>;
363
+ time_policy?: Open<'realtime' | 'free'>;
364
+ }
332
365
  /**
333
366
  * Summary of a server session (one run of the launcher). The screen rebuilds its state from it (the summary is
334
367
  * authoritative).
@@ -390,6 +423,8 @@ export interface SessionSummary {
390
423
  problems_omitted: number;
391
424
  /** Progress of the scenario run (`scenario` of `api/run`). null for a run without a scenario. */
392
425
  scenario: SummaryScenario | null;
426
+ /** Root-relative run intent suitable for re-running this session. Omitted on older servers. */
427
+ intent?: SessionIntent | null;
393
428
  /**
394
429
  * Names of the parts that could not be read (`result.participants`, `findings.code` and so on; set by the screen,
395
430
  * not a server field). The missing fields of a result shrunk to fit the limits go here too.
@@ -403,6 +438,10 @@ export interface SummaryScenario {
403
438
  /** The scenario file (relative to root). */
404
439
  file: string;
405
440
  name: string | null;
441
+ /** Selected case name, or null when none was selected. */
442
+ case?: string | null;
443
+ /** Resolved parameters of the scenario, if any. */
444
+ params?: CheckScenarioParam[];
406
445
  /** Number of steps (from the check result; null until then). */
407
446
  step_count: number | null;
408
447
  /** Steps received (in index order). After the result, every step (not_run included). */
@@ -412,6 +451,8 @@ export interface SummaryScenario {
412
451
  /** status of the result (null until there is a result). */
413
452
  status: ScenarioStatus | null;
414
453
  over_at_ms: number | null;
454
+ /** Whether the scenario passed and handed over to manual control. */
455
+ handed_over?: boolean;
415
456
  /**
416
457
  * Where the server serves the run's timeline file (`api/timeline/<session id>`, relative to the server's URL; needs
417
458
  * the token): set at the end of a run whose launcher wrote one, else null.
@@ -531,6 +572,8 @@ export interface VariableSummary {
531
572
  type: Open<'bool' | 'integer' | 'real' | 'enum'>;
532
573
  role: Open<'input' | 'output' | 'parameter'>;
533
574
  writable: boolean;
575
+ /** Whether vehicle-sil added the variable (`ecu.connected`, `peer.*`, `j1939.*`, `can.*`, `lin.*`, `eth.*`) rather than the ECU application declaring it. */
576
+ builtin: boolean;
534
577
  unit: string;
535
578
  min: number | null;
536
579
  max: number | null;
@@ -1,4 +1,4 @@
1
- import { CheckResult, ControlLink, Dropped, Finding, LauncherEvent, LauncherMode, ParticipantState, Phase, RunResult, ScenarioStatus, ScenarioStep, ServerProblem, SessionSummary, Speed, StateReport, TimeReport } from './protocol.js';
1
+ import { CheckResult, CheckScenarioParam, ControlLink, Dropped, Finding, LauncherEvent, LauncherMode, ParticipantState, Phase, RunResult, ScenarioStatus, ScenarioStep, ServerProblem, SessionIntent, SessionSummary, Speed, StateReport, TimeReport } from './protocol.js';
2
2
  /**
3
3
  * A reason: a code that stays the same (an entry of the owner's reason codes, or one the client names) and one English
4
4
  * sentence.
@@ -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`. */
@@ -152,6 +154,10 @@ export interface ScenarioView {
152
154
  /** The scenario file (relative to root). */
153
155
  file: string;
154
156
  name: string | null;
157
+ /** Selected case name, if any. */
158
+ case?: string | null;
159
+ /** Resolved parameters of the scenario, if any. */
160
+ params?: readonly CheckScenarioParam[];
155
161
  /** Number of steps (from the check result; null until then). */
156
162
  stepCount: number | null;
157
163
  /** Steps received (in index order, the last state of each step). After the result, every step. */
@@ -160,6 +166,8 @@ export interface ScenarioView {
160
166
  stepsOmitted: number;
161
167
  /** Result of the scenario (passed, failed, incomplete, not_run). null until there is a result. */
162
168
  status: ScenarioStatus | null;
169
+ /** Whether the scenario passed and handed over to manual control. */
170
+ handedOver: boolean;
163
171
  /** Virtual time at which the scenario ended. */
164
172
  overAtMs: number | null;
165
173
  /**
@@ -242,6 +250,8 @@ export interface SessionView {
242
250
  droppedMarks: number;
243
251
  /** Progress of the scenario (null for a run without a scenario). */
244
252
  scenario: ScenarioView | null;
253
+ /** Root-relative run intent suitable for re-running this session. Undefined on older servers. */
254
+ intent?: SessionIntent | null;
245
255
  }
246
256
  /** Where the run stands now (used by the status bar and the result display). */
247
257
  export type RunOutcome =
@@ -271,6 +281,10 @@ export declare function isLauncherAlive(session: SessionView | SessionSummary |
271
281
  * events, and a variable written is applied in the step at time 0.
272
282
  */
273
283
  export declare function isHolding(session: SessionView | null): boolean;
284
+ /** Whether the run's scenario has passed and handed over to manual control. */
285
+ export declare function isScenarioHandedOver(session: SessionView | SessionSummary | null | undefined): boolean;
286
+ /** Whether the run's scenario is still actively executing (not handed over and no verdict yet). */
287
+ export declare function isScenarioRunning(session: SessionView | SessionSummary | null | undefined): boolean;
274
288
  export declare function runOutcome(session: SessionView): RunOutcome;
275
289
  /** Builds a session from the server's summary (hello, a new session). The log arrives in the resend that follows. */
276
290
  export declare function sessionFromSummary(summary: SessionSummary): SessionView;
@@ -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 synced;
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
  /**
@@ -3,7 +3,7 @@ import { ConnectionState } from './connection.js';
3
3
  import { Reason, SessionView } from './session-state.js';
4
4
  import { ErrorSink, Readable } from './values.js';
5
5
  import { ValueCondition, WriteBlock, WriteStatus, WriteValue } from './variable-state.js';
6
- import { HistoryPoint, OperationView, VariableInfo, VariableReading, VariableRef, VariableWatch, VariablesState, WatchOptions, WriteOptions } from './variables.js';
6
+ import { HistoryPoint, OperationView, QueuedOperation, VariableInfo, VariableReading, VariableRef, VariableWatch, VariablesState, WatchOptions, WriteOptions } from './variables.js';
7
7
  /** Options of client.variables.bind. */
8
8
  export interface BindOptions {
9
9
  /** Interval at which values are received (ms; default WATCH_PERIOD_MS). */
@@ -109,9 +109,15 @@ export interface BindingSources {
109
109
  readonly variables: {
110
110
  readonly state: Readable<VariablesState>;
111
111
  watch(variables: readonly VariableRef[], options?: WatchOptions): VariableWatch;
112
+ enqueue?(writes: Record<string, Record<string, number | boolean | string>>, options?: WriteOptions): Promise<QueuedOperation>;
113
+ enqueueForBinder?(writes: Record<string, Record<string, number | boolean | string>>, onQueued: (seq: number) => void): Promise<OperationView>;
112
114
  write(writes: Record<string, Record<string, number | boolean | string>>, options?: WriteOptions): Promise<OperationView>;
115
+ isStale?(ref: VariableRef): boolean;
116
+ runEpoch?(): number;
113
117
  };
114
118
  readonly connection: Readable<ConnectionState>;
119
+ /** Optional session sync readiness (`session.ready`). Falls back to `connection === 'open'` when omitted. */
120
+ readonly ready?: Readable<boolean>;
115
121
  readonly connectionEpoch: () => number;
116
122
  readonly session: Readable<SessionView | null>;
117
123
  readonly onError: ErrorSink;
@@ -125,7 +131,7 @@ export interface BindingSources {
125
131
  export declare class VariableBinder {
126
132
  readonly sources: BindingSources;
127
133
  private entries;
128
- private entriesSession;
134
+ private entriesKey;
129
135
  /** Per variable, the functions to call when the write status changes (the binds listen). */
130
136
  private readonly listeners;
131
137
  /** Lookup table of the list (rebuilt when peers change). */
@@ -140,7 +146,7 @@ export declare class VariableBinder {
140
146
  find(ref: VariableRef): VariableInfo | undefined;
141
147
  /** Whether that participant is connected to the Control Server now. */
142
148
  peerConnected(peer: string): boolean;
143
- /** Whether the connection between the client and the GUI server is open. */
149
+ /** Whether the connection between the client and the GUI server is open and synced. */
144
150
  connected(): boolean;
145
151
  /**
146
152
  * 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;