@tscircuit/pcb-viewer 1.3.1 → 1.3.2

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
@@ -479,19 +479,19 @@ var require_dist = __commonJS({
479
479
  });
480
480
  module2.exports = __toCommonJS2(src_exports2);
481
481
  var import_transformation_matrix6 = require("transformation-matrix");
482
- var import_react16 = require("react");
482
+ var import_react15 = require("react");
483
483
  var useMouseMatrixTransform2 = function() {
484
484
  var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
485
- var extRef = (0, import_react16.useRef)(null);
485
+ var extRef = (0, import_react15.useRef)(null);
486
486
  var _props_canvasElm;
487
487
  var outerCanvasElm = (_props_canvasElm = props.canvasElm) !== null && _props_canvasElm !== void 0 ? _props_canvasElm : extRef.current;
488
488
  var _props_initialTransform;
489
- var _ref = _sliced_to_array((0, import_react16.useState)((_props_initialTransform = props.initialTransform) !== null && _props_initialTransform !== void 0 ? _props_initialTransform : (0, import_transformation_matrix6.identity)()), 2), internalTransform = _ref[0], setInternalTransform = _ref[1];
490
- var _ref1 = _sliced_to_array((0, import_react16.useState)(0), 2), waitCounter = _ref1[0], setWaitCounter = _ref1[1];
491
- var _ref2 = _sliced_to_array((0, import_react16.useReducer)(function(s) {
489
+ var _ref = _sliced_to_array((0, import_react15.useState)((_props_initialTransform = props.initialTransform) !== null && _props_initialTransform !== void 0 ? _props_initialTransform : (0, import_transformation_matrix6.identity)()), 2), internalTransform = _ref[0], setInternalTransform = _ref[1];
490
+ var _ref1 = _sliced_to_array((0, import_react15.useState)(0), 2), waitCounter = _ref1[0], setWaitCounter = _ref1[1];
491
+ var _ref2 = _sliced_to_array((0, import_react15.useReducer)(function(s) {
492
492
  return s + 1;
493
493
  }, 0), 2), extChangeCounter = _ref2[0], incExtChangeCounter = _ref2[1];
494
- var setTransform = (0, import_react16.useCallback)(function(newTransform) {
494
+ var setTransform = (0, import_react15.useCallback)(function(newTransform) {
495
495
  if (props.onSetTransform) {
496
496
  props.onSetTransform(newTransform);
497
497
  }
@@ -502,7 +502,7 @@ var require_dist = __commonJS({
502
502
  props.onSetTransform,
503
503
  setInternalTransform
504
504
  ]);
505
- var setTransformExt = (0, import_react16.useCallback)(function(newTransform) {
505
+ var setTransformExt = (0, import_react15.useCallback)(function(newTransform) {
506
506
  setTransform(newTransform);
507
507
  incExtChangeCounter();
508
508
  }, [
@@ -510,7 +510,7 @@ var require_dist = __commonJS({
510
510
  ]);
511
511
  var _props_transform;
512
512
  var transform = (_props_transform = props.transform) !== null && _props_transform !== void 0 ? _props_transform : internalTransform;
513
- (0, import_react16.useEffect)(function() {
513
+ (0, import_react15.useEffect)(function() {
514
514
  var handleMouseDown = function handleMouseDown(e) {
515
515
  m0 = getMousePos(e);
516
516
  md = true;
@@ -593,7 +593,7 @@ var require_dist = __commonJS({
593
593
  waitCounter,
594
594
  extChangeCounter
595
595
  ]);
596
- var applyTransformToPoint = (0, import_react16.useCallback)(function(obj) {
596
+ var applyTransformToPoint = (0, import_react15.useCallback)(function(obj) {
597
597
  return (0, import_transformation_matrix6.applyToPoint)(transform, obj);
598
598
  }, [
599
599
  transform
@@ -620,14 +620,12 @@ __export(src_exports, {
620
620
  });
621
621
  module.exports = __toCommonJS(src_exports);
622
622
  // src/PCBViewer.tsx
623
- var import_react15 = __toESM(require("react"));
623
+ var import_react14 = require("react");
624
624
  var import_react_fiber = require("@tscircuit/react-fiber");
625
625
  var import_builder3 = require("@tscircuit/builder");
626
- // src/components/CanvasElementsRenderer.tsx
627
- var import_react11 = __toESM(require("react"));
628
626
  // src/components/CanvasPrimitiveRenderer.tsx
629
627
  var import_react_supergrid = require("react-supergrid");
630
- var import_react4 = __toESM(require("react"));
628
+ var import_react4 = require("react");
631
629
  // src/assets/alphabet.ts
632
630
  var svgAlphabet = {
633
631
  "0": "M0.4544564813877358 0L0.2723441540828736 0.03592830447352719L0.1086847233315459 0.14528754990019965L0.020630545837255005 0.3040632652221331L0 0.5395277421960205L0.049259221760993496 0.7369487828466779L0.18080513776237842 0.9005494166306564L0.37036887043974215 0.9872116270037247L0.5864663759301132 1L0.8148695622827444 0.9332890276148733L0.9326583645506394 0.8113052246023419L1 0.4031281830668562L0.833288960385582 0.09886798567812842L0.6801767918233781 0.02483708485091681L0.4544564813877358 0",
@@ -1290,15 +1288,17 @@ var import_zustand = require("zustand");
1290
1288
  // src/components/ContextProviders.tsx
1291
1289
  var import_react = require("react");
1292
1290
  var import_react2 = require("react");
1291
+ var import_jsx_runtime = require("react/jsx-runtime");
1293
1292
  var StoreContext = (0, import_react2.createContext)(null);
1294
1293
  var ContextProviders = function(param) {
1295
1294
  var children = param.children;
1296
1295
  var store = (0, import_react.useMemo)(function() {
1297
1296
  return createStore();
1298
1297
  }, []);
1299
- return /* @__PURE__ */ React.createElement(StoreContext.Provider, {
1300
- value: store
1301
- }, children);
1298
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StoreContext.Provider, {
1299
+ value: store,
1300
+ children: children
1301
+ });
1302
1302
  };
1303
1303
  // src/global-store.ts
1304
1304
  var import_react3 = require("react");
@@ -1320,6 +1320,7 @@ var useStore = function(s) {
1320
1320
  };
1321
1321
  // src/components/CanvasPrimitiveRenderer.tsx
1322
1322
  var import_builder = require("@tscircuit/builder");
1323
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1323
1324
  var CanvasPrimitiveRenderer = function(param) {
1324
1325
  var primitives = param.primitives, transform = param.transform, grid = param.grid, _param_width = param.width, width = _param_width === void 0 ? 500 : _param_width, _param_height = param.height, height = _param_height === void 0 ? 500 : _param_height;
1325
1326
  var canvasRefs = (0, import_react4.useRef)();
@@ -1340,50 +1341,53 @@ var CanvasPrimitiveRenderer = function(param) {
1340
1341
  transform,
1341
1342
  selectedLayer
1342
1343
  ]);
1343
- return /* @__PURE__ */ import_react4.default.createElement("div", {
1344
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", {
1344
1345
  style: {
1345
1346
  backgroundColor: "black",
1346
1347
  width: width,
1347
1348
  height: height,
1348
1349
  position: "relative"
1349
- }
1350
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_supergrid.SuperGrid, {
1351
- textColor: "rgba(0,255,0,0.8)",
1352
- majorColor: "rgba(0,255,0,0.4)",
1353
- minorColor: "rgba(0,255,0,0.2)",
1354
- screenSpaceCellSize: 200,
1355
- width: width,
1356
- height: height,
1357
- transform: transform,
1358
- stringifyCoord: function(x, y, z) {
1359
- return "".concat((0, import_react_supergrid.toMMSI)(x, z), ", ").concat((0, import_react_supergrid.toMMSI)(y, z));
1360
- }
1361
- }), import_builder.all_layers.map(function(l) {
1362
- return l.replace(/-/g, "");
1363
- }).concat([
1364
- "drill",
1365
- "other"
1366
- ]).map(function(layer, i) {
1367
- return /* @__PURE__ */ import_react4.default.createElement("canvas", {
1368
- key: layer,
1369
- ref: function(el) {
1370
- var _canvasRefs_current;
1371
- (_canvasRefs_current = canvasRefs.current) !== null && _canvasRefs_current !== void 0 ? _canvasRefs_current : canvasRefs.current = {};
1372
- canvasRefs.current[layer] = el;
1373
- },
1374
- style: {
1375
- position: "absolute",
1376
- left: 0,
1377
- top: 0,
1378
- pointerEvents: "none"
1379
- },
1380
- width: width,
1381
- height: height
1382
- });
1383
- }));
1350
+ },
1351
+ children: [
1352
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_supergrid.SuperGrid, {
1353
+ textColor: "rgba(0,255,0,0.8)",
1354
+ majorColor: "rgba(0,255,0,0.4)",
1355
+ minorColor: "rgba(0,255,0,0.2)",
1356
+ screenSpaceCellSize: 200,
1357
+ width: width,
1358
+ height: height,
1359
+ transform: transform,
1360
+ stringifyCoord: function(x, y, z) {
1361
+ return "".concat((0, import_react_supergrid.toMMSI)(x, z), ", ").concat((0, import_react_supergrid.toMMSI)(y, z));
1362
+ }
1363
+ }),
1364
+ import_builder.all_layers.map(function(l) {
1365
+ return l.replace(/-/g, "");
1366
+ }).concat([
1367
+ "drill",
1368
+ "other"
1369
+ ]).map(function(layer, i) {
1370
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("canvas", {
1371
+ ref: function(el) {
1372
+ var _canvasRefs_current;
1373
+ (_canvasRefs_current = canvasRefs.current) !== null && _canvasRefs_current !== void 0 ? _canvasRefs_current : canvasRefs.current = {};
1374
+ canvasRefs.current[layer] = el;
1375
+ },
1376
+ style: {
1377
+ position: "absolute",
1378
+ left: 0,
1379
+ top: 0,
1380
+ pointerEvents: "none"
1381
+ },
1382
+ width: width,
1383
+ height: height
1384
+ }, layer);
1385
+ })
1386
+ ]
1387
+ });
1384
1388
  };
1385
1389
  // src/components/CanvasElementsRenderer.tsx
1386
- var import_react12 = require("react");
1390
+ var import_react11 = require("react");
1387
1391
  // src/lib/convert-element-to-primitive.ts
1388
1392
  var convertElementToPrimitives = function(element, allElements) {
1389
1393
  var _parent_pcb_component = "pcb_component_id" in element ? allElements.find(function(elm) {
@@ -1609,11 +1613,12 @@ var convertElementToPrimitives = function(element, allElements) {
1609
1613
  return [];
1610
1614
  };
1611
1615
  // src/components/MouseElementTracker.tsx
1612
- var import_react6 = __toESM(require("react"));
1616
+ var import_react6 = require("react");
1613
1617
  var import_react7 = require("react");
1614
1618
  var import_transformation_matrix2 = require("transformation-matrix");
1615
1619
  // src/components/ElementOverlayBox.tsx
1616
- var import_react5 = __toESM(require("react"));
1620
+ var import_react5 = require("react");
1621
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1617
1622
  var containerStyle = {
1618
1623
  position: "absolute",
1619
1624
  left: 0,
@@ -1671,7 +1676,7 @@ var HighlightedPrimitiveBoxWithText = function(param) {
1671
1676
  var sip = 26;
1672
1677
  var _layerColorHightlightMap_primitive__element_layer;
1673
1678
  var color = (_layerColorHightlightMap_primitive__element_layer = layerColorHightlightMap[primitive === null || primitive === void 0 ? void 0 : (_primitive__element = primitive._element) === null || _primitive__element === void 0 ? void 0 : _primitive__element.layer]) !== null && _layerColorHightlightMap_primitive__element_layer !== void 0 ? _layerColorHightlightMap_primitive__element_layer : "red";
1674
- return /* @__PURE__ */ import_react5.default.createElement("div", {
1679
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", {
1675
1680
  style: {
1676
1681
  position: "absolute",
1677
1682
  left: x - w / 2 - 8,
@@ -1679,45 +1684,49 @@ var HighlightedPrimitiveBoxWithText = function(param) {
1679
1684
  width: w + 16,
1680
1685
  height: h + 16,
1681
1686
  color: color
1682
- }
1683
- }, /* @__PURE__ */ import_react5.default.createElement("div", {
1684
- style: {
1685
- // width: finalState ? `${100 + 20 * si}%` : "100%",
1686
- // height: finalState ? `${100 + 20 * si}%` : "100%",
1687
- // marginLeft: finalState ? `${-10 * si}%` : 0,
1688
- // marginTop: finalState ? `${-10 * si}%` : 0,
1689
- width: finalState ? "calc(100% + ".concat(sip * 2 * si, "px)") : "100%",
1690
- height: finalState ? "calc(100% + ".concat(sip * 2 * si, "px)") : "100%",
1691
- marginLeft: finalState ? "".concat(-sip * si, "px") : 0,
1692
- marginTop: finalState ? "".concat(-sip * si, "px") : 0,
1693
- border: "1px solid ".concat(color),
1694
- opacity: finalState ? 1 : si === 0 ? 1 : 0,
1695
- transition: "width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"
1696
- }
1697
- }, /* @__PURE__ */ import_react5.default.createElement("div", {
1698
- style: {
1699
- position: "absolute",
1700
- left: 0,
1701
- bottom: h + 20 + sip * si,
1702
- marginLeft: finalState ? "".concat(-sip * si, "px") : 0,
1703
- marginBottom: finalState ? 0 : -sip * si,
1704
- transition: "margin-left 0.2s, margin-bottom 0.2s",
1705
- lineHeight: "0.8em"
1706
- }
1707
- }, getTextForHighlightedPrimitive(primitive))));
1687
+ },
1688
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", {
1689
+ style: {
1690
+ // width: finalState ? `${100 + 20 * si}%` : "100%",
1691
+ // height: finalState ? `${100 + 20 * si}%` : "100%",
1692
+ // marginLeft: finalState ? `${-10 * si}%` : 0,
1693
+ // marginTop: finalState ? `${-10 * si}%` : 0,
1694
+ width: finalState ? "calc(100% + ".concat(sip * 2 * si, "px)") : "100%",
1695
+ height: finalState ? "calc(100% + ".concat(sip * 2 * si, "px)") : "100%",
1696
+ marginLeft: finalState ? "".concat(-sip * si, "px") : 0,
1697
+ marginTop: finalState ? "".concat(-sip * si, "px") : 0,
1698
+ border: "1px solid ".concat(color),
1699
+ opacity: finalState ? 1 : si === 0 ? 1 : 0,
1700
+ transition: "width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"
1701
+ },
1702
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", {
1703
+ style: {
1704
+ position: "absolute",
1705
+ left: 0,
1706
+ bottom: h + 20 + sip * si,
1707
+ marginLeft: finalState ? "".concat(-sip * si, "px") : 0,
1708
+ marginBottom: finalState ? 0 : -sip * si,
1709
+ transition: "margin-left 0.2s, margin-bottom 0.2s",
1710
+ lineHeight: "0.8em"
1711
+ },
1712
+ children: getTextForHighlightedPrimitive(primitive)
1713
+ })
1714
+ })
1715
+ });
1708
1716
  };
1709
1717
  var ElementOverlayBox = function(param) {
1710
1718
  var highlightedPrimitives = param.highlightedPrimitives;
1711
- return /* @__PURE__ */ import_react5.default.createElement("div", {
1712
- style: containerStyle
1713
- }, highlightedPrimitives.map(function(primitive, i) {
1714
- return /* @__PURE__ */ import_react5.default.createElement(HighlightedPrimitiveBoxWithText, {
1715
- key: i,
1716
- primitive: primitive
1717
- });
1718
- }));
1719
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", {
1720
+ style: containerStyle,
1721
+ children: highlightedPrimitives.map(function(primitive, i) {
1722
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HighlightedPrimitiveBoxWithText, {
1723
+ primitive: primitive
1724
+ }, i);
1725
+ })
1726
+ });
1719
1727
  };
1720
1728
  // src/components/MouseElementTracker.tsx
1729
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1721
1730
  var MouseElementTracker = function(param) {
1722
1731
  var children = param.children, transform = param.transform, primitives = param.primitives;
1723
1732
  var _ref = _sliced_to_array((0, import_react6.useState)([]), 2), mousedPrimitives = _ref[0], setMousedPrimitives = _ref[1];
@@ -1768,7 +1777,7 @@ var MouseElementTracker = function(param) {
1768
1777
  mousedPrimitives,
1769
1778
  transform
1770
1779
  ]);
1771
- return /* @__PURE__ */ import_react6.default.createElement("div", {
1780
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", {
1772
1781
  style: {
1773
1782
  position: "relative"
1774
1783
  },
@@ -1810,14 +1819,19 @@ var MouseElementTracker = function(param) {
1810
1819
  }
1811
1820
  setMousedPrimitives(mousedPrimitives2);
1812
1821
  }
1813
- }
1814
- }, children, /* @__PURE__ */ import_react6.default.createElement(ElementOverlayBox, {
1815
- highlightedPrimitives: highlightedPrimitives
1816
- }));
1822
+ },
1823
+ children: [
1824
+ children,
1825
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ElementOverlayBox, {
1826
+ highlightedPrimitives: highlightedPrimitives
1827
+ })
1828
+ ]
1829
+ });
1817
1830
  };
1818
1831
  // src/components/DimensionOverlay.tsx
1819
1832
  var import_react8 = require("react");
1820
1833
  var import_transformation_matrix3 = require("transformation-matrix");
1834
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1821
1835
  var DimensionOverlay = function(param) {
1822
1836
  var children = param.children, transform = param.transform;
1823
1837
  if (!transform) transform = (0, import_transformation_matrix3.identity)();
@@ -1881,7 +1895,7 @@ var DimensionOverlay = function(param) {
1881
1895
  };
1882
1896
  arrowScreenBounds.width = arrowScreenBounds.right - arrowScreenBounds.left;
1883
1897
  arrowScreenBounds.height = arrowScreenBounds.bottom - arrowScreenBounds.top;
1884
- return /* @__PURE__ */ React.createElement("div", {
1898
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", {
1885
1899
  ref: containerRef,
1886
1900
  style: {
1887
1901
  position: "relative"
@@ -1909,130 +1923,177 @@ var DimensionOverlay = function(param) {
1909
1923
  } else if (dimensionToolVisible) {
1910
1924
  setDimensionToolVisible(false);
1911
1925
  }
1912
- }
1913
- }, children, dimensionToolVisible && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
1914
- style: {
1915
- position: "absolute",
1916
- left: arrowScreenBounds.left,
1917
- width: arrowScreenBounds.width,
1918
- textAlign: "center",
1919
- top: screenDStart.y + 2,
1920
- color: "red",
1921
- mixBlendMode: "difference",
1922
- pointerEvents: "none",
1923
- marginTop: arrowScreenBounds.flipY ? 0 : -20,
1924
- fontSize: 12,
1925
- fontFamily: "sans-serif",
1926
- zIndex: 1e3
1927
- }
1928
- }, Math.abs(dStart.x - dEnd.x).toFixed(2)), /* @__PURE__ */ React.createElement("div", {
1929
- style: {
1930
- position: "absolute",
1931
- left: screenDEnd.x,
1932
- height: arrowScreenBounds.height,
1933
- display: "flex",
1934
- flexDirection: "column",
1935
- justifyContent: "center",
1936
- top: arrowScreenBounds.top,
1937
- color: "red",
1938
- pointerEvents: "none",
1939
- mixBlendMode: "difference",
1940
- fontSize: 12,
1941
- fontFamily: "sans-serif",
1942
- zIndex: 1e3
1943
- }
1944
- }, /* @__PURE__ */ React.createElement("div", {
1945
- style: {
1946
- marginLeft: arrowScreenBounds.flipX ? "-100%" : 4,
1947
- paddingRight: 4
1948
- }
1949
- }, Math.abs(dStart.y - dEnd.y).toFixed(2))), /* @__PURE__ */ React.createElement("svg", {
1950
- style: {
1951
- position: "absolute",
1952
- left: 0,
1953
- top: 0,
1954
- pointerEvents: "none",
1955
- mixBlendMode: "difference",
1956
- zIndex: 1e3
1957
1926
  },
1958
- width: containerBounds.width,
1959
- height: containerBounds.height
1960
- }, /* @__PURE__ */ React.createElement("defs", null, /* @__PURE__ */ React.createElement("marker", {
1961
- id: "head",
1962
- orient: "auto",
1963
- markerWidth: "3",
1964
- markerHeight: "4",
1965
- refX: "2",
1966
- refY: "2"
1967
- }, /* @__PURE__ */ React.createElement("path", {
1968
- d: "M0,0 V4 L2,2 Z",
1969
- fill: "red"
1970
- }))), /* @__PURE__ */ React.createElement("line", {
1971
- x1: screenDStart.x,
1972
- y1: screenDStart.y,
1973
- x2: screenDEnd.x,
1974
- y2: screenDEnd.y,
1975
- markerEnd: "url(#head)",
1976
- strokeWidth: 1.5,
1977
- fill: "none",
1978
- stroke: "red"
1979
- }), /* @__PURE__ */ React.createElement("line", {
1980
- x1: screenDStart.x,
1981
- y1: screenDStart.y,
1982
- x2: screenDEnd.x,
1983
- y2: screenDStart.y,
1984
- strokeWidth: 1.5,
1985
- fill: "none",
1986
- strokeDasharray: "2,2",
1987
- stroke: "red"
1988
- }), /* @__PURE__ */ React.createElement("line", {
1989
- x1: screenDEnd.x,
1990
- y1: screenDStart.y,
1991
- x2: screenDEnd.x,
1992
- y2: screenDEnd.y,
1993
- strokeWidth: 1.5,
1994
- fill: "none",
1995
- strokeDasharray: "2,2",
1996
- stroke: "red"
1997
- })), /* @__PURE__ */ React.createElement("div", {
1998
- style: {
1999
- right: 0,
2000
- bottom: 0,
2001
- position: "absolute",
2002
- color: "red",
2003
- fontFamily: "sans-serif",
2004
- fontSize: 12,
2005
- margin: 4
2006
- }
2007
- }, "(", dStart.x.toFixed(2), ",", dStart.y.toFixed(2), ")", /* @__PURE__ */ React.createElement("br", null), "(", dEnd.x.toFixed(2), ",", dEnd.y.toFixed(2), ")", /* @__PURE__ */ React.createElement("br", null), "dist:", " ", Math.sqrt(Math.pow(dEnd.x - dStart.x, 2) + Math.pow(dEnd.y - dStart.y, 2)).toFixed(2))));
1927
+ children: [
1928
+ children,
1929
+ dimensionToolVisible && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, {
1930
+ children: [
1931
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
1932
+ style: {
1933
+ position: "absolute",
1934
+ left: arrowScreenBounds.left,
1935
+ width: arrowScreenBounds.width,
1936
+ textAlign: "center",
1937
+ top: screenDStart.y + 2,
1938
+ color: "red",
1939
+ mixBlendMode: "difference",
1940
+ pointerEvents: "none",
1941
+ marginTop: arrowScreenBounds.flipY ? 0 : -20,
1942
+ fontSize: 12,
1943
+ fontFamily: "sans-serif",
1944
+ zIndex: 1e3
1945
+ },
1946
+ children: Math.abs(dStart.x - dEnd.x).toFixed(2)
1947
+ }),
1948
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
1949
+ style: {
1950
+ position: "absolute",
1951
+ left: screenDEnd.x,
1952
+ height: arrowScreenBounds.height,
1953
+ display: "flex",
1954
+ flexDirection: "column",
1955
+ justifyContent: "center",
1956
+ top: arrowScreenBounds.top,
1957
+ color: "red",
1958
+ pointerEvents: "none",
1959
+ mixBlendMode: "difference",
1960
+ fontSize: 12,
1961
+ fontFamily: "sans-serif",
1962
+ zIndex: 1e3
1963
+ },
1964
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
1965
+ style: {
1966
+ marginLeft: arrowScreenBounds.flipX ? "-100%" : 4,
1967
+ paddingRight: 4
1968
+ },
1969
+ children: Math.abs(dStart.y - dEnd.y).toFixed(2)
1970
+ })
1971
+ }),
1972
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", {
1973
+ style: {
1974
+ position: "absolute",
1975
+ left: 0,
1976
+ top: 0,
1977
+ pointerEvents: "none",
1978
+ mixBlendMode: "difference",
1979
+ zIndex: 1e3
1980
+ },
1981
+ width: containerBounds.width,
1982
+ height: containerBounds.height,
1983
+ children: [
1984
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("defs", {
1985
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("marker", {
1986
+ id: "head",
1987
+ orient: "auto",
1988
+ markerWidth: "3",
1989
+ markerHeight: "4",
1990
+ refX: "2",
1991
+ refY: "2",
1992
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", {
1993
+ d: "M0,0 V4 L2,2 Z",
1994
+ fill: "red"
1995
+ })
1996
+ })
1997
+ }),
1998
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("line", {
1999
+ x1: screenDStart.x,
2000
+ y1: screenDStart.y,
2001
+ x2: screenDEnd.x,
2002
+ y2: screenDEnd.y,
2003
+ markerEnd: "url(#head)",
2004
+ strokeWidth: 1.5,
2005
+ fill: "none",
2006
+ stroke: "red"
2007
+ }),
2008
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("line", {
2009
+ x1: screenDStart.x,
2010
+ y1: screenDStart.y,
2011
+ x2: screenDEnd.x,
2012
+ y2: screenDStart.y,
2013
+ strokeWidth: 1.5,
2014
+ fill: "none",
2015
+ strokeDasharray: "2,2",
2016
+ stroke: "red"
2017
+ }),
2018
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("line", {
2019
+ x1: screenDEnd.x,
2020
+ y1: screenDStart.y,
2021
+ x2: screenDEnd.x,
2022
+ y2: screenDEnd.y,
2023
+ strokeWidth: 1.5,
2024
+ fill: "none",
2025
+ strokeDasharray: "2,2",
2026
+ stroke: "red"
2027
+ })
2028
+ ]
2029
+ }),
2030
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", {
2031
+ style: {
2032
+ right: 0,
2033
+ bottom: 0,
2034
+ position: "absolute",
2035
+ color: "red",
2036
+ fontFamily: "sans-serif",
2037
+ fontSize: 12,
2038
+ margin: 4
2039
+ },
2040
+ children: [
2041
+ "(",
2042
+ dStart.x.toFixed(2),
2043
+ ",",
2044
+ dStart.y.toFixed(2),
2045
+ ")",
2046
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("br", {}),
2047
+ "(",
2048
+ dEnd.x.toFixed(2),
2049
+ ",",
2050
+ dEnd.y.toFixed(2),
2051
+ ")",
2052
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("br", {}),
2053
+ "dist:",
2054
+ " ",
2055
+ Math.sqrt(Math.pow(dEnd.x - dStart.x, 2) + Math.pow(dEnd.y - dStart.y, 2)).toFixed(2)
2056
+ ]
2057
+ })
2058
+ ]
2059
+ })
2060
+ ]
2061
+ });
2008
2062
  };
