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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.ja.md +412 -96
  2. package/README.md +403 -89
  3. package/dist/elements.js +872 -0
  4. package/dist/index.js +2869 -259
  5. package/package.json +20 -2
  6. package/timeline/vehicle-sil-timeline.d.ts +108 -0
  7. package/timeline/vehicle-sil-timeline.js +4577 -0
  8. package/timeline/vehicle-sil-timeline.mjs +4579 -0
  9. package/types/client.d.ts +47 -7
  10. package/types/connection.d.ts +4 -0
  11. package/types/elements/index.d.ts +25 -0
  12. package/types/elements/outside-parts.d.ts +20 -0
  13. package/types/elements/page-intent.d.ts +10 -0
  14. package/types/elements/part.d.ts +48 -0
  15. package/types/elements/reasons.d.ts +12 -0
  16. package/types/elements/run-parts.d.ts +21 -0
  17. package/types/elements/scenario-parts.d.ts +18 -0
  18. package/types/elements/variable-parts.d.ts +28 -0
  19. package/types/front-actions.d.ts +130 -0
  20. package/types/front-compose.d.ts +61 -0
  21. package/types/front-outside.d.ts +19 -0
  22. package/types/front-types.d.ts +360 -0
  23. package/types/front-variable.d.ts +28 -0
  24. package/types/front.d.ts +50 -0
  25. package/types/index.d.ts +13 -5
  26. package/types/protocol/launcher.d.ts +581 -0
  27. package/types/protocol/read.d.ts +72 -0
  28. package/types/protocol/server.d.ts +780 -0
  29. package/types/protocol.d.ts +10 -972
  30. package/types/run.d.ts +21 -6
  31. package/types/session-state.d.ts +66 -10
  32. package/types/session.d.ts +48 -2
  33. package/types/time.d.ts +16 -45
  34. package/types/values.d.ts +2 -0
  35. package/types/variable-binding.d.ts +20 -5
  36. package/types/variable-editor.d.ts +25 -0
  37. package/types/variable-state.d.ts +12 -6
  38. package/types/variables.d.ts +36 -4
  39. package/types/waveforms.d.ts +14 -0
