@tscircuit/circuit-json-util 0.0.131 → 0.0.132

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as circuit_json from 'circuit-json';
2
- import { AnyCircuitElementInput, AnyCircuitElement, InsertionDirection, PcbSolderPasteRect, PcbSolderPasteRotatedRect, PcbBoard, SchematicComponent, SchematicNetLabel, SchematicTrace, SourceGroup, SourceComponentBase, PcbRenderLayer, PcbVia, PcbPin1Location, Point as Point$2, PcbPlatedHole, PcbCopperPour, PcbSmtPad } from 'circuit-json';
2
+ import { AnyCircuitElementInput, AnyCircuitElement, InsertionDirection, PcbSolderPasteRect, PcbSolderPasteRotatedRect, PcbSolderPastePill, PcbSolderPasteRotatedPill, PcbBoard, SchematicComponent, SchematicNetLabel, SchematicTrace, SourceGroup, SourceComponentBase, PcbRenderLayer, PcbVia, PcbPin1Location, Point as Point$2, PcbPlatedHole, PcbCopperPour, PcbSmtPad } from 'circuit-json';
3
3
  import * as zod from 'zod';
4
4
  import { Matrix } from 'transformation-matrix';
5
5
  import * as parsel from 'parsel-js';
@@ -13231,35 +13231,6 @@ declare const transformPCBElement: (elm: AnyCircuitElement, matrix: Matrix) => {
13231
13231
  subcircuit_id?: string | undefined;
13232
13232
  pcb_group_id?: string | undefined;
13233
13233
  pcb_smtpad_id?: string | undefined;
13234
- } | {
13235
- type: "pcb_solder_paste";
13236
- x: number;
13237
- y: number;
13238
- width: number;
13239
- height: number;
13240
- shape: "pill";
13241
- radius: number;
13242
- layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | "inner7" | "inner8";
13243
- pcb_solder_paste_id: string;
13244
- pcb_component_id?: string | undefined;
13245
- subcircuit_id?: string | undefined;
13246
- pcb_group_id?: string | undefined;
13247
- pcb_smtpad_id?: string | undefined;
13248
- } | {
13249
- type: "pcb_solder_paste";
13250
- x: number;
13251
- y: number;
13252
- width: number;
13253
- height: number;
13254
- shape: "rotated_pill";
13255
- radius: number;
13256
- ccw_rotation: number;
13257
- layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | "inner7" | "inner8";
13258
- pcb_solder_paste_id: string;
13259
- pcb_component_id?: string | undefined;
13260
- subcircuit_id?: string | undefined;
13261
- pcb_group_id?: string | undefined;
13262
- pcb_smtpad_id?: string | undefined;
13263
13234
  } | {
13264
13235
  type: "pcb_solder_paste";
13265
13236
  x: number;
@@ -16810,7 +16781,7 @@ declare const transformPCBElement: (elm: AnyCircuitElement, matrix: Matrix) => {
16810
16781
  simulation_spice_subcircuit_id: string;
16811
16782
  spice_pin_to_source_port_map: Record<string, string>;
16812
16783
  subcircuit_source: string;
16813
- } | PcbSolderPasteRect | PcbSolderPasteRotatedRect | circuit_json.PcbSoldermaskOpeningCircle | circuit_json.PcbSoldermaskOpeningRect | circuit_json.PcbSoldermaskOpeningRotatedRect | circuit_json.PcbSoldermaskOpeningPolygon;
16784
+ } | PcbSolderPasteRect | PcbSolderPasteRotatedRect | PcbSolderPastePill | PcbSolderPasteRotatedPill | circuit_json.PcbSoldermaskOpeningCircle | circuit_json.PcbSoldermaskOpeningRect | circuit_json.PcbSoldermaskOpeningRotatedRect | circuit_json.PcbSoldermaskOpeningPolygon;
16814
16785
  declare const transformPCBElements: (elms: AnyCircuitElement[], matrix: Matrix) => ({
16815
16786
  message: string;
16816
16787
  type: "source_runtime_error";
@@ -18517,35 +18488,6 @@ declare const transformPCBElements: (elms: AnyCircuitElement[], matrix: Matrix)
18517
18488
  subcircuit_id?: string | undefined;
18518
18489
  pcb_group_id?: string | undefined;
18519
18490
  pcb_smtpad_id?: string | undefined;
18520
- } | {
18521
- type: "pcb_solder_paste";
18522
- x: number;
18523
- y: number;
18524
- width: number;
18525
- height: number;
18526
- shape: "pill";
18527
- radius: number;
18528
- layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | "inner7" | "inner8";
18529
- pcb_solder_paste_id: string;
18530
- pcb_component_id?: string | undefined;
18531
- subcircuit_id?: string | undefined;
18532
- pcb_group_id?: string | undefined;
18533
- pcb_smtpad_id?: string | undefined;
18534
- } | {
18535
- type: "pcb_solder_paste";
18536
- x: number;
18537
- y: number;
18538
- width: number;
18539
- height: number;
18540
- shape: "rotated_pill";
18541
- radius: number;
18542
- ccw_rotation: number;
18543
- layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | "inner7" | "inner8";
18544
- pcb_solder_paste_id: string;
18545
- pcb_component_id?: string | undefined;
18546
- subcircuit_id?: string | undefined;
18547
- pcb_group_id?: string | undefined;
18548
- pcb_smtpad_id?: string | undefined;
18549
18491
  } | {
18550
18492
  type: "pcb_solder_paste";
18551
18493
  x: number;
@@ -22096,7 +22038,7 @@ declare const transformPCBElements: (elms: AnyCircuitElement[], matrix: Matrix)
22096
22038
  simulation_spice_subcircuit_id: string;
22097
22039
  spice_pin_to_source_port_map: Record<string, string>;
22098
22040
  subcircuit_source: string;
22099
- } | PcbSolderPasteRect | PcbSolderPasteRotatedRect | circuit_json.PcbSoldermaskOpeningCircle | circuit_json.PcbSoldermaskOpeningRect | circuit_json.PcbSoldermaskOpeningRotatedRect | circuit_json.PcbSoldermaskOpeningPolygon)[];
22041
+ } | PcbSolderPasteRect | PcbSolderPasteRotatedRect | PcbSolderPastePill | PcbSolderPasteRotatedPill | circuit_json.PcbSoldermaskOpeningCircle | circuit_json.PcbSoldermaskOpeningRect | circuit_json.PcbSoldermaskOpeningRotatedRect | circuit_json.PcbSoldermaskOpeningPolygon)[];
22100
22042
 
