@tscircuit/pcb-viewer 1.11.363 → 1.11.365

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
@@ -10100,19 +10100,12 @@ var CanvasPrimitiveRenderer = ({
10100
10100
  drawSoldermask: isShowingSolderMask
10101
10101
  });
10102
10102
  }
10103
- if (topCanvas) {
10104
- drawCopperPourElementsForLayer({
10105
- canvas: topCanvas,
10106
- elements,
10107
- layers: ["top_copper"],
10108
- realToCanvasMat: transform
10109
- });
10110
- }
10111
- if (bottomCanvas) {
10103
+ for (const { canvas, copperLayer } of copperLayers) {
10104
+ if (!canvas) continue;
10112
10105
  drawCopperPourElementsForLayer({
10113
- canvas: bottomCanvas,
10106
+ canvas,
10114
10107
  elements,
10115
- layers: ["bottom_copper"],
10108
+ layers: [copperLayer],
10116
10109
  realToCanvasMat: transform
10117
10110
  });
10118
10111
  }
@@ -10176,22 +10169,6 @@ var CanvasPrimitiveRenderer = ({
10176
10169
  });
10177
10170
  }
10178
10171
  }
10179
- if (topCanvas) {
10180
- drawCopperPourElementsForLayer({
10181
- canvas: topCanvas,
10182
- elements,
10183
- layers: ["top_copper"],
10184
- realToCanvasMat: transform
10185
- });
10186
- }
10187
- if (bottomCanvas) {
10188
- drawCopperPourElementsForLayer({
10189
- canvas: bottomCanvas,
10190
- elements,
10191
- layers: ["bottom_copper"],
10192
- realToCanvasMat: transform
10193
- });
10194
- }
10195
10172
  const drillCanvas = canvasRefs.current.drill;
