circuit-json-to-tscircuit 0.0.45 → 0.0.47
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-UXTI3RT6.js → chunk-E24YLRWU.js} +1 -1
- package/dist/cli/main.js +2 -2
- package/dist/lib/index.js +1 -1
- package/lib/generate-footprint-tsx/convert-smt-pads.ts +1 -1
- package/package.json +1 -1
- package/tests/test16-support-pcb-smtpad-shapes.test.tsx +4 -10
- package/tests/test21-silkscreen-path-props-tsx.test.tsx +57 -0
- package/tests/test22-silkscreen-path-props-roundtrip.test.tsx +78 -0
|
@@ -565,7 +565,7 @@ var convertSmtPads = (circuitJson) => {
|
|
|
565
565
|
} else if (smtPad.shape === "rotated_rect") {
|
|
566
566
|
const cornerRadius = smtPad.corner_radius ?? smtPad.rect_border_radius ?? void 0;
|
|
567
567
|
elementStrings.push(
|
|
568
|
-
`<smtpad ${commonAttrs.join(" ")}${solderMaskAttrs}${formatOptionalMmAttr("cornerRadius", cornerRadius)}${formatOptionalMmAttr("solderMaskMarginLeft", smtPad.soldermask_margin_left)}${formatOptionalMmAttr("solderMaskMarginTop", smtPad.soldermask_margin_top)}${formatOptionalMmAttr("solderMaskMarginRight", smtPad.soldermask_margin_right)}${formatOptionalMmAttr("solderMaskMarginBottom", smtPad.soldermask_margin_bottom)} width="${mmStr6(smtPad.width ?? 0)}" height="${mmStr6(smtPad.height ?? 0)}"${
|
|
568
|
+
`<smtpad ${commonAttrs.join(" ")}${solderMaskAttrs}${formatOptionalMmAttr("cornerRadius", cornerRadius)}${formatOptionalMmAttr("solderMaskMarginLeft", smtPad.soldermask_margin_left)}${formatOptionalMmAttr("solderMaskMarginTop", smtPad.soldermask_margin_top)}${formatOptionalMmAttr("solderMaskMarginRight", smtPad.soldermask_margin_right)}${formatOptionalMmAttr("solderMaskMarginBottom", smtPad.soldermask_margin_bottom)} width="${mmStr6(smtPad.width ?? 0)}" height="${mmStr6(smtPad.height ?? 0)}" ccwRotation={${smtPad.ccw_rotation ?? 0}} shape="rotated_rect" />`
|
|
569
569
|
);
|
|
570
570
|
}
|
|
571
571
|
}
|
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-E24YLRWU.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.46",
|
|
20
20
|
repository: {
|
|
21
21
|
type: "git",
|
|
22
22
|
url: "https://github.com/tscircuit/circuit-json-to-tscircuit.git"
|
package/dist/lib/index.js
CHANGED
|
@@ -51,7 +51,7 @@ export const convertSmtPads: FootprintElementConverter = (circuitJson) => {
|
|
|
51
51
|
smtPad.corner_radius ?? smtPad.rect_border_radius ?? undefined
|
|
52
52
|
|
|
53
53
|
elementStrings.push(
|
|
54
|
-
`<smtpad ${commonAttrs.join(" ")}${solderMaskAttrs}${formatOptionalMmAttr("cornerRadius", cornerRadius)}${formatOptionalMmAttr("solderMaskMarginLeft", smtPad.soldermask_margin_left)}${formatOptionalMmAttr("solderMaskMarginTop", smtPad.soldermask_margin_top)}${formatOptionalMmAttr("solderMaskMarginRight", smtPad.soldermask_margin_right)}${formatOptionalMmAttr("solderMaskMarginBottom", smtPad.soldermask_margin_bottom)} width="${mmStr(smtPad.width ?? 0)}" height="${mmStr(smtPad.height ?? 0)}"${
|
|
54
|
+
`<smtpad ${commonAttrs.join(" ")}${solderMaskAttrs}${formatOptionalMmAttr("cornerRadius", cornerRadius)}${formatOptionalMmAttr("solderMaskMarginLeft", smtPad.soldermask_margin_left)}${formatOptionalMmAttr("solderMaskMarginTop", smtPad.soldermask_margin_top)}${formatOptionalMmAttr("solderMaskMarginRight", smtPad.soldermask_margin_right)}${formatOptionalMmAttr("solderMaskMarginBottom", smtPad.soldermask_margin_bottom)} width="${mmStr(smtPad.width ?? 0)}" height="${mmStr(smtPad.height ?? 0)}" ccwRotation={${smtPad.ccw_rotation ?? 0}} shape="rotated_rect" />`,
|
|
55
55
|
)
|
|
56
56
|
}
|
|
57
57
|
}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ test("test16 support pcb smtpad shapes", async () => {
|
|
|
16
16
|
footprint={<footprint>
|
|
17
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
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"
|
|
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" ccwRotation={45} shape="rotated_rect" />
|
|
20
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" />
|
|
21
21
|
<smtpad portHints={["5"]} pcbX="-2.4mm" pcbY="1.6mm" layer="top" coveredWithSolderMask={true} solderMaskMargin="0.07mm" width="2.2mm" height="0.9mm" radius="0.45mm" pcbRotation="30deg" shape="pill" />
|
|
22
22
|
</footprint>}
|
|
@@ -24,19 +24,12 @@ test("test16 support pcb smtpad shapes", async () => {
|
|
|
24
24
|
/>
|
|
25
25
|
)"
|
|
26
26
|
`)
|
|
27
|
-
expect(tscircuit).toContain(`
|
|
27
|
+
expect(tscircuit).toContain(`ccwRotation={45}`)
|
|
28
28
|
expect(tscircuit).toContain(`shape="rotated_rect"`)
|
|
29
29
|
expect(tscircuit).toContain(`pcbRotation="30deg"`)
|
|
30
30
|
|
|
31
|
-
// The generator emits pcbRotation for consistency, but the current smtpad
|
|
32
|
-
// runtime still expects ccwRotation for rotated_rect pads.
|
|
33
|
-
const executableTscircuit = tscircuit.replace(
|
|
34
|
-
/pcbRotation="(-?\d+(?:\.\d+)?)deg"(?=[^>]*shape="rotated_rect")/g,
|
|
35
|
-
(_, rotation: string) => `ccwRotation={${rotation}}`,
|
|
36
|
-
)
|
|
37
|
-
|
|
38
31
|
const renderedCircuitJson = (await runTscircuitCode(`
|
|
39
|
-
${
|
|
32
|
+
${tscircuit}
|
|
40
33
|
|
|
41
34
|
circuit.add(
|
|
42
35
|
<board width="20mm" height="20mm">
|
|
@@ -56,6 +49,7 @@ circuit.add(
|
|
|
56
49
|
port_hints: ["3"],
|
|
57
50
|
layer: "bottom",
|
|
58
51
|
shape: "rotated_rect",
|
|
52
|
+
ccw_rotation: 45,
|
|
59
53
|
corner_radius: 0.15,
|
|
60
54
|
is_covered_with_solder_mask: true,
|
|
61
55
|
soldermask_margin: 0.04,
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { convertCircuitJsonToTscircuit } from "lib"
|
|
3
|
+
|
|
4
|
+
test.failing("test21 silkscreen path props tsx", async () => {
|
|
5
|
+
const tscircuit = convertCircuitJsonToTscircuit(circuitJson, {
|
|
6
|
+
componentName: "Test21Component",
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
expect(tscircuit).toContain('layer="bottom"')
|
|
10
|
+
expect(tscircuit).toContain("strokeWidth={0.2}")
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const circuitJson: any = [
|
|
14
|
+
{
|
|
15
|
+
type: "source_component",
|
|
16
|
+
source_component_id: "generic_0",
|
|
17
|
+
supplier_part_numbers: {},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: "schematic_component",
|
|
21
|
+
schematic_component_id: "schematic_generic_component_0",
|
|
22
|
+
source_component_id: "generic_0",
|
|
23
|
+
center: {
|
|
24
|
+
x: 0,
|
|
25
|
+
y: 0,
|
|
26
|
+
},
|
|
27
|
+
rotation: 0,
|
|
28
|
+
size: {
|
|
29
|
+
width: 0,
|
|
30
|
+
height: 0,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: "pcb_component",
|
|
35
|
+
source_component_id: "generic_0",
|
|
36
|
+
pcb_component_id: "pcb_generic_component_0",
|
|
37
|
+
layer: "top",
|
|
38
|
+
center: {
|
|
39
|
+
x: 0,
|
|
40
|
+
y: 0,
|
|
41
|
+
},
|
|
42
|
+
rotation: 0,
|
|
43
|
+
width: 2,
|
|
44
|
+
height: 1,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: "pcb_silkscreen_path",
|
|
48
|
+
pcb_silkscreen_path_id: "pcb_silkscreen_path_0",
|
|
49
|
+
pcb_component_id: "pcb_generic_component_0",
|
|
50
|
+
layer: "bottom",
|
|
51
|
+
route: [
|
|
52
|
+
{ x: -1, y: 1.8 },
|
|
53
|
+
{ x: 1, y: 1.8 },
|
|
54
|
+
],
|
|
55
|
+
stroke_width: 0.2,
|
|
56
|
+
},
|
|
57
|
+
]
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import type { AnyCircuitElement } from "circuit-json"
|
|
3
|
+
import { convertCircuitJsonToTscircuit } from "lib"
|
|
4
|
+
import { runTscircuitCode } from "tscircuit"
|
|
5
|
+
|
|
6
|
+
test.failing(
|
|
7
|
+
"test22 silkscreen path props roundtrip",
|
|
8
|
+
async () => {
|
|
9
|
+
const tscircuit = convertCircuitJsonToTscircuit(circuitJson, {
|
|
10
|
+
componentName: "Test22Component",
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const renderedCircuitJson = (await runTscircuitCode(`
|
|
14
|
+
${tscircuit}
|
|
15
|
+
|
|
16
|
+
circuit.add(
|
|
17
|
+
<board width="20mm" height="20mm">
|
|
18
|
+
<Test22Component />
|
|
19
|
+
</board>,
|
|
20
|
+
)
|
|
21
|
+
`)) as AnyCircuitElement[]
|
|
22
|
+
|
|
23
|
+
const silkscreenPath = renderedCircuitJson.find(
|
|
24
|
+
(el) => el.type === "pcb_silkscreen_path",
|
|
25
|
+
) as any
|
|
26
|
+
|
|
27
|
+
expect(silkscreenPath).toBeDefined()
|
|
28
|
+
expect(silkscreenPath.layer).toBe("bottom")
|
|
29
|
+
expect(silkscreenPath.stroke_width).toBe(0.2)
|
|
30
|
+
},
|
|
31
|
+
15000,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
const circuitJson: any = [
|
|
35
|
+
{
|
|
36
|
+
type: "source_component",
|
|
37
|
+
source_component_id: "generic_0",
|
|
38
|
+
supplier_part_numbers: {},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: "schematic_component",
|
|
42
|
+
schematic_component_id: "schematic_generic_component_0",
|
|
43
|
+
source_component_id: "generic_0",
|
|
44
|
+
center: {
|
|
45
|
+
x: 0,
|
|
46
|
+
y: 0,
|
|
47
|
+
},
|
|
48
|
+
rotation: 0,
|
|
49
|
+
size: {
|
|
50
|
+
width: 0,
|
|
51
|
+
height: 0,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: "pcb_component",
|
|
56
|
+
source_component_id: "generic_0",
|
|
57
|
+
pcb_component_id: "pcb_generic_component_0",
|
|
58
|
+
layer: "top",
|
|
59
|
+
center: {
|
|
60
|
+
x: 0,
|
|
61
|
+
y: 0,
|
|
62
|
+
},
|
|
63
|
+
rotation: 0,
|
|
64
|
+
width: 2,
|
|
65
|
+
height: 1,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
type: "pcb_silkscreen_path",
|
|
69
|
+
pcb_silkscreen_path_id: "pcb_silkscreen_path_0",
|
|
70
|
+
pcb_component_id: "pcb_generic_component_0",
|
|
71
|
+
layer: "bottom",
|
|
72
|
+
route: [
|
|
73
|
+
{ x: -1, y: 1.8 },
|
|
74
|
+
{ x: 1, y: 1.8 },
|
|
75
|
+
],
|
|
76
|
+
stroke_width: 0.2,
|
|
77
|
+
},
|
|
78
|
+
]
|