@huaqiu/dsh-hardware-ui 0.7.18 → 0.7.19
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 +9583 -627
- 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 +372 -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 +604 -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 +724 -0
- package/src/client/toolchain.ts +620 -0
- package/src/client/transport.ts +83 -4
- package/src/client/wizard.tsx +312 -261
- package/src/index.ts +126 -10
- package/src/shared/occt-asset.ts +21 -0
package/src/client/wizard.tsx
CHANGED
|
@@ -1,320 +1,371 @@
|
|
|
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
|
+
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
|
+
* The prototype's wizard card carries no per-card validate control, so this
|
|
104
|
+
* button is the step's *only* way to persist a typed path. Gating it on "both
|
|
105
|
+
* tools already configured" made a clean first launch a dead end: nothing could
|
|
106
|
+
* be configured because the button that configures was disabled. Readiness is
|
|
107
|
+
* therefore "there is something to save".
|
|
75
108
|
*/
|
|
76
|
-
export
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
109
|
+
export function saveReady(snapshot: ToolchainSnapshot): boolean {
|
|
110
|
+
if (snapshot.saving !== undefined) return false
|
|
111
|
+
if (TOOLCHAIN_IDS.some(id => (snapshot.drafts[id] ?? '').trim() !== '')) return true
|
|
112
|
+
return snapshot.status === undefined
|
|
113
|
+
? false
|
|
114
|
+
: TOOLCHAIN_IDS.some(id => snapshot.status![id].state === 'configured')
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Fields of the stored configuration this step reacts to. */function sameConfig(left: HardwareInstallationConfig | undefined, right: HardwareInstallationConfig | undefined): boolean {
|
|
118
|
+
if (left === right) return true
|
|
119
|
+
if (left === undefined || right === undefined) return false
|
|
120
|
+
return left.kicadRoot === right.kicadRoot
|
|
121
|
+
&& left.solidcraftRoot === right.solidcraftRoot
|
|
122
|
+
&& left.toolchainSetup === right.toolchainSetup
|
|
123
|
+
}
|
|
89
124
|
|
|
90
125
|
/**
|
|
91
|
-
*
|
|
126
|
+
* The form's value, read through a *stable* snapshot.
|
|
92
127
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
128
|
+
* `form.getSnapshot()` allocates a new object on every call; handing that straight
|
|
129
|
+
* to `useSyncExternalStore` makes React see a changed store on every render and
|
|
130
|
+
* spin. Keeping the last value in local state, and replacing it only when a
|
|
131
|
+
* relevant field actually moved, is what makes this safe.
|
|
96
132
|
*/
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return
|
|
133
|
+
function useFormValue(form: ConfigFormLike<HardwareInstallationConfig> | undefined): HardwareInstallationConfig | undefined {
|
|
134
|
+
const [value, setValue] = useState<HardwareInstallationConfig | undefined>(() => form?.getSnapshot().value)
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (form === undefined) {
|
|
137
|
+
setValue(undefined)
|
|
138
|
+
return
|
|
139
|
+
}
|
|
140
|
+
const read = (): void => {
|
|
141
|
+
const next = form.getSnapshot().value
|
|
142
|
+
setValue(previous => (sameConfig(previous, next) ? previous : next))
|
|
143
|
+
}
|
|
144
|
+
read()
|
|
145
|
+
return form.subscribe(read)
|
|
146
|
+
}, [form])
|
|
147
|
+
return value
|
|
112
148
|
}
|
|
113
149
|
|
|
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
|
-
)
|
|
150
|
+
const BACKDROP: CSSProperties = {
|
|
151
|
+
position: 'fixed', inset: 0, zIndex: 2000, display: 'flex', alignItems: 'center',
|
|
152
|
+
justifyContent: 'center', padding: 16, background: 'rgba(0,0,0,0.75)', backdropFilter: 'blur(2px)',
|
|
153
|
+
}
|
|
124
154
|
|
|
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>()
|
|
155
|
+
const HEADER: CSSProperties = {
|
|
156
|
+
display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 16,
|
|
157
|
+
padding: '20px 22px 14px', borderBottom: `1px solid ${C.borderSoft}`,
|
|
158
|
+
background: 'linear-gradient(90deg, #241B1C 0%, #1C1C1E 100%)', borderRadius: `${R.lg}px ${R.lg}px 0 0`,
|
|
159
|
+
}
|
|
138
160
|
|
|
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])
|
|
161
|
+
const CALLOUT: CSSProperties = {
|
|
162
|
+
display: 'flex', alignItems: 'flex-start', gap: 10, padding: 12, borderRadius: R.md,
|
|
163
|
+
background: 'rgba(59,130,246,0.10)', border: '1px solid rgba(59,130,246,0.22)',
|
|
164
|
+
color: '#BFDBFE', fontSize: 11, lineHeight: 1.6,
|
|
165
|
+
}
|
|
150
166
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
kicadConfigured: probe === undefined && installed === undefined
|
|
157
|
-
? undefined
|
|
158
|
-
: facts?.kicad?.configured === true,
|
|
159
|
-
dismissed: closed,
|
|
160
|
-
})
|
|
167
|
+
const FOOTER: CSSProperties = {
|
|
168
|
+
display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12, flexWrap: 'wrap',
|
|
169
|
+
padding: '14px 22px', borderTop: `1px solid ${C.borderSoft}`, background: '#161618',
|
|
170
|
+
borderRadius: `0 0 ${R.lg}px ${R.lg}px`,
|
|
171
|
+
}
|
|
161
172
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
173
|
+
/** Small line icon, same drawing rules as the cards. */
|
|
174
|
+
function Glyph(props: { readonly path: string; readonly size?: number; readonly color?: string; readonly extra?: string }): ReactNode {
|
|
175
|
+
return createElement(
|
|
176
|
+
'svg',
|
|
177
|
+
{
|
|
178
|
+
viewBox: '0 0 24 24', width: props.size ?? 14, height: props.size ?? 14, 'aria-hidden': true,
|
|
179
|
+
style: { flex: '0 0 auto', color: props.color ?? 'inherit' },
|
|
180
|
+
},
|
|
181
|
+
createElement('path', {
|
|
182
|
+
d: props.path, fill: 'none', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round',
|
|
183
|
+
}),
|
|
184
|
+
...(props.extra === undefined
|
|
185
|
+
? []
|
|
186
|
+
: [createElement('path', {
|
|
187
|
+
d: props.extra, fill: 'none', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round',
|
|
188
|
+
})]),
|
|
189
|
+
)
|
|
190
|
+
}
|
|
166
191
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
192
|
+
/** Stable empty snapshot for the no-controller case (identity must not churn). */
|
|
193
|
+
const EMPTY: ToolchainSnapshot = { loading: true, jobs: {}, drafts: { kicad: '', solidcraft: '' }, toasts: [] }
|
|
194
|
+
const emptySnapshot = (): ToolchainSnapshot => EMPTY
|
|
170
195
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
196
|
+
/**
|
|
197
|
+
* The step itself.
|
|
198
|
+
*
|
|
199
|
+
* `complete()` is the shell's own hand-back; the plugin additionally records
|
|
200
|
+
* `toolchainSetup` so a later launch knows the difference between "configured"
|
|
201
|
+
* and "the user said not now".
|
|
202
|
+
*/
|
|
203
|
+
export function ToolchainOnboarding(props: OnboardingProps): ReactNode {
|
|
204
|
+
const controller = props.toolchain
|
|
205
|
+
const form = props.configForm?.()
|
|
206
|
+
const value = useFormValue(form)
|
|
207
|
+
const snapshot = useSyncExternalStore<ToolchainSnapshot>(
|
|
208
|
+
controller === undefined ? (): (() => void) => () => {} : controller.subscribe,
|
|
209
|
+
controller === undefined ? emptySnapshot : controller.getSnapshot,
|
|
210
|
+
controller === undefined ? emptySnapshot : controller.getSnapshot,
|
|
211
|
+
)
|
|
212
|
+
const autoCompleted = useRef(false)
|
|
213
|
+
const phase = onboardingPhase({
|
|
214
|
+
hasController: controller !== undefined,
|
|
215
|
+
...(snapshot.status === undefined ? {} : { status: snapshot.status }),
|
|
216
|
+
loading: snapshot.loading,
|
|
217
|
+
...(value?.toolchainSetup === undefined ? {} : { setup: value.toolchainSetup }),
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
const persist = async (patch: Partial<HardwareInstallationConfig>): Promise<void> => {
|
|
221
|
+
for (const [field, entry] of Object.entries(patch)) {
|
|
222
|
+
await form?.set(field, entry)
|
|
180
223
|
}
|
|
181
224
|
}
|
|
182
225
|
|
|
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
|
-
}
|
|
226
|
+
// §4.7: both tools configured means the step has nothing left to ask, so it
|
|
227
|
+
// completes itself the moment the Host confirms — the user never sees a
|
|
228
|
+
// redundant "Save & Get Started".
|
|
229
|
+
const complete = props.complete
|
|
230
|
+
useEffect(() => {
|
|
231
|
+
if (phase !== 'configured' || autoCompleted.current) return
|
|
232
|
+
autoCompleted.current = true
|
|
233
|
+
void persist({ toolchainSetup: 'complete' }).then(() => complete?.())
|
|
234
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
235
|
+
}, [phase])
|
|
236
|
+
|
|
237
|
+
if (phase !== 'open' || controller === undefined) return null
|
|
238
|
+
|
|
239
|
+
const skip = async (): Promise<void> => {
|
|
240
|
+
await persist({ toolchainSetup: 'deferred' })
|
|
241
|
+
controller.toast('info', COPY.toolchain.toastSkipped)
|
|
242
|
+
props.complete?.()
|
|
202
243
|
}
|
|
203
244
|
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
245
|
+
const save = async (): Promise<void> => {
|
|
246
|
+
// The footer's primary button is this step's only save affordance (the
|
|
247
|
+
// prototype has no per-card validate), so it must persist what is typed:
|
|
248
|
+
// each path is validated and written through the Host first, and a rejected
|
|
249
|
+
// path leaves the modal open with the Host's reason already toasted.
|
|
250
|
+
for (const id of TOOLCHAIN_IDS) {
|
|
251
|
+
const path = (snapshot.drafts[id] ?? '').trim()
|
|
252
|
+
if (path === '') continue
|
|
253
|
+
const outcome = await controller.save(id, path)
|
|
254
|
+
if (!outcome.ok) return
|
|
208
255
|
}
|
|
209
|
-
await
|
|
256
|
+
await persist({ toolchainSetup: 'complete' })
|
|
257
|
+
props.complete?.()
|
|
210
258
|
}
|
|
211
259
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
260
|
+
// Ready means "there is something worth saving": a typed path, or a tool that
|
|
261
|
+
// is already configured (so pressing the button simply ends the step). It is
|
|
262
|
+
// *not* "everything is configured" — SolidCraft is optional, and a disabled
|
|
263
|
+
// primary button with no other way to submit was a dead end.
|
|
264
|
+
const ready = saveReady(snapshot)
|
|
265
|
+
|
|
266
|
+
return createElement(
|
|
267
|
+
'div',
|
|
268
|
+
{
|
|
269
|
+
style: BACKDROP,
|
|
270
|
+
role: 'dialog',
|
|
271
|
+
'aria-modal': true,
|
|
272
|
+
'aria-label': COPY.toolchain.onboardingAria,
|
|
273
|
+
'data-hardware-toolchain-onboarding': true,
|
|
274
|
+
},
|
|
275
|
+
createElement(
|
|
276
|
+
'div',
|
|
277
|
+
{
|
|
278
|
+
style: {
|
|
279
|
+
display: 'flex', flexDirection: 'column', width: 672, maxWidth: '100%', maxHeight: '92vh',
|
|
280
|
+
background: '#1C1C1E', border: '1px solid rgba(255,255,255,0.15)', borderRadius: R.lg,
|
|
281
|
+
boxShadow: '0 24px 64px rgba(0,0,0,0.5)', overflow: 'hidden',
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
// Header: the HuaQiu mark (`assets/huaqiu.svg`, inlined in `brand.ts`), title,
|
|
285
|
+
// First-Time Setup pill, close.
|
|
286
|
+
createElement(
|
|
215
287
|
'div',
|
|
216
|
-
{ style:
|
|
288
|
+
{ style: HEADER },
|
|
217
289
|
createElement(
|
|
218
290
|
'div',
|
|
219
|
-
{ style: {
|
|
220
|
-
createElement('
|
|
291
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 12, minWidth: 0 } },
|
|
292
|
+
createElement('img', {
|
|
293
|
+
src: HUAQIU_LOGO_SRC,
|
|
294
|
+
alt: '',
|
|
295
|
+
'aria-hidden': true,
|
|
296
|
+
width: 40,
|
|
297
|
+
height: 40,
|
|
298
|
+
// The vendor file draws its own rounded frame; the tile adds no colour of
|
|
299
|
+
// its own so the shipped mark is what the user sees.
|
|
300
|
+
style: { width: 40, height: 40, flex: '0 0 auto', display: 'block' },
|
|
301
|
+
}),
|
|
221
302
|
createElement(
|
|
222
303
|
'div',
|
|
223
|
-
{ style: { display: 'flex', flexDirection: 'column', gap:
|
|
224
|
-
createElement(
|
|
225
|
-
|
|
304
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 3, minWidth: 0 } },
|
|
305
|
+
createElement(
|
|
306
|
+
'div',
|
|
307
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
|
|
308
|
+
createElement('h2', { style: { margin: 0, fontSize: 15, fontWeight: 600, color: C.text } }, COPY.wizard.title),
|
|
309
|
+
createElement('span', {
|
|
310
|
+
style: {
|
|
311
|
+
fontSize: 10, fontWeight: 500, letterSpacing: '0.06em', textTransform: 'uppercase',
|
|
312
|
+
padding: '2px 8px', borderRadius: 999, color: C.accent,
|
|
313
|
+
background: 'rgba(198,58,62,0.20)', border: `1px solid rgba(198,58,62,0.35)`,
|
|
314
|
+
},
|
|
315
|
+
}, COPY.wizard.badge),
|
|
316
|
+
),
|
|
317
|
+
createElement('p', { style: { ...MUTED, margin: 0, lineHeight: 1.5 } }, COPY.wizard.lead),
|
|
226
318
|
),
|
|
227
319
|
),
|
|
228
|
-
createElement('
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
createElement(
|
|
235
|
-
)
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
320
|
+
createElement('button', {
|
|
321
|
+
type: 'button',
|
|
322
|
+
title: COPY.wizard.skip,
|
|
323
|
+
'aria-label': COPY.wizard.skip,
|
|
324
|
+
onClick: () => { void skip() },
|
|
325
|
+
style: { ...buttonStyle('quiet', { padding: 6 }), flex: '0 0 auto' },
|
|
326
|
+
}, createElement(Glyph, { path: TOOLCHAIN_ICONS.close, size: 16 })),
|
|
327
|
+
),
|
|
328
|
+
|
|
329
|
+
// Body: callout + one card per tool.
|
|
330
|
+
createElement(
|
|
239
331
|
'div',
|
|
240
|
-
{ style: { display: 'flex', flexDirection: 'column', gap:
|
|
332
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 14, padding: 22, overflowY: 'auto' } },
|
|
241
333
|
createElement(
|
|
242
334
|
'div',
|
|
243
|
-
{ style:
|
|
244
|
-
createElement(
|
|
245
|
-
|
|
246
|
-
|
|
335
|
+
{ style: CALLOUT },
|
|
336
|
+
createElement(Glyph, {
|
|
337
|
+
path: TOOLCHAIN_ICONS.info, size: 16, color: '#60A5FA', extra: 'M12 3a9 9 0 1018 0 9 9 0 00-18 0z',
|
|
338
|
+
}),
|
|
339
|
+
createElement('div', { style: { minWidth: 0 } }, COPY.wizard.callout),
|
|
247
340
|
),
|
|
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),
|
|
341
|
+
createElement(ToolchainCard, { tool: 'kicad', controller, snapshot, variant: 'wizard' }),
|
|
342
|
+
createElement(ToolchainCard, { tool: 'solidcraft', controller, snapshot, variant: 'wizard' }),
|
|
265
343
|
),
|
|
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
344
|
|
|
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 },
|
|
345
|
+
// Footer: where the settings live, then Skip / Save & Get Started.
|
|
281
346
|
createElement(
|
|
282
347
|
'div',
|
|
283
|
-
{ style:
|
|
348
|
+
{ style: FOOTER },
|
|
284
349
|
createElement(
|
|
285
350
|
'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] ?? '')),
|
|
351
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 8, ...MUTED, minWidth: 0 } },
|
|
352
|
+
createElement(Glyph, { path: TOOLCHAIN_ICONS.gear, color: C.text3 }),
|
|
353
|
+
createElement('span', { style: { minWidth: 0 } }, COPY.wizard.footer),
|
|
293
354
|
),
|
|
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
355
|
createElement(
|
|
306
|
-
'
|
|
307
|
-
{ style:
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
: null,
|
|
356
|
+
'div',
|
|
357
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 10, flex: '0 0 auto' } },
|
|
358
|
+
createElement('button', {
|
|
359
|
+
type: 'button',
|
|
360
|
+
style: buttonStyle('quiet'),
|
|
361
|
+
onClick: () => { void skip() },
|
|
362
|
+
}, COPY.wizard.skip),
|
|
314
363
|
createElement('button', {
|
|
315
|
-
type: 'button',
|
|
316
|
-
|
|
317
|
-
|
|
364
|
+
type: 'button',
|
|
365
|
+
style: { ...buttonStyle('primary', { padding: '8px 16px', fontSize: 12, fontWeight: 600 }), ...disabled(!ready) },
|
|
366
|
+
disabled: !ready,
|
|
367
|
+
onClick: () => { void save() },
|
|
368
|
+
}, COPY.wizard.save),
|
|
318
369
|
),
|
|
319
370
|
),
|
|
320
371
|
),
|