@tscircuit/schematic-viewer 1.1.10 → 1.1.12

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 CHANGED
@@ -23,6 +23,10 @@ var __copyProps = (to, from, except, desc) => {
23
23
  return to;
24
24
  };
25
25
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
30
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
31
  mod
28
32
  ));
@@ -937,6 +941,7 @@ module.exports = __toCommonJS(src_exports);
937
941
  var import_react5 = require("react");
938
942
  var import_react_supergrid = require("react-supergrid");
939
943
  var import_builder3 = require("@tscircuit/builder");
944
+ var builder1 = __toESM(require("@tscircuit/builder"));
940
945
  var import_react_fiber = require("@tscircuit/react-fiber");
941
946
 
942
947
  // src/lib/utils/collect-element-refs.ts
@@ -964,7 +969,7 @@ var collectElementRefs = (elm, allElms) => {
964
969
  return null;
965
970
  };
966
971
 
967
- // node_modules/zustand/esm/vanilla.mjs
972
+ // node_modules/zustand/esm/vanilla.js
968
973
  var createStoreImpl = (createState) => {
969
974
  let state;
970
975
  const listeners = /* @__PURE__ */ new Set();
@@ -992,9 +997,9 @@ var createStoreImpl = (createState) => {
992
997
  };
993
998
  var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
994
999
 
995
- // node_modules/zustand/esm/index.mjs
1000
+ // node_modules/zustand/esm/index.js
996
1001
  var import_react = require("react");
997
- var import_with_selector = __toESM(require_with_selector(), 1);
1002
+ var import_with_selector = __toESM(require_with_selector());
998
1003
  var { useSyncExternalStoreWithSelector } = import_with_selector.default;
999
1004
  function useStore(api, selector = api.getState, equalityFn) {
1000
1005
  const slice = useSyncExternalStoreWithSelector(
@@ -1267,43 +1272,54 @@ var SVGPathComponent = ({ size, center, rotation, paths }) => {
1267
1272
  width: Math.max(1, size.width * ct.a),
1268
1273
  height: Math.max(1, size.height * ct.d)
1269
1274
  };
1270
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
1271
- style: {
1272
- position: "absolute",
1273
- transform: rotation === 0 ? "" : `rotate(${rotation}rad)`,
1274
- left: absoluteCenter.x - absoluteSize.width / 2,
1275
- top: absoluteCenter.y - absoluteSize.height / 2
1276
- },
1277
- overflow: "visible",
1278
- width: absoluteSize.width,
1279
- height: absoluteSize.height,
1280
- viewBox: `${pathBounds.minX} ${pathBounds.minY} ${pathBounds.width} ${pathBounds.height}`,
1281
- children: paths.map((p, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
1282
- fill: p.fill ?? "none",
1283
- strokeLinecap: "round",
1284
- strokeWidth: 2 * (p.strokeWidth || 1),
1285
- stroke: p.stroke || "red",
1286
- d: p.d
1287
- }, i))
1288
- });
1275
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1276
+ "svg",
1277
+ {
1278
+ style: {
1279
+ position: "absolute",
1280
+ transform: rotation === 0 ? "" : `rotate(${rotation}rad)`,
1281
+ left: absoluteCenter.x - absoluteSize.width / 2,
1282
+ top: absoluteCenter.y - absoluteSize.height / 2
1283
+ // backgroundColor: badRatio ? "rgba(255, 0, 0, 0.5)" : "transparent",
1284
+ },
1285
+ overflow: "visible",
1286
+ width: absoluteSize.width,
1287
+ height: absoluteSize.height,
1288
+ viewBox: `${pathBounds.minX} ${pathBounds.minY} ${pathBounds.width} ${pathBounds.height}`,
1289
+ children: paths.map((p, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1290
+ "path",
1291
+ {
1292
+ fill: p.fill ?? "none",
1293
+ strokeLinecap: "round",
1294
+ strokeWidth: 2 * (p.strokeWidth || 1),
1295
+ stroke: p.stroke || "red",
1296
+ d: p.d
1297
+ },
1298
+ i
1299
+ ))
1300
+ }
1301
+ );
1289
1302
  };
1290
1303
  var SVGPathComponent_default = SVGPathComponent;
1291
1304
 
1292
1305
  // src/schematic-components/SimpleResistor.tsx
