@tscircuit/schematic-viewer 1.4.2 → 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 -2485
- 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 -246
- 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
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
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { AnyCircuitElement } from 'circuit-json';
|
|
3
|
-
import React from 'react';
|
|
4
2
|
|
|
5
|
-
interface
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
showTable?: boolean;
|
|
10
|
-
_soupPostProcessor?: (soup: AnyCircuitElement[]) => AnyCircuitElement[];
|
|
3
|
+
interface Props {
|
|
4
|
+
circuitJson: Array<{
|
|
5
|
+
type: string;
|
|
6
|
+
}>;
|
|
11
7
|
}
|
|
12
|
-
declare const
|
|
13
|
-
declare const SchematicWithoutContext: ({ children, soup, style, showTable, _soupPostProcessor, }: SchematicProps) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
declare const SchematicViewer: ({ circuitJson }: Props) => react_jsx_runtime.JSX.Element;
|
|
14
9
|
|
|
15
|
-
export {
|
|
10
|
+
export { SchematicViewer };
|