@tscircuit/schematic-viewer 2.0.97 → 2.0.99

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
@@ -1,3 +1,176 @@
1
+ // lib/utils/schematic-net-registry.ts
2
+ import { su } from "@tscircuit/soup-util";
3
+ function buildNetRegistry(circuitJson) {
4
+ const cju = su(circuitJson);
5
+ const srcCompToSchComp = /* @__PURE__ */ new Map();
6
+ for (const c of cju.schematic_component.list()) {
7
+ if (c.source_component_id) {
8
+ srcCompToSchComp.set(c.source_component_id, c.schematic_component_id);
9
+ }
10
+ }
11
+ const componentIdToKeys = /* @__PURE__ */ new Map();
12
+ for (const sourceTrace of cju.source_trace.list()) {
13
+ const key = sourceTrace.subcircuit_connectivity_map_key;
14
+ if (!key) continue;
15
+ for (const portId of sourceTrace.connected_source_port_ids ?? []) {
16
+ const schCompId = srcCompToSchComp.get(
17
+ cju.source_port.get(portId)?.source_component_id ?? ""
18
+ );
19
+ if (!schCompId) continue;
20
+ if (!componentIdToKeys.has(schCompId)) {
21
+ componentIdToKeys.set(schCompId, /* @__PURE__ */ new Set());
22
+ }
23
+ componentIdToKeys.get(schCompId).add(key);
24
+ }
25
+ }
26
+ const netLabelIdToKey = /* @__PURE__ */ new Map();
27
+ for (const label of cju.schematic_net_label.list()) {
28
+ if (!label.source_net_id) continue;
29
+ const key = cju.source_net.get(label.source_net_id)?.subcircuit_connectivity_map_key ?? label.source_net_id;
30
+ netLabelIdToKey.set(label.schematic_net_label_id, key);
31
+ }
32
+ const textIdToKey = /* @__PURE__ */ new Map();
33
+ for (const text of cju.schematic_text.list()) {
34
+ if (!text.source_trace_id) continue;
35
+ const key = cju.source_trace.get(
36
+ text.source_trace_id
37
+ )?.subcircuit_connectivity_map_key;
38
+ if (key) textIdToKey.set(text.schematic_text_id, key);
39
+ }
40
+ return { componentIdToKeys, netLabelIdToKey, textIdToKey };
41
+ }
42
+
43
+ // lib/utils/get-net-locations.ts
44
+ var distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
45
+ var distanceToSegment = (p, a, b) => {
46
+ const dx = b.x - a.x, dy = b.y - a.y;
47
+ const lengthSquared = dx * dx + dy * dy;
48
+ const t = lengthSquared ? Math.max(
49
+ 0,
50
+ Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / lengthSquared)
51
+ ) : 0;
52
+ return distance(p, { x: a.x + t * dx, y: a.y + t * dy });
53
+ };
54
+ var onSegment = (p, a, b) => Math.abs(distance(a, p) + distance(p, b) - distance(a, b)) < 1e-5;
55
+ function getNetKeyAtElement(target, circuitJson) {
56
+ const registry = buildNetRegistry(circuitJson);
57
+ const element = target?.closest(
58
+ "[data-subcircuit-connectivity-map-key], [data-schematic-net-label-id], [data-schematic-text-id], [data-schematic-trace-id]"
59
+ );
60
+ if (!element) return void 0;
61
+ const trace = circuitJson.find(
62
+ (e) => e.type === "schematic_trace" && e.schematic_trace_id === element.getAttribute("data-schematic-trace-id")
63
+ );
64
+ return element.getAttribute("data-subcircuit-connectivity-map-key") || registry.netLabelIdToKey.get(
65
+ element.getAttribute("data-schematic-net-label-id")
66
+ ) || registry.textIdToKey.get(element.getAttribute("data-schematic-text-id")) || (trace?.type === "schematic_trace" ? trace.subcircuit_connectivity_map_key || circuitJson.filter((e) => e.type === "source_trace").find((e) => e.source_trace_id === trace.source_trace_id)?.subcircuit_connectivity_map_key : void 0);
67
+ }
68
+ function getNetLocations(circuitJson, key) {
69
+ const registry = buildNetRegistry(circuitJson);
70
+ const sources = circuitJson.filter((e) => e.type === "source_trace");
71
+ const traces = circuitJson.filter((e) => e.type === "schematic_trace");
72
+ const sheets = circuitJson.filter((e) => e.type === "schematic_sheet");
73
+ const defaultSheet = sheets[0]?.schematic_sheet_id;
74
+ const nodes = [];
75
+ for (const trace of traces) {
76
+ const traceKey = trace.subcircuit_connectivity_map_key ?? sources.find((s) => s.source_trace_id === trace.source_trace_id)?.subcircuit_connectivity_map_key;
77
+ if (traceKey !== key) continue;
78
+ for (const edge of trace.edges)
79
+ nodes.push({
80
+ a: edge.from,
81
+ b: edge.to,
82
+ sheet: trace.schematic_sheet_id ?? defaultSheet,
83
+ target: { type: "schematic_trace", id: trace.schematic_trace_id },
84
+ sourceTraceId: trace.source_trace_id,
85
+ portIds: [
86
+ edge.from_schematic_port_id,
87
+ edge.to_schematic_port_id
88
+ ].filter((id) => !!id),
89
+ junctions: trace.junctions
90
+ });
91
+ }
92
+ for (const element of circuitJson) {
93
+ if (element.type === "schematic_net_label" && registry.netLabelIdToKey.get(element.schematic_net_label_id) === key) {
94
+ const point = element.anchor_position ?? element.center;
95
+ nodes.push({
96
+ a: point,
97
+ b: point,
98
+ sheet: element.schematic_sheet_id ?? defaultSheet,
99
+ target: {
100
+ type: "schematic_net_label",
101
+ id: element.schematic_net_label_id
102
+ },
103
+ name: element.text
104
+ });
105
+ }
106
+ }
107
+ for (const element of circuitJson) {
108
+ if (element.type !== "schematic_text" || registry.textIdToKey.get(element.schematic_text_id) !== key)
109
+ continue;
110
+ const sheet = element.schematic_sheet_id ?? defaultSheet;
111
+ const nearest = nodes.filter(
112
+ (n) => n.sheet === sheet && n.sourceTraceId === element.source_trace_id
113
+ ).sort(
114
+ (a, b) => distanceToSegment(element.position, a.a, a.b) - distanceToSegment(element.position, b.a, b.b)
115
+ )[0];
116
+ const point = nearest?.a ?? element.position;
117
+ nodes.push({
118
+ a: point,
119
+ b: point,
120
+ sheet,
121
+ target: { type: "schematic_text", id: element.schematic_text_id },
122
+ name: element.text
123
+ });
124
+ }
125
+ const parents = nodes.map((_, i) => i);
126
+ const root = (i) => parents[i] === i ? i : parents[i] = root(parents[i]);
127
+ for (let i = 0; i < nodes.length; i++)
128
+ for (let j = 0; j < i; j++) {
129
+ const a = nodes[i], b = nodes[j];
130
+ if (a.sheet !== b.sheet) continue;
131
+ if (onSegment(a.a, b.a, b.b) || onSegment(a.b, b.a, b.b) || onSegment(b.a, a.a, a.b) || onSegment(b.b, a.a, a.b) || [...a.junctions ?? [], ...b.junctions ?? []].some(
132
+ (p) => onSegment(p, a.a, a.b) && onSegment(p, b.a, b.b)
133
+ ))
134
+ parents[root(i)] = root(j);
135
+ }
136
+ const groups = /* @__PURE__ */ new Map();
137
+ nodes.forEach(
138
+ (node, i) => groups.set(root(i), [...groups.get(root(i)) ?? [], node])
139
+ );
140
+ return [...groups.values()].map((island, index) => {
141
+ const representative = island.find((n) => n.target.type !== "schematic_trace") ?? island[0];
142
+ const ports = circuitJson.filter((e) => e.type === "schematic_port").filter(
143
+ (e) => (e.schematic_sheet_id ?? defaultSheet) === representative.sheet && island.some(
144
+ (n) => n.portIds?.includes(e.schematic_port_id) || onSegment(e.center, n.a, n.b)
145
+ )
146
+ );
147
+ const names = ports.map((port) => {
148
+ const sourcePort = circuitJson.find(
149
+ (e) => e.type === "source_port" && e.source_port_id === port.source_port_id
150
+ );
151
+ if (sourcePort?.type !== "source_port") return void 0;
152
+ const component = circuitJson.find(
153
+ (e) => e.type === "source_component" && e.source_component_id === sourcePort.source_component_id
154
+ );
155
+ return component?.type === "source_component" ? `${component.name}.${sourcePort.name ?? `pin${sourcePort.pin_number}`}` : void 0;
156
+ }).filter((name) => !!name).sort();
157
+ const sheetIndex = sheets.findIndex(
158
+ (s) => s.schematic_sheet_id === representative.sheet
159
+ );
160
+ const sheetName = sheets[sheetIndex]?.name ?? `Sheet ${Math.max(0, sheetIndex) + 1}`;
161
+ return {
162
+ kind: "net",
163
+ label: `${sheetName}: ${names[0] ?? representative.name ?? `Location ${index + 1}`}`,
164
+ schematicSheetId: representative.sheet,
165
+ target: representative.target,
166
+ focusPoint: {
167
+ x: (representative.a.x + representative.b.x) / 2,
168
+ y: (representative.a.y + representative.b.y) / 2
169
+ }
170
+ };
171
+ });
172
+ }
173
+
1
174
  // lib/components/StyleAnalysisDialog.tsx
