circuit-json-to-tscircuit 0.0.67 → 0.0.69
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-GKTUIZ42.js → chunk-7VW2746G.js} +6 -1
- 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 -0
- package/package.json +1 -1
- package/tests/board-schematic-box-pin-line-styling.test.tsx +56 -0
- package/tests/board-schematic-box-pin-text-color.test.tsx +54 -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 +414 -414
- 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 +159 -159
- 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 +177 -177
- package/tests/ti-evms/ti-lm5155evm-fly-roundtrip.test.tsx +72 -72
|
@@ -573,6 +573,7 @@ var DEFAULT_BOX_BODY_STROKE_WIDTH = 0.02;
|
|
|
573
573
|
var DEFAULT_BOX_BODY_STROKE_COLOR = "#840000";
|
|
574
574
|
var DEFAULT_BOX_BODY_FILL_COLOR = "#ffffc2";
|
|
575
575
|
var DEFAULT_PIN_TEXT_FONT_SIZE = 0.15;
|
|
576
|
+
var DEFAULT_PIN_TEXT_COLOR = "#a90000";
|
|
576
577
|
var DEFAULT_PIN_LABEL_DISTANCE_FROM_EDGE = 0.1;
|
|
577
578
|
var DEFAULT_PIN_NUMBER_BASELINE_OFFSET = 0.02;
|
|
578
579
|
var convertBoxComponent = ({
|
|
@@ -613,7 +614,9 @@ var convertBoxComponent = ({
|
|
|
613
614
|
x1: edge.x,
|
|
614
615
|
y1: edge.y,
|
|
615
616
|
x2: schematicPort.center.x,
|
|
616
|
-
y2: schematicPort.center.y
|
|
617
|
+
y2: schematicPort.center.y,
|
|
618
|
+
strokeWidth: DEFAULT_BOX_BODY_STROKE_WIDTH,
|
|
619
|
+
color: DEFAULT_BOX_BODY_STROKE_COLOR
|
|
617
620
|
})
|
|
618
621
|
);
|
|
619
622
|
const sourcePort = su2(circuitJson).source_port.get(
|
|
@@ -659,6 +662,7 @@ var convertBoxComponent = ({
|
|
|
659
662
|
schY: labelPosition.y,
|
|
660
663
|
anchor,
|
|
661
664
|
fontSize: DEFAULT_PIN_TEXT_FONT_SIZE,
|
|
665
|
+
color: DEFAULT_PIN_TEXT_COLOR,
|
|
662
666
|
schRotation: rotation || void 0
|
|
663
667
|
})
|
|
664
668
|
);
|
|
@@ -670,6 +674,7 @@ var convertBoxComponent = ({
|
|
|
670
674
|
schY: pinNumberPosition.y,
|
|
671
675
|
anchor: "bottom_center",
|
|
672
676
|
fontSize: DEFAULT_PIN_TEXT_FONT_SIZE,
|
|
677
|
+
color: DEFAULT_PIN_TEXT_COLOR,
|
|
673
678
|
schRotation: rotation || void 0
|
|
674
679
|
})
|
|
675
680
|
);
|
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-7VW2746G.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.68",
|
|
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
|
@@ -12,6 +12,7 @@ const DEFAULT_BOX_BODY_FILL_COLOR = "#ffffc2"
|
|
|
12
12
|
// Circuit JSON does not encode these presentation values. They mirror the
|
|
13
13
|
// circuit-to-svg defaults so reconstructed box pins keep the compiled view.
|
|
14
14
|
const DEFAULT_PIN_TEXT_FONT_SIZE = 0.15
|
|
15
|
+
const DEFAULT_PIN_TEXT_COLOR = "#a90000"
|
|
15
16
|
const DEFAULT_PIN_LABEL_DISTANCE_FROM_EDGE = 0.1
|
|
16
17
|
const DEFAULT_PIN_NUMBER_BASELINE_OFFSET = 0.02
|
|
17
18
|
|
|
@@ -59,6 +60,8 @@ export const convertBoxComponent = ({
|
|
|
59
60
|
y1: edge.y,
|
|
60
61
|
x2: schematicPort.center.x,
|
|
61
62
|
y2: schematicPort.center.y,
|
|
63
|
+
strokeWidth: DEFAULT_BOX_BODY_STROKE_WIDTH,
|
|
64
|
+
color: DEFAULT_BOX_BODY_STROKE_COLOR,
|
|
62
65
|
}),
|
|
63
66
|
)
|
|
64
67
|
const sourcePort = su(circuitJson).source_port.get(
|
|
@@ -104,6 +107,7 @@ export const convertBoxComponent = ({
|
|
|
104
107
|
schY: labelPosition.y,
|
|
105
108
|
anchor,
|
|
106
109
|
fontSize: DEFAULT_PIN_TEXT_FONT_SIZE,
|
|
110
|
+
color: DEFAULT_PIN_TEXT_COLOR,
|
|
107
111
|
schRotation: rotation || undefined,
|
|
108
112
|
}),
|
|
109
113
|
)
|
|
@@ -115,6 +119,7 @@ export const convertBoxComponent = ({
|
|
|
115
119
|
schY: pinNumberPosition.y,
|
|
116
120
|
anchor: "bottom_center",
|
|
117
121
|
fontSize: DEFAULT_PIN_TEXT_FONT_SIZE,
|
|
122
|
+
color: DEFAULT_PIN_TEXT_COLOR,
|
|
118
123
|
schRotation: rotation || undefined,
|
|
119
124
|
}),
|
|
120
125
|
)
|
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,54 @@
|
|
|
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 compiled schematic color for box pin text", 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: "source_port",
|
|
27
|
+
source_port_id: "feedback_source",
|
|
28
|
+
name: "FB",
|
|
29
|
+
pin_number: 1,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: "schematic_port",
|
|
33
|
+
schematic_port_id: "feedback",
|
|
34
|
+
source_port_id: "feedback_source",
|
|
35
|
+
schematic_component_id: "controller",
|
|
36
|
+
center: { x: -1.4, y: 0 },
|
|
37
|
+
distance_from_component_edge: 0.4,
|
|
38
|
+
side_of_component: "left",
|
|
39
|
+
facing_direction: "left",
|
|
40
|
+
pin_number: 1,
|
|
41
|
+
},
|
|
42
|
+
]
|
|
43
|
+
const renderedCircuitJson = await runTscircuitCode(
|
|
44
|
+
convertCircuitJsonToTscircuit(circuitJson, {
|
|
45
|
+
componentName: "ImportedController",
|
|
46
|
+
}),
|
|
47
|
+
)
|
|
48
|
+
const pinTexts = renderedCircuitJson
|
|
49
|
+
.filter((element) => element.type === "schematic_text")
|
|
50
|
+
.filter((element) => element.text === "FB" || element.text === "1")
|
|
51
|
+
|
|
52
|
+
expect(pinTexts).toHaveLength(2)
|
|
53
|
+
expect(pinTexts.every((text) => text.color === "#a90000")).toBe(true)
|
|
54
|
+
})
|