1293
1306
  var import_jsx_runtime2 = require("react/jsx-runtime");
1294
1307
  var SimpleResistor = ({ component: { source, schematic } }) => {
1295
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SVGPathComponent_default, {
1296
- rotation: schematic.rotation,
1297
- center: schematic.center,
1298
- size: schematic.size,
1299
- paths: [
1300
- {
1301
- stroke: "red",
1302
- strokeWidth: 1,
1303
- d: "M 0 15 l 10 0 l 0 -6 l 20 0 l 0 12 l -20 0 l 0 -6 m 20 0 l 10 0"
1304
- }
1305
- ]
1306
- });
1308
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1309
+ SVGPathComponent_default,
1310
+ {
1311
+ rotation: schematic.rotation,
1312
+ center: schematic.center,
1313
+ size: schematic.size,
1314
+ paths: [
1315
+ {
1316
+ stroke: "red",
1317
+ strokeWidth: 1,
1318
+ d: "M 0 15 l 10 0 l 0 -6 l 20 0 l 0 12 l -20 0 l 0 -6 m 20 0 l 10 0"
1319
+ }
1320
+ ]
1321
+ }
1322
+ );
1307
1323
  };
1308
1324
 
1309
1325
  // src/schematic-components/SimpleCapacitor.tsx
@@ -1311,17 +1327,20 @@ var import_jsx_runtime3 = require("react/jsx-runtime");
1311
1327
  var SimpleCapacitor = ({
1312
1328
  component: { source, schematic }
1313
1329
  }) => {
1314
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SVGPathComponent_default, {
1315
- rotation: schematic.rotation,
1316
- center: schematic.center,
1317
- size: schematic.size,
1318
- paths: [
1319
- { stroke: "red", strokeWidth: 1, d: "M 0 15 l 12 0" },
1320
- { stroke: "red", strokeWidth: 2, d: "M 12 0 l 0 30" },
1321
- { stroke: "red", strokeWidth: 2, d: "M 18 0 l 0 30" },
1322
- { stroke: "red", strokeWidth: 1, d: "M 18 15 l 12 0" }
1323
- ]
1324
- });
1330
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1331
+ SVGPathComponent_default,
1332
+ {
1333
+ rotation: schematic.rotation,
1334
+ center: schematic.center,
1335
+ size: schematic.size,
1336
+ paths: [
1337
+ { stroke: "red", strokeWidth: 1, d: "M 0 15 l 12 0" },
1338
+ { stroke: "red", strokeWidth: 2, d: "M 12 0 l 0 30" },
1339
+ { stroke: "red", strokeWidth: 2, d: "M 18 0 l 0 30" },
1340
+ { stroke: "red", strokeWidth: 1, d: "M 18 15 l 12 0" }
1341
+ ]
1342
+ }
1343
+ );
1325
1344
  };
1326
1345
 
1327
1346
  // src/lib/hooks/use-maybe-promise.ts
@@ -1348,23 +1367,26 @@ var directionToVec = (direction) => {
1348
1367
  // src/schematic-components/SchematicPort.tsx
1349
1368
  var import_jsx_runtime5 = require("react/jsx-runtime");
1350
1369
  var SchematicPort = ({ port: { source, schematic } }) => {
1351
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SVGPathComponent, {
1352
- rotation: 0,
1353
- center: schematic.center,
1354
- size: { width: 0.2, height: 0.2 },
1355
- paths: [
1356
- {
1357
- stroke: "blue",
1358
- strokeWidth: 1,
1359
- d: "M 0 0 l 10 0 l 0 10 l -10 0 z"
1360
- },
1361
- schematic.facing_direction ? {
1362
- stroke: "blue",
1363
- strokeWidth: 0.5,
1364
- d: `M 5 5 l ${directionToVec(schematic.facing_direction).x * 7} ${directionToVec(schematic.facing_direction).y * 7}`
1365
- } : null
1366
- ].filter(Boolean)
1367
- });
1370
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1371
+ SVGPathComponent,
1372
+ {
1373
+ rotation: 0,
1374
+ center: schematic.center,
1375
+ size: { width: 0.2, height: 0.2 },
1376
+ paths: [
1377
+ {
1378
+ stroke: "blue",
1379
+ strokeWidth: 1,
1380
+ d: "M 0 0 l 10 0 l 0 10 l -10 0 z"
1381
+ },
1382
+ schematic.facing_direction ? {
1383
+ stroke: "blue",
1384
+ strokeWidth: 0.5,
1385
+ d: `M 5 5 l ${directionToVec(schematic.facing_direction).x * 7} ${directionToVec(schematic.facing_direction).y * 7}`
1386
+ } : null
1387
+ ].filter(Boolean)
1388
+ }
1389
+ );
1368
1390
  };
