@huaqiu/dsh-hardware-ui 0.7.14 → 0.7.16

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.
@@ -0,0 +1,372 @@
1
+ /**
2
+ * zh_CN copy for every user-visible string of the Hardware Engineering product
3
+ * UI (browser half).
4
+ *
5
+ * Why one module instead of strings at the call sites: the same sentence is
6
+ * rendered from up to three seats (navigation row, viewer body, settings
7
+ * section), and a literal that drifts between them reads as two different
8
+ * products. One dictionary also makes "is this text translated?" a mechanical
9
+ * question — grep for a Chinese character outside this file and the answer is
10
+ * no.
11
+ *
12
+ * Why not DSH's own locale service: `ctx.locale.register(ns, { zh, en })` plus a
13
+ * `locale: 'ns'` slot registration would put a typed, reactive `t` seat on the
14
+ * component props, and it is the right answer for a bilingual plugin. It cannot
15
+ * express zh-only: the typed overload takes
16
+ * `Record<BuiltInLocaleId, LocaleDictOf<N>>` — both baseline locales are
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`).
22
+ *
23
+ * Why one module instead of strings at the call sites: the same sentence is
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:
38
+ * - Commands, file names, extension names, and host paths are NOT translated
39
+ * (`kicad-cli`, `.kicad_pcb`, `Settings → Hardware Engineering` becomes
40
+ * 「设置 → 硬件工程」 only because the host section label is translated too).
41
+ * - 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 it
43
+ * is technical output (kicad-cli stderr) rather than prose.
44
+ * - Interpolation is a function, not `{placeholder}` templates: a function
45
+ * cannot be rendered with its placeholders unfilled by accident.
46
+ *
47
+ * @module
48
+ */
49
+
50
+ /** The only locale this bundle ships. See the module note above. */
51
+ export const LOCALE = 'zh_CN' as const
52
+
53
+ export const COPY = {
54
+ /** Product name — tab title, settings section label, wizard title. */
55
+ product: {
56
+ name: '硬件工程',
57
+ },
58
+
59
+ /** The five persistent destinations, in `DESTINATIONS` order. */
60
+ destinations: {
61
+ schematic: '原理图',
62
+ pcb: 'PCB',
63
+ bom: 'BOM',
64
+ '3d': '3D 模型',
65
+ order: '下单',
66
+ },
67
+
68
+ /** Navigation row + viewer strip. */
69
+ viewer: {
70
+ discoveryFailed: (detail: string) => `产物扫描失败:${detail}`,
71
+ installationFailed: (detail: string) => `安装检查失败:${detail}`,
72
+ noArtifact: '未选择产物',
73
+ kicadMissing: '未找到 KiCad',
74
+ kicadVersion: (version: string) => `KiCad ${version}`,
75
+ openInKicad: '用 KiCad 打开',
76
+ openInKicadTitle: (path: string) => `在 KiCad 中打开 ${path}`,
77
+ selectArtifactFirst: '请先选择一个产物',
78
+ configureKicad: '请在「设置 → 硬件工程」中配置 KiCad',
79
+ selectProject: '选择工程…',
80
+ // aria labels / titles (screen-reader text is visible text too)
81
+ projectField: '工程',
82
+ schematicSheetField: '原理图页',
83
+ boardField: '板文件',
84
+ },
85
+
86
+ /**
87
+ * Empty viewers. A placeholder names what is missing and then says how to get
88
+ * it: the agent creates hardware, so the copy points there instead of stopping
89
+ * at "not available". BOM is the one destination nobody creates directly — it
90
+ * follows the schematic.
91
+ */
92
+ placeholder: {
93
+ title: {
94
+ schematic: '暂无原理图',
95
+ pcb: '暂无 PCB',
96
+ bom: '暂无 BOM',
97
+ '3d': '暂无 3D 模型',
98
+ order: '暂无可下单的板',
99
+ },
100
+ /** One sentence: what the agent can create for this destination. */
101
+ guide: {
102
+ schematic: '可以让智能体在当前工程中创建原理图(.kicad_sch),创建后会直接在这里显示。',
103
+ pcb: '可以让智能体创建 PCB 并完成布局(.kicad_pcb),保存后会直接在这里显示。',
104
+ bom: 'BOM 由原理图自动生成:让智能体先创建原理图,BOM 会自动更新。',
105
+ '3d': '3D 模型由 PCB 生成:让智能体创建 PCB 后,这里会自动出现三维预览。',
106
+ order: '制板与贴片都需要 PCB:让智能体创建 PCB 后即可在这里报价下单。',
107
+ },
108
+ /** Shown instead of a destination guide when no project was discovered. */
109
+ noProject: '可以让智能体在当前工作区创建 KiCad 工程(.kicad_pro),工程出现后这里会自动刷新。',
110
+ /** The ask, phrased so the user can paste it into the conversation. */
111
+ askAgent: '对智能体说:「为当前工程创建原理图」/「创建 PCB」/「导出 3D 模型」即可。',
112
+ },
113
+
114
+ /**
115
+ * Discovery outcomes. These are the panel's OWN sentences for a host state —
116
+ * the host also sends a `message`, but re-deriving it here keeps the copy in
117
+ * one place and lets the count/cwd be woven in. {@link issueText} bridges the
118
+ * two: known codes get translated, unknown ones fall back to the host text.
119
+ */
120
+ discovery: {
121
+ selectionRequiredCount: (count: number) => `发现 ${count} 个硬件工程,请明确选择一个。`,
122
+ selectionRequiredArtifact: '该工程包含多个可选产物,请明确选择一个。',
123
+ noProjectSelected: '尚未选择硬件工程。请打开或选择一个硬件工程。',
124
+ noSchematic: '该工程没有可用的根原理图。',
125
+ noBoard: '该工程没有可用的 .kicad_pcb 板文件。',
126
+ noBoardToOrder: '请先选择板文件,再报价或下单制板。',
127
+ // Host `issue.code` vocabulary.
128
+ noProject: (cwd: string) => (cwd === '' ? '未找到 .kicad_pro 工程文件' : `${cwd} 下未找到 .kicad_pro 工程文件`),
129
+ missingProject: (path: string) => `工程文件不存在:${path}`,
130
+ badManifest: (detail: string) => `配置文件 .hardware-engineering.json 无效:${detail}`,
131
+ },
132
+
133
+ /** schematic / pcb / 3d / bom stages. */
134
+ preview: {
135
+ loading: '正在加载已保存的产物…',
136
+ kindSchematic: '原理图',
137
+ kindBoard: 'PCB',
138
+ revision: (revision: string) => `版本 ${revision}`,
139
+ ecadHint: '仅预览已保存的文件;文件必须存在且可解析。',
140
+ ecadKindMismatch: (expected: string, actual: string) =>
141
+ `宿主返回的产物类型(${actual})与预览类型(${expected})不一致。`,
142
+ ecadOverlay: '已保存文件 · 滚轮缩放,拖拽平移',
143
+ kicadNotConfigured: 'KiCad 尚未配置。',
144
+ glbExporting: '正在用 kicad-cli 导出 PCB 的 GLB…',
145
+ glbLoading: '正在加载 3D 模型…',
146
+ glbCached: '缓存',
147
+ glbGenerated: '已生成',
148
+ glbOverlay: '拖拽旋转 · 滚轮缩放',
149
+ bomHint: 'BOM 行来自 kicad-cli sch export bom。请在「设置 → 硬件工程」中配置 KiCad。',
150
+ bomTitle: (lines: number) => `物料清单 · ${String(lines)} 行`,
151
+ bomPlacements: (count: number) => `${String(count)} 个元件位`,
152
+ bomColumns: ['位号', '数量', '值', '封装', '备注'] as const,
153
+ },
154
+
155
+ /** Order Placing destination. */
156
+ order: {
157
+ title: '制板与贴片',
158
+ packaging: '打包中…',
159
+ packageReady: '打包完成',
160
+ packagePending: '尚未打包',
161
+ packageRunning: '正在运行 kicad-cli 导出 Gerber 与钻孔…',
162
+ packageNotPrepared: '尚未打包。',
163
+ packageCard: '制板文件包',
164
+ packageFiles: (files: number, size: string) => `${String(files)} 个文件 · ${size}`,
165
+
166
+ pcbTitle: '裸板制板',
167
+ pcbSubtitle: '通过华秋制板服务对选中的板文件报价并下单。',
168
+ pcbSummary: (zip: string, files: number, size: string) =>
169
+ `${zip} · ${String(files)} 个 Gerber/钻孔文件 · ${size}`,
170
+ pcbAction: '提交 PCB 订单',
171
+
172
+ smtTitle: '整包贴片',
173
+ smtSubtitle: '需要工程根原理图以生成 BOM 与元件坐标。',
174
+ smtSummary: (placements: number, lines: number, size: string) =>
175
+ `${String(placements)} 个贴片点位 · ${String(lines)} 行 BOM · ${size}`,
176
+ smtAction: '提交贴片订单',
177
+
178
+ boardFile: '板文件',
179
+ placements: '贴片点位',
180
+ bomLines: 'BOM 行数',
181
+ credential: '登录凭据',
182
+ signedIn: '华秋登录',
183
+ signedOut: '未登录',
184
+
185
+ signInToOrder: '请先登录华秋账号再下单——订单页将以你的账号打开。',
186
+ signInToOrderSmt: '请先登录华秋账号再下单贴片——订单页将以你的账号打开。',
187
+ waitingForPackage: '正在等待制板文件包。',
188
+ configureToPackage: '请配置 KiCad 以打包板文件。',
189
+ selectRootSchematic: '请选择根原理图,以便生成 BOM 与坐标。',
190
+
191
+ // Board facts (values keep their units, which are not prose).
192
+ layers: '层数',
193
+ layersValue: (layers: number) => `${String(layers)} 层`,
194
+ outline: '外形尺寸',
195
+ thickness: '板厚',
196
+ minTrace: '最小线宽',
197
+ minDrill: '最小钻孔',
198
+ outerCopper: '外层铜厚',
199
+ defaultValue: '默认',
200
+ copperValue: (oz: number | string) => `${String(oz)} oz`,
201
+
202
+ agentEntryPoints: 'Agent 入口',
203
+ submitting: '提交中…',
204
+
205
+ resultTitlePcb: 'PCB 订单已创建',
206
+ resultTitleSmt: '贴片订单已创建',
207
+ resultLaunched: '已在浏览器打开',
208
+ resultReady: '待打开',
209
+ resultNote: '与 KiCad 在下单窗口中展示的是同一个页面,已在你的默认浏览器中打开。',
210
+ resultLaunchedMessage: (kind: string) => `已在默认浏览器中打开「${kind}」订单页。`,
211
+ resultReadyMessage: (kind: string) => `「${kind}」订单页已就绪,打开链接即可继续。`,
212
+ openInBrowser: '在浏览器打开',
213
+ opening: '正在打开…',
214
+ copyUrl: '复制链接',
215
+ copied: '已复制',
216
+
217
+ confirmAria: '确认下单上传',
218
+ confirmTitlePcb: '上传板文件并创建 PCB 订单?',
219
+ confirmTitleSmt: '上传贴片文件包?',
220
+ confirmBody: '以下文件将发送到华秋下单服务。订单在那里创建,其页面会在你的默认浏览器中打开;付款仍在该页面完成。',
221
+ confirmZip: (zip: string, size: string) => `${zip} — Gerber 与钻孔文件(${size})`,
222
+ confirmPositions: (size: string) => `元件坐标(${size})`,
223
+ confirmBom: (size: string) => `贴片 BOM(${size})`,
224
+ confirmHost: (baseUrl: string | undefined) => baseUrl ?? '已配置的下单服务',
225
+ confirmAck: '我了解这些板文件将离开本机。',
226
+ cancel: '取消',
227
+ uploadAndOpen: '上传并打开订单页',
228
+ uploading: '正在上传…',
229
+
230
+ batch: '生产数量',
231
+ batchUnits: (count: number) => `${String(count)} 片`,
232
+ quoteBasis: (count: number) => `报价基准 · ${String(count)} 片`,
233
+ },
234
+
235
+ /** First-run setup wizard. */
236
+ wizard: {
237
+ steps: ['欢迎', 'KiCad', 'SolidCraft'] as const,
238
+ stepCounter: (index: number, total: number, label: string) =>
239
+ `${String(index)}/${String(total)} · ${label}`,
240
+ aria: '硬件工程初始化',
241
+
242
+ welcomeTitle: '配置你的硬件工具链',
243
+ welcomeKicker: '仅需一次 · 可跳过',
244
+ welcomeLead: '硬件工程可预览 KiCad 工程、导出 PCB 三维模型、打包制板文件并调用本地程序打开文件。只需指定一次本地安装位置。',
245
+ welcomeUsesTitle: '使用到的组件',
246
+ welcomeUses: 'kicad-cli 负责预览、BOM、GLB 与 Gerber/钻孔打包。SolidCraft 仅作为环境上下文提供给 Agent。',
247
+ welcomeLocal: '只使用本机的可执行文件。不会上传任何内容,也不会替你安装任何东西。',
248
+
249
+ kicadTitle: 'KiCad 安装位置',
250
+ kicadOptional: '可选',
251
+ kicadLead: '填写 KiCad 安装目录或 kicad-cli 路径。它用于 .kicad_sch / .kicad_pcb 预览、PCB 的 GLB 导出、制板文件打包,以及「用 KiCad 打开」。',
252
+ kicadPlaceholder: 'C:\\Program Files\\KiCad\\8.0\\ 或 /usr/bin/kicad-cli',
253
+ kicadSkipHint: '留空即跳过。之后可在「设置 → 硬件工程」中配置。',
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: '随时可在「设置 → 硬件工程」中修改。',
265
+ },
266
+
267
+ /** Settings section (the two CAD installation roots). */
268
+ settings: {
269
+ title: '硬件工程',
270
+ lead: '用于预览、制板打包、一键调用本地程序以及 Agent 环境上下文的本地 EDA / MCAD 可执行文件。',
271
+ kicadTitle: 'KiCad EDA 套件',
272
+ kicadBlurb: '可填 KiCad 安装目录或 kicad-cli 路径。用于 .kicad_sch / .kicad_pcb 预览、GLB 导出、BOM、Gerber 打包与本地打开。',
273
+ kicadPlaceholder: 'C:\\Program Files\\KiCad\\8.0\\ 或 /usr/bin/kicad-cli',
274
+ solidcraftTitle: 'SolidCraft 三维 CAD',
275
+ solidcraftBlurb: '本 POC 中仅用于 Agent 环境上下文。不启动本地程序,也不做结构预览;「3D 模型」页签渲染的是所选 PCB。',
276
+ solidcraftPlaceholder: 'C:\\Program Files\\SolidCraft\\bin\\SolidCraft.exe',
277
+ pathField: (title: string) => `${title}路径`,
278
+ validate: '校验并保存',
279
+ validating: '校验中…',
280
+ configured: '已配置',
281
+ notConfigured: '未配置',
282
+ notDetected: '未检测到',
283
+ savedAndValidated: (application: string) => `${application} 校验通过并已保存。`,
284
+ savedButInvalid: (application: string, detail: string) => `${application} 已保存,但校验失败:${detail}`,
285
+ hostSettingsUnavailable: '宿主未提供设置服务,无法保存。',
286
+ hostRejected: (application: string) => `宿主拒绝了${application}的设置。`,
287
+ },
288
+
289
+ /**
290
+ * Host error sentences, keyed by the stable `code` in the route envelope
291
+ * (`packages/hardware-artifacts/src/routes.ts`). A code missing here is not a
292
+ * bug in the UI: the host detail is then shown verbatim, which is the right
293
+ * answer for an unmodelled failure.
294
+ */
295
+ errors: {
296
+ unauthorized: '没有权限访问该产物:它不在当前会话的工作区授权范围内。',
297
+ forbidden: '没有权限执行该操作。',
298
+ 'missing-artifact': '该产物不存在。',
299
+ 'unsupported-artifact': '不支持该产物类型。',
300
+ 'invalid-identity': '产物路径无效。',
301
+ 'missing-executable': '已配置的 KiCad 中没有可打开该产物的程序。',
302
+ 'not-configured': '尚未配置 KiCad。请在「设置 → 硬件工程」中填写安装位置。',
303
+ 'too-large': '产物超过可预览的大小上限。',
304
+ 'export-timeout': 'kicad-cli 执行超时。',
305
+ 'export-failed': 'kicad-cli 导出失败。',
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
+ internal: '服务内部错误。',
315
+ },
316
+ } as const
317
+
318
+ export type HardwareCopy = typeof COPY
319
+
320
+ /**
321
+ * Codes whose host detail is a technical tail worth keeping next to the
322
+ * translated sentence: kicad-cli stderr, an HTTP failure, a backend payload.
323
+ * For the rest the detail merely restates the sentence in English.
324
+ */
325
+ const KEEPS_DETAIL = new Set([
326
+ 'export-failed',
327
+ 'order-unreachable',
328
+ 'order-rejected',
329
+ 'invalid-order-url',
330
+ 'internal',
331
+ ])
332
+
333
+ /**
334
+ * One host error → one zh_CN sentence.
335
+ *
336
+ * `detail` is the host's own message. Unknown codes keep it untouched, so an
337
+ * unmodelled failure still says something specific instead of collapsing into
338
+ * a generic "出错了".
339
+ */
340
+ export function describeHostError(code: string | undefined, detail: string): string {
341
+ if (code === undefined) return detail
342
+ const sentence = (COPY.errors as Record<string, string | undefined>)[code]
343
+ if (sentence === undefined) return detail
344
+ return KEEPS_DETAIL.has(code) && detail !== '' ? `${sentence}(${detail})` : sentence
345
+ }
346
+
347
+ /**
348
+ * Translate one discovery `issue` without losing the host's specifics.
349
+ *
350
+ * The count and the workspace come from the discovery result, not from the
351
+ * host sentence, so the wording does not depend on how the host phrased it.
352
+ */
353
+ export function issueText(
354
+ issue: { readonly code: string; readonly message: string },
355
+ context: { readonly cwd?: string; readonly count?: number } = {},
356
+ ): string {
357
+ switch (issue.code) {
358
+ case 'selection-required':
359
+ return context.count !== undefined && context.count > 1
360
+ ? COPY.discovery.selectionRequiredCount(context.count)
361
+ : COPY.discovery.selectionRequiredArtifact
362
+ case 'no-project':
363
+ return COPY.discovery.noProject(context.cwd ?? '')
364
+ case 'missing-project':
365
+ // Host text is `${path} does not exist`; the path is the useful half.
366
+ return COPY.discovery.missingProject(issue.message.replace(/\s+does not exist\s*$/u, ''))
367
+ case 'bad-manifest':
368
+ return COPY.discovery.badManifest(issue.message.replace(/^invalid \.hardware-engineering\.json:\s*/u, ''))
369
+ default:
370
+ return issue.message
371
+ }
372
+ }
@@ -9,6 +9,7 @@
9
9
  import { BoardParser, SchematicParser } from '@huaqiu/kicad-sexpr-parser'
