@huaqiu/dsh-engineering-workbench 0.7.27 → 0.7.29
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/README.md +10 -9
- package/lib/client.js +1883 -1348
- package/lib/host.mjs +89 -7
- package/package.json +3 -2
package/lib/client.js
CHANGED
|
@@ -107439,6 +107439,22 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
107439
107439
|
};
|
|
107440
107440
|
}
|
|
107441
107441
|
const basename = (path) => path.split(/[\\/]/).pop() || path;
|
|
107442
|
+
/** Choose a production project only when the workspace layout identifies one unambiguously. */
|
|
107443
|
+
function defaultCircuitProject(projects, cwd) {
|
|
107444
|
+
if (!cwd) return void 0;
|
|
107445
|
+
const normalize = (path) => {
|
|
107446
|
+
const slashes = path.replaceAll("\\", "/");
|
|
107447
|
+
return /^(?:[a-z]:\/|\/\/)/i.test(slashes) ? slashes.toLowerCase() : slashes;
|
|
107448
|
+
};
|
|
107449
|
+
const root = normalize(cwd).replace(/\/+$/, "") + "/";
|
|
107450
|
+
const candidates = projects.filter((project) => {
|
|
107451
|
+
const path = normalize(project.path);
|
|
107452
|
+
if (!path.startsWith(root) || !/\.kicad_pro$/i.test(path)) return false;
|
|
107453
|
+
const dirs = path.slice(root.length).split("/").slice(0, -1);
|
|
107454
|
+
return dirs.at(-1)?.toLowerCase() === "project" && !dirs.some((dir) => /^\.?candidates?(?:$|[-_.\d])/i.test(dir) || [".history", ".runtime"].includes(dir.toLowerCase()));
|
|
107455
|
+
});
|
|
107456
|
+
return candidates.length === 1 ? candidates[0] : void 0;
|
|
107457
|
+
}
|
|
107442
107458
|
function matches(path, wanted) {
|
|
107443
107459
|
const normal = (s) => s.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
107444
107460
|
let p = normal(path), w = normal(wanted);
|
|
@@ -107617,7 +107633,7 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
107617
107633
|
async function readManufacturingBom(path, cwd, session, signal) {
|
|
107618
107634
|
try {
|
|
107619
107635
|
return {
|
|
107620
|
-
|
|
107636
|
+
...await manufacturingRequest("bom", { path }, signal),
|
|
107621
107637
|
builtIn: false
|
|
107622
107638
|
};
|
|
107623
107639
|
} catch (error) {
|
|
@@ -107628,6 +107644,8 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
107628
107644
|
session,
|
|
107629
107645
|
signal
|
|
107630
107646
|
})).rows,
|
|
107647
|
+
saved: void 0,
|
|
107648
|
+
warning: void 0,
|
|
107631
107649
|
builtIn: true
|
|
107632
107650
|
};
|
|
107633
107651
|
}
|
|
@@ -107750,7 +107768,7 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
107750
107768
|
minimumFractionDigits: 2,
|
|
107751
107769
|
maximumFractionDigits: digits
|
|
107752
107770
|
});
|
|
107753
|
-
function BomGrid({ rows, matches, reference, quantity, busy, summary, select, choose }) {
|
|
107771
|
+
function BomGrid({ rows, matches, reference, quantity, busy, saving, summary, select, choose }) {
|
|
107754
107772
|
const [layout, setLayout] = (0, react.useState)(readLayout);
|
|
107755
107773
|
const [query, setQuery] = (0, react.useState)("");
|
|
107756
107774
|
const [drop, setDrop] = (0, react.useState)();
|
|
@@ -107956,6 +107974,7 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
107956
107974
|
children: status
|
|
107957
107975
|
}),
|
|
107958
107976
|
mpn: !row.dnp && options.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
107977
|
+
disabled: saving,
|
|
107959
107978
|
"aria-label": key + " 采购型号",
|
|
107960
107979
|
title: [
|
|
107961
107980
|
candidate?.mpn,
|
|
@@ -108142,6 +108161,128 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
108142
108161
|
});
|
|
108143
108162
|
}
|
|
108144
108163
|
//#endregion
|
|
108164
|
+
//#region src/bom-snapshot.ts
|
|
108165
|
+
function snapshotLines(rows, matches) {
|
|
108166
|
+
return rows.map((row) => {
|
|
108167
|
+
const match = matches[row.references.join(", ")];
|
|
108168
|
+
if (!match) return { row };
|
|
108169
|
+
return {
|
|
108170
|
+
row,
|
|
108171
|
+
candidates: match.candidates,
|
|
108172
|
+
selection: match.selected ? match.candidates.indexOf(match.selected) : -1,
|
|
108173
|
+
error: match.error
|
|
108174
|
+
};
|
|
108175
|
+
});
|
|
108176
|
+
}
|
|
108177
|
+
function signature(row) {
|
|
108178
|
+
return JSON.stringify([
|
|
108179
|
+
[...row.references].sort(),
|
|
108180
|
+
row.quantity,
|
|
108181
|
+
row.value,
|
|
108182
|
+
row.footprint,
|
|
108183
|
+
row.dnp,
|
|
108184
|
+
Object.entries(row.fields).sort(([a], [b]) => a.localeCompare(b))
|
|
108185
|
+
]);
|
|
108186
|
+
}
|
|
108187
|
+
function restoreMatches(rows, saved) {
|
|
108188
|
+
const previous = new Map(saved.lines.map((line) => [signature(line.row), line]));
|
|
108189
|
+
const matches = {};
|
|
108190
|
+
let unchanged = 0;
|
|
108191
|
+
for (const row of rows) {
|
|
108192
|
+
const line = previous.get(signature(row));
|
|
108193
|
+
if (!line) continue;
|
|
108194
|
+
unchanged++;
|
|
108195
|
+
if (line.candidates) matches[row.references.join(", ")] = {
|
|
108196
|
+
candidates: line.candidates,
|
|
108197
|
+
selected: line.candidates[line.selection ?? -1],
|
|
108198
|
+
error: line.error
|
|
108199
|
+
};
|
|
108200
|
+
}
|
|
108201
|
+
return {
|
|
108202
|
+
matches,
|
|
108203
|
+
changed: unchanged !== rows.length || unchanged !== saved.lines.length
|
|
108204
|
+
};
|
|
108205
|
+
}
|
|
108206
|
+
//#endregion
|
|
108207
|
+
//#region src/bom-export.ts
|
|
108208
|
+
function cell(value) {
|
|
108209
|
+
let text = String(value ?? "");
|
|
108210
|
+
if (typeof value === "string" && (/^\s*[=+@-]/.test(text) || /^[\t\r\n]/.test(text))) text = "'" + text;
|
|
108211
|
+
return "\"" + text.replaceAll("\"", "\"\"") + "\"";
|
|
108212
|
+
}
|
|
108213
|
+
function bomCsv(rows, matches, quantity, queriedAt) {
|
|
108214
|
+
const summary = basket(rows, matches, quantity);
|
|
108215
|
+
const counted = /* @__PURE__ */ new Set();
|
|
108216
|
+
const table = [[
|
|
108217
|
+
"位号",
|
|
108218
|
+
"名称 / 值",
|
|
108219
|
+
"封装",
|
|
108220
|
+
"原厂型号",
|
|
108221
|
+
"数量/板",
|
|
108222
|
+
"生产批量",
|
|
108223
|
+
"需求数量",
|
|
108224
|
+
"采购状态",
|
|
108225
|
+
"采购型号",
|
|
108226
|
+
"制造商",
|
|
108227
|
+
"华秋料号",
|
|
108228
|
+
"供应商",
|
|
108229
|
+
"供应商料号",
|
|
108230
|
+
"库存",
|
|
108231
|
+
"起订量",
|
|
108232
|
+
"单价(元)",
|
|
108233
|
+
"同型号合购数量(仅首行)",
|
|
108234
|
+
"合购金额(元,仅首行)",
|
|
108235
|
+
"待确认候选型号",
|
|
108236
|
+
"询价时间",
|
|
108237
|
+
"查询说明"
|
|
108238
|
+
]];
|
|
108239
|
+
for (const row of rows) {
|
|
108240
|
+
const match = matches[rowKey(row)], part = row.dnp ? void 0 : match?.selected;
|
|
108241
|
+
const price = summary.priceFor(part);
|
|
108242
|
+
const id = part && JSON.stringify([part.manufacturerId, part.mpn]);
|
|
108243
|
+
const first = !!id && !counted.has(id);
|
|
108244
|
+
if (id) counted.add(id);
|
|
108245
|
+
const state = row.dnp ? "不装配" : match?.error ? "查询失败" : part ? price ? "已匹配" : "未报价" : match?.candidates.length ? "待确认" : match ? "无匹配" : "待查询";
|
|
108246
|
+
table.push([
|
|
108247
|
+
rowKey(row),
|
|
108248
|
+
row.value,
|
|
108249
|
+
row.footprint,
|
|
108250
|
+
originalMpn(row),
|
|
108251
|
+
row.quantity,
|
|
108252
|
+
quantity,
|
|
108253
|
+
row.dnp ? 0 : row.quantity * quantity,
|
|
108254
|
+
state,
|
|
108255
|
+
part?.mpn,
|
|
108256
|
+
part?.manufacturer,
|
|
108257
|
+
part?.huaqiuPn,
|
|
108258
|
+
price?.offer.vendor,
|
|
108259
|
+
price?.offer.sku,
|
|
108260
|
+
price?.offer.stock,
|
|
108261
|
+
price && (price.offer.moq || 1),
|
|
108262
|
+
price?.unit,
|
|
108263
|
+
first ? price?.count : "",
|
|
108264
|
+
first && price ? Number(price.cost.toFixed(6)) : "",
|
|
108265
|
+
!part ? match?.candidates.map((c) => c.mpn).join(" / ") : "",
|
|
108266
|
+
queriedAt,
|
|
108267
|
+
match?.error
|
|
108268
|
+
]);
|
|
108269
|
+
}
|
|
108270
|
+
return "" + table.map((r) => r.map(cell).join(",")).join("\r\n") + "\r\n";
|
|
108271
|
+
}
|
|
108272
|
+
function downloadBom(path, csv) {
|
|
108273
|
+
const link = document.createElement("a");
|
|
108274
|
+
const url = URL.createObjectURL(new Blob([csv], { type: "text/csv;charset=utf-8" }));
|
|
108275
|
+
link.href = url;
|
|
108276
|
+
link.download = (path.split(/[\\/]/).pop() || "工程").replace(/\.kicad_sch$/i, "") + "-BOM.csv";
|
|
108277
|
+
document.body.append(link);
|
|
108278
|
+
try {
|
|
108279
|
+
link.click();
|
|
108280
|
+
} finally {
|
|
108281
|
+
link.remove();
|
|
108282
|
+
setTimeout(() => URL.revokeObjectURL(url), 3e4);
|
|
108283
|
+
}
|
|
108284
|
+
}
|
|
108285
|
+
//#endregion
|
|
108145
108286
|
//#region src/Manufacture.tsx
|
|
108146
108287
|
const manufacturingTabs = [
|
|
108147
108288
|
"BOM",
|
|
@@ -108152,8 +108293,9 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
108152
108293
|
minimumFractionDigits: 2,
|
|
108153
108294
|
maximumFractionDigits: digits
|
|
108154
108295
|
});
|
|
108155
|
-
function Manufacture({ tab, path, board, cwd, session, reference, location, select, order, ask }) {
|
|
108296
|
+
function Manufacture({ tab, path, board, boardKey = board, cwd, session, reference, location, select, order, ask }) {
|
|
108156
108297
|
const [rows, setRows] = (0, react.useState)([]);
|
|
108298
|
+
const [loading, setLoading] = (0, react.useState)(!!path);
|
|
108157
108299
|
const [message, setMessage] = (0, react.useState)("");
|
|
108158
108300
|
const [quantity, setQuantity] = (0, react.useState)(5);
|
|
108159
108301
|
const [run, setRun] = (0, react.useState)(0);
|
|
@@ -108164,27 +108306,52 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
108164
108306
|
pcb: "待查询",
|
|
108165
108307
|
smt: "待查询"
|
|
108166
108308
|
});
|
|
108309
|
+
const [queriedAt, setQueriedAt] = (0, react.useState)("");
|
|
108310
|
+
const [saved, setSaved] = (0, react.useState)();
|
|
108311
|
+
const [saving, setSaving] = (0, react.useState)(false);
|
|
108312
|
+
const [dirty, setDirty] = (0, react.useState)(false);
|
|
108313
|
+
const [saveError, setSaveError] = (0, react.useState)("");
|
|
108167
108314
|
(0, react.useEffect)(() => {
|
|
108168
108315
|
if (!path) {
|
|
108169
108316
|
setMessage("请选择原理图以生成 BOM。");
|
|
108170
108317
|
return;
|
|
108171
108318
|
}
|
|
108172
108319
|
const ctrl = new AbortController();
|
|
108320
|
+
setLoading(true);
|
|
108173
108321
|
setMessage("正在从原理图生成 BOM…");
|
|
108174
108322
|
readManufacturingBom(path, cwd, session, ctrl.signal).then((bom) => {
|
|
108175
|
-
if (
|
|
108176
|
-
|
|
108177
|
-
|
|
108178
|
-
|
|
108323
|
+
if (ctrl.signal.aborted) return;
|
|
108324
|
+
setRows(bom.rows);
|
|
108325
|
+
setBuiltIn(bom.builtIn);
|
|
108326
|
+
let message = bom.warning || (bom.rows.length ? "" : "该原理图没有物料记录。");
|
|
108327
|
+
if (bom.saved) {
|
|
108328
|
+
const previous = bom.saved;
|
|
108329
|
+
const restored = restoreMatches(bom.rows, previous);
|
|
108330
|
+
setSaved({
|
|
108331
|
+
version: previous.version,
|
|
108332
|
+
savedAt: previous.savedAt
|
|
108333
|
+
});
|
|
108334
|
+
setMatches(restored.matches);
|
|
108335
|
+
setQuantity(previous.quantity);
|
|
108336
|
+
setQueriedAt(previous.queriedAt);
|
|
108337
|
+
if (previous.boardKey === boardKey) setQuotes(previous.quotes);
|
|
108338
|
+
if (restored.changed) {
|
|
108339
|
+
message = [message, "原理图物料已变更,仅恢复了未变更行的采购结果。"].filter(Boolean).join(" ");
|
|
108340
|
+
setDirty(true);
|
|
108341
|
+
}
|
|
108179
108342
|
}
|
|
108343
|
+
setMessage(message);
|
|
108180
108344
|
}).catch((e) => {
|
|
108181
108345
|
if (!ctrl.signal.aborted) setMessage(String(e.message));
|
|
108346
|
+
}).finally(() => {
|
|
108347
|
+
if (!ctrl.signal.aborted) setLoading(false);
|
|
108182
108348
|
});
|
|
108183
108349
|
return () => ctrl.abort();
|
|
108184
108350
|
}, [
|
|
108185
108351
|
path,
|
|
108186
108352
|
cwd,
|
|
108187
|
-
session
|
|
108353
|
+
session,
|
|
108354
|
+
boardKey
|
|
108188
108355
|
]);
|
|
108189
108356
|
(0, react.useEffect)(() => {
|
|
108190
108357
|
if (!run) return;
|
|
@@ -108264,7 +108431,32 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
108264
108431
|
quantity
|
|
108265
108432
|
]);
|
|
108266
108433
|
const part = rows.find((r) => r.references.some((ref) => ref.toUpperCase() === reference.toUpperCase()));
|
|
108267
|
-
const total = summary.covered ? money(summary.total) + (summary.covered < summary.lines ? "(部分)" : "") :
|
|
108434
|
+
const total = summary.covered ? money(summary.total) + (summary.covered < summary.lines ? "(部分)" : "") : queriedAt ? "暂无已报价项" : "待查询";
|
|
108435
|
+
const querying = busy || quotes.pcb === "查询中…" || quotes.smt === "查询中…";
|
|
108436
|
+
async function save() {
|
|
108437
|
+
setSaving(true);
|
|
108438
|
+
setSaveError("");
|
|
108439
|
+
try {
|
|
108440
|
+
const result = await manufacturingRequest("save-bom", {
|
|
108441
|
+
path,
|
|
108442
|
+
version: saved?.version ?? null,
|
|
108443
|
+
snapshot: {
|
|
108444
|
+
schema: 1,
|
|
108445
|
+
boardKey,
|
|
108446
|
+
quantity,
|
|
108447
|
+
queriedAt,
|
|
108448
|
+
quotes,
|
|
108449
|
+
lines: snapshotLines(rows, matches)
|
|
108450
|
+
}
|
|
108451
|
+
}, new AbortController().signal);
|
|
108452
|
+
setSaved(result);
|
|
108453
|
+
setDirty(false);
|
|
108454
|
+
} catch (e) {
|
|
108455
|
+
setSaveError("保存失败。" + (e instanceof Error ? e.message : String(e)));
|
|
108456
|
+
} finally {
|
|
108457
|
+
setSaving(false);
|
|
108458
|
+
}
|
|
108459
|
+
}
|
|
108268
108460
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
108269
108461
|
className: "ew-manufacture",
|
|
108270
108462
|
"data-manufacturing-tab": tab,
|
|
@@ -108282,14 +108474,26 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
108282
108474
|
value: quantity,
|
|
108283
108475
|
onChange: (e) => {
|
|
108284
108476
|
const n = e.target.valueAsNumber;
|
|
108285
|
-
if (Number.isSafeInteger(n) && n >= 1 && n <= 1e5
|
|
108286
|
-
|
|
108477
|
+
if (Number.isSafeInteger(n) && n >= 1 && n <= 1e5 && n !== quantity) {
|
|
108478
|
+
setQuantity(n);
|
|
108479
|
+
setDirty(true);
|
|
108480
|
+
if (!run) setQuotes({
|
|
108481
|
+
pcb: "待查询",
|
|
108482
|
+
smt: "待查询"
|
|
108483
|
+
});
|
|
108484
|
+
}
|
|
108485
|
+
},
|
|
108486
|
+
disabled: saving || loading
|
|
108287
108487
|
}),
|
|
108288
108488
|
" 块"
|
|
108289
108489
|
] }),
|
|
108290
108490
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
108291
|
-
onClick: () =>
|
|
108292
|
-
|
|
108491
|
+
onClick: () => {
|
|
108492
|
+
setRun((n) => n + 1);
|
|
108493
|
+
setQueriedAt((/* @__PURE__ */ new Date()).toISOString());
|
|
108494
|
+
setDirty(true);
|
|
108495
|
+
},
|
|
108496
|
+
disabled: loading || querying || saving || builtIn || !rows.length && !board,
|
|
108293
108497
|
children: busy ? "正在匹配器件…" : "查询华秋价格"
|
|
108294
108498
|
}),
|
|
108295
108499
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
@@ -108310,7 +108514,7 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
108310
108514
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
108311
108515
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: "BOM 采购" }),
|
|
108312
108516
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: total }),
|
|
108313
|
-
|
|
108517
|
+
queriedAt && summary.lines > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("small", { children: [
|
|
108314
108518
|
summary.covered,
|
|
108315
108519
|
"/",
|
|
108316
108520
|
summary.lines,
|
|
@@ -108329,6 +108533,25 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
108329
108533
|
role: "status",
|
|
108330
108534
|
children: message
|
|
108331
108535
|
}),
|
|
108536
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
108537
|
+
className: "ew-files",
|
|
108538
|
+
children: [
|
|
108539
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
108540
|
+
onClick: save,
|
|
108541
|
+
disabled: !rows.length || querying || saving || builtIn,
|
|
108542
|
+
children: saving ? "保存中…" : "保存 BOM"
|
|
108543
|
+
}),
|
|
108544
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
108545
|
+
disabled: !rows.length || querying,
|
|
108546
|
+
onClick: () => downloadBom(path, bomCsv(rows, matches, quantity, queriedAt)),
|
|
108547
|
+
children: "导出 CSV"
|
|
108548
|
+
}),
|
|
108549
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
108550
|
+
role: "status",
|
|
108551
|
+
children: saveError || (dirty ? "有未保存的更改" : saved ? "已保存 · " + new Date(saved.savedAt).toLocaleString("zh-CN") : "")
|
|
108552
|
+
})
|
|
108553
|
+
]
|
|
108554
|
+
}),
|
|
108332
108555
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BomGrid, {
|
|
108333
108556
|
rows,
|
|
108334
108557
|
matches,
|
|
@@ -108337,13 +108560,17 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
108337
108560
|
busy,
|
|
108338
108561
|
summary,
|
|
108339
108562
|
select,
|
|
108340
|
-
|
|
108341
|
-
|
|
108342
|
-
|
|
108343
|
-
|
|
108344
|
-
|
|
108345
|
-
|
|
108346
|
-
|
|
108563
|
+
saving,
|
|
108564
|
+
choose: (key, selected) => {
|
|
108565
|
+
setDirty(true);
|
|
108566
|
+
setMatches((prev) => ({
|
|
108567
|
+
...prev,
|
|
108568
|
+
[key]: {
|
|
108569
|
+
...prev[key],
|
|
108570
|
+
selected
|
|
108571
|
+
}
|
|
108572
|
+
}));
|
|
108573
|
+
}
|
|
108347
108574
|
}),
|
|
108348
108575
|
part && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", { children: [
|
|
108349
108576
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: ["位号 ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
@@ -108362,454 +108589,1285 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
108362
108589
|
]
|
|
108363
108590
|
});
|
|
108364
108591
|
}
|
|
108365
|
-
|
|
108366
|
-
|
|
108367
|
-
|
|
108368
|
-
|
|
108369
|
-
|
|
108370
|
-
|
|
108371
|
-
|
|
108372
|
-
|
|
108373
|
-
|
|
108374
|
-
|
|
108375
|
-
|
|
108376
|
-
|
|
108377
|
-
|
|
108378
|
-
|
|
108379
|
-
|
|
108380
|
-
|
|
108381
|
-
|
|
108382
|
-
|
|
108383
|
-
|
|
108384
|
-
|
|
108385
|
-
|
|
108386
|
-
|
|
108387
|
-
|
|
108388
|
-
|
|
108389
|
-
|
|
108390
|
-
|
|
108391
|
-
|
|
108392
|
-
|
|
108393
|
-
|
|
108394
|
-
|
|
108395
|
-
|
|
108396
|
-
|
|
108397
|
-
|
|
108398
|
-
|
|
108399
|
-
|
|
108400
|
-
|
|
108401
|
-
|
|
108402
|
-
|
|
108403
|
-
|
|
108404
|
-
|
|
108405
|
-
|
|
108406
|
-
|
|
108407
|
-
|
|
108408
|
-
|
|
108409
|
-
|
|
108410
|
-
|
|
108411
|
-
|
|
108412
|
-
|
|
108413
|
-
|
|
108414
|
-
|
|
108415
|
-
|
|
108416
|
-
|
|
108417
|
-
|
|
108418
|
-
|
|
108419
|
-
|
|
108420
|
-
|
|
108421
|
-
|
|
108422
|
-
|
|
108423
|
-
|
|
108424
|
-
|
|
108425
|
-
|
|
108426
|
-
|
|
108427
|
-
|
|
108428
|
-
|
|
108429
|
-
|
|
108430
|
-
|
|
108431
|
-
|
|
108432
|
-
|
|
108433
|
-
|
|
108434
|
-
|
|
108435
|
-
|
|
108436
|
-
|
|
108437
|
-
|
|
108438
|
-
|
|
108439
|
-
|
|
108440
|
-
|
|
108441
|
-
|
|
108442
|
-
|
|
108443
|
-
|
|
108444
|
-
|
|
108445
|
-
|
|
108446
|
-
|
|
108447
|
-
|
|
108448
|
-
|
|
108449
|
-
|
|
108450
|
-
|
|
108451
|
-
|
|
108452
|
-
|
|
108453
|
-
|
|
108454
|
-
|
|
108455
|
-
|
|
108456
|
-
|
|
108457
|
-
|
|
108458
|
-
|
|
108459
|
-
|
|
108460
|
-
|
|
108461
|
-
|
|
108462
|
-
|
|
108463
|
-
|
|
108464
|
-
|
|
108465
|
-
|
|
108466
|
-
|
|
108467
|
-
|
|
108468
|
-
|
|
108469
|
-
|
|
108470
|
-
|
|
108471
|
-
|
|
108472
|
-
|
|
108473
|
-
|
|
108474
|
-
|
|
108475
|
-
|
|
108476
|
-
|
|
108477
|
-
|
|
108478
|
-
|
|
108479
|
-
|
|
108480
|
-
|
|
108481
|
-
|
|
108482
|
-
|
|
108483
|
-
|
|
108484
|
-
|
|
108485
|
-
|
|
108486
|
-
|
|
108487
|
-
|
|
108488
|
-
|
|
108489
|
-
|
|
108490
|
-
|
|
108491
|
-
|
|
108492
|
-
|
|
108493
|
-
|
|
108494
|
-
|
|
108495
|
-
|
|
108496
|
-
|
|
108497
|
-
|
|
108498
|
-
|
|
108499
|
-
|
|
108500
|
-
|
|
108501
|
-
|
|
108502
|
-
|
|
108503
|
-
|
|
108504
|
-
|
|
108505
|
-
|
|
108506
|
-
|
|
108507
|
-
|
|
108508
|
-
|
|
108509
|
-
|
|
108510
|
-
|
|
108511
|
-
|
|
108512
|
-
|
|
108513
|
-
|
|
108514
|
-
|
|
108515
|
-
|
|
108516
|
-
|
|
108517
|
-
|
|
108518
|
-
|
|
108519
|
-
|
|
108520
|
-
|
|
108521
|
-
|
|
108522
|
-
|
|
108523
|
-
|
|
108524
|
-
|
|
108525
|
-
|
|
108526
|
-
|
|
108527
|
-
|
|
108528
|
-
|
|
108529
|
-
|
|
108530
|
-
|
|
108531
|
-
|
|
108532
|
-
|
|
108533
|
-
|
|
108534
|
-
|
|
108535
|
-
|
|
108536
|
-
|
|
108537
|
-
|
|
108538
|
-
|
|
108539
|
-
|
|
108540
|
-
|
|
108541
|
-
|
|
108542
|
-
|
|
108543
|
-
|
|
108544
|
-
|
|
108545
|
-
|
|
108546
|
-
|
|
108547
|
-
|
|
108548
|
-
|
|
108549
|
-
|
|
108550
|
-
|
|
108551
|
-
|
|
108552
|
-
|
|
108553
|
-
|
|
108554
|
-
|
|
108555
|
-
|
|
108556
|
-
|
|
108557
|
-
|
|
108558
|
-
|
|
108559
|
-
|
|
108560
|
-
|
|
108561
|
-
|
|
108562
|
-
|
|
108563
|
-
|
|
108564
|
-
|
|
108565
|
-
|
|
108566
|
-
|
|
108567
|
-
|
|
108568
|
-
|
|
108569
|
-
|
|
108570
|
-
|
|
108571
|
-
|
|
108572
|
-
|
|
108573
|
-
|
|
108574
|
-
|
|
108575
|
-
|
|
108576
|
-
|
|
108577
|
-
|
|
108578
|
-
|
|
108579
|
-
|
|
108580
|
-
|
|
108581
|
-
|
|
108582
|
-
|
|
108583
|
-
|
|
108584
|
-
|
|
108585
|
-
|
|
108586
|
-
|
|
108587
|
-
|
|
108588
|
-
|
|
108589
|
-
|
|
108590
|
-
|
|
108591
|
-
|
|
108592
|
-
|
|
108593
|
-
|
|
108594
|
-
|
|
108595
|
-
|
|
108596
|
-
|
|
108597
|
-
|
|
108598
|
-
|
|
108599
|
-
|
|
108600
|
-
|
|
108601
|
-
|
|
108602
|
-
|
|
108603
|
-
|
|
108604
|
-
|
|
108605
|
-
|
|
108606
|
-
|
|
108607
|
-
|
|
108608
|
-
|
|
108609
|
-
|
|
108610
|
-
|
|
108611
|
-
|
|
108612
|
-
|
|
108613
|
-
|
|
108614
|
-
|
|
108615
|
-
|
|
108616
|
-
|
|
108617
|
-
|
|
108618
|
-
|
|
108619
|
-
|
|
108620
|
-
|
|
108621
|
-
|
|
108622
|
-
|
|
108623
|
-
|
|
108624
|
-
|
|
108625
|
-
|
|
108626
|
-
|
|
108627
|
-
|
|
108628
|
-
|
|
108629
|
-
|
|
108630
|
-
|
|
108631
|
-
|
|
108632
|
-
|
|
108633
|
-
|
|
108634
|
-
|
|
108635
|
-
|
|
108636
|
-
|
|
108637
|
-
|
|
108638
|
-
|
|
108639
|
-
|
|
108640
|
-
|
|
108641
|
-
|
|
108642
|
-
|
|
108643
|
-
|
|
108644
|
-
|
|
108645
|
-
|
|
108646
|
-
|
|
108647
|
-
|
|
108648
|
-
|
|
108649
|
-
|
|
108650
|
-
|
|
108651
|
-
|
|
108652
|
-
|
|
108653
|
-
|
|
108654
|
-
|
|
108655
|
-
|
|
108656
|
-
|
|
108657
|
-
|
|
108658
|
-
|
|
108659
|
-
|
|
108660
|
-
|
|
108661
|
-
|
|
108662
|
-
|
|
108663
|
-
|
|
108664
|
-
|
|
108665
|
-
|
|
108666
|
-
|
|
108667
|
-
|
|
108668
|
-
|
|
108669
|
-
|
|
108670
|
-
|
|
108671
|
-
|
|
108672
|
-
|
|
108673
|
-
|
|
108674
|
-
|
|
108675
|
-
|
|
108676
|
-
|
|
108677
|
-
|
|
108678
|
-
|
|
108679
|
-
|
|
108680
|
-
|
|
108681
|
-
|
|
108682
|
-
|
|
108683
|
-
|
|
108684
|
-
|
|
108685
|
-
|
|
108686
|
-
|
|
108687
|
-
|
|
108688
|
-
|
|
108689
|
-
|
|
108690
|
-
|
|
108691
|
-
|
|
108692
|
-
|
|
108693
|
-
|
|
108694
|
-
|
|
108695
|
-
|
|
108696
|
-
|
|
108697
|
-
|
|
108698
|
-
|
|
108699
|
-
|
|
108700
|
-
|
|
108701
|
-
|
|
108702
|
-
|
|
108703
|
-
|
|
108704
|
-
|
|
108705
|
-
|
|
108706
|
-
|
|
108707
|
-
|
|
108708
|
-
|
|
108709
|
-
|
|
108710
|
-
|
|
108711
|
-
|
|
108712
|
-
|
|
108713
|
-
|
|
108714
|
-
|
|
108715
|
-
|
|
108716
|
-
|
|
108717
|
-
|
|
108718
|
-
|
|
108719
|
-
|
|
108720
|
-
|
|
108721
|
-
|
|
108722
|
-
|
|
108723
|
-
|
|
108724
|
-
|
|
108725
|
-
|
|
108726
|
-
|
|
108727
|
-
|
|
108728
|
-
|
|
108729
|
-
|
|
108730
|
-
|
|
108731
|
-
|
|
108732
|
-
|
|
108733
|
-
|
|
108734
|
-
|
|
108735
|
-
|
|
108736
|
-
|
|
108737
|
-
|
|
108738
|
-
|
|
108739
|
-
|
|
108740
|
-
|
|
108741
|
-
|
|
108742
|
-
|
|
108743
|
-
|
|
108744
|
-
|
|
108745
|
-
|
|
108746
|
-
|
|
108747
|
-
|
|
108748
|
-
|
|
108749
|
-
|
|
108750
|
-
|
|
108751
|
-
|
|
108752
|
-
|
|
108753
|
-
|
|
108754
|
-
|
|
108755
|
-
|
|
108756
|
-
|
|
108757
|
-
|
|
108758
|
-
|
|
108759
|
-
|
|
108760
|
-
|
|
108761
|
-
|
|
108762
|
-
|
|
108763
|
-
|
|
108764
|
-
|
|
108765
|
-
|
|
108766
|
-
|
|
108767
|
-
|
|
108768
|
-
|
|
108769
|
-
|
|
108770
|
-
|
|
108771
|
-
|
|
108772
|
-
|
|
108773
|
-
|
|
108774
|
-
|
|
108775
|
-
|
|
108776
|
-
|
|
108777
|
-
|
|
108778
|
-
|
|
108779
|
-
|
|
108780
|
-
|
|
108781
|
-
|
|
108782
|
-
|
|
108783
|
-
|
|
108784
|
-
|
|
108785
|
-
|
|
108786
|
-
|
|
108787
|
-
|
|
108788
|
-
|
|
108789
|
-
|
|
108790
|
-
|
|
108791
|
-
|
|
108792
|
-
|
|
108793
|
-
|
|
108794
|
-
|
|
108795
|
-
|
|
108796
|
-
|
|
108797
|
-
|
|
108798
|
-
|
|
108799
|
-
|
|
108800
|
-
|
|
108801
|
-
|
|
108802
|
-
|
|
108803
|
-
|
|
108804
|
-
|
|
108805
|
-
|
|
108806
|
-
|
|
108807
|
-
|
|
108808
|
-
|
|
108809
|
-
|
|
108810
|
-
|
|
108811
|
-
|
|
108812
|
-
|
|
108592
|
+
const MODES = [
|
|
108593
|
+
"design",
|
|
108594
|
+
"mechanical",
|
|
108595
|
+
"review",
|
|
108596
|
+
"manufacture"
|
|
108597
|
+
];
|
|
108598
|
+
function validRequest(value) {
|
|
108599
|
+
return !!value && MODES.includes(value.view) && (value.designTool === void 0 || value.view === "design" && [
|
|
108600
|
+
"schematic",
|
|
108601
|
+
"pcb",
|
|
108602
|
+
"3d"
|
|
108603
|
+
].includes(value.designTool)) && (value.action === void 0 || ["open", "suggest"].includes(value.action)) && [
|
|
108604
|
+
value.path,
|
|
108605
|
+
value.project,
|
|
108606
|
+
value.reference
|
|
108607
|
+
].every((s) => s === void 0 || typeof s === "string" && s.trim() && s.length <= 4096) && (value.path === void 0 || /\.kicad_(pcb|sch)$/i.test(value.path)) && (value.project === void 0 || /\.kicad_pro$/i.test(value.project));
|
|
108608
|
+
}
|
|
108609
|
+
function requestsIn(nodes) {
|
|
108610
|
+
const requests = /* @__PURE__ */ new Map();
|
|
108611
|
+
const visit = (node) => {
|
|
108612
|
+
if (!node || typeof node !== "object") return;
|
|
108613
|
+
if (node.kind === "tool-result" && node.call?.name === "hardware_open_workbench" && Array.isArray(node.content)) for (const block of node.content) {
|
|
108614
|
+
if (block.type !== "text") continue;
|
|
108615
|
+
try {
|
|
108616
|
+
const value = JSON.parse(block.text);
|
|
108617
|
+
if (validRequest(value) && typeof value.requestId === "string" && Number.isFinite(value.issuedAt)) requests.set(value.requestId, value);
|
|
108618
|
+
} catch {}
|
|
108619
|
+
}
|
|
108620
|
+
for (const key of [
|
|
108621
|
+
"children",
|
|
108622
|
+
"nodes",
|
|
108623
|
+
"subCalls"
|
|
108624
|
+
]) if (Array.isArray(node[key])) node[key].forEach(visit);
|
|
108625
|
+
};
|
|
108626
|
+
nodes.forEach(visit);
|
|
108627
|
+
return [...requests.values()];
|
|
108628
|
+
}
|
|
108629
|
+
//#endregion
|
|
108630
|
+
//#region src/styles.ts
|
|
108631
|
+
const styles = `
|
|
108632
|
+
.ew-model{margin:0 6px 6px;min-height:180px}.ew-model-info{overflow-wrap:anywhere}.ew-model-picker{position:relative;cursor:pointer;padding:4px 8px;border:1px solid var(--dsw-alias-border-l2,#abbcac);border-radius:4px}.ew-model-picker input{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer}.ew-model-picker:focus-within{outline:2px solid #bf845d;outline-offset:1px}
|
|
108633
|
+
.ew-file-control{display:inline-flex;flex-wrap:wrap;align-items:center;gap:4px;max-width:100%}.ew-files .ew-preview-toggle{padding:3px 6px;font-size:12px}
|
|
108634
|
+
.ew .ew-content[data-preview=false]{min-height:0}.ew .ew-content[data-preview=false] .ew-inspect{flex:1;width:auto;max-height:none}.ew .ew-content[data-preview=false] .ew-main{min-height:0}
|
|
108635
|
+
.ew-content{display:flex;flex:1;flex-direction:column;min-height:260px}.ew-content .ew-main{min-width:0}
|
|
108636
|
+
@container(min-width:800px){.ew-content{flex-direction:row}.ew-content .ew-inspect{width:230px;max-height:100%;border-left:1px solid var(--dsw-alias-border-l2,#c4cabb)}}
|
|
108637
|
+
.ew{container-type:inline-size;box-sizing:border-box;height:100%;min-height:0;display:flex;flex-direction:column;overflow:auto;background:var(--dsw-alias-bg-layer-1,#f7f4ed);color:var(--dsw-alias-label-primary,#213b30);font-size:13px;line-height:1.5;font-family:inherit}
|
|
108638
|
+
.ew-main{display:flex;flex:1;min-height:220px}.ew-main[data-manufacture=true] .ew-drawings{order:2;flex:1;min-width:0}.ew-manufacture{min-width:0}.ew *{box-sizing:border-box}.ew p{margin:12px}.ew button,.ew select,.ew input{font:inherit;color:inherit}
|
|
108639
|
+
.ew button,.ew select,.ew input:not([type=checkbox]){background:var(--dsw-alias-bg-layer-1,#faf8f1);border:1px solid var(--dsw-alias-border-l2,#abbcac);border-radius:4px;padding:4px 8px}
|
|
108640
|
+
.ew button{cursor:pointer}.ew button:disabled{opacity:.45;cursor:default}.ew :focus-visible{outline:2px solid #bf845d;outline-offset:1px}
|
|
108641
|
+
.ew-head,.ew-tools,.ew-files,.ew-inspect header,.ew-manufacture header,.ew-manufacture footer{display:flex;align-items:center;gap:8px;padding:8px 12px;flex-wrap:wrap}
|
|
108642
|
+
.ew-head{min-height:32px;padding-block:3px;padding-right:76px;background:#153f35;color:#faf3df;flex:none}
|
|
108643
|
+
.ew-head span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:40%}.ew-head select,.ew-head button{background:#204d40;border-color:#739181;color:#fff5e2}.ew-head select{max-width:48%}
|
|
108644
|
+
.ew button[aria-pressed=true]{background:#235642;color:#fff8e9;border-color:#386c53}
|
|
108645
|
+
.ew-tools,.ew-files{font-size:12px;padding-block:5px}.ew-files label{max-width:100%}.ew-files select{max-width:min(240px,70cqw)}.ew-drawings{display:flex;flex:1 0 200px;min-height:200px;padding:6px;gap:5px}.ew-pane{display:flex;flex-direction:column;flex:1;min-width:0;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l2,#bac8bc);border-radius:5px;overflow:hidden}.ew [hidden]{display:none!important}
|
|
108646
|
+
.ew-stage{position:relative;flex:1;min-height:140px}.ew-surface{position:absolute;inset:0;overflow:hidden}.ew-message{position:absolute;inset:15px;display:grid;place-content:center;text-align:center;pointer-events:none}.ew-pane small,.ew-inspect small{padding:3px 8px}
|
|
108647
|
+
.ew-inspect{padding:0 0 8px;border-top:1px solid var(--dsw-alias-border-l2,#c4cabb);max-height:32%;overflow:auto;flex:none}.ew-inspect input:not([type=checkbox]){width:130px}.ew-details,.ew-inspect>label{padding:2px 12px}.ew-details details span{display:inline-block;margin:2px 10px 2px 0}
|
|
108648
|
+
.ew-manufacture{display:flex;flex:1;min-height:180px;flex-direction:column}.ew-manufacture header{justify-content:space-between}.ew-table-wrap{overflow:auto;flex:1}
|
|
108649
|
+
.ew table{border-collapse:collapse;width:100%;text-align:left;font-size:12px}.ew th,.ew td{padding:6px 10px;border-bottom:1px solid var(--dsw-alias-border-l2,#c9d0c5)}.ew th{position:sticky;top:0;background:var(--dsw-alias-bg-layer-2,#e4e9de)}.ew tr[data-selected=true]{box-shadow:inset 3px 0 #ca906a;background:var(--dsw-alias-button-primary-dimmed)}
|
|
108650
|
+
@container(max-width:580px){.ew-main[data-manufacture=true]{flex-direction:column-reverse;min-height:440px}.ew-drawings[data-review=true]{flex-direction:column;min-height:310px}.ew-head{padding-right:68px}.ew-tools,.ew-files{gap:4px}}
|
|
108651
|
+
.ew[data-view=manufacture] .ew-main{flex-direction:column;min-height:0}
|
|
108652
|
+
.ew[data-view=manufacture] .ew-drawings{flex:0 1 26%;min-height:140px}
|
|
108653
|
+
.ew-manufacture{flex:1 1 300px;min-height:220px;overflow:auto}
|
|
108654
|
+
.ew-pricing input{width:6em}.ew-manufacture .ew-pricing{justify-content:flex-start}
|
|
108655
|
+
.ew-prices{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;padding:8px 12px;margin:0;border-block:1px solid var(--dsw-alias-border-l2,#bac8bc)}
|
|
108656
|
+
.ew-prices dt,.ew-manufacture td small{font-size:12px}.ew-prices dd{margin:2px 0;font-weight:600;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
|
|
108657
|
+
.ew-manufacture td{vertical-align:top}.ew-manufacture td small{display:block;margin-top:3px}.ew-manufacture td select{max-width:18em}
|
|
108658
|
+
.ew-fab-file{display:flex;flex:1;min-height:160px;flex-direction:column}.ew-fab-file select{max-width:65cqw}
|
|
108659
|
+
.ew-fab-file header{justify-content:flex-start}.ew-gerber{display:grid;flex:1;min-height:160px;place-items:center;background:#15332c}.ew-gerber img{width:100%;height:100%;max-height:65vh;min-height:140px;object-fit:contain}
|
|
108660
|
+
.ew-coordinates{overflow:auto;flex:1;margin:0;padding:12px;white-space:pre;font:12px/1.6 ui-monospace,monospace}
|
|
108661
|
+
|
|
108662
|
+
.ew-manufacture[data-manufacturing-tab=BOM] {
|
|
108663
|
+
--bom-line: var(--dsw-alias-border-l2,#bac8bc);
|
|
108664
|
+
--bom-surface: var(--dsw-alias-bg-layer-1,#faf8f2);
|
|
108665
|
+
--bom-head: var(--dsw-alias-bg-layer-2,#e7ece5);
|
|
108666
|
+
--bom-accent: var(--dsw-alias-label-primary,currentColor);
|
|
108667
|
+
}
|
|
108668
|
+
.ew-manufacture[data-manufacturing-tab=BOM] .ew-prices {gap:0;padding:5px 0}
|
|
108669
|
+
.ew-manufacture[data-manufacturing-tab=BOM] .ew-prices div {padding:1px 12px}
|
|
108670
|
+
.ew-manufacture[data-manufacturing-tab=BOM] .ew-prices div+div {border-inline-start:1px solid var(--bom-line)}
|
|
108671
|
+
.ew-bom-grid {min-width:0;min-height:155px;flex:1;display:flex;flex-direction:column}
|
|
108672
|
+
.ew-bom-bar {display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:6px 10px;border-bottom:1px solid var(--bom-line)}
|
|
108673
|
+
.ew-bom-bar>span {font-size:11px;font-variant-numeric:tabular-nums;opacity:.78}
|
|
108674
|
+
.ew-bom-bar input {margin-inline-start:auto;width:min(15em,46cqw);min-width:8em}
|
|
108675
|
+
.ew-bom-bar input,.ew-bom-bar button {font-size:12px}
|
|
108676
|
+
.ew-bom-scroll {min-width:0;min-height:80px;flex:1;overflow:auto;overscroll-behavior:contain}
|
|
108677
|
+
.ew .ew-bom-table {border-collapse:separate;border-spacing:0;table-layout:fixed;font-size:12px;line-height:1.35}
|
|
108678
|
+
.ew-bom-table thead {position:sticky;top:0;z-index:2}
|
|
108679
|
+
.ew .ew-bom-table th,.ew .ew-bom-table td {padding:0 8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-inline-end:1px solid var(--bom-line);border-bottom:1px solid var(--bom-line);vertical-align:middle}
|
|
108680
|
+
.ew .ew-bom-table th {position:relative;top:auto;background:var(--bom-head);font-weight:600;text-align:start;user-select:none}
|
|
108681
|
+
.ew .ew-bom-groups th {height:21px;font-size:11px;background:var(--bom-surface);color:var(--bom-accent);box-shadow:inset 0 2px #588572}
|
|
108682
|
+
.ew .ew-bom-groups th[data-group=采购方案] {box-shadow:inset 0 2px #b8855b}
|
|
108683
|
+
.ew .ew-bom-table th[scope=col] {height:27px;padding:0}
|
|
108684
|
+
.ew-bom-heading {display:block;overflow:hidden;text-overflow:ellipsis;padding:5px 8px;cursor:grab}
|
|
108685
|
+
.ew-bom-heading:active {cursor:grabbing}
|
|
108686
|
+
.ew-bom-resize {position:absolute;top:0;bottom:0;right:0;width:9px;touch-action:none;cursor:col-resize}
|
|
108687
|
+
.ew-bom-resize::after {content:'';position:absolute;right:0;top:20%;bottom:20%;width:2px;background:var(--bom-line)}
|
|
108688
|
+
.ew-bom-resize:is(:hover,:focus-visible,:active)::after,.ew-bom-table th[data-drop]::before {background:#c98e5d}
|
|
108689
|
+
.ew-bom-table th[data-drop]::before {content:'';position:absolute;inset:0 auto 0 0;width:3px}
|
|
108690
|
+
.ew-bom-table th[data-drop=after]::before {left:auto;right:0}
|
|
108691
|
+
.ew .ew-bom-table td {height:27px;font-variant-numeric:tabular-nums}
|
|
108692
|
+
.ew-bom-table tbody tr:nth-child(even) {background:color-mix(in srgb,currentColor 3%,transparent)}
|
|
108693
|
+
.ew-bom-table tbody tr:hover {background:color-mix(in srgb,currentColor 8%,transparent)}
|
|
108694
|
+
.ew .ew-bom-table tbody tr[data-selected=true] {background:color-mix(in srgb,#769f87 26%,var(--bom-surface));box-shadow:none}
|
|
108695
|
+
.ew-bom-table tr[data-selected=true] td:first-child {box-shadow:inset 3px 0 #c58c60}
|
|
108696
|
+
.ew-bom-table td:is([data-col=qty],[data-col=stock],[data-col=moq],[data-col=unit],[data-col=batch]) {text-align:end}
|
|
108697
|
+
.ew .ew-bom-table button.ew-bom-ref,.ew .ew-bom-table td select {display:block;width:100%;font:inherit;text-align:start;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border:0;border-radius:0;padding:2px 0;background:transparent}
|
|
108698
|
+
.ew .ew-bom-table td select option {background:var(--bom-surface);color:var(--bom-accent)}
|
|
108699
|
+
.ew-bom-ref:hover {text-decoration:underline}
|
|
108700
|
+
.ew-bom-empty {opacity:.45}
|
|
108701
|
+
.ew-bom-status::before {content:'';display:inline-block;vertical-align:1px;margin-right:5px;width:5px;height:5px;border-radius:50%;background:currentColor;opacity:.5}
|
|
108702
|
+
.ew-bom-status[data-state=已匹配]::before {background:#4da478;opacity:1}
|
|
108703
|
+
.ew-bom-status:is([data-state=待确认],[data-state=未报价],[data-state=查询失败])::before {background:#c48c48;opacity:1}
|
|
108704
|
+
|
|
108705
|
+
`;
|
|
108706
|
+
//#endregion
|
|
108707
|
+
//#region src/pages.ts
|
|
108708
|
+
const baseId = "@huaqiu/dsh-engineering-workbench";
|
|
108709
|
+
const baseKind = "huaqiu-engineering-workbench";
|
|
108710
|
+
const pages = {
|
|
108711
|
+
design: {
|
|
108712
|
+
title: "电路设计",
|
|
108713
|
+
id: baseId,
|
|
108714
|
+
kind: baseKind
|
|
108715
|
+
},
|
|
108716
|
+
mechanical: {
|
|
108717
|
+
title: "结构设计",
|
|
108718
|
+
id: baseId + "/mechanical",
|
|
108719
|
+
kind: baseKind + "-mechanical"
|
|
108720
|
+
},
|
|
108721
|
+
review: {
|
|
108722
|
+
title: "评审",
|
|
108723
|
+
id: baseId + "/review",
|
|
108724
|
+
kind: baseKind + "-review"
|
|
108725
|
+
},
|
|
108726
|
+
manufacture: {
|
|
108727
|
+
title: "制造",
|
|
108728
|
+
id: baseId + "/manufacture",
|
|
108729
|
+
kind: baseKind + "-manufacture"
|
|
108730
|
+
}
|
|
108731
|
+
};
|
|
108732
|
+
const views = Object.keys(pages);
|
|
108733
|
+
//#endregion
|
|
108734
|
+
//#region src/Workbench.tsx
|
|
108735
|
+
const drawingNames = {
|
|
108736
|
+
pcb: "PCB",
|
|
108737
|
+
schematic: "原理图"
|
|
108738
|
+
};
|
|
108739
|
+
function Workbench(props) {
|
|
108740
|
+
const cwd = props.useSessions((s) => s.byId[props.sessionId]?.cwd);
|
|
108741
|
+
const nav = props.useTabInfo().tab.navigation;
|
|
108742
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Workspace, {
|
|
108743
|
+
cwd: cwd ?? "",
|
|
108744
|
+
session: props.sessionId,
|
|
108745
|
+
view: props.view,
|
|
108746
|
+
selection: props.selectionFor(props.sessionId),
|
|
108747
|
+
nav: nav.params,
|
|
108748
|
+
open: props.open,
|
|
108749
|
+
draft: props.draft
|
|
108750
|
+
}, props.sessionId + (cwd ?? ""));
|
|
108751
|
+
}
|
|
108752
|
+
function Workspace({ cwd, session, view, selection, nav, open, draft }) {
|
|
108753
|
+
const [data, setData] = (0, react.useState)();
|
|
108754
|
+
const [reload, setReload] = (0, react.useState)(0);
|
|
108755
|
+
const [error, setError] = (0, react.useState)("");
|
|
108756
|
+
const [projectPath, setProjectPath] = (0, react.useState)(selection.project ?? "");
|
|
108757
|
+
const [request, setRequest] = (0, react.useState)();
|
|
108758
|
+
const lastNav = (0, react.useRef)("");
|
|
108759
|
+
(0, react.useEffect)(() => {
|
|
108760
|
+
let live = true;
|
|
108761
|
+
setError("");
|
|
108762
|
+
loadProjects(cwd, void 0, session).then((result) => {
|
|
108763
|
+
if (!live) return;
|
|
108764
|
+
if (view === "design" && !result.selected) {
|
|
108765
|
+
const preferred = defaultCircuitProject(result.projects ?? [], result.cwd || cwd);
|
|
108766
|
+
if (preferred) {
|
|
108767
|
+
if (!selection.project) selection.project = preferred.path;
|
|
108768
|
+
setData({
|
|
108769
|
+
...result,
|
|
108770
|
+
selected: preferred
|
|
108771
|
+
});
|
|
108772
|
+
return;
|
|
108773
|
+
}
|
|
108774
|
+
}
|
|
108775
|
+
setData(result);
|
|
108776
|
+
}).catch((e) => {
|
|
108777
|
+
if (live) {
|
|
108778
|
+
setData(void 0);
|
|
108779
|
+
setError(messageOf(e));
|
|
108780
|
+
}
|
|
108781
|
+
});
|
|
108782
|
+
return () => {
|
|
108783
|
+
live = false;
|
|
108784
|
+
};
|
|
108785
|
+
}, [
|
|
108786
|
+
cwd,
|
|
108787
|
+
session,
|
|
108788
|
+
reload,
|
|
108789
|
+
view,
|
|
108790
|
+
selection
|
|
108791
|
+
]);
|
|
108792
|
+
const projects = data?.projects ?? [];
|
|
108793
|
+
const active = projects.find((p) => p.path === projectPath) ?? data?.selected ?? (projects.length === 1 ? projects[0] : void 0);
|
|
108794
|
+
(0, react.useEffect)(() => {
|
|
108795
|
+
if (!data || !nav || nav.view !== view || !validRequest(nav) || !nav.requestId || lastNav.current === nav.requestId) return;
|
|
108796
|
+
lastNav.current = nav.requestId;
|
|
108797
|
+
let candidates = data.projects ?? [];
|
|
108798
|
+
if (nav.project) candidates = candidates.filter((p) => matches(p.path, nav.project));
|
|
108799
|
+
if (nav.path) candidates = candidates.filter((p) => {
|
|
108800
|
+
const files = filesOf(p);
|
|
108801
|
+
return [...files.boards, ...files.sheets].some((f) => matches(f.path, nav.path));
|
|
108802
|
+
});
|
|
108803
|
+
if (nav.path || nav.project) {
|
|
108804
|
+
if (candidates.length !== 1) {
|
|
108805
|
+
setError(candidates.length ? "多个工程匹配,请指定完整路径。" : "当前工作区未找到指定文件或工程。");
|
|
108806
|
+
return;
|
|
108807
|
+
}
|
|
108808
|
+
setProjectPath(candidates[0].path);
|
|
108809
|
+
}
|
|
108810
|
+
setError("");
|
|
108811
|
+
setRequest(nav);
|
|
108812
|
+
}, [
|
|
108813
|
+
data,
|
|
108814
|
+
nav,
|
|
108815
|
+
view
|
|
108816
|
+
]);
|
|
108817
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
108818
|
+
className: "ew",
|
|
108819
|
+
"aria-label": pages[view].title,
|
|
108820
|
+
"data-view": view,
|
|
108821
|
+
children: [
|
|
108822
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: styles }),
|
|
108823
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
108824
|
+
className: "ew-head",
|
|
108825
|
+
children: [projects.length > 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
108826
|
+
"aria-label": "当前工程",
|
|
108827
|
+
value: active?.path ?? "",
|
|
108828
|
+
onChange: (e) => {
|
|
108829
|
+
if (active || !request?.designTool) setRequest(void 0);
|
|
108830
|
+
setError("");
|
|
108831
|
+
setProjectPath(e.target.value);
|
|
108832
|
+
Object.assign(selection, {
|
|
108833
|
+
project: e.target.value,
|
|
108834
|
+
board: void 0,
|
|
108835
|
+
sheet: void 0,
|
|
108836
|
+
reference: void 0,
|
|
108837
|
+
kind: void 0
|
|
108838
|
+
});
|
|
108839
|
+
},
|
|
108840
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
108841
|
+
value: "",
|
|
108842
|
+
disabled: true,
|
|
108843
|
+
children: "选择工程"
|
|
108844
|
+
}), projects.map((p) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("option", {
|
|
108845
|
+
value: p.path,
|
|
108846
|
+
children: [
|
|
108847
|
+
p.name,
|
|
108848
|
+
" · ",
|
|
108849
|
+
p.path
|
|
108850
|
+
]
|
|
108851
|
+
}, p.path))]
|
|
108852
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
108853
|
+
title: active?.path,
|
|
108854
|
+
children: active?.name ?? basename(cwd)
|
|
108855
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
108856
|
+
onClick: () => setReload((n) => n + 1),
|
|
108857
|
+
children: "刷新"
|
|
108858
|
+
})]
|
|
108859
|
+
}),
|
|
108860
|
+
error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
108861
|
+
role: "alert",
|
|
108862
|
+
children: error
|
|
108863
|
+
}),
|
|
108864
|
+
active ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Project, {
|
|
108865
|
+
view,
|
|
108866
|
+
selection,
|
|
108867
|
+
project: active,
|
|
108868
|
+
cwd: data?.cwd || cwd,
|
|
108869
|
+
session,
|
|
108870
|
+
request,
|
|
108871
|
+
open,
|
|
108872
|
+
draft
|
|
108873
|
+
}, active.path) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
108874
|
+
role: "status",
|
|
108875
|
+
children: !data && !error ? "正在查找 KiCad 工程…" : projects.length ? "请选择要查看的工程。" : "当前工作区没有可用的 KiCad 工程。"
|
|
108876
|
+
})
|
|
108877
|
+
]
|
|
108878
|
+
});
|
|
108879
|
+
}
|
|
108880
|
+
function Project({ project, cwd, session, view, selection, request, open, draft }) {
|
|
108881
|
+
const { boards, sheets } = filesOf(project);
|
|
108882
|
+
const seed = selection.project === project.path ? selection : {};
|
|
108883
|
+
const preferSchematic = view === "design" && sheets.length > 0 || boards.length === 0;
|
|
108884
|
+
const [kind, setKind] = (0, react.useState)(seed.kind ?? (preferSchematic ? "schematic" : "pcb"));
|
|
108885
|
+
const [awaiting3d, setAwaiting3d] = (0, react.useState)(false);
|
|
108886
|
+
const [manufacturingTab, setManufacturingTab] = (0, react.useState)("BOM");
|
|
108887
|
+
const [boardPath, setBoard] = (0, react.useState)(boards.find((f) => f.path === seed.board)?.path || project.defaultBoard || (boards.length === 1 ? boards[0].path : ""));
|
|
108888
|
+
const [sheetPath, setSheet] = (0, react.useState)(sheets.find((f) => f.path === seed.sheet)?.path || project.rootSheet?.path || project.schematic?.path || sheets[0]?.path || "");
|
|
108889
|
+
const [reference, setReference] = (0, react.useState)(seed.reference ?? "");
|
|
108890
|
+
const [parsedBoard, setParsedBoard] = (0, react.useState)();
|
|
108891
|
+
const [message, setMessage] = (0, react.useState)("");
|
|
108892
|
+
const [visited, setVisited] = (0, react.useState)({});
|
|
108893
|
+
const [closed, setClosed] = (0, react.useState)({
|
|
108894
|
+
pcb: false,
|
|
108895
|
+
schematic: false
|
|
108896
|
+
});
|
|
108897
|
+
const [records, setRecords] = (0, react.useState)([]);
|
|
108898
|
+
const seen = (0, react.useRef)("");
|
|
108899
|
+
const board = boards.find((f) => f.path === boardPath);
|
|
108900
|
+
const sheet = sheets.find((f) => f.path === sheetPath);
|
|
108901
|
+
const boardKey = boardPath + "@" + (board?.revision ?? "");
|
|
108902
|
+
const parts = parsedBoard?.key === boardKey ? parsedBoard.parts : [];
|
|
108903
|
+
const rememberParts = (0, react.useCallback)((parts) => setParsedBoard({
|
|
108904
|
+
key: boardKey,
|
|
108905
|
+
parts
|
|
108906
|
+
}), [boardKey]);
|
|
108907
|
+
(0, react.useEffect)(() => {
|
|
108908
|
+
if (!request?.requestId || seen.current === request.requestId) return;
|
|
108909
|
+
seen.current = request.requestId;
|
|
108910
|
+
const next = {
|
|
108911
|
+
project: project.path,
|
|
108912
|
+
board: boardPath,
|
|
108913
|
+
sheet: sheetPath,
|
|
108914
|
+
reference,
|
|
108915
|
+
kind
|
|
108916
|
+
};
|
|
108917
|
+
setAwaiting3d(false);
|
|
108918
|
+
if (request.path) {
|
|
108919
|
+
const targets = [...boards, ...sheets].filter((f) => matches(f.path, request.path));
|
|
108920
|
+
if (targets.length !== 1) {
|
|
108921
|
+
setMessage("文件路径不唯一或已移除,请手动选择。");
|
|
108922
|
+
return;
|
|
108923
|
+
}
|
|
108924
|
+
const target = targets[0];
|
|
108925
|
+
const targetKind = boards.includes(target) ? "pcb" : "schematic";
|
|
108926
|
+
setClosed((prev) => ({
|
|
108927
|
+
...prev,
|
|
108928
|
+
[targetKind]: false
|
|
108929
|
+
}));
|
|
108930
|
+
if (boards.includes(target)) {
|
|
108931
|
+
if (target.path !== boardPath) {
|
|
108932
|
+
setReference("");
|
|
108933
|
+
next.reference = "";
|
|
108934
|
+
}
|
|
108935
|
+
setBoard(target.path);
|
|
108936
|
+
setKind("pcb");
|
|
108937
|
+
next.board = target.path;
|
|
108938
|
+
next.kind = "pcb";
|
|
108939
|
+
} else {
|
|
108940
|
+
setSheet(target.path);
|
|
108941
|
+
setKind("schematic");
|
|
108942
|
+
next.sheet = target.path;
|
|
108943
|
+
next.kind = "schematic";
|
|
108944
|
+
}
|
|
108945
|
+
}
|
|
108946
|
+
setMessage("");
|
|
108947
|
+
if (view === "design" && request.designTool) {
|
|
108948
|
+
const tool = request.designTool;
|
|
108949
|
+
const drawing = tool === "3d" ? "pcb" : tool;
|
|
108950
|
+
next.kind = drawing;
|
|
108951
|
+
setKind(drawing);
|
|
108952
|
+
setClosed((prev) => ({
|
|
108953
|
+
...prev,
|
|
108954
|
+
[drawing]: false
|
|
108955
|
+
}));
|
|
108956
|
+
if (tool === "3d" && boards.some((b) => b.path === next.board)) open(session, "hardware-engineering", {
|
|
108957
|
+
destination: "3d",
|
|
108958
|
+
path: next.board,
|
|
108959
|
+
projectPath: project.path
|
|
108960
|
+
});
|
|
108961
|
+
else if (tool === "3d" && boards.length) {
|
|
108962
|
+
setAwaiting3d(true);
|
|
108963
|
+
setMessage("请选择要在 3D 中查看的板文件。");
|
|
108964
|
+
} else if (!(drawing === "pcb" ? boards : sheets).length) setMessage(drawing === "pcb" ? "当前工程没有板文件。" : "当前工程没有原理图文件。");
|
|
108965
|
+
}
|
|
108966
|
+
if (request.reference) {
|
|
108967
|
+
next.reference = request.reference.trim().toUpperCase();
|
|
108968
|
+
setReference(next.reference);
|
|
108969
|
+
}
|
|
108970
|
+
Object.assign(selection, next);
|
|
108971
|
+
}, [
|
|
108972
|
+
request,
|
|
108973
|
+
boards,
|
|
108974
|
+
sheets
|
|
108975
|
+
]);
|
|
108976
|
+
const showPcb = !!board && !closed.pcb && (view !== "design" || kind === "pcb") && (view !== "manufacture" || manufacturingTab === "BOM");
|
|
108977
|
+
const showSch = !!sheet && !closed.schematic && (view === "review" || view === "design" && kind === "schematic");
|
|
108978
|
+
const hasPreview = showPcb || showSch;
|
|
108979
|
+
(0, react.useEffect)(() => {
|
|
108980
|
+
setVisited((prev) => ({
|
|
108981
|
+
...prev,
|
|
108982
|
+
pcb: prev.pcb || showPcb,
|
|
108983
|
+
schematic: prev.schematic || showSch
|
|
108984
|
+
}));
|
|
108985
|
+
}, [showPcb, showSch]);
|
|
108986
|
+
const selected = parts.find((p) => p.ref.toUpperCase() === reference.toUpperCase());
|
|
108987
|
+
const inspectPath = (kind === "pcb" ? board : sheet)?.path;
|
|
108988
|
+
const ask = () => {
|
|
108989
|
+
try {
|
|
108990
|
+
draft(session, "请结合当前工程回答:" + project.name + "\n文件:" + (view === "manufacture" ? sheetPath : inspectPath || project.path) + (reference ? "\n位号:" + reference : "") + "\n");
|
|
108991
|
+
setMessage("已加入左侧对话草稿。");
|
|
108992
|
+
} catch (e) {
|
|
108993
|
+
setMessage(messageOf(e));
|
|
108994
|
+
}
|
|
108995
|
+
};
|
|
108996
|
+
function nativeOpen() {
|
|
108997
|
+
if (inspectPath) openArtifact({
|
|
108998
|
+
application: "kicad",
|
|
108999
|
+
artifactPath: inspectPath,
|
|
109000
|
+
projectPath: project.path,
|
|
109001
|
+
kind,
|
|
109002
|
+
session
|
|
109003
|
+
}).catch((e) => setMessage(messageOf(e)));
|
|
109004
|
+
}
|
|
109005
|
+
function remember(updates) {
|
|
109006
|
+
Object.assign(selection, {
|
|
109007
|
+
project: project.path,
|
|
109008
|
+
board: boardPath,
|
|
109009
|
+
sheet: sheetPath,
|
|
109010
|
+
kind,
|
|
109011
|
+
reference
|
|
109012
|
+
}, updates);
|
|
109013
|
+
}
|
|
109014
|
+
function chooseReference(value) {
|
|
109015
|
+
setReference(value);
|
|
109016
|
+
remember({ reference: value });
|
|
109017
|
+
}
|
|
109018
|
+
function chooseKind(value) {
|
|
109019
|
+
setAwaiting3d(false);
|
|
109020
|
+
setMessage("");
|
|
109021
|
+
setKind(value);
|
|
109022
|
+
remember({ kind: value });
|
|
109023
|
+
setClosed((prev) => ({
|
|
109024
|
+
...prev,
|
|
109025
|
+
[value]: false
|
|
109026
|
+
}));
|
|
109027
|
+
}
|
|
109028
|
+
const selectFile = (type, path) => {
|
|
109029
|
+
setClosed((prev) => ({
|
|
109030
|
+
...prev,
|
|
109031
|
+
[type]: false
|
|
109032
|
+
}));
|
|
109033
|
+
if (type === "pcb") {
|
|
109034
|
+
setBoard(path);
|
|
109035
|
+
setReference("");
|
|
109036
|
+
} else setSheet(path);
|
|
109037
|
+
setKind(type);
|
|
109038
|
+
setMessage("");
|
|
109039
|
+
remember(type === "pcb" ? {
|
|
109040
|
+
board: path,
|
|
109041
|
+
reference: "",
|
|
109042
|
+
kind: type
|
|
109043
|
+
} : {
|
|
109044
|
+
sheet: path,
|
|
109045
|
+
kind: type
|
|
109046
|
+
});
|
|
109047
|
+
if (type === "pcb" && awaiting3d) {
|
|
109048
|
+
setAwaiting3d(false);
|
|
109049
|
+
open(session, "hardware-engineering", {
|
|
109050
|
+
destination: "3d",
|
|
109051
|
+
path,
|
|
109052
|
+
projectPath: project.path
|
|
109053
|
+
});
|
|
109054
|
+
}
|
|
109055
|
+
};
|
|
109056
|
+
const order = () => {
|
|
109057
|
+
if (!board) {
|
|
109058
|
+
setMessage("请先选择要下单的板文件。");
|
|
109059
|
+
return;
|
|
109060
|
+
}
|
|
109061
|
+
open(session, "hardware-engineering", {
|
|
109062
|
+
destination: "order",
|
|
109063
|
+
path: board.path,
|
|
109064
|
+
projectPath: project.path,
|
|
109065
|
+
schematicPath: project.rootSheet?.path || project.schematic?.path
|
|
109066
|
+
});
|
|
109067
|
+
};
|
|
109068
|
+
const recordKey = [
|
|
109069
|
+
boardPath,
|
|
109070
|
+
board?.revision,
|
|
109071
|
+
sheetPath,
|
|
109072
|
+
sheet?.revision,
|
|
109073
|
+
reference.trim().toUpperCase()
|
|
109074
|
+
].join(" · ");
|
|
109075
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
109076
|
+
view === "design" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
109077
|
+
className: "ew-tools",
|
|
109078
|
+
children: [
|
|
109079
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
109080
|
+
"aria-pressed": kind === "schematic",
|
|
109081
|
+
onClick: () => chooseKind("schematic"),
|
|
109082
|
+
children: "原理图"
|
|
109083
|
+
}),
|
|
109084
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
109085
|
+
"aria-pressed": kind === "pcb",
|
|
109086
|
+
onClick: () => chooseKind("pcb"),
|
|
109087
|
+
children: "PCB"
|
|
109088
|
+
}),
|
|
109089
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
109090
|
+
disabled: !board,
|
|
109091
|
+
onClick: () => open(session, "hardware-engineering", {
|
|
109092
|
+
destination: "3d",
|
|
109093
|
+
path: boardPath,
|
|
109094
|
+
projectPath: project.path
|
|
109095
|
+
}),
|
|
109096
|
+
children: "板级 3D ↗"
|
|
109097
|
+
}),
|
|
109098
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
109099
|
+
disabled: !inspectPath,
|
|
109100
|
+
onClick: nativeOpen,
|
|
109101
|
+
children: "在 KiCad 中打开 ↗"
|
|
109102
|
+
})
|
|
109103
|
+
]
|
|
109104
|
+
}),
|
|
109105
|
+
view === "manufacture" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
|
|
109106
|
+
className: "ew-tools",
|
|
109107
|
+
"aria-label": "制造文件",
|
|
109108
|
+
children: manufacturingTabs.map((tab) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
109109
|
+
"aria-pressed": tab === manufacturingTab,
|
|
109110
|
+
onClick: () => setManufacturingTab(tab),
|
|
109111
|
+
children: tab
|
|
109112
|
+
}, tab))
|
|
109113
|
+
}),
|
|
109114
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
109115
|
+
className: "ew-files",
|
|
109116
|
+
children: ["schematic", "pcb"].filter((type) => (view !== "design" || kind === type) && (view !== "manufacture" || manufacturingTab === "BOM" || type === "pcb")).map((type) => {
|
|
109117
|
+
const files = type === "pcb" ? boards : sheets;
|
|
109118
|
+
const file = type === "pcb" ? board : sheet;
|
|
109119
|
+
const action = closed[type] ? "打开" : "关闭";
|
|
109120
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
109121
|
+
className: "ew-file-control",
|
|
109122
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [
|
|
109123
|
+
type === "pcb" ? "板文件" : "原理图",
|
|
109124
|
+
" ",
|
|
109125
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
109126
|
+
value: file?.path || "",
|
|
109127
|
+
onChange: (e) => selectFile(type, e.target.value),
|
|
109128
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
109129
|
+
value: "",
|
|
109130
|
+
disabled: true,
|
|
109131
|
+
children: "选择文件"
|
|
109132
|
+
}), files.map((f) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
109133
|
+
value: f.path,
|
|
109134
|
+
children: basename(f.path)
|
|
109135
|
+
}, f.path))]
|
|
109136
|
+
})
|
|
109137
|
+
] }), file && (view !== "manufacture" || type === "pcb" && manufacturingTab === "BOM") && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
109138
|
+
type: "button",
|
|
109139
|
+
className: "ew-preview-toggle",
|
|
109140
|
+
"aria-label": action + drawingNames[type] + "预览",
|
|
109141
|
+
title: action + drawingNames[type] + "预览",
|
|
109142
|
+
onClick: () => setClosed((prev) => ({
|
|
109143
|
+
...prev,
|
|
109144
|
+
[type]: !prev[type]
|
|
109145
|
+
})),
|
|
109146
|
+
children: [action, "预览"]
|
|
109147
|
+
})]
|
|
109148
|
+
}, type);
|
|
109149
|
+
})
|
|
109150
|
+
}),
|
|
109151
|
+
message && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
109152
|
+
role: "status",
|
|
109153
|
+
children: message
|
|
109154
|
+
}),
|
|
109155
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
109156
|
+
className: "ew-content",
|
|
109157
|
+
"data-preview": hasPreview,
|
|
109158
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
109159
|
+
className: "ew-main",
|
|
109160
|
+
"data-manufacture": view === "manufacture",
|
|
109161
|
+
hidden: !hasPreview && view !== "manufacture",
|
|
109162
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
109163
|
+
className: "ew-drawings",
|
|
109164
|
+
hidden: !hasPreview,
|
|
109165
|
+
"data-review": showPcb && showSch,
|
|
109166
|
+
children: ["schematic", "pcb"].map((type) => {
|
|
109167
|
+
const visible = type === "pcb" ? showPcb : showSch;
|
|
109168
|
+
const file = type === "pcb" ? board : sheet;
|
|
109169
|
+
if (!file || closed[type] || !visible && !visited[type]) return null;
|
|
109170
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
109171
|
+
className: "ew-pane",
|
|
109172
|
+
hidden: !visible,
|
|
109173
|
+
children: [view === "review" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: type === "pcb" ? "PCB" : "原理图" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Drawing, {
|
|
109174
|
+
kind: type,
|
|
109175
|
+
path: file.path,
|
|
109176
|
+
session,
|
|
109177
|
+
cwd,
|
|
109178
|
+
onParts: type === "pcb" ? rememberParts : void 0
|
|
109179
|
+
}, file.path + "@" + (file.revision ?? ""))]
|
|
109180
|
+
}, type);
|
|
109181
|
+
})
|
|
109182
|
+
}), view === "manufacture" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Manufacture, {
|
|
109183
|
+
tab: manufacturingTab,
|
|
109184
|
+
path: sheet?.path || "",
|
|
109185
|
+
board: board?.path || "",
|
|
109186
|
+
boardKey,
|
|
109187
|
+
cwd,
|
|
109188
|
+
session,
|
|
109189
|
+
reference,
|
|
109190
|
+
location: selected?.location,
|
|
109191
|
+
select: chooseReference,
|
|
109192
|
+
ask,
|
|
109193
|
+
order
|
|
109194
|
+
}, JSON.stringify([
|
|
109195
|
+
sheet?.path,
|
|
109196
|
+
sheet?.revision,
|
|
109197
|
+
boardKey
|
|
109198
|
+
]))]
|
|
109199
|
+
}), view !== "manufacture" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
109200
|
+
className: "ew-inspect",
|
|
109201
|
+
children: [
|
|
109202
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", { children: [
|
|
109203
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: view === "review" ? "评审记录" : "对象属性" }),
|
|
109204
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
109205
|
+
list: "ew-refs-" + view + "-" + session,
|
|
109206
|
+
"aria-label": "位号",
|
|
109207
|
+
placeholder: "输入位号,如 J1",
|
|
109208
|
+
value: reference,
|
|
109209
|
+
onChange: (e) => chooseReference(e.target.value)
|
|
109210
|
+
}),
|
|
109211
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("datalist", {
|
|
109212
|
+
id: "ew-refs-" + view + "-" + session,
|
|
109213
|
+
children: parts.map((p, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", { value: p.ref }, i))
|
|
109214
|
+
}),
|
|
109215
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
109216
|
+
onClick: ask,
|
|
109217
|
+
children: "询问助手"
|
|
109218
|
+
})
|
|
109219
|
+
] }),
|
|
109220
|
+
selected && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
109221
|
+
className: "ew-details",
|
|
109222
|
+
children: [
|
|
109223
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: selected.ref }),
|
|
109224
|
+
" ",
|
|
109225
|
+
selected.value,
|
|
109226
|
+
" · ",
|
|
109227
|
+
selected.footprint,
|
|
109228
|
+
selected.location && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: selected.location }),
|
|
109229
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", { children: [
|
|
109230
|
+
"焊盘与网络(",
|
|
109231
|
+
selected.pins.length,
|
|
109232
|
+
")"
|
|
109233
|
+
] }), selected.pins.map((p, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
109234
|
+
p.number,
|
|
109235
|
+
" ",
|
|
109236
|
+
p.net
|
|
109237
|
+
] }, i))] })
|
|
109238
|
+
]
|
|
109239
|
+
}),
|
|
109240
|
+
reference && !selected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: "当前已读 PCB 中未找到此位号。" }),
|
|
109241
|
+
view === "review" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [
|
|
109242
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
109243
|
+
type: "checkbox",
|
|
109244
|
+
disabled: !board || !sheet || !reference,
|
|
109245
|
+
checked: records.includes(recordKey),
|
|
109246
|
+
onChange: (e) => setRecords((prev) => e.target.checked ? [...prev, recordKey] : prev.filter((k) => k !== recordKey))
|
|
109247
|
+
}),
|
|
109248
|
+
" 当前文件对 · ",
|
|
109249
|
+
reference || "选定位号",
|
|
109250
|
+
" 已复核"
|
|
109251
|
+
] })
|
|
109252
|
+
]
|
|
109253
|
+
})]
|
|
109254
|
+
})
|
|
109255
|
+
] });
|
|
109256
|
+
}
|
|
109257
|
+
//#endregion
|
|
109258
|
+
//#region src/caption-menu.ts
|
|
109259
|
+
/** The Windows caption is created by the desktop preload, sometimes after the plugins. */
|
|
109260
|
+
function installCaptionMenu(mounted, activate) {
|
|
109261
|
+
let bar;
|
|
109262
|
+
let menu;
|
|
109263
|
+
function closeMenu(restoreFocus = false) {
|
|
109264
|
+
if (!menu) return;
|
|
109265
|
+
const popup = menu;
|
|
109266
|
+
menu = void 0;
|
|
109267
|
+
popup.remove();
|
|
109268
|
+
buttons[0].setAttribute("aria-expanded", "false");
|
|
109269
|
+
if (restoreFocus) buttons[0].focus();
|
|
109270
|
+
}
|
|
109271
|
+
function showMenu(focusLast = false) {
|
|
109272
|
+
const trigger = buttons[0];
|
|
109273
|
+
if (!bar || trigger.disabled) return;
|
|
109274
|
+
closeMenu();
|
|
109275
|
+
const popup = document.createElement("div");
|
|
109276
|
+
popup.id = "engineering-design-menu";
|
|
109277
|
+
popup.setAttribute("role", "menu");
|
|
109278
|
+
popup.setAttribute("aria-label", "设计");
|
|
109279
|
+
const rect = trigger.getBoundingClientRect();
|
|
109280
|
+
Object.assign(popup.style, {
|
|
109281
|
+
position: "fixed",
|
|
109282
|
+
top: rect.bottom + "px",
|
|
109283
|
+
left: rect.left + "px",
|
|
109284
|
+
minWidth: "124px",
|
|
109285
|
+
display: "grid",
|
|
109286
|
+
padding: "4px",
|
|
109287
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
109288
|
+
borderRadius: "6px",
|
|
109289
|
+
background: "var(--dsw-alias-bg-layer-1)",
|
|
109290
|
+
boxShadow: "0 4px 14px #0002"
|
|
109291
|
+
});
|
|
109292
|
+
for (const view of ["design", "mechanical"]) {
|
|
109293
|
+
const item = document.createElement("button");
|
|
109294
|
+
item.type = "button";
|
|
109295
|
+
item.tabIndex = -1;
|
|
109296
|
+
item.setAttribute("role", "menuitem");
|
|
109297
|
+
item.textContent = pages[view].title;
|
|
109298
|
+
item.style.textAlign = "start";
|
|
109299
|
+
item.onclick = () => {
|
|
109300
|
+
closeMenu(true);
|
|
109301
|
+
const session = mounted.getSnapshot();
|
|
109302
|
+
if (session !== void 0) activate(session, view);
|
|
109303
|
+
};
|
|
109304
|
+
popup.append(item);
|
|
109305
|
+
}
|
|
109306
|
+
popup.onkeydown = (e) => {
|
|
109307
|
+
const items = Array.from(popup.querySelectorAll("button"));
|
|
109308
|
+
if (e.key === "Escape") closeMenu(true);
|
|
109309
|
+
else if ([
|
|
109310
|
+
"ArrowDown",
|
|
109311
|
+
"ArrowUp",
|
|
109312
|
+
"Home",
|
|
109313
|
+
"End"
|
|
109314
|
+
].includes(e.key)) {
|
|
109315
|
+
const index = items.indexOf(e.target);
|
|
109316
|
+
items[e.key === "Home" ? 0 : e.key === "End" ? 1 : 1 - index]?.focus();
|
|
109317
|
+
} else return;
|
|
109318
|
+
e.preventDefault();
|
|
109319
|
+
e.stopPropagation();
|
|
109320
|
+
};
|
|
109321
|
+
popup.addEventListener("focusout", (e) => {
|
|
109322
|
+
if (!popup.contains(e.relatedTarget)) closeMenu();
|
|
109323
|
+
});
|
|
109324
|
+
bar.after(popup);
|
|
109325
|
+
menu = popup;
|
|
109326
|
+
trigger.setAttribute("aria-expanded", "true");
|
|
109327
|
+
popup.querySelector(focusLast ? "button:last-child" : "button")?.focus();
|
|
109328
|
+
}
|
|
109329
|
+
const buttons = [
|
|
109330
|
+
"design",
|
|
109331
|
+
"review",
|
|
109332
|
+
"manufacture"
|
|
109333
|
+
].map((view) => {
|
|
109334
|
+
const button = document.createElement("button");
|
|
109335
|
+
button.type = "button";
|
|
109336
|
+
button.setAttribute("role", "menuitem");
|
|
109337
|
+
button.tabIndex = -1;
|
|
109338
|
+
button.textContent = view === "design" ? "设计" : pages[view].title;
|
|
109339
|
+
if (view === "design") {
|
|
109340
|
+
button.setAttribute("aria-haspopup", "menu");
|
|
109341
|
+
button.setAttribute("aria-controls", "engineering-design-menu");
|
|
109342
|
+
button.setAttribute("aria-expanded", "false");
|
|
109343
|
+
button.onkeydown = (e) => {
|
|
109344
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
109345
|
+
e.preventDefault();
|
|
109346
|
+
e.stopPropagation();
|
|
109347
|
+
showMenu(e.key === "ArrowUp");
|
|
109348
|
+
}
|
|
109349
|
+
};
|
|
109350
|
+
}
|
|
109351
|
+
button.onpointerdown = button.onmousedown = (event) => event.preventDefault();
|
|
109352
|
+
button.onclick = () => {
|
|
109353
|
+
if (view === "design") {
|
|
109354
|
+
if (menu) closeMenu(true);
|
|
109355
|
+
else showMenu();
|
|
109356
|
+
return;
|
|
109357
|
+
}
|
|
109358
|
+
closeMenu();
|
|
109359
|
+
const session = mounted.getSnapshot();
|
|
109360
|
+
if (session !== void 0) activate(session, view);
|
|
109361
|
+
};
|
|
109362
|
+
return button;
|
|
109363
|
+
});
|
|
109364
|
+
const update = () => {
|
|
109365
|
+
closeMenu();
|
|
109366
|
+
const disabled = mounted.getSnapshot() === void 0;
|
|
109367
|
+
for (const button of buttons) {
|
|
109368
|
+
button.disabled = disabled;
|
|
109369
|
+
button.title = disabled ? "请先打开会话" : "打开" + button.textContent + "页面";
|
|
109370
|
+
}
|
|
109371
|
+
};
|
|
109372
|
+
const move = (event) => {
|
|
109373
|
+
if (event.key !== "ArrowRight" && event.key !== "ArrowLeft") return;
|
|
109374
|
+
const items = Array.from(bar.querySelectorAll("button[role=menuitem]:enabled"));
|
|
109375
|
+
const index = items.indexOf(event.target);
|
|
109376
|
+
if (index < 0) return;
|
|
109377
|
+
const next = items[(index + (event.key === "ArrowRight" ? 1 : -1) + items.length) % items.length];
|
|
109378
|
+
if (!buttons.includes(items[index]) && !buttons.includes(next)) return;
|
|
109379
|
+
event.preventDefault();
|
|
109380
|
+
event.stopPropagation();
|
|
109381
|
+
for (const item of items) item.tabIndex = item === next ? 0 : -1;
|
|
109382
|
+
next.focus();
|
|
109383
|
+
};
|
|
109384
|
+
const detach = () => {
|
|
109385
|
+
closeMenu();
|
|
109386
|
+
bar?.removeEventListener("keydown", move, true);
|
|
109387
|
+
if (bar && buttons.some((b) => b.tabIndex === 0)) {
|
|
109388
|
+
const first = bar.querySelector("button[aria-haspopup=menu]");
|
|
109389
|
+
if (first) first.tabIndex = 0;
|
|
109390
|
+
}
|
|
109391
|
+
for (const button of buttons) {
|
|
109392
|
+
button.remove();
|
|
109393
|
+
button.tabIndex = -1;
|
|
109394
|
+
}
|
|
109395
|
+
bar = void 0;
|
|
109396
|
+
};
|
|
109397
|
+
const mount = () => {
|
|
109398
|
+
const next = (document.querySelector("[data-windows-menu]")?.shadowRoot)?.querySelector("[role=menubar]");
|
|
109399
|
+
if (next === bar) return;
|
|
109400
|
+
detach();
|
|
109401
|
+
const anchor = next?.querySelector("button[data-place-order]");
|
|
109402
|
+
if (!next || !anchor) return;
|
|
109403
|
+
bar = next;
|
|
109404
|
+
for (const button of buttons) next.insertBefore(button, anchor);
|
|
109405
|
+
next.addEventListener("keydown", move, true);
|
|
109406
|
+
update();
|
|
109407
|
+
};
|
|
109408
|
+
const observer = new MutationObserver(mount);
|
|
109409
|
+
const dismiss = (e) => {
|
|
109410
|
+
if (menu && !e.composedPath().includes(menu) && !e.composedPath().includes(buttons[0])) closeMenu();
|
|
109411
|
+
};
|
|
109412
|
+
document.addEventListener("pointerdown", dismiss, true);
|
|
109413
|
+
observer.observe(document.body, { childList: true });
|
|
109414
|
+
const unsubscribe = mounted.subscribe(update);
|
|
109415
|
+
mount();
|
|
109416
|
+
return () => {
|
|
109417
|
+
document.removeEventListener("pointerdown", dismiss, true);
|
|
109418
|
+
observer.disconnect();
|
|
109419
|
+
unsubscribe();
|
|
109420
|
+
detach();
|
|
109421
|
+
};
|
|
109422
|
+
}
|
|
109423
|
+
/**
|
|
109424
|
+
* @license
|
|
109425
|
+
* Copyright 2010-2026 Three.js Authors
|
|
109426
|
+
* SPDX-License-Identifier: MIT
|
|
109427
|
+
*/
|
|
109428
|
+
/**
|
|
109429
|
+
* The texture will simply repeat to infinity.
|
|
109430
|
+
*
|
|
109431
|
+
* @type {number}
|
|
109432
|
+
* @constant
|
|
109433
|
+
*/
|
|
109434
|
+
const RepeatWrapping = 1e3;
|
|
109435
|
+
/**
|
|
109436
|
+
* The last pixel of the texture stretches to the edge of the mesh.
|
|
109437
|
+
*
|
|
109438
|
+
* @type {number}
|
|
109439
|
+
* @constant
|
|
109440
|
+
*/
|
|
109441
|
+
const ClampToEdgeWrapping = 1001;
|
|
109442
|
+
/**
|
|
109443
|
+
* The texture will repeats to infinity, mirroring on each repeat.
|
|
109444
|
+
*
|
|
109445
|
+
* @type {number}
|
|
109446
|
+
* @constant
|
|
109447
|
+
*/
|
|
109448
|
+
const MirroredRepeatWrapping = 1002;
|
|
109449
|
+
/**
|
|
109450
|
+
* Returns the value of the texture element that is nearest (in Manhattan distance)
|
|
109451
|
+
* to the specified texture coordinates.
|
|
109452
|
+
*
|
|
109453
|
+
* @type {number}
|
|
109454
|
+
* @constant
|
|
109455
|
+
*/
|
|
109456
|
+
const NearestFilter = 1003;
|
|
109457
|
+
/**
|
|
109458
|
+
* Chooses the mipmap that most closely matches the size of the pixel being textured
|
|
109459
|
+
* and uses the `NearestFilter` criterion (the texel nearest to the center of the pixel)
|
|
109460
|
+
* to produce a texture value.
|
|
109461
|
+
*
|
|
109462
|
+
* @type {number}
|
|
109463
|
+
* @constant
|
|
109464
|
+
*/
|
|
109465
|
+
const NearestMipmapNearestFilter = 1004;
|
|
109466
|
+
/**
|
|
109467
|
+
* Chooses the two mipmaps that most closely match the size of the pixel being textured and
|
|
109468
|
+
* uses the `NearestFilter` criterion to produce a texture value from each mipmap.
|
|
109469
|
+
* The final texture value is a weighted average of those two values.
|
|
109470
|
+
*
|
|
109471
|
+
* @type {number}
|
|
109472
|
+
* @constant
|
|
109473
|
+
*/
|
|
109474
|
+
const NearestMipmapLinearFilter = 1005;
|
|
109475
|
+
/**
|
|
109476
|
+
* Returns the weighted average of the four texture elements that are closest to the specified
|
|
109477
|
+
* texture coordinates, and can include items wrapped or repeated from other parts of a texture,
|
|
109478
|
+
* depending on the values of `wrapS` and `wrapT`, and on the exact mapping.
|
|
109479
|
+
*
|
|
109480
|
+
* @type {number}
|
|
109481
|
+
* @constant
|
|
109482
|
+
*/
|
|
109483
|
+
const LinearFilter = 1006;
|
|
109484
|
+
/**
|
|
109485
|
+
* Chooses the mipmap that most closely matches the size of the pixel being textured and uses
|
|
109486
|
+
* the `LinearFilter` criterion (a weighted average of the four texels that are closest to the
|
|
109487
|
+
* center of the pixel) to produce a texture value.
|
|
109488
|
+
*
|
|
109489
|
+
* @type {number}
|
|
109490
|
+
* @constant
|
|
109491
|
+
*/
|
|
109492
|
+
const LinearMipmapNearestFilter = 1007;
|
|
109493
|
+
/**
|
|
109494
|
+
* Chooses the two mipmaps that most closely match the size of the pixel being textured and uses
|
|
109495
|
+
* the `LinearFilter` criterion to produce a texture value from each mipmap. The final texture value
|
|
109496
|
+
* is a weighted average of those two values.
|
|
109497
|
+
*
|
|
109498
|
+
* @type {number}
|
|
109499
|
+
* @constant
|
|
109500
|
+
*/
|
|
109501
|
+
const LinearMipmapLinearFilter = 1008;
|
|
109502
|
+
/**
|
|
109503
|
+
* An unsigned byte data type for textures.
|
|
109504
|
+
*
|
|
109505
|
+
* @type {number}
|
|
109506
|
+
* @constant
|
|
109507
|
+
*/
|
|
109508
|
+
const UnsignedByteType = 1009;
|
|
109509
|
+
/**
|
|
109510
|
+
* A byte data type for textures.
|
|
109511
|
+
*
|
|
109512
|
+
* @type {number}
|
|
109513
|
+
* @constant
|
|
109514
|
+
*/
|
|
109515
|
+
const ByteType = 1010;
|
|
109516
|
+
/**
|
|
109517
|
+
* A short data type for textures.
|
|
109518
|
+
*
|
|
109519
|
+
* @type {number}
|
|
109520
|
+
* @constant
|
|
109521
|
+
*/
|
|
109522
|
+
const ShortType = 1011;
|
|
109523
|
+
/**
|
|
109524
|
+
* An unsigned short data type for textures.
|
|
109525
|
+
*
|
|
109526
|
+
* @type {number}
|
|
109527
|
+
* @constant
|
|
109528
|
+
*/
|
|
109529
|
+
const UnsignedShortType = 1012;
|
|
109530
|
+
/**
|
|
109531
|
+
* An int data type for textures.
|
|
109532
|
+
*
|
|
109533
|
+
* @type {number}
|
|
109534
|
+
* @constant
|
|
109535
|
+
*/
|
|
109536
|
+
const IntType = 1013;
|
|
109537
|
+
/**
|
|
109538
|
+
* An unsigned int data type for textures.
|
|
109539
|
+
*
|
|
109540
|
+
* @type {number}
|
|
109541
|
+
* @constant
|
|
109542
|
+
*/
|
|
109543
|
+
const UnsignedIntType = 1014;
|
|
109544
|
+
/**
|
|
109545
|
+
* A float data type for textures.
|
|
109546
|
+
*
|
|
109547
|
+
* @type {number}
|
|
109548
|
+
* @constant
|
|
109549
|
+
*/
|
|
109550
|
+
const FloatType = 1015;
|
|
109551
|
+
/**
|
|
109552
|
+
* A half float data type for textures.
|
|
109553
|
+
*
|
|
109554
|
+
* @type {number}
|
|
109555
|
+
* @constant
|
|
109556
|
+
*/
|
|
109557
|
+
const HalfFloatType = 1016;
|
|
109558
|
+
/**
|
|
109559
|
+
* An unsigned short 4_4_4_4 (packed) data type for textures.
|
|
109560
|
+
*
|
|
109561
|
+
* @type {number}
|
|
109562
|
+
* @constant
|
|
109563
|
+
*/
|
|
109564
|
+
const UnsignedShort4444Type = 1017;
|
|
109565
|
+
/**
|
|
109566
|
+
* An unsigned short 5_5_5_1 (packed) data type for textures.
|
|
109567
|
+
*
|
|
109568
|
+
* @type {number}
|
|
109569
|
+
* @constant
|
|
109570
|
+
*/
|
|
109571
|
+
const UnsignedShort5551Type = 1018;
|
|
109572
|
+
/**
|
|
109573
|
+
* An unsigned int 24_8 data type for textures.
|
|
109574
|
+
*
|
|
109575
|
+
* @type {number}
|
|
109576
|
+
* @constant
|
|
109577
|
+
*/
|
|
109578
|
+
const UnsignedInt248Type = 1020;
|
|
109579
|
+
/**
|
|
109580
|
+
* An unsigned int 5_9_9_9 (packed) data type for textures.
|
|
109581
|
+
*
|
|
109582
|
+
* @type {number}
|
|
109583
|
+
* @constant
|
|
109584
|
+
*/
|
|
109585
|
+
const UnsignedInt5999Type = 35902;
|
|
109586
|
+
/**
|
|
109587
|
+
* An unsigned int 10_11_11 (packed) data type for textures.
|
|
109588
|
+
*
|
|
109589
|
+
* @type {number}
|
|
109590
|
+
* @constant
|
|
109591
|
+
*/
|
|
109592
|
+
const UnsignedInt101111Type = 35899;
|
|
109593
|
+
/**
|
|
109594
|
+
* Discards the red, green and blue components and reads just the alpha component.
|
|
109595
|
+
*
|
|
109596
|
+
* @type {number}
|
|
109597
|
+
* @constant
|
|
109598
|
+
*/
|
|
109599
|
+
const AlphaFormat = 1021;
|
|
109600
|
+
/**
|
|
109601
|
+
* Discards the alpha component and reads the red, green and blue component.
|
|
109602
|
+
*
|
|
109603
|
+
* @type {number}
|
|
109604
|
+
* @constant
|
|
109605
|
+
*/
|
|
109606
|
+
const RGBFormat = 1022;
|
|
109607
|
+
/**
|
|
109608
|
+
* Reads the red, green, blue and alpha components.
|
|
109609
|
+
*
|
|
109610
|
+
* @type {number}
|
|
109611
|
+
* @constant
|
|
109612
|
+
*/
|
|
109613
|
+
const RGBAFormat = 1023;
|
|
109614
|
+
/**
|
|
109615
|
+
* Reads each element as a single depth value, converts it to floating point, and clamps to the range `[0,1]`.
|
|
109616
|
+
*
|
|
109617
|
+
* @type {number}
|
|
109618
|
+
* @constant
|
|
109619
|
+
*/
|
|
109620
|
+
const DepthFormat = 1026;
|
|
109621
|
+
/**
|
|
109622
|
+
* Reads each element is a pair of depth and stencil values. The depth component of the pair is interpreted as
|
|
109623
|
+
* in `DepthFormat`. The stencil component is interpreted based on the depth + stencil internal format.
|
|
109624
|
+
*
|
|
109625
|
+
* @type {number}
|
|
109626
|
+
* @constant
|
|
109627
|
+
*/
|
|
109628
|
+
const DepthStencilFormat = 1027;
|
|
109629
|
+
/**
|
|
109630
|
+
* Discards the green, blue and alpha components and reads just the red component.
|
|
109631
|
+
*
|
|
109632
|
+
* @type {number}
|
|
109633
|
+
* @constant
|
|
109634
|
+
*/
|
|
109635
|
+
const RedFormat = 1028;
|
|
109636
|
+
/**
|
|
109637
|
+
* Discards the green, blue and alpha components and reads just the red component. The texels are read as integers instead of floating point.
|
|
109638
|
+
*
|
|
109639
|
+
* @type {number}
|
|
109640
|
+
* @constant
|
|
109641
|
+
*/
|
|
109642
|
+
const RedIntegerFormat = 1029;
|
|
109643
|
+
/**
|
|
109644
|
+
* Discards the alpha, and blue components and reads the red, and green components.
|
|
109645
|
+
*
|
|
109646
|
+
* @type {number}
|
|
109647
|
+
* @constant
|
|
109648
|
+
*/
|
|
109649
|
+
const RGFormat = 1030;
|
|
109650
|
+
/**
|
|
109651
|
+
* Discards the alpha, and blue components and reads the red, and green components. The texels are read as integers instead of floating point.
|
|
109652
|
+
*
|
|
109653
|
+
* @type {number}
|
|
109654
|
+
* @constant
|
|
109655
|
+
*/
|
|
109656
|
+
const RGIntegerFormat = 1031;
|
|
109657
|
+
/**
|
|
109658
|
+
* Reads the red, green, blue and alpha components. The texels are read as integers instead of floating point.
|
|
109659
|
+
*
|
|
109660
|
+
* @type {number}
|
|
109661
|
+
* @constant
|
|
109662
|
+
*/
|
|
109663
|
+
const RGBAIntegerFormat = 1033;
|
|
109664
|
+
/**
|
|
109665
|
+
* A DXT1-compressed image in an RGB image format.
|
|
109666
|
+
*
|
|
109667
|
+
* @type {number}
|
|
109668
|
+
* @constant
|
|
109669
|
+
*/
|
|
109670
|
+
const RGB_S3TC_DXT1_Format = 33776;
|
|
109671
|
+
/**
|
|
109672
|
+
* A DXT1-compressed image in an RGB image format with a simple on/off alpha value.
|
|
109673
|
+
*
|
|
109674
|
+
* @type {number}
|
|
109675
|
+
* @constant
|
|
109676
|
+
*/
|
|
109677
|
+
const RGBA_S3TC_DXT1_Format = 33777;
|
|
109678
|
+
/**
|
|
109679
|
+
* A DXT3-compressed image in an RGBA image format. Compared to a 32-bit RGBA texture, it offers 4:1 compression.
|
|
109680
|
+
*
|
|
109681
|
+
* @type {number}
|
|
109682
|
+
* @constant
|
|
109683
|
+
*/
|
|
109684
|
+
const RGBA_S3TC_DXT3_Format = 33778;
|
|
109685
|
+
/**
|
|
109686
|
+
* A DXT5-compressed image in an RGBA image format. It also provides a 4:1 compression, but differs to the DXT3
|
|
109687
|
+
* compression in how the alpha compression is done.
|
|
109688
|
+
*
|
|
109689
|
+
* @type {number}
|
|
109690
|
+
* @constant
|
|
109691
|
+
*/
|
|
109692
|
+
const RGBA_S3TC_DXT5_Format = 33779;
|
|
109693
|
+
/**
|
|
109694
|
+
* PVRTC RGB compression in 4-bit mode. One block for each 4×4 pixels.
|
|
109695
|
+
*
|
|
109696
|
+
* @type {number}
|
|
109697
|
+
* @constant
|
|
109698
|
+
*/
|
|
109699
|
+
const RGB_PVRTC_4BPPV1_Format = 35840;
|
|
109700
|
+
/**
|
|
109701
|
+
* PVRTC RGB compression in 2-bit mode. One block for each 8×4 pixels.
|
|
109702
|
+
*
|
|
109703
|
+
* @type {number}
|
|
109704
|
+
* @constant
|
|
109705
|
+
*/
|
|
109706
|
+
const RGB_PVRTC_2BPPV1_Format = 35841;
|
|
109707
|
+
/**
|
|
109708
|
+
* PVRTC RGBA compression in 4-bit mode. One block for each 4×4 pixels.
|
|
109709
|
+
*
|
|
109710
|
+
* @type {number}
|
|
109711
|
+
* @constant
|
|
109712
|
+
*/
|
|
109713
|
+
const RGBA_PVRTC_4BPPV1_Format = 35842;
|
|
109714
|
+
/**
|
|
109715
|
+
* PVRTC RGBA compression in 2-bit mode. One block for each 8×4 pixels.
|
|
109716
|
+
*
|
|
109717
|
+
* @type {number}
|
|
109718
|
+
* @constant
|
|
109719
|
+
*/
|
|
109720
|
+
const RGBA_PVRTC_2BPPV1_Format = 35843;
|
|
109721
|
+
/**
|
|
109722
|
+
* ETC1 RGB format.
|
|
109723
|
+
*
|
|
109724
|
+
* @type {number}
|
|
109725
|
+
* @constant
|
|
109726
|
+
*/
|
|
109727
|
+
const RGB_ETC1_Format = 36196;
|
|
109728
|
+
/**
|
|
109729
|
+
* ETC2 RGB format.
|
|
109730
|
+
*
|
|
109731
|
+
* @type {number}
|
|
109732
|
+
* @constant
|
|
109733
|
+
*/
|
|
109734
|
+
const RGB_ETC2_Format = 37492;
|
|
109735
|
+
/**
|
|
109736
|
+
* ETC2 RGBA format.
|
|
109737
|
+
*
|
|
109738
|
+
* @type {number}
|
|
109739
|
+
* @constant
|
|
109740
|
+
*/
|
|
109741
|
+
const RGBA_ETC2_EAC_Format = 37496;
|
|
109742
|
+
/**
|
|
109743
|
+
* EAC R11 UNORM format.
|
|
109744
|
+
*
|
|
109745
|
+
* @type {number}
|
|
109746
|
+
* @constant
|
|
109747
|
+
*/
|
|
109748
|
+
const R11_EAC_Format = 37488;
|
|
109749
|
+
/**
|
|
109750
|
+
* EAC R11 SNORM format.
|
|
109751
|
+
*
|
|
109752
|
+
* @type {number}
|
|
109753
|
+
* @constant
|
|
109754
|
+
*/
|
|
109755
|
+
const SIGNED_R11_EAC_Format = 37489;
|
|
109756
|
+
/**
|
|
109757
|
+
* EAC RG11 UNORM format.
|
|
109758
|
+
*
|
|
109759
|
+
* @type {number}
|
|
109760
|
+
* @constant
|
|
109761
|
+
*/
|
|
109762
|
+
const RG11_EAC_Format = 37490;
|
|
109763
|
+
/**
|
|
109764
|
+
* EAC RG11 SNORM format.
|
|
109765
|
+
*
|
|
109766
|
+
* @type {number}
|
|
109767
|
+
* @constant
|
|
109768
|
+
*/
|
|
109769
|
+
const SIGNED_RG11_EAC_Format = 37491;
|
|
109770
|
+
/**
|
|
109771
|
+
* ASTC RGBA 4x4 format.
|
|
109772
|
+
*
|
|
109773
|
+
* @type {number}
|
|
109774
|
+
* @constant
|
|
109775
|
+
*/
|
|
109776
|
+
const RGBA_ASTC_4x4_Format = 37808;
|
|
109777
|
+
/**
|
|
109778
|
+
* ASTC RGBA 5x4 format.
|
|
109779
|
+
*
|
|
109780
|
+
* @type {number}
|
|
109781
|
+
* @constant
|
|
109782
|
+
*/
|
|
109783
|
+
const RGBA_ASTC_5x4_Format = 37809;
|
|
109784
|
+
/**
|
|
109785
|
+
* ASTC RGBA 5x5 format.
|
|
109786
|
+
*
|
|
109787
|
+
* @type {number}
|
|
109788
|
+
* @constant
|
|
109789
|
+
*/
|
|
109790
|
+
const RGBA_ASTC_5x5_Format = 37810;
|
|
109791
|
+
/**
|
|
109792
|
+
* ASTC RGBA 6x5 format.
|
|
109793
|
+
*
|
|
109794
|
+
* @type {number}
|
|
109795
|
+
* @constant
|
|
109796
|
+
*/
|
|
109797
|
+
const RGBA_ASTC_6x5_Format = 37811;
|
|
109798
|
+
/**
|
|
109799
|
+
* ASTC RGBA 6x6 format.
|
|
109800
|
+
*
|
|
109801
|
+
* @type {number}
|
|
109802
|
+
* @constant
|
|
109803
|
+
*/
|
|
109804
|
+
const RGBA_ASTC_6x6_Format = 37812;
|
|
109805
|
+
/**
|
|
109806
|
+
* ASTC RGBA 8x5 format.
|
|
109807
|
+
*
|
|
109808
|
+
* @type {number}
|
|
109809
|
+
* @constant
|
|
109810
|
+
*/
|
|
109811
|
+
const RGBA_ASTC_8x5_Format = 37813;
|
|
109812
|
+
/**
|
|
109813
|
+
* ASTC RGBA 8x6 format.
|
|
109814
|
+
*
|
|
109815
|
+
* @type {number}
|
|
109816
|
+
* @constant
|
|
109817
|
+
*/
|
|
109818
|
+
const RGBA_ASTC_8x6_Format = 37814;
|
|
109819
|
+
/**
|
|
109820
|
+
* ASTC RGBA 8x8 format.
|
|
109821
|
+
*
|
|
109822
|
+
* @type {number}
|
|
109823
|
+
* @constant
|
|
109824
|
+
*/
|
|
109825
|
+
const RGBA_ASTC_8x8_Format = 37815;
|
|
109826
|
+
/**
|
|
109827
|
+
* ASTC RGBA 10x5 format.
|
|
109828
|
+
*
|
|
109829
|
+
* @type {number}
|
|
109830
|
+
* @constant
|
|
109831
|
+
*/
|
|
109832
|
+
const RGBA_ASTC_10x5_Format = 37816;
|
|
109833
|
+
/**
|
|
109834
|
+
* ASTC RGBA 10x6 format.
|
|
109835
|
+
*
|
|
109836
|
+
* @type {number}
|
|
109837
|
+
* @constant
|
|
109838
|
+
*/
|
|
109839
|
+
const RGBA_ASTC_10x6_Format = 37817;
|
|
109840
|
+
/**
|
|
109841
|
+
* ASTC RGBA 10x8 format.
|
|
109842
|
+
*
|
|
109843
|
+
* @type {number}
|
|
109844
|
+
* @constant
|
|
109845
|
+
*/
|
|
109846
|
+
const RGBA_ASTC_10x8_Format = 37818;
|
|
109847
|
+
/**
|
|
109848
|
+
* ASTC RGBA 10x10 format.
|
|
109849
|
+
*
|
|
109850
|
+
* @type {number}
|
|
109851
|
+
* @constant
|
|
109852
|
+
*/
|
|
109853
|
+
const RGBA_ASTC_10x10_Format = 37819;
|
|
109854
|
+
/**
|
|
109855
|
+
* ASTC RGBA 12x10 format.
|
|
109856
|
+
*
|
|
109857
|
+
* @type {number}
|
|
109858
|
+
* @constant
|
|
109859
|
+
*/
|
|
109860
|
+
const RGBA_ASTC_12x10_Format = 37820;
|
|
109861
|
+
/**
|
|
109862
|
+
* ASTC RGBA 12x12 format.
|
|
109863
|
+
*
|
|
109864
|
+
* @type {number}
|
|
109865
|
+
* @constant
|
|
109866
|
+
*/
|
|
109867
|
+
const RGBA_ASTC_12x12_Format = 37821;
|
|
109868
|
+
/**
|
|
109869
|
+
* BPTC RGBA format.
|
|
109870
|
+
*
|
|
108813
109871
|
* @type {number}
|
|
108814
109872
|
* @constant
|
|
108815
109873
|
*/
|
|
@@ -140733,897 +141791,372 @@ void main() {
|
|
|
140733
141791
|
color.setRGB(r, g, b, SRGBColorSpace);
|
|
140734
141792
|
colors[componentIdx] = color.r;
|
|
140735
141793
|
colors[componentIdx + 1] = color.g;
|
|
140736
|
-
colors[componentIdx + 2] = color.b;
|
|
140737
|
-
}
|
|
140738
|
-
}
|
|
140739
|
-
}
|
|
140740
|
-
geometry.setAttribute("position", new BufferAttribute(vertices, 3));
|
|
140741
|
-
geometry.setAttribute("normal", new BufferAttribute(normals, 3));
|
|
140742
|
-
if (hasColors) {
|
|
140743
|
-
geometry.setAttribute("color", new BufferAttribute(colors, 3));
|
|
140744
|
-
geometry.hasColors = true;
|
|
140745
|
-
geometry.alpha = alpha;
|
|
140746
|
-
}
|
|
140747
|
-
return geometry;
|
|
140748
|
-
}
|
|
140749
|
-
function parseASCII(data) {
|
|
140750
|
-
const geometry = new BufferGeometry();
|
|
140751
|
-
const patternSolid = /solid([\s\S]*?)endsolid/g;
|
|
140752
|
-
const patternFace = /facet([\s\S]*?)endfacet/g;
|
|
140753
|
-
const patternName = /solid\s(.+)/;
|
|
140754
|
-
let faceCounter = 0;
|
|
140755
|
-
const patternFloat = /[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source;
|
|
140756
|
-
const patternVertex = new RegExp("vertex" + patternFloat + patternFloat + patternFloat, "g");
|
|
140757
|
-
const patternNormal = new RegExp("normal" + patternFloat + patternFloat + patternFloat, "g");
|
|
140758
|
-
const vertices = [];
|
|
140759
|
-
const normals = [];
|
|
140760
|
-
const groupNames = [];
|
|
140761
|
-
const normal = new Vector3();
|
|
140762
|
-
let result;
|
|
140763
|
-
let groupCount = 0;
|
|
140764
|
-
let startVertex = 0;
|
|
140765
|
-
let endVertex = 0;
|
|
140766
|
-
while ((result = patternSolid.exec(data)) !== null) {
|
|
140767
|
-
startVertex = endVertex;
|
|
140768
|
-
const solid = result[0];
|
|
140769
|
-
const name = (result = patternName.exec(solid)) !== null ? result[1] : "";
|
|
140770
|
-
groupNames.push(name);
|
|
140771
|
-
while ((result = patternFace.exec(solid)) !== null) {
|
|
140772
|
-
let vertexCountPerFace = 0;
|
|
140773
|
-
let normalCountPerFace = 0;
|
|
140774
|
-
const text = result[0];
|
|
140775
|
-
while ((result = patternNormal.exec(text)) !== null) {
|
|
140776
|
-
normal.x = parseFloat(result[1]);
|
|
140777
|
-
normal.y = parseFloat(result[2]);
|
|
140778
|
-
normal.z = parseFloat(result[3]);
|
|
140779
|
-
normalCountPerFace++;
|
|
140780
|
-
}
|
|
140781
|
-
while ((result = patternVertex.exec(text)) !== null) {
|
|
140782
|
-
vertices.push(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3]));
|
|
140783
|
-
normals.push(normal.x, normal.y, normal.z);
|
|
140784
|
-
vertexCountPerFace++;
|
|
140785
|
-
endVertex++;
|
|
140786
|
-
}
|
|
140787
|
-
if (normalCountPerFace !== 1) console.error("THREE.STLLoader: Something isn't right with the normal of face number " + faceCounter);
|
|
140788
|
-
if (vertexCountPerFace !== 3) console.error("THREE.STLLoader: Something isn't right with the vertices of face number " + faceCounter);
|
|
140789
|
-
faceCounter++;
|
|
140790
|
-
}
|
|
140791
|
-
const start = startVertex;
|
|
140792
|
-
const count = endVertex - startVertex;
|
|
140793
|
-
geometry.userData.groupNames = groupNames;
|
|
140794
|
-
geometry.addGroup(start, count, groupCount);
|
|
140795
|
-
groupCount++;
|
|
140796
|
-
}
|
|
140797
|
-
geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
|
|
140798
|
-
geometry.setAttribute("normal", new Float32BufferAttribute(normals, 3));
|
|
140799
|
-
return geometry;
|
|
140800
|
-
}
|
|
140801
|
-
function ensureString(buffer) {
|
|
140802
|
-
if (typeof buffer !== "string") return new TextDecoder().decode(buffer);
|
|
140803
|
-
return buffer;
|
|
140804
|
-
}
|
|
140805
|
-
function ensureBinary(buffer) {
|
|
140806
|
-
if (typeof buffer === "string") {
|
|
140807
|
-
const array_buffer = new Uint8Array(buffer.length);
|
|
140808
|
-
for (let i = 0; i < buffer.length; i++) array_buffer[i] = buffer.charCodeAt(i) & 255;
|
|
140809
|
-
return array_buffer.buffer || array_buffer;
|
|
140810
|
-
} else return buffer;
|
|
140811
|
-
}
|
|
140812
|
-
const binData = ensureBinary(data);
|
|
140813
|
-
return isBinary(binData) ? parseBinary(binData) : parseASCII(ensureString(data));
|
|
140814
|
-
}
|
|
140815
|
-
};
|
|
140816
|
-
//#endregion
|
|
140817
|
-
//#region ../dsh-hardware-ui/src/client/mesh-file.ts
|
|
140818
|
-
const meshFileTypes = ".stl,.obj";
|
|
140819
|
-
function parseMeshFile(name, bytes) {
|
|
140820
|
-
if (/\.obj$/i.test(name)) return new OBJLoader().parse(new TextDecoder().decode(bytes));
|
|
140821
|
-
if (!/\.stl$/i.test(name)) throw new Error("请选择 STL 或 OBJ 文件。");
|
|
140822
|
-
const header = new TextDecoder("ascii").decode(bytes.slice(0, 9));
|
|
140823
|
-
const binary = bytes.byteLength >= 84 && 84 + new DataView(bytes).getUint32(80, true) * 50 === bytes.byteLength;
|
|
140824
|
-
if (bytes.byteLength < 84 || !binary && !header.includes("solid")) throw new Error("STL 文件不完整或格式无效。");
|
|
140825
|
-
const geometry = new STLLoader().parse(bytes);
|
|
140826
|
-
if (!geometry.getAttribute("normal") || !binary) geometry.computeVertexNormals();
|
|
140827
|
-
return new Mesh(geometry, new MeshStandardMaterial({
|
|
140828
|
-
side: 2,
|
|
140829
|
-
vertexColors: geometry.hasAttribute("color")
|
|
140830
|
-
}));
|
|
140831
|
-
}
|
|
140832
|
-
//#endregion
|
|
140833
|
-
//#region src/Mechanical.tsx
|
|
140834
|
-
function Mechanical({ file, onFile }) {
|
|
140835
|
-
const host = (0, react.useRef)(null);
|
|
140836
|
-
const [status, setStatus] = (0, react.useState)("");
|
|
140837
|
-
(0, react.useEffect)(() => {
|
|
140838
|
-
if (!file) return;
|
|
140839
|
-
const controller = new AbortController();
|
|
140840
|
-
let preview;
|
|
140841
|
-
async function load(modelFile) {
|
|
140842
|
-
if (modelFile.size > 33554432) throw new Error("请选择不超过 32 MiB 的模型文件。");
|
|
140843
|
-
const bytes = await modelFile.arrayBuffer();
|
|
140844
|
-
if (controller.signal.aborted) return;
|
|
140845
|
-
preview = mountModel(parseMeshFile(modelFile.name, bytes), host.current, { signal: controller.signal });
|
|
140846
|
-
setStatus("");
|
|
140847
|
-
}
|
|
140848
|
-
setStatus("正在读取模型…");
|
|
140849
|
-
load(file).catch((error) => {
|
|
140850
|
-
if (!controller.signal.aborted) setStatus("无法预览模型。" + (error instanceof Error ? error.message : String(error)));
|
|
140851
|
-
});
|
|
140852
|
-
return () => {
|
|
140853
|
-
controller.abort();
|
|
140854
|
-
preview?.dispose();
|
|
140855
|
-
};
|
|
140856
|
-
}, [file]);
|
|
140857
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
140858
|
-
className: "ew-files",
|
|
140859
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
140860
|
-
className: "ew-model-picker",
|
|
140861
|
-
children: ["选择模型", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
140862
|
-
type: "file",
|
|
140863
|
-
accept: meshFileTypes,
|
|
140864
|
-
onChange: (event) => {
|
|
140865
|
-
const selected = event.target.files?.[0];
|
|
140866
|
-
if (selected) onFile(selected);
|
|
140867
|
-
event.target.value = "";
|
|
140868
|
-
}
|
|
140869
|
-
})]
|
|
140870
|
-
}), file && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
140871
|
-
className: "ew-model-info",
|
|
140872
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: file.name }), !status && " · 拖动旋转,滚轮缩放"]
|
|
140873
|
-
})]
|
|
140874
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
140875
|
-
className: "ew-pane ew-model",
|
|
140876
|
-
"aria-label": "结构件预览",
|
|
140877
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
140878
|
-
className: "ew-stage",
|
|
140879
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
140880
|
-
className: "ew-surface",
|
|
140881
|
-
ref: host
|
|
140882
|
-
}), (!file || status) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
140883
|
-
className: "ew-message",
|
|
140884
|
-
role: "status",
|
|
140885
|
-
children: status || "选择 STL 或 OBJ 文件,预览外壳或结构件。"
|
|
140886
|
-
})]
|
|
140887
|
-
})
|
|
140888
|
-
})] });
|
|
140889
|
-
}
|
|
140890
|
-
const MODES = [
|
|
140891
|
-
"design",
|
|
140892
|
-
"review",
|
|
140893
|
-
"manufacture"
|
|
140894
|
-
];
|
|
140895
|
-
function validRequest(value) {
|
|
140896
|
-
return !!value && MODES.includes(value.view) && (value.designTool === void 0 || value.view === "design" && [
|
|
140897
|
-
"schematic",
|
|
140898
|
-
"pcb",
|
|
140899
|
-
"3d",
|
|
140900
|
-
"mechanical"
|
|
140901
|
-
].includes(value.designTool)) && (value.action === void 0 || ["open", "suggest"].includes(value.action)) && [
|
|
140902
|
-
value.path,
|
|
140903
|
-
value.project,
|
|
140904
|
-
value.reference
|
|
140905
|
-
].every((s) => s === void 0 || typeof s === "string" && s.trim() && s.length <= 4096) && (value.path === void 0 || /\.kicad_(pcb|sch)$/i.test(value.path)) && (value.project === void 0 || /\.kicad_pro$/i.test(value.project));
|
|
140906
|
-
}
|
|
140907
|
-
function requestsIn(nodes) {
|
|
140908
|
-
const requests = /* @__PURE__ */ new Map();
|
|
140909
|
-
const visit = (node) => {
|
|
140910
|
-
if (!node || typeof node !== "object") return;
|
|
140911
|
-
if (node.kind === "tool-result" && node.call?.name === "hardware_open_workbench" && Array.isArray(node.content)) for (const block of node.content) {
|
|
140912
|
-
if (block.type !== "text") continue;
|
|
140913
|
-
try {
|
|
140914
|
-
const value = JSON.parse(block.text);
|
|
140915
|
-
if (validRequest(value) && typeof value.requestId === "string" && Number.isFinite(value.issuedAt)) requests.set(value.requestId, value);
|
|
140916
|
-
} catch {}
|
|
140917
|
-
}
|
|
140918
|
-
for (const key of [
|
|
140919
|
-
"children",
|
|
140920
|
-
"nodes",
|
|
140921
|
-
"subCalls"
|
|
140922
|
-
]) if (Array.isArray(node[key])) node[key].forEach(visit);
|
|
140923
|
-
};
|
|
140924
|
-
nodes.forEach(visit);
|
|
140925
|
-
return [...requests.values()];
|
|
140926
|
-
}
|
|
140927
|
-
//#endregion
|
|
140928
|
-
//#region src/styles.ts
|
|
140929
|
-
const styles = `
|
|
140930
|
-
.ew-model{margin:0 6px 6px;min-height:180px}.ew-model-info{overflow-wrap:anywhere}.ew-model-picker{position:relative;cursor:pointer;padding:4px 8px;border:1px solid var(--dsw-alias-border-l2,#abbcac);border-radius:4px}.ew-model-picker input{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer}.ew-model-picker:focus-within{outline:2px solid #bf845d;outline-offset:1px}
|
|
140931
|
-
.ew-file-control{display:inline-flex;flex-wrap:wrap;align-items:center;gap:4px;max-width:100%}.ew-files .ew-preview-toggle{padding:3px 6px;font-size:12px}
|
|
140932
|
-
.ew .ew-content[data-preview=false]{min-height:0}.ew .ew-content[data-preview=false] .ew-inspect{flex:1;width:auto;max-height:none}.ew .ew-content[data-preview=false] .ew-main{min-height:0}
|
|
140933
|
-
.ew-content{display:flex;flex:1;flex-direction:column;min-height:260px}.ew-content .ew-main{min-width:0}
|
|
140934
|
-
@container(min-width:800px){.ew-content{flex-direction:row}.ew-content .ew-inspect{width:230px;max-height:100%;border-left:1px solid var(--dsw-alias-border-l2,#c4cabb)}}
|
|
140935
|
-
.ew{container-type:inline-size;box-sizing:border-box;height:100%;min-height:0;display:flex;flex-direction:column;overflow:auto;background:var(--dsw-alias-bg-layer-1,#f7f4ed);color:var(--dsw-alias-label-primary,#213b30);font-size:13px;line-height:1.5;font-family:inherit}
|
|
140936
|
-
.ew-main{display:flex;flex:1;min-height:220px}.ew-main[data-manufacture=true] .ew-drawings{order:2;flex:1;min-width:0}.ew-manufacture{min-width:0}.ew *{box-sizing:border-box}.ew p{margin:12px}.ew button,.ew select,.ew input{font:inherit;color:inherit}
|
|
140937
|
-
.ew button,.ew select,.ew input:not([type=checkbox]){background:var(--dsw-alias-bg-layer-1,#faf8f1);border:1px solid var(--dsw-alias-border-l2,#abbcac);border-radius:4px;padding:4px 8px}
|
|
140938
|
-
.ew button{cursor:pointer}.ew button:disabled{opacity:.45;cursor:default}.ew :focus-visible{outline:2px solid #bf845d;outline-offset:1px}
|
|
140939
|
-
.ew-head,.ew-tools,.ew-files,.ew-inspect header,.ew-manufacture header,.ew-manufacture footer{display:flex;align-items:center;gap:8px;padding:8px 12px;flex-wrap:wrap}
|
|
140940
|
-
.ew-head{min-height:32px;padding-block:3px;padding-right:76px;background:#153f35;color:#faf3df;flex:none}
|
|
140941
|
-
.ew-head span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:40%}.ew-head select,.ew-head button{background:#204d40;border-color:#739181;color:#fff5e2}.ew-head select{max-width:48%}
|
|
140942
|
-
.ew button[aria-pressed=true]{background:#235642;color:#fff8e9;border-color:#386c53}
|
|
140943
|
-
.ew-tools,.ew-files{font-size:12px;padding-block:5px}.ew-files label{max-width:100%}.ew-files select{max-width:min(240px,70cqw)}.ew-drawings{display:flex;flex:1 0 200px;min-height:200px;padding:6px;gap:5px}.ew-pane{display:flex;flex-direction:column;flex:1;min-width:0;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l2,#bac8bc);border-radius:5px;overflow:hidden}.ew [hidden]{display:none!important}
|
|
140944
|
-
.ew-stage{position:relative;flex:1;min-height:140px}.ew-surface{position:absolute;inset:0;overflow:hidden}.ew-message{position:absolute;inset:15px;display:grid;place-content:center;text-align:center;pointer-events:none}.ew-pane small,.ew-inspect small{padding:3px 8px}
|
|
140945
|
-
.ew-inspect{padding:0 0 8px;border-top:1px solid var(--dsw-alias-border-l2,#c4cabb);max-height:32%;overflow:auto;flex:none}.ew-inspect input:not([type=checkbox]){width:130px}.ew-details,.ew-inspect>label{padding:2px 12px}.ew-details details span{display:inline-block;margin:2px 10px 2px 0}
|
|
140946
|
-
.ew-manufacture{display:flex;flex:1;min-height:180px;flex-direction:column}.ew-manufacture header{justify-content:space-between}.ew-table-wrap{overflow:auto;flex:1}
|
|
140947
|
-
.ew table{border-collapse:collapse;width:100%;text-align:left;font-size:12px}.ew th,.ew td{padding:6px 10px;border-bottom:1px solid var(--dsw-alias-border-l2,#c9d0c5)}.ew th{position:sticky;top:0;background:var(--dsw-alias-bg-layer-2,#e4e9de)}.ew tr[data-selected=true]{box-shadow:inset 3px 0 #ca906a;background:var(--dsw-alias-button-primary-dimmed)}
|
|
140948
|
-
@container(max-width:580px){.ew-main[data-manufacture=true]{flex-direction:column-reverse;min-height:440px}.ew-drawings[data-review=true]{flex-direction:column;min-height:310px}.ew-head{padding-right:68px}.ew-tools,.ew-files{gap:4px}}
|
|
140949
|
-
.ew[data-view=manufacture] .ew-main{flex-direction:column;min-height:0}
|
|
140950
|
-
.ew[data-view=manufacture] .ew-drawings{flex:0 1 26%;min-height:140px}
|
|
140951
|
-
.ew-manufacture{flex:1 1 300px;min-height:220px;overflow:auto}
|
|
140952
|
-
.ew-pricing input{width:6em}.ew-manufacture .ew-pricing{justify-content:flex-start}
|
|
140953
|
-
.ew-prices{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;padding:8px 12px;margin:0;border-block:1px solid var(--dsw-alias-border-l2,#bac8bc)}
|
|
140954
|
-
.ew-prices dt,.ew-manufacture td small{font-size:12px}.ew-prices dd{margin:2px 0;font-weight:600;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
|
|
140955
|
-
.ew-manufacture td{vertical-align:top}.ew-manufacture td small{display:block;margin-top:3px}.ew-manufacture td select{max-width:18em}
|
|
140956
|
-
.ew-fab-file{display:flex;flex:1;min-height:160px;flex-direction:column}.ew-fab-file select{max-width:65cqw}
|
|
140957
|
-
.ew-fab-file header{justify-content:flex-start}.ew-gerber{display:grid;flex:1;min-height:160px;place-items:center;background:#15332c}.ew-gerber img{width:100%;height:100%;max-height:65vh;min-height:140px;object-fit:contain}
|
|
140958
|
-
.ew-coordinates{overflow:auto;flex:1;margin:0;padding:12px;white-space:pre;font:12px/1.6 ui-monospace,monospace}
|
|
140959
|
-
|
|
140960
|
-
.ew-manufacture[data-manufacturing-tab=BOM] {
|
|
140961
|
-
--bom-line: var(--dsw-alias-border-l2,#bac8bc);
|
|
140962
|
-
--bom-surface: var(--dsw-alias-bg-layer-1,#faf8f2);
|
|
140963
|
-
--bom-head: var(--dsw-alias-bg-layer-2,#e7ece5);
|
|
140964
|
-
--bom-accent: var(--dsw-alias-label-primary,currentColor);
|
|
140965
|
-
}
|
|
140966
|
-
.ew-manufacture[data-manufacturing-tab=BOM] .ew-prices {gap:0;padding:5px 0}
|
|
140967
|
-
.ew-manufacture[data-manufacturing-tab=BOM] .ew-prices div {padding:1px 12px}
|
|
140968
|
-
.ew-manufacture[data-manufacturing-tab=BOM] .ew-prices div+div {border-inline-start:1px solid var(--bom-line)}
|
|
140969
|
-
.ew-bom-grid {min-width:0;min-height:155px;flex:1;display:flex;flex-direction:column}
|
|
140970
|
-
.ew-bom-bar {display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:6px 10px;border-bottom:1px solid var(--bom-line)}
|
|
140971
|
-
.ew-bom-bar>span {font-size:11px;font-variant-numeric:tabular-nums;opacity:.78}
|
|
140972
|
-
.ew-bom-bar input {margin-inline-start:auto;width:min(15em,46cqw);min-width:8em}
|
|
140973
|
-
.ew-bom-bar input,.ew-bom-bar button {font-size:12px}
|
|
140974
|
-
.ew-bom-scroll {min-width:0;min-height:80px;flex:1;overflow:auto;overscroll-behavior:contain}
|
|
140975
|
-
.ew .ew-bom-table {border-collapse:separate;border-spacing:0;table-layout:fixed;font-size:12px;line-height:1.35}
|
|
140976
|
-
.ew-bom-table thead {position:sticky;top:0;z-index:2}
|
|
140977
|
-
.ew .ew-bom-table th,.ew .ew-bom-table td {padding:0 8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-inline-end:1px solid var(--bom-line);border-bottom:1px solid var(--bom-line);vertical-align:middle}
|
|
140978
|
-
.ew .ew-bom-table th {position:relative;top:auto;background:var(--bom-head);font-weight:600;text-align:start;user-select:none}
|
|
140979
|
-
.ew .ew-bom-groups th {height:21px;font-size:11px;background:var(--bom-surface);color:var(--bom-accent);box-shadow:inset 0 2px #588572}
|
|
140980
|
-
.ew .ew-bom-groups th[data-group=采购方案] {box-shadow:inset 0 2px #b8855b}
|
|
140981
|
-
.ew .ew-bom-table th[scope=col] {height:27px;padding:0}
|
|
140982
|
-
.ew-bom-heading {display:block;overflow:hidden;text-overflow:ellipsis;padding:5px 8px;cursor:grab}
|
|
140983
|
-
.ew-bom-heading:active {cursor:grabbing}
|
|
140984
|
-
.ew-bom-resize {position:absolute;top:0;bottom:0;right:0;width:9px;touch-action:none;cursor:col-resize}
|
|
140985
|
-
.ew-bom-resize::after {content:'';position:absolute;right:0;top:20%;bottom:20%;width:2px;background:var(--bom-line)}
|
|
140986
|
-
.ew-bom-resize:is(:hover,:focus-visible,:active)::after,.ew-bom-table th[data-drop]::before {background:#c98e5d}
|
|
140987
|
-
.ew-bom-table th[data-drop]::before {content:'';position:absolute;inset:0 auto 0 0;width:3px}
|
|
140988
|
-
.ew-bom-table th[data-drop=after]::before {left:auto;right:0}
|
|
140989
|
-
.ew .ew-bom-table td {height:27px;font-variant-numeric:tabular-nums}
|
|
140990
|
-
.ew-bom-table tbody tr:nth-child(even) {background:color-mix(in srgb,currentColor 3%,transparent)}
|
|
140991
|
-
.ew-bom-table tbody tr:hover {background:color-mix(in srgb,currentColor 8%,transparent)}
|
|
140992
|
-
.ew .ew-bom-table tbody tr[data-selected=true] {background:color-mix(in srgb,#769f87 26%,var(--bom-surface));box-shadow:none}
|
|
140993
|
-
.ew-bom-table tr[data-selected=true] td:first-child {box-shadow:inset 3px 0 #c58c60}
|
|
140994
|
-
.ew-bom-table td:is([data-col=qty],[data-col=stock],[data-col=moq],[data-col=unit],[data-col=batch]) {text-align:end}
|
|
140995
|
-
.ew .ew-bom-table button.ew-bom-ref,.ew .ew-bom-table td select {display:block;width:100%;font:inherit;text-align:start;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border:0;border-radius:0;padding:2px 0;background:transparent}
|
|
140996
|
-
.ew .ew-bom-table td select option {background:var(--bom-surface);color:var(--bom-accent)}
|
|
140997
|
-
.ew-bom-ref:hover {text-decoration:underline}
|
|
140998
|
-
.ew-bom-empty {opacity:.45}
|
|
140999
|
-
.ew-bom-status::before {content:'';display:inline-block;vertical-align:1px;margin-right:5px;width:5px;height:5px;border-radius:50%;background:currentColor;opacity:.5}
|
|
141000
|
-
.ew-bom-status[data-state=已匹配]::before {background:#4da478;opacity:1}
|
|
141001
|
-
.ew-bom-status:is([data-state=待确认],[data-state=未报价],[data-state=查询失败])::before {background:#c48c48;opacity:1}
|
|
141002
|
-
|
|
141003
|
-
`;
|
|
141004
|
-
//#endregion
|
|
141005
|
-
//#region src/pages.ts
|
|
141006
|
-
const baseId = "@huaqiu/dsh-engineering-workbench";
|
|
141007
|
-
const baseKind = "huaqiu-engineering-workbench";
|
|
141008
|
-
const pages = {
|
|
141009
|
-
design: {
|
|
141010
|
-
title: "设计",
|
|
141011
|
-
id: baseId,
|
|
141012
|
-
kind: baseKind
|
|
141013
|
-
},
|
|
141014
|
-
review: {
|
|
141015
|
-
title: "评审",
|
|
141016
|
-
id: baseId + "/review",
|
|
141017
|
-
kind: baseKind + "-review"
|
|
141018
|
-
},
|
|
141019
|
-
manufacture: {
|
|
141020
|
-
title: "制造",
|
|
141021
|
-
id: baseId + "/manufacture",
|
|
141022
|
-
kind: baseKind + "-manufacture"
|
|
141023
|
-
}
|
|
141024
|
-
};
|
|
141025
|
-
const views = Object.keys(pages);
|
|
141026
|
-
//#endregion
|
|
141027
|
-
//#region src/Workbench.tsx
|
|
141028
|
-
const drawingNames = {
|
|
141029
|
-
pcb: "PCB",
|
|
141030
|
-
schematic: "原理图"
|
|
141031
|
-
};
|
|
141032
|
-
function Workbench(props) {
|
|
141033
|
-
const cwd = props.useSessions((s) => s.byId[props.sessionId]?.cwd);
|
|
141034
|
-
const nav = props.useTabInfo().tab.navigation;
|
|
141035
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Workspace, {
|
|
141036
|
-
cwd: cwd ?? "",
|
|
141037
|
-
session: props.sessionId,
|
|
141038
|
-
view: props.view,
|
|
141039
|
-
selection: props.selectionFor(props.sessionId),
|
|
141040
|
-
nav: nav.params,
|
|
141041
|
-
open: props.open,
|
|
141042
|
-
draft: props.draft
|
|
141043
|
-
}, props.sessionId + (cwd ?? ""));
|
|
141044
|
-
}
|
|
141045
|
-
function Workspace({ cwd, session, view, selection, nav, open, draft }) {
|
|
141046
|
-
const [data, setData] = (0, react.useState)();
|
|
141047
|
-
const [reload, setReload] = (0, react.useState)(0);
|
|
141048
|
-
const [error, setError] = (0, react.useState)("");
|
|
141049
|
-
const [projectPath, setProjectPath] = (0, react.useState)(selection.project ?? "");
|
|
141050
|
-
const [request, setRequest] = (0, react.useState)();
|
|
141051
|
-
const lastNav = (0, react.useRef)("");
|
|
141052
|
-
(0, react.useEffect)(() => {
|
|
141053
|
-
let live = true;
|
|
141054
|
-
setError("");
|
|
141055
|
-
loadProjects(cwd, void 0, session).then((result) => {
|
|
141056
|
-
if (live) setData(result);
|
|
141057
|
-
}).catch((e) => {
|
|
141058
|
-
if (live) {
|
|
141059
|
-
setData(void 0);
|
|
141060
|
-
setError(messageOf(e));
|
|
141061
|
-
}
|
|
141062
|
-
});
|
|
141063
|
-
return () => {
|
|
141064
|
-
live = false;
|
|
141065
|
-
};
|
|
141066
|
-
}, [
|
|
141067
|
-
cwd,
|
|
141068
|
-
session,
|
|
141069
|
-
reload
|
|
141070
|
-
]);
|
|
141071
|
-
const projects = data?.projects ?? [];
|
|
141072
|
-
const active = projects.find((p) => p.path === projectPath) ?? data?.selected ?? (projects.length === 1 ? projects[0] : void 0);
|
|
141073
|
-
(0, react.useEffect)(() => {
|
|
141074
|
-
if (!data || !nav || nav.view !== view || !validRequest(nav) || !nav.requestId || lastNav.current === nav.requestId) return;
|
|
141075
|
-
lastNav.current = nav.requestId;
|
|
141076
|
-
let candidates = data.projects ?? [];
|
|
141077
|
-
if (nav.project) candidates = candidates.filter((p) => matches(p.path, nav.project));
|
|
141078
|
-
if (nav.path) candidates = candidates.filter((p) => {
|
|
141079
|
-
const files = filesOf(p);
|
|
141080
|
-
return [...files.boards, ...files.sheets].some((f) => matches(f.path, nav.path));
|
|
141081
|
-
});
|
|
141082
|
-
if (nav.path || nav.project) {
|
|
141083
|
-
if (candidates.length !== 1) {
|
|
141084
|
-
setError(candidates.length ? "多个工程匹配,请指定完整路径。" : "当前工作区未找到指定文件或工程。");
|
|
141085
|
-
return;
|
|
141086
|
-
}
|
|
141087
|
-
setProjectPath(candidates[0].path);
|
|
141088
|
-
}
|
|
141089
|
-
setError("");
|
|
141090
|
-
setRequest(nav);
|
|
141091
|
-
}, [
|
|
141092
|
-
data,
|
|
141093
|
-
nav,
|
|
141094
|
-
view
|
|
141095
|
-
]);
|
|
141096
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
141097
|
-
className: "ew",
|
|
141098
|
-
"aria-label": pages[view].title,
|
|
141099
|
-
"data-view": view,
|
|
141100
|
-
children: [
|
|
141101
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: styles }),
|
|
141102
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
141103
|
-
className: "ew-head",
|
|
141104
|
-
children: [projects.length > 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
141105
|
-
"aria-label": "当前工程",
|
|
141106
|
-
value: active?.path ?? "",
|
|
141107
|
-
onChange: (e) => {
|
|
141108
|
-
if (active || !request?.designTool) setRequest(void 0);
|
|
141109
|
-
setError("");
|
|
141110
|
-
setProjectPath(e.target.value);
|
|
141111
|
-
Object.assign(selection, {
|
|
141112
|
-
project: e.target.value,
|
|
141113
|
-
board: void 0,
|
|
141114
|
-
sheet: void 0,
|
|
141115
|
-
reference: void 0,
|
|
141116
|
-
kind: void 0
|
|
141117
|
-
});
|
|
141118
|
-
},
|
|
141119
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
141120
|
-
value: "",
|
|
141121
|
-
disabled: true,
|
|
141122
|
-
children: "选择工程"
|
|
141123
|
-
}), projects.map((p) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("option", {
|
|
141124
|
-
value: p.path,
|
|
141125
|
-
children: [
|
|
141126
|
-
p.name,
|
|
141127
|
-
" · ",
|
|
141128
|
-
p.path
|
|
141129
|
-
]
|
|
141130
|
-
}, p.path))]
|
|
141131
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
141132
|
-
title: active?.path,
|
|
141133
|
-
children: active?.name ?? basename(cwd)
|
|
141134
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
141135
|
-
onClick: () => setReload((n) => n + 1),
|
|
141136
|
-
children: "刷新"
|
|
141137
|
-
})]
|
|
141138
|
-
}),
|
|
141139
|
-
error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
141140
|
-
role: "alert",
|
|
141141
|
-
children: error
|
|
141142
|
-
}),
|
|
141143
|
-
active ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Project, {
|
|
141144
|
-
view,
|
|
141145
|
-
selection,
|
|
141146
|
-
project: active,
|
|
141147
|
-
cwd: data?.cwd || cwd,
|
|
141148
|
-
session,
|
|
141149
|
-
request,
|
|
141150
|
-
open,
|
|
141151
|
-
draft
|
|
141152
|
-
}, active.path) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
141153
|
-
role: "status",
|
|
141154
|
-
children: !data && !error ? "正在查找 KiCad 工程…" : projects.length ? "请选择要查看的工程。" : "当前工作区没有可用的 KiCad 工程。"
|
|
141155
|
-
})
|
|
141156
|
-
]
|
|
141157
|
-
});
|
|
141158
|
-
}
|
|
141159
|
-
function Project({ project, cwd, session, view, selection, request, open, draft }) {
|
|
141160
|
-
const { boards, sheets } = filesOf(project);
|
|
141161
|
-
const seed = selection.project === project.path ? selection : {};
|
|
141162
|
-
const preferSchematic = view === "design" && sheets.length > 0 || boards.length === 0;
|
|
141163
|
-
const [kind, setKind] = (0, react.useState)(seed.kind ?? (preferSchematic ? "schematic" : "pcb"));
|
|
141164
|
-
const [mechanical, setMechanical] = (0, react.useState)(false);
|
|
141165
|
-
const [awaiting3d, setAwaiting3d] = (0, react.useState)(false);
|
|
141166
|
-
const [modelFile, setModelFile] = (0, react.useState)();
|
|
141167
|
-
const [manufacturingTab, setManufacturingTab] = (0, react.useState)("BOM");
|
|
141168
|
-
const showMechanical = view === "design" && mechanical;
|
|
141169
|
-
const [boardPath, setBoard] = (0, react.useState)(boards.find((f) => f.path === seed.board)?.path || project.defaultBoard || (boards.length === 1 ? boards[0].path : ""));
|
|
141170
|
-
const [sheetPath, setSheet] = (0, react.useState)(sheets.find((f) => f.path === seed.sheet)?.path || project.rootSheet?.path || project.schematic?.path || sheets[0]?.path || "");
|
|
141171
|
-
const [reference, setReference] = (0, react.useState)(seed.reference ?? "");
|
|
141172
|
-
const [parsedBoard, setParsedBoard] = (0, react.useState)();
|
|
141173
|
-
const [message, setMessage] = (0, react.useState)("");
|
|
141174
|
-
const [visited, setVisited] = (0, react.useState)({});
|
|
141175
|
-
const [closed, setClosed] = (0, react.useState)({
|
|
141176
|
-
pcb: false,
|
|
141177
|
-
schematic: false
|
|
141178
|
-
});
|
|
141179
|
-
const [records, setRecords] = (0, react.useState)([]);
|
|
141180
|
-
const seen = (0, react.useRef)("");
|
|
141181
|
-
const board = boards.find((f) => f.path === boardPath);
|
|
141182
|
-
const sheet = sheets.find((f) => f.path === sheetPath);
|
|
141183
|
-
const boardKey = boardPath + "@" + (board?.revision ?? "");
|
|
141184
|
-
const parts = parsedBoard?.key === boardKey ? parsedBoard.parts : [];
|
|
141185
|
-
const rememberParts = (0, react.useCallback)((parts) => setParsedBoard({
|
|
141186
|
-
key: boardKey,
|
|
141187
|
-
parts
|
|
141188
|
-
}), [boardKey]);
|
|
141189
|
-
(0, react.useEffect)(() => {
|
|
141190
|
-
if (!request?.requestId || seen.current === request.requestId) return;
|
|
141191
|
-
seen.current = request.requestId;
|
|
141192
|
-
const next = {
|
|
141193
|
-
project: project.path,
|
|
141194
|
-
board: boardPath,
|
|
141195
|
-
sheet: sheetPath,
|
|
141196
|
-
reference,
|
|
141197
|
-
kind
|
|
141198
|
-
};
|
|
141199
|
-
setAwaiting3d(false);
|
|
141200
|
-
if (request.path) {
|
|
141201
|
-
const targets = [...boards, ...sheets].filter((f) => matches(f.path, request.path));
|
|
141202
|
-
if (targets.length !== 1) {
|
|
141203
|
-
setMessage("文件路径不唯一或已移除,请手动选择。");
|
|
141204
|
-
return;
|
|
141205
|
-
}
|
|
141206
|
-
const target = targets[0];
|
|
141207
|
-
setMechanical(false);
|
|
141208
|
-
const targetKind = boards.includes(target) ? "pcb" : "schematic";
|
|
141209
|
-
setClosed((prev) => ({
|
|
141210
|
-
...prev,
|
|
141211
|
-
[targetKind]: false
|
|
141212
|
-
}));
|
|
141213
|
-
if (boards.includes(target)) {
|
|
141214
|
-
if (target.path !== boardPath) {
|
|
141215
|
-
setReference("");
|
|
141216
|
-
next.reference = "";
|
|
141217
|
-
}
|
|
141218
|
-
setBoard(target.path);
|
|
141219
|
-
setKind("pcb");
|
|
141220
|
-
next.board = target.path;
|
|
141221
|
-
next.kind = "pcb";
|
|
141222
|
-
} else {
|
|
141223
|
-
setSheet(target.path);
|
|
141224
|
-
setKind("schematic");
|
|
141225
|
-
next.sheet = target.path;
|
|
141226
|
-
next.kind = "schematic";
|
|
141794
|
+
colors[componentIdx + 2] = color.b;
|
|
141795
|
+
}
|
|
141796
|
+
}
|
|
141797
|
+
}
|
|
141798
|
+
geometry.setAttribute("position", new BufferAttribute(vertices, 3));
|
|
141799
|
+
geometry.setAttribute("normal", new BufferAttribute(normals, 3));
|
|
141800
|
+
if (hasColors) {
|
|
141801
|
+
geometry.setAttribute("color", new BufferAttribute(colors, 3));
|
|
141802
|
+
geometry.hasColors = true;
|
|
141803
|
+
geometry.alpha = alpha;
|
|
141227
141804
|
}
|
|
141805
|
+
return geometry;
|
|
141228
141806
|
}
|
|
141229
|
-
|
|
141230
|
-
|
|
141231
|
-
const
|
|
141232
|
-
|
|
141233
|
-
|
|
141234
|
-
|
|
141235
|
-
|
|
141236
|
-
|
|
141237
|
-
|
|
141238
|
-
|
|
141239
|
-
|
|
141240
|
-
|
|
141241
|
-
|
|
141242
|
-
|
|
141243
|
-
|
|
141244
|
-
|
|
141245
|
-
|
|
141246
|
-
|
|
141247
|
-
|
|
141248
|
-
|
|
141249
|
-
|
|
141807
|
+
function parseASCII(data) {
|
|
141808
|
+
const geometry = new BufferGeometry();
|
|
141809
|
+
const patternSolid = /solid([\s\S]*?)endsolid/g;
|
|
141810
|
+
const patternFace = /facet([\s\S]*?)endfacet/g;
|
|
141811
|
+
const patternName = /solid\s(.+)/;
|
|
141812
|
+
let faceCounter = 0;
|
|
141813
|
+
const patternFloat = /[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source;
|
|
141814
|
+
const patternVertex = new RegExp("vertex" + patternFloat + patternFloat + patternFloat, "g");
|
|
141815
|
+
const patternNormal = new RegExp("normal" + patternFloat + patternFloat + patternFloat, "g");
|
|
141816
|
+
const vertices = [];
|
|
141817
|
+
const normals = [];
|
|
141818
|
+
const groupNames = [];
|
|
141819
|
+
const normal = new Vector3();
|
|
141820
|
+
let result;
|
|
141821
|
+
let groupCount = 0;
|
|
141822
|
+
let startVertex = 0;
|
|
141823
|
+
let endVertex = 0;
|
|
141824
|
+
while ((result = patternSolid.exec(data)) !== null) {
|
|
141825
|
+
startVertex = endVertex;
|
|
141826
|
+
const solid = result[0];
|
|
141827
|
+
const name = (result = patternName.exec(solid)) !== null ? result[1] : "";
|
|
141828
|
+
groupNames.push(name);
|
|
141829
|
+
while ((result = patternFace.exec(solid)) !== null) {
|
|
141830
|
+
let vertexCountPerFace = 0;
|
|
141831
|
+
let normalCountPerFace = 0;
|
|
141832
|
+
const text = result[0];
|
|
141833
|
+
while ((result = patternNormal.exec(text)) !== null) {
|
|
141834
|
+
normal.x = parseFloat(result[1]);
|
|
141835
|
+
normal.y = parseFloat(result[2]);
|
|
141836
|
+
normal.z = parseFloat(result[3]);
|
|
141837
|
+
normalCountPerFace++;
|
|
141838
|
+
}
|
|
141839
|
+
while ((result = patternVertex.exec(text)) !== null) {
|
|
141840
|
+
vertices.push(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3]));
|
|
141841
|
+
normals.push(normal.x, normal.y, normal.z);
|
|
141842
|
+
vertexCountPerFace++;
|
|
141843
|
+
endVertex++;
|
|
141844
|
+
}
|
|
141845
|
+
if (normalCountPerFace !== 1) console.error("THREE.STLLoader: Something isn't right with the normal of face number " + faceCounter);
|
|
141846
|
+
if (vertexCountPerFace !== 3) console.error("THREE.STLLoader: Something isn't right with the vertices of face number " + faceCounter);
|
|
141847
|
+
faceCounter++;
|
|
141848
|
+
}
|
|
141849
|
+
const start = startVertex;
|
|
141850
|
+
const count = endVertex - startVertex;
|
|
141851
|
+
geometry.userData.groupNames = groupNames;
|
|
141852
|
+
geometry.addGroup(start, count, groupCount);
|
|
141853
|
+
groupCount++;
|
|
141250
141854
|
}
|
|
141855
|
+
geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
|
|
141856
|
+
geometry.setAttribute("normal", new Float32BufferAttribute(normals, 3));
|
|
141857
|
+
return geometry;
|
|
141251
141858
|
}
|
|
141252
|
-
|
|
141253
|
-
|
|
141254
|
-
|
|
141859
|
+
function ensureString(buffer) {
|
|
141860
|
+
if (typeof buffer !== "string") return new TextDecoder().decode(buffer);
|
|
141861
|
+
return buffer;
|
|
141255
141862
|
}
|
|
141256
|
-
|
|
141257
|
-
|
|
141258
|
-
|
|
141259
|
-
|
|
141260
|
-
|
|
141261
|
-
|
|
141262
|
-
const showPcb = !showMechanical && !!board && !closed.pcb && (view !== "design" || kind === "pcb") && (view !== "manufacture" || manufacturingTab === "BOM");
|
|
141263
|
-
const showSch = !showMechanical && !!sheet && !closed.schematic && (view === "review" || view === "design" && kind === "schematic");
|
|
141264
|
-
const hasPreview = showPcb || showSch;
|
|
141265
|
-
(0, react.useEffect)(() => {
|
|
141266
|
-
setVisited((prev) => ({
|
|
141267
|
-
...prev,
|
|
141268
|
-
pcb: prev.pcb || showPcb,
|
|
141269
|
-
schematic: prev.schematic || showSch
|
|
141270
|
-
}));
|
|
141271
|
-
}, [showPcb, showSch]);
|
|
141272
|
-
const selected = parts.find((p) => p.ref.toUpperCase() === reference.toUpperCase());
|
|
141273
|
-
const inspectPath = (kind === "pcb" ? board : sheet)?.path;
|
|
141274
|
-
const ask = () => {
|
|
141275
|
-
try {
|
|
141276
|
-
draft(session, "请结合当前工程回答:" + project.name + "\n文件:" + (view === "manufacture" ? sheetPath : inspectPath || project.path) + (reference ? "\n位号:" + reference : "") + "\n");
|
|
141277
|
-
setMessage("已加入左侧对话草稿。");
|
|
141278
|
-
} catch (e) {
|
|
141279
|
-
setMessage(messageOf(e));
|
|
141863
|
+
function ensureBinary(buffer) {
|
|
141864
|
+
if (typeof buffer === "string") {
|
|
141865
|
+
const array_buffer = new Uint8Array(buffer.length);
|
|
141866
|
+
for (let i = 0; i < buffer.length; i++) array_buffer[i] = buffer.charCodeAt(i) & 255;
|
|
141867
|
+
return array_buffer.buffer || array_buffer;
|
|
141868
|
+
} else return buffer;
|
|
141280
141869
|
}
|
|
141281
|
-
|
|
141282
|
-
|
|
141283
|
-
if (inspectPath) openArtifact({
|
|
141284
|
-
application: "kicad",
|
|
141285
|
-
artifactPath: inspectPath,
|
|
141286
|
-
projectPath: project.path,
|
|
141287
|
-
kind,
|
|
141288
|
-
session
|
|
141289
|
-
}).catch((e) => setMessage(messageOf(e)));
|
|
141290
|
-
}
|
|
141291
|
-
function remember(updates) {
|
|
141292
|
-
Object.assign(selection, {
|
|
141293
|
-
project: project.path,
|
|
141294
|
-
board: boardPath,
|
|
141295
|
-
sheet: sheetPath,
|
|
141296
|
-
kind,
|
|
141297
|
-
reference
|
|
141298
|
-
}, updates);
|
|
141299
|
-
}
|
|
141300
|
-
function chooseReference(value) {
|
|
141301
|
-
setReference(value);
|
|
141302
|
-
remember({ reference: value });
|
|
141870
|
+
const binData = ensureBinary(data);
|
|
141871
|
+
return isBinary(binData) ? parseBinary(binData) : parseASCII(ensureString(data));
|
|
141303
141872
|
}
|
|
141304
|
-
|
|
141305
|
-
|
|
141306
|
-
|
|
141307
|
-
|
|
141308
|
-
|
|
141309
|
-
|
|
141310
|
-
|
|
141311
|
-
|
|
141312
|
-
|
|
141873
|
+
};
|
|
141874
|
+
//#endregion
|
|
141875
|
+
//#region ../dsh-hardware-ui/src/client/mesh-file.ts
|
|
141876
|
+
function parseMeshFile(name, bytes) {
|
|
141877
|
+
if (/\.obj$/i.test(name)) return new OBJLoader().parse(new TextDecoder().decode(bytes));
|
|
141878
|
+
if (!/\.stl$/i.test(name)) throw new Error("请选择 STL 或 OBJ 文件。");
|
|
141879
|
+
const header = new TextDecoder("ascii").decode(bytes.slice(0, 9));
|
|
141880
|
+
const binary = bytes.byteLength >= 84 && 84 + new DataView(bytes).getUint32(80, true) * 50 === bytes.byteLength;
|
|
141881
|
+
if (bytes.byteLength < 84 || !binary && !header.includes("solid")) throw new Error("STL 文件不完整或格式无效。");
|
|
141882
|
+
const geometry = new STLLoader().parse(bytes);
|
|
141883
|
+
if (!geometry.getAttribute("normal") || !binary) geometry.computeVertexNormals();
|
|
141884
|
+
return new Mesh(geometry, new MeshStandardMaterial({
|
|
141885
|
+
side: 2,
|
|
141886
|
+
vertexColors: geometry.hasAttribute("color")
|
|
141887
|
+
}));
|
|
141888
|
+
}
|
|
141889
|
+
//#endregion
|
|
141890
|
+
//#region src/Mechanical.tsx
|
|
141891
|
+
const supported = (name) => /\.(stl|obj)$/i.test(name);
|
|
141892
|
+
const sortModels = (models) => models.sort((a, b) => a.name.localeCompare(b.name, void 0, { numeric: true }));
|
|
141893
|
+
async function scan(files, session, folder, signal) {
|
|
141894
|
+
const groups = /* @__PURE__ */ new Map();
|
|
141895
|
+
const named = /* @__PURE__ */ new Set();
|
|
141896
|
+
const pending = [{
|
|
141897
|
+
path: folder ?? ".",
|
|
141898
|
+
prefix: "",
|
|
141899
|
+
group: folder
|
|
141900
|
+
}];
|
|
141901
|
+
let incomplete = false;
|
|
141902
|
+
while (pending.length) {
|
|
141903
|
+
signal.throwIfAborted();
|
|
141904
|
+
await Promise.all(pending.splice(-4).map(async ({ path, prefix, group }) => {
|
|
141905
|
+
const result = await files.list(session, path, signal);
|
|
141906
|
+
if (!result.ok) {
|
|
141907
|
+
if (path !== (folder ?? ".")) {
|
|
141908
|
+
incomplete = true;
|
|
141909
|
+
return;
|
|
141910
|
+
}
|
|
141911
|
+
throw new Error(result.error.code === "workspace-file/not-found" ? "找不到该文件夹,请切换目录。" : result.error.message || "无法读取文件夹。");
|
|
141912
|
+
}
|
|
141913
|
+
incomplete ||= result.value.truncated;
|
|
141914
|
+
for (const entry of result.value.entries) {
|
|
141915
|
+
const child = path === "." ? entry.name : path.replace(/[/\\]+$/, "") + "/" + entry.name;
|
|
141916
|
+
if (entry.type === "directory") {
|
|
141917
|
+
if (!folder && [".git", "node_modules"].includes(entry.name)) continue;
|
|
141918
|
+
const startsGroup = !group && /^(mechanical|mechnical)$/i.test(entry.name);
|
|
141919
|
+
if (startsGroup) named.add(child);
|
|
141920
|
+
pending.push({
|
|
141921
|
+
path: child,
|
|
141922
|
+
prefix: startsGroup ? "" : prefix + entry.name + "/",
|
|
141923
|
+
group: startsGroup ? child : group
|
|
141924
|
+
});
|
|
141925
|
+
} else if (entry.type === "file" && supported(entry.name)) {
|
|
141926
|
+
const key = group ?? path;
|
|
141927
|
+
const models = groups.get(key) ?? [];
|
|
141928
|
+
models.push({
|
|
141929
|
+
name: group ? prefix + entry.name : entry.name,
|
|
141930
|
+
path: child,
|
|
141931
|
+
size: entry.size
|
|
141932
|
+
});
|
|
141933
|
+
groups.set(key, models);
|
|
141934
|
+
}
|
|
141935
|
+
}
|
|
141313
141936
|
}));
|
|
141314
141937
|
}
|
|
141315
|
-
const
|
|
141316
|
-
|
|
141317
|
-
|
|
141318
|
-
|
|
141319
|
-
|
|
141320
|
-
|
|
141321
|
-
|
|
141322
|
-
|
|
141323
|
-
} else setSheet(path);
|
|
141324
|
-
setKind(type);
|
|
141325
|
-
setMessage("");
|
|
141326
|
-
remember(type === "pcb" ? {
|
|
141327
|
-
board: path,
|
|
141328
|
-
reference: "",
|
|
141329
|
-
kind: type
|
|
141330
|
-
} : {
|
|
141331
|
-
sheet: path,
|
|
141332
|
-
kind: type
|
|
141333
|
-
});
|
|
141334
|
-
if (type === "pcb" && awaiting3d) {
|
|
141335
|
-
setAwaiting3d(false);
|
|
141336
|
-
open(session, "hardware-engineering", {
|
|
141337
|
-
destination: "3d",
|
|
141338
|
-
path,
|
|
141339
|
-
projectPath: project.path
|
|
141340
|
-
});
|
|
141341
|
-
}
|
|
141938
|
+
const priority = (dir) => named.has(dir) ? 0 : groups.get(dir)?.some((m) => /\.stl$/i.test(m.name)) ? 1 : 2;
|
|
141939
|
+
const folders = Array.from(/* @__PURE__ */ new Set([...groups.keys(), ...named])).sort((a, b) => Number(!groups.has(a)) - Number(!groups.has(b)) || priority(a) - priority(b) || a.split("/").length - b.split("/").length || a.localeCompare(b, void 0, { numeric: true }));
|
|
141940
|
+
const resolved = folder ?? folders[0];
|
|
141941
|
+
return {
|
|
141942
|
+
folder: resolved,
|
|
141943
|
+
folders,
|
|
141944
|
+
models: sortModels(groups.get(resolved ?? "") ?? []),
|
|
141945
|
+
notice: incomplete ? "部分目录未能完整列出,可直接切换到对应子目录。" : void 0
|
|
141342
141946
|
};
|
|
141343
|
-
|
|
141344
|
-
|
|
141345
|
-
|
|
141346
|
-
|
|
141947
|
+
}
|
|
141948
|
+
function ModelPreview({ model, files, session }) {
|
|
141949
|
+
const host = (0, react.useRef)(null);
|
|
141950
|
+
const [status, setStatus] = (0, react.useState)("正在读取模型…");
|
|
141951
|
+
(0, react.useEffect)(() => {
|
|
141952
|
+
const controller = new AbortController();
|
|
141953
|
+
const { signal } = controller;
|
|
141954
|
+
let preview;
|
|
141955
|
+
async function load() {
|
|
141956
|
+
if ((model.size ?? 0) > 33554432) throw new Error("模型超过 32 MiB。");
|
|
141957
|
+
let buffer;
|
|
141958
|
+
if (model.file) buffer = await model.file.arrayBuffer();
|
|
141959
|
+
else {
|
|
141960
|
+
if (!files) throw new Error("当前会话无法读取模型。");
|
|
141961
|
+
const result = await files.readBytes(session, model.path, {}, signal);
|
|
141962
|
+
if (!result.ok) throw new Error(result.error.message || "无法读取文件。");
|
|
141963
|
+
const { data, eof } = result.value;
|
|
141964
|
+
if (!eof || data.byteLength > 33554432) throw new Error("模型超过预览上限或文件不完整。");
|
|
141965
|
+
buffer = data.slice().buffer;
|
|
141966
|
+
}
|
|
141967
|
+
signal.throwIfAborted();
|
|
141968
|
+
preview = mountModel(parseMeshFile(model.name, buffer), host.current, { signal });
|
|
141969
|
+
setStatus("");
|
|
141347
141970
|
}
|
|
141348
|
-
|
|
141349
|
-
|
|
141350
|
-
|
|
141351
|
-
projectPath: project.path,
|
|
141352
|
-
schematicPath: project.rootSheet?.path || project.schematic?.path
|
|
141971
|
+
setStatus("正在读取模型…");
|
|
141972
|
+
load().catch((e) => {
|
|
141973
|
+
if (!signal.aborted) setStatus("无法预览模型。" + String(e.message || e));
|
|
141353
141974
|
});
|
|
141354
|
-
|
|
141355
|
-
|
|
141356
|
-
|
|
141357
|
-
|
|
141358
|
-
|
|
141359
|
-
|
|
141360
|
-
|
|
141361
|
-
|
|
141362
|
-
|
|
141363
|
-
|
|
141364
|
-
|
|
141365
|
-
|
|
141366
|
-
|
|
141367
|
-
|
|
141368
|
-
|
|
141369
|
-
|
|
141370
|
-
}),
|
|
141371
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
141372
|
-
"aria-pressed": !mechanical && kind === "pcb",
|
|
141373
|
-
onClick: () => chooseKind("pcb"),
|
|
141374
|
-
children: "PCB"
|
|
141375
|
-
}),
|
|
141376
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
141377
|
-
disabled: !board,
|
|
141378
|
-
onClick: () => open(session, "hardware-engineering", {
|
|
141379
|
-
destination: "3d",
|
|
141380
|
-
path: boardPath,
|
|
141381
|
-
projectPath: project.path
|
|
141382
|
-
}),
|
|
141383
|
-
children: "板级 3D ↗"
|
|
141384
|
-
}),
|
|
141385
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
141386
|
-
"aria-pressed": mechanical,
|
|
141387
|
-
onClick: () => {
|
|
141388
|
-
setAwaiting3d(false);
|
|
141389
|
-
setMessage("");
|
|
141390
|
-
setMechanical(true);
|
|
141391
|
-
},
|
|
141392
|
-
children: "结构件"
|
|
141393
|
-
}),
|
|
141394
|
-
!mechanical && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
141395
|
-
disabled: !inspectPath,
|
|
141396
|
-
onClick: nativeOpen,
|
|
141397
|
-
children: "在 KiCad 中打开 ↗"
|
|
141398
|
-
})
|
|
141399
|
-
]
|
|
141400
|
-
}),
|
|
141401
|
-
showMechanical && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Mechanical, {
|
|
141402
|
-
file: modelFile,
|
|
141403
|
-
onFile: setModelFile
|
|
141404
|
-
}),
|
|
141405
|
-
view === "manufacture" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
|
|
141406
|
-
className: "ew-tools",
|
|
141407
|
-
"aria-label": "制造文件",
|
|
141408
|
-
children: manufacturingTabs.map((tab) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
141409
|
-
"aria-pressed": tab === manufacturingTab,
|
|
141410
|
-
onClick: () => setManufacturingTab(tab),
|
|
141411
|
-
children: tab
|
|
141412
|
-
}, tab))
|
|
141413
|
-
}),
|
|
141414
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
141415
|
-
className: "ew-files",
|
|
141416
|
-
hidden: showMechanical,
|
|
141417
|
-
children: ["schematic", "pcb"].filter((type) => (view !== "design" || kind === type) && (view !== "manufacture" || manufacturingTab === "BOM" || type === "pcb")).map((type) => {
|
|
141418
|
-
const files = type === "pcb" ? boards : sheets;
|
|
141419
|
-
const file = type === "pcb" ? board : sheet;
|
|
141420
|
-
const action = closed[type] ? "打开" : "关闭";
|
|
141421
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
141422
|
-
className: "ew-file-control",
|
|
141423
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [
|
|
141424
|
-
type === "pcb" ? "板文件" : "原理图",
|
|
141425
|
-
" ",
|
|
141426
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
141427
|
-
value: file?.path || "",
|
|
141428
|
-
onChange: (e) => selectFile(type, e.target.value),
|
|
141429
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
141430
|
-
value: "",
|
|
141431
|
-
disabled: true,
|
|
141432
|
-
children: "选择文件"
|
|
141433
|
-
}), files.map((f) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
141434
|
-
value: f.path,
|
|
141435
|
-
children: basename(f.path)
|
|
141436
|
-
}, f.path))]
|
|
141437
|
-
})
|
|
141438
|
-
] }), file && (view !== "manufacture" || type === "pcb" && manufacturingTab === "BOM") && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
141439
|
-
type: "button",
|
|
141440
|
-
className: "ew-preview-toggle",
|
|
141441
|
-
"aria-label": action + drawingNames[type] + "预览",
|
|
141442
|
-
title: action + drawingNames[type] + "预览",
|
|
141443
|
-
onClick: () => setClosed((prev) => ({
|
|
141444
|
-
...prev,
|
|
141445
|
-
[type]: !prev[type]
|
|
141446
|
-
})),
|
|
141447
|
-
children: [action, "预览"]
|
|
141448
|
-
})]
|
|
141449
|
-
}, type);
|
|
141450
|
-
})
|
|
141451
|
-
}),
|
|
141452
|
-
message && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
141975
|
+
return () => {
|
|
141976
|
+
controller.abort();
|
|
141977
|
+
preview?.dispose();
|
|
141978
|
+
};
|
|
141979
|
+
}, [
|
|
141980
|
+
model,
|
|
141981
|
+
files,
|
|
141982
|
+
session
|
|
141983
|
+
]);
|
|
141984
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
141985
|
+
className: "ew-stage",
|
|
141986
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
141987
|
+
className: "ew-surface",
|
|
141988
|
+
ref: host
|
|
141989
|
+
}), status && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
141990
|
+
className: "ew-message",
|
|
141453
141991
|
role: "status",
|
|
141454
|
-
children:
|
|
141455
|
-
})
|
|
141456
|
-
|
|
141457
|
-
|
|
141458
|
-
|
|
141459
|
-
|
|
141460
|
-
|
|
141461
|
-
|
|
141462
|
-
|
|
141463
|
-
|
|
141464
|
-
|
|
141465
|
-
|
|
141466
|
-
|
|
141467
|
-
|
|
141468
|
-
|
|
141469
|
-
|
|
141470
|
-
|
|
141471
|
-
|
|
141472
|
-
|
|
141473
|
-
|
|
141474
|
-
|
|
141475
|
-
|
|
141476
|
-
|
|
141477
|
-
|
|
141478
|
-
|
|
141479
|
-
|
|
141480
|
-
|
|
141481
|
-
|
|
141482
|
-
|
|
141483
|
-
|
|
141484
|
-
})
|
|
141485
|
-
|
|
141486
|
-
|
|
141487
|
-
|
|
141488
|
-
|
|
141489
|
-
|
|
141490
|
-
|
|
141491
|
-
|
|
141492
|
-
|
|
141493
|
-
|
|
141494
|
-
|
|
141495
|
-
|
|
141496
|
-
|
|
141497
|
-
|
|
141498
|
-
|
|
141499
|
-
|
|
141500
|
-
|
|
141501
|
-
|
|
141992
|
+
children: status
|
|
141993
|
+
})]
|
|
141994
|
+
});
|
|
141995
|
+
}
|
|
141996
|
+
function Mechanical({ files, sessionId }) {
|
|
141997
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelBrowser, {
|
|
141998
|
+
files,
|
|
141999
|
+
session: sessionId
|
|
142000
|
+
}, sessionId);
|
|
142001
|
+
}
|
|
142002
|
+
function ModelBrowser({ files, session }) {
|
|
142003
|
+
const [source, setSource] = (0, react.useState)({});
|
|
142004
|
+
const [draft, setDraft] = (0, react.useState)();
|
|
142005
|
+
const [folders, setFolders] = (0, react.useState)([]);
|
|
142006
|
+
const [loaded, setLoaded] = (0, react.useState)();
|
|
142007
|
+
const [selected, setSelected] = (0, react.useState)("");
|
|
142008
|
+
const picker = (0, react.useRef)(null);
|
|
142009
|
+
const catalog = source.local ?? (loaded?.source === source ? loaded.catalog : void 0);
|
|
142010
|
+
const input = draft ?? source.folder ?? catalog?.folder ?? "";
|
|
142011
|
+
const currentFolder = source.folder ?? catalog?.folder ?? "";
|
|
142012
|
+
const model = catalog?.models.find((item) => item.name === selected) ?? catalog?.models[0];
|
|
142013
|
+
(0, react.useEffect)(() => {
|
|
142014
|
+
if (source.local) return;
|
|
142015
|
+
const controller = new AbortController();
|
|
142016
|
+
(files ? scan(files, session, source.folder, controller.signal) : Promise.reject(/* @__PURE__ */ new Error("工作区目录不可用,请使用「浏览文件夹」。"))).then((catalog) => {
|
|
142017
|
+
if (!controller.signal.aborted) {
|
|
142018
|
+
if (!source.folder) setFolders(catalog.folders ?? []);
|
|
142019
|
+
setLoaded({
|
|
142020
|
+
source,
|
|
142021
|
+
catalog
|
|
142022
|
+
});
|
|
142023
|
+
}
|
|
142024
|
+
}).catch((e) => {
|
|
142025
|
+
if (!controller.signal.aborted) setLoaded({
|
|
142026
|
+
source,
|
|
142027
|
+
catalog: {
|
|
142028
|
+
models: [],
|
|
142029
|
+
notice: String(e.message || e)
|
|
142030
|
+
}
|
|
142031
|
+
});
|
|
142032
|
+
});
|
|
142033
|
+
return () => controller.abort();
|
|
142034
|
+
}, [
|
|
142035
|
+
source,
|
|
142036
|
+
files,
|
|
142037
|
+
session
|
|
142038
|
+
]);
|
|
142039
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
142040
|
+
className: "ew",
|
|
142041
|
+
"aria-label": "结构设计",
|
|
142042
|
+
"data-view": "mechanical",
|
|
142043
|
+
children: [
|
|
142044
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: styles }),
|
|
142045
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
|
|
142046
|
+
className: "ew-files ew-model-folder",
|
|
142047
|
+
onSubmit: (e) => {
|
|
142048
|
+
e.preventDefault();
|
|
142049
|
+
if (input.trim()) setSource({ folder: input.trim() });
|
|
142050
|
+
},
|
|
141502
142051
|
children: [
|
|
141503
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
141504
|
-
|
|
141505
|
-
|
|
141506
|
-
|
|
141507
|
-
"
|
|
141508
|
-
|
|
141509
|
-
|
|
141510
|
-
|
|
141511
|
-
|
|
141512
|
-
|
|
141513
|
-
|
|
141514
|
-
|
|
141515
|
-
|
|
141516
|
-
|
|
141517
|
-
|
|
141518
|
-
|
|
141519
|
-
|
|
141520
|
-
|
|
141521
|
-
|
|
141522
|
-
|
|
141523
|
-
|
|
141524
|
-
|
|
141525
|
-
|
|
141526
|
-
|
|
141527
|
-
|
|
141528
|
-
|
|
141529
|
-
selected.location && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: selected.location }),
|
|
141530
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", { children: [
|
|
141531
|
-
"焊盘与网络(",
|
|
141532
|
-
selected.pins.length,
|
|
141533
|
-
")"
|
|
141534
|
-
] }), selected.pins.map((p, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
141535
|
-
p.number,
|
|
141536
|
-
" ",
|
|
141537
|
-
p.net
|
|
141538
|
-
] }, i))] })
|
|
141539
|
-
]
|
|
142052
|
+
folders.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: ["已定位目录 ", /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
142053
|
+
value: !source.local && folders.includes(currentFolder) ? currentFolder : "",
|
|
142054
|
+
onChange: (e) => {
|
|
142055
|
+
setDraft(void 0);
|
|
142056
|
+
setSelected("");
|
|
142057
|
+
setSource({ folder: e.target.value });
|
|
142058
|
+
},
|
|
142059
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
142060
|
+
value: "",
|
|
142061
|
+
disabled: true,
|
|
142062
|
+
children: "选择目录"
|
|
142063
|
+
}), folders.map((dir) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
142064
|
+
value: dir,
|
|
142065
|
+
children: dir
|
|
142066
|
+
}, dir))]
|
|
142067
|
+
})] }),
|
|
142068
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: ["文件夹 ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
142069
|
+
value: input,
|
|
142070
|
+
title: input,
|
|
142071
|
+
onChange: (e) => setDraft(e.target.value),
|
|
142072
|
+
placeholder: "工作区模型目录"
|
|
142073
|
+
})] }),
|
|
142074
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
142075
|
+
type: "submit",
|
|
142076
|
+
disabled: !input.trim(),
|
|
142077
|
+
children: "打开目录"
|
|
141540
142078
|
}),
|
|
141541
|
-
|
|
141542
|
-
|
|
141543
|
-
|
|
141544
|
-
|
|
141545
|
-
|
|
141546
|
-
|
|
141547
|
-
|
|
141548
|
-
|
|
141549
|
-
|
|
141550
|
-
|
|
141551
|
-
|
|
141552
|
-
|
|
142079
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
142080
|
+
type: "button",
|
|
142081
|
+
onClick: () => {
|
|
142082
|
+
setSource({});
|
|
142083
|
+
setSelected("");
|
|
142084
|
+
setDraft(void 0);
|
|
142085
|
+
},
|
|
142086
|
+
children: "自动定位"
|
|
142087
|
+
}),
|
|
142088
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
142089
|
+
type: "button",
|
|
142090
|
+
onClick: () => picker.current?.click(),
|
|
142091
|
+
children: "浏览文件夹"
|
|
142092
|
+
}),
|
|
142093
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
142094
|
+
type: "file",
|
|
142095
|
+
hidden: true,
|
|
142096
|
+
multiple: true,
|
|
142097
|
+
ref: (el) => {
|
|
142098
|
+
picker.current = el;
|
|
142099
|
+
el?.setAttribute("webkitdirectory", "");
|
|
142100
|
+
},
|
|
142101
|
+
"aria-label": "选择本机文件夹",
|
|
142102
|
+
onChange: (e) => {
|
|
142103
|
+
const entries = Array.from(e.target.files ?? []);
|
|
142104
|
+
e.target.value = "";
|
|
142105
|
+
if (!entries.length) return;
|
|
142106
|
+
const folder = entries[0].webkitRelativePath.split("/")[0];
|
|
142107
|
+
const models = entries.filter((f) => supported(f.name)).map((file) => ({
|
|
142108
|
+
file,
|
|
142109
|
+
path: file.webkitRelativePath,
|
|
142110
|
+
name: file.webkitRelativePath.slice(folder.length + 1),
|
|
142111
|
+
size: file.size
|
|
142112
|
+
}));
|
|
142113
|
+
setDraft(void 0);
|
|
142114
|
+
setSource({
|
|
142115
|
+
folder,
|
|
142116
|
+
local: { models: sortModels(models) }
|
|
142117
|
+
});
|
|
142118
|
+
setSelected("");
|
|
142119
|
+
}
|
|
142120
|
+
})
|
|
141553
142121
|
]
|
|
141554
|
-
})
|
|
141555
|
-
|
|
141556
|
-
|
|
141557
|
-
|
|
141558
|
-
|
|
141559
|
-
|
|
141560
|
-
|
|
141561
|
-
|
|
141562
|
-
|
|
141563
|
-
|
|
141564
|
-
|
|
141565
|
-
|
|
141566
|
-
|
|
141567
|
-
|
|
141568
|
-
|
|
141569
|
-
|
|
141570
|
-
|
|
141571
|
-
|
|
141572
|
-
|
|
141573
|
-
|
|
141574
|
-
|
|
142122
|
+
}),
|
|
142123
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
142124
|
+
className: "ew-files",
|
|
142125
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: ["结构件 ", /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
142126
|
+
value: model?.name ?? "",
|
|
142127
|
+
disabled: !model,
|
|
142128
|
+
onChange: (e) => setSelected(e.target.value),
|
|
142129
|
+
children: [!model && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
142130
|
+
value: "",
|
|
142131
|
+
children: "选择模型"
|
|
142132
|
+
}), catalog?.models.map((m) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
142133
|
+
value: m.name,
|
|
142134
|
+
children: m.name
|
|
142135
|
+
}, m.name))]
|
|
142136
|
+
})] }), model && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "拖动旋转,滚轮缩放" })]
|
|
142137
|
+
}),
|
|
142138
|
+
catalog?.notice && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
142139
|
+
role: "status",
|
|
142140
|
+
children: catalog.notice
|
|
142141
|
+
}),
|
|
142142
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
142143
|
+
className: "ew-pane ew-model",
|
|
142144
|
+
"aria-label": "结构件预览",
|
|
142145
|
+
children: model ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelPreview, {
|
|
142146
|
+
model,
|
|
142147
|
+
files,
|
|
142148
|
+
session
|
|
142149
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
142150
|
+
className: "ew-stage",
|
|
142151
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
142152
|
+
className: "ew-message",
|
|
142153
|
+
role: "status",
|
|
142154
|
+
children: !catalog ? "正在查找结构件…" : catalog.notice ? "请选择其他模型目录。" : source.folder ? "此文件夹及其子目录中没有 STL 或 OBJ 模型。" : "当前工作区中没有找到 STL 或 OBJ 模型。"
|
|
142155
|
+
})
|
|
142156
|
+
})
|
|
142157
|
+
})
|
|
142158
|
+
]
|
|
141575
142159
|
});
|
|
141576
|
-
const update = () => {
|
|
141577
|
-
const disabled = mounted.getSnapshot() === void 0;
|
|
141578
|
-
for (const button of buttons) {
|
|
141579
|
-
button.disabled = disabled;
|
|
141580
|
-
button.title = disabled ? "请先打开会话" : "打开" + button.textContent + "页面";
|
|
141581
|
-
}
|
|
141582
|
-
};
|
|
141583
|
-
const move = (event) => {
|
|
141584
|
-
if (event.key !== "ArrowRight" && event.key !== "ArrowLeft") return;
|
|
141585
|
-
const items = Array.from(bar.querySelectorAll("button[role=menuitem]:enabled"));
|
|
141586
|
-
const index = items.indexOf(event.target);
|
|
141587
|
-
if (index < 0) return;
|
|
141588
|
-
const next = items[(index + (event.key === "ArrowRight" ? 1 : -1) + items.length) % items.length];
|
|
141589
|
-
if (!buttons.includes(items[index]) && !buttons.includes(next)) return;
|
|
141590
|
-
event.preventDefault();
|
|
141591
|
-
event.stopPropagation();
|
|
141592
|
-
for (const item of items) item.tabIndex = item === next ? 0 : -1;
|
|
141593
|
-
next.focus();
|
|
141594
|
-
};
|
|
141595
|
-
const detach = () => {
|
|
141596
|
-
bar?.removeEventListener("keydown", move, true);
|
|
141597
|
-
if (bar && buttons.some((b) => b.tabIndex === 0)) {
|
|
141598
|
-
const first = bar.querySelector("button[aria-haspopup=menu]");
|
|
141599
|
-
if (first) first.tabIndex = 0;
|
|
141600
|
-
}
|
|
141601
|
-
for (const button of buttons) {
|
|
141602
|
-
button.remove();
|
|
141603
|
-
button.tabIndex = -1;
|
|
141604
|
-
}
|
|
141605
|
-
bar = void 0;
|
|
141606
|
-
};
|
|
141607
|
-
const mount = () => {
|
|
141608
|
-
const next = (document.querySelector("[data-windows-menu]")?.shadowRoot)?.querySelector("[role=menubar]");
|
|
141609
|
-
if (next === bar) return;
|
|
141610
|
-
detach();
|
|
141611
|
-
const anchor = next?.querySelector("button[data-place-order]");
|
|
141612
|
-
if (!next || !anchor) return;
|
|
141613
|
-
bar = next;
|
|
141614
|
-
for (const button of buttons) next.insertBefore(button, anchor);
|
|
141615
|
-
next.addEventListener("keydown", move, true);
|
|
141616
|
-
update();
|
|
141617
|
-
};
|
|
141618
|
-
const observer = new MutationObserver(mount);
|
|
141619
|
-
observer.observe(document.body, { childList: true });
|
|
141620
|
-
const unsubscribe = mounted.subscribe(update);
|
|
141621
|
-
mount();
|
|
141622
|
-
return () => {
|
|
141623
|
-
observer.disconnect();
|
|
141624
|
-
unsubscribe();
|
|
141625
|
-
detach();
|
|
141626
|
-
};
|
|
141627
142160
|
}
|
|
141628
142161
|
//#endregion
|
|
141629
142162
|
//#region src/ToolRail.tsx
|
|
@@ -141725,7 +142258,9 @@ void main() {
|
|
|
141725
142258
|
"sidebarRight",
|
|
141726
142259
|
"sidebarRightTabs",
|
|
141727
142260
|
"sessions",
|
|
141728
|
-
"conversation"
|
|
142261
|
+
"conversation",
|
|
142262
|
+
"remote",
|
|
142263
|
+
"remote.workspaceFiles"
|
|
141729
142264
|
];
|
|
141730
142265
|
const EMPTY = [];
|
|
141731
142266
|
function ConversationNavigation({ sessionId, useChat, useSession, open }) {
|
|
@@ -141801,7 +142336,7 @@ void main() {
|
|
|
141801
142336
|
}
|
|
141802
142337
|
function activateTool(session, tool) {
|
|
141803
142338
|
const selected = selectionFor(session);
|
|
141804
|
-
const view = tool === "review" || tool === "manufacture" ? tool : "design";
|
|
142339
|
+
const view = tool === "review" || tool === "manufacture" || tool === "mechanical" ? tool : "design";
|
|
141805
142340
|
const path = tool === "schematic" ? selected.sheet : tool === "mechanical" ? void 0 : selected.board;
|
|
141806
142341
|
open(session, pages[view].kind, {
|
|
141807
142342
|
view,
|
|
@@ -141840,13 +142375,13 @@ void main() {
|
|
|
141840
142375
|
ctx.effect(() => ctx.slots.inject("sidebar.right.pane.tab", () => ctx.slots.register({
|
|
141841
142376
|
name: "sidebar.right.pane.tab",
|
|
141842
142377
|
key: id,
|
|
141843
|
-
inject: () =>
|
|
142378
|
+
inject: () => view === "mechanical" ? { files: ctx.remote?.workspaceFiles } : {
|
|
141844
142379
|
open,
|
|
141845
142380
|
draft,
|
|
141846
142381
|
view,
|
|
141847
142382
|
selectionFor
|
|
141848
|
-
}
|
|
141849
|
-
}, Workbench)), "engineering page: " + view);
|
|
142383
|
+
}
|
|
142384
|
+
}, view === "mechanical" ? Mechanical : Workbench)), "engineering page: " + view);
|
|
141850
142385
|
}
|
|
141851
142386
|
ctx.effect(() => installCaptionMenu(ctx.sidebarRight.mounted, (session, view) => {
|
|
141852
142387
|
open(session, pages[view].kind);
|