1369
1391
  var SchematicPort_default = SchematicPort;
1370
1392
 
@@ -1533,16 +1555,19 @@ var SchematicText = ({ schematic_text }) => {
1533
1555
  } else if (anchor === "right") {
1534
1556
  offset = [-bounds.width, -bounds.height / 2];
1535
1557
  }
1536
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
1537
- ref: boundsRef,
1538
- style: {
1539
- fontFamily: "'IBM Plex Mono', monospace",
1540
- position: "absolute",
1541
- left: tPos.x + offset[0],
1542
- top: tPos.y + offset[1]
1543
- },
1544
- children: text
1545
- });
1558
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1559
+ "div",
1560
+ {
1561
+ ref: boundsRef,
1562
+ style: {
1563
+ fontFamily: "'IBM Plex Mono', monospace",
1564
+ position: "absolute",
1565
+ left: tPos.x + offset[0],
1566
+ top: tPos.y + offset[1]
1567
+ },
1568
+ children: text
1569
+ }
1570
+ );
1546
1571
  };
1547
1572
  var SchematicText_default = SchematicText;
1548
1573
 
@@ -1552,20 +1577,23 @@ var import_svg_path_generator = __toESM(require_svg_path_generator2());
1552
1577
  // src/schematic-components/RenderError.tsx
1553
1578
  var import_jsx_runtime7 = require("react/jsx-runtime");
1554
1579
  var RenderError_default = ({ text }) => {
1555
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
1556
- style: {
1557
- position: "fixed",
1558
- backgroundColor: "red",
1559
- color: "white",
1560
- fontSize: 14,
1561
- fontFamily: "sans-serif",
1562
- padding: 5,
1563
- right: 0,
1564
- top: 0,
1565
- opacity: 0.75
1566
- },
1567
- children: text
1568
- });
1580
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1581
+ "div",
1582
+ {
1583
+ style: {
1584
+ position: "fixed",
1585
+ backgroundColor: "red",
1586
+ color: "white",
1587
+ fontSize: 14,
1588
+ fontFamily: "sans-serif",
1589
+ padding: 5,
1590
+ right: 0,
1591
+ top: 0,
1592
+ opacity: 0.75
1593
+ },
1594
+ children: text
1595
+ }
1596
+ );
1569
1597
  };
1570
1598
 
1571
1599
  // src/schematic-components/SchematicTrace.tsx
@@ -1573,9 +1601,7 @@ var import_jsx_runtime8 = require("react/jsx-runtime");
1573
1601
  var SchematicTrace = ({ trace: { source, schematic } }) => {
1574
1602
  const edges = schematic.edges;
1575
1603
  if (edges.length === 0) {
1576
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RenderError_default, {
1577
- text: `Route with 0 edges (${source.source_trace_id})`
1578
- });
1604
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RenderError_default, { text: `Route with 0 edges (${source.source_trace_id})` });
1579
1605
  }
1580
1606
  const path = (0, import_svg_path_generator.default)();
1581
1607
  for (let i = 0; i < edges.length; i++) {
@@ -1590,18 +1616,21 @@ var SchematicTrace = ({ trace: { source, schematic } }) => {
1590
1616
  x: pathBounds.minX + pathBounds.width / 2,
1591
1617
  y: pathBounds.minY + pathBounds.height / 2
1592
1618
  };
1593
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SVGPathComponent_default, {
1594
- rotation: 0,
1595
- center,
1596
- size: pathBounds,
1597
- paths: [
1598
- {
1599
- stroke: "green",
1600
- strokeWidth: 0.02,
1601
- d
1602
- }
1603
- ]
1604
- });
1619
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1620
+ SVGPathComponent_default,
1621
+ {
1622
+ rotation: 0,
1623
+ center,
1624
+ size: pathBounds,
1625
+ paths: [
1626
+ {
1627
+ stroke: "green",
1628
+ strokeWidth: 0.02,
1629
+ d
1630
+ }
1631
+ ]
1632
+ }
1633
+ );
1605
1634
  };
