@huaqiu/dsh-hardware-ui 0.7.17 → 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 +9612 -632
- package/lib/client.js.map +1 -1
- package/lib/index.d.mts +35 -14
- package/lib/index.mjs +118 -10
- package/package.json +8 -4
- 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/copy.ts
CHANGED
|
@@ -1,86 +1,117 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* User-visible copy for the Hardware Engineering UI, backed by DSH's locale
|
|
3
|
+
* service.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* The dictionaries live in {@link ./locales.ts} in the same zh-source/en-checked
|
|
6
|
+
* shape as `@huaqiu/dsh-huaqiu-about` and the other bilingual plugins. `apply`
|
|
7
|
+
* registers them as namespace {@link HARDWARE_UI_NS} and binds a translator;
|
|
8
|
+
* this module keeps the structured call-site API (nested groups, interpolation
|
|
9
|
+
* as functions, string arrays) so nothing that renders needs to change when a
|
|
10
|
+
* language switches. DSH dictionaries are flat `{name}` templates, so the
|
|
11
|
+
* lookup and interpolation happen here, at read time.
|
|
11
12
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* required — and the untyped single-locale arm leaves an en-active host falling
|
|
18
|
-
* back to the raw key (`FALLBACK_LOCALE = 'en'`, and a namespace registered only
|
|
19
|
-
* for `zh` is not in `en`'s chain). The sibling packages hit the same wall and
|
|
20
|
-
* self-contained for the same reason (`dsh-auth/src/client/i18n.ts`,
|
|
21
|
-
* `dsh-tool-plugin-update/src/client/copy.ts`).
|
|
13
|
+
* Reads are deliberately getters/functions, never captured constants: DSH's
|
|
14
|
+
* renderer re-renders every slot outlet on a locale change, and `bind()` reads
|
|
15
|
+
* the active locale at call time. Before a locale service is bound (unit tests,
|
|
16
|
+
* a Host without one), the context-independent zh dictionary is used — the
|
|
17
|
+
* behaviour this module had when it shipped zh-only.
|
|
22
18
|
*
|
|
23
|
-
*
|
|
24
|
-
* rendered from up to three seats (navigation row, viewer body, settings
|
|
25
|
-
* section), and a literal that drifts between them reads as two different
|
|
26
|
-
* products. One dictionary also makes "is this text translated?" a mechanical
|
|
27
|
-
* question — grep for a Chinese character outside this file and the answer is
|
|
28
|
-
* no.
|
|
29
|
-
*
|
|
30
|
-
* Adding a language later is mechanical: turn `COPY` into `{ zh, en }` with
|
|
31
|
-
* `en: Record<CopyKeys, string>` (the `dsh-auth` shape, so a missing key is a
|
|
32
|
-
* COMPILE error), pick by `<html lang>`, and — if the second language is real —
|
|
33
|
-
* move the dictionary into `ctx.locale.register` and declare `locale:` on the
|
|
34
|
-
* slots to get the framework's reactive `t` seat instead. Nothing that renders
|
|
35
|
-
* would move, because every render site already reads through this module.
|
|
36
|
-
*
|
|
37
|
-
* Wording rules that hold across the file:
|
|
19
|
+
* Wording rules that hold across both languages:
|
|
38
20
|
* - Commands, file names, extension names, and host paths are NOT translated
|
|
39
|
-
* (`kicad-cli`, `.kicad_pcb`, `Settings → Hardware Engineering`
|
|
40
|
-
* 「设置 → 硬件工程」 only because the host section label is translated too).
|
|
21
|
+
* (`kicad-cli`, `.kicad_pcb`, `Settings → Hardware Engineering`).
|
|
41
22
|
* - Host-origin text is never re-spelled here: {@link describeHostError} maps
|
|
42
|
-
* a stable host `code` to a sentence and appends the host detail where
|
|
43
|
-
* is technical output (kicad-cli stderr) rather than prose.
|
|
44
|
-
* - Interpolation is a function, not `{placeholder}`
|
|
45
|
-
* cannot be rendered with its placeholders unfilled by accident.
|
|
23
|
+
* a stable host `code` to a sentence and appends the host detail only where
|
|
24
|
+
* it is technical output (kicad-cli stderr) rather than prose.
|
|
25
|
+
* - Interpolation is a function, not a `{placeholder}` at the call site: a
|
|
26
|
+
* function cannot be rendered with its placeholders unfilled by accident.
|
|
27
|
+
*
|
|
28
|
+
* Adding a language is mechanical: add its dictionary to `locales.ts` (checked
|
|
29
|
+
* against the `zh` key union) and pass it to `locale.register` in `index.ts`.
|
|
30
|
+
* No render site moves.
|
|
46
31
|
*
|
|
47
|
-
* @module
|
|
32
|
+
* @module @huaqiu/dsh-hardware-ui/client/copy
|
|
48
33
|
*/
|
|
49
34
|
|
|
50
|
-
|
|
35
|
+
import { en, zh, type HardwareCopyKey } from './locales.js'
|
|
36
|
+
|
|
37
|
+
/** DSH locale namespace owned by this plugin. */
|
|
38
|
+
export const HARDWARE_UI_NS = 'hardware-ui.huaqiu'
|
|
39
|
+
|
|
40
|
+
/** Fallback dictionary locale, used only until DSH's locale service is bound. */
|
|
51
41
|
export const LOCALE = 'zh_CN' as const
|
|
52
42
|
|
|
43
|
+
export type TranslateCopy = (key: HardwareCopyKey, params?: Record<string, unknown>) => string
|
|
44
|
+
|
|
45
|
+
/** The slice of DSH's client locale service this module needs. */
|
|
46
|
+
export interface CopyLocale {
|
|
47
|
+
register(namespace: string, dictionaries: { readonly zh: typeof zh; readonly en: typeof en }): unknown
|
|
48
|
+
bind(namespace: string): (key: string, params?: Record<string, unknown>) => string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function interpolate(template: string, params?: Record<string, unknown>): string {
|
|
52
|
+
return template.replace(/\{([A-Za-z][\w.-]*)\}/gu, (match, name: string) => {
|
|
53
|
+
const value = params?.[name]
|
|
54
|
+
return value === undefined ? match : String(value)
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const fallback: TranslateCopy = (key, params) => interpolate(zh[key], params)
|
|
59
|
+
let active: TranslateCopy = fallback
|
|
60
|
+
|
|
61
|
+
/** Read one dictionary entry through the active locale. */
|
|
62
|
+
export function translateCopy(key: HardwareCopyKey, params?: Record<string, unknown>): string {
|
|
63
|
+
return active(key, params)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Bind the copy facade to DSH's locale service.
|
|
68
|
+
*
|
|
69
|
+
* Call once from the client entry. The returned disposer restores the zh
|
|
70
|
+
* fallback so an HMR reload cannot leave a stale binding behind.
|
|
71
|
+
*/
|
|
72
|
+
export function installCopyLocale(locale?: CopyLocale): () => void {
|
|
73
|
+
if (locale === undefined) return () => {}
|
|
74
|
+
const dispose = locale.register(HARDWARE_UI_NS, { zh, en })
|
|
75
|
+
const bound = locale.bind(HARDWARE_UI_NS)
|
|
76
|
+
const installed: TranslateCopy = (key, params) => bound(key, params)
|
|
77
|
+
active = installed
|
|
78
|
+
return () => {
|
|
79
|
+
if (active === installed) active = fallback
|
|
80
|
+
if (typeof dispose === 'function') dispose()
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
53
84
|
export const COPY = {
|
|
54
85
|
/** Product name — tab title, settings section label, wizard title. */
|
|
55
86
|
product: {
|
|
56
|
-
name: '
|
|
87
|
+
get name(): string { return translateCopy('product.name') },
|
|
57
88
|
},
|
|
58
89
|
|
|
59
90
|
/** The five persistent destinations, in `DESTINATIONS` order. */
|
|
60
91
|
destinations: {
|
|
61
|
-
schematic: '
|
|
62
|
-
pcb: '
|
|
63
|
-
bom: '
|
|
64
|
-
'3d': '
|
|
65
|
-
order: '
|
|
92
|
+
get schematic(): string { return translateCopy('destinations.schematic') },
|
|
93
|
+
get pcb(): string { return translateCopy('destinations.pcb') },
|
|
94
|
+
get bom(): string { return translateCopy('destinations.bom') },
|
|
95
|
+
get '3d'(): string { return translateCopy('destinations.3d') },
|
|
96
|
+
get order(): string { return translateCopy('destinations.order') },
|
|
66
97
|
},
|
|
67
98
|
|
|
68
99
|
/** Navigation row + viewer strip. */
|
|
69
100
|
viewer: {
|
|
70
|
-
discoveryFailed: (detail: string) =>
|
|
71
|
-
installationFailed: (detail: string) =>
|
|
72
|
-
noArtifact: '
|
|
73
|
-
kicadMissing: '
|
|
74
|
-
kicadVersion: (version: string) =>
|
|
75
|
-
openInKicad:
|
|
76
|
-
openInKicadTitle: (path: string) =>
|
|
77
|
-
selectArtifactFirst: '
|
|
78
|
-
configureKicad:
|
|
79
|
-
selectProject: '
|
|
101
|
+
discoveryFailed: (detail: string): string => translateCopy('viewer.discoveryFailed', { detail }),
|
|
102
|
+
installationFailed: (detail: string): string => translateCopy('viewer.installationFailed', { detail }),
|
|
103
|
+
get noArtifact(): string { return translateCopy('viewer.noArtifact') },
|
|
104
|
+
get kicadMissing(): string { return translateCopy('viewer.kicadMissing') },
|
|
105
|
+
kicadVersion: (version: string): string => translateCopy('viewer.kicadVersion', { version }),
|
|
106
|
+
get openInKicad(): string { return translateCopy('viewer.openInKicad') },
|
|
107
|
+
openInKicadTitle: (path: string): string => translateCopy('viewer.openInKicadTitle', { path }),
|
|
108
|
+
get selectArtifactFirst(): string { return translateCopy('viewer.selectArtifactFirst') },
|
|
109
|
+
get configureKicad(): string { return translateCopy('viewer.configureKicad') },
|
|
110
|
+
get selectProject(): string { return translateCopy('viewer.selectProject') },
|
|
80
111
|
// aria labels / titles (screen-reader text is visible text too)
|
|
81
|
-
projectField: '
|
|
82
|
-
schematicSheetField: '
|
|
83
|
-
boardField: '
|
|
112
|
+
get projectField(): string { return translateCopy('viewer.projectField') },
|
|
113
|
+
get schematicSheetField(): string { return translateCopy('viewer.schematicSheetField') },
|
|
114
|
+
get boardField(): string { return translateCopy('viewer.boardField') },
|
|
84
115
|
},
|
|
85
116
|
|
|
86
117
|
/**
|
|
@@ -91,24 +122,22 @@ export const COPY = {
|
|
|
91
122
|
*/
|
|
92
123
|
placeholder: {
|
|
93
124
|
title: {
|
|
94
|
-
schematic: '
|
|
95
|
-
pcb: '
|
|
96
|
-
bom: '
|
|
97
|
-
'3d':
|
|
98
|
-
order: '
|
|
125
|
+
get schematic(): string { return translateCopy('placeholder.title.schematic') },
|
|
126
|
+
get pcb(): string { return translateCopy('placeholder.title.pcb') },
|
|
127
|
+
get bom(): string { return translateCopy('placeholder.title.bom') },
|
|
128
|
+
get '3d'(): string { return translateCopy('placeholder.title.3d') },
|
|
129
|
+
get order(): string { return translateCopy('placeholder.title.order') },
|
|
99
130
|
},
|
|
100
131
|
/** One sentence: what the agent can create for this destination. */
|
|
101
132
|
guide: {
|
|
102
|
-
schematic: '
|
|
103
|
-
pcb:
|
|
104
|
-
bom:
|
|
105
|
-
'3d':
|
|
106
|
-
order:
|
|
133
|
+
get schematic(): string { return translateCopy('placeholder.guide.schematic') },
|
|
134
|
+
get pcb(): string { return translateCopy('placeholder.guide.pcb') },
|
|
135
|
+
get bom(): string { return translateCopy('placeholder.guide.bom') },
|
|
136
|
+
get '3d'(): string { return translateCopy('placeholder.guide.3d') },
|
|
137
|
+
get order(): string { return translateCopy('placeholder.guide.order') },
|
|
107
138
|
},
|
|
108
139
|
/** Shown instead of a destination guide when no project was discovered. */
|
|
109
|
-
noProject:
|
|
110
|
-
/** The ask, phrased so the user can paste it into the conversation. */
|
|
111
|
-
askAgent: '对智能体说:「为当前工程创建原理图」/「创建 PCB」/「导出 3D 模型」即可。',
|
|
140
|
+
get noProject(): string { return translateCopy('placeholder.noProject') },
|
|
112
141
|
},
|
|
113
142
|
|
|
114
143
|
/**
|
|
@@ -118,172 +147,268 @@ export const COPY = {
|
|
|
118
147
|
* two: known codes get translated, unknown ones fall back to the host text.
|
|
119
148
|
*/
|
|
120
149
|
discovery: {
|
|
121
|
-
selectionRequiredCount: (count: number) =>
|
|
122
|
-
selectionRequiredArtifact: '
|
|
123
|
-
noProjectSelected: '
|
|
124
|
-
noSchematic: '
|
|
125
|
-
noBoard: '
|
|
126
|
-
noBoardToOrder: '
|
|
150
|
+
selectionRequiredCount: (count: number): string => translateCopy('discovery.selectionRequiredCount', { count }),
|
|
151
|
+
get selectionRequiredArtifact(): string { return translateCopy('discovery.selectionRequiredArtifact') },
|
|
152
|
+
get noProjectSelected(): string { return translateCopy('discovery.noProjectSelected') },
|
|
153
|
+
get noSchematic(): string { return translateCopy('discovery.noSchematic') },
|
|
154
|
+
get noBoard(): string { return translateCopy('discovery.noBoard') },
|
|
155
|
+
get noBoardToOrder(): string { return translateCopy('discovery.noBoardToOrder') },
|
|
127
156
|
// Host `issue.code` vocabulary.
|
|
128
|
-
noProject: (cwd: string) =>
|
|
129
|
-
|
|
130
|
-
|
|
157
|
+
noProject: (cwd: string): string => cwd === ''
|
|
158
|
+
? translateCopy('discovery.noProject')
|
|
159
|
+
: translateCopy('discovery.noProjectIn', { cwd }),
|
|
160
|
+
missingProject: (path: string): string => translateCopy('discovery.missingProject', { path }),
|
|
161
|
+
badManifest: (detail: string): string => translateCopy('discovery.badManifest', { detail }),
|
|
131
162
|
},
|
|
132
163
|
|
|
133
164
|
/** schematic / pcb / 3d / bom stages. */
|
|
134
165
|
preview: {
|
|
135
|
-
loading: '
|
|
136
|
-
kindSchematic: '
|
|
137
|
-
kindBoard: '
|
|
138
|
-
revision: (revision: string) =>
|
|
139
|
-
ecadHint: '
|
|
140
|
-
ecadKindMismatch: (expected: string, actual: string) =>
|
|
141
|
-
|
|
142
|
-
ecadOverlay:
|
|
143
|
-
kicadNotConfigured: '
|
|
144
|
-
glbExporting:
|
|
145
|
-
glbLoading:
|
|
146
|
-
glbCached: '
|
|
147
|
-
glbGenerated: '
|
|
148
|
-
glbOverlay:
|
|
149
|
-
bomHint:
|
|
150
|
-
bomTitle: (lines: number) =>
|
|
151
|
-
bomPlacements: (count: number) =>
|
|
152
|
-
bomColumns: [
|
|
166
|
+
get loading(): string { return translateCopy('preview.loading') },
|
|
167
|
+
get kindSchematic(): string { return translateCopy('preview.kindSchematic') },
|
|
168
|
+
get kindBoard(): string { return translateCopy('preview.kindBoard') },
|
|
169
|
+
revision: (revision: string): string => translateCopy('preview.revision', { revision }),
|
|
170
|
+
get ecadHint(): string { return translateCopy('preview.ecadHint') },
|
|
171
|
+
ecadKindMismatch: (expected: string, actual: string): string =>
|
|
172
|
+
translateCopy('preview.ecadKindMismatch', { expected, actual }),
|
|
173
|
+
get ecadOverlay(): string { return translateCopy('preview.ecadOverlay') },
|
|
174
|
+
get kicadNotConfigured(): string { return translateCopy('preview.kicadNotConfigured') },
|
|
175
|
+
get glbExporting(): string { return translateCopy('preview.glbExporting') },
|
|
176
|
+
get glbLoading(): string { return translateCopy('preview.glbLoading') },
|
|
177
|
+
get glbCached(): string { return translateCopy('preview.glbCached') },
|
|
178
|
+
get glbGenerated(): string { return translateCopy('preview.glbGenerated') },
|
|
179
|
+
get glbOverlay(): string { return translateCopy('preview.glbOverlay') },
|
|
180
|
+
get bomHint(): string { return translateCopy('preview.bomHint') },
|
|
181
|
+
bomTitle: (lines: number): string => translateCopy('preview.bomTitle', { lines }),
|
|
182
|
+
bomPlacements: (count: number): string => translateCopy('preview.bomPlacements', { count }),
|
|
183
|
+
get bomColumns(): readonly string[] {
|
|
184
|
+
return [
|
|
185
|
+
translateCopy('preview.bomColumn.reference'),
|
|
186
|
+
translateCopy('preview.bomColumn.quantity'),
|
|
187
|
+
translateCopy('preview.bomColumn.value'),
|
|
188
|
+
translateCopy('preview.bomColumn.footprint'),
|
|
189
|
+
translateCopy('preview.bomColumn.notes'),
|
|
190
|
+
]
|
|
191
|
+
},
|
|
153
192
|
},
|
|
154
193
|
|
|
155
194
|
/** Order Placing destination. */
|
|
156
195
|
order: {
|
|
157
|
-
title: '
|
|
158
|
-
packaging: '
|
|
159
|
-
packageReady: '
|
|
160
|
-
packagePending: '
|
|
161
|
-
packageRunning:
|
|
162
|
-
packageNotPrepared: '
|
|
163
|
-
packageCard: '
|
|
164
|
-
packageFiles: (files: number, size: string) =>
|
|
165
|
-
|
|
166
|
-
pcbTitle: '
|
|
167
|
-
pcbSubtitle: '
|
|
168
|
-
pcbSummary: (zip: string, files: number, size: string) =>
|
|
169
|
-
|
|
170
|
-
pcbAction:
|
|
171
|
-
|
|
172
|
-
smtTitle: '
|
|
173
|
-
smtSubtitle:
|
|
174
|
-
smtSummary: (placements: number, lines: number, size: string) =>
|
|
175
|
-
|
|
176
|
-
smtAction: '
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
196
|
+
get title(): string { return translateCopy('order.title') },
|
|
197
|
+
get packaging(): string { return translateCopy('order.packaging') },
|
|
198
|
+
get packageReady(): string { return translateCopy('order.packageReady') },
|
|
199
|
+
get packagePending(): string { return translateCopy('order.packagePending') },
|
|
200
|
+
get packageRunning(): string { return translateCopy('order.packageRunning') },
|
|
201
|
+
get packageNotPrepared(): string { return translateCopy('order.packageNotPrepared') },
|
|
202
|
+
get packageCard(): string { return translateCopy('order.packageCard') },
|
|
203
|
+
packageFiles: (files: number, size: string): string => translateCopy('order.packageFiles', { files, size }),
|
|
204
|
+
|
|
205
|
+
get pcbTitle(): string { return translateCopy('order.pcbTitle') },
|
|
206
|
+
get pcbSubtitle(): string { return translateCopy('order.pcbSubtitle') },
|
|
207
|
+
pcbSummary: (zip: string, files: number, size: string): string =>
|
|
208
|
+
translateCopy('order.pcbSummary', { zip, files, size }),
|
|
209
|
+
get pcbAction(): string { return translateCopy('order.pcbAction') },
|
|
210
|
+
|
|
211
|
+
get smtTitle(): string { return translateCopy('order.smtTitle') },
|
|
212
|
+
get smtSubtitle(): string { return translateCopy('order.smtSubtitle') },
|
|
213
|
+
smtSummary: (placements: number, lines: number, size: string): string =>
|
|
214
|
+
translateCopy('order.smtSummary', { placements, lines, size }),
|
|
215
|
+
get smtAction(): string { return translateCopy('order.smtAction') },
|
|
216
|
+
/** Kind name interpolated into the result sentences (not a standalone label). */
|
|
217
|
+
get smtShort(): string { return translateCopy('order.smtShort') },
|
|
218
|
+
|
|
219
|
+
get boardFile(): string { return translateCopy('order.boardFile') },
|
|
220
|
+
get placements(): string { return translateCopy('order.placements') },
|
|
221
|
+
get bomLines(): string { return translateCopy('order.bomLines') },
|
|
222
|
+
get credential(): string { return translateCopy('order.credential') },
|
|
223
|
+
get signedIn(): string { return translateCopy('order.signedIn') },
|
|
224
|
+
get signedOut(): string { return translateCopy('order.signedOut') },
|
|
225
|
+
|
|
226
|
+
get signInToOrder(): string { return translateCopy('order.signInToOrder') },
|
|
227
|
+
get signInToOrderSmt(): string { return translateCopy('order.signInToOrderSmt') },
|
|
228
|
+
get waitingForPackage(): string { return translateCopy('order.waitingForPackage') },
|
|
229
|
+
get configureToPackage(): string { return translateCopy('order.configureToPackage') },
|
|
230
|
+
get selectRootSchematic(): string { return translateCopy('order.selectRootSchematic') },
|
|
190
231
|
|
|
191
232
|
// Board facts (values keep their units, which are not prose).
|
|
192
|
-
layers: '
|
|
193
|
-
layersValue: (layers: number) =>
|
|
194
|
-
outline: '
|
|
195
|
-
thickness: '
|
|
196
|
-
minTrace: '
|
|
197
|
-
minDrill: '
|
|
198
|
-
outerCopper: '
|
|
199
|
-
defaultValue: '
|
|
200
|
-
copperValue: (oz: number | string) =>
|
|
201
|
-
|
|
202
|
-
agentEntryPoints: '
|
|
203
|
-
submitting: '
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
+
get layers(): string { return translateCopy('order.layers') },
|
|
234
|
+
layersValue: (layers: number): string => translateCopy('order.layersValue', { layers }),
|
|
235
|
+
get outline(): string { return translateCopy('order.outline') },
|
|
236
|
+
get thickness(): string { return translateCopy('order.thickness') },
|
|
237
|
+
get minTrace(): string { return translateCopy('order.minTrace') },
|
|
238
|
+
get minDrill(): string { return translateCopy('order.minDrill') },
|
|
239
|
+
get outerCopper(): string { return translateCopy('order.outerCopper') },
|
|
240
|
+
get defaultValue(): string { return translateCopy('order.defaultValue') },
|
|
241
|
+
copperValue: (oz: number | string): string => translateCopy('order.copperValue', { oz }),
|
|
242
|
+
|
|
243
|
+
get agentEntryPoints(): string { return translateCopy('order.agentEntryPoints') },
|
|
244
|
+
get submitting(): string { return translateCopy('order.submitting') },
|
|
245
|
+
|
|
246
|
+
get tabTitle(): string { return translateCopy('order.tabTitle') },
|
|
247
|
+
tabOrder: (id: string): string => translateCopy('order.tabOrder', { id }),
|
|
248
|
+
get tabMissing(): string { return translateCopy('order.tabMissing') },
|
|
249
|
+
get tabAddressHint(): string { return translateCopy('order.tabAddressHint') },
|
|
250
|
+
get openInSystemBrowser(): string { return translateCopy('order.openInSystemBrowser') },
|
|
251
|
+
|
|
252
|
+
get resultTitlePcb(): string { return translateCopy('order.resultTitlePcb') },
|
|
253
|
+
get resultTitleSmt(): string { return translateCopy('order.resultTitleSmt') },
|
|
254
|
+
get resultLaunched(): string { return translateCopy('order.resultLaunched') },
|
|
255
|
+
get resultReady(): string { return translateCopy('order.resultReady') },
|
|
256
|
+
get resultNote(): string { return translateCopy('order.resultNote') },
|
|
257
|
+
resultLaunchedMessage: (kind: string): string => translateCopy('order.resultLaunchedMessage', { kind }),
|
|
258
|
+
resultReadyMessage: (kind: string): string => translateCopy('order.resultReadyMessage', { kind }),
|
|
259
|
+
get openInBrowser(): string { return translateCopy('order.openInBrowser') },
|
|
260
|
+
get opening(): string { return translateCopy('order.opening') },
|
|
261
|
+
get copyUrl(): string { return translateCopy('order.copyUrl') },
|
|
262
|
+
get copied(): string { return translateCopy('order.copied') },
|
|
263
|
+
|
|
264
|
+
get confirmAria(): string { return translateCopy('order.confirmAria') },
|
|
265
|
+
get confirmTitlePcb(): string { return translateCopy('order.confirmTitlePcb') },
|
|
266
|
+
get confirmTitleSmt(): string { return translateCopy('order.confirmTitleSmt') },
|
|
267
|
+
get confirmBody(): string { return translateCopy('order.confirmBody') },
|
|
268
|
+
confirmZip: (zip: string, size: string): string => translateCopy('order.confirmZip', { zip, size }),
|
|
269
|
+
confirmPositions: (size: string): string => translateCopy('order.confirmPositions', { size }),
|
|
270
|
+
confirmBom: (size: string): string => translateCopy('order.confirmBom', { size }),
|
|
271
|
+
confirmHost: (baseUrl: string | undefined): string =>
|
|
272
|
+
baseUrl ?? translateCopy('order.confirmHostFallback'),
|
|
273
|
+
get confirmAck(): string { return translateCopy('order.confirmAck') },
|
|
274
|
+
get cancel(): string { return translateCopy('order.cancel') },
|
|
275
|
+
get uploadAndOpen(): string { return translateCopy('order.uploadAndOpen') },
|
|
276
|
+
get uploading(): string { return translateCopy('order.uploading') },
|
|
277
|
+
|
|
278
|
+
get batch(): string { return translateCopy('order.batch') },
|
|
279
|
+
batchUnits: (count: number): string => translateCopy('order.batchUnits', { count }),
|
|
280
|
+
quoteBasis: (count: number): string => translateCopy('order.quoteBasis', { count }),
|
|
233
281
|
},
|
|
234
282
|
|
|
235
|
-
/**
|
|
283
|
+
/**
|
|
284
|
+
* First-run wizard, following `docs/prototype/huaqiu_eda_hardware_toolchain_ux_prototype.html`.
|
|
285
|
+
*
|
|
286
|
+
* These texts are the prototype's own, so a reviewer can diff the running
|
|
287
|
+
* modal against the design instead of translating in their head.
|
|
288
|
+
*/
|
|
236
289
|
wizard: {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
solidcraftTitle: 'SolidCraft 安装位置',
|
|
256
|
-
solidcraftLead: '本 POC 中 SolidCraft 仅作为环境上下文提供给 Agent——不启动本地程序,也不做结构预览。',
|
|
257
|
-
solidcraftPlaceholder: 'C:\\Program Files\\SolidCraft\\bin\\SolidCraft.exe',
|
|
258
|
-
|
|
259
|
-
skip: '跳过设置',
|
|
260
|
-
back: '上一步',
|
|
261
|
-
next: '下一步',
|
|
262
|
-
finish: '完成',
|
|
263
|
-
saving: '保存中…',
|
|
264
|
-
footerNote: '随时可在「设置 → 硬件工程」中修改。',
|
|
290
|
+
get title(): string { return translateCopy('wizard.title') },
|
|
291
|
+
get badge(): string { return translateCopy('wizard.badge') },
|
|
292
|
+
get lead(): string { return translateCopy('wizard.lead') },
|
|
293
|
+
get callout(): string { return translateCopy('wizard.callout') },
|
|
294
|
+
get kicadTitle(): string { return translateCopy('wizard.kicadName') },
|
|
295
|
+
get kicadChip(): string { return translateCopy('wizard.kicadChip') },
|
|
296
|
+
get kicadBlurb(): string { return translateCopy('wizard.kicadBlurb') },
|
|
297
|
+
get kicadPlaceholder(): string { return translateCopy('wizard.kicadPlaceholder') },
|
|
298
|
+
get solidcraftPlaceholder(): string { return translateCopy('wizard.solidcraftPlaceholder') },
|
|
299
|
+
get solidcraftTitle(): string { return translateCopy('wizard.solidcraftName') },
|
|
300
|
+
get solidcraftChip(): string { return translateCopy('wizard.solidcraftChip') },
|
|
301
|
+
get solidcraftBlurb(): string { return translateCopy('wizard.solidcraftBlurb') },
|
|
302
|
+
get selectFile(): string { return translateCopy('wizard.selectFile') },
|
|
303
|
+
dontHave: (name: string): string => translateCopy('wizard.dontHave', { name }),
|
|
304
|
+
get serverDownload(): string { return translateCopy('wizard.serverDownload') },
|
|
305
|
+
get footer(): string { return translateCopy('wizard.footer') },
|
|
306
|
+
get skip(): string { return translateCopy('wizard.skipNow') },
|
|
307
|
+
get save(): string { return translateCopy('wizard.save') },
|
|
265
308
|
},
|
|
266
309
|
|
|
267
310
|
/** Settings section (the two CAD installation roots). */
|
|
268
311
|
settings: {
|
|
269
|
-
title: '
|
|
270
|
-
lead:
|
|
271
|
-
kicadTitle:
|
|
272
|
-
kicadBlurb:
|
|
273
|
-
kicadPlaceholder: '
|
|
274
|
-
solidcraftTitle:
|
|
275
|
-
solidcraftBlurb:
|
|
276
|
-
solidcraftPlaceholder: '
|
|
277
|
-
pathField: (title: string) =>
|
|
278
|
-
validate: '
|
|
279
|
-
validating: '
|
|
280
|
-
configured: '
|
|
281
|
-
notConfigured: '
|
|
282
|
-
notDetected: '
|
|
283
|
-
savedAndValidated: (application: string) =>
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
312
|
+
get title(): string { return translateCopy('settings.title') },
|
|
313
|
+
get lead(): string { return translateCopy('settings.lead') },
|
|
314
|
+
get kicadTitle(): string { return translateCopy('settings.kicadTitle') },
|
|
315
|
+
get kicadBlurb(): string { return translateCopy('settings.kicadCardBlurb') },
|
|
316
|
+
get kicadPlaceholder(): string { return translateCopy('settings.kicadPlaceholder') },
|
|
317
|
+
get solidcraftTitle(): string { return translateCopy('settings.solidcraftTitle') },
|
|
318
|
+
get solidcraftBlurb(): string { return translateCopy('settings.solidcraftCardBlurb') },
|
|
319
|
+
get solidcraftPlaceholder(): string { return translateCopy('settings.solidcraftPlaceholder') },
|
|
320
|
+
pathField: (title: string): string => translateCopy('settings.pathField', { title }),
|
|
321
|
+
get validate(): string { return translateCopy('settings.validate') },
|
|
322
|
+
get validating(): string { return translateCopy('settings.validating') },
|
|
323
|
+
get configured(): string { return translateCopy('settings.configured') },
|
|
324
|
+
get notConfigured(): string { return translateCopy('settings.notConfigured') },
|
|
325
|
+
get notDetected(): string { return translateCopy('settings.notDetected') },
|
|
326
|
+
savedAndValidated: (application: string): string =>
|
|
327
|
+
translateCopy('settings.savedAndValidated', { application }),
|
|
328
|
+
savedButInvalid: (application: string, detail: string): string =>
|
|
329
|
+
translateCopy('settings.savedButInvalid', { application, detail }),
|
|
330
|
+
get hostSettingsUnavailable(): string { return translateCopy('settings.hostSettingsUnavailable') },
|
|
331
|
+
hostRejected: (application: string): string => translateCopy('settings.hostRejected', { application }),
|
|
332
|
+
get statusVerified(): string { return translateCopy('settings.statusVerified') },
|
|
333
|
+
get statusAwaiting(): string { return translateCopy('settings.statusAwaiting') },
|
|
334
|
+
get statusUnsaved(): string { return translateCopy('settings.statusUnsaved') },
|
|
335
|
+
download: (tool: 'kicad' | 'solidcraft', version: string): string => (tool === 'kicad'
|
|
336
|
+
? translateCopy('settings.downloadKicad', { version })
|
|
337
|
+
: translateCopy('settings.downloadSolidCraft', { version })),
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Toolchain capability: discovery lines, status pills, download affordances
|
|
342
|
+
* and the transient notices of §11. Every sentence here is one that only the
|
|
343
|
+
* plugin can say — the Host's own text arrives separately and is passed
|
|
344
|
+
* through {@link describeHostError} where it is technical.
|
|
345
|
+
*/
|
|
346
|
+
toolchain: {
|
|
347
|
+
get checking(): string { return translateCopy('toolchain.checking') },
|
|
348
|
+
get kicadMissing(): string { return translateCopy('toolchain.kicadMissing') },
|
|
349
|
+
get solidcraftMissing(): string { return translateCopy('toolchain.solidcraftMissing') },
|
|
350
|
+
get discovering(): string { return translateCopy('toolchain.discovering') },
|
|
351
|
+
get notDetected(): string { return translateCopy('toolchain.notDetected') },
|
|
352
|
+
detected: (path: string, version: string): string => translateCopy('toolchain.detected', { path, version }),
|
|
353
|
+
detectedInvalid: (path: string, detail: string): string =>
|
|
354
|
+
translateCopy('toolchain.detectedInvalid', { path, detail }),
|
|
355
|
+
get browse(): string { return translateCopy('toolchain.browse') },
|
|
356
|
+
download: (name: string, version: string): string => translateCopy('toolchain.download', { name, version }),
|
|
357
|
+
downloadUnavailable: (name: string): string => translateCopy('toolchain.downloadUnavailable', { name }),
|
|
358
|
+
downloadUnavailableWith: (name: string, detail: string): string =>
|
|
359
|
+
translateCopy('toolchain.downloadUnavailableWith', { name, detail }),
|
|
360
|
+
get official(): string { return translateCopy('toolchain.official') },
|
|
361
|
+
get downloading(): string { return translateCopy('toolchain.downloading') },
|
|
362
|
+
get statusNotConfigured(): string { return translateCopy('toolchain.statusNotConfigured') },
|
|
363
|
+
get browseTitle(): string { return translateCopy('toolchain.browseTitle') },
|
|
364
|
+
|
|
365
|
+
// Executable picker (prototype §3): title, breadcrumb link, hint, footer.
|
|
366
|
+
pickerTitle: (name: string): string => translateCopy('toolchain.pickerTitle', { name }),
|
|
367
|
+
get pickerHint(): string { return translateCopy('toolchain.pickerHint') },
|
|
368
|
+
get pickerNative(): string { return translateCopy('toolchain.pickerNative') },
|
|
369
|
+
get pickerNativeWaiting(): string { return translateCopy('toolchain.pickerNativeWaiting') },
|
|
370
|
+
get pickerRoot(): string { return translateCopy('toolchain.pickerRoot') },
|
|
371
|
+
get pickerNoSelection(): string { return translateCopy('toolchain.pickerNoSelection') },
|
|
372
|
+
get pickerOpen(): string { return translateCopy('toolchain.pickerOpen') },
|
|
373
|
+
get pickerCancel(): string { return translateCopy('toolchain.pickerCancel') },
|
|
374
|
+
pickerOrigin: (origin: 'managed' | 'system' | 'user-local'): string => (origin === 'managed'
|
|
375
|
+
? translateCopy('toolchain.pickerOriginManaged')
|
|
376
|
+
: origin === 'user-local'
|
|
377
|
+
? translateCopy('toolchain.pickerOriginUserLocal')
|
|
378
|
+
: translateCopy('toolchain.pickerOriginSystem')),
|
|
379
|
+
get pickerValid(): string { return translateCopy('toolchain.pickerValid') },
|
|
380
|
+
get pickerInvalid(): string { return translateCopy('toolchain.pickerInvalid') },
|
|
381
|
+
get cancel(): string { return translateCopy('toolchain.cancel') },
|
|
382
|
+
get retryCheck(): string { return translateCopy('toolchain.retryCheck') },
|
|
383
|
+
get statusUnconfigured(): string { return translateCopy('toolchain.statusUnconfigured') },
|
|
384
|
+
get statusValidating(): string { return translateCopy('toolchain.statusValidating') },
|
|
385
|
+
get statusConfigured(): string { return translateCopy('toolchain.statusConfigured') },
|
|
386
|
+
get statusInvalid(): string { return translateCopy('toolchain.statusInvalid') },
|
|
387
|
+
statusDownloading: (percent: string): string => translateCopy('toolchain.statusDownloading', { percent }),
|
|
388
|
+
get statusExtracting(): string { return translateCopy('toolchain.statusExtracting') },
|
|
389
|
+
get statusDone(): string { return translateCopy('toolchain.statusDone') },
|
|
390
|
+
get statusFailed(): string { return translateCopy('toolchain.statusFailed') },
|
|
391
|
+
toastStarted: (name: string, version: string): string => translateCopy('toolchain.toastStarted', { name, version }),
|
|
392
|
+
toastDownloaded: (name: string, version: string): string =>
|
|
393
|
+
translateCopy('toolchain.toastDownloaded', { name, version }),
|
|
394
|
+
toastExtracting: (name: string): string => translateCopy('toolchain.toastExtracting', { name }),
|
|
395
|
+
toastInstalled: (name: string, version: string): string =>
|
|
396
|
+
translateCopy('toolchain.toastInstalled', { name, version }),
|
|
397
|
+
toastFailed: (name: string, detail: string): string => translateCopy('toolchain.toastFailed', { name, detail }),
|
|
398
|
+
toastChecksum: (name: string): string => translateCopy('toolchain.toastChecksum', { name }),
|
|
399
|
+
toastCancelled: (name: string): string => translateCopy('toolchain.toastCancelled', { name }),
|
|
400
|
+
toastSaved: (name: string, version: string): string => translateCopy('toolchain.toastSaved', { name, version }),
|
|
401
|
+
toastInvalid: (name: string, detail: string): string => translateCopy('toolchain.toastInvalid', { name, detail }),
|
|
402
|
+
get toastSkipped(): string { return translateCopy('toolchain.toastSkipped') },
|
|
403
|
+
browseUnsupported: (detail: string): string => translateCopy('toolchain.browseUnsupported', { detail }),
|
|
404
|
+
get onboardingTitle(): string { return translateCopy('toolchain.onboardingTitle') },
|
|
405
|
+
get onboardingLead(): string { return translateCopy('toolchain.onboardingLead') },
|
|
406
|
+
get onboardingAria(): string { return translateCopy('toolchain.onboardingAria') },
|
|
407
|
+
get skip(): string { return translateCopy('toolchain.skip') },
|
|
408
|
+
get finish(): string { return translateCopy('toolchain.finish') },
|
|
409
|
+
get footNote(): string { return translateCopy('toolchain.footNote') },
|
|
410
|
+
indicator: (summary: string): string => translateCopy('toolchain.indicator', { summary }),
|
|
411
|
+
get pending(): string { return translateCopy('toolchain.pending') },
|
|
287
412
|
},
|
|
288
413
|
|
|
289
414
|
/**
|
|
@@ -293,27 +418,29 @@ export const COPY = {
|
|
|
293
418
|
* answer for an unmodelled failure.
|
|
294
419
|
*/
|
|
295
420
|
errors: {
|
|
296
|
-
unauthorized: '
|
|
297
|
-
forbidden: '
|
|
298
|
-
'missing-artifact': '
|
|
299
|
-
'unsupported-artifact': '
|
|
300
|
-
'invalid-identity': '
|
|
301
|
-
'missing-executable':
|
|
302
|
-
'not-configured':
|
|
303
|
-
'too-large': '
|
|
304
|
-
'export-timeout': '
|
|
305
|
-
'export-failed': '
|
|
306
|
-
'stale-revision': '
|
|
307
|
-
'invalid-request': '
|
|
308
|
-
'invalid-application': '
|
|
309
|
-
'confirmation-required': '
|
|
310
|
-
'invalid-order-url': '
|
|
311
|
-
'order-unreachable': '
|
|
312
|
-
'order-rejected': '
|
|
313
|
-
'not-found': '
|
|
314
|
-
|
|
421
|
+
get unauthorized(): string { return translateCopy('errors.unauthorized') },
|
|
422
|
+
get forbidden(): string { return translateCopy('errors.forbidden') },
|
|
423
|
+
get 'missing-artifact'(): string { return translateCopy('errors.missing-artifact') },
|
|
424
|
+
get 'unsupported-artifact'(): string { return translateCopy('errors.unsupported-artifact') },
|
|
425
|
+
get 'invalid-identity'(): string { return translateCopy('errors.invalid-identity') },
|
|
426
|
+
get 'missing-executable'(): string { return translateCopy('errors.missing-executable') },
|
|
427
|
+
get 'not-configured'(): string { return translateCopy('errors.not-configured') },
|
|
428
|
+
get 'too-large'(): string { return translateCopy('errors.too-large') },
|
|
429
|
+
get 'export-timeout'(): string { return translateCopy('errors.export-timeout') },
|
|
430
|
+
get 'export-failed'(): string { return translateCopy('errors.export-failed') },
|
|
431
|
+
get 'stale-revision'(): string { return translateCopy('errors.stale-revision') },
|
|
432
|
+
get 'invalid-request'(): string { return translateCopy('errors.invalid-request') },
|
|
433
|
+
get 'invalid-application'(): string { return translateCopy('errors.invalid-application') },
|
|
434
|
+
get 'confirmation-required'(): string { return translateCopy('errors.confirmation-required') },
|
|
435
|
+
get 'invalid-order-url'(): string { return translateCopy('errors.invalid-order-url') },
|
|
436
|
+
get 'order-unreachable'(): string { return translateCopy('errors.order-unreachable') },
|
|
437
|
+
get 'order-rejected'(): string { return translateCopy('errors.order-rejected') },
|
|
438
|
+
get 'not-found'(): string { return translateCopy('errors.not-found') },
|
|
439
|
+
get 'method-not-allowed'(): string { return translateCopy('errors.method-not-allowed') },
|
|
440
|
+
get 'unknown-job'(): string { return translateCopy('errors.unknown-job') },
|
|
441
|
+
get internal(): string { return translateCopy('errors.internal') },
|
|
315
442
|
},
|
|
316
|
-
}
|
|
443
|
+
}
|
|
317
444
|
|
|
318
445
|
export type HardwareCopy = typeof COPY
|
|
319
446
|
|
|
@@ -331,7 +458,7 @@ const KEEPS_DETAIL = new Set([
|
|
|
331
458
|
])
|
|
332
459
|
|
|
333
460
|
/**
|
|
334
|
-
* One host error → one
|
|
461
|
+
* One host error → one sentence in the active locale.
|
|
335
462
|
*
|
|
336
463
|
* `detail` is the host's own message. Unknown codes keep it untouched, so an
|
|
337
464
|
* unmodelled failure still says something specific instead of collapsing into
|
|
@@ -341,7 +468,9 @@ export function describeHostError(code: string | undefined, detail: string): str
|
|
|
341
468
|
if (code === undefined) return detail
|
|
342
469
|
const sentence = (COPY.errors as Record<string, string | undefined>)[code]
|
|
343
470
|
if (sentence === undefined) return detail
|
|
344
|
-
return KEEPS_DETAIL.has(code) && detail !== ''
|
|
471
|
+
return KEEPS_DETAIL.has(code) && detail !== ''
|
|
472
|
+
? `${sentence}${translateCopy('error.detail', { detail })}`
|
|
473
|
+
: sentence
|
|
345
474
|
}
|
|
346
475
|
|
|
347
476
|
/**
|