2009
2063
  // src/components/ToolbarOverlay.tsx
2010
2064
  var import_react9 = require("react");
2011
2065
  var import_css = require("@emotion/css");
2012
2066
  var import_builder2 = require("@tscircuit/builder");
2067
+ var import_jsx_runtime6 = require("react/jsx-runtime");
2013
2068
  var LayerButton = function(param) {
2014
2069
  var name = param.name, selected = param.selected, onClick = param.onClick;
2015
- return /* @__PURE__ */ React.createElement("div", {
2070
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", {
2016
2071
  className: import_css.css(_templateObject()),
2017
- onClick: onClick
2018
- }, /* @__PURE__ */ React.createElement("span", {
2019
- style: {
2020
- marginRight: 2,
2021
- opacity: selected ? 1 : 0
2022
- }
2023
- }, "•"), /* @__PURE__ */ React.createElement("span", {
2024
- style: {
2025
- marginLeft: 2,
2026
- fontWeight: 500,
2027
- color: LAYER_NAME_TO_COLOR[name.replace(/-/, "")]
2028
- }
2029
- }, name));
2072
+ onClick: onClick,
2073
+ children: [
2074
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", {
2075
+ style: {
2076
+ marginRight: 2,
2077
+ opacity: selected ? 1 : 0
2078
+ },
2079
+ children: "•"
2080
+ }),
2081
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", {
2082
+ style: {
2083
+ marginLeft: 2,
2084
+ fontWeight: 500,
2085
+ color: LAYER_NAME_TO_COLOR[name.replace(/-/, "")]
2086
+ },
2087
+ children: name
2088
+ })
2089
+ ]
2090
+ });
2030
2091
  };