1606
1635
  var SchematicTrace_default = SchematicTrace;
1607
1636
 
@@ -1644,12 +1673,15 @@ var SchematicBug = ({ component: { source, schematic } }) => {
1644
1673
  x: schematic.center.x + (actualSize.minX + actualSize.maxX) / 2,
1645
1674
  y: schematic.center.y + (actualSize.minY + actualSize.maxY) / 2
1646
1675
  };
1647
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SVGPathComponent_default, {
1648
- rotation: schematic.rotation,
1649
- center: actualCenter,
1650
- size: actualSize,
1651
- paths
1652
- });
1676
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1677
+ SVGPathComponent_default,
1678
+ {
1679
+ rotation: schematic.rotation,
1680
+ center: actualCenter,
1681
+ size: actualSize,
1682
+ paths
1683
+ }
1684
+ );
1653
1685
  };
1654
1686
 
1655
1687
  // src/schematic-components/SimplePowerSource.tsx
@@ -1657,52 +1689,62 @@ var import_jsx_runtime10 = require("react/jsx-runtime");
1657
1689
  var SimplePowerSource = ({
1658
1690
  component: { source, schematic }
1659
1691
  }) => {
1660
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SVGPathComponent_default, {
1661
- rotation: schematic.rotation,
1662
- center: schematic.center,
1663
- size: schematic.size,
1664
- paths: [
1665
- {
1666
- stroke: "red",
1667
- strokeWidth: 1,
1668
- 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"
1669
- }
1670
- ]
1671
- });
1692
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1693
+ SVGPathComponent_default,
1694
+ {
1695
+ rotation: schematic.rotation,
1696
+ center: schematic.center,
1697
+ size: schematic.size,
1698
+ paths: [
1699
+ {
1700
+ stroke: "red",
1701
+ strokeWidth: 1,
1702
+ 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"
1703
+ }
1704
+ ]
1705
+ }
1706
+ );
1672
1707
  };
1673
1708
 
1674
1709
  // src/schematic-components/SimpleGround.tsx
1675
1710
  var import_jsx_runtime11 = require("react/jsx-runtime");
1676
1711
  var SimpleGround = ({ component: { source, schematic } }) => {
1677
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SVGPathComponent_default, {
1678
- rotation: schematic.rotation,
1679
- center: schematic.center,
1680
- size: schematic.size,
1681
- paths: [
1682
- {
1683
- stroke: "red",
1684
- strokeWidth: 0.7,
1685
- d: "M -3 3 L 3 3 M -6 0 L 6 0 M -9 -3 L 9 -3 M 0 -3 L 0 -12"
1686
- }
1687
- ]
1688
- });
1712
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1713
+ SVGPathComponent_default,
1714
+ {
1715
+ rotation: schematic.rotation,
1716
+ center: schematic.center,
1717
+ size: schematic.size,
1718
+ paths: [
1719
+ {
1720
+ stroke: "red",
1721
+ strokeWidth: 0.7,
1722
+ d: "M -3 3 L 3 3 M -6 0 L 6 0 M -9 -3 L 9 -3 M 0 -3 L 0 -12"
1723
+ }
1724
+ ]
1725
+ }
1726
+ );
1689
1727
  };
1690
1728
 
1691
1729
  // src/schematic-components/SimpleInductor.tsx
1692
1730
  var import_jsx_runtime12 = require("react/jsx-runtime");
