@tscircuit/schematic-viewer 0.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/.prettierrc +1 -0
- package/.storybook/main.js +15 -0
- package/.storybook/preview.js +9 -0
- package/README.md +26 -0
- package/ava.config.js +7 -0
- package/dist/Schematic.js +8606 -0
- package/dist/Schematic.js.map +1 -0
- package/dist/lib/hooks/index.js +2170 -0
- package/dist/lib/hooks/index.js.map +1 -0
- package/dist/lib/hooks/use-maybe-promise.js +2170 -0
- package/dist/lib/hooks/use-maybe-promise.js.map +1 -0
- package/dist/lib/render-context/index.js +45 -0
- package/dist/lib/render-context/index.js.map +1 -0
- package/dist/lib/types/core.js +18 -0
- package/dist/lib/types/core.js.map +1 -0
- package/dist/lib/types/index.js +18 -0
- package/dist/lib/types/index.js.map +1 -0
- package/dist/lib/types/route-solver.js +18 -0
- package/dist/lib/types/route-solver.js.map +1 -0
- package/dist/lib/types/source-component.js +18 -0
- package/dist/lib/types/source-component.js.map +1 -0
- package/dist/lib/types/util.js +18 -0
- package/dist/lib/types/util.js.map +1 -0
- package/dist/lib/utils/direction-to-vec.js +96 -0
- package/dist/lib/utils/direction-to-vec.js.map +1 -0
- package/dist/lib/utils/get-svg-path-bounds.js +51 -0
- package/dist/lib/utils/get-svg-path-bounds.js.map +1 -0
- package/dist/lib/utils/point-math.js +57 -0
- package/dist/lib/utils/point-math.js.map +1 -0
- package/dist/pages/_app.js +2714 -0
- package/dist/pages/_app.js.map +1 -0
- package/dist/pages/index.js +8612 -0
- package/dist/pages/index.js.map +1 -0
- package/dist/pages/led-circuit-react.js +2185 -0
- package/dist/pages/led-circuit-react.js.map +1 -0
- package/dist/pages/led-circuit.js +8656 -0
- package/dist/pages/led-circuit.js.map +1 -0
- package/dist/schematic-components/MovableGrid/MovableGrid.stories.js +47 -0
- package/dist/schematic-components/MovableGrid/MovableGrid.stories.js.map +1 -0
- package/dist/schematic-components/MovableGrid/index.js +34 -0
- package/dist/schematic-components/MovableGrid/index.js.map +1 -0
- package/dist/schematic-components/ProjectComponent.js +8584 -0
- package/dist/schematic-components/ProjectComponent.js.map +1 -0
- package/dist/schematic-components/RenderError.js +40 -0
- package/dist/schematic-components/RenderError.js.map +1 -0
- package/dist/schematic-components/SVGPathComponent.js +90 -0
- package/dist/schematic-components/SVGPathComponent.js.map +1 -0
- package/dist/schematic-components/SchematicBug.js +468 -0
- package/dist/schematic-components/SchematicBug.js.map +1 -0
- package/dist/schematic-components/SchematicComponent.js +8451 -0
- package/dist/schematic-components/SchematicComponent.js.map +1 -0
- package/dist/schematic-components/SchematicGroup.js +32 -0
- package/dist/schematic-components/SchematicGroup.js.map +1 -0
- package/dist/schematic-components/SchematicPort.js +8348 -0
- package/dist/schematic-components/SchematicPort.js.map +1 -0
- package/dist/schematic-components/SchematicText.js +71 -0
- package/dist/schematic-components/SchematicText.js.map +1 -0
- package/dist/schematic-components/SchematicTrace.js +137 -0
- package/dist/schematic-components/SchematicTrace.js.map +1 -0
- package/dist/schematic-components/SimpleCapacitor.js +103 -0
- package/dist/schematic-components/SimpleCapacitor.js.map +1 -0
- package/dist/schematic-components/SimpleDiode.js +101 -0
- package/dist/schematic-components/SimpleDiode.js.map +1 -0
- package/dist/schematic-components/SimpleGround.js +102 -0
- package/dist/schematic-components/SimpleGround.js.map +1 -0
- package/dist/schematic-components/SimpleInductor.js +102 -0
- package/dist/schematic-components/SimpleInductor.js.map +1 -0
- package/dist/schematic-components/SimplePowerSource.js +104 -0
- package/dist/schematic-components/SimplePowerSource.js.map +1 -0
- package/dist/schematic-components/SimpleResistor.js +102 -0
- package/dist/schematic-components/SimpleResistor.js.map +1 -0
- package/dist/schematic-components/index.js +8618 -0
- package/dist/schematic-components/index.js.map +1 -0
- package/next-env.d.ts +5 -0
- package/package.json +52 -0
- package/parsel.d.ts +81 -0
- package/src/Schematic.tsx +40 -0
- package/src/lib/hooks/index.ts +1 -0
- package/src/lib/hooks/use-maybe-promise.ts +14 -0
- package/src/lib/render-context/index.ts +15 -0
- package/src/lib/types/core.ts +179 -0
- package/src/lib/types/index.ts +4 -0
- package/src/lib/types/route-solver.ts +10 -0
- package/src/lib/types/source-component.ts +63 -0
- package/src/lib/types/util.ts +52 -0
- package/src/lib/utils/direction-to-vec.ts +50 -0
- package/src/lib/utils/get-svg-path-bounds.ts +22 -0
- package/src/lib/utils/point-math.ts +26 -0
- package/src/pages/_app.tsx +23 -0
- package/src/pages/index.tsx +10 -0
- package/src/pages/led-circuit-react.tsx +51 -0
- package/src/pages/led-circuit.tsx +91 -0
- package/src/schematic-components/MovableGrid/MovableGrid.stories.tsx +23 -0
- package/src/schematic-components/MovableGrid/index.tsx +4 -0
- package/src/schematic-components/ProjectComponent.tsx +62 -0
- package/src/schematic-components/RenderError.tsx +23 -0
- package/src/schematic-components/SVGPathComponent.tsx +64 -0
- package/src/schematic-components/SchematicBug.tsx +52 -0
- package/src/schematic-components/SchematicComponent.tsx +42 -0
- package/src/schematic-components/SchematicGroup.tsx +3 -0
- package/src/schematic-components/SchematicPort.tsx +39 -0
- package/src/schematic-components/SchematicText.tsx +41 -0
- package/src/schematic-components/SchematicTrace.tsx +48 -0
- package/src/schematic-components/SimpleCapacitor.tsx +29 -0
- package/src/schematic-components/SimpleDiode.tsx +38 -0
- package/src/schematic-components/SimpleGround.tsx +28 -0
- package/src/schematic-components/SimpleInductor.tsx +29 -0
- package/src/schematic-components/SimplePowerSource.tsx +30 -0
- package/src/schematic-components/SimpleResistor.tsx +28 -0
- package/src/schematic-components/index.tsx +17 -0
- package/tsconfig.json +31 -0
- package/tsconfig.tsbuildinfo +1 -0
package/.prettierrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "semi": false }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"stories": [
|
|
3
|
+
"../src/**/*.stories.mdx",
|
|
4
|
+
"../src/**/*.stories.@(js|jsx|ts|tsx)"
|
|
5
|
+
],
|
|
6
|
+
"addons": [
|
|
7
|
+
"@storybook/addon-links",
|
|
8
|
+
"@storybook/addon-essentials",
|
|
9
|
+
"@storybook/addon-interactions"
|
|
10
|
+
],
|
|
11
|
+
"framework": "@storybook/react",
|
|
12
|
+
"core": {
|
|
13
|
+
"builder": "@storybook/builder-webpack5"
|
|
14
|
+
}
|
|
15
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Schematic Viewer for TSCircuit
|
|
2
|
+
|
|
3
|
+
View schematics from [tscircuit jsx](https://tscircuit.com).
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Schematic } from "tscircuit"
|
|
9
|
+
// import { Schematic } from "@tscircuit/schematic-viewer"
|
|
10
|
+
|
|
11
|
+
export const MyReactApp = () => (
|
|
12
|
+
return (
|
|
13
|
+
<Schematic>
|
|
14
|
+
<resistor name="R1" />
|
|
15
|
+
<capacitor name="C1" />
|
|
16
|
+
<trace from=".R1 > .1" to=".C1 > .plus">
|
|
17
|
+
</Schematic>
|
|
18
|
+
)
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## References
|
|
24
|
+
|
|
25
|
+
- [SVG Path Tool](https://yqnn.github.io/svg-path-editor/)
|
|
26
|
+
- [SVG of Electrical Symbols Wikipedia](https://commons.wikimedia.org/wiki/File:Electrical_symbols_library.svg)
|