@deltarobotics/uhd-viewer 0.0.0-stage → 0.2.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/CHANGELOG.md +74 -0
- package/LICENSE +202 -0
- package/NOTICE +22 -0
- package/README.md +168 -2
- package/bin/serve.d.mts +62 -0
- package/bin/serve.mjs +257 -0
- package/bin/uhd-viewer.mjs +75 -0
- package/dist/app/assets/KodeMono-Bold-DdIivhPN.woff2 +0 -0
- package/dist/app/assets/KodeMono-Medium-CVnTuv5A.ttf +0 -0
- package/dist/app/assets/KodeMono-Regular-Bdr_-rJX.woff2 +0 -0
- package/dist/app/assets/KodeMono-SemiBold-JAfn5Dpm.ttf +0 -0
- package/dist/app/assets/index-CEJyT8hF.css +2 -0
- package/dist/app/assets/index-DWZ-48wc.js +3853 -0
- package/dist/app/index.html +16 -0
- package/dist/components/components.css +6372 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +26609 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/types/uhd-viewer/src/api.d.ts +286 -0
- package/dist/components/types/uhd-viewer/src/cad/CadView.d.ts +52 -0
- package/dist/components/types/uhd-viewer/src/cad/ModelView.d.ts +30 -0
- package/dist/components/types/uhd-viewer/src/cad/explode.d.ts +110 -0
- package/dist/components/types/uhd-viewer/src/cad/explodeSample.d.ts +25 -0
- package/dist/components/types/uhd-viewer/src/cad/findings.d.ts +41 -0
- package/dist/components/types/uhd-viewer/src/cad/labels.d.ts +76 -0
- package/dist/components/types/uhd-viewer/src/cad/model.d.ts +132 -0
- package/dist/components/types/uhd-viewer/src/cad/row.d.ts +15 -0
- package/dist/components/types/uhd-viewer/src/cad/scene.d.ts +95 -0
- package/dist/components/types/uhd-viewer/src/cad/scope.d.ts +89 -0
- package/dist/components/types/uhd-viewer/src/canvas/Canvas.d.ts +90 -0
- package/dist/components/types/uhd-viewer/src/canvas/Icon.d.ts +5 -0
- package/dist/components/types/uhd-viewer/src/canvas/LinkEdge.d.ts +40 -0
- package/dist/components/types/uhd-viewer/src/canvas/Port.d.ts +18 -0
- package/dist/components/types/uhd-viewer/src/canvas/actions.d.ts +5 -0
- package/dist/components/types/uhd-viewer/src/canvas/geometry.d.ts +72 -0
- package/dist/components/types/uhd-viewer/src/canvas/interaction.d.ts +162 -0
- package/dist/components/types/uhd-viewer/src/canvas/nodes.d.ts +43 -0
- package/dist/components/types/uhd-viewer/src/canvas/reveal.d.ts +55 -0
- package/dist/components/types/uhd-viewer/src/canvas/rightDrag.d.ts +51 -0
- package/dist/components/types/uhd-viewer/src/canvas/routing.d.ts +28 -0
- package/dist/components/types/uhd-viewer/src/chrome/ArtifactCards.d.ts +30 -0
- package/dist/components/types/uhd-viewer/src/chrome/Artifacts.d.ts +44 -0
- package/dist/components/types/uhd-viewer/src/chrome/BoardInspector.d.ts +53 -0
- package/dist/components/types/uhd-viewer/src/chrome/Chrome.d.ts +126 -0
- package/dist/components/types/uhd-viewer/src/chrome/Evidence.d.ts +20 -0
- package/dist/components/types/uhd-viewer/src/chrome/InterfaceCards.d.ts +66 -0
- package/dist/components/types/uhd-viewer/src/chrome/PairView.d.ts +37 -0
- package/dist/components/types/uhd-viewer/src/chrome/Sections.d.ts +128 -0
- package/dist/components/types/uhd-viewer/src/components.d.ts +60 -0
- package/dist/components/types/uhd-viewer/src/host/channel.d.ts +49 -0
- package/dist/components/types/uhd-viewer/src/host/context.d.ts +29 -0
- package/dist/components/types/uhd-viewer/src/host/protocol.d.ts +22 -0
- package/dist/components/types/uhd-viewer/src/host/targets.d.ts +101 -0
- package/dist/components/types/uhd-viewer/src/layout/board-layout.d.ts +69 -0
- package/dist/components/types/uhd-viewer/src/layout/card-body.d.ts +64 -0
- package/dist/components/types/uhd-viewer/src/layout/layout.d.ts +94 -0
- package/dist/components/types/uhd-viewer/src/layout/module-layout.d.ts +32 -0
- package/dist/components/types/uhd-viewer/src/layout/router.d.ts +55 -0
- package/dist/components/types/uhd-viewer/src/layout/taps.d.ts +20 -0
- package/dist/components/types/uhd-viewer/src/model/artifacts.d.ts +129 -0
- package/dist/components/types/uhd-viewer/src/model/classification.d.ts +41 -0
- package/dist/components/types/uhd-viewer/src/model/diagnostics.d.ts +27 -0
- package/dist/components/types/uhd-viewer/src/model/evidence.d.ts +63 -0
- package/dist/components/types/uhd-viewer/src/model/from-uhd.d.ts +58 -0
- package/dist/components/types/uhd-viewer/src/model/hierarchy.d.ts +173 -0
- package/dist/components/types/uhd-viewer/src/model/isolate.d.ts +33 -0
- package/dist/components/types/uhd-viewer/src/model/level.d.ts +7 -0
- package/dist/components/types/uhd-viewer/src/model/nets.d.ts +53 -0
- package/dist/components/types/uhd-viewer/src/model/outputs.d.ts +79 -0
- package/dist/components/types/uhd-viewer/src/model/slots.d.ts +184 -0
- package/dist/components/types/uhd-viewer/src/model/types.d.ts +213 -0
- package/dist/components/types/uhd-viewer/src/options.d.ts +27 -0
- package/dist/components/types/uhd-viewer/src/source/source.d.ts +109 -0
- package/dist/components/types/uhd-viewer/src/source/tolerant.d.ts +45 -0
- package/dist/components/types/uhd-viewer/src/theme/ThemeProvider.d.ts +33 -0
- package/dist/components/types/uhd-viewer/src/theme/adapters.d.ts +28 -0
- package/dist/components/types/uhd-viewer/src/theme/resolve.d.ts +19 -0
- package/dist/components/types/uhd-viewer/src/theme/themes.d.ts +67 -0
- package/dist/components/types/uhd-viewer/src/theme/tokens.d.ts +175 -0
- package/dist/components/types/uhd-viewer/src/ui/Inspector.d.ts +45 -0
- package/dist/components/types/uhd-viewer/src/ui/Legend.d.ts +59 -0
- package/dist/components/types/uhd-viewer/src/ui/ScrollArea.d.ts +16 -0
- package/dist/components/types/uhd-viewer/src/ui/Toolbar.d.ts +49 -0
- package/dist/components/types/uhd-viewer/src/ui/Tooltips.d.ts +3 -0
- package/dist/components/types/uhd-viewer/src/ui/cx.d.ts +2 -0
- package/dist/components/types/uhd-viewer/src/ui/legendFit.d.ts +55 -0
- package/dist/components/types/uhd-viewer/src/viewer/controller.d.ts +219 -0
- package/dist/components/types/uhd-viewer/src/viewer/details.d.ts +81 -0
- package/dist/components/types/uhd-viewer/src/viewer/hierarchy.d.ts +82 -0
- package/dist/components/types/uhd-viewer/src/viewer/mount.d.ts +12 -0
- package/dist/components/types/uhd-viewer/src/viewer/views.d.ts +187 -0
- package/dist/headless/index.d.ts +71 -0
- package/dist/headless/index.js +7425 -0
- package/dist/headless/index.js.map +1 -0
- package/dist/lib/api.d.ts +252 -0
- package/dist/lib/uhd-viewer.css +3 -0
- package/dist/lib/uhd-viewer.d.ts +4 -0
- package/dist/lib/uhd-viewer.js +97787 -0
- package/package.json +110 -4
- package/src/styles/fonts/OFL.txt +93 -0
- package/src/styles/tailwind-theme.css +48 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neutral view contract (PB-784). The canvas renders only these types; the
|
|
3
|
+
* UHD adapter (./from-uhd.ts) produces them from a system ModuleDef.
|
|
4
|
+
* Every id is a canonical path so layout and selection survive model edits.
|
|
5
|
+
*/
|
|
6
|
+
export type LinkState = "configured" | "partial" | "incompatible" | "unconfigured";
|
|
7
|
+
export type NodeKind = "module" | "group" | "harness" | "board" | "net";
|
|
8
|
+
export type Shape = "rect" | "circle" | "pill";
|
|
9
|
+
/** A child interface revealed when a link is opened (a slot and the leaf bound to it). */
|
|
10
|
+
export interface ViewChildPort {
|
|
11
|
+
slotId: string;
|
|
12
|
+
name: string;
|
|
13
|
+
/** Leaf interface id on the module, e.g. "gnss_uart_tx". */
|
|
14
|
+
leafId?: string;
|
|
15
|
+
/** Pad or pin label, e.g. "TX". */
|
|
16
|
+
pin?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ViewPort {
|
|
19
|
+
/** Interface id on its module (or export id on a group/module boundary). */
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
domain: string;
|
|
23
|
+
/** Primary protocol type, used for signal-type classification and grouping. */
|
|
24
|
+
protocol: string;
|
|
25
|
+
roles: string[];
|
|
26
|
+
children: ViewChildPort[];
|
|
27
|
+
/** True when the port is a boundary export of a child interface. */
|
|
28
|
+
exported?: {
|
|
29
|
+
child: string;
|
|
30
|
+
interfaceId: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface ViewNode {
|
|
34
|
+
/** Canonical path, e.g. "stack/esc" or "arm_fl". */
|
|
35
|
+
id: string;
|
|
36
|
+
label: string;
|
|
37
|
+
icon: string;
|
|
38
|
+
kind: NodeKind;
|
|
39
|
+
/** Parent node path when drawn inside an expanded module or group. */
|
|
40
|
+
parent?: string;
|
|
41
|
+
/** True when the node has children and is drawn expanded in place. */
|
|
42
|
+
expanded?: boolean;
|
|
43
|
+
ports: ViewPort[];
|
|
44
|
+
shape: Shape;
|
|
45
|
+
status: LinkState;
|
|
46
|
+
/** UHD definition id, for the inspector. */
|
|
47
|
+
defId?: string;
|
|
48
|
+
manufacturer?: string;
|
|
49
|
+
partNumber?: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
category?: string;
|
|
52
|
+
childCount: number;
|
|
53
|
+
/** A boundary port of the drilled-into module, drawn at the canvas edge. */
|
|
54
|
+
sheetPort?: boolean;
|
|
55
|
+
/** A board net (PB-823): drawn as a junction its members' grouped membership links meet at. */
|
|
56
|
+
net?: ViewNet;
|
|
57
|
+
/**
|
|
58
|
+
* A rail drawn in several places (PB-873): this junction is a local tap of the
|
|
59
|
+
* net junction with this id, joined to the members near it. Selecting a tap
|
|
60
|
+
* selects the net.
|
|
61
|
+
*/
|
|
62
|
+
tapOf?: string;
|
|
63
|
+
/** The bundle does not hold this module's definition: a placeholder with the interfaces its links name. */
|
|
64
|
+
missing?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/** A net on a board (UHD `Net` interface, exposed: false), as a junction node. */
|
|
67
|
+
export interface ViewNet {
|
|
68
|
+
/** Net interface id on the board, e.g. "v3v3". */
|
|
69
|
+
id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
/** What the net carries, for the signal classification: "power", "ground", "i2c", "digital"… */
|
|
72
|
+
signal: string;
|
|
73
|
+
/** Design voltage as stated on the net ("3.3 V", "2.5–5.5 V"). */
|
|
74
|
+
voltage?: string;
|
|
75
|
+
/** A ground net: drawn as ground symbols at its members unless GND wires are on. */
|
|
76
|
+
ground: boolean;
|
|
77
|
+
/** Pins on the net. */
|
|
78
|
+
pins: number;
|
|
79
|
+
}
|
|
80
|
+
export interface ViewEndpoint {
|
|
81
|
+
node: string;
|
|
82
|
+
port: string;
|
|
83
|
+
}
|
|
84
|
+
export interface ViewChildLink {
|
|
85
|
+
id: string;
|
|
86
|
+
label: string;
|
|
87
|
+
a: string;
|
|
88
|
+
b: string;
|
|
89
|
+
aPin?: string;
|
|
90
|
+
bPin?: string;
|
|
91
|
+
state: LinkState;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* One lane of an expanded link (PB-803/805): a child interface of the link,
|
|
95
|
+
* or a link derived through a cable. A lane with its own children is itself a
|
|
96
|
+
* bundle and can be opened in place.
|
|
97
|
+
*/
|
|
98
|
+
export interface ViewLane {
|
|
99
|
+
id: string;
|
|
100
|
+
name: string;
|
|
101
|
+
domain: string;
|
|
102
|
+
protocol: string;
|
|
103
|
+
state: LinkState;
|
|
104
|
+
children: ViewLane[];
|
|
105
|
+
/** Conductor ids this lane carries (ribbon mode groups them under the lane). */
|
|
106
|
+
conductors?: string[];
|
|
107
|
+
}
|
|
108
|
+
/** One physical conductor of a link, for ribbon (detailed) mode. */
|
|
109
|
+
export interface ViewConductor {
|
|
110
|
+
id: string;
|
|
111
|
+
label: string;
|
|
112
|
+
/** Signal protocol of the conductor, for its colour ("power", "ground", "uart", …). */
|
|
113
|
+
protocol: string;
|
|
114
|
+
domain: string;
|
|
115
|
+
/** DRC state of the connection this conductor carries. */
|
|
116
|
+
state: LinkState;
|
|
117
|
+
}
|
|
118
|
+
/** The harness a link runs through, drawn as a region along its route. */
|
|
119
|
+
export interface ViewHarnessRun {
|
|
120
|
+
/** Harness child path at this level. */
|
|
121
|
+
id: string;
|
|
122
|
+
/** Its UHD definition id (for the inspector: artifacts, thumbnail, CAD). */
|
|
123
|
+
defId: string;
|
|
124
|
+
name: string;
|
|
125
|
+
icon: string;
|
|
126
|
+
/** Carried by a physical cable (connector ends) rather than named on a logical link. */
|
|
127
|
+
physical: boolean;
|
|
128
|
+
/** Only the first link of a harness carries its name tab. */
|
|
129
|
+
tab: boolean;
|
|
130
|
+
}
|
|
131
|
+
export interface ViewLink {
|
|
132
|
+
id: string;
|
|
133
|
+
source: ViewEndpoint;
|
|
134
|
+
target: ViewEndpoint;
|
|
135
|
+
name: string;
|
|
136
|
+
domain: string;
|
|
137
|
+
protocol: string;
|
|
138
|
+
state: LinkState;
|
|
139
|
+
children: ViewChildLink[];
|
|
140
|
+
/** Pass-through from a boundary export to the child interface it exposes. */
|
|
141
|
+
passThrough?: boolean;
|
|
142
|
+
/** Ground return: drawn as ground symbols at both ports instead of a wire. */
|
|
143
|
+
ground?: boolean;
|
|
144
|
+
/** Harness node carrying the link, if any. */
|
|
145
|
+
harness?: string;
|
|
146
|
+
/**
|
|
147
|
+
* A link carried by a harness is drawn as two segments through the harness
|
|
148
|
+
* node: "a" (source → harness, carries the label) and "b" (harness → target).
|
|
149
|
+
*/
|
|
150
|
+
segment?: "a" | "b";
|
|
151
|
+
/** Stored link id (shared by both segments). */
|
|
152
|
+
linkId: string;
|
|
153
|
+
/** Other stored link ids drawn by this link (the second half of a cable). */
|
|
154
|
+
alsoIds?: string[];
|
|
155
|
+
/** Lanes shown when the link is expanded (basic mode). */
|
|
156
|
+
lanes?: ViewLane[];
|
|
157
|
+
/** Conductors shown in ribbon (detailed) mode. */
|
|
158
|
+
conductors?: ViewConductor[];
|
|
159
|
+
/** Harness region along the route. */
|
|
160
|
+
run?: ViewHarnessRun;
|
|
161
|
+
/** Child links are a stored override (remapped by the user). */
|
|
162
|
+
manual?: boolean;
|
|
163
|
+
/** Grouped net membership (PB-823): one line from a component to a net, its pins as children. */
|
|
164
|
+
net?: {
|
|
165
|
+
id: string;
|
|
166
|
+
name: string;
|
|
167
|
+
};
|
|
168
|
+
diagnostics: string[];
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* A functional link UHD derives over a board's nets (an I2C bus, a supply to
|
|
172
|
+
* a load). It is not drawn as a line of its own: the membership lines it runs
|
|
173
|
+
* over (`via`) carry its state, and the inspector lists it by name.
|
|
174
|
+
*/
|
|
175
|
+
export interface ViewDerived {
|
|
176
|
+
/** Derived link id (long: the membership links it runs over), prefixed like stored link ids. */
|
|
177
|
+
id: string;
|
|
178
|
+
/** Its name, "I2C0 ↔ I2C": what the viewer shows instead of the id. */
|
|
179
|
+
name: string;
|
|
180
|
+
protocol: string;
|
|
181
|
+
state: LinkState;
|
|
182
|
+
a: {
|
|
183
|
+
node: string;
|
|
184
|
+
iface: string;
|
|
185
|
+
};
|
|
186
|
+
b: {
|
|
187
|
+
node: string;
|
|
188
|
+
iface: string;
|
|
189
|
+
};
|
|
190
|
+
/** Net node ids it runs over. */
|
|
191
|
+
nets: string[];
|
|
192
|
+
/** View link ids (grouped memberships) it runs over. */
|
|
193
|
+
via: string[];
|
|
194
|
+
/** Conductors: each slot (or pin) and the one it is wired to. */
|
|
195
|
+
children: {
|
|
196
|
+
a: string;
|
|
197
|
+
aPin?: string;
|
|
198
|
+
b: string;
|
|
199
|
+
bPin?: string;
|
|
200
|
+
}[];
|
|
201
|
+
diagnostics: string[];
|
|
202
|
+
}
|
|
203
|
+
export interface ViewModel {
|
|
204
|
+
/** Breadcrumb labels for the level being viewed. */
|
|
205
|
+
path: {
|
|
206
|
+
id: string;
|
|
207
|
+
label: string;
|
|
208
|
+
}[];
|
|
209
|
+
nodes: ViewNode[];
|
|
210
|
+
links: ViewLink[];
|
|
211
|
+
/** Functional links derived over the level's nets (and nets of modules expanded in place). */
|
|
212
|
+
derived: ViewDerived[];
|
|
213
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a host's option changes apply (ViewerHandle.update). Kept apart from
|
|
3
|
+
* mount.tsx so it can be tested without a page.
|
|
4
|
+
*/
|
|
5
|
+
import type { ViewerLayout, ViewerOptions, ViewerViewport } from "./api";
|
|
6
|
+
/**
|
|
7
|
+
* The options after `update(change)`: the change is merged into the current
|
|
8
|
+
* options. A change that names `bundleUrl` and not `bundle` switches to
|
|
9
|
+
* loading from that URL (a given `bundle` would otherwise keep precedence).
|
|
10
|
+
*/
|
|
11
|
+
export declare function mergeOptions<T extends ViewerOptions>(current: T, change: Partial<ViewerOptions>): T;
|
|
12
|
+
/** The same layout edits (a host passing back what the viewer sent is not a change). */
|
|
13
|
+
export declare function sameLayout(a: ViewerLayout | undefined, b: ViewerLayout | undefined): boolean;
|
|
14
|
+
/** The same saved viewports, whatever order their levels come in (a host passing back what the viewer sent is not a change). */
|
|
15
|
+
export declare function sameViewports(a: Record<string, ViewerViewport> | undefined, b: Record<string, ViewerViewport> | undefined): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* What a host's `viewports` option asks of a mounted viewer (PB-1037):
|
|
18
|
+
* `replace` when the viewer must take them (the host passed viewports it was
|
|
19
|
+
* not sent, or it took over keeping them, or gave that up), `keep` otherwise.
|
|
20
|
+
* `known` is what the host has: what it passed last or what it was last sent.
|
|
21
|
+
*/
|
|
22
|
+
export declare function hostViewportsChange(o: {
|
|
23
|
+
hosted: boolean;
|
|
24
|
+
wasHosted: boolean;
|
|
25
|
+
host: Record<string, ViewerViewport> | undefined;
|
|
26
|
+
known: Record<string, ViewerViewport> | undefined;
|
|
27
|
+
}): "replace" | "keep";
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type UhdBundle, type UhdBundleDiagnostic } from "@deltarobotics/uhd";
|
|
2
|
+
import type { ModuleDef } from "@deltarobotics/uhd";
|
|
3
|
+
import type { ModuleLookup } from "@deltarobotics/uhd";
|
|
4
|
+
import type { LevelLayout } from "../layout/layout";
|
|
5
|
+
import type { ArtifactResolver, ViewerOptions } from "../api";
|
|
6
|
+
import { type LeftOut, type MissingDefinition } from "./tolerant";
|
|
7
|
+
export interface ViewerScenario {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
description: string;
|
|
11
|
+
system: ModuleDef;
|
|
12
|
+
lookup: ModuleLookup;
|
|
13
|
+
/** Definitions the bundle names and does not hold: drawn as placeholders (source/tolerant.ts). */
|
|
14
|
+
missing: MissingDefinition[];
|
|
15
|
+
/** Links and exports that could not be resolved, and are not drawn. */
|
|
16
|
+
leftOut: LeftOut[];
|
|
17
|
+
}
|
|
18
|
+
/** Surface appearance for a definition (and optionally named sub-bodies of its CAD). */
|
|
19
|
+
export interface Appearance {
|
|
20
|
+
color?: string;
|
|
21
|
+
metalness?: number;
|
|
22
|
+
roughness?: number;
|
|
23
|
+
opacity?: number;
|
|
24
|
+
parts?: Record<string, Omit<Appearance, "parts">>;
|
|
25
|
+
}
|
|
26
|
+
export interface LabelHint {
|
|
27
|
+
title?: string;
|
|
28
|
+
sub?: string;
|
|
29
|
+
hide?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Presentation hints keyed by instance path. Never topology. */
|
|
32
|
+
export interface DisplayConfig {
|
|
33
|
+
diagram?: {
|
|
34
|
+
/** Hand layouts per drill level ("" = top). */
|
|
35
|
+
layouts?: Record<string, LevelLayout>;
|
|
36
|
+
/** Instance paths drawn expanded in place by default. */
|
|
37
|
+
expanded?: string[];
|
|
38
|
+
/** Links opened (conductors shown) by default. */
|
|
39
|
+
openLinks?: string[];
|
|
40
|
+
};
|
|
41
|
+
spatial?: {
|
|
42
|
+
/** Instance path the assembly is placed from (default: the best-connected structure). */
|
|
43
|
+
root?: string;
|
|
44
|
+
/** Explicit placements for modules no mate reaches (row-major 4×4, root coordinates). */
|
|
45
|
+
placements?: Record<string, {
|
|
46
|
+
matrix: number[];
|
|
47
|
+
note?: string;
|
|
48
|
+
}>;
|
|
49
|
+
labels?: {
|
|
50
|
+
modules?: Record<string, LabelHint>;
|
|
51
|
+
/** Fastener harnesses and routed wire harnesses, by instance path. */
|
|
52
|
+
harnesses?: Record<string, LabelHint>;
|
|
53
|
+
};
|
|
54
|
+
/** By definition id. */
|
|
55
|
+
appearance?: Record<string, Appearance>;
|
|
56
|
+
/** How the 3D view opens (PB-873). */
|
|
57
|
+
view?: SpatialView;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The 3D view's opening camera, in the root's coordinates. Presentation only:
|
|
62
|
+
* a watch modelled display-down (its case's frame has the display at −z)
|
|
63
|
+
* says `up: [0, 0, -1]` and opens display-up, without changing the model.
|
|
64
|
+
*/
|
|
65
|
+
export interface SpatialView {
|
|
66
|
+
/** The direction drawn up (default [0, 0, 1]): the camera's up, the orbit axis and the ground grid follow it. */
|
|
67
|
+
up?: [number, number, number];
|
|
68
|
+
/** A saved camera: azimuth and elevation (degrees, about `up`), distance (mm) and target. Without a distance the model is fitted. */
|
|
69
|
+
camera?: {
|
|
70
|
+
azimuth?: number;
|
|
71
|
+
elevation?: number;
|
|
72
|
+
distance?: number;
|
|
73
|
+
target?: [number, number, number];
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export interface LoadedSource {
|
|
77
|
+
name: string;
|
|
78
|
+
bundleUrl: string;
|
|
79
|
+
scenarios: ViewerScenario[];
|
|
80
|
+
/** URL for a definition's artifact file path, or undefined if it cannot be resolved. */
|
|
81
|
+
resolveArtifact: ArtifactResolver;
|
|
82
|
+
/** Findings from the bundle's producer (e.g. Protoboard's aggregated check). */
|
|
83
|
+
hostDiagnostics: UhdBundleDiagnostic[];
|
|
84
|
+
display: DisplayConfig;
|
|
85
|
+
/** The bundle as loaded (for host views that read more of it than the viewer draws). */
|
|
86
|
+
bundle: UhdBundle;
|
|
87
|
+
}
|
|
88
|
+
export interface SourceOptions {
|
|
89
|
+
/** Development only: absolute filesystem bases are served through Vite's /@fs route. */
|
|
90
|
+
fsRoute?: boolean;
|
|
91
|
+
/** A host's resolver; it receives the default one as `fallback`. */
|
|
92
|
+
resolveArtifact?: ViewerOptions["resolveArtifact"];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The bundle URL for the standalone app: `?bundle=<url>`, then the URL a
|
|
96
|
+
* server injected into the page, then the development default (none in a
|
|
97
|
+
* production build).
|
|
98
|
+
*/
|
|
99
|
+
export declare function pickBundleUrl(search: string, injected?: string | null, fallback?: string | null): string | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* URL prefix for an artifact base (`UhdBundle.artifactBases`: an absolute
|
|
102
|
+
* path or a URL prefix), or undefined when it cannot be fetched over HTTP.
|
|
103
|
+
* Absolute filesystem paths only resolve in development, through /@fs.
|
|
104
|
+
*/
|
|
105
|
+
export declare function baseToUrl(base: string, options?: Pick<SourceOptions, "fsRoute">): string | undefined;
|
|
106
|
+
/** The default resolver: a definition's artifact base, or the bundle's own location. */
|
|
107
|
+
export declare function bundleResolver(bundle: UhdBundle, bundleUrl: string, options?: Pick<SourceOptions, "fsRoute">): ArtifactResolver;
|
|
108
|
+
export declare function loadBundle(url: string, options?: SourceOptions): Promise<LoadedSource>;
|
|
109
|
+
export declare function sourceFromBundle(bundle: UhdBundle, url: string, options?: SourceOptions): LoadedSource;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A bundle that does not hold everything it names still draws.
|
|
3
|
+
*
|
|
4
|
+
* UHD's resolvers throw on a child whose definition is not in the bundle, and
|
|
5
|
+
* on a link or an export that names an interface nobody has. A producer that
|
|
6
|
+
* could not fetch some definitions (a library that was unreachable) writes
|
|
7
|
+
* exactly such a bundle, and the viewer drew nothing at all for it.
|
|
8
|
+
*
|
|
9
|
+
* `tolerantSystem` gives the viewer a system the resolvers accept: a missing
|
|
10
|
+
* definition is stood in for by a placeholder that has the interfaces its
|
|
11
|
+
* parents' links and exports name, and a link or an export that still cannot
|
|
12
|
+
* be resolved is left out. What was stood in for and what was left out is
|
|
13
|
+
* returned, so the views can say so.
|
|
14
|
+
*/
|
|
15
|
+
import type { ModuleDef } from "@deltarobotics/uhd";
|
|
16
|
+
import { type ModuleLookup } from "@deltarobotics/uhd";
|
|
17
|
+
/** A definition the bundle names and does not hold. */
|
|
18
|
+
export interface MissingDefinition {
|
|
19
|
+
/** The definition id the children name. */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Where it is used: the parent definition and the child's id and label there. */
|
|
22
|
+
usedBy: {
|
|
23
|
+
parent: string;
|
|
24
|
+
child: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
/** A link or an export left out because it could not be resolved. */
|
|
29
|
+
export interface LeftOut {
|
|
30
|
+
kind: "link" | "export";
|
|
31
|
+
/** The definition it was on. */
|
|
32
|
+
on: string;
|
|
33
|
+
id: string;
|
|
34
|
+
/** The resolver's message. */
|
|
35
|
+
why: string;
|
|
36
|
+
}
|
|
37
|
+
export interface TolerantSystem {
|
|
38
|
+
root: ModuleDef;
|
|
39
|
+
lookup: ModuleLookup;
|
|
40
|
+
missing: MissingDefinition[];
|
|
41
|
+
leftOut: LeftOut[];
|
|
42
|
+
}
|
|
43
|
+
/** Whether a definition is a placeholder for one the bundle does not hold. */
|
|
44
|
+
export declare function isPlaceholder(def: ModuleDef | undefined): boolean;
|
|
45
|
+
export declare function tolerantSystem(root: ModuleDef, lookup: ModuleLookup): TolerantSystem;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Puts a theme on the viewer's root element and tells the components that
|
|
3
|
+
* draw outside CSS (the 3D scene) when it changes. Everything rendered inside
|
|
4
|
+
* reads the tokens as CSS variables; popovers portal into the same root so
|
|
5
|
+
* they keep them.
|
|
6
|
+
*/
|
|
7
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
8
|
+
import { type Theme, type ThemeToken } from "./tokens";
|
|
9
|
+
import { type ThemeAdapter } from "./adapters";
|
|
10
|
+
export interface ThemeState {
|
|
11
|
+
theme: Theme;
|
|
12
|
+
/** The themed element: tooltips and menus portal here so they keep the tokens. */
|
|
13
|
+
root: HTMLElement | null;
|
|
14
|
+
}
|
|
15
|
+
/** The current theme and the themed root element. */
|
|
16
|
+
export declare const useTheme: () => ThemeState;
|
|
17
|
+
export interface ThemeProviderProps {
|
|
18
|
+
/** Where the theme comes from (default: the viewer's own, following the system). */
|
|
19
|
+
adapter?: ThemeAdapter;
|
|
20
|
+
/** Or one theme (wins over `adapter`). */
|
|
21
|
+
theme?: Theme;
|
|
22
|
+
className?: string;
|
|
23
|
+
style?: CSSProperties;
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
/** The themed root: a full-size element carrying the tokens. */
|
|
27
|
+
export declare function ThemeProvider({ adapter, theme: fixed, className, style, children }: ThemeProviderProps): import("react").JSX.Element;
|
|
28
|
+
/**
|
|
29
|
+
* A token's colour as `#rrggbb` (alpha dropped), resolved on `element`:
|
|
30
|
+
* for canvases that cannot read CSS variables or modern colour syntax
|
|
31
|
+
* (`oklch()`, `color-mix()`), like the 3D scene's background and grid.
|
|
32
|
+
*/
|
|
33
|
+
export declare function tokenColor(element: Element | null, name: ThemeToken, fallback?: string): string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Theme, type ThemeScheme } from "./tokens";
|
|
2
|
+
export interface ThemeAdapter {
|
|
3
|
+
id: string;
|
|
4
|
+
/** The theme to show now. */
|
|
5
|
+
current(): Theme;
|
|
6
|
+
/** Calls `onChange` whenever the theme changes; returns the unsubscribe. Absent: the theme never changes. */
|
|
7
|
+
subscribe?(onChange: (theme: Theme) => void): () => void;
|
|
8
|
+
}
|
|
9
|
+
/** One fixed theme. */
|
|
10
|
+
export declare const staticTheme: (theme: Theme) => ThemeAdapter;
|
|
11
|
+
/** Several adapters' worth of themes, picked by id (a host's theme switcher). */
|
|
12
|
+
export declare function pickTheme(themes: readonly Theme[], id: string | null | undefined, fallback: Theme): Theme;
|
|
13
|
+
/** The viewer's own themes: dark, light, or the system's preference (default). */
|
|
14
|
+
export declare function defaultThemeAdapter(scheme?: "dark" | "light" | "system", win?: Window | undefined): ThemeAdapter;
|
|
15
|
+
/** The scheme of a VS Code webview, from the class VS Code puts on its body. */
|
|
16
|
+
export declare function vscodeScheme(body: {
|
|
17
|
+
classList: {
|
|
18
|
+
contains(c: string): boolean;
|
|
19
|
+
};
|
|
20
|
+
} | undefined): ThemeScheme;
|
|
21
|
+
/** The VS Code tokens for one scheme. */
|
|
22
|
+
export declare function vscodeTheme(scheme: ThemeScheme): Theme;
|
|
23
|
+
/**
|
|
24
|
+
* Follows the VS Code colour theme of the webview the viewer runs in: the
|
|
25
|
+
* tokens refer to VS Code's variables, so a colour change inside a scheme
|
|
26
|
+
* needs nothing; a change of scheme (VS Code swaps its body class) re-themes.
|
|
27
|
+
*/
|
|
28
|
+
export declare function vscodeThemeAdapter(doc?: Document | undefined): ThemeAdapter;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** A host's `theme` option (api.ts) as a theme adapter. */
|
|
2
|
+
import type { ViewerThemeOption } from "../api";
|
|
3
|
+
import { type ThemeAdapter } from "./adapters";
|
|
4
|
+
import { type Theme } from "./tokens";
|
|
5
|
+
/** A theme given with some tokens: the rest from the default of its scheme. */
|
|
6
|
+
export declare function completeTheme(theme: {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
scheme: Theme["scheme"];
|
|
10
|
+
tokens: Partial<Record<string, string>>;
|
|
11
|
+
}): Theme;
|
|
12
|
+
/**
|
|
13
|
+
* - absent or `"dark"` / `"light"`: the viewer's own dark (as it has always
|
|
14
|
+
* looked) or light theme; `"system"`: whichever the system prefers;
|
|
15
|
+
* - `"vscode"`: the VS Code adapter (in a VS Code webview);
|
|
16
|
+
* - a theme object: that theme (missing tokens from the default);
|
|
17
|
+
* - an adapter (`{ current, subscribe? }`): the host's own.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveTheme(option: ViewerThemeOption | undefined): ThemeAdapter;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The viewer's own themes: neutral dark and light. They carry no brand; a
|
|
3
|
+
* host's brand theme starts from one of these (`defineTheme`) and changes the
|
|
4
|
+
* accent, surfaces or faces it needs.
|
|
5
|
+
*/
|
|
6
|
+
import { type Theme } from "./tokens";
|
|
7
|
+
/** DRC health and finding severity read the same in every theme (owner decision, PB-894 §5). */
|
|
8
|
+
export declare const DRC_TOKENS: {
|
|
9
|
+
drcConfigured: string;
|
|
10
|
+
drcPartial: string;
|
|
11
|
+
drcIncompatible: string;
|
|
12
|
+
drcUnconfigured: string;
|
|
13
|
+
severityError: string;
|
|
14
|
+
severityWarning: string;
|
|
15
|
+
severityInfo: string;
|
|
16
|
+
severityOk: string;
|
|
17
|
+
};
|
|
18
|
+
/** Domain and signal colours on dark surfaces. */
|
|
19
|
+
export declare const DARK_DATA_TOKENS: {
|
|
20
|
+
domainElectrical: string;
|
|
21
|
+
domainMechanical: string;
|
|
22
|
+
domainPneumatic: string;
|
|
23
|
+
domainHydraulic: string;
|
|
24
|
+
domainThermal: string;
|
|
25
|
+
domainNetwork: string;
|
|
26
|
+
domainSoftware: string;
|
|
27
|
+
domainOther: string;
|
|
28
|
+
signalPower: string;
|
|
29
|
+
signalGround: string;
|
|
30
|
+
signalDigital: string;
|
|
31
|
+
signalAnalog: string;
|
|
32
|
+
signalI2c: string;
|
|
33
|
+
signalSpi: string;
|
|
34
|
+
signalUart: string;
|
|
35
|
+
signalCan: string;
|
|
36
|
+
signalPwm: string;
|
|
37
|
+
signalPhase: string;
|
|
38
|
+
signalRf: string;
|
|
39
|
+
signalOther: string;
|
|
40
|
+
};
|
|
41
|
+
/** The same on light surfaces: one step darker, so thin lines keep their contrast. */
|
|
42
|
+
export declare const LIGHT_DATA_TOKENS: {
|
|
43
|
+
domainElectrical: string;
|
|
44
|
+
domainMechanical: string;
|
|
45
|
+
domainPneumatic: string;
|
|
46
|
+
domainHydraulic: string;
|
|
47
|
+
domainThermal: string;
|
|
48
|
+
domainNetwork: string;
|
|
49
|
+
domainSoftware: string;
|
|
50
|
+
domainOther: string;
|
|
51
|
+
signalPower: string;
|
|
52
|
+
signalGround: string;
|
|
53
|
+
signalDigital: string;
|
|
54
|
+
signalAnalog: string;
|
|
55
|
+
signalI2c: string;
|
|
56
|
+
signalSpi: string;
|
|
57
|
+
signalUart: string;
|
|
58
|
+
signalCan: string;
|
|
59
|
+
signalPwm: string;
|
|
60
|
+
signalPhase: string;
|
|
61
|
+
signalRf: string;
|
|
62
|
+
signalOther: string;
|
|
63
|
+
};
|
|
64
|
+
export declare const defaultDark: Theme;
|
|
65
|
+
export declare const defaultLight: Theme;
|
|
66
|
+
/** The theme a scheme falls back to. */
|
|
67
|
+
export declare const defaultTheme: (scheme?: "dark" | "light") => Theme;
|