10
10
  import { renderPcb, renderSchematic } from '@huaqiu/ecad-renderer'
11
11
  import { loadArtifactSource, type ArtifactSource } from './transport.js'
12
+ import { COPY } from './copy.js'
12
13
 
13
14
  export type EcadKind = 'schematic' | 'pcb'
14
15
  export interface MountedEcad {
@@ -46,7 +47,7 @@ export async function mountEcad(
46
47
  })
47
48
  if (options.signal.aborted) throw aborted(options.signal)
48
49
  if (source.kind !== undefined && source.kind !== kind) {
49
- throw new Error(`host returned a ${source.kind} artifact for a ${kind} preview`)
50
+ throw new Error(COPY.preview.ecadKindMismatch(kind, source.kind))
50
51
  }
51
52
 
52
53
  // The renderer owns the backing resolution but not the CSS size, and it fits
@@ -1,24 +1,29 @@
1
1
  /**
2
2
  * Browser half of `@huaqiu/dsh-hardware-ui`.
3
3
  *
4
- * Occupies existing DSH seats only: one root navigation occupant, one
5
- * `keepMounted` right-panel tab body, and one settings section. Native open
6
- * lives inside the viewer with the resolved artifact in scope, so no
7
- * conversation-level action is registered.
4
+ * Occupies existing DSH seats only: one `keepMounted` right-panel tab body and
5
+ * one settings section. Native open lives inside the viewer with the resolved
6
+ * artifact in scope, so no conversation-level action is registered — and no
7
+ * conversation-level navigation either: the panel's own header IS the product's
8
+ * navigation, so nothing duplicates it above the conversation.
9
+ *
10
+ * The tab type declares itself the panel's default page (`default: true`), so
11
+ * expanding the column opens Hardware Engineering instead of the guide. Inside
12
+ * the panel there is no tab strip: the page's header is the panel's top edge and
13
+ * the host lays the two panel controls (full screen, collapse) over its end.
8
14
  *
9
15
  * Two store handles, not one: DSH pins a handle to a single slot scope, and
10
- * `conversation.header.leading`/`settings.section` are `root` while
11
- * `sidebar.right.pane.tab` is `session`. Mounting one handle in both scopes is
12
- * rejected at load time ("one handle, one scope"). The two halves therefore
13
- * coordinate the only way the slot contract allows — through the tab
14
- * parameters and their navigation revision.
16
+ * `settings.section` is `root` while `sidebar.right.pane.tab` is `session`.
17
+ * Mounting one handle in both scopes is rejected at load time ("one handle, one
18
+ * scope").
15
19
  */