2031
2092
  var ToolbarButton = function(_param) {
2032
2093
  var children = _param.children, props = _object_without_properties(_param, [
2033
2094
  "children"
2034
2095
  ]);
2035
- return /* @__PURE__ */ React.createElement("div", _object_spread_props(_object_spread({}, props), {
2096
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", _object_spread_props(_object_spread({}, props), {
2036
2097
  style: _object_spread({
2037
2098
  backgroundColor: "#1F1F1F",
2038
2099
  border: "1px solid #666",
@@ -2044,8 +2105,9 @@ var ToolbarButton = function(_param) {
2044
2105
  alignSelf: "start",
2045
2106
  color: "#eee",
2046
2107
  cursor: "pointer"
2047
- }, props.style)
2048
- }), children);
2108
+ }, props.style),
2109
+ children: children
2110
+ }));
2049
2111
  };
2050
2112
  var ToolbarOverlay = function(param) {
2051
2113
  var children = param.children, elements = param.elements;
@@ -2062,7 +2124,7 @@ var ToolbarOverlay = function(param) {
2062
2124
  var errorCount = (_elements_filter_length = elements === null || elements === void 0 ? void 0 : elements.filter(function(e) {
2063
2125
  return e.type.includes("error");
2064
2126
  }).length) !== null && _elements_filter_length !== void 0 ? _elements_filter_length : 0;
2065
- return /* @__PURE__ */ React.createElement("div", {
2127
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", {
2066
2128
  style: {
2067
2129
  position: "relative"
2068
2130
  },
@@ -2072,142 +2134,195 @@ var ToolbarOverlay = function(param) {
2072
2134
  onMouseLeave: function() {
2073
2135
  setIsMouseOverContainer(false);
2074
2136
  setLayerMenuOpen(false);
2075
- }
2076
- }, children, /* @__PURE__ */ React.createElement("div", {
2077
- style: {
2078
- position: "absolute",
2079
- opacity: isMouseOverContainer ? 1 : 0,
2080
- top: 16,
2081
- left: 16,
2082
- transition: isMouseOverContainer ? "opacity 100ms linear" : "opacity 1s linear",
2083
- zIndex: 100,
2084
- color: "red",
2085
- display: "flex",
2086
- fontSize: 12,
2087
- height: 100,
2088
- fontFamily: "sans-serif"
2089
- }
2090
- }, /* @__PURE__ */ React.createElement(ToolbarButton, {
2091
- onClick: function() {
2092
- setLayerMenuOpen(!isLayerMenuOpen);
2093
- },
2094
- onMouseLeave: function() {
2095
- if (isLayerMenuOpen) {
2096
- setLayerMenuOpen(false);
2097
- }
2098
- }
2099
- }, /* @__PURE__ */ React.createElement("div", null, "layer:", " ", /* @__PURE__ */ React.createElement("span", {
2100
- style: {
2101
- marginLeft: 2,
2102
- fontWeight: 500,
2103
- color: LAYER_NAME_TO_COLOR[selectedLayer]
2104
- }
2105
- }, selectedLayer)), isLayerMenuOpen && /* @__PURE__ */ React.createElement("div", {
2106
- style: {
2107
- marginTop: 4,
2108
- minWidth: 120
2109
- }
2110
- }, import_builder2.all_layers.map(function(l) {
2111
- return l.replace(/-/g, "");
2112
- }).map(function(layer) {
2113
- return /* @__PURE__ */ React.createElement(LayerButton, {
2114
- key: layer,
2115
- name: layer,
2116
- selected: layer === selectedLayer,
2117
- onClick: function() {
2118
- selectLayer(layer.replace(/-/, ""));
2119
- }
2120
- });
2121
- }))), /* @__PURE__ */ React.createElement(ToolbarButton, {
2122
- style: errorCount > 0 ? {
2123
- color: "red"
2124
- } : {},
2125
- onClick: function() {
2126
- return setErrorsOpen(!isErrorsOpen);
2127
2137
  },
2128
- onMouseLeave: function() {
2129
- return setErrorsOpen(false);
2130
- }
2131
- }, /* @__PURE__ */ React.createElement("div", null, errorCount, " errors"), isErrorsOpen && /* @__PURE__ */ React.createElement("div", {
2132
- style: {
2133
- display: "grid",
2134
- gridTemplateColumns: "100px 300px"
2135
- }
2136
- }, elements === null || elements === void 0 ? void 0 : elements.filter(function(e) {
2137
- return e.type.includes("error");
2138
- }).map(function(e, i) {
2139
- return /* @__PURE__ */ React.createElement(import_react9.Fragment, {
2140
- key: i
2141
- }, /* @__PURE__ */ React.createElement("div", null, e.error_type), /* @__PURE__ */ React.createElement("div", null, e.message));
2142
- })))));
2138
+ children: [
2139
+ children,
2140
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", {
2141
+ style: {
2142
+ position: "absolute",
2143
+ opacity: isMouseOverContainer ? 1 : 0,
2144
+ top: 16,
2145
+ left: 16,
2146
+ transition: isMouseOverContainer ? "opacity 100ms linear" : "opacity 1s linear",
2147
+ zIndex: 100,
2148
+ color: "red",
2149
+ display: "flex",
2150
+ fontSize: 12,
2151
+ height: 100,
2152
+ fontFamily: "sans-serif"
2153
+ },
2154
+ children: [
2155
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(ToolbarButton, {
2156
+ onClick: function() {
2157
+ setLayerMenuOpen(!isLayerMenuOpen);
2158
+ },
2159
+ onMouseLeave: function() {
2160
+ if (isLayerMenuOpen) {
2161
+ setLayerMenuOpen(false);
2162
+ }
2163
+ },
2164
+ children: [
2165
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", {
2166
+ children: [
2167
+ "layer:",
2168
+ " ",
2169
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", {
2170
+ style: {
2171
+ marginLeft: 2,
2172
+ fontWeight: 500,
2173
+ color: LAYER_NAME_TO_COLOR[selectedLayer]
2174
+ },
2175
+ children: selectedLayer
2176
+ })
2177
+ ]
2178
+ }),
2179
+ isLayerMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
2180
+ style: {
2181
+ marginTop: 4,
2182
+ minWidth: 120
2183
+ },
2184
+ children: import_builder2.all_layers.map(function(l) {
2185
+ return l.replace(/-/g, "");
2186
+ }).map(function(layer) {
2187
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(LayerButton, {
2188
+ name: layer,
2189
+ selected: layer === selectedLayer,
2190
+ onClick: function() {
2191
+ selectLayer(layer.replace(/-/, ""));
2192
+ }
2193
+ }, layer);
2194
+ })
2195
+ })
2196
+ ]
2197
+ }),
2198
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(ToolbarButton, {
2199
+ style: errorCount > 0 ? {
2200
+ color: "red"
2201
+ } : {},
2202
+ onClick: function() {
2203
+ return setErrorsOpen(!isErrorsOpen);
2204
+ },
2205
+ onMouseLeave: function() {
2206
+ return setErrorsOpen(false);
2207
+ },
2208
+ children: [
2209
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", {
2210
+ children: [
2211
+ errorCount,
2212
+ " errors"
2213
+ ]
2214
+ }),
2215
+ isErrorsOpen && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
2216
+ style: {
2217
+ display: "grid",
2218
+ gridTemplateColumns: "100px 300px"
2219
+ },
2220
+ children: elements === null || elements === void 0 ? void 0 : elements.filter(function(e) {
2221
+ return e.type.includes("error");
2222
+ }).map(function(e, i) {
2223
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react9.Fragment, {
2224
+ children: [
2225
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
2226
+ children: e.error_type
2227
+ }),
2228
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
2229
+ children: e.message
2230
+ })
2231
+ ]
2232
+ }, i);
2233
+ })
2234
+ })
2235
+ ]
2236
+ })
2237
+ ]
2238
+ })
2239
+ ]
2240
+ });
2143
2241
  };
