@huaqiu/dsh-hardware-ui 0.7.18 → 0.7.20
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/lib/client.js +9818 -626
- package/lib/client.js.map +1 -1
- package/lib/index.d.mts +35 -14
- package/lib/index.mjs +118 -10
- package/package.json +7 -3
- package/src/client/brand.ts +17 -0
- package/src/client/components.tsx +26 -133
- package/src/client/copy.ts +382 -243
- package/src/client/document/EcadBody.tsx +212 -0
- package/src/client/document/StepBody.tsx +124 -0
- package/src/client/document/contract.ts +156 -0
- package/src/client/document/copy.ts +49 -0
- package/src/client/document/index.ts +134 -0
- package/src/client/document/mount.ts +261 -0
- package/src/client/document/occt.d.ts +54 -0
- package/src/client/document/paths.ts +122 -0
- package/src/client/document/sheets.ts +83 -0
- package/src/client/document/step.ts +255 -0
- package/src/client/index.ts +172 -4
- package/src/client/locales.ts +613 -0
- package/src/client/model.ts +18 -9
- package/src/client/order-page.ts +44 -0
- package/src/client/order-tab.tsx +117 -0
- package/src/client/order-watcher.ts +121 -0
- package/src/client/order.tsx +9 -9
- package/src/client/toolchain-view.tsx +797 -0
- package/src/client/toolchain.ts +790 -0
- package/src/client/transport.ts +83 -4
- package/src/client/wizard.tsx +317 -261
- package/src/index.ts +126 -10
- package/src/shared/occt-asset.ts +21 -0
package/src/client/wizard.tsx
CHANGED
|
@@ -1,320 +1,376 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* First-run
|
|
2
|
+
* First-run toolchain onboarding, riding DSH's `settings.onboarding` seat.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* The seat, not the right panel, owns first run: a blank first session mounts
|
|
5
|
+
* exactly one ordered step, and the step draws its own modal surface because the
|
|
6
|
+
* shell paints no chrome. That is also why the step renders **nothing** until the
|
|
7
|
+
* Host has answered — a mounted-but-deciding step must show and block nothing.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
9
|
+
* The modal follows `docs/prototype/huaqiu_eda_hardware_toolchain_ux_prototype.html`
|
|
10
|
+
* line for line: header (H badge, "Welcome to HuaQiu EDA Agent" + a "First-Time
|
|
11
|
+
* Setup" pill, close button), the blue callout, one card per tool, and a footer
|
|
12
|
+
* that says where the settings live with `Skip for Now` / `Save & Get Started`.
|
|
13
|
+
*
|
|
14
|
+
* Two hard-won rules are encoded here:
|
|
15
|
+
* - **Never mark `#root` inert.** The slot renders *inside* `#root`, so inerting
|
|
16
|
+
* the root froze the whole application — including this modal — on every
|
|
17
|
+
* launch and every reload. The backdrop alone is enough to own the pointer.
|
|
18
|
+
* - **Never subscribe to a form snapshot that is rebuilt per call.** The Host
|
|
19
|
+
* form returns a fresh object from `getSnapshot()`, so feeding it straight to
|
|
20
|
+
* `useSyncExternalStore` re-rendered forever. {@link useFormValue} keeps a
|
|
21
|
+
* stable local copy instead.
|
|
22
|
+
*
|
|
23
|
+
* Gating (§4.6) is a pure function so the "must not reopen on every start"
|
|
24
|
+
* promise stays testable: deferred and completed both stop the step from
|
|
25
|
+
* returning. Skipping marks `toolchainSetup = 'deferred'`, not `'complete'` — the
|
|
26
|
+
* setup is still missing, so the sidebar dot and Settings keep saying so; it
|
|
27
|
+
* merely stops interrupting.
|
|
28
|
+
*
|
|
29
|
+
* @module @huaqiu/dsh-hardware-ui/client/wizard
|
|
16
30
|
*/
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
type CSSProperties, type ReactNode,
|
|
20
|
-
} from 'react'
|
|
21
|
-
import type { HardwareInstallationConfig, InstallationsInfo } from './model.js'
|
|
22
|
-
import type { HardwareProps } from './components.js'
|
|
31
|
+
import { createElement, useEffect, useRef, useState, useSyncExternalStore, type CSSProperties, type ReactNode } from 'react'
|
|
32
|
+
import { HUAQIU_LOGO_SRC } from './brand.js'
|
|
23
33
|
import { COPY } from './copy.js'
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
34
|
+
import type { ConfigFormLike, HardwareInstallationConfig } from './model.js'
|
|
35
|
+
import { ToolchainCard, TOOLCHAIN_ICONS } from './toolchain-view.js'
|
|
36
|
+
import {
|
|
37
|
+
jobRunning, setupComplete, type ToolchainController, type ToolchainId, type ToolchainSnapshot, type ToolchainStatus,
|
|
38
|
+
} from './toolchain.js'
|
|
39
|
+
import { buttonStyle, C, disabled, MUTED, R } from './theme.js'
|
|
26
40
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const STEP_LABEL: CSSProperties = { fontSize: 10, color: C.text3 }
|
|
45
|
-
const BRAND_MARK: CSSProperties = {
|
|
46
|
-
width: 26, height: 26, borderRadius: R.sm, display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
47
|
-
fontSize: 11, fontWeight: 700, color: '#fff', background: C.accent,
|
|
48
|
-
boxShadow: '0 4px 14px rgba(225,27,27,0.35)', flex: '0 0 auto',
|
|
49
|
-
}
|
|
50
|
-
const FIELD_CARD: CSSProperties = {
|
|
51
|
-
border: `1px solid ${C.borderSoft}`, borderRadius: R.md, background: C.base, padding: 10,
|
|
52
|
-
display: 'flex', flexDirection: 'column', gap: 6,
|
|
41
|
+
/** Step id claimed on `settings.onboarding`; also the launcher's `openOnboarding(id)`. */
|
|
42
|
+
export const TOOLCHAIN_ONBOARDING_STEP = 'hardware-engineering-toolchain'
|
|
43
|
+
|
|
44
|
+
/** Both cards, in prototype order. */
|
|
45
|
+
const TOOLCHAIN_IDS: readonly ToolchainId[] = ['kicad', 'solidcraft']
|
|
46
|
+
|
|
47
|
+
/** What the seat's registrant receives: the shell's own props plus our face. */
|
|
48
|
+
export interface OnboardingProps {
|
|
49
|
+
/** Shell: the step currently selected by the coordinator. */
|
|
50
|
+
readonly stepId?: string
|
|
51
|
+
/** Shell: reopened explicitly from the launcher (not first run). */
|
|
52
|
+
readonly explicit?: boolean
|
|
53
|
+
/** Shell: hand ownership back to the next entry. */
|
|
54
|
+
readonly complete?: () => void
|
|
55
|
+
readonly toolchain?: ToolchainController
|
|
56
|
+
/** The Host-backed config form, used to persist the skip flag. */
|
|
57
|
+
readonly configForm?: () => ConfigFormLike<HardwareInstallationConfig> | undefined
|
|
53
58
|
}
|
|
54
59
|
|
|
55
|
-
/**
|
|
56
|
-
|
|
60
|
+
/** How the step resolves for one render. */
|
|
61
|
+
export type OnboardingPhase =
|
|
62
|
+
/** No controller (a Host without the capability) — nothing may paint. */
|
|
63
|
+
| 'no-controller'
|
|
64
|
+
/** The Host has not answered yet: render null, decide nothing. */
|
|
65
|
+
| 'waiting'
|
|
66
|
+
/** Show the modal. */
|
|
67
|
+
| 'open'
|
|
68
|
+
/** Both tools already validate: complete silently, no modal. */
|
|
69
|
+
| 'configured'
|
|
70
|
+
/** Previously completed or skipped: stay away. */
|
|
71
|
+
| 'dismissed'
|
|
57
72
|
|
|
58
73
|
/**
|
|
59
|
-
*
|
|
74
|
+
* Decide whether the step may mount, without guessing.
|
|
60
75
|
*
|
|
61
|
-
* The
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* truth and this cannot outlive the tab.
|
|
76
|
+
* The regression this guards is the flash: the previous panel-mounted wizard
|
|
77
|
+
* decided on initial `loading`/`undefined` values and appeared before the status
|
|
78
|
+
* was known. Here `waiting` renders null, and only a definite "incomplete"
|
|
79
|
+
* answer yields `open`.
|
|
66
80
|
*/
|
|
67
|
-
|
|
81
|
+
export function onboardingPhase(input: {
|
|
82
|
+
readonly hasController: boolean
|
|
83
|
+
readonly status?: ToolchainStatus
|
|
84
|
+
readonly loading: boolean
|
|
85
|
+
readonly setup?: string
|
|
86
|
+
}): OnboardingPhase {
|
|
87
|
+
if (!input.hasController) return 'no-controller'
|
|
88
|
+
// `toolchainSetup` is the only record of what the first-run step was told:
|
|
89
|
+
// `complete` and `deferred` both mean "never interrupt again". The old
|
|
90
|
+
// `onboardingComplete` boolean is deliberately not honoured — this product is
|
|
91
|
+
// still in internal test, and one source of truth is worth more than the
|
|
92
|
+
// compatibility. A profile that only carries the legacy flag is treated as
|
|
93
|
+
// unanswered.
|
|
94
|
+
if (input.setup === 'complete' || input.setup === 'deferred') return 'dismissed'
|
|
95
|
+
if (input.status === undefined || input.loading) return 'waiting'
|
|
96
|
+
if (setupComplete(input.status)) return 'configured'
|
|
97
|
+
return 'open'
|
|
98
|
+
}
|
|
68
99
|
|
|
69
100
|
/**
|
|
70
|
-
*
|
|
101
|
+
* May the footer's primary button submit?
|
|
71
102
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
103
|
+
* Two gates, both asked for after the first-run walk:
|
|
104
|
+
* - **No run in flight.** While a toolchain is downloading or extracting, the
|
|
105
|
+
* step must not hand itself back: the install owns the profile, and
|
|
106
|
+
* "Get Started" would dismiss the modal out from under the bar it shows.
|
|
107
|
+
* - **Something usable.** At least one tool is already configured, or the text
|
|
108
|
+
* in an input has been verified against the Host (`checks`). A merely
|
|
109
|
+
* non-empty input is not enough: the button used to be pressed with garbage
|
|
110
|
+
* paths and then reported the Host's rejection, which is a worse first run
|
|
111
|
+
* than a disabled button that lights up the moment a path checks out.
|
|
75
112
|
*/
|
|
76
|
-
export
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
113
|
+
export function saveReady(snapshot: ToolchainSnapshot): boolean {
|
|
114
|
+
if (snapshot.saving !== undefined) return false
|
|
115
|
+
if (TOOLCHAIN_IDS.some(id => jobRunning(snapshot.jobs[id]))) return false
|
|
116
|
+
if (TOOLCHAIN_IDS.some(id => snapshot.status?.[id].state === 'configured')) return true
|
|
117
|
+
return TOOLCHAIN_IDS.some(id => snapshot.checks[id]?.state === 'valid')
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Fields of the stored configuration this step reacts to. */function sameConfig(left: HardwareInstallationConfig | undefined, right: HardwareInstallationConfig | undefined): boolean {
|
|
121
|
+
if (left === right) return true
|
|
122
|
+
if (left === undefined || right === undefined) return false
|
|
123
|
+
return left.kicadRoot === right.kicadRoot
|
|
124
|
+
&& left.solidcraftRoot === right.solidcraftRoot
|
|
125
|
+
&& left.toolchainSetup === right.toolchainSetup
|
|
126
|
+
}
|
|
89
127
|
|
|
90
128
|
/**
|
|
91
|
-
*
|
|
129
|
+
* The form's value, read through a *stable* snapshot.
|
|
92
130
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
131
|
+
* `form.getSnapshot()` allocates a new object on every call; handing that straight
|
|
132
|
+
* to `useSyncExternalStore` makes React see a changed store on every render and
|
|
133
|
+
* spin. Keeping the last value in local state, and replacing it only when a
|
|
134
|
+
* relevant field actually moved, is what makes this safe.
|
|
96
135
|
*/
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return
|
|
136
|
+
function useFormValue(form: ConfigFormLike<HardwareInstallationConfig> | undefined): HardwareInstallationConfig | undefined {
|
|
137
|
+
const [value, setValue] = useState<HardwareInstallationConfig | undefined>(() => form?.getSnapshot().value)
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (form === undefined) {
|
|
140
|
+
setValue(undefined)
|
|
141
|
+
return
|
|
142
|
+
}
|
|
143
|
+
const read = (): void => {
|
|
144
|
+
const next = form.getSnapshot().value
|
|
145
|
+
setValue(previous => (sameConfig(previous, next) ? previous : next))
|
|
146
|
+
}
|
|
147
|
+
read()
|
|
148
|
+
return form.subscribe(read)
|
|
149
|
+
}, [form])
|
|
150
|
+
return value
|
|
112
151
|
}
|
|
113
152
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const empty = useMemo<{ value?: HardwareInstallationConfig; status?: string }>(() => ({}), [])
|
|
119
|
-
const snapshot = useSyncExternalStore<{ value?: HardwareInstallationConfig; status?: string }>(
|
|
120
|
-
form === undefined ? () => () => {} : listener => form.subscribe(listener),
|
|
121
|
-
form === undefined ? () => empty : () => form.getSnapshot(),
|
|
122
|
-
form === undefined ? () => empty : () => form.getSnapshot(),
|
|
123
|
-
)
|
|
153
|
+
const BACKDROP: CSSProperties = {
|
|
154
|
+
position: 'fixed', inset: 0, zIndex: 2000, display: 'flex', alignItems: 'center',
|
|
155
|
+
justifyContent: 'center', padding: 16, background: 'rgba(0,0,0,0.75)', backdropFilter: 'blur(2px)',
|
|
156
|
+
}
|
|
124
157
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const [busy, setBusy] = useState(false)
|
|
131
|
-
/**
|
|
132
|
-
* This seat's own install probe: `undefined` while in flight, `null` when it
|
|
133
|
-
* failed (the wizard stays usable, paths can be typed). A result another seat
|
|
134
|
-
* already wrote to the store counts too, so a mounted viewer does not make the
|
|
135
|
-
* navigation row probe twice before deciding.
|
|
136
|
-
*/
|
|
137
|
-
const [probe, setProbe] = useState<InstallationsInfo | null>()
|
|
158
|
+
const HEADER: CSSProperties = {
|
|
159
|
+
display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 16,
|
|
160
|
+
padding: '20px 22px 14px', borderBottom: `1px solid ${C.borderSoft}`,
|
|
161
|
+
background: 'linear-gradient(90deg, #241B1C 0%, #1C1C1E 100%)', borderRadius: `${R.lg}px ${R.lg}px 0 0`,
|
|
162
|
+
}
|
|
138
163
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
setProbe(result)
|
|
145
|
-
actions.setInstallations(result)
|
|
146
|
-
})
|
|
147
|
-
.catch(() => { if (live) setProbe(null) })
|
|
148
|
-
return () => { live = false }
|
|
149
|
-
}, [actions, installations])
|
|
164
|
+
const CALLOUT: CSSProperties = {
|
|
165
|
+
display: 'flex', alignItems: 'flex-start', gap: 10, padding: 12, borderRadius: R.md,
|
|
166
|
+
background: 'rgba(59,130,246,0.10)', border: '1px solid rgba(59,130,246,0.22)',
|
|
167
|
+
color: '#BFDBFE', fontSize: 11, lineHeight: 1.6,
|
|
168
|
+
}
|
|
150
169
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
kicadConfigured: probe === undefined && installed === undefined
|
|
157
|
-
? undefined
|
|
158
|
-
: facts?.kicad?.configured === true,
|
|
159
|
-
dismissed: closed,
|
|
160
|
-
})
|
|
170
|
+
const FOOTER: CSSProperties = {
|
|
171
|
+
display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12, flexWrap: 'wrap',
|
|
172
|
+
padding: '14px 22px', borderTop: `1px solid ${C.borderSoft}`, background: '#161618',
|
|
173
|
+
borderRadius: `0 0 ${R.lg}px ${R.lg}px`,
|
|
174
|
+
}
|
|
161
175
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
176
|
+
/** Small line icon, same drawing rules as the cards. */
|
|
177
|
+
function Glyph(props: { readonly path: string; readonly size?: number; readonly color?: string; readonly extra?: string }): ReactNode {
|
|
178
|
+
return createElement(
|
|
179
|
+
'svg',
|
|
180
|
+
{
|
|
181
|
+
viewBox: '0 0 24 24', width: props.size ?? 14, height: props.size ?? 14, 'aria-hidden': true,
|
|
182
|
+
style: { flex: '0 0 auto', color: props.color ?? 'inherit' },
|
|
183
|
+
},
|
|
184
|
+
createElement('path', {
|
|
185
|
+
d: props.path, fill: 'none', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round',
|
|
186
|
+
}),
|
|
187
|
+
...(props.extra === undefined
|
|
188
|
+
? []
|
|
189
|
+
: [createElement('path', {
|
|
190
|
+
d: props.extra, fill: 'none', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round',
|
|
191
|
+
})]),
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Stable empty snapshot for the no-controller case (identity must not churn). */
|
|
196
|
+
const EMPTY: ToolchainSnapshot = {
|
|
197
|
+
loading: true, jobs: {}, drafts: { kicad: '', solidcraft: '' }, checks: {}, confirmed: {}, toasts: [],
|
|
198
|
+
}
|
|
199
|
+
const emptySnapshot = (): ToolchainSnapshot => EMPTY
|
|
166
200
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
201
|
+
/**
|
|
202
|
+
* The step itself.
|
|
203
|
+
*
|
|
204
|
+
* `complete()` is the shell's own hand-back; the plugin additionally records
|
|
205
|
+
* `toolchainSetup` so a later launch knows the difference between "configured"
|
|
206
|
+
* and "the user said not now".
|
|
207
|
+
*/
|
|
208
|
+
export function ToolchainOnboarding(props: OnboardingProps): ReactNode {
|
|
209
|
+
const controller = props.toolchain
|
|
210
|
+
const form = props.configForm?.()
|
|
211
|
+
const value = useFormValue(form)
|
|
212
|
+
const snapshot = useSyncExternalStore<ToolchainSnapshot>(
|
|
213
|
+
controller === undefined ? (): (() => void) => () => {} : controller.subscribe,
|
|
214
|
+
controller === undefined ? emptySnapshot : controller.getSnapshot,
|
|
215
|
+
controller === undefined ? emptySnapshot : controller.getSnapshot,
|
|
216
|
+
)
|
|
217
|
+
const autoCompleted = useRef(false)
|
|
218
|
+
const phase = onboardingPhase({
|
|
219
|
+
hasController: controller !== undefined,
|
|
220
|
+
...(snapshot.status === undefined ? {} : { status: snapshot.status }),
|
|
221
|
+
loading: snapshot.loading,
|
|
222
|
+
...(value?.toolchainSetup === undefined ? {} : { setup: value.toolchainSetup }),
|
|
223
|
+
})
|
|
170
224
|
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
dismissedInClient = true
|
|
175
|
-
setClosed(true)
|
|
176
|
-
try {
|
|
177
|
-
await form.set('onboardingComplete', true)
|
|
178
|
-
} catch {
|
|
179
|
-
// A refused host write must not trap the user in the wizard.
|
|
225
|
+
const persist = async (patch: Partial<HardwareInstallationConfig>): Promise<void> => {
|
|
226
|
+
for (const [field, entry] of Object.entries(patch)) {
|
|
227
|
+
await form?.set(field, entry)
|
|
180
228
|
}
|
|
181
229
|
}
|
|
182
230
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
// The viewer re-probes on its own; nothing here depends on the answer.
|
|
201
|
-
}
|
|
231
|
+
// §4.7: both tools configured means the step has nothing left to ask, so it
|
|
232
|
+
// completes itself the moment the Host confirms — the user never sees a
|
|
233
|
+
// redundant "Save & Get Started".
|
|
234
|
+
const complete = props.complete
|
|
235
|
+
useEffect(() => {
|
|
236
|
+
if (phase !== 'configured' || autoCompleted.current) return
|
|
237
|
+
autoCompleted.current = true
|
|
238
|
+
void persist({ toolchainSetup: 'complete' }).then(() => complete?.())
|
|
239
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
240
|
+
}, [phase])
|
|
241
|
+
|
|
242
|
+
if (phase !== 'open' || controller === undefined) return null
|
|
243
|
+
|
|
244
|
+
const skip = async (): Promise<void> => {
|
|
245
|
+
await persist({ toolchainSetup: 'deferred' })
|
|
246
|
+
controller.toast('info', COPY.toolchain.toastSkipped)
|
|
247
|
+
props.complete?.()
|
|
202
248
|
}
|
|
203
249
|
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
250
|
+
const save = async (): Promise<void> => {
|
|
251
|
+
// The footer's primary button is this step's only save affordance (the
|
|
252
|
+
// prototype has no per-card validate), so it must persist what is typed:
|
|
253
|
+
// each path is validated and written through the Host first, and a rejected
|
|
254
|
+
// path leaves the modal open with the Host's reason already toasted.
|
|
255
|
+
for (const id of TOOLCHAIN_IDS) {
|
|
256
|
+
const path = (snapshot.drafts[id] ?? '').trim()
|
|
257
|
+
if (path === '') continue
|
|
258
|
+
const outcome = await controller.save(id, path)
|
|
259
|
+
if (!outcome.ok) return
|
|
208
260
|
}
|
|
209
|
-
await
|
|
261
|
+
await persist({ toolchainSetup: 'complete' })
|
|
262
|
+
props.complete?.()
|
|
210
263
|
}
|
|
211
264
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
265
|
+
// Ready means "there is something worth saving": a typed path, or a tool that
|
|
266
|
+
// is already configured (so pressing the button simply ends the step). It is
|
|
267
|
+
// *not* "everything is configured" — SolidCraft is optional, and a disabled
|
|
268
|
+
// primary button with no other way to submit was a dead end.
|
|
269
|
+
const ready = saveReady(snapshot)
|
|
270
|
+
|
|
271
|
+
return createElement(
|
|
272
|
+
'div',
|
|
273
|
+
{
|
|
274
|
+
style: BACKDROP,
|
|
275
|
+
role: 'dialog',
|
|
276
|
+
'aria-modal': true,
|
|
277
|
+
'aria-label': COPY.toolchain.onboardingAria,
|
|
278
|
+
'data-hardware-toolchain-onboarding': true,
|
|
279
|
+
},
|
|
280
|
+
createElement(
|
|
281
|
+
'div',
|
|
282
|
+
{
|
|
283
|
+
style: {
|
|
284
|
+
display: 'flex', flexDirection: 'column', width: 672, maxWidth: '100%', maxHeight: '92vh',
|
|
285
|
+
background: '#1C1C1E', border: '1px solid rgba(255,255,255,0.15)', borderRadius: R.lg,
|
|
286
|
+
boxShadow: '0 24px 64px rgba(0,0,0,0.5)', overflow: 'hidden',
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
// Header: the HuaQiu mark (`assets/huaqiu.svg`, inlined in `brand.ts`), title,
|
|
290
|
+
// First-Time Setup pill, close.
|
|
291
|
+
createElement(
|
|
215
292
|
'div',
|
|
216
|
-
{ style:
|
|
293
|
+
{ style: HEADER },
|
|
217
294
|
createElement(
|
|
218
295
|
'div',
|
|
219
|
-
{ style: {
|
|
220
|
-
createElement('
|
|
296
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 12, minWidth: 0 } },
|
|
297
|
+
createElement('img', {
|
|
298
|
+
src: HUAQIU_LOGO_SRC,
|
|
299
|
+
alt: '',
|
|
300
|
+
'aria-hidden': true,
|
|
301
|
+
width: 40,
|
|
302
|
+
height: 40,
|
|
303
|
+
// The vendor file draws its own rounded frame; the tile adds no colour of
|
|
304
|
+
// its own so the shipped mark is what the user sees.
|
|
305
|
+
style: { width: 40, height: 40, flex: '0 0 auto', display: 'block' },
|
|
306
|
+
}),
|
|
221
307
|
createElement(
|
|
222
308
|
'div',
|
|
223
|
-
{ style: { display: 'flex', flexDirection: 'column', gap:
|
|
224
|
-
createElement(
|
|
225
|
-
|
|
309
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 3, minWidth: 0 } },
|
|
310
|
+
createElement(
|
|
311
|
+
'div',
|
|
312
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
|
|
313
|
+
createElement('h2', { style: { margin: 0, fontSize: 15, fontWeight: 600, color: C.text } }, COPY.wizard.title),
|
|
314
|
+
createElement('span', {
|
|
315
|
+
style: {
|
|
316
|
+
fontSize: 10, fontWeight: 500, letterSpacing: '0.06em', textTransform: 'uppercase',
|
|
317
|
+
padding: '2px 8px', borderRadius: 999, color: C.accent,
|
|
318
|
+
background: 'rgba(198,58,62,0.20)', border: `1px solid rgba(198,58,62,0.35)`,
|
|
319
|
+
},
|
|
320
|
+
}, COPY.wizard.badge),
|
|
321
|
+
),
|
|
322
|
+
createElement('p', { style: { ...MUTED, margin: 0, lineHeight: 1.5 } }, COPY.wizard.lead),
|
|
226
323
|
),
|
|
227
324
|
),
|
|
228
|
-
createElement('
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
createElement(
|
|
235
|
-
)
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
325
|
+
createElement('button', {
|
|
326
|
+
type: 'button',
|
|
327
|
+
title: COPY.wizard.skip,
|
|
328
|
+
'aria-label': COPY.wizard.skip,
|
|
329
|
+
onClick: () => { void skip() },
|
|
330
|
+
style: { ...buttonStyle('quiet', { padding: 6 }), flex: '0 0 auto' },
|
|
331
|
+
}, createElement(Glyph, { path: TOOLCHAIN_ICONS.close, size: 16 })),
|
|
332
|
+
),
|
|
333
|
+
|
|
334
|
+
// Body: callout + one card per tool.
|
|
335
|
+
createElement(
|
|
239
336
|
'div',
|
|
240
|
-
{ style: { display: 'flex', flexDirection: 'column', gap:
|
|
337
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 14, padding: 22, overflowY: 'auto' } },
|
|
241
338
|
createElement(
|
|
242
339
|
'div',
|
|
243
|
-
{ style:
|
|
244
|
-
createElement(
|
|
245
|
-
|
|
246
|
-
|
|
340
|
+
{ style: CALLOUT },
|
|
341
|
+
createElement(Glyph, {
|
|
342
|
+
path: TOOLCHAIN_ICONS.info, size: 16, color: '#60A5FA', extra: 'M12 3a9 9 0 1018 0 9 9 0 00-18 0z',
|
|
343
|
+
}),
|
|
344
|
+
createElement('div', { style: { minWidth: 0 } }, COPY.wizard.callout),
|
|
247
345
|
),
|
|
248
|
-
createElement(
|
|
249
|
-
createElement('
|
|
250
|
-
style: INPUT, value: kicadRoot, autoFocus: true, spellCheck: false,
|
|
251
|
-
placeholder: COPY.wizard.kicadPlaceholder,
|
|
252
|
-
onChange: event => setKicadRoot(event.currentTarget.value),
|
|
253
|
-
}),
|
|
254
|
-
createElement('p', { style: { ...MUTED, color: C.text3 } }, COPY.wizard.kicadSkipHint),
|
|
255
|
-
)
|
|
256
|
-
}
|
|
257
|
-
return createElement(
|
|
258
|
-
'div',
|
|
259
|
-
{ style: { display: 'flex', flexDirection: 'column', gap: 8 } },
|
|
260
|
-
createElement(
|
|
261
|
-
'div',
|
|
262
|
-
{ style: SPREAD },
|
|
263
|
-
createElement('h2', { style: TITLE }, COPY.wizard.solidcraftTitle),
|
|
264
|
-
createElement('span', { style: pillStyle('muted') }, COPY.wizard.kicadOptional),
|
|
346
|
+
createElement(ToolchainCard, { tool: 'kicad', controller, snapshot, variant: 'wizard' }),
|
|
347
|
+
createElement(ToolchainCard, { tool: 'solidcraft', controller, snapshot, variant: 'wizard' }),
|
|
265
348
|
),
|
|
266
|
-
createElement('p', { style: LEAD }, COPY.wizard.solidcraftLead),
|
|
267
|
-
createElement('input', {
|
|
268
|
-
style: INPUT, value: solidcraftRoot, autoFocus: true, spellCheck: false,
|
|
269
|
-
placeholder: COPY.wizard.solidcraftPlaceholder,
|
|
270
|
-
onChange: event => setSolidcraftRoot(event.currentTarget.value),
|
|
271
|
-
}),
|
|
272
|
-
)
|
|
273
|
-
}
|
|
274
349
|
|
|
275
|
-
|
|
276
|
-
'div',
|
|
277
|
-
{ style: BACKDROP, role: 'dialog', 'aria-modal': true, 'aria-label': COPY.wizard.aria, 'data-hardware-wizard': true },
|
|
278
|
-
createElement(
|
|
279
|
-
'div',
|
|
280
|
-
{ style: PANEL },
|
|
350
|
+
// Footer: where the settings live, then Skip / Save & Get Started.
|
|
281
351
|
createElement(
|
|
282
352
|
'div',
|
|
283
|
-
{ style:
|
|
353
|
+
{ style: FOOTER },
|
|
284
354
|
createElement(
|
|
285
355
|
'div',
|
|
286
|
-
{ style: {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
style: { ...dotStyle(index === step ? C.accent : index < step ? C.ok : C.text3, 6) },
|
|
290
|
-
title: label,
|
|
291
|
-
})),
|
|
292
|
-
createElement('span', { style: { ...STEP_LABEL, ...MONO_TEXT } }, COPY.wizard.stepCounter(step + 1, STEPS.length, STEPS[step] ?? '')),
|
|
356
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 8, ...MUTED, minWidth: 0 } },
|
|
357
|
+
createElement(Glyph, { path: TOOLCHAIN_ICONS.gear, color: C.text3 }),
|
|
358
|
+
createElement('span', { style: { minWidth: 0 } }, COPY.wizard.footer),
|
|
293
359
|
),
|
|
294
|
-
createElement('button', {
|
|
295
|
-
type: 'button', style: buttonStyle('quiet', { fontSize: 10.5 }),
|
|
296
|
-
onClick: () => { void complete() },
|
|
297
|
-
}, COPY.wizard.skip),
|
|
298
|
-
),
|
|
299
|
-
stepBody(),
|
|
300
|
-
...(message === '' ? [] : [createElement('p', { key: 'msg', style: { ...MUTED, color: C.text2 }, role: 'status' }, message)]),
|
|
301
|
-
createElement(
|
|
302
|
-
'div',
|
|
303
|
-
{ style: { ...SPREAD, paddingTop: 6, borderTop: `1px solid ${C.borderSoft}` } },
|
|
304
|
-
createElement('span', { style: { ...MUTED, color: C.text3, fontSize: 10 } }, COPY.wizard.footerNote),
|
|
305
360
|
createElement(
|
|
306
|
-
'
|
|
307
|
-
{ style:
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
: null,
|
|
361
|
+
'div',
|
|
362
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 10, flex: '0 0 auto' } },
|
|
363
|
+
createElement('button', {
|
|
364
|
+
type: 'button',
|
|
365
|
+
style: buttonStyle('quiet'),
|
|
366
|
+
onClick: () => { void skip() },
|
|
367
|
+
}, COPY.wizard.skip),
|
|
314
368
|
createElement('button', {
|
|
315
|
-
type: 'button',
|
|
316
|
-
|
|
317
|
-
|
|
369
|
+
type: 'button',
|
|
370
|
+
style: { ...buttonStyle('primary', { padding: '8px 16px', fontSize: 12, fontWeight: 600 }), ...disabled(!ready) },
|
|
371
|
+
disabled: !ready,
|
|
372
|
+
onClick: () => { void save() },
|
|
373
|
+
}, COPY.wizard.save),
|
|
318
374
|
),
|
|
319
375
|
),
|
|
320
376
|
),
|