@huaqiu/dsh-hardware-ui 0.7.15 → 0.7.17

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 CHANGED
@@ -28,13 +28,39 @@ window.__ModuleLoader__.load({
28
28
  openInKicadTitle: (path) => `在 KiCad 中打开 ${path}`,
29
29
  selectArtifactFirst: "请先选择一个产物",
30
30
  configureKicad: "请在「设置 → 硬件工程」中配置 KiCad",
31
- nothingToShow: "暂无可显示内容",
32
31
  selectProject: "选择工程…",
33
32
  projectField: "工程",
34
33
  schematicSheetField: "原理图页",
35
34
  boardField: "板文件"
36
35
  },
37
36
  /**
37
+ * Empty viewers. A placeholder names what is missing and then says how to get
38
+ * it: the agent creates hardware, so the copy points there instead of stopping
39
+ * at "not available". BOM is the one destination nobody creates directly — it
40
+ * follows the schematic.
41
+ */
42
+ placeholder: {
43
+ title: {
44
+ schematic: "暂无原理图",
45
+ pcb: "暂无 PCB",
46
+ bom: "暂无 BOM",
47
+ "3d": "暂无 3D 模型",
48
+ order: "暂无可下单的板"
49
+ },
50
+ /** One sentence: what the agent can create for this destination. */
51
+ guide: {
52
+ schematic: "可以让智能体在当前工程中创建原理图(.kicad_sch),创建后会直接在这里显示。",
53
+ pcb: "可以让智能体创建 PCB 并完成布局(.kicad_pcb),保存后会直接在这里显示。",
54
+ bom: "BOM 由原理图自动生成:让智能体先创建原理图,BOM 会自动更新。",
55
+ "3d": "3D 模型由 PCB 生成:让智能体创建 PCB 后,这里会自动出现三维预览。",
56
+ order: "制板与贴片都需要 PCB:让智能体创建 PCB 后即可在这里报价下单。"
57
+ },
58
+ /** Shown instead of a destination guide when no project was discovered. */
59
+ noProject: "可以让智能体在当前工作区创建 KiCad 工程(.kicad_pro),工程出现后这里会自动刷新。",
60
+ /** The ask, phrased so the user can paste it into the conversation. */
61
+ askAgent: "对智能体说:「为当前工程创建原理图」/「创建 PCB」/「导出 3D 模型」即可。"
62
+ },
63
+ /**
38
64
  * Discovery outcomes. These are the panel's OWN sentences for a host state —
39
65
  * the host also sends a `message`, but re-deriving it here keeps the copy in
40
66
  * one place and lets the count/cwd be woven in. {@link issueText} bridges the
@@ -54,7 +80,6 @@ window.__ModuleLoader__.load({
54
80
  /** schematic / pcb / 3d / bom stages. */
55
81
  preview: {
56
82
  loading: "正在加载已保存的产物…",
57
- unavailable: "不可用",
58
83
  kindSchematic: "原理图",
59
84
  kindBoard: "PCB",
60
85
  revision: (revision) => `版本 ${revision}`,
@@ -144348,6 +144373,9 @@ void main() {
144348
144373
  flexDirection: "column",
144349
144374
  alignItems: "center",
144350
144375
  justifyContent: "center",
144376
+ flex: "1 1 auto",
144377
+ width: "100%",
144378
+ boxSizing: "border-box",
144351
144379
  height: "100%",
144352
144380
  gap: 6,
144353
144381
  padding: 20,
@@ -144388,8 +144416,16 @@ void main() {
144388
144416
  function shortRevision(revision) {
144389
144417
  return revision === void 0 ? "" : revision.slice(0, 10);
144390
144418
  }
144391
- function statusLine(status, message, hint) {
144392
- const text = message ?? (status === "loading" ? COPY.preview.loading : "");
144419
+ /**
144420
+ * The stage's placeholder: what is missing, why, and what to do about it.
144421
+ *
144422
+ * Every variant is one centred column, so an empty schematic, an empty BOM and a
144423
+ * failed export sit in the same place. A placeholder never stops at "not
144424
+ * available": the last line always says how the artifact can exist — normally by
144425
+ * asking the agent to create it.
144426
+ */
144427
+ function statusLine(status, input) {
144428
+ const text = input.message ?? (status === "loading" ? COPY.preview.loading : "");
144393
144429
  return (0, react.createElement)("div", {
144394
144430
  style: CENTER,
144395
144431
  role: "status",
@@ -144404,11 +144440,17 @@ void main() {
144404
144440
  } }) : (0, react.createElement)("span", { style: {
144405
144441
  ...pillStyle("warn"),
144406
144442
  fontFamily: MONO
144407
- } }, COPY.preview.unavailable), (0, react.createElement)("p", { style: CENTER_TEXT }, text), hint === void 0 ? null : (0, react.createElement)("p", { style: {
144443
+ } }, input.title), text === "" ? null : (0, react.createElement)("p", { style: CENTER_TEXT }, text), input.hint === void 0 ? null : (0, react.createElement)("p", { style: {
144408
144444
  ...CENTER_TEXT,
144409
- fontSize: 10,
144410
- color: C.text3
144411
- } }, hint));
144445
+ fontSize: 10
144446
+ } }, input.hint), input.guidance === void 0 ? null : (0, react.createElement)("p", {
144447
+ style: {
144448
+ ...CENTER_TEXT,
144449
+ fontSize: 10.5,
144450
+ color: C.text2
144451
+ },
144452
+ "data-hardware-guidance": true
144453
+ }, input.guidance));
144412
144454
  }
