circuit-json-to-tscircuit 0.0.55 → 0.0.56
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-NOSIW5HF.js → chunk-TJ74IBUO.js} +6 -2
- package/dist/cli/main.js +2 -2
- package/dist/lib/index.js +1 -1
- package/lib/generate-footprint-tsx/convert-silkscreen.ts +7 -2
- package/package.json +1 -1
- package/tests/silkscreen-rect-rotation.test.tsx +39 -0
- package/tests/ti-evms/__snapshots__/ti-drv8307evm-roundtrip-pcb-comparison.snap.svg +1 -1
- package/tests/ti-evms/__snapshots__/ti-lm251772evm-pd-roundtrip-pcb-comparison.snap.svg +1 -1
- package/tests/ti-evms/__snapshots__/ti-lm5155evm-fly-roundtrip-pcb-comparison.snap.svg +1 -1
- package/tests/ti-evms/__snapshots__/ti-lmg342x-bb-evm-roundtrip-pcb-comparison.snap.svg +1 -1
- package/tests/ti-evms/ti-drv8307evm-roundtrip.test.tsx +2 -2
- package/tests/ti-evms/ti-lm251772evm-pd-roundtrip.test.tsx +3 -3
- package/tests/ti-evms/ti-lm5155evm-fly-roundtrip.test.tsx +5 -5
- package/tests/ti-evms/ti-lmg342x-bb-evm-roundtrip.test.tsx +8 -8
|
@@ -465,7 +465,9 @@ var convertSilkscreen = (circuitJson) => {
|
|
|
465
465
|
`height={${silkscreenRect.height ?? 0}}`,
|
|
466
466
|
`layer="${silkscreenRect.layer}"`
|
|
467
467
|
];
|
|
468
|
-
if (silkscreenRect.
|
|
468
|
+
if (silkscreenRect.has_stroke === false) {
|
|
469
|
+
attrs.push("strokeWidth={0}");
|
|
470
|
+
} else if (silkscreenRect.stroke_width !== void 0) {
|
|
469
471
|
attrs.push(`strokeWidth={${silkscreenRect.stroke_width}}`);
|
|
470
472
|
}
|
|
471
473
|
if (silkscreenRect.is_filled !== void 0) {
|
|
@@ -474,7 +476,9 @@ var convertSilkscreen = (circuitJson) => {
|
|
|
474
476
|
if (silkscreenRect.corner_radius !== void 0) {
|
|
475
477
|
attrs.push(`cornerRadius={${silkscreenRect.corner_radius}}`);
|
|
476
478
|
}
|
|
477
|
-
elementStrings.push(
|
|
479
|
+
elementStrings.push(
|
|
480
|
+
`<silkscreenrect ${attrs.join(" ")}${formatPcbRotationAttr(silkscreenRect.ccw_rotation)} />`
|
|
481
|
+
);
|
|
478
482
|
}
|
|
479
483
|
for (const silkscreenCircle of silkscreenCircles) {
|
|
480
484
|
const center = silkscreenCircle.center ?? { x: 0, y: 0 };
|
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-TJ74IBUO.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.55",
|
|
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
|
@@ -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 convertSilkscreen: FootprintElementConverter = (circuitJson) => {
|
|
5
6
|
const silkscreenLines = su(circuitJson).pcb_silkscreen_line.list()
|
|
@@ -31,7 +32,9 @@ export const convertSilkscreen: FootprintElementConverter = (circuitJson) => {
|
|
|
31
32
|
`layer="${silkscreenRect.layer}"`,
|
|
32
33
|
]
|
|
33
34
|
|
|
34
|
-
if (silkscreenRect.
|
|
35
|
+
if (silkscreenRect.has_stroke === false) {
|
|
36
|
+
attrs.push("strokeWidth={0}")
|
|
37
|
+
} else if (silkscreenRect.stroke_width !== undefined) {
|
|
35
38
|
attrs.push(`strokeWidth={${silkscreenRect.stroke_width}}`)
|
|
36
39
|
}
|
|
37
40
|
if (silkscreenRect.is_filled !== undefined) {
|
|
@@ -41,7 +44,9 @@ export const convertSilkscreen: FootprintElementConverter = (circuitJson) => {
|
|
|
41
44
|
attrs.push(`cornerRadius={${silkscreenRect.corner_radius}}`)
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
elementStrings.push(
|
|
47
|
+
elementStrings.push(
|
|
48
|
+
`<silkscreenrect ${attrs.join(" ")}${formatPcbRotationAttr(silkscreenRect.ccw_rotation)} />`,
|
|
49
|
+
)
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
for (const silkscreenCircle of silkscreenCircles) {
|
package/package.json
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import type { CircuitJson } from "circuit-json"
|
|
3
|
+
import { convertCircuitJsonToTscircuit } from "lib"
|
|
4
|
+
import { runTscircuitCode } from "tscircuit"
|
|
5
|
+
|
|
6
|
+
for (const ccwRotationDegrees of [0, 90, 180, 270]) {
|
|
7
|
+
test(`preserves silkscreen rectangle orientation at ${ccwRotationDegrees} degrees`, async () => {
|
|
8
|
+
const circuitJson: CircuitJson = [
|
|
9
|
+
{
|
|
10
|
+
type: "pcb_silkscreen_rect",
|
|
11
|
+
pcb_silkscreen_rect_id: "polarity_bar",
|
|
12
|
+
pcb_component_id: "diode",
|
|
13
|
+
center: { x: 0, y: 0 },
|
|
14
|
+
width: 0.5,
|
|
15
|
+
height: 3,
|
|
16
|
+
layer: "top",
|
|
17
|
+
is_filled: true,
|
|
18
|
+
stroke_width: 0.1,
|
|
19
|
+
has_stroke: false,
|
|
20
|
+
ccw_rotation: ccwRotationDegrees,
|
|
21
|
+
},
|
|
22
|
+
]
|
|
23
|
+
const generatedTscircuit = convertCircuitJsonToTscircuit(circuitJson, {
|
|
24
|
+
componentName: "PolarityBar",
|
|
25
|
+
})
|
|
26
|
+
const renderedCircuitJson = (await runTscircuitCode(`
|
|
27
|
+
${generatedTscircuit}
|
|
28
|
+
circuit.add(<board width="10mm" height="10mm"><PolarityBar /></board>)
|
|
29
|
+
`)) as CircuitJson
|
|
30
|
+
const rectangle = renderedCircuitJson.find(
|
|
31
|
+
(element) => element.type === "pcb_silkscreen_rect",
|
|
32
|
+
)
|
|
33
|
+
const isQuarterTurn = ccwRotationDegrees % 180 === 90
|
|
34
|
+
expect(rectangle?.width).toBe(isQuarterTurn ? 3 : 0.5)
|
|
35
|
+
expect(rectangle?.height).toBe(isQuarterTurn ? 0.5 : 3)
|
|
36
|
+
expect(rectangle?.is_filled).toBe(true)
|
|
37
|
+
expect(rectangle?.stroke_width).toBe(0)
|
|
38
|
+
})
|
|
39
|
+
}
|