@tscircuit/schematic-viewer 1.2.8 → 1.2.9

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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  declare const Schematic: ({ children, elements: initialElements, soup: initialSoup, style, showTable, }: {
2
2
  children?: any;
3
- /** @deprecated */
3
+ /** @deprecated use soup */
4
4
  elements?: any;
5
5
  soup?: any;
6
6
  style?: any;
package/dist/index.js CHANGED
@@ -2056,14 +2056,60 @@ var SchematicPath = (props) => {
2056
2056
  };
2057
2057
  var SchematicPath_default = SchematicPath;
2058
2058
 
2059
- // src/schematic-components/SchematicElement.tsx
2059
+ // src/schematic-components/SchematicNetLabel.tsx
2060
2060
  var import_jsx_runtime19 = require("react/jsx-runtime");
2061
+ var SchematicNetLabel = ({
2062
+ net_label
2063
+ }) => {
2064
+ console.log({ net_label });
2065
+ const text_width = net_label.text.length * 0.15;
2066
+ const path_width = 31 + net_label.text.length * 5;
2067
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
2068
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2069
+ SVGPathComponent_default,
2070
+ {
2071
+ rotation: 0,
2072
+ center: net_label.center,
2073
+ size: {
2074
+ width: 0.05 + text_width,
2075
+ height: 0.175
2076
+ },
2077
+ paths: [
2078
+ {
2079
+ stroke: "gray",
2080
+ strokeWidth: 0.75,
2081
+ d: `M 0 15 L 5 15 L 11 9 L ${path_width} 9 L ${path_width} 21 L 11 21 L 5 15`
2082
+ }
2083
+ ]
2084
+ }
2085
+ ),
2086
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2087
+ SchematicText_default,
2088
+ {
2089
+ schematic_text: {
2090
+ anchor: "left",
2091
+ position: {
2092
+ x: net_label.center.x - text_width / 4 + 0.025,
2093
+ y: net_label.center.y
2094
+ },
2095
+ schematic_component_id: "SYNTHETIC",
2096
+ schematic_text_id: "SYNTHETIC",
2097
+ text: net_label.text,
2098
+ type: "schematic_text"
2099
+ }
2100
+ }
2101
+ )
2102
+ ] });
2103
+ };
2104
+
2105
+ // src/schematic-components/SchematicElement.tsx
2106
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2061
2107
  var SchematicElement = ({
2062
2108
  element,
2063
2109
  allElements
2064
2110
  }) => {
2065
2111
  if (element.type === "schematic_component") {
2066
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2112
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2067
2113
  SchematicComponent_default,
2068
2114
  {
2069
2115
  component: collectElementRefs(element, allElements)
@@ -2071,25 +2117,28 @@ var SchematicElement = ({
2071
2117
  );
2072
2118
  }
2073
2119
  if (element.type === "schematic_trace") {
2074
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SchematicTrace_default, { trace: collectElementRefs(element, allElements) });
2120
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SchematicTrace_default, { trace: collectElementRefs(element, allElements) });
2075
2121
  }
2076
2122
  if (element.type === "schematic_port") {
2077
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SchematicPort_default, { port: collectElementRefs(element, allElements) });
2123
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SchematicPort_default, { port: collectElementRefs(element, allElements) });
2078
2124
  }
2079
2125
  if (element.type === "schematic_box") {
2080
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SchematicBox_default, { box: collectElementRefs(element, allElements) });
2126
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SchematicBox_default, { box: collectElementRefs(element, allElements) });
2081
2127
  }
2082
2128
  if (element.type === "schematic_line") {
2083
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SchematicLine_default, { line: collectElementRefs(element, allElements) });
2129
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SchematicLine_default, { line: collectElementRefs(element, allElements) });
2084
2130
  }
2085
2131
  if (element.type === "schematic_path") {
2086
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SchematicPath_default, { path: collectElementRefs(element, allElements) });
2132
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SchematicPath_default, { path: collectElementRefs(element, allElements) });
2087
2133
  }
2088
2134
  if (element.type === "schematic_text") {
2089
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SchematicText_default, { schematic_text: element });
2135
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SchematicText_default, { schematic_text: element });
2136
+ }
2137
+ if (element.type === "schematic_net_label") {
2138
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SchematicNetLabel, { net_label: element });
2090
2139
  }
2091
2140
  if (element.type === "source_error") {
2092
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RenderError_default, { text: element.message });
2141
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(RenderError_default, { text: element.message });
2093
2142
  }
2094
2143
  return null;
2095
2144
  };
@@ -2100,19 +2149,19 @@ var import_react_error_boundary = require("react-error-boundary");
2100
2149
 
2101
2150
  // src/schematic-components/TableViewer.tsx
2102
2151
  var import_react5 = require("react");
2103
- var import_jsx_runtime20 = require("react/jsx-runtime");
2152
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2104
2153
  var LazyTableViewer = (0, import_react5.lazy)(
2105
2154
  () => import("@tscircuit/table-viewer").then((m) => ({
2106
2155
  default: m.SoupTableViewer
2107
2156
  }))
2108
2157
  );
2109
- var TableViewer = (params) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react5.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { children: "Loading..." }), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(LazyTableViewer, { ...params }) });
2158
+ var TableViewer = (params) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react5.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { children: "Loading..." }), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(LazyTableViewer, { ...params }) });
2110
2159
 
2111
2160
  // src/Schematic.tsx
2112
- var import_jsx_runtime21 = require("react/jsx-runtime");
2161
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2113
2162
  var ErrorBoundary = import_react_error_boundary.ErrorBoundary;
2114
2163
  var fallbackRender = (elm) => ({ error, resetErrorBoundary }) => {
2115
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { color: "red" }, children: [
2164
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { color: "red" }, children: [
2116
2165
  "error rendering ",
2117
2166
  elm.type,
2118
2167
  ": ",
@@ -2178,8 +2227,8 @@ var Schematic = ({
2178
2227
  throw e;
2179
2228
  });
2180
2229
  }, [children]);
2181
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
2182
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2230
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
2231
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
2183
2232
  "div",
2184
2233
  {
2185
2234
  style: {
@@ -2197,7 +2246,7 @@ var Schematic = ({
2197
2246
  boundsRef(el);
2198
2247
  },
2199
2248
  children: [
2200
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2249
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2201
2250
  import_react_supergrid.SuperGrid,
2202
2251
  {
2203
2252
  stringifyCoord: (x, y, z) => {
@@ -2210,7 +2259,7 @@ var Schematic = ({
2210
2259
  transform: cameraTransform
2211
2260
  }
2212
2261
  ),
2213
- elements?.map((elm, i) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ErrorBoundary, { fallbackRender: fallbackRender(elm), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2262
+ elements?.map((elm, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ErrorBoundary, { fallbackRender: fallbackRender(elm), children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2214
2263
  SchematicElement,
2215
2264
  {
2216
2265
  element: elm,
@@ -2221,7 +2270,7 @@ var Schematic = ({
2221
2270
  ]
2222
2271
  }
2223
2272
  ),
2224
- showTable !== false && elements && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TableViewer, { elements })
2273
+ showTable !== false && elements && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(TableViewer, { elements })
2225
2274
  ] });
2226
2275
  };
2227
2276
  // Annotate the CommonJS export names for ESM import in node: