@tscircuit/circuit-json-util 0.0.102 → 0.0.103

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.js CHANGED
@@ -884,9 +884,9 @@ var insertionDirectionToVec = (direction) => {
884
884
  return { x: -1, y: 0 };
885
885
  case "from_right":
886
886
  return { x: 1, y: 0 };
887
- case "from_front":
887
+ case "from_top":
888
888
  return { x: 0, y: 1 };
889
- case "from_back":
889
+ case "from_bottom":
890
890
  return { x: 0, y: -1 };
891
891
  }
892
892
  };
@@ -896,11 +896,15 @@ var vecToInsertionDirection = ({
896
896
  }) => {
897
897
  if (x > 0) return "from_right";
898
898
  if (x < 0) return "from_left";
899
- if (y > 0) return "from_front";
900
- return "from_back";
899
+ if (y > 0) return "from_top";
900
+ return "from_bottom";
901
901
  };
902
902
  var transformInsertionDirection = (direction, opts) => {
903
- if (!direction || direction === "from_above") return direction;
903
+ if (!direction) return direction;
904
+ if (direction === "from_above" || direction === "from_below") {
905
+ if (!opts.isFlipped) return direction;
906
+ return direction === "from_above" ? "from_below" : "from_above";
907
+ }
904
908
  let { x, y } = insertionDirectionToVec(direction);
905
909
  let quarterTurns = Math.round(opts.rotationDegrees / 90);
906
910
  while (quarterTurns > 0) {
@@ -1040,7 +1044,19 @@ var transformPCBElement = (elm, matrix) => {
1040
1044
  p.y = tp.y;
1041
1045
  return p;
1042
1046
  });
1043
- } else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace" || elm.type === "pcb_trace_hint" || elm.type === "pcb_fabrication_note_path" || elm.type === "pcb_note_path") {
1047
+ } else if (elm.type === "pcb_trace") {
1048
+ elm.route = elm.route.map((rp) => {
1049
+ if (!("x" in rp)) {
1050
+ rp.start = applyToPoint(matrix, rp.start);
1051
+ rp.end = applyToPoint(matrix, rp.end);
1052
+ return rp;
1053
+ }
1054
+ const tp = applyToPoint(matrix, rp);
1055
+ rp.x = tp.x;
1056
+ rp.y = tp.y;
1057
+ return rp;
1058
+ });
1059
+ } else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace_hint" || elm.type === "pcb_fabrication_note_path" || elm.type === "pcb_note_path") {
1044
1060
  elm.route = elm.route.map((rp) => {
1045
1061
  const tp = applyToPoint(matrix, rp);
1046
1062
  rp.x = tp.x;
@@ -1442,10 +1458,13 @@ var getBoundsOfPcbElements = (elements) => {
1442
1458
  }
1443
1459
  } else if (elm.type === "pcb_trace") {
1444
1460
  for (const point of elm.route) {
1445
- minX = Math.min(minX, point.x);
1446
- minY = Math.min(minY, point.y);
1447
- maxX = Math.max(maxX, point.x);
1448
- maxY = Math.max(maxY, point.y);
1461
+ const positions = "x" in point ? [point] : [point.start, point.end];
1462
+ for (const { x, y } of positions) {
1463
+ minX = Math.min(minX, x);
1464
+ minY = Math.min(minY, y);
1465
+ maxX = Math.max(maxX, x);
1466
+ maxY = Math.max(maxY, y);
1467
+ }
1449
1468
  }
1450
1469
  } else if (elm.type === "pcb_courtyard_outline") {
1451
1470
  for (const point of elm.outline) {