22101
22043
  declare const directionToVec: (direction: "up" | "down" | "left" | "right") => {
22102
22044
  x: number;
package/dist/index.js CHANGED
@@ -1025,12 +1025,13 @@ var getTransformedRectRotation = (rotation, matrix) => {
1025
1025
  const isReflected = matrix.a * matrix.d - matrix.b * matrix.c < 0;
1026
1026
  return decomposeTSR(compose(matrix, rotateDEG(rotation)), false, isReflected).rotation.angle * 180 / Math.PI;
1027
1027
  };
1028
- var transformPcbSolderPasteRectangle = (paste, matrix) => {
1028
+ var transformPcbSolderPasteRectOrPill = (paste, matrix) => {
1029
1029
  const center = applyToPoint2(matrix, { x: paste.x, y: paste.y });
1030
1030
  paste.x = center.x;
1031
1031
  paste.y = center.y;
1032
+ const isPill = paste.shape === "pill" || paste.shape === "rotated_pill";
1032
1033
  const rotation = getTransformedRectRotation(
1033
- paste.shape === "rotated_rect" ? paste.ccw_rotation : 0,
1034
+ "ccw_rotation" in paste ? paste.ccw_rotation : 0,
1034
1035
  matrix
1035
1036
  );
1036
1037
  const quarterTurns = Math.round(rotation / 90);
@@ -1039,10 +1040,13 @@ var transformPcbSolderPasteRectangle = (paste, matrix) => {
1039
1040
  ;
1040
1041
  [paste.width, paste.height] = [paste.height, paste.width];
1041
1042
  }
1042
- Object.assign(paste, { shape: "rect" });
1043
+ Object.assign(paste, { shape: isPill ? "pill" : "rect" });
1043
1044
  Reflect.deleteProperty(paste, "ccw_rotation");
1044
1045
  } else {
1045
- Object.assign(paste, { shape: "rotated_rect", ccw_rotation: rotation });
1046
+ Object.assign(paste, {
1047
+ shape: isPill ? "rotated_pill" : "rotated_rect",
1048
+ ccw_rotation: rotation
1049
+ });
1046
1050
  }
1047
1051
  return paste;
1048
1052
  };
@@ -1089,8 +1093,8 @@ var transformPCBElement = (elm, matrix) => {
1089
1093
  if (elm.type === "pcb_soldermask_opening") {
1090
1094
  return transformPcbSoldermaskOpening(elm, matrix);
1091
1095
  }
1092
- if (elm.type === "pcb_solder_paste" && (elm.shape === "rect" || elm.shape === "rotated_rect")) {
1093
- return transformPcbSolderPasteRectangle(elm, matrix);
1096
+ if (elm.type === "pcb_solder_paste" && (elm.shape === "rect" || elm.shape === "rotated_rect" || elm.shape === "pill" || elm.shape === "rotated_pill")) {
1097
+ return transformPcbSolderPasteRectOrPill(elm, matrix);
1094
1098
  }
1095
1099
  if ((elm.type === "pcb_smtpad" || elm.type === "pcb_solder_paste") && elm.shape === "polygon") {
1096
1100
  elm.points = elm.points.map((point) => applyToPoint2(matrix, point));
@@ -1112,8 +1116,11 @@ var transformPCBElement = (elm, matrix) => {
1112
1116
  });
1113
1117
  elm.x = x;
1114
1118
  elm.y = y;
1115
- if (elm.type === "pcb_smtpad" && (elm.shape === "rotated_rect" || elm.shape === "rotated_pill")) {
1116
- elm.ccw_rotation = getTransformedRectRotation(elm.ccw_rotation, matrix);
1119
+ if (elm.type === "pcb_smtpad" && (elm.shape === "rotated_rect" || elm.shape === "rotated_pill") || elm.type === "pcb_plated_hole" && (elm.shape === "pill" || elm.shape === "oval")) {
1120
+ elm.ccw_rotation = getTransformedRectRotation(
1121
+ elm.ccw_rotation ?? 0,
1122
+ matrix
1123
+ );
1117
1124
  }
1118
1125
  } else if (elm.type === "pcb_keepout" && elm.shape === "outline") {
1119
1126
  elm.outline = elm.outline.map((point) => applyToPoint2(matrix, point));
@@ -1121,7 +1128,7 @@ var transformPCBElement = (elm, matrix) => {
1121
1128
  elm.center = applyToPoint2(matrix, elm.center);
1122
1129
  } else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text" || elm.type === "pcb_note_text") {
1123
1130
  elm.anchor_position = applyToPoint2(matrix, elm.anchor_position);
1124
- if (elm.type === "pcb_silkscreen_text") {
1131
+ if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text") {
1125
1132
  const textTransform = compose(matrix, rotateDEG(elm.ccw_rotation ?? 0));
1126
1133
  elm.ccw_rotation = Math.atan2(textTransform.b, textTransform.a) * 180 / Math.PI;
1127
1134
  }
@@ -1217,7 +1224,7 @@ var transformPCBElements = (elms, matrix) => {
1217
1224
  let transformedElms = elms.map((elm) => transformPCBElement(elm, matrix));
1218
1225
  if (flipPadWidthHeight) {
1219
1226
  transformedElms = transformedElms.map((elm) => {
1220
- if (elm.type === "pcb_smtpad" && (elm.shape === "rect" || elm.shape === "pill") || elm.type === "pcb_solder_paste" && elm.shape === "pill") {
1227
+ if (elm.type === "pcb_smtpad" && (elm.shape === "rect" || elm.shape === "pill")) {
1221
1228
  ;
1222
1229
  [elm.width, elm.height] = [elm.height, elm.width];
1223
1230
  }