2144
2242
  // src/components/ErrorOverlay.tsx
2145
2243
  var import_css2 = require("@emotion/css");
2146
2244
  var import_react10 = require("react");
2147
2245
  var import_transformation_matrix4 = require("transformation-matrix");
2246
+ var import_jsx_runtime7 = require("react/jsx-runtime");
2148
2247
  var ErrorOverlay = function(param) {
2149
2248
  var children = param.children, transform = param.transform, elements = param.elements;
2150
2249
  var _containerRef_current;
2151
2250
  if (!transform) transform = (0, import_transformation_matrix4.identity)();
2152
2251
  var containerRef = (0, import_react10.useRef)(null);
2153
2252
  var containerBounds = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.getBoundingClientRect();
2154
- return /* @__PURE__ */ React.createElement("div", {
2253
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", {
2155
2254
  style: {
2156
2255
  position: "relative"
2157
2256
  },
2158
- ref: containerRef
2159
- }, children, elements === null || elements === void 0 ? void 0 : elements.filter(function(el) {
2160
- return el.type === "pcb_error";
2161
- }).map(function(el) {
2162
- var pcb_port_ids = el.pcb_port_ids;
2163
- var port1 = elements.find(function(el2) {
2164
- return el2.type === "pcb_port" && el2.pcb_port_id === pcb_port_ids[0];
2165
- });
2166
- var port2 = elements.find(function(el2) {
2167
- return el2.type === "pcb_port" && el2.pcb_port_id === pcb_port_ids[1];
2168
- });
2169
- if (!port1 || !port2) return null;
2170
- var screenPort1 = (0, import_transformation_matrix4.applyToPoint)(transform, {
2171
- x: port1.x,
2172
- y: port1.y
2173
- });
2174
- var screenPort2 = (0, import_transformation_matrix4.applyToPoint)(transform, {
2175
- x: port2.x,
2176
- y: port2.y
2177
- });
2178
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("svg", {
2179
- style: {
2180
- position: "absolute",
2181
- left: 0,
2182
- top: 0,
2183
- pointerEvents: "none",
2184
- mixBlendMode: "difference",
2185
- zIndex: 1e3
2186
- },
2187
- width: containerBounds === null || containerBounds === void 0 ? void 0 : containerBounds.width,
2188
- height: containerBounds === null || containerBounds === void 0 ? void 0 : containerBounds.height
2189
- }, /* @__PURE__ */ React.createElement("line", {
2190
- x1: screenPort1.x,
2191
- y1: screenPort1.y,
2192
- x2: screenPort2.x,
2193
- y2: screenPort2.y,
2194
- markerEnd: "url(#head)",
2195
- strokeWidth: 1.5,
2196
- strokeDasharray: "2,2",
2197
- fill: "none",
2198
- stroke: "red"
2199
- })), /* @__PURE__ */ React.createElement("div", {
2200
- className: import_css2.css(_templateObject1(), (screenPort1.x + screenPort2.x) / 2, (screenPort1.y + screenPort2.y) / 2)
2201
- }, /* @__PURE__ */ React.createElement("div", {
2202
- className: "error-message"
2203
- }, el.message), /* @__PURE__ */ React.createElement("div", {
2204
- className: import_css2.css(_templateObject2())
2205
- })));
2206
- }));
2257
+ ref: containerRef,
2258
+ children: [
2259
+ children,
2260
+ elements === null || elements === void 0 ? void 0 : elements.filter(function(el) {
2261
+ return el.type === "pcb_error";
2262
+ }).map(function(el) {
2263
+ var pcb_port_ids = el.pcb_port_ids;
2264
+ var port1 = elements.find(function(el2) {
2265
+ return el2.type === "pcb_port" && el2.pcb_port_id === pcb_port_ids[0];
2266
+ });
2267
+ var port2 = elements.find(function(el2) {
2268
+ return el2.type === "pcb_port" && el2.pcb_port_id === pcb_port_ids[1];
2269
+ });
2270
+ if (!port1 || !port2) return null;
2271
+ var screenPort1 = (0, import_transformation_matrix4.applyToPoint)(transform, {
2272
+ x: port1.x,
2273
+ y: port1.y
2274
+ });
2275
+ var screenPort2 = (0, import_transformation_matrix4.applyToPoint)(transform, {
2276
+ x: port2.x,
2277
+ y: port2.y
2278
+ });
2279
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, {
2280
+ children: [
2281
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", {
2282
+ style: {
2283
+ position: "absolute",
2284
+ left: 0,
2285
+ top: 0,
2286
+ pointerEvents: "none",
2287
+ mixBlendMode: "difference",
2288
+ zIndex: 1e3
2289
+ },
2290
+ width: containerBounds === null || containerBounds === void 0 ? void 0 : containerBounds.width,
2291
+ height: containerBounds === null || containerBounds === void 0 ? void 0 : containerBounds.height,
2292
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("line", {
2293
+ x1: screenPort1.x,
2294
+ y1: screenPort1.y,
2295
+ x2: screenPort2.x,
2296
+ y2: screenPort2.y,
2297
+ markerEnd: "url(#head)",
2298
+ strokeWidth: 1.5,
2299
+ strokeDasharray: "2,2",
2300
+ fill: "none",
2301
+ stroke: "red"
2302
+ })
2303
+ }),
2304
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", {
2305
+ className: import_css2.css(_templateObject1(), (screenPort1.x + screenPort2.x) / 2, (screenPort1.y + screenPort2.y) / 2),
2306
+ children: [
2307
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
2308
+ className: "error-message",
2309
+ children: el.message
2310
+ }),
2311
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
2312
+ className: import_css2.css(_templateObject2())
2313
+ })
2314
+ ]
2315
+ })
2316
+ ]
2317
+ });
2318
+ })
2319
+ ]
2320
+ });
2207
2321
  };
