@tscircuit/pcb-viewer 1.11.406 → 1.11.408

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/README.md CHANGED
@@ -76,6 +76,7 @@ The PCBViewer component accepts these props:
76
76
  - `editEvents`: Array of edit events to apply
77
77
  - `onEditEventsChanged`: Callback when edit events change
78
78
  - `onBoundsSelected`: Callback when the Bounds tool completes a rectangle selection. Receives `{ minX, minY, maxX, maxY }`.
79
+ - `onViewSchematicComponent`: Optional callback for the pad context menu action `↗︎ U1 on Schematic`. Receives `{ source_component_id, pcb_component_id, refdes }`. Omit it when the host schematic tab is disabled.
79
80
  - `initialState`: Initial state for the viewer
80
81
 
81
82
  ### Features
@@ -123,3 +124,25 @@ The WebGPU renderer is installed as a bundled devDependency from
123
124
  `https://jscdn.tscircuit.com/@tscircuit/circuit-json-webgpu/0.0.3.tgz`.
124
125
  The renderer repository includes a TypeScript local render command and 597
125
126
  SVG-left/WebGPU-right feature snapshot tests.
127
+
128
+ ### Navigate from a pad to a schematic
129
+
130
+ Click or right-click an SMT pad or plated hole to see its component's manufacturer
131
+ part number in a disabled row at the bottom of the context menu, when available.
132
+ Passing `onViewSchematicComponent` also enables the schematic action:
133
+
134
+ ```tsx
135
+ <PCBViewer
136
+ circuitJson={circuitJson}
137
+ onViewSchematicComponent={schematicTabEnabled ? ({ source_component_id }) => {
138
+ // The host switches tabs and focuses the matching schematic component.
139
+ showSchematicComponent(source_component_id)
140
+ } : undefined}
141
+ />
142
+ ```
143
+
144
+ The callback uses the source component ID so hosts can resolve the corresponding
145
+ schematic component even when reference designators repeat across subcircuits.
146
+ RunFrame and CircuitJsonViewer can forward this callback from their shared PCB
147
+ preview when the schematic tab is enabled. Tab switching and schematic zooming
148
+ are implemented by the host; PCBViewer does not require schematic elements.
package/dist/index.d.ts CHANGED
@@ -4,6 +4,13 @@ import { GraphicsObject } from 'graphics-debug';
4
4
  import { ManualEditEvent } from '@tscircuit/props';
5
5
  import { Matrix } from 'transformation-matrix';
6
6
 
7
+ /** Stable identity for hosts to locate the component in their schematic. */
8
+ interface ViewSchematicComponentEvent {
9
+ source_component_id: string;
10
+ pcb_component_id: string;
11
+ refdes: string;
12
+ }
13
+
7
14
  interface State {
8
15
  hidden_layer_opacity: number;
9
16
  setHiddenLayerOpacity: (opacity: number) => void;
@@ -81,13 +88,15 @@ type Props = {
81
88
  editEvents?: ManualEditEvent[];
82
89
  initialState?: Partial<StateProps>;
83
90
  onEditEventsChanged?: (editEvents: ManualEditEvent[]) => void;
91
+ /** Omit when the host has no enabled schematic tab. */
92
+ onViewSchematicComponent?: (event: ViewSchematicComponentEvent) => void;
84
93
  onBoundsSelected?: (bounds: BoundsSelection) => void;
85
94
  focusOnHover?: boolean;
86
95
  clickToInteractEnabled?: boolean;
87
96
  debugGraphics?: GraphicsObject | null;
88
97
  disablePcbGroups?: boolean;
89
98
  };
90
- declare const PCBViewer: ({ circuitJson, debugGraphics, height, renderer, initialState, allowEditing, editEvents: editEventsProp, onEditEventsChanged, onBoundsSelected, focusOnHover, clickToInteractEnabled, disablePcbGroups, }: Props) => react_jsx_runtime.JSX.Element;
99
+ declare const PCBViewer: ({ circuitJson, debugGraphics, height, renderer, initialState, allowEditing, editEvents: editEventsProp, onEditEventsChanged, onBoundsSelected, onViewSchematicComponent, focusOnHover, clickToInteractEnabled, disablePcbGroups, }: Props) => react_jsx_runtime.JSX.Element;
91
100
 
92
101
  interface CanvasElementsRendererProps {
93
102
  elements: AnyCircuitElement[];
@@ -100,6 +109,7 @@ interface CanvasElementsRendererProps {
100
109
  grid?: GridConfig;
101
110
  allowEditing: boolean;
102
111
  focusOnHover?: boolean;
112
+ onViewSchematicComponent?: (event: ViewSchematicComponentEvent) => void;
103
113
  onBoundsSelected?: (bounds: BoundsSelection) => void;
104
114
  onContextMenuOpenChange?: (open: boolean) => void;
105
115
  cancelPanDrag: () => void;
@@ -108,4 +118,4 @@ interface CanvasElementsRendererProps {
108
118
  }
109
119
  declare const CanvasElementsRenderer: (props: CanvasElementsRendererProps) => react_jsx_runtime.JSX.Element;
110
120
 
111
- export { CanvasElementsRenderer, PCBViewer };
121
+ export { CanvasElementsRenderer, PCBViewer, type ViewSchematicComponentEvent };