@tscircuit/pcb-viewer 1.11.366 → 1.11.368

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
@@ -12751,12 +12751,9 @@ var FocusMarkerSVG = ({
12751
12751
  );
12752
12752
 
12753
12753
  // src/components/ErrorOverlay.tsx
12754
- import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
12755
- var ErrorSVG = ({
12756
- screenPort1,
12757
- screenPort2,
12754
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
12755
+ var ErrorMarkerSVG = ({
12758
12756
  errorCenter,
12759
- canLineBeDrawn,
12760
12757
  isHighlighted = false
12761
12758
  }) => /* @__PURE__ */ jsx11(
12762
12759
  "svg",
@@ -12771,85 +12768,19 @@ var ErrorSVG = ({
12771
12768
  },
12772
12769
  width: "100%",
12773
12770
  height: "100%",
12774
- children: canLineBeDrawn && /* @__PURE__ */ jsxs9(Fragment4, { children: [
12775
- /* @__PURE__ */ jsx11(
12776
- "line",
12777
- {
12778
- x1: screenPort1.x,
12779
- y1: screenPort1.y,
12780
- x2: errorCenter.x,
12781
- y2: errorCenter.y,
12782
- strokeWidth: isHighlighted ? 3 : 1.5,
12783
- strokeDasharray: "2,2",
12784
- stroke: isHighlighted ? "#ff4444" : "red"
12785
- }
12786
- ),
12787
- /* @__PURE__ */ jsx11(
12788
- "line",
12789
- {
12790
- x1: errorCenter.x,
12791
- y1: errorCenter.y,
12792
- x2: screenPort2.x,
12793
- y2: screenPort2.y,
12794
- strokeWidth: isHighlighted ? 3 : 1.5,
12795
- strokeDasharray: "2,2",
12796
- stroke: isHighlighted ? "#ff4444" : "red"
12797
- }
12798
- ),
12799
- isHighlighted ? /* @__PURE__ */ jsx11(
12800
- "rect",
12801
- {
12802
- x: errorCenter.x - 7,
12803
- y: errorCenter.y - 7,
12804
- width: 14,
12805
- height: 14,
12806
- transform: `rotate(45 ${errorCenter.x} ${errorCenter.y})`,
12807
- fill: "#ff4444"
12808
- }
12809
- ) : /* @__PURE__ */ jsx11("circle", { cx: errorCenter.x, cy: errorCenter.y, r: 5, fill: "red" })
12810
- ] })
12811
- }
12812
- );
12813
- var RouteSVG = ({
12814
- points,
12815
- errorCenter,
12816
- isHighlighted = false
12817
- }) => /* @__PURE__ */ jsxs9(
12818
- "svg",
12819
- {
12820
- style: {
12821
- position: "absolute",
12822
- left: 0,
12823
- top: 0,
12824
- pointerEvents: "none",
12825
- mixBlendMode: "difference",
12826
- zIndex: zIndexMap.errorOverlay
12827
- },
12828
- width: "100%",
12829
- height: "100%",
12830
- children: [
12831
- points.length > 1 && /* @__PURE__ */ jsx11(
12832
- "polyline",
12833
- {
12834
- points: points.map((pt) => `${pt.x},${pt.y}`).join(" "),
12835
- fill: "none",
12836
- stroke: isHighlighted ? "#ff4444" : "red",
12837
- strokeWidth: isHighlighted ? 3 : 1.5,
12838
- strokeDasharray: "2,2"
12839
- }
12840
- ),
12841
- isHighlighted ? /* @__PURE__ */ jsx11(
12842
- "rect",
12843
- {
12844
- x: errorCenter.x - 7,
12845
- y: errorCenter.y - 7,
12846
- width: 14,
12847
- height: 14,
12848
- transform: `rotate(45 ${errorCenter.x} ${errorCenter.y})`,
12849
- fill: "#ff4444"
12850
- }
12851
- ) : /* @__PURE__ */ jsx11("circle", { cx: errorCenter.x, cy: errorCenter.y, r: 5, fill: "red" })
12852
- ]
12771
+ children: /* @__PURE__ */ jsx11(
12772
+ "rect",
12773
+ {
12774
+ x: errorCenter.x - 7,
12775
+ y: errorCenter.y - 7,
12776
+ width: 14,
12777
+ height: 14,
12778
+ transform: `rotate(45 ${errorCenter.x} ${errorCenter.y})`,
12779
+ fill: isHighlighted ? "#ff4444" : "transparent",
12780
+ stroke: isHighlighted ? "#ff4444" : "red",
12781
+ strokeWidth: isHighlighted ? 2.5 : 1.5
12782
+ }
12783
+ )
12853
12784
  }
12854
12785
  );
12855
12786
  var errorMessageStyles = css2`
@@ -12884,7 +12815,7 @@ var ErrorOverlay = ({
12884
12815
  return /* @__PURE__ */ jsx11("div", { style: { position: "relative" }, ref: containerRef, children });
12885
12816
  }
12886
12817
  const traceErrors = elements.filter(
12887
- (el) => el.type === "pcb_trace_error"
12818
+ (el) => el.type === "pcb_trace_error" && !el.message?.includes("Multiple components found with name")
12888
12819
  );
12889
12820
  const viaClearanceErrors = elements.filter(
12890
12821
  (el) => el.type === "pcb_via_clearance_error"
@@ -12894,238 +12825,125 @@ var ErrorOverlay = ({
12894
12825
  );
12895
12826
  const elementIndexes = buildErrorPreviewElementIndexes(elements);
12896
12827
  const focusedErrorElement = findErrorElementById(elements, activeErrorId);
12897
- let focusScreenCenter = null;
12898
- if (focusedErrorElement) {
12828
+ const getScreenErrorCenter = (error) => {
12899
12829
  const focusCenter = getErrorFocusPoint({
12900
- error: focusedErrorElement,
12830
+ error,
12901
12831
  indexes: elementIndexes
12902
12832
  });
12903
- if (focusCenter && typeof focusCenter.x === "number" && typeof focusCenter.y === "number") {
12904
- const screenCenter = applyToPoint11(transform, focusCenter);
12905
- if (!isNaN(screenCenter.x) && !isNaN(screenCenter.y)) {
12906
- focusScreenCenter = screenCenter;
12907
- }
12833
+ if (!focusCenter || typeof focusCenter.x !== "number" || typeof focusCenter.y !== "number") {
12834
+ return null;
12835
+ }
12836
+ const screenCenter = applyToPoint11(transform, focusCenter);
12837
+ if (Number.isNaN(screenCenter.x) || Number.isNaN(screenCenter.y)) {
12838
+ return null;
12908
12839
  }
12840
+ return screenCenter;
12841
+ };
12842
+ let focusScreenCenter = null;
12843
+ if (focusedErrorElement) {
12844
+ focusScreenCenter = getScreenErrorCenter(
12845
+ focusedErrorElement
12846
+ );
12909
12847
  }
12910
12848
  return /* @__PURE__ */ jsxs9("div", { style: { position: "relative" }, ref: containerRef, children: [
12911
12849
  children,
12912
12850
  traceErrors.map((el, index) => {
12913
- const { pcb_port_ids, pcb_trace_id } = el;
12914
- const port1 = pcb_port_ids?.[0] ? elementIndexes.portsById.get(pcb_port_ids[0]) : void 0;
12915
- const port2 = pcb_port_ids?.[1] ? elementIndexes.portsById.get(pcb_port_ids[1]) : void 0;
12916
- const trace = pcb_trace_id ? elementIndexes.tracesById.get(pcb_trace_id) : void 0;
12917
12851
  const errorId = getErrorId(el, index);
12918
12852
  const isHighlighted = activeErrorId === errorId;
12919
- if (port1 && port2) {
12920
- const screenPort1 = applyToPoint11(transform, {
12921
- x: port1.x,
12922
- y: port1.y
12923
- });
12924
- const screenPort2 = applyToPoint11(transform, {
12925
- x: port2.x,
12926
- y: port2.y
12927
- });
12928
- if (!isShowingDRCErrors) {
12929
- return null;
12930
- }
12931
- const canLineBeDrawn = !(Number.isNaN(screenPort1.x) || Number.isNaN(screenPort1.y) || Number.isNaN(screenPort2.x) || Number.isNaN(screenPort2.y));
12932
- const errorCenter = {
12933
- x: (screenPort1.x + screenPort2.x) / 2,
12934
- y: (screenPort1.y + screenPort2.y) / 2
12935
- };
12936
- if (Number.isNaN(errorCenter.x) || Number.isNaN(errorCenter.y)) {
12937
- return null;
12938
- }
12939
- const popupPosition = getPopupPosition(errorCenter, containerRef);
12940
- return /* @__PURE__ */ jsxs9(Fragment3, { children: [
12941
- /* @__PURE__ */ jsx11(
12942
- ErrorSVG,
12943
- {
12944
- screenPort1,
12945
- screenPort2,
12946
- errorCenter,
12947
- canLineBeDrawn,
12948
- isHighlighted
12949
- }
12950
- ),
12951
- /* @__PURE__ */ jsx11(
12952
- "div",
12953
- {
12954
- style: {
12955
- position: "absolute",
12956
- left: errorCenter.x - 15,
12957
- top: errorCenter.y - 15,
12958
- width: 30,
12959
- height: 30,
12960
- zIndex: zIndexMap.errorOverlay + 5,
12961
- cursor: "pointer",
12962
- borderRadius: "50%"
12963
- },
12964
- onMouseEnter: (e) => {
12965
- const popup = e.currentTarget.nextElementSibling;
12966
- if (popup) {
12967
- const msg = popup.querySelector(
12968
- ".error-message"
12969
- );
12970
- if (msg) msg.style.opacity = "1";
12971
- }
12972
- },
12973
- onMouseLeave: (e) => {
12974
- if (!isHighlighted) {
12975
- const popup = e.currentTarget.nextElementSibling;
12976
- if (popup) {
12977
- const msg = popup.querySelector(
12978
- ".error-message"
12979
- );
12980
- if (msg) msg.style.opacity = "0";
12981
- }
12982
- }
12853
+ if (!isHighlighted && !isShowingDRCErrors) return null;
12854
+ const errorCenter = getScreenErrorCenter(el);
12855
+ if (!errorCenter) return null;
12856
+ const popupPosition = getPopupPosition(errorCenter, containerRef);
12857
+ return /* @__PURE__ */ jsxs9(Fragment3, { children: [
12858
+ /* @__PURE__ */ jsx11(
12859
+ ErrorMarkerSVG,
12860
+ {
12861
+ errorCenter,
12862
+ isHighlighted
12863
+ }
12864
+ ),
12865
+ /* @__PURE__ */ jsx11(
12866
+ "div",
12867
+ {
12868
+ style: {
12869
+ position: "absolute",
12870
+ left: errorCenter.x - 15,
12871
+ top: errorCenter.y - 15,
12872
+ width: 30,
12873
+ height: 30,
12874
+ zIndex: zIndexMap.errorOverlay + 5,
12875
+ cursor: "pointer",
12876
+ borderRadius: "50%"
12877
+ },
12878
+ onMouseEnter: (e) => {
12879
+ const popup = e.currentTarget.nextElementSibling;
12880
+ if (popup) {
12881
+ const msg = popup.querySelector(
12882
+ ".error-message"
12883
+ );
12884
+ if (msg) msg.style.opacity = "1";
12983
12885
  }
12984
- }
12985
- ),
12986
- /* @__PURE__ */ jsx11(
12987
- "div",
12988
- {
12989
- style: {
12990
- position: "absolute",
12991
- zIndex: isHighlighted ? 200 : 100,
12992
- left: popupPosition.left,
12993
- top: popupPosition.top,
12994
- color: isHighlighted ? "#ff4444" : "red",
12995
- textAlign: "center",
12996
- fontFamily: "sans-serif",
12997
- fontSize: 12,
12998
- display: isShowingDRCErrors || isHighlighted ? "flex" : "none",
12999
- flexDirection: "column",
13000
- alignItems: "center",
13001
- pointerEvents: "none",
13002
- transform: popupPosition.transform
13003
- },
13004
- children: /* @__PURE__ */ jsx11(
13005
- "div",
13006
- {
13007
- className: `error-message ${errorMessageStyles}`,
13008
- style: {
13009
- opacity: isHighlighted ? 1 : 0,
13010
- border: `1px solid ${isHighlighted ? "#ff4444" : "red"}`
13011
- },
13012
- children: el.message
13013
- }
13014
- )
13015
- }
13016
- )
13017
- ] }, errorId);
13018
- }
13019
- if (trace?.route && (isShowingDRCErrors || isHighlighted)) {
13020
- const screenPoints = trace.route.map(
13021
- (pt) => applyToPoint11(transform, { x: pt.x, y: pt.y })
13022
- );
13023
- if (screenPoints.some(
13024
- (pt) => Number.isNaN(pt.x) || Number.isNaN(pt.y)
13025
- ))
13026
- return null;
13027
- const mid = Math.floor(screenPoints.length / 2);
13028
- const errorCenter = screenPoints[mid];
13029
- const popupPosition = getPopupPosition(errorCenter, containerRef);
13030
- return /* @__PURE__ */ jsxs9(Fragment3, { children: [
13031
- /* @__PURE__ */ jsx11(
13032
- RouteSVG,
13033
- {
13034
- points: screenPoints,
13035
- errorCenter,
13036
- isHighlighted
13037
- }
13038
- ),
13039
- /* @__PURE__ */ jsx11(
13040
- "div",
13041
- {
13042
- style: {
13043
- position: "absolute",
13044
- left: errorCenter.x - 15,
13045
- top: errorCenter.y - 15,
13046
- width: 30,
13047
- height: 30,
13048
- zIndex: zIndexMap.errorOverlay + 5,
13049
- cursor: "pointer",
13050
- borderRadius: "50%"
13051
- },
13052
- onMouseEnter: (e) => {
12886
+ },
12887
+ onMouseLeave: (e) => {
12888
+ if (!isHighlighted) {
13053
12889
  const popup = e.currentTarget.nextElementSibling;
13054
12890
  if (popup) {
13055
12891
  const msg = popup.querySelector(
13056
12892
  ".error-message"
13057
12893
  );
13058
- if (msg) msg.style.opacity = "1";
13059
- }
13060
- },
13061
- onMouseLeave: (e) => {
13062
- if (!isHighlighted) {
13063
- const popup = e.currentTarget.nextElementSibling;
13064
- if (popup) {
13065
- const msg = popup.querySelector(
13066
- ".error-message"
13067
- );
13068
- if (msg) msg.style.opacity = "0";
13069
- }
12894
+ if (msg) msg.style.opacity = "0";
13070
12895
  }
13071
12896
  }
13072
12897
  }
13073
- ),
13074
- /* @__PURE__ */ jsx11(
13075
- "div",
13076
- {
13077
- style: {
13078
- position: "absolute",
13079
- zIndex: isHighlighted ? zIndexMap.errorOverlay + 10 : zIndexMap.errorOverlay + 1,
13080
- left: popupPosition.left,
13081
- top: popupPosition.top,
13082
- color: isHighlighted ? "#ff4444" : "red",
13083
- textAlign: "center",
13084
- fontFamily: "sans-serif",
13085
- fontSize: 12,
13086
- display: "flex",
13087
- flexDirection: "column",
13088
- alignItems: "center",
13089
- pointerEvents: "none",
13090
- transform: popupPosition.transform
13091
- },
13092
- children: /* @__PURE__ */ jsx11(
13093
- "div",
13094
- {
13095
- className: `error-message ${errorMessageStyles}`,
13096
- style: {
13097
- opacity: isHighlighted ? 1 : 0,
13098
- border: `1px solid ${isHighlighted ? "#ff4444" : "red"}`
13099
- },
13100
- children: el.message
13101
- }
13102
- )
13103
- }
13104
- )
13105
- ] }, errorId);
13106
- }
13107
- return null;
12898
+ }
12899
+ ),
12900
+ /* @__PURE__ */ jsx11(
12901
+ "div",
12902
+ {
12903
+ style: {
12904
+ position: "absolute",
12905
+ zIndex: isHighlighted ? 200 : 100,
12906
+ left: popupPosition.left,
12907
+ top: popupPosition.top,
12908
+ color: isHighlighted ? "#ff4444" : "red",
12909
+ textAlign: "center",
12910
+ fontFamily: "sans-serif",
12911
+ fontSize: 12,
12912
+ display: isShowingDRCErrors || isHighlighted ? "flex" : "none",
12913
+ flexDirection: "column",
12914
+ alignItems: "center",
12915
+ pointerEvents: "none",
12916
+ transform: popupPosition.transform
12917
+ },
12918
+ children: /* @__PURE__ */ jsx11(
12919
+ "div",
12920
+ {
12921
+ className: `error-message ${errorMessageStyles}`,
12922
+ style: {
12923
+ opacity: isHighlighted ? 1 : 0,
12924
+ border: `1px solid ${isHighlighted ? "#ff4444" : "red"}`
12925
+ },
12926
+ children: el.message
12927
+ }
12928
+ )
12929
+ }
12930
+ )
12931
+ ] }, errorId);
13108
12932
  }),
13109
12933
  viaClearanceErrors.map((el, index) => {
13110
- if (!el.pcb_center) return null;
13111
12934
  const errorId = getErrorId(el, index);
13112
12935
  const isHighlighted = activeErrorId === errorId;
13113
12936
  if (!isHighlighted && !isShowingDRCErrors) return null;
13114
- const errorCenter = applyToPoint11(transform, {
13115
- x: el.pcb_center.x,
13116
- y: el.pcb_center.y
13117
- });
13118
- if (Number.isNaN(errorCenter.x) || Number.isNaN(errorCenter.y))
13119
- return null;
12937
+ const errorCenter = getScreenErrorCenter(el);
12938
+ if (!errorCenter) return null;
13120
12939
  const popupPosition = getPopupPosition(
13121
12940
  { x: errorCenter.x, y: errorCenter.y },
13122
12941
  containerRef
13123
12942
  );
13124
12943
  return /* @__PURE__ */ jsxs9(Fragment3, { children: [
13125
12944
  /* @__PURE__ */ jsx11(
13126
- RouteSVG,
12945
+ ErrorMarkerSVG,
13127
12946
  {
13128
- points: [],
13129
12947
  errorCenter,
13130
12948
  isHighlighted
13131
12949
  }
@@ -13661,7 +13479,7 @@ var COLORS = {
13661
13479
  };
13662
13480
 
13663
13481
  // src/components/AnchorOffsetOverlay/AnchorOffsetOverlay.tsx
13664
- import { Fragment as Fragment5, jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
13482
+ import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
13665
13483
  var AnchorOffsetOverlay = ({
13666
13484
  targets,
13667
13485
  transform,
@@ -13764,7 +13582,7 @@ var AnchorOffsetOverlay = ({
13764
13582
  }
13765
13583
  ) : (
13766
13584
  // assumes "group"
13767
- /* @__PURE__ */ jsxs10(Fragment5, { children: [
13585
+ /* @__PURE__ */ jsxs10(Fragment4, { children: [
13768
13586
  /* @__PURE__ */ jsx13(
13769
13587
  "line",
13770
13588
  {
@@ -14286,7 +14104,7 @@ var PanelAnchorOffsetOverlay = ({
14286
14104
  };
14287
14105
 
14288
14106
  // src/components/MouseElementTracker.tsx
14289
- import { Fragment as Fragment6, jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
14107
+ import { Fragment as Fragment5, jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
14290
14108
  var getPolygonBoundingBox = (points) => {
14291
14109
  if (points.length === 0) return null;
14292
14110
  let minX = points[0].x;
@@ -14505,7 +14323,7 @@ var MouseElementTracker = ({
14505
14323
  highlightedPrimitives
14506
14324
  }
14507
14325
  ),
14508
- transform && /* @__PURE__ */ jsxs12(Fragment6, { children: [
14326
+ transform && /* @__PURE__ */ jsxs12(Fragment5, { children: [
14509
14327
  /* @__PURE__ */ jsx18(
14510
14328
  BoardAnchorOffsetOverlay,
14511
14329
  {
@@ -14934,7 +14752,7 @@ import { css as css3 } from "@emotion/css";
14934
14752
  // package.json
14935
14753
  var package_default = {
14936
14754
  name: "@tscircuit/pcb-viewer",
14937
- version: "1.11.365",
14755
+ version: "1.11.367",
14938
14756
  main: "dist/index.js",
14939
14757
  type: "module",
14940
14758
  repository: "tscircuit/pcb-viewer",
@@ -14987,7 +14805,7 @@ var package_default = {
14987
14805
  "@tscircuit/alphabet": "^0.0.23",
14988
14806
  "@tscircuit/math-utils": "^0.0.29",
14989
14807
  "@vitejs/plugin-react": "^5.0.2",
14990
- "circuit-json": "^0.0.403",
14808
+ "circuit-json": "^0.0.421",
14991
14809
  "circuit-to-canvas": "^0.0.98",
14992
14810
  "circuit-to-svg": "^0.0.337",
14993
14811
  color: "^4.2.3",