@tscircuit/circuit-json-util 0.0.72 → 0.0.74
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/index.d.ts +3807 -211
- package/dist/index.js +20 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -860,6 +860,15 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
860
860
|
});
|
|
861
861
|
elm.x = x;
|
|
862
862
|
elm.y = y;
|
|
863
|
+
if (elm.type === "pcb_smtpad" && elm.shape === "polygon" && Array.isArray(elm.points)) {
|
|
864
|
+
elm.points = elm.points.map((point) => {
|
|
865
|
+
const tp = applyToPoint(matrix, { x: point.x, y: point.y });
|
|
866
|
+
return {
|
|
867
|
+
x: tp.x,
|
|
868
|
+
y: tp.y
|
|
869
|
+
};
|
|
870
|
+
});
|
|
871
|
+
}
|
|
863
872
|
} else if (elm.type === "pcb_keepout" || elm.type === "pcb_board") {
|
|
864
873
|
elm.center = applyToPoint(matrix, elm.center);
|
|
865
874
|
} else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text") {
|
|
@@ -1041,7 +1050,7 @@ function getReadableNameForPcbTrace(soup, pcb_trace_id) {
|
|
|
1041
1050
|
function getComponentAndPortInfo(pcb_port_id) {
|
|
1042
1051
|
const pcbPort = cju(soup).pcb_port.get(pcb_port_id);
|
|
1043
1052
|
if (!pcbPort) return null;
|
|
1044
|
-
const pcbComponent = cju(soup).pcb_component.get(pcbPort.pcb_component_id);
|
|
1053
|
+
const pcbComponent = pcbPort.pcb_component_id ? cju(soup).pcb_component.get(pcbPort.pcb_component_id) : void 0;
|
|
1045
1054
|
if (!pcbComponent) return null;
|
|
1046
1055
|
const sourceComponent = cju(soup).source_component.get(
|
|
1047
1056
|
pcbComponent.source_component_id
|
|
@@ -1070,7 +1079,7 @@ var getReadableNameForPcbPort = (soup, pcb_port_id) => {
|
|
|
1070
1079
|
if (!pcbPort) {
|
|
1071
1080
|
return `pcb_port[#${pcb_port_id}]`;
|
|
1072
1081
|
}
|
|
1073
|
-
const pcbComponent = cju(soup).pcb_component.get(pcbPort
|
|
1082
|
+
const pcbComponent = pcbPort.pcb_component_id ? cju(soup).pcb_component.get(pcbPort.pcb_component_id) : void 0;
|
|
1074
1083
|
if (!pcbComponent) {
|
|
1075
1084
|
return `pcb_port[#${pcb_port_id}]`;
|
|
1076
1085
|
}
|
|
@@ -1133,6 +1142,15 @@ var getBoundsOfPcbElements = (elements) => {
|
|
|
1133
1142
|
let maxY = Number.NEGATIVE_INFINITY;
|
|
1134
1143
|
for (const elm of elements) {
|
|
1135
1144
|
if (!elm.type.startsWith("pcb_")) continue;
|
|
1145
|
+
if (elm.type === "pcb_smtpad" && elm.shape === "polygon" && Array.isArray(elm.points)) {
|
|
1146
|
+
for (const point of elm.points) {
|
|
1147
|
+
minX = Math.min(minX, point.x);
|
|
1148
|
+
minY = Math.min(minY, point.y);
|
|
1149
|
+
maxX = Math.max(maxX, point.x);
|
|
1150
|
+
maxY = Math.max(maxY, point.y);
|
|
1151
|
+
}
|
|
1152
|
+
continue;
|
|
1153
|
+
}
|
|
1136
1154
|
let centerX;
|
|
1137
1155
|
let centerY;
|
|
1138
1156
|
let width;
|