@tscircuit/schematic-viewer 1.4.3 → 2.0.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/.github/workflows/bun-pver-release.yml +24 -0
- package/.github/workflows/{npm-typecheck.yml → bun-typecheck.yml} +6 -6
- package/LICENSE +21 -0
- 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/examples/resistor-and-capacitor.fixture.tsx +14 -0
- package/index.html +12 -0
- package/lib/components/SchematicViewer.tsx +79 -0
- package/lib/dev/render-to-circuit-json.ts +7 -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/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/dist/index.d.ts +0 -15
- package/dist/index.js +0 -2502
- package/dist/index.js.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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
+
name: Publish to npm
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v3
|
|
12
|
+
- name: Setup bun
|
|
13
|
+
uses: oven-sh/setup-bun@v1
|
|
14
|
+
with:
|
|
15
|
+
bun-version: latest
|
|
16
|
+
- uses: actions/setup-node@v3
|
|
17
|
+
with:
|
|
18
|
+
node-version: 20
|
|
19
|
+
registry-url: https://registry.npmjs.org/
|
|
20
|
+
- run: npm install -g pver
|
|
21
|
+
- run: bun install --frozen-lockfile
|
|
22
|
+
- run: pver release
|
|
23
|
+
env:
|
|
24
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -14,13 +14,13 @@ jobs:
|
|
|
14
14
|
steps:
|
|
15
15
|
- uses: actions/checkout@v3
|
|
16
16
|
|
|
17
|
-
- name:
|
|
18
|
-
uses:
|
|
17
|
+
- name: Setup bun
|
|
18
|
+
uses: oven-sh/setup-bun@v1
|
|
19
19
|
with:
|
|
20
|
-
|
|
20
|
+
bun-version: latest
|
|
21
21
|
|
|
22
22
|
- name: Install dependencies
|
|
23
|
-
run:
|
|
23
|
+
run: bun i
|
|
24
24
|
|
|
25
|
-
- name: Run
|
|
26
|
-
run:
|
|
25
|
+
- name: Run type check
|
|
26
|
+
run: bunx tsc --noEmit
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 tscircuit Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,32 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @tscircuit/schematic-viewer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React component for viewing Circuit JSON or tscircuit as a schematic
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
View schematics from [tscircuit jsx](https://tscircuit.com).
|
|
8
|
-
|
|
9
|
-
## Usage
|
|
5
|
+
> [!WARNING]
|
|
6
|
+
> This is the 2.X.X schematic viewer, you may want to use the [old 1.X.X version](https://github.com/tscircuit/schematic-viewer/tree/v1)
|
|
10
7
|
|
|
11
8
|
```tsx
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
9
|
+
import { SchematicViewer } from "@tscircuit/schematic-viewer"
|
|
10
|
+
|
|
11
|
+
export default () => (
|
|
12
|
+
<SchematicViewer
|
|
13
|
+
circuitJson={renderToCircuitJson(
|
|
14
|
+
<board width="10mm" height="10mm">
|
|
15
|
+
<resistor name="R1" resistance={1000} schX={-2} />
|
|
16
|
+
<capacitor name="C1" capacitance="1uF" schX={2} />
|
|
17
|
+
<trace from=".R1 .pin2" to=".C1 .pin1" />
|
|
18
|
+
</board>
|
|
19
|
+
)}
|
|
20
|
+
/>
|
|
25
21
|
)
|
|
26
|
-
|
|
27
22
|
```
|
|
28
|
-
|
|
29
|
-
## References
|
|
30
|
-
|
|
31
|
-
- [SVG Path Tool](https://yqnn.github.io/svg-path-editor/)
|
|
32
|
-
- [SVG of Electrical Symbols Wikipedia](https://commons.wikimedia.org/wiki/File:Electrical_symbols_library.svg)
|
package/biome.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/1.
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
|
|
3
3
|
"organizeImports": {
|
|
4
4
|
"enabled": true
|
|
5
5
|
},
|
|
@@ -28,7 +28,14 @@
|
|
|
28
28
|
"suspicious": {
|
|
29
29
|
"noExplicitAny": "off"
|
|
30
30
|
},
|
|
31
|
+
"complexity": {
|
|
32
|
+
"noForEach": "info"
|
|
33
|
+
},
|
|
34
|
+
"correctness": {
|
|
35
|
+
"useExhaustiveDependencies": "off"
|
|
36
|
+
},
|
|
31
37
|
"style": {
|
|
38
|
+
"noUselessElse": "off",
|
|
32
39
|
"noNonNullAssertion": "off",
|
|
33
40
|
"useNumberNamespace": "off",
|
|
34
41
|
"useFilenamingConvention": {
|
package/bun.lockb
ADDED
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SchematicViewer } from "lib/components/SchematicViewer"
|
|
2
|
+
import { renderToCircuitJson } from "lib/dev/render-to-circuit-json"
|
|
3
|
+
|
|
4
|
+
export default () => (
|
|
5
|
+
<SchematicViewer
|
|
6
|
+
circuitJson={renderToCircuitJson(
|
|
7
|
+
<board width="10mm" height="10mm">
|
|
8
|
+
<resistor name="R1" resistance={1000} schX={-2} />
|
|
9
|
+
<capacitor name="C1" capacitance="1uF" schX={2} />
|
|
10
|
+
<trace from=".R1 .pin2" to=".C1 .pin1" />
|
|
11
|
+
</board>,
|
|
12
|
+
)}
|
|
13
|
+
/>
|
|
14
|
+
)
|
package/index.html
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>@tscircuit/schematic-viewer</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useMouseMatrixTransform } from "use-mouse-matrix-transform"
|
|
2
|
+
import { convertCircuitJsonToSchematicSvg } from "circuit-to-svg"
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from "react"
|
|
4
|
+
import { toString as transformToString } from "transformation-matrix"
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
circuitJson: Array<{ type: string }>
|
|
8
|
+
containerStyle?: React.CSSProperties
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const SchematicViewer = ({ circuitJson, containerStyle }: Props) => {
|
|
12
|
+
const svgDivRef = useRef<HTMLDivElement>(null)
|
|
13
|
+
const { ref: containerRef } = useMouseMatrixTransform({
|
|
14
|
+
onSetTransform(transform) {
|
|
15
|
+
if (!svgDivRef.current) return
|
|
16
|
+
svgDivRef.current.style.transform = transformToString(transform)
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
const [containerWidth, setContainerWidth] = useState(0)
|
|
20
|
+
const [containerHeight, setContainerHeight] = useState(0)
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!containerRef.current) return
|
|
24
|
+
|
|
25
|
+
const updateDimensions = () => {
|
|
26
|
+
const rect = containerRef.current?.getBoundingClientRect()
|
|
27
|
+
|
|
28
|
+
setContainerWidth(rect?.width || 0)
|
|
29
|
+
setContainerHeight(rect?.height || 0)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Set initial dimensions
|
|
33
|
+
updateDimensions()
|
|
34
|
+
|
|
35
|
+
// Add resize listener
|
|
36
|
+
const resizeObserver = new ResizeObserver(updateDimensions)
|
|
37
|
+
resizeObserver.observe(containerRef.current)
|
|
38
|
+
|
|
39
|
+
// Fallback to window resize
|
|
40
|
+
window.addEventListener("resize", updateDimensions)
|
|
41
|
+
|
|
42
|
+
return () => {
|
|
43
|
+
resizeObserver.disconnect()
|
|
44
|
+
window.removeEventListener("resize", updateDimensions)
|
|
45
|
+
}
|
|
46
|
+
}, [])
|
|
47
|
+
|
|
48
|
+
const svg = useMemo(() => {
|
|
49
|
+
if (!containerWidth || !containerHeight) return ""
|
|
50
|
+
|
|
51
|
+
return convertCircuitJsonToSchematicSvg(circuitJson as any, {
|
|
52
|
+
width: containerWidth,
|
|
53
|
+
height: containerHeight || 720,
|
|
54
|
+
})
|
|
55
|
+
}, [circuitJson, containerWidth, containerHeight])
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div
|
|
59
|
+
ref={containerRef}
|
|
60
|
+
style={{
|
|
61
|
+
backgroundColor: "#F5F1ED",
|
|
62
|
+
overflow: "hidden",
|
|
63
|
+
cursor: "grab",
|
|
64
|
+
minHeight: "300px",
|
|
65
|
+
...containerStyle,
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
<div
|
|
69
|
+
ref={svgDivRef}
|
|
70
|
+
style={{
|
|
71
|
+
pointerEvents: "auto",
|
|
72
|
+
transformOrigin: "0 0",
|
|
73
|
+
}}
|
|
74
|
+
// biome-ignore lint/security/noDangerouslySetInnerHtml: <explanation>
|
|
75
|
+
dangerouslySetInnerHTML={{ __html: svg }}
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
)
|
|
79
|
+
}
|
package/lib/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SchematicViewer } from "./components/SchematicViewer"
|
package/package.json
CHANGED
|
@@ -1,83 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/schematic-viewer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
-
"
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/tscircuit/schematic-viewer.git"
|
|
9
|
-
},
|
|
5
|
+
"type": "module",
|
|
10
6
|
"scripts": {
|
|
11
|
-
"start": "
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"build": "tsup",
|
|
15
|
-
"yalc": "npm run build && yalc push",
|
|
16
|
-
"storybook": "storybook dev -p 6006",
|
|
17
|
-
"build-storybook": "storybook build",
|
|
18
|
-
"chromatic": "npx chromatic --project-token=chpt_d88a6beb0734bbe"
|
|
19
|
-
},
|
|
20
|
-
"peerDependencies": {
|
|
21
|
-
"@tscircuit/table-viewer": "*",
|
|
22
|
-
"react": "*"
|
|
7
|
+
"start": "cosmos",
|
|
8
|
+
"build": "tsup-node ./lib/index.ts --dts --format esm --sourcemap",
|
|
9
|
+
"build:site": "cosmos-export"
|
|
23
10
|
},
|
|
24
11
|
"devDependencies": {
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"@tscircuit/table-viewer": "^0.0.6",
|
|
40
|
-
"@types/node": "^18.6.0",
|
|
41
|
-
"@types/react": "^18.0.15",
|
|
42
|
-
"@vitejs/plugin-react": "^4.3.0",
|
|
43
|
-
"ava": "^4.3.1",
|
|
44
|
-
"chromatic": "^11.5.5",
|
|
45
|
-
"circuit-json": "^0.0.92",
|
|
46
|
-
"esbuild": "^0.20.2",
|
|
47
|
-
"esbuild-register": "^3.5.0",
|
|
48
|
-
"next": "^14.2.3",
|
|
49
|
-
"parse-svg-path": "^0.1.2",
|
|
50
|
-
"react": "^18.2.0",
|
|
51
|
-
"react-dom": "^18.2.0",
|
|
52
|
-
"react-use-measure": "^2.1.1",
|
|
53
|
-
"semantic-release": "^21.0.6",
|
|
54
|
-
"storybook": "^8.1.3",
|
|
55
|
-
"svg-path-bounds": "^1.0.2",
|
|
56
|
-
"svg-path-generator": "^1.1.0",
|
|
57
|
-
"transformation-matrix": "^2.12.0",
|
|
58
|
-
"tsup": "^6.7.0",
|
|
59
|
-
"type-fest": "^2.17.0",
|
|
60
|
-
"typescript": "^5.5.3",
|
|
61
|
-
"vite": "^5.2.11",
|
|
62
|
-
"vite-tsconfig-paths": "^4.3.2",
|
|
63
|
-
"zod": "^3.23.8",
|
|
64
|
-
"zustand": "^4.0.0"
|
|
12
|
+
"@biomejs/biome": "^1.9.4",
|
|
13
|
+
"@tscircuit/core": "^0.0.222",
|
|
14
|
+
"@types/bun": "latest",
|
|
15
|
+
"@types/react": "^19.0.1",
|
|
16
|
+
"@types/react-dom": "^19.0.2",
|
|
17
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
18
|
+
"circuit-json": "^0.0.111",
|
|
19
|
+
"react": "18",
|
|
20
|
+
"react-cosmos": "^6.2.1",
|
|
21
|
+
"react-cosmos-plugin-vite": "^6.2.0",
|
|
22
|
+
"react-dom": "18",
|
|
23
|
+
"tsup": "^8.3.5",
|
|
24
|
+
"vite": "^6.0.3",
|
|
25
|
+
"react-reconciler": "^0.31.0"
|
|
65
26
|
},
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"@tscircuit/core": "^0.0.132",
|
|
69
|
-
"@tscircuit/layout": "^0.0.25",
|
|
70
|
-
"@tscircuit/props": "^0.0.23",
|
|
71
|
-
"@tscircuit/soup-util": "^0.0.38",
|
|
72
|
-
"circuit-to-svg": "^0.0.54",
|
|
73
|
-
"convert-units": "^2.3.4",
|
|
74
|
-
"react-error-boundary": "^4.0.4",
|
|
75
|
-
"react-supergrid": "^1.0.10",
|
|
76
|
-
"schematic-symbols": "^0.0.78",
|
|
77
|
-
"use-mouse-matrix-transform": "^1.1.12"
|
|
78
|
-
},
|
|
79
|
-
"bugs": {
|
|
80
|
-
"url": "https://github.com/tscircuit/schematic-viewer/issues"
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"typescript": "^5.0.0"
|
|
81
29
|
},
|
|
82
|
-
"
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"circuit-to-svg": "^0.0.90",
|
|
32
|
+
"debug": "^4.4.0",
|
|
33
|
+
"performance-now": "^2.1.0",
|
|
34
|
+
"use-mouse-matrix-transform": "^1.1.13"
|
|
35
|
+
}
|
|
83
36
|
}
|
package/src/main.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { createRoot } from "react-dom/client"
|
|
3
|
+
import { renderToCircuitJson } from "lib/dev/render-to-circuit-json"
|
|
4
|
+
import { SchematicViewer } from "lib/components/SchematicViewer"
|
|
5
|
+
|
|
6
|
+
const root = createRoot(document.getElementById("root")!)
|
|
7
|
+
|
|
8
|
+
root.render(
|
|
9
|
+
<React.StrictMode>
|
|
10
|
+
<div style={{ width: "100vw", height: "100vh" }}>
|
|
11
|
+
<SchematicViewer
|
|
12
|
+
circuitJson={renderToCircuitJson(
|
|
13
|
+
<board width="10mm" height="10mm">
|
|
14
|
+
<resistor name="R1" resistance={1000} />
|
|
15
|
+
</board>,
|
|
16
|
+
)}
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
</React.StrictMode>,
|
|
20
|
+
)
|
package/test.ts
ADDED
|
File without changes
|
package/tsconfig.json
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
|
|
4
|
-
"lib": [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
// Enable latest features
|
|
4
|
+
"lib": ["ESNext", "DOM"],
|
|
5
|
+
"target": "ES2020",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
9
|
"allowJs": true,
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
10
|
+
|
|
11
|
+
"baseUrl": ".",
|
|
12
|
+
"paths": {
|
|
13
|
+
"lib/*": ["lib/*"]
|
|
14
|
+
},
|
|
14
15
|
"esModuleInterop": true,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
16
|
+
|
|
17
|
+
// Bundler mode
|
|
18
|
+
"moduleResolution": "bundler",
|
|
19
|
+
"allowImportingTsExtensions": true,
|
|
20
|
+
"verbatimModuleSyntax": true,
|
|
21
|
+
"noEmit": true,
|
|
22
|
+
|
|
23
|
+
// Best practices
|
|
24
|
+
"strict": true,
|
|
25
|
+
"skipLibCheck": true,
|
|
26
|
+
"noFallthroughCasesInSwitch": true,
|
|
27
|
+
|
|
28
|
+
// Some stricter flags (disabled by default)
|
|
29
|
+
"noUnusedLocals": false,
|
|
30
|
+
"noUnusedParameters": false,
|
|
31
|
+
"noPropertyAccessFromIndexSignature": false
|
|
32
|
+
}
|
|
30
33
|
}
|
package/vite.config.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { defineConfig } from "vite"
|
|
2
2
|
import react from "@vitejs/plugin-react"
|
|
3
|
-
import
|
|
3
|
+
import { resolve } from "node:path"
|
|
4
4
|
|
|
5
|
-
export default {
|
|
6
|
-
plugins: [react(),
|
|
7
|
-
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [react()],
|
|
7
|
+
resolve: {
|
|
8
|
+
alias: {
|
|
9
|
+
lib: resolve(__dirname, "./lib"),
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
define: {
|
|
13
|
+
global: {},
|
|
14
|
+
},
|
|
15
|
+
})
|
package/.codesandbox/tasks.json
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// These tasks will run in order when initializing your CodeSandbox project.
|
|
3
|
-
"setupTasks": [
|
|
4
|
-
{
|
|
5
|
-
"name": "Install Dependencies",
|
|
6
|
-
"command": "npm install"
|
|
7
|
-
}
|
|
8
|
-
],
|
|
9
|
-
|
|
10
|
-
// These tasks can be run from CodeSandbox. Running one will open a log in the app.
|
|
11
|
-
"tasks": {
|
|
12
|
-
"start": {
|
|
13
|
-
"name": "start",
|
|
14
|
-
"command": "npm run start",
|
|
15
|
-
"runAtStart": true,
|
|
16
|
-
"preview": {
|
|
17
|
-
"port": 6006
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"typecheck": {
|
|
21
|
-
"name": "typecheck",
|
|
22
|
-
"command": "npm run typecheck",
|
|
23
|
-
"runAtStart": false
|
|
24
|
-
},
|
|
25
|
-
"build": {
|
|
26
|
-
"name": "build",
|
|
27
|
-
"command": "npm run build",
|
|
28
|
-
"runAtStart": false
|
|
29
|
-
},
|
|
30
|
-
"storybook": {
|
|
31
|
-
"name": "storybook",
|
|
32
|
-
"command": "npm run storybook",
|
|
33
|
-
"runAtStart": false
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
name: "Chromatic"
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
pull_request:
|
|
8
|
-
branches:
|
|
9
|
-
- main
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
chromatic:
|
|
13
|
-
name: Run Chromatic
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
steps:
|
|
16
|
-
- name: Checkout code
|
|
17
|
-
uses: actions/checkout@v4
|
|
18
|
-
with:
|
|
19
|
-
fetch-depth: 0
|
|
20
|
-
- uses: actions/setup-node@v4
|
|
21
|
-
with:
|
|
22
|
-
node-version: 20
|
|
23
|
-
- name: Install dependencies
|
|
24
|
-
# ⚠️ See your package manager's documentation for the correct command to install dependencies in a CI environment.
|
|
25
|
-
run: npm ci
|
|
26
|
-
- name: Run Chromatic
|
|
27
|
-
uses: chromaui/action@latest
|
|
28
|
-
with:
|
|
29
|
-
# ⚠️ Make sure to configure a `CHROMATIC_PROJECT_TOKEN` repository secret
|
|
30
|
-
projectToken: chpt_d88a6beb0734bbe
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
-
name: Build
|
|
3
|
-
|
|
4
|
-
on:
|
|
5
|
-
push:
|
|
6
|
-
branches: [main]
|
|
7
|
-
pull_request:
|
|
8
|
-
branches: [main]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
build:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v3
|
|
16
|
-
|
|
17
|
-
- name: Use Node.js
|
|
18
|
-
uses: actions/setup-node@v3
|
|
19
|
-
with:
|
|
20
|
-
node-version: "20"
|
|
21
|
-
|
|
22
|
-
- name: Install dependencies
|
|
23
|
-
run: npm ci
|
|
24
|
-
|
|
25
|
-
- name: Run build
|
|
26
|
-
run: npm run build
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
name: Release
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
release:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- name: Checkout code
|
|
13
|
-
uses: actions/checkout@v3
|
|
14
|
-
|
|
15
|
-
- name: Setup Node.js
|
|
16
|
-
uses: actions/setup-node@v2
|
|
17
|
-
with:
|
|
18
|
-
node-version: 18
|
|
19
|
-
|
|
20
|
-
- name: Install dependencies
|
|
21
|
-
run: npm install
|
|
22
|
-
- name: Build
|
|
23
|
-
run: npm run build
|
|
24
|
-
|
|
25
|
-
- name: Semantic Release
|
|
26
|
-
env:
|
|
27
|
-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
28
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
29
|
-
run: npx semantic-release
|
package/.prettierrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "semi": false }
|
package/.storybook/main.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { StorybookConfig } from "@storybook/react-vite"
|
|
2
|
-
|
|
3
|
-
const config: StorybookConfig = {
|
|
4
|
-
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
|
|
5
|
-
addons: [],
|
|
6
|
-
framework: {
|
|
7
|
-
name: "@storybook/react-vite",
|
|
8
|
-
options: {},
|
|
9
|
-
},
|
|
10
|
-
docs: {},
|
|
11
|
-
}
|
|
12
|
-
export default config
|
package/.storybook/preview.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Preview } from "@storybook/react"
|
|
2
|
-
|
|
3
|
-
import "react-data-grid/lib/styles.css"
|
|
4
|
-
|
|
5
|
-
const preview: Preview = {
|
|
6
|
-
parameters: {
|
|
7
|
-
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
8
|
-
controls: {
|
|
9
|
-
matchers: {
|
|
10
|
-
color: /(background|color)$/i,
|
|
11
|
-
date: /Date$/,
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default preview
|