1693
1731
  var SimpleInductor = ({ component: { source, schematic } }) => {
1694
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SVGPathComponent_default, {
1695
- rotation: schematic.rotation,
1696
- center: schematic.center,
1697
- size: schematic.size,
1698
- paths: [
1699
- {
1700
- stroke: "red",
1701
- strokeWidth: 1,
1702
- d: "m 371,710.41665 h -14 c -0.0421,-16.39898 -14.02104,-16.39898 -14,0 -0.021,-16.399 -14.04182,-16.34072 -14,0 -2.6e-4,-16.45722 -14.04236,-16.45722 -14,0 2.8e-4,-16.3407 -13.97896,-16.39898 -14,0 -0.0421,-16.39898 -13.91338,-16.39898 -13.91338,0 H 273"
1703
- }
1704
- ]
1705
- });
1732
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1733
+ SVGPathComponent_default,
1734
+ {
1735
+ rotation: schematic.rotation,
1736
+ center: schematic.center,
1737
+ size: schematic.size,
1738
+ paths: [
1739
+ {
1740
+ stroke: "red",
1741
+ strokeWidth: 1,
1742
+ // https://commons.wikimedia.org/wiki/File:Electrical_symbols_library.svg
1743
+ d: "m 371,710.41665 h -14 c -0.0421,-16.39898 -14.02104,-16.39898 -14,0 -0.021,-16.399 -14.04182,-16.34072 -14,0 -2.6e-4,-16.45722 -14.04236,-16.45722 -14,0 2.8e-4,-16.3407 -13.97896,-16.39898 -14,0 -0.0421,-16.39898 -13.91338,-16.39898 -13.91338,0 H 273"
1744
+ }
1745
+ ]
1746
+ }
1747
+ );
1706
1748
  };
1707
1749
 
1708
1750
  // src/schematic-components/SimpleDiode.tsx
@@ -1716,45 +1758,31 @@ var SchematicComponent = ({ component }) => {
1716
1758
  return null;
1717
1759
  switch (source.ftype) {
1718
1760
  case "simple_resistor": {
1719
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimpleResistor, {
1720
- component: { source, schematic }
1721
- });
1761
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimpleResistor, { component: { source, schematic } });
1722
1762
  }
1723
1763
  case "simple_capacitor": {
1724
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimpleCapacitor, {
1725
- component: { source, schematic }
1726
- });
1764
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimpleCapacitor, { component: { source, schematic } });
1727
1765
  }
1728
1766
  case "simple_power_source": {
1729
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimplePowerSource, {
1730
- component: { source, schematic }
1731
- });
1767
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimplePowerSource, { component: { source, schematic } });
1732
1768
  }
1733
1769
  case "simple_ground": {
1734
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimpleGround, {
1735
- component: { source, schematic }
1736
- });
1770
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimpleGround, { component: { source, schematic } });
1737
1771
  }
1738
1772
  case "simple_inductor": {
1739
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimpleInductor, {
1740
- component: { source, schematic }
1741
- });
1773
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimpleInductor, { component: { source, schematic } });
1742
1774
  }
1743
1775
  case "simple_bug": {
1744
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SchematicBug, {
1745
- component: { source, schematic }
1746
- });
1776
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SchematicBug, { component: { source, schematic } });
1747
1777
  }
1748
1778
  case "simple_diode": {
1749
1779
  return null;
1750
1780
  }
1751
1781
  default: {
1752
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", {
1753
- children: [
1754
- "unknown ftype: ",
1755
- component.source.ftype
1756
- ]
1757
- });
1782
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { children: [
1783
+ "unknown ftype: ",
1784
+ component.source.ftype
1785
+ ] });
1758
1786
  }
1759
1787
  }
1760
1788
  };
@@ -1764,18 +1792,21 @@ var SchematicComponent_default = SchematicComponent;
1764
1792
  var import_jsx_runtime15 = require("react/jsx-runtime");
1765
1793
  var SchematicBox = ({ box: { schematic } }) => {
1766
1794
  const { width: w, height: h } = schematic;
1767
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SVGPathComponent, {
1768
- rotation: 0,
1769
- center: schematic,
1770
- size: { width: schematic.width, height: schematic.height },
1771
- paths: [
1772
- {
1773
- stroke: "red",
1774
- strokeWidth: 0.02,
1775
- d: `M 0 0 l ${w} 0 l 0 ${h} l -${w} 0 z`
1776
- }
1777
- ]
1778
- });
1795
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1796
+ SVGPathComponent,
1797
+ {
1798
+ rotation: 0,
1799
+ center: schematic,
1800
+ size: { width: schematic.width, height: schematic.height },
1801
+ paths: [
1802
+ {
1803
+ stroke: "red",
1804
+ strokeWidth: 0.02,
1805
+ d: `M 0 0 l ${w} 0 l 0 ${h} l -${w} 0 z`
1806
+ }
1807
+ ]
1808
+ }
1809
+ );
1779
1810
  };
1780
1811
  var SchematicBox_default = SchematicBox;
1781
1812
 
