dishui 0.0.47 → 0.0.49
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/pro/CodeEditor/editors/MarkdownEditor.js +1 -2
- package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js.map +1 -1
- package/dist/components/pro/CodeEditor/themes.js +0 -25
- package/dist/components/pro/CodeEditor/themes.js.map +1 -1
- package/dist/components/pro/CodeEditor/types.d.ts +1 -1
- package/dist/components/pro/Flow/Flow.js +500 -483
- package/dist/components/pro/Flow/Flow.js.map +1 -1
- package/dist/components/pro/Flow/FlowCanvas.js +526 -524
- package/dist/components/pro/Flow/FlowCanvas.js.map +1 -1
- package/dist/components/pro/Flow/canvas/GridRenderer.d.ts +3 -0
- package/dist/components/pro/Flow/canvas/GridRenderer.js +28 -23
- package/dist/components/pro/Flow/canvas/GridRenderer.js.map +1 -1
- package/dist/components/pro/Flow/canvas/MiniMapRenderer.js +18 -17
- package/dist/components/pro/Flow/canvas/MiniMapRenderer.js.map +1 -1
- package/dist/components/pro/Flow/canvas/PixiApp.d.ts +2 -0
- package/dist/components/pro/Flow/canvas/PixiApp.js +14 -11
- package/dist/components/pro/Flow/canvas/PixiApp.js.map +1 -1
- package/dist/components/pro/Flow/constants.js +7 -7
- package/dist/components/pro/Flow/constants.js.map +1 -1
- package/dist/components/pro/Flow/context/FlowAIContext.d.ts +15 -0
- package/dist/components/pro/Flow/context/FlowAIContext.js +32 -0
- package/dist/components/pro/Flow/context/FlowAIContext.js.map +1 -0
- package/dist/components/pro/Flow/context/FlowUIContext.d.ts +4 -1
- package/dist/components/pro/Flow/context/FlowUIContext.js +58 -55
- package/dist/components/pro/Flow/context/FlowUIContext.js.map +1 -1
- package/dist/components/pro/Flow/edges/EdgeRenderer.js +22 -21
- package/dist/components/pro/Flow/edges/EdgeRenderer.js.map +1 -1
- package/dist/components/pro/Flow/hooks/useFlowImportExport.js +32 -32
- package/dist/components/pro/Flow/hooks/useFlowImportExport.js.map +1 -1
- package/dist/components/pro/Flow/hooks/usePixiApp.d.ts +6 -1
- package/dist/components/pro/Flow/hooks/usePixiApp.js +49 -30
- package/dist/components/pro/Flow/hooks/usePixiApp.js.map +1 -1
- package/dist/components/pro/Flow/index.d.ts +2 -0
- package/dist/components/pro/Flow/lines/FreehandTool.js +21 -20
- package/dist/components/pro/Flow/lines/FreehandTool.js.map +1 -1
- package/dist/components/pro/Flow/lines/GeometricLineTool.js +22 -18
- package/dist/components/pro/Flow/lines/GeometricLineTool.js.map +1 -1
- package/dist/components/pro/Flow/lines/LineRenderer.js +19 -18
- package/dist/components/pro/Flow/lines/LineRenderer.js.map +1 -1
- package/dist/components/pro/Flow/nodes/MediaContent.js +143 -124
- package/dist/components/pro/Flow/nodes/MediaContent.js.map +1 -1
- package/dist/components/pro/Flow/nodes/MediaOverlay.js +22 -17
- package/dist/components/pro/Flow/nodes/MediaOverlay.js.map +1 -1
- package/dist/components/pro/Flow/nodes/NodeRenderer.js +77 -76
- package/dist/components/pro/Flow/nodes/NodeRenderer.js.map +1 -1
- package/dist/components/pro/Flow/nodes/aiClient.d.ts +22 -0
- package/dist/components/pro/Flow/nodes/aiClient.js +107 -54
- package/dist/components/pro/Flow/nodes/aiClient.js.map +1 -1
- package/dist/components/pro/Flow/nodes/svgIcons.js +6 -6
- package/dist/components/pro/Flow/nodes/svgIcons.js.map +1 -1
- package/dist/components/pro/Flow/panels/AIPanel.d.ts +2 -0
- package/dist/components/pro/Flow/panels/AIPanel.js +498 -0
- package/dist/components/pro/Flow/panels/AIPanel.js.map +1 -0
- package/dist/components/pro/Flow/panels/FlowPanelGroup.js +51 -39
- package/dist/components/pro/Flow/panels/FlowPanelGroup.js.map +1 -1
- package/dist/components/pro/Flow/panels/FlowToolbar.js +91 -85
- package/dist/components/pro/Flow/panels/FlowToolbar.js.map +1 -1
- package/dist/components/pro/Flow/panels/InspectorPanel.js +372 -332
- package/dist/components/pro/Flow/panels/InspectorPanel.js.map +1 -1
- package/dist/components/pro/Flow/panels/OutlinePanel.js +28 -27
- package/dist/components/pro/Flow/panels/OutlinePanel.js.map +1 -1
- package/dist/components/pro/Flow/panels/ShapePalette.js +107 -104
- package/dist/components/pro/Flow/panels/ShapePalette.js.map +1 -1
- package/dist/components/pro/Flow/panels/toolbarIcons.d.ts +1 -0
- package/dist/components/pro/Flow/panels/toolbarIcons.js +25 -20
- package/dist/components/pro/Flow/panels/toolbarIcons.js.map +1 -1
- package/dist/components/pro/Flow/types.d.ts +13 -0
- package/dist/components/pro/Flow/types.js.map +1 -1
- package/dist/components/pro/Flow/utils/themeColor.d.ts +87 -0
- package/dist/components/pro/Flow/utils/themeColor.js +212 -0
- package/dist/components/pro/Flow/utils/themeColor.js.map +1 -0
- package/dist/contexts/AppContext.d.ts +1 -1
- package/dist/contexts/AppContext.js +28 -29
- package/dist/contexts/AppContext.js.map +1 -1
- package/dist/dishui.css +1 -1
- package/dist/favicon.svg +10 -0
- package/dist/flow.js +56 -51
- package/dist/styles/themeStyles.js +6 -11
- package/dist/styles/themeStyles.js.map +1 -1
- package/dist/utils/themes.js +3 -23
- package/dist/utils/themes.js.map +1 -1
- package/package.json +17 -18
|
@@ -1,405 +1,407 @@
|
|
|
1
|
-
import { useFlowContext as
|
|
2
|
-
import { useFlowUI as
|
|
3
|
-
import { usePixiApp as
|
|
4
|
-
import { useViewport as
|
|
5
|
-
import { GridRenderer as
|
|
6
|
-
import { SelectionOverlay as
|
|
7
|
-
import { shapeDrawers as
|
|
8
|
-
import { findClosestHandleWorld as
|
|
9
|
-
import { distToSegment as me, generateId as
|
|
10
|
-
import { NodeRenderer as
|
|
11
|
-
import { buildEdgePath as
|
|
12
|
-
import { EdgeRenderer as
|
|
13
|
-
import { LineRenderer as
|
|
14
|
-
import { FreehandTool as
|
|
15
|
-
import { GeometricLineTool as
|
|
16
|
-
import { computeAlignmentSnap as
|
|
17
|
-
import { AlignmentGuidesRenderer as
|
|
18
|
-
import { getDocumentSlides as
|
|
19
|
-
import { useCallback as
|
|
20
|
-
import { jsx as
|
|
21
|
-
import { Graphics as
|
|
22
|
-
var
|
|
1
|
+
import { useFlowContext as Be } from "./context/FlowContext.js";
|
|
2
|
+
import { useFlowUI as Ke } from "./context/FlowUIContext.js";
|
|
3
|
+
import { usePixiApp as je } from "./hooks/usePixiApp.js";
|
|
4
|
+
import { useViewport as Ue } from "./hooks/useViewport.js";
|
|
5
|
+
import { GridRenderer as $e } from "./canvas/GridRenderer.js";
|
|
6
|
+
import { SelectionOverlay as Je } from "./canvas/SelectionOverlay.js";
|
|
7
|
+
import { shapeDrawers as Ge } from "./nodes/shapes.js";
|
|
8
|
+
import { findClosestHandleWorld as Et, getHandlePositions as gt, handleWorldPos as Zt } from "./nodes/NodeHandles.js";
|
|
9
|
+
import { distToSegment as me, generateId as Qe, isPointInNode as Dt, rectsOverlap as tn } from "./nodes/nodeUtils.js";
|
|
10
|
+
import { NodeRenderer as en } from "./nodes/NodeRenderer.js";
|
|
11
|
+
import { buildEdgePath as Ze, linearizeSegments as qe, resolveEdgeEndpoints as Mt } from "./edges/edgePaths.js";
|
|
12
|
+
import { EdgeRenderer as nn } from "./edges/EdgeRenderer.js";
|
|
13
|
+
import { LineRenderer as rn } from "./lines/LineRenderer.js";
|
|
14
|
+
import { FreehandTool as on } from "./lines/FreehandTool.js";
|
|
15
|
+
import { GeometricLineTool as sn } from "./lines/GeometricLineTool.js";
|
|
16
|
+
import { computeAlignmentSnap as ne } from "./hooks/useAlignmentGuides.js";
|
|
17
|
+
import { AlignmentGuidesRenderer as cn } from "./canvas/AlignmentGuides.js";
|
|
18
|
+
import { getDocumentSlides as dn, nextAnimIndex as an } from "./nodes/animAnchors.js";
|
|
19
|
+
import { useCallback as qt, useEffect as wt, useRef as b, useState as We } from "react";
|
|
20
|
+
import { jsx as Le, jsxs as ln } from "react/jsx-runtime";
|
|
21
|
+
import { Graphics as Ot } from "pixi.js";
|
|
22
|
+
var un = {
|
|
23
23
|
nw: "nwse-resize",
|
|
24
24
|
ne: "nesw-resize",
|
|
25
25
|
se: "nwse-resize",
|
|
26
26
|
sw: "nesw-resize"
|
|
27
27
|
};
|
|
28
|
-
function
|
|
29
|
-
const { x:
|
|
28
|
+
function Ae(F, E, G) {
|
|
29
|
+
const { x: Z, y: D } = E.position, W = E.width, k = E.height, z = [
|
|
30
30
|
[
|
|
31
31
|
"nw",
|
|
32
|
-
|
|
32
|
+
Z,
|
|
33
33
|
D
|
|
34
34
|
],
|
|
35
35
|
[
|
|
36
36
|
"ne",
|
|
37
|
-
|
|
37
|
+
Z + W,
|
|
38
38
|
D
|
|
39
39
|
],
|
|
40
40
|
[
|
|
41
41
|
"se",
|
|
42
|
-
|
|
42
|
+
Z + W,
|
|
43
43
|
D + k
|
|
44
44
|
],
|
|
45
45
|
[
|
|
46
46
|
"sw",
|
|
47
|
-
|
|
47
|
+
Z,
|
|
48
48
|
D + k
|
|
49
49
|
]
|
|
50
50
|
];
|
|
51
|
-
let M = null,
|
|
52
|
-
for (const [
|
|
53
|
-
const
|
|
54
|
-
|
|
51
|
+
let M = null, _ = G;
|
|
52
|
+
for (const [U, it, tt] of z) {
|
|
53
|
+
const K = Math.hypot(F.x - it, F.y - tt);
|
|
54
|
+
K < _ && (_ = K, M = U);
|
|
55
55
|
}
|
|
56
56
|
return M;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
let
|
|
60
|
-
for (const
|
|
61
|
-
const M = Mt(
|
|
58
|
+
function Ye(F, E, G, Z, D) {
|
|
59
|
+
let W = null, k = D;
|
|
60
|
+
for (const z of G) {
|
|
61
|
+
const M = Mt(z, Z);
|
|
62
62
|
if (!M) continue;
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
edgeId:
|
|
63
|
+
const _ = Math.hypot(F - M.sx, E - M.sy);
|
|
64
|
+
_ < k && (k = _, W = {
|
|
65
|
+
edgeId: z.id,
|
|
66
66
|
end: "source",
|
|
67
67
|
worldX: M.sx,
|
|
68
68
|
worldY: M.sy
|
|
69
69
|
});
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
edgeId:
|
|
70
|
+
const U = Math.hypot(F - M.tx, E - M.ty);
|
|
71
|
+
U < k && (k = U, W = {
|
|
72
|
+
edgeId: z.id,
|
|
73
73
|
end: "target",
|
|
74
74
|
worldX: M.tx,
|
|
75
75
|
worldY: M.ty
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
return
|
|
78
|
+
return W;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
let D = null,
|
|
82
|
-
for (const k of
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
for (let M = 0; M <
|
|
86
|
-
const
|
|
87
|
-
|
|
80
|
+
function Xe(F, E, G, Z) {
|
|
81
|
+
let D = null, W = Z;
|
|
82
|
+
for (const k of G) {
|
|
83
|
+
const z = k.data.waypoints;
|
|
84
|
+
if (z)
|
|
85
|
+
for (let M = 0; M < z.length; M++) {
|
|
86
|
+
const _ = Math.hypot(F - z[M].x, E - z[M].y);
|
|
87
|
+
_ < W && (W = _, D = {
|
|
88
88
|
edgeId: k.id,
|
|
89
89
|
waypointIndex: M,
|
|
90
|
-
wx:
|
|
91
|
-
wy:
|
|
90
|
+
wx: z[M].x,
|
|
91
|
+
wy: z[M].y
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
return D;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
let
|
|
99
|
-
for (const
|
|
100
|
-
if (
|
|
101
|
-
const M = Mt(
|
|
97
|
+
function Fe(F, E, G, Z, D) {
|
|
98
|
+
let W = null, k = D;
|
|
99
|
+
for (const z of G) {
|
|
100
|
+
if (z.type !== "simplebezier") continue;
|
|
101
|
+
const M = Mt(z, Z);
|
|
102
102
|
if (!M) continue;
|
|
103
|
-
const
|
|
103
|
+
const _ = z.data.waypoints ?? [], U = [
|
|
104
104
|
{
|
|
105
105
|
x: M.sx,
|
|
106
106
|
y: M.sy
|
|
107
107
|
},
|
|
108
|
-
...
|
|
108
|
+
..._,
|
|
109
109
|
{
|
|
110
110
|
x: M.tx,
|
|
111
111
|
y: M.ty
|
|
112
112
|
}
|
|
113
|
-
],
|
|
114
|
-
for (let
|
|
115
|
-
const et =
|
|
116
|
-
|
|
117
|
-
edgeId:
|
|
118
|
-
segmentIndex:
|
|
113
|
+
], it = z.data.bezierControls, tt = U.length - 2;
|
|
114
|
+
for (let K = 0; K <= tt; K++) {
|
|
115
|
+
const et = U[K], nt = U[K + 1], mt = it?.[K], Vt = Math.hypot(nt.x - et.x, nt.y - et.y), kt = Math.max(30, Vt * 0.3), Bt = mt?.c1x ?? (K === 0 ? et.x + M.snx * kt : et.x + (nt.x - et.x) * 0.4), Ht = mt?.c1y ?? (K === 0 ? et.y + M.sny * kt : et.y), Tt = mt?.c2x ?? (K === tt ? nt.x + M.tnx * kt : nt.x - (nt.x - et.x) * 0.4), Rt = mt?.c2y ?? (K === tt ? nt.y + M.tny * kt : nt.y), It = Math.hypot(F - Bt, E - Ht);
|
|
116
|
+
It < k && (k = It, W = {
|
|
117
|
+
edgeId: z.id,
|
|
118
|
+
segmentIndex: K,
|
|
119
119
|
controlEnd: "c1",
|
|
120
|
-
wx:
|
|
121
|
-
wy:
|
|
120
|
+
wx: Bt,
|
|
121
|
+
wy: Ht
|
|
122
122
|
});
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
edgeId:
|
|
126
|
-
segmentIndex:
|
|
123
|
+
const yt = Math.hypot(F - Tt, E - Rt);
|
|
124
|
+
yt < k && (k = yt, W = {
|
|
125
|
+
edgeId: z.id,
|
|
126
|
+
segmentIndex: K,
|
|
127
127
|
controlEnd: "c2",
|
|
128
|
-
wx:
|
|
129
|
-
wy:
|
|
128
|
+
wx: Tt,
|
|
129
|
+
wy: Rt
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
return
|
|
133
|
+
return W;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
const D = Mt(
|
|
135
|
+
function fn(F, E, G, Z) {
|
|
136
|
+
const D = Mt(G, Z);
|
|
137
137
|
if (!D) return 0;
|
|
138
|
-
const
|
|
138
|
+
const W = G.data.waypoints ?? [], k = [
|
|
139
139
|
{
|
|
140
140
|
x: D.sx,
|
|
141
141
|
y: D.sy
|
|
142
142
|
},
|
|
143
|
-
...
|
|
143
|
+
...W,
|
|
144
144
|
{
|
|
145
145
|
x: D.tx,
|
|
146
146
|
y: D.ty
|
|
147
147
|
}
|
|
148
148
|
];
|
|
149
|
-
let
|
|
150
|
-
for (let
|
|
151
|
-
const
|
|
152
|
-
|
|
149
|
+
let z = 1 / 0, M = 0;
|
|
150
|
+
for (let _ = 0; _ < k.length - 1; _++) {
|
|
151
|
+
const U = me(F, E, k[_].x, k[_].y, k[_ + 1].x, k[_ + 1].y);
|
|
152
|
+
U < z && (z = U, M = _);
|
|
153
153
|
}
|
|
154
154
|
return M;
|
|
155
155
|
}
|
|
156
|
-
function
|
|
157
|
-
let { x:
|
|
158
|
-
const
|
|
159
|
-
return
|
|
160
|
-
x:
|
|
156
|
+
function hn(F, E, G, Z, D = 24) {
|
|
157
|
+
let { x: W, y: k, w: z, h: M } = { ...F };
|
|
158
|
+
const _ = E === "nw" || E === "sw", U = E === "ne" || E === "se", it = E === "nw" || E === "ne", tt = E === "sw" || E === "se";
|
|
159
|
+
return _ && (W += G, z -= G), U && (z += G), it && (k += Z, M -= Z), tt && (M += Z), z < D && (_ && (W = F.x + F.w - D), z = D), M < D && (it && (k = F.y + F.h - D), M = D), {
|
|
160
|
+
x: W,
|
|
161
161
|
y: k,
|
|
162
|
-
w:
|
|
162
|
+
w: z,
|
|
163
163
|
h: M
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
-
function we(
|
|
167
|
-
const
|
|
168
|
-
if (!
|
|
169
|
-
const k = Ze(
|
|
170
|
-
for (let
|
|
166
|
+
function we(F, E, G, Z, D) {
|
|
167
|
+
const W = Mt(G, Z);
|
|
168
|
+
if (!W) return !1;
|
|
169
|
+
const k = qe(Ze(G.type, W, G.data.waypoints, G.data.bezierControls));
|
|
170
|
+
for (let z = 0; z < k.length - 1; z++) if (me(F, E, k[z].x, k[z].y, k[z + 1].x, k[z + 1].y) < D) return !0;
|
|
171
171
|
return !1;
|
|
172
172
|
}
|
|
173
|
-
function
|
|
174
|
-
const D =
|
|
175
|
-
for (let
|
|
173
|
+
function _e(F, E, G, Z) {
|
|
174
|
+
const D = G.points;
|
|
175
|
+
for (let W = 0; W < D.length - 1; W++) if (me(F, E, D[W].x, D[W].y, D[W + 1].x, D[W + 1].y) < Z) return !0;
|
|
176
176
|
return !1;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
const E = b(null),
|
|
178
|
+
function Wn({ onPixiReady: F }) {
|
|
179
|
+
const E = b(null), G = b(null), Z = b(13751771), { pixiRef: D, readyRef: W } = je(E, qt((l) => {
|
|
180
|
+
Z.current = l.gridDot, G.current && (G.current.dotColor = l.gridDot);
|
|
181
|
+
}, [])), { setViewportInternal: k, viewportReqRef: z, viewport: M, autoFocus: _, showGrid: U, showAnchors: it, gridSize: tt, toolMode: K, edgeType: et, focusOnRect: nt, setFocusOnRect: mt, pendingPlacement: Vt, setPendingPlacement: kt, setContextMenu: Bt, beginNodeDrag: Ht, endNodeDrag: Tt, presentation: Rt, editingNodeId: It, setEditingNodeId: yt } = Ke(), { currentCanvas: re, selection: Ie, setSelection: lt, setDoc: J, currentCanvasId: oe, pushCanvas: Oe, doc: ve } = Be(), St = b(null), Kt = b(null), jt = b(null), Ut = b(null), se = b(null), ce = b(null), $t = b(null), Pt = b(null), Gt = b(null), Jt = b(null), zt = b([]), ie = b(null), de = b(null), ut = b(null), Wt = b(null), be = b({
|
|
180
182
|
time: 0,
|
|
181
183
|
wx: 0,
|
|
182
184
|
wy: 0
|
|
183
|
-
}),
|
|
185
|
+
}), Lt = b({
|
|
184
186
|
time: 0,
|
|
185
187
|
wx: 0,
|
|
186
188
|
wy: 0
|
|
187
|
-
}),
|
|
189
|
+
}), At = b(null), Me = b({
|
|
188
190
|
x: 0,
|
|
189
191
|
y: 0
|
|
190
|
-
}),
|
|
191
|
-
...
|
|
192
|
-
nodes:
|
|
193
|
-
},
|
|
194
|
-
|
|
192
|
+
}), Re = it || Rt ? re : {
|
|
193
|
+
...re,
|
|
194
|
+
nodes: re.nodes.filter((l) => l.type !== "animAnchor")
|
|
195
|
+
}, A = b(Re);
|
|
196
|
+
A.current = Re;
|
|
195
197
|
const V = b(oe);
|
|
196
198
|
V.current = oe;
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
const ae = b(
|
|
214
|
-
ae.current =
|
|
215
|
-
const Ne = b(
|
|
216
|
-
Ne.current =
|
|
217
|
-
const le = b(
|
|
218
|
-
le.current =
|
|
219
|
-
const ft = b(null), rt = b(null), ot = b(null), dt = b(null), xt = b(null), pt = b(null), vt = b(null), ue = b(
|
|
220
|
-
ue.current =
|
|
221
|
-
fe.current = 0,
|
|
199
|
+
const Yt = b(Ie);
|
|
200
|
+
Yt.current = Ie;
|
|
201
|
+
const Se = b(ve);
|
|
202
|
+
Se.current = ve;
|
|
203
|
+
const Xt = b(K);
|
|
204
|
+
Xt.current = K;
|
|
205
|
+
const Ft = b(_);
|
|
206
|
+
Ft.current = _;
|
|
207
|
+
const _t = b(nt);
|
|
208
|
+
_t.current = nt;
|
|
209
|
+
const ze = b(et);
|
|
210
|
+
ze.current = et;
|
|
211
|
+
const Ce = b(it);
|
|
212
|
+
Ce.current = it;
|
|
213
|
+
const Ct = b(Rt);
|
|
214
|
+
Ct.current = Rt;
|
|
215
|
+
const ae = b(Vt);
|
|
216
|
+
ae.current = Vt;
|
|
217
|
+
const Ne = b(Ht);
|
|
218
|
+
Ne.current = Ht;
|
|
219
|
+
const le = b(Tt);
|
|
220
|
+
le.current = Tt;
|
|
221
|
+
const ft = b(null), rt = b(null), ot = b(null), dt = b(null), xt = b(null), pt = b(null), vt = b(null), ue = b(M), fe = b(0), { vmRef: $, screenToWorld: Ee } = Ue(D, qt((l) => {
|
|
222
|
+
ue.current = l, fe.current || (fe.current = requestAnimationFrame(() => {
|
|
223
|
+
fe.current = 0, k(ue.current);
|
|
222
224
|
}));
|
|
223
|
-
}, [
|
|
224
|
-
st.current =
|
|
225
|
-
const [at, he] =
|
|
225
|
+
}, [k])), st = b(Ee);
|
|
226
|
+
st.current = Ee;
|
|
227
|
+
const [at, he] = We(null), [ye, xe] = We(null), pe = b(at);
|
|
226
228
|
pe.current = at;
|
|
227
|
-
const
|
|
229
|
+
const Qt = b(() => {
|
|
228
230
|
});
|
|
229
|
-
|
|
230
|
-
yt(
|
|
231
|
-
kind:
|
|
232
|
-
id:
|
|
233
|
-
value:
|
|
231
|
+
Qt.current = (l, T, Y) => {
|
|
232
|
+
yt(l === "node" ? T : null), he({
|
|
233
|
+
kind: l,
|
|
234
|
+
id: T,
|
|
235
|
+
value: Y
|
|
234
236
|
});
|
|
235
237
|
};
|
|
236
|
-
const
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
if (!
|
|
241
|
-
let
|
|
242
|
-
if (
|
|
243
|
-
...
|
|
244
|
-
nodes:
|
|
238
|
+
const De = qt((l) => {
|
|
239
|
+
const T = pe.current;
|
|
240
|
+
T && (J((Y) => {
|
|
241
|
+
const L = V.current, q = Y.canvases[L];
|
|
242
|
+
if (!q) return Y;
|
|
243
|
+
let X = q;
|
|
244
|
+
if (T.kind === "node") X = {
|
|
245
|
+
...q,
|
|
246
|
+
nodes: q.nodes.map((B) => B.id === T.id ? {
|
|
245
247
|
...B,
|
|
246
248
|
data: {
|
|
247
249
|
...B.data,
|
|
248
|
-
label:
|
|
250
|
+
label: l
|
|
249
251
|
}
|
|
250
252
|
} : B)
|
|
251
253
|
};
|
|
252
|
-
else if (
|
|
253
|
-
...
|
|
254
|
-
edges:
|
|
254
|
+
else if (T.kind === "edge") X = {
|
|
255
|
+
...q,
|
|
256
|
+
edges: q.edges.map((B) => B.id === T.id ? {
|
|
255
257
|
...B,
|
|
256
258
|
data: {
|
|
257
259
|
...B.data,
|
|
258
|
-
labelText:
|
|
260
|
+
labelText: l
|
|
259
261
|
}
|
|
260
262
|
} : B)
|
|
261
263
|
};
|
|
262
|
-
else return
|
|
264
|
+
else return Y;
|
|
263
265
|
return {
|
|
264
|
-
...
|
|
266
|
+
...Y,
|
|
265
267
|
canvases: {
|
|
266
|
-
...
|
|
267
|
-
[
|
|
268
|
+
...Y.canvases,
|
|
269
|
+
[L]: X
|
|
268
270
|
}
|
|
269
271
|
};
|
|
270
272
|
}), he(null), yt(null), xe(null));
|
|
271
|
-
}, [J, yt]),
|
|
273
|
+
}, [J, yt]), Ve = qt(() => {
|
|
272
274
|
he(null), yt(null), xe(null);
|
|
273
275
|
}, [yt]);
|
|
274
276
|
wt(() => {
|
|
275
277
|
if (!It || pe.current?.id === It) return;
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
+
const l = A.current.nodes.find((T) => T.id === It);
|
|
279
|
+
l && Qt.current("node", l.id, l.data.label);
|
|
278
280
|
}, [It]), wt(() => {
|
|
279
281
|
if (!at) return;
|
|
280
|
-
const
|
|
281
|
-
if (!
|
|
282
|
-
const
|
|
283
|
-
let
|
|
282
|
+
const l = $.current;
|
|
283
|
+
if (!l) return;
|
|
284
|
+
const T = A.current;
|
|
285
|
+
let Y = null;
|
|
284
286
|
if (at.kind === "node") {
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
x:
|
|
288
|
-
y:
|
|
287
|
+
const L = T.nodes.find((q) => q.id === at.id);
|
|
288
|
+
L && (Y = {
|
|
289
|
+
x: L.position.x + L.width / 2,
|
|
290
|
+
y: L.position.y + L.height / 2
|
|
289
291
|
});
|
|
290
292
|
} else if (at.kind === "edge") {
|
|
291
|
-
const
|
|
292
|
-
for (const
|
|
293
|
-
if (
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
const B = Ze(
|
|
297
|
-
x: (
|
|
298
|
-
y: (
|
|
293
|
+
const L = T.edges.find((X) => X.id === at.id), q = /* @__PURE__ */ new Map();
|
|
294
|
+
for (const X of T.nodes) q.set(X.id, X);
|
|
295
|
+
if (L) {
|
|
296
|
+
const X = Mt(L, q);
|
|
297
|
+
if (X) {
|
|
298
|
+
const B = qe(Ze(L.type, X, L.data.waypoints, L.data.bezierControls)), Q = B[Math.floor(B.length / 2)] ?? {
|
|
299
|
+
x: (X.sx + X.tx) / 2,
|
|
300
|
+
y: (X.sy + X.ty) / 2
|
|
299
301
|
};
|
|
300
|
-
|
|
302
|
+
Y = {
|
|
301
303
|
x: Q.x,
|
|
302
304
|
y: Q.y
|
|
303
305
|
};
|
|
304
306
|
}
|
|
305
307
|
}
|
|
306
308
|
}
|
|
307
|
-
if (
|
|
308
|
-
const
|
|
309
|
+
if (Y) {
|
|
310
|
+
const L = l.worldToScreen(Y.x, Y.y);
|
|
309
311
|
xe({
|
|
310
|
-
x:
|
|
311
|
-
y:
|
|
312
|
+
x: L.x,
|
|
313
|
+
y: L.y
|
|
312
314
|
});
|
|
313
315
|
}
|
|
314
316
|
}, [at, $]);
|
|
315
317
|
const ke = b(0);
|
|
316
318
|
wt(() => {
|
|
317
|
-
|
|
319
|
+
z.current !== ke.current && (ke.current = z.current, ue.current = M, $.current?.setState(M));
|
|
318
320
|
}, [
|
|
319
|
-
|
|
321
|
+
M,
|
|
320
322
|
$,
|
|
321
|
-
|
|
323
|
+
z
|
|
322
324
|
]), wt(() => {
|
|
323
|
-
|
|
324
|
-
const
|
|
325
|
-
if (!
|
|
326
|
-
const Q = B.clientWidth || 800,
|
|
327
|
-
|
|
328
|
-
x:
|
|
329
|
-
y:
|
|
325
|
+
mt((l, T, Y, L, q) => {
|
|
326
|
+
const X = $.current, B = E.current;
|
|
327
|
+
if (!X || !B) return;
|
|
328
|
+
const Q = B.clientWidth || 800, ct = B.clientHeight || 600, bt = Math.max(0, q?.padding ?? 60), te = Math.max(1, Q - bt * 2), m = Math.max(1, ct - bt * 2), s = q?.preserveZoom ? X.state.zoom : Math.min(te / Math.max(Y, 1), m / Math.max(L, 1), q?.maxZoom ?? 2), u = l + Y / 2, v = T + L / 2, P = Q / 2 - u * s, N = ct / 2 - v * s;
|
|
329
|
+
X.animateTo({
|
|
330
|
+
x: P,
|
|
331
|
+
y: N,
|
|
330
332
|
zoom: s
|
|
331
|
-
},
|
|
333
|
+
}, q?.duration ?? 350);
|
|
332
334
|
});
|
|
333
|
-
}, [
|
|
334
|
-
const
|
|
335
|
-
J((
|
|
336
|
-
const
|
|
337
|
-
return
|
|
338
|
-
...
|
|
335
|
+
}, [mt, $]);
|
|
336
|
+
const He = qt((l) => {
|
|
337
|
+
J((T) => {
|
|
338
|
+
const Y = T.canvases[V.current];
|
|
339
|
+
return Y ? {
|
|
340
|
+
...T,
|
|
339
341
|
canvases: {
|
|
340
|
-
...
|
|
342
|
+
...T.canvases,
|
|
341
343
|
[V.current]: {
|
|
342
|
-
...
|
|
343
|
-
lines: [...
|
|
344
|
+
...Y,
|
|
345
|
+
lines: [...Y.lines, l]
|
|
344
346
|
}
|
|
345
347
|
}
|
|
346
|
-
} :
|
|
348
|
+
} : T;
|
|
347
349
|
});
|
|
348
|
-
}, [J, oe]), ge = b(
|
|
349
|
-
return ge.current =
|
|
350
|
-
const
|
|
351
|
-
if (!
|
|
352
|
-
let
|
|
353
|
-
const
|
|
354
|
-
if (
|
|
355
|
-
if (!
|
|
356
|
-
setTimeout(
|
|
350
|
+
}, [J, oe]), ge = b(He);
|
|
351
|
+
return ge.current = He, wt(() => {
|
|
352
|
+
const l = D.current;
|
|
353
|
+
if (!l || l.destroyed) return;
|
|
354
|
+
let T = !1;
|
|
355
|
+
const Y = () => {
|
|
356
|
+
if (T) return;
|
|
357
|
+
if (!W.current) {
|
|
358
|
+
setTimeout(Y, 30);
|
|
357
359
|
return;
|
|
358
360
|
}
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
const B = new
|
|
367
|
-
B.label = "edge-edit-handles",
|
|
368
|
-
const Q = new
|
|
369
|
-
Q.label = "ghost-placement", Q.alpha = 0.5,
|
|
361
|
+
G.current = new $e(l.app.stage, tt, U), G.current.dotColor = Z.current, St.current = new Je(l.app.stage), Kt.current = new en(l.world), jt.current = new nn(l.world), Ut.current = new rn(l.world);
|
|
362
|
+
const L = new Ot();
|
|
363
|
+
L.label = "connect-line", L.visible = !1, l.world.addChild(L), xt.current = L;
|
|
364
|
+
const q = new Ot();
|
|
365
|
+
q.label = "transform-handles", l.app.stage.addChild(q), Pt.current = q;
|
|
366
|
+
const X = new Ot();
|
|
367
|
+
X.label = "handle-hover", l.world.addChild(X), Gt.current = X;
|
|
368
|
+
const B = new Ot();
|
|
369
|
+
B.label = "edge-edit-handles", l.world.addChild(B), Wt.current = B;
|
|
370
|
+
const Q = new Ot();
|
|
371
|
+
Q.label = "ghost-placement", Q.alpha = 0.5, l.world.addChild(Q), At.current = Q, Jt.current = new cn(l.world), se.current = new on(l.app.stage, l.world, {
|
|
370
372
|
onLineComplete: (m) => ge.current(m),
|
|
371
373
|
screenToWorld: (m, s) => st.current(m, s)
|
|
372
|
-
}),
|
|
374
|
+
}), ce.current = new sn(l.app.stage, l.world, {
|
|
373
375
|
onLineComplete: (m) => ge.current(m),
|
|
374
376
|
screenToWorld: (m, s) => st.current(m, s)
|
|
375
|
-
}),
|
|
376
|
-
const
|
|
377
|
-
|
|
377
|
+
}), F?.(l);
|
|
378
|
+
const ct = l.app.stage;
|
|
379
|
+
ct.on("pointerdown", (m) => {
|
|
378
380
|
if (E.current?.focus({ preventScroll: !0 }), $.current?.isPanning || $.current?.isSpaceHeld || m.button !== 0) return;
|
|
379
|
-
const s =
|
|
381
|
+
const s = Xt.current;
|
|
380
382
|
if (s === "pan") {
|
|
381
383
|
$.current?.startPan(m.global.x, m.global.y);
|
|
382
384
|
return;
|
|
383
385
|
}
|
|
384
386
|
if (s === "freehand" || s === "line" || s === "polyline" || s === "arrow") return;
|
|
385
|
-
const
|
|
387
|
+
const u = st.current(m.global.x, m.global.y), v = A.current.nodes, P = A.current.edges, N = A.current.lines, I = Yt.current, S = m.metaKey || m.ctrlKey || m.shiftKey, O = $.current?.state.zoom ?? 1, e = ae.current;
|
|
386
388
|
if (e) {
|
|
387
|
-
const t =
|
|
389
|
+
const t = Qe("node"), i = u.x - e.width / 2, n = u.y - e.height / 2, o = ne([{
|
|
388
390
|
id: "__ghost__",
|
|
389
391
|
type: e.type,
|
|
390
392
|
position: {
|
|
391
|
-
x:
|
|
393
|
+
x: i,
|
|
392
394
|
y: n
|
|
393
395
|
},
|
|
394
396
|
width: e.width,
|
|
395
397
|
height: e.height,
|
|
396
398
|
data: {}
|
|
397
|
-
}], v), r =
|
|
399
|
+
}], v), r = i + o.dx, d = n + o.dy;
|
|
398
400
|
J((w) => {
|
|
399
401
|
const g = w.canvases[V.current];
|
|
400
402
|
if (!g) return w;
|
|
401
|
-
const
|
|
402
|
-
e.type === "animAnchor" && (
|
|
403
|
+
const C = {};
|
|
404
|
+
e.type === "animAnchor" && (C.animIndex = an(w));
|
|
403
405
|
const H = Math.max(0, ...g.nodes.map((h) => h.zIndex ?? 0), ...g.lines.map((h) => h.zIndex ?? 0));
|
|
404
406
|
return {
|
|
405
407
|
...w,
|
|
@@ -419,7 +421,7 @@ function Gn({ onPixiReady: _ }) {
|
|
|
419
421
|
zIndex: H + 1,
|
|
420
422
|
data: {
|
|
421
423
|
...e.data,
|
|
422
|
-
...
|
|
424
|
+
...C
|
|
423
425
|
}
|
|
424
426
|
}]
|
|
425
427
|
}
|
|
@@ -429,8 +431,8 @@ function Gn({ onPixiReady: _ }) {
|
|
|
429
431
|
nodeIds: /* @__PURE__ */ new Set([t]),
|
|
430
432
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
431
433
|
lineIds: /* @__PURE__ */ new Set()
|
|
432
|
-
}),
|
|
433
|
-
|
|
434
|
+
}), Ft.current && window.setTimeout(() => {
|
|
435
|
+
_t.current(r, d, e.width, e.height, {
|
|
434
436
|
padding: 80,
|
|
435
437
|
preserveZoom: !0,
|
|
436
438
|
duration: 280
|
|
@@ -438,36 +440,36 @@ function Gn({ onPixiReady: _ }) {
|
|
|
438
440
|
}, 0);
|
|
439
441
|
return;
|
|
440
442
|
}
|
|
441
|
-
const
|
|
442
|
-
if (
|
|
443
|
-
time:
|
|
444
|
-
wx:
|
|
445
|
-
wy:
|
|
443
|
+
const c = Date.now(), y = be.current, f = c - y.time < 350 && Math.hypot(u.x - y.wx, u.y - y.wy) < 8 / O;
|
|
444
|
+
if (be.current = {
|
|
445
|
+
time: c,
|
|
446
|
+
wx: u.x,
|
|
447
|
+
wy: u.y
|
|
446
448
|
}, I.nodeIds.size === 1 && !S && s === "select") {
|
|
447
|
-
const t = v.find((
|
|
449
|
+
const t = v.find((i) => i.id === [...I.nodeIds][0]);
|
|
448
450
|
if (t) {
|
|
449
|
-
const
|
|
450
|
-
if (
|
|
451
|
-
const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), r = t.type === "geometryGroup", d = r || t.type === "flowGroup" || t.data.isGroup, w = t.position.x, g = t.position.y,
|
|
451
|
+
const i = Ae(u, t, Math.min(10 / O, 16));
|
|
452
|
+
if (i) {
|
|
453
|
+
const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), r = t.type === "geometryGroup", d = r || t.type === "flowGroup" || t.data.isGroup, w = t.position.x, g = t.position.y, C = t.width, H = t.height;
|
|
452
454
|
for (const h of v)
|
|
453
455
|
h.id !== t.id && (h.parentId === t.id ? n.set(h.id, {
|
|
454
456
|
x: h.position.x,
|
|
455
457
|
y: h.position.y,
|
|
456
458
|
w: h.width,
|
|
457
459
|
h: h.height
|
|
458
|
-
}) : r && h.position.x >= w && h.position.y >= g && h.position.x + h.width <= w +
|
|
460
|
+
}) : r && h.position.x >= w && h.position.y >= g && h.position.x + h.width <= w + C && h.position.y + h.height <= g + H && n.set(h.id, {
|
|
459
461
|
x: h.position.x,
|
|
460
462
|
y: h.position.y,
|
|
461
463
|
w: h.width,
|
|
462
464
|
h: h.height
|
|
463
465
|
}));
|
|
464
466
|
if (d)
|
|
465
|
-
for (const h of
|
|
467
|
+
for (const h of A.current.lines) h.parentId === t.id ? o.set(h.id, h.points.map((R) => ({ ...R }))) : r && h.points.length > 0 && h.points.every((R) => R.x >= w && R.x <= w + C && R.y >= g && R.y <= g + H) && o.set(h.id, h.points.map((R) => ({ ...R })));
|
|
466
468
|
pt.current = {
|
|
467
469
|
active: !0,
|
|
468
470
|
nodeId: t.id,
|
|
469
|
-
handle:
|
|
470
|
-
startWorld:
|
|
471
|
+
handle: i,
|
|
472
|
+
startWorld: u,
|
|
471
473
|
startBounds: {
|
|
472
474
|
x: t.position.x,
|
|
473
475
|
y: t.position.y,
|
|
@@ -482,16 +484,16 @@ function Gn({ onPixiReady: _ }) {
|
|
|
482
484
|
}
|
|
483
485
|
}
|
|
484
486
|
let x = null;
|
|
485
|
-
for (let t = v.length - 1; t >= 0; t--) if (
|
|
487
|
+
for (let t = v.length - 1; t >= 0; t--) if (Dt(u.x, u.y, v[t])) {
|
|
486
488
|
x = v[t];
|
|
487
489
|
break;
|
|
488
490
|
}
|
|
489
491
|
if (x?.parentId) {
|
|
490
|
-
const t = v.find((
|
|
492
|
+
const t = v.find((i) => i.id === x.parentId);
|
|
491
493
|
t && (x = t);
|
|
492
494
|
}
|
|
493
495
|
if (x && (s === "select" || s === "connect")) {
|
|
494
|
-
const t =
|
|
496
|
+
const t = Et(gt(x.width, x.height), x, u.x, u.y, Math.min(14 / O, 20));
|
|
495
497
|
if (t) {
|
|
496
498
|
ot.current = {
|
|
497
499
|
active: !0,
|
|
@@ -504,9 +506,9 @@ function Gn({ onPixiReady: _ }) {
|
|
|
504
506
|
if ((s === "select" || s === "connect") && !S && I.edgeIds.size > 0) {
|
|
505
507
|
const t = /* @__PURE__ */ new Map();
|
|
506
508
|
for (const o of v) t.set(o.id, o);
|
|
507
|
-
const
|
|
509
|
+
const i = P.filter((o) => I.edgeIds.has(o.id)), n = Ye(u.x, u.y, i, t, Math.min(14 / O, 20));
|
|
508
510
|
if (n) {
|
|
509
|
-
const o =
|
|
511
|
+
const o = P.find((r) => r.id === n.edgeId);
|
|
510
512
|
if (o) {
|
|
511
513
|
const r = n.end === "source" ? "target" : "source";
|
|
512
514
|
dt.current = {
|
|
@@ -523,7 +525,7 @@ function Gn({ onPixiReady: _ }) {
|
|
|
523
525
|
if (s === "select" && I.edgeIds.size > 0 && !x) {
|
|
524
526
|
const t = /* @__PURE__ */ new Map();
|
|
525
527
|
for (const d of v) t.set(d.id, d);
|
|
526
|
-
const
|
|
528
|
+
const i = P.filter((d) => I.edgeIds.has(d.id)), n = Math.min(10 / O, 14), o = Fe(u.x, u.y, i, t, n);
|
|
527
529
|
if (o) {
|
|
528
530
|
ut.current = {
|
|
529
531
|
active: !0,
|
|
@@ -533,7 +535,7 @@ function Gn({ onPixiReady: _ }) {
|
|
|
533
535
|
};
|
|
534
536
|
return;
|
|
535
537
|
}
|
|
536
|
-
const r =
|
|
538
|
+
const r = Xe(u.x, u.y, i, n);
|
|
537
539
|
if (r) {
|
|
538
540
|
if (f) {
|
|
539
541
|
J((d) => {
|
|
@@ -546,11 +548,11 @@ function Gn({ onPixiReady: _ }) {
|
|
|
546
548
|
...w,
|
|
547
549
|
edges: w.edges.map((g) => {
|
|
548
550
|
if (g.id !== r.edgeId) return g;
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
+
const C = [...g.data.waypoints ?? []];
|
|
552
|
+
C.splice(r.waypointIndex, 1);
|
|
551
553
|
const H = {
|
|
552
554
|
...g.data,
|
|
553
|
-
waypoints:
|
|
555
|
+
waypoints: C.length > 0 ? C : void 0
|
|
554
556
|
};
|
|
555
557
|
if (g.type === "simplebezier" && g.data.bezierControls) {
|
|
556
558
|
const h = [...g.data.bezierControls];
|
|
@@ -576,40 +578,40 @@ function Gn({ onPixiReady: _ }) {
|
|
|
576
578
|
return;
|
|
577
579
|
}
|
|
578
580
|
if (f) {
|
|
579
|
-
for (const d of
|
|
580
|
-
const w =
|
|
581
|
-
x:
|
|
582
|
-
y:
|
|
581
|
+
for (const d of i) if (we(u.x, u.y, d, t, Math.min(8 / O, 12))) {
|
|
582
|
+
const w = fn(u.x, u.y, d, t), g = {
|
|
583
|
+
x: u.x,
|
|
584
|
+
y: u.y
|
|
583
585
|
};
|
|
584
|
-
J((
|
|
585
|
-
const H =
|
|
586
|
+
J((C) => {
|
|
587
|
+
const H = C.canvases[V.current];
|
|
586
588
|
return H ? {
|
|
587
|
-
...
|
|
589
|
+
...C,
|
|
588
590
|
canvases: {
|
|
589
|
-
...
|
|
591
|
+
...C.canvases,
|
|
590
592
|
[V.current]: {
|
|
591
593
|
...H,
|
|
592
594
|
edges: H.edges.map((h) => {
|
|
593
595
|
if (h.id !== d.id) return h;
|
|
594
596
|
const R = [...h.data.waypoints ?? []];
|
|
595
597
|
R.splice(w, 0, g);
|
|
596
|
-
const
|
|
598
|
+
const j = {
|
|
597
599
|
...h.data,
|
|
598
600
|
waypoints: R
|
|
599
601
|
};
|
|
600
602
|
if (h.type === "simplebezier" && h.data.bezierControls) {
|
|
601
603
|
const ht = [...h.data.bezierControls];
|
|
602
604
|
for (; ht.length < (h.data.waypoints ?? []).length + 1; ) ht.push(null);
|
|
603
|
-
ht.splice(w, 1, null, null),
|
|
605
|
+
ht.splice(w, 1, null, null), j.bezierControls = ht;
|
|
604
606
|
}
|
|
605
607
|
return {
|
|
606
608
|
...h,
|
|
607
|
-
data:
|
|
609
|
+
data: j
|
|
608
610
|
};
|
|
609
611
|
})
|
|
610
612
|
}
|
|
611
613
|
}
|
|
612
|
-
} :
|
|
614
|
+
} : C;
|
|
613
615
|
}), ut.current = {
|
|
614
616
|
active: !0,
|
|
615
617
|
edgeId: d.id,
|
|
@@ -632,40 +634,40 @@ function Gn({ onPixiReady: _ }) {
|
|
|
632
634
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
633
635
|
lineIds: /* @__PURE__ */ new Set()
|
|
634
636
|
};
|
|
635
|
-
}),
|
|
637
|
+
}), Ft.current && _t.current(x.position.x, x.position.y, x.width, x.height, {
|
|
636
638
|
padding: 80,
|
|
637
639
|
preserveZoom: !0,
|
|
638
640
|
duration: 280
|
|
639
641
|
});
|
|
640
642
|
const t = I.nodeIds.has(x.id) ? new Set(I.nodeIds) : /* @__PURE__ */ new Set([x.id]);
|
|
641
643
|
S && !I.nodeIds.has(x.id) && t.add(x.id);
|
|
642
|
-
const
|
|
644
|
+
const i = /* @__PURE__ */ new Set();
|
|
643
645
|
for (const r of [...t]) {
|
|
644
646
|
const d = v.find((R) => R.id === r);
|
|
645
647
|
if (!d || d.type !== "flowGroup" && d.type !== "geometryGroup" && !d.data.isGroup) continue;
|
|
646
|
-
const w = d.type === "geometryGroup", g = d.position.x,
|
|
648
|
+
const w = d.type === "geometryGroup", g = d.position.x, C = d.position.y, H = d.width, h = d.height;
|
|
647
649
|
for (const R of v)
|
|
648
650
|
if (!(t.has(R.id) || R.id === r)) {
|
|
649
651
|
if (R.parentId === r) {
|
|
650
652
|
t.add(R.id);
|
|
651
653
|
continue;
|
|
652
654
|
}
|
|
653
|
-
w && R.position.x >= g && R.position.y >=
|
|
655
|
+
w && R.position.x >= g && R.position.y >= C && R.position.x + R.width <= g + H && R.position.y + R.height <= C + h && t.add(R.id);
|
|
654
656
|
}
|
|
655
|
-
for (const R of
|
|
656
|
-
if (w) for (const R of
|
|
657
|
-
|
|
657
|
+
for (const R of A.current.lines) R.parentId === r && i.add(R.id);
|
|
658
|
+
if (w) for (const R of A.current.lines)
|
|
659
|
+
i.has(R.id) || R.points.length > 0 && R.points.every((j) => j.x >= g && j.x <= g + H && j.y >= C && j.y <= C + h) && i.add(R.id);
|
|
658
660
|
}
|
|
659
661
|
const n = /* @__PURE__ */ new Map();
|
|
660
662
|
for (const r of v) t.has(r.id) && n.set(r.id, { ...r.position });
|
|
661
663
|
const o = /* @__PURE__ */ new Map();
|
|
662
|
-
if (
|
|
663
|
-
for (const r of
|
|
664
|
+
if (i.size > 0)
|
|
665
|
+
for (const r of A.current.lines) i.has(r.id) && o.set(r.id, r.points.map((d) => ({ ...d })));
|
|
664
666
|
ft.current = {
|
|
665
667
|
active: !0,
|
|
666
668
|
nodeIds: t,
|
|
667
|
-
lineIds:
|
|
668
|
-
startWorld:
|
|
669
|
+
lineIds: i.size > 0 ? i : void 0,
|
|
670
|
+
startWorld: u,
|
|
669
671
|
nodeStarts: n,
|
|
670
672
|
linePointStarts: o.size > 0 ? o : void 0
|
|
671
673
|
}, Ne.current();
|
|
@@ -673,23 +675,23 @@ function Gn({ onPixiReady: _ }) {
|
|
|
673
675
|
}
|
|
674
676
|
const p = /* @__PURE__ */ new Map();
|
|
675
677
|
for (const t of v) p.set(t.id, t);
|
|
676
|
-
const a = Math.min(8 /
|
|
677
|
-
for (const t of
|
|
678
|
-
if (lt(S ? (
|
|
679
|
-
const n = new Set(
|
|
678
|
+
const a = Math.min(8 / O, 12);
|
|
679
|
+
for (const t of P) if (we(u.x, u.y, t, p, a)) {
|
|
680
|
+
if (lt(S ? (i) => {
|
|
681
|
+
const n = new Set(i.edgeIds);
|
|
680
682
|
return n.has(t.id) ? n.delete(t.id) : n.add(t.id), {
|
|
681
|
-
...
|
|
683
|
+
...i,
|
|
682
684
|
edgeIds: n
|
|
683
685
|
};
|
|
684
686
|
} : {
|
|
685
687
|
nodeIds: /* @__PURE__ */ new Set(),
|
|
686
688
|
edgeIds: /* @__PURE__ */ new Set([t.id]),
|
|
687
689
|
lineIds: /* @__PURE__ */ new Set()
|
|
688
|
-
}),
|
|
689
|
-
const
|
|
690
|
-
if (
|
|
691
|
-
const o = Math.min(
|
|
692
|
-
|
|
690
|
+
}), Ft.current) {
|
|
691
|
+
const i = p.get(t.source), n = p.get(t.target);
|
|
692
|
+
if (i && n) {
|
|
693
|
+
const o = Math.min(i.position.x, n.position.x), r = Math.min(i.position.y, n.position.y), d = Math.max(i.position.x + i.width, n.position.x + n.width), w = Math.max(i.position.y + i.height, n.position.y + n.height);
|
|
694
|
+
_t.current(o, r, d - o, w - r, {
|
|
693
695
|
padding: 80,
|
|
694
696
|
preserveZoom: !0,
|
|
695
697
|
duration: 280
|
|
@@ -698,32 +700,32 @@ function Gn({ onPixiReady: _ }) {
|
|
|
698
700
|
}
|
|
699
701
|
return;
|
|
700
702
|
}
|
|
701
|
-
for (const t of
|
|
702
|
-
const
|
|
703
|
+
for (const t of N) if (_e(u.x, u.y, t, a)) {
|
|
704
|
+
const i = I.lineIds.has(t.id);
|
|
703
705
|
if (S ? lt((r) => {
|
|
704
706
|
const d = new Set(r.lineIds);
|
|
705
707
|
return d.has(t.id) ? d.delete(t.id) : d.add(t.id), {
|
|
706
708
|
...r,
|
|
707
709
|
lineIds: d
|
|
708
710
|
};
|
|
709
|
-
}) :
|
|
711
|
+
}) : i || lt({
|
|
710
712
|
nodeIds: /* @__PURE__ */ new Set(),
|
|
711
713
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
712
714
|
lineIds: /* @__PURE__ */ new Set([t.id])
|
|
713
|
-
}),
|
|
714
|
-
const r = t.points.map((h) => h.x), d = t.points.map((h) => h.y), w = Math.min(...r), g = Math.min(...d),
|
|
715
|
-
|
|
715
|
+
}), Ft.current && t.points.length > 0) {
|
|
716
|
+
const r = t.points.map((h) => h.x), d = t.points.map((h) => h.y), w = Math.min(...r), g = Math.min(...d), C = Math.max(...r), H = Math.max(...d);
|
|
717
|
+
_t.current(w, g, Math.max(1, C - w), Math.max(1, H - g), {
|
|
716
718
|
padding: 80,
|
|
717
719
|
preserveZoom: !0,
|
|
718
720
|
duration: 280
|
|
719
721
|
});
|
|
720
722
|
}
|
|
721
|
-
const n =
|
|
722
|
-
for (const r of
|
|
723
|
+
const n = i ? new Set(I.lineIds) : /* @__PURE__ */ new Set([t.id]), o = /* @__PURE__ */ new Map();
|
|
724
|
+
for (const r of N) n.has(r.id) && o.set(r.id, r.points.map((d) => ({ ...d })));
|
|
723
725
|
vt.current = {
|
|
724
726
|
active: !0,
|
|
725
727
|
lineIds: n,
|
|
726
|
-
startWorld:
|
|
728
|
+
startWorld: u,
|
|
727
729
|
pointStarts: o
|
|
728
730
|
};
|
|
729
731
|
return;
|
|
@@ -739,30 +741,30 @@ function Gn({ onPixiReady: _ }) {
|
|
|
739
741
|
y: m.global.y
|
|
740
742
|
}
|
|
741
743
|
});
|
|
742
|
-
}),
|
|
744
|
+
}), ct.on("globalpointermove", (m) => {
|
|
743
745
|
const s = st.current(m.global.x, m.global.y);
|
|
744
|
-
|
|
745
|
-
const
|
|
746
|
-
if (
|
|
747
|
-
const v =
|
|
746
|
+
Me.current = s;
|
|
747
|
+
const u = Xt.current;
|
|
748
|
+
if (u === "freehand" || u === "line" || u === "polyline" || u === "arrow") return;
|
|
749
|
+
const v = A.current.nodes, P = A.current.edges, N = $.current?.state.zoom ?? 1, I = !ft.current?.active && !ot.current?.active && !pt.current?.active && !dt.current?.active && !ut.current?.active && !vt.current?.active;
|
|
748
750
|
let S = null;
|
|
749
|
-
for (let e = v.length - 1; e >= 0; e--) if (
|
|
750
|
-
const
|
|
751
|
-
S =
|
|
751
|
+
for (let e = v.length - 1; e >= 0; e--) if (Dt(s.x, s.y, v[e])) {
|
|
752
|
+
const c = v[e];
|
|
753
|
+
S = c.parentId ? v.find((y) => y.id === c.parentId)?.id ?? c.id : c.id;
|
|
752
754
|
break;
|
|
753
755
|
}
|
|
754
|
-
if (
|
|
756
|
+
if ($t.current = S, I && (u === "select" || u === "connect")) {
|
|
755
757
|
const e = /* @__PURE__ */ new Map();
|
|
756
758
|
for (const p of v) e.set(p.id, p);
|
|
757
|
-
const
|
|
759
|
+
const c = Yt.current, y = c.edgeIds.size > 0 ? P.filter((p) => c.edgeIds.has(p.id)) : [], f = y.length > 0 ? Ye(s.x, s.y, y, e, Math.min(12 / N, 18)) : null;
|
|
758
760
|
de.current = f;
|
|
759
761
|
let x = null;
|
|
760
762
|
if (S) {
|
|
761
763
|
const p = v.find((a) => a.id === S);
|
|
762
764
|
if (p) {
|
|
763
|
-
const a =
|
|
765
|
+
const a = Et(gt(p.width, p.height), p, s.x, s.y, Math.min(14 / N, 20));
|
|
764
766
|
if (a) {
|
|
765
|
-
const t =
|
|
767
|
+
const t = Zt(a, p);
|
|
766
768
|
x = {
|
|
767
769
|
nodeId: p.id,
|
|
768
770
|
handleId: a.id,
|
|
@@ -772,38 +774,38 @@ function Gn({ onPixiReady: _ }) {
|
|
|
772
774
|
}
|
|
773
775
|
}
|
|
774
776
|
}
|
|
775
|
-
|
|
777
|
+
ie.current = x;
|
|
776
778
|
}
|
|
777
|
-
const
|
|
778
|
-
if (
|
|
779
|
-
const e =
|
|
780
|
-
let
|
|
781
|
-
if (de.current)
|
|
782
|
-
else if (
|
|
783
|
-
else if (e.edgeIds.size > 0 &&
|
|
784
|
-
const y =
|
|
779
|
+
const O = E.current;
|
|
780
|
+
if (O && I) {
|
|
781
|
+
const e = Yt.current;
|
|
782
|
+
let c = "";
|
|
783
|
+
if (de.current) c = "crosshair";
|
|
784
|
+
else if (ie.current) c = "crosshair";
|
|
785
|
+
else if (e.edgeIds.size > 0 && u === "select") {
|
|
786
|
+
const y = P.filter((p) => e.edgeIds.has(p.id)), f = /* @__PURE__ */ new Map();
|
|
785
787
|
for (const p of v) f.set(p.id, p);
|
|
786
|
-
const x = Math.min(10 /
|
|
787
|
-
(
|
|
788
|
+
const x = Math.min(10 / N, 14);
|
|
789
|
+
(Xe(s.x, s.y, y, x) || Fe(s.x, s.y, y, f, x)) && (c = "grab");
|
|
788
790
|
}
|
|
789
|
-
if (!
|
|
791
|
+
if (!c && e.nodeIds.size === 1 && u === "select") {
|
|
790
792
|
const y = v.find((f) => f.id === [...e.nodeIds][0]);
|
|
791
793
|
if (y) {
|
|
792
|
-
const f =
|
|
793
|
-
f && (
|
|
794
|
+
const f = Ae(s, y, Math.min(10 / N, 16));
|
|
795
|
+
f && (c = un[f]);
|
|
794
796
|
}
|
|
795
797
|
}
|
|
796
|
-
if (!
|
|
797
|
-
const y =
|
|
798
|
-
for (const x of y) if (
|
|
799
|
-
|
|
798
|
+
if (!c && u === "select") {
|
|
799
|
+
const y = A.current.lines, f = Math.min(8 / N, 12);
|
|
800
|
+
for (const x of y) if (_e(s.x, s.y, x, f)) {
|
|
801
|
+
c = "move";
|
|
800
802
|
break;
|
|
801
803
|
}
|
|
802
804
|
}
|
|
803
|
-
|
|
805
|
+
O.style.cursor = c;
|
|
804
806
|
}
|
|
805
807
|
if (pt.current?.active) {
|
|
806
|
-
const e = pt.current,
|
|
808
|
+
const e = pt.current, c = s.x - e.startWorld.x, y = s.y - e.startWorld.y, f = hn(e.startBounds, e.handle, c, y), x = A.current.nodes, p = ne([{
|
|
807
809
|
id: e.nodeId,
|
|
808
810
|
type: "shapeRect",
|
|
809
811
|
position: {
|
|
@@ -814,8 +816,8 @@ function Gn({ onPixiReady: _ }) {
|
|
|
814
816
|
height: f.h,
|
|
815
817
|
data: {}
|
|
816
818
|
}], x);
|
|
817
|
-
f.x += p.dx, f.y += p.dy, (e.handle === "ne" || e.handle === "se") && (f.w += p.dx), (e.handle === "se" || e.handle === "sw") && (f.h += p.dy),
|
|
818
|
-
const a = e.startBounds, t = Math.max(f.w, 24),
|
|
819
|
+
f.x += p.dx, f.y += p.dy, (e.handle === "ne" || e.handle === "se") && (f.w += p.dx), (e.handle === "se" || e.handle === "sw") && (f.h += p.dy), zt.current = p.guides;
|
|
820
|
+
const a = e.startBounds, t = Math.max(f.w, 24), i = Math.max(f.h, 24), n = a.w > 0 ? t / a.w : 1, o = a.h > 0 ? i / a.h : 1;
|
|
819
821
|
J((r) => {
|
|
820
822
|
const d = r.canvases[V.current];
|
|
821
823
|
return d ? {
|
|
@@ -832,7 +834,7 @@ function Gn({ onPixiReady: _ }) {
|
|
|
832
834
|
y: f.y
|
|
833
835
|
},
|
|
834
836
|
width: t,
|
|
835
|
-
height:
|
|
837
|
+
height: i
|
|
836
838
|
};
|
|
837
839
|
const g = e.childStarts.get(w.id);
|
|
838
840
|
return g ? {
|
|
@@ -849,9 +851,9 @@ function Gn({ onPixiReady: _ }) {
|
|
|
849
851
|
const g = e.childLineStarts.get(w.id);
|
|
850
852
|
return g ? {
|
|
851
853
|
...w,
|
|
852
|
-
points: g.map((
|
|
853
|
-
x: f.x + (
|
|
854
|
-
y: f.y + (
|
|
854
|
+
points: g.map((C) => ({
|
|
855
|
+
x: f.x + (C.x - a.x) * n,
|
|
856
|
+
y: f.y + (C.y - a.y) * o
|
|
855
857
|
}))
|
|
856
858
|
} : w;
|
|
857
859
|
}) : d.lines
|
|
@@ -862,8 +864,8 @@ function Gn({ onPixiReady: _ }) {
|
|
|
862
864
|
return;
|
|
863
865
|
}
|
|
864
866
|
if (ut.current?.active) {
|
|
865
|
-
const e = ut.current,
|
|
866
|
-
for (const f of
|
|
867
|
+
const e = ut.current, c = A.current.nodes, y = /* @__PURE__ */ new Map();
|
|
868
|
+
for (const f of c) y.set(f.id, f);
|
|
867
869
|
J((f) => {
|
|
868
870
|
const x = f.canvases[V.current];
|
|
869
871
|
return x ? {
|
|
@@ -875,21 +877,21 @@ function Gn({ onPixiReady: _ }) {
|
|
|
875
877
|
edges: x.edges.map((p) => {
|
|
876
878
|
if (p.id !== e.edgeId) return p;
|
|
877
879
|
if (e.type === "waypoint") {
|
|
878
|
-
const
|
|
879
|
-
return e.index <
|
|
880
|
+
const Nt = [...p.data.waypoints ?? []];
|
|
881
|
+
return e.index < Nt.length && (Nt[e.index] = {
|
|
880
882
|
x: s.x,
|
|
881
883
|
y: s.y
|
|
882
884
|
}), {
|
|
883
885
|
...p,
|
|
884
886
|
data: {
|
|
885
887
|
...p.data,
|
|
886
|
-
waypoints:
|
|
888
|
+
waypoints: Nt
|
|
887
889
|
}
|
|
888
890
|
};
|
|
889
891
|
}
|
|
890
892
|
const a = Mt(p, y);
|
|
891
893
|
if (!a) return p;
|
|
892
|
-
const t = p.data.waypoints ?? [],
|
|
894
|
+
const t = p.data.waypoints ?? [], i = [
|
|
893
895
|
{
|
|
894
896
|
x: a.sx,
|
|
895
897
|
y: a.sy
|
|
@@ -899,19 +901,19 @@ function Gn({ onPixiReady: _ }) {
|
|
|
899
901
|
x: a.tx,
|
|
900
902
|
y: a.ty
|
|
901
903
|
}
|
|
902
|
-
], n =
|
|
904
|
+
], n = i.length - 1, o = [...p.data.bezierControls ?? []];
|
|
903
905
|
for (; o.length < n; ) o.push(null);
|
|
904
906
|
const r = e.index;
|
|
905
907
|
if (r >= n) return p;
|
|
906
|
-
const d =
|
|
908
|
+
const d = i[r], w = i[r + 1], g = o[r], C = Math.hypot(w.x - d.x, w.y - d.y), H = Math.max(30, C * 0.3), h = n - 1, R = r === 0 ? d.x + a.snx * H : d.x + (w.x - d.x) * 0.4, j = r === 0 ? d.y + a.sny * H : d.y, ht = r === h ? w.x + a.tnx * H : w.x - (w.x - d.x) * 0.4, ee = r === h ? w.y + a.tny * H : w.y;
|
|
907
909
|
return e.type === "bezierC1" ? o[r] = {
|
|
908
910
|
c1x: s.x,
|
|
909
911
|
c1y: s.y,
|
|
910
912
|
c2x: g?.c2x ?? ht,
|
|
911
|
-
c2y: g?.c2y ??
|
|
913
|
+
c2y: g?.c2y ?? ee
|
|
912
914
|
} : o[r] = {
|
|
913
915
|
c1x: g?.c1x ?? R,
|
|
914
|
-
c1y: g?.c1y ??
|
|
916
|
+
c1y: g?.c1y ?? j,
|
|
915
917
|
c2x: s.x,
|
|
916
918
|
c2y: s.y
|
|
917
919
|
}, {
|
|
@@ -929,7 +931,7 @@ function Gn({ onPixiReady: _ }) {
|
|
|
929
931
|
return;
|
|
930
932
|
}
|
|
931
933
|
if (vt.current?.active) {
|
|
932
|
-
const e = vt.current,
|
|
934
|
+
const e = vt.current, c = s.x - e.startWorld.x, y = s.y - e.startWorld.y;
|
|
933
935
|
J((f) => {
|
|
934
936
|
const x = f.canvases[V.current];
|
|
935
937
|
return x ? {
|
|
@@ -943,7 +945,7 @@ function Gn({ onPixiReady: _ }) {
|
|
|
943
945
|
return a ? {
|
|
944
946
|
...p,
|
|
945
947
|
points: a.map((t) => ({
|
|
946
|
-
x: t.x +
|
|
948
|
+
x: t.x + c,
|
|
947
949
|
y: t.y + y
|
|
948
950
|
}))
|
|
949
951
|
} : p;
|
|
@@ -955,25 +957,25 @@ function Gn({ onPixiReady: _ }) {
|
|
|
955
957
|
return;
|
|
956
958
|
}
|
|
957
959
|
if (ft.current?.active) {
|
|
958
|
-
const e = ft.current,
|
|
959
|
-
const
|
|
960
|
+
const e = ft.current, c = s.x - e.startWorld.x, y = s.y - e.startWorld.y, f = A.current.nodes, x = ne(f.filter((t) => e.nodeIds.has(t.id)).map((t) => {
|
|
961
|
+
const i = e.nodeStarts.get(t.id);
|
|
960
962
|
return {
|
|
961
963
|
...t,
|
|
962
964
|
position: {
|
|
963
|
-
x:
|
|
964
|
-
y:
|
|
965
|
+
x: i.x + c,
|
|
966
|
+
y: i.y + y
|
|
965
967
|
}
|
|
966
968
|
};
|
|
967
|
-
}), f), p =
|
|
968
|
-
|
|
969
|
-
const
|
|
970
|
-
return
|
|
969
|
+
}), f), p = c + x.dx, a = y + x.dy;
|
|
970
|
+
zt.current = x.guides, J((t) => {
|
|
971
|
+
const i = t.canvases[V.current];
|
|
972
|
+
return i ? {
|
|
971
973
|
...t,
|
|
972
974
|
canvases: {
|
|
973
975
|
...t.canvases,
|
|
974
976
|
[V.current]: {
|
|
975
|
-
...
|
|
976
|
-
nodes:
|
|
977
|
+
...i,
|
|
978
|
+
nodes: i.nodes.map((n) => {
|
|
977
979
|
const o = e.nodeStarts.get(n.id);
|
|
978
980
|
return o ? {
|
|
979
981
|
...n,
|
|
@@ -983,7 +985,7 @@ function Gn({ onPixiReady: _ }) {
|
|
|
983
985
|
}
|
|
984
986
|
} : n;
|
|
985
987
|
}),
|
|
986
|
-
lines: e.linePointStarts ?
|
|
988
|
+
lines: e.linePointStarts ? i.lines.map((n) => {
|
|
987
989
|
const o = e.linePointStarts.get(n.id);
|
|
988
990
|
return o ? {
|
|
989
991
|
...n,
|
|
@@ -992,59 +994,59 @@ function Gn({ onPixiReady: _ }) {
|
|
|
992
994
|
y: r.y + a
|
|
993
995
|
}))
|
|
994
996
|
} : n;
|
|
995
|
-
}) :
|
|
997
|
+
}) : i.lines
|
|
996
998
|
}
|
|
997
999
|
}
|
|
998
1000
|
} : t;
|
|
999
1001
|
});
|
|
1000
1002
|
return;
|
|
1001
1003
|
}
|
|
1002
|
-
if (rt.current?.active &&
|
|
1003
|
-
const e = Math.min(rt.current.startScreen.x, m.global.x),
|
|
1004
|
-
|
|
1004
|
+
if (rt.current?.active && St.current) {
|
|
1005
|
+
const e = Math.min(rt.current.startScreen.x, m.global.x), c = Math.min(rt.current.startScreen.y, m.global.y), y = Math.abs(m.global.x - rt.current.startScreen.x), f = Math.abs(m.global.y - rt.current.startScreen.y);
|
|
1006
|
+
St.current.showMarquee(e, c, y, f);
|
|
1005
1007
|
}
|
|
1006
1008
|
if (ot.current?.active && xt.current) {
|
|
1007
|
-
const e =
|
|
1009
|
+
const e = A.current.nodes.find((c) => c.id === ot.current.sourceNodeId);
|
|
1008
1010
|
if (e) {
|
|
1009
|
-
const
|
|
1010
|
-
if (
|
|
1011
|
-
const y =
|
|
1011
|
+
const c = gt(e.width, e.height).find((y) => y.id === ot.current.sourceHandleId);
|
|
1012
|
+
if (c) {
|
|
1013
|
+
const y = Zt(c, e), f = y.x, x = y.y;
|
|
1012
1014
|
let p = s.x, a = s.y;
|
|
1013
|
-
const t =
|
|
1015
|
+
const t = $t.current;
|
|
1014
1016
|
if (t && t !== ot.current.sourceNodeId) {
|
|
1015
|
-
const n =
|
|
1017
|
+
const n = A.current.nodes.find((o) => o.id === t);
|
|
1016
1018
|
if (n) {
|
|
1017
|
-
const o =
|
|
1019
|
+
const o = Et(gt(n.width, n.height), n, s.x, s.y, 1 / 0);
|
|
1018
1020
|
if (o) {
|
|
1019
|
-
const r =
|
|
1021
|
+
const r = Zt(o, n);
|
|
1020
1022
|
p = r.x, a = r.y;
|
|
1021
1023
|
}
|
|
1022
1024
|
}
|
|
1023
1025
|
}
|
|
1024
|
-
const
|
|
1025
|
-
|
|
1026
|
+
const i = xt.current;
|
|
1027
|
+
i.clear(), i.moveTo(f, x).lineTo(p, a).stroke({
|
|
1026
1028
|
color: 3900150,
|
|
1027
1029
|
width: 2,
|
|
1028
1030
|
alpha: 0.6
|
|
1029
|
-
}),
|
|
1031
|
+
}), i.visible = !0;
|
|
1030
1032
|
}
|
|
1031
1033
|
}
|
|
1032
1034
|
}
|
|
1033
1035
|
if (dt.current?.active && xt.current && !xt.current.destroyed) {
|
|
1034
|
-
const e = dt.current,
|
|
1035
|
-
if (
|
|
1036
|
-
const y = gt(
|
|
1037
|
-
x:
|
|
1038
|
-
y:
|
|
1036
|
+
const e = dt.current, c = A.current.nodes.find((y) => y.id === e.fixedNodeId);
|
|
1037
|
+
if (c) {
|
|
1038
|
+
const y = gt(c.width, c.height).find((o) => o.id === e.fixedHandleId), f = y ? Zt(y, c) : {
|
|
1039
|
+
x: c.position.x + c.width / 2,
|
|
1040
|
+
y: c.position.y + c.height / 2
|
|
1039
1041
|
}, x = f.x, p = f.y;
|
|
1040
1042
|
let a = s.x, t = s.y;
|
|
1041
|
-
const
|
|
1042
|
-
if (
|
|
1043
|
-
const o =
|
|
1043
|
+
const i = $t.current;
|
|
1044
|
+
if (i && i !== e.fixedNodeId) {
|
|
1045
|
+
const o = A.current.nodes.find((r) => r.id === i);
|
|
1044
1046
|
if (o) {
|
|
1045
|
-
const r =
|
|
1047
|
+
const r = Et(gt(o.width, o.height), o, s.x, s.y, 1 / 0);
|
|
1046
1048
|
if (r) {
|
|
1047
|
-
const d =
|
|
1049
|
+
const d = Zt(r, o);
|
|
1048
1050
|
a = d.x, t = d.y;
|
|
1049
1051
|
}
|
|
1050
1052
|
}
|
|
@@ -1059,9 +1061,9 @@ function Gn({ onPixiReady: _ }) {
|
|
|
1059
1061
|
}
|
|
1060
1062
|
});
|
|
1061
1063
|
const bt = () => {
|
|
1062
|
-
|
|
1064
|
+
zt.current = [];
|
|
1063
1065
|
try {
|
|
1064
|
-
|
|
1066
|
+
Jt.current?.clear();
|
|
1065
1067
|
} catch {
|
|
1066
1068
|
}
|
|
1067
1069
|
try {
|
|
@@ -1071,7 +1073,7 @@ function Gn({ onPixiReady: _ }) {
|
|
|
1071
1073
|
}
|
|
1072
1074
|
E.current && (E.current.style.cursor = "");
|
|
1073
1075
|
};
|
|
1074
|
-
|
|
1076
|
+
ct.on("pointerup", (m) => {
|
|
1075
1077
|
if (bt(), ut.current?.active) {
|
|
1076
1078
|
ut.current = null;
|
|
1077
1079
|
return;
|
|
@@ -1085,44 +1087,44 @@ function Gn({ onPixiReady: _ }) {
|
|
|
1085
1087
|
return;
|
|
1086
1088
|
}
|
|
1087
1089
|
if (ft.current?.active && (ft.current = null, le.current()), rt.current?.active) {
|
|
1088
|
-
const s = st.current(rt.current.startScreen.x, rt.current.startScreen.y),
|
|
1089
|
-
if (
|
|
1090
|
-
const S =
|
|
1090
|
+
const s = st.current(rt.current.startScreen.x, rt.current.startScreen.y), u = st.current(m.global.x, m.global.y), v = Math.min(s.x, u.x), P = Math.min(s.y, u.y), N = Math.abs(u.x - s.x), I = Math.abs(u.y - s.y);
|
|
1091
|
+
if (N > 4 && I > 4) {
|
|
1092
|
+
const S = A.current.nodes.filter((e) => tn(v, P, N, I, e.position.x, e.position.y, e.width, e.height)), O = A.current.lines.filter((e) => e.points.length === 0 ? !1 : e.points.every((c) => c.x >= v && c.x <= v + N && c.y >= P && c.y <= P + I));
|
|
1091
1093
|
lt({
|
|
1092
1094
|
nodeIds: new Set(S.map((e) => e.id)),
|
|
1093
1095
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
1094
|
-
lineIds: new Set(
|
|
1096
|
+
lineIds: new Set(O.map((e) => e.id))
|
|
1095
1097
|
});
|
|
1096
1098
|
}
|
|
1097
|
-
rt.current = null,
|
|
1099
|
+
rt.current = null, St.current?.hideMarquee();
|
|
1098
1100
|
}
|
|
1099
1101
|
if (dt.current?.active) {
|
|
1100
|
-
const s = dt.current.edgeId,
|
|
1102
|
+
const s = dt.current.edgeId, u = dt.current.movingEnd, v = dt.current.fixedNodeId;
|
|
1101
1103
|
dt.current = null;
|
|
1102
|
-
const
|
|
1104
|
+
const P = st.current(m.global.x, m.global.y), N = A.current.nodes;
|
|
1103
1105
|
let I = null;
|
|
1104
|
-
for (let S =
|
|
1105
|
-
I =
|
|
1106
|
+
for (let S = N.length - 1; S >= 0; S--) if (Dt(P.x, P.y, N[S]) && N[S].id !== v) {
|
|
1107
|
+
I = N[S];
|
|
1106
1108
|
break;
|
|
1107
1109
|
}
|
|
1108
1110
|
if (I) {
|
|
1109
|
-
const S = I.id,
|
|
1111
|
+
const S = I.id, O = Et(gt(I.width, I.height), I, P.x, P.y, 1 / 0)?.id;
|
|
1110
1112
|
J((e) => {
|
|
1111
|
-
const
|
|
1112
|
-
return
|
|
1113
|
+
const c = e.canvases[V.current];
|
|
1114
|
+
return c ? {
|
|
1113
1115
|
...e,
|
|
1114
1116
|
canvases: {
|
|
1115
1117
|
...e.canvases,
|
|
1116
1118
|
[V.current]: {
|
|
1117
|
-
...
|
|
1118
|
-
edges:
|
|
1119
|
+
...c,
|
|
1120
|
+
edges: c.edges.map((y) => y.id !== s ? y : u === "source" ? {
|
|
1119
1121
|
...y,
|
|
1120
1122
|
source: S,
|
|
1121
|
-
sourceHandle:
|
|
1123
|
+
sourceHandle: O
|
|
1122
1124
|
} : {
|
|
1123
1125
|
...y,
|
|
1124
1126
|
target: S,
|
|
1125
|
-
targetHandle:
|
|
1127
|
+
targetHandle: O
|
|
1126
1128
|
})
|
|
1127
1129
|
}
|
|
1128
1130
|
}
|
|
@@ -1132,33 +1134,33 @@ function Gn({ onPixiReady: _ }) {
|
|
|
1132
1134
|
return;
|
|
1133
1135
|
}
|
|
1134
1136
|
if (ot.current?.active) {
|
|
1135
|
-
const s = ot.current.sourceNodeId,
|
|
1137
|
+
const s = ot.current.sourceNodeId, u = ot.current.sourceHandleId;
|
|
1136
1138
|
ot.current = null;
|
|
1137
|
-
const v = st.current(m.global.x, m.global.y),
|
|
1138
|
-
let
|
|
1139
|
-
for (let I =
|
|
1140
|
-
|
|
1139
|
+
const v = st.current(m.global.x, m.global.y), P = A.current.nodes;
|
|
1140
|
+
let N = null;
|
|
1141
|
+
for (let I = P.length - 1; I >= 0; I--) if (Dt(v.x, v.y, P[I]) && P[I].id !== s) {
|
|
1142
|
+
N = P[I];
|
|
1141
1143
|
break;
|
|
1142
1144
|
}
|
|
1143
|
-
if (
|
|
1144
|
-
const I =
|
|
1145
|
-
J((
|
|
1146
|
-
const y =
|
|
1147
|
-
return !y || y.edges.some((f) => f.source === s && f.target === I && f.sourceHandle ===
|
|
1148
|
-
...
|
|
1145
|
+
if (N) {
|
|
1146
|
+
const I = N.id, S = Et(gt(N.width, N.height), N, v.x, v.y, 1 / 0)?.id, O = `edge_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 6)}`, e = ze.current;
|
|
1147
|
+
J((c) => {
|
|
1148
|
+
const y = c.canvases[V.current];
|
|
1149
|
+
return !y || y.edges.some((f) => f.source === s && f.target === I && f.sourceHandle === u && f.targetHandle === S) ? c : {
|
|
1150
|
+
...c,
|
|
1149
1151
|
canvases: {
|
|
1150
|
-
...
|
|
1152
|
+
...c.canvases,
|
|
1151
1153
|
[V.current]: {
|
|
1152
1154
|
...y,
|
|
1153
1155
|
edges: [...y.edges, {
|
|
1154
|
-
id:
|
|
1156
|
+
id: O,
|
|
1155
1157
|
source: s,
|
|
1156
1158
|
target: I,
|
|
1157
|
-
sourceHandle:
|
|
1159
|
+
sourceHandle: u,
|
|
1158
1160
|
targetHandle: S,
|
|
1159
1161
|
type: e,
|
|
1160
1162
|
data: {
|
|
1161
|
-
strokeColor: "
|
|
1163
|
+
strokeColor: "theme:base-content",
|
|
1162
1164
|
strokeWidth: 2,
|
|
1163
1165
|
lineStyle: "solid",
|
|
1164
1166
|
markerEnd: "arrowclosed"
|
|
@@ -1170,49 +1172,49 @@ function Gn({ onPixiReady: _ }) {
|
|
|
1170
1172
|
});
|
|
1171
1173
|
}
|
|
1172
1174
|
}
|
|
1173
|
-
}),
|
|
1174
|
-
bt(), ft.current?.active && le.current(), ft.current = null, pt.current = null, rt.current = null, dt.current = null, ot.current = null, ut.current = null, vt.current = null,
|
|
1175
|
-
}),
|
|
1175
|
+
}), ct.on("pointerupoutside", () => {
|
|
1176
|
+
bt(), ft.current?.active && le.current(), ft.current = null, pt.current = null, rt.current = null, dt.current = null, ot.current = null, ut.current = null, vt.current = null, St.current?.hideMarquee();
|
|
1177
|
+
}), ct.on("rightclick", (m) => {
|
|
1176
1178
|
if (m.preventDefault?.(), $.current?.didRightPan) return;
|
|
1177
|
-
const s = st.current(m.global.x, m.global.y),
|
|
1179
|
+
const s = st.current(m.global.x, m.global.y), u = A.current.nodes;
|
|
1178
1180
|
let v = null;
|
|
1179
|
-
for (let S =
|
|
1180
|
-
v =
|
|
1181
|
+
for (let S = u.length - 1; S >= 0; S--) if (Dt(s.x, s.y, u[S])) {
|
|
1182
|
+
v = u[S].id;
|
|
1181
1183
|
break;
|
|
1182
1184
|
}
|
|
1183
|
-
const
|
|
1184
|
-
|
|
1185
|
-
x:
|
|
1185
|
+
const P = m.nativeEvent, N = P?.clientX ?? m.global.x, I = P?.clientY ?? m.global.y;
|
|
1186
|
+
Bt({
|
|
1187
|
+
x: N,
|
|
1186
1188
|
y: I,
|
|
1187
1189
|
nodeId: v
|
|
1188
1190
|
});
|
|
1189
|
-
}),
|
|
1191
|
+
}), ct.on("pointertap", (m) => {
|
|
1190
1192
|
if (m.button !== 0) return;
|
|
1191
|
-
const s = Date.now(),
|
|
1192
|
-
if (s - v.time < 400 && Math.abs(
|
|
1193
|
-
const I =
|
|
1194
|
-
for (let
|
|
1195
|
-
const y = I[
|
|
1193
|
+
const s = Date.now(), u = st.current(m.global.x, m.global.y), v = Lt.current, P = u.x - v.wx, N = u.y - v.wy;
|
|
1194
|
+
if (s - v.time < 400 && Math.abs(P) < 10 && Math.abs(N) < 10) {
|
|
1195
|
+
const I = A.current.nodes;
|
|
1196
|
+
for (let c = I.length - 1; c >= 0; c--) if (Dt(u.x, u.y, I[c])) {
|
|
1197
|
+
const y = I[c], f = y.data.childCanvasId;
|
|
1196
1198
|
if (f) {
|
|
1197
|
-
|
|
1199
|
+
Oe(f), Lt.current = {
|
|
1198
1200
|
time: 0,
|
|
1199
1201
|
wx: 0,
|
|
1200
1202
|
wy: 0
|
|
1201
1203
|
};
|
|
1202
1204
|
return;
|
|
1203
1205
|
}
|
|
1204
|
-
|
|
1206
|
+
Qt.current("node", y.id, y.data.label ?? ""), Lt.current = {
|
|
1205
1207
|
time: 0,
|
|
1206
1208
|
wx: 0,
|
|
1207
1209
|
wy: 0
|
|
1208
1210
|
};
|
|
1209
1211
|
return;
|
|
1210
1212
|
}
|
|
1211
|
-
const S =
|
|
1212
|
-
for (const
|
|
1213
|
+
const S = A.current.edges, O = /* @__PURE__ */ new Map();
|
|
1214
|
+
for (const c of I) O.set(c.id, c);
|
|
1213
1215
|
const e = $.current?.state.zoom ?? 1;
|
|
1214
|
-
for (let
|
|
1215
|
-
|
|
1216
|
+
for (let c = S.length - 1; c >= 0; c--) if (we(u.x, u.y, S[c], O, Math.min(8 / e, 12))) {
|
|
1217
|
+
Qt.current("edge", S[c].id, S[c].data.labelText ?? ""), Lt.current = {
|
|
1216
1218
|
time: 0,
|
|
1217
1219
|
wx: 0,
|
|
1218
1220
|
wy: 0
|
|
@@ -1220,39 +1222,39 @@ function Gn({ onPixiReady: _ }) {
|
|
|
1220
1222
|
return;
|
|
1221
1223
|
}
|
|
1222
1224
|
}
|
|
1223
|
-
|
|
1225
|
+
Lt.current = {
|
|
1224
1226
|
time: s,
|
|
1225
|
-
wx:
|
|
1226
|
-
wy:
|
|
1227
|
+
wx: u.x,
|
|
1228
|
+
wy: u.y
|
|
1227
1229
|
};
|
|
1228
1230
|
});
|
|
1229
|
-
let
|
|
1230
|
-
|
|
1231
|
-
if (
|
|
1232
|
-
const s = m.deltaMS,
|
|
1231
|
+
let te = !1;
|
|
1232
|
+
l.app.ticker.add((m) => {
|
|
1233
|
+
if (l.destroyed) return;
|
|
1234
|
+
const s = m.deltaMS, u = l.app.screen, v = $.current?.state ?? {
|
|
1233
1235
|
x: 0,
|
|
1234
1236
|
y: 0,
|
|
1235
1237
|
zoom: 1
|
|
1236
1238
|
};
|
|
1237
|
-
|
|
1238
|
-
const
|
|
1239
|
-
|
|
1240
|
-
const
|
|
1241
|
-
S.forEach((a, t) =>
|
|
1242
|
-
const e =
|
|
1243
|
-
|
|
1244
|
-
showAnchors:
|
|
1245
|
-
presentation:
|
|
1239
|
+
G.current?.update(v, u.width, u.height);
|
|
1240
|
+
const P = $.current?.isPanning ?? !1;
|
|
1241
|
+
P !== te && (te = P, E.current && (E.current.style.cursor = P ? "grabbing" : ""));
|
|
1242
|
+
const N = A.current, I = Yt.current, S = dn(Se.current), O = /* @__PURE__ */ new Map();
|
|
1243
|
+
S.forEach((a, t) => O.set(a.node.id, t + 1)), Kt.current?.advanceAnimation(s);
|
|
1244
|
+
const e = Ct.current ? S[Ct.current.current] : void 0;
|
|
1245
|
+
Kt.current?.sync(N.nodes, I.nodeIds, $t.current, O, {
|
|
1246
|
+
showAnchors: Ce.current,
|
|
1247
|
+
presentation: Ct.current !== null,
|
|
1246
1248
|
presentationAnchorId: e?.node.id,
|
|
1247
|
-
presentationAnchorVisible:
|
|
1249
|
+
presentationAnchorVisible: Ct.current?.showAnchor ?? !1
|
|
1248
1250
|
});
|
|
1249
|
-
const
|
|
1250
|
-
for (const a of
|
|
1251
|
-
|
|
1252
|
-
const y =
|
|
1251
|
+
const c = /* @__PURE__ */ new Map();
|
|
1252
|
+
for (const a of N.nodes) c.set(a.id, a);
|
|
1253
|
+
jt.current?.advanceAnimation(s), jt.current?.sync(N.edges, c, I.edgeIds, null, { presentation: Ct.current !== null }), Ut.current?.advanceAnimation(s), Ut.current?.sync(N.lines, I.lineIds), Jt.current?.update(zt.current, u.width, u.height, v);
|
|
1254
|
+
const y = Gt.current;
|
|
1253
1255
|
if (y) {
|
|
1254
1256
|
y.clear();
|
|
1255
|
-
const a =
|
|
1257
|
+
const a = ie.current;
|
|
1256
1258
|
a && (y.circle(a.wx, a.wy, 10).fill({
|
|
1257
1259
|
color: 3900150,
|
|
1258
1260
|
alpha: 0.12
|
|
@@ -1277,23 +1279,23 @@ function Gn({ onPixiReady: _ }) {
|
|
|
1277
1279
|
alpha: 0.9
|
|
1278
1280
|
}));
|
|
1279
1281
|
}
|
|
1280
|
-
const f =
|
|
1282
|
+
const f = At.current;
|
|
1281
1283
|
if (f) {
|
|
1282
1284
|
f.clear();
|
|
1283
1285
|
const a = ae.current;
|
|
1284
1286
|
if (a) {
|
|
1285
|
-
const t =
|
|
1287
|
+
const t = Me.current, i = t.x - a.width / 2, n = t.y - a.height / 2, o = ne([{
|
|
1286
1288
|
id: "__ghost__",
|
|
1287
1289
|
type: a.type,
|
|
1288
1290
|
position: {
|
|
1289
|
-
x:
|
|
1291
|
+
x: i,
|
|
1290
1292
|
y: n
|
|
1291
1293
|
},
|
|
1292
1294
|
width: a.width,
|
|
1293
1295
|
height: a.height,
|
|
1294
1296
|
data: {}
|
|
1295
|
-
}],
|
|
1296
|
-
|
|
1297
|
+
}], N.nodes);
|
|
1298
|
+
zt.current = o.guides, f.position.set(i + o.dx, n + o.dy), (Ge[a.type] ?? Ge.shapeRect)(f, {
|
|
1297
1299
|
width: a.width,
|
|
1298
1300
|
height: a.height,
|
|
1299
1301
|
fill: "#3b82f6",
|
|
@@ -1302,22 +1304,22 @@ function Gn({ onPixiReady: _ }) {
|
|
|
1302
1304
|
borderStyle: a.data.borderStyle
|
|
1303
1305
|
});
|
|
1304
1306
|
} else
|
|
1305
|
-
f.position.set(0, 0), !ft.current?.active && !pt.current?.active && (
|
|
1307
|
+
f.position.set(0, 0), !ft.current?.active && !pt.current?.active && (zt.current = []);
|
|
1306
1308
|
}
|
|
1307
|
-
const x =
|
|
1308
|
-
if (x && (x.clear(), I.edgeIds.size > 0 &&
|
|
1309
|
+
const x = Wt.current;
|
|
1310
|
+
if (x && (x.clear(), I.edgeIds.size > 0 && Xt.current === "select")) {
|
|
1309
1311
|
const a = 1 / v.zoom;
|
|
1310
|
-
for (const t of
|
|
1312
|
+
for (const t of N.edges) {
|
|
1311
1313
|
if (!I.edgeIds.has(t.id)) continue;
|
|
1312
|
-
const
|
|
1313
|
-
if (
|
|
1314
|
+
const i = t.data.waypoints;
|
|
1315
|
+
if (i) for (const n of i) x.circle(n.x, n.y, 5 * a).fill({ color: 16777215 }).stroke({
|
|
1314
1316
|
color: 3900150,
|
|
1315
1317
|
width: 1.5 * a
|
|
1316
1318
|
});
|
|
1317
1319
|
if (t.type === "simplebezier") {
|
|
1318
|
-
const n = Mt(t,
|
|
1320
|
+
const n = Mt(t, c);
|
|
1319
1321
|
if (!n) continue;
|
|
1320
|
-
const o =
|
|
1322
|
+
const o = i ?? [], r = [
|
|
1321
1323
|
{
|
|
1322
1324
|
x: n.sx,
|
|
1323
1325
|
y: n.sy
|
|
@@ -1329,19 +1331,19 @@ function Gn({ onPixiReady: _ }) {
|
|
|
1329
1331
|
}
|
|
1330
1332
|
], d = t.data.bezierControls, w = r.length - 2;
|
|
1331
1333
|
for (let g = 0; g <= w; g++) {
|
|
1332
|
-
const
|
|
1333
|
-
x.moveTo(
|
|
1334
|
+
const C = r[g], H = r[g + 1], h = d?.[g], R = Math.hypot(H.x - C.x, H.y - C.y), j = Math.max(30, R * 0.3), ht = h?.c1x ?? (g === 0 ? C.x + n.snx * j : C.x + (H.x - C.x) * 0.4), ee = h?.c1y ?? (g === 0 ? C.y + n.sny * j : C.y), Nt = h?.c2x ?? (g === w ? H.x + n.tnx * j : H.x - (H.x - C.x) * 0.4), Te = h?.c2y ?? (g === w ? H.y + n.tny * j : H.y);
|
|
1335
|
+
x.moveTo(C.x, C.y).lineTo(ht, ee).stroke({
|
|
1334
1336
|
color: 10265519,
|
|
1335
1337
|
width: 1 * a
|
|
1336
|
-
}), x.moveTo(H.x, H.y).lineTo(
|
|
1338
|
+
}), x.moveTo(H.x, H.y).lineTo(Nt, Te).stroke({
|
|
1337
1339
|
color: 10265519,
|
|
1338
1340
|
width: 1 * a
|
|
1339
1341
|
});
|
|
1340
|
-
const
|
|
1341
|
-
x.circle(ht,
|
|
1342
|
+
const Pe = 4 * a;
|
|
1343
|
+
x.circle(ht, ee, Pe).fill({ color: 16777215 }).stroke({
|
|
1342
1344
|
color: 3900150,
|
|
1343
1345
|
width: 1.5 * a
|
|
1344
|
-
}), x.circle(
|
|
1346
|
+
}), x.circle(Nt, Te, Pe).fill({ color: 16777215 }).stroke({
|
|
1345
1347
|
color: 3900150,
|
|
1346
1348
|
width: 1.5 * a
|
|
1347
1349
|
});
|
|
@@ -1349,22 +1351,22 @@ function Gn({ onPixiReady: _ }) {
|
|
|
1349
1351
|
}
|
|
1350
1352
|
}
|
|
1351
1353
|
}
|
|
1352
|
-
const p =
|
|
1353
|
-
if (p && (p.clear(), I.nodeIds.size === 1 &&
|
|
1354
|
-
const a = [...I.nodeIds][0], t =
|
|
1354
|
+
const p = Pt.current;
|
|
1355
|
+
if (p && (p.clear(), I.nodeIds.size === 1 && Xt.current === "select")) {
|
|
1356
|
+
const a = [...I.nodeIds][0], t = N.nodes.find((i) => i.id === a);
|
|
1355
1357
|
if (t) {
|
|
1356
|
-
const
|
|
1358
|
+
const i = v.zoom, n = t.position.x * i + v.x, o = t.position.y * i + v.y, r = t.width * i, d = t.height * i;
|
|
1357
1359
|
p.rect(n, o, r, d).stroke({
|
|
1358
1360
|
color: 3900150,
|
|
1359
1361
|
width: 1.5
|
|
1360
1362
|
});
|
|
1361
|
-
const w = 7, g = w / 2,
|
|
1363
|
+
const w = 7, g = w / 2, C = [
|
|
1362
1364
|
[n, o],
|
|
1363
1365
|
[n + r, o],
|
|
1364
1366
|
[n + r, o + d],
|
|
1365
1367
|
[n, o + d]
|
|
1366
1368
|
];
|
|
1367
|
-
for (const [R,
|
|
1369
|
+
for (const [R, j] of C) p.rect(R - g, j - g, w, w).fill({ color: 16777215 }).stroke({
|
|
1368
1370
|
color: 3900150,
|
|
1369
1371
|
width: 1.5
|
|
1370
1372
|
});
|
|
@@ -1374,7 +1376,7 @@ function Gn({ onPixiReady: _ }) {
|
|
|
1374
1376
|
[n + r / 2, o + d],
|
|
1375
1377
|
[n, o + d / 2]
|
|
1376
1378
|
];
|
|
1377
|
-
for (const [R,
|
|
1379
|
+
for (const [R, j] of h) p.circle(R, j, H).fill({
|
|
1378
1380
|
color: 3900150,
|
|
1379
1381
|
alpha: 0.9
|
|
1380
1382
|
});
|
|
@@ -1382,55 +1384,55 @@ function Gn({ onPixiReady: _ }) {
|
|
|
1382
1384
|
}
|
|
1383
1385
|
});
|
|
1384
1386
|
};
|
|
1385
|
-
return
|
|
1386
|
-
if (
|
|
1387
|
-
|
|
1387
|
+
return Y(), () => {
|
|
1388
|
+
if (T = !0, l && !l.destroyed) try {
|
|
1389
|
+
l.app.stage.removeAllListeners();
|
|
1388
1390
|
} catch {
|
|
1389
1391
|
}
|
|
1390
|
-
|
|
1392
|
+
G.current?.destroy(), St.current?.destroy(), Kt.current?.destroy(), jt.current?.destroy(), Ut.current?.destroy(), se.current?.destroy(), ce.current?.destroy(), xt.current?.destroy(), Pt.current && (Pt.current.destroy(), Pt.current = null), Gt.current && (Gt.current.destroy(), Gt.current = null), Wt.current && (Wt.current.destroy(), Wt.current = null), At.current && (At.current.destroy(), At.current = null), Jt.current?.destroy();
|
|
1391
1393
|
};
|
|
1392
|
-
}, [
|
|
1393
|
-
const
|
|
1394
|
-
if (!(!
|
|
1395
|
-
switch (
|
|
1394
|
+
}, [D.current]), wt(() => {
|
|
1395
|
+
const l = se.current, T = ce.current;
|
|
1396
|
+
if (!(!l || !T))
|
|
1397
|
+
switch (l.deactivate(), T.deactivate(), K) {
|
|
1396
1398
|
case "freehand":
|
|
1397
|
-
|
|
1399
|
+
l.activate();
|
|
1398
1400
|
break;
|
|
1399
1401
|
case "line":
|
|
1400
|
-
|
|
1402
|
+
T.activate("straight");
|
|
1401
1403
|
break;
|
|
1402
1404
|
case "polyline":
|
|
1403
|
-
|
|
1405
|
+
T.activate("polyline");
|
|
1404
1406
|
break;
|
|
1405
1407
|
case "arrow":
|
|
1406
|
-
|
|
1408
|
+
T.activate("arrow");
|
|
1407
1409
|
break;
|
|
1408
1410
|
}
|
|
1409
|
-
}, [
|
|
1410
|
-
|
|
1411
|
-
}, [
|
|
1412
|
-
const
|
|
1413
|
-
if (!
|
|
1414
|
-
const
|
|
1415
|
-
|
|
1416
|
-
const
|
|
1417
|
-
if (!
|
|
1418
|
-
const
|
|
1419
|
-
|
|
1411
|
+
}, [K]), wt(() => {
|
|
1412
|
+
G.current && (G.current.visible = U, G.current.gridSize = tt);
|
|
1413
|
+
}, [U, tt]), wt(() => {
|
|
1414
|
+
const l = E.current;
|
|
1415
|
+
if (!l) return;
|
|
1416
|
+
const T = 1e-3, Y = (L) => {
|
|
1417
|
+
L.preventDefault();
|
|
1418
|
+
const q = $.current;
|
|
1419
|
+
if (!q) return;
|
|
1420
|
+
const X = l.getBoundingClientRect(), B = L.clientX - X.left, Q = L.clientY - X.top, ct = L.ctrlKey ? 3 : 1, bt = -L.deltaY * T * ct;
|
|
1421
|
+
q.zoomAt(B, Q, 1 + bt);
|
|
1420
1422
|
};
|
|
1421
|
-
return
|
|
1422
|
-
}, [$]), /* @__PURE__ */
|
|
1423
|
+
return l.addEventListener("wheel", Y, { passive: !1 }), () => l.removeEventListener("wheel", Y);
|
|
1424
|
+
}, [$]), /* @__PURE__ */ ln("div", {
|
|
1423
1425
|
style: {
|
|
1424
1426
|
position: "relative",
|
|
1425
1427
|
width: "100%",
|
|
1426
1428
|
height: "100%"
|
|
1427
1429
|
},
|
|
1428
|
-
children: [/* @__PURE__ */
|
|
1430
|
+
children: [/* @__PURE__ */ Le("div", {
|
|
1429
1431
|
ref: E,
|
|
1430
1432
|
className: "flow-canvas-wrapper",
|
|
1431
1433
|
tabIndex: -1,
|
|
1432
|
-
onContextMenu: (
|
|
1433
|
-
}), at && ye && /* @__PURE__ */
|
|
1434
|
+
onContextMenu: (l) => l.preventDefault()
|
|
1435
|
+
}), at && ye && /* @__PURE__ */ Le("input", {
|
|
1434
1436
|
className: "flow-label-editor",
|
|
1435
1437
|
autoFocus: !0,
|
|
1436
1438
|
defaultValue: at.value,
|
|
@@ -1438,16 +1440,16 @@ function Gn({ onPixiReady: _ }) {
|
|
|
1438
1440
|
left: ye.x,
|
|
1439
1441
|
top: ye.y
|
|
1440
1442
|
},
|
|
1441
|
-
onKeyDown: (
|
|
1442
|
-
|
|
1443
|
+
onKeyDown: (l) => {
|
|
1444
|
+
l.key === "Enter" ? (l.preventDefault(), De(l.target.value)) : l.key === "Escape" && (l.preventDefault(), Ve()), l.stopPropagation();
|
|
1443
1445
|
},
|
|
1444
|
-
onBlur: (
|
|
1445
|
-
onPointerDown: (
|
|
1446
|
+
onBlur: (l) => De(l.target.value),
|
|
1447
|
+
onPointerDown: (l) => l.stopPropagation()
|
|
1446
1448
|
})]
|
|
1447
1449
|
});
|
|
1448
1450
|
}
|
|
1449
1451
|
export {
|
|
1450
|
-
|
|
1452
|
+
Wn as default
|
|
1451
1453
|
};
|
|
1452
1454
|
|
|
1453
1455
|
//# sourceMappingURL=FlowCanvas.js.map
|