circuit-json-to-tscircuit 0.0.63 → 0.0.64
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-MVPNWU4R.js → chunk-KBH5O2WR.js} +45 -12
- package/dist/cli/main.js +2 -2
- package/dist/lib/index.js +1 -1
- package/lib/generate-board-schematic-tsx/convert-box-components.ts +46 -17
- package/package.json +1 -1
- 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 +276 -276
- 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 +106 -106
- 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 +118 -118
- package/tests/ti-evms/ti-lm251772evm-pd-roundtrip.test.tsx +37 -0
- package/tests/ti-evms/ti-lm5155evm-fly-roundtrip.test.tsx +48 -48
|
@@ -568,12 +568,13 @@ var convertSymbolPrimitives = ({
|
|
|
568
568
|
|
|
569
569
|
// lib/generate-board-schematic-tsx/convert-box-components.ts
|
|
570
570
|
import { su as su2 } from "@tscircuit/soup-util";
|
|
571
|
-
import
|
|
572
|
-
schematic_text as schematic_text3
|
|
573
|
-
} from "circuit-json";
|
|
571
|
+
import "circuit-json";
|
|
574
572
|
var DEFAULT_BOX_BODY_STROKE_WIDTH = 0.02;
|
|
575
573
|
var DEFAULT_BOX_BODY_STROKE_COLOR = "#840000";
|
|
576
574
|
var DEFAULT_BOX_BODY_FILL_COLOR = "#ffffc2";
|
|
575
|
+
var DEFAULT_PIN_TEXT_FONT_SIZE = 0.15;
|
|
576
|
+
var DEFAULT_PIN_LABEL_DISTANCE_FROM_EDGE = 0.1;
|
|
577
|
+
var DEFAULT_PIN_NUMBER_BASELINE_OFFSET = 0.02;
|
|
577
578
|
var convertBoxComponent = ({
|
|
578
579
|
circuitJson,
|
|
579
580
|
schematicComponent
|
|
@@ -618,25 +619,57 @@ var convertBoxComponent = ({
|
|
|
618
619
|
const sourcePort = su2(circuitJson).source_port.get(
|
|
619
620
|
schematicPort.source_port_id
|
|
620
621
|
);
|
|
621
|
-
const
|
|
622
|
+
const labelPosition = { ...edge };
|
|
623
|
+
const pinNumberPosition = {
|
|
624
|
+
x: (edge.x + schematicPort.center.x) / 2,
|
|
625
|
+
y: (edge.y + schematicPort.center.y) / 2
|
|
626
|
+
};
|
|
627
|
+
let anchor = "center";
|
|
628
|
+
let rotation = 0;
|
|
629
|
+
switch (schematicPort.side_of_component) {
|
|
630
|
+
case "left":
|
|
631
|
+
labelPosition.x += DEFAULT_PIN_LABEL_DISTANCE_FROM_EDGE;
|
|
632
|
+
pinNumberPosition.y += DEFAULT_PIN_NUMBER_BASELINE_OFFSET;
|
|
633
|
+
anchor = "center_left";
|
|
634
|
+
break;
|
|
635
|
+
case "right":
|
|
636
|
+
labelPosition.x -= DEFAULT_PIN_LABEL_DISTANCE_FROM_EDGE;
|
|
637
|
+
pinNumberPosition.y += DEFAULT_PIN_NUMBER_BASELINE_OFFSET;
|
|
638
|
+
anchor = "center_right";
|
|
639
|
+
break;
|
|
640
|
+
case "top":
|
|
641
|
+
labelPosition.y -= DEFAULT_PIN_LABEL_DISTANCE_FROM_EDGE;
|
|
642
|
+
pinNumberPosition.x -= DEFAULT_PIN_NUMBER_BASELINE_OFFSET;
|
|
643
|
+
anchor = "center_right";
|
|
644
|
+
rotation = -90;
|
|
645
|
+
break;
|
|
646
|
+
case "bottom":
|
|
647
|
+
labelPosition.y += DEFAULT_PIN_LABEL_DISTANCE_FROM_EDGE;
|
|
648
|
+
pinNumberPosition.x -= DEFAULT_PIN_NUMBER_BASELINE_OFFSET;
|
|
649
|
+
anchor = "center_left";
|
|
650
|
+
rotation = -90;
|
|
651
|
+
break;
|
|
652
|
+
}
|
|
622
653
|
if (sourcePort?.name)
|
|
623
654
|
primitives.push(
|
|
624
655
|
formatElement("schematictext", {
|
|
625
656
|
text: sourcePort.name,
|
|
626
|
-
schX:
|
|
627
|
-
schY:
|
|
657
|
+
schX: labelPosition.x,
|
|
658
|
+
schY: labelPosition.y,
|
|
628
659
|
anchor,
|
|
629
|
-
fontSize:
|
|
660
|
+
fontSize: DEFAULT_PIN_TEXT_FONT_SIZE,
|
|
661
|
+
schRotation: rotation || void 0
|
|
630
662
|
})
|
|
631
663
|
);
|
|
632
664
|
if (schematicPort.pin_number !== void 0)
|
|
633
665
|
primitives.push(
|
|
634
666
|
formatElement("schematictext", {
|
|
635
667
|
text: String(schematicPort.pin_number),
|
|
636
|
-
schX:
|
|
637
|
-
schY:
|
|
668
|
+
schX: pinNumberPosition.x,
|
|
669
|
+
schY: pinNumberPosition.y,
|
|
638
670
|
anchor: "bottom_center",
|
|
639
|
-
fontSize:
|
|
671
|
+
fontSize: DEFAULT_PIN_TEXT_FONT_SIZE,
|
|
672
|
+
schRotation: rotation || void 0
|
|
640
673
|
})
|
|
641
674
|
);
|
|
642
675
|
}
|
|
@@ -672,7 +705,7 @@ var convertComponents = (circuitJson) => su3(circuitJson).schematic_component.li
|
|
|
672
705
|
|
|
673
706
|
// lib/generate-board-schematic-tsx/convert-net-labels.ts
|
|
674
707
|
import { su as su4 } from "@tscircuit/soup-util";
|
|
675
|
-
import { schematic_text as
|
|
708
|
+
import { schematic_text as schematic_text3 } from "circuit-json";
|
|
676
709
|
import { symbols as symbols2 } from "schematic-symbols";
|
|
677
710
|
import { translate as translate3 } from "transformation-matrix";
|
|
678
711
|
var convertNetLabels = (circuitJson) => su4(circuitJson).schematic_net_label.list().flatMap((schematicNetLabel) => {
|
|
@@ -696,7 +729,7 @@ var convertNetLabels = (circuitJson) => su4(circuitJson).schematic_net_label.lis
|
|
|
696
729
|
text: schematicNetLabel.text,
|
|
697
730
|
schX: anchorPosition.x,
|
|
698
731
|
schY: anchorPosition.y,
|
|
699
|
-
fontSize:
|
|
732
|
+
fontSize: schematic_text3.shape.font_size.parse(void 0)
|
|
700
733
|
})
|
|
701
734
|
];
|
|
702
735
|
});
|
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-KBH5O2WR.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.63",
|
|
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,9 +1,5 @@
|
|
|
1
1
|
import { su } from "@tscircuit/soup-util"
|
|
2
|
-
import {
|
|
3
|
-
schematic_text,
|
|
4
|
-
type AnyCircuitElement,
|
|
5
|
-
type SchematicComponent,
|
|
6
|
-
} from "circuit-json"
|
|
2
|
+
import { type AnyCircuitElement, type SchematicComponent } from "circuit-json"
|
|
7
3
|
import { convertRect } from "./convert-rect"
|
|
8
4
|
import { formatElement } from "./format-attributes"
|
|
9
5
|
|
|
@@ -13,6 +9,12 @@ const DEFAULT_BOX_BODY_STROKE_WIDTH = 0.02
|
|
|
13
9
|
const DEFAULT_BOX_BODY_STROKE_COLOR = "#840000"
|
|
14
10
|
const DEFAULT_BOX_BODY_FILL_COLOR = "#ffffc2"
|
|
15
11
|
|
|
12
|
+
// Circuit JSON does not encode these presentation values. They mirror the
|
|
13
|
+
// circuit-to-svg defaults so reconstructed box pins keep the compiled view.
|
|
14
|
+
const DEFAULT_PIN_TEXT_FONT_SIZE = 0.15
|
|
15
|
+
const DEFAULT_PIN_LABEL_DISTANCE_FROM_EDGE = 0.1
|
|
16
|
+
const DEFAULT_PIN_NUMBER_BASELINE_OFFSET = 0.02
|
|
17
|
+
|
|
16
18
|
export const convertBoxComponent = ({
|
|
17
19
|
circuitJson,
|
|
18
20
|
schematicComponent,
|
|
@@ -62,30 +64,57 @@ export const convertBoxComponent = ({
|
|
|
62
64
|
const sourcePort = su(circuitJson).source_port.get(
|
|
63
65
|
schematicPort.source_port_id,
|
|
64
66
|
)
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
const labelPosition = { ...edge }
|
|
68
|
+
const pinNumberPosition = {
|
|
69
|
+
x: (edge.x + schematicPort.center.x) / 2,
|
|
70
|
+
y: (edge.y + schematicPort.center.y) / 2,
|
|
71
|
+
}
|
|
72
|
+
let anchor = "center"
|
|
73
|
+
let rotation = 0
|
|
74
|
+
switch (schematicPort.side_of_component) {
|
|
75
|
+
case "left":
|
|
76
|
+
labelPosition.x += DEFAULT_PIN_LABEL_DISTANCE_FROM_EDGE
|
|
77
|
+
pinNumberPosition.y += DEFAULT_PIN_NUMBER_BASELINE_OFFSET
|
|
78
|
+
anchor = "center_left"
|
|
79
|
+
break
|
|
80
|
+
case "right":
|
|
81
|
+
labelPosition.x -= DEFAULT_PIN_LABEL_DISTANCE_FROM_EDGE
|
|
82
|
+
pinNumberPosition.y += DEFAULT_PIN_NUMBER_BASELINE_OFFSET
|
|
83
|
+
anchor = "center_right"
|
|
84
|
+
break
|
|
85
|
+
case "top":
|
|
86
|
+
labelPosition.y -= DEFAULT_PIN_LABEL_DISTANCE_FROM_EDGE
|
|
87
|
+
pinNumberPosition.x -= DEFAULT_PIN_NUMBER_BASELINE_OFFSET
|
|
88
|
+
anchor = "center_right"
|
|
89
|
+
rotation = -90
|
|
90
|
+
break
|
|
91
|
+
case "bottom":
|
|
92
|
+
labelPosition.y += DEFAULT_PIN_LABEL_DISTANCE_FROM_EDGE
|
|
93
|
+
pinNumberPosition.x -= DEFAULT_PIN_NUMBER_BASELINE_OFFSET
|
|
94
|
+
anchor = "center_left"
|
|
95
|
+
rotation = -90
|
|
96
|
+
break
|
|
97
|
+
}
|
|
71
98
|
if (sourcePort?.name)
|
|
72
99
|
primitives.push(
|
|
73
100
|
formatElement("schematictext", {
|
|
74
101
|
text: sourcePort.name,
|
|
75
|
-
schX:
|
|
76
|
-
schY:
|
|
102
|
+
schX: labelPosition.x,
|
|
103
|
+
schY: labelPosition.y,
|
|
77
104
|
anchor,
|
|
78
|
-
fontSize:
|
|
105
|
+
fontSize: DEFAULT_PIN_TEXT_FONT_SIZE,
|
|
106
|
+
schRotation: rotation || undefined,
|
|
79
107
|
}),
|
|
80
108
|
)
|
|
81
109
|
if (schematicPort.pin_number !== undefined)
|
|
82
110
|
primitives.push(
|
|
83
111
|
formatElement("schematictext", {
|
|
84
112
|
text: String(schematicPort.pin_number),
|
|
85
|
-
schX:
|
|
86
|
-
schY:
|
|
113
|
+
schX: pinNumberPosition.x,
|
|
114
|
+
schY: pinNumberPosition.y,
|
|
87
115
|
anchor: "bottom_center",
|
|
88
|
-
fontSize:
|
|
116
|
+
fontSize: DEFAULT_PIN_TEXT_FONT_SIZE,
|
|
117
|
+
schRotation: rotation || undefined,
|
|
89
118
|
}),
|
|
90
119
|
)
|
|
91
120
|
}
|