@tscircuit/schematic-viewer 1.2.7 → 1.2.8
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.js +127 -63
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/Schematic.tsx +1 -0
- package/src/lib/utils/direction-to-vec.ts +1 -1
- package/src/schematic-components/SVGPathComponent.tsx +47 -18
- package/src/schematic-components/SVGPathComponent2.tsx +76 -0
- package/src/schematic-components/SchematicLine.tsx +2 -2
- package/src/schematic-components/SchematicTrace.tsx +2 -1
- package/src/schematic-components/SimplePowerSource.tsx +12 -0
- package/src/stories/bugs/bug4-schematic-line.stories.tsx +18 -0
- package/src/stories/bugs/bug5-diode.stories.tsx +15 -0
- package/src/stories/bugs/bug6-trace-scaling.stories.tsx +54 -0
package/dist/index.js
CHANGED
|
@@ -1288,22 +1288,28 @@ var SVGPathComponent = ({
|
|
|
1288
1288
|
const badRatio = Math.abs(pathBounds.width / pathBounds.height - size.width / size.height) > 0.01;
|
|
1289
1289
|
if (badRatio) {
|
|
1290
1290
|
}
|
|
1291
|
+
const padding = {
|
|
1292
|
+
x: 0,
|
|
1293
|
+
y: 0
|
|
1294
|
+
};
|
|
1291
1295
|
const absoluteCenter = applyToPoint(ct, center);
|
|
1292
|
-
const
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1296
|
+
const innerSize = {
|
|
1297
|
+
width: size.width * ct.a,
|
|
1298
|
+
height: size.height * Math.abs(ct.d)
|
|
1299
|
+
};
|
|
1300
|
+
const fullSize = {
|
|
1301
|
+
width: innerSize.width + padding.x * 2,
|
|
1302
|
+
height: innerSize.height + padding.y * 2
|
|
1297
1303
|
};
|
|
1298
1304
|
const [hovering, setHovering] = (0, import_react2.useState)(false);
|
|
1299
|
-
const svgLeft = absoluteCenter.x -
|
|
1300
|
-
const svgTop = absoluteCenter.y -
|
|
1301
|
-
const
|
|
1305
|
+
const svgLeft = absoluteCenter.x - fullSize.width / 2;
|
|
1306
|
+
const svgTop = absoluteCenter.y - fullSize.height / 2;
|
|
1307
|
+
const preferredRatio = pathBounds.width === 0 ? innerSize.height / pathBounds.height : innerSize.width / pathBounds.width;
|
|
1302
1308
|
const svgToScreen = compose(
|
|
1303
1309
|
// translate(0, 0)
|
|
1304
1310
|
scale(
|
|
1305
|
-
|
|
1306
|
-
|
|
1311
|
+
pathBounds.width === 0 ? preferredRatio : fullSize.width / pathBounds.width,
|
|
1312
|
+
pathBounds.height === 0 ? preferredRatio : fullSize.height / pathBounds.height
|
|
1307
1313
|
),
|
|
1308
1314
|
translate(-pathBounds.minX, -pathBounds.minY)
|
|
1309
1315
|
// translate(center.x, center.y)
|
|
@@ -1318,8 +1324,8 @@ var SVGPathComponent = ({
|
|
|
1318
1324
|
left: svgLeft - 6,
|
|
1319
1325
|
top: svgTop - 6,
|
|
1320
1326
|
pointerEvents: "none",
|
|
1321
|
-
width:
|
|
1322
|
-
height:
|
|
1327
|
+
width: fullSize.width + 12,
|
|
1328
|
+
height: fullSize.height + 12,
|
|
1323
1329
|
border: "1px red solid",
|
|
1324
1330
|
mixBlendMode: "difference",
|
|
1325
1331
|
zIndex: 1e3
|
|
@@ -1331,7 +1337,7 @@ var SVGPathComponent = ({
|
|
|
1331
1337
|
{
|
|
1332
1338
|
style: {
|
|
1333
1339
|
position: "absolute",
|
|
1334
|
-
left: svgLeft +
|
|
1340
|
+
left: svgLeft + fullSize.width + 10,
|
|
1335
1341
|
pointerEvents: "none",
|
|
1336
1342
|
zIndex: 1e3,
|
|
1337
1343
|
color: "red",
|
|
@@ -1367,8 +1373,8 @@ var SVGPathComponent = ({
|
|
|
1367
1373
|
// backgroundColor: "rgba(255, 0, 0, 0.1)",
|
|
1368
1374
|
},
|
|
1369
1375
|
overflow: "visible",
|
|
1370
|
-
width:
|
|
1371
|
-
height:
|
|
1376
|
+
width: fullSize.width,
|
|
1377
|
+
height: fullSize.height,
|
|
1372
1378
|
children: paths.map((p, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1373
1379
|
"path",
|
|
1374
1380
|
{
|
|
@@ -1446,7 +1452,7 @@ var directionToVec = (direction) => {
|
|
|
1446
1452
|
else if (direction === "right")
|
|
1447
1453
|
return { x: 1, y: 0 };
|
|
1448
1454
|
else
|
|
1449
|
-
throw new Error(
|
|
1455
|
+
throw new Error(`Invalid direction "${direction}"`);
|
|
1450
1456
|
};
|
|
1451
1457
|
|
|
1452
1458
|
// src/schematic-components/SchematicPort.tsx
|
|
@@ -1697,12 +1703,60 @@ var RenderError_default = ({ text }) => {
|
|
|
1697
1703
|
);
|
|
1698
1704
|
};
|
|
1699
1705
|
|
|
1700
|
-
// src/schematic-components/
|
|
1706
|
+
// src/schematic-components/SVGPathComponent2.tsx
|
|
1701
1707
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1708
|
+
var SVGPathComponent2 = ({
|
|
1709
|
+
size,
|
|
1710
|
+
center,
|
|
1711
|
+
rotation,
|
|
1712
|
+
paths,
|
|
1713
|
+
zIndex,
|
|
1714
|
+
invertY,
|
|
1715
|
+
shiftToBottom,
|
|
1716
|
+
hoverContent
|
|
1717
|
+
}) => {
|
|
1718
|
+
const ct = useCameraTransform();
|
|
1719
|
+
const pathBounds = get_svg_path_bounds_default(paths.map((p) => p.d));
|
|
1720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1721
|
+
"svg",
|
|
1722
|
+
{
|
|
1723
|
+
style: {
|
|
1724
|
+
position: "absolute",
|
|
1725
|
+
left: 0,
|
|
1726
|
+
top: 0,
|
|
1727
|
+
right: 0,
|
|
1728
|
+
bottom: 0,
|
|
1729
|
+
// backgroundColor: hovering ? "rgba(0, 0, 255, 0.5)" : "transparent",
|
|
1730
|
+
pointerEvents: "none",
|
|
1731
|
+
zIndex
|
|
1732
|
+
// overflow: "hidden",
|
|
1733
|
+
// backgroundColor: badRatio ? "rgba(255, 0, 0, 0.1)" : "transparent",
|
|
1734
|
+
// backgroundColor: "rgba(255, 0, 0, 0.1)",
|
|
1735
|
+
},
|
|
1736
|
+
overflow: "visible",
|
|
1737
|
+
children: paths.map((p, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1738
|
+
"path",
|
|
1739
|
+
{
|
|
1740
|
+
transform: toSVG(ct),
|
|
1741
|
+
fill: p.fill ?? "none",
|
|
1742
|
+
strokeLinecap: "round",
|
|
1743
|
+
strokeWidth: 1.5 * (p.strokeWidth || 1),
|
|
1744
|
+
stroke: p.stroke || "red",
|
|
1745
|
+
d: p.d
|
|
1746
|
+
},
|
|
1747
|
+
i
|
|
1748
|
+
))
|
|
1749
|
+
}
|
|
1750
|
+
);
|
|
1751
|
+
};
|
|
1752
|
+
var SVGPathComponent2_default = SVGPathComponent2;
|
|
1753
|
+
|
|
1754
|
+
// src/schematic-components/SchematicTrace.tsx
|
|
1755
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1702
1756
|
var SchematicTrace = ({ trace: { source, schematic } }) => {
|
|
1703
1757
|
const edges = schematic.edges;
|
|
1704
1758
|
if (edges.length === 0) {
|
|
1705
|
-
return /* @__PURE__ */ (0,
|
|
1759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RenderError_default, { text: `Route with 0 edges (${source.source_trace_id})` });
|
|
1706
1760
|
}
|
|
1707
1761
|
const path = (0, import_svg_path_generator.default)();
|
|
1708
1762
|
for (let i = 0; i < edges.length; i++) {
|
|
@@ -1717,8 +1771,8 @@ var SchematicTrace = ({ trace: { source, schematic } }) => {
|
|
|
1717
1771
|
x: pathBounds.minX + pathBounds.width / 2,
|
|
1718
1772
|
y: pathBounds.minY + pathBounds.height / 2
|
|
1719
1773
|
};
|
|
1720
|
-
return /* @__PURE__ */ (0,
|
|
1721
|
-
|
|
1774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1775
|
+
SVGPathComponent2_default,
|
|
1722
1776
|
{
|
|
1723
1777
|
rotation: 0,
|
|
1724
1778
|
center,
|
|
@@ -1737,7 +1791,7 @@ var SchematicTrace_default = SchematicTrace;
|
|
|
1737
1791
|
|
|
1738
1792
|
// src/schematic-components/SchematicBug.tsx
|
|
1739
1793
|
var import_builder2 = require("@tscircuit/builder");
|
|
1740
|
-
var
|
|
1794
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1741
1795
|
var SchematicBug = ({ component: { source, schematic } }) => {
|
|
1742
1796
|
const port_arrangement = {
|
|
1743
1797
|
top_size: 0,
|
|
@@ -1774,7 +1828,7 @@ var SchematicBug = ({ component: { source, schematic } }) => {
|
|
|
1774
1828
|
x: schematic.center.x + (actualSize.minX + actualSize.maxX) / 2,
|
|
1775
1829
|
y: schematic.center.y + (actualSize.minY + actualSize.maxY) / 2
|
|
1776
1830
|
};
|
|
1777
|
-
return /* @__PURE__ */ (0,
|
|
1831
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1778
1832
|
SVGPathComponent_default,
|
|
1779
1833
|
{
|
|
1780
1834
|
rotation: schematic.rotation,
|
|
@@ -1786,11 +1840,11 @@ var SchematicBug = ({ component: { source, schematic } }) => {
|
|
|
1786
1840
|
};
|
|
1787
1841
|
|
|
1788
1842
|
// src/schematic-components/SimplePowerSource.tsx
|
|
1789
|
-
var
|
|
1843
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1790
1844
|
var SimplePowerSource = ({
|
|
1791
1845
|
component: { source, schematic }
|
|
1792
1846
|
}) => {
|
|
1793
|
-
return /* @__PURE__ */ (0,
|
|
1847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1794
1848
|
SVGPathComponent_default,
|
|
1795
1849
|
{
|
|
1796
1850
|
rotation: schematic.rotation,
|
|
@@ -1802,6 +1856,18 @@ var SimplePowerSource = ({
|
|
|
1802
1856
|
stroke: "red",
|
|
1803
1857
|
strokeWidth: 1,
|
|
1804
1858
|
d: "M 0 -17 L 0 -3 M -8 3 L 8 3 M 0 17 L 0 3 M -12 -3 L 12 -3"
|
|
1859
|
+
},
|
|
1860
|
+
// positive symbol
|
|
1861
|
+
{
|
|
1862
|
+
stroke: "red",
|
|
1863
|
+
strokeWidth: 0.5,
|
|
1864
|
+
d: "M 8 -9 L 8 -6 M 9.5 -7.5 L 6.5 -7.5"
|
|
1865
|
+
},
|
|
1866
|
+
// negative symbol
|
|
1867
|
+
{
|
|
1868
|
+
stroke: "red",
|
|
1869
|
+
strokeWidth: 0.5,
|
|
1870
|
+
d: "M 9.5 7.5 L 6.5 7.5"
|
|
1805
1871
|
}
|
|
1806
1872
|
]
|
|
1807
1873
|
}
|
|
@@ -1809,9 +1875,9 @@ var SimplePowerSource = ({
|
|
|
1809
1875
|
};
|
|
1810
1876
|
|
|
1811
1877
|
// src/schematic-components/SimpleGround.tsx
|
|
1812
|
-
var
|
|
1878
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1813
1879
|
var SimpleGround = ({ component: { source, schematic } }) => {
|
|
1814
|
-
return /* @__PURE__ */ (0,
|
|
1880
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1815
1881
|
SVGPathComponent_default,
|
|
1816
1882
|
{
|
|
1817
1883
|
rotation: schematic.rotation,
|
|
@@ -1831,9 +1897,9 @@ var SimpleGround = ({ component: { source, schematic } }) => {
|
|
|
1831
1897
|
};
|
|
1832
1898
|
|
|
1833
1899
|
// src/schematic-components/SimpleInductor.tsx
|
|
1834
|
-
var
|
|
1900
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1835
1901
|
var SimpleInductor = ({ component: { source, schematic } }) => {
|
|
1836
|
-
return /* @__PURE__ */ (0,
|
|
1902
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1837
1903
|
SVGPathComponent_default,
|
|
1838
1904
|
{
|
|
1839
1905
|
rotation: schematic.rotation,
|
|
@@ -1852,38 +1918,38 @@ var SimpleInductor = ({ component: { source, schematic } }) => {
|
|
|
1852
1918
|
};
|
|
1853
1919
|
|
|
1854
1920
|
// src/schematic-components/SimpleDiode.tsx
|
|
1855
|
-
var
|
|
1921
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1856
1922
|
|
|
1857
1923
|
// src/schematic-components/SchematicComponent.tsx
|
|
1858
|
-
var
|
|
1924
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1859
1925
|
var SchematicComponent = ({ component }) => {
|
|
1860
1926
|
const { source, schematic } = component;
|
|
1861
1927
|
if (!source.ftype)
|
|
1862
1928
|
return null;
|
|
1863
1929
|
switch (source.ftype) {
|
|
1864
1930
|
case "simple_resistor": {
|
|
1865
|
-
return /* @__PURE__ */ (0,
|
|
1931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SimpleResistor, { component: { source, schematic } });
|
|
1866
1932
|
}
|
|
1867
1933
|
case "simple_capacitor": {
|
|
1868
|
-
return /* @__PURE__ */ (0,
|
|
1934
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SimpleCapacitor, { component: { source, schematic } });
|
|
1869
1935
|
}
|
|
1870
1936
|
case "simple_power_source": {
|
|
1871
|
-
return /* @__PURE__ */ (0,
|
|
1937
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SimplePowerSource, { component: { source, schematic } });
|
|
1872
1938
|
}
|
|
1873
1939
|
case "simple_ground": {
|
|
1874
|
-
return /* @__PURE__ */ (0,
|
|
1940
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SimpleGround, { component: { source, schematic } });
|
|
1875
1941
|
}
|
|
1876
1942
|
case "simple_inductor": {
|
|
1877
|
-
return /* @__PURE__ */ (0,
|
|
1943
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SimpleInductor, { component: { source, schematic } });
|
|
1878
1944
|
}
|
|
1879
1945
|
case "simple_bug": {
|
|
1880
|
-
return /* @__PURE__ */ (0,
|
|
1946
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SchematicBug, { component: { source, schematic } });
|
|
1881
1947
|
}
|
|
1882
1948
|
case "simple_diode": {
|
|
1883
1949
|
return null;
|
|
1884
1950
|
}
|
|
1885
1951
|
default: {
|
|
1886
|
-
return /* @__PURE__ */ (0,
|
|
1952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
|
|
1887
1953
|
"unknown ftype: ",
|
|
1888
1954
|
component.source.ftype
|
|
1889
1955
|
] });
|
|
@@ -1893,10 +1959,10 @@ var SchematicComponent = ({ component }) => {
|
|
|
1893
1959
|
var SchematicComponent_default = SchematicComponent;
|
|
1894
1960
|
|
|
1895
1961
|
// src/schematic-components/SchematicBox.tsx
|
|
1896
|
-
var
|
|
1962
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1897
1963
|
var SchematicBox = ({ box: { schematic } }) => {
|
|
1898
1964
|
const { width: w, height: h } = schematic;
|
|
1899
|
-
return /* @__PURE__ */ (0,
|
|
1965
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1900
1966
|
SVGPathComponent,
|
|
1901
1967
|
{
|
|
1902
1968
|
rotation: 0,
|
|
@@ -1916,7 +1982,7 @@ var SchematicBox_default = SchematicBox;
|
|
|
1916
1982
|
|
|
1917
1983
|
// src/schematic-components/SchematicLine.tsx
|
|
1918
1984
|
var import_svg_path_generator2 = __toESM(require_svg_path_generator2());
|
|
1919
|
-
var
|
|
1985
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1920
1986
|
var SchematicLine = ({ line: { schematic } }) => {
|
|
1921
1987
|
const { x1, x2, y1, y2 } = schematic;
|
|
1922
1988
|
const dx = x2 - x1;
|
|
@@ -1926,13 +1992,11 @@ var SchematicLine = ({ line: { schematic } }) => {
|
|
|
1926
1992
|
path.lineTo(x2, y2);
|
|
1927
1993
|
const d = path.toString();
|
|
1928
1994
|
const pathBounds = get_svg_path_bounds_default(d);
|
|
1929
|
-
pathBounds.height = Math.max(pathBounds.height, 1);
|
|
1930
|
-
pathBounds.width = Math.max(pathBounds.width, 1);
|
|
1931
1995
|
const center = {
|
|
1932
1996
|
x: pathBounds.minX + pathBounds.width / 2,
|
|
1933
1997
|
y: pathBounds.minY + pathBounds.height / 2
|
|
1934
1998
|
};
|
|
1935
|
-
return /* @__PURE__ */ (0,
|
|
1999
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1936
2000
|
SVGPathComponent,
|
|
1937
2001
|
{
|
|
1938
2002
|
rotation: 0,
|
|
@@ -1952,7 +2016,7 @@ var SchematicLine_default = SchematicLine;
|
|
|
1952
2016
|
|
|
1953
2017
|
// src/schematic-components/SchematicPath.tsx
|
|
1954
2018
|
var import_svg_path_generator3 = __toESM(require_svg_path_generator2());
|
|
1955
|
-
var
|
|
2019
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1956
2020
|
var SchematicPath = (props) => {
|
|
1957
2021
|
const { points, is_filled, is_closed, fill_color } = props.path.schematic;
|
|
1958
2022
|
if (points.length === 0)
|
|
@@ -1973,7 +2037,7 @@ var SchematicPath = (props) => {
|
|
|
1973
2037
|
x: pathBounds.minX + pathBounds.width / 2,
|
|
1974
2038
|
y: pathBounds.minY + pathBounds.height / 2
|
|
1975
2039
|
};
|
|
1976
|
-
return /* @__PURE__ */ (0,
|
|
2040
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1977
2041
|
SVGPathComponent,
|
|
1978
2042
|
{
|
|
1979
2043
|
rotation: 0,
|
|
@@ -1993,13 +2057,13 @@ var SchematicPath = (props) => {
|
|
|
1993
2057
|
var SchematicPath_default = SchematicPath;
|
|
1994
2058
|
|
|
1995
2059
|
// src/schematic-components/SchematicElement.tsx
|
|
1996
|
-
var
|
|
2060
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1997
2061
|
var SchematicElement = ({
|
|
1998
2062
|
element,
|
|
1999
2063
|
allElements
|
|
2000
2064
|
}) => {
|
|
2001
2065
|
if (element.type === "schematic_component") {
|
|
2002
|
-
return /* @__PURE__ */ (0,
|
|
2066
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2003
2067
|
SchematicComponent_default,
|
|
2004
2068
|
{
|
|
2005
2069
|
component: collectElementRefs(element, allElements)
|
|
@@ -2007,25 +2071,25 @@ var SchematicElement = ({
|
|
|
2007
2071
|
);
|
|
2008
2072
|
}
|
|
2009
2073
|
if (element.type === "schematic_trace") {
|
|
2010
|
-
return /* @__PURE__ */ (0,
|
|
2074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SchematicTrace_default, { trace: collectElementRefs(element, allElements) });
|
|
2011
2075
|
}
|
|
2012
2076
|
if (element.type === "schematic_port") {
|
|
2013
|
-
return /* @__PURE__ */ (0,
|
|
2077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SchematicPort_default, { port: collectElementRefs(element, allElements) });
|
|
2014
2078
|
}
|
|
2015
2079
|
if (element.type === "schematic_box") {
|
|
2016
|
-
return /* @__PURE__ */ (0,
|
|
2080
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SchematicBox_default, { box: collectElementRefs(element, allElements) });
|
|
2017
2081
|
}
|
|
2018
2082
|
if (element.type === "schematic_line") {
|
|
2019
|
-
return /* @__PURE__ */ (0,
|
|
2083
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SchematicLine_default, { line: collectElementRefs(element, allElements) });
|
|
2020
2084
|
}
|
|
2021
2085
|
if (element.type === "schematic_path") {
|
|
2022
|
-
return /* @__PURE__ */ (0,
|
|
2086
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SchematicPath_default, { path: collectElementRefs(element, allElements) });
|
|
2023
2087
|
}
|
|
2024
2088
|
if (element.type === "schematic_text") {
|
|
2025
|
-
return /* @__PURE__ */ (0,
|
|
2089
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SchematicText_default, { schematic_text: element });
|
|
2026
2090
|
}
|
|
2027
2091
|
if (element.type === "source_error") {
|
|
2028
|
-
return /* @__PURE__ */ (0,
|
|
2092
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RenderError_default, { text: element.message });
|
|
2029
2093
|
}
|
|
2030
2094
|
return null;
|
|
2031
2095
|
};
|
|
@@ -2036,19 +2100,19 @@ var import_react_error_boundary = require("react-error-boundary");
|
|
|
2036
2100
|
|
|
2037
2101
|
// src/schematic-components/TableViewer.tsx
|
|
2038
2102
|
var import_react5 = require("react");
|
|
2039
|
-
var
|
|
2103
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2040
2104
|
var LazyTableViewer = (0, import_react5.lazy)(
|
|
2041
2105
|
() => import("@tscircuit/table-viewer").then((m) => ({
|
|
2042
2106
|
default: m.SoupTableViewer
|
|
2043
2107
|
}))
|
|
2044
2108
|
);
|
|
2045
|
-
var TableViewer = (params) => /* @__PURE__ */ (0,
|
|
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 }) });
|
|
2046
2110
|
|
|
2047
2111
|
// src/Schematic.tsx
|
|
2048
|
-
var
|
|
2112
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2049
2113
|
var ErrorBoundary = import_react_error_boundary.ErrorBoundary;
|
|
2050
2114
|
var fallbackRender = (elm) => ({ error, resetErrorBoundary }) => {
|
|
2051
|
-
return /* @__PURE__ */ (0,
|
|
2115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { color: "red" }, children: [
|
|
2052
2116
|
"error rendering ",
|
|
2053
2117
|
elm.type,
|
|
2054
2118
|
": ",
|
|
@@ -2114,8 +2178,8 @@ var Schematic = ({
|
|
|
2114
2178
|
throw e;
|
|
2115
2179
|
});
|
|
2116
2180
|
}, [children]);
|
|
2117
|
-
return /* @__PURE__ */ (0,
|
|
2118
|
-
/* @__PURE__ */ (0,
|
|
2181
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
2182
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2119
2183
|
"div",
|
|
2120
2184
|
{
|
|
2121
2185
|
style: {
|
|
@@ -2133,7 +2197,7 @@ var Schematic = ({
|
|
|
2133
2197
|
boundsRef(el);
|
|
2134
2198
|
},
|
|
2135
2199
|
children: [
|
|
2136
|
-
/* @__PURE__ */ (0,
|
|
2200
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2137
2201
|
import_react_supergrid.SuperGrid,
|
|
2138
2202
|
{
|
|
2139
2203
|
stringifyCoord: (x, y, z) => {
|
|
@@ -2146,7 +2210,7 @@ var Schematic = ({
|
|
|
2146
2210
|
transform: cameraTransform
|
|
2147
2211
|
}
|
|
2148
2212
|
),
|
|
2149
|
-
elements?.map((elm, i) => /* @__PURE__ */ (0,
|
|
2213
|
+
elements?.map((elm, i) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ErrorBoundary, { fallbackRender: fallbackRender(elm), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2150
2214
|
SchematicElement,
|
|
2151
2215
|
{
|
|
2152
2216
|
element: elm,
|
|
@@ -2157,7 +2221,7 @@ var Schematic = ({
|
|
|
2157
2221
|
]
|
|
2158
2222
|
}
|
|
2159
2223
|
),
|
|
2160
|
-
showTable !== false && elements && /* @__PURE__ */ (0,
|
|
2224
|
+
showTable !== false && elements && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TableViewer, { elements })
|
|
2161
2225
|
] });
|
|
2162
2226
|
};
|
|
2163
2227
|
// Annotate the CommonJS export names for ESM import in node:
|