@flowgram.ai/free-layout-core 0.1.0
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/esm/chunk-CGOMTQ3G.js +1 -0
- package/dist/esm/chunk-CGOMTQ3G.js.map +1 -0
- package/dist/esm/chunk-DDJTYHXN.js +1 -0
- package/dist/esm/chunk-DDJTYHXN.js.map +1 -0
- package/dist/esm/chunk-DE4324TR.js +7 -0
- package/dist/esm/chunk-DE4324TR.js.map +1 -0
- package/dist/esm/chunk-EUXUH3YW.js +15 -0
- package/dist/esm/chunk-EUXUH3YW.js.map +1 -0
- package/dist/esm/chunk-J5FVRRUV.js +16 -0
- package/dist/esm/chunk-J5FVRRUV.js.map +1 -0
- package/dist/esm/chunk-KAL7YCC2.js +20 -0
- package/dist/esm/chunk-KAL7YCC2.js.map +1 -0
- package/dist/esm/chunk-KNYZRMIO.js +1 -0
- package/dist/esm/chunk-KNYZRMIO.js.map +1 -0
- package/dist/esm/chunk-NU6G5HF4.js +1 -0
- package/dist/esm/chunk-NU6G5HF4.js.map +1 -0
- package/dist/esm/index.js +3432 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/typings/index.js +22 -0
- package/dist/esm/typings/index.js.map +1 -0
- package/dist/esm/typings/workflow-edge.js +2 -0
- package/dist/esm/typings/workflow-edge.js.map +1 -0
- package/dist/esm/typings/workflow-json.js +8 -0
- package/dist/esm/typings/workflow-json.js.map +1 -0
- package/dist/esm/typings/workflow-line.js +10 -0
- package/dist/esm/typings/workflow-line.js.map +1 -0
- package/dist/esm/typings/workflow-node.js +2 -0
- package/dist/esm/typings/workflow-node.js.map +1 -0
- package/dist/esm/typings/workflow-registry.js +2 -0
- package/dist/esm/typings/workflow-registry.js.map +1 -0
- package/dist/esm/typings/workflow-sub-canvas.js +2 -0
- package/dist/esm/typings/workflow-sub-canvas.js.map +1 -0
- package/dist/index.d.mts +463 -0
- package/dist/index.d.ts +463 -0
- package/dist/index.js +3483 -0
- package/dist/index.js.map +1 -0
- package/dist/typings/index.d.mts +18 -0
- package/dist/typings/index.d.ts +18 -0
- package/dist/typings/index.js +66 -0
- package/dist/typings/index.js.map +1 -0
- package/dist/typings/workflow-edge.d.mts +11 -0
- package/dist/typings/workflow-edge.d.ts +11 -0
- package/dist/typings/workflow-edge.js +19 -0
- package/dist/typings/workflow-edge.js.map +1 -0
- package/dist/typings/workflow-json.d.mts +9 -0
- package/dist/typings/workflow-json.d.ts +9 -0
- package/dist/typings/workflow-json.js +40 -0
- package/dist/typings/workflow-json.js.map +1 -0
- package/dist/typings/workflow-line.d.mts +27 -0
- package/dist/typings/workflow-line.d.ts +27 -0
- package/dist/typings/workflow-line.js +45 -0
- package/dist/typings/workflow-line.js.map +1 -0
- package/dist/typings/workflow-node.d.mts +9 -0
- package/dist/typings/workflow-node.d.ts +9 -0
- package/dist/typings/workflow-node.js +19 -0
- package/dist/typings/workflow-node.js.map +1 -0
- package/dist/typings/workflow-registry.d.mts +26 -0
- package/dist/typings/workflow-registry.d.ts +26 -0
- package/dist/typings/workflow-registry.js +19 -0
- package/dist/typings/workflow-registry.js.map +1 -0
- package/dist/typings/workflow-sub-canvas.d.mts +2 -0
- package/dist/typings/workflow-sub-canvas.d.ts +2 -0
- package/dist/typings/workflow-sub-canvas.js +19 -0
- package/dist/typings/workflow-sub-canvas.js.map +1 -0
- package/dist/workflow-line-entity-1qT4aXVU.d.mts +619 -0
- package/dist/workflow-line-entity-CG_8mknJ.d.ts +619 -0
- package/dist/workflow-sub-canvas-DOVla1mw.d.mts +15 -0
- package/dist/workflow-sub-canvas-DOVla1mw.d.ts +15 -0
- package/package.json +72 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3483 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
+
if (decorator = decorators[i])
|
|
23
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
+
if (kind && result) __defProp(target, key, result);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/index.ts
|
|
29
|
+
var src_exports = {};
|
|
30
|
+
__export(src_exports, {
|
|
31
|
+
BezierControlType: () => BezierControlType,
|
|
32
|
+
EditorCursorState: () => EditorCursorState,
|
|
33
|
+
FoldLine: () => FoldLine,
|
|
34
|
+
InteractiveType: () => InteractiveType,
|
|
35
|
+
LINE_HOVER_DISTANCE: () => LINE_HOVER_DISTANCE,
|
|
36
|
+
LineColors: () => LineColors,
|
|
37
|
+
LineType: () => LineType,
|
|
38
|
+
POINT_RADIUS: () => POINT_RADIUS,
|
|
39
|
+
PORT_SIZE: () => PORT_SIZE,
|
|
40
|
+
URLParams: () => URLParams,
|
|
41
|
+
WORKFLOW_LINE_ENTITY: () => WORKFLOW_LINE_ENTITY,
|
|
42
|
+
WorkflowCommands: () => WorkflowCommands,
|
|
43
|
+
WorkflowContentChangeType: () => WorkflowContentChangeType,
|
|
44
|
+
WorkflowDocument: () => WorkflowDocument,
|
|
45
|
+
WorkflowDocumentContainerModule: () => WorkflowDocumentContainerModule,
|
|
46
|
+
WorkflowDocumentOptions: () => WorkflowDocumentOptions,
|
|
47
|
+
WorkflowDocumentOptionsDefault: () => WorkflowDocumentOptionsDefault,
|
|
48
|
+
WorkflowDocumentProvider: () => WorkflowDocumentProvider,
|
|
49
|
+
WorkflowDragService: () => WorkflowDragService,
|
|
50
|
+
WorkflowHoverService: () => WorkflowHoverService,
|
|
51
|
+
WorkflowLineEntity: () => WorkflowLineEntity,
|
|
52
|
+
WorkflowLinesManager: () => WorkflowLinesManager,
|
|
53
|
+
WorkflowNodeEntity: () => WorkflowNodeEntity,
|
|
54
|
+
WorkflowNodeLinesData: () => WorkflowNodeLinesData,
|
|
55
|
+
WorkflowNodePortsData: () => WorkflowNodePortsData,
|
|
56
|
+
WorkflowPortEntity: () => WorkflowPortEntity,
|
|
57
|
+
WorkflowResetLayoutService: () => WorkflowResetLayoutService,
|
|
58
|
+
WorkflowSelectService: () => WorkflowSelectService,
|
|
59
|
+
bindConfigEntity: () => import_core3.bindConfigEntity,
|
|
60
|
+
compose: () => import_utils3.compose,
|
|
61
|
+
composeAsync: () => import_utils3.composeAsync,
|
|
62
|
+
delay: () => import_utils6.delay,
|
|
63
|
+
domReactToBounds: () => domReactToBounds,
|
|
64
|
+
fitView: () => fitView,
|
|
65
|
+
getAntiOverlapPosition: () => getAntiOverlapPosition,
|
|
66
|
+
getBezierHorizontalControlPoints: () => getBezierHorizontalControlPoints,
|
|
67
|
+
getBezierVerticalControlPoints: () => getBezierVerticalControlPoints,
|
|
68
|
+
getPortEntityId: () => getPortEntityId,
|
|
69
|
+
nanoid: () => nanoid,
|
|
70
|
+
useConfigEntity: () => import_core23.useConfigEntity,
|
|
71
|
+
useCurrentDomNode: () => useCurrentDomNode,
|
|
72
|
+
useCurrentEntity: () => useCurrentEntity,
|
|
73
|
+
useEntities: () => import_core23.useEntities,
|
|
74
|
+
useEntityDataFromContext: () => import_core23.useEntityDataFromContext,
|
|
75
|
+
useEntityFromContext: () => import_core23.useEntityFromContext,
|
|
76
|
+
useListenEvents: () => import_core23.useListenEvents,
|
|
77
|
+
useNodeRender: () => useNodeRender,
|
|
78
|
+
usePlayground: () => import_core23.usePlayground,
|
|
79
|
+
usePlaygroundContainer: () => import_core23.usePlaygroundContainer,
|
|
80
|
+
usePlaygroundContext: () => import_core23.usePlaygroundContext,
|
|
81
|
+
usePlaygroundLatest: () => import_core23.usePlaygroundLatest,
|
|
82
|
+
usePlaygroundReadonlyState: () => usePlaygroundReadonlyState,
|
|
83
|
+
useRefresh: () => import_core23.useRefresh,
|
|
84
|
+
useService: () => import_core23.useService,
|
|
85
|
+
useWorkflowDocument: () => useWorkflowDocument
|
|
86
|
+
});
|
|
87
|
+
module.exports = __toCommonJS(src_exports);
|
|
88
|
+
|
|
89
|
+
// src/workflow-commands.ts
|
|
90
|
+
var WorkflowCommands = /* @__PURE__ */ ((WorkflowCommands2) => {
|
|
91
|
+
WorkflowCommands2["DELETE_NODES"] = "DELETE_NODES";
|
|
92
|
+
WorkflowCommands2["COPY_NODES"] = "COPY_NODES";
|
|
93
|
+
WorkflowCommands2["PASTE_NODES"] = "PASTE_NODES";
|
|
94
|
+
WorkflowCommands2["ZOOM_IN"] = "ZOOM_IN";
|
|
95
|
+
WorkflowCommands2["ZOOM_OUT"] = "ZOOM_OUT";
|
|
96
|
+
WorkflowCommands2["UNDO"] = "UNDO";
|
|
97
|
+
WorkflowCommands2["REDO"] = "REDO";
|
|
98
|
+
return WorkflowCommands2;
|
|
99
|
+
})(WorkflowCommands || {});
|
|
100
|
+
|
|
101
|
+
// src/hooks/index.ts
|
|
102
|
+
var import_core23 = require("@flowgram.ai/core");
|
|
103
|
+
|
|
104
|
+
// src/hooks/use-node-render.tsx
|
|
105
|
+
var import_react2 = require("react");
|
|
106
|
+
var import_reactive = require("@flowgram.ai/reactive");
|
|
107
|
+
var import_node = require("@flowgram.ai/node");
|
|
108
|
+
var import_document10 = require("@flowgram.ai/document");
|
|
109
|
+
var import_core19 = require("@flowgram.ai/core");
|
|
110
|
+
|
|
111
|
+
// src/service/workflow-select-service.ts
|
|
112
|
+
var import_inversify = require("inversify");
|
|
113
|
+
var import_core7 = require("@flowgram.ai/core");
|
|
114
|
+
var import_utils9 = require("@flowgram.ai/utils");
|
|
115
|
+
|
|
116
|
+
// src/utils/index.ts
|
|
117
|
+
var import_core3 = require("@flowgram.ai/core");
|
|
118
|
+
var import_utils6 = require("@flowgram.ai/utils");
|
|
119
|
+
|
|
120
|
+
// src/utils/fold-line.ts
|
|
121
|
+
var import_utils = require("@flowgram.ai/utils");
|
|
122
|
+
function pointLineDistance(p1, p2, p3) {
|
|
123
|
+
let len;
|
|
124
|
+
if (p1.x - p2.x === 0) {
|
|
125
|
+
len = Math.abs(p3.x - p1.x);
|
|
126
|
+
} else {
|
|
127
|
+
const A = (p1.y - p2.y) / (p1.x - p2.x);
|
|
128
|
+
const B = p1.y - A * p1.x;
|
|
129
|
+
len = Math.abs((A * p3.x + B - p3.y) / Math.sqrt(A * A + 1));
|
|
130
|
+
}
|
|
131
|
+
return len;
|
|
132
|
+
}
|
|
133
|
+
var FoldLine;
|
|
134
|
+
((FoldLine2) => {
|
|
135
|
+
const EDGE_RADIUS = 5;
|
|
136
|
+
const OFFSET = 20;
|
|
137
|
+
function getEdgeCenter({ source, target }) {
|
|
138
|
+
const xOffset = Math.abs(target.x - source.x) / 2;
|
|
139
|
+
const centerX = target.x < source.x ? target.x + xOffset : target.x - xOffset;
|
|
140
|
+
const yOffset = Math.abs(target.y - source.y) / 2;
|
|
141
|
+
const centerY = target.y < source.y ? target.y + yOffset : target.y - yOffset;
|
|
142
|
+
return [centerX, centerY];
|
|
143
|
+
}
|
|
144
|
+
const getDirection = ({ source, target }) => source.x < target.x ? { x: 1, y: 0 } : { x: -1, y: 0 };
|
|
145
|
+
function getPoints({ source, target }) {
|
|
146
|
+
const sourceDir = { x: 1, y: 0 };
|
|
147
|
+
const targetDir = { x: -1, y: 0 };
|
|
148
|
+
const sourceGapped = {
|
|
149
|
+
x: source.x + sourceDir.x * OFFSET,
|
|
150
|
+
y: source.y + sourceDir.y * OFFSET
|
|
151
|
+
};
|
|
152
|
+
const targetGapped = {
|
|
153
|
+
x: target.x + targetDir.x * OFFSET,
|
|
154
|
+
y: target.y + targetDir.y * OFFSET
|
|
155
|
+
};
|
|
156
|
+
const dir = getDirection({
|
|
157
|
+
source: sourceGapped,
|
|
158
|
+
target: targetGapped
|
|
159
|
+
});
|
|
160
|
+
const dirAccessor = dir.x !== 0 ? "x" : "y";
|
|
161
|
+
const currDir = dir[dirAccessor];
|
|
162
|
+
let points = [];
|
|
163
|
+
let centerX, centerY;
|
|
164
|
+
const [defaultCenterX, defaultCenterY] = getEdgeCenter({
|
|
165
|
+
source,
|
|
166
|
+
target
|
|
167
|
+
});
|
|
168
|
+
if (sourceDir[dirAccessor] * targetDir[dirAccessor] === -1) {
|
|
169
|
+
centerX = defaultCenterX;
|
|
170
|
+
centerY = defaultCenterY;
|
|
171
|
+
const verticalSplit = [
|
|
172
|
+
{ x: centerX, y: sourceGapped.y },
|
|
173
|
+
{ x: centerX, y: targetGapped.y }
|
|
174
|
+
];
|
|
175
|
+
const horizontalSplit = [
|
|
176
|
+
{ x: sourceGapped.x, y: centerY },
|
|
177
|
+
{ x: targetGapped.x, y: centerY }
|
|
178
|
+
];
|
|
179
|
+
if (sourceDir[dirAccessor] === currDir) {
|
|
180
|
+
points = dirAccessor === "x" ? verticalSplit : horizontalSplit;
|
|
181
|
+
} else {
|
|
182
|
+
points = dirAccessor === "x" ? horizontalSplit : verticalSplit;
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
const sourceTarget = [{ x: sourceGapped.x, y: targetGapped.y }];
|
|
186
|
+
const targetSource = [{ x: targetGapped.x, y: sourceGapped.y }];
|
|
187
|
+
if (dirAccessor === "x") {
|
|
188
|
+
points = sourceDir.x === currDir ? targetSource : sourceTarget;
|
|
189
|
+
} else {
|
|
190
|
+
points = sourceDir.y === currDir ? sourceTarget : targetSource;
|
|
191
|
+
}
|
|
192
|
+
const dirAccessorOpposite = dirAccessor === "x" ? "y" : "x";
|
|
193
|
+
const isSameDir = sourceDir[dirAccessor] === targetDir[dirAccessorOpposite];
|
|
194
|
+
const sourceGtTargetOppo = sourceGapped[dirAccessorOpposite] > targetGapped[dirAccessorOpposite];
|
|
195
|
+
const sourceLtTargetOppo = sourceGapped[dirAccessorOpposite] < targetGapped[dirAccessorOpposite];
|
|
196
|
+
const flipSourceTarget = sourceDir[dirAccessor] === 1 && (!isSameDir && sourceGtTargetOppo || isSameDir && sourceLtTargetOppo) || sourceDir[dirAccessor] !== 1 && (!isSameDir && sourceLtTargetOppo || isSameDir && sourceGtTargetOppo);
|
|
197
|
+
if (flipSourceTarget) {
|
|
198
|
+
points = dirAccessor === "x" ? sourceTarget : targetSource;
|
|
199
|
+
}
|
|
200
|
+
const sourceGapPoint = { x: sourceGapped.x, y: sourceGapped.y };
|
|
201
|
+
const targetGapPoint = { x: targetGapped.x, y: targetGapped.y };
|
|
202
|
+
const maxXDistance = Math.max(
|
|
203
|
+
Math.abs(sourceGapPoint.x - points[0].x),
|
|
204
|
+
Math.abs(targetGapPoint.x - points[0].x)
|
|
205
|
+
);
|
|
206
|
+
const maxYDistance = Math.max(
|
|
207
|
+
Math.abs(sourceGapPoint.y - points[0].y),
|
|
208
|
+
Math.abs(targetGapPoint.y - points[0].y)
|
|
209
|
+
);
|
|
210
|
+
if (maxXDistance >= maxYDistance) {
|
|
211
|
+
centerX = (sourceGapPoint.x + targetGapPoint.x) / 2;
|
|
212
|
+
centerY = points[0].y;
|
|
213
|
+
} else {
|
|
214
|
+
centerX = points[0].x;
|
|
215
|
+
centerY = (sourceGapPoint.y + targetGapPoint.y) / 2;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const pathPoints = [
|
|
219
|
+
source,
|
|
220
|
+
{ x: sourceGapped.x, y: sourceGapped.y },
|
|
221
|
+
...points,
|
|
222
|
+
{ x: targetGapped.x, y: targetGapped.y },
|
|
223
|
+
target
|
|
224
|
+
];
|
|
225
|
+
return pathPoints;
|
|
226
|
+
}
|
|
227
|
+
FoldLine2.getPoints = getPoints;
|
|
228
|
+
function getBend(a, b, c) {
|
|
229
|
+
const bendSize = Math.min(
|
|
230
|
+
import_utils.Point.getDistance(a, b) / 2,
|
|
231
|
+
import_utils.Point.getDistance(b, c) / 2,
|
|
232
|
+
EDGE_RADIUS
|
|
233
|
+
);
|
|
234
|
+
const { x, y } = b;
|
|
235
|
+
if (a.x === x && x === c.x || a.y === y && y === c.y) {
|
|
236
|
+
return `L${x} ${y}`;
|
|
237
|
+
}
|
|
238
|
+
if (a.y === y) {
|
|
239
|
+
const xDir2 = a.x < c.x ? -1 : 1;
|
|
240
|
+
const yDir2 = a.y < c.y ? 1 : -1;
|
|
241
|
+
return `L ${x + bendSize * xDir2},${y}Q ${x},${y} ${x},${y + bendSize * yDir2}`;
|
|
242
|
+
}
|
|
243
|
+
const xDir = a.x < c.x ? 1 : -1;
|
|
244
|
+
const yDir = a.y < c.y ? -1 : 1;
|
|
245
|
+
return `L ${x},${y + bendSize * yDir}Q ${x},${y} ${x + bendSize * xDir},${y}`;
|
|
246
|
+
}
|
|
247
|
+
function getSmoothStepPath(points) {
|
|
248
|
+
const path = points.reduce((res, p, i) => {
|
|
249
|
+
let segment = "";
|
|
250
|
+
if (i > 0 && i < points.length - 1) {
|
|
251
|
+
segment = getBend(points[i - 1], p, points[i + 1]);
|
|
252
|
+
} else {
|
|
253
|
+
segment = `${i === 0 ? "M" : "L"}${p.x} ${p.y}`;
|
|
254
|
+
}
|
|
255
|
+
res += segment;
|
|
256
|
+
return res;
|
|
257
|
+
}, "");
|
|
258
|
+
return path;
|
|
259
|
+
}
|
|
260
|
+
FoldLine2.getSmoothStepPath = getSmoothStepPath;
|
|
261
|
+
function getBounds(points) {
|
|
262
|
+
const xList = points.map((p) => p.x);
|
|
263
|
+
const yList = points.map((p) => p.y);
|
|
264
|
+
const left = Math.min(...xList);
|
|
265
|
+
const right = Math.max(...xList);
|
|
266
|
+
const top = Math.min(...yList);
|
|
267
|
+
const bottom = Math.max(...yList);
|
|
268
|
+
return import_utils.Rectangle.createRectangleWithTwoPoints(
|
|
269
|
+
{
|
|
270
|
+
x: left,
|
|
271
|
+
y: top
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
x: right,
|
|
275
|
+
y: bottom
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
FoldLine2.getBounds = getBounds;
|
|
280
|
+
function getFoldLineToPointDistance(points, pos) {
|
|
281
|
+
const bounds = getBounds(points);
|
|
282
|
+
if (bounds.contains(pos.x, pos.y)) {
|
|
283
|
+
const lines = points.reduce((res, point, index) => {
|
|
284
|
+
if (index === 0) {
|
|
285
|
+
return res;
|
|
286
|
+
}
|
|
287
|
+
res.push([points[index - 1], point]);
|
|
288
|
+
return res;
|
|
289
|
+
}, []);
|
|
290
|
+
return Math.min(...lines.map((l) => pointLineDistance(...l, pos)));
|
|
291
|
+
}
|
|
292
|
+
return Math.min(...points.map((p) => import_utils.Point.getDistance(p, pos)));
|
|
293
|
+
}
|
|
294
|
+
FoldLine2.getFoldLineToPointDistance = getFoldLineToPointDistance;
|
|
295
|
+
})(FoldLine || (FoldLine = {}));
|
|
296
|
+
|
|
297
|
+
// src/utils/bezier.ts
|
|
298
|
+
var import_utils2 = require("@flowgram.ai/utils");
|
|
299
|
+
var BezierControlType = /* @__PURE__ */ ((BezierControlType2) => {
|
|
300
|
+
BezierControlType2[BezierControlType2["RIGHT_TOP"] = 0] = "RIGHT_TOP";
|
|
301
|
+
BezierControlType2[BezierControlType2["RIGHT_BOTTOM"] = 1] = "RIGHT_BOTTOM";
|
|
302
|
+
BezierControlType2[BezierControlType2["LEFT_TOP"] = 2] = "LEFT_TOP";
|
|
303
|
+
BezierControlType2[BezierControlType2["LEFT_BOTTOM"] = 3] = "LEFT_BOTTOM";
|
|
304
|
+
return BezierControlType2;
|
|
305
|
+
})(BezierControlType || {});
|
|
306
|
+
var CONTROL_MAX = 300;
|
|
307
|
+
function getBezierHorizontalControlPoints(fromPos, toPos) {
|
|
308
|
+
const rect = import_utils2.Rectangle.createRectangleWithTwoPoints(fromPos, toPos);
|
|
309
|
+
let type;
|
|
310
|
+
if (fromPos.x <= toPos.x) {
|
|
311
|
+
type = fromPos.y <= toPos.y ? 1 /* RIGHT_BOTTOM */ : 0 /* RIGHT_TOP */;
|
|
312
|
+
} else {
|
|
313
|
+
type = fromPos.y <= toPos.y ? 3 /* LEFT_BOTTOM */ : 2 /* LEFT_TOP */;
|
|
314
|
+
}
|
|
315
|
+
let controls;
|
|
316
|
+
switch (type) {
|
|
317
|
+
case 0 /* RIGHT_TOP */:
|
|
318
|
+
controls = [
|
|
319
|
+
{
|
|
320
|
+
x: rect.rightBottom.x - rect.width / 2,
|
|
321
|
+
y: rect.rightBottom.y
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
x: rect.leftTop.x + rect.width / 2,
|
|
325
|
+
y: rect.leftTop.y
|
|
326
|
+
}
|
|
327
|
+
];
|
|
328
|
+
break;
|
|
329
|
+
case 1 /* RIGHT_BOTTOM */:
|
|
330
|
+
controls = [
|
|
331
|
+
{
|
|
332
|
+
x: rect.rightTop.x - rect.width / 2,
|
|
333
|
+
y: rect.rightTop.y
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
x: rect.leftBottom.x + rect.width / 2,
|
|
337
|
+
y: rect.leftBottom.y
|
|
338
|
+
}
|
|
339
|
+
];
|
|
340
|
+
break;
|
|
341
|
+
case 2 /* LEFT_TOP */:
|
|
342
|
+
controls = [
|
|
343
|
+
{
|
|
344
|
+
x: rect.rightBottom.x + Math.min(rect.width, CONTROL_MAX),
|
|
345
|
+
y: rect.rightBottom.y
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
x: rect.leftTop.x - Math.min(rect.width, CONTROL_MAX),
|
|
349
|
+
y: rect.leftTop.y
|
|
350
|
+
}
|
|
351
|
+
];
|
|
352
|
+
break;
|
|
353
|
+
case 3 /* LEFT_BOTTOM */:
|
|
354
|
+
controls = [
|
|
355
|
+
{
|
|
356
|
+
x: rect.rightTop.x + Math.min(rect.width, CONTROL_MAX),
|
|
357
|
+
y: rect.rightTop.y
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
x: rect.leftBottom.x - Math.min(rect.width, CONTROL_MAX),
|
|
361
|
+
y: rect.leftBottom.y
|
|
362
|
+
}
|
|
363
|
+
];
|
|
364
|
+
}
|
|
365
|
+
return controls;
|
|
366
|
+
}
|
|
367
|
+
function getBezierVerticalControlPoints(fromPos, toPos) {
|
|
368
|
+
const rect = import_utils2.Rectangle.createRectangleWithTwoPoints(fromPos, toPos);
|
|
369
|
+
let type;
|
|
370
|
+
if (fromPos.y <= toPos.y) {
|
|
371
|
+
type = fromPos.x <= toPos.x ? 1 /* RIGHT_BOTTOM */ : 3 /* LEFT_BOTTOM */;
|
|
372
|
+
} else {
|
|
373
|
+
type = fromPos.x <= toPos.x ? 0 /* RIGHT_TOP */ : 2 /* LEFT_TOP */;
|
|
374
|
+
}
|
|
375
|
+
let controls;
|
|
376
|
+
switch (type) {
|
|
377
|
+
case 1 /* RIGHT_BOTTOM */:
|
|
378
|
+
controls = [
|
|
379
|
+
{
|
|
380
|
+
x: rect.leftTop.x,
|
|
381
|
+
y: rect.leftTop.y + rect.height / 2
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
x: rect.rightBottom.x,
|
|
385
|
+
y: rect.rightBottom.y - rect.height / 2
|
|
386
|
+
}
|
|
387
|
+
];
|
|
388
|
+
break;
|
|
389
|
+
case 3 /* LEFT_BOTTOM */:
|
|
390
|
+
controls = [
|
|
391
|
+
{
|
|
392
|
+
x: rect.rightTop.x,
|
|
393
|
+
y: rect.rightTop.y + rect.height / 2
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
x: rect.leftBottom.x,
|
|
397
|
+
y: rect.leftBottom.y - rect.height / 2
|
|
398
|
+
}
|
|
399
|
+
];
|
|
400
|
+
break;
|
|
401
|
+
case 0 /* RIGHT_TOP */:
|
|
402
|
+
controls = [
|
|
403
|
+
{
|
|
404
|
+
x: rect.leftBottom.x,
|
|
405
|
+
y: rect.leftBottom.y + Math.min(rect.height, CONTROL_MAX)
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
x: rect.rightTop.x,
|
|
409
|
+
y: rect.rightTop.y - Math.min(rect.height, CONTROL_MAX)
|
|
410
|
+
}
|
|
411
|
+
];
|
|
412
|
+
break;
|
|
413
|
+
case 2 /* LEFT_TOP */:
|
|
414
|
+
controls = [
|
|
415
|
+
{
|
|
416
|
+
x: rect.rightBottom.x,
|
|
417
|
+
y: rect.rightBottom.y + Math.min(rect.height, CONTROL_MAX)
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
x: rect.leftTop.x,
|
|
421
|
+
y: rect.leftTop.y - Math.min(rect.height, CONTROL_MAX)
|
|
422
|
+
}
|
|
423
|
+
];
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
return controls;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// src/utils/nanoid.ts
|
|
430
|
+
var import_nanoid = require("nanoid");
|
|
431
|
+
function nanoid(n) {
|
|
432
|
+
return (0, import_nanoid.nanoid)(n);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// src/utils/compose.ts
|
|
436
|
+
var import_utils3 = require("@flowgram.ai/utils");
|
|
437
|
+
|
|
438
|
+
// src/utils/fit-view.ts
|
|
439
|
+
var import_core = require("@flowgram.ai/core");
|
|
440
|
+
var import_utils4 = require("@flowgram.ai/utils");
|
|
441
|
+
var fitView = (doc, playgroundConfig, easing = true) => {
|
|
442
|
+
const bounds = import_utils4.Rectangle.enlarge(
|
|
443
|
+
doc.getAllNodes().map((node) => node.getData(import_core.TransformData).bounds)
|
|
444
|
+
);
|
|
445
|
+
return playgroundConfig.fitView(bounds, easing, 30);
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
// src/utils/get-anti-overlap-position.ts
|
|
449
|
+
var import_core2 = require("@flowgram.ai/core");
|
|
450
|
+
function getAntiOverlapPosition(doc, position, containerNode) {
|
|
451
|
+
let { x, y } = position;
|
|
452
|
+
const nodes = containerNode ? containerNode.collapsedChildren : doc.getAllNodes();
|
|
453
|
+
const positions = nodes.map((n) => {
|
|
454
|
+
const transform = n.getData(import_core2.TransformData);
|
|
455
|
+
return { x: transform.position.x, y: transform.position.y };
|
|
456
|
+
}).sort((a, b) => a.y - b.y);
|
|
457
|
+
const minDistance = 3;
|
|
458
|
+
for (const pos of positions) {
|
|
459
|
+
const { x: posX, y: posY } = pos;
|
|
460
|
+
if (y - posY < -minDistance) {
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
const deltaX = Math.abs(x - posX);
|
|
464
|
+
const deltaY = Math.abs(y - posY);
|
|
465
|
+
if (deltaX <= minDistance && deltaY <= minDistance) {
|
|
466
|
+
x += 30;
|
|
467
|
+
y += 30;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return { x, y };
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// src/utils/statics.ts
|
|
474
|
+
var import_utils5 = require("@flowgram.ai/utils");
|
|
475
|
+
var getPortEntityId = (node, portType, portID = "") => `port_${portType}_${node.id}_${portID}`;
|
|
476
|
+
var WORKFLOW_LINE_ENTITY = "WorkflowLineEntity";
|
|
477
|
+
function domReactToBounds(react) {
|
|
478
|
+
return new import_utils5.Rectangle(react.x, react.y, react.width, react.height);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// src/entities/workflow-node-entity.ts
|
|
482
|
+
var import_document = require("@flowgram.ai/document");
|
|
483
|
+
var WorkflowNodeEntity = import_document.FlowNodeEntity;
|
|
484
|
+
|
|
485
|
+
// src/entities/workflow-line-entity.ts
|
|
486
|
+
var import_lodash_es2 = require("lodash-es");
|
|
487
|
+
var import_bezier_js = require("bezier-js");
|
|
488
|
+
var import_utils8 = require("@flowgram.ai/utils");
|
|
489
|
+
var import_core6 = require("@flowgram.ai/core");
|
|
490
|
+
|
|
491
|
+
// src/typings/workflow-line.ts
|
|
492
|
+
var LineType = /* @__PURE__ */ ((LineType2) => {
|
|
493
|
+
LineType2[LineType2["BEZIER"] = 0] = "BEZIER";
|
|
494
|
+
LineType2[LineType2["LINE_CHART"] = 1] = "LINE_CHART";
|
|
495
|
+
return LineType2;
|
|
496
|
+
})(LineType || {});
|
|
497
|
+
var LineColors = /* @__PURE__ */ ((LineColors2) => {
|
|
498
|
+
LineColors2["HIDDEN"] = "transparent";
|
|
499
|
+
LineColors2["DEFUALT"] = "#4d53e8";
|
|
500
|
+
LineColors2["DRAWING"] = "#5DD6E3";
|
|
501
|
+
LineColors2["HOVER"] = "#37d0ff";
|
|
502
|
+
LineColors2["ERROR"] = "red";
|
|
503
|
+
return LineColors2;
|
|
504
|
+
})(LineColors || {});
|
|
505
|
+
|
|
506
|
+
// src/entity-datas/workflow-node-ports-data.ts
|
|
507
|
+
var import_lodash_es = require("lodash-es");
|
|
508
|
+
var import_document2 = require("@flowgram.ai/document");
|
|
509
|
+
var import_core5 = require("@flowgram.ai/core");
|
|
510
|
+
|
|
511
|
+
// src/entities/workflow-port-entity.ts
|
|
512
|
+
var import_utils7 = require("@flowgram.ai/utils");
|
|
513
|
+
var import_core4 = require("@flowgram.ai/core");
|
|
514
|
+
var PORT_SIZE = 24;
|
|
515
|
+
var WorkflowPortEntity = class extends import_core4.Entity {
|
|
516
|
+
// relativePosition
|
|
517
|
+
constructor(opts) {
|
|
518
|
+
super(opts);
|
|
519
|
+
this.portID = "";
|
|
520
|
+
this._disabled = false;
|
|
521
|
+
this._hasError = false;
|
|
522
|
+
this._onErrorChangedEmitter = new import_utils7.Emitter();
|
|
523
|
+
this.onErrorChanged = this._onErrorChangedEmitter.event;
|
|
524
|
+
this.portID = opts.portID || "";
|
|
525
|
+
this.portType = opts.type;
|
|
526
|
+
this._disabled = opts.disabled ?? false;
|
|
527
|
+
this.node = opts.node;
|
|
528
|
+
this.updateTargetElement(opts.targetElement);
|
|
529
|
+
this.toDispose.push(this.node.getData(import_core4.TransformData).onDataChange(() => this.fireChange()));
|
|
530
|
+
this.toDispose.push(this.node.onDispose(this.dispose.bind(this)));
|
|
531
|
+
}
|
|
532
|
+
static getPortEntityId(node, portType, portID = "") {
|
|
533
|
+
return getPortEntityId(node, portType, portID);
|
|
534
|
+
}
|
|
535
|
+
// 获取连线是否为错误态
|
|
536
|
+
get hasError() {
|
|
537
|
+
return this._hasError;
|
|
538
|
+
}
|
|
539
|
+
// 设置连线的错误态,外部应使用 validate 进行更新
|
|
540
|
+
set hasError(hasError) {
|
|
541
|
+
this._hasError = hasError;
|
|
542
|
+
this._onErrorChangedEmitter.fire();
|
|
543
|
+
}
|
|
544
|
+
validate() {
|
|
545
|
+
const anyLineHasError = this.allLines.some((line) => {
|
|
546
|
+
if (line.disposed || line.isHidden) {
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
line.validateSelf();
|
|
550
|
+
return line.hasError;
|
|
551
|
+
});
|
|
552
|
+
const isPortHasError = this.node.document.isErrorPort(this);
|
|
553
|
+
this.hasError = anyLineHasError || isPortHasError;
|
|
554
|
+
}
|
|
555
|
+
isErrorPort() {
|
|
556
|
+
return this.node.document.isErrorPort(this);
|
|
557
|
+
}
|
|
558
|
+
get point() {
|
|
559
|
+
const { targetElement } = this;
|
|
560
|
+
const { bounds } = this.node.getData(import_core4.TransformData);
|
|
561
|
+
if (targetElement) {
|
|
562
|
+
const pos = domReactToBounds(targetElement.getBoundingClientRect()).center;
|
|
563
|
+
return this.entityManager.getEntity(import_core4.PlaygroundConfigEntity).getPosFromMouseEvent({
|
|
564
|
+
clientX: pos.x,
|
|
565
|
+
clientY: pos.y
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
if (this.portType === "input") {
|
|
569
|
+
return bounds.leftCenter;
|
|
570
|
+
}
|
|
571
|
+
return bounds.rightCenter;
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* 点的区域
|
|
575
|
+
*/
|
|
576
|
+
get bounds() {
|
|
577
|
+
const { point } = this;
|
|
578
|
+
const halfSize = PORT_SIZE / 2;
|
|
579
|
+
return new import_utils7.Rectangle(point.x - halfSize, point.y - halfSize, PORT_SIZE, PORT_SIZE);
|
|
580
|
+
}
|
|
581
|
+
isHovered(x, y) {
|
|
582
|
+
return this.bounds.contains(x, y);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* 相对节点左上角的位置
|
|
586
|
+
*/
|
|
587
|
+
get relativePosition() {
|
|
588
|
+
const { point } = this;
|
|
589
|
+
const { bounds } = this.node.getData(import_core4.TransformData);
|
|
590
|
+
return {
|
|
591
|
+
x: point.x - bounds.x,
|
|
592
|
+
y: point.y - bounds.y
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
updateTargetElement(el) {
|
|
596
|
+
if (el !== this.targetElement) {
|
|
597
|
+
this.targetElement = el;
|
|
598
|
+
this.fireChange();
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* 是否被禁用
|
|
603
|
+
*/
|
|
604
|
+
get disabled() {
|
|
605
|
+
const document2 = this.node.document;
|
|
606
|
+
if (typeof document2.options.isDisabledPort === "function") {
|
|
607
|
+
return document2.options.isDisabledPort(this);
|
|
608
|
+
}
|
|
609
|
+
if (this._disabled) {
|
|
610
|
+
return true;
|
|
611
|
+
}
|
|
612
|
+
const meta = this.node.getNodeMeta();
|
|
613
|
+
if (this.portType === "input") {
|
|
614
|
+
return !!meta.inputDisable;
|
|
615
|
+
}
|
|
616
|
+
return !!meta.outputDisable;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* 当前点位上连接的线条
|
|
620
|
+
*/
|
|
621
|
+
get lines() {
|
|
622
|
+
return this.allLines.filter((line) => !line.isDrawing);
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* 当前点位上连接的线条(包含 isDrawing === true 的线条)
|
|
626
|
+
*/
|
|
627
|
+
get allLines() {
|
|
628
|
+
const lines = [];
|
|
629
|
+
const allLines = this.entityManager.getEntities({
|
|
630
|
+
type: WORKFLOW_LINE_ENTITY
|
|
631
|
+
});
|
|
632
|
+
allLines.forEach((line) => {
|
|
633
|
+
if (line.toPort === this || line.fromPort === this) {
|
|
634
|
+
lines.push(line);
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
return lines;
|
|
638
|
+
}
|
|
639
|
+
dispose() {
|
|
640
|
+
this.lines.forEach((l) => l.dispose());
|
|
641
|
+
super.dispose();
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
WorkflowPortEntity.type = "WorkflowPortEntity";
|
|
645
|
+
|
|
646
|
+
// src/entity-datas/workflow-node-ports-data.ts
|
|
647
|
+
var WorkflowNodePortsData = class extends import_core5.EntityData {
|
|
648
|
+
constructor(entity) {
|
|
649
|
+
super(entity);
|
|
650
|
+
/** 静态的 ports 数据 */
|
|
651
|
+
this._staticPorts = [];
|
|
652
|
+
/** 存储 port 实体的 id,用于判断 port 是否存在 */
|
|
653
|
+
this._portIDSet = /* @__PURE__ */ new Set();
|
|
654
|
+
this.entity = entity;
|
|
655
|
+
const meta = entity.getNodeMeta();
|
|
656
|
+
const defaultPorts = meta.useDynamicPort ? [] : [{ type: "input" }, { type: "output" }];
|
|
657
|
+
this._staticPorts = meta.defaultPorts?.slice() || defaultPorts;
|
|
658
|
+
this.updatePorts(this._staticPorts);
|
|
659
|
+
if (meta.useDynamicPort) {
|
|
660
|
+
this.toDispose.push(
|
|
661
|
+
// 只需要监听节点的大小,因为算的是相对位置
|
|
662
|
+
entity.getData(import_core5.SizeData).onDataChange(() => {
|
|
663
|
+
if (entity.getData(import_core5.SizeData).width && entity.getData(import_core5.SizeData).height) {
|
|
664
|
+
this.updateDynamicPorts();
|
|
665
|
+
}
|
|
666
|
+
})
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
this.onDispose(() => {
|
|
670
|
+
this.allPorts.forEach((port) => port.dispose());
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
getDefaultData() {
|
|
674
|
+
return {};
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* 更新静态的 ports 数据
|
|
678
|
+
*/
|
|
679
|
+
updateStaticPorts(ports) {
|
|
680
|
+
const meta = this.entity.getNodeMeta();
|
|
681
|
+
this._staticPorts = ports;
|
|
682
|
+
if (meta.useDynamicPort) {
|
|
683
|
+
this.updateDynamicPorts();
|
|
684
|
+
} else {
|
|
685
|
+
this.updatePorts(this._staticPorts);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* 动态计算点位,通过 dom 的 data-port-key
|
|
690
|
+
*/
|
|
691
|
+
updateDynamicPorts() {
|
|
692
|
+
const domNode = this.entity.getData(import_document2.FlowNodeRenderData).node;
|
|
693
|
+
const elements = domNode.querySelectorAll("[data-port-id]");
|
|
694
|
+
const staticPorts = this._staticPorts;
|
|
695
|
+
const dynamicPorts = [];
|
|
696
|
+
if (elements.length > 0) {
|
|
697
|
+
dynamicPorts.push(
|
|
698
|
+
...Array.from(elements).map((element) => ({
|
|
699
|
+
portID: element.getAttribute("data-port-id"),
|
|
700
|
+
type: element.getAttribute("data-port-type"),
|
|
701
|
+
targetElement: element
|
|
702
|
+
}))
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
this.updatePorts(staticPorts.concat(dynamicPorts));
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* 根据 key 获取 port 实体
|
|
709
|
+
*/
|
|
710
|
+
getPortEntityByKey(portType, portKey) {
|
|
711
|
+
const entity = this.getOrCreatePortEntity({
|
|
712
|
+
type: portType,
|
|
713
|
+
portID: portKey
|
|
714
|
+
});
|
|
715
|
+
return entity;
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* 更新 ports 数据
|
|
719
|
+
*/
|
|
720
|
+
updatePorts(ports) {
|
|
721
|
+
if (!(0, import_lodash_es.isEqual)(this._prePorts, ports)) {
|
|
722
|
+
const portKeys = ports.map((port) => this.getPortId(port.type, port.portID));
|
|
723
|
+
this._portIDSet.forEach((portId) => {
|
|
724
|
+
if (!portKeys.includes(portId)) {
|
|
725
|
+
this.getPortEntity(portId)?.dispose();
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
ports.forEach((port) => this.updatePortEntity(port));
|
|
729
|
+
this._prePorts = ports;
|
|
730
|
+
this.fireChange();
|
|
731
|
+
}
|
|
732
|
+
this.allPorts.forEach((port) => {
|
|
733
|
+
port.allLines.forEach((line) => {
|
|
734
|
+
line.validate();
|
|
735
|
+
});
|
|
736
|
+
port.validate();
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* 获取所有 port entities
|
|
741
|
+
*/
|
|
742
|
+
get allPorts() {
|
|
743
|
+
return Array.from(this._portIDSet).map((portId) => this.getPortEntity(portId)).filter(Boolean);
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* 获取输入点位
|
|
747
|
+
*/
|
|
748
|
+
get inputPorts() {
|
|
749
|
+
return this.allPorts.filter((port) => port.portType === "input");
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* 获取输出点位
|
|
753
|
+
*/
|
|
754
|
+
get outputPorts() {
|
|
755
|
+
return this.allPorts.filter((port) => port.portType === "output");
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* 获取输入点位置
|
|
759
|
+
*/
|
|
760
|
+
get inputPoints() {
|
|
761
|
+
return this.inputPorts.map((port) => port.point);
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* 获取输出点位置
|
|
765
|
+
*/
|
|
766
|
+
get outputPoints() {
|
|
767
|
+
return this.inputPorts.map((port) => port.point);
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* 根据 key 获取 输入点位置
|
|
771
|
+
*/
|
|
772
|
+
getInputPoint(key) {
|
|
773
|
+
return this.getPortEntityByKey("input", key).point;
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* 根据 key 获取输出点位置
|
|
777
|
+
*/
|
|
778
|
+
getOutputPoint(key) {
|
|
779
|
+
return this.getPortEntityByKey("output", key).point;
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* 获取 port 实体
|
|
783
|
+
*/
|
|
784
|
+
getPortEntity(portId) {
|
|
785
|
+
if (!this._portIDSet.has(portId)) {
|
|
786
|
+
return void 0;
|
|
787
|
+
}
|
|
788
|
+
return this.entity.entityManager.getEntityById(portId);
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* 拼接 port 实体的 id
|
|
792
|
+
*/
|
|
793
|
+
getPortId(portType, portKey = "") {
|
|
794
|
+
return getPortEntityId(this.entity, portType, portKey);
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* 创建 port 实体
|
|
798
|
+
*/
|
|
799
|
+
createPortEntity(portInfo) {
|
|
800
|
+
const id = this.getPortId(portInfo.type, portInfo.portID);
|
|
801
|
+
let portEntity = this.entity.entityManager.getEntityById(id);
|
|
802
|
+
if (!portEntity) {
|
|
803
|
+
portEntity = this.entity.entityManager.createEntity(WorkflowPortEntity, {
|
|
804
|
+
id,
|
|
805
|
+
node: this.entity,
|
|
806
|
+
...portInfo
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
portEntity.onDispose(() => {
|
|
810
|
+
this._portIDSet.delete(id);
|
|
811
|
+
});
|
|
812
|
+
this._portIDSet.add(id);
|
|
813
|
+
return portEntity;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* 获取或创建 port 实体
|
|
817
|
+
*/
|
|
818
|
+
getOrCreatePortEntity(portInfo) {
|
|
819
|
+
const id = this.getPortId(portInfo.type, portInfo.portID);
|
|
820
|
+
return this.getPortEntity(id) ?? this.createPortEntity(portInfo);
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* 更新 port 实体
|
|
824
|
+
*/
|
|
825
|
+
updatePortEntity(portInfo) {
|
|
826
|
+
const portEntity = this.getOrCreatePortEntity(portInfo);
|
|
827
|
+
if (portInfo.targetElement) {
|
|
828
|
+
portEntity.updateTargetElement(portInfo.targetElement);
|
|
829
|
+
}
|
|
830
|
+
return portEntity;
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
WorkflowNodePortsData.type = "WorkflowNodePortsData";
|
|
834
|
+
|
|
835
|
+
// src/entities/workflow-line-entity.ts
|
|
836
|
+
var LINE_HOVER_DISTANCE = 8;
|
|
837
|
+
var POINT_RADIUS = 10;
|
|
838
|
+
var _WorkflowLineEntity = class _WorkflowLineEntity extends import_core6.Entity {
|
|
839
|
+
constructor(opts) {
|
|
840
|
+
super(opts);
|
|
841
|
+
this._processing = false;
|
|
842
|
+
this._hasError = false;
|
|
843
|
+
/**
|
|
844
|
+
* 线条数据
|
|
845
|
+
*/
|
|
846
|
+
this.info = {
|
|
847
|
+
from: ""
|
|
848
|
+
};
|
|
849
|
+
/**
|
|
850
|
+
* 贝塞尔线条版本
|
|
851
|
+
*/
|
|
852
|
+
this._bezierVersion = "";
|
|
853
|
+
this.document = opts.document;
|
|
854
|
+
this.linesManager = opts.linesManager;
|
|
855
|
+
this.initInfo({
|
|
856
|
+
from: opts.from,
|
|
857
|
+
to: opts.to,
|
|
858
|
+
drawingTo: opts.drawingTo,
|
|
859
|
+
fromPort: opts.fromPort,
|
|
860
|
+
toPort: opts.toPort
|
|
861
|
+
});
|
|
862
|
+
if (opts.drawingTo) {
|
|
863
|
+
this.isDrawing = true;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* 转成线条 id
|
|
868
|
+
* @param info
|
|
869
|
+
*/
|
|
870
|
+
static portInfoToLineId(info) {
|
|
871
|
+
const { from, to, fromPort, toPort } = info;
|
|
872
|
+
return `${from}_${fromPort || ""}-${to || ""}_${toPort || ""}`;
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* 获取线条的前置节点
|
|
876
|
+
*/
|
|
877
|
+
get from() {
|
|
878
|
+
return this._from;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* 获取线条的后置节点
|
|
882
|
+
*/
|
|
883
|
+
get to() {
|
|
884
|
+
return this._to;
|
|
885
|
+
}
|
|
886
|
+
get isHidden() {
|
|
887
|
+
return this.highlightColor === this.linesManager.lineColor.hidden;
|
|
888
|
+
}
|
|
889
|
+
get inContainer() {
|
|
890
|
+
const nodeInContainer = (node) => !!node?.parent && node.parent.flowNodeType !== "root";
|
|
891
|
+
return nodeInContainer(this.from) || nodeInContainer(this.to);
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* 获取是否 testrun processing
|
|
895
|
+
*/
|
|
896
|
+
get processing() {
|
|
897
|
+
return this._processing;
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* 设置 testrun processing 状态
|
|
901
|
+
*/
|
|
902
|
+
set processing(status) {
|
|
903
|
+
if (this._processing !== status) {
|
|
904
|
+
this._processing = status;
|
|
905
|
+
this.fireChange();
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
// 获取连线是否为错误态
|
|
909
|
+
get hasError() {
|
|
910
|
+
return this._hasError;
|
|
911
|
+
}
|
|
912
|
+
// 设置连线的错误态
|
|
913
|
+
set hasError(hasError) {
|
|
914
|
+
if (this._hasError !== hasError) {
|
|
915
|
+
this._hasError = hasError;
|
|
916
|
+
this.fireChange();
|
|
917
|
+
}
|
|
918
|
+
if (this._node) {
|
|
919
|
+
this._node.dataset.hasError = this.hasError ? "true" : "false";
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* 设置线条的后置节点
|
|
924
|
+
*/
|
|
925
|
+
setToPort(toPort) {
|
|
926
|
+
if (!this.isDrawing) {
|
|
927
|
+
throw new Error("[setToPort] only support drawing line.");
|
|
928
|
+
}
|
|
929
|
+
if (this.toPort === toPort) {
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
if (toPort && toPort.portType === "input" && this.linesManager.canAddLine(this.fromPort, toPort, true)) {
|
|
933
|
+
const { node, portID } = toPort;
|
|
934
|
+
this._to = node;
|
|
935
|
+
this.info.drawingTo = void 0;
|
|
936
|
+
this.info.isDefaultLine = false;
|
|
937
|
+
this.info.to = node.id;
|
|
938
|
+
this.info.toPort = portID;
|
|
939
|
+
} else {
|
|
940
|
+
this._to = void 0;
|
|
941
|
+
this.info.to = void 0;
|
|
942
|
+
this.info.toPort = "";
|
|
943
|
+
}
|
|
944
|
+
this.fireChange();
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* 设置线条画线时的目标位置
|
|
948
|
+
*/
|
|
949
|
+
set drawingTo(pos) {
|
|
950
|
+
const oldDrawingTo = this.info.drawingTo;
|
|
951
|
+
if (!pos) {
|
|
952
|
+
this.info.drawingTo = void 0;
|
|
953
|
+
this.fireChange();
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
if (!oldDrawingTo || pos.x !== oldDrawingTo.x || pos.y !== oldDrawingTo.y) {
|
|
957
|
+
this.info.to = void 0;
|
|
958
|
+
this.info.isDefaultLine = false;
|
|
959
|
+
this.info.drawingTo = pos;
|
|
960
|
+
this.fireChange();
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* 获取线条正在画线的位置
|
|
965
|
+
*/
|
|
966
|
+
get drawingTo() {
|
|
967
|
+
return this.info.drawingTo;
|
|
968
|
+
}
|
|
969
|
+
get highlightColor() {
|
|
970
|
+
return this.info.highlightColor || "";
|
|
971
|
+
}
|
|
972
|
+
set highlightColor(color) {
|
|
973
|
+
if (this.info.highlightColor !== color) {
|
|
974
|
+
this.info.highlightColor = color;
|
|
975
|
+
this.fireChange();
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* 创建贝塞尔线条
|
|
980
|
+
* @param fromPos 前置节点位置
|
|
981
|
+
* @param toPos 后置节点位置
|
|
982
|
+
* @returns 贝塞尔线条数据
|
|
983
|
+
*/
|
|
984
|
+
createBezier(fromPos, toPos) {
|
|
985
|
+
const controls = this.vertical ? getBezierVerticalControlPoints(fromPos, toPos) : getBezierHorizontalControlPoints(fromPos, toPos);
|
|
986
|
+
const bezier = new import_bezier_js.Bezier([fromPos, ...controls, toPos]);
|
|
987
|
+
const bbox = bezier.bbox();
|
|
988
|
+
const bboxBounds = new import_utils8.Rectangle(
|
|
989
|
+
bbox.x.min,
|
|
990
|
+
bbox.y.min,
|
|
991
|
+
bbox.x.max - bbox.x.min,
|
|
992
|
+
bbox.y.max - bbox.y.min
|
|
993
|
+
);
|
|
994
|
+
const foldPoints = FoldLine.getPoints({
|
|
995
|
+
source: {
|
|
996
|
+
x: fromPos.x + POINT_RADIUS,
|
|
997
|
+
y: fromPos.y
|
|
998
|
+
},
|
|
999
|
+
target: {
|
|
1000
|
+
x: toPos.x - POINT_RADIUS,
|
|
1001
|
+
y: toPos.y
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
1004
|
+
const foldPath = FoldLine.getSmoothStepPath(foldPoints);
|
|
1005
|
+
this._bezier = {
|
|
1006
|
+
fromPos,
|
|
1007
|
+
toPos,
|
|
1008
|
+
bezier,
|
|
1009
|
+
bbox: bboxBounds,
|
|
1010
|
+
controls,
|
|
1011
|
+
foldPath,
|
|
1012
|
+
foldPoints,
|
|
1013
|
+
foldBounds: FoldLine.getBounds(foldPoints)
|
|
1014
|
+
};
|
|
1015
|
+
return this._bezier;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* 获取线条的边框位置大小
|
|
1019
|
+
*/
|
|
1020
|
+
get bounds() {
|
|
1021
|
+
return this.bezier.bbox;
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* 获取点和线最接近的距离
|
|
1025
|
+
*/
|
|
1026
|
+
getHoverDist(pos, lineType = 0 /* BEZIER */) {
|
|
1027
|
+
if (lineType === 0 /* BEZIER */) {
|
|
1028
|
+
return import_utils8.Point.getDistance(pos, this.bezier.bezier.project(pos));
|
|
1029
|
+
}
|
|
1030
|
+
return FoldLine.getFoldLineToPointDistance(this.bezier.foldPoints, pos);
|
|
1031
|
+
}
|
|
1032
|
+
get fromPort() {
|
|
1033
|
+
return this.from.getData(WorkflowNodePortsData).getPortEntityByKey("output", this.info.fromPort);
|
|
1034
|
+
}
|
|
1035
|
+
get toPort() {
|
|
1036
|
+
if (!this.to) {
|
|
1037
|
+
return void 0;
|
|
1038
|
+
}
|
|
1039
|
+
return this.to.getData(WorkflowNodePortsData).getPortEntityByKey("input", this.info.toPort);
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* 获取线条真实的输入输出节点坐标
|
|
1043
|
+
*/
|
|
1044
|
+
get position() {
|
|
1045
|
+
const { bezier } = this;
|
|
1046
|
+
return {
|
|
1047
|
+
from: bezier.fromPos,
|
|
1048
|
+
to: bezier.toPos
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* 获取贝塞尔数据
|
|
1053
|
+
* 根据两边节点的位置信息创建贝塞尔曲线
|
|
1054
|
+
*/
|
|
1055
|
+
get bezier() {
|
|
1056
|
+
if (!this._bezier) {
|
|
1057
|
+
this.refreshBezier();
|
|
1058
|
+
}
|
|
1059
|
+
return this._bezier;
|
|
1060
|
+
}
|
|
1061
|
+
refreshBezier() {
|
|
1062
|
+
const fromPos = this.from.getData(WorkflowNodePortsData).getOutputPoint(this.info.fromPort);
|
|
1063
|
+
const toPos = this.info.drawingTo || this.to.getData(WorkflowNodePortsData).getInputPoint(this.info.toPort);
|
|
1064
|
+
const bezierVersion = [fromPos.x, fromPos.y, toPos.x, toPos.y].join("-");
|
|
1065
|
+
if (this._bezier && this._bezierVersion === bezierVersion) {
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
this._bezierVersion = bezierVersion;
|
|
1069
|
+
this._bezier = this.createBezier(fromPos, toPos);
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* 可以用于判断线条点位信息是否变化
|
|
1073
|
+
*/
|
|
1074
|
+
get bezierDataVersion() {
|
|
1075
|
+
return this._bezierVersion;
|
|
1076
|
+
}
|
|
1077
|
+
/** 是否反转箭头 */
|
|
1078
|
+
get reverse() {
|
|
1079
|
+
return this.linesManager.isReverseLine(this);
|
|
1080
|
+
}
|
|
1081
|
+
/** 是否隐藏箭头 */
|
|
1082
|
+
get hideArrow() {
|
|
1083
|
+
return this.linesManager.isHideArrowLine(this);
|
|
1084
|
+
}
|
|
1085
|
+
/** 是否流动 */
|
|
1086
|
+
get flowing() {
|
|
1087
|
+
return this.linesManager.isFlowingLine(this);
|
|
1088
|
+
}
|
|
1089
|
+
/** 是否禁用 */
|
|
1090
|
+
get disabled() {
|
|
1091
|
+
return this.linesManager.isDisabledLine(this);
|
|
1092
|
+
}
|
|
1093
|
+
/** 是否竖向 */
|
|
1094
|
+
get vertical() {
|
|
1095
|
+
return this.linesManager.isVerticalLine(this);
|
|
1096
|
+
}
|
|
1097
|
+
get color() {
|
|
1098
|
+
return this.linesManager.getLineColor(this);
|
|
1099
|
+
}
|
|
1100
|
+
// get defaultToPos(): IPoint {
|
|
1101
|
+
// const fromPos = this.from.getData(TransformComponent)!.toBounds.center;
|
|
1102
|
+
//
|
|
1103
|
+
// return {
|
|
1104
|
+
// x: fromPos.x + DEFAULT_LINE_LENGTH,
|
|
1105
|
+
// y: fromPos.y,
|
|
1106
|
+
// };
|
|
1107
|
+
// }
|
|
1108
|
+
/**
|
|
1109
|
+
* 初始化线条
|
|
1110
|
+
* @param info 线条信息
|
|
1111
|
+
*/
|
|
1112
|
+
initInfo(info) {
|
|
1113
|
+
if (!(0, import_lodash_es2.isEqual)(info, this.info)) {
|
|
1114
|
+
this.info = info;
|
|
1115
|
+
this._from = this.document.getNode(info.from);
|
|
1116
|
+
this._to = info.to ? this.document.getNode(info.to) : void 0;
|
|
1117
|
+
this.fireChange();
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
// 校验连线是否为错误态
|
|
1121
|
+
validate() {
|
|
1122
|
+
const { fromPort, toPort } = this;
|
|
1123
|
+
this.validateSelf();
|
|
1124
|
+
fromPort?.validate();
|
|
1125
|
+
toPort?.validate();
|
|
1126
|
+
}
|
|
1127
|
+
validateSelf() {
|
|
1128
|
+
const { fromPort, toPort } = this;
|
|
1129
|
+
if (fromPort) {
|
|
1130
|
+
this.hasError = this.linesManager.isErrorLine(fromPort, toPort);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
is(line) {
|
|
1134
|
+
if (line instanceof _WorkflowLineEntity) {
|
|
1135
|
+
return this === line;
|
|
1136
|
+
}
|
|
1137
|
+
return _WorkflowLineEntity.portInfoToLineId(line) === this.id;
|
|
1138
|
+
}
|
|
1139
|
+
/**
|
|
1140
|
+
* 框选 贝塞尔曲线
|
|
1141
|
+
* TODO 这个方法可能有性能问题,后续看看有没有更好的方式
|
|
1142
|
+
* @param rect
|
|
1143
|
+
*/
|
|
1144
|
+
intersectsRectangle(rect) {
|
|
1145
|
+
const dots = this.bezier.bezier.getLUT(50);
|
|
1146
|
+
return dots.some((dot) => rect.contains(dot.x, dot.y));
|
|
1147
|
+
}
|
|
1148
|
+
canRemove(newLineInfo) {
|
|
1149
|
+
return this.linesManager.canRemove(this, newLineInfo);
|
|
1150
|
+
}
|
|
1151
|
+
get node() {
|
|
1152
|
+
if (this._node) return this._node;
|
|
1153
|
+
this._node = import_utils8.domUtils.createDivWithClass("gedit-flow-activity-line");
|
|
1154
|
+
this._node.dataset.testid = "sdk.workflow.canvas.line";
|
|
1155
|
+
this._node.dataset.lineId = this.id;
|
|
1156
|
+
this._node.dataset.fromNodeId = this.from.id;
|
|
1157
|
+
this._node.dataset.fromPortId = this.fromPort?.id ?? "";
|
|
1158
|
+
this._node.dataset.toNodeId = this.to?.id ?? "";
|
|
1159
|
+
this._node.dataset.toPortId = this.toPort?.id ?? "";
|
|
1160
|
+
this._node.dataset.hasError = this.hasError ? "true" : "false";
|
|
1161
|
+
return this._node;
|
|
1162
|
+
}
|
|
1163
|
+
toJSON() {
|
|
1164
|
+
const json = {
|
|
1165
|
+
sourceNodeID: this.info.from,
|
|
1166
|
+
targetNodeID: this.info.to,
|
|
1167
|
+
sourcePortID: this.info.fromPort,
|
|
1168
|
+
targetPortID: this.info.toPort
|
|
1169
|
+
};
|
|
1170
|
+
if (!json.sourcePortID) {
|
|
1171
|
+
delete json.sourcePortID;
|
|
1172
|
+
}
|
|
1173
|
+
if (!json.targetPortID) {
|
|
1174
|
+
delete json.targetPortID;
|
|
1175
|
+
}
|
|
1176
|
+
return json;
|
|
1177
|
+
}
|
|
1178
|
+
/** 触发线条渲染 */
|
|
1179
|
+
fireRender() {
|
|
1180
|
+
this.fireChange();
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1183
|
+
_WorkflowLineEntity.type = WORKFLOW_LINE_ENTITY;
|
|
1184
|
+
var WorkflowLineEntity = _WorkflowLineEntity;
|
|
1185
|
+
|
|
1186
|
+
// src/service/workflow-select-service.ts
|
|
1187
|
+
var WorkflowSelectService = class {
|
|
1188
|
+
get onSelectionChanged() {
|
|
1189
|
+
return this.selectionService.onSelectionChanged;
|
|
1190
|
+
}
|
|
1191
|
+
get selection() {
|
|
1192
|
+
return this.selectionService.selection;
|
|
1193
|
+
}
|
|
1194
|
+
set selection(entities) {
|
|
1195
|
+
this.selectionService.selection = entities;
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* 当前激活的节点只能有一个
|
|
1199
|
+
*/
|
|
1200
|
+
get activatedNode() {
|
|
1201
|
+
const { selectedNodes } = this;
|
|
1202
|
+
if (selectedNodes.length !== 1) {
|
|
1203
|
+
return void 0;
|
|
1204
|
+
}
|
|
1205
|
+
return selectedNodes[0];
|
|
1206
|
+
}
|
|
1207
|
+
isSelected(id) {
|
|
1208
|
+
return this.selectionService.selection.some((s) => s.id === id);
|
|
1209
|
+
}
|
|
1210
|
+
isActivated(id) {
|
|
1211
|
+
return this.activatedNode?.id === id;
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* 选中的节点
|
|
1215
|
+
*/
|
|
1216
|
+
get selectedNodes() {
|
|
1217
|
+
return this.selectionService.selection.filter(
|
|
1218
|
+
(n) => n instanceof WorkflowNodeEntity
|
|
1219
|
+
);
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* 选中
|
|
1223
|
+
* @param node
|
|
1224
|
+
*/
|
|
1225
|
+
selectNode(node) {
|
|
1226
|
+
this.selectionService.selection = [node];
|
|
1227
|
+
}
|
|
1228
|
+
toggleSelect(node) {
|
|
1229
|
+
if (this.selectionService.selection.includes(node)) {
|
|
1230
|
+
this.selectionService.selection = this.selectionService.selection.filter((n) => n !== node);
|
|
1231
|
+
} else {
|
|
1232
|
+
this.selectionService.selection = this.selectionService.selection.concat(node);
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
select(node) {
|
|
1236
|
+
this.selectionService.selection = [node];
|
|
1237
|
+
}
|
|
1238
|
+
clear() {
|
|
1239
|
+
this.selectionService.selection = [];
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* 选中并滚动到节点
|
|
1243
|
+
* @param node
|
|
1244
|
+
*/
|
|
1245
|
+
async selectNodeAndScrollToView(node, fitView2) {
|
|
1246
|
+
this.selectNodeAndFocus(node);
|
|
1247
|
+
const DELAY_TIME = 30;
|
|
1248
|
+
await (0, import_utils6.delay)(DELAY_TIME);
|
|
1249
|
+
const scrollConfig = {
|
|
1250
|
+
entities: [node]
|
|
1251
|
+
};
|
|
1252
|
+
if (fitView2) {
|
|
1253
|
+
const bounds = import_utils9.Rectangle.enlarge([node.getData(import_core7.TransformData).bounds]).pad(
|
|
1254
|
+
30,
|
|
1255
|
+
30
|
|
1256
|
+
);
|
|
1257
|
+
const viewport = this.playground.config.getViewport(false);
|
|
1258
|
+
const zoom = import_utils9.SizeSchema.fixSize(bounds, viewport);
|
|
1259
|
+
scrollConfig.zoom = zoom;
|
|
1260
|
+
scrollConfig.scrollToCenter = true;
|
|
1261
|
+
scrollConfig.easing = true;
|
|
1262
|
+
}
|
|
1263
|
+
return this.playground.config.scrollToView(scrollConfig);
|
|
1264
|
+
}
|
|
1265
|
+
selectNodeAndFocus(node) {
|
|
1266
|
+
this.select(node);
|
|
1267
|
+
this.playground.node.focus();
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
__decorateClass([
|
|
1271
|
+
(0, import_inversify.inject)(import_core7.SelectionService)
|
|
1272
|
+
], WorkflowSelectService.prototype, "selectionService", 2);
|
|
1273
|
+
__decorateClass([
|
|
1274
|
+
(0, import_inversify.inject)(import_core7.Playground)
|
|
1275
|
+
], WorkflowSelectService.prototype, "playground", 2);
|
|
1276
|
+
WorkflowSelectService = __decorateClass([
|
|
1277
|
+
(0, import_inversify.injectable)()
|
|
1278
|
+
], WorkflowSelectService);
|
|
1279
|
+
|
|
1280
|
+
// src/service/workflow-hover-service.ts
|
|
1281
|
+
var import_inversify2 = require("inversify");
|
|
1282
|
+
var import_core8 = require("@flowgram.ai/core");
|
|
1283
|
+
var import_utils11 = require("@flowgram.ai/utils");
|
|
1284
|
+
var WorkflowHoverService = class {
|
|
1285
|
+
constructor() {
|
|
1286
|
+
this.onHoveredChangeEmitter = new import_utils11.Emitter();
|
|
1287
|
+
this.onHoveredChange = this.onHoveredChangeEmitter.event;
|
|
1288
|
+
// 当前鼠标 hover 位置
|
|
1289
|
+
this.hoveredPos = { x: 0, y: 0 };
|
|
1290
|
+
/**
|
|
1291
|
+
* 当前 hovered 的 节点或者线条或者点
|
|
1292
|
+
* 1: nodeId / lineId (节点 / 线条)
|
|
1293
|
+
* 2: nodeId:portKey (节点连接点)
|
|
1294
|
+
*/
|
|
1295
|
+
this.hoveredKey = "";
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* 更新 hover 的内容
|
|
1299
|
+
* @param hoveredKey hovered key
|
|
1300
|
+
*/
|
|
1301
|
+
updateHoveredKey(hoveredKey) {
|
|
1302
|
+
if (this.hoveredKey !== hoveredKey) {
|
|
1303
|
+
this.hoveredKey = hoveredKey;
|
|
1304
|
+
this.onHoveredChangeEmitter.fire(hoveredKey);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* 清空 hover 内容
|
|
1309
|
+
*/
|
|
1310
|
+
clearHovered() {
|
|
1311
|
+
this.updateHoveredKey("");
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* 判断是否 hover
|
|
1315
|
+
* @param nodeId hoveredKey
|
|
1316
|
+
* @returns 是否 hover
|
|
1317
|
+
*/
|
|
1318
|
+
isHovered(nodeId) {
|
|
1319
|
+
return nodeId === this.hoveredKey;
|
|
1320
|
+
}
|
|
1321
|
+
isSomeHovered() {
|
|
1322
|
+
return !!this.hoveredKey;
|
|
1323
|
+
}
|
|
1324
|
+
/**
|
|
1325
|
+
* 获取被 hover 的节点或线条
|
|
1326
|
+
*/
|
|
1327
|
+
get hoveredNode() {
|
|
1328
|
+
return this.entityManager.getEntityById(this.hoveredKey);
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
__decorateClass([
|
|
1332
|
+
(0, import_inversify2.inject)(import_core8.EntityManager)
|
|
1333
|
+
], WorkflowHoverService.prototype, "entityManager", 2);
|
|
1334
|
+
WorkflowHoverService = __decorateClass([
|
|
1335
|
+
(0, import_inversify2.injectable)()
|
|
1336
|
+
], WorkflowHoverService);
|
|
1337
|
+
|
|
1338
|
+
// src/service/workflow-drag-service.ts
|
|
1339
|
+
var import_nanoid3 = require("nanoid");
|
|
1340
|
+
var import_inversify6 = require("inversify");
|
|
1341
|
+
var import_utils17 = require("@flowgram.ai/utils");
|
|
1342
|
+
var import_document7 = require("@flowgram.ai/document");
|
|
1343
|
+
var import_document8 = require("@flowgram.ai/document");
|
|
1344
|
+
var import_core14 = require("@flowgram.ai/core");
|
|
1345
|
+
|
|
1346
|
+
// src/workflow-lines-manager.ts
|
|
1347
|
+
var import_lodash_es3 = require("lodash-es");
|
|
1348
|
+
var import_inversify3 = require("inversify");
|
|
1349
|
+
var import_utils13 = require("@flowgram.ai/utils");
|
|
1350
|
+
var import_document4 = require("@flowgram.ai/document");
|
|
1351
|
+
var import_core11 = require("@flowgram.ai/core");
|
|
1352
|
+
|
|
1353
|
+
// src/workflow-document-option.ts
|
|
1354
|
+
var import_form_core2 = require("@flowgram.ai/form-core");
|
|
1355
|
+
var import_document3 = require("@flowgram.ai/document");
|
|
1356
|
+
var import_core9 = require("@flowgram.ai/core");
|
|
1357
|
+
|
|
1358
|
+
// src/utils/flow-node-form-data.ts
|
|
1359
|
+
var import_form_core = require("@flowgram.ai/form-core");
|
|
1360
|
+
function getFlowNodeFormData(node) {
|
|
1361
|
+
return node.getData(import_form_core.FlowNodeFormData);
|
|
1362
|
+
}
|
|
1363
|
+
function toFormJSON(node) {
|
|
1364
|
+
const formData = node.getData(import_form_core.FlowNodeFormData);
|
|
1365
|
+
if (!formData || !node.getNodeRegistry().formMeta) return void 0;
|
|
1366
|
+
return formData.toJSON();
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
// src/workflow-document-option.ts
|
|
1370
|
+
var WorkflowDocumentOptions = Symbol("WorkflowDocumentOptions");
|
|
1371
|
+
var WorkflowDocumentOptionsDefault = {
|
|
1372
|
+
cursors: {
|
|
1373
|
+
grab: 'url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMCAyMSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMC40ODczIDIuNjIzNzhDOS45MDczMSAyLjYyMzc4IDkuNDM3MTMgMy4wOTM5NiA5LjQzNzEzIDMuNjczOTZWNS4xNDM3NkM5LjM5NDI4IDQuNDAyNzQgOC43Nzk3OCAzLjgxNTA0IDguMDI4MDIgMy44MTUwNEM3LjI0ODQ4IDMuODE1MDQgNi42MTY1MyA0LjQ0Njk5IDYuNjE2NTMgNS4yMjY1M1YxMS44Mjg5TDUuNjc0MTggMTEuMDA0OUM1LjE1NDg3IDEwLjU1MDkgNC40MDk1IDEwLjQ2MzYgMy43OTkzOCAxMC43ODU1TDMuNjk2OTQgMTAuODM5NkMzLjA2MjE3IDExLjE3NDUgMi45MjI2IDEyLjAyMjggMy40MTY2MiAxMi41NDM0TDcuMzM5NTkgMTYuNjc3NVYxNy4zMjU5QzcuMzM5NTkgMTcuNzg2MiA3LjcxMjY5IDE4LjE1OTMgOC4xNzI5MiAxOC4xNTkzSDEzLjgwODRDMTQuMjY4NyAxOC4xNTkzIDE0LjY0MTcgMTcuNzg2MiAxNC42NDE3IDE3LjMyNTlWMTYuNzkzNUMxNS44MDk0IDE1LjY0ODUgMTYuNDY3MyAxNC4wODE5IDE2LjQ2NzMgMTIuNDQ2NVYxMS40OTY3TDE2LjQ2NzEgNi42MzY4NUMxNi40NjcxIDUuOTU2MyAxNS45MTU0IDUuNDA0NjEgMTUuMjM0OCA1LjQwNDYxQzE0LjU1NDMgNS40MDQ2MSAxNC4wMDI2IDUuOTU2MyAxNC4wMDI2IDYuNjM2ODVMMTQuMDAyMSA1LjA0NzI4QzE0LjAwMjEgNC4zNjY3MyAxMy40NTA0IDMuODE1MDQgMTIuNzY5OCAzLjgxNTA0QzEyLjA4OTMgMy44MTUwNCAxMS41Mzc2IDQuMzY2NzMgMTEuNTM3NiA1LjA0NzI4TDExLjUzNzUgMy42NzM5NUMxMS41Mzc1IDMuMDkzOTYgMTEuMDY3MyAyLjYyMzc4IDEwLjQ4NzMgMi42MjM3OFoiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMTAuNDg3NCAxLjM3NDAyQzExLjM2MTIgMS4zNzQwMiAxMi4xMjExIDEuODYxMTggMTIuNTEwNSAyLjU3ODY4QzEyLjU5NTggMi41Njk4MyAxMi42ODIzIDIuNTY1MjggMTIuNzcgMi41NjUyOEMxMy44Mjc4IDIuNTY1MjggMTQuNzMxMSAzLjIyNzAxIDE1LjA4ODUgNC4xNTkxMUMxNS4xMzcgNC4xNTYyOSAxNS4xODU4IDQuMTU0ODYgMTUuMjM1IDQuMTU0ODZDMTYuNjA1OSA0LjE1NDg2IDE3LjcxNzIgNS4yNjYxOSAxNy43MTcyIDYuNjM3MDlMMTcuNzE3NCAxMi40NDY3QzE3LjcxNzQgMTQuMjM1NSAxNy4wNjQ0IDE1Ljk1NTkgMTUuODkxOSAxNy4yOTA0VjE3LjMyNjJDMTUuODkxOSAxOC40NzY4IDE0Ljk1OTEgMTkuNDA5NSAxMy44MDg1IDE5LjQwOTVIOC4xNzMwNkM3LjAyMjQ3IDE5LjQwOTUgNi4wODk3MyAxOC40NzY4IDYuMDg5NzMgMTcuMzI2MlYxNy4xNzY0TDIuNTEwMDMgMTMuNDA0MUMxLjQ0NTk5IDEyLjI4MjggMS43NDY2IDEwLjQ1NTUgMy4xMTM3OSA5LjczNDI0TDMuMjE2MjQgOS42ODAxOUMzLjg5MTY4IDkuMzIzODMgNC42NjE4NSA5LjI1NDAxIDUuMzY2NjYgOS40NTE5OFY1LjIyNjc4QzUuMzY2NjYgMy43NTY4NyA2LjU1ODI2IDIuNTY1MjggOC4wMjgxNiAyLjU2NTI4QzguMTcyOTMgMi41NjUyOCA4LjMxNDk5IDIuNTc2ODQgOC40NTM0NyAyLjU5OTA3QzguODM5NDMgMS44NzA0MiA5LjYwNTQ2IDEuMzc0MDIgMTAuNDg3NCAxLjM3NDAyWk0xMi40NDc2IDMuODU3ODdWOS40NzY0NkMxMi40NDc2IDkuNzI4NTIgMTIuMjQzMyA5LjkzMjg1IDExLjk5MTMgOS45MzI4NUMxMS43MzkyIDkuOTMyODUgMTEuNTM0OSA5LjcyODUyIDExLjUzNDkgOS40NzY0NlYzLjc5NjU1QzExLjUzNDkgMy43Nzk1NiAxMS41MzU4IDMuNzYyNzcgMTEuNTM3NiAzLjc0NjI2VjMuNjc0MkMxMS41Mzc2IDMuNDMyODIgMTEuNDU2MiAzLjIxMDQ2IDExLjMxOTMgMy4wMzMwOUMxMS4xMjcyIDIuNzg0MjggMTAuODI2MSAyLjYyNDAyIDEwLjQ4NzQgMi42MjQwMkMxMC4xMjM4IDIuNjI0MDIgOS44MDMzMiAyLjgwODg2IDkuNjE0ODMgMy4wODk3QzkuNTAyNjkgMy4yNTY3OSA5LjQzNzI2IDMuNDU3ODUgOS40MzcyNiAzLjY3NDJWMy43ODU3M0M5LjQzNzM1IDMuNzg5MzMgOS40MzczOSAzLjc5Mjk0IDkuNDM3MzkgMy43OTY1NVY5LjkwMTdDOS40MzczOSAxMC4xNTM3IDkuMjMzMDYgMTAuMzU4MSA4Ljk4MTAxIDEwLjM1ODFDOC43Mjg5NSAxMC4zNTgxIDguNTI0NjIgMTAuMTUzNyA4LjUyNDYyIDkuOTAxN1YzLjkwNTA3QzguNDE3NzMgMy44NjQ5IDguMzA0NjggMy44MzczMiA4LjE4NzI2IDMuODI0MTVDOC4xMzUwNCAzLjgxODI5IDguMDgxOTUgMy44MTUyOCA4LjAyODE2IDMuODE1MjhDNy4yNDg2MSAzLjgxNTI4IDYuNjE2NjYgNC40NDcyMyA2LjYxNjY2IDUuMjI2NzhWMTEuODI5Mkw1LjY3NDMxIDExLjAwNTJDNS41Nzg2OCAxMC45MjE2IDUuNDc1MzcgMTAuODUwNCA1LjM2NjY2IDEwLjc5MTlDNC44ODUwNiAxMC41MzI5IDQuMjk3MjggMTAuNTIzMSAzLjc5OTUyIDEwLjc4NThMMy42OTcwNyAxMC44Mzk4QzMuMDYyMzEgMTEuMTc0NyAyLjkyMjczIDEyLjAyMzEgMy40MTY3NSAxMi41NDM3TDcuMzM5NzMgMTYuNjc3N1YxNy4zMjYyQzcuMzM5NzMgMTcuNzg2NCA3LjcxMjgyIDE4LjE1OTUgOC4xNzMwNiAxOC4xNTk1SDEzLjgwODVDMTQuMjY4OCAxOC4xNTk1IDE0LjY0MTkgMTcuNzg2NCAxNC42NDE5IDE3LjMyNjJWMTYuNzkzOEMxNS43Mzc5IDE1LjcxOSAxNi4zODQ3IDE0LjI3MjggMTYuNDYgMTIuNzQ3QzE2LjQ2NDEgMTIuNjY0MSAxNi40NjY1IDEyLjU4MDkgMTYuNDY3MiAxMi40OTc1TDE2LjQ2NzQgMTIuNDQ2N0wxNi40NjcyIDYuNjM3MDlDMTYuNDY3MiA1Ljk2MjMgMTUuOTI0OCA1LjQxNDE5IDE1LjI1MjIgNS40MDQ5N0wxNS4yMzUgNS40MDQ4NkMxNS4xMjQ2IDUuNDA0ODYgMTUuMDE3NyA1LjQxOTM2IDE0LjkxNTkgNS40NDY1NlY5LjYwMjI2QzE0LjkxNTkgOS44NTQzMSAxNC43MTE2IDEwLjA1ODYgMTQuNDU5NSAxMC4wNTg2QzE0LjIwNzUgMTAuMDU4NiAxNC4wMDMxIDkuODU0MzEgMTQuMDAzMSA5LjYwMjI2VjYuNjA1MTRDMTQuMDAyOSA2LjYxNTc2IDE0LjAwMjcgNi42MjY0MSAxNC4wMDI3IDYuNjM3MDlWOS4yNzcwNUwxNC4wMDIyIDUuMDQ3NTJDMTQuMDAyMiA0Ljg2OTEzIDEzLjk2NDMgNC42OTk2IDEzLjg5NjEgNC41NDY1M0MxMy43MDY0IDQuMTIwNzIgMTMuMjgyMiAzLjgyMjM1IDEyLjc4NzYgMy44MTU0MUwxMi43NyAzLjgxNTI4QzEyLjY1ODQgMy44MTUyOCAxMi41NTA0IDMuODMwMSAxMi40NDc2IDMuODU3ODdaIiBmaWxsPSIjMUQxQzIzIi8+Cjwvc3ZnPg=="), auto',
|
|
1374
|
+
grabbing: 'url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMCAyMSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik02LjYxODE3IDUuNTk4NzVDNi42MTgxNyA0LjgxOTIgNy4yNTAxMiA0LjE4NzI2IDguMDI5NjcgNC4xODcyNkM4Ljc3ODczIDQuMTg3MjYgOS4zOTE1MiA0Ljc3MDc1IDkuNDM4MjkgNS41MDgwMUM5LjQ1OTkyIDQuOTQ3MSA5LjkyMTQ3IDQuNDk5MDIgMTAuNDg3NyA0LjQ5OTAyQzExLjA2NzcgNC40OTkwMiAxMS41Mzc4IDQuOTY5MiAxMS41Mzc4IDUuNTQ5MTlWOC43NjI0NkwxMS41Mzc5IDYuNzExNUMxMS41Mzc5IDYuMDMwOTUgMTIuMDg5NiA1LjQ3OTI2IDEyLjc3MDIgNS40NzkyNkMxMy40NTA3IDUuNDc5MjYgMTQuMDAyNCA2LjAzMDk1IDE0LjAwMjQgNi43MTE1TDE0LjAwMjQgOC43NjI0NkwxNC4wMDI5IDguMDE5ODNDMTQuMDAyOSA3LjMzOTI5IDE0LjU1NDYgNi43ODc1OSAxNS4yMzUyIDYuNzg3NTlDMTUuOTE1NyA2Ljc4NzU5IDE2LjQ2NzQgNy4zMzkyOCAxNi40Njc0IDguMDE5ODNWMTEuNDk3TDE2LjQ2NzUgMTIuNDQ2N0MxNi40Njc1IDE0LjA4MjEgMTUuODA5NiAxNS42NDg3IDE0LjY0MiAxNi43OTM4VjE3LjMyNjJDMTQuNjQyIDE3Ljc4NjQgMTQuMjY4OSAxOC4xNTk1IDEzLjgwODcgMTguMTU5NUg4LjE3MzE3QzcuNzEyOTMgMTguMTU5NSA3LjMzOTg0IDE3Ljc4NjQgNy4zMzk4NCAxNy4zMjYyVjE1Ljk0MjRMNS4zNDU2MiAxNC43NTM0QzQuNTg5MjQgMTQuMzAyNCA0LjEyNTkxIDEzLjQ4NjcgNC4xMjU4OSAxMi42MDYxTDQuMTI1ODMgOS4yODM4M0M0LjEyNTgyIDguOTU0MjcgNC4zMjAwMyA4LjY1NTY2IDQuNjIxMjkgOC41MjIwNUw2LjYxODE3IDcuNjM2MzRWNS41OTg3NVoiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMTAuNDg3OCAzLjI0OTAyQzExLjI3OTYgMy4yNDkwMiAxMS45Nzc4IDMuNjQ5MDIgMTIuMzkxNyA0LjI1Nzk2QzEyLjUxNTEgNC4yMzkwNiAxMi42NDE2IDQuMjI5MjYgMTIuNzcwMyA0LjIyOTI2QzEzLjcyMjQgNC4yMjkyNiAxNC41NDkzIDQuNzY1MzEgMTQuOTY1NyA1LjU1MjA3QzE1LjA1NDMgNS41NDI1IDE1LjE0NDIgNS41Mzc1OSAxNS4yMzUzIDUuNTM3NTlDMTYuNjA2MiA1LjUzNzU5IDE3LjcxNzYgNi42NDg5MyAxNy43MTc2IDguMDE5ODNMMTcuNzE3NyAxMi40NDY3QzE3LjcxNzcgMTQuMjM1NSAxNy4wNjQ3IDE1Ljk1NTkgMTUuODkyMSAxNy4yOTA0VjE3LjMyNjJDMTUuODkyMSAxOC40NzY4IDE0Ljk1OTQgMTkuNDA5NSAxMy44MDg4IDE5LjQwOTVIOC4xNzMzMkM3LjAyMjczIDE5LjQwOTUgNi4wODk5OCAxOC40NzY4IDYuMDg5OTggMTcuMzI2MlYxNi42NTI0TDQuNzA1NjMgMTUuODI3QzMuNTcxMDYgMTUuMTUwNSAyLjg3NjA3IDEzLjkyNzEgMi44NzYwNCAxMi42MDYxTDIuODc1OTggOS4yODM4NUMyLjg3NTk2IDguNDU5OTYgMy4zNjE0OSA3LjcxMzQ1IDQuMTE0NjIgNy4zNzk0TDUuMzY4MzIgNi44MjMzM1Y1LjU5ODc1QzUuMzY4MzIgNC4xMjg4NSA2LjU1OTkxIDIuOTM3MjYgOC4wMjk4MiAyLjkzNzI2QzguNjA4MzEgMi45MzcyNiA5LjE0MzU1IDMuMTIxNyA5LjU4MDA1IDMuNDM1MDVDOS44NTg1MyAzLjMxNTMyIDEwLjE2NTQgMy4yNDkwMiAxMC40ODc4IDMuMjQ5MDJaTTEyLjQ0NzkgNS41MjE4NlY5LjQ3NTU3QzEyLjQ0NzkgOS43Mjc2MiAxMi4yNDM2IDkuOTMxOTUgMTEuOTkxNiA5LjkzMTk1QzExLjc1NjggOS45MzE5NSAxMS41NjM0IDkuNzU0NjUgMTEuNTM4IDkuNTI2NjNDMTEuNTM2MSA5LjUwOTg3IDExLjUzNTIgOS40OTI4MyAxMS41MzUyIDkuNDc1NTdWNS40NzE1OEMxMS41MTU0IDUuMjAwODMgMTEuMzkzIDQuOTU4NTggMTEuMjA2NiA0Ljc4MzU4QzExLjAxODggNC42MDcxMSAxMC43NjU5IDQuNDk5MDIgMTAuNDg3OCA0LjQ5OTAyQzEwLjQ3NjYgNC40OTkwMiAxMC40NjU0IDQuNDk5MTkgMTAuNDU0MiA0LjQ5OTU0QzkuOTAzNDcgNC41MTY4NCA5LjQ1OTY0IDQuOTU4MjQgOS40Mzg0NCA1LjUwODAxQzkuNDM4MiA1LjUwNDMgOS40Mzc5NSA1LjUwMDU4IDkuNDM3NjkgNS40OTY4OFY5LjkwMjQzQzkuNDM3NjkgMTAuMTU0NSA5LjIzMzM2IDEwLjM1ODggOC45ODEzMSAxMC4zNTg4QzguNzI5MjUgMTAuMzU4OCA4LjUyNDkyIDEwLjE1NDUgOC41MjQ5MiA5LjkwMjQzVjQuMjc2NTNDOC4zNzA4NiA0LjIxODgyIDguMjA0MDIgNC4xODcyNiA4LjAyOTgyIDQuMTg3MjZDNy4yNTAyNyA0LjE4NzI2IDYuNjE4MzIgNC44MTkyIDYuNjE4MzIgNS41OTg3NUw2LjYxODI3IDkuOTc1OTlDNi42MTgyNyAxMC4yMjggNi40MTM5NCAxMC40MzI0IDYuMTYxODkgMTAuNDMyNEM1LjkwOTgzIDEwLjQzMjQgNS43MDU1IDEwLjIyOCA1LjcwNTUgOS45NzU5OVY4LjA0MTIyTDQuNjIxNDQgOC41MjIwNUM0LjMyMDE4IDguNjU1NjYgNC4xMjU5NyA4Ljk1NDI3IDQuMTI1OTggOS4yODM4M0w0LjEyNjA0IDEyLjYwNjFDNC4xMjYwNiAxMy40ODY3IDQuNTg5MzkgMTQuMzAyNCA1LjM0NTc2IDE0Ljc1MzRMNy4zMzk5OCAxNS45NDI0VjE3LjMyNjJDNy4zMzk5OCAxNy43ODY0IDcuNzEzMDggMTguMTU5NSA4LjE3MzMyIDE4LjE1OTVIMTMuODA4OEMxNC4yNjkgMTguMTU5NSAxNC42NDIxIDE3Ljc4NjQgMTQuNjQyMSAxNy4zMjYyVjE2Ljc5MzhDMTUuNzM4MSAxNS43MTkgMTYuMzg1IDE0LjI3MjggMTYuNDYwMyAxMi43NDdDMTYuNDY0NiAxMi42NiAxNi40NjcgMTIuNTcyOCAxNi40Njc2IDEyLjQ4NTRMMTYuNDY3NyAxMi40NDY3TDE2LjQ2NzYgOC4wMTk4M0MxNi40Njc2IDcuMzQ1MDQgMTUuOTI1MiA2Ljc5NjkzIDE1LjI1MjUgNi43ODc3MUwxNS4yMzUzIDYuNzg3NTlDMTUuMTI1IDYuNzg3NTkgMTUuMDE4IDYuODAyMSAxNC45MTYyIDYuODI5MzFWOS42MDEzNkMxNC45MTYyIDkuODUzNDIgMTQuNzExOSAxMC4wNTc3IDE0LjQ1OTggMTAuMDU3N0MxNC4yMDc4IDEwLjA1NzcgMTQuMDAzNCA5Ljg1MzQxIDE0LjAwMzQgOS42MDEzNlY3Ljk4OTg1QzE0LjAwMzIgNy45OTk4MiAxNC4wMDMxIDguMDA5ODEgMTQuMDAzMSA4LjAxOTgzTDE0LjAwMzQgOS42MDEzNkwxNC4wMDI1IDYuNzExNUMxNC4wMDI1IDYuNDQ5NzQgMTMuOTIwOSA2LjIwNzA1IDEzLjc4MTggNi4wMDc0OEMxMy41NjIgNS42OTI0MiAxMy4xOTg5IDUuNDg0ODMgMTIuNzg3IDUuNDc5MzdMMTIuNzcwMyA1LjQ3OTI2QzEyLjY1ODggNS40NzkyNiAxMi41NTA3IDUuNDk0MDggMTIuNDQ3OSA1LjUyMTg2WiIgZmlsbD0iIzFEMUMyMyIvPgo8L3N2Zz4="), auto'
|
|
1375
|
+
},
|
|
1376
|
+
toNodeJSON(node) {
|
|
1377
|
+
const nodeError = node.getData(import_form_core2.FlowNodeErrorData)?.getError();
|
|
1378
|
+
if (nodeError) {
|
|
1379
|
+
throw nodeError;
|
|
1380
|
+
}
|
|
1381
|
+
const transform = node.getData(import_core9.TransformData);
|
|
1382
|
+
let formJSON = toFormJSON(node);
|
|
1383
|
+
const metaData = {};
|
|
1384
|
+
const nodeMeta = node.getNodeMeta();
|
|
1385
|
+
const subCanvas = nodeMeta.subCanvas?.(node);
|
|
1386
|
+
if (subCanvas?.isCanvas === false) {
|
|
1387
|
+
const canvasNodeTransform = subCanvas.canvasNode.getData(import_document3.FlowNodeTransformData);
|
|
1388
|
+
const { x, y } = canvasNodeTransform.transform.position;
|
|
1389
|
+
metaData.canvasPosition = { x, y };
|
|
1390
|
+
}
|
|
1391
|
+
const json = {
|
|
1392
|
+
id: node.id,
|
|
1393
|
+
type: node.flowNodeType,
|
|
1394
|
+
meta: {
|
|
1395
|
+
position: { x: transform.position.x, y: transform.position.y },
|
|
1396
|
+
...metaData
|
|
1397
|
+
},
|
|
1398
|
+
data: formJSON
|
|
1399
|
+
};
|
|
1400
|
+
return json;
|
|
1401
|
+
}
|
|
1402
|
+
};
|
|
1403
|
+
|
|
1404
|
+
// src/typings/workflow-json.ts
|
|
1405
|
+
var WorkflowContentChangeType = /* @__PURE__ */ ((WorkflowContentChangeType2) => {
|
|
1406
|
+
WorkflowContentChangeType2["ADD_NODE"] = "ADD_NODE";
|
|
1407
|
+
WorkflowContentChangeType2["DELETE_NODE"] = "DELETE_NODE";
|
|
1408
|
+
WorkflowContentChangeType2["MOVE_NODE"] = "MOVE_NODE";
|
|
1409
|
+
WorkflowContentChangeType2["NODE_DATA_CHANGE"] = "NODE_DATA_CHANGE";
|
|
1410
|
+
WorkflowContentChangeType2["ADD_LINE"] = "ADD_LINE";
|
|
1411
|
+
WorkflowContentChangeType2["DELETE_LINE"] = "DELETE_LINE";
|
|
1412
|
+
WorkflowContentChangeType2["META_CHANGE"] = "META_CHANGE";
|
|
1413
|
+
return WorkflowContentChangeType2;
|
|
1414
|
+
})(WorkflowContentChangeType || {});
|
|
1415
|
+
|
|
1416
|
+
// src/typings/index.ts
|
|
1417
|
+
var URLParams = Symbol("");
|
|
1418
|
+
|
|
1419
|
+
// src/entity-datas/workflow-node-lines-data.ts
|
|
1420
|
+
var import_utils12 = require("@flowgram.ai/utils");
|
|
1421
|
+
var import_core10 = require("@flowgram.ai/core");
|
|
1422
|
+
var _WorkflowNodeLinesData = class _WorkflowNodeLinesData extends import_core10.EntityData {
|
|
1423
|
+
getDefaultData() {
|
|
1424
|
+
return {
|
|
1425
|
+
inputLines: [],
|
|
1426
|
+
outputLines: []
|
|
1427
|
+
};
|
|
1428
|
+
}
|
|
1429
|
+
constructor(entity) {
|
|
1430
|
+
super(entity);
|
|
1431
|
+
this.entity = entity;
|
|
1432
|
+
this.toDispose.push(
|
|
1433
|
+
import_utils12.Disposable.create(() => {
|
|
1434
|
+
this.inputLines.slice().forEach((line) => line.dispose());
|
|
1435
|
+
this.outputLines.slice().forEach((line) => line.dispose());
|
|
1436
|
+
})
|
|
1437
|
+
);
|
|
1438
|
+
}
|
|
1439
|
+
/**
|
|
1440
|
+
* 输入线条
|
|
1441
|
+
*/
|
|
1442
|
+
get inputLines() {
|
|
1443
|
+
return this.data.inputLines;
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* 输出线条
|
|
1447
|
+
*/
|
|
1448
|
+
get outputLines() {
|
|
1449
|
+
return this.data.outputLines;
|
|
1450
|
+
}
|
|
1451
|
+
/**
|
|
1452
|
+
* 输入节点
|
|
1453
|
+
*/
|
|
1454
|
+
get inputNodes() {
|
|
1455
|
+
return this.inputLines.map((l) => l.from).filter(Boolean);
|
|
1456
|
+
}
|
|
1457
|
+
/**
|
|
1458
|
+
* 所有输入节点
|
|
1459
|
+
*/
|
|
1460
|
+
get allInputNodes() {
|
|
1461
|
+
const nodeSet = /* @__PURE__ */ new Set();
|
|
1462
|
+
const handleNode = (node) => {
|
|
1463
|
+
if (nodeSet.has(node)) {
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1466
|
+
nodeSet.add(node);
|
|
1467
|
+
const { inputNodes } = node.getData(_WorkflowNodeLinesData);
|
|
1468
|
+
if (!inputNodes || !inputNodes.length) {
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
inputNodes.forEach((inputNode) => {
|
|
1472
|
+
if (inputNode?.parent === node || node?.parent === inputNode) {
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
handleNode(inputNode);
|
|
1476
|
+
});
|
|
1477
|
+
};
|
|
1478
|
+
handleNode(this.entity);
|
|
1479
|
+
nodeSet.delete(this.entity);
|
|
1480
|
+
return Array.from(nodeSet);
|
|
1481
|
+
}
|
|
1482
|
+
/**
|
|
1483
|
+
* 输出节点
|
|
1484
|
+
*/
|
|
1485
|
+
get outputNodes() {
|
|
1486
|
+
return this.outputLines.map((l) => l.to).filter(Boolean);
|
|
1487
|
+
}
|
|
1488
|
+
/**
|
|
1489
|
+
* 输入输出节点
|
|
1490
|
+
*/
|
|
1491
|
+
get allOutputNodes() {
|
|
1492
|
+
const nodeSet = /* @__PURE__ */ new Set();
|
|
1493
|
+
const handleNode = (node) => {
|
|
1494
|
+
if (nodeSet.has(node)) {
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1497
|
+
nodeSet.add(node);
|
|
1498
|
+
const { outputNodes } = node.getData(_WorkflowNodeLinesData);
|
|
1499
|
+
if (!outputNodes || !outputNodes.length) {
|
|
1500
|
+
return;
|
|
1501
|
+
}
|
|
1502
|
+
outputNodes.forEach((outputNode) => {
|
|
1503
|
+
if (outputNode?.parent === node || node?.parent === outputNode) {
|
|
1504
|
+
return;
|
|
1505
|
+
}
|
|
1506
|
+
handleNode(outputNode);
|
|
1507
|
+
});
|
|
1508
|
+
};
|
|
1509
|
+
handleNode(this.entity);
|
|
1510
|
+
nodeSet.delete(this.entity);
|
|
1511
|
+
return Array.from(nodeSet);
|
|
1512
|
+
}
|
|
1513
|
+
addLine(line) {
|
|
1514
|
+
if (line.from === this.entity) {
|
|
1515
|
+
this.outputLines.push(line);
|
|
1516
|
+
} else {
|
|
1517
|
+
this.inputLines.push(line);
|
|
1518
|
+
}
|
|
1519
|
+
this.fireChange();
|
|
1520
|
+
}
|
|
1521
|
+
removeLine(line) {
|
|
1522
|
+
const { inputLines, outputLines } = this;
|
|
1523
|
+
const inputIndex = inputLines.indexOf(line);
|
|
1524
|
+
const outputIndex = outputLines.indexOf(line);
|
|
1525
|
+
if (inputIndex !== -1) {
|
|
1526
|
+
inputLines.splice(inputIndex, 1);
|
|
1527
|
+
this.fireChange();
|
|
1528
|
+
}
|
|
1529
|
+
if (outputIndex !== -1) {
|
|
1530
|
+
outputLines.splice(outputIndex, 1);
|
|
1531
|
+
this.fireChange();
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
};
|
|
1535
|
+
_WorkflowNodeLinesData.type = "WorkflowNodeLinesData";
|
|
1536
|
+
var WorkflowNodeLinesData = _WorkflowNodeLinesData;
|
|
1537
|
+
|
|
1538
|
+
// src/workflow-lines-manager.ts
|
|
1539
|
+
var WorkflowLinesManager = class {
|
|
1540
|
+
constructor() {
|
|
1541
|
+
this.toDispose = new import_utils13.DisposableCollection();
|
|
1542
|
+
// 线条类型
|
|
1543
|
+
this._lineType = 0 /* BEZIER */;
|
|
1544
|
+
this.onAvailableLinesChangeEmitter = new import_utils13.Emitter();
|
|
1545
|
+
this.onForceUpdateEmitter = new import_utils13.Emitter();
|
|
1546
|
+
/**
|
|
1547
|
+
* 有效的线条被添加或者删除时候触发,未连上的线条不算
|
|
1548
|
+
*/
|
|
1549
|
+
this.onAvailableLinesChange = this.onAvailableLinesChangeEmitter.event;
|
|
1550
|
+
/**
|
|
1551
|
+
* 强制渲染 lines
|
|
1552
|
+
*/
|
|
1553
|
+
this.onForceUpdate = this.onForceUpdateEmitter.event;
|
|
1554
|
+
/**
|
|
1555
|
+
* 是否在调整线条
|
|
1556
|
+
*/
|
|
1557
|
+
this.isDrawing = false;
|
|
1558
|
+
}
|
|
1559
|
+
init(doc) {
|
|
1560
|
+
this.document = doc;
|
|
1561
|
+
}
|
|
1562
|
+
forceUpdate() {
|
|
1563
|
+
this.onForceUpdateEmitter.fire();
|
|
1564
|
+
}
|
|
1565
|
+
get lineType() {
|
|
1566
|
+
return this._lineType;
|
|
1567
|
+
}
|
|
1568
|
+
get lineColor() {
|
|
1569
|
+
const color = {
|
|
1570
|
+
default: "#4d53e8" /* DEFUALT */,
|
|
1571
|
+
error: "red" /* ERROR */,
|
|
1572
|
+
hidden: "transparent" /* HIDDEN */,
|
|
1573
|
+
drawing: "#5DD6E3" /* DRAWING */,
|
|
1574
|
+
hovered: "#37d0ff" /* HOVER */,
|
|
1575
|
+
selected: "#37d0ff" /* HOVER */
|
|
1576
|
+
};
|
|
1577
|
+
if (this.options.lineColor) {
|
|
1578
|
+
Object.assign(color, this.options.lineColor);
|
|
1579
|
+
}
|
|
1580
|
+
return color;
|
|
1581
|
+
}
|
|
1582
|
+
switchLineType(newType) {
|
|
1583
|
+
if (newType === void 0) {
|
|
1584
|
+
if (this._lineType === 0 /* BEZIER */) {
|
|
1585
|
+
newType = 1 /* LINE_CHART */;
|
|
1586
|
+
} else {
|
|
1587
|
+
newType = 0 /* BEZIER */;
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
if (newType !== this._lineType) {
|
|
1591
|
+
this._lineType = newType;
|
|
1592
|
+
this.entityManager.fireEntityChanged(WorkflowLineEntity.type);
|
|
1593
|
+
}
|
|
1594
|
+
return this._lineType;
|
|
1595
|
+
}
|
|
1596
|
+
getAllLines() {
|
|
1597
|
+
return this.entityManager.getEntities(WorkflowLineEntity);
|
|
1598
|
+
}
|
|
1599
|
+
hasLine(portInfo) {
|
|
1600
|
+
return !!this.entityManager.getEntityById(
|
|
1601
|
+
WorkflowLineEntity.portInfoToLineId(portInfo)
|
|
1602
|
+
);
|
|
1603
|
+
}
|
|
1604
|
+
getLine(portInfo) {
|
|
1605
|
+
return this.entityManager.getEntityById(
|
|
1606
|
+
WorkflowLineEntity.portInfoToLineId(portInfo)
|
|
1607
|
+
);
|
|
1608
|
+
}
|
|
1609
|
+
replaceLine(oldPortInfo, newPortInfo) {
|
|
1610
|
+
const oldLine = this.getLine(oldPortInfo);
|
|
1611
|
+
if (oldLine) {
|
|
1612
|
+
oldLine.dispose();
|
|
1613
|
+
}
|
|
1614
|
+
return this.createLine(newPortInfo);
|
|
1615
|
+
}
|
|
1616
|
+
createLine(options) {
|
|
1617
|
+
const { from, to, drawingTo, fromPort, toPort } = options;
|
|
1618
|
+
const available = Boolean(from && to);
|
|
1619
|
+
const key = options.key || WorkflowLineEntity.portInfoToLineId(options);
|
|
1620
|
+
let line = this.entityManager.getEntityById(key);
|
|
1621
|
+
if (line) {
|
|
1622
|
+
line.highlightColor = "";
|
|
1623
|
+
line.validate();
|
|
1624
|
+
return line;
|
|
1625
|
+
}
|
|
1626
|
+
const fromNode = this.entityManager.getEntityById(from)?.getData(WorkflowNodeLinesData);
|
|
1627
|
+
const toNode = to ? this.entityManager.getEntityById(to).getData(WorkflowNodeLinesData) : void 0;
|
|
1628
|
+
if (!fromNode) {
|
|
1629
|
+
return;
|
|
1630
|
+
}
|
|
1631
|
+
this.isDrawing = Boolean(drawingTo);
|
|
1632
|
+
line = this.entityManager.createEntity(WorkflowLineEntity, {
|
|
1633
|
+
id: key,
|
|
1634
|
+
document: this.document,
|
|
1635
|
+
linesManager: this,
|
|
1636
|
+
from,
|
|
1637
|
+
fromPort,
|
|
1638
|
+
toPort,
|
|
1639
|
+
to,
|
|
1640
|
+
drawingTo
|
|
1641
|
+
});
|
|
1642
|
+
fromNode.addLine(line);
|
|
1643
|
+
toNode?.addLine(line);
|
|
1644
|
+
line.onDispose(() => {
|
|
1645
|
+
if (drawingTo) {
|
|
1646
|
+
this.isDrawing = false;
|
|
1647
|
+
}
|
|
1648
|
+
fromNode.removeLine(line);
|
|
1649
|
+
toNode?.removeLine(line);
|
|
1650
|
+
line.validate();
|
|
1651
|
+
});
|
|
1652
|
+
line.toDispose.push(
|
|
1653
|
+
import_utils13.Disposable.create(() => {
|
|
1654
|
+
if (available) {
|
|
1655
|
+
this.onAvailableLinesChangeEmitter.fire({
|
|
1656
|
+
type: "DELETE_LINE" /* DELETE_LINE */,
|
|
1657
|
+
toJSON: () => line.toJSON(),
|
|
1658
|
+
entity: line
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
})
|
|
1662
|
+
);
|
|
1663
|
+
if (available) {
|
|
1664
|
+
this.onAvailableLinesChangeEmitter.fire({
|
|
1665
|
+
type: "ADD_LINE" /* ADD_LINE */,
|
|
1666
|
+
toJSON: () => line.toJSON(),
|
|
1667
|
+
entity: line
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
line.validate();
|
|
1671
|
+
return line;
|
|
1672
|
+
}
|
|
1673
|
+
/**
|
|
1674
|
+
* 获取线条中距离鼠标位置最近的线条和距离
|
|
1675
|
+
* @param mousePos 鼠标位置
|
|
1676
|
+
* @param minDistance 最小检测距离
|
|
1677
|
+
* @returns 距离鼠标位置最近的线条 以及距离
|
|
1678
|
+
*/
|
|
1679
|
+
getCloseInLineFromMousePos(mousePos, minDistance = LINE_HOVER_DISTANCE) {
|
|
1680
|
+
let targetLine, targetLineDist;
|
|
1681
|
+
this.getAllLines().forEach((line) => {
|
|
1682
|
+
const dist = line.getHoverDist(mousePos, this.lineType);
|
|
1683
|
+
if (dist <= minDistance && (!targetLineDist || targetLineDist >= dist)) {
|
|
1684
|
+
targetLineDist = dist;
|
|
1685
|
+
targetLine = line;
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1688
|
+
return targetLine;
|
|
1689
|
+
}
|
|
1690
|
+
dispose() {
|
|
1691
|
+
this.toDispose.dispose();
|
|
1692
|
+
}
|
|
1693
|
+
get disposed() {
|
|
1694
|
+
return this.toDispose.disposed;
|
|
1695
|
+
}
|
|
1696
|
+
isErrorLine(fromPort, toPort) {
|
|
1697
|
+
if (this.options.isErrorLine) {
|
|
1698
|
+
return this.options.isErrorLine(fromPort, toPort, this);
|
|
1699
|
+
}
|
|
1700
|
+
return false;
|
|
1701
|
+
}
|
|
1702
|
+
isReverseLine(line) {
|
|
1703
|
+
if (this.options.isReverseLine) {
|
|
1704
|
+
return this.options.isReverseLine(line);
|
|
1705
|
+
}
|
|
1706
|
+
return false;
|
|
1707
|
+
}
|
|
1708
|
+
isHideArrowLine(line) {
|
|
1709
|
+
if (this.options.isHideArrowLine) {
|
|
1710
|
+
return this.options.isHideArrowLine(line);
|
|
1711
|
+
}
|
|
1712
|
+
return false;
|
|
1713
|
+
}
|
|
1714
|
+
isFlowingLine(line) {
|
|
1715
|
+
if (this.options.isFlowingLine) {
|
|
1716
|
+
return this.options.isFlowingLine(line);
|
|
1717
|
+
}
|
|
1718
|
+
return false;
|
|
1719
|
+
}
|
|
1720
|
+
isDisabledLine(line) {
|
|
1721
|
+
if (this.options.isDisabledLine) {
|
|
1722
|
+
return this.options.isDisabledLine(line);
|
|
1723
|
+
}
|
|
1724
|
+
return false;
|
|
1725
|
+
}
|
|
1726
|
+
isVerticalLine(line) {
|
|
1727
|
+
if (this.options.isVerticalLine) {
|
|
1728
|
+
return this.options.isVerticalLine(line);
|
|
1729
|
+
}
|
|
1730
|
+
return false;
|
|
1731
|
+
}
|
|
1732
|
+
getLineColor(line) {
|
|
1733
|
+
if (line.isHidden) {
|
|
1734
|
+
return this.lineColor.hidden;
|
|
1735
|
+
}
|
|
1736
|
+
if (line.hasError) {
|
|
1737
|
+
return this.lineColor.error;
|
|
1738
|
+
}
|
|
1739
|
+
if (line.highlightColor) {
|
|
1740
|
+
return line.highlightColor;
|
|
1741
|
+
}
|
|
1742
|
+
if (line.drawingTo) {
|
|
1743
|
+
return this.lineColor.drawing;
|
|
1744
|
+
}
|
|
1745
|
+
if (this.hoverService.isHovered(line.id)) {
|
|
1746
|
+
return this.lineColor.hovered;
|
|
1747
|
+
}
|
|
1748
|
+
if (this.selectService.isSelected(line.id)) {
|
|
1749
|
+
return this.lineColor.selected;
|
|
1750
|
+
}
|
|
1751
|
+
return this.lineColor.default;
|
|
1752
|
+
}
|
|
1753
|
+
canAddLine(fromPort, toPort, silent) {
|
|
1754
|
+
if (fromPort === toPort || fromPort.node === toPort.node || fromPort.portType !== "output" || toPort.portType !== "input" || toPort.disabled) {
|
|
1755
|
+
return false;
|
|
1756
|
+
}
|
|
1757
|
+
if (this.options.canAddLine) {
|
|
1758
|
+
return this.options.canAddLine(fromPort, toPort, this, silent);
|
|
1759
|
+
}
|
|
1760
|
+
return fromPort.node !== toPort.node;
|
|
1761
|
+
}
|
|
1762
|
+
toJSON() {
|
|
1763
|
+
return this.getAllLines().filter((l) => !l.isDrawing).map((l) => l.toJSON());
|
|
1764
|
+
}
|
|
1765
|
+
getPortById(portId) {
|
|
1766
|
+
return this.entityManager.getEntityById(portId);
|
|
1767
|
+
}
|
|
1768
|
+
canRemove(line, newLineInfo, silent) {
|
|
1769
|
+
if (this.options && this.options.canDeleteLine && !this.options.canDeleteLine(line, newLineInfo, silent)) {
|
|
1770
|
+
return false;
|
|
1771
|
+
}
|
|
1772
|
+
return true;
|
|
1773
|
+
}
|
|
1774
|
+
canReset(fromPort, oldToPort, newToPort) {
|
|
1775
|
+
if (this.options && this.options.canResetLine && !this.options.canResetLine(fromPort, oldToPort, newToPort, this)) {
|
|
1776
|
+
return false;
|
|
1777
|
+
}
|
|
1778
|
+
return true;
|
|
1779
|
+
}
|
|
1780
|
+
/**
|
|
1781
|
+
* 根据鼠标位置找到 port
|
|
1782
|
+
* @param pos
|
|
1783
|
+
*/
|
|
1784
|
+
getPortFromMousePos(pos) {
|
|
1785
|
+
const allPorts = this.entityManager.getEntities(WorkflowPortEntity).filter((port) => port.node.flowNodeType !== "root");
|
|
1786
|
+
const targetPort = allPorts.find((port) => port.isHovered(pos.x, pos.y));
|
|
1787
|
+
if (targetPort) {
|
|
1788
|
+
const targetNode = this.document.getAllNodes().slice().reverse().filter((node) => targetPort.node?.parent?.id !== node.id).find((node) => node.getData(import_core11.TransformData).contains(pos.x, pos.y));
|
|
1789
|
+
if (targetNode && targetNode !== targetPort.node) {
|
|
1790
|
+
return;
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
return targetPort;
|
|
1794
|
+
}
|
|
1795
|
+
/**
|
|
1796
|
+
* 根据鼠标位置找到 node
|
|
1797
|
+
* @param pos - 鼠标位置
|
|
1798
|
+
*/
|
|
1799
|
+
getNodeFromMousePos(pos) {
|
|
1800
|
+
const allNodes = this.document.getAllNodes();
|
|
1801
|
+
const containNodes = [];
|
|
1802
|
+
const { selection } = this.selectService;
|
|
1803
|
+
const zoom = this.entityManager.getEntity(import_core11.PlaygroundConfigEntity)?.config?.zoom || 1;
|
|
1804
|
+
allNodes.forEach((node) => {
|
|
1805
|
+
const { bounds } = node.getData(import_document4.FlowNodeTransformData);
|
|
1806
|
+
if (bounds.clone().pad(4 / zoom).contains(pos.x, pos.y)) {
|
|
1807
|
+
containNodes.push(node);
|
|
1808
|
+
}
|
|
1809
|
+
});
|
|
1810
|
+
if (selection?.length) {
|
|
1811
|
+
const filteredNodes = containNodes.filter(
|
|
1812
|
+
(node) => selection.some((_node) => node.id === _node.id)
|
|
1813
|
+
);
|
|
1814
|
+
if (filteredNodes?.length) {
|
|
1815
|
+
return (0, import_lodash_es3.last)(filteredNodes);
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
return (0, import_lodash_es3.last)(containNodes);
|
|
1819
|
+
}
|
|
1820
|
+
};
|
|
1821
|
+
__decorateClass([
|
|
1822
|
+
(0, import_inversify3.inject)(WorkflowHoverService)
|
|
1823
|
+
], WorkflowLinesManager.prototype, "hoverService", 2);
|
|
1824
|
+
__decorateClass([
|
|
1825
|
+
(0, import_inversify3.inject)(WorkflowSelectService)
|
|
1826
|
+
], WorkflowLinesManager.prototype, "selectService", 2);
|
|
1827
|
+
__decorateClass([
|
|
1828
|
+
(0, import_inversify3.inject)(import_core11.EntityManager)
|
|
1829
|
+
], WorkflowLinesManager.prototype, "entityManager", 2);
|
|
1830
|
+
__decorateClass([
|
|
1831
|
+
(0, import_inversify3.inject)(WorkflowDocumentOptions)
|
|
1832
|
+
], WorkflowLinesManager.prototype, "options", 2);
|
|
1833
|
+
WorkflowLinesManager = __decorateClass([
|
|
1834
|
+
(0, import_inversify3.injectable)()
|
|
1835
|
+
], WorkflowLinesManager);
|
|
1836
|
+
|
|
1837
|
+
// src/workflow-document.ts
|
|
1838
|
+
var import_nanoid2 = require("nanoid");
|
|
1839
|
+
var import_inversify5 = require("inversify");
|
|
1840
|
+
var import_utils15 = require("@flowgram.ai/utils");
|
|
1841
|
+
var import_form_core3 = require("@flowgram.ai/form-core");
|
|
1842
|
+
var import_document6 = require("@flowgram.ai/document");
|
|
1843
|
+
var import_core13 = require("@flowgram.ai/core");
|
|
1844
|
+
|
|
1845
|
+
// src/layout/free-layout.ts
|
|
1846
|
+
var import_inversify4 = require("inversify");
|
|
1847
|
+
var import_document5 = require("@flowgram.ai/document");
|
|
1848
|
+
var import_core12 = require("@flowgram.ai/core");
|
|
1849
|
+
var import_utils14 = require("@flowgram.ai/utils");
|
|
1850
|
+
var FREE_LAYOUT_KEY = "free-layout";
|
|
1851
|
+
var FreeLayout = class {
|
|
1852
|
+
constructor() {
|
|
1853
|
+
this.name = FREE_LAYOUT_KEY;
|
|
1854
|
+
}
|
|
1855
|
+
get document() {
|
|
1856
|
+
return this.documentProvider();
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* 更新布局
|
|
1860
|
+
*/
|
|
1861
|
+
update() {
|
|
1862
|
+
if (this.document.root.getData(import_document5.FlowNodeTransformData)?.localDirty) {
|
|
1863
|
+
this.document.root.clearMemoGlobal();
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
syncTransform(node) {
|
|
1867
|
+
const transform = node.getData(import_document5.FlowNodeTransformData);
|
|
1868
|
+
if (!transform.localDirty) {
|
|
1869
|
+
return;
|
|
1870
|
+
}
|
|
1871
|
+
node.clearMemoGlobal();
|
|
1872
|
+
node.clearMemoLocal();
|
|
1873
|
+
transform.transform.update({
|
|
1874
|
+
size: transform.data.size
|
|
1875
|
+
});
|
|
1876
|
+
if (!node.parent) {
|
|
1877
|
+
return;
|
|
1878
|
+
}
|
|
1879
|
+
node.parent.clearMemoGlobal();
|
|
1880
|
+
node.parent.clearMemoLocal();
|
|
1881
|
+
const parentTransform = node.parent.getData(import_document5.FlowNodeTransformData);
|
|
1882
|
+
parentTransform.transform.fireChange();
|
|
1883
|
+
}
|
|
1884
|
+
/**
|
|
1885
|
+
* 获取节点的 padding 数据
|
|
1886
|
+
* @param node
|
|
1887
|
+
*/
|
|
1888
|
+
getPadding(node) {
|
|
1889
|
+
const { padding } = node.getNodeMeta();
|
|
1890
|
+
const transform = node.getData(import_document5.FlowNodeTransformData);
|
|
1891
|
+
if (padding) {
|
|
1892
|
+
return typeof padding === "function" ? padding(transform) : padding;
|
|
1893
|
+
}
|
|
1894
|
+
return import_utils14.PaddingSchema.empty();
|
|
1895
|
+
}
|
|
1896
|
+
/**
|
|
1897
|
+
* 默认滚动到 fitview 区域
|
|
1898
|
+
* @param contentSize
|
|
1899
|
+
*/
|
|
1900
|
+
getInitScroll(contentSize) {
|
|
1901
|
+
const bounds = import_utils14.Rectangle.enlarge(
|
|
1902
|
+
this.document.getAllNodes().map((node) => node.getData(import_core12.TransformData).bounds)
|
|
1903
|
+
).pad(30, 30);
|
|
1904
|
+
const viewport = this.playgroundConfig.getViewport(false);
|
|
1905
|
+
const zoom = import_utils14.SizeSchema.fixSize(bounds, viewport);
|
|
1906
|
+
return {
|
|
1907
|
+
scrollX: (bounds.x + bounds.width / 2) * zoom - this.playgroundConfig.config.width / 2,
|
|
1908
|
+
scrollY: (bounds.y + bounds.height / 2) * zoom - this.playgroundConfig.config.height / 2
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1911
|
+
/**
|
|
1912
|
+
* 获取默认输入点
|
|
1913
|
+
*/
|
|
1914
|
+
getDefaultInputPoint(node) {
|
|
1915
|
+
return node.getData(import_core12.TransformData).bounds.leftCenter;
|
|
1916
|
+
}
|
|
1917
|
+
/**
|
|
1918
|
+
* 获取默认输出点
|
|
1919
|
+
*/
|
|
1920
|
+
getDefaultOutputPoint(node) {
|
|
1921
|
+
return node.getData(import_core12.TransformData).bounds.rightCenter;
|
|
1922
|
+
}
|
|
1923
|
+
/**
|
|
1924
|
+
* 水平中心点
|
|
1925
|
+
*/
|
|
1926
|
+
getDefaultNodeOrigin() {
|
|
1927
|
+
return { x: 0.5, y: 0 };
|
|
1928
|
+
}
|
|
1929
|
+
};
|
|
1930
|
+
__decorateClass([
|
|
1931
|
+
(0, import_inversify4.inject)(import_core12.PlaygroundConfigEntity)
|
|
1932
|
+
], FreeLayout.prototype, "playgroundConfig", 2);
|
|
1933
|
+
__decorateClass([
|
|
1934
|
+
(0, import_inversify4.inject)(import_document5.FlowDocumentProvider)
|
|
1935
|
+
], FreeLayout.prototype, "documentProvider", 2);
|
|
1936
|
+
FreeLayout = __decorateClass([
|
|
1937
|
+
(0, import_inversify4.injectable)()
|
|
1938
|
+
], FreeLayout);
|
|
1939
|
+
|
|
1940
|
+
// src/workflow-document.ts
|
|
1941
|
+
var nanoid2 = (0, import_nanoid2.customAlphabet)("1234567890", 5);
|
|
1942
|
+
var WorkflowDocumentProvider = Symbol("WorkflowDocumentProvider");
|
|
1943
|
+
var WorkflowDocument = class extends import_document6.FlowDocument {
|
|
1944
|
+
constructor() {
|
|
1945
|
+
super(...arguments);
|
|
1946
|
+
this._onContentChangeEmitter = new import_utils15.Emitter();
|
|
1947
|
+
this.onLoadedEmitter = new import_utils15.Emitter();
|
|
1948
|
+
this.onContentChange = this._onContentChangeEmitter.event;
|
|
1949
|
+
this._onReloadEmitter = new import_utils15.Emitter();
|
|
1950
|
+
this.onReload = this._onReloadEmitter.event;
|
|
1951
|
+
this.disposed = false;
|
|
1952
|
+
/**
|
|
1953
|
+
* 数据加载完成
|
|
1954
|
+
*/
|
|
1955
|
+
this.onLoaded = this.onLoadedEmitter.event;
|
|
1956
|
+
this._loading = false;
|
|
1957
|
+
this.options = {};
|
|
1958
|
+
}
|
|
1959
|
+
get loading() {
|
|
1960
|
+
return this._loading;
|
|
1961
|
+
}
|
|
1962
|
+
async fitView(easing) {
|
|
1963
|
+
return fitView(this, this.playgroundConfig, easing).then(() => {
|
|
1964
|
+
this.linesManager.forceUpdate();
|
|
1965
|
+
});
|
|
1966
|
+
}
|
|
1967
|
+
init() {
|
|
1968
|
+
super.init();
|
|
1969
|
+
this.currentLayoutKey = this.options.defaultLayout || FREE_LAYOUT_KEY;
|
|
1970
|
+
this.linesManager.init(this);
|
|
1971
|
+
this.playgroundConfig.getCursors = () => this.options.cursors;
|
|
1972
|
+
this.linesManager.onAvailableLinesChange((e) => this.fireContentChange(e));
|
|
1973
|
+
this.playgroundConfig.onReadonlyOrDisabledChange(({ readonly }) => {
|
|
1974
|
+
if (this.nodeEngineContext) {
|
|
1975
|
+
this.nodeEngineContext.readonly = readonly;
|
|
1976
|
+
}
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
async load() {
|
|
1980
|
+
this._loading = true;
|
|
1981
|
+
await super.load();
|
|
1982
|
+
this._loading = false;
|
|
1983
|
+
this.onLoadedEmitter.fire();
|
|
1984
|
+
}
|
|
1985
|
+
async reload(json, delayTime = 0) {
|
|
1986
|
+
this._loading = true;
|
|
1987
|
+
this.clear();
|
|
1988
|
+
this.fromJSON(json);
|
|
1989
|
+
await (0, import_utils6.delay)(delayTime);
|
|
1990
|
+
this._loading = false;
|
|
1991
|
+
this._onReloadEmitter.fire(this);
|
|
1992
|
+
}
|
|
1993
|
+
/**
|
|
1994
|
+
* 从数据加载
|
|
1995
|
+
* @param json
|
|
1996
|
+
*/
|
|
1997
|
+
fromJSON(json, fireRender = true) {
|
|
1998
|
+
const { flattenJSON, nodeBlocks, nodeEdges } = this.flatJSON(json);
|
|
1999
|
+
const nestedJSON = this.nestJSON(flattenJSON, nodeBlocks, nodeEdges);
|
|
2000
|
+
this.entityManager.changeEntityLocked = true;
|
|
2001
|
+
this.renderJSON(nestedJSON);
|
|
2002
|
+
this.entityManager.changeEntityLocked = false;
|
|
2003
|
+
this.transformer.loading = false;
|
|
2004
|
+
if (fireRender) {
|
|
2005
|
+
this.fireRender();
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
/**
|
|
2009
|
+
* 清空画布
|
|
2010
|
+
*/
|
|
2011
|
+
clear() {
|
|
2012
|
+
this.getAllNodes().map((node) => node.dispose());
|
|
2013
|
+
this.linesManager.getAllLines().map((line) => line.dispose());
|
|
2014
|
+
this.getAllPorts().map((port) => port.dispose());
|
|
2015
|
+
this.selectServices.clear();
|
|
2016
|
+
}
|
|
2017
|
+
/**
|
|
2018
|
+
* 创建流程节点
|
|
2019
|
+
* @param json
|
|
2020
|
+
*/
|
|
2021
|
+
createWorkflowNode(json, isClone = false, parentId) {
|
|
2022
|
+
const isExistedNode = this.getNode(json.id);
|
|
2023
|
+
const parent = this.getNode(parentId ?? this.root.id) ?? this.root;
|
|
2024
|
+
const node = this.addNode(
|
|
2025
|
+
{
|
|
2026
|
+
...json,
|
|
2027
|
+
parent
|
|
2028
|
+
},
|
|
2029
|
+
void 0,
|
|
2030
|
+
true
|
|
2031
|
+
);
|
|
2032
|
+
const registry = node.getNodeRegistry();
|
|
2033
|
+
const { formMeta } = registry;
|
|
2034
|
+
const meta = node.getNodeMeta();
|
|
2035
|
+
const formData = getFlowNodeFormData(node);
|
|
2036
|
+
const transform = node.getData(import_document6.FlowNodeTransformData);
|
|
2037
|
+
const freeLayout = this.layout;
|
|
2038
|
+
transform.onDataChange(() => {
|
|
2039
|
+
freeLayout.syncTransform(node);
|
|
2040
|
+
});
|
|
2041
|
+
let { position } = meta;
|
|
2042
|
+
if (!position) {
|
|
2043
|
+
position = this.getNodeDefaultPosition(json.type);
|
|
2044
|
+
}
|
|
2045
|
+
node.getData(import_core13.TransformData).update({
|
|
2046
|
+
position
|
|
2047
|
+
});
|
|
2048
|
+
if (formMeta && formData) {
|
|
2049
|
+
formData.createForm(formMeta, json.data);
|
|
2050
|
+
formData.onDataChange(() => {
|
|
2051
|
+
this.fireContentChange({
|
|
2052
|
+
type: "NODE_DATA_CHANGE" /* NODE_DATA_CHANGE */,
|
|
2053
|
+
toJSON: () => formData.toJSON(),
|
|
2054
|
+
entity: node
|
|
2055
|
+
});
|
|
2056
|
+
});
|
|
2057
|
+
}
|
|
2058
|
+
const positionData = node.getData(import_core13.PositionData);
|
|
2059
|
+
positionData.onDataChange(() => {
|
|
2060
|
+
this.fireContentChange({
|
|
2061
|
+
type: "MOVE_NODE" /* MOVE_NODE */,
|
|
2062
|
+
toJSON: () => positionData.toJSON(),
|
|
2063
|
+
entity: node
|
|
2064
|
+
});
|
|
2065
|
+
});
|
|
2066
|
+
const subCanvas = this.getNodeSubCanvas(node);
|
|
2067
|
+
if (!isExistedNode && !subCanvas?.isCanvas) {
|
|
2068
|
+
this.fireContentChange({
|
|
2069
|
+
type: "ADD_NODE" /* ADD_NODE */,
|
|
2070
|
+
entity: node,
|
|
2071
|
+
toJSON: () => this.toNodeJSON(node)
|
|
2072
|
+
});
|
|
2073
|
+
node.toDispose.push(
|
|
2074
|
+
import_utils15.Disposable.create(() => {
|
|
2075
|
+
this.fireContentChange({
|
|
2076
|
+
type: "DELETE_NODE" /* DELETE_NODE */,
|
|
2077
|
+
entity: node,
|
|
2078
|
+
toJSON: () => this.toNodeJSON(node)
|
|
2079
|
+
});
|
|
2080
|
+
})
|
|
2081
|
+
);
|
|
2082
|
+
node.toDispose.push(
|
|
2083
|
+
import_utils15.Disposable.create(() => {
|
|
2084
|
+
if (!node.parent || node.parent.flowNodeType === import_document6.FlowNodeBaseType.ROOT) {
|
|
2085
|
+
return;
|
|
2086
|
+
}
|
|
2087
|
+
const parentTransform = node.parent.getData(import_document6.FlowNodeTransformData);
|
|
2088
|
+
setTimeout(() => {
|
|
2089
|
+
parentTransform.fireChange();
|
|
2090
|
+
}, 0);
|
|
2091
|
+
})
|
|
2092
|
+
);
|
|
2093
|
+
}
|
|
2094
|
+
if (json.blocks) {
|
|
2095
|
+
this.renderJSON(
|
|
2096
|
+
{ nodes: json.blocks, edges: json.edges ?? [] },
|
|
2097
|
+
{
|
|
2098
|
+
parent: node,
|
|
2099
|
+
isClone
|
|
2100
|
+
}
|
|
2101
|
+
);
|
|
2102
|
+
}
|
|
2103
|
+
if (subCanvas) {
|
|
2104
|
+
const canvasTransform = subCanvas.canvasNode.getData(import_core13.TransformData);
|
|
2105
|
+
canvasTransform.update({
|
|
2106
|
+
position: subCanvas.parentNode.getNodeMeta()?.canvasPosition
|
|
2107
|
+
});
|
|
2108
|
+
subCanvas.parentNode.onDispose(() => {
|
|
2109
|
+
subCanvas.canvasNode.dispose();
|
|
2110
|
+
});
|
|
2111
|
+
subCanvas.canvasNode.onDispose(() => {
|
|
2112
|
+
subCanvas.parentNode.dispose();
|
|
2113
|
+
});
|
|
2114
|
+
}
|
|
2115
|
+
this.onNodeCreateEmitter.fire({
|
|
2116
|
+
node,
|
|
2117
|
+
data: json
|
|
2118
|
+
});
|
|
2119
|
+
return node;
|
|
2120
|
+
}
|
|
2121
|
+
/**
|
|
2122
|
+
* 获取默认的 x y 坐标, 默认为当前画布可视区域中心
|
|
2123
|
+
* @param type
|
|
2124
|
+
* @protected
|
|
2125
|
+
*/
|
|
2126
|
+
getNodeDefaultPosition(type) {
|
|
2127
|
+
const { size } = this.getNodeRegistry(type).meta || {};
|
|
2128
|
+
let position = this.playgroundConfig.getViewport(true).center;
|
|
2129
|
+
if (size) {
|
|
2130
|
+
position = {
|
|
2131
|
+
x: position.x,
|
|
2132
|
+
y: position.y - size.height / 2
|
|
2133
|
+
};
|
|
2134
|
+
}
|
|
2135
|
+
return getAntiOverlapPosition(this, position);
|
|
2136
|
+
}
|
|
2137
|
+
/**
|
|
2138
|
+
* 通过类型创建节点, 如果没有提供position 则直接放在画布中间
|
|
2139
|
+
* @param type
|
|
2140
|
+
*/
|
|
2141
|
+
createWorkflowNodeByType(type, position, json = {}, parentID) {
|
|
2142
|
+
let id = json.id;
|
|
2143
|
+
if (id === void 0) {
|
|
2144
|
+
do {
|
|
2145
|
+
id = `1${nanoid2()}`;
|
|
2146
|
+
} while (this.entityManager.getEntityById(id));
|
|
2147
|
+
} else {
|
|
2148
|
+
if (this.entityManager.getEntityById(id)) {
|
|
2149
|
+
throw new Error(`[WorkflowDocument.createWorkflowNodeByType] Node Id "${id}" duplicated.`);
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
return this.createWorkflowNode(
|
|
2153
|
+
{
|
|
2154
|
+
id,
|
|
2155
|
+
type,
|
|
2156
|
+
meta: { position, ...json?.meta },
|
|
2157
|
+
// TODO title 和 meta 要从注册数据去拿
|
|
2158
|
+
data: json?.data,
|
|
2159
|
+
blocks: json?.blocks,
|
|
2160
|
+
edges: json?.edges
|
|
2161
|
+
},
|
|
2162
|
+
false,
|
|
2163
|
+
parentID
|
|
2164
|
+
);
|
|
2165
|
+
}
|
|
2166
|
+
getAllNodes() {
|
|
2167
|
+
return this.entityManager.getEntities(WorkflowNodeEntity).filter((n) => n.id !== import_document6.FlowNodeBaseType.ROOT);
|
|
2168
|
+
}
|
|
2169
|
+
getAllPorts() {
|
|
2170
|
+
return this.entityManager.getEntities(WorkflowPortEntity).filter((p) => p.node.id !== import_document6.FlowNodeBaseType.ROOT);
|
|
2171
|
+
}
|
|
2172
|
+
/**
|
|
2173
|
+
* 获取画布中的非游离节点
|
|
2174
|
+
* 1. 开始节点
|
|
2175
|
+
* 2. 从开始节点出发能走到的节点
|
|
2176
|
+
* 3. 结束节点
|
|
2177
|
+
* 4. 默认所有子画布内节点为游离节点
|
|
2178
|
+
*/
|
|
2179
|
+
getAssociatedNodes() {
|
|
2180
|
+
const allNode = this.getAllNodes();
|
|
2181
|
+
const allLines = this.linesManager.getAllLines().filter((line) => line.from && line.to).map((line) => ({
|
|
2182
|
+
from: line.from.id,
|
|
2183
|
+
to: line.to.id
|
|
2184
|
+
}));
|
|
2185
|
+
const startNodeId = allNode.find((node) => node.isStart).id;
|
|
2186
|
+
const endNodeId = allNode.find((node) => node.isNodeEnd).id;
|
|
2187
|
+
const nodeInSubCanvas = allNode.filter((node) => node.parent?.flowNodeType === import_document6.FlowNodeBaseType.SUB_CANVAS).map((node) => node.id);
|
|
2188
|
+
const associatedCache = /* @__PURE__ */ new Set([endNodeId, ...nodeInSubCanvas]);
|
|
2189
|
+
const bfs = (nodeId) => {
|
|
2190
|
+
if (associatedCache.has(nodeId)) {
|
|
2191
|
+
return;
|
|
2192
|
+
}
|
|
2193
|
+
associatedCache.add(nodeId);
|
|
2194
|
+
const nextNodes = allLines.reduce((ids, { from, to }) => {
|
|
2195
|
+
if (from === nodeId && !associatedCache.has(to)) {
|
|
2196
|
+
ids.push(to);
|
|
2197
|
+
}
|
|
2198
|
+
return ids;
|
|
2199
|
+
}, []);
|
|
2200
|
+
nextNodes.forEach(bfs);
|
|
2201
|
+
};
|
|
2202
|
+
bfs(startNodeId);
|
|
2203
|
+
const associatedNodes = allNode.filter((node) => associatedCache.has(node.id));
|
|
2204
|
+
return associatedNodes;
|
|
2205
|
+
}
|
|
2206
|
+
/**
|
|
2207
|
+
* 触发渲染
|
|
2208
|
+
*/
|
|
2209
|
+
fireRender() {
|
|
2210
|
+
this.entityManager.fireEntityChanged(WorkflowNodeEntity.type);
|
|
2211
|
+
this.entityManager.fireEntityChanged(WorkflowLineEntity.type);
|
|
2212
|
+
this.entityManager.fireEntityChanged(WorkflowPortEntity.type);
|
|
2213
|
+
}
|
|
2214
|
+
fireContentChange(event) {
|
|
2215
|
+
if (this._loading || this.disposed || this.entityManager.changeEntityLocked) {
|
|
2216
|
+
return;
|
|
2217
|
+
}
|
|
2218
|
+
this._onContentChangeEmitter.fire(event);
|
|
2219
|
+
}
|
|
2220
|
+
toNodeJSON(node) {
|
|
2221
|
+
const subCanvas = this.getNodeSubCanvas(node);
|
|
2222
|
+
if (subCanvas?.isCanvas === true) {
|
|
2223
|
+
return this.toNodeJSON(subCanvas.parentNode);
|
|
2224
|
+
}
|
|
2225
|
+
const json = this.toNodeJSONFromOptions(node);
|
|
2226
|
+
const children = this.getNodeChildren(node);
|
|
2227
|
+
const blocks = children.map((child) => this.toNodeJSON(child));
|
|
2228
|
+
const linesMap = /* @__PURE__ */ new Map();
|
|
2229
|
+
children.forEach((child) => {
|
|
2230
|
+
const childLinesData = child.getData(WorkflowNodeLinesData);
|
|
2231
|
+
[...childLinesData.inputLines, ...childLinesData.outputLines].filter(Boolean).forEach((line) => {
|
|
2232
|
+
const lineJSON = this.toLineJSON(line);
|
|
2233
|
+
if (!lineJSON || linesMap.has(line.id)) {
|
|
2234
|
+
return;
|
|
2235
|
+
}
|
|
2236
|
+
linesMap.set(line.id, lineJSON);
|
|
2237
|
+
});
|
|
2238
|
+
});
|
|
2239
|
+
const edges = Array.from(linesMap.values());
|
|
2240
|
+
if (blocks.length > 0) json.blocks = blocks;
|
|
2241
|
+
if (edges.length > 0) json.edges = edges;
|
|
2242
|
+
return json;
|
|
2243
|
+
}
|
|
2244
|
+
/**
|
|
2245
|
+
* 节点转换为JSON, 没有format的过程
|
|
2246
|
+
* @param node
|
|
2247
|
+
* @returns
|
|
2248
|
+
*/
|
|
2249
|
+
toNodeJSONFromOptions(node) {
|
|
2250
|
+
if (this.options.toNodeJSON) {
|
|
2251
|
+
return this.options.toNodeJSON(node);
|
|
2252
|
+
}
|
|
2253
|
+
return WorkflowDocumentOptionsDefault.toNodeJSON(node);
|
|
2254
|
+
}
|
|
2255
|
+
copyNode(node, newNodeId, format, position) {
|
|
2256
|
+
let json = this.toNodeJSON(node);
|
|
2257
|
+
if (format) {
|
|
2258
|
+
json = format(json);
|
|
2259
|
+
}
|
|
2260
|
+
position = position || {
|
|
2261
|
+
x: json.meta.position.x + 30,
|
|
2262
|
+
y: json.meta.position.y + 30
|
|
2263
|
+
};
|
|
2264
|
+
return this.createWorkflowNode(
|
|
2265
|
+
{
|
|
2266
|
+
id: newNodeId || `1${nanoid2()}`,
|
|
2267
|
+
type: node.flowNodeType,
|
|
2268
|
+
meta: {
|
|
2269
|
+
...json.meta,
|
|
2270
|
+
position
|
|
2271
|
+
},
|
|
2272
|
+
data: json.data,
|
|
2273
|
+
blocks: json.blocks,
|
|
2274
|
+
edges: json.edges
|
|
2275
|
+
},
|
|
2276
|
+
true,
|
|
2277
|
+
node.parent?.id
|
|
2278
|
+
);
|
|
2279
|
+
}
|
|
2280
|
+
copyNodeFromJSON(flowNodeType, nodeJSON, newNodeId, position, parentId) {
|
|
2281
|
+
position = position || {
|
|
2282
|
+
x: nodeJSON.meta.position.x + 30,
|
|
2283
|
+
y: nodeJSON.meta.position.y + 30
|
|
2284
|
+
};
|
|
2285
|
+
return this.createWorkflowNode(
|
|
2286
|
+
{
|
|
2287
|
+
id: newNodeId || `1${nanoid2()}`,
|
|
2288
|
+
type: flowNodeType,
|
|
2289
|
+
meta: {
|
|
2290
|
+
...nodeJSON.meta,
|
|
2291
|
+
position
|
|
2292
|
+
},
|
|
2293
|
+
data: nodeJSON.data,
|
|
2294
|
+
blocks: nodeJSON.blocks,
|
|
2295
|
+
edges: nodeJSON.edges
|
|
2296
|
+
},
|
|
2297
|
+
true,
|
|
2298
|
+
parentId
|
|
2299
|
+
);
|
|
2300
|
+
}
|
|
2301
|
+
canRemove(node, silent) {
|
|
2302
|
+
const meta = node.getNodeMeta();
|
|
2303
|
+
if (meta.deleteDisable) {
|
|
2304
|
+
return false;
|
|
2305
|
+
}
|
|
2306
|
+
if (this.options.canDeleteNode && !this.options.canDeleteNode(node, silent)) {
|
|
2307
|
+
return false;
|
|
2308
|
+
}
|
|
2309
|
+
return true;
|
|
2310
|
+
}
|
|
2311
|
+
/**
|
|
2312
|
+
* 判断端口是否为错误态
|
|
2313
|
+
*/
|
|
2314
|
+
isErrorPort(port) {
|
|
2315
|
+
if (typeof this.options.isErrorPort === "function") {
|
|
2316
|
+
return this.options.isErrorPort(port);
|
|
2317
|
+
}
|
|
2318
|
+
return false;
|
|
2319
|
+
}
|
|
2320
|
+
/**
|
|
2321
|
+
* 导出数据
|
|
2322
|
+
*/
|
|
2323
|
+
toJSON() {
|
|
2324
|
+
const rootJSON = this.toNodeJSON(this.root);
|
|
2325
|
+
return {
|
|
2326
|
+
nodes: rootJSON.blocks ?? [],
|
|
2327
|
+
edges: rootJSON.edges ?? []
|
|
2328
|
+
};
|
|
2329
|
+
}
|
|
2330
|
+
dispose() {
|
|
2331
|
+
if (this.disposed) {
|
|
2332
|
+
return;
|
|
2333
|
+
}
|
|
2334
|
+
super.dispose();
|
|
2335
|
+
this.disposed = true;
|
|
2336
|
+
this._onReloadEmitter.dispose();
|
|
2337
|
+
}
|
|
2338
|
+
getEdgeID(edge) {
|
|
2339
|
+
return WorkflowLineEntity.portInfoToLineId({
|
|
2340
|
+
from: edge.sourceNodeID,
|
|
2341
|
+
to: edge.targetNodeID,
|
|
2342
|
+
fromPort: edge.sourcePortID,
|
|
2343
|
+
toPort: edge.targetPortID
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
/**
|
|
2347
|
+
* 拍平树形json结构,将结构信息提取到map
|
|
2348
|
+
*/
|
|
2349
|
+
flatJSON(json = { nodes: [], edges: [] }) {
|
|
2350
|
+
const nodeBlocks = /* @__PURE__ */ new Map();
|
|
2351
|
+
const nodeEdges = /* @__PURE__ */ new Map();
|
|
2352
|
+
const rootNodes = json.nodes ?? [];
|
|
2353
|
+
const rootEdges = json.edges ?? [];
|
|
2354
|
+
const flattenNodeJSONs = [...rootNodes];
|
|
2355
|
+
const flattenEdgeJSONs = [...rootEdges];
|
|
2356
|
+
const rootBlockIDs = rootNodes.map((node) => node.id);
|
|
2357
|
+
const rootEdgeIDs = rootEdges.map((edge) => this.getEdgeID(edge));
|
|
2358
|
+
nodeBlocks.set(import_document6.FlowNodeBaseType.ROOT, rootBlockIDs);
|
|
2359
|
+
nodeEdges.set(import_document6.FlowNodeBaseType.ROOT, rootEdgeIDs);
|
|
2360
|
+
rootNodes.forEach((nodeJSON) => {
|
|
2361
|
+
const { blocks, edges } = nodeJSON;
|
|
2362
|
+
if (blocks) {
|
|
2363
|
+
flattenNodeJSONs.push(...blocks);
|
|
2364
|
+
const blockIDs = [];
|
|
2365
|
+
blocks.forEach((block) => {
|
|
2366
|
+
blockIDs.push(block.id);
|
|
2367
|
+
});
|
|
2368
|
+
nodeBlocks.set(nodeJSON.id, blockIDs);
|
|
2369
|
+
delete nodeJSON.blocks;
|
|
2370
|
+
}
|
|
2371
|
+
if (edges) {
|
|
2372
|
+
flattenEdgeJSONs.push(...edges);
|
|
2373
|
+
const edgeIDs = [];
|
|
2374
|
+
edges.forEach((edge) => {
|
|
2375
|
+
const edgeID = this.getEdgeID(edge);
|
|
2376
|
+
edgeIDs.push(edgeID);
|
|
2377
|
+
});
|
|
2378
|
+
nodeEdges.set(nodeJSON.id, edgeIDs);
|
|
2379
|
+
delete nodeJSON.edges;
|
|
2380
|
+
}
|
|
2381
|
+
});
|
|
2382
|
+
const flattenJSON = {
|
|
2383
|
+
nodes: flattenNodeJSONs,
|
|
2384
|
+
edges: flattenEdgeJSONs
|
|
2385
|
+
};
|
|
2386
|
+
return {
|
|
2387
|
+
flattenJSON,
|
|
2388
|
+
nodeBlocks,
|
|
2389
|
+
nodeEdges
|
|
2390
|
+
};
|
|
2391
|
+
}
|
|
2392
|
+
/**
|
|
2393
|
+
* 对JSON进行分层
|
|
2394
|
+
*/
|
|
2395
|
+
nestJSON(flattenJSON, nodeBlocks, nodeEdges) {
|
|
2396
|
+
const nestJSON = {
|
|
2397
|
+
nodes: [],
|
|
2398
|
+
edges: []
|
|
2399
|
+
};
|
|
2400
|
+
const nodeMap = /* @__PURE__ */ new Map();
|
|
2401
|
+
const edgeMap = /* @__PURE__ */ new Map();
|
|
2402
|
+
const rootBlockSet = new Set(nodeBlocks.get(import_document6.FlowNodeBaseType.ROOT) ?? []);
|
|
2403
|
+
const rootEdgeSet = new Set(nodeEdges.get(import_document6.FlowNodeBaseType.ROOT) ?? []);
|
|
2404
|
+
flattenJSON.nodes.forEach((nodeJSON) => {
|
|
2405
|
+
nodeMap.set(nodeJSON.id, nodeJSON);
|
|
2406
|
+
});
|
|
2407
|
+
flattenJSON.edges.forEach((edgeJSON) => {
|
|
2408
|
+
const edgeID = this.getEdgeID(edgeJSON);
|
|
2409
|
+
edgeMap.set(edgeID, edgeJSON);
|
|
2410
|
+
});
|
|
2411
|
+
flattenJSON.nodes.forEach((nodeJSON) => {
|
|
2412
|
+
if (rootBlockSet.has(nodeJSON.id)) {
|
|
2413
|
+
nestJSON.nodes.push(nodeJSON);
|
|
2414
|
+
}
|
|
2415
|
+
if (nodeBlocks.has(nodeJSON.id)) {
|
|
2416
|
+
const blockIDs = nodeBlocks.get(nodeJSON.id);
|
|
2417
|
+
const blockJSONs = blockIDs.map((blockID) => nodeMap.get(blockID)).filter(Boolean);
|
|
2418
|
+
nodeJSON.blocks = blockJSONs;
|
|
2419
|
+
}
|
|
2420
|
+
if (nodeEdges.has(nodeJSON.id)) {
|
|
2421
|
+
const edgeIDs = nodeEdges.get(nodeJSON.id);
|
|
2422
|
+
const edgeJSONs = edgeIDs.map((edgeID) => edgeMap.get(edgeID)).filter(Boolean);
|
|
2423
|
+
nodeJSON.edges = edgeJSONs;
|
|
2424
|
+
}
|
|
2425
|
+
});
|
|
2426
|
+
flattenJSON.edges.forEach((edgeJSON) => {
|
|
2427
|
+
const edgeID = this.getEdgeID(edgeJSON);
|
|
2428
|
+
if (rootEdgeSet.has(edgeID)) {
|
|
2429
|
+
nestJSON.edges.push(edgeJSON);
|
|
2430
|
+
}
|
|
2431
|
+
});
|
|
2432
|
+
return nestJSON;
|
|
2433
|
+
}
|
|
2434
|
+
/**
|
|
2435
|
+
* 逐层创建节点和线条
|
|
2436
|
+
*/
|
|
2437
|
+
renderJSON(json, options) {
|
|
2438
|
+
const { parent = this.root, isClone = false } = options ?? {};
|
|
2439
|
+
const containerID = this.getNodeSubCanvas(parent)?.canvasNode.id ?? parent.id;
|
|
2440
|
+
json.nodes.forEach((nodeJSON) => {
|
|
2441
|
+
this.createWorkflowNode(nodeJSON, isClone, containerID);
|
|
2442
|
+
}), // 创建线条
|
|
2443
|
+
json.edges.forEach((edge) => this.createWorkflowLine(edge, containerID));
|
|
2444
|
+
}
|
|
2445
|
+
getNodeSubCanvas(node) {
|
|
2446
|
+
if (!node) return;
|
|
2447
|
+
const nodeMeta = node.getNodeMeta();
|
|
2448
|
+
const subCanvas = nodeMeta.subCanvas?.(node);
|
|
2449
|
+
return subCanvas;
|
|
2450
|
+
}
|
|
2451
|
+
getNodeChildren(node) {
|
|
2452
|
+
if (!node) return [];
|
|
2453
|
+
const subCanvas = this.getNodeSubCanvas(node);
|
|
2454
|
+
const childrenWithCanvas = subCanvas ? subCanvas.canvasNode.collapsedChildren : node.collapsedChildren;
|
|
2455
|
+
const children = childrenWithCanvas.filter((child) => {
|
|
2456
|
+
const childMeta = child.getNodeMeta();
|
|
2457
|
+
return !childMeta.subCanvas?.(node)?.isCanvas;
|
|
2458
|
+
}).filter(Boolean);
|
|
2459
|
+
return children;
|
|
2460
|
+
}
|
|
2461
|
+
toLineJSON(line) {
|
|
2462
|
+
const lineJSON = line.toJSON();
|
|
2463
|
+
if (!line.to || !line.info.to || !line.toPort) {
|
|
2464
|
+
return;
|
|
2465
|
+
}
|
|
2466
|
+
const fromSubCanvas = this.getNodeSubCanvas(line.from);
|
|
2467
|
+
const toSubCanvas = this.getNodeSubCanvas(line.to);
|
|
2468
|
+
if (fromSubCanvas && !fromSubCanvas.isCanvas && toSubCanvas && toSubCanvas.isCanvas) {
|
|
2469
|
+
return;
|
|
2470
|
+
}
|
|
2471
|
+
if (line.from === line.to.parent && fromSubCanvas) {
|
|
2472
|
+
return {
|
|
2473
|
+
...lineJSON,
|
|
2474
|
+
sourceNodeID: fromSubCanvas.parentNode.id
|
|
2475
|
+
};
|
|
2476
|
+
}
|
|
2477
|
+
if (line.to === line.from.parent && toSubCanvas) {
|
|
2478
|
+
return {
|
|
2479
|
+
...lineJSON,
|
|
2480
|
+
targetNodeID: toSubCanvas.parentNode.id
|
|
2481
|
+
};
|
|
2482
|
+
}
|
|
2483
|
+
return lineJSON;
|
|
2484
|
+
}
|
|
2485
|
+
createWorkflowLine(json, parentId) {
|
|
2486
|
+
const fromNode = this.getNode(json.sourceNodeID);
|
|
2487
|
+
const toNode = this.getNode(json.targetNodeID);
|
|
2488
|
+
if (!fromNode || !toNode) {
|
|
2489
|
+
return;
|
|
2490
|
+
}
|
|
2491
|
+
const lineInfo = {
|
|
2492
|
+
from: json.sourceNodeID,
|
|
2493
|
+
fromPort: json.sourcePortID,
|
|
2494
|
+
to: json.targetNodeID,
|
|
2495
|
+
toPort: json.targetPortID
|
|
2496
|
+
};
|
|
2497
|
+
if (!parentId) {
|
|
2498
|
+
return this.linesManager.createLine(lineInfo);
|
|
2499
|
+
}
|
|
2500
|
+
const canvasNode = this.getNode(parentId);
|
|
2501
|
+
if (!canvasNode) {
|
|
2502
|
+
return this.linesManager.createLine(lineInfo);
|
|
2503
|
+
}
|
|
2504
|
+
const parentSubCanvas = this.getNodeSubCanvas(canvasNode);
|
|
2505
|
+
if (!parentSubCanvas) {
|
|
2506
|
+
return this.linesManager.createLine(lineInfo);
|
|
2507
|
+
}
|
|
2508
|
+
if (lineInfo.from === parentSubCanvas.parentNode.id) {
|
|
2509
|
+
return this.linesManager.createLine({
|
|
2510
|
+
...lineInfo,
|
|
2511
|
+
from: parentSubCanvas.canvasNode.id
|
|
2512
|
+
});
|
|
2513
|
+
}
|
|
2514
|
+
if (lineInfo.to === parentSubCanvas.parentNode.id) {
|
|
2515
|
+
return this.linesManager.createLine({
|
|
2516
|
+
...lineInfo,
|
|
2517
|
+
to: parentSubCanvas.canvasNode.id
|
|
2518
|
+
});
|
|
2519
|
+
}
|
|
2520
|
+
return this.linesManager.createLine(lineInfo);
|
|
2521
|
+
}
|
|
2522
|
+
};
|
|
2523
|
+
__decorateClass([
|
|
2524
|
+
(0, import_inversify5.inject)(WorkflowLinesManager)
|
|
2525
|
+
], WorkflowDocument.prototype, "linesManager", 2);
|
|
2526
|
+
__decorateClass([
|
|
2527
|
+
(0, import_inversify5.inject)(import_core13.PlaygroundConfigEntity)
|
|
2528
|
+
], WorkflowDocument.prototype, "playgroundConfig", 2);
|
|
2529
|
+
__decorateClass([
|
|
2530
|
+
(0, import_core13.injectPlaygroundContext)()
|
|
2531
|
+
], WorkflowDocument.prototype, "playgroundContext", 2);
|
|
2532
|
+
__decorateClass([
|
|
2533
|
+
(0, import_inversify5.inject)(WorkflowDocumentOptions)
|
|
2534
|
+
], WorkflowDocument.prototype, "options", 2);
|
|
2535
|
+
__decorateClass([
|
|
2536
|
+
(0, import_inversify5.inject)(import_form_core3.NodeEngineContext),
|
|
2537
|
+
(0, import_inversify5.optional)()
|
|
2538
|
+
], WorkflowDocument.prototype, "nodeEngineContext", 2);
|
|
2539
|
+
__decorateClass([
|
|
2540
|
+
(0, import_inversify5.inject)(WorkflowSelectService)
|
|
2541
|
+
], WorkflowDocument.prototype, "selectServices", 2);
|
|
2542
|
+
__decorateClass([
|
|
2543
|
+
(0, import_inversify5.postConstruct)()
|
|
2544
|
+
], WorkflowDocument.prototype, "init", 1);
|
|
2545
|
+
WorkflowDocument = __decorateClass([
|
|
2546
|
+
(0, import_inversify5.injectable)()
|
|
2547
|
+
], WorkflowDocument);
|
|
2548
|
+
|
|
2549
|
+
// src/service/workflow-drag-service.ts
|
|
2550
|
+
var DRAG_TIMEOUT = 100;
|
|
2551
|
+
var DRAG_MIN_DELTA = 5;
|
|
2552
|
+
function checkDragSuccess(time, e, originLine) {
|
|
2553
|
+
if (!originLine || time > DRAG_TIMEOUT || Math.abs(e.endPos.x - e.startPos.x) >= DRAG_MIN_DELTA || Math.abs(e.endPos.y - e.startPos.y) >= DRAG_MIN_DELTA) {
|
|
2554
|
+
return true;
|
|
2555
|
+
}
|
|
2556
|
+
return false;
|
|
2557
|
+
}
|
|
2558
|
+
var WorkflowDragService = class {
|
|
2559
|
+
constructor() {
|
|
2560
|
+
this._onDragLineEventEmitter = new import_utils17.Emitter();
|
|
2561
|
+
this.onDragLineEventChange = this._onDragLineEventEmitter.event;
|
|
2562
|
+
this.isDragging = false;
|
|
2563
|
+
this._nodesDragEmitter = new import_utils17.Emitter();
|
|
2564
|
+
this.onNodesDrag = this._nodesDragEmitter.event;
|
|
2565
|
+
this._toDispose = new import_utils17.DisposableCollection();
|
|
2566
|
+
this._droppableTransforms = [];
|
|
2567
|
+
this.posAdjusters = /* @__PURE__ */ new Set();
|
|
2568
|
+
this._onDragLineEndCallbacks = /* @__PURE__ */ new Map();
|
|
2569
|
+
}
|
|
2570
|
+
init() {
|
|
2571
|
+
this._toDispose.pushAll([this._onDragLineEventEmitter, this._nodesDragEmitter]);
|
|
2572
|
+
}
|
|
2573
|
+
dispose() {
|
|
2574
|
+
this._toDispose.dispose();
|
|
2575
|
+
}
|
|
2576
|
+
/**
|
|
2577
|
+
* 拖拽选中节点
|
|
2578
|
+
* @param event
|
|
2579
|
+
*/
|
|
2580
|
+
startDragSelectedNodes(event) {
|
|
2581
|
+
let { selectedNodes } = this.selectService;
|
|
2582
|
+
if (selectedNodes.length === 0 || this.playgroundConfig.readonly || this.playgroundConfig.disabled) {
|
|
2583
|
+
return Promise.resolve(false);
|
|
2584
|
+
}
|
|
2585
|
+
const sameParent = this.childrenOfContainer(selectedNodes);
|
|
2586
|
+
if (sameParent && sameParent.flowNodeType !== import_document8.FlowNodeBaseType.ROOT) {
|
|
2587
|
+
selectedNodes = [sameParent];
|
|
2588
|
+
}
|
|
2589
|
+
const { altKey } = event;
|
|
2590
|
+
let startPosition = this.getNodesPosition(selectedNodes);
|
|
2591
|
+
let startPositions = selectedNodes.map((node) => {
|
|
2592
|
+
const transform = node.getData(import_core14.TransformData);
|
|
2593
|
+
return { x: transform.position.x, y: transform.position.y };
|
|
2594
|
+
});
|
|
2595
|
+
let dragSuccess = false;
|
|
2596
|
+
const startTime = Date.now();
|
|
2597
|
+
const dragger = new import_core14.PlaygroundDrag({
|
|
2598
|
+
onDragStart: () => {
|
|
2599
|
+
this.isDragging = true;
|
|
2600
|
+
},
|
|
2601
|
+
onDrag: (e) => {
|
|
2602
|
+
if (!dragSuccess && checkDragSuccess(Date.now() - startTime, e)) {
|
|
2603
|
+
dragSuccess = true;
|
|
2604
|
+
if (altKey) {
|
|
2605
|
+
const tryCopyNodes = selectedNodes;
|
|
2606
|
+
if (tryCopyNodes.length > 0) {
|
|
2607
|
+
this.commandService.executeCommand("PASTE_NODES" /* PASTE_NODES */, tryCopyNodes, true).then((newNodes) => {
|
|
2608
|
+
if (newNodes && Array.isArray(newNodes) && newNodes.length > 0) {
|
|
2609
|
+
selectedNodes = newNodes;
|
|
2610
|
+
startPosition = this.getNodesPosition(tryCopyNodes);
|
|
2611
|
+
startPositions = tryCopyNodes.filter((n) => !n.getNodeMeta().copyDisable).map((node) => {
|
|
2612
|
+
const transform = node.getData(import_core14.TransformData);
|
|
2613
|
+
return {
|
|
2614
|
+
x: transform.position.x,
|
|
2615
|
+
y: transform.position.y
|
|
2616
|
+
};
|
|
2617
|
+
});
|
|
2618
|
+
}
|
|
2619
|
+
});
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
const offset = this.getDragPosOffset({
|
|
2624
|
+
event: e,
|
|
2625
|
+
selectedNodes,
|
|
2626
|
+
startPosition
|
|
2627
|
+
});
|
|
2628
|
+
selectedNodes.forEach((node, index) => {
|
|
2629
|
+
const transform = node.getData(import_core14.TransformData);
|
|
2630
|
+
const nodeStartPosition = startPositions[index];
|
|
2631
|
+
const newPosition = {
|
|
2632
|
+
x: nodeStartPosition.x + offset.x,
|
|
2633
|
+
y: nodeStartPosition.y + offset.y
|
|
2634
|
+
};
|
|
2635
|
+
if (node.collapsedChildren?.length > 0) {
|
|
2636
|
+
node.collapsedChildren.forEach((childNode) => {
|
|
2637
|
+
const childNodeTransformData = childNode.getData(import_document7.FlowNodeTransformData);
|
|
2638
|
+
childNodeTransformData.fireChange();
|
|
2639
|
+
});
|
|
2640
|
+
}
|
|
2641
|
+
transform.update({
|
|
2642
|
+
position: newPosition
|
|
2643
|
+
});
|
|
2644
|
+
});
|
|
2645
|
+
},
|
|
2646
|
+
onDragEnd: () => {
|
|
2647
|
+
this.isDragging = false;
|
|
2648
|
+
this._nodesDragEmitter.fire({
|
|
2649
|
+
type: "onDragEnd",
|
|
2650
|
+
nodes: selectedNodes,
|
|
2651
|
+
startPositions,
|
|
2652
|
+
altKey
|
|
2653
|
+
});
|
|
2654
|
+
}
|
|
2655
|
+
});
|
|
2656
|
+
return dragger.start(event.clientX, event.clientY, this.playgroundConfig).then(() => dragSuccess);
|
|
2657
|
+
}
|
|
2658
|
+
/**
|
|
2659
|
+
* 通过拖入卡片添加
|
|
2660
|
+
* @param type
|
|
2661
|
+
* @param event
|
|
2662
|
+
* @param data 节点数据
|
|
2663
|
+
*/
|
|
2664
|
+
async dropCard(type, event, data, parent) {
|
|
2665
|
+
const mousePos = this.playgroundConfig.getPosFromMouseEvent(event);
|
|
2666
|
+
if (!this.playgroundConfig.getViewport().contains(mousePos.x, mousePos.y)) {
|
|
2667
|
+
return;
|
|
2668
|
+
}
|
|
2669
|
+
const position = this.adjustSubNodePosition(type, parent, mousePos);
|
|
2670
|
+
const node = await this.document.createWorkflowNodeByType(
|
|
2671
|
+
type,
|
|
2672
|
+
position,
|
|
2673
|
+
data,
|
|
2674
|
+
parent?.id
|
|
2675
|
+
);
|
|
2676
|
+
return node;
|
|
2677
|
+
}
|
|
2678
|
+
/**
|
|
2679
|
+
* 拖拽卡片到画布
|
|
2680
|
+
* 返回创建结果
|
|
2681
|
+
* @param type
|
|
2682
|
+
* @param event
|
|
2683
|
+
*/
|
|
2684
|
+
async startDragCard(type, event, data, cloneNode) {
|
|
2685
|
+
let domNode;
|
|
2686
|
+
let startPos = { x: 0, y: 0 };
|
|
2687
|
+
const deferred = new import_utils17.PromiseDeferred();
|
|
2688
|
+
const dragger = new import_core14.PlaygroundDrag({
|
|
2689
|
+
onDragStart: (e) => {
|
|
2690
|
+
const targetNode = event.currentTarget;
|
|
2691
|
+
domNode = cloneNode ? cloneNode(e) : targetNode.cloneNode(true);
|
|
2692
|
+
const bounds = targetNode.getBoundingClientRect();
|
|
2693
|
+
startPos = { x: bounds.left, y: bounds.top };
|
|
2694
|
+
import_utils17.domUtils.setStyle(domNode, {
|
|
2695
|
+
zIndex: 1e3,
|
|
2696
|
+
position: "absolute",
|
|
2697
|
+
left: startPos.x,
|
|
2698
|
+
top: startPos.y,
|
|
2699
|
+
boxShadow: "0 6px 8px 0 rgba(28, 31, 35, .2)"
|
|
2700
|
+
});
|
|
2701
|
+
document.body.appendChild(domNode);
|
|
2702
|
+
this.updateDroppableTransforms();
|
|
2703
|
+
},
|
|
2704
|
+
onDrag: (e) => {
|
|
2705
|
+
const deltaX = e.endPos.x - e.startPos.x;
|
|
2706
|
+
const deltaY = e.endPos.y - e.startPos.y;
|
|
2707
|
+
const left = startPos.x + deltaX;
|
|
2708
|
+
const right = startPos.y + deltaY;
|
|
2709
|
+
domNode.style.left = `${left}px`;
|
|
2710
|
+
domNode.style.top = `${right}px`;
|
|
2711
|
+
const { x, y } = this.playgroundConfig.getPosFromMouseEvent(e);
|
|
2712
|
+
const draggingRect = new import_utils17.Rectangle(x, y, 170, 90);
|
|
2713
|
+
const collisionTransform = this._droppableTransforms.find((transform) => {
|
|
2714
|
+
const { bounds, entity } = transform;
|
|
2715
|
+
const padding = this.document.layout.getPadding(entity);
|
|
2716
|
+
const transformRect = new import_utils17.Rectangle(
|
|
2717
|
+
bounds.x + padding.left + padding.right,
|
|
2718
|
+
bounds.y,
|
|
2719
|
+
bounds.width,
|
|
2720
|
+
bounds.height
|
|
2721
|
+
);
|
|
2722
|
+
return import_utils17.Rectangle.intersects(draggingRect, transformRect);
|
|
2723
|
+
});
|
|
2724
|
+
this.updateDropNode(collisionTransform?.entity);
|
|
2725
|
+
},
|
|
2726
|
+
onDragEnd: async (e) => {
|
|
2727
|
+
const dropNode = this._dropNode;
|
|
2728
|
+
const dragNode = await this.dropCard(type, e, data, dropNode);
|
|
2729
|
+
this.clearDrop();
|
|
2730
|
+
if (dragNode) {
|
|
2731
|
+
domNode.remove();
|
|
2732
|
+
deferred.resolve(dragNode);
|
|
2733
|
+
} else {
|
|
2734
|
+
domNode.style.transition = "all ease .2s";
|
|
2735
|
+
domNode.style.left = `${startPos.x}px`;
|
|
2736
|
+
domNode.style.top = `${startPos.y}px`;
|
|
2737
|
+
const TIMEOUT = 200;
|
|
2738
|
+
await (0, import_utils17.delay)(TIMEOUT);
|
|
2739
|
+
domNode.remove();
|
|
2740
|
+
deferred.resolve();
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
});
|
|
2744
|
+
await dragger.start(event.clientX, event.clientY);
|
|
2745
|
+
return deferred.promise;
|
|
2746
|
+
}
|
|
2747
|
+
/**
|
|
2748
|
+
* 如果存在容器节点,且传入鼠标坐标,需要用容器的坐标减去传入的鼠标坐标
|
|
2749
|
+
*/
|
|
2750
|
+
adjustSubNodePosition(subNodeType, containerNode, mousePos, resetEmptyPos = true) {
|
|
2751
|
+
if (!mousePos) {
|
|
2752
|
+
return { x: 0, y: 0 };
|
|
2753
|
+
}
|
|
2754
|
+
if (!subNodeType || !containerNode || containerNode.flowNodeType === import_document8.FlowNodeBaseType.ROOT) {
|
|
2755
|
+
return mousePos;
|
|
2756
|
+
}
|
|
2757
|
+
const isParentEmpty = !containerNode.children || containerNode.children.length === 0;
|
|
2758
|
+
const parentPadding = this.document.layout.getPadding(containerNode);
|
|
2759
|
+
const parentTransform = containerNode.getData(import_core14.TransformData);
|
|
2760
|
+
if (isParentEmpty && resetEmptyPos) {
|
|
2761
|
+
return {
|
|
2762
|
+
x: 0,
|
|
2763
|
+
y: parentPadding.top
|
|
2764
|
+
};
|
|
2765
|
+
} else {
|
|
2766
|
+
return {
|
|
2767
|
+
x: mousePos.x - parentTransform.position.x,
|
|
2768
|
+
y: mousePos.y - parentTransform.position.y
|
|
2769
|
+
};
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
/**
|
|
2773
|
+
* 注册位置调整
|
|
2774
|
+
*/
|
|
2775
|
+
registerPosAdjuster(adjuster) {
|
|
2776
|
+
this.posAdjusters.add(adjuster);
|
|
2777
|
+
return {
|
|
2778
|
+
dispose: () => this.posAdjusters.delete(adjuster)
|
|
2779
|
+
};
|
|
2780
|
+
}
|
|
2781
|
+
/**
|
|
2782
|
+
* 获取拖拽偏移
|
|
2783
|
+
*/
|
|
2784
|
+
getDragPosOffset(params) {
|
|
2785
|
+
const { event, selectedNodes, startPosition } = params;
|
|
2786
|
+
const { finalScale } = this.playgroundConfig;
|
|
2787
|
+
const mouseOffset = {
|
|
2788
|
+
x: (event.endPos.x - event.startPos.x) / finalScale,
|
|
2789
|
+
y: (event.endPos.y - event.startPos.y) / finalScale
|
|
2790
|
+
};
|
|
2791
|
+
const wholePosition = {
|
|
2792
|
+
x: startPosition.x + mouseOffset.x,
|
|
2793
|
+
y: startPosition.y + mouseOffset.y
|
|
2794
|
+
};
|
|
2795
|
+
const adjustedOffsets = Array.from(this.posAdjusters.values()).map(
|
|
2796
|
+
(adjuster) => adjuster({
|
|
2797
|
+
selectedNodes,
|
|
2798
|
+
position: wholePosition
|
|
2799
|
+
})
|
|
2800
|
+
);
|
|
2801
|
+
const offset = adjustedOffsets.reduce(
|
|
2802
|
+
(offset2, adjustOffset) => ({
|
|
2803
|
+
x: offset2.x + adjustOffset.x,
|
|
2804
|
+
y: offset2.y + adjustOffset.y
|
|
2805
|
+
}),
|
|
2806
|
+
mouseOffset
|
|
2807
|
+
);
|
|
2808
|
+
return offset;
|
|
2809
|
+
}
|
|
2810
|
+
updateDroppableTransforms() {
|
|
2811
|
+
this._droppableTransforms = this.document.getRenderDatas(import_document7.FlowNodeTransformData, false).filter((transform) => {
|
|
2812
|
+
const { entity } = transform;
|
|
2813
|
+
if (entity.originParent) {
|
|
2814
|
+
return this.nodeSelectable(entity) && this.nodeSelectable(entity.originParent);
|
|
2815
|
+
}
|
|
2816
|
+
return this.nodeSelectable(entity);
|
|
2817
|
+
}).filter((transform) => {
|
|
2818
|
+
const { entity } = transform;
|
|
2819
|
+
return entity.flowNodeType === import_document8.FlowNodeBaseType.SUB_CANVAS;
|
|
2820
|
+
});
|
|
2821
|
+
}
|
|
2822
|
+
/**
|
|
2823
|
+
* 获取节点整体位置
|
|
2824
|
+
*/
|
|
2825
|
+
getNodesPosition(nodes) {
|
|
2826
|
+
const selectedBounds = import_utils17.Rectangle.enlarge(
|
|
2827
|
+
nodes.map((n) => n.getData(import_document7.FlowNodeTransformData).bounds)
|
|
2828
|
+
);
|
|
2829
|
+
const position = {
|
|
2830
|
+
x: selectedBounds.x,
|
|
2831
|
+
y: selectedBounds.y
|
|
2832
|
+
};
|
|
2833
|
+
return position;
|
|
2834
|
+
}
|
|
2835
|
+
nodeSelectable(node) {
|
|
2836
|
+
const selectable = node.getNodeMeta().selectable;
|
|
2837
|
+
if (typeof selectable === "function") {
|
|
2838
|
+
return selectable(node);
|
|
2839
|
+
} else {
|
|
2840
|
+
return selectable;
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
updateDropNode(node) {
|
|
2844
|
+
if (this._dropNode) {
|
|
2845
|
+
if (this._dropNode.id === node?.id) {
|
|
2846
|
+
return;
|
|
2847
|
+
}
|
|
2848
|
+
this.selectService.clear();
|
|
2849
|
+
}
|
|
2850
|
+
if (node) {
|
|
2851
|
+
this.selectService.selectNode(node);
|
|
2852
|
+
}
|
|
2853
|
+
this._dropNode = node;
|
|
2854
|
+
}
|
|
2855
|
+
clearDrop() {
|
|
2856
|
+
if (this._dropNode) {
|
|
2857
|
+
this.selectService.clear();
|
|
2858
|
+
}
|
|
2859
|
+
this._dropNode = void 0;
|
|
2860
|
+
this._droppableTransforms = [];
|
|
2861
|
+
}
|
|
2862
|
+
setLineColor(line, color) {
|
|
2863
|
+
line.highlightColor = color;
|
|
2864
|
+
this.hoverService.clearHovered();
|
|
2865
|
+
}
|
|
2866
|
+
handleDragOnNode(toNode, fromPort, line, toPort, originLine) {
|
|
2867
|
+
if (toPort && (originLine?.toPort === toPort || toPort.portType === "input" && this.linesManager.canAddLine(fromPort, toPort, true))) {
|
|
2868
|
+
this.hoverService.updateHoveredKey(toPort.id);
|
|
2869
|
+
line.setToPort(toPort);
|
|
2870
|
+
this._onDragLineEventEmitter.fire({
|
|
2871
|
+
type: "onDrag",
|
|
2872
|
+
onDragNodeId: toNode.id
|
|
2873
|
+
});
|
|
2874
|
+
return {
|
|
2875
|
+
hasError: false
|
|
2876
|
+
};
|
|
2877
|
+
} else if (toNode.flowNodeType === import_document8.FlowNodeBaseType.SUB_CANVAS) {
|
|
2878
|
+
return {
|
|
2879
|
+
hasError: false
|
|
2880
|
+
};
|
|
2881
|
+
} else {
|
|
2882
|
+
this.setLineColor(line, this.linesManager.lineColor.error);
|
|
2883
|
+
return {
|
|
2884
|
+
hasError: true
|
|
2885
|
+
};
|
|
2886
|
+
}
|
|
2887
|
+
}
|
|
2888
|
+
childrenOfContainer(nodes) {
|
|
2889
|
+
if (nodes.length === 0) {
|
|
2890
|
+
return;
|
|
2891
|
+
}
|
|
2892
|
+
const sourceContainer = nodes[0]?.parent;
|
|
2893
|
+
if (!sourceContainer || sourceContainer.collapsedChildren.length !== nodes.length) {
|
|
2894
|
+
return;
|
|
2895
|
+
}
|
|
2896
|
+
const valid = nodes.every((node) => node?.parent === sourceContainer);
|
|
2897
|
+
if (!valid) {
|
|
2898
|
+
return;
|
|
2899
|
+
}
|
|
2900
|
+
return sourceContainer;
|
|
2901
|
+
}
|
|
2902
|
+
/**
|
|
2903
|
+
* 绘制线条
|
|
2904
|
+
* @param opts
|
|
2905
|
+
* @param event
|
|
2906
|
+
*/
|
|
2907
|
+
async startDrawingLine(fromPort, event, originLine) {
|
|
2908
|
+
const isFromInActivePort = !originLine && fromPort.isErrorPort() && fromPort.disabled;
|
|
2909
|
+
if (originLine?.disabled || isFromInActivePort || this.playgroundConfig.readonly || this.playgroundConfig.disabled) {
|
|
2910
|
+
return { dragSuccess: false, newLine: void 0 };
|
|
2911
|
+
}
|
|
2912
|
+
const config = this.playgroundConfig;
|
|
2913
|
+
const deferred = new import_utils17.PromiseDeferred();
|
|
2914
|
+
const preCursor = config.cursor;
|
|
2915
|
+
let line, toPort, toNode, lineErrorReset = false;
|
|
2916
|
+
const startTime = Date.now();
|
|
2917
|
+
let dragSuccess = false;
|
|
2918
|
+
const dragger = new import_core14.PlaygroundDrag({
|
|
2919
|
+
onDrag: (e) => {
|
|
2920
|
+
if (!line && checkDragSuccess(Date.now() - startTime, e, originLine)) {
|
|
2921
|
+
if (originLine) {
|
|
2922
|
+
originLine.highlightColor = this.linesManager.lineColor.hidden;
|
|
2923
|
+
}
|
|
2924
|
+
dragSuccess = true;
|
|
2925
|
+
line = this.linesManager.createLine({
|
|
2926
|
+
from: fromPort.node.id,
|
|
2927
|
+
fromPort: fromPort.portID,
|
|
2928
|
+
drawingTo: config.getPosFromMouseEvent(event)
|
|
2929
|
+
});
|
|
2930
|
+
if (!line) {
|
|
2931
|
+
return;
|
|
2932
|
+
}
|
|
2933
|
+
config.updateCursor("grab");
|
|
2934
|
+
line.highlightColor = this.linesManager.lineColor.drawing;
|
|
2935
|
+
this.hoverService.updateHoveredKey("");
|
|
2936
|
+
}
|
|
2937
|
+
if (!line) {
|
|
2938
|
+
return;
|
|
2939
|
+
}
|
|
2940
|
+
lineErrorReset = false;
|
|
2941
|
+
const dragPos = config.getPosFromMouseEvent(e);
|
|
2942
|
+
toNode = this.linesManager.getNodeFromMousePos(dragPos);
|
|
2943
|
+
toPort = this.linesManager.getPortFromMousePos(dragPos);
|
|
2944
|
+
if (!toPort) {
|
|
2945
|
+
line.setToPort(void 0);
|
|
2946
|
+
} else if (!this.linesManager.canAddLine(fromPort, toPort, true)) {
|
|
2947
|
+
line.highlightColor = this.linesManager.lineColor.error;
|
|
2948
|
+
lineErrorReset = true;
|
|
2949
|
+
line.setToPort(void 0);
|
|
2950
|
+
} else {
|
|
2951
|
+
line.setToPort(toPort);
|
|
2952
|
+
}
|
|
2953
|
+
this._onDragLineEventEmitter.fire({
|
|
2954
|
+
type: "onDrag"
|
|
2955
|
+
});
|
|
2956
|
+
this.setLineColor(line, this.linesManager.lineColor.drawing);
|
|
2957
|
+
if (toNode && toNode.flowNodeType !== import_document8.FlowNodeBaseType.SUB_CANVAS) {
|
|
2958
|
+
const portsData = toNode.getData(WorkflowNodePortsData);
|
|
2959
|
+
toPort = portsData.inputPorts[0];
|
|
2960
|
+
const { hasError } = this.handleDragOnNode(toNode, fromPort, line, toPort, originLine);
|
|
2961
|
+
lineErrorReset = hasError;
|
|
2962
|
+
}
|
|
2963
|
+
if (line.toPort) {
|
|
2964
|
+
line.drawingTo = { x: line.toPort.point.x, y: line.toPort.point.y };
|
|
2965
|
+
} else {
|
|
2966
|
+
line.drawingTo = { x: dragPos.x, y: dragPos.y };
|
|
2967
|
+
}
|
|
2968
|
+
originLine?.validate();
|
|
2969
|
+
line.validate();
|
|
2970
|
+
},
|
|
2971
|
+
// eslint-disable-next-line complexity
|
|
2972
|
+
onDragEnd: async (e) => {
|
|
2973
|
+
const dragPos = config.getPosFromMouseEvent(e);
|
|
2974
|
+
const onDragLineEndCallbacks = Array.from(this._onDragLineEndCallbacks.values());
|
|
2975
|
+
config.updateCursor(preCursor);
|
|
2976
|
+
await Promise.all(
|
|
2977
|
+
onDragLineEndCallbacks.map(
|
|
2978
|
+
(callback) => callback({
|
|
2979
|
+
fromPort,
|
|
2980
|
+
toPort,
|
|
2981
|
+
mousePos: dragPos,
|
|
2982
|
+
line,
|
|
2983
|
+
originLine,
|
|
2984
|
+
event: e
|
|
2985
|
+
})
|
|
2986
|
+
)
|
|
2987
|
+
);
|
|
2988
|
+
line?.dispose();
|
|
2989
|
+
this._onDragLineEventEmitter.fire({
|
|
2990
|
+
type: "onDragEnd"
|
|
2991
|
+
});
|
|
2992
|
+
if (originLine) {
|
|
2993
|
+
originLine.highlightColor = "";
|
|
2994
|
+
}
|
|
2995
|
+
const end = () => {
|
|
2996
|
+
originLine?.validate();
|
|
2997
|
+
deferred.resolve({ dragSuccess });
|
|
2998
|
+
};
|
|
2999
|
+
if (dragSuccess) {
|
|
3000
|
+
if (originLine && originLine.toPort === toPort) {
|
|
3001
|
+
return end();
|
|
3002
|
+
}
|
|
3003
|
+
if (toPort && toPort.portType !== "input") {
|
|
3004
|
+
return end();
|
|
3005
|
+
}
|
|
3006
|
+
const newLineInfo = toPort ? {
|
|
3007
|
+
from: fromPort.node.id,
|
|
3008
|
+
fromPort: fromPort.portID,
|
|
3009
|
+
to: toPort.node.id,
|
|
3010
|
+
toPort: toPort.portID
|
|
3011
|
+
} : void 0;
|
|
3012
|
+
const isReset = originLine && toPort;
|
|
3013
|
+
if (isReset && !this.linesManager.canReset(
|
|
3014
|
+
originLine.fromPort,
|
|
3015
|
+
originLine.toPort,
|
|
3016
|
+
toPort
|
|
3017
|
+
)) {
|
|
3018
|
+
return end();
|
|
3019
|
+
}
|
|
3020
|
+
if (originLine && (!this.linesManager.canRemove(originLine, newLineInfo, false) || lineErrorReset)) {
|
|
3021
|
+
return end();
|
|
3022
|
+
} else {
|
|
3023
|
+
originLine?.dispose();
|
|
3024
|
+
}
|
|
3025
|
+
if (!toPort || !this.linesManager.canAddLine(fromPort, toPort, false)) {
|
|
3026
|
+
return end();
|
|
3027
|
+
}
|
|
3028
|
+
const newLine = this.linesManager.createLine(newLineInfo);
|
|
3029
|
+
if (!newLine) {
|
|
3030
|
+
end();
|
|
3031
|
+
}
|
|
3032
|
+
deferred.resolve({
|
|
3033
|
+
dragSuccess,
|
|
3034
|
+
newLine
|
|
3035
|
+
});
|
|
3036
|
+
} else {
|
|
3037
|
+
end();
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
});
|
|
3041
|
+
await dragger.start(event.clientX, event.clientY, config);
|
|
3042
|
+
return deferred.promise;
|
|
3043
|
+
}
|
|
3044
|
+
/**
|
|
3045
|
+
* 重新连接线条
|
|
3046
|
+
* @param line
|
|
3047
|
+
* @param e
|
|
3048
|
+
*/
|
|
3049
|
+
async resetLine(line, e) {
|
|
3050
|
+
const { fromPort } = line;
|
|
3051
|
+
const { dragSuccess } = await this.startDrawingLine(fromPort, e, line);
|
|
3052
|
+
if (!dragSuccess) {
|
|
3053
|
+
this.selectService.select(line);
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
/** 线条拖拽结束 */
|
|
3057
|
+
onDragLineEnd(callback) {
|
|
3058
|
+
const id = (0, import_nanoid3.nanoid)();
|
|
3059
|
+
this._onDragLineEndCallbacks.set(id, callback);
|
|
3060
|
+
return {
|
|
3061
|
+
dispose: () => {
|
|
3062
|
+
this._onDragLineEndCallbacks.delete(id);
|
|
3063
|
+
}
|
|
3064
|
+
};
|
|
3065
|
+
}
|
|
3066
|
+
};
|
|
3067
|
+
__decorateClass([
|
|
3068
|
+
(0, import_inversify6.inject)(import_core14.PlaygroundConfigEntity)
|
|
3069
|
+
], WorkflowDragService.prototype, "playgroundConfig", 2);
|
|
3070
|
+
__decorateClass([
|
|
3071
|
+
(0, import_inversify6.inject)(WorkflowHoverService)
|
|
3072
|
+
], WorkflowDragService.prototype, "hoverService", 2);
|
|
3073
|
+
__decorateClass([
|
|
3074
|
+
(0, import_inversify6.inject)(WorkflowDocument)
|
|
3075
|
+
], WorkflowDragService.prototype, "document", 2);
|
|
3076
|
+
__decorateClass([
|
|
3077
|
+
(0, import_inversify6.inject)(WorkflowLinesManager)
|
|
3078
|
+
], WorkflowDragService.prototype, "linesManager", 2);
|
|
3079
|
+
__decorateClass([
|
|
3080
|
+
(0, import_inversify6.inject)(import_core14.CommandService)
|
|
3081
|
+
], WorkflowDragService.prototype, "commandService", 2);
|
|
3082
|
+
__decorateClass([
|
|
3083
|
+
(0, import_inversify6.inject)(WorkflowSelectService)
|
|
3084
|
+
], WorkflowDragService.prototype, "selectService", 2);
|
|
3085
|
+
__decorateClass([
|
|
3086
|
+
(0, import_inversify6.inject)(import_document7.FlowOperationBaseService)
|
|
3087
|
+
], WorkflowDragService.prototype, "operationService", 2);
|
|
3088
|
+
__decorateClass([
|
|
3089
|
+
(0, import_inversify6.postConstruct)()
|
|
3090
|
+
], WorkflowDragService.prototype, "init", 1);
|
|
3091
|
+
WorkflowDragService = __decorateClass([
|
|
3092
|
+
(0, import_inversify6.injectable)()
|
|
3093
|
+
], WorkflowDragService);
|
|
3094
|
+
|
|
3095
|
+
// src/service/workflow-reset-layout-service.ts
|
|
3096
|
+
var import_inversify7 = require("inversify");
|
|
3097
|
+
var import_core16 = require("@flowgram.ai/core");
|
|
3098
|
+
var import_core17 = require("@flowgram.ai/core");
|
|
3099
|
+
var import_utils18 = require("@flowgram.ai/utils");
|
|
3100
|
+
|
|
3101
|
+
// src/utils/layout-to-positions.ts
|
|
3102
|
+
var import_document9 = require("@flowgram.ai/document");
|
|
3103
|
+
var import_core15 = require("@flowgram.ai/core");
|
|
3104
|
+
var layoutToPositions = async (nodes, nodePositionMap) => {
|
|
3105
|
+
const newNodePositionMap = {};
|
|
3106
|
+
nodes.forEach((node) => {
|
|
3107
|
+
const transform = node.getData(import_core15.TransformData);
|
|
3108
|
+
const nodeTransform = node.getData(import_document9.FlowNodeTransformData);
|
|
3109
|
+
newNodePositionMap[node.id] = {
|
|
3110
|
+
x: transform.position.x,
|
|
3111
|
+
y: transform.position.y + nodeTransform.bounds.height / 2
|
|
3112
|
+
};
|
|
3113
|
+
});
|
|
3114
|
+
return new Promise((resolve) => {
|
|
3115
|
+
(0, import_core15.startTween)({
|
|
3116
|
+
from: { d: 0 },
|
|
3117
|
+
to: { d: 100 },
|
|
3118
|
+
duration: 300,
|
|
3119
|
+
onUpdate: (v) => {
|
|
3120
|
+
nodes.forEach((node) => {
|
|
3121
|
+
const transform = node.getData(import_core15.TransformData);
|
|
3122
|
+
const deltaX = (nodePositionMap[node.id].x - transform.position.x) * v.d / 100;
|
|
3123
|
+
const deltaY = (nodePositionMap[node.id].y - transform.bounds.height / 2 - transform.position.y) * v.d / 100;
|
|
3124
|
+
if (node.collapsedChildren?.length > 0) {
|
|
3125
|
+
node.collapsedChildren.forEach((childNode) => {
|
|
3126
|
+
const childNodeTransformData = childNode.getData(import_document9.FlowNodeTransformData);
|
|
3127
|
+
childNodeTransformData.fireChange();
|
|
3128
|
+
});
|
|
3129
|
+
}
|
|
3130
|
+
transform.update({
|
|
3131
|
+
position: {
|
|
3132
|
+
x: transform.position.x + deltaX,
|
|
3133
|
+
y: transform.position.y + deltaY
|
|
3134
|
+
}
|
|
3135
|
+
});
|
|
3136
|
+
});
|
|
3137
|
+
},
|
|
3138
|
+
onComplete: () => {
|
|
3139
|
+
resolve(newNodePositionMap);
|
|
3140
|
+
}
|
|
3141
|
+
});
|
|
3142
|
+
});
|
|
3143
|
+
};
|
|
3144
|
+
|
|
3145
|
+
// src/service/workflow-reset-layout-service.ts
|
|
3146
|
+
var WorkflowResetLayoutService = class {
|
|
3147
|
+
constructor() {
|
|
3148
|
+
this._resetLayoutEmitter = new import_utils18.Emitter();
|
|
3149
|
+
/**
|
|
3150
|
+
* reset layout事件
|
|
3151
|
+
*/
|
|
3152
|
+
this.onResetLayout = this._resetLayoutEmitter.event;
|
|
3153
|
+
this._toDispose = new import_utils18.DisposableCollection();
|
|
3154
|
+
}
|
|
3155
|
+
init() {
|
|
3156
|
+
this._toDispose.push(this._resetLayoutEmitter);
|
|
3157
|
+
}
|
|
3158
|
+
/**
|
|
3159
|
+
* 触发重置布局
|
|
3160
|
+
* @param nodeIds 节点id
|
|
3161
|
+
* @param positionMap 新布局数据
|
|
3162
|
+
* @param oldPositionMap 老布局数据
|
|
3163
|
+
*/
|
|
3164
|
+
fireResetLayout(nodeIds, positionMap, oldPositionMap) {
|
|
3165
|
+
this._resetLayoutEmitter.fire({
|
|
3166
|
+
nodeIds,
|
|
3167
|
+
positionMap,
|
|
3168
|
+
oldPositionMap
|
|
3169
|
+
});
|
|
3170
|
+
}
|
|
3171
|
+
/**
|
|
3172
|
+
* 根据数据重新布局
|
|
3173
|
+
* @param positionMap
|
|
3174
|
+
* @returns
|
|
3175
|
+
*/
|
|
3176
|
+
async layoutToPositions(nodeIds, positionMap) {
|
|
3177
|
+
const nodes = nodeIds.map((id) => this._entityManager.getEntityById(id)).filter(Boolean);
|
|
3178
|
+
const positions = await layoutToPositions(nodes, positionMap);
|
|
3179
|
+
fitView(this._document, this._config, true);
|
|
3180
|
+
return positions;
|
|
3181
|
+
}
|
|
3182
|
+
/**
|
|
3183
|
+
* 销毁
|
|
3184
|
+
*/
|
|
3185
|
+
dispose() {
|
|
3186
|
+
this._toDispose.dispose();
|
|
3187
|
+
}
|
|
3188
|
+
};
|
|
3189
|
+
__decorateClass([
|
|
3190
|
+
(0, import_inversify7.inject)(import_core16.PlaygroundConfigEntity)
|
|
3191
|
+
], WorkflowResetLayoutService.prototype, "_config", 2);
|
|
3192
|
+
__decorateClass([
|
|
3193
|
+
(0, import_inversify7.inject)(WorkflowDocument)
|
|
3194
|
+
], WorkflowResetLayoutService.prototype, "_document", 2);
|
|
3195
|
+
__decorateClass([
|
|
3196
|
+
(0, import_inversify7.inject)(import_core17.EntityManager)
|
|
3197
|
+
], WorkflowResetLayoutService.prototype, "_entityManager", 2);
|
|
3198
|
+
__decorateClass([
|
|
3199
|
+
(0, import_inversify7.postConstruct)()
|
|
3200
|
+
], WorkflowResetLayoutService.prototype, "init", 1);
|
|
3201
|
+
WorkflowResetLayoutService = __decorateClass([
|
|
3202
|
+
(0, import_inversify7.injectable)()
|
|
3203
|
+
], WorkflowResetLayoutService);
|
|
3204
|
+
|
|
3205
|
+
// src/hooks/use-playground-readonly-state.ts
|
|
3206
|
+
var import_react = require("react");
|
|
3207
|
+
var import_core18 = require("@flowgram.ai/core");
|
|
3208
|
+
function usePlaygroundReadonlyState(listenChange) {
|
|
3209
|
+
const playground = (0, import_core18.usePlayground)();
|
|
3210
|
+
const refresh = (0, import_core18.useRefresh)();
|
|
3211
|
+
(0, import_react.useEffect)(() => {
|
|
3212
|
+
let dispose = void 0;
|
|
3213
|
+
if (listenChange) {
|
|
3214
|
+
dispose = playground.config.onReadonlyOrDisabledChange(() => refresh());
|
|
3215
|
+
}
|
|
3216
|
+
return () => dispose?.dispose();
|
|
3217
|
+
}, [listenChange]);
|
|
3218
|
+
return playground.config.readonly;
|
|
3219
|
+
}
|
|
3220
|
+
|
|
3221
|
+
// src/hooks/use-node-render.tsx
|
|
3222
|
+
function checkTargetDraggable(el) {
|
|
3223
|
+
return el && el.tagName !== "INPUT" && el.tagName !== "TEXTAREA" && !el.closest(".flow-canvas-not-draggable");
|
|
3224
|
+
}
|
|
3225
|
+
function useNodeRender(nodeFromProps) {
|
|
3226
|
+
const node = nodeFromProps || (0, import_react2.useContext)(import_core19.PlaygroundEntityContext);
|
|
3227
|
+
const renderData = node.getData(import_document10.FlowNodeRenderData);
|
|
3228
|
+
const portsData = node.getData(WorkflowNodePortsData);
|
|
3229
|
+
const readonly = usePlaygroundReadonlyState();
|
|
3230
|
+
const dragService = (0, import_core19.useService)(WorkflowDragService);
|
|
3231
|
+
const selectionService = (0, import_core19.useService)(WorkflowSelectService);
|
|
3232
|
+
const isDragging = (0, import_react2.useRef)(false);
|
|
3233
|
+
const nodeRef = (0, import_react2.useRef)(null);
|
|
3234
|
+
const [linkingNodeId, setLinkingNodeId] = (0, import_react2.useState)("");
|
|
3235
|
+
(0, import_react2.useEffect)(() => {
|
|
3236
|
+
const disposable = dragService.onDragLineEventChange(({ type, onDragNodeId }) => {
|
|
3237
|
+
if (type === "onDrag") {
|
|
3238
|
+
setLinkingNodeId(onDragNodeId || "");
|
|
3239
|
+
} else {
|
|
3240
|
+
setLinkingNodeId("");
|
|
3241
|
+
}
|
|
3242
|
+
});
|
|
3243
|
+
return () => {
|
|
3244
|
+
disposable.dispose();
|
|
3245
|
+
};
|
|
3246
|
+
}, []);
|
|
3247
|
+
const startDrag = (0, import_react2.useCallback)(
|
|
3248
|
+
(e) => {
|
|
3249
|
+
e.preventDefault();
|
|
3250
|
+
if (!selectionService.isSelected(node.id)) {
|
|
3251
|
+
selectNode(e);
|
|
3252
|
+
}
|
|
3253
|
+
if (!checkTargetDraggable(e.target) || !checkTargetDraggable(document.activeElement)) {
|
|
3254
|
+
return;
|
|
3255
|
+
}
|
|
3256
|
+
isDragging.current = true;
|
|
3257
|
+
dragService.startDragSelectedNodes(e).finally(
|
|
3258
|
+
() => setTimeout(() => {
|
|
3259
|
+
isDragging.current = false;
|
|
3260
|
+
})
|
|
3261
|
+
);
|
|
3262
|
+
},
|
|
3263
|
+
[dragService, node]
|
|
3264
|
+
);
|
|
3265
|
+
const selectNode = (0, import_react2.useCallback)(
|
|
3266
|
+
(e) => {
|
|
3267
|
+
if (isDragging.current) {
|
|
3268
|
+
return;
|
|
3269
|
+
}
|
|
3270
|
+
if (e.metaKey || e.shiftKey || e.ctrlKey) {
|
|
3271
|
+
selectionService.toggleSelect(node);
|
|
3272
|
+
} else {
|
|
3273
|
+
selectionService.selectNode(node);
|
|
3274
|
+
}
|
|
3275
|
+
if (e.target) {
|
|
3276
|
+
e.target.focus();
|
|
3277
|
+
}
|
|
3278
|
+
},
|
|
3279
|
+
[node]
|
|
3280
|
+
);
|
|
3281
|
+
const deleteNode = (0, import_react2.useCallback)(() => node.dispose(), [node]);
|
|
3282
|
+
(0, import_core19.useListenEvents)(selectionService.onSelectionChanged, portsData.onDataChange);
|
|
3283
|
+
const isFirefox = navigator?.userAgent?.includes?.("Firefox");
|
|
3284
|
+
const onFocus = (0, import_react2.useCallback)(() => {
|
|
3285
|
+
if (isFirefox) {
|
|
3286
|
+
nodeRef.current?.setAttribute("draggable", "false");
|
|
3287
|
+
}
|
|
3288
|
+
}, []);
|
|
3289
|
+
const onBlur = (0, import_react2.useCallback)(() => {
|
|
3290
|
+
if (isFirefox) {
|
|
3291
|
+
nodeRef.current?.setAttribute("draggable", "true");
|
|
3292
|
+
}
|
|
3293
|
+
}, []);
|
|
3294
|
+
const getExtInfo = (0, import_react2.useCallback)(() => node.getExtInfo(), [node]);
|
|
3295
|
+
const updateExtInfo = (0, import_react2.useCallback)(
|
|
3296
|
+
(data) => {
|
|
3297
|
+
node.updateExtInfo(data);
|
|
3298
|
+
},
|
|
3299
|
+
[node]
|
|
3300
|
+
);
|
|
3301
|
+
const form = (0, import_react2.useMemo)(() => (0, import_node.getNodeForm)(node), [node]);
|
|
3302
|
+
const formState = (0, import_reactive.useObserve)(form?.state || {});
|
|
3303
|
+
const toggleExpand = (0, import_react2.useCallback)(() => {
|
|
3304
|
+
renderData.toggleExpand();
|
|
3305
|
+
}, [renderData]);
|
|
3306
|
+
return {
|
|
3307
|
+
node,
|
|
3308
|
+
selected: selectionService.isSelected(node.id),
|
|
3309
|
+
activated: selectionService.isActivated(node.id),
|
|
3310
|
+
expanded: renderData.expanded,
|
|
3311
|
+
startDrag,
|
|
3312
|
+
ports: portsData.allPorts,
|
|
3313
|
+
deleteNode,
|
|
3314
|
+
selectNode,
|
|
3315
|
+
readonly,
|
|
3316
|
+
linkingNodeId,
|
|
3317
|
+
nodeRef,
|
|
3318
|
+
onFocus,
|
|
3319
|
+
onBlur,
|
|
3320
|
+
getExtInfo,
|
|
3321
|
+
updateExtInfo,
|
|
3322
|
+
toggleExpand,
|
|
3323
|
+
get form() {
|
|
3324
|
+
if (!form) return void 0;
|
|
3325
|
+
return {
|
|
3326
|
+
...form,
|
|
3327
|
+
get values() {
|
|
3328
|
+
return form.values;
|
|
3329
|
+
},
|
|
3330
|
+
get state() {
|
|
3331
|
+
return formState;
|
|
3332
|
+
}
|
|
3333
|
+
};
|
|
3334
|
+
}
|
|
3335
|
+
};
|
|
3336
|
+
}
|
|
3337
|
+
|
|
3338
|
+
// src/hooks/use-current-dom-node.ts
|
|
3339
|
+
var import_document11 = require("@flowgram.ai/document");
|
|
3340
|
+
var import_core20 = require("@flowgram.ai/core");
|
|
3341
|
+
function useCurrentDomNode() {
|
|
3342
|
+
const entity = (0, import_core20.useEntityFromContext)();
|
|
3343
|
+
const renderData = entity.getData(import_document11.FlowNodeRenderData);
|
|
3344
|
+
return renderData.node;
|
|
3345
|
+
}
|
|
3346
|
+
|
|
3347
|
+
// src/hooks/use-current-entity.ts
|
|
3348
|
+
var import_core21 = require("@flowgram.ai/core");
|
|
3349
|
+
function useCurrentEntity() {
|
|
3350
|
+
return (0, import_core21.useEntityFromContext)();
|
|
3351
|
+
}
|
|
3352
|
+
|
|
3353
|
+
// src/hooks/use-workflow-document.ts
|
|
3354
|
+
var import_core22 = require("@flowgram.ai/core");
|
|
3355
|
+
function useWorkflowDocument() {
|
|
3356
|
+
return (0, import_core22.useService)(WorkflowDocument);
|
|
3357
|
+
}
|
|
3358
|
+
|
|
3359
|
+
// src/constants.ts
|
|
3360
|
+
var EditorCursorState = /* @__PURE__ */ ((EditorCursorState2) => {
|
|
3361
|
+
EditorCursorState2["GRAB"] = "GRAB";
|
|
3362
|
+
EditorCursorState2["SELECT"] = "SELECT";
|
|
3363
|
+
return EditorCursorState2;
|
|
3364
|
+
})(EditorCursorState || {});
|
|
3365
|
+
var InteractiveType = /* @__PURE__ */ ((InteractiveType2) => {
|
|
3366
|
+
InteractiveType2["MOUSE"] = "MOUSE";
|
|
3367
|
+
InteractiveType2["PAD"] = "PAD";
|
|
3368
|
+
return InteractiveType2;
|
|
3369
|
+
})(InteractiveType || {});
|
|
3370
|
+
|
|
3371
|
+
// src/workflow-document-container-module.ts
|
|
3372
|
+
var import_inversify9 = require("inversify");
|
|
3373
|
+
var import_document13 = require("@flowgram.ai/document");
|
|
3374
|
+
var import_utils20 = require("@flowgram.ai/utils");
|
|
3375
|
+
|
|
3376
|
+
// src/workflow-document-contribution.ts
|
|
3377
|
+
var import_inversify8 = require("inversify");
|
|
3378
|
+
var import_document12 = require("@flowgram.ai/document");
|
|
3379
|
+
var WorkflowDocumentContribution = class {
|
|
3380
|
+
registerDocument(document2) {
|
|
3381
|
+
document2.registerNodeDatas(
|
|
3382
|
+
import_document12.FlowNodeTransformData,
|
|
3383
|
+
import_document12.FlowNodeRenderData,
|
|
3384
|
+
WorkflowNodePortsData,
|
|
3385
|
+
WorkflowNodeLinesData
|
|
3386
|
+
);
|
|
3387
|
+
document2.registerLayout(this.freeLayout);
|
|
3388
|
+
}
|
|
3389
|
+
};
|
|
3390
|
+
__decorateClass([
|
|
3391
|
+
(0, import_inversify8.inject)(FreeLayout)
|
|
3392
|
+
], WorkflowDocumentContribution.prototype, "freeLayout", 2);
|
|
3393
|
+
WorkflowDocumentContribution = __decorateClass([
|
|
3394
|
+
(0, import_inversify8.injectable)()
|
|
3395
|
+
], WorkflowDocumentContribution);
|
|
3396
|
+
|
|
3397
|
+
// src/utils/get-url-params.ts
|
|
3398
|
+
function getUrlParams() {
|
|
3399
|
+
return location.search.replace(/^\?/, "").split("&").reduce((res, key) => {
|
|
3400
|
+
const [k, v] = key.split("=");
|
|
3401
|
+
res[k] = v;
|
|
3402
|
+
return res;
|
|
3403
|
+
}, {});
|
|
3404
|
+
}
|
|
3405
|
+
|
|
3406
|
+
// src/workflow-document-container-module.ts
|
|
3407
|
+
var WorkflowDocumentContainerModule = new import_inversify9.ContainerModule(
|
|
3408
|
+
(bind, unbind, isBound, rebind) => {
|
|
3409
|
+
bind(WorkflowDocument).toSelf().inSingletonScope();
|
|
3410
|
+
bind(WorkflowLinesManager).toSelf().inSingletonScope();
|
|
3411
|
+
bind(FreeLayout).toSelf().inSingletonScope();
|
|
3412
|
+
bind(WorkflowDragService).toSelf().inSingletonScope();
|
|
3413
|
+
bind(WorkflowSelectService).toSelf().inSingletonScope();
|
|
3414
|
+
bind(WorkflowHoverService).toSelf().inSingletonScope();
|
|
3415
|
+
bind(WorkflowResetLayoutService).toSelf().inSingletonScope();
|
|
3416
|
+
bind(URLParams).toDynamicValue(() => getUrlParams()).inSingletonScope();
|
|
3417
|
+
(0, import_utils20.bindContributions)(bind, WorkflowDocumentContribution, [import_document13.FlowDocumentContribution]);
|
|
3418
|
+
bind(WorkflowDocumentOptions).toConstantValue({
|
|
3419
|
+
...WorkflowDocumentOptionsDefault
|
|
3420
|
+
});
|
|
3421
|
+
rebind(import_document13.FlowDocument).toService(WorkflowDocument);
|
|
3422
|
+
bind(WorkflowDocumentProvider).toDynamicValue((ctx) => () => ctx.container.get(WorkflowDocument)).inSingletonScope();
|
|
3423
|
+
}
|
|
3424
|
+
);
|
|
3425
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3426
|
+
0 && (module.exports = {
|
|
3427
|
+
BezierControlType,
|
|
3428
|
+
EditorCursorState,
|
|
3429
|
+
FoldLine,
|
|
3430
|
+
InteractiveType,
|
|
3431
|
+
LINE_HOVER_DISTANCE,
|
|
3432
|
+
LineColors,
|
|
3433
|
+
LineType,
|
|
3434
|
+
POINT_RADIUS,
|
|
3435
|
+
PORT_SIZE,
|
|
3436
|
+
URLParams,
|
|
3437
|
+
WORKFLOW_LINE_ENTITY,
|
|
3438
|
+
WorkflowCommands,
|
|
3439
|
+
WorkflowContentChangeType,
|
|
3440
|
+
WorkflowDocument,
|
|
3441
|
+
WorkflowDocumentContainerModule,
|
|
3442
|
+
WorkflowDocumentOptions,
|
|
3443
|
+
WorkflowDocumentOptionsDefault,
|
|
3444
|
+
WorkflowDocumentProvider,
|
|
3445
|
+
WorkflowDragService,
|
|
3446
|
+
WorkflowHoverService,
|
|
3447
|
+
WorkflowLineEntity,
|
|
3448
|
+
WorkflowLinesManager,
|
|
3449
|
+
WorkflowNodeEntity,
|
|
3450
|
+
WorkflowNodeLinesData,
|
|
3451
|
+
WorkflowNodePortsData,
|
|
3452
|
+
WorkflowPortEntity,
|
|
3453
|
+
WorkflowResetLayoutService,
|
|
3454
|
+
WorkflowSelectService,
|
|
3455
|
+
bindConfigEntity,
|
|
3456
|
+
compose,
|
|
3457
|
+
composeAsync,
|
|
3458
|
+
delay,
|
|
3459
|
+
domReactToBounds,
|
|
3460
|
+
fitView,
|
|
3461
|
+
getAntiOverlapPosition,
|
|
3462
|
+
getBezierHorizontalControlPoints,
|
|
3463
|
+
getBezierVerticalControlPoints,
|
|
3464
|
+
getPortEntityId,
|
|
3465
|
+
nanoid,
|
|
3466
|
+
useConfigEntity,
|
|
3467
|
+
useCurrentDomNode,
|
|
3468
|
+
useCurrentEntity,
|
|
3469
|
+
useEntities,
|
|
3470
|
+
useEntityDataFromContext,
|
|
3471
|
+
useEntityFromContext,
|
|
3472
|
+
useListenEvents,
|
|
3473
|
+
useNodeRender,
|
|
3474
|
+
usePlayground,
|
|
3475
|
+
usePlaygroundContainer,
|
|
3476
|
+
usePlaygroundContext,
|
|
3477
|
+
usePlaygroundLatest,
|
|
3478
|
+
usePlaygroundReadonlyState,
|
|
3479
|
+
useRefresh,
|
|
3480
|
+
useService,
|
|
3481
|
+
useWorkflowDocument
|
|
3482
|
+
});
|
|
3483
|
+
//# sourceMappingURL=index.js.map
|