@tscircuit/schematic-viewer 1.0.16 → 1.0.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/schematic-viewer",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "repository": "tscircuit/schematic-viewer",
@@ -15,6 +15,7 @@
15
15
  "peerDependencies": {
16
16
  "@tscircuit/builder": "*",
17
17
  "@tscircuit/react-fiber": "*",
18
+ "@tscircuit/table-viewer": "*",
18
19
  "react": "*"
19
20
  },
20
21
  "devDependencies": {
@@ -28,11 +29,13 @@
28
29
  "@semantic-release/npm": "^10.0.4",
29
30
  "@semantic-release/release-notes-generator": "^11.0.4",
30
31
  "@storybook/blocks": "^7.0.26",
31
- "@storybook/nextjs": "^7.0.26",
32
- "@storybook/react": "^7.0.26",
32
+ "@storybook/nextjs": "^7.4.0",
33
+ "@storybook/react": "^7.4.0",
33
34
  "@storybook/testing-library": "^0.0.14-next.2",
34
- "@tscircuit/builder": "^1.2.17",
35
- "@tscircuit/react-fiber": "^1.0.4",
35
+ "@tscircuit/builder": "^1.3.2",
36
+ "@tscircuit/react-fiber": "^1.0.6",
37
+ "@tscircuit/routing": "^1.3.0",
38
+ "@tscircuit/table-viewer": "^0.0.6",
36
39
  "@types/node": "^18.6.0",
37
40
  "@types/react": "^18.0.15",
38
41
  "ava": "^4.3.1",
@@ -47,7 +50,7 @@
47
50
  "react-use-measure": "^2.1.1",
48
51
  "rectilinear-router": "^1.0.1",
49
52
  "semantic-release": "^21.0.6",
50
- "storybook": "^7.0.26",
53
+ "storybook": "^7.4.0",
51
54
  "svg-path-bounds": "^1.0.2",
52
55
  "svg-path-generator": "^1.1.0",
53
56
  "transformation-matrix": "^2.12.0",
package/src/Schematic.tsx CHANGED
@@ -15,6 +15,7 @@ import { ErrorBoundary } from "react-error-boundary"
15
15
  import { identity, compose, scale, translate } from "transformation-matrix"
16
16
  import { useRenderContext } from "lib/render-context"
17
17
  import useMeasure from "react-use-measure"
18
+ import { SoupTableViewer } from "@tscircuit/table-viewer"
18
19
 
19
20
  const fallbackRender =
20
21
  (elm) =>
@@ -93,39 +94,42 @@ export const Schematic = ({
93
94
  }, [children])
94
95
 
95
96
  return (
96
- <div
97
- style={{
98
- width: "100%",
99
- backgroundColor: "rgba(255,255,255,0)",
100
- minHeight: 200,
101
- overflow: "hidden",
102
- position: "relative",
103
- cursor: "grab",
104
- ...style,
105
- }}
106
- ref={(el) => {
107
- ref.current = el
108
- boundsRef(el)
109
- }}
110
- >
111
- <SuperGrid
112
- stringifyCoord={(x, y, z) => {
113
- if (z === 0) return ""
114
- return `${toMMSINeg(x, z)}, ${toMMSINeg(y, z)}`
97
+ <>
98
+ <div
99
+ style={{
100
+ width: "100%",
101
+ backgroundColor: "rgba(255,255,255,0)",
102
+ minHeight: 200,
103
+ overflow: "hidden",
104
+ position: "relative",
105
+ cursor: "grab",
106
+ ...style,
115
107
  }}
116
- width={bounds.width}
117
- height={bounds.height}
118
- transform={cameraTransform}
119
- />
120
- {elements?.map((elm, i) => (
121
- <ErrorBoundary key={i} fallbackRender={fallbackRender(elm)}>
122
- <SchematicElement
123
- element={elm}
124
- allElements={elements}
125
- key={JSON.stringify(elm)}
126
- />
127
- </ErrorBoundary>
128
- ))}
129
- </div>
108
+ ref={(el) => {
109
+ ref.current = el
110
+ boundsRef(el)
111
+ }}
112
+ >
113
+ <SuperGrid
114
+ stringifyCoord={(x, y, z) => {
115
+ if (z === 0) return ""
116
+ return `${toMMSINeg(x, z)}, ${toMMSINeg(y, z)}`
117
+ }}
118
+ width={bounds.width}
119
+ height={bounds.height}
120
+ transform={cameraTransform}
121
+ />
122
+ {elements?.map((elm, i) => (
123
+ <ErrorBoundary key={i} fallbackRender={fallbackRender(elm)}>
124
+ <SchematicElement
125
+ element={elm}
126
+ allElements={elements}
127
+ key={JSON.stringify(elm)}
128
+ />
129
+ </ErrorBoundary>
130
+ ))}
131
+ </div>
132
+ {elements && <SoupTableViewer elements={elements} />}
133
+ </>
130
134
  )
131
135
  }
@@ -9,6 +9,10 @@ interface Props {
9
9
  }
10
10
  }
11
11
 
12
+ /**
13
+ * @deprecated ftype-style rendering is being deprecated in favor of the builder
14
+ * generating schematic lines directly
15
+ */
12
16
  export const SchematicComponent = ({ component }: Props) => {
13
17
  const { source, schematic } = component
14
18
  switch (source.ftype) {
@@ -31,7 +35,9 @@ export const SchematicComponent = ({ component }: Props) => {
31
35
  return <Component.SchematicBug component={{ source, schematic }} />
32
36
  }
33
37
  case "simple_diode": {
34
- return <Component.SimpleDiode component={{ source, schematic }} />
38
+ // Replaced by builder
39
+ return null
40
+ // return <Component.SimpleDiode component={{ source, schematic }} />
35
41
  }
36
42
  default: {
37
43
  return <div>unknown ftype: {component.source.ftype}</div>
@@ -6,6 +6,7 @@ import SchematicText from "./SchematicText"
6
6
  import SchematicBox from "./SchematicBox"
7
7
  import SchematicTrace from "./SchematicTrace"
8
8
  import SchematicLine from "./SchematicLine"
9
+ import RenderError from "./RenderError"
9
10
 
10
11
  /**
11
12
  * Render any @tsbuilder/builder AnyElement that can be put on a schematic.
@@ -55,5 +56,10 @@ export const SchematicElement = ({
55
56
  return <SchematicText schematic_text={element} />
56
57
  }
57
58
 
59
+ if (element.type === "source_error") {
60
+ // TODO use the ids on the source error to put this in the right place
61
+ return <RenderError text={element.message} />
62
+ }
63
+
58
64
  return null
59
65
  }
@@ -39,13 +39,15 @@ export const LEDCircuitReact = () => {
39
39
  />
40
40
  <trace path={[".B1 > port.PWR", ".R2 > port.left"]} />
41
41
  <ground name="GND" center={[11, 3]} />
42
- {/* <trace path={[".B1 > port.GND", ".GND"]} /> */}
43
- {/* <trace from=".B1 > port.GND" to=".GND" /> */}
42
+ <trace path={[".B1 > port.GND", ".GND > .gnd"]} />
43
+ {/* <trace from=".B1 > port.GND" to=".GND > .gnd" /> */}
44
44
  <diode name="D1" center={[6, 3.5]} rotation="180deg" />
45
45
  <trace path={[".D1 > port.right", ".C1 > .right"]} />
46
46
  <trace path={[".D1 > port.left", ".B1 > .RG"]} />
47
- {/* <trace from=".D1 > .left" to=".B1 > .RG" />
48
- <trace from=".D1 > .right" to=".C1> .right" /> */}
47
+ {/* <trace from=".D1 > .left" to=".B1 > .RG" /> */}
48
+ {/* <trace from=".D1 > .right" to=".C1> .right" /> */}
49
+ <netalias center={["10mm", "1.5mm"]} net="D0BUS" />
50
+ <trace path={[".B1 > .D0", ".D0BUS"]} />
49
51
  </Schematic>
50
52
  )
51
53
  }