@tscircuit/pcb-viewer 1.4.2 → 1.4.3

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
@@ -13280,7 +13280,7 @@ var import_soup2 = __toESM(require_dist());
13280
13280
  // package.json
13281
13281
  var package_default = {
13282
13282
  name: "@tscircuit/pcb-viewer",
13283
- version: "1.4.1",
13283
+ version: "1.4.2",
13284
13284
  main: "dist/index.js",
13285
13285
  repository: "tscircuit/pcb-viewer",
13286
13286
  license: "MIT",
@@ -13567,12 +13567,55 @@ var import_css2 = require("@emotion/css");
13567
13567
  var import_react10 = require("react");
13568
13568
  var import_transformation_matrix4 = require("transformation-matrix");
13569
13569
  var import_jsx_runtime7 = require("react/jsx-runtime");
13570
+ var ErrorSVG = function(param) {
13571
+ var screenPort1 = param.screenPort1, screenPort2 = param.screenPort2, errorCenter = param.errorCenter, canLineBeDrawn = param.canLineBeDrawn;
13572
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", {
13573
+ style: {
13574
+ position: "absolute",
13575
+ left: 0,
13576
+ top: 0,
13577
+ pointerEvents: "none",
13578
+ mixBlendMode: "difference",
13579
+ zIndex: 1e3
13580
+ },
13581
+ width: "100%",
13582
+ height: "100%",
13583
+ children: canLineBeDrawn && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, {
13584
+ children: [
13585
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("line", {
13586
+ x1: screenPort1.x,
13587
+ y1: screenPort1.y,
13588
+ x2: errorCenter.x,
13589
+ y2: errorCenter.y,
13590
+ strokeWidth: 1.5,
13591
+ strokeDasharray: "2,2",
13592
+ stroke: "red"
13593
+ }),
13594
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("line", {
13595
+ x1: errorCenter.x,
13596
+ y1: errorCenter.y,
13597
+ x2: screenPort2.x,
13598
+ y2: screenPort2.y,
13599
+ strokeWidth: 1.5,
13600
+ strokeDasharray: "2,2",
13601
+ stroke: "red"
13602
+ }),
13603
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("rect", {
13604
+ x: errorCenter.x - 5,
13605
+ y: errorCenter.y - 5,
13606
+ width: 10,
13607
+ height: 10,
13608
+ transform: "rotate(45 ".concat(errorCenter.x, " ").concat(errorCenter.y, ")"),
13609
+ fill: "red"
13610
+ })
13611
+ ]
13612
+ })
13613
+ });
13614
+ };
13570
13615
  var ErrorOverlay = function(param) {
13571
13616
  var children = param.children, transform = param.transform, elements = param.elements;
13572
- var _containerRef_current;
13573
13617
  if (!transform) transform = (0, import_transformation_matrix4.identity)();
13574
13618
  var containerRef = (0, import_react10.useRef)(null);
13575
- var containerBounds = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.getBoundingClientRect();
13576
13619
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", {
13577
13620
  style: {
13578
13621
  position: "relative"
@@ -13600,44 +13643,26 @@ var ErrorOverlay = function(param) {
13600
13643
  y: port2.y
13601
13644
  });
13602
13645
  var canLineBeDrawn = !(isNaN(screenPort1.x) || isNaN(screenPort1.y) || isNaN(screenPort2.x) || isNaN(screenPort2.y));
13603
- var midPoint = {
13646
+ var errorCenter = el.center ? (0, import_transformation_matrix4.applyToPoint)(transform, {
13647
+ x: el.center.x,
13648
+ y: el.center.y
13649
+ }) : {
13604
13650
  x: (screenPort1.x + screenPort2.x) / 2,
13605
13651
  y: (screenPort1.y + screenPort2.y) / 2
13606
13652
  };
13607
- if (isNaN(midPoint.x) || isNaN(midPoint.y)) {
13608
- midPoint.x = isNaN(screenPort1.x) ? screenPort2.x : screenPort1.x;
13609
- midPoint.y = isNaN(screenPort1.y) ? screenPort2.y : screenPort1.y;
13610
- }
13611
- if (isNaN(midPoint.x) || isNaN(midPoint.y)) {
13653
+ if (isNaN(errorCenter.x) || isNaN(errorCenter.y)) {
13612
13654
  return null;
13613
13655
  }
13614
13656
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, {
13615
13657
  children: [
13616
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", {
13617
- style: {
13618
- position: "absolute",
13619
- left: 0,
13620
- top: 0,
13621
- pointerEvents: "none",
13622
- mixBlendMode: "difference",
13623
- zIndex: 1e3
13624
- },
13625
- width: containerBounds === null || containerBounds === void 0 ? void 0 : containerBounds.width,
13626
- height: containerBounds === null || containerBounds === void 0 ? void 0 : containerBounds.height,
13627
- children: canLineBeDrawn && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("line", {
13628
- x1: screenPort1.x,
13629
- y1: screenPort1.y,
13630
- x2: screenPort2.x,
13631
- y2: screenPort2.y,
13632
- markerEnd: "url(#head)",
13633
- strokeWidth: 1.5,
13634
- strokeDasharray: "2,2",
13635
- fill: "none",
13636
- stroke: "red"
13637
- })
13658
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ErrorSVG, {
13659
+ screenPort1: screenPort1,
13660
+ screenPort2: screenPort2,
13661
+ errorCenter: errorCenter,
13662
+ canLineBeDrawn: canLineBeDrawn
13638
13663
  }),
13639
13664
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", {
13640
- className: import_css2.css(_templateObject1(), midPoint.x, midPoint.y),
13665
+ className: import_css2.css(_templateObject1(), errorCenter.x, errorCenter.y),
13641
13666
  children: [
13642
13667
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
13643
13668
  className: "error-message",