@aivex/ui 1.2.0-dev.13 → 1.2.0-dev.14
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/components/ShapeEditor/ShapeEditor.d.ts +1 -1
- package/dist/components/ShapeEditor/_components/Minimap.d.ts +3 -1
- package/dist/components/ShapeEditor/_components/SelectionInfo.d.ts +2 -0
- package/dist/components/ShapeEditor/_model/clipboard.d.ts +22 -0
- package/dist/components/ShapeEditor/_model/clipboard.test.d.ts +1 -0
- package/dist/components/ShapeEditor/_model/props.d.ts +11 -5
- package/dist/components/ShapeEditor/_renderers/KonvaRenderer.d.ts +4 -0
- package/dist/components/ShapeEditor/_renderers/PixiRenderer.d.ts +8 -0
- package/dist/components/ShapeEditor/_renderers/types.d.ts +5 -0
- package/dist/components/ShapeEditor/_state/useEngineLifecycle.d.ts +2 -3
- package/dist/components/ShapeEditor/_state/useSelectionActions.d.ts +6 -4
- package/dist/shape-editor.cjs +1 -1
- package/dist/shape-editor.cjs.map +1 -1
- package/dist/shape-editor.js +928 -788
- package/dist/shape-editor.js.map +1 -1
- package/package.json +1 -1
package/dist/shape-editor.js
CHANGED
|
@@ -798,25 +798,26 @@ function ze({ label: e, checked: t, onChange: n }) {
|
|
|
798
798
|
}
|
|
799
799
|
//#endregion
|
|
800
800
|
//#region src/components/ShapeEditor/_components/Minimap.tsx
|
|
801
|
-
function Be({ image: e, imageUrl: s, imageVisible: c = !0,
|
|
802
|
-
let { offX:
|
|
801
|
+
function Be({ image: e, imageUrl: s, imageVisible: c = !0, loading: l = !1, maskDataUrl: u, region: d, roiMaskId: f, shapes: p, view: m, onChangeView: h, nav: g, registerShape: _, rectRef: v, zoomLabelRef: y, onZoom100: b, open: C, onToggleOpen: w, showSettings: T = !0, settingsOpen: E, onToggleSettings: D, onCloseSettings: O, labels: k = V.minimap, settingsLabels: A }) {
|
|
802
|
+
let { offX: j, offY: N, dispW: P, dispH: ee, zoomCentered: te } = g, re = {
|
|
803
803
|
position: "absolute",
|
|
804
|
-
left:
|
|
805
|
-
top:
|
|
806
|
-
width:
|
|
807
|
-
height:
|
|
804
|
+
left: j,
|
|
805
|
+
top: N,
|
|
806
|
+
width: P,
|
|
807
|
+
height: ee
|
|
808
808
|
};
|
|
809
809
|
return /* @__PURE__ */ S("div", {
|
|
810
810
|
className: "aivex:absolute aivex:bottom-2 aivex:left-2 aivex:w-[188px] aivex:rounded-[8px] aivex:border aivex:border-border-default aivex:bg-bg-primary aivex:p-[4px] aivex:shadow-lg",
|
|
811
811
|
children: [/* @__PURE__ */ x("div", {
|
|
812
|
-
className: `aivex:overflow-hidden aivex:rounded-[4px] aivex:transition-all aivex:duration-200 aivex:ease-in-out ${
|
|
812
|
+
className: `aivex:overflow-hidden aivex:rounded-[4px] aivex:transition-all aivex:duration-200 aivex:ease-in-out ${C ? "aivex:mb-1 aivex:max-h-[180px] aivex:opacity-100" : "aivex:max-h-0 aivex:opacity-0"}`,
|
|
813
813
|
children: /* @__PURE__ */ x("div", {
|
|
814
|
-
className:
|
|
815
|
-
onPointerDown:
|
|
816
|
-
onPointerMove:
|
|
817
|
-
onPointerUp:
|
|
818
|
-
onPointerCancel:
|
|
819
|
-
onWheel:
|
|
814
|
+
className: `aivex:relative aivex:h-[180px] aivex:w-[180px] aivex:touch-none aivex:overflow-hidden aivex:rounded-[4px] aivex:bg-black ${l ? "aivex:cursor-default" : "aivex:cursor-grab aivex:active:cursor-grabbing"}`,
|
|
815
|
+
onPointerDown: l ? void 0 : g.handleMinimapPointerDown,
|
|
816
|
+
onPointerMove: l ? void 0 : g.handleMinimapPointerMove,
|
|
817
|
+
onPointerUp: l ? void 0 : g.endMinimapDrag,
|
|
818
|
+
onPointerCancel: l ? void 0 : g.endMinimapDrag,
|
|
819
|
+
onWheel: l ? void 0 : g.handleMinimapWheel,
|
|
820
|
+
"aria-busy": l,
|
|
820
821
|
children: /* @__PURE__ */ S("div", {
|
|
821
822
|
style: {
|
|
822
823
|
position: "absolute",
|
|
@@ -829,53 +830,53 @@ function Be({ image: e, imageUrl: s, imageVisible: c = !0, maskDataUrl: l, regio
|
|
|
829
830
|
src: s,
|
|
830
831
|
alt: "",
|
|
831
832
|
draggable: !1,
|
|
832
|
-
style:
|
|
833
|
+
style: re
|
|
833
834
|
}),
|
|
834
|
-
|
|
835
|
-
src:
|
|
835
|
+
u && m.showGuide && /* @__PURE__ */ x("img", {
|
|
836
|
+
src: u,
|
|
836
837
|
alt: "",
|
|
837
838
|
draggable: !1,
|
|
838
839
|
style: {
|
|
839
|
-
...
|
|
840
|
+
...re,
|
|
840
841
|
opacity: .55,
|
|
841
842
|
imageRendering: "pixelated",
|
|
842
843
|
pointerEvents: "none"
|
|
843
844
|
}
|
|
844
845
|
}),
|
|
845
|
-
|
|
846
|
+
m.showRegionMask && d && d.rects.length > 0 && /* @__PURE__ */ x(Ie, {
|
|
846
847
|
image: e,
|
|
847
|
-
region:
|
|
848
|
-
maskId:
|
|
849
|
-
width:
|
|
850
|
-
height:
|
|
848
|
+
region: d,
|
|
849
|
+
maskId: f,
|
|
850
|
+
width: P,
|
|
851
|
+
height: ee,
|
|
851
852
|
strokeWidth: 1,
|
|
852
853
|
strokeDasharray: "4 4",
|
|
853
854
|
style: {
|
|
854
855
|
position: "absolute",
|
|
855
|
-
left:
|
|
856
|
-
top:
|
|
856
|
+
left: j,
|
|
857
|
+
top: N,
|
|
857
858
|
pointerEvents: "none"
|
|
858
859
|
}
|
|
859
860
|
}),
|
|
860
861
|
/* @__PURE__ */ x("svg", {
|
|
861
862
|
viewBox: `0 0 ${e.w} ${e.h}`,
|
|
862
|
-
width:
|
|
863
|
-
height:
|
|
863
|
+
width: P,
|
|
864
|
+
height: ee,
|
|
864
865
|
style: {
|
|
865
866
|
position: "absolute",
|
|
866
|
-
left:
|
|
867
|
-
top:
|
|
867
|
+
left: j,
|
|
868
|
+
top: N,
|
|
868
869
|
pointerEvents: "none"
|
|
869
870
|
},
|
|
870
871
|
"aria-hidden": !0,
|
|
871
|
-
children: ne(
|
|
872
|
+
children: ne(p).filter(M).map((e) => /* @__PURE__ */ x(Fe, {
|
|
872
873
|
shape: e,
|
|
873
|
-
strokeSize:
|
|
874
|
-
register:
|
|
874
|
+
strokeSize: m.strokeSize,
|
|
875
|
+
register: _
|
|
875
876
|
}, e.id))
|
|
876
877
|
}),
|
|
877
878
|
/* @__PURE__ */ x("div", {
|
|
878
|
-
ref:
|
|
879
|
+
ref: v,
|
|
879
880
|
style: {
|
|
880
881
|
position: "absolute",
|
|
881
882
|
border: "1px solid #00ff00",
|
|
@@ -895,54 +896,57 @@ function Be({ image: e, imageUrl: s, imageVisible: c = !0, maskDataUrl: l, regio
|
|
|
895
896
|
/* @__PURE__ */ x(a, {
|
|
896
897
|
variant: "ghost",
|
|
897
898
|
size: "icon-sm",
|
|
898
|
-
"aria-label":
|
|
899
|
-
onClick: () =>
|
|
899
|
+
"aria-label": k.zoomOut,
|
|
900
|
+
onClick: () => te(1 / 1.2),
|
|
901
|
+
disabled: l,
|
|
900
902
|
children: /* @__PURE__ */ x(r, { size: 16 })
|
|
901
903
|
}),
|
|
902
904
|
/* @__PURE__ */ x(a, {
|
|
903
905
|
variant: "ghost",
|
|
904
906
|
size: "sm",
|
|
905
|
-
"aria-label":
|
|
906
|
-
onClick:
|
|
907
|
+
"aria-label": k.zoom100,
|
|
908
|
+
onClick: b,
|
|
909
|
+
disabled: l,
|
|
907
910
|
className: "aivex:min-w-[44px] aivex:px-1 aivex:tabular-nums",
|
|
908
911
|
children: /* @__PURE__ */ x("span", {
|
|
909
|
-
ref:
|
|
912
|
+
ref: y,
|
|
910
913
|
children: "100%"
|
|
911
914
|
})
|
|
912
915
|
}),
|
|
913
916
|
/* @__PURE__ */ x(a, {
|
|
914
917
|
variant: "ghost",
|
|
915
918
|
size: "icon-sm",
|
|
916
|
-
"aria-label":
|
|
917
|
-
onClick: () =>
|
|
919
|
+
"aria-label": k.zoomIn,
|
|
920
|
+
onClick: () => te(1.2),
|
|
921
|
+
disabled: l,
|
|
918
922
|
children: /* @__PURE__ */ x(o, { size: 16 })
|
|
919
923
|
})
|
|
920
924
|
]
|
|
921
925
|
}), /* @__PURE__ */ S("div", {
|
|
922
926
|
className: "aivex:relative aivex:flex aivex:items-center aivex:gap-0.5",
|
|
923
927
|
children: [
|
|
924
|
-
|
|
928
|
+
T && /* @__PURE__ */ x(a, {
|
|
925
929
|
variant: "ghost",
|
|
926
930
|
size: "icon-sm",
|
|
927
|
-
"aria-label":
|
|
928
|
-
onClick:
|
|
931
|
+
"aria-label": k.viewSettings,
|
|
932
|
+
onClick: D,
|
|
929
933
|
onPointerDown: (e) => e.stopPropagation(),
|
|
930
|
-
className:
|
|
934
|
+
className: E ? "aivex:text-text-brand" : void 0,
|
|
931
935
|
children: /* @__PURE__ */ x(n, { size: 16 })
|
|
932
936
|
}),
|
|
933
937
|
/* @__PURE__ */ x(a, {
|
|
934
938
|
variant: "ghost",
|
|
935
939
|
size: "icon-sm",
|
|
936
|
-
"aria-label":
|
|
940
|
+
"aria-label": k.toggleMinimap,
|
|
937
941
|
title: "(M)",
|
|
938
|
-
onClick:
|
|
939
|
-
children: x(
|
|
942
|
+
onClick: w,
|
|
943
|
+
children: x(C ? i : t, { size: 16 })
|
|
940
944
|
}),
|
|
941
|
-
|
|
942
|
-
value:
|
|
943
|
-
onChange:
|
|
944
|
-
onClose:
|
|
945
|
-
labels:
|
|
945
|
+
T && E && /* @__PURE__ */ x(Re, {
|
|
946
|
+
value: m,
|
|
947
|
+
onChange: h,
|
|
948
|
+
onClose: O,
|
|
949
|
+
labels: A
|
|
946
950
|
})
|
|
947
951
|
]
|
|
948
952
|
})]
|
|
@@ -960,20 +964,34 @@ var Ve = "var(--editor-overlay-inverse-scale, 1)", He = 6, G = {
|
|
|
960
964
|
textShadow: "0 0 4px #000, 0 0 4px #000",
|
|
961
965
|
whiteSpace: "nowrap"
|
|
962
966
|
};
|
|
963
|
-
function Ue(e
|
|
964
|
-
let
|
|
967
|
+
function Ue(e) {
|
|
968
|
+
let t = I(e);
|
|
965
969
|
return {
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
height: n.maxY - n.minY
|
|
970
|
+
x: t.minX,
|
|
971
|
+
y: t.minY,
|
|
972
|
+
width: t.maxX - t.minX,
|
|
973
|
+
height: t.maxY - t.minY
|
|
971
974
|
};
|
|
972
975
|
}
|
|
973
976
|
function We(e) {
|
|
977
|
+
return `translate3d(${e.width}px, ${e.height}px, 0) scale(${Ve}) translate(-100%, ${He}px)`;
|
|
978
|
+
}
|
|
979
|
+
function Ge(e, t) {
|
|
980
|
+
let n = Ue(t);
|
|
981
|
+
e.style.transform = `translate3d(${n.x}px, ${n.y}px, 0)`;
|
|
982
|
+
let r = e.querySelector("[data-selinfo-dim]");
|
|
983
|
+
return r && (r.style.transform = We(n)), r;
|
|
984
|
+
}
|
|
985
|
+
function Ke(e, t) {
|
|
986
|
+
return {
|
|
987
|
+
shape: e,
|
|
988
|
+
...Ue(t)
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
function qe(e) {
|
|
974
992
|
return `${Math.round(e.width)} x ${Math.round(e.height)} px`;
|
|
975
993
|
}
|
|
976
|
-
function
|
|
994
|
+
function Je({ color: e, striped: t }) {
|
|
977
995
|
return /* @__PURE__ */ x("span", { style: {
|
|
978
996
|
display: "inline-block",
|
|
979
997
|
width: 12,
|
|
@@ -985,17 +1003,17 @@ function Ge({ color: e, striped: t }) {
|
|
|
985
1003
|
} : { background: e }
|
|
986
1004
|
} });
|
|
987
1005
|
}
|
|
988
|
-
function
|
|
1006
|
+
function Ye({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i }) {
|
|
989
1007
|
return /* @__PURE__ */ x(b, { children: e.map((e) => {
|
|
990
|
-
let a =
|
|
1008
|
+
let a = Ue(e.points), o = e.type === j.POINT, s = o ? void 0 : t?.(e), c = e.style?.color ?? "#00e5ff", l = !!e.readOnly || !!e.style?.dash, u = Ke(e, e.points), d = r ? r(u) : qe(u);
|
|
991
1009
|
return /* @__PURE__ */ S("div", {
|
|
992
1010
|
ref: (t) => i(e.id, t),
|
|
993
1011
|
style: {
|
|
994
1012
|
position: "absolute",
|
|
995
|
-
left:
|
|
996
|
-
top:
|
|
997
|
-
|
|
998
|
-
|
|
1013
|
+
left: 0,
|
|
1014
|
+
top: 0,
|
|
1015
|
+
transform: `translate3d(${a.x}px, ${a.y}px, 0)`,
|
|
1016
|
+
willChange: "transform",
|
|
999
1017
|
pointerEvents: "none"
|
|
1000
1018
|
},
|
|
1001
1019
|
children: [!!s && /* @__PURE__ */ S("div", {
|
|
@@ -1010,7 +1028,7 @@ function Ke({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1010
1028
|
transformOrigin: "left top",
|
|
1011
1029
|
...G
|
|
1012
1030
|
},
|
|
1013
|
-
children: [!n && /* @__PURE__ */ x(
|
|
1031
|
+
children: [!n && /* @__PURE__ */ x(Je, {
|
|
1014
1032
|
color: c,
|
|
1015
1033
|
striped: l
|
|
1016
1034
|
}), /* @__PURE__ */ x("span", { children: s })]
|
|
@@ -1018,10 +1036,11 @@ function Ke({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1018
1036
|
"data-selinfo-dim": !0,
|
|
1019
1037
|
style: {
|
|
1020
1038
|
position: "absolute",
|
|
1021
|
-
|
|
1022
|
-
top:
|
|
1023
|
-
transform:
|
|
1024
|
-
transformOrigin: "
|
|
1039
|
+
left: 0,
|
|
1040
|
+
top: 0,
|
|
1041
|
+
transform: We(a),
|
|
1042
|
+
transformOrigin: "left top",
|
|
1043
|
+
willChange: "transform",
|
|
1025
1044
|
...G
|
|
1026
1045
|
},
|
|
1027
1046
|
children: d
|
|
@@ -1030,8 +1049,88 @@ function Ke({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1030
1049
|
}) });
|
|
1031
1050
|
}
|
|
1032
1051
|
//#endregion
|
|
1052
|
+
//#region src/components/ShapeEditor/_model/clipboard.ts
|
|
1053
|
+
var Xe = "AIVEX_SHAPE_EDITOR:", Ze = 1, Qe = new Set(Object.values(j)), $e = null, et = "unavailable", tt = 0;
|
|
1054
|
+
function nt(e) {
|
|
1055
|
+
if (!e || typeof e != "object") return !1;
|
|
1056
|
+
let t = e;
|
|
1057
|
+
return Number.isFinite(t.x) && Number.isFinite(t.y);
|
|
1058
|
+
}
|
|
1059
|
+
function rt(e) {
|
|
1060
|
+
if (!e || typeof e != "object") return !1;
|
|
1061
|
+
let t = e;
|
|
1062
|
+
return typeof t.type == "string" && Qe.has(t.type) && Array.isArray(t.points) && t.points.length > 0 && t.points.every(nt);
|
|
1063
|
+
}
|
|
1064
|
+
function it(e, t, n) {
|
|
1065
|
+
return {
|
|
1066
|
+
kind: "aivex-shape-editor",
|
|
1067
|
+
version: Ze,
|
|
1068
|
+
scope: n,
|
|
1069
|
+
documentId: t,
|
|
1070
|
+
shapes: e
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
function at(e) {
|
|
1074
|
+
let t = 2166136261;
|
|
1075
|
+
for (let n = 0; n < e.length; n += 1) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
1076
|
+
return `fnv1a:${(t >>> 0).toString(36)}`;
|
|
1077
|
+
}
|
|
1078
|
+
function K(e) {
|
|
1079
|
+
return `${Xe}${JSON.stringify(e)}`;
|
|
1080
|
+
}
|
|
1081
|
+
function ot(e) {
|
|
1082
|
+
if (!e.startsWith(Xe)) return null;
|
|
1083
|
+
try {
|
|
1084
|
+
let t = JSON.parse(e.slice(19));
|
|
1085
|
+
return t.kind !== "aivex-shape-editor" || t.version !== Ze || !Array.isArray(t.shapes) || t.shapes.length === 0 || !t.shapes.every(rt) || t.scope !== void 0 && typeof t.scope != "string" || t.documentId !== void 0 && typeof t.documentId != "string" ? null : t;
|
|
1086
|
+
} catch {
|
|
1087
|
+
return null;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
function st(e) {
|
|
1091
|
+
$e = e;
|
|
1092
|
+
let t = ++tt;
|
|
1093
|
+
if (typeof navigator > "u" || !navigator.clipboard?.writeText) {
|
|
1094
|
+
et = "unavailable";
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
let n;
|
|
1098
|
+
try {
|
|
1099
|
+
n = K(e);
|
|
1100
|
+
} catch {
|
|
1101
|
+
et = "unavailable";
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
et = "pending", navigator.clipboard.writeText(n).then(() => {
|
|
1105
|
+
t === tt && (et = "written");
|
|
1106
|
+
}, () => {
|
|
1107
|
+
t === tt && (et = "unavailable");
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
function q(e, t) {
|
|
1111
|
+
return !!e && e.scope === t;
|
|
1112
|
+
}
|
|
1113
|
+
function ct(e) {
|
|
1114
|
+
return q($e, e) || typeof navigator < "u" && typeof navigator.clipboard?.readText == "function";
|
|
1115
|
+
}
|
|
1116
|
+
async function lt(e) {
|
|
1117
|
+
let t = q($e, e) ? $e : null;
|
|
1118
|
+
if (t && et !== "written") return t;
|
|
1119
|
+
if (typeof navigator < "u" && navigator.clipboard?.readText) try {
|
|
1120
|
+
let t = ot(await navigator.clipboard.readText());
|
|
1121
|
+
return t?.scope === e ? ($e = t, t) : null;
|
|
1122
|
+
} catch {}
|
|
1123
|
+
return t;
|
|
1124
|
+
}
|
|
1125
|
+
function ut(e, t, n) {
|
|
1126
|
+
return {
|
|
1127
|
+
offset: n * (t ? e : e + 1),
|
|
1128
|
+
nextPasteCount: e + 1
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
//#endregion
|
|
1033
1132
|
//#region src/components/ShapeEditor/_model/cursors.ts
|
|
1034
|
-
var
|
|
1133
|
+
var dt = new Set([
|
|
1035
1134
|
H.RECTANGLE,
|
|
1036
1135
|
H.ROTATED_RECTANGLE,
|
|
1037
1136
|
H.CIRCLE,
|
|
@@ -1042,7 +1141,7 @@ var qe = new Set([
|
|
|
1042
1141
|
H.ASSISTANT_POLYGON,
|
|
1043
1142
|
H.ASSISTANT_RECT,
|
|
1044
1143
|
H.ASSISTANT_POINT
|
|
1045
|
-
]),
|
|
1144
|
+
]), J = {
|
|
1046
1145
|
tl: -135,
|
|
1047
1146
|
t: -90,
|
|
1048
1147
|
tr: -45,
|
|
@@ -1051,21 +1150,21 @@ var qe = new Set([
|
|
|
1051
1150
|
b: 90,
|
|
1052
1151
|
bl: 135,
|
|
1053
1152
|
l: 180
|
|
1054
|
-
},
|
|
1153
|
+
}, ft = [
|
|
1055
1154
|
"ew-resize",
|
|
1056
1155
|
"nwse-resize",
|
|
1057
1156
|
"ns-resize",
|
|
1058
1157
|
"nesw-resize"
|
|
1059
1158
|
];
|
|
1060
|
-
function
|
|
1061
|
-
let n = ((
|
|
1062
|
-
return
|
|
1159
|
+
function pt(e, t = 0) {
|
|
1160
|
+
let n = ((J[e] + t * 180 / Math.PI) % 180 + 180) % 180;
|
|
1161
|
+
return ft[Math.round(n / 45) % 4];
|
|
1063
1162
|
}
|
|
1064
|
-
function
|
|
1065
|
-
return n ? "grab" : t || (e === H.SELECT ? "default" :
|
|
1163
|
+
function Y({ tool: e, externalToolCursor: t, isSpacePressed: n, isPolygonDrawing: r }) {
|
|
1164
|
+
return n ? "grab" : t || (e === H.SELECT ? "default" : dt.has(e) ? r ? "default" : "crosshair" : "default");
|
|
1066
1165
|
}
|
|
1067
|
-
function
|
|
1068
|
-
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e === H.SELECT && i ? i :
|
|
1166
|
+
function mt({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode: r, rendererCursorHint: i, isPolygonDrawing: a }) {
|
|
1167
|
+
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e === H.SELECT && i ? i : Y({
|
|
1069
1168
|
tool: e,
|
|
1070
1169
|
externalToolCursor: t,
|
|
1071
1170
|
isSpacePressed: n,
|
|
@@ -1074,7 +1173,7 @@ function Qe({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode
|
|
|
1074
1173
|
}
|
|
1075
1174
|
//#endregion
|
|
1076
1175
|
//#region src/components/ShapeEditor/_model/overlays.ts
|
|
1077
|
-
var
|
|
1176
|
+
var ht = (e) => Math.min(255, Math.max(0, e)), gt = (e) => {
|
|
1078
1177
|
let t = e.replace("#", "").trim();
|
|
1079
1178
|
if (![
|
|
1080
1179
|
3,
|
|
@@ -1088,13 +1187,13 @@ var $e = (e) => Math.min(255, Math.max(0, e)), et = (e) => {
|
|
|
1088
1187
|
c(o),
|
|
1089
1188
|
c(s)
|
|
1090
1189
|
];
|
|
1091
|
-
return l.some((e) => Number.isNaN(e)) ? null : l.map(
|
|
1092
|
-
},
|
|
1190
|
+
return l.some((e) => Number.isNaN(e)) ? null : l.map(ht);
|
|
1191
|
+
}, _t = (e, t) => {
|
|
1093
1192
|
let { width: n, height: r, indices: i, transparent: a } = e;
|
|
1094
1193
|
if (!n || !r || i.length < n * r) return null;
|
|
1095
1194
|
let o = {};
|
|
1096
1195
|
for (let [e, n] of Object.entries(t)) {
|
|
1097
|
-
let t =
|
|
1196
|
+
let t = gt(n);
|
|
1098
1197
|
t && (o[Number(e)] = t);
|
|
1099
1198
|
}
|
|
1100
1199
|
if (!Object.keys(o).length) return null;
|
|
@@ -1113,12 +1212,12 @@ var $e = (e) => Math.min(255, Math.max(0, e)), et = (e) => {
|
|
|
1113
1212
|
}
|
|
1114
1213
|
return c.putImageData(new ImageData(l, n, r), 0, 0), s;
|
|
1115
1214
|
};
|
|
1116
|
-
function
|
|
1215
|
+
function vt(e, t) {
|
|
1117
1216
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
1118
1217
|
for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
|
|
1119
1218
|
e.closePath();
|
|
1120
1219
|
}
|
|
1121
|
-
var
|
|
1220
|
+
var yt = (e) => [
|
|
1122
1221
|
{
|
|
1123
1222
|
x: e.x,
|
|
1124
1223
|
y: e.y
|
|
@@ -1136,7 +1235,7 @@ var rt = (e) => [
|
|
|
1136
1235
|
y: e.y + e.h
|
|
1137
1236
|
}
|
|
1138
1237
|
];
|
|
1139
|
-
function
|
|
1238
|
+
function bt(e, t) {
|
|
1140
1239
|
let n = !1;
|
|
1141
1240
|
for (let r = 0, i = t.length - 1; r < t.length; i = r, r += 1) {
|
|
1142
1241
|
let a = t[r], o = t[i];
|
|
@@ -1147,7 +1246,7 @@ function it(e, t) {
|
|
|
1147
1246
|
}
|
|
1148
1247
|
return n;
|
|
1149
1248
|
}
|
|
1150
|
-
function
|
|
1249
|
+
function xt(e, t, n) {
|
|
1151
1250
|
let r = [], i = t.x - e.x, a = t.y - e.y;
|
|
1152
1251
|
for (let t = 0; t < n.length; t += 1) {
|
|
1153
1252
|
let o = n[t], s = n[(t + 1) % n.length], c = s.x - o.x, l = s.y - o.y, u = i * l - a * c;
|
|
@@ -1157,15 +1256,15 @@ function at(e, t, n) {
|
|
|
1157
1256
|
}
|
|
1158
1257
|
return r;
|
|
1159
1258
|
}
|
|
1160
|
-
function
|
|
1259
|
+
function St(e, t, n) {
|
|
1161
1260
|
let r = .001, i = [], a = (e, t, n) => ({
|
|
1162
1261
|
x: e.x + (t.x - e.x) * n,
|
|
1163
1262
|
y: e.y + (t.y - e.y) * n
|
|
1164
1263
|
});
|
|
1165
1264
|
for (let o of e) if (!(o.length < 2)) for (let e = 0; e < o.length; e += 1) {
|
|
1166
1265
|
let s = o[e], c = o[(e + 1) % o.length], l = [0, 1];
|
|
1167
|
-
for (let e of t) e !== o && l.push(...
|
|
1168
|
-
if (n) for (let e of n) l.push(...
|
|
1266
|
+
for (let e of t) e !== o && l.push(...xt(s, c, e));
|
|
1267
|
+
if (n) for (let e of n) l.push(...xt(s, c, e));
|
|
1169
1268
|
let u = Math.hypot(c.x - s.x, c.y - s.y);
|
|
1170
1269
|
if (!u) continue;
|
|
1171
1270
|
let d = -(c.y - s.y) / u * r, f = (c.x - s.x) / u * r;
|
|
@@ -1179,13 +1278,13 @@ function K(e, t, n) {
|
|
|
1179
1278
|
}, h = {
|
|
1180
1279
|
x: p.x - d,
|
|
1181
1280
|
y: p.y - f
|
|
1182
|
-
}, g =
|
|
1183
|
-
t.some((e) => e !== o &&
|
|
1281
|
+
}, g = bt(m, o) ? m : h, _ = g === m ? h : m;
|
|
1282
|
+
t.some((e) => e !== o && bt(_, e)) || n && !n.some((e) => bt(g, e)) || i.push([a(s, c, r), a(s, c, u)]);
|
|
1184
1283
|
}
|
|
1185
1284
|
}
|
|
1186
1285
|
return i;
|
|
1187
1286
|
}
|
|
1188
|
-
function
|
|
1287
|
+
function Ct(e) {
|
|
1189
1288
|
let t = [...new Set(e.flatMap((e) => [e.x, e.x + e.w]))].sort((e, t) => e - t), n = [];
|
|
1190
1289
|
for (let r = 0; r + 1 < t.length; r += 1) {
|
|
1191
1290
|
let i = t[r], a = t[r + 1];
|
|
@@ -1206,38 +1305,38 @@ function ot(e) {
|
|
|
1206
1305
|
}
|
|
1207
1306
|
return n;
|
|
1208
1307
|
}
|
|
1209
|
-
function
|
|
1308
|
+
function wt(e, t, n, r) {
|
|
1210
1309
|
e.save(), e.globalAlpha *= t.dim.opacity, e.fillStyle = t.dim.color, e.beginPath(), e.rect(0, 0, n, r);
|
|
1211
1310
|
for (let n of t.dimHoles) e.moveTo(n.x, n.y), e.lineTo(n.x, n.y + n.h), e.lineTo(n.x + n.w, n.y + n.h), e.lineTo(n.x + n.w, n.y), e.closePath();
|
|
1212
1311
|
if (e.fill(), t.zones.length) {
|
|
1213
1312
|
e.beginPath();
|
|
1214
1313
|
for (let n of t.rects) e.rect(n.x, n.y, n.w, n.h);
|
|
1215
1314
|
e.clip();
|
|
1216
|
-
for (let n of t.zones)
|
|
1315
|
+
for (let n of t.zones) vt(e, n.points), e.fill();
|
|
1217
1316
|
}
|
|
1218
1317
|
e.restore();
|
|
1219
1318
|
}
|
|
1220
|
-
function
|
|
1319
|
+
function Tt(e) {
|
|
1221
1320
|
let t = [];
|
|
1222
1321
|
for (let n of e) if (!(n.length < 2)) for (let e = 0; e < n.length; e += 1) t.push([n[e], n[(e + 1) % n.length]]);
|
|
1223
1322
|
return t;
|
|
1224
1323
|
}
|
|
1225
|
-
var
|
|
1324
|
+
var Et = {
|
|
1226
1325
|
color: "#000000",
|
|
1227
1326
|
opacity: .5
|
|
1228
|
-
},
|
|
1327
|
+
}, Dt = {
|
|
1229
1328
|
color: "#ffffff",
|
|
1230
1329
|
opacity: 1,
|
|
1231
1330
|
width: 2,
|
|
1232
1331
|
dash: [6, 6],
|
|
1233
1332
|
underlayColor: "#000000"
|
|
1234
|
-
},
|
|
1333
|
+
}, Ot = {
|
|
1235
1334
|
color: "#dc2626",
|
|
1236
1335
|
opacity: .8,
|
|
1237
1336
|
width: 2,
|
|
1238
1337
|
dash: [6, 6],
|
|
1239
1338
|
underlayColor: "#000000"
|
|
1240
|
-
},
|
|
1339
|
+
}, kt = (e, t, n) => {
|
|
1241
1340
|
let r = e.occludedAreas?.filter((e) => e.points.length >= 3) ?? [];
|
|
1242
1341
|
if (!t || !n || !e.visibleAreas.length && !r.length) return null;
|
|
1243
1342
|
let i = e.visibleAreas, a = i.length ? i : [{
|
|
@@ -1245,8 +1344,8 @@ var ct = {
|
|
|
1245
1344
|
y: 0,
|
|
1246
1345
|
w: t,
|
|
1247
1346
|
h: n
|
|
1248
|
-
}], o =
|
|
1249
|
-
...
|
|
1347
|
+
}], o = Ct(a), s = {
|
|
1348
|
+
...Et,
|
|
1250
1349
|
...e.dim
|
|
1251
1350
|
}, c = e.outline;
|
|
1252
1351
|
if (c === !1) return {
|
|
@@ -1260,36 +1359,36 @@ var ct = {
|
|
|
1260
1359
|
};
|
|
1261
1360
|
let l = {
|
|
1262
1361
|
visible: {
|
|
1263
|
-
...
|
|
1362
|
+
...Dt,
|
|
1264
1363
|
...c?.visibleStyle
|
|
1265
1364
|
},
|
|
1266
1365
|
occluded: {
|
|
1267
|
-
...
|
|
1366
|
+
...Ot,
|
|
1268
1367
|
...c?.occludedStyle
|
|
1269
1368
|
}
|
|
1270
|
-
}, u = i.map(
|
|
1369
|
+
}, u = i.map(yt), d = a.map(yt), f = r.map((e) => e.points);
|
|
1271
1370
|
return c?.mode === "separate" ? {
|
|
1272
1371
|
rects: a,
|
|
1273
1372
|
zones: r,
|
|
1274
1373
|
dimHoles: o,
|
|
1275
1374
|
dim: s,
|
|
1276
|
-
visibleOutline:
|
|
1277
|
-
occludedOutline:
|
|
1375
|
+
visibleOutline: Tt(u),
|
|
1376
|
+
occludedOutline: Tt(f),
|
|
1278
1377
|
outlineStyles: l
|
|
1279
1378
|
} : {
|
|
1280
1379
|
rects: a,
|
|
1281
1380
|
zones: r,
|
|
1282
1381
|
dimHoles: o,
|
|
1283
1382
|
dim: s,
|
|
1284
|
-
visibleOutline: [...
|
|
1383
|
+
visibleOutline: [...St(u, [...u, ...f], null), ...St(f, f, d)],
|
|
1285
1384
|
occludedOutline: [],
|
|
1286
1385
|
outlineStyles: l
|
|
1287
1386
|
};
|
|
1288
|
-
},
|
|
1289
|
-
function
|
|
1387
|
+
}, At = .3, jt = .05;
|
|
1388
|
+
function Mt(e) {
|
|
1290
1389
|
return 1 - (1 - e) ** 3;
|
|
1291
1390
|
}
|
|
1292
|
-
function
|
|
1391
|
+
function Nt(e) {
|
|
1293
1392
|
return {
|
|
1294
1393
|
x: e.minX,
|
|
1295
1394
|
y: e.minY,
|
|
@@ -1297,7 +1396,7 @@ function mt(e) {
|
|
|
1297
1396
|
height: Math.max(0, e.maxY - e.minY)
|
|
1298
1397
|
};
|
|
1299
1398
|
}
|
|
1300
|
-
function
|
|
1399
|
+
function X(e, t) {
|
|
1301
1400
|
if (!t.length) return null;
|
|
1302
1401
|
if (e === j.POINT) {
|
|
1303
1402
|
let e = t[0];
|
|
@@ -1316,10 +1415,10 @@ function Y(e, t) {
|
|
|
1316
1415
|
height: i
|
|
1317
1416
|
};
|
|
1318
1417
|
}
|
|
1319
|
-
function
|
|
1418
|
+
function Pt(e) {
|
|
1320
1419
|
if (!e.length) return null;
|
|
1321
|
-
let t = e.map((e) =>
|
|
1322
|
-
return t.length ?
|
|
1420
|
+
let t = e.map((e) => X(e.type, e.points)).filter((e) => e !== null);
|
|
1421
|
+
return t.length ? Nt(I(t.flatMap((e) => [{
|
|
1323
1422
|
x: e.x,
|
|
1324
1423
|
y: e.y
|
|
1325
1424
|
}, {
|
|
@@ -1327,8 +1426,8 @@ function ht(e) {
|
|
|
1327
1426
|
y: e.y + e.height
|
|
1328
1427
|
}]))) : null;
|
|
1329
1428
|
}
|
|
1330
|
-
function
|
|
1331
|
-
let { containerRatio: i =
|
|
1429
|
+
function Ft(e, t, n, r = {}) {
|
|
1430
|
+
let { containerRatio: i = At, minScale: a = jt, maxScale: o = 20 } = r;
|
|
1332
1431
|
if (!t || !n || e.width <= 0 || e.height <= 0) return null;
|
|
1333
1432
|
let s = Math.min(t * i / e.width, n * i / e.height), c = Math.max(a, Math.min(o, s)), l = e.x + e.width / 2, u = e.y + e.height / 2;
|
|
1334
1433
|
return {
|
|
@@ -1337,18 +1436,18 @@ function gt(e, t, n, r = {}) {
|
|
|
1337
1436
|
y: n / 2 - u * c
|
|
1338
1437
|
};
|
|
1339
1438
|
}
|
|
1340
|
-
function
|
|
1439
|
+
function It(e, t, n, r = 80) {
|
|
1341
1440
|
if (!t || !n) return null;
|
|
1342
|
-
let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(
|
|
1441
|
+
let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(jt, Math.min(20, Math.min((t - r) / i, (n - r) / a))), s = (e.minX + e.maxX) / 2, c = (e.minY + e.maxY) / 2;
|
|
1343
1442
|
return {
|
|
1344
1443
|
scale: o,
|
|
1345
1444
|
x: t / 2 - s * o,
|
|
1346
1445
|
y: n / 2 - c * o
|
|
1347
1446
|
};
|
|
1348
1447
|
}
|
|
1349
|
-
function
|
|
1448
|
+
function Lt(e, t, n, r = 300) {
|
|
1350
1449
|
let i = Date.now(), a = 0, o = () => {
|
|
1351
|
-
let s = Date.now() - i, c = Math.min(s / r, 1), l =
|
|
1450
|
+
let s = Date.now() - i, c = Math.min(s / r, 1), l = Mt(c);
|
|
1352
1451
|
n({
|
|
1353
1452
|
scale: e.scale + (t.scale - e.scale) * l,
|
|
1354
1453
|
x: e.x + (t.x - e.x) * l,
|
|
@@ -1359,7 +1458,7 @@ function vt(e, t, n, r = 300) {
|
|
|
1359
1458
|
}
|
|
1360
1459
|
//#endregion
|
|
1361
1460
|
//#region src/components/ShapeEditor/_state/createInteractionController.ts
|
|
1362
|
-
function
|
|
1461
|
+
function Rt(e) {
|
|
1363
1462
|
let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, shiftRef: a, docRef: o, selRef: s, draftRef: c, readOnlyRef: l, disableMarqueeRef: u, lockedRef: d, onLockedInteraction: f, createRef: p, selectRef: m, enterEditRef: h, drawSessionRef: g, assistantRef: _, setCursorHint: v, setInteractionMode: y, syncMinimap: b, onTransformPreview: x, onDrawPreview: S } = e, C = () => g.current, w = () => _.current, T = null, E = null, D = null, O = null, k = null, A = "", M = null, N = (e) => e === H.RECTANGLE || e === H.ROTATED_RECTANGLE || e === H.CIRCLE, ee = (e) => e === H.ASSISTANT_POLYGON || e === H.ASSISTANT_RECT, re = (e) => e === H.POLYGON, F = () => r.current.get(n.current), ie = (e, t, n, r) => ({
|
|
1364
1463
|
point: t,
|
|
1365
1464
|
targetId: r,
|
|
@@ -1383,7 +1482,13 @@ function yt(e) {
|
|
|
1383
1482
|
};
|
|
1384
1483
|
return;
|
|
1385
1484
|
}
|
|
1386
|
-
if (u.button === 2 && !(g === H.ASSISTANT_POINT && u.altKey))
|
|
1485
|
+
if (u.button === 2 && !(g === H.ASSISTANT_POINT && u.altKey)) {
|
|
1486
|
+
if (r && !s.current.includes(r)) {
|
|
1487
|
+
let e = o.current.getShapes().find((e) => e.id === r);
|
|
1488
|
+
e && P(e) && m.current([r]);
|
|
1489
|
+
}
|
|
1490
|
+
return;
|
|
1491
|
+
}
|
|
1387
1492
|
let _ = F();
|
|
1388
1493
|
if (_) {
|
|
1389
1494
|
C().reset(), m.current([]), _.onPointerDown?.(ie(p, e, u, r));
|
|
@@ -1597,7 +1702,7 @@ function yt(e) {
|
|
|
1597
1702
|
}
|
|
1598
1703
|
//#endregion
|
|
1599
1704
|
//#region src/components/ShapeEditor/_state/useAssistant.ts
|
|
1600
|
-
function
|
|
1705
|
+
function zt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistantRef: i }) {
|
|
1601
1706
|
let [a, o] = y("idle"), [s, c] = y([]), [l, u] = y([]), f = v([]), p = v([]), m = v([]), h = v("idle"), g = v(0), _ = v(null), b = v(null), x = v(0), S = d((e) => {
|
|
1602
1707
|
f.current = e(f.current), u(f.current);
|
|
1603
1708
|
}, []), C = d((e) => {
|
|
@@ -1762,17 +1867,17 @@ function bt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
1762
1867
|
}
|
|
1763
1868
|
//#endregion
|
|
1764
1869
|
//#region src/components/ShapeEditor/_model/brush.ts
|
|
1765
|
-
function
|
|
1870
|
+
function Bt(e, t, n) {
|
|
1766
1871
|
let r = Math.abs(.5 * (t.x * n.y + n.x * e.y + e.x * t.y - n.x * t.y - e.x * n.y - t.x * e.y)), i = Math.hypot(t.x - n.x, t.y - n.y);
|
|
1767
1872
|
return i === 0 ? 0 : r * 2 / i;
|
|
1768
1873
|
}
|
|
1769
|
-
function
|
|
1874
|
+
function Vt(e, t = 1.5) {
|
|
1770
1875
|
if (e.length <= 2) return e;
|
|
1771
1876
|
let n = (e, t) => {
|
|
1772
1877
|
if (e.length < 3) return e;
|
|
1773
1878
|
let r = 0, i = 0, a = e.length - 1;
|
|
1774
1879
|
for (let t = 1; t < a; t++) {
|
|
1775
|
-
let n =
|
|
1880
|
+
let n = Bt(e[t], e[0], e[a]);
|
|
1776
1881
|
n > r && (i = t, r = n);
|
|
1777
1882
|
}
|
|
1778
1883
|
if (r > t) {
|
|
@@ -1785,8 +1890,8 @@ function St(e, t = 1.5) {
|
|
|
1785
1890
|
}
|
|
1786
1891
|
//#endregion
|
|
1787
1892
|
//#region src/components/ShapeEditor/_model/scalarMask.ts
|
|
1788
|
-
var
|
|
1789
|
-
function
|
|
1893
|
+
var Ht = 4096, Ut = 4;
|
|
1894
|
+
function Wt(e) {
|
|
1790
1895
|
let t = 0;
|
|
1791
1896
|
for (let n = 0; n < e.length; n++) {
|
|
1792
1897
|
let r = e[n], i = e[(n + 1) % e.length];
|
|
@@ -1794,17 +1899,17 @@ function Tt(e) {
|
|
|
1794
1899
|
}
|
|
1795
1900
|
return Math.abs(t / 2);
|
|
1796
1901
|
}
|
|
1797
|
-
function
|
|
1902
|
+
function Gt(e, t, n) {
|
|
1798
1903
|
let r = new Uint8Array(t * n);
|
|
1799
1904
|
for (let i = 0; i < t * n; i++) r[i] = e[i * 4 + 3] > 128 ? 255 : 0;
|
|
1800
1905
|
return r;
|
|
1801
1906
|
}
|
|
1802
|
-
function
|
|
1907
|
+
function Kt(e) {
|
|
1803
1908
|
let t = new Uint8ClampedArray(e.length * 4);
|
|
1804
1909
|
for (let n = 0; n < e.length; n++) e[n] > 128 && (t[n * 4 + 3] = 255);
|
|
1805
1910
|
return t;
|
|
1806
1911
|
}
|
|
1807
|
-
function
|
|
1912
|
+
function qt(e, t, n, r, i) {
|
|
1808
1913
|
let a = new Uint8Array(t * n), o = [[r, i]];
|
|
1809
1914
|
for (; o.length;) {
|
|
1810
1915
|
let [r, i] = o.pop(), s = i * t + r;
|
|
@@ -1812,8 +1917,8 @@ function Ot(e, t, n, r, i) {
|
|
|
1812
1917
|
}
|
|
1813
1918
|
return a;
|
|
1814
1919
|
}
|
|
1815
|
-
function
|
|
1816
|
-
let r =
|
|
1920
|
+
function Jt(e, t, n) {
|
|
1921
|
+
let r = Gt(e, t, n), i = [];
|
|
1817
1922
|
for (;;) {
|
|
1818
1923
|
let e = -1, a = -1;
|
|
1819
1924
|
outer: for (let i = 0; i < n; i++) for (let n = 0; n < t; n++) if (r[i * t + n] > 128) {
|
|
@@ -1821,17 +1926,17 @@ function kt(e, t, n) {
|
|
|
1821
1926
|
break outer;
|
|
1822
1927
|
}
|
|
1823
1928
|
if (e < 0) break;
|
|
1824
|
-
let o =
|
|
1929
|
+
let o = Xt(Kt(qt(r, t, n, e, a)), t, n);
|
|
1825
1930
|
o.length >= 3 && i.push(o);
|
|
1826
1931
|
}
|
|
1827
1932
|
return i;
|
|
1828
1933
|
}
|
|
1829
|
-
function
|
|
1934
|
+
function Yt(e, t, n, r, i) {
|
|
1830
1935
|
return r < 0 || i < 0 || r >= t || i >= n ? !1 : e[(i * t + r) * 4 + 3] > 128;
|
|
1831
1936
|
}
|
|
1832
|
-
function
|
|
1937
|
+
function Xt(e, t, n) {
|
|
1833
1938
|
let r = -1, i = -1;
|
|
1834
|
-
outer: for (let a = 0; a < n; a++) for (let o = 0; o < t; o++) if (
|
|
1939
|
+
outer: for (let a = 0; a < n; a++) for (let o = 0; o < t; o++) if (Yt(e, t, n, o, a)) {
|
|
1835
1940
|
r = o, i = a;
|
|
1836
1941
|
break outer;
|
|
1837
1942
|
}
|
|
@@ -1866,7 +1971,7 @@ function jt(e, t, n) {
|
|
|
1866
1971
|
let r = !1;
|
|
1867
1972
|
for (let i = 0; i < 8; i++) {
|
|
1868
1973
|
let s = (u + i) % 8, d = c + a[s], f = l + o[s];
|
|
1869
|
-
if (
|
|
1974
|
+
if (Yt(e, t, n, d, f)) {
|
|
1870
1975
|
c = d, l = f, u = (s + 6) % 8, r = !0;
|
|
1871
1976
|
break;
|
|
1872
1977
|
}
|
|
@@ -1875,13 +1980,13 @@ function jt(e, t, n) {
|
|
|
1875
1980
|
} while (c !== d.x || l !== d.y || s.length === 1);
|
|
1876
1981
|
return s;
|
|
1877
1982
|
}
|
|
1878
|
-
function
|
|
1983
|
+
function Zt(e, t) {
|
|
1879
1984
|
let n = [];
|
|
1880
1985
|
for (let t of e) for (let e of t.points) n.push(e);
|
|
1881
1986
|
for (let e of t) for (let t of e) n.push(t);
|
|
1882
1987
|
return n;
|
|
1883
1988
|
}
|
|
1884
|
-
function
|
|
1989
|
+
function Qt(e) {
|
|
1885
1990
|
switch (e.type) {
|
|
1886
1991
|
case j.RECTANGLE: return e.points.length < 2 ? null : R(e.points);
|
|
1887
1992
|
case j.POLYGON:
|
|
@@ -1900,14 +2005,14 @@ function Nt(e) {
|
|
|
1900
2005
|
default: return null;
|
|
1901
2006
|
}
|
|
1902
2007
|
}
|
|
1903
|
-
function
|
|
1904
|
-
return e.map(
|
|
2008
|
+
function $t(e) {
|
|
2009
|
+
return e.map(Qt).filter((e) => !!e && e.length >= 3);
|
|
1905
2010
|
}
|
|
1906
|
-
function
|
|
2011
|
+
function en(e, t, n = []) {
|
|
1907
2012
|
if (t <= 0 || !e.length && !n.length) return null;
|
|
1908
|
-
let r =
|
|
2013
|
+
let r = Zt(e, n);
|
|
1909
2014
|
if (!r.length) return null;
|
|
1910
|
-
let i = t + 4, a = I(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1,
|
|
2015
|
+
let i = t + 4, a = I(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1, Ht / Math.max(o, s, 1));
|
|
1911
2016
|
o = Math.max(1, Math.ceil(o * c)), s = Math.max(1, Math.ceil(s * c));
|
|
1912
2017
|
let l = a.minX - i, u = a.minY - i, d = (e) => ({
|
|
1913
2018
|
x: (e.x - l) * c,
|
|
@@ -1946,20 +2051,20 @@ function Pt(e, t, n = []) {
|
|
|
1946
2051
|
scale: c
|
|
1947
2052
|
};
|
|
1948
2053
|
}
|
|
1949
|
-
function
|
|
1950
|
-
let { canvas: n, ox: r, oy: i, scale: a } = e, o =
|
|
2054
|
+
function tn(e, t = 1.5) {
|
|
2055
|
+
let { canvas: n, ox: r, oy: i, scale: a } = e, o = Jt(n.getContext("2d").getImageData(0, 0, n.width, n.height).data, n.width, n.height);
|
|
1951
2056
|
if (!o.length) return [];
|
|
1952
2057
|
let s = (e) => ({
|
|
1953
2058
|
x: e.x / a + r,
|
|
1954
2059
|
y: e.y / a + i
|
|
1955
2060
|
}), c = [];
|
|
1956
2061
|
for (let e of o) {
|
|
1957
|
-
let n = e.map(s), r =
|
|
1958
|
-
i.length >= 3 &&
|
|
2062
|
+
let n = e.map(s), r = Vt(n, t), i = r.length >= 3 ? r : n;
|
|
2063
|
+
i.length >= 3 && Wt(i) >= Ut && c.push(i);
|
|
1959
2064
|
}
|
|
1960
2065
|
return c;
|
|
1961
2066
|
}
|
|
1962
|
-
function
|
|
2067
|
+
function nn(e, t) {
|
|
1963
2068
|
let { canvas: n } = e, r = document.createElement("canvas");
|
|
1964
2069
|
r.width = n.width, r.height = n.height;
|
|
1965
2070
|
let i = r.getContext("2d");
|
|
@@ -1967,25 +2072,25 @@ function It(e, t) {
|
|
|
1967
2072
|
}
|
|
1968
2073
|
//#endregion
|
|
1969
2074
|
//#region src/components/ShapeEditor/_state/drawSessionState.ts
|
|
1970
|
-
function
|
|
2075
|
+
function rn(e) {
|
|
1971
2076
|
return e.map((e) => ({
|
|
1972
2077
|
mode: e.mode,
|
|
1973
2078
|
points: e.points.map((e) => ({ ...e }))
|
|
1974
2079
|
}));
|
|
1975
2080
|
}
|
|
1976
|
-
function
|
|
2081
|
+
function an(e, t) {
|
|
1977
2082
|
return e.length === t.length && e.every((e, n) => e.mode === t[n].mode && e.points.length === t[n].points.length && e.points.every((e, r) => e.x === t[n].points[r].x && e.y === t[n].points[r].y));
|
|
1978
2083
|
}
|
|
1979
2084
|
function Z(e) {
|
|
1980
2085
|
return e.map((e) => ({ ...e }));
|
|
1981
2086
|
}
|
|
1982
|
-
function
|
|
2087
|
+
function on(e, t) {
|
|
1983
2088
|
return e.length === t.length && e.every((e, n) => e.x === t[n].x && e.y === t[n].y);
|
|
1984
2089
|
}
|
|
1985
2090
|
//#endregion
|
|
1986
2091
|
//#region src/components/ShapeEditor/_state/useDrawSession.ts
|
|
1987
|
-
var
|
|
1988
|
-
function
|
|
2092
|
+
var sn = 10;
|
|
2093
|
+
function cn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, brushSizeRef: a, simplifyEpsilonRef: o, draftMeta: s, engineRef: c, onDrawSessionChange: l, onDraftShapeChange: u, changeSelection: f, createShape: p }) {
|
|
1989
2094
|
let m = v(l);
|
|
1990
2095
|
m.current = l;
|
|
1991
2096
|
let h = v(u);
|
|
@@ -2031,7 +2136,7 @@ function Vt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2031
2136
|
t.clearPreview();
|
|
2032
2137
|
return;
|
|
2033
2138
|
}
|
|
2034
|
-
let n =
|
|
2139
|
+
let n = en(e, a.current, E.current);
|
|
2035
2140
|
if (!n) {
|
|
2036
2141
|
t.clearPreview();
|
|
2037
2142
|
return;
|
|
@@ -2063,11 +2168,11 @@ function Vt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2063
2168
|
c,
|
|
2064
2169
|
e
|
|
2065
2170
|
]), se = d((e) => {
|
|
2066
|
-
let t =
|
|
2067
|
-
i &&
|
|
2171
|
+
let t = rn(e), n = O.current, r = k.current, i = n[r];
|
|
2172
|
+
i && an(i, t) || (O.current = [...n.slice(0, r + 1), t], k.current += 1, L());
|
|
2068
2173
|
}, [L]), ce = d((e) => {
|
|
2069
2174
|
let t = S.current, n = C.current, r = t[n];
|
|
2070
|
-
r &&
|
|
2175
|
+
r && on(r, e) || (S.current = [...t.slice(0, n + 1), Z(e)], C.current += 1);
|
|
2071
2176
|
}, []), B = d(() => {
|
|
2072
2177
|
y.current = [], T.current = [], E.current = [], D.current = [], b.current = null, x.current = /* @__PURE__ */ new Set(), S.current = [[]], C.current = 0, w.current = "", R(), c.current?.clearPreview(), h.current?.(null), L();
|
|
2073
2178
|
}, [
|
|
@@ -2118,7 +2223,7 @@ function Vt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2118
2223
|
z
|
|
2119
2224
|
]), ye = d((e) => {
|
|
2120
2225
|
b.current = e ? { ...e } : null, z(), L();
|
|
2121
|
-
}, [L, z]), be = d(() => y.current.length > 0 ? (y.current = [], z(), L(), !0) : k.current <= 0 ? !1 : (--k.current, T.current =
|
|
2226
|
+
}, [L, z]), be = d(() => y.current.length > 0 ? (y.current = [], z(), L(), !0) : k.current <= 0 ? !1 : (--k.current, T.current = rn(O.current[k.current]), z(), L(), !0), [L, z]), xe = d(() => y.current.length > 0 || k.current >= O.current.length - 1 ? !1 : (k.current += 1, T.current = rn(O.current[k.current]), z(), L(), !0), [L, z]), Se = d(() => C.current <= 0 ? !1 : (--C.current, y.current = Z(S.current[C.current]), x.current = /* @__PURE__ */ new Set(), z(), L(), !0), [L, z]), Ce = d(() => C.current >= S.current.length - 1 ? !1 : (C.current += 1, y.current = Z(S.current[C.current]), x.current = /* @__PURE__ */ new Set(), z(), L(), !0), [L, z]), we = d(() => {
|
|
2122
2227
|
let t = e.current;
|
|
2123
2228
|
return t === H.BRUSH ? be() : t === H.POLYGON || t === H.PATH ? Se() : !1;
|
|
2124
2229
|
}, [
|
|
@@ -2135,7 +2240,7 @@ function Vt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2135
2240
|
]), Ee = d(() => {
|
|
2136
2241
|
let e = t.current;
|
|
2137
2242
|
if (!e.length) return D.current.length > 0;
|
|
2138
|
-
let r = n.current.getShapes().filter((t) => e.includes(t.id) && ee(t)), i =
|
|
2243
|
+
let r = n.current.getShapes().filter((t) => e.includes(t.id) && ee(t)), i = $t(r);
|
|
2139
2244
|
return i.length ? (D.current = r.map((e) => e.id), E.current = i, !0) : (D.current = [], E.current = [], !1);
|
|
2140
2245
|
}, [n, t]), De = d(() => {
|
|
2141
2246
|
if (r.current) return !1;
|
|
@@ -2146,13 +2251,13 @@ function Vt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2146
2251
|
});
|
|
2147
2252
|
let t = E.current, c = [...D.current];
|
|
2148
2253
|
if (!e.length && !t.length) return !1;
|
|
2149
|
-
let l =
|
|
2254
|
+
let l = en(e, a.current, t);
|
|
2150
2255
|
if (!l) return B(), !1;
|
|
2151
|
-
let u =
|
|
2256
|
+
let u = tn(l, o.current);
|
|
2152
2257
|
if (c.length) {
|
|
2153
2258
|
let e = n.current.getShapes().filter((e) => c.includes(e.id));
|
|
2154
2259
|
if (!u.length) return n.current.remove(c), B(), f([]), !0;
|
|
2155
|
-
u.sort((e, t) =>
|
|
2260
|
+
u.sort((e, t) => Wt(t) - Wt(e));
|
|
2156
2261
|
let t = [], r = [], i = [];
|
|
2157
2262
|
for (let n = 0; n < u.length; n++) {
|
|
2158
2263
|
let a = u[n];
|
|
@@ -2207,7 +2312,7 @@ function Vt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2207
2312
|
]), ke = d(() => {
|
|
2208
2313
|
let t = y.current;
|
|
2209
2314
|
if (e.current === H.PATH && t.length >= 3) {
|
|
2210
|
-
let e =
|
|
2315
|
+
let e = Vt(t, o.current);
|
|
2211
2316
|
e.length >= 3 && _.current(j.POLYGON, e);
|
|
2212
2317
|
}
|
|
2213
2318
|
B();
|
|
@@ -2233,7 +2338,7 @@ function Vt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2233
2338
|
}, [le]), Ne = d((e) => {
|
|
2234
2339
|
let t = c.current, n = y.current;
|
|
2235
2340
|
if (!t || !n.length) return -1;
|
|
2236
|
-
let r =
|
|
2341
|
+
let r = sn / (t.viewport.scale || 1);
|
|
2237
2342
|
for (let t = n.length - 1; t >= 0; t--) {
|
|
2238
2343
|
let i = n[t];
|
|
2239
2344
|
if (Math.hypot(e.x - i.x, e.y - i.y) <= r) return t;
|
|
@@ -2316,31 +2421,31 @@ function Vt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2316
2421
|
}
|
|
2317
2422
|
//#endregion
|
|
2318
2423
|
//#region src/components/ShapeEditor/_state/useEditorDocument.ts
|
|
2319
|
-
function
|
|
2424
|
+
function ln(e, t) {
|
|
2320
2425
|
return {
|
|
2321
2426
|
shapes: t,
|
|
2322
2427
|
past: [...e.past, e.shapes],
|
|
2323
2428
|
future: []
|
|
2324
2429
|
};
|
|
2325
2430
|
}
|
|
2326
|
-
function
|
|
2431
|
+
function un(e, t) {
|
|
2327
2432
|
switch (t.type) {
|
|
2328
|
-
case "CREATE": return
|
|
2433
|
+
case "CREATE": return ln(e, [...e.shapes, ...t.shapes]);
|
|
2329
2434
|
case "UPDATE": {
|
|
2330
2435
|
let n = new Map(t.shapes.map((e) => [e.id, e]));
|
|
2331
|
-
return
|
|
2436
|
+
return ln(e, e.shapes.map((e) => n.get(e.id) ?? e));
|
|
2332
2437
|
}
|
|
2333
2438
|
case "DELETE": {
|
|
2334
2439
|
let n = new Set(t.ids);
|
|
2335
|
-
return
|
|
2440
|
+
return ln(e, e.shapes.filter((e) => !n.has(e.id)));
|
|
2336
2441
|
}
|
|
2337
2442
|
case "REPLACE": {
|
|
2338
2443
|
let n = new Set(t.removeIds);
|
|
2339
|
-
return
|
|
2444
|
+
return ln(e, [...e.shapes.filter((e) => !n.has(e.id)), ...t.shapes]);
|
|
2340
2445
|
}
|
|
2341
2446
|
case "REORDER": {
|
|
2342
2447
|
let n = new Set(t.ids), r = e.shapes.filter((e) => n.has(e.id)), i = e.shapes.filter((e) => !n.has(e.id));
|
|
2343
|
-
return r.length === 0 ? e :
|
|
2448
|
+
return r.length === 0 ? e : ln(e, t.edge === "front" ? [...i, ...r] : [...r, ...i]);
|
|
2344
2449
|
}
|
|
2345
2450
|
case "RESET": return {
|
|
2346
2451
|
shapes: t.shapes,
|
|
@@ -2360,15 +2465,15 @@ function Ut(e, t) {
|
|
|
2360
2465
|
default: return e;
|
|
2361
2466
|
}
|
|
2362
2467
|
}
|
|
2363
|
-
function
|
|
2364
|
-
let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = _(
|
|
2468
|
+
function dn(e) {
|
|
2469
|
+
let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = _(un, {
|
|
2365
2470
|
shapes: [],
|
|
2366
2471
|
past: [],
|
|
2367
2472
|
future: []
|
|
2368
2473
|
}), o = v(i);
|
|
2369
2474
|
o.current = i;
|
|
2370
2475
|
let s = d((e) => {
|
|
2371
|
-
o.current =
|
|
2476
|
+
o.current = un(o.current, e), a(e);
|
|
2372
2477
|
}, []), c = d((e, i) => {
|
|
2373
2478
|
let a = new Map(e.map((e) => [e.id, e])), o = new Map(i.map((e) => [e.id, e])), s = i.filter((e) => !a.has(e.id));
|
|
2374
2479
|
s.length && t?.(s);
|
|
@@ -2437,7 +2542,7 @@ function Wt(e) {
|
|
|
2437
2542
|
}
|
|
2438
2543
|
//#endregion
|
|
2439
2544
|
//#region src/components/ShapeEditor/_model/keymap.ts
|
|
2440
|
-
var
|
|
2545
|
+
var fn = {
|
|
2441
2546
|
undo: ["mod+z"],
|
|
2442
2547
|
redo: ["mod+shift+z"],
|
|
2443
2548
|
selectAll: ["mod+a"],
|
|
@@ -2465,7 +2570,7 @@ var Gt = {
|
|
|
2465
2570
|
pathTool: ["g"],
|
|
2466
2571
|
brushTool: ["b"],
|
|
2467
2572
|
pointTool: ["i"]
|
|
2468
|
-
},
|
|
2573
|
+
}, pn = {
|
|
2469
2574
|
Equal: "=",
|
|
2470
2575
|
Minus: "-",
|
|
2471
2576
|
BracketLeft: "[",
|
|
@@ -2475,7 +2580,7 @@ var Gt = {
|
|
|
2475
2580
|
Comma: ",",
|
|
2476
2581
|
Slash: "/",
|
|
2477
2582
|
Backquote: "`"
|
|
2478
|
-
},
|
|
2583
|
+
}, mn = {
|
|
2479
2584
|
Escape: "escape",
|
|
2480
2585
|
Enter: "enter",
|
|
2481
2586
|
Backspace: "backspace",
|
|
@@ -2486,58 +2591,58 @@ var Gt = {
|
|
|
2486
2591
|
ArrowLeft: "arrowleft",
|
|
2487
2592
|
ArrowRight: "arrowright"
|
|
2488
2593
|
};
|
|
2489
|
-
function
|
|
2594
|
+
function hn(e) {
|
|
2490
2595
|
let t = e.code, n = /^Key([A-Z])$/.exec(t);
|
|
2491
2596
|
if (n) return n[1].toLowerCase();
|
|
2492
2597
|
let r = /^Digit([0-9])$/.exec(t);
|
|
2493
|
-
return r ? r[1] :
|
|
2598
|
+
return r ? r[1] : pn[t] ? pn[t] : mn[e.key] ? mn[e.key] : null;
|
|
2494
2599
|
}
|
|
2495
|
-
function
|
|
2496
|
-
let t =
|
|
2600
|
+
function gn(e) {
|
|
2601
|
+
let t = hn(e);
|
|
2497
2602
|
if (!t) return null;
|
|
2498
2603
|
let n = [];
|
|
2499
2604
|
return (e.metaKey || e.ctrlKey) && n.push("mod"), e.shiftKey && n.push("shift"), e.altKey && n.push("alt"), n.push(t), n.join("+");
|
|
2500
2605
|
}
|
|
2501
|
-
function
|
|
2606
|
+
function _n(e) {
|
|
2502
2607
|
let t = /* @__PURE__ */ new Map();
|
|
2503
|
-
for (let n of Object.keys(
|
|
2504
|
-
let r = e?.[n], i = r === void 0 ?
|
|
2608
|
+
for (let n of Object.keys(fn)) {
|
|
2609
|
+
let r = e?.[n], i = r === void 0 ? fn[n] : r === null ? [] : Array.isArray(r) ? r : [r];
|
|
2505
2610
|
for (let e of i) t.set(e.toLowerCase(), n);
|
|
2506
2611
|
}
|
|
2507
2612
|
return t;
|
|
2508
2613
|
}
|
|
2509
2614
|
//#endregion
|
|
2510
2615
|
//#region src/components/ShapeEditor/_state/useEditorHotkeys.ts
|
|
2511
|
-
var
|
|
2616
|
+
var vn = {
|
|
2512
2617
|
ArrowUp: [0, -1],
|
|
2513
2618
|
ArrowDown: [0, 1],
|
|
2514
2619
|
ArrowLeft: [-1, 0],
|
|
2515
2620
|
ArrowRight: [1, 0]
|
|
2516
2621
|
};
|
|
2517
|
-
function
|
|
2622
|
+
function yn() {
|
|
2518
2623
|
let e = document.activeElement;
|
|
2519
2624
|
return !!e && (e.tagName === "INPUT" || e.tagName === "TEXTAREA" || e.isContentEditable);
|
|
2520
2625
|
}
|
|
2521
|
-
function
|
|
2626
|
+
function bn(e, t) {
|
|
2522
2627
|
if (!t || !(e instanceof Element)) return !1;
|
|
2523
2628
|
let n = e.closest("[role=\"dialog\"],[aria-modal=\"true\"]");
|
|
2524
2629
|
return !!n && !n.contains(t);
|
|
2525
2630
|
}
|
|
2526
|
-
function
|
|
2527
|
-
let { spaceRef: t, shiftRef: n } = e, r = g(() =>
|
|
2631
|
+
function xn(e) {
|
|
2632
|
+
let { spaceRef: t, shiftRef: n } = e, r = g(() => _n(e.keymap), [e.keymap]), i = v(e);
|
|
2528
2633
|
i.current = e;
|
|
2529
2634
|
let a = v(r);
|
|
2530
2635
|
a.current = r, f(() => {
|
|
2531
2636
|
let e = (e) => {
|
|
2532
|
-
if (e.code === "Space" && (t.current = !0, i.current.onSpaceDown()), e.key === "Shift" && (n.current = !0),
|
|
2533
|
-
let r =
|
|
2637
|
+
if (e.code === "Space" && (t.current = !0, i.current.onSpaceDown()), e.key === "Shift" && (n.current = !0), yn() || bn(e.target, i.current.hostRef.current)) return;
|
|
2638
|
+
let r = vn[e.key];
|
|
2534
2639
|
if (r) {
|
|
2535
2640
|
e.preventDefault();
|
|
2536
2641
|
let t = e.shiftKey ? 10 : 1;
|
|
2537
2642
|
i.current.nudge(r[0] * t, r[1] * t);
|
|
2538
2643
|
return;
|
|
2539
2644
|
}
|
|
2540
|
-
let o =
|
|
2645
|
+
let o = gn(e);
|
|
2541
2646
|
if (!o) return;
|
|
2542
2647
|
let s = a.current.get(o);
|
|
2543
2648
|
s && i.current.actions[s]?.() !== !1 && e.preventDefault();
|
|
@@ -2551,7 +2656,7 @@ function en(e) {
|
|
|
2551
2656
|
}
|
|
2552
2657
|
//#endregion
|
|
2553
2658
|
//#region src/components/ShapeEditor/_model/imageFetch.ts
|
|
2554
|
-
async function
|
|
2659
|
+
async function Sn(e) {
|
|
2555
2660
|
for (let t of ["default", "reload"]) try {
|
|
2556
2661
|
let n = await fetch(e, {
|
|
2557
2662
|
mode: "cors",
|
|
@@ -2564,8 +2669,8 @@ async function tn(e) {
|
|
|
2564
2669
|
}
|
|
2565
2670
|
//#endregion
|
|
2566
2671
|
//#region src/components/ShapeEditor/_model/imageTiles.ts
|
|
2567
|
-
var
|
|
2568
|
-
function
|
|
2672
|
+
var Cn = 4e3;
|
|
2673
|
+
function wn(e, t, n = Cn) {
|
|
2569
2674
|
if (e <= 0 || t <= 0) return [];
|
|
2570
2675
|
let r = Math.ceil(e / n), i = Math.ceil(t / n);
|
|
2571
2676
|
return Array.from({ length: i }, (a, o) => Array.from({ length: r }, (a, s) => {
|
|
@@ -2580,7 +2685,7 @@ function rn(e, t, n = nn) {
|
|
|
2580
2685
|
};
|
|
2581
2686
|
})).flat();
|
|
2582
2687
|
}
|
|
2583
|
-
function
|
|
2688
|
+
function Tn(e, t) {
|
|
2584
2689
|
let n = document.createElement("canvas");
|
|
2585
2690
|
n.width = t.width, n.height = t.height;
|
|
2586
2691
|
let r = n.getContext("2d");
|
|
@@ -2588,7 +2693,7 @@ function an(e, t) {
|
|
|
2588
2693
|
}
|
|
2589
2694
|
//#endregion
|
|
2590
2695
|
//#region src/components/ShapeEditor/_model/konva.ts
|
|
2591
|
-
function
|
|
2696
|
+
function En(e, t, n) {
|
|
2592
2697
|
if (t === j.POINT) {
|
|
2593
2698
|
e.setAttrs({
|
|
2594
2699
|
x: n[0].x,
|
|
@@ -2624,17 +2729,17 @@ function on(e, t, n) {
|
|
|
2624
2729
|
}
|
|
2625
2730
|
//#endregion
|
|
2626
2731
|
//#region src/components/ShapeEditor/_model/pinIcon.ts
|
|
2627
|
-
var
|
|
2628
|
-
function
|
|
2629
|
-
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${
|
|
2732
|
+
var Dn = "M8 0C12.4183 0 16 3.58172 16 8C16 11.5323 13.71 14.5277 10.5342 15.5879L10.166 20.0068C10.0721 21.1334 9.13046 22 8 22C6.86954 22 5.92786 21.1334 5.83398 20.0068L5.46484 15.5879C2.28949 14.5275 0 11.532 0 8C0 3.58172 3.58172 0 8 0Z", On = "#ffffff", kn = 1.5;
|
|
2733
|
+
function An(e) {
|
|
2734
|
+
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${Dn}" fill="${e}" stroke="${On}" stroke-width="${kn}"/></svg>`;
|
|
2630
2735
|
}
|
|
2631
2736
|
//#endregion
|
|
2632
2737
|
//#region src/components/ShapeEditor/_renderers/transformSession.ts
|
|
2633
|
-
var
|
|
2634
|
-
function
|
|
2738
|
+
var jn = Math.PI / 12;
|
|
2739
|
+
function Mn(e, t) {
|
|
2635
2740
|
return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type === j.ROTATED_RECTANGLE;
|
|
2636
2741
|
}
|
|
2637
|
-
function
|
|
2742
|
+
function Nn(e, t, n) {
|
|
2638
2743
|
if (e.kind === "resize") {
|
|
2639
2744
|
let r = n ? e.box : ae(e.anchor, e.box, t.x, t.y);
|
|
2640
2745
|
return {
|
|
@@ -2665,7 +2770,7 @@ function pn(e, t, n) {
|
|
|
2665
2770
|
}
|
|
2666
2771
|
if (e.kind === "rotate") {
|
|
2667
2772
|
let n = Math.atan2(t.y - e.center.y, t.x - e.center.x) - e.startAngle;
|
|
2668
|
-
return e.shiftKey && (n = Math.round(n /
|
|
2773
|
+
return e.shiftKey && (n = Math.round(n / jn) * jn), {
|
|
2669
2774
|
updates: [{
|
|
2670
2775
|
id: e.id,
|
|
2671
2776
|
points: e.points.map((t) => L(t, e.center, n))
|
|
@@ -2685,13 +2790,13 @@ function pn(e, t, n) {
|
|
|
2685
2790
|
box: I(a)
|
|
2686
2791
|
};
|
|
2687
2792
|
}
|
|
2688
|
-
function
|
|
2793
|
+
function Pn(e, t) {
|
|
2689
2794
|
return t.kind === "move" || t.kind === "vertex" ? t.start : t.kind === "rotate" ? {
|
|
2690
2795
|
x: t.center.x + Math.cos(t.startAngle),
|
|
2691
2796
|
y: t.center.y + Math.sin(t.startAngle)
|
|
2692
|
-
} :
|
|
2797
|
+
} : Mn(e, t) ? me(t.shapes[0].points)[F.indexOf(t.anchor)] : ie(t.anchor, t.box);
|
|
2693
2798
|
}
|
|
2694
|
-
function
|
|
2799
|
+
function Fn(e, t, n) {
|
|
2695
2800
|
let r = e.filter((e) => t.includes(e.id) && te(e)).map((e) => ({
|
|
2696
2801
|
id: e.id,
|
|
2697
2802
|
points: e.points
|
|
@@ -2703,27 +2808,27 @@ function hn(e, t, n) {
|
|
|
2703
2808
|
shapes: r
|
|
2704
2809
|
} : null;
|
|
2705
2810
|
}
|
|
2706
|
-
function
|
|
2811
|
+
function In(e) {
|
|
2707
2812
|
return e.map((e) => ({
|
|
2708
2813
|
...e,
|
|
2709
2814
|
points: e.points.map((e) => ({ ...e }))
|
|
2710
2815
|
}));
|
|
2711
2816
|
}
|
|
2712
|
-
function
|
|
2817
|
+
function Ln(e, t) {
|
|
2713
2818
|
let n = new Set(t);
|
|
2714
2819
|
return e.filter((e) => n.has(e.id) && ee(e));
|
|
2715
2820
|
}
|
|
2716
|
-
function
|
|
2821
|
+
function Rn(e, t) {
|
|
2717
2822
|
return e.filter((e) => {
|
|
2718
2823
|
if (!P(e)) return !1;
|
|
2719
2824
|
let n = I(e.points);
|
|
2720
2825
|
return n.minX <= t.maxX && n.maxX >= t.minX && n.minY <= t.maxY && n.maxY >= t.minY;
|
|
2721
2826
|
}).map((e) => e.id);
|
|
2722
2827
|
}
|
|
2723
|
-
function
|
|
2828
|
+
function zn(e, t, n) {
|
|
2724
2829
|
return (e ? Pe(e, { strokeWidth: t }).pointRadius : 5) / (n || 1);
|
|
2725
2830
|
}
|
|
2726
|
-
function
|
|
2831
|
+
function Q(e, t) {
|
|
2727
2832
|
return {
|
|
2728
2833
|
minX: e.x - t,
|
|
2729
2834
|
minY: e.y - t,
|
|
@@ -2731,9 +2836,9 @@ function bn(e, t) {
|
|
|
2731
2836
|
maxY: e.y + t
|
|
2732
2837
|
};
|
|
2733
2838
|
}
|
|
2734
|
-
function
|
|
2839
|
+
function Bn(e, t, n) {
|
|
2735
2840
|
if (e.type === j.ROTATED_RECTANGLE) return t;
|
|
2736
|
-
let r = e.type === j.POINT ?
|
|
2841
|
+
let r = e.type === j.POINT ? Q(t[0], n) : I(t);
|
|
2737
2842
|
return R([{
|
|
2738
2843
|
x: r.minX,
|
|
2739
2844
|
y: r.minY
|
|
@@ -2742,24 +2847,24 @@ function xn(e, t, n) {
|
|
|
2742
2847
|
y: r.maxY
|
|
2743
2848
|
}]);
|
|
2744
2849
|
}
|
|
2745
|
-
function
|
|
2850
|
+
function Vn(e) {
|
|
2746
2851
|
return 24 / (e || 1);
|
|
2747
2852
|
}
|
|
2748
|
-
function
|
|
2853
|
+
function Hn(e, t) {
|
|
2749
2854
|
return Math.atan2(t.y - e.y, t.x - e.x);
|
|
2750
2855
|
}
|
|
2751
2856
|
//#endregion
|
|
2752
2857
|
//#region src/components/ShapeEditor/_renderers/KonvaRenderer.ts
|
|
2753
|
-
var
|
|
2858
|
+
var Un = 2, Wn = "#1e88e5", Gn = "#669def", Kn = class {
|
|
2754
2859
|
constructor(e, t) {
|
|
2755
|
-
this.layer = new C.Layer(), this.world = new C.Group(), this.bgGroup = new C.Group(), this.overlayGroup = new C.Group({ listening: !1 }), this.shapeGroup = new C.Group(), this.selGroup = new C.Group(), this.previewGroup = new C.Group(), this.handleGroup = new C.Group(), this.baseCursor = "default", this.strokeSize =
|
|
2860
|
+
this.layer = new C.Layer(), this.world = new C.Group(), this.bgGroup = new C.Group(), this.overlayGroup = new C.Group({ listening: !1 }), this.guideOverlayGroup = new C.Group({ listening: !1 }), this.regionOverlayGroup = new C.Group({ listening: !1 }), this.dimOverlayGroup = new C.Group({ listening: !1 }), this.shapeGroup = new C.Group(), this.selGroup = new C.Group(), this.previewGroup = new C.Group(), this.handleGroup = new C.Group(), this.baseCursor = "default", this.strokeSize = Un, this.imageSmoothing = !0, this.imageWidth = 0, this.imageHeight = 0, this.shapes = [], this.selected = [], this.nodes = /* @__PURE__ */ new Map(), this.altNodes = /* @__PURE__ */ new Map(), this.lastAppliedScale = -1, this.imageLoadToken = 0, this.transformEnabled = !1, this.handleNodes = [], this.vertexNodes = [], this.lastImg = {
|
|
2756
2861
|
x: 0,
|
|
2757
2862
|
y: 0
|
|
2758
2863
|
}, this.lastDragImg = null, this.ro = null, this.activeDrag = null, this.midNodes = [], this.selectedVertices = /* @__PURE__ */ new Set(), this.vertexPolygonId = null, this.editingId = null, this.rotNode = null, this.rotLineNode = null, this.transformerOutline = null, this.selectionBorders = [], this.upCleanup = null, this.lastPreviewPoly = null, this.preview = null, this.marquee = null, this.host = e, this.cb = t, this.stage = new C.Stage({
|
|
2759
2864
|
container: e,
|
|
2760
2865
|
width: e.clientWidth || 1,
|
|
2761
2866
|
height: e.clientHeight || 1
|
|
2762
|
-
}), this.world.add(this.bgGroup, this.overlayGroup, this.shapeGroup, this.selGroup, this.previewGroup), this.layer.add(this.world, this.handleGroup), this.world.visible(!1), this.stage.add(this.layer);
|
|
2867
|
+
}), this.overlayGroup.add(this.guideOverlayGroup, this.regionOverlayGroup, this.dimOverlayGroup), this.world.add(this.bgGroup, this.overlayGroup, this.shapeGroup, this.selGroup, this.previewGroup), this.layer.add(this.world, this.handleGroup), this.world.visible(!1), this.stage.add(this.layer);
|
|
2763
2868
|
}
|
|
2764
2869
|
async init() {
|
|
2765
2870
|
let e = (e) => ({
|
|
@@ -2844,7 +2949,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
2844
2949
|
return this.world.getAbsoluteTransform().point(e);
|
|
2845
2950
|
}
|
|
2846
2951
|
async setImage(e, t, n) {
|
|
2847
|
-
let r = ++this.imageLoadToken, i = await
|
|
2952
|
+
let r = ++this.imageLoadToken, i = await Sn(e);
|
|
2848
2953
|
await new Promise((a) => {
|
|
2849
2954
|
let o = new Image();
|
|
2850
2955
|
i || (o.crossOrigin = "anonymous"), o.onload = () => {
|
|
@@ -2855,7 +2960,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
2855
2960
|
x: e / o.naturalWidth,
|
|
2856
2961
|
y: s / o.naturalHeight
|
|
2857
2962
|
}), this.bgGroup.destroyChildren();
|
|
2858
|
-
for (let e of
|
|
2963
|
+
for (let e of wn(o.naturalWidth, o.naturalHeight)) this.bgGroup.add(new C.Image({
|
|
2859
2964
|
image: o,
|
|
2860
2965
|
x: e.x,
|
|
2861
2966
|
y: e.y,
|
|
@@ -2889,26 +2994,37 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
2889
2994
|
this.imageSmoothing !== e && (this.imageSmoothing = e, this.layer.imageSmoothingEnabled(e), this.layer.batchDraw());
|
|
2890
2995
|
}
|
|
2891
2996
|
setOverlays(e, t, n) {
|
|
2892
|
-
|
|
2997
|
+
this.guideOverlayGroup.destroyChildren(), e && this.guideOverlayGroup.add(new C.Image({
|
|
2893
2998
|
image: e,
|
|
2894
2999
|
opacity: .55,
|
|
2895
3000
|
imageSmoothingEnabled: !1,
|
|
2896
3001
|
listening: !1
|
|
2897
|
-
})), t) {
|
|
2898
|
-
|
|
2899
|
-
|
|
3002
|
+
})), this.setRegionOverlay(t), this.dimOverlayGroup.destroyChildren(), n && this.imageWidth && this.dimOverlayGroup.add(new C.Rect({
|
|
3003
|
+
x: 0,
|
|
3004
|
+
y: 0,
|
|
3005
|
+
width: this.imageWidth,
|
|
3006
|
+
height: this.imageHeight,
|
|
3007
|
+
fill: "#0d0d12",
|
|
3008
|
+
opacity: .3,
|
|
3009
|
+
listening: !1
|
|
3010
|
+
})), this.layer.batchDraw();
|
|
3011
|
+
}
|
|
3012
|
+
setRegionOverlay(e) {
|
|
3013
|
+
if (this.regionOverlayGroup.destroyChildren(), e) {
|
|
3014
|
+
let { imageWidth: t, imageHeight: n } = this;
|
|
3015
|
+
if (this.regionOverlayGroup.add(new C.Shape({
|
|
2900
3016
|
listening: !1,
|
|
2901
3017
|
sceneFunc: (r) => {
|
|
2902
|
-
|
|
3018
|
+
wt(r._context, e, t, n);
|
|
2903
3019
|
}
|
|
2904
|
-
})),
|
|
2905
|
-
let
|
|
3020
|
+
})), e.outlineStyles) {
|
|
3021
|
+
let t = (e, t) => {
|
|
2906
3022
|
let n = {
|
|
2907
3023
|
strokeWidth: t.width,
|
|
2908
3024
|
strokeScaleEnabled: !1,
|
|
2909
3025
|
listening: !1
|
|
2910
3026
|
};
|
|
2911
|
-
for (let [r, i] of e) t.underlayColor && this.
|
|
3027
|
+
for (let [r, i] of e) t.underlayColor && this.regionOverlayGroup.add(new C.Line({
|
|
2912
3028
|
points: [
|
|
2913
3029
|
r.x,
|
|
2914
3030
|
r.y,
|
|
@@ -2917,7 +3033,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
2917
3033
|
],
|
|
2918
3034
|
stroke: t.underlayColor,
|
|
2919
3035
|
...n
|
|
2920
|
-
})), this.
|
|
3036
|
+
})), this.regionOverlayGroup.add(new C.Line({
|
|
2921
3037
|
points: [
|
|
2922
3038
|
r.x,
|
|
2923
3039
|
r.y,
|
|
@@ -2930,18 +3046,10 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
2930
3046
|
...n
|
|
2931
3047
|
}));
|
|
2932
3048
|
};
|
|
2933
|
-
e
|
|
3049
|
+
t(e.visibleOutline, e.outlineStyles.visible), t(e.occludedOutline, e.outlineStyles.occluded);
|
|
2934
3050
|
}
|
|
2935
3051
|
}
|
|
2936
|
-
|
|
2937
|
-
x: 0,
|
|
2938
|
-
y: 0,
|
|
2939
|
-
width: this.imageWidth,
|
|
2940
|
-
height: this.imageHeight,
|
|
2941
|
-
fill: "#0d0d12",
|
|
2942
|
-
opacity: .3,
|
|
2943
|
-
listening: !1
|
|
2944
|
-
})), this.layer.batchDraw();
|
|
3052
|
+
this.layer.batchDraw();
|
|
2945
3053
|
}
|
|
2946
3054
|
get viewport() {
|
|
2947
3055
|
return {
|
|
@@ -2963,7 +3071,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
2963
3071
|
let e = this.lastPreviewPoly;
|
|
2964
3072
|
e && this.previewPoly(e.points, e.cursor, e.style, e.closed, e.selectedPointIndices, e.showVertices);
|
|
2965
3073
|
}
|
|
2966
|
-
this.activeDrag ? this.dragTransform(this.lastDragImg ??
|
|
3074
|
+
this.activeDrag ? this.dragTransform(this.lastDragImg ?? Pn(this.shapes, this.activeDrag)) : this.drawTransformer(), this.layer.batchDraw(), this.cb.onViewportChange?.();
|
|
2967
3075
|
}
|
|
2968
3076
|
fit() {
|
|
2969
3077
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -2992,7 +3100,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
2992
3100
|
});
|
|
2993
3101
|
}
|
|
2994
3102
|
setShapes(e, t) {
|
|
2995
|
-
if (this.shapes =
|
|
3103
|
+
if (this.shapes = In(e), this.selected = t, !this.activeDrag) {
|
|
2996
3104
|
this.shapeGroup.destroyChildren(), this.nodes.clear(), this.altNodes.clear();
|
|
2997
3105
|
for (let t of ne(e).filter(M)) {
|
|
2998
3106
|
let e = this.makeNode(t), n = Pe(t, { strokeWidth: this.strokeSize });
|
|
@@ -3030,7 +3138,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3030
3138
|
if (t === j.POINT) {
|
|
3031
3139
|
let t = 1 / (this.world.scaleX() || 1), a = new C.Path({
|
|
3032
3140
|
id: e.id,
|
|
3033
|
-
data:
|
|
3141
|
+
data: Dn,
|
|
3034
3142
|
x: n[0].x,
|
|
3035
3143
|
y: n[0].y,
|
|
3036
3144
|
offsetX: 16 / 2,
|
|
@@ -3038,8 +3146,8 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3038
3146
|
scaleX: t,
|
|
3039
3147
|
scaleY: t,
|
|
3040
3148
|
fill: r.color,
|
|
3041
|
-
stroke:
|
|
3042
|
-
strokeWidth:
|
|
3149
|
+
stroke: On,
|
|
3150
|
+
strokeWidth: kn,
|
|
3043
3151
|
strokeScaleEnabled: !1,
|
|
3044
3152
|
shadowColor: "#000",
|
|
3045
3153
|
shadowBlur: 2,
|
|
@@ -3084,13 +3192,13 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3084
3192
|
liveUpdateShape(e, t) {
|
|
3085
3193
|
let n = this.nodes.get(e), r = this.shapes.find((t) => t.id === e);
|
|
3086
3194
|
if (n && r) {
|
|
3087
|
-
|
|
3195
|
+
En(n, r.type, t);
|
|
3088
3196
|
let i = this.altNodes.get(e);
|
|
3089
|
-
i &&
|
|
3197
|
+
i && En(i, r.type, t), r.type === j.POINT && n instanceof C.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
|
|
3090
3198
|
}
|
|
3091
3199
|
}
|
|
3092
3200
|
pointRadius(e) {
|
|
3093
|
-
return
|
|
3201
|
+
return zn(e, this.strokeSize, this.world.scaleX() || 1);
|
|
3094
3202
|
}
|
|
3095
3203
|
scaledDash(e) {
|
|
3096
3204
|
return e;
|
|
@@ -3110,7 +3218,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3110
3218
|
}
|
|
3111
3219
|
}
|
|
3112
3220
|
shapesIntersecting(e) {
|
|
3113
|
-
return
|
|
3221
|
+
return Rn(this.shapes, e);
|
|
3114
3222
|
}
|
|
3115
3223
|
drawSelectionBorders() {
|
|
3116
3224
|
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && P(t)) : [];
|
|
@@ -3119,7 +3227,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3119
3227
|
this.selectionBorders = t.map(() => {
|
|
3120
3228
|
let e = new C.Line({
|
|
3121
3229
|
closed: !0,
|
|
3122
|
-
stroke:
|
|
3230
|
+
stroke: Gn,
|
|
3123
3231
|
strokeWidth: 1.5,
|
|
3124
3232
|
strokeScaleEnabled: !1,
|
|
3125
3233
|
listening: !1
|
|
@@ -3140,7 +3248,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3140
3248
|
}
|
|
3141
3249
|
}
|
|
3142
3250
|
selectionOutlinePoints(e, t) {
|
|
3143
|
-
return
|
|
3251
|
+
return Bn(e, t, this.pointRadius(e));
|
|
3144
3252
|
}
|
|
3145
3253
|
clearPreview() {
|
|
3146
3254
|
this.lastPreviewPoly = null, this.previewGroup.destroyChildren(), this.layer.batchDraw();
|
|
@@ -3203,8 +3311,8 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3203
3311
|
x: n.x,
|
|
3204
3312
|
y: n.y,
|
|
3205
3313
|
radius: (r ? 6 : 5) / l,
|
|
3206
|
-
fill: r ?
|
|
3207
|
-
stroke: r ? "#ffffff" :
|
|
3314
|
+
fill: r ? Wn : "#ffffff",
|
|
3315
|
+
stroke: r ? "#ffffff" : Wn,
|
|
3208
3316
|
strokeWidth: 1.5,
|
|
3209
3317
|
strokeScaleEnabled: !1,
|
|
3210
3318
|
listening: !1
|
|
@@ -3214,7 +3322,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3214
3322
|
}
|
|
3215
3323
|
previewScalarMask(e, t) {
|
|
3216
3324
|
this.previewGroup.destroyChildren();
|
|
3217
|
-
let n =
|
|
3325
|
+
let n = nn(e, t.length === 7 ? `${t}99` : t);
|
|
3218
3326
|
this.previewGroup.add(new C.Image({
|
|
3219
3327
|
image: n,
|
|
3220
3328
|
x: e.ox,
|
|
@@ -3258,14 +3366,14 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3258
3366
|
setTransformerOutlinePoints(e) {
|
|
3259
3367
|
e.length < 2 || (this.transformerOutline || (this.transformerOutline = new C.Line({
|
|
3260
3368
|
closed: !0,
|
|
3261
|
-
stroke:
|
|
3369
|
+
stroke: Wn,
|
|
3262
3370
|
strokeWidth: 1,
|
|
3263
3371
|
strokeScaleEnabled: !1,
|
|
3264
3372
|
listening: !1
|
|
3265
3373
|
}), this.selGroup.add(this.transformerOutline)), this.transformerOutline.points(e.flatMap((e) => [e.x, e.y])));
|
|
3266
3374
|
}
|
|
3267
3375
|
rotationHandleGap() {
|
|
3268
|
-
return
|
|
3376
|
+
return Vn(this.viewport.scale);
|
|
3269
3377
|
}
|
|
3270
3378
|
rotationHandleScreenPoint(e) {
|
|
3271
3379
|
return this.imgToScreen(he(e, this.rotationHandleGap()));
|
|
@@ -3284,7 +3392,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3284
3392
|
n.x,
|
|
3285
3393
|
n.y
|
|
3286
3394
|
],
|
|
3287
|
-
stroke:
|
|
3395
|
+
stroke: Wn,
|
|
3288
3396
|
strokeWidth: 1,
|
|
3289
3397
|
listening: !1
|
|
3290
3398
|
}), this.handleGroup.add(this.rotLineNode));
|
|
@@ -3299,7 +3407,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3299
3407
|
}), e.rotation(n * 180 / Math.PI);
|
|
3300
3408
|
}
|
|
3301
3409
|
orientedHandleAngle(e) {
|
|
3302
|
-
return
|
|
3410
|
+
return Hn(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
3303
3411
|
}
|
|
3304
3412
|
repositionOrientedHandles(e) {
|
|
3305
3413
|
let t = this.orientedHandleAngle(e);
|
|
@@ -3321,7 +3429,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3321
3429
|
for (let e of this.vertexNodes) e.destroy();
|
|
3322
3430
|
for (let e of this.midNodes) e.destroy();
|
|
3323
3431
|
if (this.rotNode?.destroy(), this.rotNode = null, this.rotLineNode?.destroy(), this.rotLineNode = null, this.transformerOutline?.destroy(), this.transformerOutline = null, this.handleNodes = [], this.vertexNodes = [], this.midNodes = [], !this.transformEnabled) return;
|
|
3324
|
-
let e =
|
|
3432
|
+
let e = Ln(this.shapes, this.selected);
|
|
3325
3433
|
if (!e.length || e.length === 1 && e[0].type === j.POINT) return;
|
|
3326
3434
|
let t = e.length === 1 && (e[0].type === j.POLYGON || e[0].type === j.LINE) && this.editingId === e[0].id ? e[0] : null, n = I(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === j.ROTATED_RECTANGLE ? e[0] : null, i = r ? me(r.points) : F.map((e) => ie(e, n));
|
|
3327
3435
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
@@ -3336,12 +3444,12 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3336
3444
|
offsetY: 4,
|
|
3337
3445
|
rotation: a * 180 / Math.PI,
|
|
3338
3446
|
fill: "#ffffff",
|
|
3339
|
-
stroke:
|
|
3447
|
+
stroke: Wn,
|
|
3340
3448
|
strokeWidth: 1
|
|
3341
|
-
}), r =
|
|
3449
|
+
}), r = pt(e, a);
|
|
3342
3450
|
this.bindCursor(n, r), n.on("mousedown", (t) => {
|
|
3343
3451
|
t.cancelBubble = !0, this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
3344
|
-
let n =
|
|
3452
|
+
let n = Ln(this.shapes, this.selected);
|
|
3345
3453
|
this.activeDrag = {
|
|
3346
3454
|
kind: "resize",
|
|
3347
3455
|
anchor: e,
|
|
@@ -3365,7 +3473,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3365
3473
|
radius: 4,
|
|
3366
3474
|
fill: "#ffffff",
|
|
3367
3475
|
opacity: .6,
|
|
3368
|
-
stroke:
|
|
3476
|
+
stroke: Wn,
|
|
3369
3477
|
strokeWidth: 1
|
|
3370
3478
|
});
|
|
3371
3479
|
this.bindCursor(s, "copy"), s.on("mousedown", (r) => {
|
|
@@ -3386,8 +3494,8 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3386
3494
|
x: i.x,
|
|
3387
3495
|
y: i.y,
|
|
3388
3496
|
radius: 5,
|
|
3389
|
-
fill: a ?
|
|
3390
|
-
stroke: a ? "#ffffff" :
|
|
3497
|
+
fill: a ? Wn : "#ffffff",
|
|
3498
|
+
stroke: a ? "#ffffff" : Wn,
|
|
3391
3499
|
strokeWidth: 1.5
|
|
3392
3500
|
});
|
|
3393
3501
|
this.bindCursor(o, "pointer"), o.on("mousedown", (t) => {
|
|
@@ -3412,7 +3520,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3412
3520
|
y: r.y,
|
|
3413
3521
|
radius: 6,
|
|
3414
3522
|
fill: "#ffffff",
|
|
3415
|
-
stroke:
|
|
3523
|
+
stroke: Wn,
|
|
3416
3524
|
strokeWidth: 1.5
|
|
3417
3525
|
});
|
|
3418
3526
|
this.bindCursor(i, "grab"), i.on("mousedown", (e) => {
|
|
@@ -3431,7 +3539,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3431
3539
|
this.layer.batchDraw();
|
|
3432
3540
|
}
|
|
3433
3541
|
beginMove(e, t) {
|
|
3434
|
-
let n =
|
|
3542
|
+
let n = Fn(this.shapes, t, e);
|
|
3435
3543
|
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === j.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
3436
3544
|
}
|
|
3437
3545
|
repositionHandles(e) {
|
|
@@ -3474,7 +3582,7 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3474
3582
|
let t = this.activeDrag;
|
|
3475
3583
|
if (!t) return;
|
|
3476
3584
|
this.applyCursor();
|
|
3477
|
-
let n =
|
|
3585
|
+
let n = Mn(this.shapes, t), { updates: r, box: i } = Nn(t, e, n);
|
|
3478
3586
|
for (let e of r) this.liveUpdateShape(e.id, e.points);
|
|
3479
3587
|
if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
|
|
3480
3588
|
n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandles(i);
|
|
@@ -3501,18 +3609,18 @@ var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
|
3501
3609
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
3502
3610
|
return;
|
|
3503
3611
|
}
|
|
3504
|
-
let { updates: n } =
|
|
3612
|
+
let { updates: n } = Nn(e, t, Mn(this.shapes, e));
|
|
3505
3613
|
this.commitTransformUpdates(n);
|
|
3506
3614
|
}
|
|
3507
|
-
},
|
|
3508
|
-
function
|
|
3509
|
-
if (!e) return
|
|
3615
|
+
}, qn = 2, Jn = 58879, Yn = 6725103;
|
|
3616
|
+
function $(e) {
|
|
3617
|
+
if (!e) return Jn;
|
|
3510
3618
|
let t = e.replace("#", "");
|
|
3511
3619
|
return Number.parseInt(t.length === 3 ? t.replace(/./g, "$&$&") : t, 16);
|
|
3512
3620
|
}
|
|
3513
|
-
var
|
|
3621
|
+
var Xn = class {
|
|
3514
3622
|
constructor(e, t) {
|
|
3515
|
-
this.app = new w(), this.world = new E(), this.bgLayer = new E(), this.overlayLayer = new E(), this.shapeLayer = new E(), this.selLayer = new E(), this.previewLayer = new E(), this.handleLayer = new E(), this.filter = new T(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.overlayTextures = [], this.region = null, this.regionOutlineG =
|
|
3623
|
+
this.app = new w(), this.world = new E(), this.bgLayer = new E(), this.overlayLayer = new E(), this.guideOverlayLayer = new E(), this.regionOverlayLayer = new E(), this.dimOverlayLayer = new E(), this.shapeLayer = new E(), this.selLayer = new E(), this.previewLayer = new E(), this.handleLayer = new E(), this.filter = new T(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.overlayTextures = [], this.region = null, this.regionDimMaskG = new D(), this.regionDimG = new D(), this.regionZoneMaskG = new D(), this.regionZoneG = new D(), this.regionOutlineG = new D(), this.baseCursor = "default", this.strokeSize = qn, this.shapes = [], this.selected = [], this.nodes = /* @__PURE__ */ new Map(), this.lastAppliedScale = -1, this.brightness = 1, this.contrast = 1, this.imageSmoothing = !0, this.destroyed = !1, this.transformEnabled = !1, this.handleNodes = [], this.vertexNodes = [], this.lastDragImg = null, this.activeDrag = null, this.midNodes = [], this.selectedVertices = /* @__PURE__ */ new Set(), this.vertexPolygonId = null, this.editingId = null, this.rotNode = null, this.rotLineNode = null, this.transformerOutline = null, this.selectionBorderGfx = [], this.previewG = new D(), this.marqueeG = new D(), this.previewMaskSprite = null, this.previewMaskTexture = null, this.previewReady = !1, this.lastPreview = null, this.host = e, this.cb = t;
|
|
3516
3624
|
}
|
|
3517
3625
|
ev(e) {
|
|
3518
3626
|
return {
|
|
@@ -3539,7 +3647,10 @@ var jn = class {
|
|
|
3539
3647
|
this.app.destroy(!0);
|
|
3540
3648
|
return;
|
|
3541
3649
|
}
|
|
3542
|
-
this.host.appendChild(this.app.canvas), this.applyCursor(), this.
|
|
3650
|
+
this.host.appendChild(this.app.canvas), this.applyCursor(), this.overlayLayer.addChild(this.guideOverlayLayer, this.regionOverlayLayer, this.dimOverlayLayer), this.regionOverlayLayer.addChild(this.regionDimMaskG, this.regionDimG, this.regionZoneMaskG, this.regionZoneG, this.regionOutlineG), this.regionDimG.setMask({
|
|
3651
|
+
mask: this.regionDimMaskG,
|
|
3652
|
+
inverse: !0
|
|
3653
|
+
}), this.regionZoneG.setMask({ mask: this.regionZoneMaskG }), this.world.addChild(this.bgLayer, this.overlayLayer, this.shapeLayer, this.selLayer, this.previewLayer), this.app.stage.addChild(this.world, this.handleLayer), this.world.visible = !1, this.app.stage.eventMode = "static", this.syncHitArea(), this.app.stage.on("pointerdown", (e) => {
|
|
3543
3654
|
this.cb.onPointerDown(this.toImage(e), null, this.ev(e));
|
|
3544
3655
|
}), this.app.stage.on("pointermove", (e) => {
|
|
3545
3656
|
if (this.activeDrag) {
|
|
@@ -3607,7 +3718,7 @@ var jn = class {
|
|
|
3607
3718
|
};
|
|
3608
3719
|
}
|
|
3609
3720
|
async setImage(e, t, n) {
|
|
3610
|
-
let r = ++this.imageLoadToken, i = await
|
|
3721
|
+
let r = ++this.imageLoadToken, i = await Sn(e);
|
|
3611
3722
|
if (this.destroyed) {
|
|
3612
3723
|
i && URL.revokeObjectURL(i);
|
|
3613
3724
|
return;
|
|
@@ -3619,8 +3730,8 @@ var jn = class {
|
|
|
3619
3730
|
this.imageWidth = t?.width ?? o.naturalWidth, this.imageHeight = t?.height ?? o.naturalHeight;
|
|
3620
3731
|
let e = n?.width ?? this.imageWidth, s = n?.height ?? this.imageHeight;
|
|
3621
3732
|
this.bgLayer.scale.set(e / o.naturalWidth, s / o.naturalHeight), this.clearImageTiles();
|
|
3622
|
-
for (let e of
|
|
3623
|
-
let t = A.from(
|
|
3733
|
+
for (let e of wn(o.naturalWidth, o.naturalHeight)) {
|
|
3734
|
+
let t = A.from(Tn(o, e));
|
|
3624
3735
|
t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
|
|
3625
3736
|
let n = new k(t);
|
|
3626
3737
|
n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
|
|
@@ -3662,43 +3773,35 @@ var jn = class {
|
|
|
3662
3773
|
!this.destroyed && this.app.renderer && this.app.render();
|
|
3663
3774
|
}
|
|
3664
3775
|
setOverlays(e, t, n) {
|
|
3665
|
-
for (let e of this.
|
|
3666
|
-
this.regionOutlineG = null, this.region = t;
|
|
3776
|
+
for (let e of this.guideOverlayLayer.removeChildren()) e.destroy();
|
|
3667
3777
|
for (let e of this.overlayTextures) e.destroy(!0);
|
|
3668
3778
|
if (this.overlayTextures = [], e) {
|
|
3669
3779
|
let t = A.from(e);
|
|
3670
3780
|
t.source.scaleMode = "nearest", this.overlayTextures.push(t);
|
|
3671
3781
|
let n = new k(t);
|
|
3672
|
-
n.alpha = .55, this.
|
|
3673
|
-
}
|
|
3674
|
-
if (t) {
|
|
3675
|
-
let e = Q(t.dim.color), n = () => {
|
|
3676
|
-
let e = new D();
|
|
3677
|
-
for (let n of t.rects) e.rect(n.x, n.y, n.w, n.h).fill(16777215);
|
|
3678
|
-
return e;
|
|
3679
|
-
}, r = new D().rect(0, 0, this.imageWidth, this.imageHeight).fill({
|
|
3680
|
-
color: e,
|
|
3681
|
-
alpha: t.dim.opacity
|
|
3682
|
-
}), i = n();
|
|
3683
|
-
if (this.overlayLayer.addChild(i, r), r.setMask({
|
|
3684
|
-
mask: i,
|
|
3685
|
-
inverse: !0
|
|
3686
|
-
}), t.zones.length) {
|
|
3687
|
-
let r = new D();
|
|
3688
|
-
for (let n of t.zones) r.poly(n.points.flatMap((e) => [e.x, e.y]), !0).fill({
|
|
3689
|
-
color: e,
|
|
3690
|
-
alpha: t.dim.opacity
|
|
3691
|
-
});
|
|
3692
|
-
let i = n();
|
|
3693
|
-
this.overlayLayer.addChild(i, r), r.setMask({ mask: i });
|
|
3694
|
-
}
|
|
3695
|
-
t.outlineStyles && (this.regionOutlineG = this.overlayLayer.addChild(new D()), this.redrawRegionOutline());
|
|
3782
|
+
n.alpha = .55, this.guideOverlayLayer.addChild(n);
|
|
3696
3783
|
}
|
|
3697
|
-
|
|
3784
|
+
this.setRegionOverlay(t);
|
|
3785
|
+
for (let e of this.dimOverlayLayer.removeChildren()) e.destroy();
|
|
3786
|
+
n && this.imageWidth && this.dimOverlayLayer.addChild(new D().rect(0, 0, this.imageWidth, this.imageHeight).fill({
|
|
3698
3787
|
color: 855314,
|
|
3699
3788
|
alpha: .3
|
|
3700
3789
|
})), !this.destroyed && this.app.renderer && this.app.render();
|
|
3701
3790
|
}
|
|
3791
|
+
setRegionOverlay(e) {
|
|
3792
|
+
if (this.region = e, this.regionDimMaskG.clear(), this.regionDimG.clear(), this.regionZoneMaskG.clear(), this.regionZoneG.clear(), this.regionOutlineG.clear(), !e) return;
|
|
3793
|
+
let t = $(e.dim.color);
|
|
3794
|
+
for (let t of e.rects) this.regionDimMaskG.rect(t.x, t.y, t.w, t.h).fill(16777215), this.regionZoneMaskG.rect(t.x, t.y, t.w, t.h).fill(16777215);
|
|
3795
|
+
this.regionDimG.rect(0, 0, this.imageWidth, this.imageHeight).fill({
|
|
3796
|
+
color: t,
|
|
3797
|
+
alpha: e.dim.opacity
|
|
3798
|
+
});
|
|
3799
|
+
for (let n of e.zones) this.regionZoneG.poly(n.points.flatMap((e) => [e.x, e.y]), !0).fill({
|
|
3800
|
+
color: t,
|
|
3801
|
+
alpha: e.dim.opacity
|
|
3802
|
+
});
|
|
3803
|
+
this.redrawRegionOutline();
|
|
3804
|
+
}
|
|
3702
3805
|
get viewport() {
|
|
3703
3806
|
return {
|
|
3704
3807
|
scale: this.world.scale.x,
|
|
@@ -3708,7 +3811,7 @@ var jn = class {
|
|
|
3708
3811
|
}
|
|
3709
3812
|
applyViewport(e) {
|
|
3710
3813
|
let t = e.scale !== this.lastAppliedScale;
|
|
3711
|
-
this.lastAppliedScale = e.scale, this.world.scale.set(e.scale), this.world.position.set(e.x, e.y), this.world.visible = !0, t && this.restrokeShapes(), this.activeDrag ? this.dragTransform(this.lastDragImg ??
|
|
3814
|
+
this.lastAppliedScale = e.scale, this.world.scale.set(e.scale), this.world.position.set(e.x, e.y), this.world.visible = !0, t && this.restrokeShapes(), this.activeDrag ? this.dragTransform(this.lastDragImg ?? Pn(this.shapes, this.activeDrag)) : this.drawTransformer(), this.cb.onViewportChange?.();
|
|
3712
3815
|
}
|
|
3713
3816
|
fit() {
|
|
3714
3817
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -3744,7 +3847,7 @@ var jn = class {
|
|
|
3744
3847
|
});
|
|
3745
3848
|
}
|
|
3746
3849
|
setShapes(e, t) {
|
|
3747
|
-
this.shapes =
|
|
3850
|
+
this.shapes = In(e), this.selected = t, !this.activeDrag && (this.drawShapes(), this.drawSelectionBorders(), this.drawTransformer());
|
|
3748
3851
|
}
|
|
3749
3852
|
setSelection(e) {
|
|
3750
3853
|
this.selected = e, (e.length !== 1 || e[0] !== this.vertexPolygonId) && (this.vertexPolygonId = null, this.selectedVertices.clear()), this.editingId && (e.length !== 1 || e[0] !== this.editingId) && (this.editingId = null), !this.activeDrag && (this.drawSelectionBorders(), this.drawTransformer());
|
|
@@ -3759,10 +3862,10 @@ var jn = class {
|
|
|
3759
3862
|
this.handleLayer.interactiveChildren = !e;
|
|
3760
3863
|
}
|
|
3761
3864
|
strokeW(e) {
|
|
3762
|
-
return (e ? Pe(e, { strokeWidth: this.strokeSize }).strokeWidth :
|
|
3865
|
+
return (e ? Pe(e, { strokeWidth: this.strokeSize }).strokeWidth : qn) / this.world.scale.x;
|
|
3763
3866
|
}
|
|
3764
3867
|
pointRadius(e) {
|
|
3765
|
-
return
|
|
3868
|
+
return zn(e, this.strokeSize, this.world.scale.x);
|
|
3766
3869
|
}
|
|
3767
3870
|
dashForShape(e) {
|
|
3768
3871
|
let t = Pe(e, { strokeWidth: this.strokeSize }).dash;
|
|
@@ -3787,9 +3890,9 @@ var jn = class {
|
|
|
3787
3890
|
}
|
|
3788
3891
|
paintShape(e, t) {
|
|
3789
3892
|
e.clear();
|
|
3790
|
-
let n = Pe(t, { strokeWidth: this.strokeSize }), r =
|
|
3893
|
+
let n = Pe(t, { strokeWidth: this.strokeSize }), r = $(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
|
|
3791
3894
|
if (t.type === j.POINT) {
|
|
3792
|
-
e.svg(
|
|
3895
|
+
e.svg(An(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
|
|
3793
3896
|
let r = 1 / (this.world.scale.x || 1);
|
|
3794
3897
|
e.scale.set(r, r), e.alpha = a;
|
|
3795
3898
|
return;
|
|
@@ -3803,7 +3906,7 @@ var jn = class {
|
|
|
3803
3906
|
})), o) {
|
|
3804
3907
|
t.style?.alternateColor && (this.path(e, t), e.stroke({
|
|
3805
3908
|
width: i,
|
|
3806
|
-
color:
|
|
3909
|
+
color: $(t.style.alternateColor),
|
|
3807
3910
|
alpha: a
|
|
3808
3911
|
})), this.dashedStrokeShape(e, t, i, r, a, o);
|
|
3809
3912
|
return;
|
|
@@ -3822,7 +3925,7 @@ var jn = class {
|
|
|
3822
3925
|
});
|
|
3823
3926
|
}
|
|
3824
3927
|
shapesIntersecting(e) {
|
|
3825
|
-
return
|
|
3928
|
+
return Rn(this.shapes, e);
|
|
3826
3929
|
}
|
|
3827
3930
|
shapesAt(e) {
|
|
3828
3931
|
return this.shapes.filter((t) => {
|
|
@@ -3859,16 +3962,16 @@ var jn = class {
|
|
|
3859
3962
|
}, a = this.strokeW(i);
|
|
3860
3963
|
r.alternateColor && (this.path(this.previewG, i), this.previewG.stroke({
|
|
3861
3964
|
width: a,
|
|
3862
|
-
color:
|
|
3965
|
+
color: $(r.alternateColor)
|
|
3863
3966
|
}));
|
|
3864
3967
|
let o = this.dashForShape(i);
|
|
3865
3968
|
if (o) {
|
|
3866
|
-
this.dashedStrokeShape(this.previewG, i, a,
|
|
3969
|
+
this.dashedStrokeShape(this.previewG, i, a, $(r.color ?? "#00e5ff"), r.opacity ?? 1, o);
|
|
3867
3970
|
return;
|
|
3868
3971
|
}
|
|
3869
3972
|
this.path(this.previewG, i), this.previewG.stroke({
|
|
3870
3973
|
width: a,
|
|
3871
|
-
color:
|
|
3974
|
+
color: $(r.color ?? "#00e5ff"),
|
|
3872
3975
|
alpha: r.opacity ?? 1
|
|
3873
3976
|
});
|
|
3874
3977
|
}
|
|
@@ -3890,12 +3993,12 @@ var jn = class {
|
|
|
3890
3993
|
}, c = this.strokeW(s);
|
|
3891
3994
|
n.alternateColor && (this.path(this.previewG, s), this.previewG.stroke({
|
|
3892
3995
|
width: c,
|
|
3893
|
-
color:
|
|
3996
|
+
color: $(n.alternateColor)
|
|
3894
3997
|
}));
|
|
3895
3998
|
let l = this.dashForShape(s);
|
|
3896
|
-
if (l ? this.dashedStrokeShape(this.previewG, s, c,
|
|
3999
|
+
if (l ? this.dashedStrokeShape(this.previewG, s, c, $(n.color ?? "#00e5ff"), n.opacity ?? 1, l) : (this.path(this.previewG, s), this.previewG.stroke({
|
|
3897
4000
|
width: c,
|
|
3898
|
-
color:
|
|
4001
|
+
color: $(n.color ?? "#00e5ff"),
|
|
3899
4002
|
alpha: n.opacity ?? 1
|
|
3900
4003
|
})), !a) return;
|
|
3901
4004
|
let u = new Set(i), d = 5 / this.world.scale.x, f = 6 / this.world.scale.x;
|
|
@@ -3909,12 +4012,12 @@ var jn = class {
|
|
|
3909
4012
|
}
|
|
3910
4013
|
previewScalarMask(e, t) {
|
|
3911
4014
|
this.lastPreview = null, this.ensurePreview(), this.previewG.clear();
|
|
3912
|
-
let n =
|
|
4015
|
+
let n = nn(e, t.length === 7 ? `${t}99` : t);
|
|
3913
4016
|
this.previewMaskTexture && this.previewMaskTexture.destroy(!0), this.previewMaskTexture = A.from(n), this.previewMaskSprite ? (this.previewMaskSprite.texture = this.previewMaskTexture, this.previewMaskSprite.visible = !0) : (this.previewMaskSprite = new k(this.previewMaskTexture), this.previewLayer.addChildAt(this.previewMaskSprite, 0)), this.previewMaskSprite.x = e.ox, this.previewMaskSprite.y = e.oy, this.previewMaskSprite.width = n.width / e.scale, this.previewMaskSprite.height = n.height / e.scale;
|
|
3914
4017
|
}
|
|
3915
4018
|
previewMarquee(e, t) {
|
|
3916
4019
|
this.ensurePreview(), this.marqueeG.clear();
|
|
3917
|
-
let n = Math.min(e.x, t.x), r = Math.min(e.y, t.y), i = Math.abs(t.x - e.x), a = Math.abs(t.y - e.y), o =
|
|
4020
|
+
let n = Math.min(e.x, t.x), r = Math.min(e.y, t.y), i = Math.abs(t.x - e.x), a = Math.abs(t.y - e.y), o = $(Ae);
|
|
3918
4021
|
this.marqueeG.rect(n, r, i, a).fill({
|
|
3919
4022
|
color: o,
|
|
3920
4023
|
alpha: je
|
|
@@ -3936,7 +4039,6 @@ var jn = class {
|
|
|
3936
4039
|
}
|
|
3937
4040
|
redrawRegionOutline() {
|
|
3938
4041
|
let e = this.regionOutlineG;
|
|
3939
|
-
if (!e) return;
|
|
3940
4042
|
e.clear();
|
|
3941
4043
|
let t = this.region?.outlineStyles;
|
|
3942
4044
|
if (!this.region || !t) return;
|
|
@@ -3949,8 +4051,8 @@ var jn = class {
|
|
|
3949
4051
|
o.y
|
|
3950
4052
|
], !1).stroke({
|
|
3951
4053
|
width: i,
|
|
3952
|
-
color:
|
|
3953
|
-
}), this.strokeDashedPolyline(e, [n, o], !1, i,
|
|
4054
|
+
color: $(r.underlayColor)
|
|
4055
|
+
}), this.strokeDashedPolyline(e, [n, o], !1, i, $(r.color), r.opacity, a);
|
|
3954
4056
|
};
|
|
3955
4057
|
r(this.region.visibleOutline, t.visible), r(this.region.occludedOutline, t.occluded);
|
|
3956
4058
|
}
|
|
@@ -4046,7 +4148,7 @@ var jn = class {
|
|
|
4046
4148
|
let r = this.selectionBorderGfx[t];
|
|
4047
4149
|
r.clear(), r.poly(this.selectionOutlinePoints(e, e.points).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4048
4150
|
width: n,
|
|
4049
|
-
color:
|
|
4151
|
+
color: Yn
|
|
4050
4152
|
});
|
|
4051
4153
|
});
|
|
4052
4154
|
}
|
|
@@ -4057,12 +4159,12 @@ var jn = class {
|
|
|
4057
4159
|
let a = this.selectionBorderGfx[r++];
|
|
4058
4160
|
a && (a.clear(), a.poly(this.selectionOutlinePoints(i, e(i)).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4059
4161
|
width: n,
|
|
4060
|
-
color:
|
|
4162
|
+
color: Yn
|
|
4061
4163
|
}));
|
|
4062
4164
|
}
|
|
4063
4165
|
}
|
|
4064
4166
|
selectionOutlinePoints(e, t) {
|
|
4065
|
-
return
|
|
4167
|
+
return Bn(e, t, this.pointRadius(e));
|
|
4066
4168
|
}
|
|
4067
4169
|
imgToScreen(e) {
|
|
4068
4170
|
let t = this.world.toGlobal({
|
|
@@ -4091,7 +4193,7 @@ var jn = class {
|
|
|
4091
4193
|
}));
|
|
4092
4194
|
}
|
|
4093
4195
|
rotationHandleGap() {
|
|
4094
|
-
return
|
|
4196
|
+
return Vn(this.viewport.scale);
|
|
4095
4197
|
}
|
|
4096
4198
|
rotationHandleScreenPoint(e) {
|
|
4097
4199
|
return this.imgToScreen(he(e, this.rotationHandleGap()));
|
|
@@ -4107,7 +4209,7 @@ var jn = class {
|
|
|
4107
4209
|
e.position.set(t.x, t.y), e.rotation = n;
|
|
4108
4210
|
}
|
|
4109
4211
|
orientedHandleAngle(e) {
|
|
4110
|
-
return
|
|
4212
|
+
return Hn(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
4111
4213
|
}
|
|
4112
4214
|
drawTransformer() {
|
|
4113
4215
|
if (this.activeDrag) return;
|
|
@@ -4115,7 +4217,7 @@ var jn = class {
|
|
|
4115
4217
|
for (let e of this.vertexNodes) e.destroy();
|
|
4116
4218
|
for (let e of this.midNodes) e.destroy();
|
|
4117
4219
|
if (this.rotNode?.destroy(), this.rotNode = null, this.rotLineNode?.destroy(), this.rotLineNode = null, this.transformerOutline?.destroy(), this.transformerOutline = null, this.handleNodes = [], this.vertexNodes = [], this.midNodes = [], !this.transformEnabled) return;
|
|
4118
|
-
let e =
|
|
4220
|
+
let e = Ln(this.shapes, this.selected);
|
|
4119
4221
|
if (e.length === 0 || e.length === 1 && e[0].type === j.POINT) return;
|
|
4120
4222
|
let t = e.length === 1 && (e[0].type === j.POLYGON || e[0].type === j.LINE) && this.editingId === e[0].id ? e[0] : null, n = I(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === j.ROTATED_RECTANGLE ? e[0] : null, i = r ? me(r.points) : F.map((e) => ie(e, n));
|
|
4121
4223
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
@@ -4126,10 +4228,10 @@ var jn = class {
|
|
|
4126
4228
|
width: 1,
|
|
4127
4229
|
color: 2001125
|
|
4128
4230
|
}), this.layoutResizeHandle(n, t, a), n.eventMode = "static";
|
|
4129
|
-
let r =
|
|
4231
|
+
let r = pt(e, a);
|
|
4130
4232
|
this.bindCursor(n, r), n.on("pointerdown", (t) => {
|
|
4131
4233
|
t.stopPropagation(), this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
4132
|
-
let n =
|
|
4234
|
+
let n = Ln(this.shapes, this.selected);
|
|
4133
4235
|
this.activeDrag = {
|
|
4134
4236
|
kind: "resize",
|
|
4135
4237
|
anchor: e,
|
|
@@ -4208,7 +4310,7 @@ var jn = class {
|
|
|
4208
4310
|
}
|
|
4209
4311
|
}
|
|
4210
4312
|
beginMove(e, t) {
|
|
4211
|
-
let n =
|
|
4313
|
+
let n = Fn(this.shapes, t, e);
|
|
4212
4314
|
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === j.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
4213
4315
|
}
|
|
4214
4316
|
repositionHandlesForBox(e) {
|
|
@@ -4266,7 +4368,7 @@ var jn = class {
|
|
|
4266
4368
|
let t = this.activeDrag;
|
|
4267
4369
|
if (!t) return;
|
|
4268
4370
|
this.applyCursor();
|
|
4269
|
-
let n =
|
|
4371
|
+
let n = Mn(this.shapes, t), { updates: r, box: i } = Nn(t, e, n);
|
|
4270
4372
|
if (t.kind === "move") {
|
|
4271
4373
|
let n = e.x - t.start.x, r = e.y - t.start.y;
|
|
4272
4374
|
for (let e of t.shapes) {
|
|
@@ -4298,13 +4400,13 @@ var jn = class {
|
|
|
4298
4400
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
4299
4401
|
return;
|
|
4300
4402
|
}
|
|
4301
|
-
let { updates: n } =
|
|
4403
|
+
let { updates: n } = Nn(e, t, Mn(this.shapes, e));
|
|
4302
4404
|
e.kind === "move" && this.resetMoveOffsets(), this.commitTransformUpdates(n);
|
|
4303
4405
|
}
|
|
4304
4406
|
};
|
|
4305
4407
|
//#endregion
|
|
4306
4408
|
//#region src/components/ShapeEditor/_state/useEngineLifecycle.ts
|
|
4307
|
-
function
|
|
4409
|
+
function Zn({ backend: e, hostRef: t, engineRef: n, imageUrl: r, renderedImageUrl: i, makeCallbacks: a, viewRef: o, readOnlyRef: s, toolRef: c, renderShapesRef: l, coordinateSizeRef: u, imageSizeRef: d, selRef: p, maskCanvasRef: m, regionOverlayRef: h, dimmedRef: g, syncMinimap: _, setImage: y, setImageVisible: b, setReady: x, setImageStatus: S, onContextMenuRequest: C }) {
|
|
4308
4410
|
let w = v(i);
|
|
4309
4411
|
w.current = i;
|
|
4310
4412
|
let T = v(r);
|
|
@@ -4315,7 +4417,7 @@ function Mn({ backend: e, hostRef: t, engineRef: n, imageUrl: r, renderedImageUr
|
|
|
4315
4417
|
j.current = C, f(() => {
|
|
4316
4418
|
let r = t.current;
|
|
4317
4419
|
if (!r) return;
|
|
4318
|
-
let i = !1, a = null, f = null, v = A.current(), S = e === "konva" ? new
|
|
4420
|
+
let i = !1, a = null, f = null, v = A.current(), S = e === "konva" ? new Kn(r, v) : new Xn(r, v);
|
|
4319
4421
|
return n.current = S, (async () => {
|
|
4320
4422
|
if (await S.init(), !i) {
|
|
4321
4423
|
if (S.setFilter(o.current.brightness, o.current.contrast), S.setStrokeSize(o.current.strokeSize), S.setImageSmoothing(o.current.imageSmoothing), S.setTransformEnabled(!s.current), O.current = !0, w.current) {
|
|
@@ -4365,19 +4467,27 @@ function Mn({ backend: e, hostRef: t, engineRef: n, imageUrl: r, renderedImageUr
|
|
|
4365
4467
|
};
|
|
4366
4468
|
}, [e]), f(() => {
|
|
4367
4469
|
let e = n.current;
|
|
4368
|
-
if (!e || !O.current
|
|
4369
|
-
let t =
|
|
4370
|
-
|
|
4371
|
-
|
|
4470
|
+
if (!e || !O.current) return;
|
|
4471
|
+
let t = D.current !== r, a = () => {
|
|
4472
|
+
x(!1), b(!1), e.clearImage(), e.setShapes([], []), e.setOverlays(null, null, !1);
|
|
4473
|
+
};
|
|
4474
|
+
if (!i) {
|
|
4475
|
+
t && (E.current = null, a());
|
|
4476
|
+
return;
|
|
4477
|
+
}
|
|
4478
|
+
if (!t && E.current === i) return;
|
|
4479
|
+
let s = i;
|
|
4480
|
+
t && a();
|
|
4481
|
+
let c = !1;
|
|
4372
4482
|
return (async () => {
|
|
4373
|
-
await e.setImage(
|
|
4483
|
+
await e.setImage(s, u.current, d.current), !(c || n.current !== e) && (E.current = s, t && (D.current = r, y({
|
|
4374
4484
|
w: e.imageWidth,
|
|
4375
4485
|
h: e.imageHeight
|
|
4376
4486
|
}), b(!0), e.setShapes(l.current, p.current), e.setOverlays(o.current.showGuide ? m.current : null, o.current.showRegionMask ? h.current : null, g.current), o.current.keepZoomOnImageChange || e.fit(), _(), x(!0)));
|
|
4377
4487
|
})(), () => {
|
|
4378
|
-
|
|
4488
|
+
c = !0;
|
|
4379
4489
|
};
|
|
4380
|
-
}, [i]), f(() => {
|
|
4490
|
+
}, [r, i]), f(() => {
|
|
4381
4491
|
let e = !1;
|
|
4382
4492
|
if (!i) {
|
|
4383
4493
|
S("loading");
|
|
@@ -4396,12 +4506,12 @@ function Mn({ backend: e, hostRef: t, engineRef: n, imageUrl: r, renderedImageUr
|
|
|
4396
4506
|
}
|
|
4397
4507
|
//#endregion
|
|
4398
4508
|
//#region src/components/ShapeEditor/_state/useMinimapNavigation.ts
|
|
4399
|
-
var
|
|
4400
|
-
function
|
|
4509
|
+
var Qn = .05, $n = 20;
|
|
4510
|
+
function er(e) {
|
|
4401
4511
|
let { deltaY: t, deltaX: n, deltaMode: r } = e;
|
|
4402
4512
|
return r === 0 ? Math.abs(t) < 10 || Math.abs(n) < 10 || !Number.isInteger(t) || !Number.isInteger(n) : r === 1 ? !1 : !Number.isInteger(t) || !Number.isInteger(n);
|
|
4403
4513
|
}
|
|
4404
|
-
function
|
|
4514
|
+
function tr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
4405
4515
|
let i = v(null), a = !!t && t.w > 0 && t.h > 0, o = a ? Math.min(r / t.w, r / t.h) : 1, s = a ? t.w * o : 0, c = a ? t.h * o : 0, l = a ? (r - s) / 2 : 0, u = a ? (r - c) / 2 : 0, d = (e) => {
|
|
4406
4516
|
let t = e.currentTarget.getBoundingClientRect();
|
|
4407
4517
|
return {
|
|
@@ -4464,7 +4574,7 @@ function In({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4464
4574
|
let r = e.current;
|
|
4465
4575
|
if (!r || !n) return;
|
|
4466
4576
|
t.preventDefault(), t.stopPropagation();
|
|
4467
|
-
let i =
|
|
4577
|
+
let i = er(t.nativeEvent) ? 2.5 : 1, a = t.deltaY * i, o = 1.05, s = a > 0 ? r.viewport.scale / o : r.viewport.scale * o, c = Math.max(Qn, Math.min($n, s));
|
|
4468
4578
|
p(d(t), c);
|
|
4469
4579
|
},
|
|
4470
4580
|
zoomCentered: (t) => {
|
|
@@ -4477,7 +4587,7 @@ function In({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4477
4587
|
}
|
|
4478
4588
|
//#endregion
|
|
4479
4589
|
//#region src/components/ShapeEditor/_state/useMinimapSync.ts
|
|
4480
|
-
function
|
|
4590
|
+
function nr(e, t, n) {
|
|
4481
4591
|
if (!(!e || !n.length)) {
|
|
4482
4592
|
if (t.type === j.POINT) {
|
|
4483
4593
|
e.setAttribute("cx", String(n[0].x)), e.setAttribute("cy", String(n[0].y));
|
|
@@ -4495,7 +4605,7 @@ function Ln(e, t, n) {
|
|
|
4495
4605
|
e.setAttribute("points", n.map((e) => `${e.x},${e.y}`).join(" "));
|
|
4496
4606
|
}
|
|
4497
4607
|
}
|
|
4498
|
-
function
|
|
4608
|
+
function rr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRectRef: i, minimapSize: a, onViewportChangeRef: o }) {
|
|
4499
4609
|
let s = v(/* @__PURE__ */ new Map());
|
|
4500
4610
|
return {
|
|
4501
4611
|
registerMinimapShape: d((e, t) => {
|
|
@@ -4504,13 +4614,13 @@ function Rn({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
4504
4614
|
applyMinimapPreview: d((e) => {
|
|
4505
4615
|
let n = t.current.getShapes();
|
|
4506
4616
|
if (!e.length) {
|
|
4507
|
-
for (let e of n)
|
|
4617
|
+
for (let e of n) nr(s.current.get(e.id), e, e.points);
|
|
4508
4618
|
return;
|
|
4509
4619
|
}
|
|
4510
4620
|
let r = new Map(n.map((e) => [e.id, e]));
|
|
4511
4621
|
for (let t of e) {
|
|
4512
4622
|
let e = r.get(t.id);
|
|
4513
|
-
e &&
|
|
4623
|
+
e && nr(s.current.get(e.id), e, t.points);
|
|
4514
4624
|
}
|
|
4515
4625
|
}, [t]),
|
|
4516
4626
|
syncMinimap: d(() => {
|
|
@@ -4539,44 +4649,68 @@ function Rn({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
4539
4649
|
}
|
|
4540
4650
|
//#endregion
|
|
4541
4651
|
//#region src/components/ShapeEditor/_state/useSelectionActions.ts
|
|
4542
|
-
var
|
|
4543
|
-
function
|
|
4544
|
-
let
|
|
4652
|
+
var ir = 12;
|
|
4653
|
+
function ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMergeSelection: i, clipboardDocumentId: a, clipboardScope: o }) {
|
|
4654
|
+
let s = v(0), c = v(!0), l = v(n), u = v(a), p = v(o);
|
|
4655
|
+
l.current = n, u.current = a, p.current = o, f(() => (c.current = !0, () => {
|
|
4656
|
+
c.current = !1;
|
|
4657
|
+
}), []), f(() => {
|
|
4658
|
+
s.current = 0;
|
|
4659
|
+
}, [a]);
|
|
4660
|
+
let m = d(() => r(e.getShapes().filter((e) => P(e)).map((e) => e.id)), [e, r]), h = d(() => r([]), [r]), g = d(() => e.getShapes().filter((e) => t.current.includes(e.id) && ee(e)), [e, t]), _ = d(() => {
|
|
4545
4661
|
if (n || !t.current.length) return;
|
|
4546
|
-
let i =
|
|
4662
|
+
let i = g().map((e) => e.id);
|
|
4547
4663
|
i.length && (e.remove(i), r([]));
|
|
4548
4664
|
}, [
|
|
4549
4665
|
e,
|
|
4550
4666
|
n,
|
|
4551
4667
|
r,
|
|
4552
|
-
|
|
4668
|
+
g,
|
|
4553
4669
|
t
|
|
4554
|
-
]),
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
if (n || !a.current.length) return;
|
|
4558
|
-
o.current += 1;
|
|
4559
|
-
let t = zn * o.current, i = a.current.map((e) => ({
|
|
4560
|
-
...e,
|
|
4561
|
-
id: re(),
|
|
4562
|
-
points: e.points.map((e) => ({
|
|
4563
|
-
x: e.x + t,
|
|
4564
|
-
y: e.y + t
|
|
4565
|
-
}))
|
|
4566
|
-
}));
|
|
4567
|
-
e.create(i), r(i.map((e) => e.id));
|
|
4670
|
+
]), y = d(() => {
|
|
4671
|
+
let e = g();
|
|
4672
|
+
e.length && (s.current = 0, st(it(e, a, o)));
|
|
4568
4673
|
}, [
|
|
4674
|
+
a,
|
|
4675
|
+
o,
|
|
4676
|
+
g
|
|
4677
|
+
]), b = d(() => ct(o), [o]), x = d((t) => {
|
|
4678
|
+
if (n) return;
|
|
4679
|
+
let i = a;
|
|
4680
|
+
lt(o).then((n) => {
|
|
4681
|
+
if (!c.current || l.current || u.current !== i || p.current !== o || !n?.shapes.length) return;
|
|
4682
|
+
let d, f, m = n.shapes.flatMap((e) => e.points);
|
|
4683
|
+
if (t && m.length) {
|
|
4684
|
+
let e = I(m);
|
|
4685
|
+
d = t.x - (e.minX + e.maxX) / 2, f = t.y - (e.minY + e.maxY) / 2;
|
|
4686
|
+
} else {
|
|
4687
|
+
let e = !!n.documentId && n.documentId !== a, t = ut(s.current, e, ir);
|
|
4688
|
+
d = t.offset, s.current = t.nextPasteCount, f = d;
|
|
4689
|
+
}
|
|
4690
|
+
let h = n.shapes.map((e) => ({
|
|
4691
|
+
...e,
|
|
4692
|
+
id: re(),
|
|
4693
|
+
points: e.points.map((e) => ({
|
|
4694
|
+
x: e.x + d,
|
|
4695
|
+
y: e.y + f
|
|
4696
|
+
}))
|
|
4697
|
+
}));
|
|
4698
|
+
e.create(h), r(h.map((e) => e.id));
|
|
4699
|
+
});
|
|
4700
|
+
}, [
|
|
4701
|
+
a,
|
|
4702
|
+
o,
|
|
4569
4703
|
e,
|
|
4570
4704
|
n,
|
|
4571
4705
|
r
|
|
4572
|
-
]),
|
|
4706
|
+
]), S = d(() => {
|
|
4573
4707
|
if (n || !t.current.length) return;
|
|
4574
|
-
let i =
|
|
4708
|
+
let i = g().map((e) => ({
|
|
4575
4709
|
...e,
|
|
4576
4710
|
id: re(),
|
|
4577
4711
|
points: e.points.map((e) => ({
|
|
4578
|
-
x: e.x +
|
|
4579
|
-
y: e.y +
|
|
4712
|
+
x: e.x + ir,
|
|
4713
|
+
y: e.y + ir
|
|
4580
4714
|
}))
|
|
4581
4715
|
}));
|
|
4582
4716
|
i.length && (e.create(i), r(i.map((e) => e.id)));
|
|
@@ -4584,25 +4718,25 @@ function Bn({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4584
4718
|
e,
|
|
4585
4719
|
n,
|
|
4586
4720
|
r,
|
|
4587
|
-
|
|
4721
|
+
g,
|
|
4588
4722
|
t
|
|
4589
|
-
]),
|
|
4723
|
+
]), C = d(() => {
|
|
4590
4724
|
if (n) return;
|
|
4591
|
-
let t =
|
|
4725
|
+
let t = g().map((e) => e.id);
|
|
4592
4726
|
t.length && e.reorder(t, "front");
|
|
4593
4727
|
}, [
|
|
4594
4728
|
e,
|
|
4595
4729
|
n,
|
|
4596
|
-
|
|
4597
|
-
]),
|
|
4730
|
+
g
|
|
4731
|
+
]), w = d(() => {
|
|
4598
4732
|
if (n) return;
|
|
4599
|
-
let t =
|
|
4733
|
+
let t = g().map((e) => e.id);
|
|
4600
4734
|
t.length && e.reorder(t, "back");
|
|
4601
4735
|
}, [
|
|
4602
4736
|
e,
|
|
4603
4737
|
n,
|
|
4604
|
-
|
|
4605
|
-
]),
|
|
4738
|
+
g
|
|
4739
|
+
]), T = d((r, i) => {
|
|
4606
4740
|
if (n || !t.current.length) return;
|
|
4607
4741
|
let a = e.getShapes().filter((e) => t.current.includes(e.id) && ee(e));
|
|
4608
4742
|
a.length && e.update(a.map((e) => ({
|
|
@@ -4616,27 +4750,27 @@ function Bn({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4616
4750
|
e,
|
|
4617
4751
|
n,
|
|
4618
4752
|
t
|
|
4619
|
-
]),
|
|
4753
|
+
]), E = d(() => g().filter((e) => e.type === j.POLYGON || e.type === j.RECTANGLE || e.type === j.ROTATED_RECTANGLE || e.type === j.ELLIPSE), [g]);
|
|
4620
4754
|
return {
|
|
4621
|
-
selectAll:
|
|
4622
|
-
clearSelection:
|
|
4623
|
-
getEditableSelection:
|
|
4624
|
-
deleteSelection:
|
|
4625
|
-
copySelection:
|
|
4626
|
-
canPaste:
|
|
4627
|
-
paste:
|
|
4628
|
-
duplicate:
|
|
4629
|
-
bringToFront:
|
|
4630
|
-
sendToBack:
|
|
4631
|
-
nudgeSelection:
|
|
4632
|
-
getMergeTargets:
|
|
4755
|
+
selectAll: m,
|
|
4756
|
+
clearSelection: h,
|
|
4757
|
+
getEditableSelection: g,
|
|
4758
|
+
deleteSelection: _,
|
|
4759
|
+
copySelection: y,
|
|
4760
|
+
canPaste: b,
|
|
4761
|
+
paste: x,
|
|
4762
|
+
duplicate: S,
|
|
4763
|
+
bringToFront: C,
|
|
4764
|
+
sendToBack: w,
|
|
4765
|
+
nudgeSelection: T,
|
|
4766
|
+
getMergeTargets: E,
|
|
4633
4767
|
mergeSelection: d(() => {
|
|
4634
4768
|
if (n) return;
|
|
4635
|
-
let t =
|
|
4769
|
+
let t = E();
|
|
4636
4770
|
if (t.length < 2 || i && !i(t)) return;
|
|
4637
|
-
let a =
|
|
4771
|
+
let a = en([], 1, $t(t));
|
|
4638
4772
|
if (!a) return;
|
|
4639
|
-
let o =
|
|
4773
|
+
let o = tn(a, 1);
|
|
4640
4774
|
if (!o.length) return;
|
|
4641
4775
|
let s = t[0], c = o.map((e) => ({
|
|
4642
4776
|
id: re(),
|
|
@@ -4649,7 +4783,7 @@ function Bn({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4649
4783
|
}, [
|
|
4650
4784
|
e,
|
|
4651
4785
|
n,
|
|
4652
|
-
|
|
4786
|
+
E,
|
|
4653
4787
|
i,
|
|
4654
4788
|
r
|
|
4655
4789
|
])
|
|
@@ -4657,12 +4791,12 @@ function Bn({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4657
4791
|
}
|
|
4658
4792
|
//#endregion
|
|
4659
4793
|
//#region src/components/ShapeEditor/_state/useViewportControls.ts
|
|
4660
|
-
function
|
|
4794
|
+
function or({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBound: i, ready: a }) {
|
|
4661
4795
|
let o = v(null), s = v(null), c = d(() => {
|
|
4662
4796
|
o.current?.(), o.current = null;
|
|
4663
4797
|
}, []), l = d((t, n = r) => {
|
|
4664
4798
|
let i = e.current;
|
|
4665
|
-
i && (c(), o.current =
|
|
4799
|
+
i && (c(), o.current = Lt(i.viewport, t, (e) => i.applyViewport(e), n));
|
|
4666
4800
|
}, [
|
|
4667
4801
|
c,
|
|
4668
4802
|
r,
|
|
@@ -4670,14 +4804,14 @@ function Vn({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
4670
4804
|
]), u = d((t, n = r) => {
|
|
4671
4805
|
let i = e.current;
|
|
4672
4806
|
if (!i) return;
|
|
4673
|
-
let a =
|
|
4807
|
+
let a = Ft(t, i.screenSize.w, i.screenSize.h);
|
|
4674
4808
|
a && l(a, n);
|
|
4675
4809
|
}, [
|
|
4676
4810
|
l,
|
|
4677
4811
|
r,
|
|
4678
4812
|
e
|
|
4679
4813
|
]), p = d((e, n = r) => {
|
|
4680
|
-
let i =
|
|
4814
|
+
let i = Pt(t.getShapes().filter((t) => e.includes(t.id)));
|
|
4681
4815
|
i && u(i, n);
|
|
4682
4816
|
}, [
|
|
4683
4817
|
t,
|
|
@@ -4688,7 +4822,7 @@ function Vn({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
4688
4822
|
if (!r.length) return;
|
|
4689
4823
|
let i = e.current;
|
|
4690
4824
|
if (!i) return;
|
|
4691
|
-
let a =
|
|
4825
|
+
let a = It(I(r.flatMap((e) => e.points)), i.screenSize.w, i.screenSize.h, 80);
|
|
4692
4826
|
a && l(a);
|
|
4693
4827
|
}, [
|
|
4694
4828
|
t,
|
|
@@ -4729,45 +4863,50 @@ function Vn({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
4729
4863
|
}
|
|
4730
4864
|
//#endregion
|
|
4731
4865
|
//#region src/components/ShapeEditor/ShapeEditor.tsx
|
|
4732
|
-
var
|
|
4733
|
-
|
|
4866
|
+
var sr = 180, cr = "__draft_preview__", lr = new Set([
|
|
4867
|
+
"copy",
|
|
4868
|
+
"selectAll",
|
|
4869
|
+
"clearSelection",
|
|
4870
|
+
"zoomToSelection"
|
|
4871
|
+
]);
|
|
4872
|
+
function ur(e, t) {
|
|
4734
4873
|
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
4735
4874
|
}
|
|
4736
|
-
function
|
|
4737
|
-
let Pe = v(null), U = v(null), Fe = v(null), Ie = v(null), Le = v(null), Re = `${p()}-minimap`, [W, ze] = y(null), [Ve, He] = y(!1), [G,
|
|
4875
|
+
function dr({ imageUrl: t, displayImageUrl: n, coordinateSize: r, clipboardScope: i, renderImageState: a, dimmed: o = !1, initialShapes: s, selectedIds: c, activeTool: l, draftStyle: u, draftMeta: _, readOnly: b, disableMarquee: C, locked: w, onLockedInteraction: T, onIdleEscape: E, overrideShapeInteraction: D, defaultViewSettings: O, viewSettings: k, onViewSettingsChange: A, showMinimap: N = !0, showViewSettings: te = !0, getContextMenuItems: ne, strings: F, canMergeSelection: I, brushSize: ie = 20, zoomBound: ae, zoomAnimationDuration: oe = 300, decorationShapes: L, regionMask: R, guideMask: z, maskPalette: se, overlayMarkers: ce, renderOverlayMarker: B, onOverlayMarkerClick: le, renderImageOverlay: ue, getSelectionLabel: de, hideSelectionLabelDot: fe, formatSelectionInfo: pe, externalTools: me, assistant: he, keymap: ge, handleRef: _e, backend: ve = "pixi", onActiveToolChange: V, onSelectionChange: xe, onEditingChange: Se, onShapesCreated: Ce, onShapesUpdated: we, onShapesDeleted: Ee, onDrawSessionChange: Ae, onDraftShapeChange: je, onViewportChange: Me, onShapesTransformPreview: Ne }) {
|
|
4876
|
+
let Pe = v(null), U = v(null), Fe = v(null), Ie = v(null), Le = v(null), Re = `${p()}-minimap`, [W, ze] = y(null), [Ve, He] = y(!1), [G, Ue] = y(!1), [We, Je] = y(null), [Xe, Ze] = y({
|
|
4738
4877
|
active: !1,
|
|
4739
4878
|
kind: "none",
|
|
4740
4879
|
canUndo: !1,
|
|
4741
4880
|
canRedo: !1
|
|
4742
|
-
}), [
|
|
4881
|
+
}), [Qe, $e] = y(!0), [et, tt] = y(!1), nt = n ?? t, [rt, it] = y("loading"), K = dn({
|
|
4743
4882
|
onShapesCreated: Ce,
|
|
4744
4883
|
onShapesUpdated: we,
|
|
4745
4884
|
onShapesDeleted: Ee
|
|
4746
|
-
}), [ot, st] = y([]), q =
|
|
4885
|
+
}), [ot, st] = y([]), q = c ?? ot, ct = c !== void 0, lt = g(() => new Map((me ?? []).map((e) => [e.id, e])), [me]), ut = v(lt);
|
|
4747
4886
|
ut.current = lt;
|
|
4748
|
-
let
|
|
4749
|
-
|
|
4750
|
-
let [J,
|
|
4751
|
-
let e = Object.fromEntries(Object.entries(
|
|
4887
|
+
let dt = v(Xe);
|
|
4888
|
+
dt.current = Xe;
|
|
4889
|
+
let [J, ft] = y(() => {
|
|
4890
|
+
let e = Object.fromEntries(Object.entries(O ?? {}).filter(([, e]) => e !== void 0));
|
|
4752
4891
|
return {
|
|
4753
4892
|
...be,
|
|
4754
4893
|
...e
|
|
4755
4894
|
};
|
|
4756
|
-
}),
|
|
4895
|
+
}), pt = d((e) => ft((t) => ({
|
|
4757
4896
|
...t,
|
|
4758
4897
|
...e
|
|
4759
|
-
})), []), Y = g(() => ye(
|
|
4898
|
+
})), []), Y = g(() => ye(F), [F]);
|
|
4760
4899
|
f(() => {
|
|
4761
|
-
|
|
4762
|
-
let t = Object.entries(
|
|
4900
|
+
k && ft((e) => {
|
|
4901
|
+
let t = Object.entries(k).filter(([t, n]) => n !== void 0 && e[t] !== n);
|
|
4763
4902
|
return t.length ? {
|
|
4764
4903
|
...e,
|
|
4765
4904
|
...Object.fromEntries(t)
|
|
4766
4905
|
} : e;
|
|
4767
4906
|
});
|
|
4768
|
-
}, [
|
|
4769
|
-
let ht = v(
|
|
4770
|
-
ht.current =
|
|
4907
|
+
}, [k]);
|
|
4908
|
+
let ht = v(A);
|
|
4909
|
+
ht.current = A;
|
|
4771
4910
|
let gt = v(!1);
|
|
4772
4911
|
f(() => {
|
|
4773
4912
|
if (!gt.current) {
|
|
@@ -4776,66 +4915,66 @@ function $({ imageUrl: t, displayImageUrl: n, coordinateSize: r, renderImageStat
|
|
|
4776
4915
|
}
|
|
4777
4916
|
ht.current?.(J);
|
|
4778
4917
|
}, [J]);
|
|
4779
|
-
let
|
|
4780
|
-
|
|
4781
|
-
let
|
|
4782
|
-
|
|
4783
|
-
let
|
|
4784
|
-
|
|
4785
|
-
let
|
|
4786
|
-
|
|
4787
|
-
let
|
|
4788
|
-
|
|
4789
|
-
let
|
|
4790
|
-
|
|
4791
|
-
let
|
|
4792
|
-
|
|
4793
|
-
let
|
|
4794
|
-
|
|
4795
|
-
let At = v(
|
|
4796
|
-
At.current =
|
|
4797
|
-
let jt = v(
|
|
4798
|
-
jt.current =
|
|
4918
|
+
let vt = g(() => !z || !se ? null : _t(z, se), [z, se]), yt = g(() => vt?.toDataURL() ?? null, [vt]), bt = g(() => !W || !R ? null : kt(R, W.w, W.h), [W, R]), xt = v(vt);
|
|
4919
|
+
xt.current = vt;
|
|
4920
|
+
let St = v(bt);
|
|
4921
|
+
St.current = bt;
|
|
4922
|
+
let Ct = v(o);
|
|
4923
|
+
Ct.current = o;
|
|
4924
|
+
let wt = v(W);
|
|
4925
|
+
wt.current = W;
|
|
4926
|
+
let Tt = v(r);
|
|
4927
|
+
Tt.current = r;
|
|
4928
|
+
let Et = v(r?.imageSize);
|
|
4929
|
+
Et.current = r?.imageSize;
|
|
4930
|
+
let Dt = v([]);
|
|
4931
|
+
Dt.current = q;
|
|
4932
|
+
let Ot = v(l);
|
|
4933
|
+
Ot.current = l;
|
|
4934
|
+
let At = v(u);
|
|
4935
|
+
At.current = u;
|
|
4936
|
+
let jt = v(_);
|
|
4937
|
+
jt.current = _;
|
|
4799
4938
|
let Mt = v(ie);
|
|
4800
4939
|
Mt.current = ie;
|
|
4801
4940
|
let Nt = v(J.simplifyStrength);
|
|
4802
4941
|
Nt.current = J.simplifyStrength;
|
|
4803
|
-
let X = !!
|
|
4942
|
+
let X = !!b || !!w, Pt = v(X);
|
|
4804
4943
|
Pt.current = X;
|
|
4805
|
-
let Ft = v(
|
|
4806
|
-
Ft.current =
|
|
4807
|
-
let It = v(
|
|
4808
|
-
It.current =
|
|
4809
|
-
let Lt = v(
|
|
4810
|
-
Lt.current =
|
|
4811
|
-
let
|
|
4812
|
-
|
|
4813
|
-
let
|
|
4814
|
-
|
|
4815
|
-
let
|
|
4944
|
+
let Ft = v(C);
|
|
4945
|
+
Ft.current = C;
|
|
4946
|
+
let It = v(w);
|
|
4947
|
+
It.current = w;
|
|
4948
|
+
let Lt = v(T);
|
|
4949
|
+
Lt.current = T;
|
|
4950
|
+
let Bt = v(D);
|
|
4951
|
+
Bt.current = D;
|
|
4952
|
+
let Vt = v(K);
|
|
4953
|
+
Vt.current = K;
|
|
4954
|
+
let Ht = v(!1), Ut = v(!1), Wt = v("idle"), Gt = v(null), Kt = d(() => {
|
|
4816
4955
|
let e = U.current;
|
|
4817
4956
|
if (!e) return;
|
|
4818
|
-
let t =
|
|
4819
|
-
e.setCursor(
|
|
4957
|
+
let t = Ot.current, n = ut.current.get(t), r = dt.current;
|
|
4958
|
+
e.setCursor(mt({
|
|
4820
4959
|
tool: t,
|
|
4821
4960
|
externalToolCursor: n?.cursor,
|
|
4822
|
-
isSpacePressed:
|
|
4823
|
-
interactionMode:
|
|
4824
|
-
rendererCursorHint:
|
|
4961
|
+
isSpacePressed: Ht.current,
|
|
4962
|
+
interactionMode: Wt.current,
|
|
4963
|
+
rendererCursorHint: Gt.current,
|
|
4825
4964
|
isPolygonDrawing: r.kind === "polygon" && r.active
|
|
4826
4965
|
}));
|
|
4827
|
-
}, []),
|
|
4828
|
-
|
|
4829
|
-
}, [
|
|
4830
|
-
|
|
4831
|
-
}, [
|
|
4832
|
-
let t = /* @__PURE__ */ new Set(), n = new Map(
|
|
4966
|
+
}, []), qt = d((e) => {
|
|
4967
|
+
Wt.current !== e && (Wt.current = e, Kt());
|
|
4968
|
+
}, [Kt]), Jt = d((e) => {
|
|
4969
|
+
Gt.current !== e && (Gt.current = e, Kt());
|
|
4970
|
+
}, [Kt]), Yt = d((e) => {
|
|
4971
|
+
let t = /* @__PURE__ */ new Set(), n = new Map(Vt.current.getShapes().map((e) => [e.id, e]));
|
|
4833
4972
|
return e.filter((e) => {
|
|
4834
4973
|
if (t.has(e)) return !1;
|
|
4835
4974
|
t.add(e);
|
|
4836
4975
|
let r = n.get(e);
|
|
4837
4976
|
if (!r) return !1;
|
|
4838
|
-
let i =
|
|
4977
|
+
let i = Bt.current?.(r);
|
|
4839
4978
|
return P(i ? {
|
|
4840
4979
|
...r,
|
|
4841
4980
|
interaction: {
|
|
@@ -4844,173 +4983,173 @@ function $({ imageUrl: t, displayImageUrl: n, coordinateSize: r, renderImageStat
|
|
|
4844
4983
|
}
|
|
4845
4984
|
} : r);
|
|
4846
4985
|
});
|
|
4847
|
-
}, []),
|
|
4848
|
-
let t =
|
|
4849
|
-
|
|
4986
|
+
}, []), Xt = d((e) => {
|
|
4987
|
+
let t = Yt(e);
|
|
4988
|
+
ur(Dt.current, t) || (ct || st(t), U.current?.setSelection(t), xe?.(t));
|
|
4850
4989
|
}, [
|
|
4851
|
-
|
|
4990
|
+
Yt,
|
|
4852
4991
|
xe,
|
|
4853
4992
|
ct
|
|
4854
|
-
]),
|
|
4855
|
-
|
|
4856
|
-
let [
|
|
4857
|
-
tn.current =
|
|
4993
|
+
]), Zt = v(Xt);
|
|
4994
|
+
Zt.current = Xt;
|
|
4995
|
+
let [Qt, $t] = y(null), en = d((e) => $t(e), []), tn = v(en);
|
|
4996
|
+
tn.current = en, f(() => {
|
|
4858
4997
|
if (!ct) return;
|
|
4859
|
-
let e =
|
|
4860
|
-
|
|
4998
|
+
let e = Yt(c);
|
|
4999
|
+
ur(c, e) || xe?.(e);
|
|
4861
5000
|
}, [
|
|
4862
|
-
|
|
5001
|
+
c,
|
|
4863
5002
|
K.shapes,
|
|
4864
|
-
|
|
5003
|
+
Yt,
|
|
4865
5004
|
xe,
|
|
4866
5005
|
ct
|
|
4867
5006
|
]);
|
|
4868
5007
|
let nn = v(Me);
|
|
4869
5008
|
nn.current = Me;
|
|
4870
|
-
let { registerMinimapShape: rn, applyMinimapPreview: an, syncMinimap:
|
|
5009
|
+
let { registerMinimapShape: rn, applyMinimapPreview: an, syncMinimap: Z } = rr({
|
|
4871
5010
|
engineRef: U,
|
|
4872
|
-
docRef:
|
|
5011
|
+
docRef: Vt,
|
|
4873
5012
|
overlayRef: Ie,
|
|
4874
5013
|
zoomLabelRef: Le,
|
|
4875
5014
|
minimapRectRef: Fe,
|
|
4876
|
-
minimapSize:
|
|
5015
|
+
minimapSize: sr,
|
|
4877
5016
|
onViewportChangeRef: nn
|
|
4878
|
-
}),
|
|
4879
|
-
|
|
5017
|
+
}), on = v(/* @__PURE__ */ new Map()), sn = v(pe);
|
|
5018
|
+
sn.current = pe;
|
|
4880
5019
|
let ln = d((e, t) => {
|
|
4881
|
-
t ?
|
|
4882
|
-
}, []), un = v(null), [
|
|
5020
|
+
t ? on.current.set(e, t) : on.current.delete(e);
|
|
5021
|
+
}, []), un = v(null), [fn, pn] = y(null), mn = d((e) => {
|
|
4883
5022
|
if (!e.length) return;
|
|
4884
|
-
let t = new Map(
|
|
5023
|
+
let t = new Map(Vt.current.getShapes().map((e) => [e.id, e]));
|
|
4885
5024
|
un.current && t.set(un.current.id, un.current);
|
|
4886
5025
|
for (let { id: n, points: r } of e) {
|
|
4887
|
-
let e =
|
|
5026
|
+
let e = on.current.get(n), i = t.get(n);
|
|
4888
5027
|
if (!e || !i) continue;
|
|
4889
|
-
let a =
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
let e = Ue(i, r);
|
|
4894
|
-
o.textContent = cn.current?.(e) ?? We(e);
|
|
5028
|
+
let a = Ge(e, r);
|
|
5029
|
+
if (a) {
|
|
5030
|
+
let e = Ke(i, r);
|
|
5031
|
+
a.textContent = sn.current?.(e) ?? qe(e);
|
|
4895
5032
|
}
|
|
4896
5033
|
}
|
|
4897
|
-
}, []),
|
|
4898
|
-
an(e),
|
|
5034
|
+
}, []), hn = d((e) => {
|
|
5035
|
+
an(e), mn(e), Ne?.(e);
|
|
4899
5036
|
}, [
|
|
4900
5037
|
an,
|
|
4901
|
-
|
|
5038
|
+
mn,
|
|
4902
5039
|
Ne
|
|
4903
|
-
]),
|
|
5040
|
+
]), gn = d((e) => {
|
|
4904
5041
|
if (je?.(e ? {
|
|
4905
5042
|
...e,
|
|
4906
5043
|
meta: jt.current
|
|
4907
5044
|
} : null), !e || !At.current) {
|
|
4908
|
-
un.current && (un.current = null,
|
|
5045
|
+
un.current && (un.current = null, pn(null));
|
|
4909
5046
|
return;
|
|
4910
5047
|
}
|
|
4911
5048
|
let t = {
|
|
4912
|
-
id:
|
|
5049
|
+
id: cr,
|
|
4913
5050
|
type: e.type,
|
|
4914
5051
|
points: e.points,
|
|
4915
5052
|
style: At.current,
|
|
4916
5053
|
meta: jt.current
|
|
4917
5054
|
}, n = un.current !== null;
|
|
4918
|
-
un.current = t, n ?
|
|
4919
|
-
id:
|
|
5055
|
+
un.current = t, n ? mn([{
|
|
5056
|
+
id: cr,
|
|
4920
5057
|
points: e.points
|
|
4921
|
-
}]) :
|
|
4922
|
-
}, [
|
|
5058
|
+
}]) : pn(t);
|
|
5059
|
+
}, [mn, je]), _n = d((e, t) => {
|
|
4923
5060
|
let n = At.current;
|
|
4924
5061
|
if (!n || Pt.current) return;
|
|
4925
5062
|
let r = re();
|
|
4926
|
-
|
|
5063
|
+
Vt.current.create({
|
|
4927
5064
|
id: r,
|
|
4928
5065
|
type: e,
|
|
4929
5066
|
points: t,
|
|
4930
5067
|
style: n,
|
|
4931
|
-
meta:
|
|
4932
|
-
}),
|
|
4933
|
-
}, [
|
|
4934
|
-
|
|
4935
|
-
let
|
|
4936
|
-
toolRef:
|
|
4937
|
-
selRef:
|
|
4938
|
-
docRef:
|
|
5068
|
+
meta: _
|
|
5069
|
+
}), Zt.current([r]);
|
|
5070
|
+
}, [_]), vn = v(_n);
|
|
5071
|
+
vn.current = _n;
|
|
5072
|
+
let yn = cn({
|
|
5073
|
+
toolRef: Ot,
|
|
5074
|
+
selRef: Dt,
|
|
5075
|
+
docRef: Vt,
|
|
4939
5076
|
readOnlyRef: Pt,
|
|
4940
5077
|
draftRef: At,
|
|
4941
5078
|
brushSizeRef: Mt,
|
|
4942
5079
|
simplifyEpsilonRef: Nt,
|
|
4943
|
-
draftMeta:
|
|
5080
|
+
draftMeta: _,
|
|
4944
5081
|
engineRef: U,
|
|
4945
5082
|
onDrawSessionChange: d((e) => {
|
|
4946
|
-
|
|
5083
|
+
Ze(e), Ae?.(e);
|
|
4947
5084
|
}, [Ae]),
|
|
4948
5085
|
onDraftShapeChange: je,
|
|
4949
|
-
changeSelection:
|
|
4950
|
-
createShape:
|
|
4951
|
-
}),
|
|
4952
|
-
|
|
4953
|
-
let { reset:
|
|
5086
|
+
changeSelection: Xt,
|
|
5087
|
+
createShape: _n
|
|
5088
|
+
}), bn = v(yn);
|
|
5089
|
+
bn.current = yn;
|
|
5090
|
+
let { reset: Sn, undoSession: Cn, redoSession: wn, canUndoSession: Tn, canRedoSession: En, hasDraftSession: Dn, hasDraftPoints: On, commitDraftSession: kn, setBrushScalarMode: An, getBrushScalarMode: jn, hasBrushSession: Mn, commitBrush: Nn, cancelBrush: Pn, beginBrushEditFromSelection: Fn, deleteDraftSelectedPoints: In, handleToolChange: Ln, handleBrushSelectionChange: Rn } = yn, zn = v(he);
|
|
4954
5091
|
zn.current = he;
|
|
4955
|
-
let
|
|
4956
|
-
docRef:
|
|
5092
|
+
let Q = zt({
|
|
5093
|
+
docRef: Vt,
|
|
4957
5094
|
draftRef: At,
|
|
4958
|
-
draftMeta:
|
|
4959
|
-
changeSelection:
|
|
5095
|
+
draftMeta: _,
|
|
5096
|
+
changeSelection: Xt,
|
|
4960
5097
|
assistantRef: zn
|
|
4961
|
-
}),
|
|
4962
|
-
|
|
4963
|
-
let { selectAll:
|
|
5098
|
+
}), Bn = v(Q);
|
|
5099
|
+
Bn.current = Q;
|
|
5100
|
+
let Vn = g(() => at(t), [t]), { selectAll: Hn, clearSelection: Un, deleteSelection: Wn, copySelection: Gn, canPaste: Kn, paste: qn, duplicate: Jn, bringToFront: Yn, sendToBack: $, nudgeSelection: Xn, getMergeTargets: Qn, mergeSelection: $n } = ar({
|
|
4964
5101
|
doc: K,
|
|
4965
|
-
selRef:
|
|
5102
|
+
selRef: Dt,
|
|
4966
5103
|
effectiveReadOnly: X,
|
|
4967
|
-
changeSelection:
|
|
4968
|
-
canMergeSelection:
|
|
4969
|
-
|
|
5104
|
+
changeSelection: Xt,
|
|
5105
|
+
canMergeSelection: I,
|
|
5106
|
+
clipboardDocumentId: Vn,
|
|
5107
|
+
clipboardScope: i ?? Vn
|
|
5108
|
+
}), { zoomToBounds: er, zoomToShapes: nr, zoomToSelection: ir, zoomAtCenter: dr } = or({
|
|
4970
5109
|
engineRef: U,
|
|
4971
5110
|
doc: K,
|
|
4972
|
-
selRef:
|
|
5111
|
+
selRef: Dt,
|
|
4973
5112
|
zoomAnimationDuration: oe,
|
|
4974
5113
|
zoomBound: ae,
|
|
4975
5114
|
ready: G
|
|
4976
5115
|
});
|
|
4977
5116
|
m(_e, () => ({
|
|
4978
5117
|
previewRegionMask: (e) => {
|
|
4979
|
-
let t =
|
|
5118
|
+
let t = wt.current;
|
|
4980
5119
|
if (!t) return;
|
|
4981
|
-
let n = e ?
|
|
4982
|
-
U.current?.
|
|
5120
|
+
let n = e ? kt(e, t.w, t.h) : St.current;
|
|
5121
|
+
U.current?.setRegionOverlay(fr.current.showRegionMask ? n : null);
|
|
4983
5122
|
},
|
|
4984
5123
|
undo: () => {
|
|
4985
|
-
|
|
5124
|
+
Cn() || K.undo();
|
|
4986
5125
|
},
|
|
4987
5126
|
redo: () => {
|
|
4988
|
-
|
|
5127
|
+
wn() || K.redo();
|
|
4989
5128
|
},
|
|
4990
|
-
canUndo: () =>
|
|
4991
|
-
canRedo: () =>
|
|
4992
|
-
undoSession:
|
|
4993
|
-
redoSession:
|
|
4994
|
-
canUndoSession:
|
|
4995
|
-
canRedoSession:
|
|
4996
|
-
hasDraftSession:
|
|
4997
|
-
cancelDraftSession:
|
|
4998
|
-
commitDraftSession:
|
|
4999
|
-
setSelection:
|
|
5129
|
+
canUndo: () => Tn() || K.canUndo(),
|
|
5130
|
+
canRedo: () => En() || K.canRedo(),
|
|
5131
|
+
undoSession: Cn,
|
|
5132
|
+
redoSession: wn,
|
|
5133
|
+
canUndoSession: Tn,
|
|
5134
|
+
canRedoSession: En,
|
|
5135
|
+
hasDraftSession: Dn,
|
|
5136
|
+
cancelDraftSession: Sn,
|
|
5137
|
+
commitDraftSession: kn,
|
|
5138
|
+
setSelection: Xt,
|
|
5000
5139
|
createShapes: (e) => {
|
|
5001
|
-
e.length && (K.create(e),
|
|
5140
|
+
e.length && (K.create(e), Xt(e.map((e) => e.id)));
|
|
5002
5141
|
},
|
|
5003
5142
|
updateShapes: K.update,
|
|
5004
5143
|
deleteShapes: K.remove,
|
|
5005
5144
|
getShapes: K.getShapes,
|
|
5006
|
-
selectAll:
|
|
5007
|
-
clearSelection:
|
|
5008
|
-
deleteSelection:
|
|
5009
|
-
copySelection:
|
|
5010
|
-
paste:
|
|
5011
|
-
duplicate:
|
|
5012
|
-
bringToFront:
|
|
5013
|
-
sendToBack:
|
|
5145
|
+
selectAll: Hn,
|
|
5146
|
+
clearSelection: Un,
|
|
5147
|
+
deleteSelection: Wn,
|
|
5148
|
+
copySelection: Gn,
|
|
5149
|
+
paste: qn,
|
|
5150
|
+
duplicate: Jn,
|
|
5151
|
+
bringToFront: Yn,
|
|
5152
|
+
sendToBack: $,
|
|
5014
5153
|
zoomFit: () => U.current?.fit(),
|
|
5015
5154
|
zoom100: () => U.current?.zoom100(),
|
|
5016
5155
|
zoomIn: () => {
|
|
@@ -5025,101 +5164,101 @@ function $({ imageUrl: t, displayImageUrl: n, coordinateSize: r, renderImageStat
|
|
|
5025
5164
|
let { w: t, h: n } = e.screenSize;
|
|
5026
5165
|
e.zoomAt(t / 2, n / 2, 1 / 1.2);
|
|
5027
5166
|
},
|
|
5028
|
-
zoomToSelection:
|
|
5029
|
-
zoomToShapes:
|
|
5030
|
-
zoomToBounds:
|
|
5167
|
+
zoomToSelection: ir,
|
|
5168
|
+
zoomToShapes: nr,
|
|
5169
|
+
zoomToBounds: er,
|
|
5031
5170
|
brush: {
|
|
5032
|
-
setScalarMode:
|
|
5033
|
-
getScalarMode:
|
|
5034
|
-
hasSession:
|
|
5035
|
-
commit:
|
|
5036
|
-
cancel:
|
|
5037
|
-
beginEditFromSelection:
|
|
5171
|
+
setScalarMode: An,
|
|
5172
|
+
getScalarMode: jn,
|
|
5173
|
+
hasSession: Mn,
|
|
5174
|
+
commit: Nn,
|
|
5175
|
+
cancel: Pn,
|
|
5176
|
+
beginEditFromSelection: Fn
|
|
5038
5177
|
}
|
|
5039
5178
|
}), [
|
|
5040
5179
|
K,
|
|
5041
|
-
|
|
5042
|
-
|
|
5180
|
+
Xt,
|
|
5181
|
+
Cn,
|
|
5182
|
+
wn,
|
|
5183
|
+
kn,
|
|
5043
5184
|
Sn,
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5185
|
+
Nn,
|
|
5186
|
+
Pn,
|
|
5187
|
+
Hn,
|
|
5188
|
+
Un,
|
|
5189
|
+
Wn,
|
|
5190
|
+
Gn,
|
|
5049
5191
|
qn,
|
|
5050
5192
|
Jn,
|
|
5051
5193
|
Yn,
|
|
5052
|
-
|
|
5053
|
-
Qn,
|
|
5054
|
-
$n,
|
|
5055
|
-
er,
|
|
5056
|
-
or,
|
|
5057
|
-
ar,
|
|
5194
|
+
$,
|
|
5058
5195
|
ir,
|
|
5059
|
-
|
|
5060
|
-
|
|
5196
|
+
nr,
|
|
5197
|
+
er,
|
|
5061
5198
|
An,
|
|
5062
|
-
|
|
5199
|
+
jn,
|
|
5200
|
+
Mn,
|
|
5201
|
+
Fn
|
|
5063
5202
|
]);
|
|
5064
|
-
let
|
|
5065
|
-
|
|
5066
|
-
let
|
|
5203
|
+
let fr = v(J);
|
|
5204
|
+
fr.current = J;
|
|
5205
|
+
let pr = d(() => Rt({
|
|
5067
5206
|
engineRef: U,
|
|
5068
|
-
toolRef:
|
|
5207
|
+
toolRef: Ot,
|
|
5069
5208
|
externalToolMapRef: ut,
|
|
5070
|
-
spaceRef:
|
|
5071
|
-
shiftRef:
|
|
5072
|
-
docRef:
|
|
5073
|
-
selRef:
|
|
5209
|
+
spaceRef: Ht,
|
|
5210
|
+
shiftRef: Ut,
|
|
5211
|
+
docRef: Vt,
|
|
5212
|
+
selRef: Dt,
|
|
5074
5213
|
draftRef: At,
|
|
5075
5214
|
readOnlyRef: Pt,
|
|
5076
5215
|
disableMarqueeRef: Ft,
|
|
5077
5216
|
lockedRef: It,
|
|
5078
5217
|
onLockedInteraction: () => Lt.current?.(),
|
|
5079
|
-
createRef:
|
|
5080
|
-
selectRef:
|
|
5218
|
+
createRef: vn,
|
|
5219
|
+
selectRef: Zt,
|
|
5081
5220
|
enterEditRef: tn,
|
|
5082
|
-
drawSessionRef:
|
|
5083
|
-
assistantRef:
|
|
5084
|
-
setCursorHint:
|
|
5085
|
-
setInteractionMode:
|
|
5086
|
-
syncMinimap:
|
|
5087
|
-
onTransformPreview:
|
|
5088
|
-
onDrawPreview:
|
|
5221
|
+
drawSessionRef: bn,
|
|
5222
|
+
assistantRef: Bn,
|
|
5223
|
+
setCursorHint: Jt,
|
|
5224
|
+
setInteractionMode: qt,
|
|
5225
|
+
syncMinimap: Z,
|
|
5226
|
+
onTransformPreview: hn,
|
|
5227
|
+
onDrawPreview: gn
|
|
5089
5228
|
}), [
|
|
5229
|
+
Jt,
|
|
5090
5230
|
qt,
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
Mn({
|
|
5231
|
+
Z,
|
|
5232
|
+
hn,
|
|
5233
|
+
gn
|
|
5234
|
+
]), mr = v([]);
|
|
5235
|
+
Zn({
|
|
5097
5236
|
backend: ve,
|
|
5098
5237
|
hostRef: Pe,
|
|
5099
5238
|
engineRef: U,
|
|
5100
5239
|
imageUrl: t,
|
|
5101
|
-
renderedImageUrl:
|
|
5102
|
-
makeCallbacks:
|
|
5103
|
-
viewRef:
|
|
5240
|
+
renderedImageUrl: nt,
|
|
5241
|
+
makeCallbacks: pr,
|
|
5242
|
+
viewRef: fr,
|
|
5104
5243
|
readOnlyRef: Pt,
|
|
5105
|
-
toolRef:
|
|
5106
|
-
renderShapesRef:
|
|
5107
|
-
coordinateSizeRef:
|
|
5108
|
-
imageSizeRef:
|
|
5109
|
-
selRef:
|
|
5110
|
-
maskCanvasRef:
|
|
5111
|
-
regionOverlayRef:
|
|
5112
|
-
dimmedRef:
|
|
5113
|
-
syncMinimap:
|
|
5244
|
+
toolRef: Ot,
|
|
5245
|
+
renderShapesRef: mr,
|
|
5246
|
+
coordinateSizeRef: Tt,
|
|
5247
|
+
imageSizeRef: Et,
|
|
5248
|
+
selRef: Dt,
|
|
5249
|
+
maskCanvasRef: xt,
|
|
5250
|
+
regionOverlayRef: St,
|
|
5251
|
+
dimmedRef: Ct,
|
|
5252
|
+
syncMinimap: Z,
|
|
5114
5253
|
setImage: ze,
|
|
5115
5254
|
setImageVisible: He,
|
|
5116
|
-
setReady:
|
|
5117
|
-
setImageStatus:
|
|
5255
|
+
setReady: Ue,
|
|
5256
|
+
setImageStatus: it,
|
|
5118
5257
|
onContextMenuRequest: Je
|
|
5119
5258
|
});
|
|
5120
|
-
let
|
|
5121
|
-
let e =
|
|
5122
|
-
let t =
|
|
5259
|
+
let hr = g(() => {
|
|
5260
|
+
let e = D ? K.shapes.map((e) => {
|
|
5261
|
+
let t = D(e);
|
|
5123
5262
|
return t ? {
|
|
5124
5263
|
...e,
|
|
5125
5264
|
interaction: {
|
|
@@ -5140,174 +5279,175 @@ function $({ imageUrl: t, displayImageUrl: n, coordinateSize: r, renderImageStat
|
|
|
5140
5279
|
})), ...e] : e;
|
|
5141
5280
|
}, [
|
|
5142
5281
|
K.shapes,
|
|
5143
|
-
|
|
5282
|
+
D,
|
|
5144
5283
|
L
|
|
5145
5284
|
]);
|
|
5146
|
-
|
|
5147
|
-
U.current?.setShapes(
|
|
5285
|
+
mr.current = hr, f(() => {
|
|
5286
|
+
U.current?.setShapes(hr, q), Z();
|
|
5148
5287
|
}, [
|
|
5149
|
-
|
|
5288
|
+
hr,
|
|
5150
5289
|
q,
|
|
5151
|
-
|
|
5290
|
+
Z
|
|
5152
5291
|
]), f(() => {
|
|
5153
|
-
U.current?.setEditing(
|
|
5154
|
-
}, [
|
|
5155
|
-
let
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
}, [
|
|
5159
|
-
|
|
5160
|
-
}, [
|
|
5161
|
-
|
|
5162
|
-
}, [q,
|
|
5292
|
+
U.current?.setEditing(Qt);
|
|
5293
|
+
}, [Qt, G]);
|
|
5294
|
+
let gr = v(Se);
|
|
5295
|
+
gr.current = Se, f(() => {
|
|
5296
|
+
gr.current?.(Qt);
|
|
5297
|
+
}, [Qt]), f(() => {
|
|
5298
|
+
$t(null);
|
|
5299
|
+
}, [l]), f(() => {
|
|
5300
|
+
Qt && (q.length !== 1 || q[0] !== Qt) && $t(null);
|
|
5301
|
+
}, [q, Qt]), f(() => {
|
|
5163
5302
|
let e = U.current;
|
|
5164
|
-
e && (e.setFilter(J.brightness, J.contrast), e.setStrokeSize(J.strokeSize), e.setImageSmoothing(J.imageSmoothing),
|
|
5303
|
+
e && (e.setFilter(J.brightness, J.contrast), e.setStrokeSize(J.strokeSize), e.setImageSmoothing(J.imageSmoothing), Z());
|
|
5165
5304
|
}, [
|
|
5166
5305
|
J.brightness,
|
|
5167
5306
|
J.contrast,
|
|
5168
5307
|
J.strokeSize,
|
|
5169
5308
|
J.imageSmoothing,
|
|
5170
|
-
|
|
5309
|
+
Z
|
|
5171
5310
|
]), h(() => {
|
|
5172
|
-
G && U.current?.setOverlays(J.showGuide ?
|
|
5311
|
+
G && U.current?.setOverlays(J.showGuide ? vt : null, J.showRegionMask ? bt : null, o);
|
|
5173
5312
|
}, [
|
|
5174
5313
|
G,
|
|
5175
|
-
|
|
5176
|
-
|
|
5314
|
+
vt,
|
|
5315
|
+
bt,
|
|
5177
5316
|
J.showGuide,
|
|
5178
5317
|
J.showRegionMask,
|
|
5179
|
-
|
|
5318
|
+
o
|
|
5180
5319
|
]), f(() => {
|
|
5181
|
-
!G || !W ||
|
|
5320
|
+
!G || !W || Z();
|
|
5182
5321
|
}, [
|
|
5183
5322
|
G,
|
|
5184
5323
|
W,
|
|
5185
|
-
|
|
5324
|
+
yt,
|
|
5186
5325
|
J.showGuide,
|
|
5187
5326
|
J.showRegionMask,
|
|
5188
5327
|
R,
|
|
5189
|
-
|
|
5328
|
+
Z
|
|
5190
5329
|
]), f(() => {
|
|
5191
|
-
G && U.current?.setTransformEnabled(!X &&
|
|
5330
|
+
G && U.current?.setTransformEnabled(!X && l !== H.BRUSH);
|
|
5192
5331
|
}, [
|
|
5193
5332
|
X,
|
|
5194
5333
|
G,
|
|
5195
|
-
|
|
5334
|
+
l
|
|
5196
5335
|
]), f(() => {
|
|
5197
|
-
|
|
5336
|
+
Ln(l, lt.has(l));
|
|
5198
5337
|
}, [
|
|
5199
|
-
|
|
5338
|
+
l,
|
|
5200
5339
|
lt,
|
|
5201
|
-
|
|
5340
|
+
Ln
|
|
5202
5341
|
]);
|
|
5203
|
-
let
|
|
5342
|
+
let _r = Q.finalize;
|
|
5204
5343
|
f(() => {
|
|
5205
|
-
|
|
5206
|
-
}, [
|
|
5207
|
-
|
|
5344
|
+
_r();
|
|
5345
|
+
}, [l, _r]), f(() => {
|
|
5346
|
+
Wt.current = "idle", Gt.current = null, Kt();
|
|
5208
5347
|
}, [
|
|
5209
|
-
|
|
5348
|
+
l,
|
|
5210
5349
|
ve,
|
|
5211
|
-
|
|
5350
|
+
Kt
|
|
5212
5351
|
]), f(() => {
|
|
5213
|
-
|
|
5352
|
+
Rn(q, X);
|
|
5214
5353
|
}, [
|
|
5215
5354
|
q,
|
|
5216
|
-
|
|
5355
|
+
l,
|
|
5217
5356
|
X,
|
|
5218
|
-
|
|
5357
|
+
Rn
|
|
5219
5358
|
]), f(() => {
|
|
5220
|
-
G &&
|
|
5359
|
+
G && Kt();
|
|
5221
5360
|
}, [
|
|
5222
|
-
|
|
5223
|
-
|
|
5361
|
+
l,
|
|
5362
|
+
Xe,
|
|
5224
5363
|
lt,
|
|
5225
5364
|
G,
|
|
5226
|
-
|
|
5365
|
+
Kt
|
|
5227
5366
|
]);
|
|
5228
|
-
let
|
|
5367
|
+
let vr = v(null);
|
|
5229
5368
|
f(() => {
|
|
5230
|
-
|
|
5369
|
+
vr.current !== t && (vr.current = t, Je(null), $t(null), Wt.current = "idle", Gt.current = null, K.reset(s ?? []), Xt([]), Sn(), _r(), Kt());
|
|
5231
5370
|
}, [
|
|
5232
5371
|
t,
|
|
5233
|
-
|
|
5372
|
+
s,
|
|
5234
5373
|
K.reset,
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5374
|
+
Xt,
|
|
5375
|
+
Sn,
|
|
5376
|
+
_r,
|
|
5377
|
+
Kt
|
|
5378
|
+
]), xn({
|
|
5239
5379
|
keymap: ge,
|
|
5240
5380
|
hostRef: Pe,
|
|
5241
5381
|
actions: {
|
|
5242
5382
|
undo: () => {
|
|
5243
|
-
X ||
|
|
5383
|
+
X || Cn() || K.undo();
|
|
5244
5384
|
},
|
|
5245
5385
|
redo: () => {
|
|
5246
|
-
X ||
|
|
5386
|
+
X || wn() || K.redo();
|
|
5247
5387
|
},
|
|
5248
|
-
selectAll:
|
|
5249
|
-
copy:
|
|
5388
|
+
selectAll: Hn,
|
|
5389
|
+
copy: Gn,
|
|
5250
5390
|
cut: () => {
|
|
5251
|
-
|
|
5391
|
+
Gn(), Wn();
|
|
5252
5392
|
},
|
|
5253
|
-
paste:
|
|
5254
|
-
duplicate:
|
|
5393
|
+
paste: qn,
|
|
5394
|
+
duplicate: Jn,
|
|
5255
5395
|
delete: () => {
|
|
5256
|
-
|
|
5396
|
+
On() && In() || Wn();
|
|
5257
5397
|
},
|
|
5258
5398
|
cancel: () => {
|
|
5259
|
-
let e = ut.current.get(
|
|
5399
|
+
let e = ut.current.get(Ot.current);
|
|
5260
5400
|
if (!(e?.onCancel && e.onCancel() !== !1)) {
|
|
5261
|
-
if (
|
|
5262
|
-
|
|
5401
|
+
if (Q.isActive()) {
|
|
5402
|
+
Q.cancel();
|
|
5263
5403
|
return;
|
|
5264
5404
|
}
|
|
5265
|
-
if (
|
|
5266
|
-
|
|
5405
|
+
if (Dn()) {
|
|
5406
|
+
Sn();
|
|
5267
5407
|
return;
|
|
5268
5408
|
}
|
|
5269
|
-
if (
|
|
5270
|
-
|
|
5409
|
+
if (Qt) {
|
|
5410
|
+
$t(null);
|
|
5271
5411
|
return;
|
|
5272
5412
|
}
|
|
5273
|
-
if (
|
|
5274
|
-
|
|
5413
|
+
if (Dt.current.length) {
|
|
5414
|
+
Un();
|
|
5275
5415
|
return;
|
|
5276
5416
|
}
|
|
5277
|
-
|
|
5417
|
+
E?.();
|
|
5278
5418
|
}
|
|
5279
5419
|
},
|
|
5280
5420
|
commitDraft: () => {
|
|
5281
|
-
if (
|
|
5282
|
-
|
|
5421
|
+
if (Q.isActive()) {
|
|
5422
|
+
Q.finalize();
|
|
5283
5423
|
return;
|
|
5284
5424
|
}
|
|
5285
|
-
if (
|
|
5286
|
-
|
|
5425
|
+
if (Dn()) {
|
|
5426
|
+
kn();
|
|
5287
5427
|
return;
|
|
5288
5428
|
}
|
|
5289
5429
|
if (X) return;
|
|
5290
|
-
if (
|
|
5291
|
-
|
|
5430
|
+
if (Qt) {
|
|
5431
|
+
$t(null);
|
|
5292
5432
|
return;
|
|
5293
5433
|
}
|
|
5294
|
-
let e =
|
|
5434
|
+
let e = Dt.current;
|
|
5295
5435
|
if (e.length !== 1) return;
|
|
5296
|
-
let t =
|
|
5297
|
-
t && (t.type === j.POLYGON || t.type === j.LINE) && t.interaction?.editable !== !1 && !t.readOnly &&
|
|
5436
|
+
let t = Vt.current.getShapes().find((t) => t.id === e[0]);
|
|
5437
|
+
t && (t.type === j.POLYGON || t.type === j.LINE) && t.interaction?.editable !== !1 && !t.readOnly && $t(e[0]);
|
|
5298
5438
|
},
|
|
5299
|
-
bringToFront:
|
|
5300
|
-
sendToBack:
|
|
5301
|
-
zoomIn: () =>
|
|
5302
|
-
zoomOut: () =>
|
|
5439
|
+
bringToFront: Yn,
|
|
5440
|
+
sendToBack: $,
|
|
5441
|
+
zoomIn: () => dr(1.2),
|
|
5442
|
+
zoomOut: () => dr(1 / 1.2),
|
|
5303
5443
|
zoom100: () => U.current?.zoom100(),
|
|
5304
5444
|
zoomFit: () => U.current?.fit(),
|
|
5305
5445
|
toggleMinimap: () => $e((e) => !e),
|
|
5306
|
-
toggleCursorGuide: () =>
|
|
5446
|
+
toggleCursorGuide: () => ft((e) => ({
|
|
5307
5447
|
...e,
|
|
5308
5448
|
showCursorGuide: !e.showCursorGuide
|
|
5309
5449
|
})),
|
|
5310
|
-
togglePixelation: () =>
|
|
5450
|
+
togglePixelation: () => ft((e) => ({
|
|
5311
5451
|
...e,
|
|
5312
5452
|
imageSmoothing: !e.imageSmoothing
|
|
5313
5453
|
})),
|
|
@@ -5320,113 +5460,112 @@ function $({ imageUrl: t, displayImageUrl: n, coordinateSize: r, renderImageStat
|
|
|
5320
5460
|
brushTool: () => V?.(H.BRUSH),
|
|
5321
5461
|
pointTool: () => V?.(H.POINT)
|
|
5322
5462
|
},
|
|
5323
|
-
spaceRef:
|
|
5324
|
-
shiftRef:
|
|
5463
|
+
spaceRef: Ht,
|
|
5464
|
+
shiftRef: Ut,
|
|
5325
5465
|
onSpaceDown: () => {
|
|
5326
|
-
U.current?.setPanMode(!0),
|
|
5466
|
+
U.current?.setPanMode(!0), Kt();
|
|
5327
5467
|
},
|
|
5328
5468
|
onSpaceUp: () => {
|
|
5329
|
-
U.current?.setPanMode(!1),
|
|
5469
|
+
U.current?.setPanMode(!1), Wt.current === "panning" ? qt("idle") : Kt();
|
|
5330
5470
|
},
|
|
5331
|
-
nudge:
|
|
5471
|
+
nudge: Xn
|
|
5332
5472
|
});
|
|
5333
|
-
let
|
|
5473
|
+
let yr = g(() => hr.filter((e) => q.includes(e.id) && M(e)), [hr, q]), br = g(() => fn ? [...yr, fn] : yr, [yr, fn]), xr = q.length > 0, Sr = K.shapes.some((e) => q.includes(e.id) && ee(e)), Cr = !X && q.length === 1 && (() => {
|
|
5334
5474
|
let e = K.shapes.find((e) => e.id === q[0]);
|
|
5335
5475
|
return !!e && (e.type === j.POLYGON || e.type === j.LINE) && e.interaction?.editable !== !1 && !e.readOnly;
|
|
5336
|
-
})(),
|
|
5476
|
+
})(), wr = Qn(), Tr = X || wr.length < 2 || (I ? !I(wr) : !1), Er = !!he && !X, Dr = Er && q.length === 1 ? (() => {
|
|
5337
5477
|
let e = K.shapes.find((e) => e.id === q[0]);
|
|
5338
5478
|
return e && e.type === j.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
|
|
5339
|
-
})() : null,
|
|
5479
|
+
})() : null, Or = [
|
|
5340
5480
|
{
|
|
5341
5481
|
id: "copy",
|
|
5342
5482
|
label: Y.contextMenu.copy,
|
|
5343
5483
|
shortcut: "⌘C",
|
|
5344
|
-
disabled: !
|
|
5345
|
-
onClick:
|
|
5484
|
+
disabled: !Sr,
|
|
5485
|
+
onClick: Gn
|
|
5346
5486
|
},
|
|
5347
5487
|
{
|
|
5348
5488
|
id: "paste",
|
|
5349
5489
|
label: Y.contextMenu.paste,
|
|
5350
5490
|
shortcut: "⌘V",
|
|
5351
|
-
disabled: X || !
|
|
5352
|
-
onClick:
|
|
5491
|
+
disabled: X || !Kn(),
|
|
5492
|
+
onClick: () => qn(We?.img)
|
|
5353
5493
|
},
|
|
5354
5494
|
{
|
|
5355
5495
|
id: "duplicate",
|
|
5356
5496
|
label: Y.contextMenu.duplicate,
|
|
5357
5497
|
shortcut: "⌘D",
|
|
5358
|
-
disabled: !
|
|
5359
|
-
onClick:
|
|
5498
|
+
disabled: !Sr || X,
|
|
5499
|
+
onClick: Jn
|
|
5360
5500
|
},
|
|
5361
5501
|
{
|
|
5362
5502
|
id: "delete",
|
|
5363
5503
|
label: Y.contextMenu.delete,
|
|
5364
5504
|
shortcut: "Del",
|
|
5365
5505
|
danger: !0,
|
|
5366
|
-
disabled: !
|
|
5367
|
-
onClick:
|
|
5506
|
+
disabled: !Sr || X,
|
|
5507
|
+
onClick: Wn
|
|
5368
5508
|
},
|
|
5369
5509
|
{ separator: !0 },
|
|
5370
5510
|
{
|
|
5371
5511
|
id: "editVertices",
|
|
5372
5512
|
label: Y.contextMenu.editVertices,
|
|
5373
5513
|
shortcut: "Enter",
|
|
5374
|
-
disabled: !
|
|
5375
|
-
onClick: () =>
|
|
5514
|
+
disabled: !Cr,
|
|
5515
|
+
onClick: () => $t(q[0])
|
|
5376
5516
|
},
|
|
5377
5517
|
{
|
|
5378
5518
|
id: "merge",
|
|
5379
5519
|
label: Y.contextMenu.merge,
|
|
5380
|
-
disabled:
|
|
5381
|
-
onClick:
|
|
5520
|
+
disabled: Tr,
|
|
5521
|
+
onClick: $n
|
|
5382
5522
|
},
|
|
5383
|
-
{
|
|
5523
|
+
...Er ? [{
|
|
5384
5524
|
id: "assistExpand",
|
|
5385
5525
|
label: Y.contextMenu.assistExpand,
|
|
5386
5526
|
icon: /* @__PURE__ */ x(e, { size: 14 }),
|
|
5387
|
-
disabled: !
|
|
5527
|
+
disabled: !Dr,
|
|
5388
5528
|
onClick: () => {
|
|
5389
|
-
|
|
5529
|
+
We && Dr && Q.refineShape(Dr, We.img, !0);
|
|
5390
5530
|
}
|
|
5391
|
-
},
|
|
5392
|
-
{
|
|
5531
|
+
}, {
|
|
5393
5532
|
id: "assistExclude",
|
|
5394
5533
|
label: Y.contextMenu.assistExclude,
|
|
5395
5534
|
icon: /* @__PURE__ */ x(e, { size: 14 }),
|
|
5396
|
-
disabled: !
|
|
5535
|
+
disabled: !Dr,
|
|
5397
5536
|
onClick: () => {
|
|
5398
|
-
|
|
5537
|
+
We && Dr && Q.refineShape(Dr, We.img, !1);
|
|
5399
5538
|
}
|
|
5400
|
-
},
|
|
5539
|
+
}] : [],
|
|
5401
5540
|
{
|
|
5402
5541
|
id: "bringToFront",
|
|
5403
5542
|
label: Y.contextMenu.bringToFront,
|
|
5404
|
-
disabled: !
|
|
5405
|
-
onClick:
|
|
5543
|
+
disabled: !Sr || X,
|
|
5544
|
+
onClick: Yn
|
|
5406
5545
|
},
|
|
5407
5546
|
{
|
|
5408
5547
|
id: "sendToBack",
|
|
5409
5548
|
label: Y.contextMenu.sendToBack,
|
|
5410
|
-
disabled: !
|
|
5411
|
-
onClick:
|
|
5549
|
+
disabled: !Sr || X,
|
|
5550
|
+
onClick: $
|
|
5412
5551
|
},
|
|
5413
5552
|
{ separator: !0 },
|
|
5414
5553
|
{
|
|
5415
5554
|
id: "undo",
|
|
5416
5555
|
label: Y.contextMenu.undo,
|
|
5417
5556
|
shortcut: "⌘Z",
|
|
5418
|
-
disabled: X || !
|
|
5557
|
+
disabled: X || !Tn() && !K.canUndo(),
|
|
5419
5558
|
onClick: () => {
|
|
5420
|
-
|
|
5559
|
+
Cn() || K.undo();
|
|
5421
5560
|
}
|
|
5422
5561
|
},
|
|
5423
5562
|
{
|
|
5424
5563
|
id: "redo",
|
|
5425
5564
|
label: Y.contextMenu.redo,
|
|
5426
5565
|
shortcut: "⇧⌘Z",
|
|
5427
|
-
disabled: X || !
|
|
5566
|
+
disabled: X || !En() && !K.canRedo(),
|
|
5428
5567
|
onClick: () => {
|
|
5429
|
-
|
|
5568
|
+
wn() || K.redo();
|
|
5430
5569
|
}
|
|
5431
5570
|
},
|
|
5432
5571
|
{ separator: !0 },
|
|
@@ -5434,28 +5573,28 @@ function $({ imageUrl: t, displayImageUrl: n, coordinateSize: r, renderImageStat
|
|
|
5434
5573
|
id: "selectAll",
|
|
5435
5574
|
label: Y.contextMenu.selectAll,
|
|
5436
5575
|
shortcut: "⌘A",
|
|
5437
|
-
onClick:
|
|
5576
|
+
onClick: Hn
|
|
5438
5577
|
},
|
|
5439
5578
|
{
|
|
5440
5579
|
id: "clearSelection",
|
|
5441
5580
|
label: Y.contextMenu.clearSelection,
|
|
5442
|
-
disabled: !
|
|
5443
|
-
onClick:
|
|
5581
|
+
disabled: !xr,
|
|
5582
|
+
onClick: Un
|
|
5444
5583
|
},
|
|
5445
5584
|
{
|
|
5446
5585
|
id: "zoomToSelection",
|
|
5447
5586
|
label: Y.contextMenu.zoomToSelection,
|
|
5448
|
-
disabled: !
|
|
5449
|
-
onClick:
|
|
5587
|
+
disabled: !xr,
|
|
5588
|
+
onClick: ir
|
|
5450
5589
|
}
|
|
5451
|
-
],
|
|
5590
|
+
], kr = b ? Or.filter((e) => "separator" in e || !!e.id && lr.has(e.id)) : Or, Ar = ne ? ne(kr, {
|
|
5452
5591
|
selectedIds: q,
|
|
5453
5592
|
readOnly: X
|
|
5454
|
-
}) :
|
|
5593
|
+
}) : kr, jr = tr({
|
|
5455
5594
|
engineRef: U,
|
|
5456
5595
|
image: W,
|
|
5457
5596
|
wheelZoom: J.wheelZoom,
|
|
5458
|
-
minimapSize:
|
|
5597
|
+
minimapSize: sr
|
|
5459
5598
|
});
|
|
5460
5599
|
return /* @__PURE__ */ S("div", {
|
|
5461
5600
|
className: "aivex:relative aivex:h-full aivex:w-full aivex:overflow-hidden aivex:bg-black",
|
|
@@ -5468,9 +5607,9 @@ function $({ imageUrl: t, displayImageUrl: n, coordinateSize: r, renderImageStat
|
|
|
5468
5607
|
transition: Ve ? "opacity 0.3s ease" : "none"
|
|
5469
5608
|
}
|
|
5470
5609
|
}),
|
|
5471
|
-
|
|
5472
|
-
status:
|
|
5473
|
-
render:
|
|
5610
|
+
rt !== "ready" && /* @__PURE__ */ x(ke, {
|
|
5611
|
+
status: rt,
|
|
5612
|
+
render: a,
|
|
5474
5613
|
loadingLabel: Y.imageLoading,
|
|
5475
5614
|
errorLabel: Y.imageLoadError
|
|
5476
5615
|
}),
|
|
@@ -5528,51 +5667,52 @@ function $({ imageUrl: t, displayImageUrl: n, coordinateSize: r, renderImageStat
|
|
|
5528
5667
|
y: 0
|
|
5529
5668
|
}
|
|
5530
5669
|
}),
|
|
5531
|
-
|
|
5532
|
-
shapes:
|
|
5670
|
+
br.length > 0 && /* @__PURE__ */ x(Ye, {
|
|
5671
|
+
shapes: br,
|
|
5533
5672
|
getLabel: de,
|
|
5534
5673
|
hideDot: fe,
|
|
5535
5674
|
formatInfo: pe,
|
|
5536
5675
|
register: ln
|
|
5537
5676
|
}),
|
|
5538
|
-
he && (
|
|
5677
|
+
he && (Q.status === "loading" || Q.boxes.length > 0) && /* @__PURE__ */ x(Te, {
|
|
5539
5678
|
image: W,
|
|
5540
|
-
points:
|
|
5541
|
-
boxes:
|
|
5542
|
-
status:
|
|
5679
|
+
points: Q.points,
|
|
5680
|
+
boxes: Q.boxes,
|
|
5681
|
+
status: Q.status
|
|
5543
5682
|
})
|
|
5544
5683
|
]
|
|
5545
5684
|
})
|
|
5546
5685
|
}),
|
|
5547
5686
|
G && J.showCursorGuide && /* @__PURE__ */ x(Oe, { color: "#1e88e5" }),
|
|
5548
|
-
|
|
5687
|
+
W && N && /* @__PURE__ */ x(Be, {
|
|
5549
5688
|
image: W,
|
|
5550
|
-
imageUrl:
|
|
5689
|
+
imageUrl: nt,
|
|
5551
5690
|
imageVisible: Ve,
|
|
5552
|
-
|
|
5553
|
-
|
|
5691
|
+
loading: !G,
|
|
5692
|
+
maskDataUrl: yt,
|
|
5693
|
+
region: bt,
|
|
5554
5694
|
roiMaskId: Re,
|
|
5555
|
-
shapes:
|
|
5695
|
+
shapes: hr,
|
|
5556
5696
|
view: J,
|
|
5557
|
-
onChangeView:
|
|
5558
|
-
nav:
|
|
5697
|
+
onChangeView: pt,
|
|
5698
|
+
nav: jr,
|
|
5559
5699
|
registerShape: rn,
|
|
5560
5700
|
rectRef: Fe,
|
|
5561
5701
|
zoomLabelRef: Le,
|
|
5562
5702
|
onZoom100: () => U.current?.zoom100(),
|
|
5563
|
-
open:
|
|
5703
|
+
open: Qe,
|
|
5564
5704
|
onToggleOpen: () => $e((e) => !e),
|
|
5565
5705
|
labels: Y.minimap,
|
|
5566
5706
|
settingsLabels: Y.viewSettings,
|
|
5567
|
-
showSettings:
|
|
5707
|
+
showSettings: te,
|
|
5568
5708
|
settingsOpen: et,
|
|
5569
|
-
onToggleSettings: () =>
|
|
5570
|
-
onCloseSettings: () =>
|
|
5709
|
+
onToggleSettings: () => tt((e) => !e),
|
|
5710
|
+
onCloseSettings: () => tt(!1)
|
|
5571
5711
|
}),
|
|
5572
|
-
|
|
5573
|
-
x:
|
|
5574
|
-
y:
|
|
5575
|
-
items:
|
|
5712
|
+
We && /* @__PURE__ */ x(De, {
|
|
5713
|
+
x: We.x,
|
|
5714
|
+
y: We.y,
|
|
5715
|
+
items: Ar,
|
|
5576
5716
|
onClose: () => Je(null)
|
|
5577
5717
|
})
|
|
5578
5718
|
]
|
|
@@ -5580,8 +5720,8 @@ function $({ imageUrl: t, displayImageUrl: n, coordinateSize: r, renderImageStat
|
|
|
5580
5720
|
}
|
|
5581
5721
|
//#endregion
|
|
5582
5722
|
//#region src/components/ShapeEditor/ShapeViewer.tsx
|
|
5583
|
-
async function
|
|
5584
|
-
let t = await
|
|
5723
|
+
async function fr(e) {
|
|
5724
|
+
let t = await Sn(e);
|
|
5585
5725
|
return await new Promise((n, r) => {
|
|
5586
5726
|
let i = new Image();
|
|
5587
5727
|
t || (i.crossOrigin = "anonymous"), i.onload = () => n({
|
|
@@ -5592,14 +5732,14 @@ async function Gn(e) {
|
|
|
5592
5732
|
}, i.src = t ?? e;
|
|
5593
5733
|
});
|
|
5594
5734
|
}
|
|
5595
|
-
function
|
|
5735
|
+
function pr(e, t, n) {
|
|
5596
5736
|
if (t.length !== 0) {
|
|
5597
5737
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
5598
5738
|
for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
|
|
5599
5739
|
n && e.closePath();
|
|
5600
5740
|
}
|
|
5601
5741
|
}
|
|
5602
|
-
function
|
|
5742
|
+
function mr(e, t, n, r) {
|
|
5603
5743
|
if (t.interaction?.visible === !1) return;
|
|
5604
5744
|
let i = Pe(t, {
|
|
5605
5745
|
strokeWidth: r,
|
|
@@ -5616,10 +5756,10 @@ function qn(e, t, n, r) {
|
|
|
5616
5756
|
let i = Math.min(n.x, r.x), a = Math.min(n.y, r.y), o = Math.abs(r.x - n.x), s = Math.abs(r.y - n.y);
|
|
5617
5757
|
e.beginPath(), t.type === j.ELLIPSE ? e.ellipse(i + o / 2, a + s / 2, o / 2, s / 2, 0, 0, Math.PI * 2) : e.rect(i, a, o, s);
|
|
5618
5758
|
}
|
|
5619
|
-
} else
|
|
5759
|
+
} else pr(e, t.points, t.type !== j.LINE);
|
|
5620
5760
|
i.fillVisible && (e.save(), e.fillStyle = i.color, e.globalAlpha *= i.fillAlpha, e.fill(), e.restore()), t.style?.alternateColor && i.dash?.length && (e.setLineDash([]), e.strokeStyle = t.style.alternateColor, e.stroke()), e.setLineDash((i.dash ?? []).map((e) => e / n)), e.strokeStyle = i.color, e.stroke(), e.restore();
|
|
5621
5761
|
}
|
|
5622
|
-
function
|
|
5762
|
+
function hr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes: r = [], regionMask: i, guideMask: a, maskPalette: o, focusedShapeId: s, focusFit: c = "contain", zoomPadding: l = .3, strokeSize: u = 1, brightness: d = 1, contrast: p = 1, imageSmoothing: m = !0, lazy: h = !0, className: _, style: b, renderImageState: C }) {
|
|
5623
5763
|
let w = v(null), T = v(null), E = v(null), [D, O] = y(!h), [k, A] = y("loading"), [j, M] = y(0);
|
|
5624
5764
|
f(() => {
|
|
5625
5765
|
if (!h || D) return;
|
|
@@ -5640,7 +5780,7 @@ function Jn({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
5640
5780
|
return;
|
|
5641
5781
|
}
|
|
5642
5782
|
let t = !0;
|
|
5643
|
-
return A("loading"),
|
|
5783
|
+
return A("loading"), fr(e).then((e) => {
|
|
5644
5784
|
if (!t) {
|
|
5645
5785
|
e.revoke?.();
|
|
5646
5786
|
return;
|
|
@@ -5654,7 +5794,7 @@ function Jn({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
5654
5794
|
}, [e, D]), f(() => () => {
|
|
5655
5795
|
E.current?.revoke?.(), E.current = null;
|
|
5656
5796
|
}, []);
|
|
5657
|
-
let N = g(() => r.find((e) => e.id === s), [s, r]), P = g(() => a && o ?
|
|
5797
|
+
let N = g(() => r.find((e) => e.id === s), [s, r]), P = g(() => a && o ? _t(a, o) : null, [a, o]);
|
|
5658
5798
|
return f(() => {
|
|
5659
5799
|
if (k === "error") {
|
|
5660
5800
|
let e = T.current;
|
|
@@ -5677,20 +5817,20 @@ function Jn({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
5677
5817
|
v = Math.min(o / (t + r * 2), s / (n + r * 2)), c === "cover" && (v = Math.max(v, Math.max(o / g, s / _))), y = o / 2 - (e.minX + e.maxX) / 2 * v, b = s / 2 - (e.minY + e.maxY) / 2 * v, c === "cover" && (y = Math.min(0, Math.max(y, o - g * v)), b = Math.min(0, Math.max(b, s - _ * v)));
|
|
5678
5818
|
}
|
|
5679
5819
|
h.setTransform(f, 0, 0, f, 0, 0), h.clearRect(0, 0, o, s), h.save(), h.translate(y, b), h.scale(v, v), h.imageSmoothingEnabled = m, h.filter = `brightness(${d}) contrast(${p})`, h.drawImage(a.image, 0, 0, g, _), h.filter = "none", P && (h.save(), h.globalAlpha = .55, h.drawImage(P, 0, 0, g, _), h.restore());
|
|
5680
|
-
let x = i ?
|
|
5681
|
-
if (x && (
|
|
5820
|
+
let x = i ? kt(i, g, _) : null;
|
|
5821
|
+
if (x && (wt(h, x, g, _), x.outlineStyles)) {
|
|
5682
5822
|
let e = (e, t) => {
|
|
5683
5823
|
if (h.lineWidth = t.width / v, t.underlayColor) {
|
|
5684
5824
|
h.setLineDash([]), h.strokeStyle = t.underlayColor;
|
|
5685
|
-
for (let [t, n] of e)
|
|
5825
|
+
for (let [t, n] of e) pr(h, [t, n], !1), h.stroke();
|
|
5686
5826
|
}
|
|
5687
5827
|
h.save(), h.globalAlpha *= t.opacity, h.setLineDash(t.dash.map((e) => e / v)), h.strokeStyle = t.color;
|
|
5688
|
-
for (let [t, n] of e)
|
|
5828
|
+
for (let [t, n] of e) pr(h, [t, n], !1), h.stroke();
|
|
5689
5829
|
h.restore();
|
|
5690
5830
|
};
|
|
5691
5831
|
e(x.visibleOutline, x.outlineStyles.visible), e(x.occludedOutline, x.outlineStyles.occluded);
|
|
5692
5832
|
}
|
|
5693
|
-
for (let e of ne(r))
|
|
5833
|
+
for (let e of ne(r)) mr(h, e, v, u);
|
|
5694
5834
|
h.restore();
|
|
5695
5835
|
}, [
|
|
5696
5836
|
d,
|
|
@@ -5730,6 +5870,6 @@ function Jn({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
5730
5870
|
});
|
|
5731
5871
|
}
|
|
5732
5872
|
//#endregion
|
|
5733
|
-
export { V as DEFAULT_EDITOR_STRINGS, be as DEFAULT_VIEW_SETTINGS, j as SHAPE_TYPE,
|
|
5873
|
+
export { V as DEFAULT_EDITOR_STRINGS, be as DEFAULT_VIEW_SETTINGS, j as SHAPE_TYPE, dr as ShapeEditor, dr as default, hr as ShapeViewer, H as TOOL, re as generateId };
|
|
5734
5874
|
|
|
5735
5875
|
//# sourceMappingURL=shape-editor.js.map
|