144413
144455
  function Stage(props) {
144414
144456
  return (0, react.createElement)("div", {
@@ -144489,7 +144531,14 @@ void main() {
144489
144531
  position: "relative",
144490
144532
  flex: "1 1 0",
144491
144533
  minHeight: 160
144492
- } }, ...status === "ready" ? [] : [statusLine(status, message, status === "error" ? COPY.preview.ecadHint : void 0)], (0, react.createElement)("div", {
144534
+ } }, ...status === "ready" ? [] : [statusLine(status, {
144535
+ title: COPY.placeholder.title[kind],
144536
+ ...message === void 0 ? {} : { message },
144537
+ ...status === "error" ? {
144538
+ hint: COPY.preview.ecadHint,
144539
+ guidance: COPY.placeholder.guide[kind]
144540
+ } : {}
144541
+ })], (0, react.createElement)("div", {
144493
144542
  key: "canvas",
144494
144543
  ref: container,
144495
144544
  style: {
@@ -144564,7 +144613,11 @@ void main() {
144564
144613
  position: "relative",
144565
144614
  flex: "1 1 0",
144566
144615
  minHeight: 160
144567
- } }, ...status === "ready" ? [] : [statusLine(status, message)], (0, react.createElement)("div", {
144616
+ } }, ...status === "ready" ? [] : [statusLine(status, {
144617
+ title: COPY.placeholder.title["3d"],
144618
+ ...message === void 0 ? {} : { message },
144619
+ ...status === "error" && configured ? { guidance: COPY.placeholder.guide["3d"] } : {}
144620
+ })], (0, react.createElement)("div", {
144568
144621
  key: "canvas",
144569
144622
  ref: container,
144570
144623
  style: {
@@ -144622,8 +144675,14 @@ void main() {
144622
144675
  overlay: "kicad-cli sch export bom"
144623
144676
  }, (0, react.createElement)("div", { style: {
144624
144677
  flex: "1 1 0",
144678
+ minWidth: 0,
144625
144679
  display: "flex"
144626
- } }, statusLine(status, message, status === "error" && !configured ? COPY.preview.bomHint : void 0)));
144680
+ } }, statusLine(status, {
144681
+ title: COPY.placeholder.title.bom,
144682
+ ...message === void 0 ? {} : { message },
144683
+ ...status === "error" && !configured ? { hint: COPY.preview.bomHint } : {},
144684
+ ...status === "error" && configured ? { guidance: COPY.placeholder.guide.bom } : {}
144685
+ })));
144627
144686
  const total = bom.rows.reduce((sum, row) => sum + row.quantity, 0);
144628
144687
  return (0, react.createElement)("div", {
144629
144688
  style: cardStyle({
@@ -145031,15 +145090,6 @@ void main() {
145031
145090
  flexWrap: "wrap",
145032
145091
  minWidth: 0
145033
145092
  };
145034
- const NAV = {
145035
- display: "flex",
145036
- alignItems: "center",
145037
- gap: 3,
145038
- minWidth: 0,
145039
- fontSize: 12,
145040
- position: "relative",
145041
- flexWrap: "nowrap"
145042
- };
145043
145093
  const NAV_ITEM = {
145044
145094
  display: "inline-flex",
145045
145095
  alignItems: "center",
@@ -145062,20 +145112,6 @@ void main() {
145062
145112
  background: C.card,
145063
145113
  border: `1px solid ${C.border}`
145064
145114
  };
145065
- `${C.border}`;
145066
- R.sm, C.accent;
145067
- C.text;
145068
- const CHIP = {
145069
- minWidth: 0,
145070
- maxWidth: 168,
145071
- overflow: "hidden",
145072
- textOverflow: "ellipsis",
145073
- whiteSpace: "nowrap",
145074
- color: C.text3,
145075
- fontSize: 10,
145076
- fontFamily: MONO,
145077
- flex: "0 1 auto"
145078
- };
145079
145115
  const PANEL_ROOT = {
145080
145116
  display: "flex",
145081
145117
  flexDirection: "column",
@@ -145086,12 +145122,22 @@ void main() {
145086
145122
  background: C.base,
145087
145123
  color: C.text
145088
145124
  };
145089
- const STRIP = {
145125
+ /**
145126
+ * The panel's top edge.
145127
+ *
145128
+ * The tab strip that used to sit here is gone: this page's destination switches
145129
+ * ARE the panel's header. The right padding is the room the host lays its two
145130
+ * panel controls (full screen, collapse) over — both rows are 38px, so the
145131
+ * buttons centre on this row's centre line.
145132
+ */
145133
+ const HEADER = {
145090
145134
  display: "flex",
145091
145135
  alignItems: "center",
145092
145136
  justifyContent: "space-between",
145093
145137
  gap: 6,
145094
- padding: "5px 8px",
145138
+ height: 38,
145139
+ boxSizing: "border-box",
145140
+ padding: "0 76px 0 10px",
145095
145141
  background: C.panel,
145096
145142
  borderBottom: `1px solid ${C.border}`,
145097
145143
  flex: "0 0 auto",
@@ -145151,61 +145197,6 @@ void main() {
145151
145197
  if (!DESTINATIONS.includes(params.destination)) return void 0;
145152
145198
  return params;
145153
145199
  }
145154
- /**
145155
- * One product navigation row: brand, the five persistent destinations, and the
145156
- * selected project. The first-run wizard renders from this root-scope seat
145157
- * because it must be able to run before any session exists.
145158
- */
145159
- function EngineeringNav(props) {
145160
- const { useStore, actions, useSessions, discover, openDestination } = props;
145161
- const active = useStore((state) => state.activeDestination);
145162
- const projectPath = useStore((state) => state.projectPath);
145163
- const selected = useStore((state) => state.discovery?.selected);
145164
- const sessionId = useSessions?.((state) => state.ids[0]);
145165
- const cwd = useSessions?.((state) => {
145166
- const id = state.ids[0];
145167
- return id === void 0 ? void 0 : state.byId[id]?.cwd;
145168
- });
145169
- (0, react.useEffect)(() => {
145170
- let live = true;
145171
- discover(cwd, void 0, sessionId).then((discovery) => {
145172
- if (live) actions.setDiscovery(discovery);
145173
- }).catch((error) => {
145174
- if (live) actions.setNotice(COPY.viewer.discoveryFailed(messageOf(error)));
145175
- });
145176
- return () => {
145177
- live = false;
145178
- };
145179
- }, [
145180
- cwd,
145181
- sessionId,
145182
- discover,
145183
- actions
145184
- ]);
145185
- const projectName = selected?.name ?? (projectPath === void 0 ? void 0 : basename(projectPath));
145186
- return (0, react.createElement)("div", {
145187
- style: NAV,
145188
- "data-hardware-nav": true
145189
- }, ...DESTINATIONS.map((destination) => (0, react.createElement)("button", {
145190
- key: destination,
145191
- type: "button",
145192
- style: destination === active ? NAV_ITEM_ACTIVE : NAV_ITEM,
145193
- "aria-pressed": destination === active,
145194
- "data-destination": destination,
145195
- title: DESTINATION_LABELS[destination],
145196
- onClick: () => {
145197
- actions.setActive(destination);
145198
- openDestination(destination);
145199
- }
145200
- }, (0, react.createElement)("span", { style: dotStyle(DOT_COLORS[destination], 6) }), DESTINATION_LABELS[destination])), ...projectName === void 0 ? [] : [(0, react.createElement)("span", {
145201
- key: "project",
145202
- style: {
145203
- ...CHIP,
145204
- paddingLeft: 4
145205
- },
145206
- title: projectPath ?? projectName
145207
- }, projectName)], (0, react.createElement)(OnboardingWizard, props));
145208
- }
145209
145200
  /** The artifact a destination previews, with its canonical identity. */
145210
145201
  function selectedArtifact(state, destination) {
145211
145202
  const project = state.discovery?.selected;
@@ -145224,19 +145215,46 @@ void main() {
145224
145215
  if (destination === "schematic" || destination === "bom") return schematic;
145225
145216
  return board;
145226
145217
  }
145227
- function missingReason(state, destination) {
145218
+ /**
145219
+ * Resolve the placeholder for one destination, or `undefined` while there is
145220
+ * nothing to say (no discovery yet, or an artifact to render).
145221
+ *
145222
+ * The guidance points at the agent: this product's hardware is authored in the
145223
+ * conversation, so "暂无原理图" alone leaves the user with no next step.
145224
+ */
145225
+ function missingState(state, destination) {
145228
145226
  const discovery = state.discovery;
145229
145227
  if (discovery === void 0) return void 0;
145230
- if (discovery.issue?.code === "selection-required" && (discovery.projects?.length ?? 0) > 1) return COPY.discovery.selectionRequiredCount(discovery.projects?.length ?? 0);
145231
- if (discovery.selected === void 0) return COPY.discovery.noProjectSelected;
145228
+ const title = COPY.placeholder.title[destination];
145229
+ if (discovery.issue?.code === "selection-required" && (discovery.projects?.length ?? 0) > 1) return {
145230
+ title,
145231
+ reason: COPY.discovery.selectionRequiredCount(discovery.projects?.length ?? 0)
145232
+ };
145233
+ if (discovery.selected === void 0) return {
145234
+ title,
145235
+ reason: COPY.discovery.noProjectSelected,
145236
+ guidance: COPY.placeholder.noProject
145237
+ };
145232
145238
  if (destination === "schematic" || destination === "bom") {
145233
- if (discovery.selected.schematic === void 0) return COPY.discovery.noSchematic;
145239
+ if (discovery.selected.schematic === void 0) return {
145240
+ title,
145241
+ reason: COPY.discovery.noSchematic,
145242
+ guidance: COPY.placeholder.guide[destination]
145243
+ };
145234
145244
  }
145235
145245
  if (destination === "pcb" || destination === "3d") {
145236
- if ((discovery.selected.boards?.length ?? 0) === 0) return COPY.discovery.noBoard;
145246
+ if ((discovery.selected.boards?.length ?? 0) === 0) return {
145247
+ title,
145248
+ reason: COPY.discovery.noBoard,
145249
+ guidance: COPY.placeholder.guide[destination]
145250
+ };
145237
145251
  }
145238
145252
  if (destination === "order") {
145239
- if ((discovery.selected.boards?.length ?? 0) === 0) return COPY.discovery.noBoardToOrder;
145253
+ if ((discovery.selected.boards?.length ?? 0) === 0) return {
145254
+ title,
145255
+ reason: COPY.discovery.noBoardToOrder,
145256
+ guidance: COPY.placeholder.guide.order
145257
+ };
145240
145258
  }
145241
145259
  }
145242
145260
  /** Native-open affordance for the artifact currently on screen. */
@@ -145290,7 +145308,7 @@ void main() {
145290
145308
  const noticeText = useStore((state) => state.notice);
145291
145309
  const installed = useStore((state) => state.installations);
145292
145310
  const artifact = useStore((state) => selectedArtifact(state, active));
145293
- const reason = useStore((state) => missingReason(state, active));
145311
+ const missing = useStore((state) => missingState(state, active));
145294
145312
  const workspaceRoot = useStore((state) => state.workspaceRoot);
145295
145313
  const cwd = useSessions?.((state) => {
145296
145314
  if (sessionId === void 0) return void 0;
@@ -145340,8 +145358,9 @@ void main() {
145340
145358
  actions.setActive(destination);
145341
145359
  openDestination(destination, destination === "schematic" || destination === "bom" ? schematicPath : pcbPath);
145342
145360
  };
145343
- const strip = (0, react.createElement)("div", {
145344
- style: STRIP,
145361
+ const header = (0, react.createElement)("div", {
145362
+ style: HEADER,
145363
+ "data-hardware-header": true,
145345
145364
  "data-hardware-destinations": true
145346
145365
  }, (0, react.createElement)("div", { style: STRIP_GROUP }, ...DESTINATIONS.map((destination) => (0, react.createElement)("button", {
145347
145366
  key: destination,
@@ -145354,6 +145373,8 @@ void main() {
145354
145373
  fontSize: 11
145355
145374
  },
145356
145375
  "aria-pressed": destination === active,
145376
+ "data-destination": destination,
145377
+ title: DESTINATION_LABELS[destination],
145357
145378
  onClick: () => {
145358
145379
  go(destination);
145359
145380
  }
@@ -145445,10 +145466,10 @@ void main() {
145445
145466
  return (0, react.createElement)("div", {
145446
145467
  style: PANEL_ROOT,
145447
145468
  "data-hardware-destination": active
145448
- }, (0, react.createElement)("style", null, PANEL_STYLE), strip, meta, selectors.length === 0 && noticeText === void 0 && (discovery?.issue === void 0 || discovery.issue.code === "selection-required") ? null : (0, react.createElement)("div", { style: { padding: "6px 10px 0" } }, banner), (0, react.createElement)("div", { style: {
145469
+ }, (0, react.createElement)("style", null, PANEL_STYLE), header, meta, selectors.length === 0 && noticeText === void 0 && (discovery?.issue === void 0 || discovery.issue.code === "selection-required") ? null : (0, react.createElement)("div", { style: { padding: "6px 10px 0" } }, banner), (0, react.createElement)("div", { style: {
145449
145470
  ...BODY,
145450
145471
  overflow: active === "order" || active === "bom" ? "auto" : "hidden"
145451
- } }, ...reason === void 0 ? [(0, react.createElement)(HardwarePreview, {
145472
+ } }, ...missing === void 0 ? [(0, react.createElement)(HardwarePreview, {
145452
145473
  key: `preview:${info.tab.id}:${String(navRevision)}:${active}:${artifact?.path ?? ""}`,
145453
145474
  destination: active,
145454
145475
  artifact,
@@ -145458,22 +145479,35 @@ void main() {
145458
145479
  revision: navRevision,
145459
145480
  configured: kicadConfigured
145460
145481
  })] : [(0, react.createElement)("div", {
145461
- key: "reason",
145482
+ key: "missing",
145462
145483
  style: cardStyle({
145463
145484
  alignItems: "center",
145464
145485
  justifyContent: "center",
145465
145486
  flex: "1 1 0",
145466
- gap: 6
145487
+ gap: 6,
145488
+ padding: 20
145467
145489
  }),
145468
145490
  "data-hardware-state": "missing"
145469
- }, (0, react.createElement)("span", { style: pillStyle("warn") }, COPY.viewer.nothingToShow), (0, react.createElement)("p", {
145491
+ }, (0, react.createElement)("span", { style: pillStyle("warn") }, missing.title), (0, react.createElement)("p", {
145470
145492
  role: "status",
145471
145493
  style: {
145472
145494
  ...MUTED,
145495
+ fontSize: 11.5,
145473
145496
  textAlign: "center",
145474
145497
  maxWidth: 320
145475
145498
  }
145476
- }, reason))]));
145499
+ }, missing.reason), ...missing.guidance === void 0 ? [] : [(0, react.createElement)("p", {
145500
+ key: "guidance",
145501
+ "data-hardware-guidance": true,
145502
+ style: {
145503
+ ...MUTED,
145504
+ color: C.text2,
145505
+ fontSize: 10.5,
145506
+ lineHeight: 1.6,
145507
+ textAlign: "center",
145508
+ maxWidth: 360
145509
+ }
145510
+ }, missing.guidance)])]), (0, react.createElement)(OnboardingWizard, props));
145477
145511
  }
145478
145512
  /** Settings section: the two CAD installation roots, host-validated. */
145479
145513
  function HardwareSettingsSection(props) {
@@ -145736,17 +145770,21 @@ void main() {
145736
145770
  /**
145737
145771
  * Browser half of `@huaqiu/dsh-hardware-ui`.
145738
145772
  *
145739
- * Occupies existing DSH seats only: one root navigation occupant, one
145740
- * `keepMounted` right-panel tab body, and one settings section. Native open
145741
- * lives inside the viewer with the resolved artifact in scope, so no
145742
- * conversation-level action is registered.
145773
+ * Occupies existing DSH seats only: one `keepMounted` right-panel tab body and
145774
+ * one settings section. Native open lives inside the viewer with the resolved
145775
+ * artifact in scope, so no conversation-level action is registered — and no
145776
+ * conversation-level navigation either: the panel's own header IS the product's
145777
+ * navigation, so nothing duplicates it above the conversation.
145778
+ *
145779
+ * The tab type declares itself the panel's default page (`default: true`), so
145780
+ * expanding the column opens Hardware Engineering instead of the guide. Inside
145781
+ * the panel there is no tab strip: the page's header is the panel's top edge and
145782
+ * the host lays the two panel controls (full screen, collapse) over its end.
145743
145783
  *
145744
145784
  * Two store handles, not one: DSH pins a handle to a single slot scope, and
145745
- * `conversation.header.leading`/`settings.section` are `root` while
145746
- * `sidebar.right.pane.tab` is `session`. Mounting one handle in both scopes is
145747
- * rejected at load time ("one handle, one scope"). The two halves therefore
145748
- * coordinate the only way the slot contract allows — through the tab
145749
- * parameters and their navigation revision.
145785
+ * `settings.section` is `root` while `sidebar.right.pane.tab` is `session`.
145786
+ * Mounting one handle in both scopes is rejected at load time ("one handle, one
145787
+ * scope").
145750
145788
  */
145751
145789
  /** Real Cordis service names this browser plugin waits for. */
145752
145790
  const inject = [
@@ -145818,15 +145856,11 @@ void main() {
145818
145856
  id: "@huaqiu/dsh-hardware-ui",
145819
145857
  kind: "hardware-engineering",
145820
145858
  keepMounted: true,
145859
+ default: true,
145821
145860
  title: () => COPY.product.name
145822
145861
  }) ?? (() => {}), "hardware-ui: right-panel tab type");
145823
145862
  const slots = ctx.slots;
145824
145863
  if (slots === void 0) return;
145825
- effect(() => slots.inject("conversation.header.leading", () => slots.register({
145826
- name: "conversation.header.leading",
145827
- store: rootStore,
145828
- inject: () => controller
145829
- }, EngineeringNav)), "hardware-ui: five-destination navigation");
145830
145864
  effect(() => slots.inject("sidebar.right.pane.tab", () => slots.register({
145831
145865
  name: "sidebar.right.pane.tab",
145832
145866
  key: HARDWARE_TAB_ID,