@huaqiu/dsh-hardware-ui 0.7.20 → 0.7.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huaqiu/dsh-hardware-ui",
3
- "version": "0.7.20",
3
+ "version": "0.7.22",
4
4
  "type": "module",
5
5
  "description": "Hardware Engineering product UI for DSH: five-destination engineering navigation, right-panel artifact viewer, CAD installation settings and contextual native-application actions.",
6
6
  "license": "MIT",
@@ -261,6 +261,8 @@ export function HardwareViewerBody(props: HardwareProps): ReactNode {
261
261
  const artifact = useStore(state => selectedArtifact(state, active))
262
262
  const missing = useStore(state => missingState(state, active))
263
263
  const workspaceRoot = useStore(state => state.workspaceRoot)
264
+ /** Operation the Place Order view picked, if this navigation came from it. */
265
+ const orderKind = params?.orderKind
264
266
  const cwd = useSessions?.(state => {
265
267
  if (sessionId === undefined) return undefined
266
268
  return state.byId[sessionId]?.cwd
@@ -425,6 +427,7 @@ export function HardwareViewerBody(props: HardwareProps): ReactNode {
425
427
  ...(sessionId === undefined ? {} : { session: sessionId }),
426
428
  revision: navRevision,
427
429
  configured: kicadConfigured,
430
+ ...(orderKind === undefined ? {} : { orderKind }),
428
431
  })]
429
432
  : [createElement('div', {
430
433
  key: 'missing',
@@ -261,22 +261,52 @@ export const COPY = {
261
261
  get copyUrl(): string { return translateCopy('order.copyUrl') },
262
262
  get copied(): string { return translateCopy('order.copied') },
263
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') },
264
+ /**
265
+ * The one-click contract, stated once where the click happens.
266
+ *
267
+ * There is no confirmation dialog: the button uploads, so the panel says
268
+ * that plainly instead of asking afterwards.
269
+ */
270
+ get uploadHint(): string { return translateCopy('order.uploadHint') },
277
271
 
278
272
  get batch(): string { return translateCopy('order.batch') },
279
273
  batchUnits: (count: number): string => translateCopy('order.batchUnits', { count }),
274
+
275
+ /**
276
+ * The project-selection view in front of this destination.
277
+ *
278
+ * It only chooses *what* to order; the package, the price, the token and the
279
+ * page stay where they already were, so this block is deliberately short.
280
+ */
281
+ placeOrder: {
282
+ get title(): string { return translateCopy('order.placeOrder.title') },
283
+ get lead(): string { return translateCopy('order.placeOrder.lead') },
284
+ get workspace(): string { return translateCopy('order.placeOrder.workspace') },
285
+ get workspaceUnknown(): string { return translateCopy('order.placeOrder.workspaceUnknown') },
286
+ get refresh(): string { return translateCopy('order.placeOrder.refresh') },
287
+ get refreshing(): string { return translateCopy('order.placeOrder.refreshing') },
288
+ get loading(): string { return translateCopy('order.placeOrder.loading') },
289
+ get noProjects(): string { return translateCopy('order.placeOrder.noProjects') },
290
+ get noProjectsHint(): string { return translateCopy('order.placeOrder.noProjectsHint') },
291
+ discoveryFailed: (detail: string): string =>
292
+ translateCopy('order.placeOrder.discoveryFailed', { detail }),
293
+ get colProject(): string { return translateCopy('order.placeOrder.colProject') },
294
+ get colArtifacts(): string { return translateCopy('order.placeOrder.colArtifacts') },
295
+ get colActions(): string { return translateCopy('order.placeOrder.colActions') },
296
+ get pcbAction(): string { return translateCopy('order.placeOrder.pcbAction') },
297
+ get pcbaAction(): string { return translateCopy('order.placeOrder.pcbaAction') },
298
+ boardCount: (count: number): string => translateCopy('order.placeOrder.boardCount', { count }),
299
+ get noSchematic(): string { return translateCopy('order.placeOrder.noSchematic') },
300
+ get noBoard(): string { return translateCopy('order.placeOrder.noBoard') },
301
+ get needsKicad(): string { return translateCopy('order.placeOrder.needsKicad') },
302
+ get kicadReady(): string { return translateCopy('order.placeOrder.kicadReady') },
303
+ /** Emitted while the readiness probes are still in flight, never as a claim. */
304
+ get checking(): string { return translateCopy('order.placeOrder.checking') },
305
+ get needsSignIn(): string { return translateCopy('order.placeOrder.needsSignIn') },
306
+ get signInReady(): string { return translateCopy('order.placeOrder.signInReady') },
307
+ get selectedProject(): string { return translateCopy('order.placeOrder.selectedProject') },
308
+ get multipleProjects(): string { return translateCopy('order.placeOrder.multipleProjects') },
309
+ },
280
310
  quoteBasis: (count: number): string => translateCopy('order.quoteBasis', { count }),
281
311
  },
282
312
 
@@ -18,6 +18,7 @@
18
18
  * scope").
19
19
  */
20
20
  import { HardwareSettingsSection, HardwareViewerBody } from './components.js'
21
+ import { PlaceOrderBody } from './place-order.js'
21
22
  import { ToolchainIndicator, ToolchainToastHost } from './toolchain-view.js'
22
23
  import { TOOLCHAIN_ONBOARDING_STEP, ToolchainOnboarding } from './wizard.js'
23
24
  import { ToolchainController } from './toolchain.js'
@@ -41,9 +42,28 @@ export const inject = ['slots', 'locale', 'sidebarRight', 'sidebarRightTabs', 'c
41
42
  export const HARDWARE_SETTINGS_ID = 'hardware-engineering'
42
43
  export const HARDWARE_TAB_ID = '@huaqiu/dsh-hardware-ui'
43
44
  export const HARDWARE_TAB_KIND = 'hardware-engineering'
45
+ /** The project-selection view that fronts the order destination. */
46
+ export const PLACE_ORDER_TAB_ID = '@huaqiu/dsh-hardware-ui/place-order'
47
+ export const PLACE_ORDER_TAB_KIND = 'hardware-place-order'
44
48
  /** Host plugin row id whose volatile config backs the product settings page. */
45
49
  export const HARDWARE_CONFIG_ENTRY = 'hardware-artifacts'
46
50
 
51
+ declare global {
52
+ interface Window {
53
+ /**
54
+ * Desktop's preload surface, reached through `contextBridge` (PO-02).
55
+ *
56
+ * Only the member this plugin needs is declared: Desktop windows run with
57
+ * `contextIsolation: true`, so the plugin cannot publish a callback by
58
+ * assigning a window global — it must hand the callback to preload, which
59
+ * the caption menu then runs.
60
+ */
61
+ dshDesktop?: {
62
+ registerPlaceOrder?: (handler: () => boolean) => () => void
63
+ }
64
+ }
65
+ }
66
+
47
67
  interface SlotSpec {
48
68
  name: string
49
69
  id?: string
@@ -205,6 +225,35 @@ export function apply(ctx: ClientContext): void {
205
225
  revealIfOpened: true,
206
226
  })
207
227
  },
228
+ // One tab, not one per click: a menu that is pressed twice must reveal what
229
+ // the first press opened rather than stack two project lists.
230
+ placeOrder() {
231
+ const tabs = ctx.sidebarRight
232
+ if (tabs === undefined) return false
233
+ tabs.openTab(PLACE_ORDER_TAB_KIND, { revealIfOpened: true })
234
+ return true
235
+ },
236
+ /**
237
+ * Hand the chosen project to the existing order destination. The path and
238
+ * the project travel in the navigation params, so the viewer discovers that
239
+ * project and the order panel packages the board — no second packaging path.
240
+ */
241
+ orderProject(request) {
242
+ navigation += 1
243
+ const params: ViewerNavigationParams = {
244
+ destination: 'order',
245
+ path: request.boardPath,
246
+ kind: 'pcb',
247
+ projectPath: request.projectPath,
248
+ ...(request.schematicPath === undefined ? {} : { schematicPath: request.schematicPath }),
249
+ orderKind: request.kind,
250
+ navigationRevision: navigation,
251
+ }
252
+ ctx.sidebarRight?.openTab(HARDWARE_TAB_KIND, {
253
+ params: params as unknown as Readonly<Record<string, unknown>>,
254
+ revealIfOpened: true,
255
+ })
256
+ },
208
257
  async openNative(request) {
209
258
  await openArtifact({
210
259
  application: request.application,
@@ -239,6 +288,26 @@ export function apply(ctx: ClientContext): void {
239
288
  title: () => COPY.product.name,
240
289
  }) ?? (() => {}), 'hardware-ui: right-panel tab type')
241
290
 
291
+ // The Place Order view is its own tab: reachable with no engineering document
292
+ // open, and a single instance so a second menu click only brings it forward.
293
+ effect(() => ctx.sidebarRightTabs?.register({
294
+ id: PLACE_ORDER_TAB_ID,
295
+ kind: PLACE_ORDER_TAB_KIND,
296
+ title: () => COPY.order.placeOrder.title,
297
+ }) ?? (() => {}), 'hardware-ui: place order tab type')
298
+
299
+ // The desktop shell's Place Order menu (PO-02) needs one thing from this
300
+ // plugin: a way to ask for the workflow. Desktop preload owns the registry
301
+ // (`dshDesktop.registerPlaceOrder`) and the caption entry runs whatever is
302
+ // registered, so the menu never reaches into business logic. Leaving the
303
+ // registration behind when the plugin unloads keeps "not loaded" honest.
304
+ if (typeof window !== 'undefined') {
305
+ effect(() => {
306
+ const unregister = window.dshDesktop?.registerPlaceOrder?.(() => controller.placeOrder())
307
+ return () => { unregister?.() }
308
+ }, 'hardware-ui: place order handle')
309
+ }
310
+
242
311
  const slots = ctx.slots
243
312
  if (slots === undefined) return
244
313
 
@@ -255,6 +324,18 @@ export function apply(ctx: ClientContext): void {
255
324
  OrderTabBody,
256
325
  )), 'hardware-ui: order page body')
257
326
 
327
+ // Project selection for the Place Order workflow: same panel seat, its own tab.
328
+ effect(() => slots.inject('sidebar.right.pane.tab', () => slots.register({
329
+ name: 'sidebar.right.pane.tab',
330
+ key: PLACE_ORDER_TAB_ID,
331
+ locale: HARDWARE_UI_NS,
332
+ inject: () => ({
333
+ discover: controller.discover,
334
+ installations: controller.installations,
335
+ orderProject: controller.orderProject,
336
+ }),
337
+ }, PlaceOrderBody)), 'hardware-ui: place order body')
338
+
258
339
  effect(() => slots.inject('settings.section', () => slots.register({
259
340
  name: 'settings.section',
260
341
  id: HARDWARE_SETTINGS_ID,
@@ -142,21 +142,35 @@ export const zh = {
142
142
  'order.opening': '正在打开…',
143
143
  'order.copyUrl': '复制链接',
144
144
  'order.copied': '已复制',
145
- 'order.confirmAria': '确认下单上传',
146
- 'order.confirmTitlePcb': '上传板文件并创建 PCB 订单?',
147
- 'order.confirmTitleSmt': '上传贴片文件包?',
148
- 'order.confirmBody': '以下文件将发送到华秋下单服务。订单在那里创建,其页面会在右侧面板中打开;付款仍在该页面完成。',
149
- 'order.confirmZip': '{zip} — Gerber 与钻孔文件({size})',
150
- 'order.confirmPositions': '元件坐标({size})',
151
- 'order.confirmBom': '贴片 BOM({size})',
152
- 'order.confirmHostFallback': '已配置的下单服务',
153
- 'order.confirmAck': '我了解这些板文件将离开本机。',
154
- 'order.cancel': '取消',
155
- 'order.uploadAndOpen': '上传并打开订单页',
156
- 'order.uploading': '正在上传…',
145
+ 'order.uploadHint': '点击「提交订单」即上传上面列出的文件到华秋并创建订单,订单页随后在右侧页签打开;付款在华秋页面完成。',
157
146
  'order.batch': '生产数量',
158
147
  'order.batchUnits': '{count} 片',
159
148
  'order.quoteBasis': '报价基准 · {count} 片',
149
+ 'order.placeOrder.title': '下单',
150
+ 'order.placeOrder.lead': '从当前工作目录中选择一个 KiCad 工程,直接进入 PCB 或 PCBA 下单流程。',
151
+ 'order.placeOrder.workspace': '工作目录',
152
+ 'order.placeOrder.workspaceUnknown': '尚未确定工作目录',
153
+ 'order.placeOrder.refresh': '重新扫描',
154
+ 'order.placeOrder.refreshing': '正在扫描…',
155
+ 'order.placeOrder.loading': '正在扫描工作目录中的 KiCad 工程…',
156
+ 'order.placeOrder.noProjects': '这个工作目录里没有找到 KiCad 工程',
157
+ 'order.placeOrder.noProjectsHint': '工程需要包含 .kicad_pro 文件。保存工程后点「重新扫描」。',
158
+ 'order.placeOrder.discoveryFailed': '工程扫描失败:{detail}',
159
+ 'order.placeOrder.colProject': '工程',
160
+ 'order.placeOrder.colArtifacts': '工程文件',
161
+ 'order.placeOrder.colActions': '下单',
162
+ 'order.placeOrder.pcbAction': '下 PCB',
163
+ 'order.placeOrder.pcbaAction': '下 PCBA',
164
+ 'order.placeOrder.boardCount': '{count} 个 PCB',
165
+ 'order.placeOrder.noSchematic': '缺少工程原理图,无法生成贴片 BOM 与坐标',
166
+ 'order.placeOrder.noBoard': '缺少 .kicad_pcb,无法打包制板文件',
167
+ 'order.placeOrder.needsKicad': '未配置 KiCad,无法打包 Gerber',
168
+ 'order.placeOrder.kicadReady': 'KiCad 已就绪',
169
+ 'order.placeOrder.checking': '检测中…',
170
+ 'order.placeOrder.needsSignIn': '未登录华秋账号,订单页将无法带登录态打开',
171
+ 'order.placeOrder.signInReady': '已登录华秋',
172
+ 'order.placeOrder.selectedProject': '当前工程',
173
+ 'order.placeOrder.multipleProjects': '{count} 个工程',
160
174
 
161
175
  // First-run setup wizard.
162
176
 
@@ -192,7 +206,7 @@ export const zh = {
192
206
  'errors.stale-revision': '文件已变化,请刷新后重试。',
193
207
  'errors.invalid-request': '请求参数不完整。',
194
208
  'errors.invalid-application': '不支持该本地程序。',
195
- 'errors.confirmation-required': '下单需要先在上传确认框中确认。',
209
+ 'errors.confirmation-required': '下单请求缺少确认标志,已被拒绝。',
196
210
  'errors.invalid-order-url': '订单链接无效,已拒绝打开。',
197
211
  'errors.order-unreachable': '无法连接下单服务。',
198
212
  'errors.order-rejected': '下单服务未能返回可用的订单页。',
@@ -441,21 +455,35 @@ export const en: Record<HardwareCopyKey, string> = {
441
455
  'order.opening': 'Opening…',
442
456
  'order.copyUrl': 'Copy link',
443
457
  'order.copied': 'Copied',
444
- 'order.confirmAria': 'Confirm order upload',
445
- 'order.confirmTitlePcb': 'Upload board files and create a PCB order?',
446
- 'order.confirmTitleSmt': 'Upload the assembly package?',
447
- 'order.confirmBody': 'The following files will be sent to the Huaqiu ordering service. The order is created there and its page opens in the right panel; payment is completed on that page.',
448
- 'order.confirmZip': '{zip} — Gerber and drill files ({size})',
449
- 'order.confirmPositions': 'Component positions ({size})',
450
- 'order.confirmBom': 'Assembly BOM ({size})',
451
- 'order.confirmHostFallback': 'the configured ordering service',
452
- 'order.confirmAck': 'I understand these board files will leave this machine.',
453
- 'order.cancel': 'Cancel',
454
- 'order.uploadAndOpen': 'Upload and open order page',
455
- 'order.uploading': 'Uploading…',
458
+ 'order.uploadHint': 'Clicking the order button uploads the files listed above to Huaqiu and creates the order; the order page then opens in a tab on the right, where payment is completed.',
456
459
  'order.batch': 'Quantity',
457
460
  'order.batchUnits': '{count} boards',
458
461
  'order.quoteBasis': 'Quote basis · {count} boards',
462
+ 'order.placeOrder.title': 'Place Order',
463
+ 'order.placeOrder.lead': 'Pick one KiCad project from the current workspace and go straight to a PCB or PCBA order.',
464
+ 'order.placeOrder.workspace': 'Workspace',
465
+ 'order.placeOrder.workspaceUnknown': 'No workspace resolved yet',
466
+ 'order.placeOrder.refresh': 'Scan again',
467
+ 'order.placeOrder.refreshing': 'Scanning...',
468
+ 'order.placeOrder.loading': 'Scanning the workspace for KiCad projects...',
469
+ 'order.placeOrder.noProjects': 'No KiCad project in this workspace',
470
+ 'order.placeOrder.noProjectsHint': 'A project needs a .kicad_pro file. Save it, then scan again.',
471
+ 'order.placeOrder.discoveryFailed': 'Project scan failed: {detail}',
472
+ 'order.placeOrder.colProject': 'Project',
473
+ 'order.placeOrder.colArtifacts': 'Files',
474
+ 'order.placeOrder.colActions': 'Order',
475
+ 'order.placeOrder.pcbAction': 'Order PCB',
476
+ 'order.placeOrder.pcbaAction': 'Order PCBA',
477
+ 'order.placeOrder.boardCount': '{count} PCB',
478
+ 'order.placeOrder.noSchematic': 'No project schematic, so no positions or assembly BOM',
479
+ 'order.placeOrder.noBoard': 'No .kicad_pcb, so no fabrication package',
480
+ 'order.placeOrder.needsKicad': 'KiCad is not configured, so Gerbers cannot be packaged',
481
+ 'order.placeOrder.kicadReady': 'KiCad ready',
482
+ 'order.placeOrder.checking': 'Checking…',
483
+ 'order.placeOrder.needsSignIn': 'Not signed in to Huaqiu, so the order page cannot open signed in',
484
+ 'order.placeOrder.signInReady': 'Signed in to Huaqiu',
485
+ 'order.placeOrder.selectedProject': 'Current project',
486
+ 'order.placeOrder.multipleProjects': '{count} projects',
459
487
 
460
488
 
461
489
  'settings.title': 'Hardware Engineering',
@@ -488,7 +516,7 @@ export const en: Record<HardwareCopyKey, string> = {
488
516
  'errors.stale-revision': 'The file changed; refresh and try again.',
489
517
  'errors.invalid-request': 'The request parameters are incomplete.',
490
518
  'errors.invalid-application': 'This local application is not supported.',
491
- 'errors.confirmation-required': 'Confirm the upload dialog before placing an order.',
519
+ 'errors.confirmation-required': 'The order request carried no confirmation flag, so it was refused.',
492
520
  'errors.invalid-order-url': 'The order link is invalid and was refused.',
493
521
  'errors.order-unreachable': 'Could not connect to the ordering service.',
494
522
  'errors.order-rejected': 'The ordering service did not return a usable order page.',
@@ -61,6 +61,11 @@ export interface HardwareProjectInfo {
61
61
  readonly boards?: readonly HardwareArtifactInfo[]
62
62
  readonly defaultBoard?: string
63
63
  readonly selectionRequired?: boolean
64
+ /** Static order readiness the Host derives from the project's own files. */
65
+ readonly order?: {
66
+ readonly pcb: { readonly ready: boolean; readonly reason?: string }
67
+ readonly pcba: { readonly ready: boolean; readonly reason?: string }
68
+ }
64
69
  }
65
70
 
66
71
  export interface InstallationsInfo {
@@ -146,6 +151,22 @@ export interface ViewerNavigationParams {
146
151
  /** Source revision of the artifact at navigation time, when known. */
147
152
  readonly revision?: string
148
153
  readonly projectPath?: string
154
+ /**
155
+ * The manufacturing operation the user picked in the Place Order view.
156
+ *
157
+ * The order destination serves both; this only decides which workflow card's
158
+ * confirmation opens first, so the choice between PCB and PCBA is carried
159
+ * instead of being lost on the way.
160
+ */
161
+ readonly orderKind?: 'pcb' | 'smt'
162
+ /**
163
+ * Root schematic of the project being ordered.
164
+ *
165
+ * Discovery also assigns a unique schematic from the scanned tree, so a tab
166
+ * that already had another project selected would otherwise package the new
167
+ * board's PCBA with the old project's BOM and positions.
168
+ */
169
+ readonly schematicPath?: string
149
170
  /** Monotonic navigation counter: increments even when params are unchanged. */
150
171
  readonly navigationRevision: number
151
172
  }
@@ -175,6 +196,25 @@ export interface HardwareController {
175
196
  configForm(): ConfigFormLike<HardwareInstallationConfig> | undefined
176
197
  /** Open or retarget the product viewer tab. */
177
198
  openDestination(destination: HardwareDestination, path?: string): void
199
+ /**
200
+ * Open the plugin-owned Place Order view (project selection) in the panel.
201
+ *
202
+ * Idempotent by design: the view is one tab, so a second click from the
203
+ * desktop menu reveals the tab that is already there instead of opening a
204
+ * second copy. Returns whether a panel was asked to open it.
205
+ */
206
+ placeOrder(): boolean
207
+ /**
208
+ * Send one discovered project to the order destination, carrying the
209
+ * operation the user picked there.
210
+ */
211
+ orderProject(request: {
212
+ readonly projectPath: string
213
+ readonly boardPath: string
214
+ /** The project's root schematic, so PCBA orders this project, not the last one. */
215
+ readonly schematicPath?: string
216
+ readonly kind: 'pcb' | 'smt'
217
+ }): void
178
218
  /** Launch the exact artifact in its configured native application. */
179
219
  openNative(request: {
180
220
  application: NativeApplication