16
- import { EngineeringNav, HardwareSettingsSection, HardwareViewerBody } from './components.js'
20
+ import { HardwareSettingsSection, HardwareViewerBody } from './components.js'
17
21
  import type {
18
22
  ConfigFormLike, HardwareController, HardwareDestination, HardwareInstallationConfig,
19
23
  ViewerNavigationParams,
20
24
  } from './model.js'
21
25
  import { createHardwareStore } from './store.js'
26
+ import { COPY } from './copy.js'
22
27
  import { loadInstallations, loadProjects, openArtifact } from './transport.js'
23
28
 
24
29
  /** Real Cordis service names this browser plugin waits for. */
@@ -57,6 +62,11 @@ interface ClientContext {
57
62
  kind: string
58
63
  keepMounted?: boolean
59
64
  title: (address: string) => string
65
+ /**
66
+ * Seed this kind into a fresh docked pane, i.e. make it the page the
67
+ * expand button opens. At most one registered type may declare it.
68
+ */
69
+ default?: boolean
60
70
  }): () => void
61
71
  }
62
72
  readonly configForms?: {
@@ -82,7 +92,7 @@ function nativeKindFor(destination: HardwareDestination, path: string): string {
82
92
 
83
93
  /** Install all product UI contributions on a DSH client context. */
84
94
  export function apply(ctx: ClientContext): void {
85
- // Root scope: product chrome (navigation + settings) shares one instance.
95
+ // Root scope: the settings section. The viewer owns the session scope below.
86
96
  const rootStore = createHardwareStore()
87
97
  // Session scope: each viewer owns its own selection/discovery state.
88
98
  const viewerStore = createHardwareStore()
@@ -101,10 +111,12 @@ export function apply(ctx: ClientContext): void {
101
111
  },
102
112
  async saveInstallation(application, root) {
103
113
  const form = ctx.configForms?.get<HardwareInstallationConfig>(HARDWARE_CONFIG_ENTRY)
104
- if (form === undefined) throw new Error('host settings are unavailable')
114
+ if (form === undefined) throw new Error(COPY.settings.hostSettingsUnavailable)
105
115
  const field = application === 'kicad' ? 'kicadRoot' : 'solidcraftRoot'
106
116
  const accepted = await form.set(field, root)
107
- if (!accepted) throw new Error(`the host rejected the ${field} setting`)
117
+ if (!accepted) {
118
+ throw new Error(COPY.settings.hostRejected(application === 'kicad' ? 'KiCad' : 'SolidCraft'))
119
+ }
108
120
  },
109
121
  configForm() {
110
122
  return ctx.configForms?.get<HardwareInstallationConfig>(HARDWARE_CONFIG_ENTRY)
@@ -136,18 +148,15 @@ export function apply(ctx: ClientContext): void {
136
148
  id: HARDWARE_TAB_ID,
137
149
  kind: HARDWARE_TAB_KIND,
138
150
  keepMounted: true,
139
- title: () => 'Hardware Engineering',
151
+ // The panel's default page: an expansion seeds this kind into the empty
152
+ // docked pane, replacing the product's general-purpose start page.
153
+ default: true,
154
+ title: () => COPY.product.name,
140
155
  }) ?? (() => {}), 'hardware-ui: right-panel tab type')
141
156
 
142
157
  const slots = ctx.slots
143
158
  if (slots === undefined) return
144
159
 
145
- effect(() => slots.inject('conversation.header.leading', () => slots.register({
146
- name: 'conversation.header.leading',
147
- store: rootStore,
148
- inject: () => controller,
149
- }, EngineeringNav)), 'hardware-ui: five-destination navigation')
150
-
151
160
  effect(() => slots.inject('sidebar.right.pane.tab', () => slots.register({
152
161
  name: 'sidebar.right.pane.tab',
153
162
  key: HARDWARE_TAB_ID,
@@ -159,7 +168,7 @@ export function apply(ctx: ClientContext): void {
159
168
  name: 'settings.section',
160
169
  id: HARDWARE_SETTINGS_ID,
161
170
  order: 85,
162
- label: () => 'Hardware Engineering',
171
+ label: () => COPY.product.name,
163
172
  store: rootStore,
164
173
  inject: () => controller,
165
174
  }, HardwareSettingsSection)), 'hardware-ui: CAD installation settings')
@@ -1,4 +1,5 @@
1
1
  /** Product-owned navigation and artifact identity. No shadow project database. */
2
+ import { COPY } from './copy.js'
2
3
 
3
4
  /** The five persistent product destinations. DFM and mechanical are out of scope. */
4
5
  export type HardwareDestination = 'schematic' | 'pcb' | 'bom' | '3d' | 'order'
@@ -16,12 +17,20 @@ export const DESTINATIONS: readonly HardwareDestination[] = Object.freeze([
16
17
  'schematic', 'pcb', 'bom', '3d', 'order',
17
18
  ])
18
19
 
20
+ /**
21
+ * Visible destination labels, in `DESTINATIONS` order.
22
+ *
23
+ * Read from the copy module rather than written here: the same strings are
24
+ * rendered from the navigation row and the viewer strip, and the two must never
25
+ * disagree. Keys stay in destination order because the navigation maps over
26
+ * `DESTINATIONS`, not over this object.
27
+ */
19
28
  export const DESTINATION_LABELS: Readonly<Record<HardwareDestination, string>> = Object.freeze({
20
- schematic: 'Schematic',
21
- pcb: 'PCB',
22
- bom: 'BOM',
23
- '3d': '3D CAD',
24
- order: 'Order Placing',
29
+ schematic: COPY.destinations.schematic,
30
+ pcb: COPY.destinations.pcb,
31
+ bom: COPY.destinations.bom,
32
+ '3d': COPY.destinations['3d'],
33
+ order: COPY.destinations.order,
25
34
  })
26
35
 
27
36
  /** Which native application a destination can open, if any. */