@vehicle-sil/gui-client 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +452 -744
- package/README.md +451 -741
- package/dist/elements.js +656 -47
- package/dist/empty.js +2 -0
- package/dist/index.js +3202 -1813
- package/package.json +13 -1
- package/timeline/vehicle-sil-timeline.d.ts +76 -0
- package/timeline/vehicle-sil-timeline.js +817 -139
- package/timeline/vehicle-sil-timeline.mjs +817 -139
- package/types/client.d.ts +13 -0
- package/types/connection.d.ts +10 -2
- package/types/elements/contracts.d.ts +112 -0
- package/types/elements/index.d.ts +5 -3
- package/types/elements/outside-parts.d.ts +5 -0
- package/types/elements/page-intent.d.ts +1 -1
- package/types/elements/part.d.ts +11 -4
- package/types/elements/run-parts.d.ts +19 -0
- package/types/elements/scenario-parts.d.ts +5 -1
- package/types/elements/variable-parts.d.ts +58 -11
- package/types/frameworks/all-contracts.d.ts +18 -0
- package/types/frameworks/react.d.ts +40 -0
- package/types/frameworks/svelte.d.ts +22 -0
- package/types/frameworks/vue.d.ts +35 -0
- package/types/front-actions.d.ts +18 -0
- package/types/front-types.d.ts +63 -8
- package/types/front-variable.d.ts +5 -0
- package/types/front.d.ts +11 -24
- package/types/http.d.ts +2 -0
- package/types/index.d.ts +4 -4
- package/types/protocol/launcher.d.ts +70 -1
- package/types/protocol/server.d.ts +36 -1
- package/types/session-state.d.ts +7 -1
- package/types/variable-binding.d.ts +3 -1
- package/types/variables.d.ts +92 -50
package/types/client.d.ts
CHANGED
|
@@ -39,6 +39,17 @@ export interface ClientOptions {
|
|
|
39
39
|
socket?: SocketFactory;
|
|
40
40
|
/** How long to wait for the answer to a time command (ms; default ANSWER_TIMEOUT_MS). */
|
|
41
41
|
answerTimeoutMs?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Interval for batching incoming WebSocket notifications (ms; finite number `0..1000`, default `BATCH_MS` = 100).
|
|
44
|
+
* `0` flushes each turn's messages on a microtask.
|
|
45
|
+
*/
|
|
46
|
+
batchMs?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Default interval for variable watches created through this client (ms; finite number `20..60_000`, default
|
|
49
|
+
* `WATCH_PERIOD_MS` = 100). Rounded down to the nearest tier in `WATCH_PERIODS_MS` and clamped to the server's
|
|
50
|
+
* limits. Note: latest-value polling at 20 ms does not guarantee capturing pulses shorter than 20 ms.
|
|
51
|
+
*/
|
|
52
|
+
watchPeriodMs?: number;
|
|
42
53
|
/**
|
|
43
54
|
* Receives what subscribers (functions passed to subscribe, onBatch, onMessages, onUnreadable) threw. The client
|
|
44
55
|
* carries on (other subscribers still get notified, and handling such as disconnecting after a refusal still
|
|
@@ -156,5 +167,7 @@ export interface ClientParts {
|
|
|
156
167
|
}
|
|
157
168
|
/** Use the client's error sink for readables built on top of it. */
|
|
158
169
|
export declare function clientErrorSink(client: GuiClient): ErrorSink | undefined;
|
|
170
|
+
/** Validates ClientOptions / ConnectOptions at runtime, rejecting unknown (e.g. legacy snake_case) fields. */
|
|
171
|
+
export declare function validateClientOptions(options: unknown): asserts options is ClientOptions;
|
|
159
172
|
/** createClient, and the parts the front door is built from. */
|
|
160
173
|
export declare function buildClient(options: ClientOptions): ClientParts;
|
package/types/connection.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ export declare const TRY_AGAIN_LATER = 1013;
|
|
|
15
15
|
* refused token (if it were longer, the client would reconnect once and then stop).
|
|
16
16
|
*/
|
|
17
17
|
export declare const BATCH_MS = 100;
|
|
18
|
+
/** Minimum allowed value for `batchMs` (0 flushes each turn's messages on a microtask). */
|
|
19
|
+
export declare const BATCH_MS_MIN = 0;
|
|
20
|
+
/** Maximum allowed value for `batchMs` (ms). */
|
|
21
|
+
export declare const BATCH_MS_MAX = 1000;
|
|
18
22
|
/** Receives WebSocket events. Passed to SocketFactory. */
|
|
19
23
|
export interface SocketHandlers {
|
|
20
24
|
open(): void;
|
|
@@ -58,7 +62,7 @@ export interface ConnectionOptions {
|
|
|
58
62
|
afterGreeting?: () => readonly unknown[];
|
|
59
63
|
/** Upper limit of the reconnect delay. */
|
|
60
64
|
maxBackoffMs?: number;
|
|
61
|
-
/** Interval for batching received notifications. */
|
|
65
|
+
/** Interval for batching received notifications (ms; 0 flushes each turn's messages on a microtask). */
|
|
62
66
|
batchMs?: number;
|
|
63
67
|
/** Receives what subscribers threw. */
|
|
64
68
|
onError?: ErrorSink;
|
|
@@ -125,6 +129,9 @@ export declare class Connection implements ClientConnection {
|
|
|
125
129
|
private steadyTimer;
|
|
126
130
|
private retryTimer;
|
|
127
131
|
private batchTimer;
|
|
132
|
+
private flushQueued;
|
|
133
|
+
private flushing;
|
|
134
|
+
private flushAgain;
|
|
128
135
|
private pending;
|
|
129
136
|
readonly state: Readable<ConnectionState>;
|
|
130
137
|
readonly failures: Readable<number>;
|
|
@@ -148,8 +155,9 @@ export declare class Connection implements ClientConnection {
|
|
|
148
155
|
send(message: unknown): boolean;
|
|
149
156
|
onBatch(listener: (batch: readonly unknown[]) => void): () => void;
|
|
150
157
|
onUnreadable(listener: (text: string) => void): () => void;
|
|
151
|
-
/** Passes on the batched notifications without waiting. */
|
|
158
|
+
/** Passes on the batched notifications without waiting. Re-entrant calls drain iteratively in order. */
|
|
152
159
|
flush(): void;
|
|
160
|
+
private scheduleImmediateFlush;
|
|
153
161
|
private dropPending;
|
|
154
162
|
private open;
|
|
155
163
|
/** Identifies the connection that produced a batch; restarting alone does not create the next one. */
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { ActionError, Front, Intent, WriteResult } from '../index.js';
|
|
2
|
+
import type { VsilConnectElement, VsilOutsideElement } from './outside-parts.js';
|
|
3
|
+
import type { VsilRunControlsElement, VsilStatusElement, VsilTimeControlsElement } from './run-parts.js';
|
|
4
|
+
import type { VsilCaseSelectElement, VsilScenarioResultElement, VsilScenarioSelectElement, VsilTimelineElement } from './scenario-parts.js';
|
|
5
|
+
import type { VsilSliderElement, VsilValueElement, VsilWriteElement } from './variable-parts.js';
|
|
6
|
+
/** Declarative contract of one custom element: its DOM class, HTML attributes, JS properties and custom events. */
|
|
7
|
+
export interface ElementContract<El extends HTMLElement = HTMLElement, Attrs extends object = Record<never, never>, Props extends object = Record<never, never>, Events extends object = Record<never, never>> {
|
|
8
|
+
readonly element: El;
|
|
9
|
+
readonly attrs: Attrs;
|
|
10
|
+
readonly props: Props;
|
|
11
|
+
readonly events: Events;
|
|
12
|
+
}
|
|
13
|
+
/** HTML boolean attribute value accepted in markup (`<el attr>`, `attr=""`, `attr={true}`). Use the camelCase JS property for dynamic boolean `false` bindings. */
|
|
14
|
+
export type BooleanAttr = true | '';
|
|
15
|
+
/** Properties common to every `Part` custom element. */
|
|
16
|
+
export interface VsilPartProps {
|
|
17
|
+
client?: Front | null;
|
|
18
|
+
}
|
|
19
|
+
/** Detail of the `vsil-write-queued` event: the write reached the ECU queue (`seq` assigned). */
|
|
20
|
+
export interface WriteQueuedInfo {
|
|
21
|
+
readonly session: string;
|
|
22
|
+
readonly seq: number;
|
|
23
|
+
readonly peer: string;
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly value: number | boolean | string;
|
|
26
|
+
}
|
|
27
|
+
/** Detail of the `vsil-write-result` event when the ECU applied the write. */
|
|
28
|
+
export interface WriteSuccess extends WriteResult {
|
|
29
|
+
readonly ok: true;
|
|
30
|
+
}
|
|
31
|
+
/** Detail of the `vsil-write-result` event when the write did not apply. */
|
|
32
|
+
export interface WriteFailure {
|
|
33
|
+
readonly ok: false;
|
|
34
|
+
readonly peer: string;
|
|
35
|
+
readonly name: string;
|
|
36
|
+
readonly value: number | boolean | string;
|
|
37
|
+
readonly error: ActionError;
|
|
38
|
+
readonly seq?: number;
|
|
39
|
+
}
|
|
40
|
+
/** Detail of the `vsil-write-result` event: either applied (`ok: true`) or failed (`ok: false`). */
|
|
41
|
+
export type WriteOutcome = WriteSuccess | WriteFailure;
|
|
42
|
+
/** Custom DOM events dispatched by `<vsil-slider>` and `<vsil-write>`. */
|
|
43
|
+
export interface VsilWriteEventMap {
|
|
44
|
+
'vsil-write-queued': CustomEvent<WriteQueuedInfo>;
|
|
45
|
+
'vsil-write-result': CustomEvent<WriteOutcome>;
|
|
46
|
+
}
|
|
47
|
+
/** Contracts of all 12 `vsil-*` custom elements defined by `@vehicle-sil/gui-client/elements`. */
|
|
48
|
+
export interface VsilElementContracts {
|
|
49
|
+
'vsil-status': ElementContract<VsilStatusElement, Record<never, never>, VsilPartProps>;
|
|
50
|
+
'vsil-run-controls': ElementContract<VsilRunControlsElement, {
|
|
51
|
+
'label-start'?: string;
|
|
52
|
+
'label-stop'?: string;
|
|
53
|
+
'label-force-stop'?: string;
|
|
54
|
+
}, VsilPartProps & {
|
|
55
|
+
intent?: Intent | null;
|
|
56
|
+
labelStart?: string | null;
|
|
57
|
+
labelStop?: string | null;
|
|
58
|
+
labelForceStop?: string | null;
|
|
59
|
+
}>;
|
|
60
|
+
'vsil-time-controls': ElementContract<VsilTimeControlsElement, {
|
|
61
|
+
speeds?: string;
|
|
62
|
+
'step-ms'?: string | number;
|
|
63
|
+
'label-pause'?: string;
|
|
64
|
+
'label-resume'?: string;
|
|
65
|
+
'label-step'?: string;
|
|
66
|
+
'label-run-until'?: string;
|
|
67
|
+
}, VsilPartProps & {
|
|
68
|
+
speeds?: string | null;
|
|
69
|
+
stepMs?: number | string | null;
|
|
70
|
+
labelPause?: string | null;
|
|
71
|
+
labelResume?: string | null;
|
|
72
|
+
labelStep?: string | null;
|
|
73
|
+
labelRunUntil?: string | null;
|
|
74
|
+
}>;
|
|
75
|
+
'vsil-value': ElementContract<VsilValueElement, {
|
|
76
|
+
variable?: string;
|
|
77
|
+
on?: string;
|
|
78
|
+
off?: string;
|
|
79
|
+
'no-unit'?: BooleanAttr;
|
|
80
|
+
}, VsilPartProps & {
|
|
81
|
+
variable?: string | null;
|
|
82
|
+
on?: string | null;
|
|
83
|
+
off?: string | null;
|
|
84
|
+
noUnit?: boolean;
|
|
85
|
+
}>;
|
|
86
|
+
'vsil-slider': ElementContract<VsilSliderElement, {
|
|
87
|
+
variable?: string;
|
|
88
|
+
}, VsilPartProps & {
|
|
89
|
+
variable?: string | null;
|
|
90
|
+
}, VsilWriteEventMap>;
|
|
91
|
+
'vsil-write': ElementContract<VsilWriteElement, {
|
|
92
|
+
variable?: string;
|
|
93
|
+
value?: string;
|
|
94
|
+
label?: string;
|
|
95
|
+
}, VsilPartProps & {
|
|
96
|
+
variable?: string | null;
|
|
97
|
+
value?: string | number | boolean | null;
|
|
98
|
+
label?: string | null;
|
|
99
|
+
}, VsilWriteEventMap>;
|
|
100
|
+
'vsil-scenario-select': ElementContract<VsilScenarioSelectElement, Record<never, never>, VsilPartProps>;
|
|
101
|
+
'vsil-case-select': ElementContract<VsilCaseSelectElement, Record<never, never>, VsilPartProps>;
|
|
102
|
+
'vsil-scenario-result': ElementContract<VsilScenarioResultElement, Record<never, never>, VsilPartProps>;
|
|
103
|
+
'vsil-timeline': ElementContract<VsilTimelineElement, Record<never, never>, VsilPartProps>;
|
|
104
|
+
'vsil-connect': ElementContract<VsilConnectElement, {
|
|
105
|
+
network?: string;
|
|
106
|
+
file?: string;
|
|
107
|
+
}, VsilPartProps & {
|
|
108
|
+
network?: string | null;
|
|
109
|
+
file?: string | null;
|
|
110
|
+
}>;
|
|
111
|
+
'vsil-outside': ElementContract<VsilOutsideElement, Record<never, never>, VsilPartProps>;
|
|
112
|
+
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { pageIntent } from './page-intent.js';
|
|
2
2
|
import { setReasonText } from './reasons.js';
|
|
3
3
|
import type { ReasonText } from './reasons.js';
|
|
4
|
+
import type { BooleanAttr, ElementContract, VsilElementContracts, VsilPartProps, VsilWriteEventMap, WriteFailure, WriteOutcome, WriteQueuedInfo, WriteSuccess } from './contracts.js';
|
|
4
5
|
import { VsilConnectElement, VsilOutsideElement } from './outside-parts.js';
|
|
5
6
|
import { VsilRunControlsElement, VsilStatusElement, VsilTimeControlsElement } from './run-parts.js';
|
|
6
|
-
import { VsilScenarioResultElement, VsilScenarioSelectElement, VsilTimelineElement } from './scenario-parts.js';
|
|
7
|
+
import { VsilCaseSelectElement, VsilScenarioResultElement, VsilScenarioSelectElement, VsilTimelineElement } from './scenario-parts.js';
|
|
7
8
|
import { VsilSliderElement, VsilValueElement, VsilWriteElement } from './variable-parts.js';
|
|
8
9
|
export { pageIntent, setReasonText };
|
|
9
|
-
export type { ReasonText };
|
|
10
|
-
export { VsilConnectElement, VsilOutsideElement, VsilRunControlsElement, VsilScenarioResultElement, VsilScenarioSelectElement, VsilSliderElement, VsilStatusElement, VsilTimeControlsElement, VsilTimelineElement, VsilValueElement, VsilWriteElement, };
|
|
10
|
+
export type { BooleanAttr, ElementContract, ReasonText, VsilElementContracts, VsilPartProps, VsilWriteEventMap, WriteFailure, WriteOutcome, WriteQueuedInfo, WriteSuccess, };
|
|
11
|
+
export { VsilCaseSelectElement, VsilConnectElement, VsilOutsideElement, VsilRunControlsElement, VsilScenarioResultElement, VsilScenarioSelectElement, VsilSliderElement, VsilStatusElement, VsilTimeControlsElement, VsilTimelineElement, VsilValueElement, VsilWriteElement, };
|
|
11
12
|
declare global {
|
|
12
13
|
interface HTMLElementTagNameMap {
|
|
13
14
|
'vsil-status': VsilStatusElement;
|
|
@@ -17,6 +18,7 @@ declare global {
|
|
|
17
18
|
'vsil-slider': VsilSliderElement;
|
|
18
19
|
'vsil-write': VsilWriteElement;
|
|
19
20
|
'vsil-scenario-select': VsilScenarioSelectElement;
|
|
21
|
+
'vsil-case-select': VsilCaseSelectElement;
|
|
20
22
|
'vsil-scenario-result': VsilScenarioResultElement;
|
|
21
23
|
'vsil-timeline': VsilTimelineElement;
|
|
22
24
|
'vsil-connect': VsilConnectElement;
|
|
@@ -9,6 +9,11 @@ import { Part } from './part.js';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class VsilConnectElement extends Part {
|
|
11
11
|
static observedAttributes: string[];
|
|
12
|
+
get network(): string;
|
|
13
|
+
set network(value: string | null);
|
|
14
|
+
get file(): string;
|
|
15
|
+
set file(value: string | null);
|
|
16
|
+
constructor();
|
|
12
17
|
protected draw(client: Front, root: HTMLElement, alive: () => boolean): void;
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Intent } from '../index.js';
|
|
2
2
|
type Listener = (intent: Intent) => void;
|
|
3
|
-
/** The page's selection for the next run (`<vsil-scenario-select>`
|
|
3
|
+
/** The page's selection for the next run (`<vsil-scenario-select>` and `<vsil-case-select>` write it, `<vsil-run-controls>` starts with it). */
|
|
4
4
|
export declare const pageIntent: {
|
|
5
5
|
get: () => Intent;
|
|
6
6
|
subscribe(listener: Listener): () => void;
|
package/types/elements/part.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ export declare function h<K extends keyof HTMLElementTagNameMap>(tag: K, attribu
|
|
|
4
4
|
/** Sets or removes a data attribute. */
|
|
5
5
|
export declare function setData(element: HTMLElement, name: string, value: string | null): void;
|
|
6
6
|
/** Runs an operation and drops its failure: `status.problem` (or the variable's `problem`) shows it. */
|
|
7
|
-
export declare function quietly(operation: () => Promise<
|
|
7
|
+
export declare function quietly(operation: () => Promise<unknown>): Promise<void>;
|
|
8
|
+
/** Whether `code` is a self-evident state whose description stays hidden visually while remaining accessible. */
|
|
9
|
+
export declare function isQuietReason(code: string): boolean;
|
|
8
10
|
/**
|
|
9
11
|
* The base of the parts. Subclasses draw into `root` in `draw()` and register what to stop with `own()`.
|
|
10
12
|
*
|
|
@@ -23,7 +25,11 @@ export declare abstract class Part extends HTMLElement {
|
|
|
23
25
|
* A property that the page set before this class was defined sits on the object itself and hides the accessor:
|
|
24
26
|
* take it off and set it again.
|
|
25
27
|
*/
|
|
26
|
-
protected upgrade(
|
|
28
|
+
protected upgrade(...names: string[]): void;
|
|
29
|
+
/** Reflects a string attribute; `null` or `undefined` removes it while empty string is kept. */
|
|
30
|
+
protected reflectString(name: string, value: string | null | undefined): void;
|
|
31
|
+
/** Reflects a non-empty string attribute; `null`, `undefined` or `""` removes it. */
|
|
32
|
+
protected reflectNonEmpty(name: string, value: string | null | undefined): void;
|
|
27
33
|
/** Draws and subscribes. `alive()` turns false when the part has left the document or was bound again. */
|
|
28
34
|
protected abstract draw(client: Front, root: HTMLElement, alive: () => boolean): void | Promise<void>;
|
|
29
35
|
/** Stops `stop` when the part is unbound. */
|
|
@@ -36,8 +42,9 @@ export declare abstract class Part extends HTMLElement {
|
|
|
36
42
|
/**
|
|
37
43
|
* Binds `element` to one control of `client.controls`: `aria-disabled` (the caller ignores input while it is true),
|
|
38
44
|
* `data-reason` and `data-caution` (the codes), and a sentence in an element that describes it (`aria-describedby`;
|
|
39
|
-
* returned, to be put next to `element`).
|
|
40
|
-
*
|
|
45
|
+
* returned, to be put next to `element`). Empty descriptions and self-evident `QUIET` reasons (`not-running`,
|
|
46
|
+
* `offline`, `connecting`, `already-running`, `paused`, `not-paused`, `not-stopping`, `already-stopping`, `starting`)
|
|
47
|
+
* stay hidden visually while remaining accessible to screen readers.
|
|
41
48
|
*/
|
|
42
49
|
protected describe(client: Front, control: OperationName, element: HTMLElement): HTMLElement;
|
|
43
50
|
/**
|
|
@@ -11,11 +11,30 @@ export declare class VsilRunControlsElement extends Part {
|
|
|
11
11
|
/** What to start with, over what the choosing parts of the page selected. */
|
|
12
12
|
get intent(): Intent | null;
|
|
13
13
|
set intent(value: Intent | null);
|
|
14
|
+
get labelStart(): string;
|
|
15
|
+
set labelStart(value: string | null);
|
|
16
|
+
get labelStop(): string;
|
|
17
|
+
set labelStop(value: string | null);
|
|
18
|
+
get labelForceStop(): string;
|
|
19
|
+
set labelForceStop(value: string | null);
|
|
14
20
|
constructor();
|
|
15
21
|
protected draw(client: Front, root: HTMLElement): void;
|
|
16
22
|
}
|
|
17
23
|
/** `<vsil-time-controls speeds="0.5 1 5 max" step-ms="10">`: pause, resume, step, run until and speed. */
|
|
18
24
|
export declare class VsilTimeControlsElement extends Part {
|
|
19
25
|
static observedAttributes: string[];
|
|
26
|
+
get speeds(): string;
|
|
27
|
+
set speeds(value: string | null);
|
|
28
|
+
get stepMs(): string;
|
|
29
|
+
set stepMs(value: number | string | null);
|
|
30
|
+
get labelPause(): string;
|
|
31
|
+
set labelPause(value: string | null);
|
|
32
|
+
get labelResume(): string;
|
|
33
|
+
set labelResume(value: string | null);
|
|
34
|
+
get labelStep(): string;
|
|
35
|
+
set labelStep(value: string | null);
|
|
36
|
+
get labelRunUntil(): string;
|
|
37
|
+
set labelRunUntil(value: string | null);
|
|
38
|
+
constructor();
|
|
20
39
|
protected draw(client: Front, root: HTMLElement): void;
|
|
21
40
|
}
|
|
@@ -4,7 +4,11 @@ import { Part } from './part.js';
|
|
|
4
4
|
export declare class VsilScenarioSelectElement extends Part {
|
|
5
5
|
protected draw(client: Front, root: HTMLElement, alive: () => boolean): void;
|
|
6
6
|
}
|
|
7
|
-
/** `<vsil-
|
|
7
|
+
/** `<vsil-case-select>`: chooses the named case of the selected scenario for the next run. */
|
|
8
|
+
export declare class VsilCaseSelectElement extends Part {
|
|
9
|
+
protected draw(client: Front, root: HTMLElement, alive: () => boolean): void;
|
|
10
|
+
}
|
|
11
|
+
/** `<vsil-scenario-result>`: the result, metadata, and steps (with failure source and call stack) of the run's scenario. */
|
|
8
12
|
export declare class VsilScenarioResultElement extends Part {
|
|
9
13
|
protected draw(client: Front, root: HTMLElement): void;
|
|
10
14
|
}
|
|
@@ -1,28 +1,75 @@
|
|
|
1
|
-
import type { Front, FrontVariable, VariableView } from '../index.js';
|
|
1
|
+
import type { Front, FrontVariable, QueuedWrite, VariableRef, VariableView } from '../index.js';
|
|
2
|
+
import type { VsilWriteEventMap } from './contracts.js';
|
|
2
3
|
import { Part } from './part.js';
|
|
4
|
+
/** Per-binding write lifecycle tracker following the latest initiated write (matching `VariableBinder.shown`). */
|
|
5
|
+
interface WriteLifecycleTracker {
|
|
6
|
+
enqueueStarted: () => number;
|
|
7
|
+
enqueueQueued: (token: number) => void;
|
|
8
|
+
enqueueFailed: (token: number) => void;
|
|
9
|
+
appliedSucceeded: (token: number) => void;
|
|
10
|
+
appliedFailed: (token: number) => void;
|
|
11
|
+
dropped: () => void;
|
|
12
|
+
hasQueued: () => boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Per-binding context passed from `VariablePart.draw()` to subclasses. */
|
|
15
|
+
interface VariableDrawContext {
|
|
16
|
+
readonly variable: FrontVariable;
|
|
17
|
+
readonly root: HTMLElement;
|
|
18
|
+
readonly note: HTMLElement;
|
|
19
|
+
readonly alive: () => boolean;
|
|
20
|
+
readonly fallbackRef: VariableRef;
|
|
21
|
+
readonly trackLifecycle: WriteLifecycleTracker;
|
|
22
|
+
}
|
|
3
23
|
/** A part that shows or sets the variable of its `variable` attribute (`"ECU.variable"`). */
|
|
4
24
|
declare abstract class VariablePart extends Part {
|
|
5
25
|
static observedAttributes: string[];
|
|
6
|
-
/** Whether the part writes (so that it says why it cannot). */
|
|
26
|
+
/** Whether the part writes (so that it says why it cannot and tracks `data-write-status`). */
|
|
7
27
|
protected readonly writes: boolean;
|
|
28
|
+
get variable(): string;
|
|
29
|
+
set variable(value: string | null);
|
|
30
|
+
constructor();
|
|
8
31
|
/** Builds the controls once; returns what to do with each new view. */
|
|
9
|
-
protected abstract build(
|
|
10
|
-
protected draw(client: Front, root: HTMLElement): void;
|
|
32
|
+
protected abstract build(ctx: VariableDrawContext): (view: VariableView) => void;
|
|
33
|
+
protected draw(client: Front, root: HTMLElement, alive: () => boolean): void;
|
|
34
|
+
}
|
|
35
|
+
/** Shared base for variable parts that write (`<vsil-slider>`, `<vsil-write>`) and emit write lifecycle DOM events. */
|
|
36
|
+
declare abstract class WritingVariablePart extends VariablePart {
|
|
37
|
+
protected readonly writes = true;
|
|
38
|
+
addEventListener<K extends keyof VsilWriteEventMap>(type: K, listener: (this: this, ev: VsilWriteEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
|
|
39
|
+
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
|
|
40
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
41
|
+
removeEventListener<K extends keyof VsilWriteEventMap>(type: K, listener: (this: this, ev: VsilWriteEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
|
|
42
|
+
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
|
|
43
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
44
|
+
/** Dispatches a bubbling, composed write lifecycle event only while this binding is still alive and connected. */
|
|
45
|
+
protected emitWriteEvent<K extends keyof VsilWriteEventMap>(type: K, detail: VsilWriteEventMap[K]['detail'], alive: () => boolean): void;
|
|
46
|
+
/** Awaits stage 3+4 (`queued.applied()`) and emits `vsil-write-result` without ever leaking unhandled rejections. */
|
|
47
|
+
protected awaitApplied(queued: QueuedWrite, token: number, ctx: Pick<VariableDrawContext, 'alive' | 'trackLifecycle'>, onSettled?: () => void): Promise<void>;
|
|
11
48
|
}
|
|
12
49
|
/** `<vsil-value variable="ECU.variable" [on="LOST" off="ok"] [no-unit]>`: the value and its unit; a bool shows as the `on` and `off` text. */
|
|
13
50
|
export declare class VsilValueElement extends VariablePart {
|
|
14
51
|
static observedAttributes: string[];
|
|
15
|
-
|
|
52
|
+
get on(): string;
|
|
53
|
+
set on(value: string | null);
|
|
54
|
+
get off(): string;
|
|
55
|
+
set off(value: string | null);
|
|
56
|
+
get noUnit(): boolean;
|
|
57
|
+
set noUnit(value: boolean);
|
|
58
|
+
constructor();
|
|
59
|
+
protected build({ root, note }: VariableDrawContext): (v: VariableView) => void;
|
|
16
60
|
}
|
|
17
61
|
/** `<vsil-slider variable="ECU.variable">`: a number in the variable's range; it is written when the knob is released. */
|
|
18
|
-
export declare class VsilSliderElement extends
|
|
19
|
-
protected
|
|
20
|
-
protected build(variable: FrontVariable, root: HTMLElement, note: HTMLElement): (v: VariableView) => void;
|
|
62
|
+
export declare class VsilSliderElement extends WritingVariablePart {
|
|
63
|
+
protected build(ctx: VariableDrawContext): (v: VariableView) => void;
|
|
21
64
|
}
|
|
22
65
|
/** `<vsil-write variable="ECU.variable" value="false" label="Cut">`: writes one value when pressed (not when it already is that value). */
|
|
23
|
-
export declare class VsilWriteElement extends
|
|
66
|
+
export declare class VsilWriteElement extends WritingVariablePart {
|
|
24
67
|
static observedAttributes: string[];
|
|
25
|
-
|
|
26
|
-
|
|
68
|
+
get value(): string | number | boolean | null;
|
|
69
|
+
set value(value: string | number | boolean | null);
|
|
70
|
+
get label(): string;
|
|
71
|
+
set label(value: string | null);
|
|
72
|
+
constructor();
|
|
73
|
+
protected build(ctx: VariableDrawContext): (v: VariableView) => void;
|
|
27
74
|
}
|
|
28
75
|
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Single source of truth combining all 12 vsil-* parts and <vehicle-sil-timeline>.
|
|
2
|
+
import type { VsilElementContracts } from '../elements/contracts.js';
|
|
3
|
+
import type { VehicleSilTimelineContract } from '../../timeline/vehicle-sil-timeline.js';
|
|
4
|
+
|
|
5
|
+
/** Combined contract map for all 13 vehicle-sil custom elements. */
|
|
6
|
+
export type AllElementContracts = VsilElementContracts & VehicleSilTimelineContract;
|
|
7
|
+
|
|
8
|
+
/** Per-key union of HTML attributes and JS properties (avoids intersection collapse on union types). */
|
|
9
|
+
export type MergeBindings<A, P> = {
|
|
10
|
+
[K in keyof A | keyof P]?:
|
|
11
|
+
| (K extends keyof A ? A[K] : never)
|
|
12
|
+
| (K extends keyof P ? P[K] : never);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** Converts kebab-case event names (e.g. 'vsil-write-result') to camelCase ('vsilWriteResult'). */
|
|
16
|
+
export type CamelCase<S extends string> = S extends `${infer Head}-${infer Tail}`
|
|
17
|
+
? `${Head}${Capitalize<CamelCase<Tail>>}`
|
|
18
|
+
: S;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// React 18 & 19 JSX intrinsic element types derived from AllElementContracts.
|
|
2
|
+
// React 19 delegates lowercase `on<event>` props directly via addEventListener (use `onload`/`onerror`,
|
|
3
|
+
// or `ref` + `addEventListener` across React 18 and 19).
|
|
4
|
+
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
5
|
+
import type { AllElementContracts, MergeBindings } from './all-contracts.js';
|
|
6
|
+
|
|
7
|
+
export type ReactEventProps<E> = {
|
|
8
|
+
[K in keyof E & string as `on${K}`]?: (event: E[K]) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Omit React's PascalCase synthetic handlers (e.g. onLoad/onError) for custom events declared on the element:
|
|
12
|
+
// React 19 intercepts PascalCase onLoad/onError as synthetic events that never fire for custom element CustomEvents.
|
|
13
|
+
type ReactSyntheticConflicts<E> = {
|
|
14
|
+
[K in keyof E & string as `on${Capitalize<K>}`]: never;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type ReactElementProps<C extends AllElementContracts[keyof AllElementContracts]> = Omit<
|
|
18
|
+
DetailedHTMLProps<HTMLAttributes<C['element']>, C['element']>,
|
|
19
|
+
| keyof MergeBindings<C['attrs'], C['props']>
|
|
20
|
+
| keyof ReactEventProps<C['events']>
|
|
21
|
+
| keyof ReactSyntheticConflicts<C['events']>
|
|
22
|
+
> &
|
|
23
|
+
MergeBindings<C['attrs'], C['props']> &
|
|
24
|
+
ReactEventProps<C['events']>;
|
|
25
|
+
|
|
26
|
+
export type VehicleSilReactIntrinsicElements = {
|
|
27
|
+
[Tag in keyof AllElementContracts]: ReactElementProps<AllElementContracts[Tag]>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
declare module 'react' {
|
|
31
|
+
namespace JSX {
|
|
32
|
+
interface IntrinsicElements extends VehicleSilReactIntrinsicElements {}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare global {
|
|
37
|
+
namespace JSX {
|
|
38
|
+
interface IntrinsicElements extends VehicleSilReactIntrinsicElements {}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Svelte 5 HTML element types derived from AllElementContracts.
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { AllElementContracts, MergeBindings } from './all-contracts.js';
|
|
4
|
+
|
|
5
|
+
export type SvelteEventProps<E> = {
|
|
6
|
+
[K in keyof E & string as `on${K}`]?: (event: E[K]) => void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type SvelteElementProps<C extends AllElementContracts[keyof AllElementContracts]> = Omit<
|
|
10
|
+
HTMLAttributes<C['element']>,
|
|
11
|
+
keyof MergeBindings<C['attrs'], C['props']> | keyof SvelteEventProps<C['events']>
|
|
12
|
+
> &
|
|
13
|
+
MergeBindings<C['attrs'], C['props']> &
|
|
14
|
+
SvelteEventProps<C['events']>;
|
|
15
|
+
|
|
16
|
+
export type VehicleSilSvelteElements = {
|
|
17
|
+
[Tag in keyof AllElementContracts]: SvelteElementProps<AllElementContracts[Tag]>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
declare module 'svelte/elements' {
|
|
21
|
+
export interface SvelteHTMLElements extends VehicleSilSvelteElements {}
|
|
22
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Vue 3 GlobalComponents types derived from AllElementContracts.
|
|
2
|
+
import type {
|
|
3
|
+
AllowedComponentProps,
|
|
4
|
+
ComponentCustomProps,
|
|
5
|
+
HTMLAttributes,
|
|
6
|
+
VNodeProps,
|
|
7
|
+
} from 'vue';
|
|
8
|
+
import type { AllElementContracts, CamelCase, MergeBindings } from './all-contracts.js';
|
|
9
|
+
|
|
10
|
+
export type VueEventProps<E> = {
|
|
11
|
+
[K in keyof E & string as `on${Capitalize<K>}`]?: (event: E[K]) => void;
|
|
12
|
+
} & {
|
|
13
|
+
[K in keyof E & string as `on${Capitalize<CamelCase<K>>}`]?: (event: E[K]) => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type VueElementProps<C extends AllElementContracts[keyof AllElementContracts]> = Omit<
|
|
17
|
+
HTMLAttributes,
|
|
18
|
+
keyof MergeBindings<C['attrs'], C['props']> | keyof VueEventProps<C['events']>
|
|
19
|
+
> &
|
|
20
|
+
MergeBindings<C['attrs'], C['props']> &
|
|
21
|
+
VueEventProps<C['events']>;
|
|
22
|
+
|
|
23
|
+
export type VehicleSilVueGlobalComponents = {
|
|
24
|
+
[Tag in keyof AllElementContracts]: new () => {
|
|
25
|
+
$el: AllElementContracts[Tag]['element'];
|
|
26
|
+
$props: AllowedComponentProps &
|
|
27
|
+
ComponentCustomProps &
|
|
28
|
+
VNodeProps &
|
|
29
|
+
VueElementProps<AllElementContracts[Tag]>;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
declare module 'vue' {
|
|
34
|
+
export interface GlobalComponents extends VehicleSilVueGlobalComponents {}
|
|
35
|
+
}
|
package/types/front-actions.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface ActionSources {
|
|
|
20
20
|
low: GuiClient;
|
|
21
21
|
http: HttpTransport;
|
|
22
22
|
captureStop(): StopCapture;
|
|
23
|
+
activeTarget?(): RunTarget | null;
|
|
23
24
|
snapshot(): Snapshot;
|
|
24
25
|
controls(): FrontControls;
|
|
25
26
|
run(): RunState;
|
|
@@ -43,6 +44,9 @@ export declare class FrontActions {
|
|
|
43
44
|
private readonly stopConfirmedForValue;
|
|
44
45
|
private readonly waiting;
|
|
45
46
|
private readonly inFlight;
|
|
47
|
+
private readonly syncCancelers;
|
|
48
|
+
private syncingStop;
|
|
49
|
+
private syncingForceStop;
|
|
46
50
|
/** The checks not answered yet, in the order they are sent: the first is on its way, the others wait. */
|
|
47
51
|
private readonly checks;
|
|
48
52
|
/** Rejects when the client closes: a check that waits ends with it. */
|
|
@@ -102,8 +106,21 @@ export declare class FrontActions {
|
|
|
102
106
|
private textRequestOf;
|
|
103
107
|
/** What the client refuses before it sends a start: the connection, and a start of this page still on its way. */
|
|
104
108
|
private refusalOfStart;
|
|
109
|
+
private timeoutDelayMs;
|
|
110
|
+
/**
|
|
111
|
+
* Waits while `link === 'connecting'` (bounded by `answerTimeoutMs`).
|
|
112
|
+
* Resolves once `link !== 'connecting'` (or `extraDone()` holds), and never hangs on WS close,
|
|
113
|
+
* auth rejection, protocol mismatch, timeout, or `dispose()`.
|
|
114
|
+
*/
|
|
115
|
+
waitForSync(opLabel: string, recordOnTimeout?: boolean, extraDone?: () => boolean): Promise<void>;
|
|
116
|
+
private hasLocalStart;
|
|
117
|
+
private needsSyncForStop;
|
|
118
|
+
private isStoppable;
|
|
119
|
+
private refusalBeforeStop;
|
|
105
120
|
stop(): Promise<void>;
|
|
121
|
+
private stopReady;
|
|
106
122
|
forceStop(target?: RunTarget): Promise<void>;
|
|
123
|
+
private forceStopReady;
|
|
107
124
|
/** Pending stop only affects controls of the run it was sent for. */
|
|
108
125
|
busyForCurrent(): ReadonlySet<OperationName>;
|
|
109
126
|
private stopKey;
|
|
@@ -116,6 +133,7 @@ export declare class FrontActions {
|
|
|
116
133
|
setSpeed(value: number | 'max', target?: RunTarget | null): Promise<void>;
|
|
117
134
|
runUntil(ms: number, target?: RunTarget | null): Promise<void>;
|
|
118
135
|
private time;
|
|
136
|
+
private timeReady;
|
|
119
137
|
/** Ends a waiting command: with an error, or (null) as done. A command ended twice is ended once. */
|
|
120
138
|
private settle;
|
|
121
139
|
private stillSent;
|