2
175
  import * as Dialog from "@radix-ui/react-dialog";
3
176
 
@@ -221,7 +394,7 @@ var setStoredString = (key, value) => {
221
394
 
222
395
  // lib/hooks/useSchematicGroupsOverlay.ts
223
396
  import { useEffect as useEffect2 } from "react";
224
- import { su } from "@tscircuit/soup-util";
397
+ import { su as su2 } from "@tscircuit/soup-util";
225
398
  var GROUP_COLORS = [
226
399
  "#8B0000",
227
400
  // Dark Red
@@ -265,8 +438,8 @@ var useSchematicGroupsOverlay = (options) => {
265
438
  const existingOverlays = svg.querySelectorAll(".schematic-group-overlay");
266
439
  existingOverlays.forEach((overlay) => overlay.remove());
267
440
  try {
268
- const sourceGroups = su(circuitJson).source_group?.list().filter((x) => !!!x.is_subcircuit) || [];
269
- const schematicComponents = su(circuitJson).schematic_component?.list() || [];
441
+ const sourceGroups = su2(circuitJson).source_group?.list().filter((x) => !!!x.is_subcircuit) || [];
442
+ const schematicComponents = su2(circuitJson).schematic_component?.list() || [];
270
443
  const sourceGroupHierarchy = /* @__PURE__ */ new Map();
271
444
  sourceGroups.forEach((group) => {
272
445
  const groupWithParent = group;
@@ -304,7 +477,7 @@ var useSchematicGroupsOverlay = (options) => {
304
477
  if (hasMeaningfulGroups) {
305
478
  const groupMap = /* @__PURE__ */ new Map();
306
479
  for (const comp of schematicComponents) {
307
- const sourceComp = su(circuitJson).source_component.get(
480
+ const sourceComp = su2(circuitJson).source_component.get(
308
481
  comp.source_component_id
309
482
  );
310
483
  if (sourceComp?.source_group_id) {
@@ -488,11 +661,10 @@ function calculateGroupBounds(components, svg) {
488
661
  }
489
662
 
490
663
  // lib/hooks/useSchematicNetHover.ts
491
- import { su as su2 } from "@tscircuit/soup-util";
492
664
  import { useEffect as useEffect3 } from "react";
493
665
  var FADED_CLASS = "sch-net-faded";
494
666
  var TRACE_SELECTOR = "g.trace[data-subcircuit-connectivity-map-key], g.trace-overlays[data-subcircuit-connectivity-map-key]";
495
- var NET_LABEL_SELECTOR = "[data-schematic-net-label-id]";
667
+ var NET_LABEL_SELECTOR = "[data-schematic-net-label-id], [data-schematic-text-id]";
496
668
  var useSchematicNetHover = ({
497
669
  svgDivRef,
498
670
  circuitJson,
@@ -502,7 +674,7 @@ var useSchematicNetHover = ({
502
674
  useEffect3(() => {
503
675
  const svgDiv = svgDivRef.current;
504
676
  if (!enabled || !svgDiv) return;
505
- const { componentIdToKeys, netLabelIdToKey } = buildNetRegistry(circuitJson);
677
+ const { componentIdToKeys, netLabelIdToKey, textIdToKey } = buildNetRegistry(circuitJson);
506
678
  let netElements = [];
507
679
  const triggerNetKeys = /* @__PURE__ */ new Map();
508
680
  let hoveredNetKey = null;
@@ -531,7 +703,7 @@ var useSchematicNetHover = ({
531
703
  for (const el of Array.from(svg.querySelectorAll(NET_LABEL_SELECTOR))) {
532
704
  const key = netLabelIdToKey.get(
533
705
  el.getAttribute("data-schematic-net-label-id")
534
- );
706
+ ) ?? textIdToKey.get(el.getAttribute("data-schematic-text-id"));
535
707
  const keys = /* @__PURE__ */ new Set();
536
708
  if (key) {
537
709
  keys.add(key);
@@ -547,64 +719,41 @@ var useSchematicNetHover = ({
547
719
  el.classList.toggle(FADED_CLASS, key !== null && !keys.has(key));
548
720
  }
549
721
  };
550
- const handleMouseOver = (e) => {
722
+ const handleMouseMove = (e) => {
551
723
  const target = e.target;
552
724
  if (!(target instanceof Element)) {
553
725
  highlightNet(null);
554
726
  return;
555
727
  }
556
728
  const trigger = target.closest(`${TRACE_SELECTOR}, ${NET_LABEL_SELECTOR}`);
557
- if (!trigger) {
558
- highlightNet(null);
729
+ if (trigger && triggerNetKeys.has(trigger)) {
730
+ highlightNet(triggerNetKeys.get(trigger));
559
731
  return;
560
732
  }
561
- highlightNet(triggerNetKeys.get(trigger) ?? null);
733
+ for (const [el, key] of triggerNetKeys) {
734
+ if (!el.matches(NET_LABEL_SELECTOR)) continue;
735
+ const rect = el.getBoundingClientRect();
736
+ if (e.clientX >= rect.left - 6 && e.clientX <= rect.right + 6 && e.clientY >= rect.top - 6 && e.clientY <= rect.bottom + 6) {
737
+ highlightNet(key);
738
+ return;
739
+ }
740
+ }
741
+ highlightNet(null);
562
742
  };
563
743
  const handleMouseLeave = () => highlightNet(null);
564
744
  collectNetElements();
565
- svgDiv.addEventListener("mouseover", handleMouseOver);
745
+ svgDiv.addEventListener("mousemove", handleMouseMove);
566
746
  svgDiv.addEventListener("mouseleave", handleMouseLeave);
567
747
  const observer = new MutationObserver(collectNetElements);
568
748
  observer.observe(svgDiv, { childList: true });
569
749
  return () => {
570
750
  observer.disconnect();
571
- svgDiv.removeEventListener("mouseover", handleMouseOver);
751
+ svgDiv.removeEventListener("mousemove", handleMouseMove);
572
752
  svgDiv.removeEventListener("mouseleave", handleMouseLeave);
573
753
  for (const { el } of netElements) el.classList.remove(FADED_CLASS);
574
754
  };
575
755
  }, [svgDivRef, circuitJsonKey, enabled]);
576
756
  };
577
- function buildNetRegistry(circuitJson) {
578
- const cju = su2(circuitJson);
579
- const srcCompToSchComp = /* @__PURE__ */ new Map();
580
- for (const c of cju.schematic_component.list()) {
581
- if (c.source_component_id) {
582
- srcCompToSchComp.set(c.source_component_id, c.schematic_component_id);
583
- }
584
- }
585
- const componentIdToKeys = /* @__PURE__ */ new Map();
586
- for (const sourceTrace of cju.source_trace.list()) {
587
- const key = sourceTrace.subcircuit_connectivity_map_key;
588
- if (!key) continue;
589
- for (const portId of sourceTrace.connected_source_port_ids ?? []) {
590
- const schCompId = srcCompToSchComp.get(
591
- cju.source_port.get(portId)?.source_component_id ?? ""
592
- );
593
- if (!schCompId) continue;
594
- if (!componentIdToKeys.has(schCompId)) {
595
- componentIdToKeys.set(schCompId, /* @__PURE__ */ new Set());
596
- }
597
- componentIdToKeys.get(schCompId).add(key);
598
- }
599
- }
600
- const netLabelIdToKey = /* @__PURE__ */ new Map();
601
- for (const label of cju.schematic_net_label.list()) {
602
- if (!label.source_net_id) continue;
603
- const key = cju.source_net.get(label.source_net_id)?.subcircuit_connectivity_map_key ?? label.source_net_id;
604
- netLabelIdToKey.set(label.schematic_net_label_id, key);
605
- }
606
- return { componentIdToKeys, netLabelIdToKey };
607
- }
608
757
 
609
758
  // lib/hooks/useSchematicWarnings.ts
610
759
  import { useLayoutEffect, useRef } from "react";
@@ -716,7 +865,7 @@ var useSchematicWarnings = ({
716
865
 
717
866
  // lib/hooks/useSchematicSearch.ts
718
867
  import { useCallback as useCallback2, useEffect as useEffect4, useMemo, useRef as useRef2, useState as useState2 } from "react";
719
- import { fromString } from "transformation-matrix";
868
+ import { applyToPoint, fromString } from "transformation-matrix";
720
869
 
721
870
  // lib/utils/get-schematic-search-results.ts
722
871
  var normalize = (value) => String(value ?? "").toLocaleLowerCase();
@@ -851,7 +1000,7 @@ var getSchematicSearchResults = (circuitJson, query) => {
851
1000
  port.center.x - anchorPosition.x,
852
1001
  port.center.y - anchorPosition.y
853
1002
  )
854
- })).filter(({ distance }) => distance <= 1).sort((a, b) => a.distance - b.distance)[0]?.port;
1003
+ })).filter(({ distance: distance2 }) => distance2 <= 1).sort((a, b) => a.distance - b.distance)[0]?.port;
855
1004
  const sourcePort = nearestConnectedPort ? sourcePorts.get(nearestConnectedPort.source_port_id) : void 0;
856
1005
  const connectedComponent = sourcePort?.source_component_id ? sourceComponents.get(sourcePort.source_component_id) : void 0;
857
1006
  const connectedPinName = sourcePort?.name ?? (sourcePort?.pin_number !== void 0 ? `pin${sourcePort.pin_number}` : nearestConnectedPort?.display_pin_label);
@@ -873,6 +1022,23 @@ var getSchematicSearchResults = (circuitJson, query) => {
873
1022
  results.push(result);
874
1023
  resultScores.set(result, getTextMatchScore(netLabel.text, normalizedQuery));
875
1024
  }
1025
+ for (const element of circuitJson) {
1026
+ if (element.type !== "schematic_text" || !element.source_trace_id) continue;
1027
+ const score = getTextMatchScore(element.text, normalizedQuery);
1028
+ if (!Number.isFinite(score)) continue;
1029
+ const result = {
1030
+ label: element.text,
1031
+ kind: "net",
1032
+ schematicSheetId: element.schematic_sheet_id,
1033
+ schematicSheetName: getSchematicSheetName({
1034
+ schematicSheets,
1035
+ schematicSheetId: element.schematic_sheet_id
1036
+ }),
1037
+ target: { type: "schematic_text", id: element.schematic_text_id }
1038
+ };
1039
+ results.push(result);
1040
+ resultScores.set(result, score);
1041
+ }
876
1042
  return results.sort((a, b) => {
877
1043
  return (resultScores.get(a) ?? Number.POSITIVE_INFINITY) - (resultScores.get(b) ?? Number.POSITIVE_INFINITY) || a.label.localeCompare(b.label);
878
1044
  });
@@ -936,15 +1102,29 @@ var useSchematicSearch = ({
936
1102
  const svgRoot = svgDivRef.current;
937
1103
  const container = containerRef.current;
938
1104
  if (!svgRoot || !container) return false;
939
- let attribute = "data-schematic-net-label-id";
940
- if (result.target.type === "schematic_component") {
941
- attribute = "data-schematic-component-id";
942
- }
1105
+ const attribute = `data-${result.target.type.replaceAll("_", "-")}-id`;
943
1106
  const target = Array.from(
944
1107
  svgRoot.querySelectorAll(`[${attribute}]`)
945
1108
  ).find((element) => element.getAttribute(attribute) === result.target.id);
946
1109
  if (!target) return false;
947
- const targetRect = target.getBoundingClientRect();
1110
+ let targetRect = target.getBoundingClientRect();
1111
+ if (result.focusPoint) {
1112
+ const svg = target.closest("svg");
1113
+ const transform = svg?.getAttribute("data-real-to-screen-transform");
1114
+ const screenMatrix = svg?.getScreenCTM?.();
1115
+ if (transform && screenMatrix) {
1116
+ const point = applyToPoint(
1117
+ screenMatrix,
1118
+ applyToPoint(fromString(transform), result.focusPoint)
1119
+ );
1120
+ targetRect = {
1121
+ left: point.x - 1,
1122
+ top: point.y - 1,
1123
+ width: 2,
1124
+ height: 2
1125
+ };
1126
+ }
1127
+ }
948
1128
  const containerRect = container.getBoundingClientRect();
949
1129
  if (!containerRect.width || !containerRect.height) return false;
950
1130
  if (!targetRect.width && !targetRect.height) return false;
@@ -1137,6 +1317,7 @@ import { useCallback as useCallback3, useEffect as useEffect6, useRef as useRef3
1137
1317
  var LONG_PRESS_DURATION_MS = 600;
1138
1318
  var MOVEMENT_THRESHOLD_PX = 10;
1139
1319
  var useContextMenu = ({ containerRef }) => {
1320
+ const [menuTarget, setMenuTarget] = useState4(null);
1140
1321
  const [menuVisible, setMenuVisible] = useState4(false);
1141
1322
  const [menuPos, setMenuPos] = useState4({ x: 0, y: 0 });
1142
1323
  const menuRef = useRef3(null);
@@ -1156,6 +1337,7 @@ var useContextMenu = ({ containerRef }) => {
1156
1337
  const movedTooFar = Math.abs(event.clientX - origin.x) > MOVEMENT_THRESHOLD_PX || Math.abs(event.clientY - origin.y) > MOVEMENT_THRESHOLD_PX;
1157
1338
  interactionOriginRef.current = null;
1158
1339
  if (movedTooFar) return;
1340
+ setMenuTarget(event.target instanceof Element ? event.target : null);
1159
1341
  setMenuPos({ x: event.clientX, y: event.clientY });
1160
1342
  setMenuVisible(true);
1161
1343
  }, []);
@@ -1168,6 +1350,7 @@ var useContextMenu = ({ containerRef }) => {
1168
1350
  }
1169
1351
  const touch = event.touches[0];
1170
1352
  if (!touch) return;
1353
+ const target = event.target instanceof Element ? event.target : null;
1171
1354
  interactionOriginRef.current = {
1172
1355
  x: touch.clientX,
1173
1356
  y: touch.clientY
@@ -1175,6 +1358,7 @@ var useContextMenu = ({ containerRef }) => {
1175
1358
  longPressTimeoutRef.current = window.setTimeout(() => {
1176
1359
  const container = containerRef.current;
1177
1360
  if (!container || !interactionOriginRef.current) return;
1361
+ setMenuTarget(target);
1178
1362
  const rect = container.getBoundingClientRect();
1179
1363
  setMenuPos({
1180
1364
  x: rect.left + rect.width / 2,
@@ -1225,6 +1409,7 @@ var useContextMenu = ({ containerRef }) => {
1225
1409
  useEffect6(() => clearLongPressTimeout, [clearLongPressTimeout]);
1226
1410
  return {
1227
1411
  menuVisible,
1412
+ menuTarget,
1228
1413
  menuPos,
1229
1414
  menuRef,
1230
1415
  setMenuVisible,
@@ -1537,10 +1722,10 @@ var MouseTrackerProvider = ({ children }) => {
1537
1722
  const { clientX, clientY } = event;
1538
1723
  const mouseDownPos = storeRef.current.mouseDownPosition;
1539
1724
  if (mouseDownPos) {
1540
- const distance = Math.sqrt(
1725
+ const distance2 = Math.sqrt(
1541
1726
  Math.pow(clientX - mouseDownPos.x, 2) + Math.pow(clientY - mouseDownPos.y, 2)
1542
1727
  );
1543
- if (distance > DRAG_THRESHOLD_PX) {
1728
+ if (distance2 > DRAG_THRESHOLD_PX) {
1544
1729
  storeRef.current.mouseDownPosition = null;
1545
1730
  return;
1546
1731
  }
@@ -2925,7 +3110,7 @@ import { useMemo as useMemo5 } from "react";
2925
3110
  // package.json
2926
3111
  var package_default = {
2927
3112
  name: "@tscircuit/schematic-viewer",
2928
- version: "2.0.96",
3113
+ version: "2.0.98",
2929
3114
  repository: {
2930
3115
  type: "git",
2931
3116
  url: "https://github.com/tscircuit/schematic-viewer"
@@ -2972,7 +3157,7 @@ var package_default = {
2972
3157
  "@radix-ui/react-dropdown-menu": "^2.1.16",
2973
3158
  "@tscircuit/circuit-json-util": "^0.0.108",
2974
3159
  "circuit-json": "^0.0.479",
2975
- "circuit-to-svg": "^0.0.421",
3160
+ "circuit-to-svg": "^0.0.432",
2976
3161
  debug: "^4.4.0",
2977
3162
  fflate: "^0.8.3",
2978
3163
  "performance-now": "^2.1.0",
@@ -3046,6 +3231,8 @@ var CheckIcon2 = () => /* @__PURE__ */ jsx10(
3046
3231
  }
3047
3232
  );
3048
3233
  var ViewMenu = ({
3234
+ netLocations = [],
3235
+ onSelectNetLocation,
3049
3236
  circuitJson,
3050
3237
  circuitJsonKey,
3051
3238
  menuRef,
@@ -3117,6 +3304,40 @@ var ViewMenu = ({
3117
3304
  avoidCollisions: true,
3118
3305
  children: [
3119
3306
  /* @__PURE__ */ jsx10("style", { children: HIGHLIGHT_CSS }),
3307
+ netLocations.length > 0 && /* @__PURE__ */ jsxs8(DropdownMenu2.Sub, { children: [
3308
+ /* @__PURE__ */ jsxs8(
3309
+ DropdownMenu2.SubTrigger,
3310
+ {
3311
+ className: "sv-vm-item",
3312
+ style: itemStyles2,
3313
+ children: [
3314
+ "Net Locations ",
3315
+ /* @__PURE__ */ jsx10("span", { style: { marginLeft: "auto" }, children: "\u203A" })
3316
+ ]
3317
+ }
3318
+ ),
3319
+ /* @__PURE__ */ jsx10(DropdownMenu2.Portal, { children: /* @__PURE__ */ jsx10(
3320
+ DropdownMenu2.SubContent,
3321
+ {
3322
+ style: {
3323
+ ...contentStyles2,
3324
+ maxHeight: "min(400px, var(--radix-dropdown-menu-content-available-height))",
3325
+ overflowY: "auto"
3326
+ },
3327
+ collisionPadding: 10,
3328
+ children: netLocations.map((location, index) => /* @__PURE__ */ jsx10(
3329
+ DropdownMenu2.Item,
3330
+ {
3331
+ className: "sv-vm-item",
3332
+ style: itemStyles2,
3333
+ onSelect: () => onSelectNetLocation?.(location),
3334
+ children: location.label
3335
+ },
3336
+ index
3337
+ ))
3338
+ }
3339
+ ) })
3340
+ ] }),
3120
3341
  /* @__PURE__ */ jsxs8(
3121
3342
  DropdownMenu2.Item,
3122
3343
  {
@@ -3424,7 +3645,8 @@ var SchematicViewer = ({
3424
3645
  menuPos,
3425
3646
  menuRef,
3426
3647
  setMenuVisible,
3427
- contextMenuEventHandlers
3648
+ contextMenuEventHandlers,
3649
+ menuTarget
3428
3650
  } = useContextMenu({ containerRef });
3429
3651
  const { containerWidth, containerHeight } = useResizeHandling(containerRef);
3430
3652
  const selectedComponentDetails = useMemo6(
@@ -3680,6 +3902,14 @@ var SchematicViewer = ({
3680
3902
  {
3681
3903
  circuitJson,
3682
3904
  circuitJsonKey,
3905
+ netLocations: (() => {
3906
+ const key = getNetKeyAtElement(menuTarget, circuitJson);
3907
+ return key ? getNetLocations(circuitJson, key) : [];
3908
+ })(),
3909
+ onSelectNetLocation: (location) => {
3910
+ setMenuVisible(false);
3911
+ handleSearchResultSelect(location);
3912
+ },
3683
3913
  menuRef,
3684
3914
  menuPos,
3685
3915
  onOpenChange: setMenuVisible,