@tscircuit/schematic-viewer 1.4.3 → 2.0.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 +16 -26
- package/biome.json +8 -1
- package/bun.lockb +0 -0
- package/cosmos.config.json +3 -0
- package/cosmos.decorator.tsx +3 -0
- package/dist/index.d.ts +6 -11
- package/dist/index.js +54 -2488
- package/dist/index.js.map +1 -1
- package/examples/resistor-and-capacitor.fixture.tsx +14 -0
- package/index.html +12 -0
- package/lib/components/SchematicViewer.tsx +78 -0
- package/lib/dev/render-to-circuit-json.ts +8 -0
- package/lib/index.ts +1 -0
- package/package.json +27 -74
- package/src/main.tsx +20 -0
- package/test.ts +0 -0
- package/tsconfig.json +28 -25
- package/vite.config.js +12 -4
- package/.codesandbox/tasks.json +0 -36
- package/.github/workflows/chromatic.yml +0 -30
- package/.github/workflows/npm-build.yml +0 -26
- package/.github/workflows/npm-typecheck.yml +0 -26
- package/.github/workflows/release.yml +0 -29
- package/.prettierrc +0 -1
- package/.storybook/main.ts +0 -12
- package/.storybook/preview.ts +0 -17
- package/ava.config.js +0 -7
- package/dist/index.css +0 -7
- package/dist/index.css.map +0 -1
- package/next-env.d.ts +0 -5
- package/parsel.d.ts +0 -81
- package/release.config.js +0 -15
- package/renovate.json +0 -17
- package/src/Schematic.tsx +0 -250
- package/src/index.ts +0 -1
- package/src/lib/hooks/index.ts +0 -1
- package/src/lib/hooks/use-maybe-promise.ts +0 -14
- package/src/lib/render-context/index.ts +0 -28
- package/src/lib/types/core.ts +0 -181
- package/src/lib/types/index.ts +0 -4
- package/src/lib/types/route-solver.ts +0 -10
- package/src/lib/types/source-component.ts +0 -73
- package/src/lib/types/util.ts +0 -52
- package/src/lib/utils/collect-element-refs.ts +0 -45
- package/src/lib/utils/colors.ts +0 -235
- package/src/lib/utils/direction-to-vec.ts +0 -50
- package/src/lib/utils/get-rotation-from-anchor-side.ts +0 -11
- package/src/lib/utils/get-svg-path-bounds.ts +0 -22
- package/src/lib/utils/get-vec-from-anchor-side.ts +0 -11
- package/src/lib/utils/point-math.ts +0 -26
- package/src/pages/_app.tsx +0 -23
- package/src/pages/index.tsx +0 -10
- package/src/pages/led-circuit-react.tsx +0 -54
- package/src/pages/style.css +0 -5
- package/src/schematic-components/ContextProviders.tsx +0 -15
- package/src/schematic-components/DebugPoint.tsx +0 -25
- package/src/schematic-components/RenderError.tsx +0 -23
- package/src/schematic-components/SVGPathComponent.tsx +0 -183
- package/src/schematic-components/SVGPathComponent2.tsx +0 -76
- package/src/schematic-components/SchematicChip.tsx +0 -202
- package/src/schematic-components/SchematicComponent.tsx +0 -51
- package/src/schematic-components/SchematicComponentFromSymbol.tsx +0 -46
- package/src/schematic-components/SchematicElement.tsx +0 -43
- package/src/schematic-components/SchematicGroup.tsx +0 -3
- package/src/schematic-components/SchematicNetLabel.tsx +0 -63
- package/src/schematic-components/SchematicText.tsx +0 -44
- package/src/schematic-components/SchematicTrace.tsx +0 -51
- package/src/schematic-components/TableViewer.tsx +0 -13
- package/src/schematic-components/index.tsx +0 -9
- package/src/stories/basics/schematic-net-label.stories.tsx +0 -138
- package/src/stories/basics/schematic-net-labels-2.stories.tsx +0 -35
- package/src/stories/bug-connections.stories.tsx +0 -31
- package/src/stories/bug-high-port-numbers.stories.tsx +0 -130
- package/src/stories/bug-one-sided.stories.tsx +0 -34
- package/src/stories/bug-pin-spacing.stories.tsx +0 -52
- package/src/stories/bugs/bug1-y-flip.stories.tsx +0 -20
- package/src/stories/bugs/bug2-component-bounds.stories.tsx +0 -62
- package/src/stories/bugs/bug3-scaling-trace.stories.tsx +0 -24
- package/src/stories/bugs/bug4-schematic-line.stories.tsx +0 -17
- package/src/stories/bugs/bug5-diode.stories.tsx +0 -16
- package/src/stories/bugs/bug6-trace-scaling.stories.tsx +0 -18
- package/src/stories/bugs/bug7-multiple-schematic-panning.stories.tsx +0 -23
- package/src/stories/bugs/bug8-autolayout.stories.tsx +0 -43
- package/src/stories/circuit-components/diode.stories.tsx +0 -16
- package/src/stories/circuit-components/netalias.stories.tsx +0 -14
- package/src/stories/circuit-components/resistor.stories.tsx +0 -16
- package/src/stories/component-drawing-example.stories.tsx +0 -17
- package/src/stories/led-circuit-react.stories.tsx +0 -48
- package/src/stories/net-alias.stories.tsx +0 -92
- package/src/stories/off-center-render.stories.tsx +0 -29
- package/src/stories/rotated-resistor.stories.tsx +0 -23
- package/src/stories/schematic-path.stories.tsx +0 -40
- package/src/stories/three-sided-bug.stories.tsx +0 -30
- package/tsconfig.tsbuildinfo +0 -1
- package/tsup.config.ts +0 -8
- package/vercel.json +0 -3
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { SchematicText as SchematicTextType } from "circuit-json"
|
|
2
|
-
import { useGlobalStore } from "lib/render-context"
|
|
3
|
-
import useMeasure from "react-use-measure"
|
|
4
|
-
import { applyToPoint } from "transformation-matrix"
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
schematic_text: SchematicTextType
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const SchematicText = ({ schematic_text }: Props) => {
|
|
11
|
-
const ct = useGlobalStore((s) => s.camera_transform)
|
|
12
|
-
const { text, position, anchor } = schematic_text
|
|
13
|
-
const tPos = applyToPoint(ct, position)
|
|
14
|
-
const [boundsRef, bounds] = useMeasure()
|
|
15
|
-
let offset = [0, 0]
|
|
16
|
-
if (anchor === "center") {
|
|
17
|
-
offset = [-bounds.width / 2, -bounds.height / 2]
|
|
18
|
-
} else if (anchor === "left") {
|
|
19
|
-
offset = [0, -bounds.height / 2]
|
|
20
|
-
} else if (anchor === "right") {
|
|
21
|
-
offset = [-bounds.width, -bounds.height / 2]
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const fontTransformRatio = 0.15 // magic number (roughly 0.1mm = 12px)
|
|
25
|
-
const projectedTextSize = fontTransformRatio * ct.a
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<div
|
|
29
|
-
ref={boundsRef}
|
|
30
|
-
style={{
|
|
31
|
-
fontFamily: "'IBM Plex Mono', monospace",
|
|
32
|
-
position: "absolute",
|
|
33
|
-
fontSize: projectedTextSize,
|
|
34
|
-
left: tPos.x + offset[0],
|
|
35
|
-
top: tPos.y + offset[1],
|
|
36
|
-
color: schematic_text.color,
|
|
37
|
-
}}
|
|
38
|
-
>
|
|
39
|
-
{text}
|
|
40
|
-
</div>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default SchematicText
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type * as Type from "lib/types"
|
|
2
|
-
import { colorMap } from "lib/utils/colors"
|
|
3
|
-
import getSVGPathBounds from "lib/utils/get-svg-path-bounds"
|
|
4
|
-
import Path from "svg-path-generator"
|
|
5
|
-
import RenderError from "./RenderError"
|
|
6
|
-
import SVGPathComponent from "./SVGPathComponent"
|
|
7
|
-
|
|
8
|
-
interface Props {
|
|
9
|
-
trace: {
|
|
10
|
-
source: Type.SourceTrace
|
|
11
|
-
schematic: Type.SchematicTrace
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const SchematicTrace = ({ trace: { source, schematic } }: Props) => {
|
|
16
|
-
const edges = schematic.edges
|
|
17
|
-
if (edges.length === 0) {
|
|
18
|
-
return (
|
|
19
|
-
<RenderError text={`Route with 0 edges (${source.source_trace_id})`} />
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
const path = Path()
|
|
23
|
-
for (let i = 0; i < edges.length; i++) {
|
|
24
|
-
path.moveTo(edges[i].from.x, edges[i].from.y)
|
|
25
|
-
path.lineTo(edges[i].to.x, edges[i].to.y)
|
|
26
|
-
}
|
|
27
|
-
const d = path.toString()
|
|
28
|
-
const pathBounds = getSVGPathBounds(d)
|
|
29
|
-
pathBounds.height = Math.max(pathBounds.height, 1)
|
|
30
|
-
pathBounds.width = Math.max(pathBounds.width, 1)
|
|
31
|
-
const center = {
|
|
32
|
-
x: pathBounds.minX + pathBounds.width / 2,
|
|
33
|
-
y: pathBounds.minY + pathBounds.height / 2,
|
|
34
|
-
}
|
|
35
|
-
return (
|
|
36
|
-
<SVGPathComponent
|
|
37
|
-
rotation={0}
|
|
38
|
-
center={center}
|
|
39
|
-
size={pathBounds}
|
|
40
|
-
paths={[
|
|
41
|
-
{
|
|
42
|
-
stroke: colorMap.schematic.wire,
|
|
43
|
-
strokeWidth: 0.01,
|
|
44
|
-
d,
|
|
45
|
-
},
|
|
46
|
-
]}
|
|
47
|
-
/>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default SchematicTrace
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { lazy, Suspense } from "react"
|
|
2
|
-
|
|
3
|
-
const LazyTableViewer = lazy(() =>
|
|
4
|
-
import("@tscircuit/table-viewer").then((m) => ({
|
|
5
|
-
default: m.SoupTableViewer,
|
|
6
|
-
})),
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
export const TableViewer = (params: Parameters<typeof LazyTableViewer>[0]) => (
|
|
10
|
-
<Suspense fallback={<div>Loading...</div>}>
|
|
11
|
-
<LazyTableViewer {...params} />
|
|
12
|
-
</Suspense>
|
|
13
|
-
)
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "./ContextProviders"
|
|
2
|
-
export * from "./RenderError"
|
|
3
|
-
export * from "./SchematicChip"
|
|
4
|
-
export * from "./SchematicComponent"
|
|
5
|
-
export * from "./SchematicComponentFromSymbol"
|
|
6
|
-
export * from "./SchematicGroup"
|
|
7
|
-
export * from "./SchematicText"
|
|
8
|
-
export * from "./SchematicTrace"
|
|
9
|
-
export * from "./SVGPathComponent"
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { Schematic } from "../../Schematic"
|
|
2
|
-
|
|
3
|
-
export const SchematicNetLabel = () => {
|
|
4
|
-
return (
|
|
5
|
-
<Schematic
|
|
6
|
-
style={{ height: 500 }}
|
|
7
|
-
soup={[
|
|
8
|
-
{
|
|
9
|
-
type: "source_component",
|
|
10
|
-
source_component_id: "simple_resistor_0",
|
|
11
|
-
name: "R1",
|
|
12
|
-
supplier_part_numbers: {},
|
|
13
|
-
ftype: "simple_resistor",
|
|
14
|
-
resistance: 100,
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
type: "schematic_component",
|
|
18
|
-
source_component_id: "simple_resistor_0",
|
|
19
|
-
schematic_component_id: "schematic_component_simple_resistor_0",
|
|
20
|
-
rotation: 0,
|
|
21
|
-
size: {
|
|
22
|
-
width: 1,
|
|
23
|
-
height: 0.3,
|
|
24
|
-
},
|
|
25
|
-
center: {
|
|
26
|
-
x: 0,
|
|
27
|
-
y: 0,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
type: "source_port",
|
|
32
|
-
name: "left",
|
|
33
|
-
source_port_id: "source_port_0",
|
|
34
|
-
source_component_id: "simple_resistor_0",
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
type: "schematic_port",
|
|
38
|
-
schematic_port_id: "schematic_port_0",
|
|
39
|
-
source_port_id: "source_port_0",
|
|
40
|
-
center: {
|
|
41
|
-
x: -0.5,
|
|
42
|
-
y: 0,
|
|
43
|
-
},
|
|
44
|
-
facing_direction: "left",
|
|
45
|
-
schematic_component_id: "schematic_component_simple_resistor_0",
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
type: "source_port",
|
|
49
|
-
name: "right",
|
|
50
|
-
source_port_id: "source_port_1",
|
|
51
|
-
source_component_id: "simple_resistor_0",
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
type: "schematic_port",
|
|
55
|
-
schematic_port_id: "schematic_port_1",
|
|
56
|
-
source_port_id: "source_port_1",
|
|
57
|
-
center: {
|
|
58
|
-
x: 0.5,
|
|
59
|
-
y: 0,
|
|
60
|
-
},
|
|
61
|
-
facing_direction: "right",
|
|
62
|
-
schematic_component_id: "schematic_component_simple_resistor_0",
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
type: "schematic_text",
|
|
66
|
-
text: "R1",
|
|
67
|
-
schematic_text_id: "schematic_text_0",
|
|
68
|
-
schematic_component_id: "schematic_component_simple_resistor_0",
|
|
69
|
-
anchor: "left",
|
|
70
|
-
position: {
|
|
71
|
-
x: -0.2,
|
|
72
|
-
y: -0.5,
|
|
73
|
-
},
|
|
74
|
-
rotation: 0,
|
|
75
|
-
color: "black",
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
type: "schematic_text",
|
|
79
|
-
text: "100",
|
|
80
|
-
schematic_text_id: "schematic_text_1",
|
|
81
|
-
schematic_component_id: "schematic_component_simple_resistor_0",
|
|
82
|
-
anchor: "left",
|
|
83
|
-
position: {
|
|
84
|
-
x: -0.2,
|
|
85
|
-
y: -0.3,
|
|
86
|
-
},
|
|
87
|
-
rotation: 0,
|
|
88
|
-
color: "black",
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
type: "source_net",
|
|
92
|
-
member_source_group_ids: [],
|
|
93
|
-
source_net_id: "net_0",
|
|
94
|
-
name: "N1",
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
type: "source_trace",
|
|
98
|
-
connected_source_port_ids: ["source_port_1"],
|
|
99
|
-
connected_source_net_ids: ["net_0"],
|
|
100
|
-
source_trace_id: "source_trace_0",
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
type: "schematic_net_label",
|
|
104
|
-
source_net_id: "net_0",
|
|
105
|
-
text: "N1",
|
|
106
|
-
anchor_side: "left",
|
|
107
|
-
center: {
|
|
108
|
-
x: 1.5,
|
|
109
|
-
y: 0,
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
type: "schematic_trace",
|
|
114
|
-
schematic_trace_id: "schematic_trace_0",
|
|
115
|
-
source_trace_id: "source_trace_0",
|
|
116
|
-
edges: [
|
|
117
|
-
{
|
|
118
|
-
from: {
|
|
119
|
-
x: 0.5,
|
|
120
|
-
y: 0,
|
|
121
|
-
},
|
|
122
|
-
to: {
|
|
123
|
-
x: 1.5,
|
|
124
|
-
y: 0,
|
|
125
|
-
},
|
|
126
|
-
from_schematic_port_id: "schematic_port_1",
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
},
|
|
130
|
-
]}
|
|
131
|
-
/>
|
|
132
|
-
)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export default {
|
|
136
|
-
title: "Basics/SchematicNetLabel",
|
|
137
|
-
component: SchematicNetLabel,
|
|
138
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Schematic } from "../../Schematic"
|
|
2
|
-
|
|
3
|
-
export const SchematicNetLabel2 = () => {
|
|
4
|
-
return (
|
|
5
|
-
<Schematic style={{ height: 500 }}>
|
|
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>
|
|
28
|
-
</Schematic>
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export default {
|
|
33
|
-
title: "Basics/SchematicNetLabel2",
|
|
34
|
-
component: SchematicNetLabel2,
|
|
35
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Schematic } from "Schematic"
|
|
2
|
-
|
|
3
|
-
export const BugConnections = () => {
|
|
4
|
-
return (
|
|
5
|
-
<Schematic style={{ height: 600 }}>
|
|
6
|
-
<board width={10} height={10}>
|
|
7
|
-
<bug
|
|
8
|
-
name="B1"
|
|
9
|
-
schPortArrangement={{
|
|
10
|
-
leftSize: 3,
|
|
11
|
-
rightSize: 2,
|
|
12
|
-
}}
|
|
13
|
-
schHeight={5}
|
|
14
|
-
schWidth={3}
|
|
15
|
-
schPinSpacing={2}
|
|
16
|
-
schX={8}
|
|
17
|
-
schY={3}
|
|
18
|
-
pinLabels={{
|
|
19
|
-
"1": "D0",
|
|
20
|
-
"2": "D1",
|
|
21
|
-
}}
|
|
22
|
-
/>
|
|
23
|
-
</board>
|
|
24
|
-
</Schematic>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default {
|
|
29
|
-
title: "BugConnections",
|
|
30
|
-
component: BugConnections,
|
|
31
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { Circuit } from "@tscircuit/core"
|
|
2
|
-
import { Schematic } from "Schematic"
|
|
3
|
-
|
|
4
|
-
export const BugHighPortNumbers = () => {
|
|
5
|
-
const circuit = new Circuit()
|
|
6
|
-
|
|
7
|
-
circuit.add(
|
|
8
|
-
<board
|
|
9
|
-
width={10}
|
|
10
|
-
height={10}
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
>
|
|
13
|
-
<chip
|
|
14
|
-
name="U1"
|
|
15
|
-
manufacturerPartNumber="part-number"
|
|
16
|
-
schPortArrangement={{
|
|
17
|
-
leftSide: {
|
|
18
|
-
pins: [16, 15, 20, 17, 4, 27, 28, 19, 26, 25, 7, 18, 21],
|
|
19
|
-
direction: "top-to-bottom",
|
|
20
|
-
},
|
|
21
|
-
rightSide: {
|
|
22
|
-
pins: [1, 5, 11, 3, 2, 9, 10, 6, 23, 22, 14, 13, 12],
|
|
23
|
-
direction: "top-to-bottom",
|
|
24
|
-
},
|
|
25
|
-
bottomSide: {
|
|
26
|
-
pins: [29],
|
|
27
|
-
direction: "left-to-right",
|
|
28
|
-
},
|
|
29
|
-
topSide: {
|
|
30
|
-
pins: [30],
|
|
31
|
-
direction: "left-to-right",
|
|
32
|
-
},
|
|
33
|
-
}}
|
|
34
|
-
schWidth={3}
|
|
35
|
-
schHeight={6}
|
|
36
|
-
footprint="ssop28Db"
|
|
37
|
-
pinLabels={{
|
|
38
|
-
"1": "TXD",
|
|
39
|
-
"5": "RXD",
|
|
40
|
-
"11": "CTS",
|
|
41
|
-
"3": "RTS",
|
|
42
|
-
"2": "DTR",
|
|
43
|
-
"9": "DSR",
|
|
44
|
-
"10": "DCD",
|
|
45
|
-
"6": "RI",
|
|
46
|
-
"23": "TXLED",
|
|
47
|
-
"22": "RXLED",
|
|
48
|
-
"14": "PWRUN",
|
|
49
|
-
"13": "TXDEN",
|
|
50
|
-
"12": "SLEEP",
|
|
51
|
-
"16": "USBDM",
|
|
52
|
-
"15": "USBDP",
|
|
53
|
-
"20": "VCC",
|
|
54
|
-
"17": "3V3OUT",
|
|
55
|
-
"4": "VCCIO",
|
|
56
|
-
"27": "OSCI",
|
|
57
|
-
"28": "OSCO",
|
|
58
|
-
"19": "RESET",
|
|
59
|
-
"26": "TEST",
|
|
60
|
-
"25": "AGND",
|
|
61
|
-
"7": "GND7",
|
|
62
|
-
"18": "GND18",
|
|
63
|
-
"21": "GND21",
|
|
64
|
-
}}
|
|
65
|
-
/>
|
|
66
|
-
<resistor
|
|
67
|
-
resistance="1kohm"
|
|
68
|
-
name="R1"
|
|
69
|
-
footprint="0805"
|
|
70
|
-
schX={3}
|
|
71
|
-
schY={-1}
|
|
72
|
-
symbolName="boxresistor_vert"
|
|
73
|
-
/>
|
|
74
|
-
<resistor
|
|
75
|
-
resistance="1kohm"
|
|
76
|
-
name="R2"
|
|
77
|
-
footprint="0805"
|
|
78
|
-
schX={4.5}
|
|
79
|
-
schY={-1}
|
|
80
|
-
symbolName="boxresistor_vert"
|
|
81
|
-
/>
|
|
82
|
-
<diode
|
|
83
|
-
name="LED1"
|
|
84
|
-
footprint="0805"
|
|
85
|
-
symbolName="diode_vert"
|
|
86
|
-
schX={3}
|
|
87
|
-
schY={2}
|
|
88
|
-
/>
|
|
89
|
-
<diode
|
|
90
|
-
name="LED2"
|
|
91
|
-
footprint="0805"
|
|
92
|
-
symbolName="diode_vert"
|
|
93
|
-
schX={4.5}
|
|
94
|
-
schY={2}
|
|
95
|
-
/>
|
|
96
|
-
<netalias net="5V" schX={3} schY={-2} />
|
|
97
|
-
<netalias net="5V" schX={4.5} schY={-2} />
|
|
98
|
-
{/* <trace path={[".5V", ".R2 > port.left"]} />
|
|
99
|
-
<trace path={[".5V", ".R1 > port.left"]} /> */}
|
|
100
|
-
<trace path={[".R1 > port.right", ".LED1 > port.left"]} />
|
|
101
|
-
<trace path={[".R2 > port.right", ".LED2 > port.left"]} />
|
|
102
|
-
<trace path={[".LED1 > port.right", ".U1 > .pin20"]} />
|
|
103
|
-
<trace path={[".LED2 > port.right", ".U1 > .pin6"]} />
|
|
104
|
-
<netalias net="GND" schX={-3} schY={4} schRotation="180deg" />
|
|
105
|
-
<netalias net="GND" schX={-5} schY={3} schRotation="180deg" />
|
|
106
|
-
<netalias net="GND" schX={-6} schY={3} schRotation="180deg" />
|
|
107
|
-
<netalias net="GND" schX={-7} schY={3} schRotation="180deg" />
|
|
108
|
-
<netalias net="GND" schX={-8} schY={2} schRotation="180deg" />
|
|
109
|
-
{/* <component>
|
|
110
|
-
<schematicbox
|
|
111
|
-
name="USB"
|
|
112
|
-
center={[-9, 0]}
|
|
113
|
-
type="schematic_box"
|
|
114
|
-
drawing_type="box"
|
|
115
|
-
width={2}
|
|
116
|
-
height={2}
|
|
117
|
-
/>
|
|
118
|
-
</component> */}
|
|
119
|
-
</board>,
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
const circuitJson = circuit.getCircuitJson()
|
|
123
|
-
|
|
124
|
-
return <Schematic soup={circuitJson as any} style={{ height: 600 }} />
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export default {
|
|
128
|
-
title: "BugHighPortNumbers",
|
|
129
|
-
component: BugHighPortNumbers,
|
|
130
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Schematic } from "Schematic"
|
|
2
|
-
|
|
3
|
-
const OneSidedBugExample = () => (
|
|
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>
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
export const OneSidedBug = () => {
|
|
24
|
-
return (
|
|
25
|
-
<Schematic style={{ height: 600 }}>
|
|
26
|
-
<OneSidedBugExample />
|
|
27
|
-
</Schematic>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default {
|
|
32
|
-
title: "OneSidedBug",
|
|
33
|
-
component: OneSidedBug,
|
|
34
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Schematic } from "Schematic"
|
|
2
|
-
|
|
3
|
-
const BugPinSpacingExample = () => (
|
|
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>
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
export const BugPinSpacing = () => {
|
|
26
|
-
return (
|
|
27
|
-
<Schematic
|
|
28
|
-
style={{ height: 600 }}
|
|
29
|
-
_soupPostProcessor={(soup) => {
|
|
30
|
-
return soup.map((elm) => {
|
|
31
|
-
if (elm.type === "schematic_component") {
|
|
32
|
-
// return {
|
|
33
|
-
// ...elm,
|
|
34
|
-
// size: { width: 3, height: 3 },
|
|
35
|
-
// pin_spacing: 1.5,
|
|
36
|
-
// }
|
|
37
|
-
console.log(elm)
|
|
38
|
-
return elm
|
|
39
|
-
}
|
|
40
|
-
return elm
|
|
41
|
-
})
|
|
42
|
-
}}
|
|
43
|
-
>
|
|
44
|
-
<BugPinSpacingExample />
|
|
45
|
-
</Schematic>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export default {
|
|
50
|
-
title: "BugPinSpacing",
|
|
51
|
-
component: BugPinSpacing,
|
|
52
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Schematic } from "Schematic"
|
|
2
|
-
|
|
3
|
-
export const Bug1YFlip = () => {
|
|
4
|
-
return (
|
|
5
|
-
<Schematic style={{ height: 600 }}>
|
|
6
|
-
<board width={10} height={10}>
|
|
7
|
-
<bug
|
|
8
|
-
name="U1"
|
|
9
|
-
schPortArrangement={{ topSize: 2 }}
|
|
10
|
-
pinLabels={{ 1: "foo", 2: "baz" }}
|
|
11
|
-
/>
|
|
12
|
-
</board>
|
|
13
|
-
</Schematic>
|
|
14
|
-
)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default {
|
|
18
|
-
title: "Bugs/Bug1YFlip",
|
|
19
|
-
component: Bug1YFlip,
|
|
20
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Schematic } from "Schematic"
|
|
2
|
-
|
|
3
|
-
const Battery = ({
|
|
4
|
-
name,
|
|
5
|
-
center,
|
|
6
|
-
pcb_x,
|
|
7
|
-
pcb_y,
|
|
8
|
-
}: {
|
|
9
|
-
name: string
|
|
10
|
-
center: [number, number]
|
|
11
|
-
pcb_x: number
|
|
12
|
-
pcb_y: number
|
|
13
|
-
}) => (
|
|
14
|
-
<component
|
|
15
|
-
schX={center[0]}
|
|
16
|
-
schY={center[1]}
|
|
17
|
-
name={name}
|
|
18
|
-
pcbX={pcb_x}
|
|
19
|
-
pcbY={pcb_y}
|
|
20
|
-
supplierPartNumbers={{
|
|
21
|
-
jlcpcb: ["C70377"],
|
|
22
|
-
}}
|
|
23
|
-
>
|
|
24
|
-
<port name="neg" schX="-1mm" schY="0mm" direction="left" />
|
|
25
|
-
<port name="pos" schX="1mm" schY="0mm" direction="right" />
|
|
26
|
-
<schematicbox width="2mm" height="0.5mm" schX={0} schY={0} />
|
|
27
|
-
<schematictext text={name} schX={0} schY={0} />
|
|
28
|
-
<schematictext text="-" schX={-0.25} schY={-0.125} />
|
|
29
|
-
<schematictext text="+" schX={0.25} schY={-0.125} />
|
|
30
|
-
<smtpad
|
|
31
|
-
shape="rect"
|
|
32
|
-
layer="top"
|
|
33
|
-
pcbX={0}
|
|
34
|
-
pcbY={-26 / 2 - 3 / 2}
|
|
35
|
-
width="4.2mm"
|
|
36
|
-
height="3mm"
|
|
37
|
-
portHints={["pos"]}
|
|
38
|
-
/>
|
|
39
|
-
<smtpad
|
|
40
|
-
shape="rect"
|
|
41
|
-
layer="top"
|
|
42
|
-
pcbX={0}
|
|
43
|
-
pcbY={26 / 2 + 3 / 2}
|
|
44
|
-
width="4.2mm"
|
|
45
|
-
height="3mm"
|
|
46
|
-
portHints={["neg"]}
|
|
47
|
-
/>
|
|
48
|
-
</component>
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
export const Bug2ComponentBounds = () => {
|
|
52
|
-
return (
|
|
53
|
-
<Schematic style={{ height: 600 }}>
|
|
54
|
-
<Battery name="B1" center={[0, 0]} pcb_x={-30} pcb_y={30} />
|
|
55
|
-
</Schematic>
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export default {
|
|
60
|
-
title: "Bugs/Bug2ComponentBounds",
|
|
61
|
-
component: Bug2ComponentBounds,
|
|
62
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Schematic } from "../../Schematic"
|
|
2
|
-
|
|
3
|
-
export const Bug3ScalingTrace = () => {
|
|
4
|
-
return (
|
|
5
|
-
<Schematic style={{ height: 500 }}>
|
|
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>
|
|
17
|
-
</Schematic>
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default {
|
|
22
|
-
title: "Bugs/Bug3ScalingTrace",
|
|
23
|
-
component: Bug3ScalingTrace,
|
|
24
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Schematic } from "../../Schematic"
|
|
2
|
-
|
|
3
|
-
export const Bug4SchematicLine = () => {
|
|
4
|
-
return (
|
|
5
|
-
<Schematic style={{ height: 500 }}>
|
|
6
|
-
{/* <resistor name="R1" resistance="10" schX={2} schY={1} /> */}
|
|
7
|
-
<component name="K1" schX={0} schY={0}>
|
|
8
|
-
<schematicline x1={0} y1={0} x2={0} y2={2} />
|
|
9
|
-
</component>
|
|
10
|
-
</Schematic>
|
|
11
|
-
)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default {
|
|
15
|
-
title: "Bugs/Bug4SchematicLine",
|
|
16
|
-
component: Bug4SchematicLine,
|
|
17
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Schematic } from "../../Schematic"
|
|
2
|
-
|
|
3
|
-
export const Bug5SchematicLine = () => {
|
|
4
|
-
return (
|
|
5
|
-
<Schematic style={{ height: 500 }}>
|
|
6
|
-
<board width={10} height={10}>
|
|
7
|
-
<diode name="D1" />
|
|
8
|
-
</board>
|
|
9
|
-
</Schematic>
|
|
10
|
-
)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
title: "Bugs/Bug5SchematicLine",
|
|
15
|
-
component: Bug5SchematicLine,
|
|
16
|
-
}
|