graphics-debug 0.0.84 → 0.0.85
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/{chunk-HPNVGPHJ.js → chunk-5O6JHGHI.js} +2 -2
- package/dist/{chunk-AKONCUCE.js → chunk-ME47RV6O.js} +39 -3
- package/dist/chunk-ME47RV6O.js.map +1 -0
- package/dist/{chunk-IOVKI3ZO.js → chunk-PCHDJSKZ.js} +48 -2
- package/dist/chunk-PCHDJSKZ.js.map +1 -0
- package/dist/{chunk-MYMDOAQN.js → chunk-PEHHGMS7.js} +2 -2
- package/dist/{chunk-ZWAXHWX2.js → chunk-TBTTAU4R.js} +67 -5
- package/dist/chunk-TBTTAU4R.js.map +1 -0
- package/dist/cli/cli.js +5 -5
- package/dist/lib/arrowHelpers.d.ts +27 -1
- package/dist/lib/arrowHelpers.js +5 -3
- package/dist/lib/drawGraphicsToCanvas.js +2 -2
- package/dist/lib/getSvgFromGraphicsObject.d.ts +3 -2
- package/dist/lib/getSvgFromGraphicsObject.js +2 -2
- package/dist/lib/index.js +5 -5
- package/dist/lib/matcher.js +2 -2
- package/dist/lib/react.js +70 -19
- package/dist/lib/react.js.map +1 -1
- package/dist/lib/stackGraphics.js +3 -3
- package/dist/lib/types.d.ts +3 -0
- package/package.json +1 -1
- package/dist/chunk-AKONCUCE.js.map +0 -1
- package/dist/chunk-IOVKI3ZO.js.map +0 -1
- package/dist/chunk-ZWAXHWX2.js.map +0 -1
- /package/dist/{chunk-HPNVGPHJ.js.map → chunk-5O6JHGHI.js.map} +0 -0
- /package/dist/{chunk-MYMDOAQN.js.map → chunk-PEHHGMS7.js.map} +0 -0
package/dist/lib/react.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-5O6JHGHI.js";
|
|
2
2
|
import "../chunk-OB4CGOL3.js";
|
|
3
|
-
import "../chunk-
|
|
3
|
+
import "../chunk-PEHHGMS7.js";
|
|
4
4
|
import "../chunk-K37Y2KHE.js";
|
|
5
5
|
import "../chunk-7236NVI2.js";
|
|
6
6
|
import {
|
|
7
7
|
defaultColors,
|
|
8
8
|
drawGraphicsToCanvas,
|
|
9
9
|
getBounds
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-ME47RV6O.js";
|
|
11
11
|
import "../chunk-NG6H63SM.js";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-TBTTAU4R.js";
|
|
13
13
|
import {
|
|
14
14
|
getArrowBoundingBox,
|
|
15
|
-
getArrowGeometry
|
|
16
|
-
|
|
15
|
+
getArrowGeometry,
|
|
16
|
+
getInlineLabelLayout
|
|
17
|
+
} from "../chunk-PCHDJSKZ.js";
|
|
17
18
|
import "../chunk-ZGI74PYD.js";
|
|
18
19
|
import {
|
|
19
20
|
clipInfiniteLineToBounds,
|
|
@@ -494,19 +495,8 @@ var DimensionOverlay = ({ children, transform }) => {
|
|
|
494
495
|
};
|
|
495
496
|
|
|
496
497
|
// site/components/InteractiveGraphics/Arrow.tsx
|
|
497
|
-
import { applyToPoint as applyToPoint2 } from "transformation-matrix";
|
|
498
498
|
import { useMemo as useMemo2, useState as useState2 } from "react";
|
|
499
499
|
|
|
500
|
-
// site/utils/safeLighten.ts
|
|
501
|
-
import { lighten } from "polished";
|
|
502
|
-
var safeLighten = (amount, color) => {
|
|
503
|
-
try {
|
|
504
|
-
return lighten(amount, color);
|
|
505
|
-
} catch (e) {
|
|
506
|
-
return color;
|
|
507
|
-
}
|
|
508
|
-
};
|
|
509
|
-
|
|
510
500
|
// site/utils/distToLineSegment.ts
|
|
511
501
|
var distToLineSegment = (px, py, x1, y1, x2, y2) => {
|
|
512
502
|
const A = px - x1;
|
|
@@ -534,7 +524,18 @@ var distToLineSegment = (px, py, x1, y1, x2, y2) => {
|
|
|
534
524
|
return Math.sqrt(dx * dx + dy * dy);
|
|
535
525
|
};
|
|
536
526
|
|
|
527
|
+
// site/utils/safeLighten.ts
|
|
528
|
+
import { lighten } from "polished";
|
|
529
|
+
var safeLighten = (amount, color) => {
|
|
530
|
+
try {
|
|
531
|
+
return lighten(amount, color);
|
|
532
|
+
} catch (e) {
|
|
533
|
+
return color;
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
|
|
537
537
|
// site/components/InteractiveGraphics/Arrow.tsx
|
|
538
|
+
import { applyToPoint as applyToPoint2 } from "transformation-matrix";
|
|
538
539
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
539
540
|
var Arrow = ({
|
|
540
541
|
arrow,
|
|
@@ -557,6 +558,27 @@ var Arrow = ({
|
|
|
557
558
|
};
|
|
558
559
|
}, [geometry, realToScreen]);
|
|
559
560
|
const scaleFactor = Math.abs(realToScreen.a);
|
|
561
|
+
const fontSize = 12;
|
|
562
|
+
const strokeWidth = geometry.shaftWidth * (scaleFactor || 1);
|
|
563
|
+
const alongSeparation = fontSize * 0.6;
|
|
564
|
+
const inlineLabelLayout = useMemo2(
|
|
565
|
+
() => getInlineLabelLayout(screenPoints.shaftStart, screenPoints.shaftEnd, {
|
|
566
|
+
fontSize,
|
|
567
|
+
strokeWidth,
|
|
568
|
+
normalPadding: 6,
|
|
569
|
+
alongOffset: arrow.label ? alongSeparation : 0
|
|
570
|
+
}),
|
|
571
|
+
[screenPoints, fontSize, strokeWidth, arrow.label, alongSeparation]
|
|
572
|
+
);
|
|
573
|
+
const labelLayout = useMemo2(
|
|
574
|
+
() => getInlineLabelLayout(screenPoints.shaftStart, screenPoints.shaftEnd, {
|
|
575
|
+
fontSize,
|
|
576
|
+
strokeWidth,
|
|
577
|
+
normalPadding: 12,
|
|
578
|
+
alongOffset: arrow.inlineLabel ? -alongSeparation : 0
|
|
579
|
+
}),
|
|
580
|
+
[screenPoints, fontSize, strokeWidth, arrow.inlineLabel, alongSeparation]
|
|
581
|
+
);
|
|
560
582
|
const baseColor = arrow.color || defaultColors[index % defaultColors.length] || "black";
|
|
561
583
|
const displayColor = isHovered ? safeLighten(0.2, baseColor) : baseColor;
|
|
562
584
|
const handleMouseMove = (e) => {
|
|
@@ -611,7 +633,7 @@ var Arrow = ({
|
|
|
611
633
|
x2: screenPoints.shaftEnd.x,
|
|
612
634
|
y2: screenPoints.shaftEnd.y,
|
|
613
635
|
stroke: displayColor,
|
|
614
|
-
strokeWidth
|
|
636
|
+
strokeWidth,
|
|
615
637
|
strokeLinecap: "round",
|
|
616
638
|
pointerEvents: "stroke"
|
|
617
639
|
}
|
|
@@ -623,7 +645,36 @@ var Arrow = ({
|
|
|
623
645
|
fill: displayColor
|
|
624
646
|
},
|
|
625
647
|
headIndex
|
|
626
|
-
))
|
|
648
|
+
)),
|
|
649
|
+
arrow.label && /* @__PURE__ */ jsx2(
|
|
650
|
+
"text",
|
|
651
|
+
{
|
|
652
|
+
x: labelLayout.x,
|
|
653
|
+
y: labelLayout.y,
|
|
654
|
+
fill: displayColor,
|
|
655
|
+
fontSize,
|
|
656
|
+
fontFamily: "sans-serif",
|
|
657
|
+
textAnchor: "middle",
|
|
658
|
+
dominantBaseline: "central",
|
|
659
|
+
pointerEvents: "none",
|
|
660
|
+
children: arrow.label
|
|
661
|
+
}
|
|
662
|
+
),
|
|
663
|
+
arrow.inlineLabel && /* @__PURE__ */ jsx2(
|
|
664
|
+
"text",
|
|
665
|
+
{
|
|
666
|
+
x: inlineLabelLayout.x,
|
|
667
|
+
y: inlineLabelLayout.y,
|
|
668
|
+
fill: displayColor,
|
|
669
|
+
fontSize,
|
|
670
|
+
fontFamily: "sans-serif",
|
|
671
|
+
textAnchor: "middle",
|
|
672
|
+
dominantBaseline: "central",
|
|
673
|
+
transform: `rotate(${inlineLabelLayout.angleDegrees} ${inlineLabelLayout.x} ${inlineLabelLayout.y})`,
|
|
674
|
+
pointerEvents: "none",
|
|
675
|
+
children: arrow.inlineLabel
|
|
676
|
+
}
|
|
677
|
+
)
|
|
627
678
|
]
|
|
628
679
|
}
|
|
629
680
|
);
|