@@ -1797,18 +1828,21 @@ var SchematicLine = ({ line: { schematic } }) => {
1797
1828
  x: pathBounds.minX + pathBounds.width / 2,
1798
1829
  y: pathBounds.minY + pathBounds.height / 2
1799
1830
  };
1800
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SVGPathComponent, {
1801
- rotation: 0,
1802
- center,
1803
- size: pathBounds,
1804
- paths: [
1805
- {
1806
- stroke: "red",
1807
- strokeWidth: 0.02,
1808
- d
1809
- }
1810
- ]
1811
- });
1831
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1832
+ SVGPathComponent,
1833
+ {
1834
+ rotation: 0,
1835
+ center,
1836
+ size: pathBounds,
1837
+ paths: [
1838
+ {
1839
+ stroke: "red",
1840
+ strokeWidth: 0.02,
1841
+ d
1842
+ }
1843
+ ]
1844
+ }
1845
+ );
1812
1846
  };
1813
1847
  var SchematicLine_default = SchematicLine;
1814
1848
 
@@ -1816,7 +1850,6 @@ var SchematicLine_default = SchematicLine;
1816
1850
  var import_svg_path_generator3 = __toESM(require_svg_path_generator2());
1817
1851
  var import_jsx_runtime17 = require("react/jsx-runtime");
1818
1852
  var SchematicPath = (props) => {
1819
- console.log("SchematicPath", props);
1820
1853
  const { points, is_filled, is_closed, fill_color } = props.path.schematic;
1821
1854
  if (points.length === 0)
1822
1855
  return null;
@@ -1836,19 +1869,22 @@ var SchematicPath = (props) => {
1836
1869
  x: pathBounds.minX + pathBounds.width / 2,
1837
1870
  y: pathBounds.minY + pathBounds.height / 2
1838
1871
  };
1839
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SVGPathComponent, {
1840
- rotation: 0,
1841
- center,
1842
- size: pathBounds,
1843
- paths: [
1844
- {
1845
- stroke: is_filled ? "none" : fill_color ?? "red",
1846
- strokeWidth: 0.02,
1847
- fill: is_filled ? fill_color ?? "red" : void 0,
1848
- d
1849
- }
1850
- ]
1851
- });
1872
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1873
+ SVGPathComponent,
1874
+ {
1875
+ rotation: 0,
1876
+ center,
1877
+ size: pathBounds,
1878
+ paths: [
1879
+ {
1880
+ stroke: is_filled ? "none" : fill_color ?? "red",
1881
+ strokeWidth: 0.02,
1882
+ fill: is_filled ? fill_color ?? "red" : void 0,
1883
+ d
1884
+ }
1885
+ ]
1886
+ }
1887
+ );
1852
1888
  };
1853
1889
  var SchematicPath_default = SchematicPath;
1854
1890
 
@@ -1859,44 +1895,33 @@ var SchematicElement = ({
1859
1895
  allElements
1860
1896
  }) => {
1861
1897
  if (element.type === "schematic_component") {
1862
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicComponent_default, {
1863
- component: collectElementRefs(element, allElements)
1864
- });
1898
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1899
+ SchematicComponent_default,
1900
+ {
1901
+ component: collectElementRefs(element, allElements)
1902
+ }
1903
+ );
1865
1904
  }
1866
1905
  if (element.type === "schematic_trace") {
1867
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicTrace_default, {
1868
- trace: collectElementRefs(element, allElements)
1869
- });
1906
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicTrace_default, { trace: collectElementRefs(element, allElements) });
1870
1907
  }
1871
1908
  if (element.type === "schematic_port") {
1872
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicPort_default, {
1873
- port: collectElementRefs(element, allElements)
1874
- });
1909
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicPort_default, { port: collectElementRefs(element, allElements) });
1875
1910
  }
1876
1911
  if (element.type === "schematic_box") {
1877
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicBox_default, {
1878
- box: collectElementRefs(element, allElements)
1879
- });
1912
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicBox_default, { box: collectElementRefs(element, allElements) });
1880
1913
  }
1881
1914
  if (element.type === "schematic_line") {
1882
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicLine_default, {
1883
- line: collectElementRefs(element, allElements)
1884
- });
1915
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicLine_default, { line: collectElementRefs(element, allElements) });
1885
1916
  }