package/README.md CHANGED
@@ -12,57 +12,91 @@ The library handles the connection (token, reconnection), the session copy (a co
12
12
  | Which names are public | [Entry points](#entry-points), [Public API](#public-api) |
13
13
  | The code to connect and start a run | [Basic usage](#basic-usage) |
14
14
  | Reading and writing variable values | [ECU variables](#ecu-variables) |
15
+ | What a screen shows and which buttons work: `connect()` | [The front door (`connect()`)](#the-front-door-connect) |
16
+ | The elements to put in HTML, with no script | [Parts (custom elements)](#parts-custom-elements) |
15
17
  | Building sliders and lamps (the values of `condition` and `block`) | [Build widgets (`bind`)](#build-widgets-bind) |
16
18
  | What happens after `connect()` and `close()` | [Lifecycle](#lifecycle) |
17
19
  | Developing the library | [Coding rules](#coding-rules), [Tests](#tests) |
18
20
 
19
21
  ## Installing and importing
20
22
 
21
- The library is TypeScript source with no dependencies. It is not published to the npm registry.
23
+ The library is TypeScript source with no dependencies. Each release publishes it on the npm registry as `@vehicle-sil/gui-client` (the dist-tag `latest` is the newest release, `next` the newest pre-release) and attaches the same package to the release as `vehicle-sil-gui-client-<version>.tgz`. Install the version of your GUI server: the client refuses a server that speaks another version of the GUI protocol.
22
24
 
23
- | Use | How to get it | Import |
24
- | ----------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
25
- | Plain JavaScript, no build step | Put `vehicle-sil-gui-client.mjs`, the library bundled into one ESM file, in the screen's directory | `import { createClient } from './vehicle-sil-gui-client.mjs'` |
26
- | TypeScript and any framework | Get the package `vehicle-sil-gui-client-<version>.tgz` and run `npm install <that .tgz>` in your project | `import { createClient } from '@vehicle-sil/gui-client'` |
27
- | A TypeScript app in this repository (`gui/web`) | Point the entry point names to `src/` with `paths` in `tsconfig.json` | `import { createClient } from '@vehicle-sil/gui-client'` |
25
+ | Use | How to get it | Import |
26
+ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
27
+ | A page that the GUI server serves (`--web`) | Nothing to copy: the server serves the files (below) | `import { connect } from '/vsil/vehicle-sil-gui-client.mjs'` |
28
+ | Plain JavaScript, outside such a page | Put `vehicle-sil-gui-client.mjs`, the library bundled into one ESM file, next to your script | `import { connect } from './vehicle-sil-gui-client.mjs'` |
29
+ | TypeScript and any framework | Run `npm install @vehicle-sil/gui-client@<version>` in your project (or `npm install <the release's .tgz>`) | `import { connect } from '@vehicle-sil/gui-client'` |
30
+ | A TypeScript app in this repository (`gui/web`) | Point the entry point names to `src/` with `paths` in `tsconfig.json` | `import { createClient } from '@vehicle-sil/gui-client'` |
28
31
 
29
- Where to find the 2 files:
32
+ Where to find the 3 files:
30
33
 
31
34
  | File | Prebuilt tools | Build in the repository (run in `gui/web`) |
32
35
  | -------------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------- |
33
36
  | `vehicle-sil-gui-client.mjs` | `<tools>/client/vehicle-sil-gui-client.mjs` | `npm run build:client` creates `build/gui-client/vehicle-sil-gui-client.mjs` |
37
+ | `vehicle-sil-gui-elements.mjs` | `<tools>/client/vehicle-sil-gui-elements.mjs` | `npm run build:client` creates `build/gui-client/vehicle-sil-gui-elements.mjs` |
34
38
  | `vehicle-sil-gui-client-<version>.tgz` | `<tools>/client/vehicle-sil-gui-client-<version>.tgz` | `npm run pack:client` creates `build/gui-client/vehicle-sil-gui-client-<version>.tgz` |
35
39
 
36
40
  The releases page has the same `.tgz`. `build/` is the one at the top of the repository and is not tracked in Git.
37
41
 
42
+ The GUI server also serves the two `.mjs` files, without the token, as `/vsil/vehicle-sil-gui-client.mjs` and `/vsil/vehicle-sil-gui-elements.mjs` (in the repository, from `build/gui-client/`; it says what to run when they are not built). A screen without a build can load them from there and copy nothing.
43
+
38
44
  - **Bundled file**: loads in the browser and in Node (22 or later). `scripts/verify-gui.py` runs an example that uses this file from Node against the replay launcher.
39
- - **Package**: contains the bundled ESM, `.d.ts` files, `exports`, the README and the LICENSE (`pack.mjs` builds it). Its version is the same as the GUI server's. Its types use the browser types (`DOM` in `lib`). The only entry point is `.` (`testing` and `internal` are not included).
45
+ - **Package**: contains the bundled ESM, `.d.ts` files, `exports`, the README and the LICENSE (`pack.mjs` builds it). Its version is the same as the GUI server's. Its types use the browser types (`DOM` in `lib`). Its entry points are `.`, `./elements` and `./timeline` (`testing` and `internal` are not included).
40
46
 
41
47
  ## Entry points
42
48
 
43
- | Entry point | Name | Contents |
44
- | ---------------------- | ---------------------------------- | --------------------------------------------------------------------------------------- |
45
- | `src/index.ts` | `@vehicle-sil/gui-client` | The public API ("Public API" below). Only this entry point is kept compatible |
46
- | `src/testing/index.ts` | `@vehicle-sil/gui-client/testing` | Test helpers (usable in tests of your own widgets) |
47
- | `src/internal.ts` | `@vehicle-sil/gui-client/internal` | **No compatibility guarantee.** Internal classes and functions; do not use them in apps |
49
+ | Entry point | Name | Contents |
50
+ | --------------------------------------------------------------------------------------------------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
51
+ | `src/index.ts` | `@vehicle-sil/gui-client` | The public API ("Public API" below). This entry point and `./elements` are kept compatible |
52
+ | `src/testing/index.ts` | `@vehicle-sil/gui-client/testing` | Test helpers (usable in tests of your own widgets) |
53
+ | `src/internal.ts` | `@vehicle-sil/gui-client/internal` | **No compatibility guarantee.** Internal classes and functions; do not use them in apps |
54
+ | `src/elements/index.ts` (in the package as `dist/elements.js`, which imports `dist/index.js`) | `@vehicle-sil/gui-client/elements` | The parts (custom elements `<vsil-status>` and 10 more), `pageIntent` and `setReasonText`: importing it defines them ("Parts (custom elements)" below). It needs a DOM; the main entry does not import it |
55
+ | `../timeline/vehicle-sil-timeline.js` (in the package as `timeline/vehicle-sil-timeline.mjs`, with `export {}`) | `@vehicle-sil/gui-client/timeline` | The element `<vehicle-sil-timeline>`, with its types: importing it defines the element ("Putting a timeline on your own screen" in [docs/gui.md](../../docs/gui.md#putting-a-timeline-on-your-own-screen)) |
48
56
 
49
57
  - `testing` contains a fake WebSocket (`FakeWebSockets`), a fake HTTP (`FakeHttp`), loaders for `gui/protocol/examples/`, and `sessionViewFrom`, which builds a `SessionView` from a summary.
50
58
  - `internal` contains the internal classes, the functions that apply a summary, and the parsers. They are public for tests only, and change or disappear without notice.
51
59
 
52
60
  The public API is kept small, because adding to it keeps compatibility and removing from it breaks compatibility. If the public entry point lacks something you need, do not reach into `internal`; decide whether to add it to the public API.
53
61
 
62
+ ## Live waveforms and variable editing
63
+
64
+ `createWaveforms` returns live histories in selection order. Signals shared by two selections keep their history, and a new run clears the histories. It keeps up to 600 points per signal by default. The screen draws the points and handles cross-tab synchronization.
65
+
66
+ `createVariableEditor` exposes the variable definition, display value and write outcome in `state`. It validates numeric, Boolean and enum edits against the definition. After a Boolean edit is applied, it waits for readback for up to 500 ms before accepting another edit. Set visibility to subscribe to values, and call `close()` on both parts when done.
67
+
68
+ ```ts
69
+ import { connect, createVariableEditor, createWaveforms } from '@vehicle-sil/gui-client';
70
+
71
+ const front = await connect();
72
+ const ref = { peer: 'Engine', name: 'engine.throttle' };
73
+ const waves = createWaveforms(front.low, { periodMs: 20 });
74
+ waves.setSignals([ref]);
75
+ const editor = createVariableEditor(front, ref);
76
+ editor.setVisible(true);
77
+ // Render waves.series and editor.state. Call editor.write(value) on commit.
78
+ ```
79
+
54
80
  ## Public API
55
81
 
56
82
  The names that `src/index.ts` exports, by group. Parentheses list the members of the object.
57
83
 
58
84
  ### Client
59
85
 
60
- | Kind | Name |
61
- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
62
- | Function | `createClient(options)` |
63
- | Type | `ClientOptions` (`baseUrl`, `token`, `origin`, `http`, `socket`, `answerTimeoutMs`, `onError`) |
64
- | Type | `GuiClient` (`connection`, `session`, `run`, `time`, `variables`, `app`, `limits`, `connect()`, `close()`, `loadApp()`, `configs()`, `check()`, `fetchSession()`, `dashboard(file)`, `scenarios(file)`, `recording()`) |
65
- | Constant | `DEFAULT_LIMITS` |
86
+ | Kind | Name |
87
+ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
88
+ | Function | `createClient(options)` |
89
+ | Type | `ClientOptions` (`baseUrl`, `token`, `origin`, `http`, `socket`, `answerTimeoutMs`, `onError`) |
90
+ | Type | `GuiClient` (`connection`, `session`, `run`, `time`, `variables`, `app`, `limits`, `connect()`, `close()`, `loadApp()`, `configs()`, `config(file)`, `check()`, `describe()`, `saveConfig()`, `connections()`, `fetchSession()`, `dashboard(file)`, `scenarios(file)`, `recording()`) |
91
+ | Constant | `DEFAULT_LIMITS` |
92
+
93
+ ### Front door
94
+
95
+ | Kind | Name |
96
+ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
97
+ | Function | `connect(options?)`, `createFront(options)`, `watch(source, fn)`, `until(source, test, options?)` |
98
+ | Class | `ActionError` (`code`, `message`, `outcome`, `findings`) |
99
+ | Type | `ConnectOptions` (`base_url`, `token`, `origin`, `http`, `socket`, `answer_timeout_ms`, `on_error`), `Front` (`low`, `status`, `clock`, `controls`, `scenario`, `outside`, `run`, `time`, `variable()`, `scenarios()`, `connections()`, `check()`, `readConfig()`, `describeAgain()`, `saveConfig()`, `close()`), `FrontStatus`, `FrontResult`, `FrontClock`, `FrontControls`, `Control`, `Reason`, `FrontScenario`, `FrontRun`, `FrontTime`, `FrontVariable`, `VariableView`, `Intent`, `Outside`, `ConnectEntry`, `ConnectTarget`, `ConnectListError`, `Link`, `RunState`, `EndKind`, `Pacing`, `OperationName` |
66
100
 
67
101
  ### Token
68
102
 
@@ -84,18 +118,26 @@ In the browser, call `takeToken(window)`. It reads `#token=` from the URL, remov
84
118
 
85
119
  ### Session copy
86
120
 
87
- | Kind | Name |
88
- | -------- | ----------------------------------------------------------------------------------------------------------------------------------- |
89
- | Type | `ClientSession` (`session`, `ready`, `lastEventAt`, `notices`, `rejected`, `incompatible`, `onMessages`, `report`, `dismissNotice`) |
90
- | Type | `Notice`, `SessionView`, `ParticipantView`, `LauncherView`, `LogLine`, `LogSource`, `TimeView`, `CommandView`, `RunOutcome` |
91
- | Function | `runOutcome`, `phaseIndex` |
121
+ | Kind | Name |
122
+ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
123
+ | Type | `ClientSession` (`session`, `currentTarget`, `currentInstance`, `ready`, `allowed`, `lastEventAt`, `notices`, `rejected`, `incompatible`, `onMessages`, `report`, `dismissNotice`) |
124
+ | Type | `Notice`, `SessionView`, `ParticipantView`, `LauncherView`, `LogLine`, `LogSource`, `TimeView`, `CommandView`, `RunOutcome`, `LauncherAnswer` |
125
+ | Function | `runOutcome`, `phaseIndex`, `isHolding`, `launcherAnswer` |
126
+
127
+ `ClientSession.allowed` is what the GUI server accepts now (`start`, `stop` and `force`, each with `ok`, a `reason` code and a `message`; the larger `rev` wins; `null` until the server says). `SessionView.launcherState` is the launcher's last `state` event (where the run stands and what it accepts; the larger `rev` wins; `null` until one arrives). `launcherAnswer(launcherState, name)` reads what it says of one operation (`write`, `pause`, ...): `reason` (`null` when the launcher accepts it) and `caution`. A launcher that has not said (no `state` yet, or no entry for the operation) does not accept it (`unsupported`). The front door's `controls` and `variables.bind` read the launcher with it.
128
+
129
+ Server-provided session and variable revisions order snapshots across HTTP and WebSocket; older servers omit them, so cross-transport ordering is best effort. Revisions do not suppress replay, command answers, or terminal operation results.
130
+
131
+ The `currentTarget()` method returns the current `{session, instance}` pair, or `null` when it is unknown. `currentInstance()` returns the last authenticated server instance even if no run exists, and retains it while disconnected. On reconnect the client requests the retained replay from the beginning, so a restarted server cannot apply a cursor from another instance. An HTTP-only client can refresh its copy with `fetchSession()` after a server restart.
92
132
 
93
133
  ### Run control
94
134
 
95
- | Kind | Name |
96
- | ---- | ------------------------------------------------------------------------------------------------ |
97
- | Type | `ClientRun` (`starting`, `stopping`, `stopWhileStarting`, `error`, `start`, `stop`, `forceStop`) |
98
- | Type | `StopAction` |
135
+ | Kind | Name |
136
+ | ---- | ------------------------------------------------------------------------------------------------------------------- |
137
+ | Type | `ClientRun` (`starting`, `stopping`, `currentStopping`, `stopWhileStarting`, `error`, `start`, `stop`, `forceStop`) |
138
+ | Type | `StopAction` |
139
+
140
+ `currentStopping` reports only pending stops of the current session or current start; `stopping` includes stops for earlier runs. Stop and force stop target the known session and instance. A confirmation can pass the captured pair to `front.run.forceStop(target)`; the action is refused if the target has changed or a new start is pending. A stop requested during this client’s start waits for its answer; if that answer is lost, the stop is not sent and the error says so. Check the current session before retrying. An old server without targeted stop is rejected; overlapping starts on one client are rejected.
99
141
 
100
142
  ### Time
101
143
 
@@ -103,7 +145,7 @@ In the browser, call `takeToken(window)`. It reads `#token=` from the URL, remov
103
145
  | -------- | ---------------------------------------------------------------------------------------- |
104
146
  | Type | `ClientTime` (`state`, `answerTimeoutMs`, `pause`, `resume`, `step`, `setSpeed`, `send`) |
105
147
  | Type | `TimeState`, `TimeFailure`, `Lateness`, `SendResult`, `NotSentReason` |
106
- | Constant | `ANSWER_TIMEOUT_MS`, `FEATURE_SPEED`, `FEATURE_START_PAUSED`, `FEATURE_TIME_COMMANDS` |
148
+ | Constant | `ANSWER_TIMEOUT_MS` |
107
149
 
108
150
  ### ECU variable API
109
151
 
@@ -118,16 +160,16 @@ In the browser, call `takeToken(window)`. It reads `#token=` from the URL, remov
118
160
 
119
161
  ### Binding variables to widgets (`bind`)
120
162
 
121
- | Kind | Name |
122
- | -------- | -------------------------------------------------------------------------------------------------------------------- |
123
- | Method | `client.variables.bind(ref, options)` |
124
- | Type | `BindOptions` (`periodMs`, `history`, `needsRange`, `needsValue`, `visible`) |
125
- | Type | `VariableBinding` (`ref`, `state`, `history()`, `write(value)`, `reject(message)`, `setVisible(visible)`, `close()`) |
126
- | Type | `BoundVariable` (`ref`, `info`, `reading`, `condition`, `block`, `writeStatus`, `pending`) |
127
- | Type | `ValueCondition`, `WriteBlock`, `WriteStatus`, `WriteValue` |
128
- | Function | `isWriteError`, `hasRange` |
129
- | Function | `valueCondition` (`ConditionInput`), `writeBlock` (`WriteBlockInput`) |
130
- | Constant | `DROPPED_MESSAGE` |
163
+ | Kind | Name |
164
+ | -------- | ------------------------------------------------------------------------------------------------------------------------- |
165
+ | Method | `client.variables.bind(ref, options)` |
166
+ | Type | `BindOptions` (`periodMs`, `history`, `needsRange`, `needsValue`, `visible`) |
167
+ | Type | `VariableBinding` (`ref`, `state`, `history()`, `write(value)`, `reject(message)`, `setVisible(visible)`, `close()`) |
168
+ | Type | `BoundVariable` (`ref`, `info`, `reading`, `condition`, `block`, `launcherReason` (a `Reason`), `writeStatus`, `pending`) |
169
+ | Type | `ValueCondition`, `WriteBlock`, `WriteStatus`, `WriteValue` |
170
+ | Function | `isWriteError`, `hasRange` |
171
+ | Function | `valueCondition` (`ConditionInput`), `writeBlock` (`WriteBlockInput`) |
172
+ | Constant | `DROPPED_MESSAGE` |
131
173
 
132
174
  `valueCondition`, `writeBlock` and `hasRange` are the pure functions that `bind` builds its state with.
133
175
 
@@ -158,38 +200,40 @@ In the browser, call `takeToken(window)`. It reads `#token=` from the URL, remov
158
200
 
159
201
  Types for the shapes that `gui/protocol` defines, and the parsers to use when you read the server API yourself.
160
202
 
161
- | Subject | Name |
162
- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
163
- | Types of the `gui/protocol` shapes | `SessionSummary`, `ServerMessage`, `LauncherEvent`, `CheckResult`, `RunResult`, `AppInfo` and others |
164
- | Constants and functions | `PROTOCOL_VERSION`, `PHASES`, `severityRank` |
165
- | Parsers | `readServerMessage`, `readAppInfo`, `readConfigList`, `readCheckResponse`, `readSessionResponse`, `readTimeResponse`, `readWriteResponse`, `readVariablesSummary`, `readDashboardResponse`, `readScenarioList`, `readRecording` |
166
- | Shapes of the variable API | `VariablesSummary`, `VariableSummary`, `ValuesMessage`, `OperationReport`, `WatchMessage`, `WriteAnswer` |
167
- | Dashboard files (`dashboard(file)`) | `DashboardResponse`, `DashboardFile`, `DashboardFileSection`, `DashboardFileItem`, `DashboardFileError`, `DashboardPanelModule`, `DashboardVariable` |
168
- | Scenarios (`--scenario`, `scenarios(file)`, `recording()`) | `ScenarioStep`, `ScenarioStepStatus`, `ScenarioStatus`, `CheckScenario`, `ScenarioResult`, `SummaryScenario`, `ScenarioList`, `ScenarioFile`, `Recording`, `FEATURE_SCENARIO`, `FEATURE_SCENARIO_CONTROL` |
169
- | Request shapes | `CheckRequest`, `RunRequest`, `Speed`, `StopRequest`, `TimeCommand` |
170
- | List of configuration files | `ConfigList`, `ConfigFile` |
171
- | Error shape | `ServerProblem` |
172
- | Findings | `Finding`, `Severity` |
173
- | Participants you start yourself (`manual`) | `FEATURE_MANUAL` |
174
- | `SessionView.scenario` of the session copy | `ScenarioView` |
203
+ | Subject | Name |
204
+ | ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
205
+ | Types of the `gui/protocol` shapes | `SessionSummary`, `ServerMessage`, `LauncherEvent`, `CheckResult`, `RunResult`, `AppInfo` and others |
206
+ | Constants and functions | `PROTOCOL_VERSION`, `PHASES`, `severityRank` |
207
+ | Parsers | `readServerMessage`, `readAppInfo`, `readConfigList`, `readConfigText`, `readSavedConfig`, `readCheckResponse`, `readConnections`, `readSessionResponse`, `readTimeResponse`, `readWriteResponse`, `readVariablesSummary`, `readDashboardResponse`, `readScenarioList`, `readRecording` |
208
+ | Shapes of the variable API | `VariablesSummary`, `VariableSummary`, `ValuesMessage`, `OperationReport`, `WatchMessage`, `WriteAnswer` |
209
+ | Dashboard files (`dashboard(file)`) | `DashboardResponse`, `DashboardFile`, `DashboardFileSection`, `DashboardFileItem`, `DashboardFileError`, `DashboardPanelModule`, `DashboardVariable` |
210
+ | Scenarios (`--scenario`, `scenarios(file)`, `recording()`) | `ScenarioStep`, `ScenarioStepStatus`, `ScenarioStatus`, `CheckScenario`, `ScenarioResult`, `SummaryScenario`, `ScenarioList`, `ScenarioFile`, `Recording` |
211
+ | Request shapes | `CheckRequest`, `CheckTextRequest`, `DescribeRequest`, `SaveConfigRequest`, `RunRequest`, `ConnectionsRequest`, `Speed`, `StopRequest`, `TimeCommand` |
212
+ | List of configuration files | `ConfigList`, `ConfigFile`, `ConfigText`, `SavedConfig` |
213
+ | Error shape | `ServerProblem` |
214
+ | Findings | `Finding`, `Severity` |
215
+ | The launcher's keys and traffic | `FromLauncher`, `LauncherFields`, `RunTraffic`, `TrafficNetwork`, `TrafficParticipant`, `TrafficUnplaced`, `ParticipantRole`, `OutsideState` |
216
+ | `SessionView.scenario` of the session copy | `ScenarioView` |
175
217
 
176
218
  ## Basic usage
177
219
 
220
+ This is the lower door of the library, `createClient`, which the front door is built on (it is `client.low` there). A screen starts with `connect()` and the parts ("The front door (`connect()`)" and "Parts (custom elements)" below) and uses this door for what they do not cover: events, logs, findings, participants and `bind`.
221
+
178
222
  ```ts
179
223
  import { createClient, takeToken } from '@vehicle-sil/gui-client';
180
224
 
181
225
  // A screen opened from the URL the server printed (http://127.0.0.1:<port>/#token=<token>): take #token= from the URL and remove it.
182
- // A Node tool takes baseUrl and the token out of that URL itself and passes them (examples/gui_client).
226
+ // A Node tool takes baseUrl and the token out of that URL itself and passes them (examples/gui_client, in a clone of the repository).
183
227
  const client = createClient({
184
228
  baseUrl: new URL('/', location.href).href,
185
229
  token: takeToken(window),
186
230
  });
187
- await client.loadApp(); // the launcher's features (whether it has time commands, and so on)
231
+ await client.loadApp(); // the server's information (the start-up file, the limits, whether variables are available)
188
232
  client.connect();
189
233
  const stop = client.session.session.subscribe((session) => {
190
234
  if (session?.result) console.log(session.result.result);
191
235
  });
192
- await client.run.start({ file: 'simulation.yaml', disable: [], speed: null, start_paused: false });
236
+ await client.run.start({ file: 'simulation.yaml', disable: [] });
193
237
  ```
194
238
 
195
239
  ### Read state (`Readable`)
@@ -205,7 +249,7 @@ Every state is a `Readable` (a read-only value).
205
249
  - Notifications are synchronous: they arrive inside the code that changed the value.
206
250
  - A subscriber that unsubscribes during a notification still receives that notification.
207
251
  - If a subscriber changes the same value, every subscriber receives the new value, and the old value does not arrive afterward.
208
- - A framework wrapper takes the first value with `get()` and converts later values into its own state with `subscribe()` (Angular uses `readableSignal`).
252
+ - A framework wrapper takes the first value with `get()` and converts later values into its own state with `subscribe()` (an Angular signal is shown in "[A project with a framework](../../examples/gui_starter/README.md#a-project-with-a-framework)"; the package has no framework code).
209
253
  - If a subscriber (a function passed to `subscribe`, `onBatch`, `onMessages` or `onUnreadable`) throws, the other subscribers are still notified and the library carries on (disconnecting when rejected, rebuilding and so on). The thrown value goes to `onError` (default `console.error`).
210
254
  - `client.session.ready` tells whether the session copy is complete (connected, and `hello` and the replay have arrived). Other features (values, for example) have their own ready state.
211
255
 
@@ -218,12 +262,22 @@ Every state is a `Readable` (a read-only value).
218
262
  - A timeout is not a rejection: no response came. For a start, the server may have started the run; the session copy (WebSocket) shows whether it did, and `client.run.error` says so.
219
263
  - Redirects are not followed.
220
264
 
265
+ ### The launcher's keys (`raw`)
266
+
267
+ The check result, the run result, findings and launcher events come from the launcher, and the library passes on every key of them. The typed fields (for example `traffic` of the run result, `participants[].log`, and `role` of a check participant) follow the launcher's format versions (`vehicle_sil_check`, `vehicle_sil_run`, `vehicle_sil_events`), not the version of this library. Every object read from the launcher also has `raw`: the launcher's object as it arrived, with the keys the types do not name. `raw` is read-only and not enumerable (`JSON.stringify` and spreading leave it out). Its values are unchecked JSON: check their type, and show them as text, never as HTML.
268
+
269
+ ```ts
270
+ const result = client.session.session.get()?.result; // RunResult | null
271
+ for (const network of result?.traffic?.networks ?? []) console.log(network.name, network.delivered);
272
+ const strict = result?.raw?.['strict']; // a key without a typed field: unknown
273
+ ```
274
+
221
275
  ### Handling unreadable notifications
222
276
 
223
277
  The library parses each part separately.
224
278
 
225
279
  - If part of a summary or an event cannot be read, the library uses the readable parts and adds the names of the unreadable parts to `SessionView.unreadable`.
226
- - Unknown notifications and events pass through without changing the state (`client.connection.onBatch` receives everything, before parsing).
280
+ - Unknown notifications and events pass through without changing the state, and `onMessages` does not get them (`client.connection.onBatch` receives everything, before parsing: read an event that the library does not know there).
227
281
  - A notification that is not valid JSON raises a notice, and the library receives everything again from `hello`.
228
282
 
229
283
  ### Use from Node, or replace the transport
@@ -232,7 +286,260 @@ The library parses each part separately.
232
286
  - In the browser and in Web Workers, do not pass `origin`: the browser sets it (a Worker's WebSocket cannot set handshake headers).
233
287
  - To replace the HTTP implementation, pass `http` (`HttpTransport`); to replace the WebSocket, pass `socket` (`SocketFactory`).
234
288
 
235
- For the rules the library does not enforce for you (request fields that match the launcher's `features`, whether a variable is writable, whether a value is stale), see "Rules for building a screen" in [docs/gui.md](../../docs/gui.md#rules-for-building-a-screen).
289
+ For the rules the library does not enforce for you (the fields of check and start requests, whether a variable is writable, whether a value is stale), see "Rules for building a screen" in [docs/gui.md](../../docs/gui.md#rules-for-building-a-screen).
290
+
291
+ ## The front door (`connect()`)
292
+
293
+ `connect()` returns the front door of the library: what a screen shows (`status`, `clock`, `controls`, `scenario`), the operations as Promises (`run`, `time`) and one variable at a time (`variable()`). It is built on the client described above and changes nothing in it: `front.low` is the same `GuiClient` (events, logs, findings, participants), and `createClient` still works as before. Use the front door for what a screen needs to decide ("which state is this", "may this button be pressed now, and if not, why"); use `low` for the rest.
294
+
295
+ An app that must show its screens before the server answers, and while it cannot be reached (the standard screens), uses `createFront(options)` instead: it makes the front door without connecting, as `createClient` does, and the app calls `front.low.connect()` and `front.low.loadApp()` itself. Until `loadApp()` has answered, the front knows no start-up file, and the ranges in `controls` are the defaults (`DEFAULT_LIMITS`).
296
+
297
+ ```ts
298
+ import { ActionError, connect, until, watch } from '@vehicle-sil/gui-client';
299
+
300
+ // A page that the GUI server served, opened from the URL it printed: no options. The first call connects; the next calls
301
+ // (another part of the page) get the same connection. In Node, or for a second connection, pass the server's URL and the token.
302
+ const client = await connect();
303
+ // const client = await connect({ base_url: 'http://127.0.0.1:8765/', token });
304
+
305
+ const stop = watch([client.status, client.controls], (status, controls) => {
306
+ startButton.disabled = !controls.start.ok;
307
+ startButton.title = controls.start.reason?.message ?? '';
308
+ banner.textContent = status.problem?.message ?? '';
309
+ });
310
+
311
+ try {
312
+ await client.time.pause(); // a step needs a paused run (or start it paused: `run.start({ start_paused: true })`)
313
+ await client.time.step(100); // resolves when time has arrived and the run is paused again
314
+ } catch (error) {
315
+ if (error instanceof ActionError) console.log(error.code, error.message, error.outcome);
316
+ }
317
+ ```
318
+
319
+ | Name | What it is |
320
+ | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
321
+ | `status` | The one state to show: `link`, `run`, `file`, `result` and `problem` (below). Discrete values only |
322
+ | `clock` | `sim_ms` (the virtual time in ms; `null` before a run), `speed`, `actual_speed` (the speed over about the last second; `null` while paused and right after the start) and `pacing` (`not-paced`, `on-time` or `late`). It changes often, so it is apart from `status` |
323
+ | `controls` | Whether each operation can be used now: `start`, `stop`, `force_stop`, `pause`, `resume`, `step` (with `min_ms` and `max_ms`), `run_until`, `speed` (with `min`, `max` and `fastest`: whether `'max'` is accepted besides the numbers), and `save` |
324
+ | `scenario` | The scenario of the current (or last) run: `file`, `name`, `status`, `steps`, `timeline_url`; `null` for a run without one |
325
+ | `outside` | The networks that the run's `connect` connected to a real bus ("Connecting a network outside" below) |
326
+ | `connections({ network }, { file }?)`, `check(intent?, { file }?)` | Where a network can be connected, and the check of an intent without starting it ("Connecting a network outside" below) |
327
+ | `readConfig({ file }?)` | The text of a configuration file as it is saved, with its `stamp` ("Editing the text of a configuration file" below) |
328
+ | `check(intent?, { file, text }?)` | With `text`, the check of an unsaved text of the file (the same section) |
329
+ | `describeAgain({ file, variant }?)` | Describes the participants of the saved file again, and returns that check (the same section) |
330
+ | `saveConfig({ file, text, stamp })` | Saves a text as the file, with the `stamp` it was read with (`null`: a new file), and returns the new `stamp` (the same section) |
331
+ | `run` | `start(intent?, { file }?)`, `stop()` and `forceStop()` |
332
+ | `time` | `pause()`, `resume()`, `step(ms)`, `setSpeed(value)` and `runUntil(ms)` |
333
+ | `variable(ref)` | One variable, by `"ECU.variable"` (cut at the first dot) or `{ peer, name }` (for an ECU whose name has a dot) |
334
+ | `low`, `close()` | The `GuiClient` of the same connection; `close()` disconnects (a shared connection is made again by the next `connect()`) |
335
+ | `watch(source, fn)`, `until(source, test, options)` | `watch` calls `fn` now and on every change (several sources: `watch([a, b], (a, b) => ...)`) and returns the function that stops it. `until` resolves with the first value that satisfies `test`; it rejects with an `ActionError` (`timeout` or `aborted`, both `unknown`) |
336
+
337
+ Data fields use the wire's names (`force_stop`, `sim_ms`); functions use JavaScript's (`forceStop`, `runUntil`). Every state is a `Readable`; `get()` returns the same object while nothing changed, and `get` and `subscribe` work without `this` (they can be passed to `useSyncExternalStore` as they are).
338
+
339
+ ### `status`
340
+
341
+ | Field | Values |
342
+ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
343
+ | `link` | `connecting`, `online`, `offline`, `rejected` (the token was refused) or `incompatible` (another protocol version). `online` means the copy matches the server |
344
+ | `run` | `none`, `starting` (a start is on its way, from this page or another), `waiting` (the launcher waits for the participants to join), `running`, `paused`, `stopping`, `ended` (there is a result) or `crashed` (the launcher ended without one) |
345
+ | `file` | The configuration file of the run (the last one if none is running); the server's start-up file before the first run. `null` until the first answer from the server (the type is `string \| null`), and when there is no start-up file |
346
+ | `result` | While `run` is `ended` or `crashed`: `end` (`completed`, `stopped`, `interrupted`, `failed`, `setup_failed` or `crashed`; `null` when nothing was started: the check failed, or the file or the command line could not be used), `scenario`, `ok` and `message` (one English sentence). A stop by the operator is `ok`, except when it stopped a scenario before its end |
347
+ | `problem` | The one problem to tell the user now (`{ code, message }`), or `null` |
348
+
349
+ `problem` is chosen in this order: the connection first (the token refused, another protocol version, offline); otherwise the newest of the launcher's crash, the failure of the last operation and a failed run (`result.ok` is false). A crash and a failed run go when the next run begins. The failure of an operation goes at the next operation or when `status.run` changes. A stop by the operator is not a problem, except when it stopped a scenario before its end (`result.ok` is false then, and the message says that the scenario has no verdict). The failure of a variable write is in the variable's own `problem`, not here. The server's notices (`low.session.session` `problems`) and `notices` stay in `low`.
350
+
351
+ `result.end`, `result.ok` and `result.message` are the launcher's: it writes them into its result (`end`, `ok` and `message`; see "How a run ended" in [simulation-run.md](../../docs/simulation-run.md#how-a-run-ended-end-ok-message)), and the library passes them on. The library has no table of result names. Only `crashed` is the library's own (`ok` is false, with a sentence of its own), because a launcher that ended without a result wrote nothing.
352
+
353
+ ### `controls`
354
+
355
+ Each entry is `{ ok, reason, caution }`: `reason` is `{ code, message }` when `ok` is false, `caution` is the same shape for an operation that is accepted with something to know first. The codes stay the same (a new code may be added; the meaning of one does not change); the sentence is English, written by the owner of the rule.
356
+
357
+ | Entry | Comes from |
358
+ | ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
359
+ | `start` | The GUI server's `allowed.start` (`starting`, `already-running`, `launcher-unusable`, `shutting-down`), with its sentence |
360
+ | `stop`, `force_stop` | The GUI server's `allowed.stop` and `allowed.force`. `stop` is `ok` for the last known run (or a start on its way), also offline, and while the server says the launcher still runs after its result. `force_stop` is `ok` only after a first stop (`not-stopping` before) |
361
+ | `pause`, `resume`, `step`, `speed`, `run_until` | The launcher's `state.allowed` (reason, sentence and `caution` as the launcher wrote them; the ranges of `step` and `speed`; `fastest` is false when `min` equals `max`, as the launcher promises). No run in the copy: `not-running`; the launcher has not said yet (no `state` yet at the start of a run, or no entry for the operation): `unsupported` |
362
+ | `pause`, `resume` (what would change nothing) | `pause` is not `ok` while the run is paused (`paused`), `resume` is not `ok` while it is not (`not-paused`): the launcher accepts both, but a button has nothing to do. While a step or a run_until is on its way (accepted, and not yet seen to arrive: virtual time at its `at_ms` and the launcher's `state` paused), neither is claimed |
363
+ | `save` | The GUI server's `allowed.save` (`save-disabled`: started with `--no-save`; `shutting-down`), with its `caution` (`command-changes-allowed`: started with `--allow-command-changes`, so it also saves edits that change the commands that run). Whether one edit is saved is the answer to `saveConfig()` |
364
+ | All of them | The connection: `rejected`, `incompatible`, `offline` or `connecting` turn them off (`stop` and `force_stop` stay as above); `busy` while the same operation of this page has not been answered |
365
+
366
+ ### Operations
367
+
368
+ `run.start(intent, { file })` takes the intent: `vehicle_sil_run_request` (1, optional), `variant`, `params`, `scenario`, `disable`, `enable`, `manual`, `strict`, `speed`, `start_paused`, `connect` and `time_policy`, as the launcher's request file names them (`scenario` is a `path` that `scenarios()` gave, relative to the GUI server's root; the request file's own `scenario` is relative to the configuration file's directory, and the server rewrites the path, so do not compose it) (any other field is refused with `unknown-field`; a choice that is not made is a key that is left out, never `null`); `file` defaults to the server's start-up file (`scenarios({ file })` and `connections()` default to it too: give the same `file` to each when a run uses another file). Every operation is a Promise. It rejects with an `ActionError`: `code`, a sentence (`message`), `findings` (for `check-failed`) and `outcome`: `refused` (the owner said no; nothing happened) or `unknown` (it may have been done: look at `status` and `clock` before you send it again).
369
+
370
+ | Operation | Resolves when | Rejects with |
371
+ | ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
372
+ | `run.start` | The server took the request. Whether the run began is `status.run` (wait with `until(client.status, s => s.run !== 'starting')`, then read `run`) | The refusal (`check-failed` with the `findings`, `already-running`, ...). No answer in time: `no-answer` (`unknown`: it may have started) |
373
+ | `run.stop`, `run.forceStop` | The server took the request. Sent whatever the state of the connection (HTTP may reach the server when the WebSocket is down); asking again while one is on its way is the same request | The same |
374
+ | `time.pause`, `resume`, `setSpeed` | The launcher answered. `pause` while paused and `resume` while running send nothing and resolve, only when the connection is `online` and a run takes the operation | The launcher's `reason` and sentence (`refused`); no answer within 5 seconds: `no-answer` (`unknown`); the run ended before the answer: `not-running` (`unknown`) |
375
+ | `time.step`, `time.runUntil` | Time has arrived and the run is paused again, so `clock` can be read after `await`. `runUntil(t)` arrives at `t` (a `t` the paused run has already passed resolves at once and time does not move); `step(ms)` at the `at_ms` the launcher writes in the answer (older launcher: the time it was accepted plus the `ms` it rounded to, an estimate) | As above; and `interrupted` (`unknown`) when a resume or a pause of another sender (another page or stdin) comes before it arrives (a pause or resume of this page, or a stop, rejects it the same way but is not shown in `status.problem`). Another step sent meanwhile does not end it |
376
+
377
+ The client refuses before sending only what it owns: the connection (`rejected`, `incompatible`), the same operation still waiting for its answer (`busy`; this includes `start()`) and the shape of an argument (`invalid-argument`). Anything else is sent even if `controls` says no, and the owner's answer comes back (the copy may be old). The 5 seconds are the front door's own (they do not apply to the wait for arrival, which ends when the run ends or another command interrupts it).
378
+
379
+ A time command carries a request number (`id`) that the page chose, and the answer is the launcher's `command` event with the same `id`; an answer to another page's or stdin's command with the same name is not taken for it.
380
+
381
+ ### Connecting a network outside
382
+
383
+ A `can` or `ethernet` network can be connected to a real bus through the launcher's bridge ("Connecting a network outside" in [gui/protocol/README.md](../protocol/README.md#connecting-a-network-outside-connect-time_policy-apiconnections)). The front door adds three things for it, with no rule of its own.
384
+
385
+ ```ts
386
+ const entries = await client.connections({ network: 'ETH_EXT' }); // when the user opens the choice
387
+ const intent = { connect: { ETH_EXT: 'fake0' }, time_policy: 'free' as const };
388
+ const result = await client.check(intent); // the launcher's findings, before anything starts
389
+ await client.run.start(intent);
390
+ const stop = watch(client.outside, (rows) => console.log(rows.map((r) => r.condition)));
391
+ ```
392
+
393
+ - **`connections({ network }, { file }?)`** asks `POST api/connections` and lays the answer out as one list, in its order: `{ backend, value, label, detail, usable, reason }` for each target, and `{ backend, error }` (the launcher's sentence) for a backend whose bridge could not list, or for an error of the file. Tell the two apart with `'error' in entry`. A list that lacks a backend (exit code 1) is not a failure. It starts that network's bridge on the computer of the GUI server (on Windows, Npcap may ask to raise the rights there), so call it when the user opens the choice, not when the page opens. The list is that computer's, not the browser's. It rejects with an `ActionError` (`check-busy`, `unknown-network`, ...).
394
+ - **`intent.connect`** maps a network to a `value` that the list gave with `usable: true`, as written there; `'none'` keeps it on SIL Kit only, the same as leaving it out. The server refuses a value that its last list of that network did not give (`target-not-listed`): list the network again. **`intent.time_policy`** is `realtime` (the launcher's default: a connected run keeps real time) or `free`.
395
+ - **`check(intent?, { file, signal }?)`** returns the launcher's check result of what `run.start(intent)` would start (`findings`; `time_lock` and `networks[].outside` are in `raw`), or rejects with an `ActionError`. Its failure is not put into `status.problem`. It sends one check at a time: the next is sent after the answer to the one before (the server runs checks one at a time and refuses with `check-busy` when too many wait). A check of the same intent and file as one that waits or is on its way shares it, so the parts and the screen of a page that check the same page intent make one check. A check that waits is not sent when `signal` has aborted for every caller of it; it rejects with the signal's reason. A check on its way is shared too, and its answer reads the file as it was when it was sent: pass `fresh: true` when the user asks to check again (it shares only a check that waits). After `close()`, a check that waits is not sent and rejects with `closed`.
396
+ - **`outside`** has one row for each network that the run's `connect` connected: `network`, `target`, `participant`, `link` (Ethernet) or `bus` (CAN), `condition` (`ok`, `interrupted`, `degraded`), `reasons` (codes, in the launcher's order), `nothing_received` (apart from `condition`), and `to_outside` and `from_outside` (`null` until an `outside` event has arrived on this page). It is empty while no run is going, and in a run that a `role: bridge` participant of the file connects: do not read from it whether the run is connected outside (`time_lock.because` of the check says what makes the run keep real time). How the run ended, `connect-failed` and `connect-lost` included, is in `status`.
397
+
398
+ ### Editing the text of a configuration file
399
+
400
+ A screen that edits a configuration file reads it, checks the text before it is saved, saves it, and asks for the participants to be described again after an executable was built again ("The text of a configuration file" and "Saving a text" in [gui/protocol/README.md](../protocol/README.md#the-text-of-a-configuration-file-apiconfig-text-of-apicheck-apidescribe)). The client does not read YAML: the text is a string to it.
401
+
402
+ ```ts
403
+ const { text } = await client.readConfig({ file: 'simulation.yaml' }); // the file as it is saved
404
+ const edited = text + '\n# edited on the screen\n'; // the screen's own edit
405
+ const result = await client.check({ variant: 'fast' }, { file: 'simulation.yaml', text: edited });
406
+ console.log(result.findings.map((f) => `${f.severity}: ${f.message}`));
407
+ const open = result.participants.filter((p) => p.status === 'not_described');
408
+ if (open.length > 0) {
409
+ console.log(`${open.length} participants need describeAgain before they are compared`);
410
+ await client.describeAgain({ file: 'simulation.yaml', variant: 'fast' }); // then check the text again
411
+ }
412
+ ```
413
+
414
+ Saving sends the `stamp` that was read. When the file changed meanwhile, the server refuses with `config-changed`: read it again and make the edit on that text.
415
+
416
+ ```ts
417
+ const read = await client.readConfig({ file: 'simulation.yaml' });
418
+ const edited = read.text.replace('kind: can', 'kind: can\n external: true'); // the screen's own edit
419
+ try {
420
+ const saved = await client.saveConfig({
421
+ file: 'simulation.yaml',
422
+ text: edited,
423
+ stamp: read.stamp,
424
+ });
425
+ console.log(`saved; the next save sends ${saved.stamp}`);
426
+ } catch (error) {
427
+ if (error instanceof ActionError && error.code === 'config-changed') {
428
+ // the file changed since it was read: read it again, edit that text, save again
429
+ } else if (error instanceof ActionError && error.code === 'commands-changed') {
430
+ console.log(error.message); // the edit changes the commands that run: the launcher's finding says what
431
+ } else {
432
+ throw error;
433
+ }
434
+ }
435
+ ```
436
+
437
+ - **`readConfig({ file }?)`** asks `GET api/config` and returns `{ file, text, stamp }`: the bytes as UTF-8 as they are, and the SHA-256 of those bytes (`stamp` is what `saveConfig` sends). `file` defaults to the start-up file (`no-file` if there is none). It rejects with an `ActionError` (`not-a-configuration`, `config-too-large`, `config-unreadable`, ...).
438
+ - **`check(intent?, { file, text }?)`** with `text` checks that text as the content of `file`, which must exist; no process starts. The intent takes only `variant`, `strict` and `vehicle_sil_run_request`; the types say so, and any other field rejects with `unknown-field` before anything is sent. The check waits its turn in the same line as the other checks, but it is never shared: a check of a text is not the check of the page, and the parts and `status` do not see its answer. A refusal (`text-too-large`, `check-busy`, `check-timeout`, ...) is the caller's, as for a check without `text`. A check can pass while a participant is `not_described`: that participant was not compared with its executable. Tell them apart in `result.participants[].status === 'not_described'` (in `raw.participants[].status` if you read the raw check).
439
+ - **`describeAgain({ file, variant }?)`** asks `POST api/describe`: it checks the saved file, saves the descriptions of its participants again, and returns that check. After it, the check of a text compares those participants; a participant that only the text has needs the file saved first. It waits in the same line. A describe of the same file and variant that waits or is on its way is shared (pressing again starts the executables once). Its answer is the caller's alone, and its failure is not put into `status.problem`.
440
+ - **`saveConfig({ file, text, stamp })`** asks `POST api/config` and resolves with `{ file, stamp }`, the stamp of the saved content (send it with the next save). `stamp` is the one `readConfig` gave, or `null` to make a new file. By default the server saves only an edit that keeps the commands that run, as the launcher's check of the text says (the networks, their mapping, `external`); `controls.save` tells whether the server saves at all, and its `caution` when it also saves edits that change the commands. The text is written as it is (a BOM and the line ends stay). It rejects with an `ActionError`: `save-disabled`, `commands-changed` (`findings` are the launcher's; also a new file to a server started without `--allow-command-changes`), `config-changed` (the file changed since it was read, or a new file is there already), `config-busy` (the file could not be replaced: another program has it open, say), `config-unreadable` (the launcher cannot read the text as a configuration; `findings`), `text-too-large`, `check-busy`, .... It waits in the server's line of the checks, not in this page's. Its failure is not put into `status.problem`. After a save, the next check of a text describes the saved file first (its executables start with `--describe`).
441
+
442
+ ### One variable
443
+
444
+ ```ts
445
+ const throttle = client.variable('Engine.engine.throttle');
446
+ const stop = throttle.subscribe((view) => {
447
+ slider.value = String(view.value ?? 0);
448
+ slider.disabled = !view.can_write;
449
+ slider.title = view.why?.message ?? view.note ?? '';
450
+ });
451
+ await throttle.write(40); // resolves when it was applied in an ECU step
452
+ stop(); // the last unsubscribe stops asking the server for values
453
+ ```
454
+
455
+ The view has `value`, `text` (an enum shows the item's name), `unit`, `min`, `max`, `step`, `sim_ms`, `stale`, `note` (a sentence when the value is not a live one), `availability` (`unknown`, `active` or `inactive`: whether the ECU uses the variable now; information only, so `can_write`, `why` and `note` do not look at it, and a lost connection does not change it; `unknown` until the run's summary has the variable, then `active` with a GUI server that does not send it), `can_write` (the variable's own conditions and what the launcher accepts: `state.allowed.write`), `why` (a `{ code, message }` for what cannot be written: the variable's own reason first, then the launcher's), `writing`, `problem` (why the last write of this page did not go through), and the values of `client.low.variables.bind` (`condition`, `block`, `write_status`).
456
+
457
+ - The first subscription asks the server for the value, and the last unsubscribe stops it. There is no `close()`.
458
+ - `write(value)` needs no subscription (it sends that one write). It rejects with an `ActionError`; `no-answer` is `unknown`, and a write whose answer did not come is not sent again.
459
+ - The binding (`client.low.variables.bind`) holds back and merges writes while one is on its way (for sliders); `write()` of the front door sends each call.
460
+
461
+ ## Parts (custom elements)
462
+
463
+ `@vehicle-sil/gui-client/elements` defines 11 custom elements that draw what `connect()` returns, so that a screen can be written as HTML without a script. They use native controls in the light DOM and have no styles of their own: your CSS styles them, and they work in plain HTML and in the templates of Angular, React, Vue and Svelte. Importing the module defines them (a name that is defined already is skipped).
464
+
465
+ | Element | What it shows or does | Attributes and properties |
466
+ | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
467
+ | `<vsil-status>` | The connection, the run, the virtual time (marked when it falls behind real time) and the one problem | none |
468
+ | `<vsil-run-controls>` | Start (with the page's selection), Stop and, after a first stop, Stop without waiting | property `intent` (what the next run starts with); `label-start`, `label-stop`, `label-force-stop` (the button texts) |
469
+ | `<vsil-time-controls>` | Pause, Resume, Step, Run until and the speed | `speeds` (the speeds to choose from, separated by spaces; default `0.5 1 5 max`; a speed outside the range of `controls.speed` cannot be chosen, and `max` is not offered while `fastest` is false; the part does not say why, so a page that wants to say it reads the range from `client.controls`), `step-ms` (the size of a step in ms; default `10`); `label-pause`, `label-resume`, `label-step`, `label-run-until` (the button texts) |
470
+ | `<vsil-value>` | The value and its unit, and a sentence when it is not live. A bool shows as the `on` and `off` text | `variable`; `on`, `off` (the text for a bool's true and false); `no-unit` (leave the unit out) |
471
+ | `<vsil-slider>` | A number in the variable's range; it is written when the knob is released | `variable` |
472
+ | `<vsil-write>` | A button that writes one value (not usable when the variable already has it) | `variable`; `value` (what to write: JSON such as `false` or `3`, otherwise text); `label` (the button text) |
473
+ | `<vsil-scenario-select>` | The scenario of the next run, among those next to the run's configuration file (the first choice is none) | none |
474
+ | `<vsil-scenario-result>` | The status and the steps of the run's scenario | none |
475
+ | `<vsil-timeline>` | The timeline of the run's scenario, in the `<vehicle-sil-timeline>` that you put inside it | none; the attributes of that element are yours (see below) |
476
+ | `<vsil-connect>` | Where one network of the next run is connected: SIL Kit only first, then the targets of the list ("Connecting a network outside with the parts" below) | `network` (a `can` or `ethernet` network of the configuration file) |
477
+ | `<vsil-outside>` | One row for each network that the run connected, with its condition and counts | none |
478
+
479
+ A variable is written `ECU.variable` (cut at the first dot), as for `client.variable()`.
480
+
481
+ ```html
482
+ <script type="module" src="/vsil/vehicle-sil-gui-elements.mjs"></script>
483
+ <vsil-status></vsil-status> <vsil-run-controls></vsil-run-controls>
484
+ <label>Throttle <vsil-slider variable="Engine.engine.throttle"></vsil-slider></label>
485
+ <vsil-write
486
+ variable="Engine.ecu.connected"
487
+ value="false"
488
+ label="Cut engine from the bus"
489
+ ></vsil-write>
490
+ <p>
491
+ Engine lost:
492
+ <vsil-value variable="Dashboard.dashboard.engine_lost" on="LOST" off="ok"></vsil-value>
493
+ </p>
494
+ <vsil-time-controls speeds="0.5 1 5 max"></vsil-time-controls>
495
+ <label>Scenario of the next run <vsil-scenario-select></vsil-scenario-select></label>
496
+ <vsil-scenario-result></vsil-scenario-result>
497
+ <script src="/timeline/vehicle-sil-timeline.js"></script>
498
+ <vsil-timeline>
499
+ <vehicle-sil-timeline compact hide="help tables"></vehicle-sil-timeline>
500
+ </vsil-timeline>
501
+ ```
502
+
503
+ `<vsil-timeline>` only ties the element to the run: it sets `src` (the run's `timeline_url`, from the server's root) and `hidden` (when the run has no timeline) of the `<vehicle-sil-timeline>` inside it, and nothing else of it. It adds a default element when you put none, and removes only that one. The part does not load the element's script: the page does (`<script src="/timeline/vehicle-sil-timeline.js">`, or `import '@vehicle-sil/gui-client/timeline'`); an element that is defined later works too. The element sends the token that the page keeps in the tab; for a part with another connection (`client`), give the element its `token` property. It sets `data-timeline` (`shown` or `none`) on itself. The attributes and events of the element are in "Putting a timeline on your own screen" in [docs/gui.md](../../docs/gui.md#putting-a-timeline-on-your-own-screen).
504
+
505
+ ### What the parts promise
506
+
507
+ - **The page's connection.** A part calls `connect()` without options, so the page's own script and all the parts share one connection (one WebSocket), and a refusal of your own button shows in `<vsil-status>`. To give a part another connection, set its `client` property (a part that is in the document binds again).
508
+ - **One set of files.** Use the package, the copies of the single files, or the GUI server's `/vsil/` files, not a mix. The parts import the main entry by its file name; they do not carry a copy of it. In a project (the package) the parts and your script both import `@vehicle-sil/gui-client`. With copies, put `vehicle-sil-gui-elements.mjs` next to `vehicle-sil-gui-client.mjs` and import the client from that same file. With the server, load the parts from `/vsil/vehicle-sil-gui-elements.mjs` and the client from `/vsil/vehicle-sil-gui-client.mjs` (the parts' own import resolves to it). A second copy of the library, such as a copy of the client next to the page and the parts from `/vsil/`, makes a second connection.
509
+ - **Your markup and your CSS.** There is no shadow DOM. A part draws into one `<span class="vsil">` that it adds, and the children you put in the element stay. It sets `data-*` attributes for CSS: `data-link`, `data-run`, `data-pacing` (`<vsil-status>`), `data-stale`, `data-can-write`, `data-availability` and `data-on` (the variable parts; `data-availability` never disables a part; to dim an unused variable, write `[data-availability="inactive"] { opacity: .45; }`), `data-error` (every part that could not connect, the code of the error when it has one, else `error`; removed when it binds again), `data-status` (`<vsil-scenario-result>` and its steps), `data-network`, `data-chosen` and `data-reverted` (`<vsil-connect>`; its `data-error` is also the code of a list that failed), `data-network`, `data-condition` and `data-nothing-received` (each row of `<vsil-outside>`), and on each button of `<vsil-run-controls>` and `<vsil-time-controls>`, and on the speed select, `data-reason` and `data-caution` (the code, when there is one).
510
+ - **A button that cannot be used** is not `disabled`: it has `aria-disabled="true"` (so it keeps the focus), pressing it does nothing, and the reason is a sentence in an element that `aria-describedby` points to (the speed select is described the same way). A reason that only says there is nothing to do (`not-running`, `offline`) is in that element too, but the element is `hidden`: a screen reader reads it, and the page does not repeat it beside every button (`<vsil-status>` shows the state). The same goes for `<vsil-write>` when the variable already has the value ("already false"). A slider that cannot be written, or has no range, is `disabled`, and the reason is next to it.
511
+ - **Life.** A part subscribes when it enters the document and stops everything when it leaves. When it leaves while it waits for the connection, it draws nothing. When `variable` or another attribute changes, it binds again. `<vsil-connect>` takes its network out of `pageIntent.connect` when it leaves or its `network` or `file` changes, so that no run is connected by a choice that is not on the page (a part drawn again starts at SIL Kit only).
512
+ - **A part that could not connect** (no token, the server is not there) fails together with the other parts of the page, because they share one connection. The page shows the error sentence once: in `<vsil-status>`, or in the first part in document order when the page has no `<vsil-status>` (if that part leaves, another one shows it). Every such part gets `data-error`, so CSS and scripts see the failure; the mark goes when the part binds again and succeeds. A part that was given its own connection in `client`, or that fails while it draws (a missing `variable` attribute), shows its own sentence.
513
+ - **A failed action** (an `ActionError`) is not thrown at the page: `status.problem` shows it in `<vsil-status>`, and a failed write shows next to its variable.
514
+ - **No more than these 11.** Graphs, tables and the layout are the screen's work. For a graph of a variable over time, keep its history with `client.low.variables.bind(ref, { history: 600 })` and draw the points yourself ("[History](#history)" below).
515
+
516
+ ### Words and the next run
517
+
518
+ The words are English. Attributes rename the buttons (`label-start` and the others in the table, and `label` of `<vsil-write>`). The sentences of reasons (a button that cannot be used, `caution`, the problem, why a variable cannot be written) come from the owner of the reason, in English; `setReasonText(fn)` replaces them: `fn(reason)` returns the sentence, or `null` or `undefined` to keep the English one, and `setReasonText(null)` removes it. Call it before the parts are in the page. The other words of the parts (`ready`, `writing…`, `(no scenario)`, `fastest`, `behind real time`, `Step (ms)`, `Until (ms)`, `Speed`, `-`, the default `on` and `off`, `SIL Kit only (not connected)`, the sentence of a choice taken back to SIL Kit only, and `link`, `bus`, `to outside`, `from outside` and `nothing received` of `<vsil-outside>`) cannot be changed.
519
+
520
+ The choosing parts and the start button are separate elements, so the module keeps what the page selected for the next run in `pageIntent` (`get()`, `subscribe(fn)` and `update(patch)`; a field set to `''` or `undefined` is removed). `<vsil-scenario-select>` writes `scenario`; `<vsil-run-controls>` starts with `{ ...pageIntent.get(), ...intent }`, so its `intent` property wins, and it starts the file that `status.file` names, the same file whose scenarios `<vsil-scenario-select>` lists (the server's start-up file when no run has been started). A screen that starts a run with its own code passes the intent to `client.run.start(intent)` itself; it writes the choices that the check sees into `pageIntent` too, so that `<vsil-connect>` checks what the screen will start.
521
+
522
+ Start the GUI server with a configuration file (`vehicle-sil-gui --web my-screen simulation.yaml`). Without one the server has no start-up file, and a screen made of parts alone cannot start a run: `<vsil-status>` shows the refusal (`no-file`). Only your own code can name the file then: `client.run.start(intent, { file })`.
523
+
524
+ ```ts
525
+ import '@vehicle-sil/gui-client/elements'; // defines the parts
526
+ import { pageIntent, setReasonText } from '@vehicle-sil/gui-client/elements';
527
+
528
+ setReasonText((reason) => (reason.code === 'running' ? 'A run is going.' : null));
529
+ pageIntent.update({ variant: 'winter' }); // what the next start uses, with the scenario that was chosen
530
+ const controls = document.querySelector('vsil-run-controls'); // typed: the parts are in HTMLElementTagNameMap
531
+ if (controls) controls.intent = { speed: 'max' };
532
+ ```
533
+
534
+ The parts need a DOM, so Node does not load them (the main entry does not import them).
535
+
536
+ ### Connecting a network outside with the parts
537
+
538
+ `<vsil-connect network="ETH_EXT">` is a plain `<select>`. Its first choice is `none` (SIL Kit only). It asks for the list (`connections()`) only when the user opens it: a press, or a key other than Tab, Shift, Escape and the modifiers alone (passing it by with Tab asks for nothing, and neither does opening the page). It asks again each time, with `aria-busy` while it waits. The targets come in the list's order, under the name of their backend (`<optgroup>`). A target that cannot be used is a `disabled` option whose text is its label, its detail and the launcher's reason; a backend that has no list is a line in the element that describes the select (`aria-describedby`). The choice goes into `pageIntent.connect` (`none` takes the network out). A choice that the page put into `pageIntent` itself is shown as written. The part lists and checks the configuration file that its `file` attribute names (default: the start-up file, as `run.start`): a page that starts another file sets `file` to it.
539
+
540
+ While the network has a choice, the part checks the page intent (`check()`) about 200 ms after it last changed, whichever part or script changed it; the parts and the screen of a page that check the same intent share one check (`check()` shares it). It shows, as the launcher wrote them, the findings `connect-*` and `outside-*` of its network, the `connect-*` findings of the other networks of `connect` after their name (`CAN1: ...`; a finding about two networks names one of them), and the `outside-*` findings of the run when the check says that this network makes the run keep real time (`time_lock.because`). Each line has `data-code` and `data-severity`. These lines are a guide before the start: what the run does is decided when it starts, by the GUI server and the launcher. A refusal is shown as the server wrote it. After `target-not-listed`, a part that the user has opened lists the network again, once, and checks again if the choice is still listed. When a new list does not offer the choice, or offers it as one that cannot be used, the choice goes back to `none`: a line in the description says which value and why (`'<value>' is not in the list of this computer: back to SIL Kit only`, or `'<value>' cannot be used (<reason>): back to SIL Kit only`), and `data-reverted` holds the value until the user chooses again. The part does not keep a choice from one page load to the next, and it has no choice of `time_policy`: the page sets it with `pageIntent.update({ time_policy: 'free' })`.
541
+
542
+ `<vsil-outside>` draws the rows of `client.outside` in words (not only in colour; the counts are not a live region, since they change every second), and nothing when there are none.
236
543
 
237
544
  ## ECU variables
238
545
 
@@ -337,7 +644,7 @@ The `kind` of a `WriteError`:
337
644
  - Resend only once you know that the write was not applied.
338
645
  - This matters most for writes that add to a value (writing twice gives a different result). Writing the same value twice gives the same result.
339
646
 
340
- **Reconnection**: if the connection drops while you wait for a result, the summary after reconnecting (`hello`, `fetchSession()`) tells how it went on. The summary holds every open operation the server keeps, and every operation whose number is `operations_from_seq` or higher.
647
+ **Reconnection**: if the connection drops while you wait for a result, the summary after reconnecting (`hello`, `fetchSession()`) tells how it went on. The summary holds every open operation the server keeps, and every operation whose number is `operations_from_seq` or higher (of those the server receives: the operations of a scenario's own writes never come).
341
648
 
342
649
  | Your operation | What the library does |
343
650
  | ------------------------------------------------------------------ | --------------------------------------------------------------------------- |
@@ -353,12 +660,12 @@ The `kind` of a `WriteError`:
353
660
  - `onAccepted` (a function that receives `{session, seq}`) is called once, when the server has received the write and returned the operation number. This is before the result. It is not called when the write is rejected or no response comes.
354
661
  - Use `onAccepted` to show "accepted, waiting to be applied", and to know when you may send the next write. Writes through `bind` use it: a next value that comes before the server has received the previous write is kept instead of sent, and only the last value is sent once the server has it.
355
662
  - `timeoutMs` (default `WRITE_TIMEOUT_MS`) counts from the HTTP response. `Infinity` sets no time limit (the write waits until the run changes or `close()` is called). Values above 2^31-1 ms (about 24.8 days) are capped there. Non-numbers and values of 0 or less mean the default.
356
- - A write is applied in the step at the given virtual time (`atMs`; if omitted, the next step), so it does not complete while the simulation is paused. To write while paused, wait for `queued` in `client.variables.operations` before you advance (`examples/gui_client/variables.mjs`).
357
- - `client.variables.operations` lists recent operations, including writes from other clients.
663
+ - A write is applied in the step at the given virtual time (`atMs`; if omitted, the next step), so it does not complete while the simulation is paused. To write while paused, wait for `queued` in `client.variables.operations` before you advance (`examples/gui_client/variables.mjs`, in a clone of the repository).
664
+ - `client.variables.operations` lists recent operations, including writes from other clients, but not a scenario's own writes.
358
665
 
359
666
  ### Write before the first step
360
667
 
361
- A run started paused (`start_paused`) waits before the first step if the launcher can read and write variables. Meanwhile `beforeStart` in `client.time.state` is true, and you can resume and step (written values are applied in the step at time 0).
668
+ A run started paused (`start_paused`) waits before the first step if the launcher can read and write variables. Meanwhile `isHolding(session)` is true (`holding` in the launcher's `state`, `launcherState` of the session copy), and you can resume and step (written values are applied in the step at time 0).
362
669
 
363
670
  ## Build widgets (`bind`)
364
671
 
@@ -384,14 +691,15 @@ Always call `close()` when you are done (it cleans up the watch and the subscrip
384
691
 
385
692
  ### Fields of `state` (`BoundVariable`)
386
693
 
387
- | Field | Contents |
388
- | ------------- | ------------------------------------------------------------------------------------------------ |
389
- | `info` | The variable definition (`undefined` if the current run does not have the variable) |
390
- | `reading` | The last value (`VariableReading`; `undefined` if there is none yet or while `visible` is false) |
391
- | `condition` | The value condition ("Value condition (`condition`)" below) |
392
- | `block` | Why the variable cannot be written now ("Why a write is blocked (`block`)" below) |
393
- | `writeStatus` | The status of the last write ("Write status (`writeStatus`, `pending`)" below) |
394
- | `pending` | The value sent and still waiting for its result (`null` if none) |
694
+ | Field | Contents |
695
+ | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
696
+ | `info` | The variable definition (`undefined` if the current run does not have the variable) |
697
+ | `reading` | The last value (`VariableReading`; `undefined` if there is none yet or while `visible` is false) |
698
+ | `condition` | The value condition ("Value condition (`condition`)" below) |
699
+ | `block` | Why the variable cannot be written now ("Why a write is blocked (`block`)" below) |
700
+ | `launcherReason` | When `block` is `launcher`: the launcher's reason (`code` and an English `message`, as `launcherAnswer` reads it); `null` otherwise |
701
+ | `writeStatus` | The status of the last write ("Write status (`writeStatus`, `pending`)" below) |
702
+ | `pending` | The value sent and still waiting for its result (`null` if none) |
395
703
 
396
704
  - `subscribe` is called only on changes (get the first state with `state.get()`).
397
705
  - `get()` always builds the state from the current values. So if you call `get()` during a notification of another `Readable` (such as `client.variables.state`), it may notify this `state`'s subscribers of a new state right there.
@@ -423,18 +731,20 @@ The `status` of `unavailable` is one of: not running, this run has no variables,
423
731
 
424
732
  `null` if the variable can be written. If several reasons apply, `block` is the one highest in the table.
425
733
 
426
- | `block` | Meaning |
427
- | ------------------- | ---------------------------------------------------------------------------------------------------------------------- |
428
- | `read-only` | A read-only variable (`role` is `output`) |
429
- | `disconnected` | The connection between the client and the server is down |
430
- | `ended` | The run ended |
431
- | `not-ready` | The variable feature is not available (not running, connecting, cannot connect) |
432
- | `missing` | The current run does not have the variable |
433
- | `peer-disconnected` | The ECU is not connected to the Control Server |
434
- | `parameter` | A `parameter` can be written only before the first step of a run started paused (`beforeStart` in `client.time.state`) |
435
- | `scenario` | A scenario is running (view only) |
436
- | `no-range` | `needsRange` is set, but the variable has no range (`min` and `max`) |
437
- | `no-value` | `needsValue` is set, and there is no value yet (neither read nor sent) |
734
+ The facts of the variable and the run come first, then the launcher's answer (`launcher`), then the client's prediction (`parameter`), then what the widget needs. Only `launcher` comes from the launcher; the other values are the client's own. The client has no rule of its own about what the launcher accepts: when the launcher takes a write during a scenario, `bind` lets it through. It reads the launcher's answer with `launcherAnswer(launcherState, 'write')`, as `controls` of the front door read theirs.
735
+
736
+ | `block` | Meaning |
737
+ | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
738
+ | `read-only` | A read-only variable (`role` is `output`) |
739
+ | `disconnected` | The connection between the client and the server is down |
740
+ | `ended` | The run ended |
741
+ | `not-ready` | The variable feature is not available (not running, connecting, cannot connect) |
742
+ | `missing` | The current run does not have the variable |
743
+ | `peer-disconnected` | The ECU is not connected to the Control Server |
744
+ | `launcher` | The launcher does not take a write now (`allowed.write` of its `state`; `launcherReason` has its code and sentence, for example `scenario-running` while a scenario plays), or has not said yet that it does: until a `state` with `allowed.write` arrives, `unsupported` |
745
+ | `parameter` | A `parameter` can be written only before the first step of a run started paused (`isHolding(session)`: `holding` in the launcher's `state`). The client's prediction of the ECU's rule: the launcher does not say it for each variable |
746
+ | `no-range` | `needsRange` is set, but the variable has no range (`min` and `max`) |
747
+ | `no-value` | `needsValue` is set, and there is no value yet (neither read nor sent) |
438
748
 
439
749
  ### Write status (`writeStatus`, `pending`)
440
750
 
@@ -519,12 +829,14 @@ If you create it with `{ history: 600 }`, `history()` returns the points, oldest
519
829
 
520
830
  The tools (TypeScript, ESLint, Prettier, Vitest, esbuild) are the ones in `node_modules` of `gui/web`. Run these in `gui/web` (`scripts/verify-web.py` runs them too):
521
831
 
522
- | Command | What it does |
523
- | ---------------------- | ----------------------------------------------------------------------------------------------- |
524
- | `npm run test:client` | Type check (`tsc -p ../client`) and unit tests (Vitest; runs on Node, without Angular or a DOM) |
525
- | `npm run build:client` | Bundles into one ESM file (esbuild, the copy that comes with the Angular build tools) |
526
- | `npm run lint` | `gui/web`, and this directory with its `eslint.config.js` |
527
- | `npm run format:check` | Formatting of `gui/web` and this directory (`gui/.prettierrc`) |
832
+ | Command | What it does |
833
+ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
834
+ | `npm run test:client` | Type check (`tsc -p ../client`) and unit tests (Vitest; the library runs on Node, without Angular; the parts in `src/elements` run in a headless Chromium) |
835
+ | `npm run build:client` | Bundles into one ESM file, and the parts into a second one that imports it (esbuild, the copy that comes with the Angular build tools) |
836
+ | `npm run lint` | `gui/web`, and this directory with its `eslint.config.js` |
837
+ | `npm run format:check` | Formatting of `gui/web` and this directory (`gui/.prettierrc`) |
838
+
839
+ The tests of the parts need Playwright's Chromium (`npx playwright install --only-shell chromium` in `gui/web`; `scripts/doctor.py` says whether it starts). They run headless; to watch them, run `npx vitest --config ../client/vitest.config.mjs --project browser --browser.headless=false` in `gui/web`.
528
840
 
529
841
  The unit tests feed the examples in `gui/protocol/examples/` instead of building server notifications by hand (`testing/protocol-examples.ts`).
530
842
 
@@ -532,6 +844,7 @@ The unit tests feed the examples in `gui/protocol/examples/` instead of building
532
844
 
533
845
  | To find | Document |
534
846
  | ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
847
+ | Which way to add your own code to the GUI: a custom panel, your own screen or a tool | "Build your own screen" in [docs/gui.md](../../docs/gui.md#build-your-own-screen) |
535
848
  | How to build your own screen and have the GUI server serve it | [Build your own screen for the browser GUI](../../docs/howto/gui-screen.md) |
536
849
  | The server API (HTTP and WebSocket shapes, versioning and compatibility rules, authentication) | [gui/protocol](../protocol/README.md) |
537
850
  | The rules the library does not enforce for you | "Rules for building a screen" in [docs/gui.md](../../docs/gui.md#rules-for-building-a-screen) |
@@ -544,4 +857,5 @@ The unit tests feed the examples in `gui/protocol/examples/` instead of building
544
857
  | ---------------------- | ---------------------------------------------------------- |
545
858
  | `run.mjs` | Calls the server API without the library |
546
859
  | `run-with-library.mjs` | Uses the bundled library file from plain JavaScript (Node) |
860
+ | `front.mjs` | Uses the front door (`connect()`, `status`) from Node |
547
861
  | `variables.mjs` | Also uses the library, to read and write ECU variables |