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

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/package.json CHANGED
@@ -1,20 +1,38 @@
1
1
  {
2
2
  "name": "@vehicle-sil/gui-client",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-rc.1",
4
4
  "description": "Client library of the vehicle-sil GUI server: connection, run and time control, ECU variables. No dependencies; browser and Node.",
5
5
  "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/rahanahu/vehicle-sil.git",
9
+ "directory": "gui/client"
10
+ },
6
11
  "type": "module",
7
12
  "exports": {
8
13
  ".": {
9
14
  "types": "./types/index.d.ts",
10
15
  "default": "./dist/index.js"
16
+ },
17
+ "./elements": {
18
+ "types": "./types/elements/index.d.ts",
19
+ "default": "./dist/elements.js"
20
+ },
21
+ "./timeline": {
22
+ "types": "./timeline/vehicle-sil-timeline.d.ts",
23
+ "default": "./timeline/vehicle-sil-timeline.mjs"
11
24
  }
12
25
  },
13
26
  "types": "./types/index.d.ts",
14
- "sideEffects": false,
27
+ "sideEffects": [
28
+ "./dist/elements.js",
29
+ "./timeline/vehicle-sil-timeline.js",
30
+ "./timeline/vehicle-sil-timeline.mjs"
31
+ ],
15
32
  "files": [
16
33
  "dist",
17
34
  "types",
35
+ "timeline",
18
36
  "README.ja.md"
19
37
  ],
20
38
  "engines": {
@@ -0,0 +1,108 @@
1
+ // Types of vehicle-sil-timeline.js: the custom element <vehicle-sil-timeline>, which draws a timeline file of
2
+ // vehicle-sil. Importing the file defines the element (it exports nothing):
3
+ //
4
+ // import '@vehicle-sil/gui-client/timeline'; // the npm package of the client library
5
+ // const timeline = document.createElement('vehicle-sil-timeline');
6
+ //
7
+ // docs/gui.md ("Putting a timeline on your own screen") says what each attribute, property and event does.
8
+
9
+ /** Words of the element that a page adds or changes: { <language>: { <key of messages.js>: text } }. */
10
+ export type VehicleSilTimelineMessages = Record<
11
+ string,
12
+ Record<string, string | ((args: Record<string, unknown>) => string)>
13
+ >;
14
+
15
+ /** The parts of the element that `hide` can leave out. */
16
+ export type VehicleSilTimelinePart =
17
+ 'header' | 'summary' | 'toolbar' | 'help' | 'steps' | 'readout' | 'legend' | 'tables';
18
+
19
+ export interface VehicleSilTimelineLoadDetail {
20
+ /** The file's name (file-name, or the name the server gives), or null. */
21
+ file: string | null;
22
+ /** The scenario's name, or null. */
23
+ scenario: string | null;
24
+ /** The scenario's result as the file writes it: 'passed', 'failed', 'incomplete', 'not_run' or another. */
25
+ status: string;
26
+ /** The whole run that can be shown, in virtual ms. */
27
+ start: number;
28
+ end: number;
29
+ }
30
+
31
+ export interface VehicleSilTimelineErrorDetail {
32
+ /** Why the file cannot be shown, and what to do (in the element's language). */
33
+ message: string;
34
+ /** The HTTP status when src was answered with an error, else null. */
35
+ status: number | null;
36
+ }
37
+
38
+ export interface VehicleSilTimelineEventMap {
39
+ load: CustomEvent<VehicleSilTimelineLoadDetail>;
40
+ error: CustomEvent<VehicleSilTimelineErrorDetail>;
41
+ cursorchange: CustomEvent<{ cursor: number | null }>;
42
+ stepselect: CustomEvent<{ step: number | null }>;
43
+ viewchange: CustomEvent<{ from: number; to: number }>;
44
+ }
45
+
46
+ export interface VehicleSilTimelineElement extends HTMLElement {
47
+ /** The address of a timeline file on the page's own server (attribute src). */
48
+ src: string;
49
+ /** The name shown for the file (attribute file-name). */
50
+ fileName: string;
51
+ /** The file itself: its text or its parsed JSON. Shown instead of src while it is not null. */
52
+ data: string | object | null;
53
+ /** The token sent with src (Authorization: Bearer). Default: the one the GUI's screens keep in the tab. */
54
+ token: string | null;
55
+ /** More headers sent with src. */
56
+ headers: Record<string, string> | null;
57
+ /** The cursor, in virtual ms (attribute cursor), or null. */
58
+ cursor: number | null;
59
+ /** The chosen step, by its index (attribute step), or null. */
60
+ step: number | null;
61
+ /** The part of the run shown, in virtual ms (attributes from and to). */
62
+ from: number | null;
63
+ to: number | null;
64
+ /** The variables to draw, in this order: names, or prefixes ending in '*' (attribute variables). */
65
+ variables: string[] | null;
66
+ /** A label for a variable, by its name, shown in its lane. */
67
+ labels: Record<string, string> | null;
68
+ /** The parts to leave out: words of VehicleSilTimelinePart separated by spaces (attribute hide). */
69
+ hide: string;
70
+ /** Smaller lanes for a small box (attribute compact). */
71
+ compact: boolean;
72
+ /**
73
+ * 'light', 'dark', or 'auto': the color-scheme of the page around the element (light where the page declares
74
+ * none; attribute theme).
75
+ */
76
+ theme: 'light' | 'dark' | 'auto';
77
+ /** Words that the page adds or changes; a language here can be named in lang. */
78
+ messages: VehicleSilTimelineMessages | null;
79
+ /** Loads src again. */
80
+ reload(): void;
81
+
82
+ addEventListener<K extends keyof VehicleSilTimelineEventMap>(
83
+ type: K,
84
+ listener: (this: VehicleSilTimelineElement, ev: VehicleSilTimelineEventMap[K]) => unknown,
85
+ options?: boolean | AddEventListenerOptions,
86
+ ): void;
87
+ addEventListener(
88
+ type: string,
89
+ listener: EventListenerOrEventListenerObject,
90
+ options?: boolean | AddEventListenerOptions,
91
+ ): void;
92
+ removeEventListener<K extends keyof VehicleSilTimelineEventMap>(
93
+ type: K,
94
+ listener: (this: VehicleSilTimelineElement, ev: VehicleSilTimelineEventMap[K]) => unknown,
95
+ options?: boolean | EventListenerOptions,
96
+ ): void;
97
+ removeEventListener(
98
+ type: string,
99
+ listener: EventListenerOrEventListenerObject,
100
+ options?: boolean | EventListenerOptions,
101
+ ): void;
102
+ }
103
+
104
+ declare global {
105
+ interface HTMLElementTagNameMap {
106
+ 'vehicle-sil-timeline': VehicleSilTimelineElement;
107
+ }
108
+ }