@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.
Files changed (96) hide show
  1. package/README.md +16 -26
  2. package/biome.json +8 -1
  3. package/bun.lockb +0 -0
  4. package/cosmos.config.json +3 -0
  5. package/cosmos.decorator.tsx +3 -0
  6. package/dist/index.d.ts +6 -11
  7. package/dist/index.js +54 -2488
  8. package/dist/index.js.map +1 -1
  9. package/examples/resistor-and-capacitor.fixture.tsx +14 -0
  10. package/index.html +12 -0
  11. package/lib/components/SchematicViewer.tsx +78 -0
  12. package/lib/dev/render-to-circuit-json.ts +8 -0
  13. package/lib/index.ts +1 -0
  14. package/package.json +27 -74
  15. package/src/main.tsx +20 -0
  16. package/test.ts +0 -0
  17. package/tsconfig.json +28 -25
  18. package/vite.config.js +12 -4
  19. package/.codesandbox/tasks.json +0 -36
  20. package/.github/workflows/chromatic.yml +0 -30
  21. package/.github/workflows/npm-build.yml +0 -26
  22. package/.github/workflows/npm-typecheck.yml +0 -26
  23. package/.github/workflows/release.yml +0 -29
  24. package/.prettierrc +0 -1
  25. package/.storybook/main.ts +0 -12
  26. package/.storybook/preview.ts +0 -17
  27. package/ava.config.js +0 -7
  28. package/dist/index.css +0 -7
  29. package/dist/index.css.map +0 -1
  30. package/next-env.d.ts +0 -5
  31. package/parsel.d.ts +0 -81
  32. package/release.config.js +0 -15
  33. package/renovate.json +0 -17
  34. package/src/Schematic.tsx +0 -250
  35. package/src/index.ts +0 -1
  36. package/src/lib/hooks/index.ts +0 -1
  37. package/src/lib/hooks/use-maybe-promise.ts +0 -14
  38. package/src/lib/render-context/index.ts +0 -28
  39. package/src/lib/types/core.ts +0 -181
  40. package/src/lib/types/index.ts +0 -4
  41. package/src/lib/types/route-solver.ts +0 -10
  42. package/src/lib/types/source-component.ts +0 -73
  43. package/src/lib/types/util.ts +0 -52
  44. package/src/lib/utils/collect-element-refs.ts +0 -45
  45. package/src/lib/utils/colors.ts +0 -235
  46. package/src/lib/utils/direction-to-vec.ts +0 -50
  47. package/src/lib/utils/get-rotation-from-anchor-side.ts +0 -11
  48. package/src/lib/utils/get-svg-path-bounds.ts +0 -22
  49. package/src/lib/utils/get-vec-from-anchor-side.ts +0 -11
  50. package/src/lib/utils/point-math.ts +0 -26
  51. package/src/pages/_app.tsx +0 -23
  52. package/src/pages/index.tsx +0 -10
  53. package/src/pages/led-circuit-react.tsx +0 -54
  54. package/src/pages/style.css +0 -5
  55. package/src/schematic-components/ContextProviders.tsx +0 -15
  56. package/src/schematic-components/DebugPoint.tsx +0 -25
  57. package/src/schematic-components/RenderError.tsx +0 -23
  58. package/src/schematic-components/SVGPathComponent.tsx +0 -183
  59. package/src/schematic-components/SVGPathComponent2.tsx +0 -76
  60. package/src/schematic-components/SchematicChip.tsx +0 -202
  61. package/src/schematic-components/SchematicComponent.tsx +0 -51
  62. package/src/schematic-components/SchematicComponentFromSymbol.tsx +0 -46
  63. package/src/schematic-components/SchematicElement.tsx +0 -43
  64. package/src/schematic-components/SchematicGroup.tsx +0 -3
  65. package/src/schematic-components/SchematicNetLabel.tsx +0 -63
  66. package/src/schematic-components/SchematicText.tsx +0 -44
  67. package/src/schematic-components/SchematicTrace.tsx +0 -51
  68. package/src/schematic-components/TableViewer.tsx +0 -13
  69. package/src/schematic-components/index.tsx +0 -9
  70. package/src/stories/basics/schematic-net-label.stories.tsx +0 -138
  71. package/src/stories/basics/schematic-net-labels-2.stories.tsx +0 -35
  72. package/src/stories/bug-connections.stories.tsx +0 -31
  73. package/src/stories/bug-high-port-numbers.stories.tsx +0 -130
  74. package/src/stories/bug-one-sided.stories.tsx +0 -34
  75. package/src/stories/bug-pin-spacing.stories.tsx +0 -52
  76. package/src/stories/bugs/bug1-y-flip.stories.tsx +0 -20
  77. package/src/stories/bugs/bug2-component-bounds.stories.tsx +0 -62
  78. package/src/stories/bugs/bug3-scaling-trace.stories.tsx +0 -24
  79. package/src/stories/bugs/bug4-schematic-line.stories.tsx +0 -17
  80. package/src/stories/bugs/bug5-diode.stories.tsx +0 -16
  81. package/src/stories/bugs/bug6-trace-scaling.stories.tsx +0 -18
  82. package/src/stories/bugs/bug7-multiple-schematic-panning.stories.tsx +0 -23
  83. package/src/stories/bugs/bug8-autolayout.stories.tsx +0 -43
  84. package/src/stories/circuit-components/diode.stories.tsx +0 -16
  85. package/src/stories/circuit-components/netalias.stories.tsx +0 -14
  86. package/src/stories/circuit-components/resistor.stories.tsx +0 -16
  87. package/src/stories/component-drawing-example.stories.tsx +0 -17
  88. package/src/stories/led-circuit-react.stories.tsx +0 -48
  89. package/src/stories/net-alias.stories.tsx +0 -92
  90. package/src/stories/off-center-render.stories.tsx +0 -29
  91. package/src/stories/rotated-resistor.stories.tsx +0 -23
  92. package/src/stories/schematic-path.stories.tsx +0 -40
  93. package/src/stories/three-sided-bug.stories.tsx +0 -30
  94. package/tsconfig.tsbuildinfo +0 -1
  95. package/tsup.config.ts +0 -8
  96. package/vercel.json +0 -3