1886
1917
  if (element.type === "schematic_path") {
1887
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicPath_default, {
1888
- path: collectElementRefs(element, allElements)
1889
- });
1918
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicPath_default, { path: collectElementRefs(element, allElements) });
1890
1919
  }
1891
1920
  if (element.type === "schematic_text") {
1892
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicText_default, {
1893
- schematic_text: element
1894
- });
1921
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicText_default, { schematic_text: element });
1895
1922
  }
1896
1923
  if (element.type === "source_error") {
1897
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RenderError_default, {
1898
- text: element.message
1899
- });
1924
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RenderError_default, { text: element.message });
1900
1925
  }
1901
1926
  return null;
1902
1927
  };
@@ -1913,27 +1938,17 @@ var LazyTableViewer = (0, import_react4.lazy)(
1913
1938
  default: m.SoupTableViewer
1914
1939
  }))
1915
1940
  );
1916
- var TableViewer = (params) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react4.Suspense, {
1917
- fallback: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", {
1918
- children: "Loading..."
1919
- }),
1920
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LazyTableViewer, {
1921
- ...params
1922
- })
1923
- });
1941
+ var TableViewer = (params) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react4.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: "Loading..." }), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LazyTableViewer, { ...params }) });
1924
1942
 
1925
1943
  // src/Schematic.tsx
1926
1944
  var import_jsx_runtime20 = require("react/jsx-runtime");
1927
1945
  var fallbackRender = (elm) => ({ error, resetErrorBoundary }) => {
1928
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", {
1929
- style: { color: "red" },
1930
- children: [
1931
- "error rendering ",
1932
- elm.type,
1933
- ": ",
1934
- error.toString()
1935
- ]
1936
- });
1946
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { style: { color: "red" }, children: [
1947
+ "error rendering ",
1948
+ elm.type,
1949
+ ": ",
1950
+ error.toString()
1951
+ ] });
1937
1952
  };
1938
1953
  var toMMSINeg = (v, z) => v >= 0 ? (0, import_react_supergrid.toMMSI)(v, z) : `-${(0, import_react_supergrid.toMMSI)(-v, z)}`;
1939
1954
  var Schematic = ({
@@ -1953,7 +1968,9 @@ var Schematic = ({
1953
1968
  onSetTransform: (transform2) => {
1954
1969
  setCameraTransform(transform2);
1955
1970
  }
1971
+ // initialTransform: compose(scale(100, 100, 0, 0)),
1956
1972
  });
1973
+ console.log({ builder1 });
1957
1974
  const setElementsAndCamera = (0, import_react5.useCallback)(
1958
1975
  (elements2) => {
1959
1976
  const elmBounds = ref.current.getBoundingClientRect();
@@ -1972,6 +1989,7 @@ var Schematic = ({
1972
1989
  setTransform(
1973
1990
  compose(
1974
1991
  translate((elmBounds.width ?? 0) / 2, (elmBounds.height ?? 0) / 2),
1992
+ // translate(100, 0),
1975
1993
  scale(scaleFactor, scaleFactor, 0, 0),
1976
1994
  translate(-center.x, -center.y)
1977
1995
  )
@@ -1992,9 +2010,10 @@ var Schematic = ({
1992
2010
  throw e;
1993
2011
  });
1994
2012
  }, [children]);
1995
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, {
1996
- children: [
1997
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", {
2013
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
2014
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2015
+ "div",
2016
+ {
1998
2017
  style: {
1999
2018
  width: "100%",
2000
2019
  backgroundColor: "rgba(255,255,255,0)",
@@ -2009,69 +2028,81 @@ var Schematic = ({
2009
2028
  boundsRef(el);
2010
2029
  },
2011
2030
  children: [
2012
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react_supergrid.SuperGrid, {
2013
- stringifyCoord: (x, y, z) => {
2014
- if (z === 0)
2015
- return "";
2016
- return `${toMMSINeg(x, z)}, ${toMMSINeg(y, z)}`;
2017
- },
2018
- width: bounds.width,
2019
- height: bounds.height,
2020
- transform: cameraTransform
2021
- }),
2022
- elements == null ? void 0 : elements.map((elm, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react_error_boundary.ErrorBoundary, {
2023
- fallbackRender: fallbackRender(elm),
2024
- children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SchematicElement, {
2031
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2032
+ import_react_supergrid.SuperGrid,
2033
+ {
2034
+ stringifyCoord: (x, y, z) => {
2035
+ if (z === 0)
2036
+ return "";
2037
+ return `${toMMSINeg(x, z)}, ${toMMSINeg(y, z)}`;
2038
+ },
2039
+ width: bounds.width,
2040
+ height: bounds.height,
2041
+ transform: cameraTransform
2042
+ }
2043
+ ),
2044
+ elements?.map((elm, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react_error_boundary.ErrorBoundary, { fallbackRender: fallbackRender(elm), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2045
+ SchematicElement,
2046
+ {
2025
2047
  element: elm,
2026
2048
  allElements: elements
2027
- }, JSON.stringify(elm))
2028
- }, i))
2049
+ },
2050
+ JSON.stringify(elm)
2051
+ ) }, i))
2029
2052
  ]
2030
- }),
2031
- showTable !== false && elements && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TableViewer, {
2032
- elements
2033
- })
2034
- ]
2035
- });
2053
+ }
2054
+ ),
2055
+ showTable !== false && elements && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TableViewer, { elements })
2056
+ ] });
2036
2057
  };
