@tscircuit/schematic-viewer 1.3.0 → 1.4.0
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 +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +694 -687
- package/dist/index.js.map +1 -1
- package/package.json +5 -6
- package/src/Schematic.tsx +139 -65
- package/src/lib/types/core.ts +14 -49
- package/src/lib/types/source-component.ts +5 -0
- package/src/lib/utils/collect-element-refs.ts +1 -0
- package/src/lib/utils/colors.ts +236 -0
- package/src/schematic-components/SVGPathComponent.tsx +84 -144
- package/src/schematic-components/SchematicChip.tsx +183 -0
- package/src/schematic-components/SchematicComponent.tsx +18 -24
- package/src/schematic-components/SchematicComponentFromSymbol.tsx +44 -0
- package/src/schematic-components/SchematicElement.tsx +0 -28
- package/src/schematic-components/SchematicTrace.tsx +4 -3
- package/src/schematic-components/index.tsx +7 -14
- package/src/stories/basics/schematic-net-labels-2.stories.tsx +22 -20
- package/src/stories/bug-connections.stories.tsx +3 -0
- package/src/stories/bug-high-port-numbers.stories.tsx +99 -85
- package/src/stories/bugs/bug3-scaling-trace.stories.tsx +11 -5
- package/src/stories/bugs/bug4-schematic-line.stories.tsx +0 -1
- package/src/stories/bugs/bug5-diode.stories.tsx +0 -1
- package/src/stories/bugs/bug8-autolayout.stories.tsx +20 -29
- package/src/stories/circuit-components/diode.stories.tsx +3 -1
- package/src/stories/circuit-components/resistor.stories.tsx +3 -1
- package/src/stories/led-circuit-react.stories.tsx +40 -48
- package/src/pages/led-circuit.tsx +0 -96
- package/src/schematic-components/ProjectComponent.tsx +0 -70
- package/src/schematic-components/SchematicBox.tsx +0 -29
- package/src/schematic-components/SchematicBug.tsx +0 -107
- package/src/schematic-components/SchematicLine.tsx +0 -48
- package/src/schematic-components/SchematicPath.tsx +0 -51
- package/src/schematic-components/SchematicPort.tsx +0 -63
- package/src/schematic-components/SimpleCapacitor.tsx +0 -29
- package/src/schematic-components/SimpleDiode.tsx +0 -42
- package/src/schematic-components/SimpleGround.tsx +0 -30
- package/src/schematic-components/SimpleInductor.tsx +0 -29
- package/src/schematic-components/SimplePowerSource.tsx +0 -43
- package/src/schematic-components/SimpleResistor.tsx +0 -28
- package/src/stories/led-circuit-builder.stories.tsx +0 -104
|
@@ -3,26 +3,28 @@ import { Schematic } from "../../Schematic"
|
|
|
3
3
|
export const SchematicNetLabel2 = () => {
|
|
4
4
|
return (
|
|
5
5
|
<Schematic style={{ height: 500 }}>
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
<board width={10} height={10}>
|
|
7
|
+
<resistor resistance="1k" name="R1" schX={-2} schY={0} />
|
|
8
|
+
<resistor resistance="1k" name="R2" schX={2} schY={0} />
|
|
9
|
+
<resistor
|
|
10
|
+
schRotation="90deg"
|
|
11
|
+
resistance="1k"
|
|
12
|
+
name="R3"
|
|
13
|
+
schX={0}
|
|
14
|
+
schY={2}
|
|
15
|
+
/>
|
|
16
|
+
<resistor
|
|
17
|
+
schRotation="90deg"
|
|
18
|
+
resistance="1k"
|
|
19
|
+
name="R4"
|
|
20
|
+
schX={0}
|
|
21
|
+
schY={-2}
|
|
22
|
+
/>
|
|
23
|
+
<trace from=".R1 > .right" to="net.N1" />
|
|
24
|
+
<trace from=".R2 > .left" to="net.N2" />
|
|
25
|
+
<trace from=".R3 > .left" to="net.N3" />
|
|
26
|
+
<trace from=".R4 > .right" to="net.GND2" />
|
|
27
|
+
</board>
|
|
26
28
|
</Schematic>
|
|
27
29
|
)
|
|
28
30
|
}
|
|
@@ -1,82 +1,99 @@
|
|
|
1
|
+
import { Circuit } from "@tscircuit/core"
|
|
1
2
|
import { Schematic } from "Schematic"
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
4
|
+
export const BugHighPortNumbers = () => {
|
|
5
|
+
const circuit = new Circuit()
|
|
6
|
+
|
|
7
|
+
circuit.add(
|
|
8
|
+
<group>
|
|
9
|
+
<chip
|
|
10
|
+
name="U1"
|
|
11
|
+
manufacturerPartNumber="part-number"
|
|
12
|
+
schPortArrangement={{
|
|
13
|
+
leftSide: {
|
|
14
|
+
pins: [16, 15, 20, 17, 4, 27, 28, 19, 26, 25, 7, 18, 21],
|
|
15
|
+
direction: "top-to-bottom",
|
|
16
|
+
},
|
|
17
|
+
rightSide: {
|
|
18
|
+
pins: [1, 5, 11, 3, 2, 9, 10, 6, 23, 22, 14, 13, 12],
|
|
19
|
+
direction: "top-to-bottom",
|
|
20
|
+
},
|
|
21
|
+
}}
|
|
22
|
+
schWidth={1}
|
|
23
|
+
footprint="ssop28Db"
|
|
24
|
+
pinLabels={{
|
|
25
|
+
"1": "TXD",
|
|
26
|
+
"5": "RXD",
|
|
27
|
+
"11": "CTS",
|
|
28
|
+
"3": "RTS",
|
|
29
|
+
"2": "DTR",
|
|
30
|
+
"9": "DSR",
|
|
31
|
+
"10": "DCD",
|
|
32
|
+
"6": "RI",
|
|
33
|
+
"23": "TXLED",
|
|
34
|
+
"22": "RXLED",
|
|
35
|
+
"14": "PWRUN",
|
|
36
|
+
"13": "TXDEN",
|
|
37
|
+
"12": "SLEEP",
|
|
38
|
+
"16": "USBDM",
|
|
39
|
+
"15": "USBDP",
|
|
40
|
+
"20": "VCC",
|
|
41
|
+
"17": "3V3OUT",
|
|
42
|
+
"4": "VCCIO",
|
|
43
|
+
"27": "OSCI",
|
|
44
|
+
"28": "OSCO",
|
|
45
|
+
"19": "RESET",
|
|
46
|
+
"26": "TEST",
|
|
47
|
+
"25": "AGND",
|
|
48
|
+
"7": "GND7",
|
|
49
|
+
"18": "GND18",
|
|
50
|
+
"21": "GND21",
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
<resistor
|
|
54
|
+
resistance="1kohm"
|
|
55
|
+
name="R1"
|
|
56
|
+
footprint="0805"
|
|
57
|
+
schX={3}
|
|
58
|
+
schY={0}
|
|
59
|
+
symbolName="boxresistor_vert"
|
|
60
|
+
/>
|
|
61
|
+
<resistor
|
|
62
|
+
resistance="1kohm"
|
|
63
|
+
name="R2"
|
|
64
|
+
footprint="0805"
|
|
65
|
+
schX={4.5}
|
|
66
|
+
schY={0}
|
|
67
|
+
symbolName="boxresistor_vert"
|
|
68
|
+
/>
|
|
69
|
+
<diode
|
|
70
|
+
name="LED1"
|
|
71
|
+
footprint="0805"
|
|
72
|
+
symbolName="diode_vert"
|
|
73
|
+
schX={3}
|
|
74
|
+
schY={3}
|
|
75
|
+
/>
|
|
76
|
+
<diode
|
|
77
|
+
name="LED2"
|
|
78
|
+
footprint="0805"
|
|
79
|
+
symbolName="diode_vert"
|
|
80
|
+
schX={4.5}
|
|
81
|
+
schY={3}
|
|
82
|
+
/>
|
|
83
|
+
<netalias net="5V" schX={3} schY={-2} />
|
|
84
|
+
<netalias net="5V" schX={4.5} schY={-2} />
|
|
85
|
+
{/* <trace path={[".5V", ".R2 > port.left"]} />
|
|
86
|
+
<trace path={[".5V", ".R1 > port.left"]} /> */}
|
|
87
|
+
<trace path={[".R1 > port.right", ".LED1 > port.left"]} />
|
|
88
|
+
<trace path={[".R2 > port.right", ".LED2 > port.left"]} />
|
|
89
|
+
<trace path={[".LED1 > port.right", ".U1 > .pin1"]} />
|
|
90
|
+
<trace path={[".LED2 > port.right", ".U1 > .RXLED"]} />
|
|
91
|
+
<netalias net="GND" schX={-3} schY={4} schRotation="180deg" />
|
|
92
|
+
<netalias net="GND" schX={-5} schY={3} schRotation="180deg" />
|
|
93
|
+
<netalias net="GND" schX={-6} schY={3} schRotation="180deg" />
|
|
94
|
+
<netalias net="GND" schX={-7} schY={3} schRotation="180deg" />
|
|
95
|
+
<netalias net="GND" schX={-8} schY={2} schRotation="180deg" />
|
|
96
|
+
{/* <component>
|
|
80
97
|
<schematicbox
|
|
81
98
|
name="USB"
|
|
82
99
|
center={[-9, 0]}
|
|
@@ -86,15 +103,12 @@ const FTDIBasic3v3 = () => (
|
|
|
86
103
|
height={2}
|
|
87
104
|
/>
|
|
88
105
|
</component> */}
|
|
89
|
-
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
export const BugHighPortNumbers = () => {
|
|
93
|
-
return (
|
|
94
|
-
<Schematic style={{ height: 600 }}>
|
|
95
|
-
<FTDIBasic3v3 />
|
|
96
|
-
</Schematic>
|
|
106
|
+
</group>,
|
|
97
107
|
)
|
|
108
|
+
|
|
109
|
+
const circuitJson = circuit.getCircuitJson()
|
|
110
|
+
|
|
111
|
+
return <Schematic soup={circuitJson as any} style={{ height: 600 }} />
|
|
98
112
|
}
|
|
99
113
|
|
|
100
114
|
export default {
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import { useResistor } from "@tscircuit/react-fiber"
|
|
2
1
|
import { Schematic } from "../../Schematic"
|
|
3
2
|
|
|
4
3
|
export const Bug3ScalingTrace = () => {
|
|
5
|
-
const R1 = useResistor("R1", { resistance: "10" })
|
|
6
|
-
const R2 = useResistor("R2", { resistance: "1k" })
|
|
7
4
|
return (
|
|
8
5
|
<Schematic style={{ height: 500 }}>
|
|
9
|
-
<
|
|
10
|
-
|
|
6
|
+
<board width={"10mm"} height={"10mm"} pcbX={0} pcbY={0}>
|
|
7
|
+
<resistor name="R1" resistance="10" schX={2} schY={1} />
|
|
8
|
+
<resistor
|
|
9
|
+
name="R2"
|
|
10
|
+
resistance="1k"
|
|
11
|
+
schX={0}
|
|
12
|
+
schY={3}
|
|
13
|
+
symbolName="boxresistor_vert"
|
|
14
|
+
/>
|
|
15
|
+
<trace path={[".R1 > port.right", ".R2 > port.left"]} />
|
|
16
|
+
</board>
|
|
11
17
|
</Schematic>
|
|
12
18
|
)
|
|
13
19
|
}
|
|
@@ -1,30 +1,7 @@
|
|
|
1
|
-
import { Schematic } from "../../Schematic"
|
|
2
1
|
import { layout } from "@tscircuit/layout"
|
|
3
|
-
import {
|
|
2
|
+
import { Schematic } from "../../Schematic"
|
|
4
3
|
|
|
5
4
|
export const Bug8Autolayout = () => {
|
|
6
|
-
const U1 = useBug("U1", {
|
|
7
|
-
pinLabels: {
|
|
8
|
-
1: "VCC",
|
|
9
|
-
2: "D0",
|
|
10
|
-
3: "D1",
|
|
11
|
-
4: "GND",
|
|
12
|
-
5: "INP",
|
|
13
|
-
6: "THR",
|
|
14
|
-
},
|
|
15
|
-
schPortArrangement: {
|
|
16
|
-
leftSize: 3,
|
|
17
|
-
topSize: 0,
|
|
18
|
-
bottomSize: 0,
|
|
19
|
-
rightSize: 3,
|
|
20
|
-
},
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const R1 = useResistor("R1", { resistance: "10k" })
|
|
24
|
-
const R2 = useResistor("R2", { resistance: "1k" })
|
|
25
|
-
const R3 = useResistor("R3", { resistance: "5k" })
|
|
26
|
-
const C1 = useCapacitor("C1", { capacitance: "1uF" })
|
|
27
|
-
|
|
28
5
|
return (
|
|
29
6
|
<div>
|
|
30
7
|
<Schematic style={{ height: 500 }}>
|
|
@@ -35,11 +12,25 @@ export const Bug8Autolayout = () => {
|
|
|
35
12
|
width={"10mm"}
|
|
36
13
|
height={"10mm"}
|
|
37
14
|
>
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
<bug
|
|
16
|
+
name="U1"
|
|
17
|
+
schX={0}
|
|
18
|
+
schY={0}
|
|
19
|
+
schPortArrangement={{
|
|
20
|
+
leftSize: 3,
|
|
21
|
+
topSize: 0,
|
|
22
|
+
bottomSize: 0,
|
|
23
|
+
rightSize: 3,
|
|
24
|
+
}}
|
|
25
|
+
/>
|
|
26
|
+
<resistor name="R1" resistance="10k" schX={0} schY={1} />
|
|
27
|
+
<resistor name="R2" resistance="1k" schX={0} schY={3} />
|
|
28
|
+
<resistor name="R3" resistance="5k" schX={2} schY={1} />
|
|
29
|
+
<capacitor name="C1" capacitance="1uF" schX={2} schY={3} />
|
|
30
|
+
<trace path={[".R1 > port.right", ".R2 > port.left"]} />
|
|
31
|
+
<trace path={[".R2 > port.right", ".R3 > port.left"]} />
|
|
32
|
+
<trace path={[".R3 > port.right", ".C1 > port.left"]} />
|
|
33
|
+
<trace path={[".C1 > port.right", ".R1 > port.left"]} />
|
|
43
34
|
</board>
|
|
44
35
|
</Schematic>
|
|
45
36
|
</div>
|
|
@@ -3,7 +3,9 @@ import { Schematic } from "../../Schematic"
|
|
|
3
3
|
export const Diode = () => {
|
|
4
4
|
return (
|
|
5
5
|
<Schematic style={{ height: 500 }}>
|
|
6
|
-
<
|
|
6
|
+
<board width={10} height={10}>
|
|
7
|
+
<diode name="D1" schX={2} schY={1} />
|
|
8
|
+
</board>
|
|
7
9
|
</Schematic>
|
|
8
10
|
)
|
|
9
11
|
}
|
|
@@ -3,7 +3,9 @@ import { Schematic } from "../../Schematic"
|
|
|
3
3
|
export const Resistor = () => {
|
|
4
4
|
return (
|
|
5
5
|
<Schematic style={{ height: 500 }}>
|
|
6
|
-
<
|
|
6
|
+
<board width={10} height={10}>
|
|
7
|
+
<resistor name="R1" resistance="10 ohm" schX={2} schY={1} />
|
|
8
|
+
</board>
|
|
7
9
|
</Schematic>
|
|
8
10
|
)
|
|
9
11
|
}
|
|
@@ -3,54 +3,46 @@ import { Schematic } from "../Schematic"
|
|
|
3
3
|
export const LEDCircuitReact = () => {
|
|
4
4
|
return (
|
|
5
5
|
<Schematic style={{ height: 500 }}>
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
path={[".
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{/* <trace from=".B1 > port.GND" to=".GND > .gnd" /> */}
|
|
47
|
-
<diode name="D1" schX={6} schY={3.5} schRotation="180deg" />
|
|
48
|
-
<trace path={[".D1 > port.right", ".C1 > .right"]} />
|
|
49
|
-
<trace path={[".D1 > port.left", ".B1 > .RG"]} />
|
|
50
|
-
{/* <trace from=".D1 > .left" to=".B1 > .RG" /> */}
|
|
51
|
-
{/* <trace from=".D1 > .right" to=".C1> .right" /> */}
|
|
52
|
-
<netalias schX={"10mm"} schY={"1.5mm"} net="D0BUS" />
|
|
53
|
-
<trace path={[".B1 > .D0", ".D0BUS"]} />
|
|
6
|
+
<group>
|
|
7
|
+
<resistor name="R1" resistance="10 ohm" schX={2} schY={1}/>
|
|
8
|
+
<capacitor
|
|
9
|
+
name="C1"
|
|
10
|
+
capacitance="10 uF"
|
|
11
|
+
schX={4}
|
|
12
|
+
schY={2}
|
|
13
|
+
symbolName="capacitor_vert"
|
|
14
|
+
/>
|
|
15
|
+
<resistor
|
|
16
|
+
name="R2"
|
|
17
|
+
resistance="10 ohm"
|
|
18
|
+
schX={6}
|
|
19
|
+
schY={1}
|
|
20
|
+
/>
|
|
21
|
+
<trace path={[".R1 > port.right", ".C1 > port.left"]} />
|
|
22
|
+
<trace path={[".C1 > port.right", ".R2 > port.left"]} />
|
|
23
|
+
<powersource voltage={5} schX={1} schY={2} name="main_power" />
|
|
24
|
+
<trace path={[".main_power > port.positive", ".R1 > port.left"]} />
|
|
25
|
+
<trace path={[".main_power > port.negative", ".C1 > port.right"]} />
|
|
26
|
+
<trace path={[".C1 > port.right", ".R2 > port.right"]} />
|
|
27
|
+
<bug
|
|
28
|
+
name="B1"
|
|
29
|
+
schPortArrangement={{
|
|
30
|
+
leftSide: { pins: [3, 2, 1], direction: "top-to-bottom" },
|
|
31
|
+
rightSide: { pins: [6, 5, 4], direction: "top-to-bottom" },
|
|
32
|
+
}}
|
|
33
|
+
// schWidth={4}
|
|
34
|
+
schX={8}
|
|
35
|
+
schY={3}
|
|
36
|
+
pinLabels={{
|
|
37
|
+
1: "PWR",
|
|
38
|
+
2: "NC",
|
|
39
|
+
3: "RG",
|
|
40
|
+
4: "D0",
|
|
41
|
+
5: "D1",
|
|
42
|
+
6: "GND",
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
</group>
|
|
54
46
|
</Schematic>
|
|
55
47
|
)
|
|
56
48
|
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { createProjectBuilder } from "@tscircuit/builder"
|
|
2
|
-
import { useMaybePromise } from "lib/hooks"
|
|
3
|
-
import { Schematic } from "../Schematic"
|
|
4
|
-
|
|
5
|
-
const pb = createProjectBuilder()
|
|
6
|
-
const $elements = pb
|
|
7
|
-
.addGroup((gb) =>
|
|
8
|
-
gb
|
|
9
|
-
.addResistor((rb) =>
|
|
10
|
-
rb
|
|
11
|
-
.setSourceProperties({
|
|
12
|
-
resistance: "10 ohm",
|
|
13
|
-
name: "R1",
|
|
14
|
-
})
|
|
15
|
-
.setSchematicCenter(2, 1)
|
|
16
|
-
)
|
|
17
|
-
.addCapacitor((cb) =>
|
|
18
|
-
cb
|
|
19
|
-
.setSourceProperties({
|
|
20
|
-
name: "C1",
|
|
21
|
-
capacitance: "10 uF",
|
|
22
|
-
})
|
|
23
|
-
.setSchematicCenter(4, 2)
|
|
24
|
-
.setSchematicRotation("90deg")
|
|
25
|
-
)
|
|
26
|
-
.addResistor((cb) =>
|
|
27
|
-
cb
|
|
28
|
-
.setSourceProperties({
|
|
29
|
-
resistance: "10 ohm",
|
|
30
|
-
name: "R2",
|
|
31
|
-
})
|
|
32
|
-
.setSchematicCenter(6, 1)
|
|
33
|
-
.setSchematicRotation("90deg")
|
|
34
|
-
)
|
|
35
|
-
.addTrace([".R1 > port.right", ".C1 > port.left", ".R2 > port.left"])
|
|
36
|
-
.addPowerSource((cb) =>
|
|
37
|
-
cb
|
|
38
|
-
.setSourceProperties({
|
|
39
|
-
voltage: "5V",
|
|
40
|
-
name: "main_power",
|
|
41
|
-
})
|
|
42
|
-
.setSchematicCenter(1, 2)
|
|
43
|
-
)
|
|
44
|
-
.addTrace(["power > port.positive", ".R1 > port.left"])
|
|
45
|
-
.addTrace([
|
|
46
|
-
"power > port.negative",
|
|
47
|
-
".C1 > port.right",
|
|
48
|
-
".R2 > port.right",
|
|
49
|
-
])
|
|
50
|
-
.addBug((cb) =>
|
|
51
|
-
cb
|
|
52
|
-
.setSourceProperties({ name: "B1" })
|
|
53
|
-
.setSchematicProperties({
|
|
54
|
-
port_arrangement: {
|
|
55
|
-
left_size: 3,
|
|
56
|
-
right_size: 3,
|
|
57
|
-
},
|
|
58
|
-
})
|
|
59
|
-
.labelPort(1, "PWR")
|
|
60
|
-
.labelPort(2, "NC")
|
|
61
|
-
.labelPort(3, "RG")
|
|
62
|
-
.labelPort(4, "D0")
|
|
63
|
-
.labelPort(5, "D1")
|
|
64
|
-
.labelPort(6, "GND")
|
|
65
|
-
.setSchematicCenter(8, 3)
|
|
66
|
-
)
|
|
67
|
-
.addTrace([".B1 > port.PWR", ".R2 > port.left"])
|
|
68
|
-
.addGround((cb) =>
|
|
69
|
-
cb
|
|
70
|
-
.setSourceProperties({
|
|
71
|
-
name: "GND",
|
|
72
|
-
})
|
|
73
|
-
.setSchematicCenter(11, 3)
|
|
74
|
-
)
|
|
75
|
-
.addTrace([".B1 > port.GND", ".gnd"])
|
|
76
|
-
.addDiode((db) =>
|
|
77
|
-
db
|
|
78
|
-
.setSourceProperties({ name: "D1" })
|
|
79
|
-
.setSchematicCenter(6, 3.5)
|
|
80
|
-
.setSchematicRotation("180deg")
|
|
81
|
-
)
|
|
82
|
-
.addTrace([".D1 > .left", ".B1 > .RG"])
|
|
83
|
-
.addTrace([".D1 > .right", ".C1 > .right"])
|
|
84
|
-
)
|
|
85
|
-
.build(pb.createBuildContext())
|
|
86
|
-
|
|
87
|
-
export default () => {
|
|
88
|
-
const elements = useMaybePromise($elements)
|
|
89
|
-
if (!elements) return null
|
|
90
|
-
return (
|
|
91
|
-
<>
|
|
92
|
-
<Schematic style={{ height: 400 }} elements={elements} />
|
|
93
|
-
<pre>{JSON.stringify(elements, null, " ")}</pre>
|
|
94
|
-
</>
|
|
95
|
-
)
|
|
96
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { useMaybePromise } from "lib/hooks"
|
|
2
|
-
import { ProjectClass } from "@tscircuit/builder"
|
|
3
|
-
import * as Types from "lib/types"
|
|
4
|
-
import * as Components from "./"
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
project: Types.Project | Promise<Types.Project>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated use SchematicElement instead because we're most likely
|
|
12
|
-
* deprecating projects
|
|
13
|
-
*/
|
|
14
|
-
export const ProjectComponent = ({ project: $project }: Props) => {
|
|
15
|
-
const project = useMaybePromise($project)
|
|
16
|
-
|
|
17
|
-
if (!project) return <span>loading</span>
|
|
18
|
-
|
|
19
|
-
const projectClass = new ProjectClass(project as any)
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<>
|
|
23
|
-
{project.schematic_components.map((schematic_component) => (
|
|
24
|
-
<Components.SchematicComponent
|
|
25
|
-
key={schematic_component.schematic_component_id}
|
|
26
|
-
component={
|
|
27
|
-
{
|
|
28
|
-
source: projectClass.getSourceComponent(
|
|
29
|
-
schematic_component.source_component_id
|
|
30
|
-
),
|
|
31
|
-
schematic: schematic_component,
|
|
32
|
-
} as any
|
|
33
|
-
}
|
|
34
|
-
/>
|
|
35
|
-
))}
|
|
36
|
-
{project.schematic_ports.map((schematic_port) => (
|
|
37
|
-
<Components.SchematicPort
|
|
38
|
-
key={schematic_port.schematic_port_id}
|
|
39
|
-
port={
|
|
40
|
-
{
|
|
41
|
-
source: projectClass.getSourcePort(
|
|
42
|
-
schematic_port.schematic_port_id
|
|
43
|
-
),
|
|
44
|
-
schematic: schematic_port,
|
|
45
|
-
} as any
|
|
46
|
-
}
|
|
47
|
-
/>
|
|
48
|
-
))}
|
|
49
|
-
{project.schematic_traces.map((schematic_trace) => (
|
|
50
|
-
<Components.SchematicTrace
|
|
51
|
-
key={schematic_trace.schematic_trace_id}
|
|
52
|
-
trace={{
|
|
53
|
-
source: projectClass.getSourceTrace(
|
|
54
|
-
schematic_trace.source_trace_id
|
|
55
|
-
),
|
|
56
|
-
schematic: schematic_trace,
|
|
57
|
-
}}
|
|
58
|
-
/>
|
|
59
|
-
))}
|
|
60
|
-
{project.schematic_texts.map((schematic_text) => (
|
|
61
|
-
<Components.SchematicText
|
|
62
|
-
key={schematic_text.schematic_text_id}
|
|
63
|
-
schematic_text={schematic_text}
|
|
64
|
-
/>
|
|
65
|
-
))}
|
|
66
|
-
</>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default ProjectComponent
|