@tscircuit/pcb-viewer 1.11.110 → 1.11.111

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.d.ts CHANGED
@@ -14,6 +14,7 @@ interface State {
14
14
  is_moving_component: boolean;
15
15
  is_drawing_trace: boolean;
16
16
  is_showing_autorouting: boolean;
17
+ is_showing_drc_errors: boolean;
17
18
  is_showing_multiple_traces_length: boolean;
18
19
  is_showing_rats_nest: boolean;
19
20
  selectLayer: (layer: LayerRef) => void;
@@ -24,6 +25,7 @@ interface State {
24
25
  setIsMouseOverContainer: (is_focused: boolean) => void;
25
26
  setIsShowingAutorouting: (is_showing: boolean) => void;
26
27
  setIsShowingMultipleTracesLength: (is_showing: boolean) => void;
28
+ setIsShowingDrcErrors: (is_showing: boolean) => void;
27
29
  }
28
30
  type StateProps = {
29
31
  [key in keyof State]: State[key] extends boolean ? boolean : never;
package/dist/index.js CHANGED
@@ -5844,6 +5844,7 @@ var createStore = (initialState = {}) => createZustandStore(
5844
5844
  is_showing_multiple_traces_length: false,
5845
5845
  is_showing_rats_nest: false,
5846
5846
  is_showing_autorouting: true,
5847
+ is_showing_drc_errors: true,
5847
5848
  ...initialState,
5848
5849
  selectLayer: (layer) => set({ selected_layer: layer }),
5849
5850
  setEditMode: (mode) => set({
@@ -5858,7 +5859,8 @@ var createStore = (initialState = {}) => createZustandStore(
5858
5859
  setIsDrawingTrace: (is_drawing) => set({ is_drawing_trace: is_drawing }),
5859
5860
  setIsMouseOverContainer: (is_focused) => set({ is_mouse_over_container: is_focused }),
5860
5861
  setIsShowingMultipleTracesLength: (is_showing) => set({ is_showing_multiple_traces_length: is_showing }),
5861
- setIsShowingAutorouting: (is_showing) => set({ is_showing_autorouting: is_showing })
5862
+ setIsShowingAutorouting: (is_showing) => set({ is_showing_autorouting: is_showing }),
5863
+ setIsShowingDrcErrors: (is_showing) => set({ is_showing_drc_errors: is_showing })
5862
5864
  })
5863
5865
  );
5864
5866
  var useGlobalStore = (s) => {
@@ -8810,50 +8812,95 @@ var ErrorSVG = ({
8810
8812
  ] })
8811
8813
  }
8812
8814
  );
8815
+ var RouteSVG = ({
8816
+ points,
8817
+ errorCenter
8818
+ }) => /* @__PURE__ */ jsxs8(
8819
+ "svg",
8820
+ {
8821
+ style: {
8822
+ position: "absolute",
8823
+ left: 0,
8824
+ top: 0,
8825
+ pointerEvents: "none",
8826
+ mixBlendMode: "difference",
8827
+ zIndex: zIndexMap.errorOverlay
8828
+ },
8829
+ width: "100%",
8830
+ height: "100%",
8831
+ children: [
8832
+ points.length > 1 && /* @__PURE__ */ jsx10(
8833
+ "polyline",
8834
+ {
8835
+ points: points.map((pt) => `${pt.x},${pt.y}`).join(" "),
8836
+ fill: "none",
8837
+ stroke: "red",
8838
+ strokeWidth: 1.5,
8839
+ strokeDasharray: "2,2"
8840
+ }
8841
+ ),
8842
+ /* @__PURE__ */ jsx10(
8843
+ "rect",
8844
+ {
8845
+ x: errorCenter.x - 5,
8846
+ y: errorCenter.y - 5,
8847
+ width: 10,
8848
+ height: 10,
8849
+ transform: `rotate(45 ${errorCenter.x} ${errorCenter.y})`,
8850
+ fill: "red"
8851
+ }
8852
+ )
8853
+ ]
8854
+ }
8855
+ );
8813
8856
  var ErrorOverlay = ({ children, transform, elements }) => {
8814
8857
  if (!transform) transform = identity7();
8815
8858
  const containerRef = useRef8(null);
8859
+ const isShowingDRCErrors = useGlobalStore(
8860
+ (state) => state.is_showing_drc_errors
8861
+ );
8816
8862
  return /* @__PURE__ */ jsxs8("div", { style: { position: "relative" }, ref: containerRef, children: [
8817
8863
  children,
8818
8864
  elements?.filter((el) => el.type === "pcb_trace_error").map((el) => {
8819
- const { pcb_port_ids } = el;
8865
+ const { pcb_port_ids, pcb_trace_id } = el;
8820
8866
  const port1 = elements.find(
8821
8867
  (el2) => el2.type === "pcb_port" && el2.pcb_port_id === pcb_port_ids?.[0]
8822
8868
  );
8823
8869
  const port2 = elements.find(
8824
8870
  (el2) => el2.type === "pcb_port" && el2.pcb_port_id === pcb_port_ids?.[1]
8825
8871
  );
8826
- if (!port1 || !port2) return null;
8827
- const screenPort1 = applyToPoint9(transform, {
8828
- x: port1.x,
8829
- y: port1.y
8830
- });
8831
- const screenPort2 = applyToPoint9(transform, {
8832
- x: port2.x,
8833
- y: port2.y
8834
- });
8835
- const canLineBeDrawn = !(isNaN(screenPort1.x) || isNaN(screenPort1.y) || isNaN(screenPort2.x) || isNaN(screenPort2.y));
8836
- const errorCenter = {
8837
- x: (screenPort1.x + screenPort2.x) / 2,
8838
- y: (screenPort1.y + screenPort2.y) / 2
8839
- };
8840
- if (isNaN(errorCenter.x) || isNaN(errorCenter.y)) {
8841
- return null;
8842
- }
8843
- return /* @__PURE__ */ jsxs8(Fragment3, { children: [
8844
- /* @__PURE__ */ jsx10(
8845
- ErrorSVG,
8846
- {
8847
- screenPort1,
8848
- screenPort2,
8849
- errorCenter,
8850
- canLineBeDrawn
8851
- }
8852
- ),
8853
- /* @__PURE__ */ jsxs8(
8854
- "div",
8855
- {
8856
- className: css2`
8872
+ const trace = su_default(elements).pcb_trace.get(pcb_trace_id);
8873
+ if (port1 && port2) {
8874
+ const screenPort1 = applyToPoint9(transform, {
8875
+ x: port1.x,
8876
+ y: port1.y
8877
+ });
8878
+ const screenPort2 = applyToPoint9(transform, {
8879
+ x: port2.x,
8880
+ y: port2.y
8881
+ });
8882
+ const canLineBeDrawn = !(isNaN(screenPort1.x) || isNaN(screenPort1.y) || isNaN(screenPort2.x) || isNaN(screenPort2.y));
8883
+ const errorCenter = {
8884
+ x: (screenPort1.x + screenPort2.x) / 2,
8885
+ y: (screenPort1.y + screenPort2.y) / 2
8886
+ };
8887
+ if (isNaN(errorCenter.x) || isNaN(errorCenter.y)) {
8888
+ return null;
8889
+ }
8890
+ return /* @__PURE__ */ jsxs8(Fragment3, { children: [
8891
+ /* @__PURE__ */ jsx10(
8892
+ ErrorSVG,
8893
+ {
8894
+ screenPort1,
8895
+ screenPort2,
8896
+ errorCenter,
8897
+ canLineBeDrawn
8898
+ }
8899
+ ),
8900
+ /* @__PURE__ */ jsxs8(
8901
+ "div",
8902
+ {
8903
+ className: css2`
8857
8904
  position: absolute;
8858
8905
  z-index: 100;
8859
8906
  left: ${errorCenter.x}px;
@@ -8882,23 +8929,74 @@ var ErrorOverlay = ({ children, transform, elements }) => {
8882
8929
  display: flex;
8883
8930
  }
8884
8931
  `,
8885
- children: [
8886
- /* @__PURE__ */ jsx10("div", { className: "error-message", children: el.message }),
8887
- /* @__PURE__ */ jsx10(
8888
- "div",
8889
- {
8890
- className: css2`
8932
+ children: [
8933
+ /* @__PURE__ */ jsx10("div", { className: "error-message", children: el.message }),
8934
+ /* @__PURE__ */ jsx10(
8935
+ "div",
8936
+ {
8937
+ className: css2`
8891
8938
  width: 10px;
8892
8939
  height: 10px;
8893
8940
  transform: translate(0, 5px) rotate(45deg);
8894
8941
  background-color: red;
8895
8942
  `
8896
- }
8897
- )
8898
- ]
8899
- }
8900
- )
8901
- ] });
8943
+ }
8944
+ )
8945
+ ]
8946
+ }
8947
+ )
8948
+ ] });
8949
+ }
8950
+ if (trace?.route && isShowingDRCErrors) {
8951
+ const screenPoints = trace.route.map(
8952
+ (pt) => applyToPoint9(transform, { x: pt.x, y: pt.y })
8953
+ );
8954
+ if (screenPoints.some((pt) => isNaN(pt.x) || isNaN(pt.y)))
8955
+ return null;
8956
+ const mid = Math.floor(screenPoints.length / 2);
8957
+ const errorCenter = screenPoints[mid];
8958
+ return /* @__PURE__ */ jsxs8(Fragment3, { children: [
8959
+ /* @__PURE__ */ jsx10(RouteSVG, { points: screenPoints, errorCenter }),
8960
+ /* @__PURE__ */ jsxs8(
8961
+ "div",
8962
+ {
8963
+ className: css2`
8964
+ position: absolute;
8965
+ z-index: ${zIndexMap.errorOverlay + 1};
8966
+ left: ${errorCenter.x}px;
8967
+ top: ${errorCenter.y}px;
8968
+ color: red;
8969
+ text-align: center;
8970
+ font-family: sans-serif;
8971
+ font-size: 12px;
8972
+ display: flex;
8973
+ flex-direction: column;
8974
+ align-items: center;
8975
+ cursor: pointer;
8976
+ transform: translate(-50%, -100%);
8977
+
8978
+ & .error-message { opacity: 0; pointer-events: none; width: 200px; transition: opacity 0.2s; margin-bottom: 10px; }
8979
+ &:hover .error-message { opacity: 1; display: flex; }
8980
+ `,
8981
+ children: [
8982
+ /* @__PURE__ */ jsx10("div", { className: "error-message", children: el.message }),
8983
+ /* @__PURE__ */ jsx10(
8984
+ "div",
8985
+ {
8986
+ className: css2`
8987
+ width: 10px;
8988
+ height: 10px;
8989
+ transform: translate(0, 5px) rotate(45deg);
8990
+ background-color: red;
8991
+ `
8992
+ }
8993
+ )
8994
+ ]
8995
+ }
8996
+ )
8997
+ ] });
8998
+ }
8999
+ return null;
8902
9000
  })