2208
2322
  // src/components/CanvasElementsRenderer.tsx
2323
+ var import_jsx_runtime8 = require("react/jsx-runtime");
2209
2324
  var CanvasElementsRenderer = function(props) {
2210
- var primitives = (0, import_react12.useMemo)(function() {
2325
+ var primitives = (0, import_react11.useMemo)(function() {
2211
2326
  var primitives2 = props.elements.flatMap(function(elm) {
2212
2327
  return convertElementToPrimitives(elm, props.elements);
2213
2328
  });
@@ -2215,23 +2330,27 @@ var CanvasElementsRenderer = function(props) {
2215
2330
  }, [
2216
2331
  props.elements
2217
2332
  ]);
2218
- return /* @__PURE__ */ import_react11.default.createElement(MouseElementTracker, {
2219
- transform: props.transform,
2220
- primitives: primitives
2221
- }, /* @__PURE__ */ import_react11.default.createElement(DimensionOverlay, {
2222
- transform: props.transform
2223
- }, /* @__PURE__ */ import_react11.default.createElement(ToolbarOverlay, {
2224
- elements: props.elements
2225
- }, /* @__PURE__ */ import_react11.default.createElement(ErrorOverlay, {
2226
- transform: props.transform,
2227
- elements: props.elements
2228
- }, /* @__PURE__ */ import_react11.default.createElement(CanvasPrimitiveRenderer, {
2333
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MouseElementTracker, {
2229
2334
  transform: props.transform,
2230
2335
  primitives: primitives,
2231
- width: props.width,
2232
- height: props.height,
2233
- grid: props.grid
2234
- })))));
2336
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DimensionOverlay, {
2337
+ transform: props.transform,
2338
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ToolbarOverlay, {
2339
+ elements: props.elements,
2340
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ErrorOverlay, {
2341
+ transform: props.transform,
2342
+ elements: props.elements,
2343
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CanvasPrimitiveRenderer, {
2344
+ transform: props.transform,
2345
+ primitives: primitives,
2346
+ width: props.width,
2347
+ height: props.height,
2348
+ grid: props.grid
2349
+ })
2350
+ })
2351
+ })
2352
+ })
2353
+ });
2235
2354
  };
