circuit-json-to-tscircuit 0.0.36 → 0.0.37
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-PIWUZ3WB.js → chunk-7VZ63UWJ.js} +77 -5
- package/dist/cli/main.js +2 -2
- package/dist/lib/index.js +1 -1
- package/lib/generate-footprint-tsx/convert-smt-pads.ts +80 -5
- package/package.json +1 -1
- package/tests/__snapshots__/test16-support-pcb-smtpad-shapes-pcb.snap.svg +1 -1
- package/tests/cli/cli-circuit-json-to-tsx.test.tsx +3 -3
- package/tests/test1-basic-circuit.test.tsx +3 -3
- package/tests/test16-support-pcb-smtpad-shapes.test.tsx +64 -9
- package/tests/test2-get-component-template.test.tsx +3 -3
- package/tests/test3-kicad-mod-circuit-json-example.test.tsx +29 -29
- package/tests/test4-support-silkscreen.test.tsx +2 -2
- package/tests/test5-pcb-cutout.test.tsx +2 -2
- package/tests/test8-support-courtyard.test.tsx +1 -1
|
@@ -500,26 +500,98 @@ var convertSmtPads = (circuitJson) => {
|
|
|
500
500
|
const smtPads = su11(circuitJson).pcb_smtpad.list();
|
|
501
501
|
const elementStrings = [];
|
|
502
502
|
for (const smtPad of smtPads) {
|
|
503
|
+
const commonAttrs = [];
|
|
504
|
+
if (smtPad.port_hints !== void 0) {
|
|
505
|
+
commonAttrs.push(`portHints={${JSON.stringify(smtPad.port_hints)}}`);
|
|
506
|
+
}
|
|
507
|
+
if ("x" in smtPad && smtPad.x !== void 0) {
|
|
508
|
+
commonAttrs.push(`pcbX="${mmStr5(smtPad.x)}"`);
|
|
509
|
+
}
|
|
510
|
+
if ("y" in smtPad && smtPad.y !== void 0) {
|
|
511
|
+
commonAttrs.push(`pcbY="${mmStr5(smtPad.y)}"`);
|
|
512
|
+
}
|
|
513
|
+
if (smtPad.layer !== void 0) {
|
|
514
|
+
commonAttrs.push(`layer="${smtPad.layer}"`);
|
|
515
|
+
}
|
|
516
|
+
if (smtPad.is_covered_with_solder_mask !== void 0) {
|
|
517
|
+
commonAttrs.push(
|
|
518
|
+
`coveredWithSolderMask={${smtPad.is_covered_with_solder_mask}}`
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
if (smtPad.soldermask_margin !== void 0) {
|
|
522
|
+
commonAttrs.push(`solderMaskMargin="${mmStr5(smtPad.soldermask_margin)}"`);
|
|
523
|
+
}
|
|
503
524
|
if (smtPad.shape === "circle") {
|
|
504
525
|
elementStrings.push(
|
|
505
|
-
`<smtpad
|
|
526
|
+
`<smtpad ${commonAttrs.join(" ")} radius="${mmStr5(smtPad.radius ?? 0)}" shape="circle" />`
|
|
506
527
|
);
|
|
507
528
|
} else if (smtPad.shape === "rect") {
|
|
529
|
+
if (smtPad.rect_border_radius !== void 0) {
|
|
530
|
+
commonAttrs.push(
|
|
531
|
+
`rectBorderRadius="${mmStr5(smtPad.rect_border_radius)}"`
|
|
532
|
+
);
|
|
533
|
+
}
|
|
534
|
+
if (smtPad.corner_radius !== void 0) {
|
|
535
|
+
commonAttrs.push(`cornerRadius="${mmStr5(smtPad.corner_radius)}"`);
|
|
536
|
+
}
|
|
537
|
+
if (smtPad.soldermask_margin_left !== void 0) {
|
|
538
|
+
commonAttrs.push(
|
|
539
|
+
`solderMaskMarginLeft="${mmStr5(smtPad.soldermask_margin_left)}"`
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
if (smtPad.soldermask_margin_top !== void 0) {
|
|
543
|
+
commonAttrs.push(
|
|
544
|
+
`solderMaskMarginTop="${mmStr5(smtPad.soldermask_margin_top)}"`
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
if (smtPad.soldermask_margin_right !== void 0) {
|
|
548
|
+
commonAttrs.push(
|
|
549
|
+
`solderMaskMarginRight="${mmStr5(smtPad.soldermask_margin_right)}"`
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
if (smtPad.soldermask_margin_bottom !== void 0) {
|
|
553
|
+
commonAttrs.push(
|
|
554
|
+
`solderMaskMarginBottom="${mmStr5(smtPad.soldermask_margin_bottom)}"`
|
|
555
|
+
);
|
|
556
|
+
}
|
|
508
557
|
elementStrings.push(
|
|
509
|
-
`<smtpad
|
|
558
|
+
`<smtpad ${commonAttrs.join(" ")} width="${mmStr5(smtPad.width ?? 0)}" height="${mmStr5(smtPad.height ?? 0)}" shape="rect" />`
|
|
510
559
|
);
|
|
511
560
|
} else if (smtPad.shape === "pill") {
|
|
512
561
|
elementStrings.push(
|
|
513
|
-
`<smtpad
|
|
562
|
+
`<smtpad ${commonAttrs.join(" ")} width="${mmStr5(smtPad.width ?? 0)}" height="${mmStr5(smtPad.height ?? 0)}" radius="${mmStr5(smtPad.radius ?? 0)}" shape="pill" />`
|
|
514
563
|
);
|
|
515
564
|
} else if (smtPad.shape === "polygon") {
|
|
516
565
|
elementStrings.push(
|
|
517
|
-
`<smtpad
|
|
566
|
+
`<smtpad ${commonAttrs.join(" ")} shape="polygon" points={${JSON.stringify(smtPad.points)}} />`
|
|
518
567
|
);
|
|
519
568
|
} else if (smtPad.shape === "rotated_rect") {
|
|
520
569
|
const cornerRadius = smtPad.corner_radius ?? smtPad.rect_border_radius ?? void 0;
|
|
570
|
+
if (cornerRadius !== void 0) {
|
|
571
|
+
commonAttrs.push(`cornerRadius="${mmStr5(cornerRadius)}"`);
|
|
572
|
+
}
|
|
573
|
+
if (smtPad.soldermask_margin_left !== void 0) {
|
|
574
|
+
commonAttrs.push(
|
|
575
|
+
`solderMaskMarginLeft="${mmStr5(smtPad.soldermask_margin_left)}"`
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
if (smtPad.soldermask_margin_top !== void 0) {
|
|
579
|
+
commonAttrs.push(
|
|
580
|
+
`solderMaskMarginTop="${mmStr5(smtPad.soldermask_margin_top)}"`
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
if (smtPad.soldermask_margin_right !== void 0) {
|
|
584
|
+
commonAttrs.push(
|
|
585
|
+
`solderMaskMarginRight="${mmStr5(smtPad.soldermask_margin_right)}"`
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
if (smtPad.soldermask_margin_bottom !== void 0) {
|
|
589
|
+
commonAttrs.push(
|
|
590
|
+
`solderMaskMarginBottom="${mmStr5(smtPad.soldermask_margin_bottom)}"`
|
|
591
|
+
);
|
|
592
|
+
}
|
|
521
593
|
elementStrings.push(
|
|
522
|
-
`<smtpad
|
|
594
|
+
`<smtpad ${commonAttrs.join(" ")} width="${mmStr5(smtPad.width ?? 0)}" height="${mmStr5(smtPad.height ?? 0)}"${formatPcbRotationAttr(smtPad.ccw_rotation)} shape="rotated_rect" />`
|
|
523
595
|
);
|
|
524
596
|
}
|
|
525
597
|
}
|
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-7VZ63UWJ.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.36",
|
|
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
|
@@ -8,27 +8,102 @@ export const convertSmtPads: FootprintElementConverter = (circuitJson) => {
|
|
|
8
8
|
const elementStrings: string[] = []
|
|
9
9
|
|
|
10
10
|
for (const smtPad of smtPads) {
|
|
11
|
+
const commonAttrs: string[] = []
|
|
12
|
+
|
|
13
|
+
if (smtPad.port_hints !== undefined) {
|
|
14
|
+
commonAttrs.push(`portHints={${JSON.stringify(smtPad.port_hints)}}`)
|
|
15
|
+
}
|
|
16
|
+
if ("x" in smtPad && smtPad.x !== undefined) {
|
|
17
|
+
commonAttrs.push(`pcbX="${mmStr(smtPad.x)}"`)
|
|
18
|
+
}
|
|
19
|
+
if ("y" in smtPad && smtPad.y !== undefined) {
|
|
20
|
+
commonAttrs.push(`pcbY="${mmStr(smtPad.y)}"`)
|
|
21
|
+
}
|
|
22
|
+
if (smtPad.layer !== undefined) {
|
|
23
|
+
commonAttrs.push(`layer="${smtPad.layer}"`)
|
|
24
|
+
}
|
|
25
|
+
if (smtPad.is_covered_with_solder_mask !== undefined) {
|
|
26
|
+
commonAttrs.push(
|
|
27
|
+
`coveredWithSolderMask={${smtPad.is_covered_with_solder_mask}}`,
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
if (smtPad.soldermask_margin !== undefined) {
|
|
31
|
+
commonAttrs.push(`solderMaskMargin="${mmStr(smtPad.soldermask_margin)}"`)
|
|
32
|
+
}
|
|
33
|
+
|
|
11
34
|
if (smtPad.shape === "circle") {
|
|
12
35
|
elementStrings.push(
|
|
13
|
-
`<smtpad
|
|
36
|
+
`<smtpad ${commonAttrs.join(" ")} radius="${mmStr(smtPad.radius ?? 0)}" shape="circle" />`,
|
|
14
37
|
)
|
|
15
38
|
} else if (smtPad.shape === "rect") {
|
|
39
|
+
if (smtPad.rect_border_radius !== undefined) {
|
|
40
|
+
commonAttrs.push(
|
|
41
|
+
`rectBorderRadius="${mmStr(smtPad.rect_border_radius)}"`,
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
if (smtPad.corner_radius !== undefined) {
|
|
45
|
+
commonAttrs.push(`cornerRadius="${mmStr(smtPad.corner_radius)}"`)
|
|
46
|
+
}
|
|
47
|
+
if (smtPad.soldermask_margin_left !== undefined) {
|
|
48
|
+
commonAttrs.push(
|
|
49
|
+
`solderMaskMarginLeft="${mmStr(smtPad.soldermask_margin_left)}"`,
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
if (smtPad.soldermask_margin_top !== undefined) {
|
|
53
|
+
commonAttrs.push(
|
|
54
|
+
`solderMaskMarginTop="${mmStr(smtPad.soldermask_margin_top)}"`,
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
if (smtPad.soldermask_margin_right !== undefined) {
|
|
58
|
+
commonAttrs.push(
|
|
59
|
+
`solderMaskMarginRight="${mmStr(smtPad.soldermask_margin_right)}"`,
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
if (smtPad.soldermask_margin_bottom !== undefined) {
|
|
63
|
+
commonAttrs.push(
|
|
64
|
+
`solderMaskMarginBottom="${mmStr(smtPad.soldermask_margin_bottom)}"`,
|
|
65
|
+
)
|
|
66
|
+
}
|
|
16
67
|
elementStrings.push(
|
|
17
|
-
`<smtpad
|
|
68
|
+
`<smtpad ${commonAttrs.join(" ")} width="${mmStr(smtPad.width ?? 0)}" height="${mmStr(smtPad.height ?? 0)}" shape="rect" />`,
|
|
18
69
|
)
|
|
19
70
|
} else if (smtPad.shape === "pill") {
|
|
20
71
|
elementStrings.push(
|
|
21
|
-
`<smtpad
|
|
72
|
+
`<smtpad ${commonAttrs.join(" ")} width="${mmStr(smtPad.width ?? 0)}" height="${mmStr(smtPad.height ?? 0)}" radius="${mmStr(smtPad.radius ?? 0)}" shape="pill" />`,
|
|
22
73
|
)
|
|
23
74
|
} else if (smtPad.shape === "polygon") {
|
|
24
75
|
elementStrings.push(
|
|
25
|
-
`<smtpad
|
|
76
|
+
`<smtpad ${commonAttrs.join(" ")} shape="polygon" points={${JSON.stringify(smtPad.points)}} />`,
|
|
26
77
|
)
|
|
27
78
|
} else if (smtPad.shape === "rotated_rect") {
|
|
28
79
|
const cornerRadius =
|
|
29
80
|
smtPad.corner_radius ?? smtPad.rect_border_radius ?? undefined
|
|
81
|
+
|
|
82
|
+
if (cornerRadius !== undefined) {
|
|
83
|
+
commonAttrs.push(`cornerRadius="${mmStr(cornerRadius)}"`)
|
|
84
|
+
}
|
|
85
|
+
if (smtPad.soldermask_margin_left !== undefined) {
|
|
86
|
+
commonAttrs.push(
|
|
87
|
+
`solderMaskMarginLeft="${mmStr(smtPad.soldermask_margin_left)}"`,
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
if (smtPad.soldermask_margin_top !== undefined) {
|
|
91
|
+
commonAttrs.push(
|
|
92
|
+
`solderMaskMarginTop="${mmStr(smtPad.soldermask_margin_top)}"`,
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
if (smtPad.soldermask_margin_right !== undefined) {
|
|
96
|
+
commonAttrs.push(
|
|
97
|
+
`solderMaskMarginRight="${mmStr(smtPad.soldermask_margin_right)}"`,
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
if (smtPad.soldermask_margin_bottom !== undefined) {
|
|
101
|
+
commonAttrs.push(
|
|
102
|
+
`solderMaskMarginBottom="${mmStr(smtPad.soldermask_margin_bottom)}"`,
|
|
103
|
+
)
|
|
104
|
+
}
|
|
30
105
|
elementStrings.push(
|
|
31
|
-
`<smtpad
|
|
106
|
+
`<smtpad ${commonAttrs.join(" ")} width="${mmStr(smtPad.width ?? 0)}" height="${mmStr(smtPad.height ?? 0)}"${formatPcbRotationAttr(smtPad.ccw_rotation)} shape="rotated_rect" />`,
|
|
32
107
|
)
|
|
33
108
|
}
|
|
34
109
|
}
|
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.1090"><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 class="pcb-pad" fill="rgb(77, 127, 196)" x="-27.272727272727273" y="-8.181818181818182" width="54.54545454545455" height="16.363636363636363" transform="translate(372.72727272727275 354.54545454545456) rotate(-45)" data-type="pcb_smtpad" data-pcb-layer="bottom" rx="4.090909090909091" ry="4.090909090909091"/><rect class="pcb-pad" fill="rgb(77, 127, 196)" x="443.6363636363636" y="328.6363636363636" width="49.09090909090909" height="24.545454545454547" data-type="pcb_smtpad" data-pcb-layer="bottom" rx="5.454545454545455" ry="5.454545454545455"/><rect class="pcb-pad" fill="rgb(77, 127, 196)" x="-27.272727272727273" y="-8.181818181818182" width="54.54545454545455" height="16.363636363636363" transform="translate(372.72727272727275 354.54545454545456) rotate(-45)" data-type="pcb_smtpad" data-pcb-layer="bottom" rx="4.090909090909091" ry="4.090909090909091"/><rect class="pcb-pad" fill="rgb(77, 127, 196)" x="443.6363636363636" y="328.6363636363636" width="49.09090909090909" height="24.545454545454547" data-type="pcb_smtpad" data-pcb-layer="bottom" rx="5.454545454545455" ry="5.454545454545455"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="406.8181818181818" y="234.54545454545453" width="40.90909090909091" height="21.81818181818182" rx="10.90909090909091" ry="10.90909090909091" data-type="pcb_smtpad" data-pcb-layer="top"/><polygon class="pcb-pad" fill="rgb(200, 52, 52)" points="400,300 427.27272727272725,300 413.6363636363636,272.72727272727275" data-type="pcb_smtpad" data-pcb-layer="top"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="406.8181818181818" y="234.54545454545453" width="40.90909090909091" height="21.81818181818182" rx="10.90909090909091" ry="10.90909090909091" data-type="pcb_smtpad" data-pcb-layer="top"/><polygon class="pcb-pad" fill="rgb(200, 52, 52)" points="400,300 427.27272727272725,300 413.6363636363636,272.72727272727275" data-type="pcb_smtpad" data-pcb-layer="top"/></svg>
|
|
@@ -22,13 +22,13 @@ test("should convert sample circuit.json to TSX", async () => {
|
|
|
22
22
|
export const Circuit = (props: ChipProps) => (
|
|
23
23
|
<chip
|
|
24
24
|
footprint={<footprint>
|
|
25
|
-
<smtpad portHints={["1","left"]} pcbX="-0.5mm" pcbY="0mm" width="0.6000000000000001mm" height="0.6000000000000001mm" shape="rect" />
|
|
26
|
-
<smtpad portHints={["2","right"]} pcbX="0.5mm" pcbY="0mm" width="0.6000000000000001mm" height="0.6000000000000001mm" shape="rect" />
|
|
25
|
+
<smtpad portHints={["1","left"]} pcbX="-0.5mm" pcbY="0mm" layer="top" width="0.6000000000000001mm" height="0.6000000000000001mm" shape="rect" />
|
|
26
|
+
<smtpad portHints={["2","right"]} pcbX="0.5mm" pcbY="0mm" layer="top" width="0.6000000000000001mm" height="0.6000000000000001mm" shape="rect" />
|
|
27
27
|
</footprint>}
|
|
28
28
|
{...props}
|
|
29
29
|
/>
|
|
30
30
|
)"
|
|
31
|
-
|
|
31
|
+
`)
|
|
32
32
|
})
|
|
33
33
|
|
|
34
34
|
test("should require output path", async () => {
|
|
@@ -26,11 +26,11 @@ test("test1 basic circuit", async () => {
|
|
|
26
26
|
export const MyResistor = (props: ChipProps) => (
|
|
27
27
|
<chip
|
|
28
28
|
footprint={<footprint>
|
|
29
|
-
<smtpad portHints={["1","left"]} pcbX="-0.5mm" pcbY="0mm" width="0.6000000000000001mm" height="0.6000000000000001mm" shape="rect" />
|
|
30
|
-
<smtpad portHints={["2","right"]} pcbX="0.5mm" pcbY="0mm" width="0.6000000000000001mm" height="0.6000000000000001mm" shape="rect" />
|
|
29
|
+
<smtpad portHints={["1","left"]} pcbX="-0.5mm" pcbY="0mm" layer="top" width="0.6000000000000001mm" height="0.6000000000000001mm" shape="rect" />
|
|
30
|
+
<smtpad portHints={["2","right"]} pcbX="0.5mm" pcbY="0mm" layer="top" width="0.6000000000000001mm" height="0.6000000000000001mm" shape="rect" />
|
|
31
31
|
</footprint>}
|
|
32
32
|
{...props}
|
|
33
33
|
/>
|
|
34
34
|
)"
|
|
35
|
-
|
|
35
|
+
`)
|
|
36
36
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { expect, test } from "bun:test"
|
|
2
2
|
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
|
|
3
|
+
import type { AnyCircuitElement, PcbSmtPad } from "circuit-json"
|
|
3
4
|
import { convertCircuitJsonToTscircuit } from "lib"
|
|
4
5
|
import { runTscircuitCode } from "tscircuit"
|
|
5
6
|
|
|
@@ -13,9 +14,10 @@ test("test16 support pcb smtpad shapes", async () => {
|
|
|
13
14
|
export const Test16Component = (props: ChipProps) => (
|
|
14
15
|
<chip
|
|
15
16
|
footprint={<footprint>
|
|
16
|
-
<smtpad portHints={["1"]} pcbX="1mm" pcbY="2mm" width="1.5mm" height="0.8mm" radius="0.4mm" shape="pill" />
|
|
17
|
-
<smtpad portHints={["2"]} shape="polygon" points={[{"x":0,"y":0},{"x":1,"y":0},{"x":0.5,"y":1}]} />
|
|
18
|
-
<smtpad portHints={["3"]} pcbX="-1mm" pcbY="-2mm" width="2mm" height="0.6mm" pcbRotation="45deg"
|
|
17
|
+
<smtpad portHints={["1"]} pcbX="1mm" pcbY="2mm" layer="top" coveredWithSolderMask={true} solderMaskMargin="0.03mm" width="1.5mm" height="0.8mm" radius="0.4mm" shape="pill" />
|
|
18
|
+
<smtpad portHints={["2"]} layer="top" coveredWithSolderMask={true} solderMaskMargin="0.06mm" shape="polygon" points={[{"x":0,"y":0},{"x":1,"y":0},{"x":0.5,"y":1}]} />
|
|
19
|
+
<smtpad portHints={["3"]} pcbX="-1mm" pcbY="-2mm" layer="bottom" coveredWithSolderMask={true} solderMaskMargin="0.04mm" cornerRadius="0.15mm" solderMaskMarginLeft="0.01mm" solderMaskMarginTop="0.02mm" solderMaskMarginRight="0.03mm" solderMaskMarginBottom="0.05mm" width="2mm" height="0.6mm" pcbRotation="45deg" shape="rotated_rect" />
|
|
20
|
+
<smtpad portHints={["4"]} pcbX="2.5mm" pcbY="-1.5mm" layer="bottom" coveredWithSolderMask={true} solderMaskMargin="0.05mm" rectBorderRadius="0.25mm" cornerRadius="0.2mm" solderMaskMarginLeft="0.11mm" solderMaskMarginTop="0.12mm" solderMaskMarginRight="0.13mm" solderMaskMarginBottom="0.14mm" width="1.8mm" height="0.9mm" shape="rect" />
|
|
19
21
|
</footprint>}
|
|
20
22
|
{...props}
|
|
21
23
|
/>
|
|
@@ -39,10 +41,33 @@ circuit.add(
|
|
|
39
41
|
<Test16Component />
|
|
40
42
|
</board>,
|
|
41
43
|
)
|
|
42
|
-
`)) as
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
`)) as AnyCircuitElement[]
|
|
45
|
+
|
|
46
|
+
const renderedSmtPads = renderedCircuitJson.filter(
|
|
47
|
+
(elm): elm is PcbSmtPad => elm.type === "pcb_smtpad",
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
expect(renderedSmtPads).toHaveLength(8)
|
|
51
|
+
expect(renderedSmtPads).toEqual(
|
|
52
|
+
expect.arrayContaining([
|
|
53
|
+
expect.objectContaining({
|
|
54
|
+
port_hints: ["3"],
|
|
55
|
+
layer: "bottom",
|
|
56
|
+
shape: "rotated_rect",
|
|
57
|
+
corner_radius: 0.15,
|
|
58
|
+
is_covered_with_solder_mask: true,
|
|
59
|
+
soldermask_margin: 0.04,
|
|
60
|
+
}),
|
|
61
|
+
expect.objectContaining({
|
|
62
|
+
port_hints: ["4"],
|
|
63
|
+
layer: "bottom",
|
|
64
|
+
shape: "rect",
|
|
65
|
+
corner_radius: 0.2,
|
|
66
|
+
is_covered_with_solder_mask: true,
|
|
67
|
+
soldermask_margin: 0.05,
|
|
68
|
+
}),
|
|
69
|
+
]),
|
|
70
|
+
)
|
|
46
71
|
|
|
47
72
|
const pcbSvg = convertCircuitJsonToPcbSvg(renderedCircuitJson)
|
|
48
73
|
await expect(pcbSvg).toMatchSvgSnapshot(import.meta.path, "pcb")
|
|
@@ -83,6 +108,8 @@ const circuitJson: any = [
|
|
|
83
108
|
height: 0.8,
|
|
84
109
|
radius: 0.4,
|
|
85
110
|
layer: "top",
|
|
111
|
+
is_covered_with_solder_mask: true,
|
|
112
|
+
soldermask_margin: 0.03,
|
|
86
113
|
port_hints: ["1"],
|
|
87
114
|
},
|
|
88
115
|
{
|
|
@@ -96,6 +123,8 @@ const circuitJson: any = [
|
|
|
96
123
|
{ x: 0.5, y: 1 },
|
|
97
124
|
],
|
|
98
125
|
layer: "top",
|
|
126
|
+
is_covered_with_solder_mask: true,
|
|
127
|
+
soldermask_margin: 0.06,
|
|
99
128
|
port_hints: ["2"],
|
|
100
129
|
},
|
|
101
130
|
{
|
|
@@ -108,8 +137,34 @@ const circuitJson: any = [
|
|
|
108
137
|
width: 2,
|
|
109
138
|
height: 0.6,
|
|
110
139
|
ccw_rotation: 45,
|
|
111
|
-
corner_radius: 0.
|
|
112
|
-
layer: "
|
|
140
|
+
corner_radius: 0.15,
|
|
141
|
+
layer: "bottom",
|
|
142
|
+
is_covered_with_solder_mask: true,
|
|
143
|
+
soldermask_margin: 0.04,
|
|
144
|
+
soldermask_margin_left: 0.01,
|
|
145
|
+
soldermask_margin_top: 0.02,
|
|
146
|
+
soldermask_margin_right: 0.03,
|
|
147
|
+
soldermask_margin_bottom: 0.05,
|
|
113
148
|
port_hints: ["3"],
|
|
114
149
|
},
|
|
150
|
+
{
|
|
151
|
+
type: "pcb_smtpad",
|
|
152
|
+
pcb_smtpad_id: "rect_pad",
|
|
153
|
+
pcb_component_id: "pcb_generic_component_0",
|
|
154
|
+
shape: "rect",
|
|
155
|
+
x: 2.5,
|
|
156
|
+
y: -1.5,
|
|
157
|
+
width: 1.8,
|
|
158
|
+
height: 0.9,
|
|
159
|
+
rect_border_radius: 0.25,
|
|
160
|
+
corner_radius: 0.2,
|
|
161
|
+
layer: "bottom",
|
|
162
|
+
is_covered_with_solder_mask: true,
|
|
163
|
+
soldermask_margin: 0.05,
|
|
164
|
+
soldermask_margin_left: 0.11,
|
|
165
|
+
soldermask_margin_top: 0.12,
|
|
166
|
+
soldermask_margin_right: 0.13,
|
|
167
|
+
soldermask_margin_bottom: 0.14,
|
|
168
|
+
port_hints: ["4"],
|
|
169
|
+
},
|
|
115
170
|
]
|
|
@@ -37,8 +37,8 @@ test("test2 getComponentUsingTemplate", async () => {
|
|
|
37
37
|
export const MyResistor = (props: ChipProps<typeof pinLabels>) => (
|
|
38
38
|
<chip
|
|
39
39
|
footprint={<footprint>
|
|
40
|
-
<smtpad portHints={["1","left"]} pcbX="-0.5mm" pcbY="0mm" width="0.6000000000000001mm" height="0.6000000000000001mm" shape="rect" />
|
|
41
|
-
<smtpad portHints={["2","right"]} pcbX="0.5mm" pcbY="0mm" width="0.6000000000000001mm" height="0.6000000000000001mm" shape="rect" />
|
|
40
|
+
<smtpad portHints={["1","left"]} pcbX="-0.5mm" pcbY="0mm" layer="top" width="0.6000000000000001mm" height="0.6000000000000001mm" shape="rect" />
|
|
41
|
+
<smtpad portHints={["2","right"]} pcbX="0.5mm" pcbY="0mm" layer="top" width="0.6000000000000001mm" height="0.6000000000000001mm" shape="rect" />
|
|
42
42
|
</footprint>}
|
|
43
43
|
pinLabels={pinLabels}
|
|
44
44
|
cadModel={{
|
|
@@ -55,5 +55,5 @@ test("test2 getComponentUsingTemplate", async () => {
|
|
|
55
55
|
{...props}
|
|
56
56
|
/>
|
|
57
57
|
)"
|
|
58
|
-
|
|
58
|
+
`)
|
|
59
59
|
})
|
|
@@ -38,34 +38,34 @@ test("test3 kicad mod circuit json example", async () => {
|
|
|
38
38
|
<platedhole portHints={["13"]} pcbX="8.89mm" pcbY="5.08mm" outerDiameter="1.27mm" holeDiameter="0.7mm" shape="circle" />
|
|
39
39
|
<platedhole portHints={["14"]} pcbX="7.62mm" pcbY="7.62mm" outerDiameter="1.5mm" holeDiameter="0.85mm" shape="circle" />
|
|
40
40
|
<platedhole portHints={["14"]} pcbX="8.89mm" pcbY="7.62mm" outerDiameter="1.27mm" holeDiameter="0.7mm" shape="circle" />
|
|
41
|
-
<smtpad portHints={["1"]} pcbX="-8.278mm" pcbY="7.62mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
42
|
-
<smtpad portHints={["1"]} pcbX="-8.278mm" pcbY="7.62mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
43
|
-
<smtpad portHints={["2"]} pcbX="-8.337mm" pcbY="5.08mm" width="1.626mm" height="1.208mm" shape="rect" />
|
|
44
|
-
<smtpad portHints={["2"]} pcbX="-8.337mm" pcbY="5.08mm" width="1.626mm" height="1.208mm" shape="rect" />
|
|
45
|
-
<smtpad portHints={["3"]} pcbX="-8.278mm" pcbY="2.54mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
46
|
-
<smtpad portHints={["3"]} pcbX="-8.278mm" pcbY="2.54mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
47
|
-
<smtpad portHints={["4"]} pcbX="-8.278mm" pcbY="0mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
48
|
-
<smtpad portHints={["4"]} pcbX="-8.278mm" pcbY="0mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
49
|
-
<smtpad portHints={["5"]} pcbX="-8.278mm" pcbY="-2.54mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
50
|
-
<smtpad portHints={["5"]} pcbX="-8.278mm" pcbY="-2.54mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
51
|
-
<smtpad portHints={["6"]} pcbX="-8.337mm" pcbY="-5.08mm" width="1.626mm" height="1.208mm" shape="rect" />
|
|
52
|
-
<smtpad portHints={["6"]} pcbX="-8.337mm" pcbY="-5.08mm" width="1.626mm" height="1.208mm" shape="rect" />
|
|
53
|
-
<smtpad portHints={["7"]} pcbX="-8.278mm" pcbY="-7.62mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
54
|
-
<smtpad portHints={["7"]} pcbX="-8.278mm" pcbY="-7.62mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
55
|
-
<smtpad portHints={["8"]} pcbX="8.278mm" pcbY="-7.62mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
56
|
-
<smtpad portHints={["8"]} pcbX="8.278mm" pcbY="-7.62mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
57
|
-
<smtpad portHints={["9"]} pcbX="8.337mm" pcbY="-5.08mm" width="1.626mm" height="1.208mm" shape="rect" />
|
|
58
|
-
<smtpad portHints={["9"]} pcbX="8.337mm" pcbY="-5.08mm" width="1.626mm" height="1.208mm" shape="rect" />
|
|
59
|
-
<smtpad portHints={["10"]} pcbX="8.278mm" pcbY="-2.54mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
60
|
-
<smtpad portHints={["10"]} pcbX="8.278mm" pcbY="-2.54mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
61
|
-
<smtpad portHints={["11"]} pcbX="8.278mm" pcbY="0mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
62
|
-
<smtpad portHints={["11"]} pcbX="8.278mm" pcbY="0mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
63
|
-
<smtpad portHints={["12"]} pcbX="8.278mm" pcbY="2.54mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
64
|
-
<smtpad portHints={["12"]} pcbX="8.278mm" pcbY="2.54mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
65
|
-
<smtpad portHints={["13"]} pcbX="8.337mm" pcbY="5.08mm" width="1.626mm" height="1.208mm" shape="rect" />
|
|
66
|
-
<smtpad portHints={["13"]} pcbX="8.337mm" pcbY="5.08mm" width="1.626mm" height="1.208mm" shape="rect" />
|
|
67
|
-
<smtpad portHints={["14"]} pcbX="8.278mm" pcbY="7.62mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
68
|
-
<smtpad portHints={["14"]} pcbX="8.278mm" pcbY="7.62mm" width="1.626mm" height="1.325mm" shape="rect" />
|
|
41
|
+
<smtpad portHints={["1"]} pcbX="-8.278mm" pcbY="7.62mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
42
|
+
<smtpad portHints={["1"]} pcbX="-8.278mm" pcbY="7.62mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
43
|
+
<smtpad portHints={["2"]} pcbX="-8.337mm" pcbY="5.08mm" layer="top" width="1.626mm" height="1.208mm" shape="rect" />
|
|
44
|
+
<smtpad portHints={["2"]} pcbX="-8.337mm" pcbY="5.08mm" layer="top" width="1.626mm" height="1.208mm" shape="rect" />
|
|
45
|
+
<smtpad portHints={["3"]} pcbX="-8.278mm" pcbY="2.54mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
46
|
+
<smtpad portHints={["3"]} pcbX="-8.278mm" pcbY="2.54mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
47
|
+
<smtpad portHints={["4"]} pcbX="-8.278mm" pcbY="0mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
48
|
+
<smtpad portHints={["4"]} pcbX="-8.278mm" pcbY="0mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
49
|
+
<smtpad portHints={["5"]} pcbX="-8.278mm" pcbY="-2.54mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
50
|
+
<smtpad portHints={["5"]} pcbX="-8.278mm" pcbY="-2.54mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
51
|
+
<smtpad portHints={["6"]} pcbX="-8.337mm" pcbY="-5.08mm" layer="top" width="1.626mm" height="1.208mm" shape="rect" />
|
|
52
|
+
<smtpad portHints={["6"]} pcbX="-8.337mm" pcbY="-5.08mm" layer="top" width="1.626mm" height="1.208mm" shape="rect" />
|
|
53
|
+
<smtpad portHints={["7"]} pcbX="-8.278mm" pcbY="-7.62mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
54
|
+
<smtpad portHints={["7"]} pcbX="-8.278mm" pcbY="-7.62mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
55
|
+
<smtpad portHints={["8"]} pcbX="8.278mm" pcbY="-7.62mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
56
|
+
<smtpad portHints={["8"]} pcbX="8.278mm" pcbY="-7.62mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
57
|
+
<smtpad portHints={["9"]} pcbX="8.337mm" pcbY="-5.08mm" layer="top" width="1.626mm" height="1.208mm" shape="rect" />
|
|
58
|
+
<smtpad portHints={["9"]} pcbX="8.337mm" pcbY="-5.08mm" layer="top" width="1.626mm" height="1.208mm" shape="rect" />
|
|
59
|
+
<smtpad portHints={["10"]} pcbX="8.278mm" pcbY="-2.54mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
60
|
+
<smtpad portHints={["10"]} pcbX="8.278mm" pcbY="-2.54mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
61
|
+
<smtpad portHints={["11"]} pcbX="8.278mm" pcbY="0mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
62
|
+
<smtpad portHints={["11"]} pcbX="8.278mm" pcbY="0mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
63
|
+
<smtpad portHints={["12"]} pcbX="8.278mm" pcbY="2.54mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
64
|
+
<smtpad portHints={["12"]} pcbX="8.278mm" pcbY="2.54mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
65
|
+
<smtpad portHints={["13"]} pcbX="8.337mm" pcbY="5.08mm" layer="top" width="1.626mm" height="1.208mm" shape="rect" />
|
|
66
|
+
<smtpad portHints={["13"]} pcbX="8.337mm" pcbY="5.08mm" layer="top" width="1.626mm" height="1.208mm" shape="rect" />
|
|
67
|
+
<smtpad portHints={["14"]} pcbX="8.278mm" pcbY="7.62mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
68
|
+
<smtpad portHints={["14"]} pcbX="8.278mm" pcbY="7.62mm" layer="top" width="1.626mm" height="1.325mm" shape="rect" />
|
|
69
69
|
<silkscreenpath route={[{"x":-8.89,"y":-8.509},{"x":-8.89,"y":8.636}]} />
|
|
70
70
|
<silkscreenpath route={[{"x":-6.985,"y":-10.414},{"x":6.985,"y":-10.414}]} />
|
|
71
71
|
<silkscreenpath route={[{"x":6.985,"y":10.541},{"x":-6.985,"y":10.541}]} />
|
|
@@ -80,7 +80,7 @@ test("test3 kicad mod circuit json example", async () => {
|
|
|
80
80
|
{...props}
|
|
81
81
|
/>
|
|
82
82
|
)"
|
|
83
|
-
|
|
83
|
+
`)
|
|
84
84
|
})
|
|
85
85
|
const circuitJson: any = [
|
|
86
86
|
{
|
|
@@ -14,8 +14,8 @@ test("test4 support silkscreen", async () => {
|
|
|
14
14
|
export const Test4Component = (props: ChipProps) => (
|
|
15
15
|
<chip
|
|
16
16
|
footprint={<footprint>
|
|
17
|
-
<smtpad portHints={["1"]} pcbX="-0.32mm" pcbY="0mm" width="0.46mm" height="0.4mm" shape="rect" />
|
|
18
|
-
<smtpad portHints={["2"]} pcbX="0.32mm" pcbY="0mm" width="0.46mm" height="0.4mm" shape="rect" />
|
|
17
|
+
<smtpad portHints={["1"]} pcbX="-0.32mm" pcbY="0mm" layer="top" width="0.46mm" height="0.4mm" shape="rect" />
|
|
18
|
+
<smtpad portHints={["2"]} pcbX="0.32mm" pcbY="0mm" layer="top" width="0.46mm" height="0.4mm" shape="rect" />
|
|
19
19
|
<fabricationnotepath route={[{"x":-0.3,"y":0.15},{"x":0.3,"y":0.15}]} strokeWidth={0.1} />
|
|
20
20
|
<fabricationnotepath route={[{"x":-0.3,"y":-0.15},{"x":-0.3,"y":0.15}]} strokeWidth={0.1} />
|
|
21
21
|
<fabricationnotepath route={[{"x":0.3,"y":0.15},{"x":0.3,"y":-0.15}]} strokeWidth={0.1} />
|
|
@@ -136,13 +136,13 @@ test("test pcb_cutout conversion - mixed with other elements", async () => {
|
|
|
136
136
|
<chip
|
|
137
137
|
footprint={<footprint>
|
|
138
138
|
<hole pcbX="10mm" pcbY="10mm" diameter="0.5mm" />
|
|
139
|
-
<smtpad portHints={["1"]} pcbX="0mm" pcbY="0mm" width="1mm" height="1mm" shape="rect" />
|
|
139
|
+
<smtpad portHints={["1"]} pcbX="0mm" pcbY="0mm" layer="top" width="1mm" height="1mm" shape="rect" />
|
|
140
140
|
<cutout shape="circle" pcbX="5mm" pcbY="5mm" radius="1.5mm" />
|
|
141
141
|
</footprint>}
|
|
142
142
|
{...props}
|
|
143
143
|
/>
|
|
144
144
|
)"
|
|
145
|
-
|
|
145
|
+
`)
|
|
146
146
|
|
|
147
147
|
const result = await runTscircuitCode(tscircuit)
|
|
148
148
|
expect(Array.isArray(result)).toBe(true)
|
|
@@ -12,7 +12,7 @@ test("test8 support courtyard elements", async () => {
|
|
|
12
12
|
export const Test8Component = (props: ChipProps) => (
|
|
13
13
|
<chip
|
|
14
14
|
footprint={<footprint>
|
|
15
|
-
<smtpad portHints={["1"]} pcbX="-0.5mm" pcbY="0mm" width="0.6mm" height="0.9mm" shape="rect" />
|
|
15
|
+
<smtpad portHints={["1"]} pcbX="-0.5mm" pcbY="0mm" layer="top" width="0.6mm" height="0.9mm" shape="rect" />
|
|
16
16
|
<courtyardoutline outline={[{"x":-1.8,"y":-1.4},{"x":1.8,"y":-1.4},{"x":1.8,"y":1.4},{"x":-1.8,"y":1.4}]} layer="top" />
|
|
17
17
|
<courtyardrect pcbX={0} pcbY={0} width={4} height={3} layer="top" />
|
|
18
18
|
<courtyardrect pcbX={0.2} pcbY={0.2} width={4.6} height={3.6} layer="bottom" />
|