@tscircuit/pcb-viewer 1.11.362 → 1.11.364

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
@@ -8821,19 +8821,16 @@ var Drawer = class {
8821
8821
  ...associatedFabrication ? [associatedFabrication] : [],
8822
8822
  ...associatedCourtyard ? [associatedCourtyard] : []
8823
8823
  ];
8824
- const drillBeforeForeground = foregroundLayer === "drill" ? [] : ["drill"];
8825
- const drillAfterForeground = foregroundLayer === "drill" ? ["drill"] : [];
8826
8824
  const order = [
8827
8825
  ...DEFAULT_DRAW_ORDER.filter((l) => !layersToShiftToTop.includes(l)),
8828
- ...drillBeforeForeground,
8829
- foregroundLayer,
8826
+ ...foregroundLayer === "drill" ? [] : [foregroundLayer],
8830
8827
  ...associatedSoldermask ? [associatedSoldermask] : [],
8831
- ...drillAfterForeground,
8832
8828
  "edge_cuts",
8833
8829
  ...associatedSilkscreen ? [associatedSilkscreen] : [],
8834
8830
  ...associatedNotes ? [associatedNotes] : [],
8835
8831
  ...associatedFabrication ? [associatedFabrication] : [],
8836
- ...associatedCourtyard ? [associatedCourtyard] : []
8832
+ ...associatedCourtyard ? [associatedCourtyard] : [],
8833
+ "drill"
8837
8834
  ];