2236
2355
  // src/PCBViewer.tsx
2237
2356
  var import_use_mouse_matrix_transform = __toESM(require_dist());
@@ -2239,11 +2358,11 @@ var import_use_mouse_matrix_transform = __toESM(require_dist());
2239
2358
  var noop = function noop() {};
2240
2359
  var isBrowser = typeof window !== "undefined";
2241
2360
  // node_modules/react-use/esm/useIsomorphicLayoutEffect.js
2242
- var import_react13 = require("react");
2243
- var useIsomorphicLayoutEffect = isBrowser ? import_react13.useLayoutEffect : import_react13.useEffect;
2361
+ var import_react12 = require("react");
2362
+ var useIsomorphicLayoutEffect = isBrowser ? import_react12.useLayoutEffect : import_react12.useEffect;
2244
2363
  var useIsomorphicLayoutEffect_default = useIsomorphicLayoutEffect;
2245
2364
  // node_modules/react-use/esm/useMeasure.js
2246
- var import_react14 = require("react");
2365
+ var import_react13 = require("react");
2247
2366
  var defaultState = {
2248
2367
  x: 0,
2249
2368
  y: 0,
@@ -2255,9 +2374,9 @@ var defaultState = {
2255
2374
  right: 0
2256
2375
  };
2257
2376
  function useMeasure() {
2258
- var _a = (0, import_react14.useState)(null), element = _a[0], ref = _a[1];
2259
- var _b = (0, import_react14.useState)(defaultState), rect = _b[0], setRect = _b[1];
2260
- var observer = (0, import_react14.useMemo)(function() {
2377
+ var _a = (0, import_react13.useState)(null), element = _a[0], ref = _a[1];
2378
+ var _b = (0, import_react13.useState)(defaultState), rect = _b[0], setRect = _b[1];
2379
+ var observer = (0, import_react13.useMemo)(function() {
2261
2380
  return new window.ResizeObserver(function(entries) {
2262
2381
  if (entries[0]) {
2263
2382
  var _a2 = entries[0].contentRect, x = _a2.x, y = _a2.y, width = _a2.width, height = _a2.height, top_1 = _a2.top, left = _a2.left, bottom = _a2.bottom, right = _a2.right;
@@ -2297,17 +2416,18 @@ var useMeasure_default = isBrowser && typeof window.ResizeObserver !== "undefine
2297
2416
  // src/PCBViewer.tsx
2298
2417
  var import_transformation_matrix5 = require("transformation-matrix");
2299
2418
  var import_builder4 = require("@tscircuit/builder");
2419
+ var import_jsx_runtime9 = require("react/jsx-runtime");
2300
2420
  var defaultTransform = (0, import_transformation_matrix5.compose)((0, import_transformation_matrix5.translate)(400, 300), (0, import_transformation_matrix5.scale)(40, -40));
2301
2421
  var PCBViewer = function(param) {
2302
2422
  var children = param.children, soup = param.soup, _param_height = param.height, height = _param_height === void 0 ? 600 : _param_height;
2303
- var _ref = _sliced_to_array((0, import_react15.useState)([]), 2), stateElements = _ref[0], setStateElements = _ref[1];
2423
+ var _ref = _sliced_to_array((0, import_react14.useState)([]), 2), stateElements = _ref[0], setStateElements = _ref[1];
2304
2424
  var _useMeasure_default = _sliced_to_array(useMeasure_default(), 2), ref = _useMeasure_default[0], refDimensions = _useMeasure_default[1];
2305
- var _ref1 = _sliced_to_array((0, import_react15.useState)(defaultTransform), 2), transform = _ref1[0], setTransformInternal = _ref1[1];
2425
+ var _ref1 = _sliced_to_array((0, import_react14.useState)(defaultTransform), 2), transform = _ref1[0], setTransformInternal = _ref1[1];
2306
2426
  var _ref2 = (0, import_use_mouse_matrix_transform.default)({
2307
2427
  transform: transform,
2308
2428
  onSetTransform: setTransformInternal
2309
2429
  }), transformRef = _ref2.ref, setTransform = _ref2.setTransform;
2310
- var _ref3 = _sliced_to_array((0, import_react15.useState)(null), 2), error = _ref3[0], setError = _ref3[1];
2430
+ var _ref3 = _sliced_to_array((0, import_react14.useState)(null), 2), error = _ref3[0], setError = _ref3[1];
2311
2431
  var resetTransform = function() {
2312
2432
  var elmBounds = (refDimensions === null || refDimensions === void 0 ? void 0 : refDimensions.width) > 0 ? refDimensions : {
2313
2433
  width: 500,
@@ -2331,7 +2451,7 @@ var PCBViewer = function(param) {
2331
2451
  setTransform((0, import_transformation_matrix5.compose)((0, import_transformation_matrix5.translate)(((_elmBounds_width1 = elmBounds.width) !== null && _elmBounds_width1 !== void 0 ? _elmBounds_width1 : 0) / 2, ((_elmBounds_height1 = elmBounds.height) !== null && _elmBounds_height1 !== void 0 ? _elmBounds_height1 : 0) / 2), // translate(100, 0),
2332
2452
  (0, import_transformation_matrix5.scale)(scaleFactor, -scaleFactor, 0, 0), (0, import_transformation_matrix5.translate)(-center.x, -center.y)));
2333
2453
  };
2334
- (0, import_react15.useEffect)(function() {
2454
+ (0, import_react14.useEffect)(function() {
2335
2455
  var doRender = function doRender() {
2336
2456
  return _doRender.apply(this, arguments);
2337
2457
  };
@@ -2367,7 +2487,7 @@ var PCBViewer = function(param) {
2367
2487
  }, [
2368
2488
  children
2369
2489
  ]);
2370
- (0, import_react15.useEffect)(function() {
2490
+ (0, import_react14.useEffect)(function() {
2371
2491
  if (refDimensions && refDimensions.width !== 0 && (children || soup)) {
2372
2492
  resetTransform();
2373
2493
  }
@@ -2375,34 +2495,42 @@ var PCBViewer = function(param) {
2375
2495
  children,
2376
2496
  refDimensions
2377
2497
  ]);
2378
- if (error) return /* @__PURE__ */ import_react15.default.createElement("div", {
2498
+ if (error) return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", {
2379
2499
  style: {
2380
2500
  color: "red"
2381
- }
2382
- }, " ", error, " ");
2383
- var elements = soup !== null && soup !== void 0 ? soup : stateElements;
2384
- return /* @__PURE__ */ import_react15.default.createElement("div", {
2385
- ref: transformRef
2386
- }, /* @__PURE__ */ import_react15.default.createElement("div", {
2387
- ref: ref
2388
- }, /* @__PURE__ */ import_react15.default.createElement(ContextProviders, null, /* @__PURE__ */ import_react15.default.createElement(CanvasElementsRenderer, {
2389
- key: refDimensions.width,
2390
- transform: transform,
2391
- height: height,
2392
- width: refDimensions.width,
2393
- grid: {
2394
- spacing: 1,
2395
- view_window: {
2396
- left: 0,
2397
- right: refDimensions.width || 500,
2398
- top: height,
2399
- bottom: 0
2400
- }
2401
2501
  },
2402
- elements: elements.filter(function(elm) {
2403
- return elm.type.startsWith("pcb_") || elm.type.startsWith("source_");
2502
+ children: [
2503
+ " ",
2504
+ error,
2505
+ " "
2506
+ ]
2507
+ });
2508
+ var elements = soup !== null && soup !== void 0 ? soup : stateElements;
2509
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", {
2510
+ ref: transformRef,
2511
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", {
2512
+ ref: ref,
2513
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ContextProviders, {
2514
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CanvasElementsRenderer, {
2515
+ transform: transform,
2516
+ height: height,
2517
+ width: refDimensions.width,
2518
+ grid: {
2519
+ spacing: 1,
2520
+ view_window: {
2521
+ left: 0,
2522
+ right: refDimensions.width || 500,
2523
+ top: height,
2524
+ bottom: 0
2525
+ }
2526
+ },
2527
+ elements: elements.filter(function(elm) {
2528
+ return elm.type.startsWith("pcb_") || elm.type.startsWith("source_");
2529
+ })
2530
+ }, refDimensions.width)
2531
+ })
2404
2532
  })
2405
- }))));
2533
+ });
2406
2534
  };
2407
2535
  // Annotate the CommonJS export names for ESM import in node:
2408
2536
  0 && (module.exports = {