@vehicle-sil/gui-client 0.2.0-rc.1 → 0.2.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.
@@ -1,4 +1,5 @@
1
1
  import type { GuiClient } from './client.js';
2
+ import type { RunTarget } from './session.js';
2
3
  import type { CheckResult, ConfigText, SavedConfig, Finding, OutsideState, RunEnd, ScenarioFile, ScenarioStatus, ScenarioStep } from './protocol.js';
3
4
  import type { ValueCondition, WriteBlock, WriteStatus } from './variable-state.js';
4
5
  import type { VariableRef, VariableValue } from './variables.js';
@@ -136,6 +137,10 @@ export interface Intent {
136
137
  params?: Record<string, string | number | boolean>;
137
138
  speed?: number | 'max';
138
139
  start_paused?: boolean;
140
+ /** Exact virtual time at which to stop. Omit for no automatic stop. */
141
+ stop_at_ms?: number;
142
+ /** Wall-clock milliseconds of lateness before a paced step counts as late. */
143
+ late_tolerance_ms?: number;
139
144
  strict?: boolean;
140
145
  /**
141
146
  * Network name to where it is connected outside the simulation: a `value` that `connections()` gave with `usable`
@@ -200,19 +205,23 @@ export interface FrontRun {
200
205
  /** Stops in order. Works whatever the state of the connection (the request is sent if the network is up). */
201
206
  stop(): Promise<void>;
202
207
  /** Stops without waiting for the participants. */
203
- forceStop(): Promise<void>;
208
+ forceStop(target?: {
209
+ session: number;
210
+ instance: string;
211
+ }): Promise<void>;
204
212
  }
205
213
  /**
206
214
  * Time operations. `pause`, `resume` and `setSpeed` resolve when the launcher has answered; `step` and `runUntil`
207
215
  * resolve when time has arrived and the run is paused again (read `clock` after `await`). Another command sent before
208
216
  * it arrives (from this page, another page or stdin) rejects it with `interrupted`.
217
+ * Pass the target from the rendered view to refuse the operation if the run changes before dispatch.
209
218
  */
210
219
  export interface FrontTime {
211
- pause(): Promise<void>;
212
- resume(): Promise<void>;
213
- step(ms: number): Promise<void>;
214
- setSpeed(value: number | 'max'): Promise<void>;
215
- runUntil(ms: number): Promise<void>;
220
+ pause(target?: RunTarget | null): Promise<void>;
221
+ resume(target?: RunTarget | null): Promise<void>;
222
+ step(ms: number, target?: RunTarget | null): Promise<void>;
223
+ setSpeed(value: number | 'max', target?: RunTarget | null): Promise<void>;
224
+ runUntil(ms: number, target?: RunTarget | null): Promise<void>;
216
225
  }
217
226
  /** What a screen shows for one variable. */