2037
2058
  // Annotate the CommonJS export names for ESM import in node:
2038
2059
  0 && (module.exports = {
2039
2060
  Schematic
2040
2061
  });
2041
- /**
2042
- * @license React
2043
- * use-sync-external-store-shim.development.js
2044
- *
2045
- * Copyright (c) Facebook, Inc. and its affiliates.
2046
- *
2047
- * This source code is licensed under the MIT license found in the
2048
- * LICENSE file in the root directory of this source tree.
2049
- */
2050
- /**
2051
- * @license React
2052
- * use-sync-external-store-shim.production.min.js
2053
- *
2054
- * Copyright (c) Facebook, Inc. and its affiliates.
2055
- *
2056
- * This source code is licensed under the MIT license found in the
2057
- * LICENSE file in the root directory of this source tree.
2058
- */
2059
- /**
2060
- * @license React
2061
- * use-sync-external-store-shim/with-selector.development.js
2062
- *
2063
- * Copyright (c) Facebook, Inc. and its affiliates.
2064
- *
2065
- * This source code is licensed under the MIT license found in the
2066
- * LICENSE file in the root directory of this source tree.
2067
- */
2068
- /**
2069
- * @license React
2070
- * use-sync-external-store-shim/with-selector.production.min.js
2071
- *
2072
- * Copyright (c) Facebook, Inc. and its affiliates.
2073
- *
2074
- * This source code is licensed under the MIT license found in the
2075
- * LICENSE file in the root directory of this source tree.
2076
- */
2062
+ /*! Bundled license information:
2063
+
2064
+ use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js:
2065
+ (**
2066
+ * @license React
2067
+ * use-sync-external-store-shim.production.min.js
2068
+ *
2069
+ * Copyright (c) Facebook, Inc. and its affiliates.
2070
+ *
2071
+ * This source code is licensed under the MIT license found in the
2072
+ * LICENSE file in the root directory of this source tree.
2073
+ *)
2074
+
2075
+ use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
2076
+ (**
2077
+ * @license React
2078
+ * use-sync-external-store-shim.development.js
2079
+ *
2080
+ * Copyright (c) Facebook, Inc. and its affiliates.
2081
+ *
2082
+ * This source code is licensed under the MIT license found in the
2083
+ * LICENSE file in the root directory of this source tree.
2084
+ *)
2085
+
2086
+ use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js:
2087
+ (**
2088
+ * @license React
2089
+ * use-sync-external-store-shim/with-selector.production.min.js
2090
+ *
2091
+ * Copyright (c) Facebook, Inc. and its affiliates.
2092
+ *
2093
+ * This source code is licensed under the MIT license found in the
2094
+ * LICENSE file in the root directory of this source tree.
2095
+ *)
2096
+
2097
+ use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
2098
+ (**
2099
+ * @license React
2100
+ * use-sync-external-store-shim/with-selector.development.js
2101
+ *
2102
+ * Copyright (c) Facebook, Inc. and its affiliates.
2103
+ *
2104
+ * This source code is licensed under the MIT license found in the
2105
+ * LICENSE file in the root directory of this source tree.
2106
+ *)
2107
+ */
2077
2108
  //# sourceMappingURL=index.js.map