@huaqiu/dsh-hardware-ui 0.7.18 → 0.7.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +9583 -627
- package/lib/client.js.map +1 -1
- package/lib/index.d.mts +35 -14
- package/lib/index.mjs +118 -10
- package/package.json +7 -3
- package/src/client/brand.ts +17 -0
- package/src/client/components.tsx +26 -133
- package/src/client/copy.ts +372 -243
- package/src/client/document/EcadBody.tsx +212 -0
- package/src/client/document/StepBody.tsx +124 -0
- package/src/client/document/contract.ts +156 -0
- package/src/client/document/copy.ts +49 -0
- package/src/client/document/index.ts +134 -0
- package/src/client/document/mount.ts +261 -0
- package/src/client/document/occt.d.ts +54 -0
- package/src/client/document/paths.ts +122 -0
- package/src/client/document/sheets.ts +83 -0
- package/src/client/document/step.ts +255 -0
- package/src/client/index.ts +172 -4
- package/src/client/locales.ts +604 -0
- package/src/client/model.ts +18 -9
- package/src/client/order-page.ts +44 -0
- package/src/client/order-tab.tsx +117 -0
- package/src/client/order-watcher.ts +121 -0
- package/src/client/order.tsx +9 -9
- package/src/client/toolchain-view.tsx +724 -0
- package/src/client/toolchain.ts +620 -0
- package/src/client/transport.ts +83 -4
- package/src/client/wizard.tsx +312 -261
- package/src/index.ts +126 -10
- package/src/shared/occt-asset.ts +21 -0
package/src/client/transport.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { describeHostError } from './copy.js'
|
|
|
3
3
|
import type {
|
|
4
4
|
DiscoveryInfo, HardwareProjectInfo, InstallationsInfo, NativeApplication,
|
|
5
5
|
} from './model.js'
|
|
6
|
+
import type {
|
|
7
|
+
BrowseOutcome, InstallJob, ToolchainId, ToolchainStatus, ToolSource, ValidationOutcome,
|
|
8
|
+
} from './toolchain.js'
|
|
6
9
|
|
|
7
10
|
const PREFIX = '/api/v1/hardware'
|
|
8
11
|
|
|
@@ -262,20 +265,19 @@ export interface PlacedOrder {
|
|
|
262
265
|
|
|
263
266
|
/**
|
|
264
267
|
* Submit one order. `confirm` is what the host requires; the panel sets it only
|
|
265
|
-
* after the user confirms the upload in the dialog. The host opens the
|
|
266
|
-
* page
|
|
268
|
+
* after the user confirms the upload in the dialog. The host never opens the
|
|
269
|
+
* page by itself — the client shows `orderUrl` in its own Browser tab.
|
|
267
270
|
*/
|
|
268
271
|
export async function placeOrder(
|
|
269
272
|
kind: 'pcb' | 'smt',
|
|
270
273
|
requestBody: {
|
|
271
274
|
path: string
|
|
272
275
|
schematic?: string
|
|
273
|
-
/** Workspace root
|
|
276
|
+
/** Workspace root of the panel's session; the base for a relative path. */
|
|
274
277
|
cwd?: string
|
|
275
278
|
session?: string
|
|
276
279
|
quantity?: number
|
|
277
280
|
confirm: boolean
|
|
278
|
-
launch?: boolean
|
|
279
281
|
},
|
|
280
282
|
signal?: AbortSignal,
|
|
281
283
|
): Promise<PlacedOrder> {
|
|
@@ -295,3 +297,80 @@ export async function openOrderUrl(url: string): Promise<{ readonly launched: bo
|
|
|
295
297
|
body: JSON.stringify({ url }),
|
|
296
298
|
})
|
|
297
299
|
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Toolchain capability calls (`/api/v1/hardware/toolchain`).
|
|
303
|
+
*
|
|
304
|
+
* Every read is a poll: the Host owns the truth, including whether a job is
|
|
305
|
+
* still running, so nothing here caches. `install` is the one call that answers
|
|
306
|
+
* a *state* rather than a failure when a download is impossible (no manifest
|
|
307
|
+
* entry for this platform) — that state is the UI's cue to offer the official
|
|
308
|
+
* page instead (§9.2/§14.2), which is why it resolves to `undefined`.
|
|
309
|
+
*/
|
|
310
|
+
/** `?job=a,b` — the panel watches both tools' runs at once, so ids travel together. */
|
|
311
|
+
export async function loadToolchainStatus(jobIds?: readonly string[]): Promise<ToolchainStatus> {
|
|
312
|
+
const ids = (jobIds ?? []).filter(id => id !== '')
|
|
313
|
+
const suffix = ids.length === 0 ? '' : `?job=${encodeURIComponent(ids.join(','))}`
|
|
314
|
+
return request<ToolchainStatus>(`/toolchain/status${suffix}`)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** Validate one path without persisting it (the input's own verdict). */
|
|
318
|
+
export async function validateToolchain(tool: ToolchainId, path: string): Promise<ValidationOutcome> {
|
|
319
|
+
return request<ValidationOutcome>('/toolchain/validate', {
|
|
320
|
+
method: 'POST',
|
|
321
|
+
headers: { 'content-type': 'application/json' },
|
|
322
|
+
body: JSON.stringify({ tool, path }),
|
|
323
|
+
})
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** Validate and persist one path; the Host settings service stays authoritative. */
|
|
327
|
+
export async function saveToolchain(
|
|
328
|
+
tool: ToolchainId,
|
|
329
|
+
path: string,
|
|
330
|
+
source: ToolSource,
|
|
331
|
+
): Promise<ValidationOutcome> {
|
|
332
|
+
return request<ValidationOutcome>('/toolchain/save', {
|
|
333
|
+
method: 'POST',
|
|
334
|
+
headers: { 'content-type': 'application/json' },
|
|
335
|
+
body: JSON.stringify({ tool, path, source }),
|
|
336
|
+
})
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** Open the Host's native chooser for one tool; a cancellation is not an error. */
|
|
340
|
+
export async function browseToolchain(tool: ToolchainId): Promise<BrowseOutcome> {
|
|
341
|
+
return request<BrowseOutcome>('/toolchain/browse', {
|
|
342
|
+
method: 'POST',
|
|
343
|
+
headers: { 'content-type': 'application/json' },
|
|
344
|
+
body: JSON.stringify({ tool }),
|
|
345
|
+
})
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** Start the manifest download for one tool; `undefined` means "not offered here". */
|
|
349
|
+
export async function installToolchain(tool: ToolchainId): Promise<InstallJob | undefined> {
|
|
350
|
+
const body = await request<{ readonly job?: InstallJob }>('/toolchain/install', {
|
|
351
|
+
method: 'POST',
|
|
352
|
+
headers: { 'content-type': 'application/json' },
|
|
353
|
+
body: JSON.stringify({ tool }),
|
|
354
|
+
})
|
|
355
|
+
return body.job
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** Cancel one running job; the Host reports whether it was still cancellable. */
|
|
359
|
+
export async function cancelToolchain(id: string): Promise<boolean> {
|
|
360
|
+
const body = await request<{ readonly cancelled?: boolean }>('/toolchain/cancel', {
|
|
361
|
+
method: 'POST',
|
|
362
|
+
headers: { 'content-type': 'application/json' },
|
|
363
|
+
body: JSON.stringify({ id }),
|
|
364
|
+
})
|
|
365
|
+
return body.cancelled === true
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** Start background discovery (answers immediately, verdicts arrive by poll). */
|
|
369
|
+
export async function startToolchainDiscovery(tool?: ToolchainId): Promise<void> {
|
|
370
|
+
await request('/toolchain/discover', {
|
|
371
|
+
method: 'POST',
|
|
372
|
+
headers: { 'content-type': 'application/json' },
|
|
373
|
+
body: JSON.stringify(tool === undefined ? {} : { tool }),
|
|
374
|
+
})
|
|
375
|
+
}
|
|
376
|
+
|