@tscircuit/schematic-viewer 1.4.0 → 1.4.1
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/biome.json +45 -0
- package/dist/index.js +55 -16
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
- package/src/Schematic.tsx +3 -1
- package/src/lib/render-context/index.ts +1 -1
- package/src/lib/types/source-component.ts +1 -1
- package/src/lib/utils/collect-element-refs.ts +4 -4
- package/src/lib/utils/colors.ts +215 -216
- package/src/lib/utils/direction-to-vec.ts +3 -3
- package/src/schematic-components/SVGPathComponent.tsx +67 -48
- package/src/schematic-components/SchematicChip.tsx +124 -85
- package/src/schematic-components/SchematicComponent.tsx +17 -8
- package/src/schematic-components/SchematicComponentFromSymbol.tsx +3 -1
- package/src/schematic-components/SchematicNetLabel.tsx +3 -0
- package/src/schematic-components/SchematicText.tsx +4 -6
- package/src/schematic-components/SchematicTrace.tsx +1 -1
- package/src/schematic-components/TableViewer.tsx +1 -1
- package/src/schematic-components/index.tsx +0 -1
- package/src/stories/basics/schematic-net-label.stories.tsx +2 -0
- package/src/stories/bug-connections.stories.tsx +18 -16
- package/src/stories/bug-high-port-numbers.stories.tsx +16 -8
- package/src/stories/bug-one-sided.stories.tsx +17 -15
- package/src/stories/bug-pin-spacing.stories.tsx +19 -17
- package/src/stories/bugs/bug1-y-flip.stories.tsx +7 -5
- package/src/stories/bugs/bug5-diode.stories.tsx +3 -1
- package/src/stories/bugs/bug6-trace-scaling.stories.tsx +5 -41
- package/src/stories/led-circuit-react.stories.tsx +3 -8
- package/src/stories/rotated-resistor.stories.tsx +10 -8
- package/src/stories/three-sided-bug.stories.tsx +17 -15
|
@@ -5,7 +5,11 @@ export const BugHighPortNumbers = () => {
|
|
|
5
5
|
const circuit = new Circuit()
|
|
6
6
|
|
|
7
7
|
circuit.add(
|
|
8
|
-
<
|
|
8
|
+
<board
|
|
9
|
+
width={10}
|
|
10
|
+
height={10}
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
>
|
|
9
13
|
<chip
|
|
10
14
|
name="U1"
|
|
11
15
|
manufacturerPartNumber="part-number"
|
|
@@ -18,6 +22,10 @@ export const BugHighPortNumbers = () => {
|
|
|
18
22
|
pins: [1, 5, 11, 3, 2, 9, 10, 6, 23, 22, 14, 13, 12],
|
|
19
23
|
direction: "top-to-bottom",
|
|
20
24
|
},
|
|
25
|
+
bottomSide: {
|
|
26
|
+
pins: [29],
|
|
27
|
+
direction: "left-to-right",
|
|
28
|
+
},
|
|
21
29
|
}}
|
|
22
30
|
schWidth={1}
|
|
23
31
|
footprint="ssop28Db"
|
|
@@ -55,7 +63,7 @@ export const BugHighPortNumbers = () => {
|
|
|
55
63
|
name="R1"
|
|
56
64
|
footprint="0805"
|
|
57
65
|
schX={3}
|
|
58
|
-
schY={
|
|
66
|
+
schY={-1}
|
|
59
67
|
symbolName="boxresistor_vert"
|
|
60
68
|
/>
|
|
61
69
|
<resistor
|
|
@@ -63,7 +71,7 @@ export const BugHighPortNumbers = () => {
|
|
|
63
71
|
name="R2"
|
|
64
72
|
footprint="0805"
|
|
65
73
|
schX={4.5}
|
|
66
|
-
schY={
|
|
74
|
+
schY={-1}
|
|
67
75
|
symbolName="boxresistor_vert"
|
|
68
76
|
/>
|
|
69
77
|
<diode
|
|
@@ -71,14 +79,14 @@ export const BugHighPortNumbers = () => {
|
|
|
71
79
|
footprint="0805"
|
|
72
80
|
symbolName="diode_vert"
|
|
73
81
|
schX={3}
|
|
74
|
-
schY={
|
|
82
|
+
schY={2}
|
|
75
83
|
/>
|
|
76
84
|
<diode
|
|
77
85
|
name="LED2"
|
|
78
86
|
footprint="0805"
|
|
79
87
|
symbolName="diode_vert"
|
|
80
88
|
schX={4.5}
|
|
81
|
-
schY={
|
|
89
|
+
schY={2}
|
|
82
90
|
/>
|
|
83
91
|
<netalias net="5V" schX={3} schY={-2} />
|
|
84
92
|
<netalias net="5V" schX={4.5} schY={-2} />
|
|
@@ -86,8 +94,8 @@ export const BugHighPortNumbers = () => {
|
|
|
86
94
|
<trace path={[".5V", ".R1 > port.left"]} /> */}
|
|
87
95
|
<trace path={[".R1 > port.right", ".LED1 > port.left"]} />
|
|
88
96
|
<trace path={[".R2 > port.right", ".LED2 > port.left"]} />
|
|
89
|
-
<trace path={[".LED1 > port.right", ".U1 > .
|
|
90
|
-
<trace path={[".LED2 > port.right", ".U1 > .
|
|
97
|
+
<trace path={[".LED1 > port.right", ".U1 > .pin20"]} />
|
|
98
|
+
<trace path={[".LED2 > port.right", ".U1 > .pin6"]} />
|
|
91
99
|
<netalias net="GND" schX={-3} schY={4} schRotation="180deg" />
|
|
92
100
|
<netalias net="GND" schX={-5} schY={3} schRotation="180deg" />
|
|
93
101
|
<netalias net="GND" schX={-6} schY={3} schRotation="180deg" />
|
|
@@ -103,7 +111,7 @@ export const BugHighPortNumbers = () => {
|
|
|
103
111
|
height={2}
|
|
104
112
|
/>
|
|
105
113
|
</component> */}
|
|
106
|
-
</
|
|
114
|
+
</board>,
|
|
107
115
|
)
|
|
108
116
|
|
|
109
117
|
const circuitJson = circuit.getCircuitJson()
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { Schematic } from "Schematic"
|
|
2
2
|
|
|
3
3
|
const OneSidedBugExample = () => (
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
<board width={10} height={10}>
|
|
5
|
+
<bug
|
|
6
|
+
name="U2"
|
|
7
|
+
schPortArrangement={{
|
|
8
|
+
leftSize: 0,
|
|
9
|
+
rightSize: 4,
|
|
10
|
+
}}
|
|
11
|
+
schX={-10}
|
|
12
|
+
schY={0}
|
|
13
|
+
pinLabels={{
|
|
14
|
+
"1": "GND",
|
|
15
|
+
"2": "VBUS",
|
|
16
|
+
"3": "D-",
|
|
17
|
+
"4": "D+",
|
|
18
|
+
}}
|
|
19
|
+
/>
|
|
20
|
+
</board>
|
|
19
21
|
)
|
|
20
22
|
|
|
21
23
|
export const OneSidedBug = () => {
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { Schematic } from "Schematic"
|
|
2
2
|
|
|
3
3
|
const BugPinSpacingExample = () => (
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
<board width={10} height={10}>
|
|
5
|
+
<bug
|
|
6
|
+
name="U2"
|
|
7
|
+
manufacturerPartNumber="part-number"
|
|
8
|
+
schPortArrangement={{
|
|
9
|
+
leftSize: 2,
|
|
10
|
+
rightSize: 2,
|
|
11
|
+
}}
|
|
12
|
+
schX={-10}
|
|
13
|
+
schY={0}
|
|
14
|
+
schPinSpacing="1.5mm"
|
|
15
|
+
pinLabels={{
|
|
16
|
+
"1": "GND",
|
|
17
|
+
"2": "VBUS",
|
|
18
|
+
"3": "D-",
|
|
19
|
+
"4": "D+",
|
|
20
|
+
}}
|
|
21
|
+
/>
|
|
22
|
+
</board>
|
|
21
23
|
)
|
|
22
24
|
|
|
23
25
|
export const BugPinSpacing = () => {
|
|
@@ -3,11 +3,13 @@ import { Schematic } from "Schematic"
|
|
|
3
3
|
export const Bug1YFlip = () => {
|
|
4
4
|
return (
|
|
5
5
|
<Schematic style={{ height: 600 }}>
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
<board width={10} height={10}>
|
|
7
|
+
<bug
|
|
8
|
+
name="U1"
|
|
9
|
+
schPortArrangement={{ topSize: 2 }}
|
|
10
|
+
pinLabels={{ 1: "foo", 2: "baz" }}
|
|
11
|
+
/>
|
|
12
|
+
</board>
|
|
11
13
|
</Schematic>
|
|
12
14
|
)
|
|
13
15
|
}
|
|
@@ -3,48 +3,12 @@ import { Schematic } from "../../Schematic"
|
|
|
3
3
|
export const Bug6TraceScaling = () => {
|
|
4
4
|
return (
|
|
5
5
|
<Schematic style={{ height: 500 }}>
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
<board width={10} height={10}>
|
|
7
|
+
<resistor name="R1" resistance="10 ohm" schX={2} schY={1} />
|
|
8
|
+
<resistor resistance="1k" schX={1} schY={2} name="main_power" />
|
|
9
|
+
<trace path={[".main_power > port.right", ".R1 > port.left"]} />
|
|
10
|
+
</board>
|
|
11
11
|
</Schematic>
|
|
12
|
-
// <Schematic
|
|
13
|
-
// style={{ height: 500 }}
|
|
14
|
-
// soup={[
|
|
15
|
-
// {
|
|
16
|
-
// type: "source_trace",
|
|
17
|
-
// source_trace_id: "source_trace_0",
|
|
18
|
-
// },
|
|
19
|
-
// {
|
|
20
|
-
// type: "schematic_trace",
|
|
21
|
-
// source_trace_id: "source_trace_0",
|
|
22
|
-
// schematic_trace_id: "schematic_trace_0",
|
|
23
|
-
// edges: [
|
|
24
|
-
// {
|
|
25
|
-
// from: {
|
|
26
|
-
// x: 1,
|
|
27
|
-
// y: 1.4000000000000001,
|
|
28
|
-
// },
|
|
29
|
-
// to: {
|
|
30
|
-
// x: 1,
|
|
31
|
-
// y: 1,
|
|
32
|
-
// },
|
|
33
|
-
// },
|
|
34
|
-
// {
|
|
35
|
-
// from: {
|
|
36
|
-
// x: 1,
|
|
37
|
-
// y: 1,
|
|
38
|
-
// },
|
|
39
|
-
// to: {
|
|
40
|
-
// x: 1.4000000000000001,
|
|
41
|
-
// y: 1,
|
|
42
|
-
// },
|
|
43
|
-
// },
|
|
44
|
-
// ],
|
|
45
|
-
// },
|
|
46
|
-
// ]}
|
|
47
|
-
// />
|
|
48
12
|
)
|
|
49
13
|
}
|
|
50
14
|
|
|
@@ -4,20 +4,15 @@ export const LEDCircuitReact = () => {
|
|
|
4
4
|
return (
|
|
5
5
|
<Schematic style={{ height: 500 }}>
|
|
6
6
|
<group>
|
|
7
|
-
<resistor name="R1" resistance="10 ohm" schX={2} schY={1}/>
|
|
7
|
+
<resistor name="R1" resistance="10 ohm" schX={2} schY={1} />
|
|
8
8
|
<capacitor
|
|
9
9
|
name="C1"
|
|
10
10
|
capacitance="10 uF"
|
|
11
11
|
schX={4}
|
|
12
12
|
schY={2}
|
|
13
|
-
|
|
14
|
-
/>
|
|
15
|
-
<resistor
|
|
16
|
-
name="R2"
|
|
17
|
-
resistance="10 ohm"
|
|
18
|
-
schX={6}
|
|
19
|
-
schY={1}
|
|
13
|
+
symbolName="capacitor_vert"
|
|
20
14
|
/>
|
|
15
|
+
<resistor name="R2" resistance="10 ohm" schX={6} schY={1} />
|
|
21
16
|
<trace path={[".R1 > port.right", ".C1 > port.left"]} />
|
|
22
17
|
<trace path={[".C1 > port.right", ".R2 > port.left"]} />
|
|
23
18
|
<powersource voltage={5} schX={1} schY={2} name="main_power" />
|
|
@@ -3,14 +3,16 @@ import { Schematic } from "../Schematic"
|
|
|
3
3
|
export const RotatedResistor = () => {
|
|
4
4
|
return (
|
|
5
5
|
<Schematic style={{ height: 500 }}>
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
<board width={10} height={10}>
|
|
7
|
+
<resistor
|
|
8
|
+
name="R1"
|
|
9
|
+
resistance="10 ohm"
|
|
10
|
+
schX={2}
|
|
11
|
+
schY={1}
|
|
12
|
+
schRotation="90deg"
|
|
13
|
+
pcbRotation="90deg"
|
|
14
|
+
/>
|
|
15
|
+
</board>
|
|
14
16
|
</Schematic>
|
|
15
17
|
)
|
|
16
18
|
}
|
|
@@ -3,21 +3,23 @@ import { Schematic } from "Schematic"
|
|
|
3
3
|
export const ThreeSidedBug = () => {
|
|
4
4
|
return (
|
|
5
5
|
<Schematic style={{ height: 600 }}>
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
<board width={10} height={10}>
|
|
7
|
+
<bug
|
|
8
|
+
name="B1"
|
|
9
|
+
schPortArrangement={{
|
|
10
|
+
leftSize: 3,
|
|
11
|
+
rightSize: 3,
|
|
12
|
+
topSize: 0,
|
|
13
|
+
bottomSize: 5,
|
|
14
|
+
}}
|
|
15
|
+
schX={8}
|
|
16
|
+
schY={3}
|
|
17
|
+
pinLabels={{
|
|
18
|
+
"1": "D0",
|
|
19
|
+
"2": "D1",
|
|
20
|
+
}}
|
|
21
|
+
/>
|
|
22
|
+
</board>
|
|
21
23
|
</Schematic>
|
|
22
24
|
)
|
|
23
25
|
}
|