10196
10173
  if (drillCanvas) {
10197
10174
  drawPcbHoleElementsForLayer({
@@ -12429,6 +12406,9 @@ var ErrorOverlay = ({
12429
12406
  const traceErrors = elements.filter(
12430
12407
  (el) => el.type === "pcb_trace_error"
12431
12408
  );
12409
+ const viaClearanceErrors = elements.filter(
12410
+ (el) => el.type === "pcb_via_clearance_error"
12411
+ );
12432
12412
  const componentErrors = elements.filter(
12433
12413
  (el) => el.type === "pcb_trace_error" && el.message?.includes("Multiple components found with name")
12434
12414
  );
@@ -12445,7 +12425,7 @@ var ErrorOverlay = ({
12445
12425
  const port1 = pcb_port_ids?.[0] ? portsMap.get(pcb_port_ids[0]) : void 0;
12446
12426
  const port2 = pcb_port_ids?.[1] ? portsMap.get(pcb_port_ids[1]) : void 0;
12447
12427
  const trace = elements ? su(elements).pcb_trace.get(pcb_trace_id) : void 0;
12448
- const errorId = el.pcb_trace_error_id || `error_${index}_${el.error_type}_${el.message?.slice(0, 20)}`;
12428
+ const errorId = el.pcb_trace_error_id;
12449
12429
  const isHighlighted = hoveredErrorId === errorId;
12450
12430
  if (port1 && port2) {
12451
12431
  const screenPort1 = applyToPoint11(transform, {
@@ -12459,12 +12439,12 @@ var ErrorOverlay = ({
12459
12439
  if (!isShowingDRCErrors) {
12460
12440
  return null;
12461
12441
  }
12462
- const canLineBeDrawn = !(isNaN(screenPort1.x) || isNaN(screenPort1.y) || isNaN(screenPort2.x) || isNaN(screenPort2.y));
12442
+ const canLineBeDrawn = !(Number.isNaN(screenPort1.x) || Number.isNaN(screenPort1.y) || Number.isNaN(screenPort2.x) || Number.isNaN(screenPort2.y));
12463
12443
  const errorCenter = {
12464
12444
  x: (screenPort1.x + screenPort2.x) / 2,
12465
12445
  y: (screenPort1.y + screenPort2.y) / 2
12466
12446
  };
12467
- if (isNaN(errorCenter.x) || isNaN(errorCenter.y)) {
12447
+ if (Number.isNaN(errorCenter.x) || Number.isNaN(errorCenter.y)) {
12468
12448
  return null;
12469
12449
  }
12470
12450
  const popupPosition = getPopupPosition(errorCenter, containerRef);
@@ -12551,7 +12531,8 @@ var ErrorOverlay = ({
12551
12531
  const screenPoints = trace.route.map(
12552
12532
  (pt) => applyToPoint11(transform, { x: pt.x, y: pt.y })
12553
12533
  );
12554
- if (screenPoints.some((pt) => isNaN(pt.x) || isNaN(pt.y))) return null;
12534
+ if (screenPoints.some((pt) => Number.isNaN(pt.x) || Number.isNaN(pt.y)))
12535
+ return null;
12555
12536
  const mid = Math.floor(screenPoints.length / 2);
12556
12537
  const errorCenter = screenPoints[mid];
12557
12538
  const popupPosition = getPopupPosition(errorCenter, containerRef);
@@ -12634,6 +12615,98 @@ var ErrorOverlay = ({
12634
12615
  }
12635
12616
  return null;
12636
12617
  }),
12618
+ viaClearanceErrors.map((el, index) => {
12619
+ if (!el.pcb_center) return null;
12620
+ const errorId = el.pcb_via_ids;
12621
+ const isHighlighted = hoveredErrorId === errorId[0];
12622
+ if (!isHighlighted && !isShowingDRCErrors) return null;
12623
+ const errorCenter = applyToPoint11(transform, {
12624
+ x: el.pcb_center.x,
12625
+ y: el.pcb_center.y
12626
+ });
12627
+ if (Number.isNaN(errorCenter.x) || Number.isNaN(errorCenter.y))
12628
+ return null;
12629
+ const popupPosition = getPopupPosition(
12630
+ { x: errorCenter.x, y: errorCenter.y },
12631
+ containerRef
12632
+ );
12633
+ return /* @__PURE__ */ jsxs8(Fragment3, { children: [
12634
+ /* @__PURE__ */ jsx10(
12635
+ RouteSVG,
12636
+ {
12637
+ points: [],
12638
+ errorCenter,
12639
+ isHighlighted
12640
+ }
12641
+ ),
12642
+ /* @__PURE__ */ jsx10(
12643
+ "div",
12644
+ {
12645
+ style: {
12646
+ position: "absolute",
12647
+ left: errorCenter.x - 15,
12648
+ top: errorCenter.y - 15,
12649
+ width: 30,
12650
+ height: 30,
12651
+ zIndex: zIndexMap.errorOverlay + 5,
12652
+ cursor: "pointer",
12653
+ borderRadius: "50%"
12654
+ },
12655
+ onMouseEnter: (e) => {
12656
+ const popup = e.currentTarget.nextElementSibling;
12657
+ if (popup) {
12658
+ const msg = popup.querySelector(
12659
+ ".error-message"
12660
+ );
12661
+ if (msg) msg.style.opacity = "1";
12662
+ }
12663
+ },
12664
+ onMouseLeave: (e) => {
12665
+ if (!isHighlighted) {
12666
+ const popup = e.currentTarget.nextElementSibling;
12667
+ if (popup) {
12668
+ const msg = popup.querySelector(
12669
+ ".error-message"
12670
+ );
12671
+ if (msg) msg.style.opacity = "0";
12672
+ }
12673
+ }
12674
+ }
12675
+ }
12676
+ ),
12677
+ /* @__PURE__ */ jsx10(
12678
+ "div",
12679
+ {
12680
+ style: {
12681
+ position: "absolute",
12682
+ zIndex: isHighlighted ? zIndexMap.errorOverlay + 10 : zIndexMap.errorOverlay + 1,
12683
+ left: popupPosition.left,
12684
+ top: popupPosition.top,
12685
+ color: isHighlighted ? "#ff4444" : "red",
12686
+ textAlign: "center",
12687
+ fontFamily: "sans-serif",
12688
+ fontSize: 12,
12689
+ display: "flex",
12690
+ flexDirection: "column",
12691
+ alignItems: "center",
12692
+ pointerEvents: "none",
12693
+ transform: popupPosition.transform
12694
+ },
12695
+ children: /* @__PURE__ */ jsx10(
12696
+ "div",
12697
+ {
12698
+ className: `error-message ${errorMessageStyles}`,
12699
+ style: {
12700
+ opacity: isHighlighted ? 1 : 0,
12701
+ border: `1px solid ${isHighlighted ? "#ff4444" : "red"}`
12702
+ },
12703
+ children: el.message
12704
+ }
12705
+ )
12706
+ }
12707
+ )
12708
+ ] }, errorId[0]);
12709
+ }),
12637
12710
  componentErrors.map((el, index) => {
12638
12711
  const componentName = el.component_name || el.message?.match(/name "([^"]+)"/)?.[1];
12639
12712
  if (!componentName) return null;
@@ -12642,7 +12715,7 @@ var ErrorOverlay = ({
12642
12715
  (src) => src.type === "source_component" && src.source_component_id === comp.source_component_id && src.name === componentName
12643
12716
  )
12644
12717
  ) || [];
12645
- const errorId = el.pcb_trace_error_id || `error_${index}_${el.error_type}_${el.message?.slice(0, 20)}`;
12718
+ const errorId = el.error_id;
12646
12719
  const isHighlighted = hoveredErrorId === errorId;
12647
12720
  if (!isHighlighted && !isShowingDRCErrors) return null;
12648
12721
  return components.map((comp, compIndex) => {
@@ -12657,7 +12730,8 @@ var ErrorOverlay = ({
12657
12730
  center = pcbComp.center || { x: 0, y: 0 };
12658
12731
  }
12659
12732
  const screenCenter = applyToPoint11(transform, center);
12660
- if (isNaN(screenCenter.x) || isNaN(screenCenter.y)) return null;
12733
+ if (Number.isNaN(screenCenter.x) || Number.isNaN(screenCenter.y))
12734
+ return null;
12661
12735
  const scale6 = Math.abs(transform.a);
12662
12736
  const baseRadius = 0.5;
12663
12737
  const minRadius = 8;
@@ -12767,7 +12841,7 @@ var ErrorOverlay = ({
12767
12841
  )
12768
12842
  }
12769
12843
  )
12770
- ] }, `${errorId}_${compIndex}`);
12844
+ ] }, errorId);
12771
12845
  });
12772
12846
  })
12773
12847
  ] });
@@ -14368,7 +14442,7 @@ import { css as css3 } from "@emotion/css";
14368
14442
  // package.json
14369
14443
  var package_default = {
14370
14444
  name: "@tscircuit/pcb-viewer",
14371
- version: "1.11.362",
14445
+ version: "1.11.364",
14372
14446
  main: "dist/index.js",
14373
14447
  type: "module",
14374
14448
  repository: "tscircuit/pcb-viewer",
@@ -14422,7 +14496,7 @@ var package_default = {
14422
14496
  "@tscircuit/math-utils": "^0.0.29",
14423
14497
  "@vitejs/plugin-react": "^5.0.2",
14424
14498
  "circuit-json": "^0.0.403",
14425
- "circuit-to-canvas": "^0.0.95",
14499
+ "circuit-to-canvas": "^0.0.98",
14426
14500
  "circuit-to-svg": "^0.0.337",
14427
14501
  color: "^4.2.3",
14428
14502
  "react-supergrid": "^1.0.10",
@@ -14616,12 +14690,6 @@ var ToolbarErrorDropdown = ({
14616
14690
  [elements]
14617
14691
  );
14618
14692
  const errorCount = errorElements.length;
14619
- const getErrorId = useCallback8(
14620
- (error, index) => {
14621
- return error.pcb_trace_error_id || `error_${index}_${error.error_type}_${error.message?.slice(0, 20)}`;
14622
- },
14623
- []
14624
- );
14625
14693
  const groupedErrorElements = useMemo7(() => {
14626
14694
  const groups = /* @__PURE__ */ new Map();
14627
14695
  errorElements.forEach((error, index) => {
@@ -14630,7 +14698,7 @@ var ToolbarErrorDropdown = ({
14630
14698
  existingGroup.push({
14631
14699
  error,
14632
14700
  index,
14633
- errorId: getErrorId(error, index)
14701
+ errorId: error.pcb_trace_error_id
14634
14702
  });
14635
14703
  groups.set(errorType, existingGroup);
14636
14704
  });
@@ -14638,7 +14706,7 @@ var ToolbarErrorDropdown = ({
14638
14706
  errorType,
14639
14707
  errors
14640
14708
  }));
14641
- }, [errorElements, getErrorId]);
14709
+ }, [errorElements]);
14642
14710
  const toggleErrorGroup = useCallback8((errorType) => {
14643
14711
  setCollapsedErrorGroups((prev) => {
14644
14712
  const next = new Set(prev);
@@ -15577,9 +15645,8 @@ var CanvasElementsRenderer = (props) => {
15577
15645
  const errorElements = elements.filter(
15578
15646
  (el) => el.type.includes("error")
15579
15647
  );
15580
- const hoveredError = errorElements.find((el, index) => {
15581
- const errorId = el.pcb_trace_error_id || `error_${index}_${el.error_type}_${el.message?.slice(0, 20)}`;
15582
- return errorId === hoveredErrorId;
15648
+ const hoveredError = errorElements.find((el) => {
15649
+ return el.error_id === hoveredErrorId;
15583
15650
  });
15584
15651
  if (!hoveredError) return [];
15585
15652
  const relatedIds = [];
@@ -15589,6 +15656,9 @@ var CanvasElementsRenderer = (props) => {
15589
15656
  if (hoveredError.pcb_port_ids) {
15590
15657
  relatedIds.push(...hoveredError.pcb_port_ids);
15591
15658
  }
15659
+ if (hoveredError.pcb_via_ids) {
15660
+ relatedIds.push(...hoveredError.pcb_via_ids);
15661
+ }
15592
15662
  return relatedIds;
15593
15663
  }, [hoveredErrorId, elements]);
15594
15664
  const primitives = useMemo8(() => {