@tscircuit/pcb-viewer 1.10.16 → 1.10.18
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 +57 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +520 -2523
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -12,12 +12,18 @@ If you want to render to an image, check out [circuit-to-png](https://github.com
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
-
```
|
|
15
|
+
```bash
|
|
16
16
|
npm install @tscircuit/pcb-viewer
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
There are two main ways to use the PCBViewer:
|
|
20
|
+
|
|
21
|
+
### 1. Using Circuit Components
|
|
22
|
+
|
|
23
|
+
This approach allows you to declaratively define your circuit using React components:
|
|
24
|
+
|
|
19
25
|
```tsx
|
|
20
|
-
import React
|
|
26
|
+
import React from "react"
|
|
21
27
|
import { PCBViewer } from "@tscircuit/pcb-viewer"
|
|
22
28
|
|
|
23
29
|
export default () => {
|
|
@@ -25,8 +31,57 @@ export default () => {
|
|
|
25
31
|
<div style={{ backgroundColor: "black" }}>
|
|
26
32
|
<PCBViewer>
|
|
27
33
|
<resistor footprint="0805" resistance="10k" />
|
|
34
|
+
<capacitor footprint="0603" capacitance="100nF" />
|
|
28
35
|
</PCBViewer>
|
|
29
36
|
</div>
|
|
30
37
|
)
|
|
31
38
|
}
|
|
32
39
|
```
|
|
40
|
+
|
|
41
|
+
### 2. Using Circuit JSON
|
|
42
|
+
|
|
43
|
+
If you already have circuit JSON data, you can pass it directly:
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import React from "react"
|
|
47
|
+
import { PCBViewer } from "@tscircuit/pcb-viewer"
|
|
48
|
+
|
|
49
|
+
const circuitJson = [
|
|
50
|
+
{
|
|
51
|
+
type: "pcb_component",
|
|
52
|
+
pcb_component_id: "R1",
|
|
53
|
+
center: { x: 0, y: 0 },
|
|
54
|
+
// ... other component properties
|
|
55
|
+
},
|
|
56
|
+
// ... more elements
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
export default () => {
|
|
60
|
+
return (
|
|
61
|
+
<div style={{ backgroundColor: "black" }}>
|
|
62
|
+
<PCBViewer circuitJson={circuitJson} />
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Props
|
|
69
|
+
|
|
70
|
+
The PCBViewer component accepts these props:
|
|
71
|
+
|
|
72
|
+
- `children`: Circuit components to render
|
|
73
|
+
- `circuitJson`: Circuit JSON elements array (alternative to children)
|
|
74
|
+
- `height`: Height of viewer in pixels (default: 600)
|
|
75
|
+
- `allowEditing`: Enable/disable editing capabilities (default: true)
|
|
76
|
+
- `editEvents`: Array of edit events to apply
|
|
77
|
+
- `onEditEventsChanged`: Callback when edit events change
|
|
78
|
+
- `initialState`: Initial state for the viewer
|
|
79
|
+
|
|
80
|
+
### Features
|
|
81
|
+
|
|
82
|
+
- Interactive PCB viewing with pan and zoom
|
|
83
|
+
- Multiple layer support (top, bottom, inner layers)
|
|
84
|
+
- Component placement editing
|
|
85
|
+
- Trace routing
|
|
86
|
+
- DRC (Design Rule Check) visualization
|
|
87
|
+
- Measurement tools
|
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ type EditEvent = EditComponentLocationEvent | EditTraceHintEvent;
|
|
|
56
56
|
|
|
57
57
|
type Props = {
|
|
58
58
|
children?: any;
|
|
59
|
+
circuitJson?: AnyCircuitElement[];
|
|
59
60
|
soup?: any;
|
|
60
61
|
height?: number;
|
|
61
62
|
allowEditing?: boolean;
|
|
@@ -63,7 +64,7 @@ type Props = {
|
|
|
63
64
|
initialState?: Partial<StateProps>;
|
|
64
65
|
onEditEventsChanged?: (editEvents: EditEvent[]) => void;
|
|
65
66
|
};
|
|
66
|
-
declare const PCBViewer: ({ children, soup, height, initialState, allowEditing, editEvents: editEventsProp, onEditEventsChanged, }: Props) => react_jsx_runtime.JSX.Element;
|
|
67
|
+
declare const PCBViewer: ({ children, soup, circuitJson, height, initialState, allowEditing, editEvents: editEventsProp, onEditEventsChanged, }: Props) => react_jsx_runtime.JSX.Element;
|
|
67
68
|
|
|
68
69
|
declare const applyEditEvents: (soup: AnyCircuitElement[], edit_events: EditEvent[]) => AnyCircuitElement[];
|
|
69
70
|
|