218
227
  export interface VariableView {
package/types/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { DEFAULT_LIMITS, createClient } from './client.js';
2
2
  export type { ClientOptions, GuiClient } from './client.js';
3
3
  export type { ClientConnection, CloseInfo, ConnectionState } from './connection.js';
4
- export type { ClientSession, Notice } from './session.js';
4
+ export type { ClientSession, Notice, RunTarget } from './session.js';
5
5
  export type { ClientRun, StopAction } from './run.js';
6
6
  export type { ClientTime, Lateness, NotSentReason, SendResult, TimeFailure, TimeState, } from './time.js';
7
7
  export { ANSWER_TIMEOUT_MS } from './time.js';
@@ -25,4 +25,8 @@ export type { FetchTransportOptions, HttpOutcome, HttpRequest, HttpTransport } f
25
25
  export { isHolding, 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, readRecording, readScenarioList, readServerMessage, readSessionAllowed, readSessionResponse, readTimeResponse, readVariablesSummary, readWriteResponse, severityRank, } from './protocol.js';
28
- export type { AppInfo, AuthMessage, CheckNetwork, CheckOutcome, CheckParticipant, CheckRequest, CheckResult, CheckScenario, CheckStatus, CheckTextRequest, Caution, CommandReport, ConfigFile, ConfigList, ConfigText, SaveConfigRequest, SavedConfig, Connections, ConnectionsRequest, ControlLink, ControlOffer, ControlState, DashboardFile, DashboardFileError, DashboardFileItem, DashboardFileSection, DashboardPanelModule, DashboardResponse, DescribeRequest, DashboardVariable, Dropped, Finding, FromLauncher, LauncherAllowedItem, LauncherEvent, LauncherFields, LogCounts, Open, OutsideState, ParticipantRole, ParticipantState, Phase, Recording, Replay, RunParticipant, RunRequest, RunResult, RunEnd, RunResultName, RunTiming, RunTraffic, ScenarioFile, ScenarioList, ScenarioResult, ScenarioStatus, ScenarioStep, ScenarioStepStatus, ServerAllowed, ServerAllowedItem, ServerSaveItem, ServerMessage, ServerProblem, SessionSummary, Severity, Speed, StateReport, StopRequest, StopRequestBody, 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 { AppInfo, AuthMessage, CheckNetwork, CheckOutcome, CheckParticipant, CheckRequest, CheckResult, CheckScenario, CheckStatus, CheckTextRequest, Caution, CommandReport, ConfigFile, ConfigList, ConfigText, SaveConfigRequest, SavedConfig, Connections, ConnectionsRequest, ControlLink, ControlOffer, ControlState, DashboardFile, DashboardFileError, DashboardFileItem, DashboardFileSection, DashboardPanelModule, DashboardResponse, DescribeRequest, DashboardVariable, Dropped, Finding, FromLauncher, LauncherAllowedItem, LauncherEvent, LauncherFields, LogCounts, Open, OutsideState, ParticipantRole, ParticipantState, Phase, Recording, Replay, RunParticipant, RunRequest, RunResult, RunEnd, RunResultName, RunTiming, RunTraffic, ScenarioFile, ScenarioList, ScenarioResult, ScenarioStatus, ScenarioStep, ScenarioStepStatus, ServerAllowed, ServerAllowedItem, ServerSaveItem, ServerMessage, ServerProblem, SessionSummary, Severity, Speed, StateReport, StopRequest, StopRequestBody, StopSessionRequestBody, SummaryCommand, SummaryLauncher, SummaryParticipant, SummaryScenario, SummaryState, TimeAnswer, TimeCommand, TimeCommandName, TimeReport, TrafficNetwork, TrafficParticipant, TrafficUnplaced, ValuesMessage, Variable, VariableSummary, VariablesSummary, OperationReport, VariableAvailability, WatchMessage, WriteAnswer, } from './protocol.js';
29
+ export { createWaveforms } from './waveforms.js';
30
+ export type { Waveforms, WaveformSeries } from './waveforms.js';
31
+ export { createVariableEditor } from './variable-editor.js';
32
+ export type { VariableEditor, VariableEditorState } from './variable-editor.js';
@@ -34,6 +34,8 @@ export interface FromLauncher {
34
34
  export type Severity = Open<'error' | 'warning' | 'note'>;
35
35
  /** A finding of the check or the run. message and detail are shown in English, unchanged. */
36
36
  export interface Finding extends FromLauncher {
37
+ /** Launcher event sequence on a finding kept by a GUI server, when available. */
38
+ event_seq?: number;
37
39
  severity: Severity;
38
40
  code: string;
39
41
  file: string | null;
@@ -146,6 +148,7 @@ export interface CheckResult extends FromLauncher {
146
148
  warnings: number;
147
149
  notes: number;
148
150
  stop_at_ms: number | null;
151
+ time_step_ms?: number | null;
149
152
  participants: CheckParticipant[];
150
153
  networks: CheckNetwork[];
151
154
  findings: Finding[];
@@ -9,11 +9,13 @@ import { CheckResult, ControlLink, Finding, LauncherEvent, ParticipantState, Pha
9
9
  * read a hello or an api/app of another version (their fields may mean something else). When to raise the version:
10
10
  * "Versioning and compatibility" in gui/protocol/README.md.
11
11
  */
12
- export declare const PROTOCOL_VERSION = 2;
12
+ export declare const PROTOCOL_VERSION = 3;
13
13
  /**
14
14
  * A server notice (an API error, a WebSocket error, problems of the session). message is shown in English, unchanged.
15
15
  */
16
16
  export interface ServerProblem {
17
+ /** Monotonic per-run diagnostic identifier, absent on older servers. */
18
+ problem_seq?: number;
17
19
  code: string;
18
20
  message: string;
19
21
  /** For launcher-stderr, the number of lines dropped at this point (`detail.skipped`). Other notices lack it. */
@@ -74,6 +76,8 @@ export declare const readAppInfo: (value: unknown) => AppInfo;
74
76
  export interface ConfigFile {
75
77
  /** Path relative to root (separator /). */
76
78
  path: string;
79
+ /** The server recognized a simulation configuration. Older servers may omit this flag. */
80
+ simulation?: boolean;
77
81
  }
78
82
  /** GET api/configs: the configuration files under root. */
79
83
  export interface ConfigList {
@@ -106,6 +110,10 @@ export interface CheckRequest {
106
110
  params?: Record<string, string | number | boolean>;
107
111
  /** true: fail on warnings too. */
108
112
  strict?: boolean;
113
+ /** Exact virtual time at which to stop. Omit for no automatic stop. */
114
+ stop_at_ms?: number;
115
+ /** Wall-clock milliseconds of lateness before a paced step counts as late. */
116
+ late_tolerance_ms?: number;
109
117
  /**
110
118
  * Where networks are connected outside the simulation: network name to target. For a network of the file, a target
111
119
  * other than `none` must be a `value` that the last `POST api/connections` of that network gave with `usable: true`
@@ -302,6 +310,8 @@ export interface LogCounts {
302
310
  */
303
311
  export interface SessionSummary {
304
312
  id: number;
313
+ /** Server capture order within this instance and run; absent on older servers. */
314
+ snapshot_rev?: number | null;
305
315
  /** Path relative to root. */
306
316
  file: string;
307
317
  disable: string[];
@@ -310,7 +320,7 @@ export interface SessionSummary {
310
320
  * is in the check result).
311
321
  */
312
322
  manual: string[];
313
- /** Speed given at the start (null means as in the configuration file). The current speed is `speed` of launcher_state. */
323
+ /** Speed requested at the start (null means no speed was requested). The current speed is `speed` of launcher_state. */
314
324
  speed: Speed;
315
325
  /** Whether the run started paused. */
316
326
  start_paused: boolean;
@@ -345,6 +355,8 @@ export interface SessionSummary {
345
355
  * that asked for `session_without_check` lack the field and read it as null (the local check result is used as is).
346
356
  */
347
357
  check: CheckResult | null;
358
+ /** The checked stop time when the full check was too large to keep. */
359
+ stop_at_ms?: number | null;
348
360
  participants: SummaryParticipant[];
349
361
  findings: Finding[];
350
362
  result: RunResult | null;
@@ -352,6 +364,8 @@ export interface SessionSummary {
352
364
  log: Record<string, LogCounts>;
353
365
  problems: ServerProblem[];
354
366
  problems_omitted: number;
367
+ /** Highest diagnostic identifier allocated by the server, including omitted diagnostics. */
368
+ problem_seq?: number | null;
355
369
  /** Progress of the scenario run (`scenario` of `api/run`). null for a run without a scenario. */
356
370
  scenario: SummaryScenario | null;
357
371
  /**
@@ -423,6 +437,8 @@ export interface ServerAllowed {
423
437
  export declare const readServerAllowed: Reader<ServerAllowed>;
424
438
  /** Answer of GET api/session, POST api/run and POST api/stop (the current session; null if none). */
425
439
  export declare const readSessionResponse: (value: unknown) => SessionSummary | null;
440
+ /** GET api/session and POST api/run must identify the GUI server that supplied the run ID. */
441
+ export declare const readSessionInstance: (value: unknown) => string;
426
442
  /** What the server accepts, from `allowed` of an `api/session` response: also there when there is no run. */
427
443
  export declare const readSessionAllowed: (value: unknown) => ServerAllowed | null;
428
444
  /**
@@ -431,11 +447,16 @@ export declare const readSessionAllowed: (value: unknown) => ServerAllowed | nul
431
447
  export interface StopRequestBody {
432
448
  force: boolean;
433
449
  }
450
+ /** POST api/stop-session: the server stops only this session. */
451
+ export interface StopSessionRequestBody extends StopRequestBody {
452
+ session: number;
453
+ instance: string;
454
+ }
434
455
  /** Names of the time commands (the launcher's stdin commands other than stop). */
435
456
  export type TimeCommandName = 'pause' | 'resume' | 'step' | 'run_until' | 'speed';
436
457
  /**
437
- * Body of POST api/time. The server passes it to the launcher as one line and returns at once. Whether it was accepted
438
- * arrives as a command event, and its effect as a time event.
458
+ * The command sent in POST api/time. The GUI Client adds the run's session and server instance to the request.
459
+ * The server passes the command to the launcher as one line. The answer arrives as a command event.
439
460
  */
440
461
  export type TimeCommand = ({
441
462
  command: 'pause';
@@ -520,6 +541,8 @@ export interface OperationReport {
520
541
  }
521
542
  /** `variables` of the summary: state of the variable API, variables per participant, recent operations. */
522
543
  export interface VariablesSummary {
544
+ /** Server capture order for variable snapshots and availability deltas; absent on older servers. */
545
+ rev?: number | null;
523
546
  state: Open<'off' | 'connecting' | 'ready' | 'failed' | 'ended'>;
524
547
  reason: string | null;
525
548
  peers: {
@@ -749,6 +772,7 @@ export type ServerMessage =
749
772
  | {
750
773
  type: 'availability';
751
774
  session: number;
775
+ rev?: number | null;
752
776
  peers: Record<string, Record<string, VariableAvailability>>;
753
777
  };
754
778
  /**
package/types/run.d.ts CHANGED
@@ -4,12 +4,18 @@ import { SessionFeed } from './session.js';
4
4
  import { ErrorSink, Readable } from './values.js';
5
5
  /** Stop action: stop in order, or stop without waiting. */
6
6
  export type StopAction = 'stop' | 'force';
7
+ export interface StopCapture {
8
+ readonly key: object | string;
9
+ readonly send: (force: boolean) => Promise<SessionSummary | null>;
10
+ }
7
11
  /** Run control and its state (GuiClient.run). */
8
12
  export interface ClientRun {
9
13
  /** A start was sent and its answer is pending. */
10
14
  readonly starting: Readable<boolean>;
11
15
  /** A stop was sent and its answer is pending (which kind of stop). */
12
16
  readonly stopping: Readable<StopAction | null>;
17
+ /** A pending stop of the current session or current start, if any. */
18
+ readonly currentStopping: Readable<StopAction | null>;
13
19
  /** A stop was asked for while the answer to a start was pending. */
14
20
  readonly stopWhileStarting: Readable<boolean>;
15
21
  /** Why the last action was refused (the server's text, unchanged). null once a run starts or ends. */
@@ -22,19 +28,22 @@ export interface ClientRun {
22
28
  * have started it.
23
29
  */
24
30
  start(request: RunRequest): Promise<SessionSummary | null>;
25
- /** Stops in order (`POST api/stop` `{force: false}`). Asking again has no further effect. */
31
+ /**
32
+ * Stops the session currently seen by this client. During its own pending start, waits for the answer and targets
33
+ * that session. If the ID or server instance is unknown, or the start answer is lost, rejects without sending an
34
+ * unscoped stop. An older server without `api/stop-session` is refused, rather than stopping an unrelated run.
35
+ */
26
36
  stop(): Promise<SessionSummary | null>;
27
- /** Stops without waiting (`POST api/stop` `{force: true}`). */
37
+ /** Stops without waiting for participants. A stop during this client's pending start is targeted the same way. */
28
38
  forceStop(): Promise<SessionSummary | null>;
29
39
  }
30
40
  /**
31
- * Run control: start (`POST api/run`), stop in order or without waiting (`POST api/stop`), and the state for them.
41
+ * Run control: start (`POST api/run`), stop in order or without waiting (`POST api/stop-session`), and their state.
32
42
  *
33
43
  * - The answer to an action (the current summary) is applied to the session copy without waiting for the notification
34
44
  * (no stale display right after a click).
35
- * - Start and stop are sent separately. A stop can be asked for while the answer to a start is pending (the server
36
- * delivers it once the launcher has started; stopping in order has no further effect when asked again, so if the
37
- * summary in the start's answer does not show the stop as asked for yet, it is asked for again).
45
+ * - A stop requested while a start is pending waits for its answer, then names that session in the stop request. The
46
+ * server checks the ID atomically, so a later run cannot be stopped by the delayed request.
38
47
  * - error holds the reason for a refusal (the server's English text). It is cleared once a run starts or ends.
39
48
  * - The Promises of start() and stop() resolve with the summary in the answer (null if unreadable) and reject with an
40
49
  * HttpError when refused. No answer (`timedOut`) is not a refusal: the session copy tells whether the run started.
@@ -47,12 +56,16 @@ export declare class RunControl implements ClientRun {
47
56
  * How long to wait for the answer to a start (ms). Long, because the server may check again as part of the start.
48
57
  */
49
58
  private readonly startTimeoutMs;
59
+ private startOperation;
60
+ private readonly pendingStops;
61
+ private readonly pendingRevision;
50
62
  private readonly startSending;
51
63
  private readonly stopSending;
52
64
  private readonly stopAskedWhileStarting;
53
65
  private readonly failure;
54
66
  readonly starting: Readable<boolean>;
55
67
  readonly stopping: Readable<StopAction | null>;
68
+ readonly currentStopping: Readable<StopAction | null>;
56
69
  readonly stopWhileStarting: Readable<boolean>;
57
70
  readonly error: Readable<string | null>;
58
71
  constructor(feed: SessionFeed, transport: HttpTransport, onError?: ErrorSink,
@@ -66,6 +79,8 @@ export declare class RunControl implements ClientRun {
66
79
  stop(): Promise<SessionSummary | null>;
67
80
  /** Stops without waiting (kills the participants). */
68
81
  forceStop(): Promise<SessionSummary | null>;
82
+ captureStop(): StopCapture;
83
+ private requestStop;
69
84
  /**
70
85
  * Sends and applies the summary in the answer. done is called after the answer (failures too), before the Promise
71
86
  * settles.
@@ -45,6 +45,7 @@ export interface LogLine {
45
45
  count: number;
46
46
  atLeast: boolean;
47
47
  launcher?: boolean;
48
+ notKept?: boolean;
48
49
  };
49
50
  }
50
51
  /** Log counts per source. */
@@ -167,6 +168,25 @@ export interface ScenarioView {
167
168
  export interface SessionView {
168
169
  /** Session number the server assigned. */
169
170
  id: number;
171
+ /** Server snapshot capture order for this run, null on older servers. */
172
+ snapshotRev?: number | null;
173
+ /** Capture order of the last adopted launcher projection, independent of server state. */
174
+ projectionRev?: number | null;
175
+ /** Highest launcher event position included in an adopted summary projection. */
176
+ projectionSeq?: number;
177
+ /** Highest diagnostic identifier represented in this view. */
178
+ problemSeq?: number;
179
+ /** Highest diagnostic delivered by the ordered WebSocket stream. */
180
+ problemEventSeq?: number;
181
+ /** Summary findings awaiting possible earlier buffered live events. */
182
+ pendingFindings?: {
183
+ through: number;
184
+ keys: readonly string[];
185
+ };
186
+ /** Highest live or replay event observed, retained across full log replay. */
187
+ observedSeq?: number;
188
+ /** Last event position for each launcher projection, retained across replay. */
189
+ eventSeqs?: Readonly<Record<string, number>>;
170
190
  /** seq of the last event received (-1 if none). On reconnect, the resend is requested from the next one. */
171
191
  lastSeq: number;
172
192
  /** The configuration file (relative to root). */
@@ -177,7 +197,7 @@ export interface SessionView {
177
197
  * Participants the user chose on the screen to start themselves (manual: true in the configuration file is in check).
178
198
  */
179
199
  manual: readonly string[];
180
- /** Speed given at the start (null means as in the configuration file). The current speed is `speed` of launcherState. */
200
+ /** Speed requested at the start (null means no speed was requested). The current speed is `speed` of launcherState. */
181
201
  speed: Speed;
182
202
  /** Whether the run started paused. */
183
203
  startPaused: boolean;
@@ -185,6 +205,8 @@ export interface SessionView {
185
205
  /** Position of the last known phase received (so an unknown phase never moves the phase backwards). */
186
206
  phaseRank: number;
187
207
  check: CheckResult | null;
208
+ /** The checked stop time when the full check was too large to keep. */
209
+ stopAtMs?: number | null;
188
210
  participants: readonly ParticipantView[];
189
211
  /** Log lines (in seq order). */
190
212
  logs: readonly LogLine[];
@@ -287,3 +309,5 @@ export declare function phaseIndex(phase: Phase | null): number;
287
309
  * staleEvents (seq went back). The log array is rebuilt once per batch (not copied for every event).
288
310
  */
289
311
  export declare function applyEvents(session: SessionView, events: readonly LauncherEvent[], countStale?: boolean): SessionView;
312
+ /** Combines a same-run full replay with lines only the client still holds. */
313
+ export declare function recoverReplayLogs(session: SessionView, recovered: readonly LogLine[], notKept: ReadonlyMap<string, number>): SessionView;
@@ -19,10 +19,20 @@ export interface Notice {
19
19
  /** How many times the same text arrived. */
20
20
  count: number;
21
21
  }
22
+ /** Identity of one run across all starts of the server. */
23
+ export interface RunTarget {
24
+ session: number;
25
+ instance: string;
26
+ }
27
+ export declare function sameRunTarget(left: RunTarget | null, right: RunTarget | null): boolean;
22
28
  /** Read side of the session copy (GuiClient.session). */
23
29
  export interface ClientSession {
24
30
  /** The current (or last) session. null while the server has none yet. */
25
31
  readonly session: Readable<SessionView | null>;
32
+ /** Identity of the session suitable for a targeted action. */
33
+ currentTarget(): RunTarget | null;
34
+ /** The last authenticated server instance, even when there is no session. */
35
+ currentInstance(): string | null;
26
36
  /**
27
37
  * The session copy matches the server: connected, and hello and the resent events have all arrived. Until then,
28
38
  * Start and Stop are disabled so that nobody acts on a stale display. Other features (values and so on) have their
@@ -64,6 +74,11 @@ export interface ClientSession {
64
74
  /** Removes a notice. */
65
75
  dismissNotice(id: number): void;
66
76
  }
77
+ interface Adoption {
78
+ revision: number;
79
+ instance: string | null;
80
+ session: number | null;
81
+ }
67
82
  /**
68
83
  * Copy of a session (one run of the launcher). Reads the notifications of the connection (Connection) and builds the
69
84
  * state from the server's summary and events.
@@ -82,6 +97,12 @@ export interface ClientSession {
82
97
  export declare class SessionFeed implements ClientSession {
83
98
  private readonly connection;
84
99
  private readonly onError;
100
+ private readonly rawListeners;
101
+ private snapshotVersion;
102
+ private instanceId;
103
+ private adoptionRevision;
104
+ private instanceListener;
105
+ private stopTarget;
85
106
  private readonly current;
86
107
  private readonly synced;
87
108
  private readonly allowedValue;
@@ -92,6 +113,7 @@ export declare class SessionFeed implements ClientSession {
92
113
  private readonly messageListeners;
93
114
  private noticeId;
94
115
  private stoppedFlag;
116
+ private replayLogs;
95
117
  readonly session: Readable<SessionView | null>;
96
118
  readonly ready: Readable<boolean>;
97
119
  readonly allowed: Readable<ServerAllowed | null>;
@@ -115,7 +137,16 @@ export declare class SessionFeed implements ClientSession {
115
137
  * request for the same run (the rest arrives in notifications). A summary of an earlier run never brings back an old
116
138
  * run over a new one.
117
139
  */
118
- adopt(summary: SessionSummary | null): void;
140
+ onRawMessages(listener: (batch: readonly unknown[], current: () => boolean, snapshotVersion: number) => void): () => void;
141
+ onSnapshotVersion(read: () => number): void;
142
+ /** Called before a new server's session can be published. */
143
+ onInstance(listener: (instance: string, current: () => boolean) => void): void;
144
+ /** Instance associated with the current session, or null if its origin is not known. */
145
+ currentInstance(): string | null;
146
+ currentTarget(): RunTarget | null;
147
+ adopt(summary: SessionSummary | null, instance: string, resyncFrom?: string | null): Adoption | null;
148
+ sameRun(adoption: Adoption): boolean;
149
+ isCurrent(revision: number): boolean;
119
150
  /**
120
151
  * Takes what the server accepts (an HTTP answer or a notification): the one with the larger `rev` wins (rev 0 is a
121
152
  * server that does not number it: the newest arrival wins). Used inside the library.
@@ -125,6 +156,9 @@ export declare class SessionFeed implements ClientSession {
125
156
  dismissNotice(id: number): void;
126
157
  /** Reads and applies a batch from the connection. */
127
158
  private receive;
159
+ /** Keep messages at or after the run already observed over HTTP, within each server instance. */
160
+ private filterOlderRuns;
128
161
  private apply;
129
162
  private notify;
130
163
  }
164
+ export {};
package/types/time.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { HttpTransport } from './http.js';
2
2
  import { TimeCommand, TimeCommandName } from './protocol.js';
3
+ import { type RunTarget } from './session.js';
3
4
  import { CommandView, SessionView, TimeView } from './session-state.js';
4
5
  import { ErrorSink, Readable } from './values.js';
5
6
  /**
@@ -98,16 +99,17 @@ export interface ClientTime {
98
99
  export declare class TimeControl implements ClientTime {
99
100
  private readonly session;
100
101
  private readonly transport;
102
+ private readonly currentTarget;
101
103
  /** How long to wait for an answer (ms). */
102
104
  readonly answerTimeoutMs: number;
103
- private readonly inFlight;
105
+ private readonly awaitingHttp;
104
106
  private readonly pending;
105
107
  private readonly failureValue;
106
108
  private answerTimer;
107
109
  private lastLateness;
108
110
  /** Time state. */
109
111
  readonly state: Readable<TimeState>;
110
- constructor(session: Readable<SessionView | null>, transport: HttpTransport,
112
+ constructor(session: Readable<SessionView | null>, transport: HttpTransport, currentTarget: () => RunTarget | null,
111
113
  /** How long to wait for an answer (ms). */
112
114
  answerTimeoutMs?: number, onError?: ErrorSink);
113
115
  pause(): SendResult;
package/types/values.d.ts CHANGED
@@ -39,6 +39,8 @@ export declare class Writable<T> implements Readable<T> {
39
39
  onError?: ErrorSink);
40
40
  get(): T;
41
41
  set(value: T): void;
42
+ /** Changes the value immediately and returns its notification, for an atomic multi-value update. */
43
+ setDeferred(value: T): () => void;
42
44
  update(change: (value: T) => T): void;
43
45
  subscribe(listener: (value: T) => void): () => void;
44
46
  /** Read-only view (get and subscribe only). */
@@ -112,6 +112,7 @@ export interface BindingSources {
112
112
  write(writes: Record<string, Record<string, number | boolean | string>>, options?: WriteOptions): Promise<OperationView>;
113
113
  };
114
114
  readonly connection: Readable<ConnectionState>;
115
+ readonly connectionEpoch: () => number;
115
116
  readonly session: Readable<SessionView | null>;
116
117
  readonly onError: ErrorSink;
117
118
  }
@@ -0,0 +1,25 @@
1
+ import type { Front, VariableView } from './front-types.js';
2
+ import { type Readable } from './values.js';
3
+ import type { VariableInfo, VariableRef } from './variables.js';
4
+ import type { WriteValue } from './variable-state.js';
5
+ export interface VariableEditorState {
6
+ readonly info: (Omit<Readonly<VariableInfo>, 'enum'> & {
7
+ readonly enum: readonly Readonly<{
8
+ name: string;
9
+ value: number;
10
+ }>[] | null;
11
+ }) | undefined;
12
+ readonly view: VariableView;
13
+ readonly shown: WriteValue | null;
14
+ readonly waiting: boolean;
15
+ readonly canWrite: boolean;
16
+ }
17
+ export interface VariableEditor {
18
+ readonly state: Readable<VariableEditorState>;
19
+ /** Returns false when no edit can be attempted. Read the write result in state. */
20
+ write(value: WriteValue): boolean;
21
+ setVisible(visible: boolean): void;
22
+ close(): void;
23
+ }
24
+ /** Binds a typed editor to a variable, including the acknowledgement and readback of a Boolean edit. */
25
+ export declare function createVariableEditor(front: Front, ref: VariableRef): VariableEditor;
@@ -277,7 +277,7 @@ export declare function readOperation(value: unknown, session: number): Operatio
277
277
  export interface VariablesLink {
278
278
  /** Sends if connected (does nothing otherwise; resume() sends what is needed on connect). */
279
279
  send(message: unknown): unknown;
280
- onBatch(listener: (batch: readonly unknown[]) => void): () => void;
280
+ onBatch(listener: (batch: readonly unknown[], current?: () => boolean, snapshotVersion?: number) => void): () => void;
281
281
  }
282
282
  /**
283
283
  * ECU variables: list and state, value watches, writes and their results. No framework needed.
@@ -299,6 +299,10 @@ export declare class VariablesFeed implements Omit<ClientVariables, 'bind'> {
299
299
  private readonly onError;
300
300
  /** Limits (from limits of api/app; the defaults until then). */
301
301
  private readonly limits;
302
+ private instanceId;
303
+ private snapshotVersionValue;
304
+ private snapshotIdentity;
305
+ private serverRevision;
302
306
  private readonly stateValue;
303
307
  private readonly operationsValue;
304
308
  private readonly handles;
@@ -334,8 +338,15 @@ export declare class VariablesFeed implements Omit<ClientVariables, 'bind'> {
334
338
  private receive;
335
339
  /** Returns whether any state changed. Only the availability table changes: `peers` keeps its identity. */
336
340
  private takeAvailability;
337
- /** Applies the variables part of hello and of an HTTP summary (`session`). */
338
- adoptSummary(summary: unknown): void;
341
+ snapshotVersion(): number;
342
+ /** Compare server capture order when available; legacy peers use the local best-effort watermark. */
343
+ isSnapshotCurrent(version: number, instance: string | null, session: number | null, rev: number | null): boolean;
344
+ private markSnapshot;
345
+ private applySnapshot;
346
+ /** A reused numeric session on another server is a different run. */
347
+ adoptInstance(value: unknown): void;
348
+ /** Applies a summary: an older snapshot can still carry a terminal write result. */
349
+ adoptSummary(summary: unknown, current?: () => boolean, snapshotCurrent?: () => boolean): number | null;
339
350
  /**
340
351
  * With the summary after a reconnect (or from api/session), settles as "no answer came" (lost) the writes waiting for
341
352
  * a result that will no longer arrive. For writes whose number is not known yet (before the HTTP answer), the summary
@@ -359,6 +370,7 @@ export declare class VariablesFeed implements Omit<ClientVariables, 'bind'> {
359
370
  * settled operations cut from the list are picked up from here.
360
371
  */
361
372
  private setOperations;
373
+ private prepareOperations;
362
374
  private settle;
363
375
  write(writes: Record<string, Record<string, number | boolean | string>>, options?: WriteOptions): Promise<OperationView>;
364
376
  watch(variables: readonly VariableRef[] | 'all', options?: WatchOptions): VariableWatch;
@@ -0,0 +1,14 @@
1
+ import { type GuiClient } from './client.js';
2
+ import { type Readable } from './values.js';
3
+ import type { HistoryPoint, VariableRef, WatchOptions } from './variables.js';
4
+ export interface WaveformSeries {
5
+ readonly ref: Readonly<VariableRef>;
6
+ readonly points: readonly Readonly<HistoryPoint>[];
7
+ }
8
+ export interface Waveforms {
9
+ readonly series: Readable<readonly WaveformSeries[]>;
10
+ setSignals(refs: readonly VariableRef[]): void;
11
+ close(): void;
12
+ }
13
+ /** Keeps histories for the selected signals of the current run in selection order. */
14
+ export declare function createWaveforms(client: GuiClient, options?: WatchOptions): Waveforms;