graphics-debug 0.0.46 → 0.0.48
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/README.md +20 -0
- package/dist/{chunk-G3XJ25G4.js → chunk-A2H7K3HS.js} +38 -4
- package/dist/chunk-A2H7K3HS.js.map +1 -0
- package/dist/{chunk-OPY7K7QC.js → chunk-HFEWNTMS.js} +2 -2
- package/dist/chunk-HFEWNTMS.js.map +1 -0
- package/dist/chunk-K2IJQPPY.js +33 -0
- package/dist/chunk-K2IJQPPY.js.map +1 -0
- package/dist/{chunk-O3RDZ6NK.js → chunk-L3RR2Y2G.js} +52 -6
- package/dist/chunk-L3RR2Y2G.js.map +1 -0
- package/dist/chunk-TJJMMKHI.js +16 -0
- package/dist/chunk-TJJMMKHI.js.map +1 -0
- package/dist/cli/cli.js +5 -3
- package/dist/cli/cli.js.map +1 -1
- package/dist/lib/drawGraphicsToCanvas.js +1 -1
- package/dist/lib/getSvgFromGraphicsObject.js +1 -1
- package/dist/lib/index.d.ts +3 -1
- package/dist/lib/index.js +12 -4
- package/dist/lib/matcher.js +1 -1
- package/dist/lib/mergeGraphics.d.ts +6 -0
- package/dist/lib/mergeGraphics.js +7 -0
- package/dist/lib/mergeGraphics.js.map +1 -0
- package/dist/lib/react.d.ts +1 -1
- package/dist/lib/react.js +166 -74
- package/dist/lib/react.js.map +1 -1
- package/dist/lib/translateGraphics.d.ts +6 -0
- package/dist/lib/translateGraphics.js +7 -0
- package/dist/lib/translateGraphics.js.map +1 -0
- package/dist/lib/types.d.ts +13 -1
- package/package.json +1 -1
- package/dist/chunk-G3XJ25G4.js.map +0 -1
- package/dist/chunk-O3RDZ6NK.js.map +0 -1
- package/dist/chunk-OPY7K7QC.js.map +0 -1
package/dist/lib/react.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-HFEWNTMS.js";
|
|
2
|
+
import "../chunk-K2IJQPPY.js";
|
|
2
3
|
import {
|
|
3
4
|
defaultColors,
|
|
4
5
|
drawGraphicsToCanvas,
|
|
5
6
|
getBounds
|
|
6
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-A2H7K3HS.js";
|
|
7
8
|
import "../chunk-NG6H63SM.js";
|
|
8
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-L3RR2Y2G.js";
|
|
10
|
+
import "../chunk-TJJMMKHI.js";
|
|
9
11
|
|
|
10
12
|
// site/components/InteractiveGraphics/InteractiveGraphics.tsx
|
|
11
13
|
import {
|
|
@@ -13,9 +15,9 @@ import {
|
|
|
13
15
|
scale,
|
|
14
16
|
translate,
|
|
15
17
|
inverse as inverse2,
|
|
16
|
-
applyToPoint as
|
|
18
|
+
applyToPoint as applyToPoint11
|
|
17
19
|
} from "transformation-matrix";
|
|
18
|
-
import { useMemo as
|
|
20
|
+
import { useMemo as useMemo8, useState as useState6, useEffect as useEffect3, useCallback } from "react";
|
|
19
21
|
import useMouseMatrixTransform from "use-mouse-matrix-transform";
|
|
20
22
|
import { SuperGrid } from "react-supergrid";
|
|
21
23
|
import useResizeObserver from "@react-hook/resize-observer";
|
|
@@ -353,6 +355,48 @@ var Circle = ({
|
|
|
353
355
|
);
|
|
354
356
|
};
|
|
355
357
|
|
|
358
|
+
// site/components/InteractiveGraphics/Text.tsx
|
|
359
|
+
import { applyToPoint as applyToPoint5 } from "transformation-matrix";
|
|
360
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
361
|
+
var Text = ({
|
|
362
|
+
textObj,
|
|
363
|
+
interactiveState,
|
|
364
|
+
index
|
|
365
|
+
}) => {
|
|
366
|
+
const { realToScreen, onObjectClicked } = interactiveState;
|
|
367
|
+
const { x, y, text, color, fontSize, anchorSide } = textObj;
|
|
368
|
+
const screenPos = applyToPoint5(realToScreen, { x, y });
|
|
369
|
+
const transformMap = {
|
|
370
|
+
top_left: "translate(0%, 0%)",
|
|
371
|
+
top_center: "translate(-50%, 0%)",
|
|
372
|
+
top_right: "translate(-100%, 0%)",
|
|
373
|
+
center_left: "translate(0%, -50%)",
|
|
374
|
+
center: "translate(-50%, -50%)",
|
|
375
|
+
center_right: "translate(-100%, -50%)",
|
|
376
|
+
bottom_left: "translate(0%, -100%)",
|
|
377
|
+
bottom_center: "translate(-50%, -100%)",
|
|
378
|
+
bottom_right: "translate(-100%, -100%)"
|
|
379
|
+
};
|
|
380
|
+
const transform = transformMap[anchorSide ?? "center"];
|
|
381
|
+
return /* @__PURE__ */ jsx6(
|
|
382
|
+
"div",
|
|
383
|
+
{
|
|
384
|
+
style: {
|
|
385
|
+
position: "absolute",
|
|
386
|
+
left: screenPos.x,
|
|
387
|
+
top: screenPos.y,
|
|
388
|
+
transform,
|
|
389
|
+
color: color || "black",
|
|
390
|
+
fontSize: fontSize ?? 12,
|
|
391
|
+
whiteSpace: "pre",
|
|
392
|
+
cursor: "default"
|
|
393
|
+
},
|
|
394
|
+
onClick: () => onObjectClicked?.({ type: "text", index, object: textObj }),
|
|
395
|
+
children: text
|
|
396
|
+
}
|
|
397
|
+
);
|
|
398
|
+
};
|
|
399
|
+
|
|
356
400
|
// site/utils/getGraphicsBounds.ts
|
|
357
401
|
var getGraphicsBounds = (graphics) => {
|
|
358
402
|
const bounds = {
|
|
@@ -384,22 +428,34 @@ var getGraphicsBounds = (graphics) => {
|
|
|
384
428
|
bounds.maxX = Math.max(bounds.maxX, point.x);
|
|
385
429
|
bounds.maxY = Math.max(bounds.maxY, point.y);
|
|
386
430
|
}
|
|
431
|
+
for (const circle of graphics.circles ?? []) {
|
|
432
|
+
bounds.minX = Math.min(bounds.minX, circle.center.x - circle.radius);
|
|
433
|
+
bounds.minY = Math.min(bounds.minY, circle.center.y - circle.radius);
|
|
434
|
+
bounds.maxX = Math.max(bounds.maxX, circle.center.x + circle.radius);
|
|
435
|
+
bounds.maxY = Math.max(bounds.maxY, circle.center.y + circle.radius);
|
|
436
|
+
}
|
|
437
|
+
for (const text of graphics.texts ?? []) {
|
|
438
|
+
bounds.minX = Math.min(bounds.minX, text.x);
|
|
439
|
+
bounds.minY = Math.min(bounds.minY, text.y);
|
|
440
|
+
bounds.maxX = Math.max(bounds.maxX, text.x);
|
|
441
|
+
bounds.maxY = Math.max(bounds.maxY, text.y);
|
|
442
|
+
}
|
|
387
443
|
return bounds;
|
|
388
444
|
};
|
|
389
445
|
|
|
390
446
|
// site/components/InteractiveGraphics/hooks/useIsPointOnScreen.ts
|
|
391
|
-
import { applyToPoint as
|
|
447
|
+
import { applyToPoint as applyToPoint7 } from "transformation-matrix";
|
|
392
448
|
import { useMemo as useMemo2 } from "react";
|
|
393
449
|
|
|
394
450
|
// site/components/InteractiveGraphics/hooks/useDoesLineIntersectViewport.ts
|
|
395
|
-
import { applyToPoint as
|
|
451
|
+
import { applyToPoint as applyToPoint6 } from "transformation-matrix";
|
|
396
452
|
import { useMemo } from "react";
|
|
397
453
|
var OFFSCREEN_MARGIN = 5;
|
|
398
454
|
var useDoesLineIntersectViewport = (realToScreen, size) => {
|
|
399
455
|
return useMemo(() => {
|
|
400
456
|
return (p1, p2) => {
|
|
401
|
-
const sp1 =
|
|
402
|
-
const sp2 =
|
|
457
|
+
const sp1 = applyToPoint6(realToScreen, p1);
|
|
458
|
+
const sp2 = applyToPoint6(realToScreen, p2);
|
|
403
459
|
const left = -OFFSCREEN_MARGIN;
|
|
404
460
|
const right = size.width + OFFSCREEN_MARGIN;
|
|
405
461
|
const top = -OFFSCREEN_MARGIN;
|
|
@@ -429,7 +485,7 @@ var useDoesLineIntersectViewport = (realToScreen, size) => {
|
|
|
429
485
|
var useIsPointOnScreen = (realToScreen, size) => {
|
|
430
486
|
return useMemo2(() => {
|
|
431
487
|
return (point) => {
|
|
432
|
-
const screenPoint =
|
|
488
|
+
const screenPoint = applyToPoint7(realToScreen, point);
|
|
433
489
|
return screenPoint.x >= -OFFSCREEN_MARGIN && screenPoint.x <= size.width + OFFSCREEN_MARGIN && screenPoint.y >= -OFFSCREEN_MARGIN && screenPoint.y <= size.height + OFFSCREEN_MARGIN;
|
|
434
490
|
};
|
|
435
491
|
}, [realToScreen, size]);
|
|
@@ -495,7 +551,7 @@ var useFilterRects = (isPointOnScreen, doesLineIntersectViewport, filterLayerAnd
|
|
|
495
551
|
};
|
|
496
552
|
|
|
497
553
|
// site/components/InteractiveGraphics/hooks/useFilterCircles.ts
|
|
498
|
-
import { applyToPoint as
|
|
554
|
+
import { applyToPoint as applyToPoint8 } from "transformation-matrix";
|
|
499
555
|
import { useMemo as useMemo6 } from "react";
|
|
500
556
|
var useFilterCircles = (isPointOnScreen, filterLayerAndStep, realToScreen, size) => {
|
|
501
557
|
return useMemo6(() => {
|
|
@@ -505,7 +561,7 @@ var useFilterCircles = (isPointOnScreen, filterLayerAndStep, realToScreen, size)
|
|
|
505
561
|
if (isPointOnScreen(center) || isPointOnScreen({ x: center.x + radius, y: center.y }) || isPointOnScreen({ x: center.x - radius, y: center.y }) || isPointOnScreen({ x: center.x, y: center.y + radius }) || isPointOnScreen({ x: center.x, y: center.y - radius })) {
|
|
506
562
|
return true;
|
|
507
563
|
}
|
|
508
|
-
const screenCenter =
|
|
564
|
+
const screenCenter = applyToPoint8(realToScreen, center);
|
|
509
565
|
const scale4 = Math.abs(realToScreen.a);
|
|
510
566
|
const screenRadius = radius * scale4;
|
|
511
567
|
const left = -OFFSCREEN_MARGIN;
|
|
@@ -533,10 +589,21 @@ var useFilterCircles = (isPointOnScreen, filterLayerAndStep, realToScreen, size)
|
|
|
533
589
|
}, [isPointOnScreen, filterLayerAndStep, realToScreen, size]);
|
|
534
590
|
};
|
|
535
591
|
|
|
592
|
+
// site/components/InteractiveGraphics/hooks/useFilterTexts.ts
|
|
593
|
+
import { useMemo as useMemo7 } from "react";
|
|
594
|
+
var useFilterTexts = (isPointOnScreen, filterLayerAndStep) => {
|
|
595
|
+
return useMemo7(() => {
|
|
596
|
+
return (text) => {
|
|
597
|
+
if (!filterLayerAndStep(text)) return false;
|
|
598
|
+
return isPointOnScreen({ x: text.x, y: text.y });
|
|
599
|
+
};
|
|
600
|
+
}, [isPointOnScreen, filterLayerAndStep]);
|
|
601
|
+
};
|
|
602
|
+
|
|
536
603
|
// site/components/DimensionOverlay.tsx
|
|
537
604
|
import { useEffect, useRef, useState as useState5 } from "react";
|
|
538
|
-
import { applyToPoint as
|
|
539
|
-
import { Fragment, jsx as
|
|
605
|
+
import { applyToPoint as applyToPoint9, identity, inverse } from "transformation-matrix";
|
|
606
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
540
607
|
var DimensionOverlay = ({ children, transform }) => {
|
|
541
608
|
if (!transform) transform = identity();
|
|
542
609
|
const [dimensionToolVisible, setDimensionToolVisible] = useState5(false);
|
|
@@ -587,8 +654,8 @@ var DimensionOverlay = ({ children, transform }) => {
|
|
|
587
654
|
};
|
|
588
655
|
};
|
|
589
656
|
useEffect(bindKeys, [containerBounds?.width, containerBounds?.height]);
|
|
590
|
-
const screenDStart =
|
|
591
|
-
const screenDEnd =
|
|
657
|
+
const screenDStart = applyToPoint9(transform, dStart);
|
|
658
|
+
const screenDEnd = applyToPoint9(transform, dEnd);
|
|
592
659
|
const arrowScreenBounds = {
|
|
593
660
|
left: Math.min(screenDStart.x, screenDEnd.x),
|
|
594
661
|
right: Math.max(screenDStart.x, screenDEnd.x),
|
|
@@ -611,7 +678,7 @@ var DimensionOverlay = ({ children, transform }) => {
|
|
|
611
678
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
612
679
|
const x = e.clientX - rect.left;
|
|
613
680
|
const y = e.clientY - rect.top;
|
|
614
|
-
const rwPoint =
|
|
681
|
+
const rwPoint = applyToPoint9(inverse(transform), { x, y });
|
|
615
682
|
mousePosRef.current.x = rwPoint.x;
|
|
616
683
|
mousePosRef.current.y = rwPoint.y;
|
|
617
684
|
if (dimensionToolStretching) {
|
|
@@ -633,7 +700,7 @@ var DimensionOverlay = ({ children, transform }) => {
|
|
|
633
700
|
children: [
|
|
634
701
|
children,
|
|
635
702
|
dimensionToolVisible && /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
636
|
-
/* @__PURE__ */
|
|
703
|
+
/* @__PURE__ */ jsx7(
|
|
637
704
|
"div",
|
|
638
705
|
{
|
|
639
706
|
style: {
|
|
@@ -653,7 +720,7 @@ var DimensionOverlay = ({ children, transform }) => {
|
|
|
653
720
|
children: Math.abs(dStart.x - dEnd.x).toFixed(2)
|
|
654
721
|
}
|
|
655
722
|
),
|
|
656
|
-
/* @__PURE__ */
|
|
723
|
+
/* @__PURE__ */ jsx7(
|
|
657
724
|
"div",
|
|
658
725
|
{
|
|
659
726
|
style: {
|
|
@@ -671,7 +738,7 @@ var DimensionOverlay = ({ children, transform }) => {
|
|
|
671
738
|
fontFamily: "sans-serif",
|
|
672
739
|
zIndex: 30
|
|
673
740
|
},
|
|
674
|
-
children: /* @__PURE__ */
|
|
741
|
+
children: /* @__PURE__ */ jsx7(
|
|
675
742
|
"div",
|
|
676
743
|
{
|
|
677
744
|
style: {
|
|
@@ -697,7 +764,7 @@ var DimensionOverlay = ({ children, transform }) => {
|
|
|
697
764
|
width: containerBounds?.width || "100%",
|
|
698
765
|
height: containerBounds?.height || "100%",
|
|
699
766
|
children: [
|
|
700
|
-
/* @__PURE__ */
|
|
767
|
+
/* @__PURE__ */ jsx7("defs", { children: /* @__PURE__ */ jsx7(
|
|
701
768
|
"marker",
|
|
702
769
|
{
|
|
703
770
|
id: "head",
|
|
@@ -706,10 +773,10 @@ var DimensionOverlay = ({ children, transform }) => {
|
|
|
706
773
|
markerHeight: "4",
|
|
707
774
|
refX: "2",
|
|
708
775
|
refY: "2",
|
|
709
|
-
children: /* @__PURE__ */
|
|
776
|
+
children: /* @__PURE__ */ jsx7("path", { d: "M0,0 V4 L2,2 Z", fill: "red" })
|
|
710
777
|
}
|
|
711
778
|
) }),
|
|
712
|
-
/* @__PURE__ */
|
|
779
|
+
/* @__PURE__ */ jsx7(
|
|
713
780
|
"line",
|
|
714
781
|
{
|
|
715
782
|
x1: screenDStart.x,
|
|
@@ -722,7 +789,7 @@ var DimensionOverlay = ({ children, transform }) => {
|
|
|
722
789
|
stroke: "red"
|
|
723
790
|
}
|
|
724
791
|
),
|
|
725
|
-
/* @__PURE__ */
|
|
792
|
+
/* @__PURE__ */ jsx7(
|
|
726
793
|
"line",
|
|
727
794
|
{
|
|
728
795
|
x1: screenDStart.x,
|
|
@@ -735,7 +802,7 @@ var DimensionOverlay = ({ children, transform }) => {
|
|
|
735
802
|
stroke: "red"
|
|
736
803
|
}
|
|
737
804
|
),
|
|
738
|
-
/* @__PURE__ */
|
|
805
|
+
/* @__PURE__ */ jsx7(
|
|
739
806
|
"line",
|
|
740
807
|
{
|
|
741
808
|
x1: screenDEnd.x,
|
|
@@ -769,13 +836,13 @@ var DimensionOverlay = ({ children, transform }) => {
|
|
|
769
836
|
",",
|
|
770
837
|
dStart.y.toFixed(2),
|
|
771
838
|
")",
|
|
772
|
-
/* @__PURE__ */
|
|
839
|
+
/* @__PURE__ */ jsx7("br", {}),
|
|
773
840
|
"(",
|
|
774
841
|
dEnd.x.toFixed(2),
|
|
775
842
|
",",
|
|
776
843
|
dEnd.y.toFixed(2),
|
|
777
844
|
")",
|
|
778
|
-
/* @__PURE__ */
|
|
845
|
+
/* @__PURE__ */ jsx7("br", {}),
|
|
779
846
|
"dist:",
|
|
780
847
|
" ",
|
|
781
848
|
Math.sqrt(
|
|
@@ -803,12 +870,19 @@ function getMaxStep(graphics) {
|
|
|
803
870
|
const maxLineStep = getMaxStepFromArray(graphics.lines);
|
|
804
871
|
const maxRectStep = getMaxStepFromArray(graphics.rects);
|
|
805
872
|
const maxCircleStep = getMaxStepFromArray(graphics.circles);
|
|
806
|
-
|
|
873
|
+
const maxTextStep = getMaxStepFromArray(graphics.texts);
|
|
874
|
+
return Math.max(
|
|
875
|
+
maxPointStep,
|
|
876
|
+
maxLineStep,
|
|
877
|
+
maxRectStep,
|
|
878
|
+
maxCircleStep,
|
|
879
|
+
maxTextStep
|
|
880
|
+
);
|
|
807
881
|
}
|
|
808
882
|
|
|
809
883
|
// site/components/InteractiveGraphics/ContextMenu.tsx
|
|
810
884
|
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
811
|
-
import { jsx as
|
|
885
|
+
import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
812
886
|
var ContextMenu = ({
|
|
813
887
|
x,
|
|
814
888
|
y,
|
|
@@ -856,7 +930,7 @@ var ContextMenu = ({
|
|
|
856
930
|
e.currentTarget.style.backgroundColor = "";
|
|
857
931
|
};
|
|
858
932
|
return /* @__PURE__ */ jsxs3("div", { ref: menuRef, style: menuStyle, children: [
|
|
859
|
-
/* @__PURE__ */
|
|
933
|
+
/* @__PURE__ */ jsx8(
|
|
860
934
|
"div",
|
|
861
935
|
{
|
|
862
936
|
style: menuItemStyle,
|
|
@@ -869,7 +943,7 @@ var ContextMenu = ({
|
|
|
869
943
|
children: "Save Camera Position"
|
|
870
944
|
}
|
|
871
945
|
),
|
|
872
|
-
/* @__PURE__ */
|
|
946
|
+
/* @__PURE__ */ jsx8(
|
|
873
947
|
"div",
|
|
874
948
|
{
|
|
875
949
|
style: menuItemStyle,
|
|
@@ -882,7 +956,7 @@ var ContextMenu = ({
|
|
|
882
956
|
children: "Clear Saved Camera Position"
|
|
883
957
|
}
|
|
884
958
|
),
|
|
885
|
-
/* @__PURE__ */
|
|
959
|
+
/* @__PURE__ */ jsx8(
|
|
886
960
|
"div",
|
|
887
961
|
{
|
|
888
962
|
style: menuItemStyle,
|
|
@@ -895,7 +969,7 @@ var ContextMenu = ({
|
|
|
895
969
|
children: "Add Mark"
|
|
896
970
|
}
|
|
897
971
|
),
|
|
898
|
-
/* @__PURE__ */
|
|
972
|
+
/* @__PURE__ */ jsx8(
|
|
899
973
|
"div",
|
|
900
974
|
{
|
|
901
975
|
style: menuItemStyle,
|
|
@@ -912,11 +986,11 @@ var ContextMenu = ({
|
|
|
912
986
|
};
|
|
913
987
|
|
|
914
988
|
// site/components/InteractiveGraphics/Marker.tsx
|
|
915
|
-
import { applyToPoint as
|
|
916
|
-
import { jsx as
|
|
989
|
+
import { applyToPoint as applyToPoint10 } from "transformation-matrix";
|
|
990
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
917
991
|
var Marker = ({ marker, transform }) => {
|
|
918
|
-
const [screenX, screenY] =
|
|
919
|
-
return /* @__PURE__ */
|
|
992
|
+
const [screenX, screenY] = applyToPoint10(transform, [marker.x, marker.y]);
|
|
993
|
+
return /* @__PURE__ */ jsx9(
|
|
920
994
|
"svg",
|
|
921
995
|
{
|
|
922
996
|
style: {
|
|
@@ -927,7 +1001,7 @@ var Marker = ({ marker, transform }) => {
|
|
|
927
1001
|
zIndex: 900
|
|
928
1002
|
},
|
|
929
1003
|
children: /* @__PURE__ */ jsxs4("g", { transform: `translate(${screenX}, ${screenY})`, children: [
|
|
930
|
-
/* @__PURE__ */
|
|
1004
|
+
/* @__PURE__ */ jsx9(
|
|
931
1005
|
"circle",
|
|
932
1006
|
{
|
|
933
1007
|
r: 7,
|
|
@@ -936,14 +1010,14 @@ var Marker = ({ marker, transform }) => {
|
|
|
936
1010
|
strokeWidth: 2
|
|
937
1011
|
}
|
|
938
1012
|
),
|
|
939
|
-
/* @__PURE__ */
|
|
1013
|
+
/* @__PURE__ */ jsx9("circle", { r: 2, fill: "rgba(255, 0, 0, 0.9)" })
|
|
940
1014
|
] })
|
|
941
1015
|
}
|
|
942
1016
|
);
|
|
943
1017
|
};
|
|
944
1018
|
|
|
945
1019
|
// site/components/InteractiveGraphics/InteractiveGraphics.tsx
|
|
946
|
-
import { jsx as
|
|
1020
|
+
import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
947
1021
|
var InteractiveGraphics = ({
|
|
948
1022
|
graphics,
|
|
949
1023
|
onObjectClicked,
|
|
@@ -959,11 +1033,12 @@ var InteractiveGraphics = ({
|
|
|
959
1033
|
/* @__PURE__ */ new Set([
|
|
960
1034
|
...graphics.lines?.map((l) => l.layer).filter(Boolean) ?? [],
|
|
961
1035
|
...graphics.rects?.map((r) => r.layer).filter(Boolean) ?? [],
|
|
962
|
-
...graphics.points?.map((p) => p.layer).filter(Boolean) ?? []
|
|
1036
|
+
...graphics.points?.map((p) => p.layer).filter(Boolean) ?? [],
|
|
1037
|
+
...graphics.texts?.map((t) => t.layer).filter(Boolean) ?? []
|
|
963
1038
|
])
|
|
964
1039
|
);
|
|
965
1040
|
const maxStep = getMaxStep(graphics);
|
|
966
|
-
const graphicsBoundsWithPadding =
|
|
1041
|
+
const graphicsBoundsWithPadding = useMemo8(() => {
|
|
967
1042
|
const actualBounds = getGraphicsBounds(graphics);
|
|
968
1043
|
const width = actualBounds.maxX - actualBounds.minX;
|
|
969
1044
|
const height = actualBounds.maxY - actualBounds.minY;
|
|
@@ -1093,7 +1168,7 @@ var InteractiveGraphics = ({
|
|
|
1093
1168
|
const screenX = screenPoint.x - rect.left;
|
|
1094
1169
|
const screenY = screenPoint.y - rect.top;
|
|
1095
1170
|
const inverseTransform = inverse2(realToScreen);
|
|
1096
|
-
const [realX, realY] =
|
|
1171
|
+
const [realX, realY] = applyToPoint11(inverseTransform, [
|
|
1097
1172
|
screenX,
|
|
1098
1173
|
screenY
|
|
1099
1174
|
]);
|
|
@@ -1147,28 +1222,33 @@ var InteractiveGraphics = ({
|
|
|
1147
1222
|
realToScreen,
|
|
1148
1223
|
size
|
|
1149
1224
|
);
|
|
1225
|
+
const filterTexts = useFilterTexts(isPointOnScreen, filterLayerAndStep);
|
|
1150
1226
|
const filterAndLimit = (objects, filterFn) => {
|
|
1151
1227
|
if (!objects) return [];
|
|
1152
1228
|
const filtered = objects.map((obj, index) => ({ ...obj, originalIndex: index })).filter(filterFn);
|
|
1153
1229
|
return objectLimit ? filtered.slice(-objectLimit) : filtered;
|
|
1154
1230
|
};
|
|
1155
|
-
const filteredLines =
|
|
1231
|
+
const filteredLines = useMemo8(
|
|
1156
1232
|
() => filterAndLimit(graphics.lines, filterLines),
|
|
1157
1233
|
[graphics.lines, filterLines, objectLimit]
|
|
1158
1234
|
);
|
|
1159
|
-
const filteredRects =
|
|
1235
|
+
const filteredRects = useMemo8(
|
|
1160
1236
|
() => filterAndLimit(graphics.rects, filterRects),
|
|
1161
1237
|
[graphics.rects, filterRects, objectLimit]
|
|
1162
1238
|
);
|
|
1163
|
-
const filteredPoints =
|
|
1239
|
+
const filteredPoints = useMemo8(
|
|
1164
1240
|
() => filterAndLimit(graphics.points, filterPoints),
|
|
1165
1241
|
[graphics.points, filterPoints, objectLimit]
|
|
1166
1242
|
);
|
|
1167
|
-
const filteredCircles =
|
|
1243
|
+
const filteredCircles = useMemo8(
|
|
1168
1244
|
() => filterAndLimit(graphics.circles, filterCircles),
|
|
1169
1245
|
[graphics.circles, filterCircles, objectLimit]
|
|
1170
1246
|
);
|
|
1171
|
-
const
|
|
1247
|
+
const filteredTexts = useMemo8(
|
|
1248
|
+
() => filterAndLimit(graphics.texts, filterTexts),
|
|
1249
|
+
[graphics.texts, filterTexts, objectLimit]
|
|
1250
|
+
);
|
|
1251
|
+
const totalFilteredObjects = filteredLines.length + filteredRects.length + filteredPoints.length + filteredCircles.length + filteredTexts.length;
|
|
1172
1252
|
const isLimitReached = objectLimit && totalFilteredObjects > objectLimit;
|
|
1173
1253
|
return /* @__PURE__ */ jsxs5("div", { children: [
|
|
1174
1254
|
showToolbar && /* @__PURE__ */ jsxs5("div", { style: { margin: 8 }, children: [
|
|
@@ -1182,8 +1262,8 @@ var InteractiveGraphics = ({
|
|
|
1182
1262
|
},
|
|
1183
1263
|
style: { marginRight: 8 },
|
|
1184
1264
|
children: [
|
|
1185
|
-
/* @__PURE__ */
|
|
1186
|
-
availableLayers.map((layer) => /* @__PURE__ */
|
|
1265
|
+
/* @__PURE__ */ jsx10("option", { value: "", children: "All Layers" }),
|
|
1266
|
+
availableLayers.map((layer) => /* @__PURE__ */ jsx10("option", { value: layer, children: layer }, layer))
|
|
1187
1267
|
]
|
|
1188
1268
|
}
|
|
1189
1269
|
),
|
|
@@ -1193,7 +1273,7 @@ var InteractiveGraphics = ({
|
|
|
1193
1273
|
style: { display: "inline-flex", alignItems: "center", gap: 8 },
|
|
1194
1274
|
children: [
|
|
1195
1275
|
"Step:",
|
|
1196
|
-
/* @__PURE__ */
|
|
1276
|
+
/* @__PURE__ */ jsx10(
|
|
1197
1277
|
"input",
|
|
1198
1278
|
{
|
|
1199
1279
|
type: "number",
|
|
@@ -1209,7 +1289,7 @@ var InteractiveGraphics = ({
|
|
|
1209
1289
|
}
|
|
1210
1290
|
),
|
|
1211
1291
|
/* @__PURE__ */ jsxs5("label", { children: [
|
|
1212
|
-
/* @__PURE__ */
|
|
1292
|
+
/* @__PURE__ */ jsx10(
|
|
1213
1293
|
"input",
|
|
1214
1294
|
{
|
|
1215
1295
|
type: "checkbox",
|
|
@@ -1224,7 +1304,7 @@ var InteractiveGraphics = ({
|
|
|
1224
1304
|
"Filter by step"
|
|
1225
1305
|
] }),
|
|
1226
1306
|
/* @__PURE__ */ jsxs5("label", { children: [
|
|
1227
|
-
/* @__PURE__ */
|
|
1307
|
+
/* @__PURE__ */ jsx10(
|
|
1228
1308
|
"input",
|
|
1229
1309
|
{
|
|
1230
1310
|
type: "checkbox",
|
|
@@ -1262,7 +1342,7 @@ var InteractiveGraphics = ({
|
|
|
1262
1342
|
onContextMenu: handleContextMenu,
|
|
1263
1343
|
children: [
|
|
1264
1344
|
/* @__PURE__ */ jsxs5(DimensionOverlay, { transform: realToScreen, children: [
|
|
1265
|
-
filteredLines.map((line) => /* @__PURE__ */
|
|
1345
|
+
filteredLines.map((line) => /* @__PURE__ */ jsx10(
|
|
1266
1346
|
Line,
|
|
1267
1347
|
{
|
|
1268
1348
|
line,
|
|
@@ -1271,7 +1351,7 @@ var InteractiveGraphics = ({
|
|
|
1271
1351
|
},
|
|
1272
1352
|
line.originalIndex
|
|
1273
1353
|
)),
|
|
1274
|
-
filteredRects.map((rect) => /* @__PURE__ */
|
|
1354
|
+
filteredRects.map((rect) => /* @__PURE__ */ jsx10(
|
|
1275
1355
|
Rect,
|
|
1276
1356
|
{
|
|
1277
1357
|
rect,
|
|
@@ -1280,7 +1360,7 @@ var InteractiveGraphics = ({
|
|
|
1280
1360
|
},
|
|
1281
1361
|
rect.originalIndex
|
|
1282
1362
|
)),
|
|
1283
|
-
filteredPoints.map((point) => /* @__PURE__ */
|
|
1363
|
+
filteredPoints.map((point) => /* @__PURE__ */ jsx10(
|
|
1284
1364
|
Point,
|
|
1285
1365
|
{
|
|
1286
1366
|
point,
|
|
@@ -1289,7 +1369,7 @@ var InteractiveGraphics = ({
|
|
|
1289
1369
|
},
|
|
1290
1370
|
point.originalIndex
|
|
1291
1371
|
)),
|
|
1292
|
-
filteredCircles.map((circle) => /* @__PURE__ */
|
|
1372
|
+
filteredCircles.map((circle) => /* @__PURE__ */ jsx10(
|
|
1293
1373
|
Circle,
|
|
1294
1374
|
{
|
|
1295
1375
|
circle,
|
|
@@ -1298,7 +1378,16 @@ var InteractiveGraphics = ({
|
|
|
1298
1378
|
},
|
|
1299
1379
|
circle.originalIndex
|
|
1300
1380
|
)),
|
|
1301
|
-
/* @__PURE__ */
|
|
1381
|
+
filteredTexts.map((txt) => /* @__PURE__ */ jsx10(
|
|
1382
|
+
Text,
|
|
1383
|
+
{
|
|
1384
|
+
textObj: txt,
|
|
1385
|
+
index: txt.originalIndex,
|
|
1386
|
+
interactiveState
|
|
1387
|
+
},
|
|
1388
|
+
txt.originalIndex
|
|
1389
|
+
)),
|
|
1390
|
+
/* @__PURE__ */ jsx10(
|
|
1302
1391
|
SuperGrid,
|
|
1303
1392
|
{
|
|
1304
1393
|
stringifyCoord: (x, y) => `${x.toFixed(2)}, ${y.toFixed(2)}`,
|
|
@@ -1308,7 +1397,7 @@ var InteractiveGraphics = ({
|
|
|
1308
1397
|
}
|
|
1309
1398
|
)
|
|
1310
1399
|
] }),
|
|
1311
|
-
markers.map((marker, index) => /* @__PURE__ */
|
|
1400
|
+
markers.map((marker, index) => /* @__PURE__ */ jsx10(
|
|
1312
1401
|
Marker,
|
|
1313
1402
|
{
|
|
1314
1403
|
marker,
|
|
@@ -1317,7 +1406,7 @@ var InteractiveGraphics = ({
|
|
|
1317
1406
|
},
|
|
1318
1407
|
index
|
|
1319
1408
|
)),
|
|
1320
|
-
contextMenu && /* @__PURE__ */
|
|
1409
|
+
contextMenu && /* @__PURE__ */ jsx10(
|
|
1321
1410
|
ContextMenu,
|
|
1322
1411
|
{
|
|
1323
1412
|
x: contextMenu.x,
|
|
@@ -1364,6 +1453,9 @@ function getGraphicsFilteredByStep(graphics, {
|
|
|
1364
1453
|
),
|
|
1365
1454
|
circles: graphics.circles?.filter(
|
|
1366
1455
|
(c) => c.step === void 0 || c.step === selectedStep
|
|
1456
|
+
),
|
|
1457
|
+
texts: graphics.texts?.filter(
|
|
1458
|
+
(t) => t.step === void 0 || t.step === selectedStep
|
|
1367
1459
|
)
|
|
1368
1460
|
};
|
|
1369
1461
|
return filteredGraphics;
|
|
@@ -1383,7 +1475,7 @@ function getGraphicsBoundsWithPadding(graphics) {
|
|
|
1383
1475
|
}
|
|
1384
1476
|
|
|
1385
1477
|
// site/components/InteractiveGraphicsCanvas.tsx
|
|
1386
|
-
import { jsx as
|
|
1478
|
+
import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1387
1479
|
function InteractiveGraphicsCanvas({
|
|
1388
1480
|
graphics,
|
|
1389
1481
|
showLabelsByDefault = true,
|
|
@@ -1495,7 +1587,7 @@ function InteractiveGraphicsCanvas({
|
|
|
1495
1587
|
/* @__PURE__ */ jsxs6("div", { style: { display: "flex", gap: "12px", alignItems: "center" }, children: [
|
|
1496
1588
|
/* @__PURE__ */ jsxs6("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
|
|
1497
1589
|
/* @__PURE__ */ jsxs6("label", { children: [
|
|
1498
|
-
/* @__PURE__ */
|
|
1590
|
+
/* @__PURE__ */ jsx11(
|
|
1499
1591
|
"input",
|
|
1500
1592
|
{
|
|
1501
1593
|
type: "checkbox",
|
|
@@ -1508,7 +1600,7 @@ function InteractiveGraphicsCanvas({
|
|
|
1508
1600
|
),
|
|
1509
1601
|
"Filter by step"
|
|
1510
1602
|
] }),
|
|
1511
|
-
/* @__PURE__ */
|
|
1603
|
+
/* @__PURE__ */ jsx11(
|
|
1512
1604
|
"input",
|
|
1513
1605
|
{
|
|
1514
1606
|
type: "number",
|
|
@@ -1525,7 +1617,7 @@ function InteractiveGraphicsCanvas({
|
|
|
1525
1617
|
}
|
|
1526
1618
|
),
|
|
1527
1619
|
/* @__PURE__ */ jsxs6("label", { children: [
|
|
1528
|
-
/* @__PURE__ */
|
|
1620
|
+
/* @__PURE__ */ jsx11(
|
|
1529
1621
|
"input",
|
|
1530
1622
|
{
|
|
1531
1623
|
type: "checkbox",
|
|
@@ -1540,8 +1632,8 @@ function InteractiveGraphicsCanvas({
|
|
|
1540
1632
|
"Show last step"
|
|
1541
1633
|
] })
|
|
1542
1634
|
] }),
|
|
1543
|
-
/* @__PURE__ */
|
|
1544
|
-
/* @__PURE__ */
|
|
1635
|
+
/* @__PURE__ */ jsx11("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: /* @__PURE__ */ jsxs6("label", { children: [
|
|
1636
|
+
/* @__PURE__ */ jsx11(
|
|
1545
1637
|
"input",
|
|
1546
1638
|
{
|
|
1547
1639
|
type: "checkbox",
|
|
@@ -1555,7 +1647,7 @@ function InteractiveGraphicsCanvas({
|
|
|
1555
1647
|
"Show labels"
|
|
1556
1648
|
] }) })
|
|
1557
1649
|
] }),
|
|
1558
|
-
/* @__PURE__ */
|
|
1650
|
+
/* @__PURE__ */ jsx11(
|
|
1559
1651
|
"div",
|
|
1560
1652
|
{
|
|
1561
1653
|
ref: (node) => {
|
|
@@ -1571,7 +1663,7 @@ function InteractiveGraphicsCanvas({
|
|
|
1571
1663
|
border: "1px solid #ccc",
|
|
1572
1664
|
overflow: "hidden"
|
|
1573
1665
|
},
|
|
1574
|
-
children: /* @__PURE__ */
|
|
1666
|
+
children: /* @__PURE__ */ jsx11(
|
|
1575
1667
|
"canvas",
|
|
1576
1668
|
{
|
|
1577
1669
|
ref: canvasRef,
|
|
@@ -1594,7 +1686,7 @@ import React3, { useRef as useRef4, useEffect as useEffect5, useState as useStat
|
|
|
1594
1686
|
import useMouseMatrixTransform3 from "use-mouse-matrix-transform";
|
|
1595
1687
|
import { compose as compose3, scale as scale3, translate as translate3 } from "transformation-matrix";
|
|
1596
1688
|
import useResizeObserver3 from "@react-hook/resize-observer";
|
|
1597
|
-
import { jsx as
|
|
1689
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1598
1690
|
function TransformContainer({
|
|
1599
1691
|
initialTransform,
|
|
1600
1692
|
children,
|
|
@@ -1606,7 +1698,7 @@ function TransformContainer({
|
|
|
1606
1698
|
useEffect5(() => {
|
|
1607
1699
|
onTransformChange(transform);
|
|
1608
1700
|
}, [transform, onTransformChange]);
|
|
1609
|
-
return /* @__PURE__ */
|
|
1701
|
+
return /* @__PURE__ */ jsx12(
|
|
1610
1702
|
"div",
|
|
1611
1703
|
{
|
|
1612
1704
|
ref,
|
|
@@ -1742,7 +1834,7 @@ var CanvasGraphics = ({
|
|
|
1742
1834
|
useEffect5(() => {
|
|
1743
1835
|
setCurrentTransform(computedInitialTransform);
|
|
1744
1836
|
}, [computedInitialTransform]);
|
|
1745
|
-
return /* @__PURE__ */
|
|
1837
|
+
return /* @__PURE__ */ jsx12(
|
|
1746
1838
|
"div",
|
|
1747
1839
|
{
|
|
1748
1840
|
ref: containerRef,
|
|
@@ -1753,16 +1845,16 @@ var CanvasGraphics = ({
|
|
|
1753
1845
|
border: "1px solid #eee",
|
|
1754
1846
|
overflow: "hidden"
|
|
1755
1847
|
},
|
|
1756
|
-
children: /* @__PURE__ */
|
|
1848
|
+
children: /* @__PURE__ */ jsx12(
|
|
1757
1849
|
TransformContainer,
|
|
1758
1850
|
{
|
|
1759
1851
|
initialTransform: computedInitialTransform,
|
|
1760
1852
|
onTransformChange: handleTransformChange,
|
|
1761
|
-
children: /* @__PURE__ */
|
|
1853
|
+
children: /* @__PURE__ */ jsx12(
|
|
1762
1854
|
DimensionOverlay,
|
|
1763
1855
|
{
|
|
1764
1856
|
transform: currentTransform || computedInitialTransform,
|
|
1765
|
-
children: /* @__PURE__ */
|
|
1857
|
+
children: /* @__PURE__ */ jsx12(
|
|
1766
1858
|
"canvas",
|
|
1767
1859
|
{
|
|
1768
1860
|
ref: canvasRef,
|