@tscircuit/pcb-viewer 1.11.285 → 1.11.287

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
@@ -6938,11 +6938,9 @@ var getFullConnectivityMapFromCircuitJson = (circuitJson) => {
6938
6938
  }
6939
6939
  if (Array.isArray(route)) {
6940
6940
  const startId = route.find(
6941
- (rp) => rp && rp.start_pcb_port_id
6941
+ (rp) => rp?.start_pcb_port_id
6942
6942
  )?.start_pcb_port_id;
6943
- const endId = route.find(
6944
- (rp) => rp && rp.end_pcb_port_id
6945
- )?.end_pcb_port_id;
6943
+ const endId = route.find((rp) => rp?.end_pcb_port_id)?.end_pcb_port_id;
6946
6944
  if (startId && pcb_trace_id && endId) {
6947
6945
  connections.push([startId, pcb_trace_id, endId]);
6948
6946
  }
@@ -12675,7 +12673,8 @@ var VISUAL_CONFIG = {
12675
12673
  LABEL_OFFSET_ABOVE: 2,
12676
12674
  LABEL_OFFSET_BELOW: -18,
12677
12675
  LABEL_OFFSET_RIGHT: 8,
12678
- LABEL_OFFSET_LEFT: -80,
12676
+ LABEL_OFFSET_LEFT: -120,
12677
+ Y_LABEL_MIN_WIDTH: 110,
12679
12678
  LINE_STROKE_WIDTH: 1.5,
12680
12679
  LINE_DASH_PATTERN: "4,4",
12681
12680
  COMPONENT_MARKER_RADIUS: 3,
@@ -12807,8 +12806,8 @@ var BoardAnchorOffsetOverlay = ({
12807
12806
  } else {
12808
12807
  if (!target.group.center) return null;
12809
12808
  targetCenter = {
12810
- x: target.group.center.x,
12811
- y: target.group.center.y
12809
+ x: target.group.anchor_position?.x ?? target.group.center.x,
12810
+ y: target.group.anchor_position?.y ?? target.group.center.y
12812
12811
  };
12813
12812
  targetId = target.group.pcb_group_id;
12814
12813
  displayOffsetX = target.group.display_offset_x;
@@ -12830,8 +12829,8 @@ var BoardAnchorOffsetOverlay = ({
12830
12829
  const yLabelOffset = isTargetRightOfAnchor ? VISUAL_CONFIG.LABEL_OFFSET_RIGHT : VISUAL_CONFIG.LABEL_OFFSET_LEFT;
12831
12830
  const shouldShowXLabel = xLineLength > VISUAL_CONFIG.MIN_LINE_LENGTH_FOR_LABEL;
12832
12831
  const shouldShowYLabel = yLineLength > VISUAL_CONFIG.MIN_LINE_LENGTH_FOR_LABEL;
12833
- const xLabelText = displayOffsetX ?? `Board \u0394x: ${offsetX.toFixed(2)}mm`;
12834
- const yLabelText = displayOffsetY ?? `Board \u0394y: ${offsetY.toFixed(2)}mm`;
12832
+ const xLabelText = `Board \u0394x: ${displayOffsetX ? displayOffsetX : offsetX.toFixed(2)}mm`;
12833
+ const yLabelText = `Board \u0394y: ${displayOffsetX ? displayOffsetX : offsetY.toFixed(2)}mm`;
12835
12834
  return /* @__PURE__ */ jsxs9("g", { children: [
12836
12835
  /* @__PURE__ */ jsx12(
12837
12836
  "line",
@@ -12907,7 +12906,7 @@ var BoardAnchorOffsetOverlay = ({
12907
12906
  {
12908
12907
  x: targetScreen.x + yLabelOffset,
12909
12908
  y: Math.min(anchorMarkerScreen.y, targetScreen.y),
12910
- width: 20,
12909
+ width: VISUAL_CONFIG.Y_LABEL_MIN_WIDTH,
12911
12910
  height: Math.abs(targetScreen.y - anchorMarkerScreen.y),
12912
12911
  style: { overflow: "visible" },
12913
12912
  children: /* @__PURE__ */ jsx12(
@@ -12917,6 +12916,9 @@ var BoardAnchorOffsetOverlay = ({
12917
12916
  ...labelStyle,
12918
12917
  display: "flex",
12919
12918
  alignItems: "center",
12919
+ justifyContent: isTargetRightOfAnchor ? "flex-start" : "flex-end",
12920
+ whiteSpace: "nowrap",
12921
+ padding: "0 4px",
12920
12922
  height: "100%"
12921
12923
  },
12922
12924
  children: yLabelText
@@ -13133,8 +13135,8 @@ var GroupAnchorOffsetOverlay = ({
13133
13135
  const yLabelOffset = isTargetRightOfAnchor ? VISUAL_CONFIG.LABEL_OFFSET_RIGHT : VISUAL_CONFIG.LABEL_OFFSET_LEFT;
13134
13136
  const shouldShowXLabel = xLineLength > VISUAL_CONFIG.MIN_LINE_LENGTH_FOR_LABEL;
13135
13137
  const shouldShowYLabel = yLineLength > VISUAL_CONFIG.MIN_LINE_LENGTH_FOR_LABEL;
13136
- const xLabelText = displayOffsetX ?? `\u0394x: ${offsetX.toFixed(2)}mm`;
13137
- const yLabelText = displayOffsetY ?? `\u0394y: ${offsetY.toFixed(2)}mm`;
13138
+ const xLabelText = `\u0394x: ${displayOffsetX ? displayOffsetX : offsetX.toFixed(2)}mm`;
13139
+ const yLabelText = `\u0394y: ${displayOffsetY ? displayOffsetY : offsetY.toFixed(2)}mm`;
13138
13140
  return /* @__PURE__ */ jsxs10(
13139
13141
  "g",
13140
13142
  {
@@ -13632,33 +13634,47 @@ var PcbGroupOverlay = ({
13632
13634
  groupComponents = [...groupComponents, ...childComponents];
13633
13635
  }
13634
13636
  }
13635
- if (groupComponents.length === 0) return;
13636
- let minX = Infinity;
13637
- let minY = Infinity;
13638
- let maxX = -Infinity;
13639
- let maxY = -Infinity;
13640
- groupComponents.forEach((comp) => {
13641
- if (comp.center && typeof comp.width === "number" && typeof comp.height === "number") {
13642
- const left = comp.center.x - comp.width / 2;
13643
- const right = comp.center.x + comp.width / 2;
13644
- const top = comp.center.y + comp.height / 2;
13645
- const bottom = comp.center.y - comp.height / 2;
13646
- minX = Math.min(minX, left);
13647
- maxX = Math.max(maxX, right);
13648
- minY = Math.min(minY, bottom);
13649
- maxY = Math.max(maxY, top);
13650
- }
13651
- });
13652
- if (minX === Infinity || maxX === -Infinity) return;
13637
+ let minX, minY, maxX, maxY;
13638
+ let isExplicitlySized = false;
13639
+ if (group.center && group.width && group.height) {
13640
+ isExplicitlySized = true;
13641
+ const halfWidth = group.width / 2;
13642
+ const halfHeight = group.height / 2;
13643
+ minX = group.center.x - halfWidth;
13644
+ maxX = group.center.x + halfWidth;
13645
+ minY = group.center.y - halfHeight;
13646
+ maxY = group.center.y + halfHeight;
13647
+ } else {
13648
+ if (groupComponents.length === 0) return;
13649
+ minX = Infinity;
13650
+ minY = Infinity;
13651
+ maxX = -Infinity;
13652
+ maxY = -Infinity;
13653
+ groupComponents.forEach((comp) => {
13654
+ if (comp.center && typeof comp.width === "number" && typeof comp.height === "number") {
13655
+ const left = comp.center.x - comp.width / 2;
13656
+ const right = comp.center.x + comp.width / 2;
13657
+ const top = comp.center.y + comp.height / 2;
13658
+ const bottom = comp.center.y - comp.height / 2;
13659
+ minX = Math.min(minX, left);
13660
+ maxX = Math.max(maxX, right);
13661
+ minY = Math.min(minY, bottom);
13662
+ maxY = Math.max(maxY, top);
13663
+ }
13664
+ });
13665
+ if (minX === Infinity || maxX === -Infinity) return;
13666
+ }
13653
13667
  const depthLevel = group.source_group_id ? getGroupDepthLevel(group.source_group_id) : 0;
13654
13668
  const hasChildren = group.source_group_id ? getAllDescendantSourceGroups(group.source_group_id).length > 0 : false;
13655
- const basePadding = 1;
13656
- const hierarchyPadding = hasChildren ? 0.5 : 0;
13657
- const totalPadding = basePadding + hierarchyPadding;
13658
- minX -= totalPadding;
13659
- maxX += totalPadding;
13660
- minY -= totalPadding;
13661
- maxY += totalPadding;
13669
+ if (!isExplicitlySized) {
13670
+ const basePadding = 1;
13671
+ const hierarchyPadding = hasChildren ? 0.5 : 0;
13672
+ const totalPadding = basePadding + hierarchyPadding;
13673
+ minX -= totalPadding;
13674
+ maxX += totalPadding;
13675
+ minY -= totalPadding;
13676
+ maxY += totalPadding;
13677
+ }
13662
13678
  const topLeft = applyToPoint15(transform, { x: minX, y: maxY });
13663
13679
  const topRight = applyToPoint15(transform, { x: maxX, y: maxY });
13664
13680
  const bottomLeft = applyToPoint15(transform, { x: minX, y: minY });
@@ -13873,7 +13889,7 @@ import { css as css3 } from "@emotion/css";
13873
13889
  // package.json
13874
13890
  var package_default = {
13875
13891
  name: "@tscircuit/pcb-viewer",
13876
- version: "1.11.284",
13892
+ version: "1.11.286",
13877
13893
  main: "dist/index.js",
13878
13894
  type: "module",
13879
13895
  repository: "tscircuit/pcb-viewer",
@@ -13910,7 +13926,7 @@ var package_default = {
13910
13926
  "react-cosmos-plugin-vite": "7.0.0-beta.0",
13911
13927
  "react-dom": "19.1.0",
13912
13928
  "react-use": "^17.4.0",
13913
- tscircuit: "^0.0.1015",
13929
+ tscircuit: "^0.0.1040",
13914
13930
  tsup: "^8.0.2",
13915
13931
  "type-fest": "^3.0.0",
13916
13932
  typescript: "^5.4.4",