circuit-json-to-tscircuit 0.0.66 → 0.0.68
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-3AKANUWD.js → chunk-KCSCUJOW.js} +6 -3
- package/dist/cli/main.js +2 -2
- package/dist/lib/index.js +1 -1
- package/lib/generate-board-schematic-tsx/convert-box-components.ts +5 -2
- package/package.json +1 -1
- package/tests/board-schematic-box-pin-line-styling.test.tsx +56 -0
- package/tests/board-schematic-pin-display-label.test.tsx +60 -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 +179 -179
- 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 +56 -56
- 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 +61 -61
- package/tests/ti-evms/ti-lm5155evm-fly-roundtrip.test.tsx +24 -24
|
@@ -613,7 +613,9 @@ var convertBoxComponent = ({
|
|
|
613
613
|
x1: edge.x,
|
|
614
614
|
y1: edge.y,
|
|
615
615
|
x2: schematicPort.center.x,
|
|
616
|
-
y2: schematicPort.center.y
|
|
616
|
+
y2: schematicPort.center.y,
|
|
617
|
+
strokeWidth: DEFAULT_BOX_BODY_STROKE_WIDTH,
|
|
618
|
+
color: DEFAULT_BOX_BODY_STROKE_COLOR
|
|
617
619
|
})
|
|
618
620
|
);
|
|
619
621
|
const sourcePort = su2(circuitJson).source_port.get(
|
|
@@ -650,10 +652,11 @@ var convertBoxComponent = ({
|
|
|
650
652
|
rotation = -90;
|
|
651
653
|
break;
|
|
652
654
|
}
|
|
653
|
-
|
|
655
|
+
const displayPinLabel = schematicPort.display_pin_label ?? sourcePort?.name;
|
|
656
|
+
if (displayPinLabel)
|
|
654
657
|
primitives.push(
|
|
655
658
|
formatElement("schematictext", {
|
|
656
|
-
text:
|
|
659
|
+
text: displayPinLabel,
|
|
657
660
|
schX: labelPosition.x,
|
|
658
661
|
schY: labelPosition.y,
|
|
659
662
|
anchor,
|
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-KCSCUJOW.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.67",
|
|
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
|
@@ -59,6 +59,8 @@ export const convertBoxComponent = ({
|
|
|
59
59
|
y1: edge.y,
|
|
60
60
|
x2: schematicPort.center.x,
|
|
61
61
|
y2: schematicPort.center.y,
|
|
62
|
+
strokeWidth: DEFAULT_BOX_BODY_STROKE_WIDTH,
|
|
63
|
+
color: DEFAULT_BOX_BODY_STROKE_COLOR,
|
|
62
64
|
}),
|
|
63
65
|
)
|
|
64
66
|
const sourcePort = su(circuitJson).source_port.get(
|
|
@@ -95,10 +97,11 @@ export const convertBoxComponent = ({
|
|
|
95
97
|
rotation = -90
|
|
96
98
|
break
|
|
97
99
|
}
|
|
98
|
-
|
|
100
|
+
const displayPinLabel = schematicPort.display_pin_label ?? sourcePort?.name
|
|
101
|
+
if (displayPinLabel)
|
|
99
102
|
primitives.push(
|
|
100
103
|
formatElement("schematictext", {
|
|
101
|
-
text:
|
|
104
|
+
text: displayPinLabel,
|
|
102
105
|
schX: labelPosition.x,
|
|
103
106
|
schY: labelPosition.y,
|
|
104
107
|
anchor,
|
package/package.json
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
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 compiled schematic styling for box pin lines", 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: "schematic_component",
|
|
20
|
+
schematic_component_id: "controller",
|
|
21
|
+
center: { x: 0, y: 0 },
|
|
22
|
+
size: { width: 2, height: 1 },
|
|
23
|
+
is_box_with_pins: true,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: "schematic_port",
|
|
27
|
+
schematic_port_id: "feedback",
|
|
28
|
+
source_port_id: "feedback_source",
|
|
29
|
+
schematic_component_id: "controller",
|
|
30
|
+
center: { x: -1.4, y: 0 },
|
|
31
|
+
distance_from_component_edge: 0.4,
|
|
32
|
+
side_of_component: "left",
|
|
33
|
+
facing_direction: "left",
|
|
34
|
+
display_pin_label: "FB",
|
|
35
|
+
pin_number: 1,
|
|
36
|
+
},
|
|
37
|
+
]
|
|
38
|
+
const renderedCircuitJson = await runTscircuitCode(
|
|
39
|
+
convertCircuitJsonToTscircuit(circuitJson, {
|
|
40
|
+
componentName: "ImportedController",
|
|
41
|
+
}),
|
|
42
|
+
)
|
|
43
|
+
const pinLine = renderedCircuitJson.find(
|
|
44
|
+
(element) =>
|
|
45
|
+
element.type === "schematic_line" &&
|
|
46
|
+
element.x1 === -1 &&
|
|
47
|
+
element.y1 === 0 &&
|
|
48
|
+
element.x2 === -1.4 &&
|
|
49
|
+
element.y2 === 0,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
expect(pinLine).toMatchObject({
|
|
53
|
+
stroke_width: 0.02,
|
|
54
|
+
color: "#840000",
|
|
55
|
+
})
|
|
56
|
+
})
|
|
@@ -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
|
+
})
|