@tscircuit/cli 0.1.1492 → 0.1.1494
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/dist/cli/main.js +891 -94
- package/dist/lib/index.js +3 -3
- package/package.json +3 -3
package/dist/cli/main.js
CHANGED
|
@@ -100763,7 +100763,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
|
100763
100763
|
// lib/getVersion.ts
|
|
100764
100764
|
import { createRequire as createRequire2 } from "node:module";
|
|
100765
100765
|
// package.json
|
|
100766
|
-
var version = "0.1.
|
|
100766
|
+
var version = "0.1.1493";
|
|
100767
100767
|
var package_default = {
|
|
100768
100768
|
name: "@tscircuit/cli",
|
|
100769
100769
|
version,
|
|
@@ -100806,7 +100806,7 @@ var package_default = {
|
|
|
100806
100806
|
"circuit-json-to-readable-netlist": "^0.0.15",
|
|
100807
100807
|
"circuit-json-to-spice": "^0.0.10",
|
|
100808
100808
|
"circuit-json-to-step": "^0.0.33",
|
|
100809
|
-
"circuit-json-to-tscircuit": "^0.0.
|
|
100809
|
+
"circuit-json-to-tscircuit": "^0.0.35",
|
|
100810
100810
|
"circuit-json-trace-length-analysis": "github:tscircuit/circuit-json-trace-length-analysis#2b44792a40df0ca83b6bfb6ac95ed5e35e7168b8",
|
|
100811
100811
|
commander: "^14.0.0",
|
|
100812
100812
|
conf: "^13.1.0",
|
|
@@ -100814,7 +100814,7 @@ var package_default = {
|
|
|
100814
100814
|
cosmiconfig: "^9.0.0",
|
|
100815
100815
|
debug: "^4.4.0",
|
|
100816
100816
|
delay: "^6.0.0",
|
|
100817
|
-
"dsn-converter": "^0.0.
|
|
100817
|
+
"dsn-converter": "^0.0.90",
|
|
100818
100818
|
easyeda: "^0.0.269",
|
|
100819
100819
|
"fuse.js": "^7.1.0",
|
|
100820
100820
|
"get-port": "^7.1.0",
|
|
@@ -247293,6 +247293,9 @@ import fs46 from "node:fs/promises";
|
|
|
247293
247293
|
import path49 from "node:path";
|
|
247294
247294
|
import { parseKicadModToCircuitJson } from "kicad-component-converter";
|
|
247295
247295
|
|
|
247296
|
+
// node_modules/circuit-json-to-tscircuit/dist/chunk-WC7XDXUV.js
|
|
247297
|
+
import { su as su6 } from "@tscircuit/soup-util";
|
|
247298
|
+
|
|
247296
247299
|
// node_modules/@tscircuit/mm/dist/index.js
|
|
247297
247300
|
var unitToMm2 = {
|
|
247298
247301
|
in: 25.4,
|
|
@@ -247318,51 +247321,478 @@ var mmStr = (n3) => {
|
|
|
247318
247321
|
return `${mm3(n3)}mm`;
|
|
247319
247322
|
};
|
|
247320
247323
|
|
|
247321
|
-
// node_modules/circuit-json-to-tscircuit/dist/chunk-
|
|
247322
|
-
import { su as
|
|
247323
|
-
|
|
247324
|
-
|
|
247325
|
-
|
|
247326
|
-
|
|
247327
|
-
|
|
247328
|
-
|
|
247329
|
-
|
|
247324
|
+
// node_modules/circuit-json-to-tscircuit/dist/chunk-WC7XDXUV.js
|
|
247325
|
+
import { su as su23 } from "@tscircuit/soup-util";
|
|
247326
|
+
import { su as su33 } from "@tscircuit/soup-util";
|
|
247327
|
+
import { su as su42 } from "@tscircuit/soup-util";
|
|
247328
|
+
import { su as su5 } from "@tscircuit/soup-util";
|
|
247329
|
+
import { su as su62 } from "@tscircuit/soup-util";
|
|
247330
|
+
import { su as su7 } from "@tscircuit/soup-util";
|
|
247331
|
+
import { su as su8 } from "@tscircuit/soup-util";
|
|
247332
|
+
import { su as su9 } from "@tscircuit/soup-util";
|
|
247333
|
+
import { su as su10 } from "@tscircuit/soup-util";
|
|
247334
|
+
import { su as su11 } from "@tscircuit/soup-util";
|
|
247335
|
+
import { su as su12 } from "@tscircuit/soup-util";
|
|
247336
|
+
var escapeJsxText = (value) => String(value ?? "").replace(/"/g, "\\\"");
|
|
247337
|
+
var formatMm = (value) => mmStr(value ?? 0);
|
|
247338
|
+
var formatOptionalMmAttr = (attrName, value) => {
|
|
247339
|
+
if (value === undefined)
|
|
247340
|
+
return "";
|
|
247341
|
+
return ` ${attrName}="${mmStr(value)}"`;
|
|
247342
|
+
};
|
|
247343
|
+
var formatSolderMaskAttrs = (platedHole) => `${platedHole.is_covered_with_solder_mask === undefined ? "" : ` coveredWithSolderMask={${platedHole.is_covered_with_solder_mask}}`}${formatOptionalMmAttr("solderMaskMargin", platedHole.soldermask_margin)}`;
|
|
247344
|
+
var formatPcbRotationAttr = (rotation4, attrName = "pcbRotation") => {
|
|
247345
|
+
if (rotation4 === undefined)
|
|
247346
|
+
return "";
|
|
247347
|
+
const formatted = typeof rotation4 === "number" ? `${rotation4}deg` : rotation4;
|
|
247348
|
+
return ` ${attrName}="${formatted}"`;
|
|
247349
|
+
};
|
|
247350
|
+
var convertCopperText = (circuitJson) => {
|
|
247351
|
+
const copperTexts = su6(circuitJson).pcb_copper_text.list();
|
|
247352
|
+
const elementStrings = [];
|
|
247353
|
+
for (const copperText of copperTexts) {
|
|
247354
|
+
const anchorPosition = copperText.anchor_position ?? { x: 0, y: 0 };
|
|
247355
|
+
const attrs = [
|
|
247356
|
+
`pcbX={${anchorPosition.x}}`,
|
|
247357
|
+
`pcbY={${anchorPosition.y}}`,
|
|
247358
|
+
`anchorAlignment="${copperText.anchor_alignment ?? "center"}"`,
|
|
247359
|
+
`text="${escapeJsxText(copperText.text)}"`
|
|
247360
|
+
];
|
|
247361
|
+
if (copperText.font !== undefined) {
|
|
247362
|
+
attrs.push(`font="${copperText.font}"`);
|
|
247363
|
+
}
|
|
247364
|
+
if (copperText.font_size !== undefined) {
|
|
247365
|
+
attrs.push(`fontSize={${copperText.font_size}}`);
|
|
247366
|
+
}
|
|
247367
|
+
if (copperText.ccw_rotation !== undefined) {
|
|
247368
|
+
attrs.push(`pcbRotation="${copperText.ccw_rotation}deg"`);
|
|
247369
|
+
}
|
|
247370
|
+
if (copperText.is_knockout !== undefined) {
|
|
247371
|
+
attrs.push(`knockout={${copperText.is_knockout}}`);
|
|
247372
|
+
}
|
|
247373
|
+
if (copperText.is_mirrored !== undefined) {
|
|
247374
|
+
attrs.push(`mirrored={${copperText.is_mirrored}}`);
|
|
247375
|
+
}
|
|
247376
|
+
if (copperText.layer !== undefined && copperText.layer !== "top") {
|
|
247377
|
+
attrs.push(`layer="${copperText.layer}"`);
|
|
247378
|
+
}
|
|
247379
|
+
elementStrings.push(`<coppertext ${attrs.join(" ")} />`);
|
|
247380
|
+
}
|
|
247381
|
+
return elementStrings;
|
|
247382
|
+
};
|
|
247383
|
+
var convertCourtyard = (circuitJson) => {
|
|
247384
|
+
const courtyardOutlines = su23(circuitJson).pcb_courtyard_outline.list();
|
|
247385
|
+
const courtyardRects = su23(circuitJson).pcb_courtyard_rect.list();
|
|
247386
|
+
const courtyardCircles = su23(circuitJson).pcb_courtyard_circle.list();
|
|
247387
|
+
const elementStrings = [];
|
|
247388
|
+
for (const courtyardOutline of courtyardOutlines) {
|
|
247389
|
+
const attrs = [
|
|
247390
|
+
`outline={${JSON.stringify(courtyardOutline.outline ?? [])}}`
|
|
247391
|
+
];
|
|
247392
|
+
if (courtyardOutline.layer !== undefined) {
|
|
247393
|
+
attrs.push(`layer="${courtyardOutline.layer}"`);
|
|
247394
|
+
}
|
|
247395
|
+
elementStrings.push(`<courtyardoutline ${attrs.join(" ")} />`);
|
|
247396
|
+
}
|
|
247397
|
+
for (const courtyardRect of courtyardRects) {
|
|
247398
|
+
const attrs = [
|
|
247399
|
+
`pcbX={${courtyardRect.center?.x ?? 0}}`,
|
|
247400
|
+
`pcbY={${courtyardRect.center?.y ?? 0}}`,
|
|
247401
|
+
`width={${courtyardRect.width ?? 0}}`,
|
|
247402
|
+
`height={${courtyardRect.height ?? 0}}`
|
|
247403
|
+
];
|
|
247404
|
+
if (courtyardRect.layer !== undefined) {
|
|
247405
|
+
attrs.push(`layer="${courtyardRect.layer}"`);
|
|
247406
|
+
}
|
|
247407
|
+
elementStrings.push(`<courtyardrect ${attrs.join(" ")} />`);
|
|
247408
|
+
}
|
|
247409
|
+
for (const courtyardCircle of courtyardCircles) {
|
|
247410
|
+
const attrs = [
|
|
247411
|
+
`pcbX={${courtyardCircle.center?.x ?? 0}}`,
|
|
247412
|
+
`pcbY={${courtyardCircle.center?.y ?? 0}}`,
|
|
247413
|
+
`radius={${courtyardCircle.radius ?? 0}}`
|
|
247414
|
+
];
|
|
247415
|
+
if (courtyardCircle.layer !== undefined) {
|
|
247416
|
+
attrs.push(`layer="${courtyardCircle.layer}"`);
|
|
247417
|
+
}
|
|
247418
|
+
elementStrings.push(`<courtyardcircle ${attrs.join(" ")} />`);
|
|
247419
|
+
}
|
|
247420
|
+
return elementStrings;
|
|
247421
|
+
};
|
|
247422
|
+
var convertCutouts = (circuitJson) => {
|
|
247423
|
+
const pcbCutouts = su33(circuitJson).pcb_cutout.list();
|
|
247424
|
+
const elementStrings = [];
|
|
247425
|
+
for (const cutout of pcbCutouts) {
|
|
247426
|
+
if (cutout.shape === "rect") {
|
|
247427
|
+
const rotation4 = cutout.rotation !== undefined ? ` pcbRotation="${formatMm(cutout.rotation)}"` : "";
|
|
247428
|
+
elementStrings.push(`<cutout shape="rect" pcbX="${formatMm(cutout.center.x)}" pcbY="${formatMm(cutout.center.y)}" width="${formatMm(cutout.width)}" height="${formatMm(cutout.height)}"${rotation4} />`);
|
|
247429
|
+
} else if (cutout.shape === "circle") {
|
|
247430
|
+
elementStrings.push(`<cutout shape="circle" pcbX="${formatMm(cutout.center.x)}" pcbY="${formatMm(cutout.center.y)}" radius="${formatMm(cutout.radius)}" />`);
|
|
247431
|
+
} else if (cutout.shape === "polygon") {
|
|
247432
|
+
elementStrings.push(`<cutout shape="polygon" points={${JSON.stringify(cutout.points)}} />`);
|
|
247433
|
+
} else {
|
|
247434
|
+
console.warn(`Unhandled pcb_cutout shape: ${cutout.shape}`);
|
|
247435
|
+
}
|
|
247436
|
+
}
|
|
247437
|
+
return elementStrings;
|
|
247438
|
+
};
|
|
247439
|
+
var convertFabrication = (circuitJson) => {
|
|
247440
|
+
const fabricationNotePaths = su42(circuitJson).pcb_fabrication_note_path.list();
|
|
247441
|
+
const fabricationNoteTexts = su42(circuitJson).pcb_fabrication_note_text.list();
|
|
247442
|
+
const fabricationNoteRects = su42(circuitJson).pcb_fabrication_note_rect.list();
|
|
247443
|
+
const fabricationNoteDimensions = su42(circuitJson).pcb_fabrication_note_dimension.list();
|
|
247444
|
+
const elementStrings = [];
|
|
247445
|
+
for (const fabPath of fabricationNotePaths) {
|
|
247446
|
+
const attrs = [`route={${JSON.stringify(fabPath.route)}}`];
|
|
247447
|
+
if ("stroke_width" in fabPath && fabPath.stroke_width !== undefined) {
|
|
247448
|
+
attrs.push(`strokeWidth={${fabPath.stroke_width}}`);
|
|
247449
|
+
}
|
|
247450
|
+
if ("color" in fabPath && fabPath.color !== undefined) {
|
|
247451
|
+
attrs.push(`color="${fabPath.color}"`);
|
|
247452
|
+
}
|
|
247453
|
+
if ("layer" in fabPath && fabPath.layer === "bottom") {
|
|
247454
|
+
attrs.push(`layer="bottom"`);
|
|
247455
|
+
}
|
|
247456
|
+
elementStrings.push(`<fabricationnotepath ${attrs.join(" ")} />`);
|
|
247457
|
+
}
|
|
247458
|
+
for (const fabText of fabricationNoteTexts) {
|
|
247459
|
+
const anchorPosition = fabText.anchor_position ?? { x: 0, y: 0 };
|
|
247460
|
+
const attrs = [
|
|
247461
|
+
`pcbX={${anchorPosition.x}}`,
|
|
247462
|
+
`pcbY={${anchorPosition.y}}`,
|
|
247463
|
+
`anchorAlignment="${fabText.anchor_alignment ?? "center"}"`,
|
|
247464
|
+
`text="${escapeJsxText(fabText.text)}"`
|
|
247465
|
+
];
|
|
247466
|
+
if (fabText.font !== undefined) {
|
|
247467
|
+
attrs.push(`font="${fabText.font}"`);
|
|
247468
|
+
}
|
|
247469
|
+
if (fabText.font_size !== undefined) {
|
|
247470
|
+
attrs.push(`fontSize={${fabText.font_size}}`);
|
|
247471
|
+
}
|
|
247472
|
+
if (fabText.color !== undefined) {
|
|
247473
|
+
attrs.push(`color="${fabText.color}"`);
|
|
247474
|
+
}
|
|
247475
|
+
if (fabText.layer === "bottom") {
|
|
247476
|
+
attrs.push(`layer="bottom"`);
|
|
247477
|
+
}
|
|
247478
|
+
elementStrings.push(`<fabricationnotetext ${attrs.join(" ")} />`);
|
|
247479
|
+
}
|
|
247480
|
+
for (const fabRect of fabricationNoteRects) {
|
|
247481
|
+
const center2 = fabRect.center ?? { x: 0, y: 0 };
|
|
247482
|
+
const attrs = [
|
|
247483
|
+
`pcbX={${center2.x}}`,
|
|
247484
|
+
`pcbY={${center2.y}}`,
|
|
247485
|
+
`width={${fabRect.width ?? 0}}`,
|
|
247486
|
+
`height={${fabRect.height ?? 0}}`
|
|
247487
|
+
];
|
|
247488
|
+
if (fabRect.stroke_width !== undefined) {
|
|
247489
|
+
attrs.push(`strokeWidth={${fabRect.stroke_width}}`);
|
|
247490
|
+
}
|
|
247491
|
+
if (fabRect.is_filled !== undefined) {
|
|
247492
|
+
attrs.push(`isFilled={${fabRect.is_filled}}`);
|
|
247493
|
+
}
|
|
247494
|
+
if (fabRect.has_stroke !== undefined) {
|
|
247495
|
+
attrs.push(`hasStroke={${fabRect.has_stroke}}`);
|
|
247496
|
+
}
|
|
247497
|
+
if (fabRect.is_stroke_dashed !== undefined) {
|
|
247498
|
+
attrs.push(`isStrokeDashed={${fabRect.is_stroke_dashed}}`);
|
|
247499
|
+
}
|
|
247500
|
+
if (fabRect.color !== undefined) {
|
|
247501
|
+
attrs.push(`color="${fabRect.color}"`);
|
|
247502
|
+
}
|
|
247503
|
+
if ("corner_radius" in fabRect && fabRect.corner_radius !== undefined) {
|
|
247504
|
+
attrs.push(`cornerRadius={${fabRect.corner_radius}}`);
|
|
247505
|
+
}
|
|
247506
|
+
if (fabRect.layer === "bottom") {
|
|
247507
|
+
attrs.push(`layer="bottom"`);
|
|
247508
|
+
}
|
|
247509
|
+
elementStrings.push(`<fabricationnoterect ${attrs.join(" ")} />`);
|
|
247510
|
+
}
|
|
247511
|
+
for (const fabDimension of fabricationNoteDimensions) {
|
|
247512
|
+
const fromPoint = fabDimension.from ?? { x: 0, y: 0 };
|
|
247513
|
+
const toPoint = fabDimension.to ?? { x: 0, y: 0 };
|
|
247514
|
+
const attrs = [
|
|
247515
|
+
`from={{ x: ${fromPoint.x}, y: ${fromPoint.y} }}`,
|
|
247516
|
+
`to={{ x: ${toPoint.x}, y: ${toPoint.y} }}`
|
|
247517
|
+
];
|
|
247518
|
+
if (fabDimension.text !== undefined) {
|
|
247519
|
+
attrs.push(`text="${escapeJsxText(fabDimension.text)}"`);
|
|
247520
|
+
}
|
|
247521
|
+
if (fabDimension.font !== undefined) {
|
|
247522
|
+
attrs.push(`font="${fabDimension.font}"`);
|
|
247523
|
+
}
|
|
247524
|
+
if (fabDimension.font_size !== undefined) {
|
|
247525
|
+
attrs.push(`fontSize={${fabDimension.font_size}}`);
|
|
247526
|
+
}
|
|
247527
|
+
if (fabDimension.color !== undefined) {
|
|
247528
|
+
attrs.push(`color="${fabDimension.color}"`);
|
|
247529
|
+
}
|
|
247530
|
+
if (fabDimension.arrow_size !== undefined) {
|
|
247531
|
+
attrs.push(`arrowSize={${fabDimension.arrow_size}}`);
|
|
247532
|
+
}
|
|
247533
|
+
if (fabDimension.offset !== undefined) {
|
|
247534
|
+
attrs.push(`offset={${fabDimension.offset}}`);
|
|
247535
|
+
} else if ("offset_distance" in fabDimension && fabDimension.offset_distance !== undefined) {
|
|
247536
|
+
attrs.push(`offset={${fabDimension.offset_distance}}`);
|
|
247537
|
+
}
|
|
247538
|
+
if (fabDimension.layer === "bottom") {
|
|
247539
|
+
attrs.push(`layer="bottom"`);
|
|
247540
|
+
}
|
|
247541
|
+
elementStrings.push(`<fabricationnotedimension ${attrs.join(" ")} />`);
|
|
247542
|
+
}
|
|
247543
|
+
return elementStrings;
|
|
247544
|
+
};
|
|
247545
|
+
var convertHoles = (circuitJson) => {
|
|
247546
|
+
const holes = su5(circuitJson).pcb_hole.list();
|
|
247330
247547
|
const elementStrings = [];
|
|
247331
247548
|
for (const hole of holes) {
|
|
247332
247549
|
if (hole.hole_shape === "circle") {
|
|
247333
247550
|
elementStrings.push(`<hole pcbX="${mmStr(hole.x)}" pcbY="${mmStr(hole.y)}" diameter="${mmStr(hole.hole_diameter)}" />`);
|
|
247551
|
+
} else if (hole.hole_shape === "rect") {
|
|
247552
|
+
elementStrings.push(`<hole pcbX="${mmStr(hole.x)}" pcbY="${mmStr(hole.y)}" width="${mmStr(hole.hole_width)}" height="${mmStr(hole.hole_height)}" shape="rect" />`);
|
|
247334
247553
|
} else if (hole.hole_shape === "oval") {
|
|
247335
|
-
|
|
247554
|
+
elementStrings.push(`<hole pcbX="${mmStr(hole.x)}" pcbY="${mmStr(hole.y)}" width="${mmStr(hole.hole_width)}" height="${mmStr(hole.hole_height)}" shape="oval" />`);
|
|
247555
|
+
} else if (hole.hole_shape === "pill" || hole.hole_shape === "rotated_pill") {
|
|
247556
|
+
elementStrings.push(`<hole pcbX="${mmStr(hole.x)}" pcbY="${mmStr(hole.y)}" width="${mmStr(hole.hole_width)}" height="${mmStr(hole.hole_height)}" shape="pill"${formatPcbRotationAttr("ccw_rotation" in hole ? hole.ccw_rotation : undefined)} />`);
|
|
247557
|
+
}
|
|
247558
|
+
}
|
|
247559
|
+
return elementStrings;
|
|
247560
|
+
};
|
|
247561
|
+
var convertKeepouts = (circuitJson) => {
|
|
247562
|
+
const pcbKeepouts = su62(circuitJson).pcb_keepout.list();
|
|
247563
|
+
const elementStrings = [];
|
|
247564
|
+
for (const keepout of pcbKeepouts) {
|
|
247565
|
+
if (keepout.shape === "rect") {
|
|
247566
|
+
elementStrings.push(`<keepout shape="rect" pcbX="${formatMm(keepout.center.x)}" pcbY="${formatMm(keepout.center.y)}" width="${formatMm(keepout.width)}" height="${formatMm(keepout.height)}" />`);
|
|
247567
|
+
} else if (keepout.shape === "circle") {
|
|
247568
|
+
elementStrings.push(`<keepout shape="circle" pcbX="${formatMm(keepout.center.x)}" pcbY="${formatMm(keepout.center.y)}" radius="${formatMm(keepout.radius)}" />`);
|
|
247569
|
+
} else {
|
|
247570
|
+
console.warn(`Unhandled pcb_keepout shape: ${keepout.shape}`);
|
|
247571
|
+
}
|
|
247572
|
+
}
|
|
247573
|
+
return elementStrings;
|
|
247574
|
+
};
|
|
247575
|
+
var convertNotes = (circuitJson) => {
|
|
247576
|
+
const noteTexts = su7(circuitJson).pcb_note_text.list();
|
|
247577
|
+
const noteRects = su7(circuitJson).pcb_note_rect.list();
|
|
247578
|
+
const notePaths = su7(circuitJson).pcb_note_path.list();
|
|
247579
|
+
const noteLines = su7(circuitJson).pcb_note_line.list();
|
|
247580
|
+
const noteDimensions = su7(circuitJson).pcb_note_dimension.list();
|
|
247581
|
+
const elementStrings = [];
|
|
247582
|
+
for (const noteText of noteTexts) {
|
|
247583
|
+
const anchorPosition = noteText.anchor_position ?? { x: 0, y: 0 };
|
|
247584
|
+
const colorAttr = noteText.color ? ` color="${noteText.color}"` : "";
|
|
247585
|
+
elementStrings.push(`<pcbnotetext pcbX={${anchorPosition.x}} pcbY={${anchorPosition.y}} anchorAlignment="${noteText.anchor_alignment ?? "center"}" font="${noteText.font ?? "tscircuit2024"}" fontSize={${noteText.font_size ?? 0}} text="${escapeJsxText(noteText.text)}"${colorAttr} />`);
|
|
247586
|
+
}
|
|
247587
|
+
for (const noteRect of noteRects) {
|
|
247588
|
+
const center2 = noteRect.center ?? { x: 0, y: 0 };
|
|
247589
|
+
const attrs = [
|
|
247590
|
+
`pcbX={${center2.x}}`,
|
|
247591
|
+
`pcbY={${center2.y}}`,
|
|
247592
|
+
`width={${noteRect.width ?? 0}}`,
|
|
247593
|
+
`height={${noteRect.height ?? 0}}`,
|
|
247594
|
+
`strokeWidth={${noteRect.stroke_width ?? 0}}`
|
|
247595
|
+
];
|
|
247596
|
+
if (noteRect.is_filled !== undefined) {
|
|
247597
|
+
attrs.push(`isFilled={${noteRect.is_filled}}`);
|
|
247336
247598
|
}
|
|
247599
|
+
if (noteRect.has_stroke !== undefined) {
|
|
247600
|
+
attrs.push(`hasStroke={${noteRect.has_stroke}}`);
|
|
247601
|
+
}
|
|
247602
|
+
if (noteRect.is_stroke_dashed !== undefined) {
|
|
247603
|
+
attrs.push(`isStrokeDashed={${noteRect.is_stroke_dashed}}`);
|
|
247604
|
+
}
|
|
247605
|
+
if (noteRect.color !== undefined) {
|
|
247606
|
+
attrs.push(`color="${noteRect.color}"`);
|
|
247607
|
+
}
|
|
247608
|
+
elementStrings.push(`<pcbnoterect ${attrs.join(" ")} />`);
|
|
247609
|
+
}
|
|
247610
|
+
for (const notePath of notePaths) {
|
|
247611
|
+
const attrs = [`route={${JSON.stringify(notePath.route ?? [])}}`];
|
|
247612
|
+
if (notePath.stroke_width !== undefined) {
|
|
247613
|
+
attrs.push(`strokeWidth={${notePath.stroke_width}}`);
|
|
247614
|
+
}
|
|
247615
|
+
if (notePath.color !== undefined) {
|
|
247616
|
+
attrs.push(`color="${notePath.color}"`);
|
|
247617
|
+
}
|
|
247618
|
+
elementStrings.push(`<pcbnotepath ${attrs.join(" ")} />`);
|
|
247619
|
+
}
|
|
247620
|
+
for (const noteLine of noteLines) {
|
|
247621
|
+
const attrs = [
|
|
247622
|
+
`x1={${noteLine.x1 ?? 0}}`,
|
|
247623
|
+
`y1={${noteLine.y1 ?? 0}}`,
|
|
247624
|
+
`x2={${noteLine.x2 ?? 0}}`,
|
|
247625
|
+
`y2={${noteLine.y2 ?? 0}}`
|
|
247626
|
+
];
|
|
247627
|
+
if (noteLine.stroke_width !== undefined) {
|
|
247628
|
+
attrs.push(`strokeWidth={${noteLine.stroke_width}}`);
|
|
247629
|
+
}
|
|
247630
|
+
if (noteLine.color !== undefined) {
|
|
247631
|
+
attrs.push(`color="${noteLine.color}"`);
|
|
247632
|
+
}
|
|
247633
|
+
if (noteLine.is_dashed !== undefined) {
|
|
247634
|
+
attrs.push(`isDashed={${noteLine.is_dashed}}`);
|
|
247635
|
+
}
|
|
247636
|
+
elementStrings.push(`<pcbnoteline ${attrs.join(" ")} />`);
|
|
247637
|
+
}
|
|
247638
|
+
for (const noteDimension of noteDimensions) {
|
|
247639
|
+
const fromPoint = noteDimension.from ?? { x: 0, y: 0 };
|
|
247640
|
+
const toPoint = noteDimension.to ?? { x: 0, y: 0 };
|
|
247641
|
+
const attrs = [
|
|
247642
|
+
`from={{ x: ${fromPoint.x}, y: ${fromPoint.y} }}`,
|
|
247643
|
+
`to={{ x: ${toPoint.x}, y: ${toPoint.y} }}`,
|
|
247644
|
+
`font="${noteDimension.font ?? "tscircuit2024"}"`,
|
|
247645
|
+
`fontSize={${noteDimension.font_size ?? 0}}`
|
|
247646
|
+
];
|
|
247647
|
+
if (noteDimension.arrow_size !== undefined) {
|
|
247648
|
+
attrs.push(`arrowSize={${noteDimension.arrow_size}}`);
|
|
247649
|
+
}
|
|
247650
|
+
if ("offset" in noteDimension) {
|
|
247651
|
+
const offsetValue = noteDimension.offset;
|
|
247652
|
+
if (offsetValue !== undefined) {
|
|
247653
|
+
attrs.push(`offset={${offsetValue}}`);
|
|
247654
|
+
}
|
|
247655
|
+
}
|
|
247656
|
+
if (noteDimension.text !== undefined) {
|
|
247657
|
+
attrs.push(`text="${escapeJsxText(noteDimension.text)}"`);
|
|
247658
|
+
}
|
|
247659
|
+
if (noteDimension.color !== undefined) {
|
|
247660
|
+
attrs.push(`color="${noteDimension.color}"`);
|
|
247661
|
+
}
|
|
247662
|
+
elementStrings.push(`<pcbnotedimension ${attrs.join(" ")} />`);
|
|
247337
247663
|
}
|
|
247664
|
+
return elementStrings;
|
|
247665
|
+
};
|
|
247666
|
+
var convertPlatedHoles2 = (circuitJson) => {
|
|
247667
|
+
const platedHoles = su8(circuitJson).pcb_plated_hole.list();
|
|
247668
|
+
const elementStrings = [];
|
|
247338
247669
|
for (const platedHole of platedHoles) {
|
|
247339
247670
|
if (platedHole.shape === "oval" || platedHole.shape === "pill") {
|
|
247340
|
-
elementStrings.push(`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr(platedHole.x)}" pcbY="${mmStr(platedHole.y)}" outerHeight="${mmStr(platedHole.outer_height)}" outerWidth="${mmStr(platedHole.outer_width)}" holeHeight="${mmStr(platedHole.hole_height)}" holeWidth="${mmStr(platedHole.hole_width)}" height="${mmStr(platedHole.hole_height)}" shape="${platedHole.shape}" />`);
|
|
247671
|
+
elementStrings.push(`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr(platedHole.x)}" pcbY="${mmStr(platedHole.y)}"${formatSolderMaskAttrs(platedHole)} outerHeight="${mmStr(platedHole.outer_height)}" outerWidth="${mmStr(platedHole.outer_width)}" holeHeight="${mmStr(platedHole.hole_height)}" holeWidth="${mmStr(platedHole.hole_width)}" height="${mmStr(platedHole.hole_height)}" shape="${platedHole.shape}"${formatPcbRotationAttr("ccw_rotation" in platedHole ? platedHole.ccw_rotation : undefined)} />`);
|
|
247341
247672
|
} else if (platedHole.shape === "circle") {
|
|
247342
|
-
elementStrings.push(`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr(platedHole.x)}" pcbY="${mmStr(platedHole.y)}" outerDiameter="${mmStr(platedHole.outer_diameter)}" holeDiameter="${mmStr(platedHole.hole_diameter)}" shape="circle" />`);
|
|
247673
|
+
elementStrings.push(`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr(platedHole.x)}" pcbY="${mmStr(platedHole.y)}"${formatSolderMaskAttrs(platedHole)} outerDiameter="${mmStr(platedHole.outer_diameter)}" holeDiameter="${mmStr(platedHole.hole_diameter)}" shape="circle" />`);
|
|
247674
|
+
} else if (platedHole.shape === "circular_hole_with_rect_pad") {
|
|
247675
|
+
elementStrings.push(`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr(platedHole.x)}" pcbY="${mmStr(platedHole.y)}"${platedHole.hole_shape === undefined ? "" : ` holeShape="${platedHole.hole_shape}"`}${platedHole.pad_shape === undefined ? "" : ` padShape="${platedHole.pad_shape}"`}${formatSolderMaskAttrs(platedHole)} holeDiameter="${mmStr(platedHole.hole_diameter)}" rectPadWidth="${mmStr(platedHole.rect_pad_width)}" rectPadHeight="${mmStr(platedHole.rect_pad_height)}"${formatOptionalMmAttr("rectBorderRadius", platedHole.rect_border_radius)}${formatOptionalMmAttr("holeOffsetX", platedHole.hole_offset_x)}${formatOptionalMmAttr("holeOffsetY", platedHole.hole_offset_y)}${formatPcbRotationAttr(platedHole.rect_ccw_rotation)} shape="circular_hole_with_rect_pad" />`);
|
|
247676
|
+
} else if (platedHole.shape === "pill_hole_with_rect_pad" || platedHole.shape === "rotated_pill_hole_with_rect_pad") {
|
|
247677
|
+
const holeShape = platedHole.shape === "rotated_pill_hole_with_rect_pad" ? "pill" : platedHole.hole_shape;
|
|
247678
|
+
const rotation4 = platedHole.shape === "rotated_pill_hole_with_rect_pad" ? platedHole.hole_ccw_rotation : undefined;
|
|
247679
|
+
elementStrings.push(`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr(platedHole.x)}" pcbY="${mmStr(platedHole.y)}"${holeShape === undefined ? "" : ` holeShape="${holeShape}"`}${platedHole.pad_shape === undefined ? "" : ` padShape="${platedHole.pad_shape}"`}${formatSolderMaskAttrs(platedHole)} holeWidth="${mmStr(platedHole.hole_width)}" holeHeight="${mmStr(platedHole.hole_height)}" rectPadWidth="${mmStr(platedHole.rect_pad_width)}" rectPadHeight="${mmStr(platedHole.rect_pad_height)}"${formatOptionalMmAttr("rectBorderRadius", platedHole.rect_border_radius)}${formatOptionalMmAttr("holeOffsetX", platedHole.hole_offset_x)}${formatOptionalMmAttr("holeOffsetY", platedHole.hole_offset_y)}${formatPcbRotationAttr(rotation4)} shape="pill_hole_with_rect_pad" />`);
|
|
247680
|
+
} else if (platedHole.shape === "hole_with_polygon_pad") {
|
|
247681
|
+
const holeSizeAttrs = platedHole.hole_shape === "circle" ? ` holeDiameter="${mmStr(platedHole.hole_diameter ?? 0)}"` : `${formatOptionalMmAttr("holeWidth", platedHole.hole_width)}${formatOptionalMmAttr("holeHeight", platedHole.hole_height)}`;
|
|
247682
|
+
elementStrings.push(`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr(platedHole.x)}" pcbY="${mmStr(platedHole.y)}"${platedHole.hole_shape === undefined ? "" : ` holeShape="${platedHole.hole_shape}"`}${formatSolderMaskAttrs(platedHole)}${holeSizeAttrs} padOutline={${JSON.stringify(platedHole.pad_outline)}} holeOffsetX="${mmStr(platedHole.hole_offset_x ?? 0)}" holeOffsetY="${mmStr(platedHole.hole_offset_y ?? 0)}" shape="hole_with_polygon_pad" />`);
|
|
247683
|
+
}
|
|
247684
|
+
}
|
|
247685
|
+
return elementStrings;
|
|
247686
|
+
};
|
|
247687
|
+
var convertSilkscreen = (circuitJson) => {
|
|
247688
|
+
const silkscreenLines = su9(circuitJson).pcb_silkscreen_line.list();
|
|
247689
|
+
const silkscreenPaths = su9(circuitJson).pcb_silkscreen_path.list();
|
|
247690
|
+
const silkscreenRects = su9(circuitJson).pcb_silkscreen_rect.list();
|
|
247691
|
+
const silkscreenCircles = su9(circuitJson).pcb_silkscreen_circle.list();
|
|
247692
|
+
const elementStrings = [];
|
|
247693
|
+
for (const silkscreenPath of silkscreenPaths) {
|
|
247694
|
+
elementStrings.push(`<silkscreenpath route={${JSON.stringify(silkscreenPath.route)}} />`);
|
|
247695
|
+
}
|
|
247696
|
+
for (const silkscreenRect of silkscreenRects) {
|
|
247697
|
+
const center2 = silkscreenRect.center ?? { x: 0, y: 0 };
|
|
247698
|
+
const attrs = [
|
|
247699
|
+
`pcbX={${center2.x}}`,
|
|
247700
|
+
`pcbY={${center2.y}}`,
|
|
247701
|
+
`width={${silkscreenRect.width ?? 0}}`,
|
|
247702
|
+
`height={${silkscreenRect.height ?? 0}}`,
|
|
247703
|
+
`layer="${silkscreenRect.layer}"`
|
|
247704
|
+
];
|
|
247705
|
+
if (silkscreenRect.stroke_width !== undefined) {
|
|
247706
|
+
attrs.push(`strokeWidth={${silkscreenRect.stroke_width}}`);
|
|
247707
|
+
}
|
|
247708
|
+
if (silkscreenRect.is_filled !== undefined) {
|
|
247709
|
+
attrs.push(`filled={${silkscreenRect.is_filled}}`);
|
|
247710
|
+
}
|
|
247711
|
+
if (silkscreenRect.corner_radius !== undefined) {
|
|
247712
|
+
attrs.push(`cornerRadius={${silkscreenRect.corner_radius}}`);
|
|
247713
|
+
}
|
|
247714
|
+
elementStrings.push(`<silkscreenrect ${attrs.join(" ")} />`);
|
|
247715
|
+
}
|
|
247716
|
+
for (const silkscreenCircle of silkscreenCircles) {
|
|
247717
|
+
const center2 = silkscreenCircle.center ?? { x: 0, y: 0 };
|
|
247718
|
+
const attrs = [
|
|
247719
|
+
`pcbX={${center2.x}}`,
|
|
247720
|
+
`pcbY={${center2.y}}`,
|
|
247721
|
+
`radius={${silkscreenCircle.radius ?? 0}}`,
|
|
247722
|
+
`layer="${silkscreenCircle.layer}"`
|
|
247723
|
+
];
|
|
247724
|
+
if (silkscreenCircle.stroke_width !== undefined) {
|
|
247725
|
+
attrs.push(`strokeWidth={${silkscreenCircle.stroke_width}}`);
|
|
247726
|
+
}
|
|
247727
|
+
if (silkscreenCircle.is_filled !== undefined) {
|
|
247728
|
+
attrs.push(`isFilled={${silkscreenCircle.is_filled}}`);
|
|
247729
|
+
}
|
|
247730
|
+
elementStrings.push(`<silkscreencircle ${attrs.join(" ")} />`);
|
|
247731
|
+
}
|
|
247732
|
+
for (const silkscreenLine of silkscreenLines) {
|
|
247733
|
+
const attrs = [
|
|
247734
|
+
`x1={${silkscreenLine.x1 ?? 0}}`,
|
|
247735
|
+
`y1={${silkscreenLine.y1 ?? 0}}`,
|
|
247736
|
+
`x2={${silkscreenLine.x2 ?? 0}}`,
|
|
247737
|
+
`y2={${silkscreenLine.y2 ?? 0}}`
|
|
247738
|
+
];
|
|
247739
|
+
if (silkscreenLine.stroke_width !== undefined) {
|
|
247740
|
+
attrs.push(`strokeWidth={${silkscreenLine.stroke_width}}`);
|
|
247741
|
+
}
|
|
247742
|
+
if (silkscreenLine.layer === "bottom") {
|
|
247743
|
+
attrs.push(`layer="bottom"`);
|
|
247343
247744
|
}
|
|
247745
|
+
elementStrings.push(`<silkscreenline ${attrs.join(" ")} />`);
|
|
247344
247746
|
}
|
|
247747
|
+
return elementStrings;
|
|
247748
|
+
};
|
|
247749
|
+
var convertSilkscreenText = (circuitJson) => {
|
|
247750
|
+
const silkscreenTexts = su10(circuitJson).pcb_silkscreen_text.list();
|
|
247751
|
+
const elementStrings = [];
|
|
247752
|
+
for (const silkscreenText of silkscreenTexts) {
|
|
247753
|
+
const pcbX = silkscreenText.anchor_position?.x ?? 0;
|
|
247754
|
+
const pcbY = silkscreenText.anchor_position?.y ?? 0;
|
|
247755
|
+
const knockoutPadding = silkscreenText.knockout_padding;
|
|
247756
|
+
const hasUniformKnockoutPadding = knockoutPadding && knockoutPadding.left === knockoutPadding.top && knockoutPadding.top === knockoutPadding.right && knockoutPadding.right === knockoutPadding.bottom;
|
|
247757
|
+
elementStrings.push(`<silkscreentext pcbX={${pcbX}} pcbY={${pcbY}} anchorAlignment="${silkscreenText.anchor_alignment}" fontSize={${silkscreenText.font_size}}${silkscreenText.font !== undefined ? ` font="${silkscreenText.font}"` : ""}${silkscreenText.ccw_rotation !== undefined ? ` pcbRotation="${typeof silkscreenText.ccw_rotation === "number" ? `${silkscreenText.ccw_rotation}deg` : silkscreenText.ccw_rotation}"` : ""}${silkscreenText.is_knockout !== undefined ? ` isKnockout={${silkscreenText.is_knockout}}` : ""}${knockoutPadding ? hasUniformKnockoutPadding ? ` knockoutPadding="${mmStr(knockoutPadding.left)}"` : ` knockoutPaddingLeft="${mmStr(knockoutPadding.left)}" knockoutPaddingTop="${mmStr(knockoutPadding.top)}" knockoutPaddingRight="${mmStr(knockoutPadding.right)}" knockoutPaddingBottom="${mmStr(knockoutPadding.bottom)}"` : ""}${silkscreenText.is_mirrored !== undefined ? ` mirrored={${silkscreenText.is_mirrored}}` : ""}${silkscreenText.layer !== undefined ? ` layer="${silkscreenText.layer}"` : ""} text="${escapeJsxText(silkscreenText.text)}" />`);
|
|
247758
|
+
}
|
|
247759
|
+
return elementStrings;
|
|
247760
|
+
};
|
|
247761
|
+
var convertSmtPads = (circuitJson) => {
|
|
247762
|
+
const smtPads = su11(circuitJson).pcb_smtpad.list();
|
|
247763
|
+
const elementStrings = [];
|
|
247345
247764
|
for (const smtPad of smtPads) {
|
|
247346
247765
|
if (smtPad.shape === "circle") {
|
|
247347
247766
|
elementStrings.push(`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${mmStr(smtPad.x)}" pcbY="${mmStr(smtPad.y)}" radius="${mmStr(smtPad.radius)}" shape="circle" />`);
|
|
247348
247767
|
} else if (smtPad.shape === "rect") {
|
|
247349
247768
|
elementStrings.push(`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${mmStr(smtPad.x)}" pcbY="${mmStr(smtPad.y)}" width="${mmStr(smtPad.width)}" height="${mmStr(smtPad.height)}" shape="rect" />`);
|
|
247769
|
+
} else if (smtPad.shape === "pill") {
|
|
247770
|
+
elementStrings.push(`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${mmStr(smtPad.x)}" pcbY="${mmStr(smtPad.y)}" width="${mmStr(smtPad.width)}" height="${mmStr(smtPad.height)}" radius="${mmStr(smtPad.radius)}" shape="pill" />`);
|
|
247771
|
+
} else if (smtPad.shape === "polygon") {
|
|
247772
|
+
elementStrings.push(`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} shape="polygon" points={${JSON.stringify(smtPad.points)}} />`);
|
|
247773
|
+
} else if (smtPad.shape === "rotated_rect") {
|
|
247774
|
+
elementStrings.push(`<smtpad portHints={${JSON.stringify(smtPad.port_hints)}} pcbX="${mmStr(smtPad.x)}" pcbY="${mmStr(smtPad.y)}" width="${mmStr(smtPad.width)}" height="${mmStr(smtPad.height)}" ccwRotation={${smtPad.ccw_rotation}} shape="rotated_rect" />`);
|
|
247350
247775
|
}
|
|
247351
247776
|
}
|
|
247352
|
-
|
|
247353
|
-
|
|
247354
|
-
|
|
247355
|
-
|
|
247356
|
-
|
|
247357
|
-
|
|
247358
|
-
|
|
247359
|
-
|
|
247360
|
-
|
|
247361
|
-
|
|
247362
|
-
|
|
247363
|
-
|
|
247364
|
-
|
|
247365
|
-
|
|
247777
|
+
return elementStrings;
|
|
247778
|
+
};
|
|
247779
|
+
var generateFootprintTsx = (circuitJson) => {
|
|
247780
|
+
const converters = [
|
|
247781
|
+
convertHoles,
|
|
247782
|
+
convertPlatedHoles2,
|
|
247783
|
+
convertSmtPads,
|
|
247784
|
+
convertSilkscreen,
|
|
247785
|
+
convertFabrication,
|
|
247786
|
+
convertSilkscreenText,
|
|
247787
|
+
convertCopperText,
|
|
247788
|
+
convertKeepouts,
|
|
247789
|
+
convertCutouts,
|
|
247790
|
+
convertNotes,
|
|
247791
|
+
convertCourtyard
|
|
247792
|
+
];
|
|
247793
|
+
const elementStrings = converters.flatMap((convert) => convert(circuitJson));
|
|
247794
|
+
if (elementStrings.length === 0) {
|
|
247795
|
+
return null;
|
|
247366
247796
|
}
|
|
247367
247797
|
return `
|
|
247368
247798
|
<footprint>
|
|
@@ -247371,6 +247801,206 @@ var generateFootprintTsx = (circuitJson) => {
|
|
|
247371
247801
|
</footprint>
|
|
247372
247802
|
`.trim();
|
|
247373
247803
|
};
|
|
247804
|
+
var escapeJsxText2 = (text) => text.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
247805
|
+
var generateSymbolTsx = (circuitJson) => {
|
|
247806
|
+
const schematicArcs = su12(circuitJson).schematic_arc.list();
|
|
247807
|
+
const schematicLines = su12(circuitJson).schematic_line.list();
|
|
247808
|
+
const schematicPaths = su12(circuitJson).schematic_path.list();
|
|
247809
|
+
const schematicTexts = su12(circuitJson).schematic_text.list();
|
|
247810
|
+
const schematicCircles = su12(circuitJson).schematic_circle.list();
|
|
247811
|
+
const schematicBoxes = su12(circuitJson).schematic_box.list();
|
|
247812
|
+
const schematicRects = su12(circuitJson).schematic_rect.list();
|
|
247813
|
+
const schematicTables = su12(circuitJson).schematic_table.list();
|
|
247814
|
+
const schematicTableCells = su12(circuitJson).schematic_table_cell.list();
|
|
247815
|
+
const elementStrings = [];
|
|
247816
|
+
for (const arc2 of schematicArcs) {
|
|
247817
|
+
const center2 = arc2.center ?? { x: 0, y: 0 };
|
|
247818
|
+
const radius = arc2.radius ?? 0;
|
|
247819
|
+
const startAngle = arc2.start_angle_degrees ?? 0;
|
|
247820
|
+
const endAngle = arc2.end_angle_degrees ?? 0;
|
|
247821
|
+
const strokeWidth = arc2.stroke_width ?? 0.05;
|
|
247822
|
+
const color = arc2.color ?? "black";
|
|
247823
|
+
const isDashed = arc2.is_dashed ?? false;
|
|
247824
|
+
const direction2 = arc2.direction ?? "counterclockwise";
|
|
247825
|
+
elementStrings.push(`<schematicarc
|
|
247826
|
+
center={{ x: ${center2.x}, y: ${center2.y} }}
|
|
247827
|
+
radius={${radius}}
|
|
247828
|
+
startAngleDegrees={${startAngle}}
|
|
247829
|
+
endAngleDegrees={${endAngle}}
|
|
247830
|
+
strokeWidth={${strokeWidth}}
|
|
247831
|
+
color="${color}"
|
|
247832
|
+
isDashed={${isDashed}}
|
|
247833
|
+
direction="${direction2}"
|
|
247834
|
+
/>`);
|
|
247835
|
+
}
|
|
247836
|
+
for (const line2 of schematicLines) {
|
|
247837
|
+
const x12 = line2.x1 ?? 0;
|
|
247838
|
+
const y12 = line2.y1 ?? 0;
|
|
247839
|
+
const x23 = line2.x2 ?? 0;
|
|
247840
|
+
const y23 = line2.y2 ?? 0;
|
|
247841
|
+
const strokeWidth = line2.stroke_width ?? 0.05;
|
|
247842
|
+
const color = line2.color ?? "black";
|
|
247843
|
+
const isDashed = line2.is_dashed ?? false;
|
|
247844
|
+
const dashLength = line2.dash_length;
|
|
247845
|
+
const dashGap = line2.dash_gap;
|
|
247846
|
+
const attrs = [
|
|
247847
|
+
`x1={${x12}}`,
|
|
247848
|
+
`y1={${y12}}`,
|
|
247849
|
+
`x2={${x23}}`,
|
|
247850
|
+
`y2={${y23}}`,
|
|
247851
|
+
`strokeWidth={${strokeWidth}}`,
|
|
247852
|
+
`color="${color}"`,
|
|
247853
|
+
`isDashed={${isDashed}}`
|
|
247854
|
+
];
|
|
247855
|
+
if (dashLength != null) {
|
|
247856
|
+
attrs.push(`dashLength={${dashLength}}`);
|
|
247857
|
+
}
|
|
247858
|
+
if (dashGap != null) {
|
|
247859
|
+
attrs.push(`dashGap={${dashGap}}`);
|
|
247860
|
+
}
|
|
247861
|
+
elementStrings.push(`<schematicline ${attrs.join(" ")}/>`);
|
|
247862
|
+
}
|
|
247863
|
+
for (const box2 of schematicBoxes) {
|
|
247864
|
+
const x3 = box2.x ?? 0;
|
|
247865
|
+
const y4 = box2.y ?? 0;
|
|
247866
|
+
const width = box2.width ?? 0;
|
|
247867
|
+
const height = box2.height ?? 0;
|
|
247868
|
+
const isDashed = box2.is_dashed ?? false;
|
|
247869
|
+
elementStrings.push(`<schematicbox center={{ x: ${x3}, y: ${y4} }} width={${width}} height={${height}} isDashed={${isDashed}}/>`);
|
|
247870
|
+
}
|
|
247871
|
+
for (const rect of schematicRects) {
|
|
247872
|
+
const center2 = rect.center ?? { x: 0, y: 0 };
|
|
247873
|
+
const width = rect.width ?? 0;
|
|
247874
|
+
const height = rect.height ?? 0;
|
|
247875
|
+
const rotation4 = rect.rotation ?? 0;
|
|
247876
|
+
const strokeWidth = rect.stroke_width ?? 0;
|
|
247877
|
+
const color = rect.color ?? "black";
|
|
247878
|
+
const isFilled = rect.is_filled ?? false;
|
|
247879
|
+
const fillColor = rect.fill_color ?? color;
|
|
247880
|
+
const isDashed = rect.is_dashed ?? false;
|
|
247881
|
+
elementStrings.push(`<schematicrect schX={${center2.x}} schY={${center2.y}} width={${width}} height={${height}} rotation={${rotation4}} strokeWidth={${strokeWidth}} color="${color}" isFilled={${isFilled}} fillColor="${fillColor}" isDashed={${isDashed}} />`);
|
|
247882
|
+
}
|
|
247883
|
+
for (const path49 of schematicPaths) {
|
|
247884
|
+
const points = path49.points ?? [];
|
|
247885
|
+
const fillColor = path49.fill_color ?? "red";
|
|
247886
|
+
const isFilled = path49.is_filled ?? false;
|
|
247887
|
+
const dashLength = path49.dash_length;
|
|
247888
|
+
const dashGap = path49.dash_gap;
|
|
247889
|
+
const attrs = [
|
|
247890
|
+
`points={${JSON.stringify(points)}}`,
|
|
247891
|
+
`strokeColor="${fillColor}"`,
|
|
247892
|
+
`fillColor="${fillColor}"`,
|
|
247893
|
+
`isFilled={${isFilled}}`
|
|
247894
|
+
];
|
|
247895
|
+
if (dashLength != null) {
|
|
247896
|
+
attrs.push(`dashLength={${dashLength}}`);
|
|
247897
|
+
}
|
|
247898
|
+
if (dashGap != null) {
|
|
247899
|
+
attrs.push(`dashGap={${dashGap}}`);
|
|
247900
|
+
}
|
|
247901
|
+
elementStrings.push(`<schematicpath ${attrs.join(" ")}/>`);
|
|
247902
|
+
}
|
|
247903
|
+
for (const text of schematicTexts) {
|
|
247904
|
+
const x3 = text.position?.x ?? 0;
|
|
247905
|
+
const y4 = text.position?.y ?? 0;
|
|
247906
|
+
const rawText = String(text.text ?? "");
|
|
247907
|
+
const escapedText = escapeJsxText2(rawText);
|
|
247908
|
+
const anchorAlignment = text.anchor ?? "center";
|
|
247909
|
+
const fontSize = text.font_size ?? 0.1;
|
|
247910
|
+
const color = text.color ?? "black";
|
|
247911
|
+
const rotation4 = text.rotation ?? 0;
|
|
247912
|
+
elementStrings.push(`<schematictext text="${escapedText}" x={${x3}} y={${y4}} anchorAlignment="${anchorAlignment}" fontSize={${fontSize}} color="${color}" rotation={${rotation4}} />`);
|
|
247913
|
+
}
|
|
247914
|
+
for (const circle2 of schematicCircles) {
|
|
247915
|
+
const x3 = circle2.center?.x ?? 0;
|
|
247916
|
+
const y4 = circle2.center?.y ?? 0;
|
|
247917
|
+
const radius = circle2.radius ?? 0;
|
|
247918
|
+
const strokeWidth = circle2.stroke_width ?? 0.05;
|
|
247919
|
+
const color = circle2.color ?? "black";
|
|
247920
|
+
const isFilled = circle2.is_filled ?? false;
|
|
247921
|
+
const isDashed = circle2.is_dashed ?? false;
|
|
247922
|
+
elementStrings.push(`<schematiccircle center={{ x: ${x3}, y: ${y4} }} radius={${radius}} strokeWidth={${strokeWidth}} color="${color}" isFilled={${isFilled}} isDashed={${isDashed}} />`);
|
|
247923
|
+
}
|
|
247924
|
+
for (const table of schematicTables) {
|
|
247925
|
+
const tableCells = schematicTableCells.filter((cell) => cell.schematic_table_id === table.schematic_table_id).sort((a2, b) => {
|
|
247926
|
+
if (a2.start_row_index !== b.start_row_index) {
|
|
247927
|
+
return a2.start_row_index - b.start_row_index;
|
|
247928
|
+
}
|
|
247929
|
+
return a2.start_column_index - b.start_column_index;
|
|
247930
|
+
});
|
|
247931
|
+
const rowCount = table.row_heights.length;
|
|
247932
|
+
const rowStrings = [];
|
|
247933
|
+
for (let rowIndex = 0;rowIndex < rowCount; rowIndex++) {
|
|
247934
|
+
const rowHeight = table.row_heights[rowIndex];
|
|
247935
|
+
const rowCells = tableCells.filter((cell) => cell.start_row_index === rowIndex);
|
|
247936
|
+
const cellStrings = [];
|
|
247937
|
+
for (const cell of rowCells) {
|
|
247938
|
+
const rowSpan = cell.end_row_index - cell.start_row_index + 1;
|
|
247939
|
+
const colSpan = cell.end_column_index - cell.start_column_index + 1;
|
|
247940
|
+
const columnWidths = table.column_widths.slice(cell.start_column_index, cell.end_column_index + 1);
|
|
247941
|
+
const averageColumnWidth = columnWidths.length > 0 ? columnWidths.reduce((sum, width) => sum + width, 0) / columnWidths.length : cell.width / Math.max(colSpan, 1);
|
|
247942
|
+
const props = [];
|
|
247943
|
+
const text = cell.text ?? "";
|
|
247944
|
+
if (text.length > 0) {
|
|
247945
|
+
props.push(`text="${escapeJsxText2(text)}"`);
|
|
247946
|
+
}
|
|
247947
|
+
if (cell.horizontal_align) {
|
|
247948
|
+
props.push(`horizontalAlign="${cell.horizontal_align}"`);
|
|
247949
|
+
}
|
|
247950
|
+
if (cell.vertical_align) {
|
|
247951
|
+
props.push(`verticalAlign="${cell.vertical_align}"`);
|
|
247952
|
+
}
|
|
247953
|
+
if (cell.font_size != null) {
|
|
247954
|
+
props.push(`fontSize={${cell.font_size}}`);
|
|
247955
|
+
}
|
|
247956
|
+
if (rowSpan !== 1) {
|
|
247957
|
+
props.push(`rowSpan={${rowSpan}}`);
|
|
247958
|
+
}
|
|
247959
|
+
if (colSpan !== 1) {
|
|
247960
|
+
props.push(`colSpan={${colSpan}}`);
|
|
247961
|
+
}
|
|
247962
|
+
if (averageColumnWidth > 0) {
|
|
247963
|
+
props.push(`width={${averageColumnWidth}}`);
|
|
247964
|
+
}
|
|
247965
|
+
cellStrings.push(`<schematiccell ${props.join(" ")} />`);
|
|
247966
|
+
}
|
|
247967
|
+
rowStrings.push(`<schematicrow height={${rowHeight}}>
|
|
247968
|
+
${cellStrings.join(`
|
|
247969
|
+
`)}
|
|
247970
|
+
</schematicrow>`);
|
|
247971
|
+
}
|
|
247972
|
+
const tableProps = [
|
|
247973
|
+
`schX={${table.anchor_position.x}}`,
|
|
247974
|
+
`schY={${table.anchor_position.y}}`
|
|
247975
|
+
];
|
|
247976
|
+
if (table.cell_padding != null) {
|
|
247977
|
+
tableProps.push(`cellPadding={${table.cell_padding}}`);
|
|
247978
|
+
}
|
|
247979
|
+
if (table.border_width != null) {
|
|
247980
|
+
tableProps.push(`borderWidth={${table.border_width}}`);
|
|
247981
|
+
}
|
|
247982
|
+
if (table.anchor) {
|
|
247983
|
+
tableProps.push(`anchor="${table.anchor}"`);
|
|
247984
|
+
}
|
|
247985
|
+
elementStrings.push(`<schematictable ${tableProps.join(" ")}>
|
|
247986
|
+
${rowStrings.map((s2) => s2.split(`
|
|
247987
|
+
`).join(`
|
|
247988
|
+
`)).join(`
|
|
247989
|
+
`)}
|
|
247990
|
+
</schematictable>`);
|
|
247991
|
+
}
|
|
247992
|
+
if (elementStrings.length === 0) {
|
|
247993
|
+
return null;
|
|
247994
|
+
}
|
|
247995
|
+
return `
|
|
247996
|
+
<symbol>
|
|
247997
|
+
${elementStrings.map((s2) => s2.split(`
|
|
247998
|
+
`).join(`
|
|
247999
|
+
`)).join(`
|
|
248000
|
+
`)}
|
|
248001
|
+
</symbol>
|
|
248002
|
+
`.trim();
|
|
248003
|
+
};
|
|
247374
248004
|
var getComponentUsingTemplate = ({
|
|
247375
248005
|
pinLabels,
|
|
247376
248006
|
componentName,
|
|
@@ -247380,12 +248010,14 @@ var getComponentUsingTemplate = ({
|
|
|
247380
248010
|
manufacturerPartNumber
|
|
247381
248011
|
}) => {
|
|
247382
248012
|
const footprintTsx = generateFootprintTsx(circuitJson);
|
|
248013
|
+
const symbolTsx = generateSymbolTsx(circuitJson);
|
|
247383
248014
|
return `
|
|
247384
248015
|
import { type ChipProps } from "tscircuit"
|
|
247385
248016
|
${pinLabels ? `const pinLabels = ${JSON.stringify(pinLabels, null, " ")} as const
|
|
247386
248017
|
` : ""}export const ${componentName} = (props: ChipProps${pinLabels ? `<typeof pinLabels>` : ""}) => (
|
|
247387
248018
|
<chip
|
|
247388
|
-
footprint={${footprintTsx}}
|
|
248019
|
+
${footprintTsx ? `footprint={${footprintTsx}}` : ""}
|
|
248020
|
+
${symbolTsx ? `symbol={${symbolTsx}}` : ""}
|
|
247389
248021
|
${pinLabels ? "pinLabels={pinLabels}" : ""}
|
|
247390
248022
|
${objUrl ? `cadModel={{
|
|
247391
248023
|
objUrl: "${objUrl}",
|
|
@@ -252236,16 +252868,17 @@ import {
|
|
|
252236
252868
|
} from "circuit-to-svg";
|
|
252237
252869
|
|
|
252238
252870
|
// node_modules/dsn-converter/dist/index.js
|
|
252239
|
-
import { su as
|
|
252871
|
+
import { su as su13 } from "@tscircuit/soup-util";
|
|
252872
|
+
import { getBoundsFromPoints as getBoundsFromPoints3 } from "@tscircuit/math-utils";
|
|
252240
252873
|
import { applyToPoint as applyToPoint25, scale as scale7 } from "transformation-matrix";
|
|
252241
|
-
import { su as
|
|
252242
|
-
import { su as
|
|
252874
|
+
import { su as su24 } from "@tscircuit/soup-util";
|
|
252875
|
+
import { su as su34 } from "@tscircuit/soup-util";
|
|
252243
252876
|
import Debug4 from "debug";
|
|
252244
|
-
import { su as
|
|
252877
|
+
import { su as su43 } from "@tscircuit/soup-util";
|
|
252245
252878
|
import { applyToPoint as applyToPoint24, scale as scale22 } from "transformation-matrix";
|
|
252246
252879
|
import Debug22 from "debug";
|
|
252247
252880
|
import { applyToPoint as applyToPoint92, scale as scale32 } from "transformation-matrix";
|
|
252248
|
-
import { su as
|
|
252881
|
+
import { su as su52 } from "@tscircuit/soup-util";
|
|
252249
252882
|
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
252250
252883
|
import Debug32 from "debug";
|
|
252251
252884
|
import { applyToPoint as applyToPoint42 } from "transformation-matrix";
|
|
@@ -252257,7 +252890,7 @@ import { applyToPoint as applyToPoint62 } from "transformation-matrix";
|
|
|
252257
252890
|
import Debug5 from "debug";
|
|
252258
252891
|
import { applyToPoint as applyToPoint72 } from "transformation-matrix";
|
|
252259
252892
|
import"transformation-matrix";
|
|
252260
|
-
import { su as
|
|
252893
|
+
import { su as su63 } from "@tscircuit/soup-util";
|
|
252261
252894
|
import Debug7 from "debug";
|
|
252262
252895
|
import { applyToPoint as applyToPoint112, scale as scale42 } from "transformation-matrix";
|
|
252263
252896
|
import"transformation-matrix";
|
|
@@ -252363,6 +252996,24 @@ function createRectangularPadstack(name, width, height, layer) {
|
|
|
252363
252996
|
attach: "off"
|
|
252364
252997
|
};
|
|
252365
252998
|
}
|
|
252999
|
+
function createPolygonPadstack({
|
|
253000
|
+
name,
|
|
253001
|
+
coordinates,
|
|
253002
|
+
layer
|
|
253003
|
+
}) {
|
|
253004
|
+
return {
|
|
253005
|
+
name,
|
|
253006
|
+
shapes: [
|
|
253007
|
+
{
|
|
253008
|
+
shapeType: "polygon",
|
|
253009
|
+
layer: layer === "bottom" ? "B.Cu" : "F.Cu",
|
|
253010
|
+
width: 0,
|
|
253011
|
+
coordinates
|
|
253012
|
+
}
|
|
253013
|
+
],
|
|
253014
|
+
attach: "off"
|
|
253015
|
+
};
|
|
253016
|
+
}
|
|
252366
253017
|
function createCircularHoleRectangularPadstack(name, outerWidth, outerHeight, holeDiameter, numLayers = 2) {
|
|
252367
253018
|
const halfWidth = outerWidth / 2;
|
|
252368
253019
|
const halfHeight = outerHeight / 2;
|
|
@@ -252393,13 +253044,21 @@ function createCircularHoleRectangularPadstack(name, outerWidth, outerHeight, ho
|
|
|
252393
253044
|
attach: "off"
|
|
252394
253045
|
};
|
|
252395
253046
|
}
|
|
253047
|
+
var padstackNamePrefixes = {
|
|
253048
|
+
circle: "Round[",
|
|
253049
|
+
oval: "Oval[",
|
|
253050
|
+
pill: "Oval[",
|
|
253051
|
+
rect: "RoundRect[",
|
|
253052
|
+
polygon: "Cust["
|
|
253053
|
+
};
|
|
252396
253054
|
function getPadstackName({
|
|
252397
253055
|
shape,
|
|
252398
253056
|
width,
|
|
252399
253057
|
height,
|
|
252400
253058
|
holeDiameter,
|
|
252401
253059
|
outerDiameter,
|
|
252402
|
-
layer = "top"
|
|
253060
|
+
layer = "top",
|
|
253061
|
+
customDescriptor
|
|
252403
253062
|
}) {
|
|
252404
253063
|
const layerCode = {
|
|
252405
253064
|
top: "T",
|
|
@@ -252408,52 +253067,182 @@ function getPadstackName({
|
|
|
252408
253067
|
}[layer] ?? "T";
|
|
252409
253068
|
switch (shape) {
|
|
252410
253069
|
case "circle":
|
|
252411
|
-
return
|
|
253070
|
+
return `${padstackNamePrefixes.circle}${layerCode}]Pad_${holeDiameter}_${outerDiameter}_um`;
|
|
252412
253071
|
case "oval":
|
|
252413
|
-
return
|
|
253072
|
+
return `${padstackNamePrefixes.oval}${layerCode}]Pad_${width}x${height}_um`;
|
|
252414
253073
|
case "pill":
|
|
252415
|
-
return
|
|
253074
|
+
return `${padstackNamePrefixes.pill}${layerCode}]Pad_${width}x${height}_um`;
|
|
252416
253075
|
case "rect":
|
|
252417
|
-
return
|
|
253076
|
+
return `${padstackNamePrefixes.rect}${layerCode}]Pad_${width}x${height}_um`;
|
|
253077
|
+
case "polygon":
|
|
253078
|
+
return `${padstackNamePrefixes.polygon}${layerCode}]Pad_${customDescriptor ?? `${width}x${height}`}_um`;
|
|
252418
253079
|
default:
|
|
252419
253080
|
return "default_pad";
|
|
252420
253081
|
}
|
|
252421
253082
|
}
|
|
252422
|
-
function
|
|
253083
|
+
function roundMicrons(microns) {
|
|
253084
|
+
return Number(microns.toFixed(3));
|
|
253085
|
+
}
|
|
253086
|
+
function getNormalizedPoints(points) {
|
|
253087
|
+
if (points.length < 2)
|
|
253088
|
+
return points;
|
|
253089
|
+
const firstPoint = points[0];
|
|
253090
|
+
const lastPoint = points[points.length - 1];
|
|
253091
|
+
if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) {
|
|
253092
|
+
return points.slice(0, -1);
|
|
253093
|
+
}
|
|
253094
|
+
return points;
|
|
253095
|
+
}
|
|
253096
|
+
function getPolygonCentroid2(points) {
|
|
253097
|
+
let signedArea3 = 0;
|
|
253098
|
+
let centroidX = 0;
|
|
253099
|
+
let centroidY = 0;
|
|
253100
|
+
for (let index = 0;index < points.length; index++) {
|
|
253101
|
+
const currentPoint = points[index];
|
|
253102
|
+
const nextPoint = points[(index + 1) % points.length];
|
|
253103
|
+
const crossProduct = currentPoint.x * nextPoint.y - nextPoint.x * currentPoint.y;
|
|
253104
|
+
signedArea3 += crossProduct;
|
|
253105
|
+
centroidX += (currentPoint.x + nextPoint.x) * crossProduct;
|
|
253106
|
+
centroidY += (currentPoint.y + nextPoint.y) * crossProduct;
|
|
253107
|
+
}
|
|
253108
|
+
if (signedArea3 === 0)
|
|
253109
|
+
return null;
|
|
253110
|
+
const areaFactor = signedArea3 * 3;
|
|
253111
|
+
return {
|
|
253112
|
+
x: centroidX / areaFactor,
|
|
253113
|
+
y: centroidY / areaFactor
|
|
253114
|
+
};
|
|
253115
|
+
}
|
|
253116
|
+
function getPolygonSmtPadGeometry(pad2) {
|
|
253117
|
+
const points = getNormalizedPoints(pad2.points);
|
|
253118
|
+
const bounds = getBoundsFromPoints3(points);
|
|
253119
|
+
if (!bounds) {
|
|
253120
|
+
return {
|
|
253121
|
+
center: { x: 0, y: 0 },
|
|
253122
|
+
widthUm: 0,
|
|
253123
|
+
heightUm: 0,
|
|
253124
|
+
relativePointsUm: []
|
|
253125
|
+
};
|
|
253126
|
+
}
|
|
253127
|
+
const { minX, maxX, minY, maxY } = bounds;
|
|
253128
|
+
const polygonCentroid = getPolygonCentroid2(points);
|
|
253129
|
+
const center2 = polygonCentroid ?? {
|
|
253130
|
+
x: (minX + maxX) / 2,
|
|
253131
|
+
y: (minY + maxY) / 2
|
|
253132
|
+
};
|
|
253133
|
+
const relativePointsUm = points.flatMap((point5) => [
|
|
253134
|
+
roundMicrons((point5.x - center2.x) * 1000),
|
|
253135
|
+
roundMicrons((point5.y - center2.y) * 1000)
|
|
253136
|
+
]);
|
|
253137
|
+
if (points.length > 0) {
|
|
253138
|
+
relativePointsUm.push(relativePointsUm[0], relativePointsUm[1]);
|
|
253139
|
+
}
|
|
253140
|
+
return {
|
|
253141
|
+
center: center2,
|
|
253142
|
+
widthUm: roundMicrons((maxX - minX) * 1000),
|
|
253143
|
+
heightUm: roundMicrons((maxY - minY) * 1000),
|
|
253144
|
+
relativePointsUm
|
|
253145
|
+
};
|
|
253146
|
+
}
|
|
253147
|
+
function createAndAddPadstackFromPcbSmtPad({
|
|
253148
|
+
pcb,
|
|
253149
|
+
pad: pad2,
|
|
253150
|
+
processedPadstacks
|
|
253151
|
+
}) {
|
|
252423
253152
|
const isCircle = pad2.shape === "circle";
|
|
253153
|
+
const isPolygon = pad2.shape === "polygon";
|
|
253154
|
+
const polygonPadGeometry = isPolygon ? getPolygonSmtPadGeometry(pad2) : undefined;
|
|
253155
|
+
let shape = "rect";
|
|
253156
|
+
let outerDiameter;
|
|
253157
|
+
let holeDiameter;
|
|
253158
|
+
let width;
|
|
253159
|
+
let height;
|
|
253160
|
+
let customDescriptor;
|
|
253161
|
+
if (isCircle) {
|
|
253162
|
+
shape = "circle";
|
|
253163
|
+
outerDiameter = pad2.radius * 1000 * 2;
|
|
253164
|
+
holeDiameter = pad2.radius * 1000 * 2;
|
|
253165
|
+
} else if (isPolygon) {
|
|
253166
|
+
shape = "polygon";
|
|
253167
|
+
width = polygonPadGeometry?.widthUm;
|
|
253168
|
+
height = polygonPadGeometry?.heightUm;
|
|
253169
|
+
customDescriptor = `${polygonPadGeometry?.widthUm}x${polygonPadGeometry?.heightUm}_${polygonPadGeometry?.relativePointsUm.join("_")}`;
|
|
253170
|
+
} else {
|
|
253171
|
+
width = pad2.width * 1000;
|
|
253172
|
+
height = pad2.height * 1000;
|
|
253173
|
+
}
|
|
252424
253174
|
const padstackParams = {
|
|
252425
|
-
shape
|
|
252426
|
-
outerDiameter
|
|
252427
|
-
holeDiameter
|
|
252428
|
-
width
|
|
252429
|
-
height
|
|
252430
|
-
layer: pad2.layer
|
|
253175
|
+
shape,
|
|
253176
|
+
outerDiameter,
|
|
253177
|
+
holeDiameter,
|
|
253178
|
+
width,
|
|
253179
|
+
height,
|
|
253180
|
+
layer: pad2.layer,
|
|
253181
|
+
customDescriptor
|
|
252431
253182
|
};
|
|
252432
253183
|
const padstackName = getPadstackName(padstackParams);
|
|
252433
253184
|
if (!processedPadstacks.has(padstackName)) {
|
|
252434
|
-
|
|
253185
|
+
let padstack;
|
|
253186
|
+
if (isCircle) {
|
|
253187
|
+
padstack = createCircularPadstack(padstackName, padstackParams.outerDiameter, padstackParams.holeDiameter);
|
|
253188
|
+
} else if (isPolygon) {
|
|
253189
|
+
padstack = createPolygonPadstack({
|
|
253190
|
+
name: padstackName,
|
|
253191
|
+
coordinates: polygonPadGeometry.relativePointsUm,
|
|
253192
|
+
layer: pad2.layer
|
|
253193
|
+
});
|
|
253194
|
+
} else {
|
|
253195
|
+
padstack = createRectangularPadstack(padstackName, padstackParams.width, padstackParams.height, pad2.layer);
|
|
253196
|
+
}
|
|
252435
253197
|
pcb.library.padstacks.push(padstack);
|
|
252436
253198
|
processedPadstacks.add(padstackName);
|
|
252437
253199
|
}
|
|
252438
253200
|
return padstackName;
|
|
252439
253201
|
}
|
|
252440
|
-
function createPinForImage(
|
|
253202
|
+
function createPinForImage({
|
|
253203
|
+
pad: pad2,
|
|
253204
|
+
pcbComponent,
|
|
253205
|
+
sourcePort
|
|
253206
|
+
}) {
|
|
252441
253207
|
if (!sourcePort)
|
|
252442
253208
|
return;
|
|
252443
253209
|
const isCircle = pad2.shape === "circle";
|
|
253210
|
+
const isPolygon = pad2.shape === "polygon";
|
|
253211
|
+
const polygonPadGeometry = isPolygon ? getPolygonSmtPadGeometry(pad2) : undefined;
|
|
253212
|
+
let shape = "rect";
|
|
253213
|
+
let outerDiameter;
|
|
253214
|
+
let holeDiameter;
|
|
253215
|
+
let width;
|
|
253216
|
+
let height;
|
|
253217
|
+
let customDescriptor;
|
|
253218
|
+
if (isCircle) {
|
|
253219
|
+
shape = "circle";
|
|
253220
|
+
outerDiameter = pad2.radius * 1000 * 2;
|
|
253221
|
+
holeDiameter = pad2.radius * 1000 * 2;
|
|
253222
|
+
} else if (isPolygon) {
|
|
253223
|
+
shape = "polygon";
|
|
253224
|
+
width = polygonPadGeometry?.widthUm;
|
|
253225
|
+
height = polygonPadGeometry?.heightUm;
|
|
253226
|
+
customDescriptor = `${polygonPadGeometry?.widthUm}x${polygonPadGeometry?.heightUm}_${polygonPadGeometry?.relativePointsUm.join("_")}`;
|
|
253227
|
+
} else {
|
|
253228
|
+
width = pad2.width * 1000;
|
|
253229
|
+
height = pad2.height * 1000;
|
|
253230
|
+
}
|
|
252444
253231
|
const padstackParams = {
|
|
252445
|
-
shape
|
|
252446
|
-
outerDiameter
|
|
252447
|
-
holeDiameter
|
|
252448
|
-
width
|
|
252449
|
-
height
|
|
252450
|
-
layer: pad2.layer
|
|
253232
|
+
shape,
|
|
253233
|
+
outerDiameter,
|
|
253234
|
+
holeDiameter,
|
|
253235
|
+
width,
|
|
253236
|
+
height,
|
|
253237
|
+
layer: pad2.layer,
|
|
253238
|
+
customDescriptor
|
|
252451
253239
|
};
|
|
253240
|
+
const padCenter = isPolygon ? polygonPadGeometry.center : { x: pad2.x, y: pad2.y };
|
|
252452
253241
|
return {
|
|
252453
253242
|
padstack_name: getPadstackName(padstackParams),
|
|
252454
253243
|
pin_number: sourcePort.port_hints?.find((hint) => !Number.isNaN(Number(hint))) || 1,
|
|
252455
|
-
x: (
|
|
252456
|
-
y: (
|
|
253244
|
+
x: (padCenter.x - pcbComponent.center.x) * 1000,
|
|
253245
|
+
y: (padCenter.y - pcbComponent.center.y) * 1000
|
|
252457
253246
|
};
|
|
252458
253247
|
}
|
|
252459
253248
|
function getComponentValue(sourceComponent) {
|
|
@@ -252488,8 +253277,8 @@ function processComponentsAndPads(componentGroups, circuitElements, pcb) {
|
|
|
252488
253277
|
const { pcb_component_id, pcb_smtpads } = group;
|
|
252489
253278
|
if (pcb_smtpads.length === 0)
|
|
252490
253279
|
continue;
|
|
252491
|
-
const pcbComponent =
|
|
252492
|
-
const sourceComponent =
|
|
253280
|
+
const pcbComponent = su13(circuitElements).pcb_component.list().find((e4) => e4.pcb_component_id === pcb_component_id);
|
|
253281
|
+
const sourceComponent = su13(circuitElements).source_component.list().find((e4) => e4.source_component_id === pcbComponent?.source_component_id);
|
|
252493
253282
|
const footprintName = getFootprintName(sourceComponent, pcbComponent);
|
|
252494
253283
|
const componentName = sourceComponent?.name || "Unknown";
|
|
252495
253284
|
const circuitSpaceCoordinates = applyToPoint25(transformMmToUm, pcbComponent.center);
|
|
@@ -252513,16 +253302,24 @@ function processComponentsAndPads(componentGroups, circuitElements, pcb) {
|
|
|
252513
253302
|
if (!componentGroup)
|
|
252514
253303
|
continue;
|
|
252515
253304
|
for (const pad2 of componentGroup.pcb_smtpads) {
|
|
252516
|
-
createAndAddPadstackFromPcbSmtPad(
|
|
253305
|
+
createAndAddPadstackFromPcbSmtPad({
|
|
253306
|
+
pcb,
|
|
253307
|
+
pad: pad2,
|
|
253308
|
+
processedPadstacks
|
|
253309
|
+
});
|
|
252517
253310
|
}
|
|
252518
253311
|
const image = {
|
|
252519
253312
|
name: footprintName,
|
|
252520
253313
|
outlines: [],
|
|
252521
253314
|
pins: componentGroup.pcb_smtpads.map((pad2) => {
|
|
252522
253315
|
const pcbComponent = circuitElements.find((e4) => e4.type === "pcb_component" && e4.source_component_id === firstComponent.sourceComponent?.source_component_id);
|
|
252523
|
-
const pcbPort =
|
|
252524
|
-
const sourcePort =
|
|
252525
|
-
return createPinForImage(
|
|
253316
|
+
const pcbPort = su13(circuitElements).pcb_port.list().find((e4) => e4.pcb_port_id === pad2.pcb_port_id);
|
|
253317
|
+
const sourcePort = su13(circuitElements).source_port.list().find((e4) => e4.source_port_id === pcbPort?.source_port_id);
|
|
253318
|
+
return createPinForImage({
|
|
253319
|
+
pad: pad2,
|
|
253320
|
+
pcbComponent,
|
|
253321
|
+
sourcePort
|
|
253322
|
+
});
|
|
252526
253323
|
}).filter((pin) => pin !== undefined)
|
|
252527
253324
|
};
|
|
252528
253325
|
pcb.library.images.push(image);
|
|
@@ -252550,9 +253347,9 @@ function processNets(circuitElements, pcb) {
|
|
|
252550
253347
|
const padsBySourcePortId = /* @__PURE__ */ new Map;
|
|
252551
253348
|
for (const element of circuitElements) {
|
|
252552
253349
|
if ((element.type === "pcb_smtpad" || element.type === "pcb_plated_hole") && element.pcb_port_id) {
|
|
252553
|
-
const pcbPort =
|
|
253350
|
+
const pcbPort = su24(circuitElements).pcb_port.list().find((e4) => e4.pcb_port_id === element.pcb_port_id);
|
|
252554
253351
|
if (pcbPort && "source_port_id" in pcbPort) {
|
|
252555
|
-
const sourcePort =
|
|
253352
|
+
const sourcePort = su24(circuitElements).source_port.list().find((e4) => e4.source_port_id === pcbPort.source_port_id);
|
|
252556
253353
|
if (sourcePort && "source_component_id" in sourcePort) {
|
|
252557
253354
|
const componentName = componentNameMap.get(sourcePort.source_component_id ?? "") || "";
|
|
252558
253355
|
const pinNumber = sourcePort.port_hints?.find((hint) => !Number.isNaN(Number(hint)));
|
|
@@ -252813,10 +253610,10 @@ function processPcbTraces(circuitElements, pcb, numLayers = 2) {
|
|
|
252813
253610
|
for (const element of circuitElements) {
|
|
252814
253611
|
if (element.type === "pcb_trace") {
|
|
252815
253612
|
const pcbTrace = element;
|
|
252816
|
-
const source_trace2 =
|
|
253613
|
+
const source_trace2 = su34(circuitElements).source_trace.getWhere({
|
|
252817
253614
|
source_trace_id: pcbTrace.source_trace_id
|
|
252818
253615
|
});
|
|
252819
|
-
const source_net2 = source_trace2 &&
|
|
253616
|
+
const source_net2 = source_trace2 && su34(circuitElements).source_net.list().find((n3) => source_trace2.connected_source_net_ids.includes(n3.source_net_id));
|
|
252820
253617
|
debug14(`PCB TRACE
|
|
252821
253618
|
----------
|
|
252822
253619
|
`, pcbTrace);
|
|
@@ -252994,17 +253791,17 @@ function processPlatedHoles(componentGroups, circuitElements, pcb, numLayers = 2
|
|
|
252994
253791
|
const { pcb_component_id, pcb_plated_holes, pcb_smtpads } = group;
|
|
252995
253792
|
if (pcb_plated_holes.length === 0)
|
|
252996
253793
|
continue;
|
|
252997
|
-
const pcbComponent =
|
|
253794
|
+
const pcbComponent = su43(circuitElements).pcb_component.list().find((e4) => e4.pcb_component_id === pcb_component_id);
|
|
252998
253795
|
if (!pcbComponent)
|
|
252999
253796
|
continue;
|
|
253000
|
-
const sourceComponent =
|
|
253797
|
+
const sourceComponent = su43(circuitElements).source_component.list().find((e4) => e4.source_component_id === pcbComponent.source_component_id);
|
|
253001
253798
|
const footprintName = getFootprintName(sourceComponent, pcbComponent);
|
|
253002
253799
|
const image = ensureImage(footprintName);
|
|
253003
253800
|
const nextPinNumber = createNextPinNumberGenerator(image);
|
|
253004
253801
|
for (const hole of pcb_plated_holes) {
|
|
253005
253802
|
const padstackName = ensurePadstack(hole);
|
|
253006
|
-
const pcbPort = hole.pcb_port_id ?
|
|
253007
|
-
const sourcePort = pcbPort ?
|
|
253803
|
+
const pcbPort = hole.pcb_port_id ? su43(circuitElements).pcb_port.list().find((e4) => e4.pcb_port_id === hole.pcb_port_id) : undefined;
|
|
253804
|
+
const sourcePort = pcbPort ? su43(circuitElements).source_port.list().find((e4) => e4.source_port_id === pcbPort.source_port_id) : undefined;
|
|
253008
253805
|
const pinNumber = findNumericHint(sourcePort) ?? nextPinNumber();
|
|
253009
253806
|
const pin = {
|
|
253010
253807
|
padstack_name: padstackName,
|
|
@@ -255566,14 +256363,14 @@ var convertBomRowsToCsv = (bom_rows) => {
|
|
|
255566
256363
|
// node_modules/circuit-json-to-pnp-csv/dist/index.js
|
|
255567
256364
|
var import_papaparse2 = __toESM2(require_papaparse(), 1);
|
|
255568
256365
|
import"circuit-json";
|
|
255569
|
-
import { su as
|
|
256366
|
+
import { su as su15 } from "@tscircuit/soup-util";
|
|
255570
256367
|
var fixedDecimals = 3;
|
|
255571
256368
|
var convertCircuitJsonToPickAndPlaceRows = (circuitJson, opts = {}) => {
|
|
255572
256369
|
opts.flip_y_axis ??= false;
|
|
255573
256370
|
const rows = [];
|
|
255574
256371
|
for (const element of circuitJson) {
|
|
255575
256372
|
if (element.type === "pcb_component") {
|
|
255576
|
-
const source_component =
|
|
256373
|
+
const source_component = su15(circuitJson).source_component.get(element.source_component_id);
|
|
255577
256374
|
rows.push({
|
|
255578
256375
|
designator: source_component?.name ?? element.pcb_component_id,
|
|
255579
256376
|
mid_x: element.center.x,
|
|
@@ -263660,7 +264457,7 @@ var cju8 = (circuitJsonInput, options = {}) => {
|
|
|
263660
264457
|
}
|
|
263661
264458
|
}
|
|
263662
264459
|
}
|
|
263663
|
-
const
|
|
264460
|
+
const su25 = new Proxy({}, {
|
|
263664
264461
|
get: (proxy_target, prop) => {
|
|
263665
264462
|
if (prop === "toArray") {
|
|
263666
264463
|
return () => {
|
|
@@ -263699,7 +264496,7 @@ var cju8 = (circuitJsonInput, options = {}) => {
|
|
|
263699
264496
|
}
|
|
263700
264497
|
if (prop === "insertAll") {
|
|
263701
264498
|
return (elms) => {
|
|
263702
|
-
return elms.map((elm) =>
|
|
264499
|
+
return elms.map((elm) => su25.insert(elm));
|
|
263703
264500
|
};
|
|
263704
264501
|
}
|
|
263705
264502
|
const component_type = prop;
|
|
@@ -263780,10 +264577,10 @@ var cju8 = (circuitJsonInput, options = {}) => {
|
|
|
263780
264577
|
};
|
|
263781
264578
|
}
|
|
263782
264579
|
});
|
|
263783
|
-
return
|
|
264580
|
+
return su25;
|
|
263784
264581
|
};
|
|
263785
264582
|
cju8.unparsed = cju8;
|
|
263786
|
-
var
|
|
264583
|
+
var su16 = cju8;
|
|
263787
264584
|
function createIdKey2(element) {
|
|
263788
264585
|
const type = element.type;
|
|
263789
264586
|
return `${type}:${element[`${type}_id`]}`;
|
|
@@ -264590,7 +265387,7 @@ var getBoundsCenter = (bounds) => ({
|
|
|
264590
265387
|
x: (bounds.minX + bounds.maxX) / 2,
|
|
264591
265388
|
y: (bounds.minY + bounds.maxY) / 2
|
|
264592
265389
|
});
|
|
264593
|
-
var
|
|
265390
|
+
var getBoundsFromPoints4 = (points) => {
|
|
264594
265391
|
if (points.length === 0) {
|
|
264595
265392
|
return null;
|
|
264596
265393
|
}
|
|
@@ -264656,7 +265453,7 @@ var getEasyEdaModelOriginOnBoardMm = ({
|
|
|
264656
265453
|
}
|
|
264657
265454
|
let modelOriginMm = null;
|
|
264658
265455
|
if (points.length > 0) {
|
|
264659
|
-
const bounds =
|
|
265456
|
+
const bounds = getBoundsFromPoints4(points);
|
|
264660
265457
|
modelOriginMm = bounds ? getBoundsCenter(bounds) : null;
|
|
264661
265458
|
} else {
|
|
264662
265459
|
const [originX, originY] = String(svgNode.svgData.attrs?.c_origin ?? "0,0").split(",").map((value) => Number(value.trim()));
|
|
@@ -266207,13 +267004,13 @@ var mapPortHints = (portHints2, portHintsMap) => {
|
|
|
266207
267004
|
return portHints2.flatMap((hint) => portHintsMap[hint] ?? [hint]);
|
|
266208
267005
|
};
|
|
266209
267006
|
var generateFootprintTsx2 = (circuitJson, options = {}) => {
|
|
266210
|
-
const holes =
|
|
266211
|
-
const platedHoles =
|
|
266212
|
-
const smtPads =
|
|
266213
|
-
const vias =
|
|
266214
|
-
const silkscreenPaths =
|
|
266215
|
-
const silkscreenTexts =
|
|
266216
|
-
const courtyardOutlines =
|
|
267007
|
+
const holes = su16(circuitJson).pcb_hole.list();
|
|
267008
|
+
const platedHoles = su16(circuitJson).pcb_plated_hole.list();
|
|
267009
|
+
const smtPads = su16(circuitJson).pcb_smtpad.list();
|
|
267010
|
+
const vias = su16(circuitJson).pcb_via.list();
|
|
267011
|
+
const silkscreenPaths = su16(circuitJson).pcb_silkscreen_path.list();
|
|
267012
|
+
const silkscreenTexts = su16(circuitJson).pcb_silkscreen_text.list();
|
|
267013
|
+
const courtyardOutlines = su16(circuitJson).pcb_courtyard_outline.list();
|
|
266217
267014
|
const elementStrings = [];
|
|
266218
267015
|
for (const hole of holes) {
|
|
266219
267016
|
if (hole.hole_shape === "circle") {
|
|
@@ -266458,14 +267255,14 @@ var convertBetterEasyToTsx = async ({
|
|
|
266458
267255
|
cadModelBounds: cadPlacement?.bounds,
|
|
266459
267256
|
showDesignator: true
|
|
266460
267257
|
});
|
|
266461
|
-
const [cadComponent] =
|
|
267258
|
+
const [cadComponent] = su16(circuitJson).cad_component.list();
|
|
266462
267259
|
if (cadComponent) {
|
|
266463
267260
|
cadComponent.position.x = 0;
|
|
266464
267261
|
cadComponent.position.y = 0;
|
|
266465
267262
|
}
|
|
266466
267263
|
const rawPn = betterEasy.dataStr.head.c_para["Manufacturer Part"];
|
|
266467
267264
|
const pn3 = rawPn ? normalizeManufacturerPartNumber(rawPn) : "unknown";
|
|
266468
|
-
const sourcePorts =
|
|
267265
|
+
const sourcePorts = su16(circuitJson).source_port.list();
|
|
266469
267266
|
const pinLabels = {};
|
|
266470
267267
|
const sortedPorts = sourcePorts.sort((a2, b) => {
|
|
266471
267268
|
const aNum = Number.parseInt(a2.name.replace("pin", ""));
|
|
@@ -270447,7 +271244,7 @@ var cju9 = (circuitJsonInput, options = {}) => {
|
|
|
270447
271244
|
}
|
|
270448
271245
|
}
|
|
270449
271246
|
}
|
|
270450
|
-
const
|
|
271247
|
+
const su25 = new Proxy({}, {
|
|
270451
271248
|
get: (proxy_target, prop) => {
|
|
270452
271249
|
if (prop === "toArray") {
|
|
270453
271250
|
return () => {
|
|
@@ -270486,7 +271283,7 @@ var cju9 = (circuitJsonInput, options = {}) => {
|
|
|
270486
271283
|
}
|
|
270487
271284
|
if (prop === "insertAll") {
|
|
270488
271285
|
return (elms) => {
|
|
270489
|
-
return elms.map((elm) =>
|
|
271286
|
+
return elms.map((elm) => su25.insert(elm));
|
|
270490
271287
|
};
|
|
270491
271288
|
}
|
|
270492
271289
|
const component_type = prop;
|
|
@@ -270567,7 +271364,7 @@ var cju9 = (circuitJsonInput, options = {}) => {
|
|
|
270567
271364
|
};
|
|
270568
271365
|
}
|
|
270569
271366
|
});
|
|
270570
|
-
return
|
|
271367
|
+
return su25;
|
|
270571
271368
|
};
|
|
270572
271369
|
cju9.unparsed = cju9;
|
|
270573
271370
|
function createIdKey3(element) {
|
|
@@ -271373,7 +272170,7 @@ var getBoundsCenter2 = (bounds) => ({
|
|
|
271373
272170
|
x: (bounds.minX + bounds.maxX) / 2,
|
|
271374
272171
|
y: (bounds.minY + bounds.maxY) / 2
|
|
271375
272172
|
});
|
|
271376
|
-
var
|
|
272173
|
+
var getBoundsFromPoints5 = (points) => {
|
|
271377
272174
|
if (points.length === 0) {
|
|
271378
272175
|
return null;
|
|
271379
272176
|
}
|
|
@@ -271439,7 +272236,7 @@ var getEasyEdaModelOriginOnBoardMm2 = ({
|
|
|
271439
272236
|
}
|
|
271440
272237
|
let modelOriginMm = null;
|
|
271441
272238
|
if (points.length > 0) {
|
|
271442
|
-
const bounds =
|
|
272239
|
+
const bounds = getBoundsFromPoints5(points);
|
|
271443
272240
|
modelOriginMm = bounds ? getBoundsCenter2(bounds) : null;
|
|
271444
272241
|
} else {
|
|
271445
272242
|
const [originX, originY] = String(svgNode.svgData.attrs?.c_origin ?? "0,0").split(",").map((value) => Number(value.trim()));
|
package/dist/lib/index.js
CHANGED
|
@@ -65808,7 +65808,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
65808
65808
|
}));
|
|
65809
65809
|
};
|
|
65810
65810
|
// package.json
|
|
65811
|
-
var version = "0.1.
|
|
65811
|
+
var version = "0.1.1493";
|
|
65812
65812
|
var package_default = {
|
|
65813
65813
|
name: "@tscircuit/cli",
|
|
65814
65814
|
version,
|
|
@@ -65851,7 +65851,7 @@ var package_default = {
|
|
|
65851
65851
|
"circuit-json-to-readable-netlist": "^0.0.15",
|
|
65852
65852
|
"circuit-json-to-spice": "^0.0.10",
|
|
65853
65853
|
"circuit-json-to-step": "^0.0.33",
|
|
65854
|
-
"circuit-json-to-tscircuit": "^0.0.
|
|
65854
|
+
"circuit-json-to-tscircuit": "^0.0.35",
|
|
65855
65855
|
"circuit-json-trace-length-analysis": "github:tscircuit/circuit-json-trace-length-analysis#2b44792a40df0ca83b6bfb6ac95ed5e35e7168b8",
|
|
65856
65856
|
commander: "^14.0.0",
|
|
65857
65857
|
conf: "^13.1.0",
|
|
@@ -65859,7 +65859,7 @@ var package_default = {
|
|
|
65859
65859
|
cosmiconfig: "^9.0.0",
|
|
65860
65860
|
debug: "^4.4.0",
|
|
65861
65861
|
delay: "^6.0.0",
|
|
65862
|
-
"dsn-converter": "^0.0.
|
|
65862
|
+
"dsn-converter": "^0.0.90",
|
|
65863
65863
|
easyeda: "^0.0.269",
|
|
65864
65864
|
"fuse.js": "^7.1.0",
|
|
65865
65865
|
"get-port": "^7.1.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1494",
|
|
4
4
|
"main": "dist/cli/main.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/cli/main.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"circuit-json-to-readable-netlist": "^0.0.15",
|
|
41
41
|
"circuit-json-to-spice": "^0.0.10",
|
|
42
42
|
"circuit-json-to-step": "^0.0.33",
|
|
43
|
-
"circuit-json-to-tscircuit": "^0.0.
|
|
43
|
+
"circuit-json-to-tscircuit": "^0.0.35",
|
|
44
44
|
"circuit-json-trace-length-analysis": "github:tscircuit/circuit-json-trace-length-analysis#2b44792a40df0ca83b6bfb6ac95ed5e35e7168b8",
|
|
45
45
|
"commander": "^14.0.0",
|
|
46
46
|
"conf": "^13.1.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"cosmiconfig": "^9.0.0",
|
|
49
49
|
"debug": "^4.4.0",
|
|
50
50
|
"delay": "^6.0.0",
|
|
51
|
-
"dsn-converter": "^0.0.
|
|
51
|
+
"dsn-converter": "^0.0.90",
|
|
52
52
|
"easyeda": "^0.0.269",
|
|
53
53
|
"fuse.js": "^7.1.0",
|
|
54
54
|
"get-port": "^7.1.0",
|