8903
9001
  ] });
8904
9002
  };
@@ -9413,7 +9511,7 @@ import { css as css3 } from "@emotion/css";
9413
9511
  // package.json
9414
9512
  var package_default = {
9415
9513
  name: "@tscircuit/pcb-viewer",
9416
- version: "1.11.109",
9514
+ version: "1.11.110",
9417
9515
  main: "dist/index.js",
9418
9516
  type: "module",
9419
9517
  repository: "tscircuit/pcb-viewer",
@@ -9610,13 +9708,15 @@ var ToolbarOverlay = ({ children, elements }) => {
9610
9708
  in_draw_trace_mode,
9611
9709
  is_showing_rats_nest,
9612
9710
  is_showing_multiple_traces_length,
9613
- is_showing_autorouting
9711
+ is_showing_autorouting,
9712
+ is_showing_drc_errors
9614
9713
  ] = useGlobalStore((s) => [
9615
9714
  s.in_move_footprint_mode,
9616
9715
  s.in_draw_trace_mode,
9617
9716
  s.is_showing_rats_nest,
9618
9717
  s.is_showing_multiple_traces_length,
9619
- s.is_showing_autorouting
9718
+ s.is_showing_autorouting,
9719
+ s.is_showing_drc_errors
9620
9720
  ]);
9621
9721
  const setEditMode = useGlobalStore((s) => s.setEditMode);
9622
9722
  const setIsShowingRatsNest = useGlobalStore((s) => s.setIsShowingRatsNest);
@@ -9626,6 +9726,7 @@ var ToolbarOverlay = ({ children, elements }) => {
9626
9726
  const setIsShowingAutorouting = useGlobalStore(
9627
9727
  (s) => s.setIsShowingAutorouting
9628
9728
  );
9729
+ const setIsShowingDrcErrors = useGlobalStore((s) => s.setIsShowingDrcErrors);
9629
9730
  useHotKey("1", () => selectLayer("top"));
9630
9731
  useHotKey("2", () => selectLayer("bottom"));
9631
9732
  useHotKey("3", () => selectLayer("inner1"));
@@ -9845,6 +9946,16 @@ var ToolbarOverlay = ({ children, elements }) => {
9845
9946
  setIsShowingAutorouting(!is_showing_autorouting);
9846
9947
  }
9847
9948
  }
9949
+ ),
9950
+ /* @__PURE__ */ jsx14(
9951
+ CheckboxMenuItem,
9952
+ {
9953
+ label: "Show DRC Errors",
9954
+ checked: is_showing_drc_errors,
9955
+ onClick: () => {
9956
+ setIsShowingDrcErrors(!is_showing_drc_errors);
9957
+ }
9958
+ }
9848
9959
  )
9849
9960
  ] })
9850
9961
  ] })