circuit-json-to-tscircuit 0.0.40 → 0.0.41
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/{chunk-UHPKLBYL.js → chunk-BA4FQZIF.js} +68 -44
- package/dist/cli/main.js +2 -2
- package/dist/lib/index.js +1 -1
- package/lib/generate-footprint-tsx/convert-copper-text.ts +1 -1
- package/lib/generate-footprint-tsx/convert-courtyard.ts +4 -0
- package/lib/generate-footprint-tsx/convert-cutouts.ts +1 -1
- package/lib/generate-footprint-tsx/convert-fabrication.ts +1 -1
- package/lib/generate-footprint-tsx/convert-holes.ts +1 -1
- package/lib/generate-footprint-tsx/convert-keepouts.ts +1 -1
- package/lib/generate-footprint-tsx/convert-notes.ts +1 -1
- package/lib/generate-footprint-tsx/convert-plated-holes.ts +3 -5
- package/lib/generate-footprint-tsx/convert-silkscreen-text.ts +1 -1
- package/lib/generate-footprint-tsx/convert-smt-pads.ts +1 -1
- package/lib/generate-footprint-tsx/footprint-tsx-attribute-formatters/escape-jsx-text.ts +2 -0
- package/lib/generate-footprint-tsx/footprint-tsx-attribute-formatters/format-mm.ts +3 -0
- package/lib/generate-footprint-tsx/footprint-tsx-attribute-formatters/format-optional-mm-attr.ts +9 -0
- package/lib/generate-footprint-tsx/footprint-tsx-attribute-formatters/format-pcb-rotation-attr.ts +8 -0
- package/lib/generate-footprint-tsx/footprint-tsx-attribute-formatters/format-solder-mask-attrs.ts +14 -0
- package/package.json +1 -1
- package/tests/__snapshots__/test8-support-courtyard-courtyard-pcb.snap.svg +1 -1
- package/tests/test8-support-courtyard.test.tsx +31 -10
- package/lib/generate-footprint-tsx/helpers.ts +0 -33
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
// lib/get-board-using-template.ts
|
|
2
|
-
import { mmStr as
|
|
2
|
+
import { mmStr as mmStr7 } from "@tscircuit/mm";
|
|
3
3
|
import { su as su12 } from "@tscircuit/soup-util";
|
|
4
4
|
|
|
5
5
|
// lib/generate-footprint-tsx/convert-copper-text.ts
|
|
6
6
|
import { su } from "@tscircuit/soup-util";
|
|
7
7
|
|
|
8
|
-
// lib/generate-footprint-tsx/
|
|
9
|
-
import { mmStr } from "@tscircuit/mm";
|
|
8
|
+
// lib/generate-footprint-tsx/footprint-tsx-attribute-formatters/escape-jsx-text.ts
|
|
10
9
|
var escapeJsxText = (value) => String(value ?? "").replace(/"/g, '\\"');
|
|
11
|
-
var formatMm = (value) => mmStr(value ?? 0);
|
|
12
|
-
var formatOptionalMmAttr = (attrName, value) => {
|
|
13
|
-
if (value === void 0) return "";
|
|
14
|
-
return ` ${attrName}="${mmStr(value)}"`;
|
|
15
|
-
};
|
|
16
|
-
var formatSolderMaskAttrs = (platedHole) => `${platedHole.is_covered_with_solder_mask === void 0 ? "" : ` coveredWithSolderMask={${platedHole.is_covered_with_solder_mask}}`}${formatOptionalMmAttr("solderMaskMargin", platedHole.soldermask_margin)}`;
|
|
17
|
-
var formatPcbRotationAttr = (rotation, attrName = "pcbRotation") => {
|
|
18
|
-
if (rotation === void 0) return "";
|
|
19
|
-
const formatted = typeof rotation === "number" ? `${rotation}deg` : rotation;
|
|
20
|
-
return ` ${attrName}="${formatted}"`;
|
|
21
|
-
};
|
|
22
10
|
|
|
23
11
|
// lib/generate-footprint-tsx/convert-copper-text.ts
|
|
24
12
|
var convertCopperText = (circuitJson) => {
|
|
@@ -57,6 +45,15 @@ var convertCopperText = (circuitJson) => {
|
|
|
57
45
|
|
|
58
46
|
// lib/generate-footprint-tsx/convert-courtyard.ts
|
|
59
47
|
import { su as su2 } from "@tscircuit/soup-util";
|
|
48
|
+
|
|
49
|
+
// lib/generate-footprint-tsx/footprint-tsx-attribute-formatters/format-pcb-rotation-attr.ts
|
|
50
|
+
var formatPcbRotationAttr = (rotation, attrName = "pcbRotation") => {
|
|
51
|
+
if (rotation === void 0) return "";
|
|
52
|
+
const formatted = typeof rotation === "number" ? `${rotation}deg` : rotation;
|
|
53
|
+
return ` ${attrName}="${formatted}"`;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// lib/generate-footprint-tsx/convert-courtyard.ts
|
|
60
57
|
var convertCourtyard = (circuitJson) => {
|
|
61
58
|
const courtyardOutlines = su2(circuitJson).pcb_courtyard_outline.list();
|
|
62
59
|
const courtyardRects = su2(circuitJson).pcb_courtyard_rect.list();
|
|
@@ -81,6 +78,9 @@ var convertCourtyard = (circuitJson) => {
|
|
|
81
78
|
if (courtyardRect.layer !== void 0) {
|
|
82
79
|
attrs.push(`layer="${courtyardRect.layer}"`);
|
|
83
80
|
}
|
|
81
|
+
if (courtyardRect.ccw_rotation !== void 0) {
|
|
82
|
+
attrs.push(formatPcbRotationAttr(courtyardRect.ccw_rotation).trimStart());
|
|
83
|
+
}
|
|
84
84
|
elementStrings.push(`<courtyardrect ${attrs.join(" ")} />`);
|
|
85
85
|
}
|
|
86
86
|
for (const courtyardCircle of courtyardCircles) {
|
|
@@ -99,6 +99,12 @@ var convertCourtyard = (circuitJson) => {
|
|
|
99
99
|
|
|
100
100
|
// lib/generate-footprint-tsx/convert-cutouts.ts
|
|
101
101
|
import { su as su3 } from "@tscircuit/soup-util";
|
|
102
|
+
|
|
103
|
+
// lib/generate-footprint-tsx/footprint-tsx-attribute-formatters/format-mm.ts
|
|
104
|
+
import { mmStr } from "@tscircuit/mm";
|
|
105
|
+
var formatMm = (value) => mmStr(value ?? 0);
|
|
106
|
+
|
|
107
|
+
// lib/generate-footprint-tsx/convert-cutouts.ts
|
|
102
108
|
var convertCutouts = (circuitJson) => {
|
|
103
109
|
const pcbCutouts = su3(circuitJson).pcb_cutout.list();
|
|
104
110
|
const elementStrings = [];
|
|
@@ -379,33 +385,51 @@ var convertNotes = (circuitJson) => {
|
|
|
379
385
|
|
|
380
386
|
// lib/generate-footprint-tsx/convert-plated-holes.ts
|
|
381
387
|
import { su as su8 } from "@tscircuit/soup-util";
|
|
388
|
+
import { mmStr as mmStr4 } from "@tscircuit/mm";
|
|
389
|
+
|
|
390
|
+
// lib/generate-footprint-tsx/footprint-tsx-attribute-formatters/format-optional-mm-attr.ts
|
|
382
391
|
import { mmStr as mmStr3 } from "@tscircuit/mm";
|
|
392
|
+
var formatOptionalMmAttr = (attrName, value) => {
|
|
393
|
+
if (value === void 0) return "";
|
|
394
|
+
return ` ${attrName}="${mmStr3(value)}"`;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
// lib/generate-footprint-tsx/footprint-tsx-attribute-formatters/format-solder-mask-attrs.ts
|
|
398
|
+
var formatSolderMaskAttrs = (platedHole) => {
|
|
399
|
+
let coveredWithSolderMaskAttr = "";
|
|
400
|
+
if (platedHole.is_covered_with_solder_mask !== void 0) {
|
|
401
|
+
coveredWithSolderMaskAttr = ` coveredWithSolderMask={${platedHole.is_covered_with_solder_mask}}`;
|
|
402
|
+
}
|
|
403
|
+
return `${coveredWithSolderMaskAttr}${formatOptionalMmAttr("solderMaskMargin", platedHole.soldermask_margin)}`;
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
// lib/generate-footprint-tsx/convert-plated-holes.ts
|
|
383
407
|
var convertPlatedHoles = (circuitJson) => {
|
|
384
408
|
const platedHoles = su8(circuitJson).pcb_plated_hole.list();
|
|
385
409
|
const elementStrings = [];
|
|
386
410
|
for (const platedHole of platedHoles) {
|
|
387
411
|
if (platedHole.shape === "oval" || platedHole.shape === "pill") {
|
|
388
412
|
elementStrings.push(
|
|
389
|
-
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${
|
|
413
|
+
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr4(platedHole.x)}" pcbY="${mmStr4(platedHole.y)}"${formatSolderMaskAttrs(platedHole)} outerHeight="${mmStr4(platedHole.outer_height)}" outerWidth="${mmStr4(platedHole.outer_width)}" holeHeight="${mmStr4(platedHole.hole_height)}" holeWidth="${mmStr4(platedHole.hole_width)}" height="${mmStr4(platedHole.hole_height)}" shape="${platedHole.shape}"${formatPcbRotationAttr("ccw_rotation" in platedHole ? platedHole.ccw_rotation : void 0)} />`
|
|
390
414
|
);
|
|
391
415
|
} else if (platedHole.shape === "circle") {
|
|
392
416
|
elementStrings.push(
|
|
393
|
-
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${
|
|
417
|
+
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr4(platedHole.x)}" pcbY="${mmStr4(platedHole.y)}"${formatSolderMaskAttrs(platedHole)} outerDiameter="${mmStr4(platedHole.outer_diameter)}" holeDiameter="${mmStr4(platedHole.hole_diameter)}" shape="circle" />`
|
|
394
418
|
);
|
|
395
419
|
} else if (platedHole.shape === "circular_hole_with_rect_pad") {
|
|
396
420
|
elementStrings.push(
|
|
397
|
-
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${
|
|
421
|
+
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr4(platedHole.x)}" pcbY="${mmStr4(platedHole.y)}"${platedHole.hole_shape === void 0 ? "" : ` holeShape="${platedHole.hole_shape}"`}${platedHole.pad_shape === void 0 ? "" : ` padShape="${platedHole.pad_shape}"`}${formatSolderMaskAttrs(platedHole)} holeDiameter="${mmStr4(platedHole.hole_diameter)}" rectPadWidth="${mmStr4(platedHole.rect_pad_width)}" rectPadHeight="${mmStr4(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" />`
|
|
398
422
|
);
|
|
399
423
|
} else if (platedHole.shape === "pill_hole_with_rect_pad" || platedHole.shape === "rotated_pill_hole_with_rect_pad") {
|
|
400
424
|
const holeShape = platedHole.shape === "rotated_pill_hole_with_rect_pad" ? "pill" : platedHole.hole_shape;
|
|
401
425
|
const rotation = platedHole.shape === "rotated_pill_hole_with_rect_pad" ? platedHole.hole_ccw_rotation : void 0;
|
|
402
426
|
elementStrings.push(
|
|
403
|
-
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${
|
|
427
|
+
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr4(platedHole.x)}" pcbY="${mmStr4(platedHole.y)}"${holeShape === void 0 ? "" : ` holeShape="${holeShape}"`}${platedHole.pad_shape === void 0 ? "" : ` padShape="${platedHole.pad_shape}"`}${formatSolderMaskAttrs(platedHole)} holeWidth="${mmStr4(platedHole.hole_width)}" holeHeight="${mmStr4(platedHole.hole_height)}" rectPadWidth="${mmStr4(platedHole.rect_pad_width)}" rectPadHeight="${mmStr4(platedHole.rect_pad_height)}"${formatOptionalMmAttr("rectBorderRadius", platedHole.rect_border_radius)}${formatOptionalMmAttr("holeOffsetX", platedHole.hole_offset_x)}${formatOptionalMmAttr("holeOffsetY", platedHole.hole_offset_y)}${formatPcbRotationAttr(rotation)} shape="pill_hole_with_rect_pad" />`
|
|
404
428
|
);
|
|
405
429
|
} else if (platedHole.shape === "hole_with_polygon_pad") {
|
|
406
|
-
const holeSizeAttrs = platedHole.hole_shape === "circle" ? ` holeDiameter="${
|
|
430
|
+
const holeSizeAttrs = platedHole.hole_shape === "circle" ? ` holeDiameter="${mmStr4(platedHole.hole_diameter ?? 0)}"` : `${formatOptionalMmAttr("holeWidth", platedHole.hole_width)}${formatOptionalMmAttr("holeHeight", platedHole.hole_height)}`;
|
|
407
431
|
elementStrings.push(
|
|
408
|
-
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${
|
|
432
|
+
`<platedhole portHints={${JSON.stringify(platedHole.port_hints)}} pcbX="${mmStr4(platedHole.x)}" pcbY="${mmStr4(platedHole.y)}"${platedHole.hole_shape === void 0 ? "" : ` holeShape="${platedHole.hole_shape}"`}${formatSolderMaskAttrs(platedHole)}${holeSizeAttrs} padOutline={${JSON.stringify(platedHole.pad_outline)}} holeOffsetX="${mmStr4(platedHole.hole_offset_x ?? 0)}" holeOffsetY="${mmStr4(platedHole.hole_offset_y ?? 0)}" shape="hole_with_polygon_pad" />`
|
|
409
433
|
);
|
|
410
434
|
}
|
|
411
435
|
}
|
|
@@ -481,7 +505,7 @@ var convertSilkscreen = (circuitJson) => {
|
|
|
481
505
|
|
|
482
506
|
// lib/generate-footprint-tsx/convert-silkscreen-text.ts
|
|
483
507
|
import { su as su10 } from "@tscircuit/soup-util";
|
|
484
|
-
import { mmStr as
|
|
508
|
+
import { mmStr as mmStr5 } from "@tscircuit/mm";
|
|
485
509
|
var convertSilkscreenText = (circuitJson) => {
|
|
486
510
|
const silkscreenTexts = su10(circuitJson).pcb_silkscreen_text.list();
|
|
487
511
|
const elementStrings = [];
|
|
@@ -491,7 +515,7 @@ var convertSilkscreenText = (circuitJson) => {
|
|
|
491
515
|
const knockoutPadding = silkscreenText.knockout_padding;
|
|
492
516
|
const hasUniformKnockoutPadding = knockoutPadding && knockoutPadding.left === knockoutPadding.top && knockoutPadding.top === knockoutPadding.right && knockoutPadding.right === knockoutPadding.bottom;
|
|
493
517
|
elementStrings.push(
|
|
494
|
-
`<silkscreentext pcbX={${pcbX}} pcbY={${pcbY}} anchorAlignment="${silkscreenText.anchor_alignment}" fontSize={${silkscreenText.font_size}}${silkscreenText.font !== void 0 ? ` font="${silkscreenText.font}"` : ""}${silkscreenText.ccw_rotation !== void 0 ? ` pcbRotation="${typeof silkscreenText.ccw_rotation === "number" ? `${silkscreenText.ccw_rotation}deg` : silkscreenText.ccw_rotation}"` : ""}${silkscreenText.is_knockout !== void 0 ? ` isKnockout={${silkscreenText.is_knockout}}` : ""}${knockoutPadding ? hasUniformKnockoutPadding ? ` knockoutPadding="${
|
|
518
|
+
`<silkscreentext pcbX={${pcbX}} pcbY={${pcbY}} anchorAlignment="${silkscreenText.anchor_alignment}" fontSize={${silkscreenText.font_size}}${silkscreenText.font !== void 0 ? ` font="${silkscreenText.font}"` : ""}${silkscreenText.ccw_rotation !== void 0 ? ` pcbRotation="${typeof silkscreenText.ccw_rotation === "number" ? `${silkscreenText.ccw_rotation}deg` : silkscreenText.ccw_rotation}"` : ""}${silkscreenText.is_knockout !== void 0 ? ` isKnockout={${silkscreenText.is_knockout}}` : ""}${knockoutPadding ? hasUniformKnockoutPadding ? ` knockoutPadding="${mmStr5(knockoutPadding.left)}"` : ` knockoutPaddingLeft="${mmStr5(knockoutPadding.left)}" knockoutPaddingTop="${mmStr5(knockoutPadding.top)}" knockoutPaddingRight="${mmStr5(knockoutPadding.right)}" knockoutPaddingBottom="${mmStr5(knockoutPadding.bottom)}"` : ""}${silkscreenText.is_mirrored !== void 0 ? ` mirrored={${silkscreenText.is_mirrored}}` : ""}${silkscreenText.layer !== void 0 ? ` layer="${silkscreenText.layer}"` : ""} text="${escapeJsxText(silkscreenText.text)}" />`
|
|
495
519
|
);
|
|
496
520
|
}
|
|
497
521
|
return elementStrings;
|
|
@@ -499,7 +523,7 @@ var convertSilkscreenText = (circuitJson) => {
|
|
|
499
523
|
|
|
500
524
|
// lib/generate-footprint-tsx/convert-smt-pads.ts
|
|
501
525
|
import { su as su11 } from "@tscircuit/soup-util";
|
|
502
|
-
import { mmStr as
|
|
526
|
+
import { mmStr as mmStr6 } from "@tscircuit/mm";
|
|
503
527
|
var convertSmtPads = (circuitJson) => {
|
|
504
528
|
const smtPads = su11(circuitJson).pcb_smtpad.list();
|
|
505
529
|
const elementStrings = [];
|
|
@@ -509,10 +533,10 @@ var convertSmtPads = (circuitJson) => {
|
|
|
509
533
|
commonAttrs.push(`portHints={${JSON.stringify(smtPad.port_hints)}}`);
|
|
510
534
|
}
|
|
511
535
|
if ("x" in smtPad && smtPad.x !== void 0) {
|
|
512
|
-
commonAttrs.push(`pcbX="${
|
|
536
|
+
commonAttrs.push(`pcbX="${mmStr6(smtPad.x)}"`);
|
|
513
537
|
}
|
|
514
538
|
if ("y" in smtPad && smtPad.y !== void 0) {
|
|
515
|
-
commonAttrs.push(`pcbY="${
|
|
539
|
+
commonAttrs.push(`pcbY="${mmStr6(smtPad.y)}"`);
|
|
516
540
|
}
|
|
517
541
|
if (smtPad.layer !== void 0) {
|
|
518
542
|
commonAttrs.push(`layer="${smtPad.layer}"`);
|
|
@@ -523,47 +547,47 @@ var convertSmtPads = (circuitJson) => {
|
|
|
523
547
|
);
|
|
524
548
|
}
|
|
525
549
|
if (smtPad.soldermask_margin !== void 0) {
|
|
526
|
-
commonAttrs.push(`solderMaskMargin="${
|
|
550
|
+
commonAttrs.push(`solderMaskMargin="${mmStr6(smtPad.soldermask_margin)}"`);
|
|
527
551
|
}
|
|
528
552
|
if (smtPad.shape === "circle") {
|
|
529
553
|
elementStrings.push(
|
|
530
|
-
`<smtpad ${commonAttrs.join(" ")} radius="${
|
|
554
|
+
`<smtpad ${commonAttrs.join(" ")} radius="${mmStr6(smtPad.radius ?? 0)}" shape="circle" />`
|
|
531
555
|
);
|
|
532
556
|
} else if (smtPad.shape === "rect") {
|
|
533
557
|
if (smtPad.rect_border_radius !== void 0) {
|
|
534
558
|
commonAttrs.push(
|
|
535
|
-
`rectBorderRadius="${
|
|
559
|
+
`rectBorderRadius="${mmStr6(smtPad.rect_border_radius)}"`
|
|
536
560
|
);
|
|
537
561
|
}
|
|
538
562
|
if (smtPad.corner_radius !== void 0) {
|
|
539
|
-
commonAttrs.push(`cornerRadius="${
|
|
563
|
+
commonAttrs.push(`cornerRadius="${mmStr6(smtPad.corner_radius)}"`);
|
|
540
564
|
}
|
|
541
565
|
if (smtPad.soldermask_margin_left !== void 0) {
|
|
542
566
|
commonAttrs.push(
|
|
543
|
-
`solderMaskMarginLeft="${
|
|
567
|
+
`solderMaskMarginLeft="${mmStr6(smtPad.soldermask_margin_left)}"`
|
|
544
568
|
);
|
|
545
569
|
}
|
|
546
570
|
if (smtPad.soldermask_margin_top !== void 0) {
|
|
547
571
|
commonAttrs.push(
|
|
548
|
-
`solderMaskMarginTop="${
|
|
572
|
+
`solderMaskMarginTop="${mmStr6(smtPad.soldermask_margin_top)}"`
|
|
549
573
|
);
|
|
550
574
|
}
|
|
551
575
|
if (smtPad.soldermask_margin_right !== void 0) {
|
|
552
576
|
commonAttrs.push(
|
|
553
|
-
`solderMaskMarginRight="${
|
|
577
|
+
`solderMaskMarginRight="${mmStr6(smtPad.soldermask_margin_right)}"`
|
|
554
578
|
);
|
|
555
579
|
}
|
|
556
580
|
if (smtPad.soldermask_margin_bottom !== void 0) {
|
|
557
581
|
commonAttrs.push(
|
|
558
|
-
`solderMaskMarginBottom="${
|
|
582
|
+
`solderMaskMarginBottom="${mmStr6(smtPad.soldermask_margin_bottom)}"`
|
|
559
583
|
);
|
|
560
584
|
}
|
|
561
585
|
elementStrings.push(
|
|
562
|
-
`<smtpad ${commonAttrs.join(" ")} width="${
|
|
586
|
+
`<smtpad ${commonAttrs.join(" ")} width="${mmStr6(smtPad.width ?? 0)}" height="${mmStr6(smtPad.height ?? 0)}" shape="rect" />`
|
|
563
587
|
);
|
|
564
588
|
} else if (smtPad.shape === "pill") {
|
|
565
589
|
elementStrings.push(
|
|
566
|
-
`<smtpad ${commonAttrs.join(" ")} width="${
|
|
590
|
+
`<smtpad ${commonAttrs.join(" ")} width="${mmStr6(smtPad.width ?? 0)}" height="${mmStr6(smtPad.height ?? 0)}" radius="${mmStr6(smtPad.radius ?? 0)}" shape="pill" />`
|
|
567
591
|
);
|
|
568
592
|
} else if (smtPad.shape === "polygon") {
|
|
569
593
|
elementStrings.push(
|
|
@@ -572,30 +596,30 @@ var convertSmtPads = (circuitJson) => {
|
|
|
572
596
|
} else if (smtPad.shape === "rotated_rect") {
|
|
573
597
|
const cornerRadius = smtPad.corner_radius ?? smtPad.rect_border_radius ?? void 0;
|
|
574
598
|
if (cornerRadius !== void 0) {
|
|
575
|
-
commonAttrs.push(`cornerRadius="${
|
|
599
|
+
commonAttrs.push(`cornerRadius="${mmStr6(cornerRadius)}"`);
|
|
576
600
|
}
|
|
577
601
|
if (smtPad.soldermask_margin_left !== void 0) {
|
|
578
602
|
commonAttrs.push(
|
|
579
|
-
`solderMaskMarginLeft="${
|
|
603
|
+
`solderMaskMarginLeft="${mmStr6(smtPad.soldermask_margin_left)}"`
|
|
580
604
|
);
|
|
581
605
|
}
|
|
582
606
|
if (smtPad.soldermask_margin_top !== void 0) {
|
|
583
607
|
commonAttrs.push(
|
|
584
|
-
`solderMaskMarginTop="${
|
|
608
|
+
`solderMaskMarginTop="${mmStr6(smtPad.soldermask_margin_top)}"`
|
|
585
609
|
);
|
|
586
610
|
}
|
|
587
611
|
if (smtPad.soldermask_margin_right !== void 0) {
|
|
588
612
|
commonAttrs.push(
|
|
589
|
-
`solderMaskMarginRight="${
|
|
613
|
+
`solderMaskMarginRight="${mmStr6(smtPad.soldermask_margin_right)}"`
|
|
590
614
|
);
|
|
591
615
|
}
|
|
592
616
|
if (smtPad.soldermask_margin_bottom !== void 0) {
|
|
593
617
|
commonAttrs.push(
|
|
594
|
-
`solderMaskMarginBottom="${
|
|
618
|
+
`solderMaskMarginBottom="${mmStr6(smtPad.soldermask_margin_bottom)}"`
|
|
595
619
|
);
|
|
596
620
|
}
|
|
597
621
|
elementStrings.push(
|
|
598
|
-
`<smtpad ${commonAttrs.join(" ")} width="${
|
|
622
|
+
`<smtpad ${commonAttrs.join(" ")} width="${mmStr6(smtPad.width ?? 0)}" height="${mmStr6(smtPad.height ?? 0)}"${formatPcbRotationAttr(smtPad.ccw_rotation)} shape="rotated_rect" />`
|
|
599
623
|
);
|
|
600
624
|
}
|
|
601
625
|
}
|
|
@@ -634,17 +658,17 @@ var getBoardUsingTemplate = ({ circuitJson }) => {
|
|
|
634
658
|
const boardProps = [];
|
|
635
659
|
if (pcbBoard) {
|
|
636
660
|
if (pcbBoard.width !== void 0) {
|
|
637
|
-
boardProps.push(`width="${
|
|
661
|
+
boardProps.push(`width="${mmStr7(pcbBoard.width)}"`);
|
|
638
662
|
}
|
|
639
663
|
if (pcbBoard.height !== void 0) {
|
|
640
|
-
boardProps.push(`height="${
|
|
664
|
+
boardProps.push(`height="${mmStr7(pcbBoard.height)}"`);
|
|
641
665
|
}
|
|
642
666
|
if (pcbBoard.outline && pcbBoard.outline.length > 0) {
|
|
643
667
|
const points = pcbBoard.outline.map((p) => `{ x: ${p.x}, y: ${p.y} }`).join(", ");
|
|
644
668
|
boardProps.push(`outline={[${points}]}`);
|
|
645
669
|
}
|
|
646
670
|
if (pcbBoard.thickness !== void 0) {
|
|
647
|
-
boardProps.push(`thickness="${
|
|
671
|
+
boardProps.push(`thickness="${mmStr7(pcbBoard.thickness)}"`);
|
|
648
672
|
}
|
|
649
673
|
if (pcbBoard.num_layers !== void 0) {
|
|
650
674
|
boardProps.push(`layers={${pcbBoard.num_layers}}`);
|
package/dist/cli/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
convertCircuitJsonToTscircuit
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-BA4FQZIF.js";
|
|
5
5
|
|
|
6
6
|
// cli/main.ts
|
|
7
7
|
import { Command } from "commander";
|
|
@@ -16,7 +16,7 @@ var package_default = {
|
|
|
16
16
|
"./cli": "./dist/cli/main.js"
|
|
17
17
|
},
|
|
18
18
|
type: "module",
|
|
19
|
-
version: "0.0.
|
|
19
|
+
version: "0.0.40",
|
|
20
20
|
scripts: {
|
|
21
21
|
build: "tsup-node lib/index.ts cli/main.ts --format esm --dts",
|
|
22
22
|
test: "bun test",
|
package/dist/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { su } from "@tscircuit/soup-util"
|
|
2
2
|
import type { FootprintElementConverter } from "./converter-types"
|
|
3
|
-
import { escapeJsxText } from "./
|
|
3
|
+
import { escapeJsxText } from "./footprint-tsx-attribute-formatters/escape-jsx-text"
|
|
4
4
|
|
|
5
5
|
export const convertCopperText: FootprintElementConverter = (circuitJson) => {
|
|
6
6
|
const copperTexts = su(circuitJson).pcb_copper_text.list()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { su } from "@tscircuit/soup-util"
|
|
2
2
|
import type { FootprintElementConverter } from "./converter-types"
|
|
3
|
+
import { formatPcbRotationAttr } from "./footprint-tsx-attribute-formatters/format-pcb-rotation-attr"
|
|
3
4
|
|
|
4
5
|
export const convertCourtyard: FootprintElementConverter = (circuitJson) => {
|
|
5
6
|
const courtyardOutlines = su(circuitJson).pcb_courtyard_outline.list()
|
|
@@ -28,6 +29,9 @@ export const convertCourtyard: FootprintElementConverter = (circuitJson) => {
|
|
|
28
29
|
if (courtyardRect.layer !== undefined) {
|
|
29
30
|
attrs.push(`layer="${courtyardRect.layer}"`)
|
|
30
31
|
}
|
|
32
|
+
if (courtyardRect.ccw_rotation !== undefined) {
|
|
33
|
+
attrs.push(formatPcbRotationAttr(courtyardRect.ccw_rotation).trimStart())
|
|
34
|
+
}
|
|
31
35
|
|
|
32
36
|
elementStrings.push(`<courtyardrect ${attrs.join(" ")} />`)
|
|
33
37
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { su } from "@tscircuit/soup-util"
|
|
2
2
|
import type { FootprintElementConverter } from "./converter-types"
|
|
3
|
-
import { formatMm } from "./
|
|
3
|
+
import { formatMm } from "./footprint-tsx-attribute-formatters/format-mm"
|
|
4
4
|
|
|
5
5
|
export const convertCutouts: FootprintElementConverter = (circuitJson) => {
|
|
6
6
|
const pcbCutouts = su(circuitJson).pcb_cutout.list()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { su } from "@tscircuit/soup-util"
|
|
2
2
|
import type { FootprintElementConverter } from "./converter-types"
|
|
3
|
-
import { escapeJsxText } from "./
|
|
3
|
+
import { escapeJsxText } from "./footprint-tsx-attribute-formatters/escape-jsx-text"
|
|
4
4
|
|
|
5
5
|
export const convertFabrication: FootprintElementConverter = (circuitJson) => {
|
|
6
6
|
const fabricationNotePaths = su(circuitJson).pcb_fabrication_note_path.list()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { su } from "@tscircuit/soup-util"
|
|
2
2
|
import { mmStr } from "@tscircuit/mm"
|
|
3
3
|
import type { FootprintElementConverter } from "./converter-types"
|
|
4
|
-
import { formatPcbRotationAttr } from "./
|
|
4
|
+
import { formatPcbRotationAttr } from "./footprint-tsx-attribute-formatters/format-pcb-rotation-attr"
|
|
5
5
|
|
|
6
6
|
export const convertHoles: FootprintElementConverter = (circuitJson) => {
|
|
7
7
|
const holes = su(circuitJson).pcb_hole.list()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { su } from "@tscircuit/soup-util"
|
|
2
2
|
import type { FootprintElementConverter } from "./converter-types"
|
|
3
|
-
import { formatMm } from "./
|
|
3
|
+
import { formatMm } from "./footprint-tsx-attribute-formatters/format-mm"
|
|
4
4
|
|
|
5
5
|
export const convertKeepouts: FootprintElementConverter = (circuitJson) => {
|
|
6
6
|
const pcbKeepouts = su(circuitJson).pcb_keepout.list()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { su } from "@tscircuit/soup-util"
|
|
2
2
|
import type { FootprintElementConverter } from "./converter-types"
|
|
3
|
-
import { escapeJsxText } from "./
|
|
3
|
+
import { escapeJsxText } from "./footprint-tsx-attribute-formatters/escape-jsx-text"
|
|
4
4
|
|
|
5
5
|
export const convertNotes: FootprintElementConverter = (circuitJson) => {
|
|
6
6
|
const noteTexts = su(circuitJson).pcb_note_text.list()
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { su } from "@tscircuit/soup-util"
|
|
2
2
|
import { mmStr } from "@tscircuit/mm"
|
|
3
3
|
import type { FootprintElementConverter } from "./converter-types"
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
formatSolderMaskAttrs,
|
|
8
|
-
} from "./helpers"
|
|
4
|
+
import { formatOptionalMmAttr } from "./footprint-tsx-attribute-formatters/format-optional-mm-attr"
|
|
5
|
+
import { formatPcbRotationAttr } from "./footprint-tsx-attribute-formatters/format-pcb-rotation-attr"
|
|
6
|
+
import { formatSolderMaskAttrs } from "./footprint-tsx-attribute-formatters/format-solder-mask-attrs"
|
|
9
7
|
|
|
10
8
|
export const convertPlatedHoles: FootprintElementConverter = (circuitJson) => {
|
|
11
9
|
const platedHoles = su(circuitJson).pcb_plated_hole.list()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { su } from "@tscircuit/soup-util"
|
|
2
2
|
import { mmStr } from "@tscircuit/mm"
|
|
3
3
|
import type { FootprintElementConverter } from "./converter-types"
|
|
4
|
-
import { escapeJsxText } from "./
|
|
4
|
+
import { escapeJsxText } from "./footprint-tsx-attribute-formatters/escape-jsx-text"
|
|
5
5
|
|
|
6
6
|
export const convertSilkscreenText: FootprintElementConverter = (
|
|
7
7
|
circuitJson,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { su } from "@tscircuit/soup-util"
|
|
2
2
|
import { mmStr } from "@tscircuit/mm"
|
|
3
3
|
import type { FootprintElementConverter } from "./converter-types"
|
|
4
|
-
import { formatPcbRotationAttr } from "./
|
|
4
|
+
import { formatPcbRotationAttr } from "./footprint-tsx-attribute-formatters/format-pcb-rotation-attr"
|
|
5
5
|
|
|
6
6
|
export const convertSmtPads: FootprintElementConverter = (circuitJson) => {
|
|
7
7
|
const smtPads = su(circuitJson).pcb_smtpad.list()
|
package/lib/generate-footprint-tsx/footprint-tsx-attribute-formatters/format-pcb-rotation-attr.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const formatPcbRotationAttr = (
|
|
2
|
+
rotation: string | number | undefined,
|
|
3
|
+
attrName = "pcbRotation",
|
|
4
|
+
): string => {
|
|
5
|
+
if (rotation === undefined) return ""
|
|
6
|
+
const formatted = typeof rotation === "number" ? `${rotation}deg` : rotation
|
|
7
|
+
return ` ${attrName}="${formatted}"`
|
|
8
|
+
}
|
package/lib/generate-footprint-tsx/footprint-tsx-attribute-formatters/format-solder-mask-attrs.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { formatOptionalMmAttr } from "./format-optional-mm-attr"
|
|
2
|
+
|
|
3
|
+
export const formatSolderMaskAttrs = (platedHole: {
|
|
4
|
+
is_covered_with_solder_mask?: boolean
|
|
5
|
+
soldermask_margin?: number
|
|
6
|
+
}): string => {
|
|
7
|
+
let coveredWithSolderMaskAttr = ""
|
|
8
|
+
|
|
9
|
+
if (platedHole.is_covered_with_solder_mask !== undefined) {
|
|
10
|
+
coveredWithSolderMaskAttr = ` coveredWithSolderMask={${platedHole.is_covered_with_solder_mask}}`
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return `${coveredWithSolderMaskAttr}${formatOptionalMmAttr("solderMaskMargin", platedHole.soldermask_margin)}`
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="600" data-software-used-string="@tscircuit/core@0.0.
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="600" data-software-used-string="@tscircuit/core@0.0.1322"><style></style><rect class="boundary" x="0" y="0" fill="#000" width="800" height="600" data-type="pcb_background" data-pcb-layer="global"/><rect class="pcb-boundary" fill="none" stroke="#fff" stroke-width="0.3" x="127.27272727272725" y="27.272727272727252" width="545.4545454545455" height="545.4545454545455" data-type="pcb_boundary" data-pcb-layer="global"/><path class="pcb-board" d="M 127.27272727272725 572.7272727272727 L 672.7272727272727 572.7272727272727 L 672.7272727272727 27.272727272727252 L 127.27272727272725 27.272727272727252 Z" fill="none" stroke="rgba(255, 255, 255, 0.5)" stroke-width="2.7272727272727275" data-type="pcb_board" data-pcb-layer="board"/><rect x="506.3636363636364" y="245.45454545454547" width="125.45454545454545" height="98.18181818181819" class="pcb-courtyard-rect pcb-courtyard-bottom" data-pcb-courtyard-rect-id="pcb_courtyard_rect_1" data-type="pcb_courtyard_rect" data-pcb-layer="bottom" stroke-linejoin="round" fill="none" stroke="rgb(38, 233, 255)" stroke-width="1.3636363636363638"/><rect x="506.3636363636364" y="245.45454545454547" width="125.45454545454545" height="98.18181818181819" class="pcb-courtyard-rect pcb-courtyard-bottom" data-pcb-courtyard-rect-id="pcb_courtyard_rect_3" data-type="pcb_courtyard_rect" data-pcb-layer="bottom" stroke-linejoin="round" fill="none" stroke="rgb(38, 233, 255)" stroke-width="1.3636363636363638"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="378.1818181818182" y="287.72727272727275" width="16.363636363636363" height="24.545454545454547" data-type="pcb_smtpad" data-pcb-layer="top"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="378.1818181818182" y="287.72727272727275" width="16.363636363636363" height="24.545454545454547" data-type="pcb_smtpad" data-pcb-layer="top"/><polygon points="187.27272727272728,338.1818181818182 285.45454545454544,338.1818181818182 285.45454545454544,261.8181818181818 187.27272727272728,261.8181818181818" class="pcb-courtyard-outline pcb-courtyard-top" data-pcb-courtyard-outline-id="pcb_courtyard_outline_0" data-type="pcb_courtyard_outline" data-pcb-layer="top" fill="none" stroke="#FF00FF" stroke-width="1.3636363636363638" stroke-linejoin="round"/><rect x="-54.54545454545455" y="-40.90909090909091" width="109.0909090909091" height="81.81818181818181" class="pcb-courtyard-rect pcb-courtyard-top" data-pcb-courtyard-rect-id="pcb_courtyard_rect_0" data-type="pcb_courtyard_rect" data-pcb-layer="top" stroke-linejoin="round" transform="translate(400 300) rotate(-45)" fill="none" stroke="#FF00FF" stroke-width="1.3636363636363638"/><circle cx="410.90909090909093" cy="152.72727272727272" r="57.27272727272727" class="pcb-courtyard-circle pcb-courtyard-top" data-pcb-courtyard-circle-id="pcb_courtyard_circle_0" data-type="pcb_courtyard_circle" data-pcb-layer="top" fill="none" stroke="#FF00FF" stroke-width="1.3636363636363638"/><polygon points="187.27272727272728,338.1818181818182 285.45454545454544,338.1818181818182 285.45454545454544,261.8181818181818 187.27272727272728,261.8181818181818" class="pcb-courtyard-outline pcb-courtyard-top" data-pcb-courtyard-outline-id="pcb_courtyard_outline_1" data-type="pcb_courtyard_outline" data-pcb-layer="top" fill="none" stroke="#FF00FF" stroke-width="1.3636363636363638" stroke-linejoin="round"/><rect x="-54.54545454545455" y="-40.90909090909091" width="109.0909090909091" height="81.81818181818181" class="pcb-courtyard-rect pcb-courtyard-top" data-pcb-courtyard-rect-id="pcb_courtyard_rect_2" data-type="pcb_courtyard_rect" data-pcb-layer="top" stroke-linejoin="round" transform="translate(400 300) rotate(-45)" fill="none" stroke="#FF00FF" stroke-width="1.3636363636363638"/><circle cx="410.90909090909093" cy="152.72727272727272" r="57.27272727272727" class="pcb-courtyard-circle pcb-courtyard-top" data-pcb-courtyard-circle-id="pcb_courtyard_circle_1" data-type="pcb_courtyard_circle" data-pcb-layer="top" fill="none" stroke="#FF00FF" stroke-width="1.3636363636363638"/></svg>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { expect, test } from "bun:test"
|
|
2
|
+
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
|
|
2
3
|
import { convertCircuitJsonToTscircuit } from "lib"
|
|
3
4
|
import { runTscircuitCode } from "tscircuit"
|
|
4
5
|
|
|
@@ -13,10 +14,10 @@ test("test8 support courtyard elements", async () => {
|
|
|
13
14
|
<chip
|
|
14
15
|
footprint={<footprint>
|
|
15
16
|
<smtpad portHints={["1"]} pcbX="-0.5mm" pcbY="0mm" layer="top" width="0.6mm" height="0.9mm" shape="rect" />
|
|
16
|
-
<courtyardoutline outline={[{"x":-
|
|
17
|
-
<courtyardrect pcbX={0} pcbY={0} width={4} height={3} layer="top" />
|
|
18
|
-
<courtyardrect pcbX={
|
|
19
|
-
<courtyardcircle pcbX={0.4} pcbY={
|
|
17
|
+
<courtyardoutline outline={[{"x":-7.8,"y":-1.4},{"x":-4.2,"y":-1.4},{"x":-4.2,"y":1.4},{"x":-7.8,"y":1.4}]} layer="top" />
|
|
18
|
+
<courtyardrect pcbX={0} pcbY={0} width={4} height={3} layer="top" pcbRotation="45deg" />
|
|
19
|
+
<courtyardrect pcbX={6.2} pcbY={0.2} width={4.6} height={3.6} layer="bottom" />
|
|
20
|
+
<courtyardcircle pcbX={0.4} pcbY={5.4} radius={2.1} layer="top" />
|
|
20
21
|
</footprint>}
|
|
21
22
|
{...props}
|
|
22
23
|
/>
|
|
@@ -57,6 +58,25 @@ circuit.add(
|
|
|
57
58
|
expect(
|
|
58
59
|
courtyardElements.filter((elm) => elm.type === "pcb_courtyard_circle"),
|
|
59
60
|
).toHaveLength(2)
|
|
61
|
+
expect(
|
|
62
|
+
courtyardElements.filter(
|
|
63
|
+
(elm) =>
|
|
64
|
+
elm.type === "pcb_courtyard_rect" &&
|
|
65
|
+
elm.layer === "top" &&
|
|
66
|
+
elm.center?.x === 0 &&
|
|
67
|
+
elm.center?.y === 0 &&
|
|
68
|
+
elm.width === 4 &&
|
|
69
|
+
elm.height === 3,
|
|
70
|
+
),
|
|
71
|
+
).toEqual([
|
|
72
|
+
expect.objectContaining({ ccw_rotation: 45 }),
|
|
73
|
+
expect.objectContaining({ ccw_rotation: 45 }),
|
|
74
|
+
])
|
|
75
|
+
|
|
76
|
+
const pcbSvg = convertCircuitJsonToPcbSvg(renderedCircuitJson, {
|
|
77
|
+
showCourtyards: true,
|
|
78
|
+
})
|
|
79
|
+
await expect(pcbSvg).toMatchSvgSnapshot(import.meta.path, "courtyard-pcb")
|
|
60
80
|
})
|
|
61
81
|
|
|
62
82
|
const circuitJson: any = [
|
|
@@ -110,10 +130,10 @@ const circuitJson: any = [
|
|
|
110
130
|
pcb_component_id: "pcb_generic_component_0",
|
|
111
131
|
layer: "top",
|
|
112
132
|
outline: [
|
|
113
|
-
{ x: -
|
|
114
|
-
{ x:
|
|
115
|
-
{ x:
|
|
116
|
-
{ x: -
|
|
133
|
+
{ x: -7.8, y: -1.4 },
|
|
134
|
+
{ x: -4.2, y: -1.4 },
|
|
135
|
+
{ x: -4.2, y: 1.4 },
|
|
136
|
+
{ x: -7.8, y: 1.4 },
|
|
117
137
|
],
|
|
118
138
|
},
|
|
119
139
|
{
|
|
@@ -124,12 +144,13 @@ const circuitJson: any = [
|
|
|
124
144
|
width: 4,
|
|
125
145
|
height: 3,
|
|
126
146
|
layer: "top",
|
|
147
|
+
ccw_rotation: 45,
|
|
127
148
|
},
|
|
128
149
|
{
|
|
129
150
|
type: "pcb_courtyard_rect",
|
|
130
151
|
pcb_courtyard_rect_id: "pcb_courtyard_rect_1",
|
|
131
152
|
pcb_component_id: "pcb_generic_component_0",
|
|
132
|
-
center: { x:
|
|
153
|
+
center: { x: 6.2, y: 0.2 },
|
|
133
154
|
width: 4.6,
|
|
134
155
|
height: 3.6,
|
|
135
156
|
layer: "bottom",
|
|
@@ -138,7 +159,7 @@ const circuitJson: any = [
|
|
|
138
159
|
type: "pcb_courtyard_circle",
|
|
139
160
|
pcb_courtyard_circle_id: "pcb_courtyard_circle_0",
|
|
140
161
|
pcb_component_id: "pcb_generic_component_0",
|
|
141
|
-
center: { x: 0.4, y:
|
|
162
|
+
center: { x: 0.4, y: 5.4 },
|
|
142
163
|
radius: 2.1,
|
|
143
164
|
layer: "top",
|
|
144
165
|
},
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { mmStr } from "@tscircuit/mm"
|
|
2
|
-
|
|
3
|
-
export const escapeJsxText = (value: unknown): string =>
|
|
4
|
-
String(value ?? "").replace(/"/g, '\\"')
|
|
5
|
-
|
|
6
|
-
export const formatMm = (value: number | undefined): string => mmStr(value ?? 0)
|
|
7
|
-
|
|
8
|
-
export const formatOptionalMmAttr = (
|
|
9
|
-
attrName: string,
|
|
10
|
-
value: number | undefined,
|
|
11
|
-
): string => {
|
|
12
|
-
if (value === undefined) return ""
|
|
13
|
-
return ` ${attrName}="${mmStr(value)}"`
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const formatSolderMaskAttrs = (platedHole: {
|
|
17
|
-
is_covered_with_solder_mask?: boolean
|
|
18
|
-
soldermask_margin?: number
|
|
19
|
-
}): string =>
|
|
20
|
-
`${
|
|
21
|
-
platedHole.is_covered_with_solder_mask === undefined
|
|
22
|
-
? ""
|
|
23
|
-
: ` coveredWithSolderMask={${platedHole.is_covered_with_solder_mask}}`
|
|
24
|
-
}${formatOptionalMmAttr("solderMaskMargin", platedHole.soldermask_margin)}`
|
|
25
|
-
|
|
26
|
-
export const formatPcbRotationAttr = (
|
|
27
|
-
rotation: string | number | undefined,
|
|
28
|
-
attrName = "pcbRotation",
|
|
29
|
-
): string => {
|
|
30
|
-
if (rotation === undefined) return ""
|
|
31
|
-
const formatted = typeof rotation === "number" ? `${rotation}deg` : rotation
|
|
32
|
-
return ` ${attrName}="${formatted}"`
|
|
33
|
-
}
|