@huaqiu/dsh-hardware-ui 0.7.22 → 0.7.24
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 +5927 -355
- package/lib/client.js.map +1 -1
- package/package.json +1 -1
- package/src/client/copy.ts +4 -0
- package/src/client/document/EcadBody.tsx +64 -14
- package/src/client/document/ModelBody.tsx +202 -0
- package/src/client/document/OpenInApplicationAction.tsx +313 -0
- package/src/client/document/contract.ts +49 -2
- package/src/client/document/copy.ts +56 -0
- package/src/client/document/index.ts +89 -4
- package/src/client/document/model/adapters/amf.ts +93 -0
- package/src/client/document/model/adapters/gltf.ts +120 -0
- package/src/client/document/model/adapters/obj.ts +103 -0
- package/src/client/document/model/adapters/ply.ts +49 -0
- package/src/client/document/model/adapters/stl.ts +49 -0
- package/src/client/document/model/adapters/threemf.ts +103 -0
- package/src/client/document/model/companions.ts +355 -0
- package/src/client/document/model/index.ts +130 -0
- package/src/client/document/model/mesh.ts +163 -0
- package/src/client/document/model/types.ts +92 -0
- package/src/client/document/model/units.ts +93 -0
- package/src/client/document/model/viewer.ts +160 -0
- package/src/client/document/mount.ts +128 -9
- package/src/client/document/step.ts +12 -92
- package/src/client/index.ts +86 -2
- package/src/client/locales.ts +64 -4
- package/src/client/model.ts +37 -5
- package/src/client/theme.ts +26 -1
- package/src/client/toolchain-view.tsx +19 -19
- package/src/client/toolchain.ts +43 -0
- package/src/client/wizard.tsx +14 -8
package/src/client/index.ts
CHANGED
|
@@ -24,16 +24,19 @@ import { TOOLCHAIN_ONBOARDING_STEP, ToolchainOnboarding } from './wizard.js'
|
|
|
24
24
|
import { ToolchainController } from './toolchain.js'
|
|
25
25
|
import type {
|
|
26
26
|
ConfigFormLike, HardwareController, HardwareDestination, HardwareInstallationConfig,
|
|
27
|
-
ViewerNavigationParams,
|
|
27
|
+
NativeApplication, ViewerNavigationParams,
|
|
28
28
|
} from './model.js'
|
|
29
29
|
import { createHardwareStore } from './store.js'
|
|
30
30
|
import { COPY, HARDWARE_UI_NS, installCopyLocale, type CopyLocale } from './copy.js'
|
|
31
31
|
import { loadInstallations, loadProjects, openArtifact } from './transport.js'
|
|
32
32
|
import { installDocumentPreviews } from './document/index.js'
|
|
33
|
+
import { OpenInApplicationAction, type ApplicationActionInjected } from './document/OpenInApplicationAction.js'
|
|
34
|
+
import { DOCUMENT_ACTION_SLOT } from './document/contract.js'
|
|
33
35
|
import { setOrderPageOpener } from './order-page.js'
|
|
34
36
|
import { ORDER_TAB_ID, ORDER_TAB_KIND, OrderTabBody, orderTabRegistration } from './order-tab.js'
|
|
35
37
|
import { OrderWatcher } from './order-watcher.js'
|
|
36
38
|
import type { DocumentClientContext, WorkspaceFilesRemote } from './document/contract.js'
|
|
39
|
+
import type { CompanionReader } from './document/model/types.js'
|
|
37
40
|
import type { ProbeSheetFile } from './document/EcadBody.js'
|
|
38
41
|
|
|
39
42
|
/** Real Cordis service names this browser plugin waits for. */
|
|
@@ -45,6 +48,10 @@ export const HARDWARE_TAB_KIND = 'hardware-engineering'
|
|
|
45
48
|
/** The project-selection view that fronts the order destination. */
|
|
46
49
|
export const PLACE_ORDER_TAB_ID = '@huaqiu/dsh-hardware-ui/place-order'
|
|
47
50
|
export const PLACE_ORDER_TAB_KIND = 'hardware-place-order'
|
|
51
|
+
/** Document-header action that hands the previewed design to KiCad. */
|
|
52
|
+
export const KICAD_ACTION_ID = 'hardware-ui-open-in-kicad'
|
|
53
|
+
/** Document-header action that hands the previewed model to SolidCraft. */
|
|
54
|
+
export const SOLIDCRAFT_ACTION_ID = 'hardware-ui-open-in-solidcraft'
|
|
48
55
|
/** Host plugin row id whose volatile config backs the product settings page. */
|
|
49
56
|
export const HARDWARE_CONFIG_ENTRY = 'hardware-artifacts'
|
|
50
57
|
|
|
@@ -158,6 +165,39 @@ function sheetProbeFactory(workspace: WorkspaceHolder): (sessionId: string) => P
|
|
|
158
165
|
}
|
|
159
166
|
}
|
|
160
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Build the companion-file reader for the 3D document body.
|
|
170
|
+
*
|
|
171
|
+
* An OBJ's MTL, its textures and a glTF's external buffers are ordinary files
|
|
172
|
+
* beside the document, and §5.4/§5.5 allow exactly one way to read them: DSH's
|
|
173
|
+
* own bounded file read. So this is the same `readBytes` the sheet probe uses,
|
|
174
|
+
* with the whole file requested — no second HTTP server, no `file://` path
|
|
175
|
+
* handed to the renderer, and no plugin-local filesystem access.
|
|
176
|
+
*
|
|
177
|
+
* A companion that cannot be read resolves to `undefined` rather than throwing:
|
|
178
|
+
* the model renders with the geometry it has and the status line lists what was
|
|
179
|
+
* missing (§5.4). Same holder as the probe, so a late `remote` still works.
|
|
180
|
+
* @param workspace - holder filled by nested injection once `remote` is available.
|
|
181
|
+
* @returns a per-session reader factory that stays usable across a late dependency.
|
|
182
|
+
*/
|
|
183
|
+
function companionReaderFactory(workspace: WorkspaceHolder): (sessionId: string) => CompanionReader | undefined {
|
|
184
|
+
return sessionId => {
|
|
185
|
+
if (workspace.files === undefined) return undefined
|
|
186
|
+
return async (path, signal) => {
|
|
187
|
+
const files = workspace.files
|
|
188
|
+
if (files === undefined) return undefined
|
|
189
|
+
try {
|
|
190
|
+
const result = await files.readBytes(sessionId, path, {}, signal)
|
|
191
|
+
if (!result.ok) return undefined
|
|
192
|
+
const data = (result.value as { readonly data?: Uint8Array } | undefined)?.data
|
|
193
|
+
return data === undefined ? undefined : new Uint8Array(data)
|
|
194
|
+
} catch {
|
|
195
|
+
return undefined
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
161
201
|
/** Artifact kind discriminator carried in navigation params. */
|
|
162
202
|
export function kindForPath(path: string): string {
|
|
163
203
|
if (path.toLowerCase().endsWith('.kicad_sch')) return 'schematic'
|
|
@@ -400,6 +440,47 @@ export function apply(ctx: ClientContext): void {
|
|
|
400
440
|
inject: () => ({}),
|
|
401
441
|
}, OrderWatcher)), 'hardware-ui: order page in a Browser tab')
|
|
402
442
|
|
|
443
|
+
// `Open in KiCad` and `Open in SolidCraft` (§4 of the toolchain-aware task):
|
|
444
|
+
// one component, one launch route, two registrations on the document header's
|
|
445
|
+
// own action list. DSH renders that list only once the previewed file's Host
|
|
446
|
+
// path is known, so neither action derives, guesses or rewrites a path — each
|
|
447
|
+
// asks the Host to launch the configured GUI and reports what it confirmed.
|
|
448
|
+
//
|
|
449
|
+
// Two registrations rather than one action with a selector: the labels are
|
|
450
|
+
// application-specific, and §4 forbids a generic application chooser. They
|
|
451
|
+
// never appear together either, because the Host's verified format lists are
|
|
452
|
+
// disjoint — a document has exactly one route.
|
|
453
|
+
//
|
|
454
|
+
// `order` puts KiCad first: a KiCad document is the common case in this
|
|
455
|
+
// product, and DSH orders the header by it.
|
|
456
|
+
const documentActions: readonly { application: NativeApplication; id: string; order: number }[] = [
|
|
457
|
+
{ application: 'kicad', id: KICAD_ACTION_ID, order: 90 },
|
|
458
|
+
{ application: 'solidcraft', id: SOLIDCRAFT_ACTION_ID, order: 100 },
|
|
459
|
+
]
|
|
460
|
+
for (const entry of documentActions) {
|
|
461
|
+
effect(() => slots.inject(DOCUMENT_ACTION_SLOT, () => slots.register({
|
|
462
|
+
name: DOCUMENT_ACTION_SLOT,
|
|
463
|
+
id: entry.id,
|
|
464
|
+
order: entry.order,
|
|
465
|
+
locale: HARDWARE_UI_NS,
|
|
466
|
+
inject: (): ApplicationActionInjected => ({
|
|
467
|
+
application: entry.application,
|
|
468
|
+
installations: () => loadInstallations(),
|
|
469
|
+
open: path => openArtifact({
|
|
470
|
+
application: entry.application,
|
|
471
|
+
artifactPath: path,
|
|
472
|
+
// A label for the route's own bookkeeping: the launch resolves the
|
|
473
|
+
// executable by suffix, so `kind` is never a dispatch decision.
|
|
474
|
+
kind: entry.application === 'kicad' ? kindForPath(path) : 'mechanical-3d',
|
|
475
|
+
}),
|
|
476
|
+
notify: (tone, text) => toolchain.toast(tone, text),
|
|
477
|
+
// Availability follows the live configuration: a settings write re-reads
|
|
478
|
+
// the installation report instead of waiting for a DSH restart (§5).
|
|
479
|
+
subscribe: listener => toolchain.onCapabilityChange(listener),
|
|
480
|
+
}),
|
|
481
|
+
}, OpenInApplicationAction)), `hardware-ui: open in ${entry.application} action`)
|
|
482
|
+
}
|
|
483
|
+
|
|
403
484
|
// Document renderers ride DSH's own document pipeline: they contribute four
|
|
404
485
|
// registry entries and four bodies, and nothing else. Installed through a
|
|
405
486
|
// nested injection so a Host without the document-preview service loses only
|
|
@@ -410,7 +491,10 @@ export function apply(ctx: ClientContext): void {
|
|
|
410
491
|
// undeclared access) or declared plugin-wide (which would take the product
|
|
411
492
|
// panel down with it on a Host without a client remote).
|
|
412
493
|
const workspace: WorkspaceHolder = {}
|
|
413
|
-
const documentOptions = {
|
|
494
|
+
const documentOptions = {
|
|
495
|
+
probeSheet: sheetProbeFactory(workspace),
|
|
496
|
+
readCompanion: companionReaderFactory(workspace),
|
|
497
|
+
}
|
|
414
498
|
if (ctx.inject !== undefined) {
|
|
415
499
|
ctx.inject(['remote', 'remote.workspaceFiles'], (scope) => {
|
|
416
500
|
workspace.files = scope.remote?.workspaceFiles
|
package/src/client/locales.ts
CHANGED
|
@@ -198,11 +198,12 @@ export const zh = {
|
|
|
198
198
|
'errors.missing-artifact': '该产物不存在。',
|
|
199
199
|
'errors.unsupported-artifact': '不支持该产物类型。',
|
|
200
200
|
'errors.invalid-identity': '产物路径无效。',
|
|
201
|
-
'errors.missing-executable': '
|
|
202
|
-
'errors.not-configured': '
|
|
201
|
+
'errors.missing-executable': '已配置的安装中没有可打开该产物的程序。',
|
|
202
|
+
'errors.not-configured': '尚未配置所需的本地程序。请在「设置 → 硬件工程」中填写安装位置。',
|
|
203
203
|
'errors.too-large': '产物超过可预览的大小上限。',
|
|
204
204
|
'errors.export-timeout': 'kicad-cli 执行超时。',
|
|
205
205
|
'errors.export-failed': 'kicad-cli 导出失败。',
|
|
206
|
+
'errors.launch-failed': '无法启动本地程序。',
|
|
206
207
|
'errors.stale-revision': '文件已变化,请刷新后重试。',
|
|
207
208
|
'errors.invalid-request': '请求参数不完整。',
|
|
208
209
|
'errors.invalid-application': '不支持该本地程序。',
|
|
@@ -220,6 +221,8 @@ export const zh = {
|
|
|
220
221
|
// Document-rendering surfaces.
|
|
221
222
|
'document.viewer.schematic': '原理图',
|
|
222
223
|
'document.viewer.pcb': 'PCB',
|
|
224
|
+
'document.viewer.symbol': '符号',
|
|
225
|
+
'document.viewer.footprint': '封装',
|
|
223
226
|
'document.viewer.model': '3D 模型',
|
|
224
227
|
'document.state.loading': '正在解析并渲染…',
|
|
225
228
|
'document.state.stepLoading': '正在解析 STEP 几何…',
|
|
@@ -227,6 +230,9 @@ export const zh = {
|
|
|
227
230
|
'document.state.parseFailed': '解析失败:{message}',
|
|
228
231
|
'document.state.renderFailed': '渲染失败:{message}',
|
|
229
232
|
'document.state.aborted': '渲染已取消。',
|
|
233
|
+
'document.state.emptySymbolLibrary': '该符号库文件中没有符号,无法预览。',
|
|
234
|
+
'document.state.emptyFootprint': '该封装文件中没有封装,无法预览。',
|
|
235
|
+
'document.symbols.label': '符号库中的符号',
|
|
230
236
|
'document.state.noWebgl': '当前环境无法创建 WebGL 上下文,无法渲染该文档。',
|
|
231
237
|
'document.state.stepInvalid': '该 STEP/STP 文件不含可用实体几何,无法预览。',
|
|
232
238
|
'document.state.wasmFailed': '3D 解析组件加载失败。',
|
|
@@ -237,6 +243,30 @@ export const zh = {
|
|
|
237
243
|
'document.sheets.found': '{label}',
|
|
238
244
|
'document.sheets.hint': '子图在各自的文件中单独打开预览;本预览只渲染当前文档。',
|
|
239
245
|
|
|
246
|
+
// 3D model documents: the status line states what was actually read, so a
|
|
247
|
+
// file whose units nobody declared is never presented as measured (§5.7).
|
|
248
|
+
'document.state.modelLoading': '正在解析 {format} 几何…',
|
|
249
|
+
'document.state.modelInvalid': '{format} 文件不含可预览的网格几何。',
|
|
250
|
+
'document.state.modelMissing': '此 {format} 文件依赖外部文件 {name},但该文件无法读取。',
|
|
251
|
+
'document.model.unit': '单位 {unit}',
|
|
252
|
+
'document.model.unitUnknown': '单位未知',
|
|
253
|
+
'document.model.objects': '{count} 个对象',
|
|
254
|
+
'document.model.materials': '{count} 种材质',
|
|
255
|
+
'document.model.warnings': '{count} 项未加载',
|
|
256
|
+
'document.model.missing': '未加载:{list}',
|
|
257
|
+
'document.model.separator': ' · ',
|
|
258
|
+
|
|
259
|
+
// Document header action: one contextual hand-off per application, no new
|
|
260
|
+
// navigation. `{app}` is the product's own name and is never translated.
|
|
261
|
+
'document.actions.openIn': '用 {app} 打开',
|
|
262
|
+
'document.actions.openInTitle': '在 {app} 中打开 {name}',
|
|
263
|
+
'document.actions.opening': '正在启动 {app}…',
|
|
264
|
+
'document.actions.notConfigured': '未配置 {app}。请在「设置 → 硬件工程」中指定安装位置。',
|
|
265
|
+
'document.actions.noGui': '配置的 {app} 中没有图形界面程序,只有命令行版本可用。',
|
|
266
|
+
'document.actions.noEditor': '配置的 {app} 安装中没有能打开 {ext} 文件的编辑器。',
|
|
267
|
+
'document.actions.launched': '已用 {app} 打开 {name}。',
|
|
268
|
+
'document.actions.failed': '启动 {app} 失败:{detail}',
|
|
269
|
+
|
|
240
270
|
// Toolchain capability: discovery, validation, download, notices.
|
|
241
271
|
'toolchain.checking': '正在检查现有安装…',
|
|
242
272
|
'toolchain.kicadMissing': 'KiCad 未配置',
|
|
@@ -508,11 +538,12 @@ export const en: Record<HardwareCopyKey, string> = {
|
|
|
508
538
|
'errors.missing-artifact': 'This artifact does not exist.',
|
|
509
539
|
'errors.unsupported-artifact': 'This artifact type is not supported.',
|
|
510
540
|
'errors.invalid-identity': 'The artifact path is invalid.',
|
|
511
|
-
'errors.missing-executable': 'The configured
|
|
512
|
-
'errors.not-configured': '
|
|
541
|
+
'errors.missing-executable': 'The configured installation has no program that can open this artifact.',
|
|
542
|
+
'errors.not-configured': 'The required local application is not configured. Enter its installation location in Settings → Hardware Engineering.',
|
|
513
543
|
'errors.too-large': 'The artifact exceeds the size limit for previews.',
|
|
514
544
|
'errors.export-timeout': 'kicad-cli timed out.',
|
|
515
545
|
'errors.export-failed': 'kicad-cli export failed.',
|
|
546
|
+
'errors.launch-failed': 'The local application could not be started.',
|
|
516
547
|
'errors.stale-revision': 'The file changed; refresh and try again.',
|
|
517
548
|
'errors.invalid-request': 'The request parameters are incomplete.',
|
|
518
549
|
'errors.invalid-application': 'This local application is not supported.',
|
|
@@ -528,6 +559,8 @@ export const en: Record<HardwareCopyKey, string> = {
|
|
|
528
559
|
|
|
529
560
|
'document.viewer.schematic': 'Schematic',
|
|
530
561
|
'document.viewer.pcb': 'PCB',
|
|
562
|
+
'document.viewer.symbol': 'Symbol',
|
|
563
|
+
'document.viewer.footprint': 'Footprint',
|
|
531
564
|
'document.viewer.model': '3D model',
|
|
532
565
|
'document.state.loading': 'Parsing and rendering…',
|
|
533
566
|
'document.state.stepLoading': 'Parsing STEP geometry…',
|
|
@@ -535,6 +568,9 @@ export const en: Record<HardwareCopyKey, string> = {
|
|
|
535
568
|
'document.state.parseFailed': 'Parse failed: {message}',
|
|
536
569
|
'document.state.renderFailed': 'Render failed: {message}',
|
|
537
570
|
'document.state.aborted': 'Rendering was cancelled.',
|
|
571
|
+
'document.state.emptySymbolLibrary': 'This symbol library declares no symbols, so there is nothing to preview.',
|
|
572
|
+
'document.state.emptyFootprint': 'This footprint file declares no footprint, so there is nothing to preview.',
|
|
573
|
+
'document.symbols.label': 'Symbol in this library',
|
|
538
574
|
'document.state.noWebgl': 'This environment cannot create a WebGL context, so the document cannot be rendered.',
|
|
539
575
|
'document.state.stepInvalid': 'This STEP/STP file has no usable solid geometry to preview.',
|
|
540
576
|
'document.state.wasmFailed': 'The 3D parser failed to load.',
|
|
@@ -545,6 +581,30 @@ export const en: Record<HardwareCopyKey, string> = {
|
|
|
545
581
|
'document.sheets.found': '{label}',
|
|
546
582
|
'document.sheets.hint': 'Child sheets preview in their own files; this preview renders only the current document.',
|
|
547
583
|
|
|
584
|
+
// 3D model documents: the status line states what was actually read, so a
|
|
585
|
+
// file whose units nobody declared is never presented as measured (§5.7).
|
|
586
|
+
'document.state.modelLoading': 'Parsing {format} geometry…',
|
|
587
|
+
'document.state.modelInvalid': 'This {format} file has no previewable mesh geometry.',
|
|
588
|
+
'document.state.modelMissing': 'This {format} file needs an external file, {name}, that could not be read.',
|
|
589
|
+
'document.model.unit': 'unit {unit}',
|
|
590
|
+
'document.model.unitUnknown': 'unit unknown',
|
|
591
|
+
'document.model.objects': '{count} objects',
|
|
592
|
+
'document.model.materials': '{count} materials',
|
|
593
|
+
'document.model.warnings': '{count} not loaded',
|
|
594
|
+
'document.model.missing': 'Not loaded: {list}',
|
|
595
|
+
'document.model.separator': ' · ',
|
|
596
|
+
|
|
597
|
+
// Document header action: one contextual hand-off per application, no new
|
|
598
|
+
// navigation. `{app}` is the product's own name and is never translated.
|
|
599
|
+
'document.actions.openIn': 'Open in {app}',
|
|
600
|
+
'document.actions.openInTitle': 'Open {name} in {app}',
|
|
601
|
+
'document.actions.opening': 'Starting {app}…',
|
|
602
|
+
'document.actions.notConfigured': '{app} is not configured. Set its installation in Settings → Hardware Engineering.',
|
|
603
|
+
'document.actions.noGui': 'The configured {app} has no GUI executable; only the command line is available.',
|
|
604
|
+
'document.actions.noEditor': 'The configured {app} installation has no editor for {ext} files.',
|
|
605
|
+
'document.actions.launched': 'Opened {name} in {app}.',
|
|
606
|
+
'document.actions.failed': 'Could not start {app}: {detail}',
|
|
607
|
+
|
|
548
608
|
// Toolchain capability: discovery, validation, download, notices.
|
|
549
609
|
'toolchain.checking': 'Checking for an existing installation…',
|
|
550
610
|
'toolchain.kicadMissing': 'KiCad not configured',
|
package/src/client/model.ts
CHANGED
|
@@ -5,13 +5,15 @@ import { COPY } from './copy.js'
|
|
|
5
5
|
export type HardwareDestination = 'schematic' | 'pcb' | 'bom' | '3d' | 'order'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Native applications a
|
|
8
|
+
* Native applications a document action can hand off to.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Both are reached from a document now: `kicad` through `Open in KiCad` on
|
|
11
|
+
* `.kicad_sch` / `.kicad_pcb` / `.kicad_pro`, `solidcraft` through
|
|
12
|
+
* `Open in SolidCraft` on its verified model inputs. `kicad` is additionally
|
|
13
|
+
* reached from the product's own destinations, whose source artifacts are the
|
|
14
|
+
* same project files.
|
|
13
15
|
*/
|
|
14
|
-
export type NativeApplication = 'kicad'
|
|
16
|
+
export type NativeApplication = 'kicad' | 'solidcraft'
|
|
15
17
|
|
|
16
18
|
export const DESTINATIONS: readonly HardwareDestination[] = Object.freeze([
|
|
17
19
|
'schematic', 'pcb', 'bom', '3d', 'order',
|
|
@@ -71,17 +73,47 @@ export interface HardwareProjectInfo {
|
|
|
71
73
|
export interface InstallationsInfo {
|
|
72
74
|
readonly kicad?: {
|
|
73
75
|
readonly configured: boolean
|
|
76
|
+
/**
|
|
77
|
+
* Whether an editor this product can launch exists. Independent of
|
|
78
|
+
* `cliAvailable`: an installation with only `kicad-cli` can package and
|
|
79
|
+
* export but cannot open a document.
|
|
80
|
+
*/
|
|
81
|
+
readonly guiAvailable?: boolean
|
|
82
|
+
/** Whether the command line half (`kicad-cli`) resolved. */
|
|
83
|
+
readonly cliAvailable?: boolean
|
|
74
84
|
readonly root?: string
|
|
75
85
|
readonly version?: string
|
|
76
86
|
readonly cli?: string
|
|
87
|
+
/** `pcbnew`, which opens a `.kicad_pcb`. */
|
|
77
88
|
readonly pcbEditor?: string
|
|
89
|
+
/** `eeschema`, which opens a `.kicad_sch`. */
|
|
78
90
|
readonly schematicEditor?: string
|
|
91
|
+
/** `kicad`, the project manager, which opens a `.kicad_pro`. */
|
|
92
|
+
readonly projectManager?: string
|
|
93
|
+
/**
|
|
94
|
+
* Formats KiCad opens as a design document, from the Host's verified list —
|
|
95
|
+
* a suffix has no editor resolution behind it, so it is not in this list (§2).
|
|
96
|
+
*/
|
|
97
|
+
readonly inputFormats?: readonly string[]
|
|
79
98
|
readonly error?: string
|
|
80
99
|
}
|
|
81
100
|
readonly solidcraft?: {
|
|
82
101
|
readonly configured: boolean
|
|
102
|
+
/** `solidcraft.exe` resolved and launchable on its own (§6.2). */
|
|
103
|
+
readonly guiAvailable?: boolean
|
|
104
|
+
/** `solidcraft-cli.exe` resolved and probeable on its own (§6.2). */
|
|
105
|
+
readonly cliAvailable?: boolean
|
|
83
106
|
readonly root?: string
|
|
107
|
+
readonly version?: string
|
|
108
|
+
/** The GUI executable; the field keeps its historical name for the launch path. */
|
|
84
109
|
readonly executable?: string
|
|
110
|
+
/** The CLI executable, reported separately and never required for a launch. */
|
|
111
|
+
readonly cli?: string
|
|
112
|
+
/**
|
|
113
|
+
* Formats SolidCraft opens natively, from the Host's verified list — not from
|
|
114
|
+
* the document previewer's adapters (§7.1).
|
|
115
|
+
*/
|
|
116
|
+
readonly inputFormats?: readonly string[]
|
|
85
117
|
readonly error?: string
|
|
86
118
|
}
|
|
87
119
|
}
|
package/src/client/theme.ts
CHANGED
|
@@ -15,11 +15,36 @@ export const C = {
|
|
|
15
15
|
panel: 'var(--dsw-alias-bg-layer-1, #1d1d20)',
|
|
16
16
|
card: 'var(--dsw-alias-bg-layer-2, #202024)',
|
|
17
17
|
raised: 'var(--dsw-alias-bg-layer-3, #2a2a2e)',
|
|
18
|
+
/**
|
|
19
|
+
* Nested surface inside a panel (cards, bars, chips).
|
|
20
|
+
*
|
|
21
|
+
* The theme's layer stack collapses to one white in the light theme, so layer-2
|
|
22
|
+
* there is indistinguishable from the panel behind it, while in the dark theme
|
|
23
|
+
* it is the visibly raised step. Deriving the surface from the theme's own ink
|
|
24
|
+
* instead — 5% of `label-primary` over `layer-1` — gives rgb(243 244 244) on
|
|
25
|
+
* white and rgb(46 46 47) on near-black: a step in both themes, from one
|
|
26
|
+
* expression. The fallbacks keep a token-less host on the old dark surface.
|
|
27
|
+
*/
|
|
28
|
+
inset: 'color-mix(in srgb, var(--dsw-alias-label-primary, #ececee) 5%, var(--dsw-alias-bg-layer-1, #1d1d20))',
|
|
29
|
+
/** Theme-independent neutral wash for chips and tracks (alpha of mid grey). */
|
|
30
|
+
neutral: 'rgba(127,127,127,0.16)',
|
|
31
|
+
/** The 6px progress track, a touch stronger than a chip. */
|
|
32
|
+
track: 'rgba(127,127,127,0.28)',
|
|
33
|
+
/** Modal scrim: the theme decides how far a mask dims what is behind it. */
|
|
34
|
+
scrim: 'var(--dsw-alias-bg-mask-3, rgba(0,0,0,0.48))',
|
|
35
|
+
/** Lighter veil for a dialog stacked on an already dimmed page. */
|
|
36
|
+
veil: 'var(--dsw-alias-bg-mask-1, rgba(0,0,0,0.4))',
|
|
37
|
+
/** Shadow colour for raised surfaces (softer in the light theme). */
|
|
38
|
+
shadow: 'var(--dsw-alias-bg-mask-1, rgba(0,0,0,0.4))',
|
|
18
39
|
border: 'var(--dsw-alias-border-l2, rgba(127,127,127,0.24))',
|
|
19
40
|
borderSoft: 'var(--dsw-alias-border-l1, rgba(127,127,127,0.14))',
|
|
20
41
|
text: 'var(--dsw-alias-label-primary, #ececee)',
|
|
21
42
|
text2: 'var(--dsw-alias-label-secondary, #a1a1aa)',
|
|
22
43
|
text3: 'var(--dsw-alias-label-tertiary, #71717a)',
|
|
44
|
+
/** Link/accent ink that stays legible on white and on near-black. */
|
|
45
|
+
link: 'var(--dsw-alias-link, #4176e6)',
|
|
46
|
+
/** Amber ink for the optional tool, readable on both themes. */
|
|
47
|
+
warnLabel: 'var(--dsw-alias-state-warn-label, #dd8629)',
|
|
23
48
|
accent: '#e1251b',
|
|
24
49
|
accentHover: '#c41e15',
|
|
25
50
|
accentSoft: 'rgba(225, 37, 27, 0.15)',
|
|
@@ -47,7 +72,7 @@ export function cardStyle(extra?: CSSProperties): CSSProperties {
|
|
|
47
72
|
return {
|
|
48
73
|
border: `1px solid ${C.border}`,
|
|
49
74
|
borderRadius: R.lg,
|
|
50
|
-
background: C.
|
|
75
|
+
background: C.inset,
|
|
51
76
|
padding: 12,
|
|
52
77
|
display: 'flex',
|
|
53
78
|
flexDirection: 'column',
|
|
@@ -38,7 +38,7 @@ const TOOL_META = {
|
|
|
38
38
|
short: 'KiCad',
|
|
39
39
|
letter: 'Ki',
|
|
40
40
|
color: '#2563EB',
|
|
41
|
-
accent:
|
|
41
|
+
accent: C.link,
|
|
42
42
|
bar: '#3B82F6',
|
|
43
43
|
/** The prototype shows the CLI name beside the title for KiCad only. */
|
|
44
44
|
code: 'kicad-cli' as string | undefined,
|
|
@@ -48,7 +48,7 @@ const TOOL_META = {
|
|
|
48
48
|
short: 'SolidCraft',
|
|
49
49
|
letter: 'Sc',
|
|
50
50
|
color: '#B45309',
|
|
51
|
-
accent:
|
|
51
|
+
accent: C.warnLabel,
|
|
52
52
|
bar: '#F59E0B',
|
|
53
53
|
code: undefined as string | undefined,
|
|
54
54
|
},
|
|
@@ -102,7 +102,7 @@ function LetterBadge(props: { readonly letter: string; readonly color: string; r
|
|
|
102
102
|
function Chip(props: { readonly text: string }): ReactNode {
|
|
103
103
|
return createElement('span', {
|
|
104
104
|
style: {
|
|
105
|
-
fontSize: 10, padding: '2px 6px', borderRadius: 4, background:
|
|
105
|
+
fontSize: 10, padding: '2px 6px', borderRadius: 4, background: C.neutral,
|
|
106
106
|
color: C.text2, whiteSpace: 'nowrap',
|
|
107
107
|
},
|
|
108
108
|
}, props.text)
|
|
@@ -205,7 +205,7 @@ export function discoveryLine(tool: ToolStatus): { readonly text: string; readon
|
|
|
205
205
|
*/
|
|
206
206
|
const PROGRESS_TRACK: CSSProperties = {
|
|
207
207
|
position: 'relative', height: 6, minHeight: 6, flex: '0 0 auto', borderRadius: 999,
|
|
208
|
-
background:
|
|
208
|
+
background: C.track, overflow: 'hidden',
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
/** Inline download progress: label + percent on one line, bar underneath (§7.4). */
|
|
@@ -326,7 +326,7 @@ export function ToolchainCard(props: {
|
|
|
326
326
|
title: COPY.toolchain.browseTitle,
|
|
327
327
|
onClick: () => { controller.openPicker(id) },
|
|
328
328
|
},
|
|
329
|
-
createElement(Icon, { path: TOOLCHAIN_ICONS.folder, color:
|
|
329
|
+
createElement(Icon, { path: TOOLCHAIN_ICONS.folder, color: C.warnLabel }),
|
|
330
330
|
variant === 'wizard' ? COPY.wizard.selectFile : COPY.toolchain.browse),
|
|
331
331
|
)
|
|
332
332
|
|
|
@@ -466,7 +466,7 @@ function officialFallback(tool: ToolchainId, snapshot: ToolchainSnapshot): React
|
|
|
466
466
|
href: snapshot.status?.official?.[tool] ?? '#',
|
|
467
467
|
target: '_blank',
|
|
468
468
|
rel: 'noreferrer noopener',
|
|
469
|
-
style: { fontSize: 11, color: C.
|
|
469
|
+
style: { fontSize: 11, color: C.link, textDecoration: 'none', whiteSpace: 'nowrap' },
|
|
470
470
|
}, COPY.toolchain.official)
|
|
471
471
|
}
|
|
472
472
|
|
|
@@ -593,11 +593,11 @@ function ExecutablePicker(props: {
|
|
|
593
593
|
style: {
|
|
594
594
|
position: 'fixed', inset: 0, zIndex: 2200, display: 'flex', alignItems: 'center',
|
|
595
595
|
justifyContent: 'center', padding: 16,
|
|
596
|
-
// The picker opens *inside* a modal that already dims the page (`
|
|
597
|
-
// Two stacked
|
|
598
|
-
//
|
|
599
|
-
//
|
|
600
|
-
background:
|
|
596
|
+
// The picker opens *inside* a modal that already dims the page (`C.scrim`).
|
|
597
|
+
// Two stacked scrims multiply into "the lights went out" rather than "a
|
|
598
|
+
// dialog is on top" — so this layer only adds the theme's lighter veil,
|
|
599
|
+
// enough to separate the panel from the card behind it.
|
|
600
|
+
background: C.veil,
|
|
601
601
|
pointerEvents: 'auto',
|
|
602
602
|
},
|
|
603
603
|
role: 'dialog',
|
|
@@ -613,8 +613,8 @@ function ExecutablePicker(props: {
|
|
|
613
613
|
{
|
|
614
614
|
style: {
|
|
615
615
|
display: 'flex', flexDirection: 'column', width: 512, maxWidth: '100%', maxHeight: '85vh',
|
|
616
|
-
background:
|
|
617
|
-
boxShadow:
|
|
616
|
+
background: C.panel, border: `1px solid ${C.border}`, borderRadius: R.md,
|
|
617
|
+
boxShadow: `0 24px 64px ${C.shadow}`, overflow: 'hidden',
|
|
618
618
|
},
|
|
619
619
|
},
|
|
620
620
|
// OS-style title bar.
|
|
@@ -623,13 +623,13 @@ function ExecutablePicker(props: {
|
|
|
623
623
|
{
|
|
624
624
|
style: {
|
|
625
625
|
display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8,
|
|
626
|
-
padding: '12px 16px', background:
|
|
626
|
+
padding: '12px 16px', background: C.inset, borderBottom: `1px solid ${C.borderSoft}`,
|
|
627
627
|
},
|
|
628
628
|
},
|
|
629
629
|
createElement(
|
|
630
630
|
'div',
|
|
631
631
|
{ style: { display: 'flex', alignItems: 'center', gap: 8, minWidth: 0, fontSize: 12, fontWeight: 500, color: C.text2 } },
|
|
632
|
-
createElement(Icon, { path: TOOLCHAIN_ICONS.folder, color:
|
|
632
|
+
createElement(Icon, { path: TOOLCHAIN_ICONS.folder, color: C.warnLabel, size: 16 }),
|
|
633
633
|
createElement('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } },
|
|
634
634
|
COPY.toolchain.pickerTitle(executable)),
|
|
635
635
|
),
|
|
@@ -648,7 +648,7 @@ function ExecutablePicker(props: {
|
|
|
648
648
|
{
|
|
649
649
|
style: {
|
|
650
650
|
display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8,
|
|
651
|
-
padding: '8px 16px', background:
|
|
651
|
+
padding: '8px 16px', background: C.inset, borderBottom: `1px solid ${C.borderSoft}`,
|
|
652
652
|
...MONO_TEXT, fontSize: 11, color: C.text3,
|
|
653
653
|
},
|
|
654
654
|
},
|
|
@@ -660,7 +660,7 @@ function ExecutablePicker(props: {
|
|
|
660
660
|
type: 'button',
|
|
661
661
|
style: {
|
|
662
662
|
...buttonStyle('quiet', { padding: 0, flex: '0 0 auto' }),
|
|
663
|
-
color: C.
|
|
663
|
+
color: C.link, fontWeight: 500, textDecoration: 'underline', fontSize: 11,
|
|
664
664
|
},
|
|
665
665
|
onClick: () => { void controller.nativePick() },
|
|
666
666
|
}, picker.nativePending ? COPY.toolchain.pickerNativeWaiting : COPY.toolchain.pickerNative),
|
|
@@ -683,14 +683,14 @@ function ExecutablePicker(props: {
|
|
|
683
683
|
{
|
|
684
684
|
style: {
|
|
685
685
|
display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 10,
|
|
686
|
-
padding: '12px 16px', background:
|
|
686
|
+
padding: '12px 16px', background: C.inset, borderTop: `1px solid ${C.borderSoft}`,
|
|
687
687
|
},
|
|
688
688
|
},
|
|
689
689
|
createElement('div', {
|
|
690
690
|
title: picker.chosen ?? '',
|
|
691
691
|
style: {
|
|
692
692
|
...MONO_TEXT, flex: 1, minWidth: 0, fontSize: 11, color: picker.chosen === undefined ? C.text3 : C.text2,
|
|
693
|
-
background:
|
|
693
|
+
background: C.base, border: `1px solid ${C.borderSoft}`, borderRadius: 4, padding: '6px 10px',
|
|
694
694
|
overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
|
|
695
695
|
},
|
|
696
696
|
}, picker.chosen ?? COPY.toolchain.pickerNoSelection),
|
package/src/client/toolchain.ts
CHANGED
|
@@ -278,6 +278,23 @@ export function setupSummary(status: ToolchainStatus | undefined): string {
|
|
|
278
278
|
return `${kicad} · ${solidcraft}`
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
+
/**
|
|
282
|
+
* The configuration facts that change what an external hand-off can do.
|
|
283
|
+
*
|
|
284
|
+
* Deliberately narrow: the stored root, the verdict and the resolved executables
|
|
285
|
+
* — not discovery candidates, drafts, job progress or toasts. Two statuses with
|
|
286
|
+
* the same signature describe the same set of launchable applications, so a
|
|
287
|
+
* document action has nothing to re-read.
|
|
288
|
+
* @param status - last status the Host reported, if any.
|
|
289
|
+
* @returns a comparable string; empty before the first answer.
|
|
290
|
+
*/
|
|
291
|
+
function capabilitySignatureOf(status: ToolchainStatus | undefined): string {
|
|
292
|
+
if (status === undefined) return ''
|
|
293
|
+
const one = (tool: ToolStatus): string =>
|
|
294
|
+
[tool.state, tool.installPath, tool.cliPath, tool.appPath, tool.version, tool.error].join('|')
|
|
295
|
+
return `${one(status.kicad)}::${one(status.solidcraft)}`
|
|
296
|
+
}
|
|
297
|
+
|
|
281
298
|
type Listener = () => void
|
|
282
299
|
|
|
283
300
|
/**
|
|
@@ -293,6 +310,10 @@ export class ToolchainController {
|
|
|
293
310
|
loading: true, jobs: {}, drafts: EMPTY_DRAFTS, checks: {}, confirmed: {}, toasts: [],
|
|
294
311
|
}
|
|
295
312
|
private readonly listeners = new Set<Listener>()
|
|
313
|
+
/** Listeners that only care about the stored configuration, not UI churn. */
|
|
314
|
+
private readonly capabilityListeners = new Set<() => void>()
|
|
315
|
+
/** Last configuration signature seen, so a toast never wakes those listeners. */
|
|
316
|
+
private capabilitySignature = ''
|
|
296
317
|
private toastSeq = 0
|
|
297
318
|
private timer?: ReturnType<typeof setTimeout>
|
|
298
319
|
private readonly timers = new Map<number, ReturnType<typeof setTimeout>>()
|
|
@@ -319,11 +340,32 @@ export class ToolchainController {
|
|
|
319
340
|
return () => { this.listeners.delete(listener) }
|
|
320
341
|
}
|
|
321
342
|
|
|
343
|
+
/**
|
|
344
|
+
* Subscribe to *configuration* changes only.
|
|
345
|
+
*
|
|
346
|
+
* A component that re-reads the Host's installation report on every snapshot
|
|
347
|
+
* would re-probe both installations on every toast, draft keystroke and job
|
|
348
|
+
* tick. This fires only when the stored root, the verdict or the resolved
|
|
349
|
+
* executables of either tool move — which is exactly "the user changed the
|
|
350
|
+
* configuration", and exactly what a document action must not miss (§5 of the
|
|
351
|
+
* toolchain-aware open-in-app task).
|
|
352
|
+
* @param listener - called after the snapshot adopted a different configuration.
|
|
353
|
+
* @returns unsubscribe.
|
|
354
|
+
*/
|
|
355
|
+
onCapabilityChange = (listener: () => void): (() => void) => {
|
|
356
|
+
this.capabilityListeners.add(listener)
|
|
357
|
+
return () => { this.capabilityListeners.delete(listener) }
|
|
358
|
+
}
|
|
359
|
+
|
|
322
360
|
getSnapshot = (): ToolchainSnapshot => this.snapshot
|
|
323
361
|
|
|
324
362
|
private set(patch: Partial<ToolchainSnapshot>): void {
|
|
325
363
|
this.snapshot = { ...this.snapshot, ...patch }
|
|
326
364
|
for (const listener of this.listeners) listener()
|
|
365
|
+
const signature = capabilitySignatureOf(this.snapshot.status)
|
|
366
|
+
if (signature === this.capabilitySignature) return
|
|
367
|
+
this.capabilitySignature = signature
|
|
368
|
+
for (const listener of this.capabilityListeners) listener()
|
|
327
369
|
}
|
|
328
370
|
|
|
329
371
|
/**
|
|
@@ -350,6 +392,7 @@ export class ToolchainController {
|
|
|
350
392
|
for (const timer of this.confirmTimers.values()) clearTimeout(timer)
|
|
351
393
|
this.confirmTimers.clear()
|
|
352
394
|
this.listeners.clear()
|
|
395
|
+
this.capabilityListeners.clear()
|
|
353
396
|
}
|
|
354
397
|
|
|
355
398
|
/** Read the Host status, asking about every job a card is watching. */
|
package/src/client/wizard.tsx
CHANGED
|
@@ -152,24 +152,30 @@ function useFormValue(form: ConfigFormLike<HardwareInstallationConfig> | undefin
|
|
|
152
152
|
|
|
153
153
|
const BACKDROP: CSSProperties = {
|
|
154
154
|
position: 'fixed', inset: 0, zIndex: 2000, display: 'flex', alignItems: 'center',
|
|
155
|
-
justifyContent: 'center', padding: 16, background:
|
|
155
|
+
justifyContent: 'center', padding: 16, background: C.scrim, backdropFilter: 'blur(2px)',
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
const HEADER: CSSProperties = {
|
|
159
159
|
display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 16,
|
|
160
160
|
padding: '20px 22px 14px', borderBottom: `1px solid ${C.borderSoft}`,
|
|
161
|
-
|
|
161
|
+
// The prototype's warm wash is an accent tint *over* the theme surface, not a
|
|
162
|
+
// dark gradient: on white it reads as the same pale red, on near-black as the
|
|
163
|
+
// same warm charcoal.
|
|
164
|
+
background: `linear-gradient(90deg, rgba(225,37,27,0.12) 0%, rgba(225,37,27,0.04) 55%, rgba(225,37,27,0) 100%), ${C.panel}`,
|
|
165
|
+
borderRadius: `${R.lg}px ${R.lg}px 0 0`,
|
|
162
166
|
}
|
|
163
167
|
|
|
164
168
|
const CALLOUT: CSSProperties = {
|
|
165
169
|
display: 'flex', alignItems: 'flex-start', gap: 10, padding: 12, borderRadius: R.md,
|
|
166
|
-
background: 'rgba(59,130,246,0.10)', border: '1px solid rgba(59,130,246,0.
|
|
167
|
-
|
|
170
|
+
background: 'rgba(59,130,246,0.10)', border: '1px solid rgba(59,130,246,0.28)',
|
|
171
|
+
// Blue tint only; the text stays the theme's own ink so it is readable on a
|
|
172
|
+
// white card as well as on a dark one.
|
|
173
|
+
color: C.text2, fontSize: 11, lineHeight: 1.6,
|
|
168
174
|
}
|
|
169
175
|
|
|
170
176
|
const FOOTER: CSSProperties = {
|
|
171
177
|
display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12, flexWrap: 'wrap',
|
|
172
|
-
padding: '14px 22px', borderTop: `1px solid ${C.borderSoft}`, background:
|
|
178
|
+
padding: '14px 22px', borderTop: `1px solid ${C.borderSoft}`, background: C.base,
|
|
173
179
|
borderRadius: `0 0 ${R.lg}px ${R.lg}px`,
|
|
174
180
|
}
|
|
175
181
|
|
|
@@ -282,8 +288,8 @@ export function ToolchainOnboarding(props: OnboardingProps): ReactNode {
|
|
|
282
288
|
{
|
|
283
289
|
style: {
|
|
284
290
|
display: 'flex', flexDirection: 'column', width: 672, maxWidth: '100%', maxHeight: '92vh',
|
|
285
|
-
background:
|
|
286
|
-
boxShadow:
|
|
291
|
+
background: C.panel, border: `1px solid ${C.border}`, borderRadius: R.lg,
|
|
292
|
+
boxShadow: `0 24px 64px ${C.shadow}`, overflow: 'hidden',
|
|
287
293
|
},
|
|
288
294
|
},
|
|
289
295
|
// Header: the HuaQiu mark (`assets/huaqiu.svg`, inlined in `brand.ts`), title,
|
|
@@ -339,7 +345,7 @@ export function ToolchainOnboarding(props: OnboardingProps): ReactNode {
|
|
|
339
345
|
'div',
|
|
340
346
|
{ style: CALLOUT },
|
|
341
347
|
createElement(Glyph, {
|
|
342
|
-
path: TOOLCHAIN_ICONS.info, size: 16, color:
|
|
348
|
+
path: TOOLCHAIN_ICONS.info, size: 16, color: C.link, extra: 'M12 3a9 9 0 1018 0 9 9 0 00-18 0z',
|
|
343
349
|
}),
|
|
344
350
|
createElement('div', { style: { minWidth: 0 } }, COPY.wizard.callout),
|
|
345
351
|
),
|