circuit-json-to-tscircuit 0.0.65 → 0.0.67
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-BEFEQ6FB.js → chunk-GKTUIZ42.js} +6 -4
- package/dist/cli/main.js +2 -2
- package/dist/lib/index.js +1 -1
- package/lib/generate-board-schematic-tsx/convert-box-components.ts +3 -2
- package/lib/generate-board-schematic-tsx/convert-traces.ts +3 -2
- package/package.json +1 -1
- package/tests/__snapshots__/test22-preserve-board-schematic-schematic.snap.svg +1 -1
- package/tests/board-schematic-pin-display-label.test.tsx +60 -0
- package/tests/board-schematic-trace-junction.test.tsx +3 -0
- package/tests/ti-evms/__snapshots__/ti-drv8307evm-roundtrip-schematic-comparison.snap.svg +1 -1
- package/tests/ti-evms/__snapshots__/ti-drv8307evm-roundtrip.test.tsx.snap +109 -109
- package/tests/ti-evms/__snapshots__/ti-lm251772evm-pd-roundtrip-schematic-comparison.snap.svg +1 -1
- package/tests/ti-evms/__snapshots__/ti-lm251772evm-pd-roundtrip.test.tsx.snap +168 -168
- package/tests/ti-evms/__snapshots__/ti-lm5155evm-fly-roundtrip-schematic-comparison.snap.svg +1 -1
- package/tests/ti-evms/__snapshots__/ti-lmg342x-bb-evm-roundtrip-schematic-comparison.snap.svg +1 -1
- package/tests/ti-evms/__snapshots__/ti-lmg342x-bb-evm-roundtrip.test.tsx.snap +81 -81
- package/tests/ti-evms/ti-lm5155evm-fly-roundtrip.test.tsx +95 -95
|
@@ -650,10 +650,11 @@ var convertBoxComponent = ({
|
|
|
650
650
|
rotation = -90;
|
|
651
651
|
break;
|
|
652
652
|
}
|
|
653
|
-
|
|
653
|
+
const displayPinLabel = schematicPort.display_pin_label ?? sourcePort?.name;
|
|
654
|
+
if (displayPinLabel)
|
|
654
655
|
primitives.push(
|
|
655
656
|
formatElement("schematictext", {
|
|
656
|
-
text:
|
|
657
|
+
text: displayPinLabel,
|
|
657
658
|
schX: labelPosition.x,
|
|
658
659
|
schY: labelPosition.y,
|
|
659
660
|
anchor,
|
|
@@ -748,8 +749,9 @@ var convertTraces = (circuitJson) => su5(circuitJson).schematic_trace.list().fla
|
|
|
748
749
|
(center) => formatElement("schematiccircle", {
|
|
749
750
|
center,
|
|
750
751
|
radius: 0.03,
|
|
751
|
-
|
|
752
|
-
|
|
752
|
+
strokeWidth: 0,
|
|
753
|
+
color: "#009600",
|
|
754
|
+
fillColor: "#009600",
|
|
753
755
|
isFilled: true
|
|
754
756
|
})
|
|
755
757
|
)
|
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-GKTUIZ42.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.66",
|
|
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
|
@@ -95,10 +95,11 @@ export const convertBoxComponent = ({
|
|
|
95
95
|
rotation = -90
|
|
96
96
|
break
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
const displayPinLabel = schematicPort.display_pin_label ?? sourcePort?.name
|
|
99
|
+
if (displayPinLabel)
|
|
99
100
|
primitives.push(
|
|
100
101
|
formatElement("schematictext", {
|
|
101
|
-
text:
|
|
102
|
+
text: displayPinLabel,
|
|
102
103
|
schX: labelPosition.x,
|
|
103
104
|
schY: labelPosition.y,
|
|
104
105
|
anchor,
|
|
@@ -18,8 +18,9 @@ export const convertTraces: SchematicElementConverter = (circuitJson) =>
|
|
|
18
18
|
formatElement("schematiccircle", {
|
|
19
19
|
center,
|
|
20
20
|
radius: 0.03,
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
strokeWidth: 0,
|
|
22
|
+
color: "#009600",
|
|
23
|
+
fillColor: "#009600",
|
|
23
24
|
isFilled: true,
|
|
24
25
|
}),
|
|
25
26
|
),
|
package/package.json
CHANGED
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
.pin-number { fill: rgb(169, 0, 0); }
|
|
23
23
|
.port-label { fill: rgb(0, 100, 100); }
|
|
24
24
|
.component-name { fill: rgb(0, 100, 100); }
|
|
25
|
-
</style><rect class="boundary" x="0" y="0" width="1200" height="600"/><circle cx="567.7065134203" cy="373.29972421080004" r="1.937609194779" fill="#
|
|
25
|
+
</style><rect class="boundary" x="0" y="0" width="1200" height="600"/><circle cx="567.7065134203" cy="373.29972421080004" r="1.937609194779" fill="#009600" stroke="#009600" stroke-width="0" data-schematic-circle-id="schematic_circle_0"/><path d="M 632.2934865796 405.59321079045003 L 761.4674328982001 405.59321079045003 L 761.4674328982001 211.83229131255 L 632.2934865796 211.83229131255 L 632.2934865796 405.59321079045003" stroke="#840000" stroke-width="1.291739463186" fill="#ffffc2" stroke-linecap="round" stroke-linejoin="round"/><path d="M 438.5325671017 373.29972421080004 L 567.7065134203 373.29972421080004" stroke="#009600" stroke-width="1.291739463186" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M 567.7065134203 373.29972421080004 L 567.7065134203 567.0606436887" stroke="#009600" stroke-width="1.291739463186" fill="none" stroke-linecap="round" stroke-linejoin="round"/><text x="632.2934865796" y="179.53880473290002" fill="#000000" text-anchor="start" dominant-baseline="ideographic" font-family="sans-serif" font-size="12.91739463186px" transform="rotate(90, 632.2934865796, 179.53880473290002)">U1 "controller" {flyback}</text></svg>
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
test("uses the schematic port display label for imported box pins", async () => {
|
|
7
|
+
const circuitJson: CircuitJson = [
|
|
8
|
+
{
|
|
9
|
+
type: "pcb_board",
|
|
10
|
+
pcb_board_id: "board",
|
|
11
|
+
center: { x: 0, y: 0 },
|
|
12
|
+
width: 10,
|
|
13
|
+
height: 10,
|
|
14
|
+
num_layers: 2,
|
|
15
|
+
thickness: 1.6,
|
|
16
|
+
material: "fr4",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: "source_component",
|
|
20
|
+
source_component_id: "controller",
|
|
21
|
+
name: "U1",
|
|
22
|
+
ftype: "simple_chip",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: "source_port",
|
|
26
|
+
source_port_id: "feedback",
|
|
27
|
+
name: "FB/I\\N\\T\\",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: "schematic_component",
|
|
31
|
+
schematic_component_id: "controller_symbol",
|
|
32
|
+
source_component_id: "controller",
|
|
33
|
+
center: { x: 0, y: 0 },
|
|
34
|
+
size: { width: 2, height: 2 },
|
|
35
|
+
is_box_with_pins: true,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: "schematic_port",
|
|
39
|
+
schematic_port_id: "feedback_pin",
|
|
40
|
+
schematic_component_id: "controller_symbol",
|
|
41
|
+
source_port_id: "feedback",
|
|
42
|
+
center: { x: 1.4, y: 0 },
|
|
43
|
+
side_of_component: "right",
|
|
44
|
+
facing_direction: "right",
|
|
45
|
+
pin_number: 1,
|
|
46
|
+
display_pin_label: "FB/INT",
|
|
47
|
+
},
|
|
48
|
+
]
|
|
49
|
+
const renderedCircuitJson = await runTscircuitCode(
|
|
50
|
+
convertCircuitJsonToTscircuit(circuitJson, {
|
|
51
|
+
componentName: "PinLabelBoard",
|
|
52
|
+
}),
|
|
53
|
+
)
|
|
54
|
+
const text = renderedCircuitJson
|
|
55
|
+
.filter((element) => element.type === "schematic_text")
|
|
56
|
+
.map((element) => element.text)
|
|
57
|
+
|
|
58
|
+
expect(text).toContain("FB/INT")
|
|
59
|
+
expect(text).not.toContain("FB/I\\N\\T\\")
|
|
60
|
+
})
|
|
@@ -39,6 +39,9 @@ test("preserves board schematic trace junction markers", async () => {
|
|
|
39
39
|
element.center.x === 0 &&
|
|
40
40
|
element.center.y === 0 &&
|
|
41
41
|
element.radius === 0.03 &&
|
|
42
|
+
element.stroke_width === 0 &&
|
|
43
|
+
element.color === "#009600" &&
|
|
44
|
+
element.fill_color === "#009600" &&
|
|
42
45
|
element.is_filled,
|
|
43
46
|
),
|
|
44
47
|
).toBe(true)
|