@huaqiu/dsh-hardware-ui 0.7.13 → 0.7.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +2791 -699
- package/lib/client.js.map +1 -1
- package/package.json +3 -3
- package/src/client/components.tsx +460 -186
- package/src/client/ecad.ts +33 -5
- package/src/client/index.ts +49 -71
- package/src/client/model.ts +37 -12
- package/src/client/order.tsx +451 -0
- package/src/client/preview.tsx +257 -110
- package/src/client/store.ts +41 -8
- package/src/client/theme.ts +158 -0
- package/src/client/transport.ts +152 -12
- package/src/client/wizard.tsx +326 -0
package/lib/client.js
CHANGED
|
@@ -25,94 +25,94 @@ window.__ModuleLoader__.load({
|
|
|
25
25
|
if (destination === "schematic" || destination === "pcb" || destination === "bom" || destination === "3d") return "kicad";
|
|
26
26
|
}
|
|
27
27
|
//#endregion
|
|
28
|
-
//#region ../../node_modules/.pnpm/@huaqiu+kicad-sexpr-parser@0.1.
|
|
29
|
-
var __defProp$
|
|
28
|
+
//#region ../../node_modules/.pnpm/@huaqiu+kicad-sexpr-parser@0.1.2/node_modules/@huaqiu/kicad-sexpr-parser/dist/index.mjs
|
|
29
|
+
var __defProp$2 = Object.defineProperty;
|
|
30
30
|
var __defProps = Object.defineProperties;
|
|
31
31
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
32
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
33
|
-
var __hasOwnProp$
|
|
34
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
35
|
-
var __typeError = (msg) => {
|
|
32
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
33
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
34
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
35
|
+
var __typeError$1 = (msg) => {
|
|
36
36
|
throw TypeError(msg);
|
|
37
37
|
};
|
|
38
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp$
|
|
38
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$2(obj, key, {
|
|
39
39
|
enumerable: true,
|
|
40
40
|
configurable: true,
|
|
41
41
|
writable: true,
|
|
42
42
|
value
|
|
43
43
|
}) : obj[key] = value;
|
|
44
|
-
var __spreadValues = (a, b) => {
|
|
45
|
-
for (var prop in b || (b = {})) if (__hasOwnProp$
|
|
46
|
-
if (__getOwnPropSymbols) {
|
|
47
|
-
for (var prop of __getOwnPropSymbols(b)) if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
44
|
+
var __spreadValues$1 = (a, b) => {
|
|
45
|
+
for (var prop in b || (b = {})) if (__hasOwnProp$2.call(b, prop)) __defNormalProp$1(a, prop, b[prop]);
|
|
46
|
+
if (__getOwnPropSymbols$1) {
|
|
47
|
+
for (var prop of __getOwnPropSymbols$1(b)) if (__propIsEnum$1.call(b, prop)) __defNormalProp$1(a, prop, b[prop]);
|
|
48
48
|
}
|
|
49
49
|
return a;
|
|
50
50
|
};
|
|
51
51
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
52
|
-
var __export = (target, all) => {
|
|
53
|
-
for (var name in all) __defProp$
|
|
52
|
+
var __export$1 = (target, all) => {
|
|
53
|
+
for (var name in all) __defProp$2(target, name, {
|
|
54
54
|
get: all[name],
|
|
55
55
|
enumerable: true
|
|
56
56
|
});
|
|
57
57
|
};
|
|
58
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
59
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
60
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
61
|
-
__export({}, {
|
|
62
|
-
DimensionFormatUnits: () => DimensionFormatUnits,
|
|
63
|
-
DimensionFormatUnitsFormat: () => DimensionFormatUnitsFormat,
|
|
64
|
-
DimensionStyleTextFrame: () => DimensionStyleTextFrame,
|
|
65
|
-
DimensionStyleTextPositionMode: () => DimensionStyleTextPositionMode
|
|
58
|
+
var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
|
|
59
|
+
var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
60
|
+
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
|
61
|
+
__export$1({}, {
|
|
62
|
+
DimensionFormatUnits: () => DimensionFormatUnits$1,
|
|
63
|
+
DimensionFormatUnitsFormat: () => DimensionFormatUnitsFormat$1,
|
|
64
|
+
DimensionStyleTextFrame: () => DimensionStyleTextFrame$1,
|
|
65
|
+
DimensionStyleTextPositionMode: () => DimensionStyleTextPositionMode$1
|
|
66
66
|
});
|
|
67
|
-
var DimensionFormatUnits = /* @__PURE__ */ ((DimensionFormatUnits2) => {
|
|
67
|
+
var DimensionFormatUnits$1 = /* @__PURE__ */ ((DimensionFormatUnits2) => {
|
|
68
68
|
DimensionFormatUnits2[DimensionFormatUnits2["inches"] = 0] = "inches";
|
|
69
69
|
DimensionFormatUnits2[DimensionFormatUnits2["mils"] = 1] = "mils";
|
|
70
70
|
DimensionFormatUnits2[DimensionFormatUnits2["millimeters"] = 2] = "millimeters";
|
|
71
71
|
DimensionFormatUnits2[DimensionFormatUnits2["automatic"] = 3] = "automatic";
|
|
72
72
|
return DimensionFormatUnits2;
|
|
73
|
-
})(DimensionFormatUnits || {});
|
|
74
|
-
var DimensionFormatUnitsFormat = /* @__PURE__ */ ((DimensionFormatUnitsFormat2) => {
|
|
73
|
+
})(DimensionFormatUnits$1 || {});
|
|
74
|
+
var DimensionFormatUnitsFormat$1 = /* @__PURE__ */ ((DimensionFormatUnitsFormat2) => {
|
|
75
75
|
DimensionFormatUnitsFormat2[DimensionFormatUnitsFormat2["none"] = 0] = "none";
|
|
76
76
|
DimensionFormatUnitsFormat2[DimensionFormatUnitsFormat2["bare"] = 1] = "bare";
|
|
77
77
|
DimensionFormatUnitsFormat2[DimensionFormatUnitsFormat2["parenthesis"] = 2] = "parenthesis";
|
|
78
78
|
return DimensionFormatUnitsFormat2;
|
|
79
|
-
})(DimensionFormatUnitsFormat || {});
|
|
80
|
-
var DimensionStyleTextPositionMode = /* @__PURE__ */ ((DimensionStyleTextPositionMode2) => {
|
|
79
|
+
})(DimensionFormatUnitsFormat$1 || {});
|
|
80
|
+
var DimensionStyleTextPositionMode$1 = /* @__PURE__ */ ((DimensionStyleTextPositionMode2) => {
|
|
81
81
|
DimensionStyleTextPositionMode2[DimensionStyleTextPositionMode2["outside"] = 0] = "outside";
|
|
82
82
|
DimensionStyleTextPositionMode2[DimensionStyleTextPositionMode2["inline"] = 1] = "inline";
|
|
83
83
|
DimensionStyleTextPositionMode2[DimensionStyleTextPositionMode2["manual"] = 2] = "manual";
|
|
84
84
|
return DimensionStyleTextPositionMode2;
|
|
85
|
-
})(DimensionStyleTextPositionMode || {});
|
|
86
|
-
var DimensionStyleTextFrame = /* @__PURE__ */ ((DimensionStyleTextFrame2) => {
|
|
85
|
+
})(DimensionStyleTextPositionMode$1 || {});
|
|
86
|
+
var DimensionStyleTextFrame$1 = /* @__PURE__ */ ((DimensionStyleTextFrame2) => {
|
|
87
87
|
DimensionStyleTextFrame2[DimensionStyleTextFrame2["none"] = 0] = "none";
|
|
88
88
|
DimensionStyleTextFrame2[DimensionStyleTextFrame2["rect"] = 1] = "rect";
|
|
89
89
|
DimensionStyleTextFrame2[DimensionStyleTextFrame2["circle"] = 2] = "circle";
|
|
90
90
|
DimensionStyleTextFrame2[DimensionStyleTextFrame2["roundrect"] = 3] = "roundrect";
|
|
91
91
|
return DimensionStyleTextFrame2;
|
|
92
|
-
})(DimensionStyleTextFrame || {});
|
|
93
|
-
var EOF = "";
|
|
94
|
-
var Token = class {
|
|
92
|
+
})(DimensionStyleTextFrame$1 || {});
|
|
93
|
+
var EOF$1 = "";
|
|
94
|
+
var Token$1 = class {
|
|
95
95
|
constructor(type, value = null) {
|
|
96
96
|
this.type = type;
|
|
97
97
|
this.value = value;
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
|
-
Token.OPEN = Symbol("opn");
|
|
101
|
-
Token.CLOSE = Symbol("clo");
|
|
102
|
-
Token.ATOM = Symbol("atm");
|
|
103
|
-
Token.NUMBER = Symbol("num");
|
|
104
|
-
Token.STRING = Symbol("str");
|
|
105
|
-
function is_digit(c) {
|
|
100
|
+
Token$1.OPEN = Symbol("opn");
|
|
101
|
+
Token$1.CLOSE = Symbol("clo");
|
|
102
|
+
Token$1.ATOM = Symbol("atm");
|
|
103
|
+
Token$1.NUMBER = Symbol("num");
|
|
104
|
+
Token$1.STRING = Symbol("str");
|
|
105
|
+
function is_digit$1(c) {
|
|
106
106
|
return c >= "0" && c <= "9";
|
|
107
107
|
}
|
|
108
|
-
function is_alpha(c) {
|
|
108
|
+
function is_alpha$1(c) {
|
|
109
109
|
return c >= "A" && c <= "Z" || c >= "a" && c <= "z";
|
|
110
110
|
}
|
|
111
|
-
function is_whitespace(c) {
|
|
112
|
-
return c === EOF || c === " " || c === "\n" || c === "\r" || c === " " || c === "|";
|
|
111
|
+
function is_whitespace$1(c) {
|
|
112
|
+
return c === EOF$1 || c === " " || c === "\n" || c === "\r" || c === " " || c === "|";
|
|
113
113
|
}
|
|
114
|
-
function is_atom(c) {
|
|
115
|
-
return is_alpha(c) || is_digit(c) || [
|
|
114
|
+
function is_atom$1(c) {
|
|
115
|
+
return is_alpha$1(c) || is_digit$1(c) || [
|
|
116
116
|
"_",
|
|
117
117
|
"-",
|
|
118
118
|
":",
|
|
@@ -134,21 +134,21 @@ window.__ModuleLoader__.load({
|
|
|
134
134
|
"$"
|
|
135
135
|
].includes(c);
|
|
136
136
|
}
|
|
137
|
-
function error_context(input, index) {
|
|
137
|
+
function error_context$1(input, index) {
|
|
138
138
|
let start = input.slice(0, index).lastIndexOf("\n");
|
|
139
139
|
if (start < 0) start = 0;
|
|
140
140
|
let end = input.slice(index).indexOf("\n");
|
|
141
141
|
if (end < 0) end = 20;
|
|
142
142
|
return input.slice(start, index + end);
|
|
143
143
|
}
|
|
144
|
-
function* tokenize$
|
|
145
|
-
const open_token = new Token(Token.OPEN);
|
|
146
|
-
const close_token = new Token(Token.CLOSE);
|
|
144
|
+
function* tokenize$2(input) {
|
|
145
|
+
const open_token = new Token$1(Token$1.OPEN);
|
|
146
|
+
const close_token = new Token$1(Token$1.CLOSE);
|
|
147
147
|
let state = 0;
|
|
148
148
|
let start_idx = 0;
|
|
149
149
|
let escaping = false;
|
|
150
150
|
for (let i = 0; i < input.length + 1; i++) {
|
|
151
|
-
const c = i < input.length ? input[i] : EOF;
|
|
151
|
+
const c = i < input.length ? input[i] : EOF$1;
|
|
152
152
|
if (state == 0) {
|
|
153
153
|
if (c === "(") {
|
|
154
154
|
yield open_token;
|
|
@@ -160,11 +160,11 @@ window.__ModuleLoader__.load({
|
|
|
160
160
|
state = 1;
|
|
161
161
|
start_idx = i;
|
|
162
162
|
continue;
|
|
163
|
-
} else if (c === "-" || c == "+" || is_digit(c)) {
|
|
163
|
+
} else if (c === "-" || c == "+" || is_digit$1(c)) {
|
|
164
164
|
state = 2;
|
|
165
165
|
start_idx = i;
|
|
166
166
|
continue;
|
|
167
|
-
} else if (is_alpha(c) || [
|
|
167
|
+
} else if (is_alpha$1(c) || [
|
|
168
168
|
"*",
|
|
169
169
|
"&",
|
|
170
170
|
"$",
|
|
@@ -174,19 +174,19 @@ window.__ModuleLoader__.load({
|
|
|
174
174
|
state = 3;
|
|
175
175
|
start_idx = i;
|
|
176
176
|
continue;
|
|
177
|
-
} else if (is_whitespace(c)) continue;
|
|
177
|
+
} else if (is_whitespace$1(c)) continue;
|
|
178
178
|
else if (c === "|") continue;
|
|
179
179
|
else throw new Error(`Unexpected character at index ${i}: ${c}
|
|
180
|
-
Context: ${error_context(input, i)}`);
|
|
180
|
+
Context: ${error_context$1(input, i)}`);
|
|
181
181
|
} else if (state == 3) {
|
|
182
|
-
if (is_atom(c)) continue;
|
|
183
|
-
else if (c === ")" || is_whitespace(c)) {
|
|
184
|
-
yield new Token(Token.ATOM, input.substring(start_idx, i));
|
|
182
|
+
if (is_atom$1(c)) continue;
|
|
183
|
+
else if (c === ")" || is_whitespace$1(c)) {
|
|
184
|
+
yield new Token$1(Token$1.ATOM, input.substring(start_idx, i));
|
|
185
185
|
state = 0;
|
|
186
186
|
if (c === ")") yield close_token;
|
|
187
187
|
} else continue;
|
|
188
188
|
} else if (state == 2) {
|
|
189
|
-
if (c === "." || is_digit(c)) continue;
|
|
189
|
+
if (c === "." || is_digit$1(c)) continue;
|
|
190
190
|
else if (c.toLowerCase() === "x") {
|
|
191
191
|
state = 4;
|
|
192
192
|
continue;
|
|
@@ -202,18 +202,18 @@ Context: ${error_context(input, i)}`);
|
|
|
202
202
|
].includes(c.toLowerCase())) {
|
|
203
203
|
state = 3;
|
|
204
204
|
continue;
|
|
205
|
-
} else if (is_atom(c)) {
|
|
205
|
+
} else if (is_atom$1(c)) {
|
|
206
206
|
state = 3;
|
|
207
207
|
continue;
|
|
208
|
-
} else if (c === ")" || is_whitespace(c)) {
|
|
209
|
-
yield new Token(Token.NUMBER, parseFloat(input.substring(start_idx, i)));
|
|
208
|
+
} else if (c === ")" || is_whitespace$1(c)) {
|
|
209
|
+
yield new Token$1(Token$1.NUMBER, parseFloat(input.substring(start_idx, i)));
|
|
210
210
|
state = 0;
|
|
211
211
|
if (c === ")") yield close_token;
|
|
212
212
|
continue;
|
|
213
213
|
} else throw new Error(`Unexpected character at index ${i}: ${c}, expected numeric.
|
|
214
|
-
Context: ${error_context(input, i)}`);
|
|
214
|
+
Context: ${error_context$1(input, i)}`);
|
|
215
215
|
} else if (state == 4) {
|
|
216
|
-
if (is_digit(c) || [
|
|
216
|
+
if (is_digit$1(c) || [
|
|
217
217
|
"a",
|
|
218
218
|
"b",
|
|
219
219
|
"c",
|
|
@@ -222,20 +222,20 @@ Context: ${error_context(input, i)}`);
|
|
|
222
222
|
"f",
|
|
223
223
|
"_"
|
|
224
224
|
].includes(c.toLowerCase())) continue;
|
|
225
|
-
else if (c === ")" || is_whitespace(c)) {
|
|
225
|
+
else if (c === ")" || is_whitespace$1(c)) {
|
|
226
226
|
const hexstr = input.substring(start_idx, i).replace("_", "");
|
|
227
|
-
yield new Token(Token.NUMBER, Number.parseInt(hexstr, 16));
|
|
227
|
+
yield new Token$1(Token$1.NUMBER, Number.parseInt(hexstr, 16));
|
|
228
228
|
state = 0;
|
|
229
229
|
if (c === ")") yield close_token;
|
|
230
230
|
continue;
|
|
231
|
-
} else if (is_atom(c)) {
|
|
231
|
+
} else if (is_atom$1(c)) {
|
|
232
232
|
state = 3;
|
|
233
233
|
continue;
|
|
234
234
|
} else throw new Error(`Unexpected character at index ${i}: ${c}, expected hexadecimal.
|
|
235
|
-
Context: ${error_context(input, i)}`);
|
|
235
|
+
Context: ${error_context$1(input, i)}`);
|
|
236
236
|
} else if (state == 1) {
|
|
237
237
|
if (!escaping && c === "\"") {
|
|
238
|
-
yield new Token(Token.STRING, input.substring((start_idx != null ? start_idx : 0) + 1, i).replaceAll("\\n", "\n").replaceAll("\\\\", "\\").replaceAll("\\\"", "\""));
|
|
238
|
+
yield new Token$1(Token$1.STRING, input.substring((start_idx != null ? start_idx : 0) + 1, i).replaceAll("\\n", "\n").replaceAll("\\\\", "\\").replaceAll("\\\"", "\""));
|
|
239
239
|
state = 0;
|
|
240
240
|
escaping = false;
|
|
241
241
|
continue;
|
|
@@ -247,61 +247,61 @@ Context: ${error_context(input, i)}`);
|
|
|
247
247
|
continue;
|
|
248
248
|
}
|
|
249
249
|
} else throw new Error(`Unknown tokenizer state ${state}
|
|
250
|
-
Context: ${error_context(input, i)}`);
|
|
250
|
+
Context: ${error_context$1(input, i)}`);
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
function* listify_tokens(tokens) {
|
|
253
|
+
function* listify_tokens$1(tokens) {
|
|
254
254
|
let token;
|
|
255
255
|
let it;
|
|
256
256
|
while (true) {
|
|
257
257
|
it = tokens.next();
|
|
258
258
|
token = it.value;
|
|
259
259
|
switch (token == null ? void 0 : token.type) {
|
|
260
|
-
case Token.ATOM:
|
|
261
|
-
case Token.STRING:
|
|
262
|
-
case Token.NUMBER:
|
|
260
|
+
case Token$1.ATOM:
|
|
261
|
+
case Token$1.STRING:
|
|
262
|
+
case Token$1.NUMBER:
|
|
263
263
|
yield token.value;
|
|
264
264
|
break;
|
|
265
|
-
case Token.OPEN:
|
|
266
|
-
yield Array.from(listify_tokens(tokens));
|
|
265
|
+
case Token$1.OPEN:
|
|
266
|
+
yield Array.from(listify_tokens$1(tokens));
|
|
267
267
|
break;
|
|
268
|
-
case Token.CLOSE:
|
|
268
|
+
case Token$1.CLOSE:
|
|
269
269
|
case void 0: return;
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
-
function listify(src) {
|
|
274
|
-
const tokens = tokenize$
|
|
275
|
-
return Array.from(listify_tokens(tokens));
|
|
273
|
+
function listify$1(src) {
|
|
274
|
+
const tokens = tokenize$2(src);
|
|
275
|
+
return Array.from(listify_tokens$1(tokens));
|
|
276
276
|
}
|
|
277
|
-
var _Logger_instances;
|
|
278
|
-
var log_fn;
|
|
279
|
-
var Logger$
|
|
277
|
+
var _Logger_instances$1;
|
|
278
|
+
var log_fn$1;
|
|
279
|
+
var Logger$2 = class {
|
|
280
280
|
constructor(name, level = 1) {
|
|
281
281
|
this.name = name;
|
|
282
282
|
this.level = level;
|
|
283
|
-
__privateAdd(this, _Logger_instances);
|
|
283
|
+
__privateAdd$1(this, _Logger_instances$1);
|
|
284
284
|
}
|
|
285
285
|
debug(...args) {
|
|
286
|
-
if (this.level >= 2) __privateMethod(this, _Logger_instances, log_fn).call(this, console.debug, ...args);
|
|
286
|
+
if (this.level >= 2) __privateMethod$1(this, _Logger_instances$1, log_fn$1).call(this, console.debug, ...args);
|
|
287
287
|
}
|
|
288
288
|
info(...args) {
|
|
289
|
-
if (this.level >= 1) __privateMethod(this, _Logger_instances, log_fn).call(this, console.info.bind(console), ...args);
|
|
289
|
+
if (this.level >= 1) __privateMethod$1(this, _Logger_instances$1, log_fn$1).call(this, console.info.bind(console), ...args);
|
|
290
290
|
}
|
|
291
291
|
warn(...args) {
|
|
292
|
-
if (this.level >= 0) __privateMethod(this, _Logger_instances, log_fn).call(this, console.warn, ...args);
|
|
292
|
+
if (this.level >= 0) __privateMethod$1(this, _Logger_instances$1, log_fn$1).call(this, console.warn, ...args);
|
|
293
293
|
}
|
|
294
294
|
error(...args) {
|
|
295
|
-
if (this.level >= 0) __privateMethod(this, _Logger_instances, log_fn).call(this, console.error, ...args);
|
|
295
|
+
if (this.level >= 0) __privateMethod$1(this, _Logger_instances$1, log_fn$1).call(this, console.error, ...args);
|
|
296
296
|
}
|
|
297
297
|
};
|
|
298
|
-
_Logger_instances = /* @__PURE__ */ new WeakSet();
|
|
299
|
-
log_fn = function(method, ...args) {};
|
|
300
|
-
new Logger$
|
|
301
|
-
var log$
|
|
302
|
-
var is_string$
|
|
303
|
-
var is_number$
|
|
304
|
-
var T = {
|
|
298
|
+
_Logger_instances$1 = /* @__PURE__ */ new WeakSet();
|
|
299
|
+
log_fn$1 = function(method, ...args) {};
|
|
300
|
+
new Logger$2("kicad-parser");
|
|
301
|
+
var log$3 = new Logger$2("kicanvas:parser");
|
|
302
|
+
var is_string$2 = (e) => typeof e === "string";
|
|
303
|
+
var is_number$2 = (e) => typeof e === "number";
|
|
304
|
+
var T$1 = {
|
|
305
305
|
any(obj, name, e) {
|
|
306
306
|
return e;
|
|
307
307
|
},
|
|
@@ -315,11 +315,11 @@ Context: ${error_context(input, i)}`);
|
|
|
315
315
|
}
|
|
316
316
|
},
|
|
317
317
|
string(obj, name, e) {
|
|
318
|
-
if (is_string$
|
|
318
|
+
if (is_string$2(e)) return e;
|
|
319
319
|
else return;
|
|
320
320
|
},
|
|
321
321
|
number(obj, name, e) {
|
|
322
|
-
if (is_number$
|
|
322
|
+
if (is_number$2(e)) return e;
|
|
323
323
|
else return;
|
|
324
324
|
},
|
|
325
325
|
item(factory, ...args) {
|
|
@@ -332,7 +332,7 @@ Context: ${error_context(input, i)}`);
|
|
|
332
332
|
var _a, _b;
|
|
333
333
|
let existing = {};
|
|
334
334
|
if (start !== null) existing = (_b = (_a = obj[name]) != null ? _a : start) != null ? _b : {};
|
|
335
|
-
return __spreadValues(__spreadValues({}, existing), parse_expr(e, P.start(name), ...defs));
|
|
335
|
+
return __spreadValues$1(__spreadValues$1({}, existing), parse_expr$1(e, P$1.start(name), ...defs));
|
|
336
336
|
};
|
|
337
337
|
},
|
|
338
338
|
vec2(obj, name, e) {
|
|
@@ -362,22 +362,22 @@ Context: ${error_context(input, i)}`);
|
|
|
362
362
|
};
|
|
363
363
|
}
|
|
364
364
|
};
|
|
365
|
-
var P = {
|
|
365
|
+
var P$1 = {
|
|
366
366
|
start(name) {
|
|
367
367
|
return {
|
|
368
368
|
kind: 0,
|
|
369
369
|
name,
|
|
370
|
-
fn: T.string
|
|
370
|
+
fn: T$1.string
|
|
371
371
|
};
|
|
372
372
|
},
|
|
373
|
-
positional(name, typefn = T.any) {
|
|
373
|
+
positional(name, typefn = T$1.any) {
|
|
374
374
|
return {
|
|
375
375
|
kind: 1,
|
|
376
376
|
name,
|
|
377
377
|
fn: typefn
|
|
378
378
|
};
|
|
379
379
|
},
|
|
380
|
-
pair(name, typefn = T.any) {
|
|
380
|
+
pair(name, typefn = T$1.any) {
|
|
381
381
|
return {
|
|
382
382
|
kind: 2,
|
|
383
383
|
name,
|
|
@@ -387,7 +387,7 @@ Context: ${error_context(input, i)}`);
|
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
389
|
},
|
|
390
|
-
list(name, typefn = T.any) {
|
|
390
|
+
list(name, typefn = T$1.any) {
|
|
391
391
|
return {
|
|
392
392
|
kind: 3,
|
|
393
393
|
name,
|
|
@@ -397,7 +397,7 @@ Context: ${error_context(input, i)}`);
|
|
|
397
397
|
}
|
|
398
398
|
};
|
|
399
399
|
},
|
|
400
|
-
collection(name, accept, typefn = T.any) {
|
|
400
|
+
collection(name, accept, typefn = T$1.any) {
|
|
401
401
|
return {
|
|
402
402
|
kind: 5,
|
|
403
403
|
name,
|
|
@@ -410,7 +410,7 @@ Context: ${error_context(input, i)}`);
|
|
|
410
410
|
}
|
|
411
411
|
};
|
|
412
412
|
},
|
|
413
|
-
mapped_collection(name, accept, keyfn, typefn = T.any) {
|
|
413
|
+
mapped_collection(name, accept, keyfn, typefn = T$1.any) {
|
|
414
414
|
return {
|
|
415
415
|
kind: 5,
|
|
416
416
|
name,
|
|
@@ -425,7 +425,7 @@ Context: ${error_context(input, i)}`);
|
|
|
425
425
|
}
|
|
426
426
|
};
|
|
427
427
|
},
|
|
428
|
-
dict(name, accept, typefn = T.any) {
|
|
428
|
+
dict(name, accept, typefn = T$1.any) {
|
|
429
429
|
return {
|
|
430
430
|
kind: 5,
|
|
431
431
|
name,
|
|
@@ -441,9 +441,9 @@ Context: ${error_context(input, i)}`);
|
|
|
441
441
|
},
|
|
442
442
|
atom(name, values) {
|
|
443
443
|
let typefn;
|
|
444
|
-
if (values) typefn = T.string;
|
|
444
|
+
if (values) typefn = T$1.string;
|
|
445
445
|
else {
|
|
446
|
-
typefn = T.boolean;
|
|
446
|
+
typefn = T$1.boolean;
|
|
447
447
|
values = [name];
|
|
448
448
|
}
|
|
449
449
|
return {
|
|
@@ -456,7 +456,7 @@ Context: ${error_context(input, i)}`);
|
|
|
456
456
|
}
|
|
457
457
|
};
|
|
458
458
|
},
|
|
459
|
-
expr(name, typefn = T.any) {
|
|
459
|
+
expr(name, typefn = T$1.any) {
|
|
460
460
|
return {
|
|
461
461
|
kind: 6,
|
|
462
462
|
name,
|
|
@@ -465,28 +465,28 @@ Context: ${error_context(input, i)}`);
|
|
|
465
465
|
};
|
|
466
466
|
},
|
|
467
467
|
object(name, start, ...defs) {
|
|
468
|
-
return P.expr(name, T.object(start, ...defs));
|
|
468
|
+
return P$1.expr(name, T$1.object(start, ...defs));
|
|
469
469
|
},
|
|
470
470
|
item(name, factory, ...args) {
|
|
471
|
-
return P.expr(name, T.item(factory, ...args));
|
|
471
|
+
return P$1.expr(name, T$1.item(factory, ...args));
|
|
472
472
|
},
|
|
473
473
|
vec2(name) {
|
|
474
|
-
return P.expr(name, T.vec2);
|
|
474
|
+
return P$1.expr(name, T$1.vec2);
|
|
475
475
|
},
|
|
476
476
|
vec4(name) {
|
|
477
|
-
return P.expr(name, T.vec4);
|
|
477
|
+
return P$1.expr(name, T$1.vec4);
|
|
478
478
|
},
|
|
479
479
|
color(name = "color") {
|
|
480
|
-
return P.expr(name, T.color);
|
|
480
|
+
return P$1.expr(name, T$1.color);
|
|
481
481
|
}
|
|
482
482
|
};
|
|
483
|
-
function as_array(v) {
|
|
483
|
+
function as_array$1(v) {
|
|
484
484
|
if (Array.isArray(v)) return v;
|
|
485
485
|
else return [v];
|
|
486
486
|
}
|
|
487
|
-
function parse_expr(expr, ...defs) {
|
|
488
|
-
if (is_string$
|
|
489
|
-
expr = listify(expr);
|
|
487
|
+
function parse_expr$1(expr, ...defs) {
|
|
488
|
+
if (is_string$2(expr)) {
|
|
489
|
+
expr = listify$1(expr);
|
|
490
490
|
if (expr.length == 1 && Array.isArray(expr[0])) expr = expr[0];
|
|
491
491
|
}
|
|
492
492
|
const defs_map = /* @__PURE__ */ new Map();
|
|
@@ -498,7 +498,7 @@ Context: ${error_context(input, i)}`);
|
|
|
498
498
|
n++;
|
|
499
499
|
} else for (const a of def.accepts) defs_map.set(a, def);
|
|
500
500
|
if (start_def) {
|
|
501
|
-
const acceptable_start_strings = as_array(start_def.name);
|
|
501
|
+
const acceptable_start_strings = as_array$1(start_def.name);
|
|
502
502
|
const first = expr.at(0);
|
|
503
503
|
if (!acceptable_start_strings.includes(first)) throw new Error(`Expression must start with ${start_def.name} found ${first} in ${expr}`);
|
|
504
504
|
expr = expr.slice(1);
|
|
@@ -507,18 +507,18 @@ Context: ${error_context(input, i)}`);
|
|
|
507
507
|
n = 0;
|
|
508
508
|
for (const element of expr) {
|
|
509
509
|
let def = null;
|
|
510
|
-
if (is_string$
|
|
511
|
-
if (!def && (is_string$
|
|
510
|
+
if (is_string$2(element)) def = defs_map.get(element);
|
|
511
|
+
if (!def && (is_string$2(element) || is_number$2(element))) {
|
|
512
512
|
def = defs_map.get(n);
|
|
513
513
|
if (!def) {
|
|
514
|
-
log$
|
|
514
|
+
log$3.warn(`no def for bare element ${element} at position ${n} in expression ${expr}`);
|
|
515
515
|
continue;
|
|
516
516
|
}
|
|
517
517
|
n++;
|
|
518
518
|
}
|
|
519
519
|
if (!def && Array.isArray(element)) def = defs_map.get(element[0]);
|
|
520
520
|
if (!def) {
|
|
521
|
-
log$
|
|
521
|
+
log$3.warn(`No def found for element ${element} in expression ${expr}`);
|
|
522
522
|
continue;
|
|
523
523
|
}
|
|
524
524
|
const value = def.fn(out, def.name, element);
|
|
@@ -528,7 +528,7 @@ Context: ${error_context(input, i)}`);
|
|
|
528
528
|
}
|
|
529
529
|
function parseAt(expr) {
|
|
530
530
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
531
|
-
const parsed = parse_expr(expr, P.start("at"), P.vec2("position"), P.positional("x", T.number), P.positional("y", T.number), P.positional("rotation", T.number), P.atom("unlocked"));
|
|
531
|
+
const parsed = parse_expr$1(expr, P$1.start("at"), P$1.vec2("position"), P$1.positional("x", T$1.number), P$1.positional("y", T$1.number), P$1.positional("rotation", T$1.number), P$1.atom("unlocked"));
|
|
532
532
|
return {
|
|
533
533
|
position: {
|
|
534
534
|
x: (_c = (_b = (_a = parsed.position) == null ? void 0 : _a.x) != null ? _b : parsed.x) != null ? _c : 0,
|
|
@@ -539,10 +539,10 @@ Context: ${error_context(input, i)}`);
|
|
|
539
539
|
};
|
|
540
540
|
}
|
|
541
541
|
function parseStroke(expr) {
|
|
542
|
-
return parse_expr(expr, P.start("stroke"), P.pair("width", T.number), P.pair("type", T.string), P.color());
|
|
542
|
+
return parse_expr$1(expr, P$1.start("stroke"), P$1.pair("width", T$1.number), P$1.pair("type", T$1.string), P$1.color());
|
|
543
543
|
}
|
|
544
544
|
function parseEffects(expr) {
|
|
545
|
-
return parse_expr(expr, P.start("effects"), P.object("font", {}, P.start("font"), P.pair("face", T.string), P.vec2("size"), P.pair("thickness", T.number), P.atom("bold"), P.atom("italic"), P.pair("line_spacing", T.number)), P.item("justify", (e) => {
|
|
545
|
+
return parse_expr$1(expr, P$1.start("effects"), P$1.object("font", {}, P$1.start("font"), P$1.pair("face", T$1.string), P$1.vec2("size"), P$1.pair("thickness", T$1.number), P$1.atom("bold"), P$1.atom("italic"), P$1.pair("line_spacing", T$1.number)), P$1.item("justify", (e) => {
|
|
546
546
|
let horiz = "center";
|
|
547
547
|
let vert = "center";
|
|
548
548
|
let mirror = false;
|
|
@@ -559,37 +559,37 @@ Context: ${error_context(input, i)}`);
|
|
|
559
559
|
vert,
|
|
560
560
|
mirror
|
|
561
561
|
};
|
|
562
|
-
}), P.atom("hide"), P.pair("href", T.string));
|
|
562
|
+
}), P$1.atom("hide"), P$1.pair("href", T$1.string));
|
|
563
563
|
}
|
|
564
564
|
function parseTitleBlock(expr) {
|
|
565
|
-
return parse_expr(expr, P.start("title_block"), P.pair("title", T.string), P.pair("date", T.string), P.pair("rev", T.string), P.pair("company", T.string), P.dict("comment", "comment", T.string));
|
|
565
|
+
return parse_expr$1(expr, P$1.start("title_block"), P$1.pair("title", T$1.string), P$1.pair("date", T$1.string), P$1.pair("rev", T$1.string), P$1.pair("company", T$1.string), P$1.dict("comment", "comment", T$1.string));
|
|
566
566
|
}
|
|
567
567
|
function parsePaper(expr) {
|
|
568
|
-
return parse_expr(expr, P.start("paper"), P.positional("size", T.string), P.positional("width", T.number), P.positional("height", T.number), P.atom("portrait"));
|
|
568
|
+
return parse_expr$1(expr, P$1.start("paper"), P$1.positional("size", T$1.string), P$1.positional("width", T$1.number), P$1.positional("height", T$1.number), P$1.atom("portrait"));
|
|
569
569
|
}
|
|
570
570
|
function parseLayer(expr) {
|
|
571
|
-
return parse_expr(expr, P.positional("ordinal", T.number), P.positional("canonical_name", T.string), P.positional("type", T.string), P.positional("user_name", T.string));
|
|
571
|
+
return parse_expr$1(expr, P$1.positional("ordinal", T$1.number), P$1.positional("canonical_name", T$1.string), P$1.positional("type", T$1.string), P$1.positional("user_name", T$1.string));
|
|
572
572
|
}
|
|
573
573
|
function parseStackupLayer(expr) {
|
|
574
|
-
return parse_expr(expr, P.positional("name", T.string), P.pair("type", T.string), P.pair("color", T.string), P.pair("thickness", T.number), P.pair("material", T.string), P.pair("epsilon_r", T.number), P.pair("loss_tangent", T.number));
|
|
574
|
+
return parse_expr$1(expr, P$1.positional("name", T$1.string), P$1.pair("type", T$1.string), P$1.pair("color", T$1.string), P$1.pair("thickness", T$1.number), P$1.pair("material", T$1.string), P$1.pair("epsilon_r", T$1.number), P$1.pair("loss_tangent", T$1.number));
|
|
575
575
|
}
|
|
576
576
|
function parseStackup(expr) {
|
|
577
|
-
return parse_expr(expr, P.start("stackup"), P.collection("layers", "layer", T.item(parseStackupLayer)), P.pair("copper_finish", T.string), P.pair("dielectric_constraints", T.boolean), P.pair("edge_connector", T.string), P.pair("castellated_pads", T.boolean), P.pair("edge_plating", T.boolean));
|
|
577
|
+
return parse_expr$1(expr, P$1.start("stackup"), P$1.collection("layers", "layer", T$1.item(parseStackupLayer)), P$1.pair("copper_finish", T$1.string), P$1.pair("dielectric_constraints", T$1.boolean), P$1.pair("edge_connector", T$1.string), P$1.pair("castellated_pads", T$1.boolean), P$1.pair("edge_plating", T$1.boolean));
|
|
578
578
|
}
|
|
579
579
|
function parsePCBPlotParams(expr) {
|
|
580
|
-
return parse_expr(expr, P.start("pcbplotparams"), P.pair("layerselection", T.number), P.pair("disableapertmacros", T.boolean), P.pair("usegerberextensions", T.boolean), P.pair("usegerberattributes", T.boolean), P.pair("usegerberadvancedattributes", T.boolean), P.pair("creategerberjobfile", T.boolean), P.pair("gerberprecision", T.number), P.pair("svguseinch", T.boolean), P.pair("svgprecision", T.number), P.pair("excludeedgelayer", T.boolean), P.pair("plotframeref", T.boolean), P.pair("viasonmask", T.boolean), P.pair("mode", T.number), P.pair("useauxorigin", T.boolean), P.pair("hpglpennumber", T.number), P.pair("hpglpenspeed", T.number), P.pair("hpglpendiameter", T.number), P.pair("dxfpolygonmode", T.boolean), P.pair("dxfimperialunits", T.boolean), P.pair("dxfusepcbnewfont", T.boolean), P.pair("psnegative", T.boolean), P.pair("psa4output", T.boolean), P.pair("plotreference", T.boolean), P.pair("plotvalue", T.boolean), P.pair("plotinvisibletext", T.boolean), P.pair("sketchpadsonfab", T.boolean), P.pair("subtractmaskfromsilk", T.boolean), P.pair("outputformat", T.number), P.pair("mirror", T.boolean), P.pair("drillshape", T.number), P.pair("scaleselection", T.number), P.pair("outputdirectory", T.string), P.pair("plot_on_all_layers_selection", T.number), P.pair("dashed_line_dash_ratio", T.number), P.pair("dashed_line_gap_ratio", T.number), P.pair("pdf_front_fp_property_popups", T.boolean), P.pair("pdf_back_fp_property_popups", T.boolean), P.pair("plotfptext", T.boolean));
|
|
580
|
+
return parse_expr$1(expr, P$1.start("pcbplotparams"), P$1.pair("layerselection", T$1.number), P$1.pair("disableapertmacros", T$1.boolean), P$1.pair("usegerberextensions", T$1.boolean), P$1.pair("usegerberattributes", T$1.boolean), P$1.pair("usegerberadvancedattributes", T$1.boolean), P$1.pair("creategerberjobfile", T$1.boolean), P$1.pair("gerberprecision", T$1.number), P$1.pair("svguseinch", T$1.boolean), P$1.pair("svgprecision", T$1.number), P$1.pair("excludeedgelayer", T$1.boolean), P$1.pair("plotframeref", T$1.boolean), P$1.pair("viasonmask", T$1.boolean), P$1.pair("mode", T$1.number), P$1.pair("useauxorigin", T$1.boolean), P$1.pair("hpglpennumber", T$1.number), P$1.pair("hpglpenspeed", T$1.number), P$1.pair("hpglpendiameter", T$1.number), P$1.pair("dxfpolygonmode", T$1.boolean), P$1.pair("dxfimperialunits", T$1.boolean), P$1.pair("dxfusepcbnewfont", T$1.boolean), P$1.pair("psnegative", T$1.boolean), P$1.pair("psa4output", T$1.boolean), P$1.pair("plotreference", T$1.boolean), P$1.pair("plotvalue", T$1.boolean), P$1.pair("plotinvisibletext", T$1.boolean), P$1.pair("sketchpadsonfab", T$1.boolean), P$1.pair("subtractmaskfromsilk", T$1.boolean), P$1.pair("outputformat", T$1.number), P$1.pair("mirror", T$1.boolean), P$1.pair("drillshape", T$1.number), P$1.pair("scaleselection", T$1.number), P$1.pair("outputdirectory", T$1.string), P$1.pair("plot_on_all_layers_selection", T$1.number), P$1.pair("dashed_line_dash_ratio", T$1.number), P$1.pair("dashed_line_gap_ratio", T$1.number), P$1.pair("pdf_front_fp_property_popups", T$1.boolean), P$1.pair("pdf_back_fp_property_popups", T$1.boolean), P$1.pair("plotfptext", T$1.boolean));
|
|
581
581
|
}
|
|
582
582
|
function parseSetup(expr) {
|
|
583
|
-
return parse_expr(expr, P.start("setup"), P.pair("pad_to_mask_clearance", T.number), P.pair("solder_mask_min_width", T.number), P.pair("pad_to_paste_clearance", T.number), P.pair("pad_to_paste_clearance_ratio", T.number), P.vec2("aux_axis_origin"), P.vec2("grid_origin"), P.item("pcbplotparams", parsePCBPlotParams), P.item("stackup", parseStackup), P.pair("allow_soldermask_bridges_in_footprints", T.boolean));
|
|
583
|
+
return parse_expr$1(expr, P$1.start("setup"), P$1.pair("pad_to_mask_clearance", T$1.number), P$1.pair("solder_mask_min_width", T$1.number), P$1.pair("pad_to_paste_clearance", T$1.number), P$1.pair("pad_to_paste_clearance_ratio", T$1.number), P$1.vec2("aux_axis_origin"), P$1.vec2("grid_origin"), P$1.item("pcbplotparams", parsePCBPlotParams), P$1.item("stackup", parseStackup), P$1.pair("allow_soldermask_bridges_in_footprints", T$1.boolean));
|
|
584
584
|
}
|
|
585
585
|
function parseNet(expr) {
|
|
586
|
-
return parse_expr(expr, P.start("net"), P.positional("number", T.number), P.positional("name", T.string));
|
|
586
|
+
return parse_expr$1(expr, P$1.start("net"), P$1.positional("number", T$1.number), P$1.positional("name", T$1.string));
|
|
587
587
|
}
|
|
588
588
|
function parseNetReference(expr) {
|
|
589
|
-
return parse_expr(expr, P.start("net"), P.positional("number", T.number), P.positional("name", T.string));
|
|
589
|
+
return parse_expr$1(expr, P$1.start("net"), P$1.positional("number", T$1.number), P$1.positional("name", T$1.string));
|
|
590
590
|
}
|
|
591
591
|
function parseLine(expr, start) {
|
|
592
|
-
return parse_expr(expr, P.start(start), P.pair("layer", T.string), P.pair("tstamp", T.string), P.pair("uuid", T.string), P.atom("locked"), P.vec2("start"), P.vec2("end"), P.pair("width", T.number), P.item("stroke", parseStroke));
|
|
592
|
+
return parse_expr$1(expr, P$1.start(start), P$1.pair("layer", T$1.string), P$1.pair("tstamp", T$1.string), P$1.pair("uuid", T$1.string), P$1.atom("locked"), P$1.vec2("start"), P$1.vec2("end"), P$1.pair("width", T$1.number), P$1.item("stroke", parseStroke));
|
|
593
593
|
}
|
|
594
594
|
function parse_gr_Line(expr) {
|
|
595
595
|
return parseLine(expr, "gr_line");
|
|
@@ -598,7 +598,7 @@ Context: ${error_context(input, i)}`);
|
|
|
598
598
|
return parseLine(expr, "fp_line");
|
|
599
599
|
}
|
|
600
600
|
function parseCircle(expr, start) {
|
|
601
|
-
return parse_expr(expr, P.start(start), P.pair("layer", T.string), P.pair("tstamp", T.string), P.pair("uuid", T.string), P.atom("locked"), P.vec2("center"), P.vec2("end"), P.pair("width", T.number), P.pair("fill", T.string), P.item("stroke", parseStroke));
|
|
601
|
+
return parse_expr$1(expr, P$1.start(start), P$1.pair("layer", T$1.string), P$1.pair("tstamp", T$1.string), P$1.pair("uuid", T$1.string), P$1.atom("locked"), P$1.vec2("center"), P$1.vec2("end"), P$1.pair("width", T$1.number), P$1.pair("fill", T$1.string), P$1.item("stroke", parseStroke));
|
|
602
602
|
}
|
|
603
603
|
function parse_gr_Circle(expr) {
|
|
604
604
|
return parseCircle(expr, "gr_circle");
|
|
@@ -607,7 +607,7 @@ Context: ${error_context(input, i)}`);
|
|
|
607
607
|
return parseCircle(expr, "fp_circle");
|
|
608
608
|
}
|
|
609
609
|
function parseArc(expr, start) {
|
|
610
|
-
return parse_expr(expr, P.start(start), P.pair("layer", T.string), P.pair("tstamp", T.string), P.pair("uuid", T.string), P.atom("locked"), P.vec2("start"), P.vec2("mid"), P.vec2("end"), P.pair("angle", T.number), P.pair("width", T.number), P.item("stroke", parseStroke));
|
|
610
|
+
return parse_expr$1(expr, P$1.start(start), P$1.pair("layer", T$1.string), P$1.pair("tstamp", T$1.string), P$1.pair("uuid", T$1.string), P$1.atom("locked"), P$1.vec2("start"), P$1.vec2("mid"), P$1.vec2("end"), P$1.pair("angle", T$1.number), P$1.pair("width", T$1.number), P$1.item("stroke", parseStroke));
|
|
611
611
|
}
|
|
612
612
|
function parse_gr_Arc(expr) {
|
|
613
613
|
return parseArc(expr, "gr_arc");
|
|
@@ -619,10 +619,10 @@ Context: ${error_context(input, i)}`);
|
|
|
619
619
|
return parseArc(expr, "arc");
|
|
620
620
|
}
|
|
621
621
|
function parsePoly(expr, start) {
|
|
622
|
-
return parse_expr(expr, P.start(start), P.pair("layer", T.string), P.pair("tstamp", T.string), P.pair("uuid", T.string), P.atom("locked"), P.expr("pts", (obj, name, expr2) => {
|
|
623
|
-
const parsed = parse_expr(expr2, P.start("pts"), P.collection("items", "xy", T.vec2), P.collection("items", "arc", T.item(parse_poly_Arc)));
|
|
622
|
+
return parse_expr$1(expr, P$1.start(start), P$1.pair("layer", T$1.string), P$1.pair("tstamp", T$1.string), P$1.pair("uuid", T$1.string), P$1.atom("locked"), P$1.expr("pts", (obj, name, expr2) => {
|
|
623
|
+
const parsed = parse_expr$1(expr2, P$1.start("pts"), P$1.collection("items", "xy", T$1.vec2), P$1.collection("items", "arc", T$1.item(parse_poly_Arc)));
|
|
624
624
|
return parsed == null ? void 0 : parsed["items"];
|
|
625
|
-
}), P.pair("width", T.number), P.pair("fill", T.string), P.atom("island"), P.item("stroke", parseStroke));
|
|
625
|
+
}), P$1.pair("width", T$1.number), P$1.pair("fill", T$1.string), P$1.atom("island"), P$1.item("stroke", parseStroke));
|
|
626
626
|
}
|
|
627
627
|
function parse_gr_poly(expr) {
|
|
628
628
|
return parsePoly(expr, "gr_poly");
|
|
@@ -637,7 +637,7 @@ Context: ${error_context(input, i)}`);
|
|
|
637
637
|
return parsePoly(expr, "filled_polygon");
|
|
638
638
|
}
|
|
639
639
|
function parseRect(expr, start) {
|
|
640
|
-
return parse_expr(expr, P.start(start), P.pair("layer", T.string), P.pair("tstamp", T.string), P.pair("uuid", T.string), P.atom("locked"), P.vec2("start"), P.vec2("end"), P.pair("width", T.number), P.pair("fill", T.string), P.item("stroke", parseStroke));
|
|
640
|
+
return parse_expr$1(expr, P$1.start(start), P$1.pair("layer", T$1.string), P$1.pair("tstamp", T$1.string), P$1.pair("uuid", T$1.string), P$1.atom("locked"), P$1.vec2("start"), P$1.vec2("end"), P$1.pair("width", T$1.number), P$1.pair("fill", T$1.string), P$1.item("stroke", parseStroke));
|
|
641
641
|
}
|
|
642
642
|
function parse_gr_Rect(expr) {
|
|
643
643
|
return parseRect(expr, "gr_rect");
|
|
@@ -646,69 +646,69 @@ Context: ${error_context(input, i)}`);
|
|
|
646
646
|
return parseRect(expr, "fp_rect");
|
|
647
647
|
}
|
|
648
648
|
function parseTextRenderCache(expr) {
|
|
649
|
-
return parse_expr(expr, P.start("render_cache"), P.positional("text", T.string), P.positional("angle", T.number), P.pair("uuid", T.string), P.collection("polygons", "polygon", T.item(parse_polygon)));
|
|
649
|
+
return parse_expr$1(expr, P$1.start("render_cache"), P$1.positional("text", T$1.string), P$1.positional("angle", T$1.number), P$1.pair("uuid", T$1.string), P$1.collection("polygons", "polygon", T$1.item(parse_polygon)));
|
|
650
650
|
}
|
|
651
651
|
function parseFpText(expr) {
|
|
652
|
-
return parse_expr(expr, P.start("fp_text"), P.atom("locked"), P.positional("type", T.string), P.positional("text", T.string), P.item("at", parseAt), P.atom("hide"), P.atom("unlocked"), P.pair("uuid", T.string), P.object("layer", {}, P.start("layer"), P.positional("name", T.string), P.atom("knockout")), P.pair("tstamp", T.string), P.item("effects", parseEffects), P.item("render_cache", parseTextRenderCache));
|
|
652
|
+
return parse_expr$1(expr, P$1.start("fp_text"), P$1.atom("locked"), P$1.positional("type", T$1.string), P$1.positional("text", T$1.string), P$1.item("at", parseAt), P$1.atom("hide"), P$1.atom("unlocked"), P$1.pair("uuid", T$1.string), P$1.object("layer", {}, P$1.start("layer"), P$1.positional("name", T$1.string), P$1.atom("knockout")), P$1.pair("tstamp", T$1.string), P$1.item("effects", parseEffects), P$1.item("render_cache", parseTextRenderCache));
|
|
653
653
|
}
|
|
654
654
|
function parseGrText(expr) {
|
|
655
|
-
return parse_expr(expr, P.start("gr_text"), P.positional("text", T.string), P.item("at", parseAt), P.object("layer", {}, P.start("layer"), P.positional("name", T.string), P.atom("knockout")), P.atom("unlocked"), P.atom("hide"), P.atom("locked"), P.item("effects", parseEffects), P.pair("tstamp", T.string), P.pair("uuid", T.string), P.item("render_cache", parseTextRenderCache));
|
|
655
|
+
return parse_expr$1(expr, P$1.start("gr_text"), P$1.positional("text", T$1.string), P$1.item("at", parseAt), P$1.object("layer", {}, P$1.start("layer"), P$1.positional("name", T$1.string), P$1.atom("knockout")), P$1.atom("unlocked"), P$1.atom("hide"), P$1.atom("locked"), P$1.item("effects", parseEffects), P$1.pair("tstamp", T$1.string), P$1.pair("uuid", T$1.string), P$1.item("render_cache", parseTextRenderCache));
|
|
656
656
|
}
|
|
657
657
|
function parseDimension(expr) {
|
|
658
|
-
return parse_expr(expr, P.start("dimension"), P.atom("locked"), P.positional("type", T.string), P.pair("layer", T.string), P.pair("tstamp", T.string), P.pair("uuid", T.string), P.collection("pts", "pts", (obj, name, e) => {
|
|
659
|
-
return parse_expr(e, P.collection("points", "xy", T.vec2))["points"];
|
|
660
|
-
}), P.pair("height", T.number), P.pair("orientation", T.number), P.pair("leader_length", T.number), P.item("gr_text", parseGrText), P.object("format", {}, P.start("format"), P.pair("prefix", T.string), P.pair("suffix", T.string), P.pair("units", T.number), P.pair("units_format", T.number), P.pair("precision", T.number), P.pair("override_value", T.string), P.pair("suppress_zeroes", T.boolean)), P.object("style", {}, P.start("style"), P.pair("thickness", T.number), P.pair("arrow_length", T.number), P.pair("text_position_mode", T.number), P.pair("extension_height", T.number), P.pair("text_frame", T.number), P.pair("extension_offset", T.number), P.pair("keep_text_aligned", T.boolean)));
|
|
658
|
+
return parse_expr$1(expr, P$1.start("dimension"), P$1.atom("locked"), P$1.positional("type", T$1.string), P$1.pair("layer", T$1.string), P$1.pair("tstamp", T$1.string), P$1.pair("uuid", T$1.string), P$1.collection("pts", "pts", (obj, name, e) => {
|
|
659
|
+
return parse_expr$1(e, P$1.collection("points", "xy", T$1.vec2))["points"];
|
|
660
|
+
}), P$1.pair("height", T$1.number), P$1.pair("orientation", T$1.number), P$1.pair("leader_length", T$1.number), P$1.item("gr_text", parseGrText), P$1.object("format", {}, P$1.start("format"), P$1.pair("prefix", T$1.string), P$1.pair("suffix", T$1.string), P$1.pair("units", T$1.number), P$1.pair("units_format", T$1.number), P$1.pair("precision", T$1.number), P$1.pair("override_value", T$1.string), P$1.pair("suppress_zeroes", T$1.boolean)), P$1.object("style", {}, P$1.start("style"), P$1.pair("thickness", T$1.number), P$1.pair("arrow_length", T$1.number), P$1.pair("text_position_mode", T$1.number), P$1.pair("extension_height", T$1.number), P$1.pair("text_frame", T$1.number), P$1.pair("extension_offset", T$1.number), P$1.pair("keep_text_aligned", T$1.boolean)));
|
|
661
661
|
}
|
|
662
662
|
function parsePad(expr) {
|
|
663
|
-
return parse_expr(expr, P.start("pad"), P.positional("number", T.string), P.positional("type", T.string), P.positional("shape", T.string), P.atom("locked"), P.item("at", parseAt), P.vec2("size"), P.vec2("rect_delta"), P.list("layers", T.string), P.pair("remove_unused_layers", T.boolean), P.pair("keep_end_layers", T.boolean), P.pair("roundrect_rratio", T.number), P.pair("chamfer_ratio", T.number), P.object("chamfer", {}, P.start("chamfer"), P.atom("top_left"), P.atom("top_right"), P.atom("bottom_right"), P.atom("bottom_left")), P.pair("pinfunction", T.string), P.pair("pintype", T.string), P.pair("die_length", T.number), P.pair("solder_mask_margin", T.number), P.pair("solder_paste_margin", T.number), P.pair("solder_paste_margin_ratio", T.number), P.pair("clearance", T.number), P.pair("thermal_width", T.number), P.pair("thermal_gap", T.number), P.pair("thermal_bridge_angle", T.number), P.pair("zone_connect", T.number), P.object("drill", {}, P.start("drill"), P.atom("oval"), P.positional("diameter", T.number), P.positional("width", T.number), P.vec2("offset")), P.item("net", parseNetReference), P.object("options", {}, P.start("options"), P.pair("clearance", T.string), P.pair("anchor", T.string)), P.expr("primitives", (obj, name, expr2) => {
|
|
664
|
-
const parsed = parse_expr(expr2, P.start("primitives"), P.collection("items", "gr_line", T.item(parse_gr_Line)), P.collection("items", "gr_circle", T.item(parse_gr_Circle)), P.collection("items", "gr_arc", T.item(parse_gr_Arc)), P.collection("items", "gr_rect", T.item(parse_gr_Rect)), P.collection("items", "gr_poly", T.item(parse_gr_poly)));
|
|
663
|
+
return parse_expr$1(expr, P$1.start("pad"), P$1.positional("number", T$1.string), P$1.positional("type", T$1.string), P$1.positional("shape", T$1.string), P$1.atom("locked"), P$1.item("at", parseAt), P$1.vec2("size"), P$1.vec2("rect_delta"), P$1.list("layers", T$1.string), P$1.pair("remove_unused_layers", T$1.boolean), P$1.pair("keep_end_layers", T$1.boolean), P$1.pair("roundrect_rratio", T$1.number), P$1.pair("chamfer_ratio", T$1.number), P$1.object("chamfer", {}, P$1.start("chamfer"), P$1.atom("top_left"), P$1.atom("top_right"), P$1.atom("bottom_right"), P$1.atom("bottom_left")), P$1.pair("pinfunction", T$1.string), P$1.pair("pintype", T$1.string), P$1.pair("die_length", T$1.number), P$1.pair("solder_mask_margin", T$1.number), P$1.pair("solder_paste_margin", T$1.number), P$1.pair("solder_paste_margin_ratio", T$1.number), P$1.pair("clearance", T$1.number), P$1.pair("thermal_width", T$1.number), P$1.pair("thermal_gap", T$1.number), P$1.pair("thermal_bridge_angle", T$1.number), P$1.pair("zone_connect", T$1.number), P$1.object("drill", {}, P$1.start("drill"), P$1.atom("oval"), P$1.positional("diameter", T$1.number), P$1.positional("width", T$1.number), P$1.vec2("offset")), P$1.item("net", parseNetReference), P$1.object("options", {}, P$1.start("options"), P$1.pair("clearance", T$1.string), P$1.pair("anchor", T$1.string)), P$1.expr("primitives", (obj, name, expr2) => {
|
|
664
|
+
const parsed = parse_expr$1(expr2, P$1.start("primitives"), P$1.collection("items", "gr_line", T$1.item(parse_gr_Line)), P$1.collection("items", "gr_circle", T$1.item(parse_gr_Circle)), P$1.collection("items", "gr_arc", T$1.item(parse_gr_Arc)), P$1.collection("items", "gr_rect", T$1.item(parse_gr_Rect)), P$1.collection("items", "gr_poly", T$1.item(parse_gr_poly)));
|
|
665
665
|
return parsed == null ? void 0 : parsed["items"];
|
|
666
|
-
}), P.pair("tstamp", T.string), P.pair("uuid", T.string));
|
|
666
|
+
}), P$1.pair("tstamp", T$1.string), P$1.pair("uuid", T$1.string));
|
|
667
667
|
}
|
|
668
668
|
function parseModel(expr) {
|
|
669
|
-
return parse_expr(expr, P.start("model"), P.positional("filename", T.string), P.object("offset", {}, P.start("offset"), P.collection("xyz", "xyz", T.number)), P.object("scale", {}, P.start("scale"), P.collection("xyz", "xyz", T.number)), P.object("rotate", {}, P.start("rotate"), P.collection("xyz", "xyz", T.number)), P.atom("hide"), P.pair("opacity", T.number));
|
|
669
|
+
return parse_expr$1(expr, P$1.start("model"), P$1.positional("filename", T$1.string), P$1.object("offset", {}, P$1.start("offset"), P$1.collection("xyz", "xyz", T$1.number)), P$1.object("scale", {}, P$1.start("scale"), P$1.collection("xyz", "xyz", T$1.number)), P$1.object("rotate", {}, P$1.start("rotate"), P$1.collection("xyz", "xyz", T$1.number)), P$1.atom("hide"), P$1.pair("opacity", T$1.number));
|
|
670
670
|
}
|
|
671
671
|
function parsePropertyKicad8(expr) {
|
|
672
|
-
return parse_expr(expr, P.start("property"), P.positional("name", T.string), P.positional("value", T.string), P.item("at", parseAt), P.atom("unlocked"), P.object("layer", {}, P.start("layer"), P.positional("name", T.string), P.atom("knockout")), P.atom("hide"), P.pair("uuid", T.string), P.item("effects", parseEffects), P.item("render_cache", parseTextRenderCache));
|
|
672
|
+
return parse_expr$1(expr, P$1.start("property"), P$1.positional("name", T$1.string), P$1.positional("value", T$1.string), P$1.item("at", parseAt), P$1.atom("unlocked"), P$1.object("layer", {}, P$1.start("layer"), P$1.positional("name", T$1.string), P$1.atom("knockout")), P$1.atom("hide"), P$1.pair("uuid", T$1.string), P$1.item("effects", parseEffects), P$1.item("render_cache", parseTextRenderCache));
|
|
673
673
|
}
|
|
674
674
|
function parseZoneFill(expr) {
|
|
675
|
-
return parse_expr(expr, P.start("fill"), P.positional("fill", T.boolean), P.pair("mode", T.string), P.pair("thermal_gap", T.number), P.pair("thermal_bridge_width", T.number), P.object("smoothing", {}, P.start("smoothing"), P.positional("style", T.string), P.pair("radius", T.number)), P.pair("radius", T.number), P.pair("island_removal_mode", T.number), P.pair("island_area_min", T.number), P.pair("hatch_thickness", T.number), P.pair("hatch_gap", T.number), P.pair("hatch_orientation", T.number), P.pair("hatch_smoothing_level", T.number), P.pair("hatch_smoothing_value", T.number), P.pair("hatch_border_algorithm", T.string), P.pair("hatch_min_hole_area", T.number), P.pair("uuid", T.string));
|
|
675
|
+
return parse_expr$1(expr, P$1.start("fill"), P$1.positional("fill", T$1.boolean), P$1.pair("mode", T$1.string), P$1.pair("thermal_gap", T$1.number), P$1.pair("thermal_bridge_width", T$1.number), P$1.object("smoothing", {}, P$1.start("smoothing"), P$1.positional("style", T$1.string), P$1.pair("radius", T$1.number)), P$1.pair("radius", T$1.number), P$1.pair("island_removal_mode", T$1.number), P$1.pair("island_area_min", T$1.number), P$1.pair("hatch_thickness", T$1.number), P$1.pair("hatch_gap", T$1.number), P$1.pair("hatch_orientation", T$1.number), P$1.pair("hatch_smoothing_level", T$1.number), P$1.pair("hatch_smoothing_value", T$1.number), P$1.pair("hatch_border_algorithm", T$1.string), P$1.pair("hatch_min_hole_area", T$1.number), P$1.pair("uuid", T$1.string));
|
|
676
676
|
}
|
|
677
677
|
function parseZoneKeepout(expr) {
|
|
678
|
-
return parse_expr(expr, P.start("keepout"), P.pair("tracks", T.string), P.pair("vias", T.string), P.pair("pads", T.string), P.pair("copperpour", T.string), P.pair("footprints", T.string), P.pair("uuid", T.string));
|
|
678
|
+
return parse_expr$1(expr, P$1.start("keepout"), P$1.pair("tracks", T$1.string), P$1.pair("vias", T$1.string), P$1.pair("pads", T$1.string), P$1.pair("copperpour", T$1.string), P$1.pair("footprints", T$1.string), P$1.pair("uuid", T$1.string));
|
|
679
679
|
}
|
|
680
680
|
function parseZone(expr) {
|
|
681
|
-
return parse_expr(expr, P.start("zone"), P.atom("locked"), P.pair("net", T.number), P.pair("net_name", T.string), P.pair("name", T.string), P.pair("layer", T.string), P.list("layers", T.string), P.object("hatch", {}, P.start("hatch"), P.positional("style", T.string), P.positional("pitch", T.number)), P.pair("priority", T.number), P.object("connect_pads", {}, P.start("connect_pads"), P.positional("type", T.string), P.pair("clearance", T.number)), P.pair("min_thickness", T.number), P.pair("filled_areas_thickness", T.boolean), P.item("keepout", parseZoneKeepout), P.item("fill", parseZoneFill), P.collection("polygons", "polygon", T.item(parse_polygon)), P.collection("filled_polygons", "filled_polygon", T.item(parse_filled_polygon)), P.pair("tstamp", T.string), P.pair("uuid", T.string));
|
|
681
|
+
return parse_expr$1(expr, P$1.start("zone"), P$1.atom("locked"), P$1.pair("net", T$1.number), P$1.pair("net_name", T$1.string), P$1.pair("name", T$1.string), P$1.pair("layer", T$1.string), P$1.list("layers", T$1.string), P$1.object("hatch", {}, P$1.start("hatch"), P$1.positional("style", T$1.string), P$1.positional("pitch", T$1.number)), P$1.pair("priority", T$1.number), P$1.object("connect_pads", {}, P$1.start("connect_pads"), P$1.positional("type", T$1.string), P$1.pair("clearance", T$1.number)), P$1.pair("min_thickness", T$1.number), P$1.pair("filled_areas_thickness", T$1.boolean), P$1.item("keepout", parseZoneKeepout), P$1.item("fill", parseZoneFill), P$1.collection("polygons", "polygon", T$1.item(parse_polygon)), P$1.collection("filled_polygons", "filled_polygon", T$1.item(parse_filled_polygon)), P$1.pair("tstamp", T$1.string), P$1.pair("uuid", T$1.string));
|
|
682
682
|
}
|
|
683
683
|
function parseFootprint(expr) {
|
|
684
|
-
return parse_expr(expr, P.start("footprint"), P.positional("library_link", T.string), P.pair("version", T.number), P.pair("embedded_fonts", T.boolean), P.pair("generator", T.string), P.atom("locked"), P.atom("placed"), P.pair("layer", T.string), P.pair("tedit", T.string), P.pair("tstamp", T.string), P.item("at", parseAt), P.pair("uuid", T.string), P.pair("descr", T.string), P.pair("tags", T.string), P.pair("sheetname", T.string), P.pair("sheetfile", T.string), P.pair("path", T.string), P.pair("autoplace_cost90", T.number), P.pair("autoplace_cost180", T.number), P.pair("solder_mask_margin", T.number), P.pair("solder_paste_margin", T.number), P.pair("solder_paste_ratio", T.number), P.pair("clearance", T.number), P.pair("zone_connect", T.number), P.pair("thermal_width", T.number), P.pair("thermal_gap", T.number), P.object("attr", {}, P.start("attr"), P.atom("through_hole"), P.atom("smd"), P.atom("virtual"), P.atom("board_only"), P.atom("exclude_from_pos_files"), P.atom("exclude_from_bom"), P.atom("allow_solder_mask_bridges"), P.atom("allow_missing_courtyard")), P.dict("properties", "property", T.string), P.collection("properties_kicad_8", "property", T.item(parsePropertyKicad8)), P.collection("drawings", "fp_line", T.item(parse_fp_Line)), P.collection("drawings", "fp_circle", T.item(parse_fp_Circle)), P.collection("drawings", "fp_arc", T.item(parse_fp_Arc)), P.collection("drawings", "fp_poly", T.item(parse_fp_poly)), P.collection("drawings", "fp_rect", T.item(parse_fp_Rect)), P.collection("fp_texts", "fp_text", T.item(parseFpText)), P.collection("zones", "zone", T.item(parseZone)), P.collection("models", "model", T.item(parseModel)), P.collection("pads", "pad", T.item(parsePad)));
|
|
684
|
+
return parse_expr$1(expr, P$1.start("footprint"), P$1.positional("library_link", T$1.string), P$1.pair("version", T$1.number), P$1.pair("embedded_fonts", T$1.boolean), P$1.pair("generator", T$1.string), P$1.atom("locked"), P$1.atom("placed"), P$1.pair("layer", T$1.string), P$1.pair("tedit", T$1.string), P$1.pair("tstamp", T$1.string), P$1.item("at", parseAt), P$1.pair("uuid", T$1.string), P$1.pair("descr", T$1.string), P$1.pair("tags", T$1.string), P$1.pair("sheetname", T$1.string), P$1.pair("sheetfile", T$1.string), P$1.pair("path", T$1.string), P$1.pair("autoplace_cost90", T$1.number), P$1.pair("autoplace_cost180", T$1.number), P$1.pair("solder_mask_margin", T$1.number), P$1.pair("solder_paste_margin", T$1.number), P$1.pair("solder_paste_ratio", T$1.number), P$1.pair("clearance", T$1.number), P$1.pair("zone_connect", T$1.number), P$1.pair("thermal_width", T$1.number), P$1.pair("thermal_gap", T$1.number), P$1.object("attr", {}, P$1.start("attr"), P$1.atom("through_hole"), P$1.atom("smd"), P$1.atom("virtual"), P$1.atom("board_only"), P$1.atom("exclude_from_pos_files"), P$1.atom("exclude_from_bom"), P$1.atom("allow_solder_mask_bridges"), P$1.atom("allow_missing_courtyard")), P$1.dict("properties", "property", T$1.string), P$1.collection("properties_kicad_8", "property", T$1.item(parsePropertyKicad8)), P$1.collection("drawings", "fp_line", T$1.item(parse_fp_Line)), P$1.collection("drawings", "fp_circle", T$1.item(parse_fp_Circle)), P$1.collection("drawings", "fp_arc", T$1.item(parse_fp_Arc)), P$1.collection("drawings", "fp_poly", T$1.item(parse_fp_poly)), P$1.collection("drawings", "fp_rect", T$1.item(parse_fp_Rect)), P$1.collection("fp_texts", "fp_text", T$1.item(parseFpText)), P$1.collection("zones", "zone", T$1.item(parseZone)), P$1.collection("models", "model", T$1.item(parseModel)), P$1.collection("pads", "pad", T$1.item(parsePad)));
|
|
685
685
|
}
|
|
686
686
|
function parseLineSegment(expr) {
|
|
687
|
-
return parse_expr(expr, P.start("segment"), P.vec2("start"), P.vec2("end"), P.pair("width", T.number), P.pair("layer", T.string), P.pair("net", T.number), P.atom("locked"), P.pair("tstamp", T.string), P.pair("uuid", T.string));
|
|
687
|
+
return parse_expr$1(expr, P$1.start("segment"), P$1.vec2("start"), P$1.vec2("end"), P$1.pair("width", T$1.number), P$1.pair("layer", T$1.string), P$1.pair("net", T$1.number), P$1.atom("locked"), P$1.pair("tstamp", T$1.string), P$1.pair("uuid", T$1.string));
|
|
688
688
|
}
|
|
689
689
|
function parseArcSegment(expr) {
|
|
690
|
-
return parse_expr(expr, P.start("arc"), P.vec2("start"), P.vec2("mid"), P.vec2("end"), P.pair("width", T.number), P.pair("layer", T.string), P.pair("net", T.number), P.atom("locked"), P.pair("tstamp", T.string), P.pair("uuid", T.string));
|
|
690
|
+
return parse_expr$1(expr, P$1.start("arc"), P$1.vec2("start"), P$1.vec2("mid"), P$1.vec2("end"), P$1.pair("width", T$1.number), P$1.pair("layer", T$1.string), P$1.pair("net", T$1.number), P$1.atom("locked"), P$1.pair("tstamp", T$1.string), P$1.pair("uuid", T$1.string));
|
|
691
691
|
}
|
|
692
692
|
function parseVia(expr) {
|
|
693
|
-
return parse_expr(expr, P.start("via"), P.item("at", parseAt), P.pair("size", T.number), P.pair("drill", T.number), P.list("layers", T.string), P.atom("remove_unused_layers"), P.atom("keep_end_layers"), P.atom("locked"), P.atom("free"), P.pair("net", T.number), P.pair("tstamp", T.string), P.pair("uuid", T.string), P.atom("type", [
|
|
693
|
+
return parse_expr$1(expr, P$1.start("via"), P$1.item("at", parseAt), P$1.pair("size", T$1.number), P$1.pair("drill", T$1.number), P$1.list("layers", T$1.string), P$1.atom("remove_unused_layers"), P$1.atom("keep_end_layers"), P$1.atom("locked"), P$1.atom("free"), P$1.pair("net", T$1.number), P$1.pair("tstamp", T$1.string), P$1.pair("uuid", T$1.string), P$1.atom("type", [
|
|
694
694
|
"blind",
|
|
695
695
|
"micro",
|
|
696
696
|
"through-hole"
|
|
697
697
|
]));
|
|
698
698
|
}
|
|
699
699
|
function parseGroup(expr) {
|
|
700
|
-
return parse_expr(expr, P.start("group"), P.positional("name", T.string), P.pair("id", T.string), P.atom("locked"), P.collection("members", "members", T.string));
|
|
700
|
+
return parse_expr$1(expr, P$1.start("group"), P$1.positional("name", T$1.string), P$1.pair("id", T$1.string), P$1.atom("locked"), P$1.collection("members", "members", T$1.string));
|
|
701
701
|
}
|
|
702
702
|
var BoardParser = class {
|
|
703
703
|
parse(text) {
|
|
704
|
-
const expr = listify(text);
|
|
705
|
-
return parse_expr(expr.length === 1 && Array.isArray(expr[0]) ? expr[0] : expr, P.start("kicad_pcb"), P.pair("version", T.number), P.pair("generator", T.string), P.pair("embedded_fonts", T.boolean), P.pair("generator_version", T.string), P.object("general", {}, P.start("general"), P.pair("thickness", T.number), P.atom("legacy_teardrops")), P.item("paper", parsePaper), P.item("title_block", parseTitleBlock), P.item("setup", parseSetup), P.dict("properties", "property", (obj, name, e) => {
|
|
704
|
+
const expr = listify$1(text);
|
|
705
|
+
return parse_expr$1(expr.length === 1 && Array.isArray(expr[0]) ? expr[0] : expr, P$1.start("kicad_pcb"), P$1.pair("version", T$1.number), P$1.pair("generator", T$1.string), P$1.pair("embedded_fonts", T$1.boolean), P$1.pair("generator_version", T$1.string), P$1.object("general", {}, P$1.start("general"), P$1.pair("thickness", T$1.number), P$1.atom("legacy_teardrops")), P$1.item("paper", parsePaper), P$1.item("title_block", parseTitleBlock), P$1.item("setup", parseSetup), P$1.dict("properties", "property", (obj, name, e) => {
|
|
706
706
|
const el = e;
|
|
707
707
|
return {
|
|
708
708
|
name: el[1],
|
|
709
709
|
value: el[2]
|
|
710
710
|
};
|
|
711
|
-
}), P.list("layers", T.item(parseLayer)), P.collection("nets", "net", T.item(parseNet)), P.collection("footprints", "footprint", T.item(parseFootprint)), P.collection("footprints", "module", T.item(parseFootprint)), P.collection("zones", "zone", T.item(parseZone)), P.collection("segments", "segment", T.item(parseLineSegment)), P.collection("segments", "arc", T.item(parseArcSegment)), P.collection("vias", "via", T.item(parseVia)), P.collection("drawings", "gr_line", T.item(parse_gr_Line)), P.collection("drawings", "gr_circle", T.item(parse_gr_Circle)), P.collection("drawings", "gr_arc", T.item(parse_gr_Arc)), P.collection("drawings", "gr_poly", T.item(parse_gr_poly)), P.collection("drawings", "gr_rect", T.item(parse_gr_Rect)), P.collection("drawings", "gr_text", T.item(parseGrText)), P.collection("drawings", "dimension", T.item(parseDimension)), P.collection("groups", "group", T.item(parseGroup)));
|
|
711
|
+
}), P$1.list("layers", T$1.item(parseLayer)), P$1.collection("nets", "net", T$1.item(parseNet)), P$1.collection("footprints", "footprint", T$1.item(parseFootprint)), P$1.collection("footprints", "module", T$1.item(parseFootprint)), P$1.collection("zones", "zone", T$1.item(parseZone)), P$1.collection("segments", "segment", T$1.item(parseLineSegment)), P$1.collection("segments", "arc", T$1.item(parseArcSegment)), P$1.collection("vias", "via", T$1.item(parseVia)), P$1.collection("drawings", "gr_line", T$1.item(parse_gr_Line)), P$1.collection("drawings", "gr_circle", T$1.item(parse_gr_Circle)), P$1.collection("drawings", "gr_arc", T$1.item(parse_gr_Arc)), P$1.collection("drawings", "gr_poly", T$1.item(parse_gr_poly)), P$1.collection("drawings", "gr_rect", T$1.item(parse_gr_Rect)), P$1.collection("drawings", "gr_text", T$1.item(parseGrText)), P$1.collection("drawings", "dimension", T$1.item(parseDimension)), P$1.collection("groups", "group", T$1.item(parseGroup)));
|
|
712
712
|
}
|
|
713
713
|
};
|
|
714
714
|
function escapeString(str) {
|
|
@@ -1564,23 +1564,23 @@ ${indent})`;
|
|
|
1564
1564
|
return result;
|
|
1565
1565
|
}
|
|
1566
1566
|
function parseFill(expr) {
|
|
1567
|
-
const parsed = parse_expr(expr, P.start("fill"), P.color(), P.pair("type", T.string));
|
|
1567
|
+
const parsed = parse_expr$1(expr, P$1.start("fill"), P$1.color(), P$1.pair("type", T$1.string));
|
|
1568
1568
|
return {
|
|
1569
1569
|
type: parsed.type || "none",
|
|
1570
1570
|
color: parsed.color
|
|
1571
1571
|
};
|
|
1572
1572
|
}
|
|
1573
1573
|
function parseWire(expr) {
|
|
1574
|
-
return parse_expr(expr, P.start("wire"), P.list("pts", T.vec2), P.item("stroke", parseStroke), P.pair("uuid", T.string));
|
|
1574
|
+
return parse_expr$1(expr, P$1.start("wire"), P$1.list("pts", T$1.vec2), P$1.item("stroke", parseStroke), P$1.pair("uuid", T$1.string));
|
|
1575
1575
|
}
|
|
1576
1576
|
function parseBus(expr) {
|
|
1577
|
-
return parse_expr(expr, P.start("bus"), P.list("pts", T.vec2), P.item("stroke", parseStroke), P.pair("uuid", T.string));
|
|
1577
|
+
return parse_expr$1(expr, P$1.start("bus"), P$1.list("pts", T$1.vec2), P$1.item("stroke", parseStroke), P$1.pair("uuid", T$1.string));
|
|
1578
1578
|
}
|
|
1579
1579
|
function parseBusEntry(expr) {
|
|
1580
|
-
return parse_expr(expr, P.start("bus_entry"), P.item("at", parseAt), P.vec2("size"), P.item("stroke", parseStroke), P.pair("uuid", T.string));
|
|
1580
|
+
return parse_expr$1(expr, P$1.start("bus_entry"), P$1.item("at", parseAt), P$1.vec2("size"), P$1.item("stroke", parseStroke), P$1.pair("uuid", T$1.string));
|
|
1581
1581
|
}
|
|
1582
1582
|
function parseBusAlias(expr) {
|
|
1583
|
-
return parse_expr(expr, P.start("bus_alias"), P.positional("name", T.string), P.item("members", (e) => {
|
|
1583
|
+
return parse_expr$1(expr, P$1.start("bus_alias"), P$1.positional("name", T$1.string), P$1.item("members", (e) => {
|
|
1584
1584
|
if (Array.isArray(e) && e.length > 1) return e.slice(1).map((member) => {
|
|
1585
1585
|
if (typeof member === "string") return member;
|
|
1586
1586
|
return "";
|
|
@@ -1589,17 +1589,17 @@ ${indent})`;
|
|
|
1589
1589
|
}));
|
|
1590
1590
|
}
|
|
1591
1591
|
function parseJunction(expr) {
|
|
1592
|
-
return parse_expr(expr, P.start("junction"), P.item("at", parseAt), P.pair("diameter", T.number), P.color(), P.pair("uuid", T.string));
|
|
1592
|
+
return parse_expr$1(expr, P$1.start("junction"), P$1.item("at", parseAt), P$1.pair("diameter", T$1.number), P$1.color(), P$1.pair("uuid", T$1.string));
|
|
1593
1593
|
}
|
|
1594
1594
|
function parseNoConnect(expr) {
|
|
1595
|
-
return parse_expr(expr, P.start("no_connect"), P.item("at", parseAt), P.pair("uuid", T.string));
|
|
1595
|
+
return parse_expr$1(expr, P$1.start("no_connect"), P$1.item("at", parseAt), P$1.pair("uuid", T$1.string));
|
|
1596
1596
|
}
|
|
1597
1597
|
function parsePolyline(expr) {
|
|
1598
|
-
return __spreadProps(__spreadValues({}, parse_expr(expr, P.start("polyline"), P.list("pts", T.vec2), P.item("stroke", parseStroke), P.item("fill", parseFill), P.pair("uuid", T.string))), { type: "polyline" });
|
|
1598
|
+
return __spreadProps(__spreadValues$1({}, parse_expr$1(expr, P$1.start("polyline"), P$1.list("pts", T$1.vec2), P$1.item("stroke", parseStroke), P$1.item("fill", parseFill), P$1.pair("uuid", T$1.string))), { type: "polyline" });
|
|
1599
1599
|
}
|
|
1600
1600
|
function parseCenterOrStartOrEnd(expr, name) {
|
|
1601
1601
|
if (Array.isArray(expr)) {
|
|
1602
|
-
if (expr.length >= 2 && Array.isArray(expr[1]) && expr[1][0] === "xy") return parse_expr(expr, P.start(name), P.vec2("xy"))["xy"];
|
|
1602
|
+
if (expr.length >= 2 && Array.isArray(expr[1]) && expr[1][0] === "xy") return parse_expr$1(expr, P$1.start(name), P$1.vec2("xy"))["xy"];
|
|
1603
1603
|
else if (expr.length >= 3 && typeof expr[1] === "number" && typeof expr[2] === "number") return {
|
|
1604
1604
|
x: expr[1],
|
|
1605
1605
|
y: expr[2]
|
|
@@ -1611,22 +1611,22 @@ ${indent})`;
|
|
|
1611
1611
|
};
|
|
1612
1612
|
}
|
|
1613
1613
|
function parseRectangle(expr) {
|
|
1614
|
-
return __spreadProps(__spreadValues({}, parse_expr(expr, P.start("rectangle"), P.item("start", (e) => parseCenterOrStartOrEnd(e, "start")), P.item("end", (e) => parseCenterOrStartOrEnd(e, "end")), P.item("stroke", parseStroke), P.item("fill", parseFill), P.pair("uuid", T.string))), { type: "rectangle" });
|
|
1614
|
+
return __spreadProps(__spreadValues$1({}, parse_expr$1(expr, P$1.start("rectangle"), P$1.item("start", (e) => parseCenterOrStartOrEnd(e, "start")), P$1.item("end", (e) => parseCenterOrStartOrEnd(e, "end")), P$1.item("stroke", parseStroke), P$1.item("fill", parseFill), P$1.pair("uuid", T$1.string))), { type: "rectangle" });
|
|
1615
1615
|
}
|
|
1616
1616
|
function parseCircle2(expr) {
|
|
1617
|
-
return __spreadProps(__spreadValues({}, parse_expr(expr, P.start("circle"), P.item("center", (e) => parseCenterOrStartOrEnd(e, "center")), P.pair("radius", T.number), P.item("stroke", parseStroke), P.item("fill", parseFill), P.pair("uuid", T.string))), { type: "circle" });
|
|
1617
|
+
return __spreadProps(__spreadValues$1({}, parse_expr$1(expr, P$1.start("circle"), P$1.item("center", (e) => parseCenterOrStartOrEnd(e, "center")), P$1.pair("radius", T$1.number), P$1.item("stroke", parseStroke), P$1.item("fill", parseFill), P$1.pair("uuid", T$1.string))), { type: "circle" });
|
|
1618
1618
|
}
|
|
1619
1619
|
function parseArc2(expr) {
|
|
1620
|
-
return __spreadProps(__spreadValues({}, parse_expr(expr, P.start("arc"), P.item("start", (e) => parseCenterOrStartOrEnd(e, "start")), P.item("mid", (e) => parseCenterOrStartOrEnd(e, "mid")), P.item("end", (e) => parseCenterOrStartOrEnd(e, "end")), P.object("radius", {}, P.start("radius"), P.item("at", (e) => parseCenterOrStartOrEnd(e, "at")), P.pair("length"), P.item("angles", (e) => parseCenterOrStartOrEnd(e, "angles"))), P.item("stroke", parseStroke), P.item("fill", parseFill), P.pair("uuid", T.string))), { type: "arc" });
|
|
1620
|
+
return __spreadProps(__spreadValues$1({}, parse_expr$1(expr, P$1.start("arc"), P$1.item("start", (e) => parseCenterOrStartOrEnd(e, "start")), P$1.item("mid", (e) => parseCenterOrStartOrEnd(e, "mid")), P$1.item("end", (e) => parseCenterOrStartOrEnd(e, "end")), P$1.object("radius", {}, P$1.start("radius"), P$1.item("at", (e) => parseCenterOrStartOrEnd(e, "at")), P$1.pair("length"), P$1.item("angles", (e) => parseCenterOrStartOrEnd(e, "angles"))), P$1.item("stroke", parseStroke), P$1.item("fill", parseFill), P$1.pair("uuid", T$1.string))), { type: "arc" });
|
|
1621
1621
|
}
|
|
1622
1622
|
function parseBezier(expr) {
|
|
1623
|
-
return __spreadProps(__spreadValues({}, parse_expr(expr, P.start("bezier"), P.list("pts", T.vec2), P.item("stroke", parseStroke), P.item("fill", parseFill), P.pair("uuid", T.string))), { type: "bezier" });
|
|
1623
|
+
return __spreadProps(__spreadValues$1({}, parse_expr$1(expr, P$1.start("bezier"), P$1.list("pts", T$1.vec2), P$1.item("stroke", parseStroke), P$1.item("fill", parseFill), P$1.pair("uuid", T$1.string))), { type: "bezier" });
|
|
1624
1624
|
}
|
|
1625
1625
|
function parseText(expr) {
|
|
1626
|
-
return __spreadProps(__spreadValues({}, parse_expr(expr, P.start("text"), P.positional("text", T.string), P.item("at", parseAt), P.item("effects", parseEffects), P.pair("exclude_from_sim", T.boolean), P.pair("uuid", T.string))), { type: "text" });
|
|
1626
|
+
return __spreadProps(__spreadValues$1({}, parse_expr$1(expr, P$1.start("text"), P$1.positional("text", T$1.string), P$1.item("at", parseAt), P$1.item("effects", parseEffects), P$1.pair("exclude_from_sim", T$1.boolean), P$1.pair("uuid", T$1.string))), { type: "text" });
|
|
1627
1627
|
}
|
|
1628
1628
|
function parseTextBox(expr) {
|
|
1629
|
-
return __spreadProps(__spreadValues({}, parse_expr(expr, P.start("text_box"), P.positional("text", T.string), P.item("at", parseAt), P.vec2("size"), P.item("effects", parseEffects), P.item("stroke", parseStroke), P.item("fill", parseFill), P.pair("exclude_from_sim", T.boolean), P.vec4("margins"), P.pair("uuid", T.string))), { type: "text_box" });
|
|
1629
|
+
return __spreadProps(__spreadValues$1({}, parse_expr$1(expr, P$1.start("text_box"), P$1.positional("text", T$1.string), P$1.item("at", parseAt), P$1.vec2("size"), P$1.item("effects", parseEffects), P$1.item("stroke", parseStroke), P$1.item("fill", parseFill), P$1.pair("exclude_from_sim", T$1.boolean), P$1.vec4("margins"), P$1.pair("uuid", T$1.string))), { type: "text_box" });
|
|
1630
1630
|
}
|
|
1631
1631
|
function parseImage(expr) {
|
|
1632
1632
|
let data = "";
|
|
@@ -1634,15 +1634,15 @@ ${indent})`;
|
|
|
1634
1634
|
data = it.slice(1).join("");
|
|
1635
1635
|
break;
|
|
1636
1636
|
}
|
|
1637
|
-
const parsed = parse_expr(expr, P.start("image"), P.item("at", parseAt), P.pair("scale", T.number), P.pair("uuid", T.string));
|
|
1638
|
-
return __spreadProps(__spreadValues({}, parsed), {
|
|
1637
|
+
const parsed = parse_expr$1(expr, P$1.start("image"), P$1.item("at", parseAt), P$1.pair("scale", T$1.number), P$1.pair("uuid", T$1.string));
|
|
1638
|
+
return __spreadProps(__spreadValues$1({}, parsed), {
|
|
1639
1639
|
data,
|
|
1640
1640
|
ppi: null,
|
|
1641
1641
|
scale: typeof parsed["scale"] === "number" ? parsed["scale"] : 1
|
|
1642
1642
|
});
|
|
1643
1643
|
}
|
|
1644
1644
|
function parseTableCell(expr) {
|
|
1645
|
-
const parsed = parse_expr(expr, P.start("table_cell"), P.positional("text", T.string), P.item("at", parseAt), P.vec2("size"), P.vec4("margins"), P.item("effects", parseEffects), P.item("fill", parseFill), P.item("stroke", parseStroke), P.pair("exclude_from_sim", T.boolean), P.pair("uuid", T.string), P.expr("span", (obj, name, e) => {
|
|
1645
|
+
const parsed = parse_expr$1(expr, P$1.start("table_cell"), P$1.positional("text", T$1.string), P$1.item("at", parseAt), P$1.vec2("size"), P$1.vec4("margins"), P$1.item("effects", parseEffects), P$1.item("fill", parseFill), P$1.item("stroke", parseStroke), P$1.pair("exclude_from_sim", T$1.boolean), P$1.pair("uuid", T$1.string), P$1.expr("span", (obj, name, e) => {
|
|
1646
1646
|
if (Array.isArray(e) && e[0] === "span") return {
|
|
1647
1647
|
rows: e[1],
|
|
1648
1648
|
cols: e[2]
|
|
@@ -1662,8 +1662,8 @@ ${indent})`;
|
|
|
1662
1662
|
};
|
|
1663
1663
|
}
|
|
1664
1664
|
function parseTable(expr) {
|
|
1665
|
-
const parsed = parse_expr(expr, P.start("table"), P.pair("column_count", T.number), P.object("border", {}, P.start("border"), P.pair("external", T.boolean), P.pair("header", T.boolean), P.item("stroke", parseStroke)), P.object("separators", {}, P.start("separators"), P.pair("rows", T.boolean), P.pair("cols", T.boolean), P.item("stroke", parseStroke)), P.list("column_widths", T.number), P.list("row_heights", T.number), P.pair("uuid", T.string), P.item("cells", (e) => {
|
|
1666
|
-
return parse_expr(e, P.start("cells"), P.collection("items", "table_cell", T.item(parseTableCell))).items || [];
|
|
1665
|
+
const parsed = parse_expr$1(expr, P$1.start("table"), P$1.pair("column_count", T$1.number), P$1.object("border", {}, P$1.start("border"), P$1.pair("external", T$1.boolean), P$1.pair("header", T$1.boolean), P$1.item("stroke", parseStroke)), P$1.object("separators", {}, P$1.start("separators"), P$1.pair("rows", T$1.boolean), P$1.pair("cols", T$1.boolean), P$1.item("stroke", parseStroke)), P$1.list("column_widths", T$1.number), P$1.list("row_heights", T$1.number), P$1.pair("uuid", T$1.string), P$1.item("cells", (e) => {
|
|
1666
|
+
return parse_expr$1(e, P$1.start("cells"), P$1.collection("items", "table_cell", T$1.item(parseTableCell))).items || [];
|
|
1667
1667
|
}));
|
|
1668
1668
|
return {
|
|
1669
1669
|
column_count: parsed.column_count,
|
|
@@ -1676,10 +1676,10 @@ ${indent})`;
|
|
|
1676
1676
|
};
|
|
1677
1677
|
}
|
|
1678
1678
|
function parseNetLabel(expr) {
|
|
1679
|
-
return parse_expr(expr, P.start("label"), P.positional("text", T.string), P.item("at", parseAt), P.item("effects", parseEffects), P.atom("fields_autoplaced"), P.pair("uuid", T.string));
|
|
1679
|
+
return parse_expr$1(expr, P$1.start("label"), P$1.positional("text", T$1.string), P$1.item("at", parseAt), P$1.item("effects", parseEffects), P$1.atom("fields_autoplaced"), P$1.pair("uuid", T$1.string));
|
|
1680
1680
|
}
|
|
1681
1681
|
function parseProperty(expr) {
|
|
1682
|
-
const parsed = parse_expr(expr, P.start("property"), P.positional("name", T.string), P.positional("text", T.string), P.pair("id", T.number), P.item("at", parseAt), P.item("effects", parseEffects), P.atom("show_name"), P.atom("do_not_autoplace"), P.atom("hide"));
|
|
1682
|
+
const parsed = parse_expr$1(expr, P$1.start("property"), P$1.positional("name", T$1.string), P$1.positional("text", T$1.string), P$1.pair("id", T$1.number), P$1.item("at", parseAt), P$1.item("effects", parseEffects), P$1.atom("show_name"), P$1.atom("do_not_autoplace"), P$1.atom("hide"));
|
|
1683
1683
|
return {
|
|
1684
1684
|
name: parsed.name,
|
|
1685
1685
|
text: parsed.text,
|
|
@@ -1692,31 +1692,31 @@ ${indent})`;
|
|
|
1692
1692
|
};
|
|
1693
1693
|
}
|
|
1694
1694
|
function parseGlobalLabel(expr) {
|
|
1695
|
-
return parse_expr(expr, P.start("global_label"), P.positional("text", T.string), P.item("at", parseAt), P.item("effects", parseEffects), P.atom("fields_autoplaced"), P.pair("uuid", T.string), P.pair("shape", T.string), P.collection("properties", "property", T.item(parseProperty)));
|
|
1695
|
+
return parse_expr$1(expr, P$1.start("global_label"), P$1.positional("text", T$1.string), P$1.item("at", parseAt), P$1.item("effects", parseEffects), P$1.atom("fields_autoplaced"), P$1.pair("uuid", T$1.string), P$1.pair("shape", T$1.string), P$1.collection("properties", "property", T$1.item(parseProperty)));
|
|
1696
1696
|
}
|
|
1697
1697
|
function parseHierarchicalLabel(expr) {
|
|
1698
|
-
return parse_expr(expr, P.start("hierarchical_label"), P.positional("text", T.string), P.item("at", parseAt), P.item("effects", parseEffects), P.atom("fields_autoplaced"), P.pair("uuid", T.string), P.pair("shape", T.string));
|
|
1698
|
+
return parse_expr$1(expr, P$1.start("hierarchical_label"), P$1.positional("text", T$1.string), P$1.item("at", parseAt), P$1.item("effects", parseEffects), P$1.atom("fields_autoplaced"), P$1.pair("uuid", T$1.string), P$1.pair("shape", T$1.string));
|
|
1699
1699
|
}
|
|
1700
1700
|
function parsePinAlternate(expr) {
|
|
1701
|
-
return parse_expr(expr, P.start("alternate"), P.positional("name", T.string), P.positional("type", T.string), P.positional("shape", T.string));
|
|
1701
|
+
return parse_expr$1(expr, P$1.start("alternate"), P$1.positional("name", T$1.string), P$1.positional("type", T$1.string), P$1.positional("shape", T$1.string));
|
|
1702
1702
|
}
|
|
1703
1703
|
function parsePin(expr) {
|
|
1704
|
-
return parse_expr(expr, P.start("pin"), P.positional("type", T.string), P.positional("shape", T.string), P.atom("hide"), P.item("at", parseAt), P.pair("length", T.number), P.object("name", {}, P.start("name"), P.positional("text", T.string), P.item("effects", parseEffects)), P.object("number", {}, P.start("number"), P.positional("text", T.string), P.item("effects", parseEffects)), P.collection("alternates", "alternate", T.item(parsePinAlternate)));
|
|
1704
|
+
return parse_expr$1(expr, P$1.start("pin"), P$1.positional("type", T$1.string), P$1.positional("shape", T$1.string), P$1.atom("hide"), P$1.item("at", parseAt), P$1.pair("length", T$1.number), P$1.object("name", {}, P$1.start("name"), P$1.positional("text", T$1.string), P$1.item("effects", parseEffects)), P$1.object("number", {}, P$1.start("number"), P$1.positional("text", T$1.string), P$1.item("effects", parseEffects)), P$1.collection("alternates", "alternate", T$1.item(parsePinAlternate)));
|
|
1705
1705
|
}
|
|
1706
1706
|
function parsePinInstance(expr) {
|
|
1707
|
-
return parse_expr(expr, P.start("pin"), P.positional("number", T.string), P.pair("uuid", T.string), P.pair("alternate", T.string));
|
|
1707
|
+
return parse_expr$1(expr, P$1.start("pin"), P$1.positional("number", T$1.string), P$1.pair("uuid", T$1.string), P$1.pair("alternate", T$1.string));
|
|
1708
1708
|
}
|
|
1709
1709
|
function parseLibSymbol(expr) {
|
|
1710
|
-
return parse_expr(expr, P.start("symbol"), P.positional("name", T.string), P.atom("power"), P.object("pin_numbers", {}, P.start("pin_numbers"), P.atom("hide")), P.object("pin_names", {}, P.start("pin_names"), P.pair("offset", T.number), P.atom("hide")), P.pair("exclude_from_sim", T.boolean), P.pair("in_bom", T.boolean), P.pair("embedded_fonts", T.boolean), P.pair("embedded_files", T.string), P.pair("on_board", T.boolean), P.collection("properties", "property", T.item(parseProperty)), P.collection("pins", "pin", T.item(parsePin)), P.collection("children", "symbol", T.item(parseLibSymbol)), P.collection("drawings", "arc", T.item(parseArc2)), P.collection("drawings", "bezier", T.item(parseBezier)), P.collection("drawings", "circle", T.item(parseCircle2)), P.collection("drawings", "polyline", T.item(parsePolyline)), P.collection("drawings", "rectangle", T.item(parseRectangle)), P.collection("drawings", "text", T.item(parseText)), P.collection("drawings", "textbox", T.item(parseTextBox)));
|
|
1710
|
+
return parse_expr$1(expr, P$1.start("symbol"), P$1.positional("name", T$1.string), P$1.atom("power"), P$1.object("pin_numbers", {}, P$1.start("pin_numbers"), P$1.atom("hide")), P$1.object("pin_names", {}, P$1.start("pin_names"), P$1.pair("offset", T$1.number), P$1.atom("hide")), P$1.pair("exclude_from_sim", T$1.boolean), P$1.pair("in_bom", T$1.boolean), P$1.pair("embedded_fonts", T$1.boolean), P$1.pair("embedded_files", T$1.string), P$1.pair("on_board", T$1.boolean), P$1.collection("properties", "property", T$1.item(parseProperty)), P$1.collection("pins", "pin", T$1.item(parsePin)), P$1.collection("children", "symbol", T$1.item(parseLibSymbol)), P$1.collection("drawings", "arc", T$1.item(parseArc2)), P$1.collection("drawings", "bezier", T$1.item(parseBezier)), P$1.collection("drawings", "circle", T$1.item(parseCircle2)), P$1.collection("drawings", "polyline", T$1.item(parsePolyline)), P$1.collection("drawings", "rectangle", T$1.item(parseRectangle)), P$1.collection("drawings", "text", T$1.item(parseText)), P$1.collection("drawings", "textbox", T$1.item(parseTextBox)));
|
|
1711
1711
|
}
|
|
1712
1712
|
function parseSchematicSymbol(expr) {
|
|
1713
|
-
return parse_expr(expr, P.start("symbol"), P.pair("lib_name", T.string), P.pair("lib_id", T.string), P.item("at", parseAt), P.pair("mirror", T.string), P.pair("exclude_from_sim", T.boolean), P.pair("unit", T.number), P.pair("convert", T.number), P.pair("in_bom", T.boolean), P.pair("on_board", T.boolean), P.pair("dnp", T.boolean), P.atom("fields_autoplaced"), P.pair("uuid", T.string), P.collection("properties", "property", T.item(parseProperty)), P.collection("pins", "pin", T.item(parsePinInstance)), P.object("default_instance", {}, P.start("default_instance"), P.pair("reference", T.string), P.pair("unit", T.string), P.pair("value", T.string), P.pair("footprint", T.string)), P.object("instances", {}, P.start("instances"), P.collection("projects", "project", T.object(null, P.start("project"), P.positional("name", T.string), P.collection("paths", "path", T.object(null, P.start("path"), P.positional("path", T.string), P.pair("reference", T.string), P.pair("value", T.string), P.pair("unit", T.number), P.pair("footprint", T.string)))))));
|
|
1713
|
+
return parse_expr$1(expr, P$1.start("symbol"), P$1.pair("lib_name", T$1.string), P$1.pair("lib_id", T$1.string), P$1.item("at", parseAt), P$1.pair("mirror", T$1.string), P$1.pair("exclude_from_sim", T$1.boolean), P$1.pair("unit", T$1.number), P$1.pair("convert", T$1.number), P$1.pair("in_bom", T$1.boolean), P$1.pair("on_board", T$1.boolean), P$1.pair("dnp", T$1.boolean), P$1.atom("fields_autoplaced"), P$1.pair("uuid", T$1.string), P$1.collection("properties", "property", T$1.item(parseProperty)), P$1.collection("pins", "pin", T$1.item(parsePinInstance)), P$1.object("default_instance", {}, P$1.start("default_instance"), P$1.pair("reference", T$1.string), P$1.pair("unit", T$1.string), P$1.pair("value", T$1.string), P$1.pair("footprint", T$1.string)), P$1.object("instances", {}, P$1.start("instances"), P$1.collection("projects", "project", T$1.object(null, P$1.start("project"), P$1.positional("name", T$1.string), P$1.collection("paths", "path", T$1.object(null, P$1.start("path"), P$1.positional("path", T$1.string), P$1.pair("reference", T$1.string), P$1.pair("value", T$1.string), P$1.pair("unit", T$1.number), P$1.pair("footprint", T$1.string)))))));
|
|
1714
1714
|
}
|
|
1715
1715
|
function parseSheetPin(expr) {
|
|
1716
|
-
return parse_expr(expr, P.start("pin"), P.positional("name", T.string), P.positional("shape", T.string), P.item("at", parseAt), P.item("effects", parseEffects), P.pair("uuid", T.string));
|
|
1716
|
+
return parse_expr$1(expr, P$1.start("pin"), P$1.positional("name", T$1.string), P$1.positional("shape", T$1.string), P$1.item("at", parseAt), P$1.item("effects", parseEffects), P$1.pair("uuid", T$1.string));
|
|
1717
1717
|
}
|
|
1718
1718
|
function parseSchematicSheet(expr) {
|
|
1719
|
-
const parsed = parse_expr(expr, P.start("sheet"), P.item("at", parseAt), P.vec2("size"), P.atom("fields_autoplaced"), P.pair("exclude_from_sim", T.boolean), P.pair("in_bom", T.boolean), P.pair("on_board", T.boolean), P.pair("dnp", T.boolean), P.item("stroke", parseStroke), P.item("fill", parseFill), P.pair("uuid", T.string), P.collection("properties", "property", T.item(parseProperty)), P.collection("pins", "pin", T.item(parseSheetPin)), P.object("instances", {}, P.start("instances"), P.collection("projects", "project", T.object(null, P.start("project"), P.positional("name", T.string), P.collection("paths", "path", T.object(null, P.start("path"), P.positional("path", T.string), P.pair("page", T.string)))))));
|
|
1719
|
+
const parsed = parse_expr$1(expr, P$1.start("sheet"), P$1.item("at", parseAt), P$1.vec2("size"), P$1.atom("fields_autoplaced"), P$1.pair("exclude_from_sim", T$1.boolean), P$1.pair("in_bom", T$1.boolean), P$1.pair("on_board", T$1.boolean), P$1.pair("dnp", T$1.boolean), P$1.item("stroke", parseStroke), P$1.item("fill", parseFill), P$1.pair("uuid", T$1.string), P$1.collection("properties", "property", T$1.item(parseProperty)), P$1.collection("pins", "pin", T$1.item(parseSheetPin)), P$1.object("instances", {}, P$1.start("instances"), P$1.collection("projects", "project", T$1.object(null, P$1.start("project"), P$1.positional("name", T$1.string), P$1.collection("paths", "path", T$1.object(null, P$1.start("path"), P$1.positional("path", T$1.string), P$1.pair("page", T$1.string)))))));
|
|
1720
1720
|
return {
|
|
1721
1721
|
at: parsed["at"],
|
|
1722
1722
|
size: parsed["size"],
|
|
@@ -1734,26 +1734,26 @@ ${indent})`;
|
|
|
1734
1734
|
};
|
|
1735
1735
|
}
|
|
1736
1736
|
function parseSheetInstances(expr) {
|
|
1737
|
-
return parse_expr(expr, P.start("sheet_instances"), P.collection("paths", "path", T.object(null, P.start("path"), P.positional("path", T.string), P.pair("page", T.string))))["paths"];
|
|
1737
|
+
return parse_expr$1(expr, P$1.start("sheet_instances"), P$1.collection("paths", "path", T$1.object(null, P$1.start("path"), P$1.positional("path", T$1.string), P$1.pair("page", T$1.string))))["paths"];
|
|
1738
1738
|
}
|
|
1739
1739
|
function parseSymbolInstances(expr) {
|
|
1740
|
-
return parse_expr(expr, P.start("symbol_instances"), P.collection("paths", "path", T.object(null, P.start("path"), P.positional("path", T.string), P.pair("reference", T.string), P.pair("unit", T.number), P.pair("value", T.string), P.pair("footprint", T.string))))["paths"];
|
|
1740
|
+
return parse_expr$1(expr, P$1.start("symbol_instances"), P$1.collection("paths", "path", T$1.object(null, P$1.start("path"), P$1.positional("path", T$1.string), P$1.pair("reference", T$1.string), P$1.pair("unit", T$1.number), P$1.pair("value", T$1.string), P$1.pair("footprint", T$1.string))))["paths"];
|
|
1741
1741
|
}
|
|
1742
1742
|
var SchematicParser = class {
|
|
1743
1743
|
parse(text) {
|
|
1744
|
-
const expr = listify(text);
|
|
1745
|
-
return parse_expr(expr.length === 1 && Array.isArray(expr[0]) ? expr[0] : expr, P.start("kicad_sch"), P.pair("version", T.number), P.pair("generator", T.string), P.pair("generator_version", T.string), P.pair("uuid", T.string), P.item("paper", parsePaper), P.pair("embedded_fonts", T.boolean), P.item("title_block", parseTitleBlock), P.item("lib_symbols", (e) => {
|
|
1744
|
+
const expr = listify$1(text);
|
|
1745
|
+
return parse_expr$1(expr.length === 1 && Array.isArray(expr[0]) ? expr[0] : expr, P$1.start("kicad_sch"), P$1.pair("version", T$1.number), P$1.pair("generator", T$1.string), P$1.pair("generator_version", T$1.string), P$1.pair("uuid", T$1.string), P$1.item("paper", parsePaper), P$1.pair("embedded_fonts", T$1.boolean), P$1.item("title_block", parseTitleBlock), P$1.item("lib_symbols", (e) => {
|
|
1746
1746
|
var _a;
|
|
1747
|
-
return (_a = parse_expr(e, P.start("lib_symbols"), P.collection("symbols", "symbol", T.item(parseLibSymbol)))["symbols"]) != null ? _a : [];
|
|
1748
|
-
}), P.collection("wires", "wire", T.item(parseWire)), P.collection("buses", "bus", T.item(parseBus)), P.collection("bus_entries", "bus_entry", T.item(parseBusEntry)), P.collection("bus_aliases", "bus_alias", T.item(parseBusAlias)), P.collection("junctions", "junction", T.item(parseJunction)), P.collection("no_connects", "no_connect", T.item(parseNoConnect)), P.collection("net_labels", "label", T.item(parseNetLabel)), P.collection("global_labels", "global_label", T.item(parseGlobalLabel)), P.collection("hierarchical_labels", "hierarchical_label", T.item(parseHierarchicalLabel)), P.collection("symbols", "symbol", T.item(parseSchematicSymbol)), P.collection("drawings", "polyline", T.item(parsePolyline)), P.collection("drawings", "rectangle", T.item(parseRectangle)), P.collection("drawings", "arc", T.item(parseArc2)), P.collection("drawings", "text", T.item(parseText)), P.collection("drawings", "bezier", T.item(parseBezier)), P.collection("drawings", "text_box", T.item(parseTextBox)), P.collection("drawings", "circle", T.item(parseCircle2)), P.collection("images", "image", T.item(parseImage)), P.collection("tables", "table", T.item(parseTable)), P.item("sheet_instances", parseSheetInstances), P.item("symbol_instances", parseSymbolInstances), P.collection("sheets", "sheet", T.item(parseSchematicSheet)));
|
|
1747
|
+
return (_a = parse_expr$1(e, P$1.start("lib_symbols"), P$1.collection("symbols", "symbol", T$1.item(parseLibSymbol)))["symbols"]) != null ? _a : [];
|
|
1748
|
+
}), P$1.collection("wires", "wire", T$1.item(parseWire)), P$1.collection("buses", "bus", T$1.item(parseBus)), P$1.collection("bus_entries", "bus_entry", T$1.item(parseBusEntry)), P$1.collection("bus_aliases", "bus_alias", T$1.item(parseBusAlias)), P$1.collection("junctions", "junction", T$1.item(parseJunction)), P$1.collection("no_connects", "no_connect", T$1.item(parseNoConnect)), P$1.collection("net_labels", "label", T$1.item(parseNetLabel)), P$1.collection("global_labels", "global_label", T$1.item(parseGlobalLabel)), P$1.collection("hierarchical_labels", "hierarchical_label", T$1.item(parseHierarchicalLabel)), P$1.collection("symbols", "symbol", T$1.item(parseSchematicSymbol)), P$1.collection("drawings", "polyline", T$1.item(parsePolyline)), P$1.collection("drawings", "rectangle", T$1.item(parseRectangle)), P$1.collection("drawings", "arc", T$1.item(parseArc2)), P$1.collection("drawings", "text", T$1.item(parseText)), P$1.collection("drawings", "bezier", T$1.item(parseBezier)), P$1.collection("drawings", "text_box", T$1.item(parseTextBox)), P$1.collection("drawings", "circle", T$1.item(parseCircle2)), P$1.collection("images", "image", T$1.item(parseImage)), P$1.collection("tables", "table", T$1.item(parseTable)), P$1.item("sheet_instances", parseSheetInstances), P$1.item("symbol_instances", parseSymbolInstances), P$1.collection("sheets", "sheet", T$1.item(parseSchematicSheet)));
|
|
1749
1749
|
}
|
|
1750
1750
|
save(schematic) {
|
|
1751
1751
|
return serializeSchematic(schematic);
|
|
1752
1752
|
}
|
|
1753
1753
|
parseLibSymbols(text) {
|
|
1754
1754
|
var _a;
|
|
1755
|
-
const expr = listify(text);
|
|
1756
|
-
return (_a = parse_expr(expr.length === 1 && Array.isArray(expr[0]) ? expr[0] : expr, P.start("kicad_symbol_lib"), P.pair("version", T.number), P.pair("generator", T.string), P.pair("generator_version", T.string), P.collection("symbols", "symbol", T.item(parseLibSymbol)))["symbols"]) != null ? _a : [];
|
|
1755
|
+
const expr = listify$1(text);
|
|
1756
|
+
return (_a = parse_expr$1(expr.length === 1 && Array.isArray(expr[0]) ? expr[0] : expr, P$1.start("kicad_symbol_lib"), P$1.pair("version", T$1.number), P$1.pair("generator", T$1.string), P$1.pair("generator_version", T$1.string), P$1.collection("symbols", "symbol", T$1.item(parseLibSymbol)))["symbols"]) != null ? _a : [];
|
|
1757
1757
|
}
|
|
1758
1758
|
saveLibSymbols(libSymbols) {
|
|
1759
1759
|
let result = "(kicad_symbol_lib\n";
|
|
@@ -1770,6 +1770,535 @@ ${indent})`;
|
|
|
1770
1770
|
return result;
|
|
1771
1771
|
}
|
|
1772
1772
|
};
|
|
1773
|
+
P$1.pair("name", T$1.string), P$1.pair("comment", T$1.string), P$1.pair("option", T$1.string), P$1.pair("repeat", T$1.number), P$1.pair("incrx", T$1.number), P$1.pair("incry", T$1.number), P$1.pair("linewidth", T$1.number);
|
|
1774
|
+
__export$1({}, { MANDATORY_FIELD_T: () => MANDATORY_FIELD_T$1 });
|
|
1775
|
+
var MANDATORY_FIELD_T$1 = /* @__PURE__ */ ((MANDATORY_FIELD_T2) => {
|
|
1776
|
+
MANDATORY_FIELD_T2[MANDATORY_FIELD_T2["INVALID_FIELD"] = -1] = "INVALID_FIELD";
|
|
1777
|
+
MANDATORY_FIELD_T2[MANDATORY_FIELD_T2["REFERENCE_FIELD"] = 0] = "REFERENCE_FIELD";
|
|
1778
|
+
MANDATORY_FIELD_T2[MANDATORY_FIELD_T2["VALUE_FIELD"] = 1] = "VALUE_FIELD";
|
|
1779
|
+
MANDATORY_FIELD_T2[MANDATORY_FIELD_T2["FOOTPRINT_FIELD"] = 2] = "FOOTPRINT_FIELD";
|
|
1780
|
+
MANDATORY_FIELD_T2[MANDATORY_FIELD_T2["DATASHEET_FIELD"] = 3] = "DATASHEET_FIELD";
|
|
1781
|
+
MANDATORY_FIELD_T2[MANDATORY_FIELD_T2["DESCRIPTION_FIELD"] = 4] = "DESCRIPTION_FIELD";
|
|
1782
|
+
MANDATORY_FIELD_T2[MANDATORY_FIELD_T2["MANDATORY_FIELD_COUNT"] = 5] = "MANDATORY_FIELD_COUNT";
|
|
1783
|
+
return MANDATORY_FIELD_T2;
|
|
1784
|
+
})(MANDATORY_FIELD_T$1 || {});
|
|
1785
|
+
__export$1({}, { PaperSize: () => PaperSize$2 });
|
|
1786
|
+
var PaperSize$2 = {
|
|
1787
|
+
User: [431.8, 279.4],
|
|
1788
|
+
A0: [1189, 841],
|
|
1789
|
+
A1: [841, 594],
|
|
1790
|
+
A2: [594, 420],
|
|
1791
|
+
A3: [420, 297],
|
|
1792
|
+
A4: [297, 210],
|
|
1793
|
+
A5: [210, 148],
|
|
1794
|
+
A: [279.4, 215.9],
|
|
1795
|
+
B: [431.8, 279.4],
|
|
1796
|
+
C: [558.8, 431.8],
|
|
1797
|
+
D: [863.6, 558.8],
|
|
1798
|
+
E: [1117.6, 863.6],
|
|
1799
|
+
USLetter: [279.4, 215.9],
|
|
1800
|
+
USLegal: [355.6, 215.9],
|
|
1801
|
+
USLedger: [431.8, 279.4]
|
|
1802
|
+
};
|
|
1803
|
+
//#endregion
|
|
1804
|
+
//#region ../../node_modules/.pnpm/@huaqiu+kicad-sexpr-parser@0.1.1/node_modules/@huaqiu/kicad-sexpr-parser/dist/index.mjs
|
|
1805
|
+
var __defProp$1 = Object.defineProperty;
|
|
1806
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1807
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
1808
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
1809
|
+
var __typeError = (msg) => {
|
|
1810
|
+
throw TypeError(msg);
|
|
1811
|
+
};
|
|
1812
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp$1(obj, key, {
|
|
1813
|
+
enumerable: true,
|
|
1814
|
+
configurable: true,
|
|
1815
|
+
writable: true,
|
|
1816
|
+
value
|
|
1817
|
+
}) : obj[key] = value;
|
|
1818
|
+
var __spreadValues = (a, b) => {
|
|
1819
|
+
for (var prop in b || (b = {})) if (__hasOwnProp$1.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
1820
|
+
if (__getOwnPropSymbols) {
|
|
1821
|
+
for (var prop of __getOwnPropSymbols(b)) if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
1822
|
+
}
|
|
1823
|
+
return a;
|
|
1824
|
+
};
|
|
1825
|
+
var __export = (target, all) => {
|
|
1826
|
+
for (var name in all) __defProp$1(target, name, {
|
|
1827
|
+
get: all[name],
|
|
1828
|
+
enumerable: true
|
|
1829
|
+
});
|
|
1830
|
+
};
|
|
1831
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
1832
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1833
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
1834
|
+
__export({}, {
|
|
1835
|
+
DimensionFormatUnits: () => DimensionFormatUnits,
|
|
1836
|
+
DimensionFormatUnitsFormat: () => DimensionFormatUnitsFormat,
|
|
1837
|
+
DimensionStyleTextFrame: () => DimensionStyleTextFrame,
|
|
1838
|
+
DimensionStyleTextPositionMode: () => DimensionStyleTextPositionMode
|
|
1839
|
+
});
|
|
1840
|
+
var DimensionFormatUnits = /* @__PURE__ */ ((DimensionFormatUnits2) => {
|
|
1841
|
+
DimensionFormatUnits2[DimensionFormatUnits2["inches"] = 0] = "inches";
|
|
1842
|
+
DimensionFormatUnits2[DimensionFormatUnits2["mils"] = 1] = "mils";
|
|
1843
|
+
DimensionFormatUnits2[DimensionFormatUnits2["millimeters"] = 2] = "millimeters";
|
|
1844
|
+
DimensionFormatUnits2[DimensionFormatUnits2["automatic"] = 3] = "automatic";
|
|
1845
|
+
return DimensionFormatUnits2;
|
|
1846
|
+
})(DimensionFormatUnits || {});
|
|
1847
|
+
var DimensionFormatUnitsFormat = /* @__PURE__ */ ((DimensionFormatUnitsFormat2) => {
|
|
1848
|
+
DimensionFormatUnitsFormat2[DimensionFormatUnitsFormat2["none"] = 0] = "none";
|
|
1849
|
+
DimensionFormatUnitsFormat2[DimensionFormatUnitsFormat2["bare"] = 1] = "bare";
|
|
1850
|
+
DimensionFormatUnitsFormat2[DimensionFormatUnitsFormat2["parenthesis"] = 2] = "parenthesis";
|
|
1851
|
+
return DimensionFormatUnitsFormat2;
|
|
1852
|
+
})(DimensionFormatUnitsFormat || {});
|
|
1853
|
+
var DimensionStyleTextPositionMode = /* @__PURE__ */ ((DimensionStyleTextPositionMode2) => {
|
|
1854
|
+
DimensionStyleTextPositionMode2[DimensionStyleTextPositionMode2["outside"] = 0] = "outside";
|
|
1855
|
+
DimensionStyleTextPositionMode2[DimensionStyleTextPositionMode2["inline"] = 1] = "inline";
|
|
1856
|
+
DimensionStyleTextPositionMode2[DimensionStyleTextPositionMode2["manual"] = 2] = "manual";
|
|
1857
|
+
return DimensionStyleTextPositionMode2;
|
|
1858
|
+
})(DimensionStyleTextPositionMode || {});
|
|
1859
|
+
var DimensionStyleTextFrame = /* @__PURE__ */ ((DimensionStyleTextFrame2) => {
|
|
1860
|
+
DimensionStyleTextFrame2[DimensionStyleTextFrame2["none"] = 0] = "none";
|
|
1861
|
+
DimensionStyleTextFrame2[DimensionStyleTextFrame2["rect"] = 1] = "rect";
|
|
1862
|
+
DimensionStyleTextFrame2[DimensionStyleTextFrame2["circle"] = 2] = "circle";
|
|
1863
|
+
DimensionStyleTextFrame2[DimensionStyleTextFrame2["roundrect"] = 3] = "roundrect";
|
|
1864
|
+
return DimensionStyleTextFrame2;
|
|
1865
|
+
})(DimensionStyleTextFrame || {});
|
|
1866
|
+
var EOF = "";
|
|
1867
|
+
var Token = class {
|
|
1868
|
+
constructor(type, value = null) {
|
|
1869
|
+
this.type = type;
|
|
1870
|
+
this.value = value;
|
|
1871
|
+
}
|
|
1872
|
+
};
|
|
1873
|
+
Token.OPEN = Symbol("opn");
|
|
1874
|
+
Token.CLOSE = Symbol("clo");
|
|
1875
|
+
Token.ATOM = Symbol("atm");
|
|
1876
|
+
Token.NUMBER = Symbol("num");
|
|
1877
|
+
Token.STRING = Symbol("str");
|
|
1878
|
+
function is_digit(c) {
|
|
1879
|
+
return c >= "0" && c <= "9";
|
|
1880
|
+
}
|
|
1881
|
+
function is_alpha(c) {
|
|
1882
|
+
return c >= "A" && c <= "Z" || c >= "a" && c <= "z";
|
|
1883
|
+
}
|
|
1884
|
+
function is_whitespace(c) {
|
|
1885
|
+
return c === EOF || c === " " || c === "\n" || c === "\r" || c === " " || c === "|";
|
|
1886
|
+
}
|
|
1887
|
+
function is_atom(c) {
|
|
1888
|
+
return is_alpha(c) || is_digit(c) || [
|
|
1889
|
+
"_",
|
|
1890
|
+
"-",
|
|
1891
|
+
":",
|
|
1892
|
+
"!",
|
|
1893
|
+
".",
|
|
1894
|
+
"[",
|
|
1895
|
+
"]",
|
|
1896
|
+
"{",
|
|
1897
|
+
"}",
|
|
1898
|
+
"@",
|
|
1899
|
+
"*",
|
|
1900
|
+
"/",
|
|
1901
|
+
"&",
|
|
1902
|
+
"#",
|
|
1903
|
+
"%",
|
|
1904
|
+
"+",
|
|
1905
|
+
"=",
|
|
1906
|
+
"~",
|
|
1907
|
+
"$"
|
|
1908
|
+
].includes(c);
|
|
1909
|
+
}
|
|
1910
|
+
function error_context(input, index) {
|
|
1911
|
+
let start = input.slice(0, index).lastIndexOf("\n");
|
|
1912
|
+
if (start < 0) start = 0;
|
|
1913
|
+
let end = input.slice(index).indexOf("\n");
|
|
1914
|
+
if (end < 0) end = 20;
|
|
1915
|
+
return input.slice(start, index + end);
|
|
1916
|
+
}
|
|
1917
|
+
function* tokenize$1(input) {
|
|
1918
|
+
const open_token = new Token(Token.OPEN);
|
|
1919
|
+
const close_token = new Token(Token.CLOSE);
|
|
1920
|
+
let state = 0;
|
|
1921
|
+
let start_idx = 0;
|
|
1922
|
+
let escaping = false;
|
|
1923
|
+
for (let i = 0; i < input.length + 1; i++) {
|
|
1924
|
+
const c = i < input.length ? input[i] : EOF;
|
|
1925
|
+
if (state == 0) {
|
|
1926
|
+
if (c === "(") {
|
|
1927
|
+
yield open_token;
|
|
1928
|
+
continue;
|
|
1929
|
+
} else if (c === ")") {
|
|
1930
|
+
yield close_token;
|
|
1931
|
+
continue;
|
|
1932
|
+
} else if (c === "\"") {
|
|
1933
|
+
state = 1;
|
|
1934
|
+
start_idx = i;
|
|
1935
|
+
continue;
|
|
1936
|
+
} else if (c === "-" || c == "+" || is_digit(c)) {
|
|
1937
|
+
state = 2;
|
|
1938
|
+
start_idx = i;
|
|
1939
|
+
continue;
|
|
1940
|
+
} else if (is_alpha(c) || [
|
|
1941
|
+
"*",
|
|
1942
|
+
"&",
|
|
1943
|
+
"$",
|
|
1944
|
+
"/",
|
|
1945
|
+
"%"
|
|
1946
|
+
].includes(c)) {
|
|
1947
|
+
state = 3;
|
|
1948
|
+
start_idx = i;
|
|
1949
|
+
continue;
|
|
1950
|
+
} else if (is_whitespace(c)) continue;
|
|
1951
|
+
else if (c === "|") continue;
|
|
1952
|
+
else throw new Error(`Unexpected character at index ${i}: ${c}
|
|
1953
|
+
Context: ${error_context(input, i)}`);
|
|
1954
|
+
} else if (state == 3) {
|
|
1955
|
+
if (is_atom(c)) continue;
|
|
1956
|
+
else if (c === ")" || is_whitespace(c)) {
|
|
1957
|
+
yield new Token(Token.ATOM, input.substring(start_idx, i));
|
|
1958
|
+
state = 0;
|
|
1959
|
+
if (c === ")") yield close_token;
|
|
1960
|
+
} else continue;
|
|
1961
|
+
} else if (state == 2) {
|
|
1962
|
+
if (c === "." || is_digit(c)) continue;
|
|
1963
|
+
else if (c.toLowerCase() === "x") {
|
|
1964
|
+
state = 4;
|
|
1965
|
+
continue;
|
|
1966
|
+
} else if ([
|
|
1967
|
+
"+",
|
|
1968
|
+
"-",
|
|
1969
|
+
"a",
|
|
1970
|
+
"b",
|
|
1971
|
+
"c",
|
|
1972
|
+
"d",
|
|
1973
|
+
"e",
|
|
1974
|
+
"f"
|
|
1975
|
+
].includes(c.toLowerCase())) {
|
|
1976
|
+
state = 3;
|
|
1977
|
+
continue;
|
|
1978
|
+
} else if (is_atom(c)) {
|
|
1979
|
+
state = 3;
|
|
1980
|
+
continue;
|
|
1981
|
+
} else if (c === ")" || is_whitespace(c)) {
|
|
1982
|
+
yield new Token(Token.NUMBER, parseFloat(input.substring(start_idx, i)));
|
|
1983
|
+
state = 0;
|
|
1984
|
+
if (c === ")") yield close_token;
|
|
1985
|
+
continue;
|
|
1986
|
+
} else throw new Error(`Unexpected character at index ${i}: ${c}, expected numeric.
|
|
1987
|
+
Context: ${error_context(input, i)}`);
|
|
1988
|
+
} else if (state == 4) {
|
|
1989
|
+
if (is_digit(c) || [
|
|
1990
|
+
"a",
|
|
1991
|
+
"b",
|
|
1992
|
+
"c",
|
|
1993
|
+
"d",
|
|
1994
|
+
"e",
|
|
1995
|
+
"f",
|
|
1996
|
+
"_"
|
|
1997
|
+
].includes(c.toLowerCase())) continue;
|
|
1998
|
+
else if (c === ")" || is_whitespace(c)) {
|
|
1999
|
+
const hexstr = input.substring(start_idx, i).replace("_", "");
|
|
2000
|
+
yield new Token(Token.NUMBER, Number.parseInt(hexstr, 16));
|
|
2001
|
+
state = 0;
|
|
2002
|
+
if (c === ")") yield close_token;
|
|
2003
|
+
continue;
|
|
2004
|
+
} else if (is_atom(c)) {
|
|
2005
|
+
state = 3;
|
|
2006
|
+
continue;
|
|
2007
|
+
} else throw new Error(`Unexpected character at index ${i}: ${c}, expected hexadecimal.
|
|
2008
|
+
Context: ${error_context(input, i)}`);
|
|
2009
|
+
} else if (state == 1) {
|
|
2010
|
+
if (!escaping && c === "\"") {
|
|
2011
|
+
yield new Token(Token.STRING, input.substring((start_idx != null ? start_idx : 0) + 1, i).replaceAll("\\n", "\n").replaceAll("\\\\", "\\").replaceAll("\\\"", "\""));
|
|
2012
|
+
state = 0;
|
|
2013
|
+
escaping = false;
|
|
2014
|
+
continue;
|
|
2015
|
+
} else if (!escaping && c === "\\") {
|
|
2016
|
+
escaping = true;
|
|
2017
|
+
continue;
|
|
2018
|
+
} else {
|
|
2019
|
+
escaping = false;
|
|
2020
|
+
continue;
|
|
2021
|
+
}
|
|
2022
|
+
} else throw new Error(`Unknown tokenizer state ${state}
|
|
2023
|
+
Context: ${error_context(input, i)}`);
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
function* listify_tokens(tokens) {
|
|
2027
|
+
let token;
|
|
2028
|
+
let it;
|
|
2029
|
+
while (true) {
|
|
2030
|
+
it = tokens.next();
|
|
2031
|
+
token = it.value;
|
|
2032
|
+
switch (token == null ? void 0 : token.type) {
|
|
2033
|
+
case Token.ATOM:
|
|
2034
|
+
case Token.STRING:
|
|
2035
|
+
case Token.NUMBER:
|
|
2036
|
+
yield token.value;
|
|
2037
|
+
break;
|
|
2038
|
+
case Token.OPEN:
|
|
2039
|
+
yield Array.from(listify_tokens(tokens));
|
|
2040
|
+
break;
|
|
2041
|
+
case Token.CLOSE:
|
|
2042
|
+
case void 0: return;
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
function listify(src) {
|
|
2047
|
+
const tokens = tokenize$1(src);
|
|
2048
|
+
return Array.from(listify_tokens(tokens));
|
|
2049
|
+
}
|
|
2050
|
+
var _Logger_instances;
|
|
2051
|
+
var log_fn;
|
|
2052
|
+
var Logger$1 = class {
|
|
2053
|
+
constructor(name, level = 1) {
|
|
2054
|
+
this.name = name;
|
|
2055
|
+
this.level = level;
|
|
2056
|
+
__privateAdd(this, _Logger_instances);
|
|
2057
|
+
}
|
|
2058
|
+
debug(...args) {
|
|
2059
|
+
if (this.level >= 2) __privateMethod(this, _Logger_instances, log_fn).call(this, console.debug, ...args);
|
|
2060
|
+
}
|
|
2061
|
+
info(...args) {
|
|
2062
|
+
if (this.level >= 1) __privateMethod(this, _Logger_instances, log_fn).call(this, console.info.bind(console), ...args);
|
|
2063
|
+
}
|
|
2064
|
+
warn(...args) {
|
|
2065
|
+
if (this.level >= 0) __privateMethod(this, _Logger_instances, log_fn).call(this, console.warn, ...args);
|
|
2066
|
+
}
|
|
2067
|
+
error(...args) {
|
|
2068
|
+
if (this.level >= 0) __privateMethod(this, _Logger_instances, log_fn).call(this, console.error, ...args);
|
|
2069
|
+
}
|
|
2070
|
+
};
|
|
2071
|
+
_Logger_instances = /* @__PURE__ */ new WeakSet();
|
|
2072
|
+
log_fn = function(method, ...args) {};
|
|
2073
|
+
new Logger$1("kicad-parser");
|
|
2074
|
+
var log$2 = new Logger$1("kicanvas:parser");
|
|
2075
|
+
var is_string$1 = (e) => typeof e === "string";
|
|
2076
|
+
var is_number$1 = (e) => typeof e === "number";
|
|
2077
|
+
var T = {
|
|
2078
|
+
any(obj, name, e) {
|
|
2079
|
+
return e;
|
|
2080
|
+
},
|
|
2081
|
+
boolean(obj, name, e) {
|
|
2082
|
+
switch (e) {
|
|
2083
|
+
case "false":
|
|
2084
|
+
case "no": return false;
|
|
2085
|
+
case "true":
|
|
2086
|
+
case "yes": return true;
|
|
2087
|
+
default: return e ? true : false;
|
|
2088
|
+
}
|
|
2089
|
+
},
|
|
2090
|
+
string(obj, name, e) {
|
|
2091
|
+
if (is_string$1(e)) return e;
|
|
2092
|
+
else return;
|
|
2093
|
+
},
|
|
2094
|
+
number(obj, name, e) {
|
|
2095
|
+
if (is_number$1(e)) return e;
|
|
2096
|
+
else return;
|
|
2097
|
+
},
|
|
2098
|
+
item(factory, ...args) {
|
|
2099
|
+
return (obj, name, e) => {
|
|
2100
|
+
return factory(e, ...args);
|
|
2101
|
+
};
|
|
2102
|
+
},
|
|
2103
|
+
object(start, ...defs) {
|
|
2104
|
+
return (obj, name, e) => {
|
|
2105
|
+
var _a, _b;
|
|
2106
|
+
let existing = {};
|
|
2107
|
+
if (start !== null) existing = (_b = (_a = obj[name]) != null ? _a : start) != null ? _b : {};
|
|
2108
|
+
return __spreadValues(__spreadValues({}, existing), parse_expr(e, P.start(name), ...defs));
|
|
2109
|
+
};
|
|
2110
|
+
},
|
|
2111
|
+
vec2(obj, name, e) {
|
|
2112
|
+
const el = e;
|
|
2113
|
+
return {
|
|
2114
|
+
x: el[1] || 0,
|
|
2115
|
+
y: el[2] || 0
|
|
2116
|
+
};
|
|
2117
|
+
},
|
|
2118
|
+
vec4(obj, name, e) {
|
|
2119
|
+
const el = e;
|
|
2120
|
+
return {
|
|
2121
|
+
x: el[1] || 0,
|
|
2122
|
+
y: el[2] || 0,
|
|
2123
|
+
z: el[3] || 0,
|
|
2124
|
+
w: el[4] || 0
|
|
2125
|
+
};
|
|
2126
|
+
},
|
|
2127
|
+
color(obj, name, e) {
|
|
2128
|
+
var _a;
|
|
2129
|
+
const el = e;
|
|
2130
|
+
return {
|
|
2131
|
+
r: el[1] / 255,
|
|
2132
|
+
g: el[2] / 255,
|
|
2133
|
+
b: el[3] / 255,
|
|
2134
|
+
a: (_a = el[4]) != null ? _a : 1
|
|
2135
|
+
};
|
|
2136
|
+
}
|
|
2137
|
+
};
|
|
2138
|
+
var P = {
|
|
2139
|
+
start(name) {
|
|
2140
|
+
return {
|
|
2141
|
+
kind: 0,
|
|
2142
|
+
name,
|
|
2143
|
+
fn: T.string
|
|
2144
|
+
};
|
|
2145
|
+
},
|
|
2146
|
+
positional(name, typefn = T.any) {
|
|
2147
|
+
return {
|
|
2148
|
+
kind: 1,
|
|
2149
|
+
name,
|
|
2150
|
+
fn: typefn
|
|
2151
|
+
};
|
|
2152
|
+
},
|
|
2153
|
+
pair(name, typefn = T.any) {
|
|
2154
|
+
return {
|
|
2155
|
+
kind: 2,
|
|
2156
|
+
name,
|
|
2157
|
+
accepts: [name],
|
|
2158
|
+
fn: (obj, name2, e) => {
|
|
2159
|
+
return typefn(obj, name2, e[1]);
|
|
2160
|
+
}
|
|
2161
|
+
};
|
|
2162
|
+
},
|
|
2163
|
+
list(name, typefn = T.any) {
|
|
2164
|
+
return {
|
|
2165
|
+
kind: 3,
|
|
2166
|
+
name,
|
|
2167
|
+
accepts: [name],
|
|
2168
|
+
fn: (obj, name2, e) => {
|
|
2169
|
+
return e.slice(1).map((n) => typefn(obj, name2, n));
|
|
2170
|
+
}
|
|
2171
|
+
};
|
|
2172
|
+
},
|
|
2173
|
+
collection(name, accept, typefn = T.any) {
|
|
2174
|
+
return {
|
|
2175
|
+
kind: 5,
|
|
2176
|
+
name,
|
|
2177
|
+
accepts: [accept],
|
|
2178
|
+
fn: (obj, name2, e) => {
|
|
2179
|
+
var _a;
|
|
2180
|
+
const list = (_a = obj[name2]) != null ? _a : [];
|
|
2181
|
+
list.push(typefn(obj, name2, e));
|
|
2182
|
+
return list;
|
|
2183
|
+
}
|
|
2184
|
+
};
|
|
2185
|
+
},
|
|
2186
|
+
mapped_collection(name, accept, keyfn, typefn = T.any) {
|
|
2187
|
+
return {
|
|
2188
|
+
kind: 5,
|
|
2189
|
+
name,
|
|
2190
|
+
accepts: [accept],
|
|
2191
|
+
fn: (obj, name2, e) => {
|
|
2192
|
+
var _a;
|
|
2193
|
+
const map = (_a = obj[name2]) != null ? _a : {};
|
|
2194
|
+
const val = typefn(obj, name2, e);
|
|
2195
|
+
const key = keyfn(val);
|
|
2196
|
+
map[key] = val;
|
|
2197
|
+
return map;
|
|
2198
|
+
}
|
|
2199
|
+
};
|
|
2200
|
+
},
|
|
2201
|
+
dict(name, accept, typefn = T.any) {
|
|
2202
|
+
return {
|
|
2203
|
+
kind: 5,
|
|
2204
|
+
name,
|
|
2205
|
+
accepts: [accept],
|
|
2206
|
+
fn: (obj, name2, e) => {
|
|
2207
|
+
var _a;
|
|
2208
|
+
const el = e;
|
|
2209
|
+
const rec = (_a = obj[name2]) != null ? _a : {};
|
|
2210
|
+
rec[el[1]] = typefn(obj, name2, el[2]);
|
|
2211
|
+
return rec;
|
|
2212
|
+
}
|
|
2213
|
+
};
|
|
2214
|
+
},
|
|
2215
|
+
atom(name, values) {
|
|
2216
|
+
let typefn;
|
|
2217
|
+
if (values) typefn = T.string;
|
|
2218
|
+
else {
|
|
2219
|
+
typefn = T.boolean;
|
|
2220
|
+
values = [name];
|
|
2221
|
+
}
|
|
2222
|
+
return {
|
|
2223
|
+
kind: 4,
|
|
2224
|
+
name,
|
|
2225
|
+
accepts: values,
|
|
2226
|
+
fn(obj, name2, e) {
|
|
2227
|
+
if (Array.isArray(e) && e.length == 1) e = e[0];
|
|
2228
|
+
return typefn(obj, name2, e);
|
|
2229
|
+
}
|
|
2230
|
+
};
|
|
2231
|
+
},
|
|
2232
|
+
expr(name, typefn = T.any) {
|
|
2233
|
+
return {
|
|
2234
|
+
kind: 6,
|
|
2235
|
+
name,
|
|
2236
|
+
accepts: [name],
|
|
2237
|
+
fn: typefn
|
|
2238
|
+
};
|
|
2239
|
+
},
|
|
2240
|
+
object(name, start, ...defs) {
|
|
2241
|
+
return P.expr(name, T.object(start, ...defs));
|
|
2242
|
+
},
|
|
2243
|
+
item(name, factory, ...args) {
|
|
2244
|
+
return P.expr(name, T.item(factory, ...args));
|
|
2245
|
+
},
|
|
2246
|
+
vec2(name) {
|
|
2247
|
+
return P.expr(name, T.vec2);
|
|
2248
|
+
},
|
|
2249
|
+
vec4(name) {
|
|
2250
|
+
return P.expr(name, T.vec4);
|
|
2251
|
+
},
|
|
2252
|
+
color(name = "color") {
|
|
2253
|
+
return P.expr(name, T.color);
|
|
2254
|
+
}
|
|
2255
|
+
};
|
|
2256
|
+
function as_array(v) {
|
|
2257
|
+
if (Array.isArray(v)) return v;
|
|
2258
|
+
else return [v];
|
|
2259
|
+
}
|
|
2260
|
+
function parse_expr(expr, ...defs) {
|
|
2261
|
+
if (is_string$1(expr)) {
|
|
2262
|
+
expr = listify(expr);
|
|
2263
|
+
if (expr.length == 1 && Array.isArray(expr[0])) expr = expr[0];
|
|
2264
|
+
}
|
|
2265
|
+
const defs_map = /* @__PURE__ */ new Map();
|
|
2266
|
+
let start_def;
|
|
2267
|
+
let n = 0;
|
|
2268
|
+
for (const def of defs) if (def.kind == 0) start_def = def;
|
|
2269
|
+
else if (def.kind == 1) {
|
|
2270
|
+
defs_map.set(n, def);
|
|
2271
|
+
n++;
|
|
2272
|
+
} else for (const a of def.accepts) defs_map.set(a, def);
|
|
2273
|
+
if (start_def) {
|
|
2274
|
+
const acceptable_start_strings = as_array(start_def.name);
|
|
2275
|
+
const first = expr.at(0);
|
|
2276
|
+
if (!acceptable_start_strings.includes(first)) throw new Error(`Expression must start with ${start_def.name} found ${first} in ${expr}`);
|
|
2277
|
+
expr = expr.slice(1);
|
|
2278
|
+
}
|
|
2279
|
+
const out = {};
|
|
2280
|
+
n = 0;
|
|
2281
|
+
for (const element of expr) {
|
|
2282
|
+
let def = null;
|
|
2283
|
+
if (is_string$1(element)) def = defs_map.get(element);
|
|
2284
|
+
if (!def && (is_string$1(element) || is_number$1(element))) {
|
|
2285
|
+
def = defs_map.get(n);
|
|
2286
|
+
if (!def) {
|
|
2287
|
+
log$2.warn(`no def for bare element ${element} at position ${n} in expression ${expr}`);
|
|
2288
|
+
continue;
|
|
2289
|
+
}
|
|
2290
|
+
n++;
|
|
2291
|
+
}
|
|
2292
|
+
if (!def && Array.isArray(element)) def = defs_map.get(element[0]);
|
|
2293
|
+
if (!def) {
|
|
2294
|
+
log$2.warn(`No def found for element ${element} in expression ${expr}`);
|
|
2295
|
+
continue;
|
|
2296
|
+
}
|
|
2297
|
+
const value = def.fn(out, def.name, element);
|
|
2298
|
+
out[def.name] = value;
|
|
2299
|
+
}
|
|
2300
|
+
return out;
|
|
2301
|
+
}
|
|
1773
2302
|
function parse_drawing_sheet(expr) {
|
|
1774
2303
|
return parse_expr(expr, P.start("kicad_wks"), P.pair("version", T.number), P.pair("generator", T.string), P.item("setup", parse_setup), P.collection("drawings", "line", T.item(parse_line)), P.collection("drawings", "rect", T.item(parse_rect)), P.collection("drawings", "polygon", T.item(parse_polygon2)), P.collection("drawings", "bitmap", T.item(parse_bitmap)), P.collection("drawings", "tbtext", T.item(parse_tbtext)));
|
|
1775
2304
|
}
|
|
@@ -1841,7 +2370,7 @@ ${indent})`;
|
|
|
1841
2370
|
USLedger: [431.8, 279.4]
|
|
1842
2371
|
};
|
|
1843
2372
|
//#endregion
|
|
1844
|
-
//#region ../../node_modules/.pnpm/@huaqiu+ecad-renderer@0.2.
|
|
2373
|
+
//#region ../../node_modules/.pnpm/@huaqiu+ecad-renderer@0.2.5/node_modules/@huaqiu/ecad-renderer/dist/index.js
|
|
1845
2374
|
var __create = Object.create;
|
|
1846
2375
|
var __defProp = Object.defineProperty;
|
|
1847
2376
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -6317,9 +6846,9 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
6317
6846
|
this.#background_color = effectiveColor;
|
|
6318
6847
|
this.canvas.style.backgroundColor = this.#background_color.to_css();
|
|
6319
6848
|
}
|
|
6320
|
-
prep_image(image_or_img, x, y, scale
|
|
6849
|
+
prep_image(image_or_img, x, y, scale) {
|
|
6321
6850
|
let image;
|
|
6322
|
-
const PIXEL_TO_MM = 25.4 /
|
|
6851
|
+
const PIXEL_TO_MM = 25.4 / 300;
|
|
6323
6852
|
if (image_or_img instanceof Image) image = image_or_img;
|
|
6324
6853
|
else {
|
|
6325
6854
|
const src_bbox = new BBox(0, 0, image_or_img.width, image_or_img.height);
|
|
@@ -6654,48 +7183,6 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
6654
7183
|
}
|
|
6655
7184
|
}
|
|
6656
7185
|
};
|
|
6657
|
-
function get_image_ppi(data) {
|
|
6658
|
-
try {
|
|
6659
|
-
const bin_str = atob(data);
|
|
6660
|
-
const len = bin_str.length;
|
|
6661
|
-
const bytes = new Uint8Array(len);
|
|
6662
|
-
for (let i = 0; i < len; i++) bytes[i] = bin_str.charCodeAt(i);
|
|
6663
|
-
if (bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71) return get_png_ppi(bytes);
|
|
6664
|
-
if (bytes[0] === 255 && bytes[1] === 216) return get_jpeg_ppi(bytes);
|
|
6665
|
-
} catch (e) {
|
|
6666
|
-
console.error(`Failed to extract PPI from image: ${e}`);
|
|
6667
|
-
}
|
|
6668
|
-
return null;
|
|
6669
|
-
}
|
|
6670
|
-
function get_png_ppi(bytes) {
|
|
6671
|
-
let offset = 8;
|
|
6672
|
-
const view = new DataView(bytes.buffer);
|
|
6673
|
-
while (offset < bytes.length) {
|
|
6674
|
-
const length = view.getUint32(offset);
|
|
6675
|
-
if (String.fromCharCode(bytes[offset + 4], bytes[offset + 5], bytes[offset + 6], bytes[offset + 7]) === "pHYs") {
|
|
6676
|
-
const ppu_x = view.getUint32(offset + 8);
|
|
6677
|
-
if (bytes[offset + 16] === 1) return Math.round(ppu_x * .0254);
|
|
6678
|
-
}
|
|
6679
|
-
offset += 12 + length;
|
|
6680
|
-
}
|
|
6681
|
-
return null;
|
|
6682
|
-
}
|
|
6683
|
-
function get_jpeg_ppi(bytes) {
|
|
6684
|
-
let offset = 2;
|
|
6685
|
-
const view = new DataView(bytes.buffer);
|
|
6686
|
-
while (offset < bytes.length) {
|
|
6687
|
-
const marker = view.getUint16(offset);
|
|
6688
|
-
const length = view.getUint16(offset + 2);
|
|
6689
|
-
if (marker === 65504) {
|
|
6690
|
-
const density_units = bytes[offset + 11];
|
|
6691
|
-
const x_density = view.getUint16(offset + 12);
|
|
6692
|
-
if (density_units === 1) return x_density;
|
|
6693
|
-
else if (density_units === 2) return Math.round(x_density * 2.54);
|
|
6694
|
-
}
|
|
6695
|
-
offset += 2 + length;
|
|
6696
|
-
}
|
|
6697
|
-
return null;
|
|
6698
|
-
}
|
|
6699
7186
|
var DefaultValues = {
|
|
6700
7187
|
dangling_symbol_size: .3048,
|
|
6701
7188
|
unselected_end_size: .1016,
|
|
@@ -6953,12 +7440,10 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
6953
7440
|
var Image2 = class {
|
|
6954
7441
|
constructor(data) {
|
|
6955
7442
|
this.scale = 1;
|
|
6956
|
-
this.ppi = null;
|
|
6957
7443
|
this.at = new At(data.at);
|
|
6958
7444
|
this.data = data.data;
|
|
6959
7445
|
this.scale = data.scale;
|
|
6960
7446
|
this.uuid = data.uuid;
|
|
6961
|
-
if (this.data) this.ppi = get_image_ppi(this.data);
|
|
6962
7447
|
this.#img = document.createElement("img");
|
|
6963
7448
|
this.#img.src = `data:image/png;base64,${this.data}`;
|
|
6964
7449
|
}
|
|
@@ -31641,6 +32126,14 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
31641
32126
|
super(_ComponentERCResultEvent.type, { detail: d });
|
|
31642
32127
|
}
|
|
31643
32128
|
});
|
|
32129
|
+
(class _SchematicHighlightNetEvent extends CustomEvent {
|
|
32130
|
+
static {
|
|
32131
|
+
this.type = "sch:highlight:net";
|
|
32132
|
+
}
|
|
32133
|
+
constructor(detail) {
|
|
32134
|
+
super(_SchematicHighlightNetEvent.type, { detail });
|
|
32135
|
+
}
|
|
32136
|
+
});
|
|
31644
32137
|
(class _ProjectERCResultEvent extends CustomEvent {
|
|
31645
32138
|
static {
|
|
31646
32139
|
this.type = "sch:erc:project";
|
|
@@ -33559,7 +34052,7 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
33559
34052
|
this.color_cache = null;
|
|
33560
34053
|
}
|
|
33561
34054
|
layers_for(z) {
|
|
33562
|
-
const layers = z.layers
|
|
34055
|
+
const layers = z.layers?.length ? [...z.layers] : [z.layer];
|
|
33563
34056
|
if (layers.length && layers[0] == "F&B.Cu") {
|
|
33564
34057
|
layers.shift();
|
|
33565
34058
|
layers.push("F.Cu", "B.Cu");
|
|
@@ -37825,8 +38318,8 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
37825
38318
|
}
|
|
37826
38319
|
focus_net(num) {
|
|
37827
38320
|
this.highlight_net(num);
|
|
37828
|
-
const
|
|
37829
|
-
if (
|
|
38321
|
+
const net_bbox2 = this.painter.net_bbox;
|
|
38322
|
+
if (net_bbox2) this.viewport.camera.bbox = net_bbox2.grow(net_bbox2.w * .5, net_bbox2.h * .5);
|
|
37830
38323
|
}
|
|
37831
38324
|
on_click(pos, event) {
|
|
37832
38325
|
const items = this.find_items_under_pos(pos);
|
|
@@ -38010,8 +38503,8 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
38010
38503
|
/** State */
|
|
38011
38504
|
this.state = new RenderStateStack();
|
|
38012
38505
|
}
|
|
38013
|
-
image(img, x, y, scale
|
|
38014
|
-
const image_primitive = super.prep_image(img, x, y, scale
|
|
38506
|
+
image(img, x, y, scale) {
|
|
38507
|
+
const image_primitive = super.prep_image(img, x, y, scale);
|
|
38015
38508
|
this.#active_layer?.commands.push(new ImageCommand(img, image_primitive.src_bbox, image_primitive.target_bbox));
|
|
38016
38509
|
}
|
|
38017
38510
|
#layers;
|
|
@@ -38190,8 +38683,8 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
38190
38683
|
render(camera) {}
|
|
38191
38684
|
};
|
|
38192
38685
|
var NullRenderer = class extends Renderer {
|
|
38193
|
-
image(img, x, y, scale
|
|
38194
|
-
this.#active_layer.shapes.push(super.prep_image(img, x, y, scale
|
|
38686
|
+
image(img, x, y, scale) {
|
|
38687
|
+
this.#active_layer.shapes.push(super.prep_image(img, x, y, scale));
|
|
38195
38688
|
}
|
|
38196
38689
|
#active_layer;
|
|
38197
38690
|
constructor() {
|
|
@@ -38229,6 +38722,7 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
38229
38722
|
LayerNames4["interactive"] = ":Interactive";
|
|
38230
38723
|
LayerNames4["marks"] = ":Marks";
|
|
38231
38724
|
LayerNames4["erc"] = ":ERC";
|
|
38725
|
+
LayerNames4["net_highlight"] = ":NetHighlight";
|
|
38232
38726
|
LayerNames4["symbol_field"] = ":Symbol:Field";
|
|
38233
38727
|
LayerNames4["sheet"] = ":Sheet";
|
|
38234
38728
|
LayerNames4["label"] = ":Label";
|
|
@@ -38264,6 +38758,101 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
38264
38758
|
yield this.by_name(":Interactive");
|
|
38265
38759
|
}
|
|
38266
38760
|
};
|
|
38761
|
+
var EPSILON = .02;
|
|
38762
|
+
var NET_HIGHLIGHT = {
|
|
38763
|
+
/** 亮芯颜色(紫),白底与黑底上都醒目 */
|
|
38764
|
+
color: new Color$1(.76, .3, 1, 1),
|
|
38765
|
+
/** 外发光颜色:同色半透明,垫在亮芯下面 */
|
|
38766
|
+
glow: new Color$1(.76, .3, 1, .22),
|
|
38767
|
+
/** 亮芯线宽(毫米),约为导线默认线宽 0.1524 的 4.6 倍 */
|
|
38768
|
+
width: .7,
|
|
38769
|
+
/** 外发光线宽(毫米),柔晕垫底 */
|
|
38770
|
+
glow_width: 2.4
|
|
38771
|
+
};
|
|
38772
|
+
function net_bbox(wires) {
|
|
38773
|
+
let min_x = Infinity;
|
|
38774
|
+
let min_y = Infinity;
|
|
38775
|
+
let max_x = -Infinity;
|
|
38776
|
+
let max_y = -Infinity;
|
|
38777
|
+
for (const wire of wires) for (const point of wire.pts) {
|
|
38778
|
+
min_x = Math.min(min_x, point.x);
|
|
38779
|
+
min_y = Math.min(min_y, point.y);
|
|
38780
|
+
max_x = Math.max(max_x, point.x);
|
|
38781
|
+
max_y = Math.max(max_y, point.y);
|
|
38782
|
+
}
|
|
38783
|
+
return new BBox(min_x, min_y, max_x - min_x, max_y - min_y);
|
|
38784
|
+
}
|
|
38785
|
+
function normalize_name(value) {
|
|
38786
|
+
return String(value ?? "").trim().replace(/^\/+/, "").toUpperCase();
|
|
38787
|
+
}
|
|
38788
|
+
function point_on_segment(p, [a, b]) {
|
|
38789
|
+
const dx = b.x - a.x;
|
|
38790
|
+
const dy = b.y - a.y;
|
|
38791
|
+
const length = Math.hypot(dx, dy);
|
|
38792
|
+
if (!length) return Math.hypot(p.x - a.x, p.y - a.y) <= EPSILON;
|
|
38793
|
+
const cross = dx * (p.y - a.y) - dy * (p.x - a.x);
|
|
38794
|
+
if (Math.abs(cross) / length > EPSILON) return false;
|
|
38795
|
+
const dot = (p.x - a.x) * dx + (p.y - a.y) * dy;
|
|
38796
|
+
return dot >= -EPSILON && dot <= length * length + EPSILON;
|
|
38797
|
+
}
|
|
38798
|
+
function symbol_property(symbol, name) {
|
|
38799
|
+
return symbol.properties.get(name)?.text;
|
|
38800
|
+
}
|
|
38801
|
+
function flatten3(wires) {
|
|
38802
|
+
const segments = [];
|
|
38803
|
+
const ends = [];
|
|
38804
|
+
for (const [index, wire] of wires.entries()) {
|
|
38805
|
+
for (let k = 0; k + 1 < wire.pts.length; k += 1) {
|
|
38806
|
+
const start = wire.pts[k];
|
|
38807
|
+
const end = wire.pts[k + 1];
|
|
38808
|
+
if (start && end) segments.push([index, [start, end]]);
|
|
38809
|
+
}
|
|
38810
|
+
for (const point of [wire.pts[0], wire.pts[wire.pts.length - 1]]) if (point) ends.push([index, point]);
|
|
38811
|
+
}
|
|
38812
|
+
return {
|
|
38813
|
+
segments,
|
|
38814
|
+
ends
|
|
38815
|
+
};
|
|
38816
|
+
}
|
|
38817
|
+
function find_net(doc, names) {
|
|
38818
|
+
const targets = new Set(names.map(normalize_name));
|
|
38819
|
+
const labels = [
|
|
38820
|
+
...doc.net_labels ?? [],
|
|
38821
|
+
...doc.global_labels ?? [],
|
|
38822
|
+
...doc.hierarchical_labels ?? []
|
|
38823
|
+
].filter((label) => targets.has(normalize_name(label.text)));
|
|
38824
|
+
const power_symbols = [];
|
|
38825
|
+
for (const symbol of doc.symbols.values()) {
|
|
38826
|
+
if (!(symbol_property(symbol, "Reference") ?? "").startsWith("#")) continue;
|
|
38827
|
+
if (targets.has(normalize_name(symbol_property(symbol, "Value")))) power_symbols.push(symbol);
|
|
38828
|
+
}
|
|
38829
|
+
const points = [...labels.map((label) => label.at.position), ...power_symbols.map((symbol) => symbol.at.position)];
|
|
38830
|
+
return {
|
|
38831
|
+
wires: trace(doc.wires ?? [], points),
|
|
38832
|
+
points,
|
|
38833
|
+
labels,
|
|
38834
|
+
power_symbols
|
|
38835
|
+
};
|
|
38836
|
+
}
|
|
38837
|
+
function trace(wires, seeds) {
|
|
38838
|
+
if (!wires.length || !seeds.length) return [];
|
|
38839
|
+
const parent = wires.map((_, index) => index);
|
|
38840
|
+
const find2 = (index) => {
|
|
38841
|
+
const parent_index = parent[index];
|
|
38842
|
+
if (parent_index === void 0 || parent_index === index) return index;
|
|
38843
|
+
return parent[index] = find2(parent_index);
|
|
38844
|
+
};
|
|
38845
|
+
const union = (a, b) => {
|
|
38846
|
+
const root_a = find2(a);
|
|
38847
|
+
const root_b = find2(b);
|
|
38848
|
+
if (root_a !== root_b) parent[root_b] = root_a;
|
|
38849
|
+
};
|
|
38850
|
+
const { segments, ends } = flatten3(wires);
|
|
38851
|
+
for (const [i, point] of ends) for (const [j, segment] of segments) if (i !== j && point_on_segment(point, segment)) union(i, j);
|
|
38852
|
+
const roots = /* @__PURE__ */ new Set();
|
|
38853
|
+
for (const [i, segment] of segments) for (const seed of seeds) if (point_on_segment(seed, segment)) roots.add(find2(i));
|
|
38854
|
+
return wires.filter((_, index) => roots.has(find2(index)));
|
|
38855
|
+
}
|
|
38267
38856
|
var BaseSchematicPainter = class extends DocumentPainter {};
|
|
38268
38857
|
var SchematicItemPainter = class extends ItemPainter {
|
|
38269
38858
|
get theme() {
|
|
@@ -39261,7 +39850,7 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
39261
39850
|
const img = t.img;
|
|
39262
39851
|
if (!img.complete) throw new Error("Image not ready");
|
|
39263
39852
|
this.gfx.state.push();
|
|
39264
|
-
this.gfx.image(img, t.at.position.x, t.at.position.y, t.scale
|
|
39853
|
+
this.gfx.image(img, t.at.position.x, t.at.position.y, t.scale);
|
|
39265
39854
|
this.gfx.state.pop();
|
|
39266
39855
|
}
|
|
39267
39856
|
};
|
|
@@ -39490,6 +40079,29 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
39490
40079
|
new BezierPainter(this, gfx)
|
|
39491
40080
|
];
|
|
39492
40081
|
}
|
|
40082
|
+
/**
|
|
40083
|
+
* 高亮一组网络:追踪出属于这些网络的导线,用紫色"柔晕 + 加粗亮芯"
|
|
40084
|
+
* 描边到 :NetHighlight 图层(颜色对齐 KiCad 内部网络高亮)。
|
|
40085
|
+
*
|
|
40086
|
+
* 与 board 侧的 paint_net 对应——绘制细节留在 painter,viewer 只负责协调
|
|
40087
|
+
* (收拢相机)。没追踪到任何导线时返回 null。
|
|
40088
|
+
*/
|
|
40089
|
+
paint_net(doc, names) {
|
|
40090
|
+
const net = find_net(doc, names);
|
|
40091
|
+
if (!net.wires.length) return null;
|
|
40092
|
+
const layer = this.layers.by_name(":NetHighlight");
|
|
40093
|
+
layer.clear();
|
|
40094
|
+
this.gfx.start_layer(layer.name);
|
|
40095
|
+
for (const item of [...net.labels, ...net.power_symbols]) this.paint_item(layer, item);
|
|
40096
|
+
for (const wire of net.wires) this.gfx.line(wire.pts, NET_HIGHLIGHT.glow_width, NET_HIGHLIGHT.glow);
|
|
40097
|
+
for (const wire of net.wires) this.gfx.line(wire.pts, NET_HIGHLIGHT.width, NET_HIGHLIGHT.color);
|
|
40098
|
+
const graphics = this.gfx.end_layer();
|
|
40099
|
+
if (graphics) {
|
|
40100
|
+
layer.graphics = graphics;
|
|
40101
|
+
graphics.composite_operation = "source-over";
|
|
40102
|
+
}
|
|
40103
|
+
return net;
|
|
40104
|
+
}
|
|
39493
40105
|
};
|
|
39494
40106
|
function get_sch_bbox(theme3, sch) {
|
|
39495
40107
|
const gfx = new NullRenderer();
|
|
@@ -39647,10 +40259,11 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
39647
40259
|
const layer = this.layers.selection_bg;
|
|
39648
40260
|
layer.clear();
|
|
39649
40261
|
if (selected) {
|
|
39650
|
-
const
|
|
40262
|
+
const line_color = new Color$1(.1, .2, 1, 1);
|
|
40263
|
+
const fill_color = new Color$1(.1, .2, 1, .2);
|
|
39651
40264
|
this.renderer.start_layer(layer.name);
|
|
39652
|
-
this.renderer.
|
|
39653
|
-
this.renderer.
|
|
40265
|
+
this.renderer.polygon(Polygon.from_BBox(selected, fill_color));
|
|
40266
|
+
this.renderer.line(Polyline.from_BBox(selected, _SchematicViewer.InterActiveBBoxLineWidth, line_color));
|
|
39654
40267
|
layer.graphics = this.renderer.end_layer();
|
|
39655
40268
|
layer.graphics.composite_operation = "source-over";
|
|
39656
40269
|
}
|
|
@@ -39680,6 +40293,39 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
39680
40293
|
this.paint_selected(combined_bbox);
|
|
39681
40294
|
}
|
|
39682
40295
|
}
|
|
40296
|
+
/**
|
|
40297
|
+
* 按网络名高亮整条网络。
|
|
40298
|
+
*
|
|
40299
|
+
* 与 board/viewer 保持一致:绘制细节全部在 SchematicPainter.paint_net,
|
|
40300
|
+
* 这里只负责协调——把相机收拢到网络外接框后重绘。
|
|
40301
|
+
*/
|
|
40302
|
+
highlight_net(names) {
|
|
40303
|
+
const doc = this.document;
|
|
40304
|
+
if (!doc) return {
|
|
40305
|
+
ok: false,
|
|
40306
|
+
reason: "no-document"
|
|
40307
|
+
};
|
|
40308
|
+
const net = this.painter.paint_net(doc, names);
|
|
40309
|
+
if (!net) return {
|
|
40310
|
+
ok: false,
|
|
40311
|
+
reason: "no-wire-found"
|
|
40312
|
+
};
|
|
40313
|
+
this.viewport.camera.bbox = net_bbox(net.wires).grow(20);
|
|
40314
|
+
this.layers.selection_bg.clear();
|
|
40315
|
+
this.draw();
|
|
40316
|
+
return {
|
|
40317
|
+
ok: true,
|
|
40318
|
+
wires: net.wires.length,
|
|
40319
|
+
labels: net.labels.length,
|
|
40320
|
+
power_symbols: net.power_symbols.length
|
|
40321
|
+
};
|
|
40322
|
+
}
|
|
40323
|
+
/** 清除网络高亮;同时清掉器件选中框,两者互斥 */
|
|
40324
|
+
clear_net_highlight() {
|
|
40325
|
+
this.layers.by_name(":NetHighlight").clear();
|
|
40326
|
+
this.layers.selection_bg.clear();
|
|
40327
|
+
this.draw();
|
|
40328
|
+
}
|
|
39683
40329
|
paint_erc() {
|
|
39684
40330
|
const layer = this.layers.by_name(":ERC");
|
|
39685
40331
|
layer.clear();
|
|
@@ -105307,15 +105953,16 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
105307
105953
|
}
|
|
105308
105954
|
return body;
|
|
105309
105955
|
}
|
|
105310
|
-
function query(cwd, project) {
|
|
105956
|
+
function query(cwd, project, session) {
|
|
105311
105957
|
const params = new URLSearchParams();
|
|
105312
105958
|
if (cwd !== void 0 && cwd !== "") params.set("cwd", cwd);
|
|
105313
105959
|
if (project !== void 0 && project !== "") params.set("project", project);
|
|
105960
|
+
if (session !== void 0 && session !== "") params.set("session", session);
|
|
105314
105961
|
const text = params.toString();
|
|
105315
105962
|
return text === "" ? "" : `?${text}`;
|
|
105316
105963
|
}
|
|
105317
|
-
async function loadProjects(cwd, project) {
|
|
105318
|
-
const body = await request(`/projects${query(cwd, project)}`);
|
|
105964
|
+
async function loadProjects(cwd, project, session) {
|
|
105965
|
+
const body = await request(`/projects${query(cwd, project, session)}`);
|
|
105319
105966
|
return {
|
|
105320
105967
|
cwd: body.cwd,
|
|
105321
105968
|
projects: Array.isArray(body.projects) ? body.projects : [],
|
|
@@ -105333,29 +105980,73 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
105333
105980
|
body: JSON.stringify(requestBody)
|
|
105334
105981
|
});
|
|
105335
105982
|
}
|
|
105336
|
-
async function loadArtifactSource(artifactPath,
|
|
105983
|
+
async function loadArtifactSource(artifactPath, options = {}) {
|
|
105337
105984
|
const params = new URLSearchParams({ path: artifactPath });
|
|
105338
|
-
if (expectedRevision !== void 0 && expectedRevision !== "") params.set("revision", expectedRevision);
|
|
105339
|
-
|
|
105985
|
+
if (options.expectedRevision !== void 0 && options.expectedRevision !== "") params.set("revision", options.expectedRevision);
|
|
105986
|
+
if (options.session !== void 0 && options.session !== "") params.set("session", options.session);
|
|
105987
|
+
if (options.cwd !== void 0 && options.cwd !== "") params.set("cwd", options.cwd);
|
|
105988
|
+
return request(`/source?${params.toString()}`, options.signal === void 0 ? {} : { signal: options.signal });
|
|
105340
105989
|
}
|
|
105341
|
-
async function loadBom(artifactPath,
|
|
105990
|
+
async function loadBom(artifactPath, options = {}) {
|
|
105342
105991
|
return request("/bom", {
|
|
105343
105992
|
method: "POST",
|
|
105344
105993
|
headers: { "content-type": "application/json" },
|
|
105345
|
-
body: JSON.stringify({
|
|
105346
|
-
|
|
105994
|
+
body: JSON.stringify({
|
|
105995
|
+
path: artifactPath,
|
|
105996
|
+
...options.session === void 0 ? {} : { session: options.session },
|
|
105997
|
+
...options.cwd === void 0 ? {} : { cwd: options.cwd }
|
|
105998
|
+
}),
|
|
105999
|
+
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
105347
106000
|
});
|
|
105348
106001
|
}
|
|
105349
106002
|
/** Prepare the GLB; the returned `url` is served by the same host route. */
|
|
105350
|
-
async function prepareBoardGlb(artifactPath, cwd, signal) {
|
|
106003
|
+
async function prepareBoardGlb(artifactPath, cwd, signal, session) {
|
|
105351
106004
|
return request("/glb", {
|
|
105352
106005
|
method: "POST",
|
|
105353
106006
|
headers: { "content-type": "application/json" },
|
|
105354
106007
|
body: JSON.stringify({
|
|
105355
106008
|
path: artifactPath,
|
|
105356
|
-
...cwd === void 0 ? {} : { cwd }
|
|
106009
|
+
...cwd === void 0 ? {} : { cwd },
|
|
106010
|
+
...session === void 0 ? {} : { session }
|
|
106011
|
+
}),
|
|
106012
|
+
...signal === void 0 ? {} : { signal }
|
|
106013
|
+
});
|
|
106014
|
+
}
|
|
106015
|
+
async function loadOrderConfig() {
|
|
106016
|
+
return request("/order");
|
|
106017
|
+
}
|
|
106018
|
+
async function prepareFabrication(boardPath, schematicPath, cwd, signal, session) {
|
|
106019
|
+
return request("/fabrication", {
|
|
106020
|
+
method: "POST",
|
|
106021
|
+
headers: { "content-type": "application/json" },
|
|
106022
|
+
body: JSON.stringify({
|
|
106023
|
+
path: boardPath,
|
|
106024
|
+
...schematicPath === void 0 ? {} : { schematic: schematicPath },
|
|
106025
|
+
...cwd === void 0 ? {} : { cwd },
|
|
106026
|
+
...session === void 0 ? {} : { session }
|
|
105357
106027
|
}),
|
|
105358
|
-
signal
|
|
106028
|
+
...signal === void 0 ? {} : { signal }
|
|
106029
|
+
});
|
|
106030
|
+
}
|
|
106031
|
+
/**
|
|
106032
|
+
* Submit one order. `confirm` is what the host requires; the panel sets it only
|
|
106033
|
+
* after the user confirms the upload in the dialog. The host opens the order
|
|
106034
|
+
* page in the default browser unless `launch` is false.
|
|
106035
|
+
*/
|
|
106036
|
+
async function placeOrder(kind, requestBody, signal) {
|
|
106037
|
+
return request(`/order/${kind}`, {
|
|
106038
|
+
method: "POST",
|
|
106039
|
+
headers: { "content-type": "application/json" },
|
|
106040
|
+
body: JSON.stringify(requestBody),
|
|
106041
|
+
...signal === void 0 ? {} : { signal }
|
|
106042
|
+
});
|
|
106043
|
+
}
|
|
106044
|
+
/** Hand an already-created order page back to the OS default browser. */
|
|
106045
|
+
async function openOrderUrl(url) {
|
|
106046
|
+
return request("/order/open", {
|
|
106047
|
+
method: "POST",
|
|
106048
|
+
headers: { "content-type": "application/json" },
|
|
106049
|
+
body: JSON.stringify({ url })
|
|
105359
106050
|
});
|
|
105360
106051
|
}
|
|
105361
106052
|
//#endregion
|
|
@@ -105382,25 +106073,47 @@ while (n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3] && n3 === a3[++i3]
|
|
|
105382
106073
|
* late fetch or a slow parse can never paint into an obsolete viewer.
|
|
105383
106074
|
*/
|
|
105384
106075
|
async function mountEcad(kind, artifactPath, container, options) {
|
|
105385
|
-
const source = await loadArtifactSource(artifactPath,
|
|
106076
|
+
const source = await loadArtifactSource(artifactPath, {
|
|
106077
|
+
signal: options.signal,
|
|
106078
|
+
...options.revision === void 0 ? {} : { expectedRevision: options.revision },
|
|
106079
|
+
...options.session === void 0 ? {} : { session: options.session }
|
|
106080
|
+
});
|
|
105386
106081
|
if (options.signal.aborted) throw aborted$1(options.signal);
|
|
105387
106082
|
if (source.kind !== void 0 && source.kind !== kind) throw new Error(`host returned a ${source.kind} artifact for a ${kind} preview`);
|
|
106083
|
+
const canvas = document.createElement("canvas");
|
|
106084
|
+
canvas.style.cssText = "position:absolute;inset:0;display:block;width:100%;height:100%;outline:none";
|
|
106085
|
+
container.append(canvas);
|
|
105388
106086
|
let rendered;
|
|
105389
106087
|
if (kind === "schematic") rendered = await renderSchematic(new SchematicParser().parse(source.text), {
|
|
106088
|
+
canvas,
|
|
105390
106089
|
container,
|
|
105391
106090
|
interactive: true
|
|
105392
106091
|
});
|
|
105393
106092
|
else rendered = await renderPcb(new BoardParser().parse(source.text), {
|
|
106093
|
+
canvas,
|
|
105394
106094
|
container,
|
|
105395
106095
|
interactive: true
|
|
105396
106096
|
});
|
|
105397
106097
|
if (options.signal.aborted) {
|
|
105398
106098
|
rendered.dispose();
|
|
106099
|
+
canvas.remove();
|
|
105399
106100
|
throw aborted$1(options.signal);
|
|
105400
106101
|
}
|
|
106102
|
+
const viewer = rendered.viewer;
|
|
106103
|
+
if (typeof viewer.zoom_fit_top_item === "function") {
|
|
106104
|
+
await new Promise((resolve) => {
|
|
106105
|
+
requestAnimationFrame(() => {
|
|
106106
|
+
requestAnimationFrame(() => {
|
|
106107
|
+
resolve();
|
|
106108
|
+
});
|
|
106109
|
+
});
|
|
106110
|
+
});
|
|
106111
|
+
if (!options.signal.aborted) viewer.zoom_fit_top_item();
|
|
106112
|
+
}
|
|
105401
106113
|
return {
|
|
105402
106114
|
dispose: () => {
|
|
105403
106115
|
rendered.dispose();
|
|
106116
|
+
canvas.remove();
|
|
105404
106117
|
},
|
|
105405
106118
|
sourceRevision: source.revision,
|
|
105406
106119
|
source
|
|
@@ -142592,68 +143305,838 @@ void main() {
|
|
|
142592
143305
|
});
|
|
142593
143306
|
}
|
|
142594
143307
|
//#endregion
|
|
143308
|
+
//#region src/client/theme.ts
|
|
143309
|
+
const MONO = "ui-monospace, \"JetBrains Mono\", SFMono-Regular, Menlo, monospace";
|
|
143310
|
+
const C = {
|
|
143311
|
+
base: "var(--dsw-alias-bg-base, #161618)",
|
|
143312
|
+
panel: "var(--dsw-alias-bg-layer-1, #1d1d20)",
|
|
143313
|
+
card: "var(--dsw-alias-bg-layer-2, #202024)",
|
|
143314
|
+
raised: "var(--dsw-alias-bg-layer-3, #2a2a2e)",
|
|
143315
|
+
border: "var(--dsw-alias-border-l2, rgba(127,127,127,0.24))",
|
|
143316
|
+
borderSoft: "var(--dsw-alias-border-l1, rgba(127,127,127,0.14))",
|
|
143317
|
+
text: "var(--dsw-alias-label-primary, #ececee)",
|
|
143318
|
+
text2: "var(--dsw-alias-label-secondary, #a1a1aa)",
|
|
143319
|
+
text3: "var(--dsw-alias-label-tertiary, #71717a)",
|
|
143320
|
+
accent: "#e1251b",
|
|
143321
|
+
accentHover: "#c41e15",
|
|
143322
|
+
accentSoft: "rgba(225, 37, 27, 0.15)",
|
|
143323
|
+
ok: "#34d399",
|
|
143324
|
+
okSoft: "rgba(52, 211, 153, 0.14)",
|
|
143325
|
+
warn: "#fbbf24",
|
|
143326
|
+
warnSoft: "rgba(251, 191, 36, 0.14)",
|
|
143327
|
+
info: "#38bdf8",
|
|
143328
|
+
infoSoft: "rgba(56, 189, 248, 0.14)",
|
|
143329
|
+
violet: "#a78bfa",
|
|
143330
|
+
pink: "#f472b6"
|
|
143331
|
+
};
|
|
143332
|
+
const R = {
|
|
143333
|
+
sm: 6,
|
|
143334
|
+
md: 8,
|
|
143335
|
+
lg: 12,
|
|
143336
|
+
pill: 999
|
|
143337
|
+
};
|
|
143338
|
+
const DOT_COLORS = {
|
|
143339
|
+
schematic: C.info,
|
|
143340
|
+
pcb: C.ok,
|
|
143341
|
+
bom: C.pink,
|
|
143342
|
+
"3d": C.warn,
|
|
143343
|
+
order: C.accent
|
|
143344
|
+
};
|
|
143345
|
+
function cardStyle(extra) {
|
|
143346
|
+
return {
|
|
143347
|
+
border: `1px solid ${C.border}`,
|
|
143348
|
+
borderRadius: R.lg,
|
|
143349
|
+
background: C.card,
|
|
143350
|
+
padding: 12,
|
|
143351
|
+
display: "flex",
|
|
143352
|
+
flexDirection: "column",
|
|
143353
|
+
gap: 8,
|
|
143354
|
+
minWidth: 0,
|
|
143355
|
+
...extra
|
|
143356
|
+
};
|
|
143357
|
+
}
|
|
143358
|
+
const SECTION_TITLE = {
|
|
143359
|
+
margin: 0,
|
|
143360
|
+
fontSize: 11,
|
|
143361
|
+
fontWeight: 600,
|
|
143362
|
+
letterSpacing: .2,
|
|
143363
|
+
color: C.text2,
|
|
143364
|
+
textTransform: "uppercase"
|
|
143365
|
+
};
|
|
143366
|
+
const MUTED = {
|
|
143367
|
+
margin: 0,
|
|
143368
|
+
fontSize: 11,
|
|
143369
|
+
lineHeight: 1.55,
|
|
143370
|
+
color: C.text3
|
|
143371
|
+
};
|
|
143372
|
+
const MONO_TEXT = {
|
|
143373
|
+
fontFamily: MONO,
|
|
143374
|
+
fontVariantNumeric: "tabular-nums"
|
|
143375
|
+
};
|
|
143376
|
+
function dotStyle(color, size = 7) {
|
|
143377
|
+
return {
|
|
143378
|
+
width: size,
|
|
143379
|
+
height: size,
|
|
143380
|
+
borderRadius: R.pill,
|
|
143381
|
+
background: color,
|
|
143382
|
+
flex: "0 0 auto"
|
|
143383
|
+
};
|
|
143384
|
+
}
|
|
143385
|
+
function pillStyle(tone = "muted", extra) {
|
|
143386
|
+
const tone_ = {
|
|
143387
|
+
ok: {
|
|
143388
|
+
color: C.ok,
|
|
143389
|
+
background: C.okSoft,
|
|
143390
|
+
border: "rgba(52, 211, 153, 0.28)"
|
|
143391
|
+
},
|
|
143392
|
+
warn: {
|
|
143393
|
+
color: C.warn,
|
|
143394
|
+
background: C.warnSoft,
|
|
143395
|
+
border: "rgba(251, 191, 36, 0.28)"
|
|
143396
|
+
},
|
|
143397
|
+
info: {
|
|
143398
|
+
color: C.info,
|
|
143399
|
+
background: C.infoSoft,
|
|
143400
|
+
border: "rgba(56, 189, 248, 0.28)"
|
|
143401
|
+
},
|
|
143402
|
+
accent: {
|
|
143403
|
+
color: C.accent,
|
|
143404
|
+
background: C.accentSoft,
|
|
143405
|
+
border: "rgba(225, 37, 27, 0.32)"
|
|
143406
|
+
},
|
|
143407
|
+
muted: {
|
|
143408
|
+
color: C.text3,
|
|
143409
|
+
background: "transparent",
|
|
143410
|
+
border: C.border
|
|
143411
|
+
}
|
|
143412
|
+
}[tone];
|
|
143413
|
+
return {
|
|
143414
|
+
display: "inline-flex",
|
|
143415
|
+
alignItems: "center",
|
|
143416
|
+
gap: 4,
|
|
143417
|
+
padding: "1px 7px",
|
|
143418
|
+
borderRadius: R.pill,
|
|
143419
|
+
border: `1px solid ${tone_.border}`,
|
|
143420
|
+
background: tone_.background,
|
|
143421
|
+
color: tone_.color,
|
|
143422
|
+
fontSize: 10,
|
|
143423
|
+
lineHeight: 1.6,
|
|
143424
|
+
whiteSpace: "nowrap",
|
|
143425
|
+
fontFamily: MONO,
|
|
143426
|
+
...extra
|
|
143427
|
+
};
|
|
143428
|
+
}
|
|
143429
|
+
function buttonStyle(kind = "secondary", extra) {
|
|
143430
|
+
const base = {
|
|
143431
|
+
display: "inline-flex",
|
|
143432
|
+
alignItems: "center",
|
|
143433
|
+
justifyContent: "center",
|
|
143434
|
+
gap: 6,
|
|
143435
|
+
padding: "5px 10px",
|
|
143436
|
+
borderRadius: R.md,
|
|
143437
|
+
font: "inherit",
|
|
143438
|
+
fontSize: 11,
|
|
143439
|
+
fontWeight: 500,
|
|
143440
|
+
lineHeight: 1.4,
|
|
143441
|
+
cursor: "pointer",
|
|
143442
|
+
whiteSpace: "nowrap",
|
|
143443
|
+
transition: "background 120ms ease, border-color 120ms ease, opacity 120ms ease"
|
|
143444
|
+
};
|
|
143445
|
+
if (kind === "primary") return {
|
|
143446
|
+
...base,
|
|
143447
|
+
border: "1px solid transparent",
|
|
143448
|
+
background: C.accent,
|
|
143449
|
+
color: "#fff",
|
|
143450
|
+
boxShadow: "0 6px 16px rgba(225, 37, 27, 0.22)",
|
|
143451
|
+
...extra
|
|
143452
|
+
};
|
|
143453
|
+
if (kind === "quiet") return {
|
|
143454
|
+
...base,
|
|
143455
|
+
border: "1px solid transparent",
|
|
143456
|
+
background: "transparent",
|
|
143457
|
+
color: C.text2,
|
|
143458
|
+
...extra
|
|
143459
|
+
};
|
|
143460
|
+
return {
|
|
143461
|
+
...base,
|
|
143462
|
+
border: `1px solid ${C.border}`,
|
|
143463
|
+
background: C.raised,
|
|
143464
|
+
color: C.text,
|
|
143465
|
+
...extra
|
|
143466
|
+
};
|
|
143467
|
+
}
|
|
143468
|
+
const INPUT = {
|
|
143469
|
+
width: "100%",
|
|
143470
|
+
boxSizing: "border-box",
|
|
143471
|
+
padding: "5px 8px",
|
|
143472
|
+
borderRadius: R.md,
|
|
143473
|
+
border: `1px solid ${C.border}`,
|
|
143474
|
+
background: C.base,
|
|
143475
|
+
color: C.text,
|
|
143476
|
+
font: "inherit",
|
|
143477
|
+
fontSize: 11,
|
|
143478
|
+
fontFamily: MONO
|
|
143479
|
+
};
|
|
143480
|
+
const SELECT = {
|
|
143481
|
+
...INPUT,
|
|
143482
|
+
cursor: "pointer"
|
|
143483
|
+
};
|
|
143484
|
+
function disabled(active) {
|
|
143485
|
+
return active ? {
|
|
143486
|
+
opacity: .45,
|
|
143487
|
+
cursor: "not-allowed",
|
|
143488
|
+
boxShadow: "none"
|
|
143489
|
+
} : {};
|
|
143490
|
+
}
|
|
143491
|
+
//#endregion
|
|
143492
|
+
//#region src/client/order.tsx
|
|
143493
|
+
/**
|
|
143494
|
+
* Order Placing destination.
|
|
143495
|
+
*
|
|
143496
|
+
* The panel never prices anything and never keeps its own order backend. It
|
|
143497
|
+
* prepares the fabrication package with `kicad-cli` through the host, shows
|
|
143498
|
+
* exactly what would be uploaded, and submits only after the user confirms in
|
|
143499
|
+
* a dialog. The URL shown afterwards is the backend's own URL, passed through.
|
|
143500
|
+
*/
|
|
143501
|
+
const QUANTITIES = [
|
|
143502
|
+
5,
|
|
143503
|
+
20,
|
|
143504
|
+
100
|
|
143505
|
+
];
|
|
143506
|
+
function formatBytes(bytes) {
|
|
143507
|
+
if (bytes < 1024) return `${String(bytes)} B`;
|
|
143508
|
+
if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
143509
|
+
return `${(bytes / 1048576).toFixed(2)} MB`;
|
|
143510
|
+
}
|
|
143511
|
+
function describe$1(error) {
|
|
143512
|
+
return error instanceof Error ? error.message : String(error);
|
|
143513
|
+
}
|
|
143514
|
+
function specRows(facts) {
|
|
143515
|
+
return [
|
|
143516
|
+
{
|
|
143517
|
+
label: "Layers",
|
|
143518
|
+
value: `${String(facts.layers)} Cu`
|
|
143519
|
+
},
|
|
143520
|
+
{
|
|
143521
|
+
label: "Outline",
|
|
143522
|
+
value: `${facts.widthMm.toFixed(1)} × ${facts.heightMm.toFixed(1)} mm`
|
|
143523
|
+
},
|
|
143524
|
+
{
|
|
143525
|
+
label: "Thickness",
|
|
143526
|
+
value: `${facts.thicknessMm.toFixed(2)} mm`
|
|
143527
|
+
},
|
|
143528
|
+
{
|
|
143529
|
+
label: "Min trace",
|
|
143530
|
+
value: facts.minTrackMm === void 0 ? "default" : `${facts.minTrackMm.toFixed(2)} mm`
|
|
143531
|
+
},
|
|
143532
|
+
{
|
|
143533
|
+
label: "Min drill",
|
|
143534
|
+
value: facts.minViaDrillMm === void 0 ? "default" : `${facts.minViaDrillMm.toFixed(2)} mm`
|
|
143535
|
+
},
|
|
143536
|
+
{
|
|
143537
|
+
label: "Outer Cu",
|
|
143538
|
+
value: `${String(facts.outerOz ?? 1)} oz`
|
|
143539
|
+
}
|
|
143540
|
+
];
|
|
143541
|
+
}
|
|
143542
|
+
const SPEC_GRID = {
|
|
143543
|
+
display: "grid",
|
|
143544
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(88px, 1fr))",
|
|
143545
|
+
gap: 6
|
|
143546
|
+
};
|
|
143547
|
+
const SPEC_CELL = {
|
|
143548
|
+
border: `1px solid ${C.borderSoft}`,
|
|
143549
|
+
borderRadius: R.md,
|
|
143550
|
+
background: C.base,
|
|
143551
|
+
padding: "5px 7px",
|
|
143552
|
+
display: "flex",
|
|
143553
|
+
flexDirection: "column",
|
|
143554
|
+
gap: 1,
|
|
143555
|
+
minWidth: 0
|
|
143556
|
+
};
|
|
143557
|
+
const SPEC_LABEL = {
|
|
143558
|
+
fontSize: 9.5,
|
|
143559
|
+
color: C.text3,
|
|
143560
|
+
letterSpacing: .2
|
|
143561
|
+
};
|
|
143562
|
+
const SPEC_VALUE = {
|
|
143563
|
+
fontSize: 11,
|
|
143564
|
+
...MONO_TEXT,
|
|
143565
|
+
color: C.text,
|
|
143566
|
+
whiteSpace: "nowrap",
|
|
143567
|
+
overflow: "hidden",
|
|
143568
|
+
textOverflow: "ellipsis"
|
|
143569
|
+
};
|
|
143570
|
+
const ROW$2 = {
|
|
143571
|
+
display: "flex",
|
|
143572
|
+
alignItems: "center",
|
|
143573
|
+
gap: 6,
|
|
143574
|
+
flexWrap: "wrap",
|
|
143575
|
+
minWidth: 0
|
|
143576
|
+
};
|
|
143577
|
+
const SPREAD$1 = {
|
|
143578
|
+
...ROW$2,
|
|
143579
|
+
justifyContent: "space-between"
|
|
143580
|
+
};
|
|
143581
|
+
const TAG = {
|
|
143582
|
+
fontSize: 9.5,
|
|
143583
|
+
fontWeight: 600,
|
|
143584
|
+
letterSpacing: .6,
|
|
143585
|
+
padding: "1px 5px",
|
|
143586
|
+
borderRadius: R.sm,
|
|
143587
|
+
border: "1px solid currentColor",
|
|
143588
|
+
fontFamily: MONO
|
|
143589
|
+
};
|
|
143590
|
+
const LINK = {
|
|
143591
|
+
color: C.info,
|
|
143592
|
+
fontSize: 11,
|
|
143593
|
+
fontFamily: MONO,
|
|
143594
|
+
wordBreak: "break-all",
|
|
143595
|
+
textDecoration: "underline",
|
|
143596
|
+
textUnderlineOffset: 2
|
|
143597
|
+
};
|
|
143598
|
+
const DIALOG_BACKDROP = {
|
|
143599
|
+
position: "absolute",
|
|
143600
|
+
inset: 0,
|
|
143601
|
+
background: "rgba(0,0,0,0.55)",
|
|
143602
|
+
backdropFilter: "blur(2px)",
|
|
143603
|
+
display: "flex",
|
|
143604
|
+
alignItems: "center",
|
|
143605
|
+
justifyContent: "center",
|
|
143606
|
+
padding: 14,
|
|
143607
|
+
zIndex: 20
|
|
143608
|
+
};
|
|
143609
|
+
const DIALOG = {
|
|
143610
|
+
width: "100%",
|
|
143611
|
+
maxWidth: 420,
|
|
143612
|
+
maxHeight: "90%",
|
|
143613
|
+
overflow: "auto",
|
|
143614
|
+
background: C.card,
|
|
143615
|
+
border: `1px solid ${C.border}`,
|
|
143616
|
+
borderRadius: R.lg,
|
|
143617
|
+
boxShadow: "0 24px 60px rgba(0,0,0,0.45)",
|
|
143618
|
+
padding: 14,
|
|
143619
|
+
display: "flex",
|
|
143620
|
+
flexDirection: "column",
|
|
143621
|
+
gap: 10
|
|
143622
|
+
};
|
|
143623
|
+
/** One workflow card: what it will do, what it needs, and its action. */
|
|
143624
|
+
function workflowCard(input) {
|
|
143625
|
+
const blocked = input.blocked !== void 0;
|
|
143626
|
+
return (0, react.createElement)("div", {
|
|
143627
|
+
style: cardStyle({ gap: 9 }),
|
|
143628
|
+
"data-hardware-order-card": input.tag.toLowerCase()
|
|
143629
|
+
}, (0, react.createElement)("div", { style: {
|
|
143630
|
+
...ROW$2,
|
|
143631
|
+
gap: 7
|
|
143632
|
+
} }, (0, react.createElement)("span", { style: {
|
|
143633
|
+
...TAG,
|
|
143634
|
+
color: input.tagColor
|
|
143635
|
+
} }, input.tag), (0, react.createElement)("span", { style: {
|
|
143636
|
+
fontSize: 12,
|
|
143637
|
+
fontWeight: 600,
|
|
143638
|
+
color: C.text,
|
|
143639
|
+
minWidth: 0
|
|
143640
|
+
} }, input.title)), (0, react.createElement)("p", { style: MUTED }, input.subtitle), (0, react.createElement)("div", { style: SPEC_GRID }, ...input.details.map((detail) => (0, react.createElement)("div", {
|
|
143641
|
+
key: detail.label,
|
|
143642
|
+
style: SPEC_CELL
|
|
143643
|
+
}, (0, react.createElement)("span", { style: SPEC_LABEL }, detail.label), (0, react.createElement)("span", {
|
|
143644
|
+
style: SPEC_VALUE,
|
|
143645
|
+
title: detail.value
|
|
143646
|
+
}, detail.value)))), blocked ? (0, react.createElement)("p", { style: {
|
|
143647
|
+
...MUTED,
|
|
143648
|
+
color: C.warn
|
|
143649
|
+
} }, input.blocked ?? "") : null, (0, react.createElement)("button", {
|
|
143650
|
+
type: "button",
|
|
143651
|
+
style: {
|
|
143652
|
+
...buttonStyle("primary"),
|
|
143653
|
+
width: "100%",
|
|
143654
|
+
...disabled(blocked || input.busy)
|
|
143655
|
+
},
|
|
143656
|
+
disabled: blocked || input.busy,
|
|
143657
|
+
"data-hardware-order-action": input.tag.toLowerCase(),
|
|
143658
|
+
onClick: input.onAction
|
|
143659
|
+
}, input.busy ? "Submitting…" : input.action));
|
|
143660
|
+
}
|
|
143661
|
+
function OrderPanel(props) {
|
|
143662
|
+
const { boardPath, boardTitle, schematicPath, workspaceRoot, session, configured } = props;
|
|
143663
|
+
const [config, setConfig] = (0, react.useState)();
|
|
143664
|
+
const [prepared, setPrepared] = (0, react.useState)();
|
|
143665
|
+
const [preparing, setPreparing] = (0, react.useState)(false);
|
|
143666
|
+
const [message, setMessage] = (0, react.useState)();
|
|
143667
|
+
const [quantity, setQuantity] = (0, react.useState)(20);
|
|
143668
|
+
const [confirming, setConfirming] = (0, react.useState)();
|
|
143669
|
+
const [acknowledged, setAcknowledged] = (0, react.useState)(false);
|
|
143670
|
+
const [placing, setPlacing] = (0, react.useState)();
|
|
143671
|
+
const [placed, setPlaced] = (0, react.useState)();
|
|
143672
|
+
const [copied, setCopied] = (0, react.useState)(false);
|
|
143673
|
+
const [reopening, setReopening] = (0, react.useState)(false);
|
|
143674
|
+
const live = (0, react.useRef)(true);
|
|
143675
|
+
(0, react.useEffect)(() => {
|
|
143676
|
+
live.current = true;
|
|
143677
|
+
return () => {
|
|
143678
|
+
live.current = false;
|
|
143679
|
+
};
|
|
143680
|
+
}, []);
|
|
143681
|
+
(0, react.useEffect)(() => {
|
|
143682
|
+
loadOrderConfig().then((value) => {
|
|
143683
|
+
if (live.current) setConfig(value);
|
|
143684
|
+
}).catch((error) => {
|
|
143685
|
+
if (live.current) setMessage(describe$1(error));
|
|
143686
|
+
});
|
|
143687
|
+
}, []);
|
|
143688
|
+
(0, react.useEffect)(() => {
|
|
143689
|
+
if (!configured) {
|
|
143690
|
+
setPrepared(void 0);
|
|
143691
|
+
return;
|
|
143692
|
+
}
|
|
143693
|
+
const controller = new AbortController();
|
|
143694
|
+
setPreparing(true);
|
|
143695
|
+
setMessage(void 0);
|
|
143696
|
+
setPlaced(void 0);
|
|
143697
|
+
prepareFabrication(boardPath, schematicPath, workspaceRoot, controller.signal, session).then((value) => {
|
|
143698
|
+
if (!controller.signal.aborted) setPrepared(value);
|
|
143699
|
+
}).catch((error) => {
|
|
143700
|
+
if (controller.signal.aborted || isAbortError(error)) return;
|
|
143701
|
+
setMessage(describe$1(error));
|
|
143702
|
+
}).finally(() => {
|
|
143703
|
+
if (!controller.signal.aborted) setPreparing(false);
|
|
143704
|
+
});
|
|
143705
|
+
return () => {
|
|
143706
|
+
controller.abort();
|
|
143707
|
+
};
|
|
143708
|
+
}, [
|
|
143709
|
+
boardPath,
|
|
143710
|
+
schematicPath,
|
|
143711
|
+
workspaceRoot,
|
|
143712
|
+
session,
|
|
143713
|
+
configured
|
|
143714
|
+
]);
|
|
143715
|
+
const facts = prepared?.facts;
|
|
143716
|
+
const specs = (0, react.useMemo)(() => facts === void 0 ? [] : specRows(facts), [facts]);
|
|
143717
|
+
const submit = async (kind) => {
|
|
143718
|
+
setPlacing(kind);
|
|
143719
|
+
setMessage(void 0);
|
|
143720
|
+
try {
|
|
143721
|
+
const result = await placeOrder(kind, {
|
|
143722
|
+
path: boardPath,
|
|
143723
|
+
...schematicPath === void 0 ? {} : { schematic: schematicPath },
|
|
143724
|
+
...workspaceRoot === void 0 ? {} : { cwd: workspaceRoot },
|
|
143725
|
+
...session === void 0 ? {} : { session },
|
|
143726
|
+
quantity,
|
|
143727
|
+
confirm: true
|
|
143728
|
+
}, void 0);
|
|
143729
|
+
setPlaced(result);
|
|
143730
|
+
setConfirming(void 0);
|
|
143731
|
+
setAcknowledged(false);
|
|
143732
|
+
} catch (error) {
|
|
143733
|
+
setMessage(describe$1(error));
|
|
143734
|
+
} finally {
|
|
143735
|
+
setPlacing(void 0);
|
|
143736
|
+
}
|
|
143737
|
+
};
|
|
143738
|
+
const copy = async () => {
|
|
143739
|
+
if (placed === void 0) return;
|
|
143740
|
+
try {
|
|
143741
|
+
await navigator.clipboard.writeText(placed.orderUrl);
|
|
143742
|
+
setCopied(true);
|
|
143743
|
+
setTimeout(() => {
|
|
143744
|
+
setCopied(false);
|
|
143745
|
+
}, 1600);
|
|
143746
|
+
} catch {
|
|
143747
|
+
setCopied(false);
|
|
143748
|
+
}
|
|
143749
|
+
};
|
|
143750
|
+
const reopen = async () => {
|
|
143751
|
+
if (placed === void 0) return;
|
|
143752
|
+
setReopening(true);
|
|
143753
|
+
setMessage(void 0);
|
|
143754
|
+
try {
|
|
143755
|
+
await openOrderUrl(placed.orderUrl);
|
|
143756
|
+
setPlaced({
|
|
143757
|
+
...placed,
|
|
143758
|
+
launched: true,
|
|
143759
|
+
status: "launched"
|
|
143760
|
+
});
|
|
143761
|
+
} catch (error) {
|
|
143762
|
+
setMessage(describe$1(error));
|
|
143763
|
+
} finally {
|
|
143764
|
+
setReopening(false);
|
|
143765
|
+
}
|
|
143766
|
+
};
|
|
143767
|
+
const zipSize = prepared === void 0 ? void 0 : formatBytes(prepared.archive.zipBytes);
|
|
143768
|
+
const assembly = prepared?.assembly;
|
|
143769
|
+
const tokenReady = config?.hasToken ?? false;
|
|
143770
|
+
const header = (0, react.createElement)("div", { style: {
|
|
143771
|
+
display: "flex",
|
|
143772
|
+
flexDirection: "column",
|
|
143773
|
+
gap: 3
|
|
143774
|
+
} }, (0, react.createElement)("div", { style: SPREAD$1 }, (0, react.createElement)("h3", { style: {
|
|
143775
|
+
margin: 0,
|
|
143776
|
+
fontSize: 13,
|
|
143777
|
+
fontWeight: 600,
|
|
143778
|
+
color: C.text,
|
|
143779
|
+
display: "flex",
|
|
143780
|
+
alignItems: "center",
|
|
143781
|
+
gap: 6
|
|
143782
|
+
} }, (0, react.createElement)("span", { style: dotStyle(C.accent) }), "Fabrication & assembly"), preparing ? (0, react.createElement)("span", { style: pillStyle("info") }, "packaging…") : prepared !== void 0 ? (0, react.createElement)("span", { style: pillStyle("ok") }, "package ready") : (0, react.createElement)("span", { style: pillStyle(configured ? "muted" : "warn") }, configured ? "not prepared" : "KiCad missing")), (0, react.createElement)("p", { style: {
|
|
143783
|
+
...MUTED,
|
|
143784
|
+
...MONO_TEXT,
|
|
143785
|
+
fontSize: 10.5
|
|
143786
|
+
} }, boardTitle));
|
|
143787
|
+
const packageCard = (0, react.createElement)("div", { style: cardStyle() }, (0, react.createElement)("div", { style: SPREAD$1 }, (0, react.createElement)("span", { style: SECTION_TITLE }, "Fabrication package"), prepared === void 0 ? null : (0, react.createElement)("span", { style: pillStyle("muted") }, `${String(prepared.archive.files.length)} files · ${zipSize}`)), prepared === void 0 ? (0, react.createElement)("p", { style: MUTED }, preparing ? "Running kicad-cli pcb export gerbers and drill…" : "Not prepared yet.") : (0, react.createElement)("div", { style: {
|
|
143788
|
+
display: "flex",
|
|
143789
|
+
flexWrap: "wrap",
|
|
143790
|
+
gap: 4,
|
|
143791
|
+
maxHeight: 74,
|
|
143792
|
+
overflow: "auto",
|
|
143793
|
+
border: `1px solid ${C.borderSoft}`,
|
|
143794
|
+
borderRadius: R.md,
|
|
143795
|
+
padding: 6,
|
|
143796
|
+
background: C.base
|
|
143797
|
+
} }, ...prepared.archive.files.map((file) => (0, react.createElement)("span", {
|
|
143798
|
+
key: file.name,
|
|
143799
|
+
style: {
|
|
143800
|
+
...pillStyle("muted"),
|
|
143801
|
+
fontSize: 9.5,
|
|
143802
|
+
padding: "0 5px"
|
|
143803
|
+
},
|
|
143804
|
+
title: `${file.name} · ${formatBytes(file.bytes)}`
|
|
143805
|
+
}, file.name))));
|
|
143806
|
+
const pcbCard = workflowCard({
|
|
143807
|
+
tag: "PCB",
|
|
143808
|
+
tagColor: C.ok,
|
|
143809
|
+
title: "Bare board fabrication",
|
|
143810
|
+
subtitle: prepared === void 0 ? "Quotes and orders the selected board through the Huaqiu fabrication service." : `${prepared.archive.zipName} · ${String(prepared.archive.files.length)} gerber/drill files · ${zipSize}`,
|
|
143811
|
+
details: specs.length === 0 ? [{
|
|
143812
|
+
label: "Board",
|
|
143813
|
+
value: boardTitle
|
|
143814
|
+
}] : specs,
|
|
143815
|
+
action: "Submit PCB order",
|
|
143816
|
+
onAction: () => {
|
|
143817
|
+
setAcknowledged(false);
|
|
143818
|
+
setConfirming("pcb");
|
|
143819
|
+
},
|
|
143820
|
+
busy: placing === "pcb",
|
|
143821
|
+
...configured && prepared !== void 0 ? tokenReady ? {} : { blocked: "Sign in to Huaqiu to place an order — the order page opens under your account." } : { blocked: configured ? "Waiting for the fabrication package." : "Configure KiCad to package the board files." }
|
|
143822
|
+
});
|
|
143823
|
+
const smtCard = workflowCard({
|
|
143824
|
+
tag: "PCBA",
|
|
143825
|
+
tagColor: C.info,
|
|
143826
|
+
title: "Turnkey assembly",
|
|
143827
|
+
subtitle: assembly === void 0 ? "Needs the project root schematic for the BOM and component positions." : `${String(assembly.positions)} placements · ${String(assembly.bomLines)} BOM lines · ${formatBytes(assembly.bomBytes + assembly.positionsBytes)}`,
|
|
143828
|
+
details: [
|
|
143829
|
+
{
|
|
143830
|
+
label: "Placements",
|
|
143831
|
+
value: assembly === void 0 ? "—" : String(assembly.positions)
|
|
143832
|
+
},
|
|
143833
|
+
{
|
|
143834
|
+
label: "BOM lines",
|
|
143835
|
+
value: assembly === void 0 ? "—" : String(assembly.bomLines)
|
|
143836
|
+
},
|
|
143837
|
+
{
|
|
143838
|
+
label: "Token",
|
|
143839
|
+
value: tokenReady ? "Huaqiu login" : "signed out"
|
|
143840
|
+
}
|
|
143841
|
+
],
|
|
143842
|
+
action: "Submit assembly order",
|
|
143843
|
+
onAction: () => {
|
|
143844
|
+
setAcknowledged(false);
|
|
143845
|
+
setConfirming("smt");
|
|
143846
|
+
},
|
|
143847
|
+
busy: placing === "smt",
|
|
143848
|
+
...assembly === void 0 ? { blocked: "Select a root schematic so the BOM and positions can be built." } : tokenReady ? {} : { blocked: "Sign in to Huaqiu to order assembly — the page opens under your account." }
|
|
143849
|
+
});
|
|
143850
|
+
const agentHint = (0, react.createElement)("div", { style: {
|
|
143851
|
+
...ROW$2,
|
|
143852
|
+
gap: 4,
|
|
143853
|
+
paddingTop: 2
|
|
143854
|
+
} }, (0, react.createElement)("span", { style: {
|
|
143855
|
+
fontSize: 10,
|
|
143856
|
+
color: C.text3
|
|
143857
|
+
} }, "Agent entry points"), ...[
|
|
143858
|
+
"quote_pcb",
|
|
143859
|
+
"place_pcb_order",
|
|
143860
|
+
"quote_smt",
|
|
143861
|
+
"place_smt_order"
|
|
143862
|
+
].map((name) => (0, react.createElement)("span", {
|
|
143863
|
+
key: name,
|
|
143864
|
+
style: {
|
|
143865
|
+
...pillStyle("muted"),
|
|
143866
|
+
fontSize: 9.5
|
|
143867
|
+
}
|
|
143868
|
+
}, name)));
|
|
143869
|
+
const resultCard = placed === void 0 ? null : (0, react.createElement)("div", {
|
|
143870
|
+
style: cardStyle({ borderColor: "rgba(52,211,153,0.4)" }),
|
|
143871
|
+
"data-hardware-order-result": placed.kind
|
|
143872
|
+
}, (0, react.createElement)("div", { style: SPREAD$1 }, (0, react.createElement)("span", { style: SECTION_TITLE }, `${placed.kind === "pcb" ? "PCB" : "Assembly"} order created`), (0, react.createElement)("span", { style: pillStyle(placed.launched ? "ok" : "muted") }, placed.launched ? "opened in browser" : "ready to open")), (0, react.createElement)("p", { style: MUTED }, placed.message), (0, react.createElement)("a", {
|
|
143873
|
+
style: LINK,
|
|
143874
|
+
href: placed.orderUrl,
|
|
143875
|
+
target: "_blank",
|
|
143876
|
+
rel: "noreferrer noopener",
|
|
143877
|
+
"data-hardware-order-url": true
|
|
143878
|
+
}, placed.orderUrl), (0, react.createElement)("p", { style: {
|
|
143879
|
+
...MUTED,
|
|
143880
|
+
fontSize: 10
|
|
143881
|
+
} }, "Same page KiCad shows in its order webview, opened in your default browser."), (0, react.createElement)("div", { style: ROW$2 }, (0, react.createElement)("button", {
|
|
143882
|
+
type: "button",
|
|
143883
|
+
style: {
|
|
143884
|
+
...buttonStyle("primary"),
|
|
143885
|
+
...disabled(reopening)
|
|
143886
|
+
},
|
|
143887
|
+
disabled: reopening,
|
|
143888
|
+
"data-hardware-order-reopen": true,
|
|
143889
|
+
onClick: () => {
|
|
143890
|
+
reopen();
|
|
143891
|
+
}
|
|
143892
|
+
}, reopening ? "Opening…" : "Open in browser"), (0, react.createElement)("button", {
|
|
143893
|
+
type: "button",
|
|
143894
|
+
style: buttonStyle("secondary"),
|
|
143895
|
+
onClick: () => {
|
|
143896
|
+
copy();
|
|
143897
|
+
}
|
|
143898
|
+
}, copied ? "Copied" : "Copy URL"), (0, react.createElement)("span", { style: {
|
|
143899
|
+
...MUTED,
|
|
143900
|
+
...MONO_TEXT,
|
|
143901
|
+
fontSize: 10
|
|
143902
|
+
} }, `${placed.archive.zipName} · ${formatBytes(placed.archive.zipBytes)}`)));
|
|
143903
|
+
const dialog = confirming === void 0 ? null : (0, react.createElement)("div", {
|
|
143904
|
+
style: DIALOG_BACKDROP,
|
|
143905
|
+
role: "dialog",
|
|
143906
|
+
"aria-modal": true,
|
|
143907
|
+
"aria-label": "Confirm order upload",
|
|
143908
|
+
"data-hardware-order-confirm": confirming
|
|
143909
|
+
}, (0, react.createElement)("div", { style: DIALOG }, (0, react.createElement)("div", { style: {
|
|
143910
|
+
display: "flex",
|
|
143911
|
+
flexDirection: "column",
|
|
143912
|
+
gap: 3
|
|
143913
|
+
} }, (0, react.createElement)("h4", { style: {
|
|
143914
|
+
margin: 0,
|
|
143915
|
+
fontSize: 13,
|
|
143916
|
+
fontWeight: 600
|
|
143917
|
+
} }, confirming === "pcb" ? "Upload board files and create the PCB order?" : "Upload the assembly package?"), (0, react.createElement)("p", { style: MUTED }, "This sends the files below to the Huaqiu order service. The order is created there and its page opens in your default browser; payment still happens on that page.")), (0, react.createElement)("ul", { style: {
|
|
143918
|
+
margin: 0,
|
|
143919
|
+
paddingLeft: 16,
|
|
143920
|
+
fontSize: 11,
|
|
143921
|
+
color: C.text2,
|
|
143922
|
+
lineHeight: 1.7
|
|
143923
|
+
} }, (0, react.createElement)("li", null, `${prepared?.archive.zipName ?? "board.zip"} — gerbers and drill files (${zipSize ?? "—"})`), ...confirming === "smt" ? [(0, react.createElement)("li", { key: "pos" }, `Component positions (${assembly === void 0 ? "—" : formatBytes(assembly.positionsBytes)})`), (0, react.createElement)("li", { key: "bom" }, `Assembly BOM (${assembly === void 0 ? "—" : formatBytes(assembly.bomBytes)})`)] : [], (0, react.createElement)("li", { key: "host" }, (0, react.createElement)("span", { style: MONO_TEXT }, config?.baseUrl ?? "the configured order service"))), (0, react.createElement)("label", { style: {
|
|
143924
|
+
...ROW$2,
|
|
143925
|
+
alignItems: "flex-start",
|
|
143926
|
+
fontSize: 11,
|
|
143927
|
+
color: C.text2,
|
|
143928
|
+
cursor: "pointer"
|
|
143929
|
+
} }, (0, react.createElement)("input", {
|
|
143930
|
+
type: "checkbox",
|
|
143931
|
+
checked: acknowledged,
|
|
143932
|
+
style: {
|
|
143933
|
+
marginTop: 2,
|
|
143934
|
+
accentColor: C.accent
|
|
143935
|
+
},
|
|
143936
|
+
onChange: (event) => {
|
|
143937
|
+
setAcknowledged(event.currentTarget.checked);
|
|
143938
|
+
},
|
|
143939
|
+
"data-hardware-order-ack": true
|
|
143940
|
+
}), "I understand these board files leave this machine."), (0, react.createElement)("div", { style: {
|
|
143941
|
+
...ROW$2,
|
|
143942
|
+
justifyContent: "flex-end"
|
|
143943
|
+
} }, (0, react.createElement)("button", {
|
|
143944
|
+
type: "button",
|
|
143945
|
+
style: buttonStyle("quiet"),
|
|
143946
|
+
onClick: () => {
|
|
143947
|
+
setConfirming(void 0);
|
|
143948
|
+
setAcknowledged(false);
|
|
143949
|
+
}
|
|
143950
|
+
}, "Cancel"), (0, react.createElement)("button", {
|
|
143951
|
+
type: "button",
|
|
143952
|
+
style: {
|
|
143953
|
+
...buttonStyle("primary"),
|
|
143954
|
+
...disabled(!acknowledged || placing !== void 0)
|
|
143955
|
+
},
|
|
143956
|
+
disabled: !acknowledged || placing !== void 0,
|
|
143957
|
+
"data-hardware-order-confirm-submit": true,
|
|
143958
|
+
onClick: () => {
|
|
143959
|
+
submit(confirming);
|
|
143960
|
+
}
|
|
143961
|
+
}, placing === void 0 ? "Upload and open order page" : "Uploading…"))));
|
|
143962
|
+
return (0, react.createElement)("div", {
|
|
143963
|
+
style: {
|
|
143964
|
+
position: "relative",
|
|
143965
|
+
display: "flex",
|
|
143966
|
+
flexDirection: "column",
|
|
143967
|
+
gap: 10,
|
|
143968
|
+
minHeight: 0
|
|
143969
|
+
},
|
|
143970
|
+
"data-hardware-order": true
|
|
143971
|
+
}, header, ...message === void 0 ? [] : [(0, react.createElement)("p", {
|
|
143972
|
+
key: "message",
|
|
143973
|
+
role: "status",
|
|
143974
|
+
style: {
|
|
143975
|
+
...MUTED,
|
|
143976
|
+
color: C.warn,
|
|
143977
|
+
borderLeft: `2px solid ${C.warn}`,
|
|
143978
|
+
paddingLeft: 8
|
|
143979
|
+
}
|
|
143980
|
+
}, message)], (0, react.createElement)("div", { style: {
|
|
143981
|
+
display: "grid",
|
|
143982
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(250px, 1fr))",
|
|
143983
|
+
gap: 10
|
|
143984
|
+
} }, pcbCard, smtCard), (0, react.createElement)("div", { style: {
|
|
143985
|
+
...SPREAD$1,
|
|
143986
|
+
...cardStyle({
|
|
143987
|
+
flexDirection: "row",
|
|
143988
|
+
alignItems: "center"
|
|
143989
|
+
})
|
|
143990
|
+
} }, (0, react.createElement)("span", { style: {
|
|
143991
|
+
fontSize: 11,
|
|
143992
|
+
color: C.text2
|
|
143993
|
+
} }, "Production batch"), (0, react.createElement)("select", {
|
|
143994
|
+
style: {
|
|
143995
|
+
...SELECT,
|
|
143996
|
+
width: "auto"
|
|
143997
|
+
},
|
|
143998
|
+
value: quantity,
|
|
143999
|
+
"data-hardware-order-quantity": true,
|
|
144000
|
+
onChange: (event) => {
|
|
144001
|
+
setQuantity(Number(event.currentTarget.value));
|
|
144002
|
+
}
|
|
144003
|
+
}, ...QUANTITIES.map((count) => (0, react.createElement)("option", {
|
|
144004
|
+
key: count,
|
|
144005
|
+
value: count
|
|
144006
|
+
}, `${String(count)} units`))), (0, react.createElement)("span", { style: {
|
|
144007
|
+
...MUTED,
|
|
144008
|
+
...MONO_TEXT,
|
|
144009
|
+
fontSize: 10
|
|
144010
|
+
} }, `quote basis · ${String(quantity)} pcs`)), packageCard, resultCard, agentHint, dialog);
|
|
144011
|
+
}
|
|
144012
|
+
//#endregion
|
|
142595
144013
|
//#region src/client/preview.tsx
|
|
142596
144014
|
/**
|
|
142597
|
-
* One preview surface per destination.
|
|
142598
|
-
*
|
|
142599
|
-
*
|
|
144015
|
+
* One preview surface per destination.
|
|
144016
|
+
*
|
|
144017
|
+
* Every asynchronous mount is keyed by the navigation revision and owns an
|
|
144018
|
+
* AbortController, so a superseded navigation disposes its predecessor instead
|
|
144019
|
+
* of painting over it. A load that finishes after the viewer moved on is
|
|
144020
|
+
* disposed, never attached.
|
|
142600
144021
|
*/
|
|
142601
144022
|
const STAGE = {
|
|
142602
144023
|
position: "relative",
|
|
142603
|
-
flex: "1 1
|
|
142604
|
-
minHeight:
|
|
144024
|
+
flex: "1 1 0",
|
|
144025
|
+
minHeight: 200,
|
|
142605
144026
|
overflow: "hidden",
|
|
142606
|
-
border:
|
|
142607
|
-
borderRadius:
|
|
142608
|
-
background:
|
|
144027
|
+
border: `1px solid ${C.border}`,
|
|
144028
|
+
borderRadius: R.lg,
|
|
144029
|
+
background: C.base
|
|
144030
|
+
};
|
|
144031
|
+
const OVERLAY = {
|
|
144032
|
+
position: "absolute",
|
|
144033
|
+
bottom: 8,
|
|
144034
|
+
left: 8,
|
|
144035
|
+
display: "flex",
|
|
144036
|
+
alignItems: "center",
|
|
144037
|
+
gap: 6,
|
|
144038
|
+
padding: "2px 8px",
|
|
144039
|
+
borderRadius: R.pill,
|
|
144040
|
+
background: "rgba(0,0,0,0.55)",
|
|
144041
|
+
color: "#e4e4e7",
|
|
144042
|
+
fontSize: 10,
|
|
144043
|
+
fontFamily: MONO,
|
|
144044
|
+
backdropFilter: "blur(6px)",
|
|
144045
|
+
pointerEvents: "none",
|
|
144046
|
+
maxWidth: "calc(100% - 16px)",
|
|
144047
|
+
overflow: "hidden"
|
|
144048
|
+
};
|
|
144049
|
+
const TOP_RIGHT = {
|
|
144050
|
+
position: "absolute",
|
|
144051
|
+
top: 8,
|
|
144052
|
+
right: 8,
|
|
144053
|
+
display: "flex",
|
|
144054
|
+
alignItems: "center",
|
|
144055
|
+
gap: 4,
|
|
144056
|
+
padding: "1px 3px",
|
|
144057
|
+
pointerEvents: "none"
|
|
142609
144058
|
};
|
|
142610
|
-
const
|
|
144059
|
+
const CENTER = {
|
|
142611
144060
|
display: "flex",
|
|
144061
|
+
flexDirection: "column",
|
|
142612
144062
|
alignItems: "center",
|
|
142613
144063
|
justifyContent: "center",
|
|
142614
144064
|
height: "100%",
|
|
144065
|
+
gap: 6,
|
|
144066
|
+
padding: 20,
|
|
144067
|
+
textAlign: "center"
|
|
144068
|
+
};
|
|
144069
|
+
const CENTER_TEXT = {
|
|
142615
144070
|
margin: 0,
|
|
142616
|
-
|
|
142617
|
-
|
|
142618
|
-
|
|
142619
|
-
|
|
144071
|
+
fontSize: 11,
|
|
144072
|
+
color: C.text3,
|
|
144073
|
+
maxWidth: 340,
|
|
144074
|
+
lineHeight: 1.6
|
|
142620
144075
|
};
|
|
142621
144076
|
const TABLE = {
|
|
142622
144077
|
width: "100%",
|
|
142623
144078
|
borderCollapse: "collapse",
|
|
142624
|
-
fontSize:
|
|
144079
|
+
fontSize: 11
|
|
142625
144080
|
};
|
|
142626
144081
|
const TH = {
|
|
142627
144082
|
textAlign: "left",
|
|
142628
|
-
padding: "
|
|
142629
|
-
|
|
144083
|
+
padding: "5px 8px",
|
|
144084
|
+
position: "sticky",
|
|
144085
|
+
top: 0,
|
|
144086
|
+
zIndex: 1,
|
|
144087
|
+
background: C.raised,
|
|
144088
|
+
color: C.text2,
|
|
144089
|
+
fontWeight: 600,
|
|
144090
|
+
fontSize: 10,
|
|
144091
|
+
borderBottom: `1px solid ${C.border}`,
|
|
144092
|
+
whiteSpace: "nowrap"
|
|
142630
144093
|
};
|
|
142631
144094
|
const TD = {
|
|
142632
|
-
padding: "4px
|
|
142633
|
-
borderBottom:
|
|
142634
|
-
verticalAlign: "top"
|
|
142635
|
-
|
|
142636
|
-
const SCRIPT = {
|
|
142637
|
-
margin: 0,
|
|
142638
|
-
padding: "8px 10px",
|
|
142639
|
-
borderRadius: 6,
|
|
142640
|
-
fontSize: 11,
|
|
142641
|
-
whiteSpace: "pre-wrap",
|
|
142642
|
-
wordBreak: "break-all",
|
|
142643
|
-
background: "color-mix(in srgb, currentColor 6%, transparent)"
|
|
144095
|
+
padding: "4px 8px",
|
|
144096
|
+
borderBottom: `1px solid ${C.borderSoft}`,
|
|
144097
|
+
verticalAlign: "top",
|
|
144098
|
+
color: C.text
|
|
142644
144099
|
};
|
|
144100
|
+
R.md, C.base, C.text2;
|
|
142645
144101
|
function describe(error) {
|
|
142646
|
-
|
|
142647
|
-
return String(error);
|
|
144102
|
+
return error instanceof Error ? error.message : String(error);
|
|
142648
144103
|
}
|
|
142649
|
-
function
|
|
142650
|
-
return
|
|
142651
|
-
|
|
144104
|
+
function shortRevision(revision) {
|
|
144105
|
+
return revision === void 0 ? "" : revision.slice(0, 10);
|
|
144106
|
+
}
|
|
144107
|
+
function statusLine(status, message, hint) {
|
|
144108
|
+
const text = message ?? (status === "loading" ? "Loading saved artifact…" : "");
|
|
144109
|
+
return (0, react.createElement)("div", {
|
|
144110
|
+
style: CENTER,
|
|
142652
144111
|
role: "status",
|
|
142653
144112
|
"data-hardware-stage": status
|
|
142654
|
-
},
|
|
144113
|
+
}, status === "loading" ? (0, react.createElement)("span", { style: {
|
|
144114
|
+
width: 18,
|
|
144115
|
+
height: 18,
|
|
144116
|
+
borderRadius: R.pill,
|
|
144117
|
+
border: `2px solid ${C.borderSoft}`,
|
|
144118
|
+
borderTopColor: C.info,
|
|
144119
|
+
animation: "dsh-hw-spin 900ms linear infinite"
|
|
144120
|
+
} }) : (0, react.createElement)("span", { style: {
|
|
144121
|
+
...pillStyle("warn"),
|
|
144122
|
+
fontFamily: MONO
|
|
144123
|
+
} }, "unavailable"), (0, react.createElement)("p", { style: CENTER_TEXT }, text), hint === void 0 ? null : (0, react.createElement)("p", { style: {
|
|
144124
|
+
...CENTER_TEXT,
|
|
144125
|
+
fontSize: 10,
|
|
144126
|
+
color: C.text3
|
|
144127
|
+
} }, hint));
|
|
144128
|
+
}
|
|
144129
|
+
function Stage(props) {
|
|
144130
|
+
return (0, react.createElement)("div", {
|
|
144131
|
+
style: {
|
|
144132
|
+
...STAGE,
|
|
144133
|
+
display: "flex",
|
|
144134
|
+
flexDirection: "column"
|
|
144135
|
+
},
|
|
144136
|
+
...props.attrs
|
|
144137
|
+
}, props.topRight === void 0 ? null : (0, react.createElement)("div", { style: TOP_RIGHT }, props.topRight), props.children, props.overlay === void 0 ? null : (0, react.createElement)("div", { style: OVERLAY }, props.overlay));
|
|
142655
144138
|
}
|
|
142656
|
-
function EcadStage({ kind, path, revision }) {
|
|
144139
|
+
function EcadStage({ kind, path, revision, session, cwd }) {
|
|
142657
144140
|
const container = (0, react.useRef)(null);
|
|
142658
144141
|
const [status, setStatus] = (0, react.useState)("loading");
|
|
142659
144142
|
const [message, setMessage] = (0, react.useState)();
|
|
@@ -142669,7 +144152,9 @@ void main() {
|
|
|
142669
144152
|
element.replaceChildren();
|
|
142670
144153
|
mountEcad(kind, path, element, {
|
|
142671
144154
|
signal: controller.signal,
|
|
142672
|
-
...revision === void 0 ? {} : { revision }
|
|
144155
|
+
...revision === void 0 ? {} : { revision },
|
|
144156
|
+
...session === void 0 ? {} : { session },
|
|
144157
|
+
...cwd === void 0 ? {} : { cwd }
|
|
142673
144158
|
}).then((result) => {
|
|
142674
144159
|
if (!live) {
|
|
142675
144160
|
result.dispose();
|
|
@@ -142692,52 +144177,76 @@ void main() {
|
|
|
142692
144177
|
}, [
|
|
142693
144178
|
kind,
|
|
142694
144179
|
path,
|
|
142695
|
-
revision
|
|
144180
|
+
revision,
|
|
144181
|
+
session,
|
|
144182
|
+
cwd
|
|
142696
144183
|
]);
|
|
142697
|
-
return (0, react.createElement)(
|
|
142698
|
-
|
|
142699
|
-
"data-hardware-ecad": kind
|
|
142700
|
-
|
|
144184
|
+
return (0, react.createElement)(Stage, {
|
|
144185
|
+
label: kind,
|
|
144186
|
+
attrs: { "data-hardware-ecad": kind },
|
|
144187
|
+
topRight: status === "ready" ? [(0, react.createElement)("span", {
|
|
144188
|
+
key: "kind",
|
|
144189
|
+
style: {
|
|
144190
|
+
...pillStyle("muted"),
|
|
144191
|
+
fontSize: 9.5
|
|
144192
|
+
}
|
|
144193
|
+
}, kind === "schematic" ? "sheet" : "board"), sourceRevision === void 0 ? null : (0, react.createElement)("span", {
|
|
144194
|
+
key: "rev",
|
|
144195
|
+
style: {
|
|
144196
|
+
...pillStyle("muted"),
|
|
144197
|
+
fontSize: 9.5
|
|
144198
|
+
}
|
|
144199
|
+
}, `rev ${shortRevision(sourceRevision)}`)] : void 0,
|
|
144200
|
+
overlay: status === "ready" ? [(0, react.createElement)("span", {
|
|
144201
|
+
key: "dot",
|
|
144202
|
+
style: dotStyle(kind === "schematic" ? C.info : C.ok, 6)
|
|
144203
|
+
}), "saved file · scroll to zoom, drag to pan"] : void 0
|
|
144204
|
+
}, (0, react.createElement)("div", { style: {
|
|
144205
|
+
position: "relative",
|
|
144206
|
+
flex: "1 1 0",
|
|
144207
|
+
minHeight: 160
|
|
144208
|
+
} }, ...status === "ready" ? [] : [statusLine(status, message, status === "error" ? "Saved-file preview only; the file must exist and parse." : void 0)], (0, react.createElement)("div", {
|
|
142701
144209
|
key: "canvas",
|
|
142702
144210
|
ref: container,
|
|
142703
144211
|
style: {
|
|
142704
|
-
|
|
142705
|
-
|
|
144212
|
+
position: "absolute",
|
|
144213
|
+
inset: 0
|
|
142706
144214
|
}
|
|
142707
|
-
})
|
|
142708
|
-
key: "rev",
|
|
142709
|
-
style: {
|
|
142710
|
-
...MESSAGE,
|
|
142711
|
-
height: "auto",
|
|
142712
|
-
justifyContent: "flex-start",
|
|
142713
|
-
padding: "4px 8px"
|
|
142714
|
-
}
|
|
142715
|
-
}, `Saved source revision ${sourceRevision.slice(0, 12)}…`)] : []);
|
|
144215
|
+
})));
|
|
142716
144216
|
}
|
|
142717
|
-
function GlbStage({ boardPath, cwd }) {
|
|
144217
|
+
function GlbStage({ boardPath, cwd, session, configured }) {
|
|
142718
144218
|
const container = (0, react.useRef)(null);
|
|
142719
144219
|
const [status, setStatus] = (0, react.useState)("loading");
|
|
142720
144220
|
const [message, setMessage] = (0, react.useState)();
|
|
142721
144221
|
const [revision, setRevision] = (0, react.useState)();
|
|
144222
|
+
const [cached, setCached] = (0, react.useState)(false);
|
|
142722
144223
|
(0, react.useEffect)(() => {
|
|
142723
144224
|
const element = container.current;
|
|
142724
144225
|
if (element === null) return;
|
|
144226
|
+
if (!configured) {
|
|
144227
|
+
setStatus("error");
|
|
144228
|
+
setMessage("KiCad is not configured.");
|
|
144229
|
+
return;
|
|
144230
|
+
}
|
|
142725
144231
|
const controller = new AbortController();
|
|
142726
144232
|
let live = true;
|
|
142727
144233
|
let mounted;
|
|
142728
144234
|
setStatus("loading");
|
|
142729
|
-
setMessage(
|
|
144235
|
+
setMessage("Exporting the PCB to GLB with kicad-cli…");
|
|
142730
144236
|
element.replaceChildren();
|
|
142731
144237
|
const run = async () => {
|
|
142732
|
-
const glb = await prepareBoardGlb(boardPath, cwd, controller.signal);
|
|
144238
|
+
const glb = await prepareBoardGlb(boardPath, cwd, controller.signal, session);
|
|
142733
144239
|
if (!live) return;
|
|
142734
144240
|
setRevision(glb.revision);
|
|
144241
|
+
setCached(glb.cached);
|
|
144242
|
+
setMessage("Loading the 3D model…");
|
|
142735
144243
|
mounted = await mountGlb(glb.url, element, { signal: controller.signal });
|
|
142736
144244
|
if (!live) {
|
|
142737
144245
|
mounted.dispose();
|
|
142738
144246
|
return;
|
|
142739
144247
|
}
|
|
142740
144248
|
setStatus("ready");
|
|
144249
|
+
setMessage(void 0);
|
|
142741
144250
|
};
|
|
142742
144251
|
run().catch((error) => {
|
|
142743
144252
|
if (!live || isAbortError(error)) return;
|
|
@@ -142750,36 +144259,61 @@ void main() {
|
|
|
142750
144259
|
mounted?.dispose();
|
|
142751
144260
|
element.replaceChildren();
|
|
142752
144261
|
};
|
|
142753
|
-
}, [
|
|
142754
|
-
|
|
142755
|
-
|
|
142756
|
-
|
|
142757
|
-
|
|
144262
|
+
}, [
|
|
144263
|
+
boardPath,
|
|
144264
|
+
cwd,
|
|
144265
|
+
session,
|
|
144266
|
+
configured
|
|
144267
|
+
]);
|
|
144268
|
+
return (0, react.createElement)(Stage, {
|
|
144269
|
+
label: "3d",
|
|
144270
|
+
attrs: { "data-hardware-glb": true },
|
|
144271
|
+
topRight: status === "ready" ? [(0, react.createElement)("span", {
|
|
144272
|
+
key: "mode",
|
|
144273
|
+
style: pillStyle("muted", { fontSize: 9.5 })
|
|
144274
|
+
}, cached ? "cached" : "generated"), (0, react.createElement)("span", {
|
|
144275
|
+
key: "rev",
|
|
144276
|
+
style: pillStyle("muted", { fontSize: 9.5 })
|
|
144277
|
+
}, `rev ${shortRevision(revision)}`)] : void 0,
|
|
144278
|
+
overlay: status === "ready" ? "drag to orbit · wheel to zoom" : "kicad-cli pcb export glb"
|
|
144279
|
+
}, (0, react.createElement)("div", { style: {
|
|
144280
|
+
position: "relative",
|
|
144281
|
+
flex: "1 1 0",
|
|
144282
|
+
minHeight: 160
|
|
144283
|
+
} }, ...status === "ready" ? [] : [statusLine(status, message)], (0, react.createElement)("div", {
|
|
142758
144284
|
key: "canvas",
|
|
142759
144285
|
ref: container,
|
|
142760
144286
|
style: {
|
|
142761
|
-
|
|
142762
|
-
|
|
144287
|
+
position: "absolute",
|
|
144288
|
+
inset: 0
|
|
142763
144289
|
}
|
|
142764
|
-
})
|
|
142765
|
-
key: "rev",
|
|
142766
|
-
style: {
|
|
142767
|
-
...MESSAGE,
|
|
142768
|
-
height: "auto",
|
|
142769
|
-
justifyContent: "flex-start",
|
|
142770
|
-
padding: "4px 8px"
|
|
142771
|
-
}
|
|
142772
|
-
}, `Generated from saved board revision ${revision.slice(0, 12)}…`)] : []);
|
|
144290
|
+
})));
|
|
142773
144291
|
}
|
|
142774
|
-
|
|
144292
|
+
/**
|
|
144293
|
+
* BOM table.
|
|
144294
|
+
*
|
|
144295
|
+
* Rows come from `kicad-cli sch export bom`, so a missing installation is a
|
|
144296
|
+
* configuration state, not a failure: the stage reports it without calling the
|
|
144297
|
+
* host, the same way the 3D stage does.
|
|
144298
|
+
*/
|
|
144299
|
+
function BomStage({ schematicPath, session, cwd, configured }) {
|
|
142775
144300
|
const [status, setStatus] = (0, react.useState)("loading");
|
|
142776
144301
|
const [message, setMessage] = (0, react.useState)();
|
|
142777
144302
|
const [bom, setBom] = (0, react.useState)();
|
|
142778
144303
|
(0, react.useEffect)(() => {
|
|
144304
|
+
if (!configured) {
|
|
144305
|
+
setStatus("error");
|
|
144306
|
+
setMessage("KiCad is not configured.");
|
|
144307
|
+
return;
|
|
144308
|
+
}
|
|
142779
144309
|
const controller = new AbortController();
|
|
142780
144310
|
let live = true;
|
|
142781
144311
|
setStatus("loading");
|
|
142782
|
-
loadBom(schematicPath,
|
|
144312
|
+
loadBom(schematicPath, {
|
|
144313
|
+
signal: controller.signal,
|
|
144314
|
+
...session === void 0 ? {} : { session },
|
|
144315
|
+
...cwd === void 0 ? {} : { cwd }
|
|
144316
|
+
}).then((projection) => {
|
|
142783
144317
|
if (!live) return;
|
|
142784
144318
|
setBom(projection);
|
|
142785
144319
|
setStatus("ready");
|
|
@@ -142792,23 +144326,45 @@ void main() {
|
|
|
142792
144326
|
live = false;
|
|
142793
144327
|
controller.abort();
|
|
142794
144328
|
};
|
|
142795
|
-
}, [
|
|
142796
|
-
|
|
142797
|
-
|
|
142798
|
-
|
|
142799
|
-
|
|
144329
|
+
}, [
|
|
144330
|
+
schematicPath,
|
|
144331
|
+
session,
|
|
144332
|
+
cwd,
|
|
144333
|
+
configured
|
|
144334
|
+
]);
|
|
144335
|
+
if (status !== "ready" || bom === void 0) return (0, react.createElement)(Stage, {
|
|
144336
|
+
label: "bom",
|
|
144337
|
+
attrs: { "data-hardware-bom": true },
|
|
144338
|
+
overlay: "kicad-cli sch export bom"
|
|
144339
|
+
}, (0, react.createElement)("div", { style: {
|
|
144340
|
+
flex: "1 1 0",
|
|
144341
|
+
display: "flex"
|
|
144342
|
+
} }, statusLine(status, message, status === "error" && !configured ? "BOM rows come from kicad-cli sch export bom. Configure KiCad in Settings → Hardware Engineering." : void 0)));
|
|
144343
|
+
const total = bom.rows.reduce((sum, row) => sum + row.quantity, 0);
|
|
142800
144344
|
return (0, react.createElement)("div", {
|
|
142801
|
-
style: {
|
|
142802
|
-
|
|
142803
|
-
overflow: "
|
|
142804
|
-
|
|
142805
|
-
|
|
144345
|
+
style: cardStyle({
|
|
144346
|
+
padding: 0,
|
|
144347
|
+
overflow: "hidden",
|
|
144348
|
+
flex: "1 1 0",
|
|
144349
|
+
minHeight: 0
|
|
144350
|
+
}),
|
|
142806
144351
|
"data-hardware-bom": true
|
|
142807
|
-
}, (0, react.createElement)("
|
|
142808
|
-
|
|
142809
|
-
|
|
142810
|
-
|
|
142811
|
-
|
|
144352
|
+
}, (0, react.createElement)("div", { style: {
|
|
144353
|
+
display: "flex",
|
|
144354
|
+
alignItems: "center",
|
|
144355
|
+
justifyContent: "space-between",
|
|
144356
|
+
gap: 8,
|
|
144357
|
+
padding: "8px 10px",
|
|
144358
|
+
borderBottom: `1px solid ${C.border}`
|
|
144359
|
+
} }, (0, react.createElement)("span", { style: SECTION_TITLE }, `Bill of materials · ${String(bom.rows.length)} lines`), (0, react.createElement)("div", { style: {
|
|
144360
|
+
display: "flex",
|
|
144361
|
+
gap: 4,
|
|
144362
|
+
alignItems: "center"
|
|
144363
|
+
} }, (0, react.createElement)("span", { style: pillStyle("muted") }, `${String(total)} placements`), (0, react.createElement)("span", { style: pillStyle("muted") }, `rev ${shortRevision(bom.revision)}`))), (0, react.createElement)("div", { style: {
|
|
144364
|
+
flex: "1 1 0",
|
|
144365
|
+
minHeight: 0,
|
|
144366
|
+
overflow: "auto"
|
|
144367
|
+
} }, (0, react.createElement)("table", { style: TABLE }, (0, react.createElement)("thead", {}, (0, react.createElement)("tr", {}, ...[
|
|
142812
144368
|
"Refs",
|
|
142813
144369
|
"Qty",
|
|
142814
144370
|
"Value",
|
|
@@ -142817,236 +144373,563 @@ void main() {
|
|
|
142817
144373
|
].map((label) => (0, react.createElement)("th", {
|
|
142818
144374
|
key: label,
|
|
142819
144375
|
style: TH
|
|
142820
|
-
}, label)))), (0, react.createElement)("tbody", {}, ...bom.rows.map((row, index) => (0, react.createElement)("tr", {
|
|
142821
|
-
|
|
142822
|
-
|
|
142823
|
-
|
|
142824
|
-
|
|
142825
|
-
|
|
142826
|
-
|
|
142827
|
-
|
|
142828
|
-
|
|
142829
|
-
|
|
142830
|
-
|
|
142831
|
-
|
|
142832
|
-
|
|
142833
|
-
|
|
142834
|
-
|
|
142835
|
-
|
|
142836
|
-
|
|
142837
|
-
|
|
142838
|
-
|
|
142839
|
-
|
|
142840
|
-
return () => {
|
|
142841
|
-
live = false;
|
|
142842
|
-
controller.abort();
|
|
142843
|
-
};
|
|
142844
|
-
}, [schematicPath]);
|
|
142845
|
-
const calls = [
|
|
142846
|
-
{
|
|
142847
|
-
tool: "quote_pcb",
|
|
142848
|
-
args: { pcbPath: boardPath }
|
|
142849
|
-
},
|
|
142850
|
-
{
|
|
142851
|
-
tool: "place_pcb_order",
|
|
142852
|
-
args: { pcbPath: boardPath }
|
|
142853
|
-
},
|
|
142854
|
-
{
|
|
142855
|
-
tool: "quote_smt",
|
|
142856
|
-
args: { pcbPath: boardPath }
|
|
142857
|
-
},
|
|
142858
|
-
{
|
|
142859
|
-
tool: "place_smt_order",
|
|
142860
|
-
args: { pcbPath: boardPath }
|
|
142861
|
-
}
|
|
142862
|
-
];
|
|
142863
|
-
return (0, react.createElement)("div", {
|
|
142864
|
-
style: {
|
|
142865
|
-
...STAGE,
|
|
142866
|
-
overflow: "auto",
|
|
142867
|
-
padding: 10,
|
|
142868
|
-
display: "flex",
|
|
142869
|
-
flexDirection: "column",
|
|
142870
|
-
gap: 8
|
|
142871
|
-
},
|
|
142872
|
-
"data-hardware-order": true
|
|
142873
|
-
}, (0, react.createElement)("p", { style: {
|
|
142874
|
-
...MESSAGE,
|
|
142875
|
-
height: "auto",
|
|
142876
|
-
padding: 0,
|
|
142877
|
-
justifyContent: "flex-start"
|
|
142878
|
-
} }, `Selected board: ${boardPath}`), (0, react.createElement)("p", { style: {
|
|
142879
|
-
...MESSAGE,
|
|
142880
|
-
height: "auto",
|
|
142881
|
-
padding: 0,
|
|
142882
|
-
justifyContent: "flex-start"
|
|
142883
|
-
} }, lines === void 0 ? "BOM context unavailable." : `BOM context: ${String(lines)} grouped lines from the selected project.`), (0, react.createElement)("p", { style: {
|
|
142884
|
-
...MESSAGE,
|
|
142885
|
-
height: "auto",
|
|
142886
|
-
padding: 0,
|
|
142887
|
-
justifyContent: "flex-start"
|
|
142888
|
-
} }, "Ask the agent to run one of these existing tool calls. Quoting and ordering keep their own confirmation step; this panel never places an order."), ...calls.map((call) => (0, react.createElement)("div", { key: call.tool }, (0, react.createElement)("p", { style: {
|
|
142889
|
-
margin: "0 0 4px",
|
|
142890
|
-
fontSize: 12,
|
|
142891
|
-
fontWeight: 600
|
|
142892
|
-
} }, call.tool), (0, react.createElement)("pre", { style: SCRIPT }, JSON.stringify(call, null, 2)))));
|
|
144376
|
+
}, label)))), (0, react.createElement)("tbody", {}, ...bom.rows.map((row, index) => (0, react.createElement)("tr", {
|
|
144377
|
+
key: `${row.references.join(",")}:${String(index)}`,
|
|
144378
|
+
style: index % 2 === 1 ? { background: "color-mix(in srgb, currentColor 3%, transparent)" } : void 0
|
|
144379
|
+
}, (0, react.createElement)("td", { style: {
|
|
144380
|
+
...TD,
|
|
144381
|
+
...MONO_TEXT,
|
|
144382
|
+
whiteSpace: "nowrap"
|
|
144383
|
+
} }, row.references.join(" ")), (0, react.createElement)("td", { style: {
|
|
144384
|
+
...TD,
|
|
144385
|
+
...MONO_TEXT
|
|
144386
|
+
} }, String(row.quantity)), (0, react.createElement)("td", { style: TD }, row.value), (0, react.createElement)("td", { style: {
|
|
144387
|
+
...TD,
|
|
144388
|
+
color: C.text2,
|
|
144389
|
+
fontFamily: MONO,
|
|
144390
|
+
fontSize: 10
|
|
144391
|
+
} }, row.footprint), (0, react.createElement)("td", { style: {
|
|
144392
|
+
...TD,
|
|
144393
|
+
color: C.text3,
|
|
144394
|
+
fontSize: 10
|
|
144395
|
+
} }, [row.dnp ? "DNP" : "", ...Object.entries(row.fields).map(([key, value]) => `${key}=${value}`)].filter(Boolean).join(" · "))))))));
|
|
142893
144396
|
}
|
|
142894
144397
|
/** Destination → preview dispatcher. */
|
|
142895
|
-
function HardwarePreview({ destination, artifact,
|
|
144398
|
+
function HardwarePreview({ destination, artifact, schematicPath, workspaceRoot, session, revision, configured = false }) {
|
|
142896
144399
|
if (artifact === void 0) return null;
|
|
142897
144400
|
const key = `${destination}:${artifact.path}:${String(revision)}`;
|
|
142898
144401
|
if (destination === "schematic" || destination === "pcb") return (0, react.createElement)(EcadStage, {
|
|
142899
144402
|
key,
|
|
142900
144403
|
kind: destination === "schematic" ? "schematic" : "pcb",
|
|
142901
144404
|
path: artifact.path,
|
|
142902
|
-
revision: artifact.revision
|
|
144405
|
+
...artifact.revision === void 0 ? {} : { revision: artifact.revision },
|
|
144406
|
+
...session === void 0 ? {} : { session },
|
|
144407
|
+
...workspaceRoot === void 0 ? {} : { cwd: workspaceRoot }
|
|
142903
144408
|
});
|
|
142904
144409
|
if (destination === "3d") return (0, react.createElement)(GlbStage, {
|
|
142905
144410
|
key,
|
|
142906
144411
|
boardPath: artifact.path,
|
|
142907
|
-
cwd:
|
|
144412
|
+
...workspaceRoot === void 0 ? {} : { cwd: workspaceRoot },
|
|
144413
|
+
...session === void 0 ? {} : { session },
|
|
144414
|
+
configured
|
|
142908
144415
|
});
|
|
142909
144416
|
if (destination === "bom") return (0, react.createElement)(BomStage, {
|
|
142910
144417
|
key,
|
|
142911
|
-
schematicPath: artifact.path
|
|
144418
|
+
schematicPath: artifact.path,
|
|
144419
|
+
...session === void 0 ? {} : { session },
|
|
144420
|
+
...workspaceRoot === void 0 ? {} : { cwd: workspaceRoot },
|
|
144421
|
+
configured
|
|
142912
144422
|
});
|
|
142913
|
-
return (0, react.createElement)(
|
|
144423
|
+
return (0, react.createElement)(OrderPanel, {
|
|
142914
144424
|
key,
|
|
142915
144425
|
boardPath: artifact.path,
|
|
142916
|
-
|
|
144426
|
+
boardTitle: artifact.title || artifact.path,
|
|
144427
|
+
...schematicPath === void 0 ? {} : { schematicPath },
|
|
144428
|
+
...workspaceRoot === void 0 ? {} : { workspaceRoot },
|
|
144429
|
+
...session === void 0 ? {} : { session },
|
|
144430
|
+
configured
|
|
142917
144431
|
});
|
|
142918
144432
|
}
|
|
142919
144433
|
//#endregion
|
|
144434
|
+
//#region src/client/wizard.tsx
|
|
144435
|
+
/**
|
|
144436
|
+
* First-run setup wizard.
|
|
144437
|
+
*
|
|
144438
|
+
* Rendered from the root navigation seat so it can appear before any session
|
|
144439
|
+
* exists. It only guides the user towards a local KiCad/SolidCraft executable:
|
|
144440
|
+
* everything on it is skippable, and completion is recorded in the host-backed
|
|
144441
|
+
* product config (`onboardingComplete`) rather than in browser storage.
|
|
144442
|
+
*
|
|
144443
|
+
* It is a full-screen modal, so it must never mount on a guess. Both facts it
|
|
144444
|
+
* depends on arrive asynchronously — the host's synced config (is onboarding
|
|
144445
|
+
* recorded?) and one local install probe (is KiCad already usable?) — and
|
|
144446
|
+
* {@link wizardPhase} refuses to decide until they are known. Deciding on the
|
|
144447
|
+
* initial `loading`/`undefined` values is what made the wizard flash on first
|
|
144448
|
+
* launch and on every browser refresh: it mounted, then unmounted a frame later
|
|
144449
|
+
* when the real answer landed.
|
|
144450
|
+
*/
|
|
144451
|
+
const BACKDROP = {
|
|
144452
|
+
position: "fixed",
|
|
144453
|
+
inset: 0,
|
|
144454
|
+
zIndex: 60,
|
|
144455
|
+
display: "flex",
|
|
144456
|
+
alignItems: "center",
|
|
144457
|
+
justifyContent: "center",
|
|
144458
|
+
padding: 16,
|
|
144459
|
+
background: "rgba(0,0,0,0.6)",
|
|
144460
|
+
backdropFilter: "blur(3px)"
|
|
144461
|
+
};
|
|
144462
|
+
const PANEL = {
|
|
144463
|
+
width: "min(520px, 100%)",
|
|
144464
|
+
maxHeight: "85vh",
|
|
144465
|
+
overflow: "auto",
|
|
144466
|
+
borderRadius: R.lg,
|
|
144467
|
+
padding: 16,
|
|
144468
|
+
display: "flex",
|
|
144469
|
+
flexDirection: "column",
|
|
144470
|
+
gap: 12,
|
|
144471
|
+
color: C.text,
|
|
144472
|
+
background: C.panel,
|
|
144473
|
+
border: `1px solid ${C.border}`,
|
|
144474
|
+
boxShadow: "0 28px 70px rgba(0,0,0,0.55)",
|
|
144475
|
+
fontSize: 12,
|
|
144476
|
+
lineHeight: 1.5
|
|
144477
|
+
};
|
|
144478
|
+
const TITLE = {
|
|
144479
|
+
margin: 0,
|
|
144480
|
+
fontSize: 15,
|
|
144481
|
+
fontWeight: 600,
|
|
144482
|
+
letterSpacing: .1
|
|
144483
|
+
};
|
|
144484
|
+
const LEAD = {
|
|
144485
|
+
margin: 0,
|
|
144486
|
+
fontSize: 11.5,
|
|
144487
|
+
lineHeight: 1.6,
|
|
144488
|
+
color: C.text2
|
|
144489
|
+
};
|
|
144490
|
+
const ROW$1 = {
|
|
144491
|
+
display: "flex",
|
|
144492
|
+
alignItems: "center",
|
|
144493
|
+
gap: 8,
|
|
144494
|
+
flexWrap: "wrap"
|
|
144495
|
+
};
|
|
144496
|
+
const SPREAD = {
|
|
144497
|
+
...ROW$1,
|
|
144498
|
+
justifyContent: "space-between"
|
|
144499
|
+
};
|
|
144500
|
+
const STEP_LABEL = {
|
|
144501
|
+
fontSize: 10,
|
|
144502
|
+
color: C.text3
|
|
144503
|
+
};
|
|
144504
|
+
const BRAND_MARK = {
|
|
144505
|
+
width: 26,
|
|
144506
|
+
height: 26,
|
|
144507
|
+
borderRadius: R.sm,
|
|
144508
|
+
display: "flex",
|
|
144509
|
+
alignItems: "center",
|
|
144510
|
+
justifyContent: "center",
|
|
144511
|
+
fontSize: 11,
|
|
144512
|
+
fontWeight: 700,
|
|
144513
|
+
color: "#fff",
|
|
144514
|
+
background: C.accent,
|
|
144515
|
+
boxShadow: "0 4px 14px rgba(225,27,27,0.35)",
|
|
144516
|
+
flex: "0 0 auto"
|
|
144517
|
+
};
|
|
144518
|
+
const FIELD_CARD = {
|
|
144519
|
+
border: `1px solid ${C.borderSoft}`,
|
|
144520
|
+
borderRadius: R.md,
|
|
144521
|
+
background: C.base,
|
|
144522
|
+
padding: 10,
|
|
144523
|
+
display: "flex",
|
|
144524
|
+
flexDirection: "column",
|
|
144525
|
+
gap: 6
|
|
144526
|
+
};
|
|
144527
|
+
const STEPS = [
|
|
144528
|
+
"Welcome",
|
|
144529
|
+
"KiCad",
|
|
144530
|
+
"SolidCraft"
|
|
144531
|
+
];
|
|
144532
|
+
/**
|
|
144533
|
+
* Dismissal remembered for the life of this client bundle, not one mount.
|
|
144534
|
+
*
|
|
144535
|
+
* The navigation seat is remounted by the framework (a conversation switch, a
|
|
144536
|
+
* slot refresh), so component state alone lets a just-closed wizard come back
|
|
144537
|
+
* for a frame while the host config write is still in flight. A browser refresh
|
|
144538
|
+
* reloads the bundle, so the host config stays the only cross-session source of
|
|
144539
|
+
* truth and this cannot outlive the tab.
|
|
144540
|
+
*/
|
|
144541
|
+
let dismissedInClient = false;
|
|
144542
|
+
/**
|
|
144543
|
+
* Decide whether the wizard may mount, without guessing.
|
|
144544
|
+
*
|
|
144545
|
+
* Order matters: a completed onboarding needs no probe, so it must not wait on
|
|
144546
|
+
* one; a `loading` config must not fall through to "not completed", which is the
|
|
144547
|
+
* flash this function exists to prevent.
|
|
144548
|
+
*/
|
|
144549
|
+
function wizardPhase(input) {
|
|
144550
|
+
if (!input.hasForm) return "no-form";
|
|
144551
|
+
if (input.dismissed) return "dismissed";
|
|
144552
|
+
if (input.status === "loading") return "waiting";
|
|
144553
|
+
if (input.onboardingComplete) return "completed";
|
|
144554
|
+
if (input.kicadConfigured === void 0) return "waiting";
|
|
144555
|
+
return input.kicadConfigured ? "configured" : "open";
|
|
144556
|
+
}
|
|
144557
|
+
function OnboardingWizard(props) {
|
|
144558
|
+
const { actions, configForm, saveInstallation, installations, useStore } = props;
|
|
144559
|
+
const installed = useStore((state) => state.installations);
|
|
144560
|
+
const form = configForm();
|
|
144561
|
+
const empty = (0, react.useMemo)(() => ({}), []);
|
|
144562
|
+
const snapshot = (0, react.useSyncExternalStore)(form === void 0 ? () => () => {} : (listener) => form.subscribe(listener), form === void 0 ? () => empty : () => form.getSnapshot(), form === void 0 ? () => empty : () => form.getSnapshot());
|
|
144563
|
+
const [step, setStep] = (0, react.useState)(0);
|
|
144564
|
+
const [closed, setClosed] = (0, react.useState)(dismissedInClient);
|
|
144565
|
+
const [kicadRoot, setKicadRoot] = (0, react.useState)("");
|
|
144566
|
+
const [solidcraftRoot, setSolidcraftRoot] = (0, react.useState)("");
|
|
144567
|
+
const [message, setMessage] = (0, react.useState)("");
|
|
144568
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
144569
|
+
/**
|
|
144570
|
+
* This seat's own install probe: `undefined` while in flight, `null` when it
|
|
144571
|
+
* failed (the wizard stays usable, paths can be typed). A result another seat
|
|
144572
|
+
* already wrote to the store counts too, so a mounted viewer does not make the
|
|
144573
|
+
* navigation row probe twice before deciding.
|
|
144574
|
+
*/
|
|
144575
|
+
const [probe, setProbe] = (0, react.useState)();
|
|
144576
|
+
(0, react.useEffect)(() => {
|
|
144577
|
+
let live = true;
|
|
144578
|
+
installations().then((result) => {
|
|
144579
|
+
if (!live) return;
|
|
144580
|
+
setProbe(result);
|
|
144581
|
+
actions.setInstallations(result);
|
|
144582
|
+
}).catch(() => {
|
|
144583
|
+
if (live) setProbe(null);
|
|
144584
|
+
});
|
|
144585
|
+
return () => {
|
|
144586
|
+
live = false;
|
|
144587
|
+
};
|
|
144588
|
+
}, [actions, installations]);
|
|
144589
|
+
const facts = probe ?? installed;
|
|
144590
|
+
const phase = wizardPhase({
|
|
144591
|
+
hasForm: form !== void 0,
|
|
144592
|
+
status: snapshot.status,
|
|
144593
|
+
onboardingComplete: snapshot.value?.onboardingComplete === true,
|
|
144594
|
+
kicadConfigured: probe === void 0 && installed === void 0 ? void 0 : facts?.kicad?.configured === true,
|
|
144595
|
+
dismissed: closed
|
|
144596
|
+
});
|
|
144597
|
+
(0, react.useEffect)(() => {
|
|
144598
|
+
if (kicadRoot !== "" || facts?.kicad?.root === void 0) return;
|
|
144599
|
+
setKicadRoot(facts.kicad.root);
|
|
144600
|
+
}, [facts?.kicad?.root, kicadRoot]);
|
|
144601
|
+
if (form === void 0 || phase !== "open") return null;
|
|
144602
|
+
const complete = async () => {
|
|
144603
|
+
dismissedInClient = true;
|
|
144604
|
+
setClosed(true);
|
|
144605
|
+
try {
|
|
144606
|
+
await form.set("onboardingComplete", true);
|
|
144607
|
+
} catch {}
|
|
144608
|
+
};
|
|
144609
|
+
const finish = async () => {
|
|
144610
|
+
setBusy(true);
|
|
144611
|
+
try {
|
|
144612
|
+
if (kicadRoot !== "") await saveInstallation("kicad", kicadRoot);
|
|
144613
|
+
if (solidcraftRoot !== "") await saveInstallation("solidcraft", solidcraftRoot);
|
|
144614
|
+
} catch (error) {
|
|
144615
|
+
setMessage(String(error));
|
|
144616
|
+
setBusy(false);
|
|
144617
|
+
return;
|
|
144618
|
+
}
|
|
144619
|
+
await complete();
|
|
144620
|
+
try {
|
|
144621
|
+
actions.setInstallations(await installations());
|
|
144622
|
+
} catch {}
|
|
144623
|
+
};
|
|
144624
|
+
const next = async () => {
|
|
144625
|
+
if (step < STEPS.length - 1) {
|
|
144626
|
+
setStep(step + 1);
|
|
144627
|
+
return;
|
|
144628
|
+
}
|
|
144629
|
+
await finish();
|
|
144630
|
+
};
|
|
144631
|
+
const stepBody = () => {
|
|
144632
|
+
if (step === 0) return (0, react.createElement)("div", { style: {
|
|
144633
|
+
display: "flex",
|
|
144634
|
+
flexDirection: "column",
|
|
144635
|
+
gap: 10
|
|
144636
|
+
} }, (0, react.createElement)("div", { style: {
|
|
144637
|
+
...ROW$1,
|
|
144638
|
+
gap: 10
|
|
144639
|
+
} }, (0, react.createElement)("span", { style: BRAND_MARK }, "H!"), (0, react.createElement)("div", { style: {
|
|
144640
|
+
display: "flex",
|
|
144641
|
+
flexDirection: "column",
|
|
144642
|
+
gap: 1
|
|
144643
|
+
} }, (0, react.createElement)("h2", { style: TITLE }, "Set up your hardware toolchain"), (0, react.createElement)("span", { style: STEP_LABEL }, "one-time · skippable"))), (0, react.createElement)("p", { style: LEAD }, "Hardware Engineering previews KiCad projects, exports PCB 3D models, packages fabrication files and opens native files. Point it at your local installations once."), (0, react.createElement)("div", { style: FIELD_CARD }, (0, react.createElement)("span", { style: {
|
|
144644
|
+
fontSize: 11,
|
|
144645
|
+
fontWeight: 600
|
|
144646
|
+
} }, "What it uses"), (0, react.createElement)("p", { style: {
|
|
144647
|
+
...MUTED,
|
|
144648
|
+
color: C.text3
|
|
144649
|
+
} }, "kicad-cli for previews, BOM, GLB and gerber/drill packaging. SolidCraft is shared with the agent as environment context only.")), (0, react.createElement)("p", { style: {
|
|
144650
|
+
...MUTED,
|
|
144651
|
+
color: C.text3
|
|
144652
|
+
} }, "Only local executables are used. Nothing is uploaded, and nothing is installed for you."));
|
|
144653
|
+
if (step === 1) return (0, react.createElement)("div", { style: {
|
|
144654
|
+
display: "flex",
|
|
144655
|
+
flexDirection: "column",
|
|
144656
|
+
gap: 8
|
|
144657
|
+
} }, (0, react.createElement)("div", { style: SPREAD }, (0, react.createElement)("h2", { style: TITLE }, "KiCad installation"), (0, react.createElement)("span", { style: facts?.kicad?.configured === true ? pillStyle("ok") : pillStyle("muted") }, facts?.kicad?.configured === true ? `v${facts.kicad.version ?? "?"}` : "optional")), (0, react.createElement)("p", { style: LEAD }, "Enter a KiCad installation folder or a kicad-cli path. It is used for .kicad_sch / .kicad_pcb previews, PCB GLB export, fabrication packaging, and “Open in KiCad”."), (0, react.createElement)("input", {
|
|
144658
|
+
style: INPUT,
|
|
144659
|
+
value: kicadRoot,
|
|
144660
|
+
autoFocus: true,
|
|
144661
|
+
spellCheck: false,
|
|
144662
|
+
placeholder: "C:\\Program Files\\KiCad\\8.0\\ or /usr/bin/kicad-cli",
|
|
144663
|
+
onChange: (event) => setKicadRoot(event.currentTarget.value)
|
|
144664
|
+
}), (0, react.createElement)("p", { style: {
|
|
144665
|
+
...MUTED,
|
|
144666
|
+
color: C.text3
|
|
144667
|
+
} }, "Leave it empty to skip. You can configure it later in Settings → Hardware Engineering."));
|
|
144668
|
+
return (0, react.createElement)("div", { style: {
|
|
144669
|
+
display: "flex",
|
|
144670
|
+
flexDirection: "column",
|
|
144671
|
+
gap: 8
|
|
144672
|
+
} }, (0, react.createElement)("div", { style: SPREAD }, (0, react.createElement)("h2", { style: TITLE }, "SolidCraft installation"), (0, react.createElement)("span", { style: pillStyle("muted") }, "optional")), (0, react.createElement)("p", { style: LEAD }, "SolidCraft is shared with the agent as environment context only in this POC — no native launch, no mechanical preview."), (0, react.createElement)("input", {
|
|
144673
|
+
style: INPUT,
|
|
144674
|
+
value: solidcraftRoot,
|
|
144675
|
+
autoFocus: true,
|
|
144676
|
+
spellCheck: false,
|
|
144677
|
+
placeholder: "C:\\Program Files\\SolidCraft\\bin\\SolidCraft.exe",
|
|
144678
|
+
onChange: (event) => setSolidcraftRoot(event.currentTarget.value)
|
|
144679
|
+
}));
|
|
144680
|
+
};
|
|
144681
|
+
return (0, react.createElement)("div", {
|
|
144682
|
+
style: BACKDROP,
|
|
144683
|
+
role: "dialog",
|
|
144684
|
+
"aria-modal": true,
|
|
144685
|
+
"aria-label": "Hardware Engineering setup",
|
|
144686
|
+
"data-hardware-wizard": true
|
|
144687
|
+
}, (0, react.createElement)("div", { style: PANEL }, (0, react.createElement)("div", { style: SPREAD }, (0, react.createElement)("div", { style: {
|
|
144688
|
+
...ROW$1,
|
|
144689
|
+
gap: 6
|
|
144690
|
+
} }, ...STEPS.map((label, index) => (0, react.createElement)("span", {
|
|
144691
|
+
key: label,
|
|
144692
|
+
style: { ...dotStyle(index === step ? C.accent : index < step ? C.ok : C.text3, 6) },
|
|
144693
|
+
title: label
|
|
144694
|
+
})), (0, react.createElement)("span", { style: {
|
|
144695
|
+
...STEP_LABEL,
|
|
144696
|
+
...MONO_TEXT
|
|
144697
|
+
} }, `${String(step + 1)}/${String(STEPS.length)} · ${STEPS[step]}`)), (0, react.createElement)("button", {
|
|
144698
|
+
type: "button",
|
|
144699
|
+
style: buttonStyle("quiet", { fontSize: 10.5 }),
|
|
144700
|
+
onClick: () => {
|
|
144701
|
+
complete();
|
|
144702
|
+
}
|
|
144703
|
+
}, "Skip setup")), stepBody(), ...message === "" ? [] : [(0, react.createElement)("p", {
|
|
144704
|
+
key: "msg",
|
|
144705
|
+
style: {
|
|
144706
|
+
...MUTED,
|
|
144707
|
+
color: C.text2
|
|
144708
|
+
},
|
|
144709
|
+
role: "status"
|
|
144710
|
+
}, message)], (0, react.createElement)("div", { style: {
|
|
144711
|
+
...SPREAD,
|
|
144712
|
+
paddingTop: 6,
|
|
144713
|
+
borderTop: `1px solid ${C.borderSoft}`
|
|
144714
|
+
} }, (0, react.createElement)("span", { style: {
|
|
144715
|
+
...MUTED,
|
|
144716
|
+
color: C.text3,
|
|
144717
|
+
fontSize: 10
|
|
144718
|
+
} }, "You can change this any time in Settings → Hardware Engineering."), (0, react.createElement)("span", { style: ROW$1 }, step > 0 ? (0, react.createElement)("button", {
|
|
144719
|
+
type: "button",
|
|
144720
|
+
style: buttonStyle("secondary"),
|
|
144721
|
+
onClick: () => {
|
|
144722
|
+
setStep(step - 1);
|
|
144723
|
+
}
|
|
144724
|
+
}, "Back") : null, (0, react.createElement)("button", {
|
|
144725
|
+
type: "button",
|
|
144726
|
+
style: buttonStyle("primary"),
|
|
144727
|
+
disabled: busy,
|
|
144728
|
+
onClick: () => {
|
|
144729
|
+
next();
|
|
144730
|
+
}
|
|
144731
|
+
}, busy ? "Saving…" : step === STEPS.length - 1 ? "Finish" : "Next")))));
|
|
144732
|
+
}
|
|
144733
|
+
//#endregion
|
|
142920
144734
|
//#region src/client/components.tsx
|
|
142921
144735
|
/**
|
|
142922
|
-
* Hardware Engineering UI components.
|
|
142923
|
-
*
|
|
142924
|
-
*
|
|
144736
|
+
* Hardware Engineering UI components.
|
|
144737
|
+
*
|
|
144738
|
+
* Props come from three declared sources and nothing else:
|
|
144739
|
+
* - the slot store seat (`useStore`, `actions`),
|
|
144740
|
+
* - the registrant's inject face (the {@link HardwareController} members,
|
|
144741
|
+
* delivered verbatim — never through a `hooks` compartment),
|
|
144742
|
+
* - the framework standard kit (`sessionId`, `useSessions`, `useTabInfo`).
|
|
144743
|
+
*
|
|
144744
|
+
* Importing nothing from Node keeps the client bundle loadable by the DSH
|
|
144745
|
+
* ModuleLoader; every host read goes through `./transport.ts`.
|
|
142925
144746
|
*/
|
|
142926
|
-
const
|
|
144747
|
+
const EMPTY_TAB = { tab: {
|
|
144748
|
+
id: "",
|
|
144749
|
+
navigation: {}
|
|
144750
|
+
} };
|
|
144751
|
+
const useEmptyTab = () => EMPTY_TAB;
|
|
144752
|
+
const ROW = {
|
|
142927
144753
|
display: "flex",
|
|
142928
144754
|
alignItems: "center",
|
|
142929
144755
|
gap: 4,
|
|
142930
144756
|
flexWrap: "wrap",
|
|
144757
|
+
minWidth: 0
|
|
144758
|
+
};
|
|
144759
|
+
const NAV = {
|
|
144760
|
+
display: "flex",
|
|
144761
|
+
alignItems: "center",
|
|
144762
|
+
gap: 3,
|
|
142931
144763
|
minWidth: 0,
|
|
142932
|
-
fontSize: 12
|
|
144764
|
+
fontSize: 12,
|
|
144765
|
+
position: "relative",
|
|
144766
|
+
flexWrap: "nowrap"
|
|
142933
144767
|
};
|
|
142934
|
-
const
|
|
142935
|
-
|
|
142936
|
-
|
|
142937
|
-
|
|
142938
|
-
color: "var(--dsw-alias-label-secondary)",
|
|
144768
|
+
const NAV_ITEM = {
|
|
144769
|
+
display: "inline-flex",
|
|
144770
|
+
alignItems: "center",
|
|
144771
|
+
gap: 5,
|
|
142939
144772
|
padding: "3px 8px",
|
|
144773
|
+
borderRadius: R.md,
|
|
144774
|
+
border: "1px solid transparent",
|
|
144775
|
+
background: "transparent",
|
|
144776
|
+
color: C.text2,
|
|
142940
144777
|
cursor: "pointer",
|
|
142941
144778
|
font: "inherit",
|
|
142942
|
-
|
|
144779
|
+
fontSize: 11.5,
|
|
144780
|
+
whiteSpace: "nowrap",
|
|
144781
|
+
flex: "0 0 auto",
|
|
144782
|
+
transition: "background 120ms ease, color 120ms ease, border-color 120ms ease"
|
|
142943
144783
|
};
|
|
142944
|
-
const
|
|
142945
|
-
...
|
|
142946
|
-
color:
|
|
142947
|
-
|
|
142948
|
-
|
|
144784
|
+
const NAV_ITEM_ACTIVE = {
|
|
144785
|
+
...NAV_ITEM,
|
|
144786
|
+
color: C.text,
|
|
144787
|
+
background: C.card,
|
|
144788
|
+
border: `1px solid ${C.border}`
|
|
142949
144789
|
};
|
|
142950
|
-
|
|
144790
|
+
`${C.border}`;
|
|
144791
|
+
R.sm, C.accent;
|
|
144792
|
+
C.text;
|
|
144793
|
+
const CHIP = {
|
|
142951
144794
|
minWidth: 0,
|
|
142952
|
-
maxWidth:
|
|
144795
|
+
maxWidth: 168,
|
|
142953
144796
|
overflow: "hidden",
|
|
142954
144797
|
textOverflow: "ellipsis",
|
|
142955
144798
|
whiteSpace: "nowrap",
|
|
142956
|
-
color:
|
|
142957
|
-
fontSize:
|
|
144799
|
+
color: C.text3,
|
|
144800
|
+
fontSize: 10,
|
|
144801
|
+
fontFamily: MONO,
|
|
144802
|
+
flex: "0 1 auto"
|
|
142958
144803
|
};
|
|
142959
|
-
const
|
|
144804
|
+
const PANEL_ROOT = {
|
|
142960
144805
|
display: "flex",
|
|
142961
144806
|
flexDirection: "column",
|
|
142962
144807
|
height: "100%",
|
|
144808
|
+
minHeight: 0,
|
|
142963
144809
|
minWidth: 0,
|
|
142964
144810
|
boxSizing: "border-box",
|
|
142965
|
-
|
|
142966
|
-
|
|
142967
|
-
color: "var(--dsw-alias-label-primary)",
|
|
142968
|
-
overflow: "auto"
|
|
144811
|
+
background: C.base,
|
|
144812
|
+
color: C.text
|
|
142969
144813
|
};
|
|
142970
|
-
const
|
|
144814
|
+
const STRIP = {
|
|
142971
144815
|
display: "flex",
|
|
142972
144816
|
alignItems: "center",
|
|
142973
144817
|
justifyContent: "space-between",
|
|
142974
|
-
gap:
|
|
144818
|
+
gap: 6,
|
|
144819
|
+
padding: "5px 8px",
|
|
144820
|
+
background: C.panel,
|
|
144821
|
+
borderBottom: `1px solid ${C.border}`,
|
|
144822
|
+
flex: "0 0 auto",
|
|
144823
|
+
minWidth: 0
|
|
142975
144824
|
};
|
|
142976
|
-
const
|
|
142977
|
-
|
|
142978
|
-
|
|
142979
|
-
|
|
142980
|
-
|
|
142981
|
-
|
|
142982
|
-
...TAB,
|
|
142983
|
-
padding: "5px 10px",
|
|
142984
|
-
color: "var(--dsw-alias-label-primary)"
|
|
144825
|
+
const STRIP_GROUP = {
|
|
144826
|
+
...ROW,
|
|
144827
|
+
gap: 2,
|
|
144828
|
+
flexWrap: "nowrap",
|
|
144829
|
+
overflowX: "auto",
|
|
144830
|
+
minWidth: 0
|
|
142985
144831
|
};
|
|
142986
|
-
const
|
|
144832
|
+
const META = {
|
|
142987
144833
|
display: "flex",
|
|
142988
|
-
|
|
142989
|
-
|
|
142990
|
-
|
|
142991
|
-
|
|
142992
|
-
|
|
142993
|
-
|
|
142994
|
-
|
|
142995
|
-
|
|
142996
|
-
|
|
142997
|
-
|
|
142998
|
-
background: "transparent",
|
|
142999
|
-
color: "inherit",
|
|
143000
|
-
font: "inherit"
|
|
144834
|
+
alignItems: "center",
|
|
144835
|
+
justifyContent: "space-between",
|
|
144836
|
+
gap: 8,
|
|
144837
|
+
padding: "4px 10px",
|
|
144838
|
+
background: C.base,
|
|
144839
|
+
borderBottom: `1px solid ${C.borderSoft}`,
|
|
144840
|
+
flex: "0 0 auto",
|
|
144841
|
+
minWidth: 0,
|
|
144842
|
+
fontSize: 10,
|
|
144843
|
+
color: C.text3
|
|
143001
144844
|
};
|
|
143002
|
-
const
|
|
143003
|
-
|
|
143004
|
-
fontSize:
|
|
143005
|
-
|
|
144845
|
+
const META_PATH = {
|
|
144846
|
+
...MONO_TEXT,
|
|
144847
|
+
fontSize: 10,
|
|
144848
|
+
color: C.text2,
|
|
144849
|
+
overflow: "hidden",
|
|
144850
|
+
textOverflow: "ellipsis",
|
|
144851
|
+
whiteSpace: "nowrap",
|
|
144852
|
+
minWidth: 0
|
|
143006
144853
|
};
|
|
143007
|
-
const
|
|
143008
|
-
|
|
143009
|
-
|
|
144854
|
+
const BODY = {
|
|
144855
|
+
flex: "1 1 0",
|
|
144856
|
+
minHeight: 0,
|
|
144857
|
+
display: "flex",
|
|
144858
|
+
flexDirection: "column",
|
|
144859
|
+
padding: 10,
|
|
144860
|
+
gap: 8
|
|
143010
144861
|
};
|
|
143011
|
-
function option(value, label
|
|
144862
|
+
function option(value, label) {
|
|
143012
144863
|
return (0, react.createElement)("option", {
|
|
143013
144864
|
key: value,
|
|
143014
|
-
value
|
|
143015
|
-
selected
|
|
144865
|
+
value
|
|
143016
144866
|
}, label);
|
|
143017
144867
|
}
|
|
143018
|
-
function
|
|
143019
|
-
|
|
144868
|
+
function basename(path) {
|
|
144869
|
+
const parts = path.split(/[\\/]/u);
|
|
144870
|
+
return parts[parts.length - 1] ?? path;
|
|
143020
144871
|
}
|
|
143021
|
-
/**
|
|
143022
|
-
function
|
|
144872
|
+
/** Read the viewer navigation params carried by one `openTab` call. */
|
|
144873
|
+
function navigationParams(info) {
|
|
144874
|
+
const params = info?.tab.navigation.params;
|
|
144875
|
+
if (params === void 0 || typeof params.destination !== "string") return void 0;
|
|
144876
|
+
if (!DESTINATIONS.includes(params.destination)) return void 0;
|
|
144877
|
+
return params;
|
|
144878
|
+
}
|
|
144879
|
+
/**
|
|
144880
|
+
* One product navigation row: brand, the five persistent destinations, and the
|
|
144881
|
+
* selected project. The first-run wizard renders from this root-scope seat
|
|
144882
|
+
* because it must be able to run before any session exists.
|
|
144883
|
+
*/
|
|
144884
|
+
function EngineeringNav(props) {
|
|
144885
|
+
const { useStore, actions, useSessions, discover, openDestination } = props;
|
|
143023
144886
|
const active = useStore((state) => state.activeDestination);
|
|
143024
144887
|
const projectPath = useStore((state) => state.projectPath);
|
|
144888
|
+
const selected = useStore((state) => state.discovery?.selected);
|
|
144889
|
+
const sessionId = useSessions?.((state) => state.ids[0]);
|
|
143025
144890
|
const cwd = useSessions?.((state) => {
|
|
143026
144891
|
const id = state.ids[0];
|
|
143027
144892
|
return id === void 0 ? void 0 : state.byId[id]?.cwd;
|
|
143028
144893
|
});
|
|
143029
144894
|
(0, react.useEffect)(() => {
|
|
143030
|
-
|
|
143031
|
-
|
|
144895
|
+
let live = true;
|
|
144896
|
+
discover(cwd, void 0, sessionId).then((discovery) => {
|
|
144897
|
+
if (live) actions.setDiscovery(discovery);
|
|
144898
|
+
}).catch((error) => {
|
|
144899
|
+
if (live) actions.setNotice(`Artifact discovery failed: ${String(error)}`);
|
|
144900
|
+
});
|
|
144901
|
+
return () => {
|
|
144902
|
+
live = false;
|
|
144903
|
+
};
|
|
144904
|
+
}, [
|
|
144905
|
+
cwd,
|
|
144906
|
+
sessionId,
|
|
144907
|
+
discover,
|
|
144908
|
+
actions
|
|
144909
|
+
]);
|
|
144910
|
+
const projectName = selected?.name ?? (projectPath === void 0 ? void 0 : basename(projectPath));
|
|
143032
144911
|
return (0, react.createElement)("div", {
|
|
143033
144912
|
style: NAV,
|
|
143034
144913
|
"data-hardware-nav": true
|
|
143035
144914
|
}, ...DESTINATIONS.map((destination) => (0, react.createElement)("button", {
|
|
143036
144915
|
key: destination,
|
|
143037
144916
|
type: "button",
|
|
143038
|
-
style: destination === active ?
|
|
144917
|
+
style: destination === active ? NAV_ITEM_ACTIVE : NAV_ITEM,
|
|
143039
144918
|
"aria-pressed": destination === active,
|
|
143040
144919
|
"data-destination": destination,
|
|
144920
|
+
title: DESTINATION_LABELS[destination],
|
|
143041
144921
|
onClick: () => {
|
|
143042
144922
|
actions.setActive(destination);
|
|
143043
|
-
|
|
144923
|
+
openDestination(destination);
|
|
143044
144924
|
}
|
|
143045
|
-
}, DESTINATION_LABELS[destination])), ...
|
|
143046
|
-
key: "
|
|
143047
|
-
style:
|
|
143048
|
-
|
|
143049
|
-
|
|
144925
|
+
}, (0, react.createElement)("span", { style: dotStyle(DOT_COLORS[destination], 6) }), DESTINATION_LABELS[destination])), ...projectName === void 0 ? [] : [(0, react.createElement)("span", {
|
|
144926
|
+
key: "project",
|
|
144927
|
+
style: {
|
|
144928
|
+
...CHIP,
|
|
144929
|
+
paddingLeft: 4
|
|
144930
|
+
},
|
|
144931
|
+
title: projectPath ?? projectName
|
|
144932
|
+
}, projectName)], (0, react.createElement)(OnboardingWizard, props));
|
|
143050
144933
|
}
|
|
143051
144934
|
/** The artifact a destination previews, with its canonical identity. */
|
|
143052
144935
|
function selectedArtifact(state, destination) {
|
|
@@ -143055,22 +144938,21 @@ void main() {
|
|
|
143055
144938
|
id: `schematic:${state.schematicPath}`,
|
|
143056
144939
|
kind: "schematic",
|
|
143057
144940
|
path: state.schematicPath,
|
|
143058
|
-
title: state.schematicPath
|
|
144941
|
+
title: basename(state.schematicPath)
|
|
143059
144942
|
};
|
|
143060
144943
|
const board = state.pcbPath === void 0 ? project?.boards?.find((candidate) => candidate.path === project?.defaultBoard) ?? project?.boards?.[0] : {
|
|
143061
144944
|
id: `pcb:${state.pcbPath}`,
|
|
143062
144945
|
kind: "pcb",
|
|
143063
144946
|
path: state.pcbPath,
|
|
143064
|
-
title: state.pcbPath
|
|
144947
|
+
title: basename(state.pcbPath)
|
|
143065
144948
|
};
|
|
143066
144949
|
if (destination === "schematic" || destination === "bom") return schematic;
|
|
143067
|
-
if (destination === "pcb" || destination === "3d") return board;
|
|
143068
144950
|
return board;
|
|
143069
144951
|
}
|
|
143070
144952
|
function missingReason(state, destination) {
|
|
143071
144953
|
const discovery = state.discovery;
|
|
143072
144954
|
if (discovery === void 0) return void 0;
|
|
143073
|
-
if (discovery.issue?.code === "selection-required" && discovery.projects
|
|
144955
|
+
if (discovery.issue?.code === "selection-required" && (discovery.projects?.length ?? 0) > 1) return `${String(discovery.projects?.length)} hardware projects found; choose one explicitly.`;
|
|
143074
144956
|
if (discovery.selected === void 0) return "No hardware project selected. Open or select a hardware project.";
|
|
143075
144957
|
if (destination === "schematic" || destination === "bom") {
|
|
143076
144958
|
if (discovery.selected.schematic === void 0) return "This project has no discoverable root schematic.";
|
|
@@ -143082,159 +144964,377 @@ void main() {
|
|
|
143082
144964
|
if ((discovery.selected.boards?.length ?? 0) === 0) return "Select a board before quoting or ordering fabrication.";
|
|
143083
144965
|
}
|
|
143084
144966
|
}
|
|
143085
|
-
/**
|
|
143086
|
-
function
|
|
144967
|
+
/** Native-open affordance for the artifact currently on screen. */
|
|
144968
|
+
function nativeAction(active, artifact, configured, notice, openNative) {
|
|
144969
|
+
const application = applicationFor(active);
|
|
144970
|
+
if (application === void 0) return null;
|
|
144971
|
+
const canOpen = configured && artifact !== void 0;
|
|
144972
|
+
return (0, react.createElement)("button", {
|
|
144973
|
+
type: "button",
|
|
144974
|
+
style: {
|
|
144975
|
+
...buttonStyle(canOpen ? "secondary" : "quiet"),
|
|
144976
|
+
fontSize: 10.5,
|
|
144977
|
+
padding: "2px 7px",
|
|
144978
|
+
...disabled(!canOpen)
|
|
144979
|
+
},
|
|
144980
|
+
disabled: !canOpen,
|
|
144981
|
+
"data-hardware-native-open": true,
|
|
144982
|
+
title: canOpen ? `Open ${artifact.path} in KiCad` : configured ? "Select an artifact first" : "Configure KiCad in Settings → Hardware Engineering",
|
|
144983
|
+
onClick: () => {
|
|
144984
|
+
if (artifact === void 0) return;
|
|
144985
|
+
openNative({
|
|
144986
|
+
application,
|
|
144987
|
+
artifactPath: artifact.path,
|
|
144988
|
+
kind: active === "3d" ? "pcb-3d" : active === "bom" ? "bom" : artifact.kind
|
|
144989
|
+
}).catch((error) => {
|
|
144990
|
+
notice(String(error));
|
|
144991
|
+
});
|
|
144992
|
+
}
|
|
144993
|
+
}, (0, react.createElement)("span", { style: dotStyle(configured ? C.ok : C.text3, 6) }), "Open in KiCad");
|
|
144994
|
+
}
|
|
144995
|
+
/** Keyframes the stages reference; rendered once per panel. */
|
|
144996
|
+
const PANEL_STYLE = `
|
|
144997
|
+
@keyframes dsh-hw-spin { to { transform: rotate(360deg) } }
|
|
144998
|
+
`;
|
|
144999
|
+
/**
|
|
145000
|
+
* Right-panel body: one destination at a time, driven by the tab's navigation
|
|
145001
|
+
* params so a navigation with unchanged params still refreshes (the revision
|
|
145002
|
+
* changes), and so the viewer never depends on a remount.
|
|
145003
|
+
*/
|
|
145004
|
+
function HardwareViewerBody(props) {
|
|
145005
|
+
const { useStore, actions, useTabInfo, sessionId, useSessions, discover, installations, openDestination, openNative } = props;
|
|
145006
|
+
const info = (useTabInfo ?? useEmptyTab)();
|
|
145007
|
+
const navigation = info.tab.navigation;
|
|
145008
|
+
const params = (0, react.useMemo)(() => navigationParams(info), [navigation.params, navigation.revision]);
|
|
145009
|
+
const navRevision = navigation.revision ?? 0;
|
|
143087
145010
|
const active = useStore((state) => state.activeDestination);
|
|
143088
145011
|
const discovery = useStore((state) => state.discovery);
|
|
143089
145012
|
const projectPath = useStore((state) => state.projectPath);
|
|
143090
145013
|
const schematicPath = useStore((state) => state.schematicPath);
|
|
143091
145014
|
const pcbPath = useStore((state) => state.pcbPath);
|
|
143092
|
-
const
|
|
143093
|
-
const
|
|
143094
|
-
const revision = tab?.navigation?.revision ?? 0;
|
|
143095
|
-
const selectedProject = discovery?.selected;
|
|
143096
|
-
(0, react.useEffect)(() => {
|
|
143097
|
-
hooks.fetchInstallations();
|
|
143098
|
-
}, [hooks]);
|
|
145015
|
+
const noticeText = useStore((state) => state.notice);
|
|
145016
|
+
const installed = useStore((state) => state.installations);
|
|
143099
145017
|
const artifact = useStore((state) => selectedArtifact(state, active));
|
|
143100
145018
|
const reason = useStore((state) => missingReason(state, active));
|
|
143101
|
-
const
|
|
143102
|
-
const
|
|
143103
|
-
|
|
143104
|
-
|
|
143105
|
-
|
|
143106
|
-
|
|
145019
|
+
const workspaceRoot = useStore((state) => state.workspaceRoot);
|
|
145020
|
+
const cwd = useSessions?.((state) => {
|
|
145021
|
+
if (sessionId === void 0) return void 0;
|
|
145022
|
+
return state.byId[sessionId]?.cwd;
|
|
145023
|
+
});
|
|
145024
|
+
(0, react.useEffect)(() => {
|
|
145025
|
+
if (params !== void 0) actions.applyNavigation(params);
|
|
145026
|
+
}, [
|
|
145027
|
+
navRevision,
|
|
145028
|
+
params,
|
|
145029
|
+
actions
|
|
145030
|
+
]);
|
|
145031
|
+
(0, react.useEffect)(() => {
|
|
145032
|
+
let live = true;
|
|
145033
|
+
discover(cwd, params?.projectPath, sessionId).then((result) => {
|
|
145034
|
+
if (live) actions.setDiscovery(result, params?.path !== void 0);
|
|
145035
|
+
}).catch((error) => {
|
|
145036
|
+
if (live) actions.setNotice(`Artifact discovery failed: ${String(error)}`);
|
|
145037
|
+
});
|
|
145038
|
+
return () => {
|
|
145039
|
+
live = false;
|
|
145040
|
+
};
|
|
145041
|
+
}, [
|
|
145042
|
+
cwd,
|
|
145043
|
+
sessionId,
|
|
145044
|
+
params?.projectPath,
|
|
145045
|
+
actions,
|
|
145046
|
+
discover
|
|
145047
|
+
]);
|
|
145048
|
+
(0, react.useEffect)(() => {
|
|
145049
|
+
let live = true;
|
|
145050
|
+
installations().then((result) => {
|
|
145051
|
+
if (live) actions.setInstallations(result);
|
|
145052
|
+
}).catch((error) => {
|
|
145053
|
+
if (live) actions.setNotice(`Installation check failed: ${String(error)}`);
|
|
145054
|
+
});
|
|
145055
|
+
return () => {
|
|
145056
|
+
live = false;
|
|
145057
|
+
};
|
|
145058
|
+
}, [actions, installations]);
|
|
145059
|
+
const selectedProject = discovery?.selected;
|
|
145060
|
+
const kicadConfigured = installed?.kicad?.configured ?? false;
|
|
145061
|
+
const notice = (message) => {
|
|
145062
|
+
actions.setNotice(message);
|
|
145063
|
+
};
|
|
145064
|
+
const go = (destination) => {
|
|
145065
|
+
actions.setActive(destination);
|
|
145066
|
+
openDestination(destination, destination === "schematic" || destination === "bom" ? schematicPath : pcbPath);
|
|
145067
|
+
};
|
|
145068
|
+
const strip = (0, react.createElement)("div", {
|
|
145069
|
+
style: STRIP,
|
|
145070
|
+
"data-hardware-destinations": true
|
|
145071
|
+
}, (0, react.createElement)("div", { style: STRIP_GROUP }, ...DESTINATIONS.map((destination) => (0, react.createElement)("button", {
|
|
145072
|
+
key: destination,
|
|
143107
145073
|
type: "button",
|
|
143108
|
-
style:
|
|
143109
|
-
|
|
143110
|
-
|
|
143111
|
-
|
|
145074
|
+
style: destination === active ? {
|
|
145075
|
+
...NAV_ITEM_ACTIVE,
|
|
145076
|
+
fontSize: 11
|
|
145077
|
+
} : {
|
|
145078
|
+
...NAV_ITEM,
|
|
145079
|
+
fontSize: 11
|
|
145080
|
+
},
|
|
145081
|
+
"aria-pressed": destination === active,
|
|
143112
145082
|
onClick: () => {
|
|
143113
|
-
|
|
143114
|
-
}
|
|
143115
|
-
},
|
|
145083
|
+
go(destination);
|
|
145084
|
+
}
|
|
145085
|
+
}, (0, react.createElement)("span", { style: dotStyle(DOT_COLORS[destination], 6) }), DESTINATION_LABELS[destination]))), nativeAction(active, artifact, kicadConfigured, notice, openNative));
|
|
145086
|
+
const meta = (0, react.createElement)("div", { style: META }, (0, react.createElement)("span", {
|
|
145087
|
+
style: META_PATH,
|
|
145088
|
+
title: artifact?.path ?? ""
|
|
145089
|
+
}, artifact === void 0 ? "no artifact selected" : artifact.path), (0, react.createElement)("span", { style: {
|
|
145090
|
+
display: "flex",
|
|
145091
|
+
alignItems: "center",
|
|
145092
|
+
gap: 4,
|
|
145093
|
+
flex: "0 0 auto"
|
|
145094
|
+
} }, ...selectedProject === void 0 ? [] : [(0, react.createElement)("span", {
|
|
145095
|
+
key: "project",
|
|
145096
|
+
style: pillStyle("muted")
|
|
145097
|
+
}, selectedProject.name)], ...kicadConfigured ? [(0, react.createElement)("span", {
|
|
145098
|
+
key: "kicad",
|
|
145099
|
+
style: pillStyle("ok")
|
|
145100
|
+
}, `KiCad ${installed?.kicad?.version ?? ""}`.trim())] : [(0, react.createElement)("span", {
|
|
145101
|
+
key: "kicad",
|
|
145102
|
+
style: pillStyle("warn"),
|
|
145103
|
+
title: installed?.kicad?.error ?? ""
|
|
145104
|
+
}, "KiCad missing")]));
|
|
143116
145105
|
const selectors = [];
|
|
143117
|
-
|
|
145106
|
+
const selectStyle = {
|
|
145107
|
+
...INPUT,
|
|
145108
|
+
width: "auto",
|
|
145109
|
+
maxWidth: 220,
|
|
145110
|
+
fontSize: 10.5
|
|
145111
|
+
};
|
|
145112
|
+
if ((discovery?.projects?.length ?? 0) > 1 || discovery?.issue?.code === "selection-required") selectors.push((0, react.createElement)("select", {
|
|
143118
145113
|
key: "project",
|
|
143119
|
-
style:
|
|
143120
|
-
}, "Project", (0, react.createElement)("select", {
|
|
143121
|
-
style: SELECT,
|
|
145114
|
+
style: selectStyle,
|
|
143122
145115
|
value: projectPath ?? "",
|
|
145116
|
+
"aria-label": "Project",
|
|
143123
145117
|
onChange: (event) => {
|
|
143124
|
-
|
|
143125
|
-
|
|
145118
|
+
const path = event.currentTarget.value;
|
|
145119
|
+
actions.selectProject(path);
|
|
145120
|
+
discover(cwd, path, sessionId).then((result) => actions.setDiscovery(result)).catch((error) => actions.setNotice(String(error)));
|
|
143126
145121
|
}
|
|
143127
|
-
}, option("", "Select a project…"
|
|
145122
|
+
}, option("", "Select a project…"), ...(discovery?.projects ?? []).map((project) => option(project.path, project.name))));
|
|
143128
145123
|
if ((active === "schematic" || active === "bom") && selectedProject !== void 0) {
|
|
143129
145124
|
const candidates = [selectedProject.schematic, ...selectedProject.sheets ?? []].filter((candidate) => candidate !== void 0);
|
|
143130
|
-
selectors.push((0, react.createElement)("
|
|
145125
|
+
if (candidates.length > 1) selectors.push((0, react.createElement)("select", {
|
|
143131
145126
|
key: "sheet",
|
|
143132
|
-
style:
|
|
143133
|
-
}, "Schematic / sheet", (0, react.createElement)("select", {
|
|
143134
|
-
style: SELECT,
|
|
145127
|
+
style: selectStyle,
|
|
143135
145128
|
value: schematicPath ?? "",
|
|
145129
|
+
"aria-label": "Schematic sheet",
|
|
143136
145130
|
onChange: (event) => {
|
|
143137
|
-
|
|
143138
|
-
|
|
145131
|
+
const path = event.currentTarget.value;
|
|
145132
|
+
actions.selectArtifact(path, "schematic");
|
|
145133
|
+
openDestination(active, path);
|
|
143139
145134
|
}
|
|
143140
|
-
},
|
|
143141
|
-
}
|
|
143142
|
-
if ((active === "pcb" || active === "3d" || active === "order") && selectedProject !== void 0)
|
|
143143
|
-
|
|
143144
|
-
|
|
143145
|
-
|
|
143146
|
-
|
|
143147
|
-
|
|
143148
|
-
|
|
143149
|
-
|
|
143150
|
-
|
|
143151
|
-
|
|
143152
|
-
|
|
143153
|
-
|
|
143154
|
-
|
|
143155
|
-
|
|
143156
|
-
|
|
145135
|
+
}, ...candidates.map((candidate) => option(candidate.path, candidate.title))));
|
|
145136
|
+
}
|
|
145137
|
+
if ((active === "pcb" || active === "3d" || active === "order") && selectedProject !== void 0) {
|
|
145138
|
+
if ((selectedProject.boards?.length ?? 0) > 1) selectors.push((0, react.createElement)("select", {
|
|
145139
|
+
key: "board",
|
|
145140
|
+
style: selectStyle,
|
|
145141
|
+
value: pcbPath ?? "",
|
|
145142
|
+
"aria-label": "Board",
|
|
145143
|
+
onChange: (event) => {
|
|
145144
|
+
const path = event.currentTarget.value;
|
|
145145
|
+
actions.selectArtifact(path, "pcb");
|
|
145146
|
+
openDestination(active, path);
|
|
145147
|
+
}
|
|
145148
|
+
}, ...(selectedProject.boards ?? []).map((board) => option(board.path, board.title || board.path))));
|
|
145149
|
+
}
|
|
145150
|
+
const banner = (0, react.createElement)("div", { style: {
|
|
145151
|
+
...ROW,
|
|
145152
|
+
gap: 6,
|
|
145153
|
+
padding: "0 2px",
|
|
145154
|
+
flex: "0 0 auto"
|
|
145155
|
+
} }, ...selectors, ...noticeText === void 0 ? [] : [(0, react.createElement)("span", {
|
|
143157
145156
|
key: "notice",
|
|
143158
|
-
|
|
143159
|
-
|
|
143160
|
-
|
|
145157
|
+
role: "status",
|
|
145158
|
+
style: {
|
|
145159
|
+
...MUTED,
|
|
145160
|
+
color: C.warn
|
|
145161
|
+
}
|
|
145162
|
+
}, noticeText)], ...discovery?.issue === void 0 || discovery.issue.code === "selection-required" ? [] : [(0, react.createElement)("span", {
|
|
143161
145163
|
key: "issue",
|
|
143162
|
-
|
|
143163
|
-
role: "status"
|
|
143164
|
-
}, discovery.issue.message)], (0, react.createElement)("p", {
|
|
143165
|
-
key: "project-path",
|
|
145164
|
+
role: "status",
|
|
143166
145165
|
style: MUTED
|
|
143167
|
-
},
|
|
143168
|
-
|
|
145166
|
+
}, discovery.issue.message)]);
|
|
145167
|
+
return (0, react.createElement)("div", {
|
|
145168
|
+
style: PANEL_ROOT,
|
|
145169
|
+
"data-hardware-destination": active
|
|
145170
|
+
}, (0, react.createElement)("style", null, PANEL_STYLE), strip, meta, selectors.length === 0 && noticeText === void 0 && (discovery?.issue === void 0 || discovery.issue.code === "selection-required") ? null : (0, react.createElement)("div", { style: { padding: "6px 10px 0" } }, banner), (0, react.createElement)("div", { style: {
|
|
145171
|
+
...BODY,
|
|
145172
|
+
overflow: active === "order" || active === "bom" ? "auto" : "hidden"
|
|
145173
|
+
} }, ...reason === void 0 ? [(0, react.createElement)(HardwarePreview, {
|
|
145174
|
+
key: `preview:${info.tab.id}:${String(navRevision)}:${active}:${artifact?.path ?? ""}`,
|
|
143169
145175
|
destination: active,
|
|
143170
145176
|
artifact,
|
|
143171
|
-
|
|
143172
|
-
|
|
143173
|
-
|
|
143174
|
-
|
|
145177
|
+
...schematicPath === void 0 ? {} : { schematicPath },
|
|
145178
|
+
...workspaceRoot === void 0 ? {} : { workspaceRoot },
|
|
145179
|
+
...sessionId === void 0 ? {} : { session: sessionId },
|
|
145180
|
+
revision: navRevision,
|
|
145181
|
+
configured: kicadConfigured
|
|
145182
|
+
})] : [(0, react.createElement)("div", {
|
|
143175
145183
|
key: "reason",
|
|
143176
|
-
style:
|
|
143177
|
-
|
|
145184
|
+
style: cardStyle({
|
|
145185
|
+
alignItems: "center",
|
|
145186
|
+
justifyContent: "center",
|
|
145187
|
+
flex: "1 1 0",
|
|
145188
|
+
gap: 6
|
|
145189
|
+
}),
|
|
143178
145190
|
"data-hardware-state": "missing"
|
|
143179
|
-
},
|
|
143180
|
-
|
|
143181
|
-
style:
|
|
143182
|
-
|
|
143183
|
-
|
|
143184
|
-
|
|
143185
|
-
|
|
143186
|
-
},
|
|
143187
|
-
}
|
|
143188
|
-
/** Settings section
|
|
143189
|
-
function HardwareSettingsSection(
|
|
143190
|
-
const
|
|
143191
|
-
const
|
|
143192
|
-
const
|
|
143193
|
-
const
|
|
143194
|
-
const
|
|
145191
|
+
}, (0, react.createElement)("span", { style: pillStyle("warn") }, "nothing to show"), (0, react.createElement)("p", {
|
|
145192
|
+
role: "status",
|
|
145193
|
+
style: {
|
|
145194
|
+
...MUTED,
|
|
145195
|
+
textAlign: "center",
|
|
145196
|
+
maxWidth: 320
|
|
145197
|
+
}
|
|
145198
|
+
}, reason))]));
|
|
145199
|
+
}
|
|
145200
|
+
/** Settings section: the two CAD installation roots, host-validated. */
|
|
145201
|
+
function HardwareSettingsSection(props) {
|
|
145202
|
+
const { useStore, actions, configForm, saveInstallation, installations } = props;
|
|
145203
|
+
const installed = useStore((state) => state.installations);
|
|
145204
|
+
const form = configForm();
|
|
145205
|
+
const empty = (0, react.useMemo)(() => ({}), []);
|
|
145206
|
+
const snapshot = (0, react.useSyncExternalStore)(form === void 0 ? () => () => {} : (listener) => form.subscribe(listener), form === void 0 ? () => empty : () => form.getSnapshot(), form === void 0 ? () => empty : () => form.getSnapshot());
|
|
145207
|
+
const [kicadRoot, setKicadRoot] = (0, react.useState)(snapshot.value?.kicadRoot ?? "");
|
|
145208
|
+
const [solidcraftRoot, setSolidcraftRoot] = (0, react.useState)(snapshot.value?.solidcraftRoot ?? "");
|
|
143195
145209
|
const [message, setMessage] = (0, react.useState)("");
|
|
145210
|
+
const [busy, setBusy] = (0, react.useState)();
|
|
143196
145211
|
(0, react.useEffect)(() => {
|
|
143197
|
-
setKicadRoot(value?.kicadRoot ?? "");
|
|
143198
|
-
|
|
143199
|
-
|
|
145212
|
+
setKicadRoot(snapshot.value?.kicadRoot ?? "");
|
|
145213
|
+
}, [snapshot.value?.kicadRoot]);
|
|
145214
|
+
(0, react.useEffect)(() => {
|
|
145215
|
+
setSolidcraftRoot(snapshot.value?.solidcraftRoot ?? "");
|
|
145216
|
+
}, [snapshot.value?.solidcraftRoot]);
|
|
145217
|
+
(0, react.useEffect)(() => {
|
|
145218
|
+
let live = true;
|
|
145219
|
+
installations().then((result) => {
|
|
145220
|
+
if (live) actions.setInstallations(result);
|
|
145221
|
+
}).catch(() => {});
|
|
145222
|
+
return () => {
|
|
145223
|
+
live = false;
|
|
145224
|
+
};
|
|
145225
|
+
}, [actions, installations]);
|
|
143200
145226
|
const save = async (application, root) => {
|
|
145227
|
+
setBusy(application);
|
|
143201
145228
|
try {
|
|
143202
|
-
await
|
|
143203
|
-
await
|
|
143204
|
-
|
|
145229
|
+
await saveInstallation(application, root);
|
|
145230
|
+
const refreshed = await installations();
|
|
145231
|
+
actions.setInstallations(refreshed);
|
|
145232
|
+
const state = application === "kicad" ? refreshed.kicad : refreshed.solidcraft;
|
|
145233
|
+
setMessage(state?.configured === true ? `${application === "kicad" ? "KiCad" : "SolidCraft"} validated and saved.` : `${application === "kicad" ? "KiCad" : "SolidCraft"} saved, but validation failed: ${state?.error ?? "not detected"}`);
|
|
143205
145234
|
} catch (error) {
|
|
143206
145235
|
setMessage(String(error));
|
|
145236
|
+
} finally {
|
|
145237
|
+
setBusy(void 0);
|
|
143207
145238
|
}
|
|
143208
145239
|
};
|
|
145240
|
+
const kicad = installed?.kicad;
|
|
145241
|
+
const solidcraft = installed?.solidcraft;
|
|
145242
|
+
const installationCard = (input) => (0, react.createElement)("div", {
|
|
145243
|
+
key: input.key,
|
|
145244
|
+
style: cardStyle()
|
|
145245
|
+
}, (0, react.createElement)("div", { style: {
|
|
145246
|
+
...ROW,
|
|
145247
|
+
justifyContent: "space-between",
|
|
145248
|
+
gap: 8
|
|
145249
|
+
} }, (0, react.createElement)("div", { style: {
|
|
145250
|
+
...ROW,
|
|
145251
|
+
gap: 7
|
|
145252
|
+
} }, (0, react.createElement)("span", { style: {
|
|
145253
|
+
width: 22,
|
|
145254
|
+
height: 22,
|
|
145255
|
+
borderRadius: R.sm,
|
|
145256
|
+
display: "flex",
|
|
145257
|
+
alignItems: "center",
|
|
145258
|
+
justifyContent: "center",
|
|
145259
|
+
fontSize: 10,
|
|
145260
|
+
fontWeight: 700,
|
|
145261
|
+
fontFamily: MONO,
|
|
145262
|
+
color: input.color,
|
|
145263
|
+
background: `color-mix(in srgb, ${input.color} 18%, transparent)`,
|
|
145264
|
+
border: `1px solid color-mix(in srgb, ${input.color} 40%, transparent)`
|
|
145265
|
+
} }, input.letter), (0, react.createElement)("span", { style: {
|
|
145266
|
+
fontSize: 12,
|
|
145267
|
+
fontWeight: 600
|
|
145268
|
+
} }, input.title)), (0, react.createElement)("span", { style: pillStyle(input.ok ? "ok" : "warn") }, input.status)), (0, react.createElement)("p", { style: MUTED }, input.blurb), (0, react.createElement)("input", {
|
|
145269
|
+
style: INPUT,
|
|
145270
|
+
value: input.value,
|
|
145271
|
+
placeholder: input.placeholder,
|
|
145272
|
+
spellCheck: false,
|
|
145273
|
+
"aria-label": `${input.title} path`,
|
|
145274
|
+
onChange: (event) => input.onChange(event.currentTarget.value)
|
|
145275
|
+
}), (0, react.createElement)("div", { style: {
|
|
145276
|
+
...ROW,
|
|
145277
|
+
justifyContent: "space-between"
|
|
145278
|
+
} }, (0, react.createElement)("button", {
|
|
145279
|
+
type: "button",
|
|
145280
|
+
style: {
|
|
145281
|
+
...buttonStyle("secondary"),
|
|
145282
|
+
...disabled(busy !== void 0)
|
|
145283
|
+
},
|
|
145284
|
+
disabled: busy !== void 0,
|
|
145285
|
+
onClick: () => {
|
|
145286
|
+
save(input.key, input.value);
|
|
145287
|
+
}
|
|
145288
|
+
}, busy === input.key ? "Validating…" : "Validate / save"), input.detail === void 0 ? null : (0, react.createElement)("span", { style: {
|
|
145289
|
+
...MUTED,
|
|
145290
|
+
...MONO_TEXT,
|
|
145291
|
+
fontSize: 10,
|
|
145292
|
+
maxWidth: 240,
|
|
145293
|
+
overflow: "hidden",
|
|
145294
|
+
textOverflow: "ellipsis",
|
|
145295
|
+
whiteSpace: "nowrap"
|
|
145296
|
+
} }, input.detail)));
|
|
143209
145297
|
return (0, react.createElement)("div", {
|
|
143210
145298
|
style: {
|
|
143211
|
-
|
|
143212
|
-
|
|
145299
|
+
display: "flex",
|
|
145300
|
+
flexDirection: "column",
|
|
145301
|
+
gap: 10
|
|
143213
145302
|
},
|
|
143214
145303
|
"data-hardware-settings": true
|
|
143215
|
-
}, (0, react.createElement)("h2", { style:
|
|
143216
|
-
|
|
145304
|
+
}, (0, react.createElement)("h2", { style: {
|
|
145305
|
+
margin: 0,
|
|
145306
|
+
fontSize: 15,
|
|
145307
|
+
fontWeight: 600
|
|
145308
|
+
} }, "Hardware Engineering"), (0, react.createElement)("p", { style: MUTED }, "Local EDA and MCAD executables used for previews, fabrication packaging, one-click native open, and the agent environment context."), installationCard({
|
|
145309
|
+
key: "kicad",
|
|
145310
|
+
letter: "Ki",
|
|
145311
|
+
color: C.info,
|
|
145312
|
+
title: "KiCad EDA suite",
|
|
145313
|
+
blurb: "Accepts a KiCad installation root or a kicad-cli path. Drives .kicad_sch / .kicad_pcb preview, GLB export, BOM, gerber packaging and native open.",
|
|
143217
145314
|
value: kicadRoot,
|
|
143218
|
-
|
|
143219
|
-
|
|
143220
|
-
|
|
143221
|
-
|
|
143222
|
-
|
|
143223
|
-
|
|
143224
|
-
|
|
143225
|
-
|
|
143226
|
-
|
|
145315
|
+
placeholder: "C:\\Program Files\\KiCad\\8.0\\ or /usr/bin/kicad-cli",
|
|
145316
|
+
ok: kicad?.configured === true,
|
|
145317
|
+
status: kicad?.configured ? `v${kicad.version ?? "?"}` : "not configured",
|
|
145318
|
+
...kicad?.cli === void 0 ? {} : { detail: kicad.cli },
|
|
145319
|
+
onChange: setKicadRoot
|
|
145320
|
+
}), installationCard({
|
|
145321
|
+
key: "solidcraft",
|
|
145322
|
+
letter: "Sc",
|
|
145323
|
+
color: C.warn,
|
|
145324
|
+
title: "SolidCraft 3D CAD",
|
|
145325
|
+
blurb: "Agent environment context only in this POC. No native launch and no mechanical preview; the 3D destination renders the selected PCB.",
|
|
143227
145326
|
value: solidcraftRoot,
|
|
143228
|
-
|
|
143229
|
-
|
|
143230
|
-
|
|
143231
|
-
|
|
143232
|
-
|
|
143233
|
-
|
|
145327
|
+
placeholder: "C:\\Program Files\\SolidCraft\\bin\\SolidCraft.exe",
|
|
145328
|
+
ok: solidcraft?.configured === true,
|
|
145329
|
+
status: solidcraft?.configured ? "configured" : "not configured",
|
|
145330
|
+
...solidcraft?.executable === void 0 ? {} : { detail: solidcraft.executable },
|
|
145331
|
+
onChange: setSolidcraftRoot
|
|
145332
|
+
}), ...message === "" ? [] : [(0, react.createElement)("p", {
|
|
145333
|
+
role: "status",
|
|
145334
|
+
style: {
|
|
145335
|
+
...MUTED,
|
|
145336
|
+
color: C.text2
|
|
143234
145337
|
}
|
|
143235
|
-
}, "Validate / Save SolidCraft"), (0, react.createElement)("p", { style: MUTED }, "SolidCraft is agent environment context only in this POC; it has no native open action."), ...message === "" ? [] : [(0, react.createElement)("p", {
|
|
143236
|
-
style: MUTED,
|
|
143237
|
-
role: "status"
|
|
143238
145338
|
}, message)]);
|
|
143239
145339
|
}
|
|
143240
145340
|
//#endregion
|
|
@@ -143266,10 +145366,13 @@ void main() {
|
|
|
143266
145366
|
setWorkspaceRoot(draft, root) {
|
|
143267
145367
|
draft.workspaceRoot = root;
|
|
143268
145368
|
},
|
|
143269
|
-
setDiscovery(draft, discovery) {
|
|
145369
|
+
setDiscovery(draft, discovery, preserveSelection) {
|
|
145370
|
+
const moved = discovery.cwd !== void 0 && draft.workspaceRoot !== void 0 && discovery.cwd !== draft.workspaceRoot;
|
|
143270
145371
|
draft.discovery = discovery;
|
|
143271
145372
|
draft.workspaceRoot = discovery.cwd ?? draft.workspaceRoot;
|
|
143272
|
-
|
|
145373
|
+
if (preserveSelection === true && !moved) {
|
|
145374
|
+
if (discovery.selected !== void 0) draft.projectPath = discovery.selected.path;
|
|
145375
|
+
} else adoptProject(draft, discovery.selected);
|
|
143273
145376
|
draft.revision += 1;
|
|
143274
145377
|
},
|
|
143275
145378
|
selectProject(draft, path) {
|
|
@@ -143284,6 +145387,17 @@ void main() {
|
|
|
143284
145387
|
} else draft.pcbPath = path;
|
|
143285
145388
|
draft.revision += 1;
|
|
143286
145389
|
},
|
|
145390
|
+
applyNavigation(draft, params) {
|
|
145391
|
+
draft.activeDestination = params.destination;
|
|
145392
|
+
if (params.projectPath !== void 0) draft.projectPath = params.projectPath;
|
|
145393
|
+
if (params.path !== void 0) {
|
|
145394
|
+
if (params.destination === "schematic" || params.destination === "bom") {
|
|
145395
|
+
draft.schematicPath = params.path;
|
|
145396
|
+
draft.sheetPath = params.path;
|
|
145397
|
+
} else if (params.destination === "pcb" || params.destination === "3d" || params.destination === "order") draft.pcbPath = params.path;
|
|
145398
|
+
}
|
|
145399
|
+
draft.revision += 1;
|
|
145400
|
+
},
|
|
143287
145401
|
setInstallations(draft, installations) {
|
|
143288
145402
|
draft.installations = installations;
|
|
143289
145403
|
draft.revision += 1;
|
|
@@ -143318,9 +145432,10 @@ void main() {
|
|
|
143318
145432
|
setWorkspaceRoot: (root) => commit((draft) => {
|
|
143319
145433
|
draft.workspaceRoot = root;
|
|
143320
145434
|
}),
|
|
143321
|
-
setDiscovery: (discovery) => commit((draft) => mutators.setDiscovery(draft, discovery)),
|
|
145435
|
+
setDiscovery: (discovery, preserveSelection) => commit((draft) => mutators.setDiscovery(draft, discovery, preserveSelection)),
|
|
143322
145436
|
selectProject: (path) => commit((draft) => mutators.selectProject(draft, path)),
|
|
143323
145437
|
selectArtifact: (path, kind) => commit((draft) => mutators.selectArtifact(draft, path, kind)),
|
|
145438
|
+
applyNavigation: (params) => commit((draft) => mutators.applyNavigation(draft, params)),
|
|
143324
145439
|
setInstallations: (installations) => commit((draft) => mutators.setInstallations(draft, installations)),
|
|
143325
145440
|
setNotice: (notice) => commit((draft) => mutators.setNotice(draft, notice)),
|
|
143326
145441
|
refresh: () => commit((draft) => mutators.refresh(draft))
|
|
@@ -143346,6 +145461,13 @@ void main() {
|
|
|
143346
145461
|
* `keepMounted` right-panel tab body, and one settings section. Native open
|
|
143347
145462
|
* lives inside the viewer with the resolved artifact in scope, so no
|
|
143348
145463
|
* conversation-level action is registered.
|
|
145464
|
+
*
|
|
145465
|
+
* Two store handles, not one: DSH pins a handle to a single slot scope, and
|
|
145466
|
+
* `conversation.header.leading`/`settings.section` are `root` while
|
|
145467
|
+
* `sidebar.right.pane.tab` is `session`. Mounting one handle in both scopes is
|
|
145468
|
+
* rejected at load time ("one handle, one scope"). The two halves therefore
|
|
145469
|
+
* coordinate the only way the slot contract allows — through the tab
|
|
145470
|
+
* parameters and their navigation revision.
|
|
143349
145471
|
*/
|
|
143350
145472
|
/** Real Cordis service names this browser plugin waits for. */
|
|
143351
145473
|
const inject = [
|
|
@@ -143357,6 +145479,8 @@ void main() {
|
|
|
143357
145479
|
const HARDWARE_SETTINGS_ID = "hardware-engineering";
|
|
143358
145480
|
const HARDWARE_TAB_ID = "@huaqiu/dsh-hardware-ui";
|
|
143359
145481
|
const HARDWARE_TAB_KIND = "hardware-engineering";
|
|
145482
|
+
/** Host plugin row id whose volatile config backs the product settings page. */
|
|
145483
|
+
const HARDWARE_CONFIG_ENTRY = "hardware-artifacts";
|
|
143360
145484
|
/** Artifact kind discriminator carried in navigation params. */
|
|
143361
145485
|
function kindForPath(path) {
|
|
143362
145486
|
if (path.toLowerCase().endsWith(".kicad_sch")) return "schematic";
|
|
@@ -143364,84 +145488,51 @@ void main() {
|
|
|
143364
145488
|
if (path.toLowerCase().endsWith(".kicad_pro")) return "project";
|
|
143365
145489
|
return "bom";
|
|
143366
145490
|
}
|
|
143367
|
-
/** Destination-specific artifact kind used by the host `open` route. */
|
|
143368
|
-
function nativeKindFor(destination, path) {
|
|
143369
|
-
if (destination === "3d") return "pcb-3d";
|
|
143370
|
-
if (destination === "bom") return "bom";
|
|
143371
|
-
return kindForPath(path);
|
|
143372
|
-
}
|
|
143373
145491
|
/** Install all product UI contributions on a DSH client context. */
|
|
143374
145492
|
function apply(ctx) {
|
|
143375
|
-
const
|
|
143376
|
-
|
|
143377
|
-
let
|
|
145493
|
+
const rootStore = createHardwareStore();
|
|
145494
|
+
const viewerStore = createHardwareStore();
|
|
145495
|
+
let navigation = 0;
|
|
143378
145496
|
const effect = (fn, label) => {
|
|
143379
145497
|
if (ctx.effect !== void 0) ctx.effect(fn, label);
|
|
143380
145498
|
else fn();
|
|
143381
145499
|
};
|
|
143382
|
-
const
|
|
143383
|
-
|
|
143384
|
-
|
|
143385
|
-
};
|
|
143386
|
-
const injected = {
|
|
143387
|
-
async refreshDiscovery(cwd, project) {
|
|
143388
|
-
try {
|
|
143389
|
-
const result = await loadProjects(cwd, project);
|
|
143390
|
-
actions?.setDiscovery(result);
|
|
143391
|
-
if (result.issue?.code === "bad-manifest") actions?.setNotice(result.issue.message);
|
|
143392
|
-
} catch (error) {
|
|
143393
|
-
actions?.setNotice(`Artifact discovery failed: ${String(error)}`);
|
|
143394
|
-
}
|
|
145500
|
+
const controller = {
|
|
145501
|
+
discover(cwd, project, session) {
|
|
145502
|
+
return loadProjects(cwd, project, session);
|
|
143395
145503
|
},
|
|
143396
|
-
|
|
143397
|
-
|
|
143398
|
-
const kind = path === void 0 ? void 0 : kindForPath(path);
|
|
143399
|
-
try {
|
|
143400
|
-
ctx.sidebarRight?.openTab(HARDWARE_TAB_KIND, {
|
|
143401
|
-
params: {
|
|
143402
|
-
destination,
|
|
143403
|
-
...path === void 0 ? {} : { path },
|
|
143404
|
-
...kind === void 0 ? {} : { kind },
|
|
143405
|
-
navigationRevision: revision
|
|
143406
|
-
},
|
|
143407
|
-
revealIfOpened: true
|
|
143408
|
-
});
|
|
143409
|
-
} catch (error) {
|
|
143410
|
-
actions?.setNotice(`Open viewer failed: ${String(error)}`);
|
|
143411
|
-
}
|
|
143412
|
-
},
|
|
143413
|
-
async openNative(application, artifactPath) {
|
|
143414
|
-
if (artifactPath === void 0 || artifactPath === "") {
|
|
143415
|
-
actions?.setNotice("Select an artifact before opening it in KiCad.");
|
|
143416
|
-
return;
|
|
143417
|
-
}
|
|
143418
|
-
const destination = store.create().getSnapshot().activeDestination;
|
|
143419
|
-
try {
|
|
143420
|
-
await openArtifact({
|
|
143421
|
-
application: application ?? "kicad",
|
|
143422
|
-
artifactPath,
|
|
143423
|
-
kind: nativeKindFor(destination, artifactPath)
|
|
143424
|
-
});
|
|
143425
|
-
} catch (error) {
|
|
143426
|
-
actions?.setNotice(`Native launch failed: ${String(error)}`);
|
|
143427
|
-
throw error;
|
|
143428
|
-
}
|
|
145504
|
+
installations() {
|
|
145505
|
+
return loadInstallations();
|
|
143429
145506
|
},
|
|
143430
145507
|
async saveInstallation(application, root) {
|
|
143431
|
-
const form = ctx.configForms?.get(
|
|
145508
|
+
const form = ctx.configForms?.get(HARDWARE_CONFIG_ENTRY);
|
|
143432
145509
|
if (form === void 0) throw new Error("host settings are unavailable");
|
|
143433
145510
|
const field = application === "kicad" ? "kicadRoot" : "solidcraftRoot";
|
|
143434
145511
|
if (!await form.set(field, root)) throw new Error(`the host rejected the ${field} setting`);
|
|
143435
145512
|
},
|
|
143436
|
-
|
|
143437
|
-
|
|
143438
|
-
|
|
143439
|
-
|
|
143440
|
-
|
|
143441
|
-
|
|
145513
|
+
configForm() {
|
|
145514
|
+
return ctx.configForms?.get(HARDWARE_CONFIG_ENTRY);
|
|
145515
|
+
},
|
|
145516
|
+
openDestination(destination, path) {
|
|
145517
|
+
navigation += 1;
|
|
145518
|
+
const kind = path === void 0 ? void 0 : kindForPath(path);
|
|
145519
|
+
const params = {
|
|
145520
|
+
destination,
|
|
145521
|
+
...path === void 0 ? {} : { path },
|
|
145522
|
+
...kind === void 0 ? {} : { kind },
|
|
145523
|
+
navigationRevision: navigation
|
|
145524
|
+
};
|
|
145525
|
+
ctx.sidebarRight?.openTab(HARDWARE_TAB_KIND, {
|
|
145526
|
+
params,
|
|
145527
|
+
revealIfOpened: true
|
|
145528
|
+
});
|
|
143442
145529
|
},
|
|
143443
|
-
|
|
143444
|
-
|
|
145530
|
+
async openNative(request) {
|
|
145531
|
+
await openArtifact({
|
|
145532
|
+
application: request.application,
|
|
145533
|
+
artifactPath: request.artifactPath,
|
|
145534
|
+
kind: request.kind
|
|
145535
|
+
});
|
|
143445
145536
|
}
|
|
143446
145537
|
};
|
|
143447
145538
|
effect(() => ctx.sidebarRightTabs?.register({
|
|
@@ -143454,25 +145545,26 @@ void main() {
|
|
|
143454
145545
|
if (slots === void 0) return;
|
|
143455
145546
|
effect(() => slots.inject("conversation.header.leading", () => slots.register({
|
|
143456
145547
|
name: "conversation.header.leading",
|
|
143457
|
-
store,
|
|
143458
|
-
inject:
|
|
145548
|
+
store: rootStore,
|
|
145549
|
+
inject: () => controller
|
|
143459
145550
|
}, EngineeringNav)), "hardware-ui: five-destination navigation");
|
|
143460
145551
|
effect(() => slots.inject("sidebar.right.pane.tab", () => slots.register({
|
|
143461
145552
|
name: "sidebar.right.pane.tab",
|
|
143462
145553
|
key: HARDWARE_TAB_ID,
|
|
143463
|
-
store,
|
|
143464
|
-
inject:
|
|
145554
|
+
store: viewerStore,
|
|
145555
|
+
inject: () => controller
|
|
143465
145556
|
}, HardwareViewerBody)), "hardware-ui: viewer body");
|
|
143466
145557
|
effect(() => slots.inject("settings.section", () => slots.register({
|
|
143467
145558
|
name: "settings.section",
|
|
143468
145559
|
id: HARDWARE_SETTINGS_ID,
|
|
143469
145560
|
order: 85,
|
|
143470
145561
|
label: () => "Hardware Engineering",
|
|
143471
|
-
store,
|
|
143472
|
-
inject:
|
|
145562
|
+
store: rootStore,
|
|
145563
|
+
inject: () => controller
|
|
143473
145564
|
}, HardwareSettingsSection)), "hardware-ui: CAD installation settings");
|
|
143474
145565
|
}
|
|
143475
145566
|
//#endregion
|
|
145567
|
+
exports.HARDWARE_CONFIG_ENTRY = HARDWARE_CONFIG_ENTRY;
|
|
143476
145568
|
exports.HARDWARE_SETTINGS_ID = HARDWARE_SETTINGS_ID;
|
|
143477
145569
|
exports.HARDWARE_TAB_ID = HARDWARE_TAB_ID;
|
|
143478
145570
|
exports.HARDWARE_TAB_KIND = HARDWARE_TAB_KIND;
|