package/README.md CHANGED
@@ -1,32 +1,22 @@
1
- # Schematic Viewer for TSCircuit
1
+ # @tscircuit/schematic-viewer
2
2
 
3
- [![npm version](https://badge.fury.io/js/@tscircuit%2Fschematic-viewer.svg)](https://badge.fury.io/js/@tscircuit%2Fschematic-viewer)
3
+ React component for viewing Circuit JSON or tscircuit as a schematic
4
4
 
5
- [Examples](https://schematic-viewer.vercel.app/) · [TSCircuit](https://tscircuit.com) · [Open in CodeSandbox](https://codesandbox.io/s/github/tscircuit/schematic-viewer) · [discord](https://tscircuit.com/join)
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 { Schematic } from "@tscircuit/schematic-viewer"
13
-
14
- // To get styles for debug table
15
- import "react-data-grid/lib/styles.css"
16
-
17
- export const MyReactApp = () => (
18
- return (
19
- <Schematic>
20
- <resistor name="R1" />
21
- <capacitor name="C1" />
22
- <trace from=".R1 > .1" to=".C1 > .plus">
23
- </Schematic>
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.7.3/schema.json",
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,3 @@
1
+ {
2
+ "plugins": ["react-cosmos-plugin-vite"]
3
+ }
@@ -0,0 +1,3 @@
1
+ export default ({ children }: { children: React.ReactNode }) => (
2
+ <div style={{ width: "100vw", height: "100vh" }}>{children}</div>
3
+ )
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 SchematicProps {
6
- children?: any;
7
- soup?: AnyCircuitElement[];
8
- style?: React.CSSProperties;
9
- showTable?: boolean;
10
- _soupPostProcessor?: (soup: AnyCircuitElement[]) => AnyCircuitElement[];
3
+ interface Props {
4
+ circuitJson: Array<{
5
+ type: string;
6
+ }>;
11
7
  }
12
- declare const Schematic: (props: SchematicProps) => react_jsx_runtime.JSX.Element;
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 { Schematic, SchematicProps, SchematicWithoutContext };
10
+ export { SchematicViewer };