8838
8835
  order.forEach((layer, i) => {
8839
8836
  const canvas = canvasLayerMap[layer];
@@ -12432,6 +12429,9 @@ var ErrorOverlay = ({
12432
12429
  const traceErrors = elements.filter(
12433
12430
  (el) => el.type === "pcb_trace_error"
12434
12431
  );
12432
+ const viaClearanceErrors = elements.filter(
12433
+ (el) => el.type === "pcb_via_clearance_error"
12434
+ );
12435
12435
  const componentErrors = elements.filter(
12436
12436
  (el) => el.type === "pcb_trace_error" && el.message?.includes("Multiple components found with name")
12437
12437
  );
@@ -12448,7 +12448,7 @@ var ErrorOverlay = ({
12448
12448
  const port1 = pcb_port_ids?.[0] ? portsMap.get(pcb_port_ids[0]) : void 0;
12449
12449
  const port2 = pcb_port_ids?.[1] ? portsMap.get(pcb_port_ids[1]) : void 0;
12450
12450
  const trace = elements ? su(elements).pcb_trace.get(pcb_trace_id) : void 0;
12451
- const errorId = el.pcb_trace_error_id || `error_${index}_${el.error_type}_${el.message?.slice(0, 20)}`;
12451
+ const errorId = el.pcb_trace_error_id;
12452
12452
  const isHighlighted = hoveredErrorId === errorId;
12453
12453
  if (port1 && port2) {
12454
12454
  const screenPort1 = applyToPoint11(transform, {
@@ -12462,12 +12462,12 @@ var ErrorOverlay = ({
12462
12462
  if (!isShowingDRCErrors) {
12463
12463
  return null;
12464
12464
  }
12465
- const canLineBeDrawn = !(isNaN(screenPort1.x) || isNaN(screenPort1.y) || isNaN(screenPort2.x) || isNaN(screenPort2.y));
12465
+ const canLineBeDrawn = !(Number.isNaN(screenPort1.x) || Number.isNaN(screenPort1.y) || Number.isNaN(screenPort2.x) || Number.isNaN(screenPort2.y));
12466
12466
  const errorCenter = {
12467
12467
  x: (screenPort1.x + screenPort2.x) / 2,
12468
12468
  y: (screenPort1.y + screenPort2.y) / 2
12469
12469
  };
12470
- if (isNaN(errorCenter.x) || isNaN(errorCenter.y)) {
12470
+ if (Number.isNaN(errorCenter.x) || Number.isNaN(errorCenter.y)) {
12471
12471
  return null;
12472
12472
  }
12473
12473
  const popupPosition = getPopupPosition(errorCenter, containerRef);
@@ -12554,7 +12554,8 @@ var ErrorOverlay = ({
12554
12554
  const screenPoints = trace.route.map(
12555
12555
  (pt) => applyToPoint11(transform, { x: pt.x, y: pt.y })
12556
12556
  );
12557
- if (screenPoints.some((pt) => isNaN(pt.x) || isNaN(pt.y))) return null;
12557
+ if (screenPoints.some((pt) => Number.isNaN(pt.x) || Number.isNaN(pt.y)))
12558
+ return null;
12558
12559
  const mid = Math.floor(screenPoints.length / 2);
12559
12560
  const errorCenter = screenPoints[mid];
12560
12561
  const popupPosition = getPopupPosition(errorCenter, containerRef);
@@ -12637,6 +12638,98 @@ var ErrorOverlay = ({
12637
12638
  }
12638
12639
  return null;
12639
12640
  }),
12641
+ viaClearanceErrors.map((el, index) => {
12642
+ if (!el.pcb_center) return null;
12643
+ const errorId = el.pcb_via_ids;
12644
+ const isHighlighted = hoveredErrorId === errorId[0];
12645
+ if (!isHighlighted && !isShowingDRCErrors) return null;
12646
+ const errorCenter = applyToPoint11(transform, {
12647
+ x: el.pcb_center.x,
12648
+ y: el.pcb_center.y
12649
+ });
12650
+ if (Number.isNaN(errorCenter.x) || Number.isNaN(errorCenter.y))
12651
+ return null;
12652
+ const popupPosition = getPopupPosition(
12653
+ { x: errorCenter.x, y: errorCenter.y },
12654
+ containerRef
12655
+ );
12656
+ return /* @__PURE__ */ jsxs8(Fragment3, { children: [
12657
+ /* @__PURE__ */ jsx10(
12658
+ RouteSVG,
12659
+ {
12660
+ points: [],
12661
+ errorCenter,
12662
+ isHighlighted
12663
+ }
12664
+ ),
12665
+ /* @__PURE__ */ jsx10(
12666
+ "div",
12667
+ {
12668
+ style: {
12669
+ position: "absolute",
12670
+ left: errorCenter.x - 15,
12671
+ top: errorCenter.y - 15,
12672
+ width: 30,
12673
+ height: 30,
12674
+ zIndex: zIndexMap.errorOverlay + 5,
12675
+ cursor: "pointer",
12676
+ borderRadius: "50%"
12677
+ },
12678
+ onMouseEnter: (e) => {
12679
+ const popup = e.currentTarget.nextElementSibling;
12680
+ if (popup) {
12681
+ const msg = popup.querySelector(
12682
+ ".error-message"
12683
+ );
12684
+ if (msg) msg.style.opacity = "1";
12685
+ }
12686
+ },
12687
+ onMouseLeave: (e) => {
12688
+ if (!isHighlighted) {
12689
+ const popup = e.currentTarget.nextElementSibling;
12690
+ if (popup) {
12691
+ const msg = popup.querySelector(
12692
+ ".error-message"
12693
+ );
12694
+ if (msg) msg.style.opacity = "0";
12695
+ }
12696
+ }
12697
+ }
12698
+ }
12699
+ ),
12700
+ /* @__PURE__ */ jsx10(
12701
+ "div",
12702
+ {
12703
+ style: {
12704
+ position: "absolute",
12705
+ zIndex: isHighlighted ? zIndexMap.errorOverlay + 10 : zIndexMap.errorOverlay + 1,
12706
+ left: popupPosition.left,
12707
+ top: popupPosition.top,
12708
+ color: isHighlighted ? "#ff4444" : "red",
12709
+ textAlign: "center",
12710
+ fontFamily: "sans-serif",
12711
+ fontSize: 12,
12712
+ display: "flex",
12713
+ flexDirection: "column",
12714
+ alignItems: "center",
12715
+ pointerEvents: "none",
12716
+ transform: popupPosition.transform
12717
+ },
12718
+ children: /* @__PURE__ */ jsx10(
12719
+ "div",
12720
+ {
12721
+ className: `error-message ${errorMessageStyles}`,
12722
+ style: {
12723
+ opacity: isHighlighted ? 1 : 0,
12724
+ border: `1px solid ${isHighlighted ? "#ff4444" : "red"}`
12725
+ },
12726
+ children: el.message
12727
+ }
12728
+ )
12729
+ }
12730
+ )
12731
+ ] }, errorId[0]);
12732
+ }),
12640
12733
  componentErrors.map((el, index) => {
12641
12734
  const componentName = el.component_name || el.message?.match(/name "([^"]+)"/)?.[1];
12642
12735
  if (!componentName) return null;
@@ -12645,7 +12738,7 @@ var ErrorOverlay = ({
12645
12738
  (src) => src.type === "source_component" && src.source_component_id === comp.source_component_id && src.name === componentName
12646
12739
  )
12647
12740
  ) || [];
12648
- const errorId = el.pcb_trace_error_id || `error_${index}_${el.error_type}_${el.message?.slice(0, 20)}`;
12741
+ const errorId = el.error_id;
12649
12742
  const isHighlighted = hoveredErrorId === errorId;
12650
12743
  if (!isHighlighted && !isShowingDRCErrors) return null;
12651
12744
  return components.map((comp, compIndex) => {
@@ -12660,7 +12753,8 @@ var ErrorOverlay = ({
12660
12753
  center = pcbComp.center || { x: 0, y: 0 };
12661
12754
  }
12662
12755
  const screenCenter = applyToPoint11(transform, center);
12663
- if (isNaN(screenCenter.x) || isNaN(screenCenter.y)) return null;
12756
+ if (Number.isNaN(screenCenter.x) || Number.isNaN(screenCenter.y))
12757
+ return null;
12664
12758
  const scale6 = Math.abs(transform.a);
12665
12759
  const baseRadius = 0.5;
12666
12760
  const minRadius = 8;
@@ -12770,7 +12864,7 @@ var ErrorOverlay = ({
12770
12864
  )
12771
12865
  }
12772
12866
  )
12773
- ] }, `${errorId}_${compIndex}`);
12867
+ ] }, errorId);
12774
12868
  });
12775
12869
  })
12776
12870
  ] });
@@ -14371,7 +14465,7 @@ import { css as css3 } from "@emotion/css";
14371
14465
  // package.json
14372
14466
  var package_default = {
14373
14467
  name: "@tscircuit/pcb-viewer",
14374
- version: "1.11.361",
14468
+ version: "1.11.363",
14375
14469
  main: "dist/index.js",
14376
14470
  type: "module",
14377
14471
  repository: "tscircuit/pcb-viewer",
@@ -14619,12 +14713,6 @@ var ToolbarErrorDropdown = ({
14619
14713
  [elements]
14620
14714
  );
14621
14715
  const errorCount = errorElements.length;
14622
- const getErrorId = useCallback8(
14623
- (error, index) => {
14624
- return error.pcb_trace_error_id || `error_${index}_${error.error_type}_${error.message?.slice(0, 20)}`;
14625
- },
14626
- []
14627
- );
14628
14716
  const groupedErrorElements = useMemo7(() => {
14629
14717
  const groups = /* @__PURE__ */ new Map();
14630
14718
  errorElements.forEach((error, index) => {
@@ -14633,7 +14721,7 @@ var ToolbarErrorDropdown = ({
14633
14721
  existingGroup.push({
14634
14722
  error,
14635
14723
  index,
14636
- errorId: getErrorId(error, index)
14724
+ errorId: error.pcb_trace_error_id
14637
14725
  });
14638
14726
  groups.set(errorType, existingGroup);
14639
14727
  });
@@ -14641,7 +14729,7 @@ var ToolbarErrorDropdown = ({
14641
14729
  errorType,
14642
14730
  errors
14643
14731
  }));
14644
- }, [errorElements, getErrorId]);
14732
+ }, [errorElements]);
14645
14733
  const toggleErrorGroup = useCallback8((errorType) => {
14646
14734
  setCollapsedErrorGroups((prev) => {
14647
14735
  const next = new Set(prev);
@@ -15580,9 +15668,8 @@ var CanvasElementsRenderer = (props) => {
15580
15668
  const errorElements = elements.filter(
15581
15669
  (el) => el.type.includes("error")
15582
15670
  );
15583
- const hoveredError = errorElements.find((el, index) => {
15584
- const errorId = el.pcb_trace_error_id || `error_${index}_${el.error_type}_${el.message?.slice(0, 20)}`;
15585
- return errorId === hoveredErrorId;
15671
+ const hoveredError = errorElements.find((el) => {
15672
+ return el.error_id === hoveredErrorId;
15586
15673
  });
15587
15674
  if (!hoveredError) return [];
15588
15675
  const relatedIds = [];
@@ -15592,6 +15679,9 @@ var CanvasElementsRenderer = (props) => {
15592
15679
  if (hoveredError.pcb_port_ids) {
15593
15680
  relatedIds.push(...hoveredError.pcb_port_ids);
15594
15681
  }
15682
+ if (hoveredError.pcb_via_ids) {
15683
+ relatedIds.push(...hoveredError.pcb_via_ids);
15684
+ }
15595
15685
  return relatedIds;
15596
15686
  }, [hoveredErrorId, elements]);
15597
15687
  const primitives = useMemo8(() => {