@flowgram.ai/free-layout-core 0.2.27 → 0.2.28
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/index.js +50 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +89 -51
- package/dist/index.js.map +1 -1
- package/dist/typings/index.d.mts +1 -1
- package/dist/typings/index.d.ts +1 -1
- package/dist/typings/workflow-drag.d.mts +1 -1
- package/dist/typings/workflow-drag.d.ts +1 -1
- package/dist/typings/workflow-json.d.mts +1 -1
- package/dist/typings/workflow-json.d.ts +1 -1
- package/dist/typings/workflow-line.d.mts +1 -1
- package/dist/typings/workflow-line.d.ts +1 -1
- package/dist/typings/workflow-node.d.mts +1 -1
- package/dist/typings/workflow-node.d.ts +1 -1
- package/dist/typings/workflow-registry.d.mts +1 -1
- package/dist/typings/workflow-registry.d.ts +1 -1
- package/dist/{workflow-line-entity-pkRs4Hgt.d.ts → workflow-line-entity-A940oVos.d.ts} +4 -4
- package/dist/{workflow-line-entity-BmfC83KK.d.mts → workflow-line-entity-JyclGGfq.d.mts} +4 -4
- package/package.json +10 -10
package/dist/esm/index.js
CHANGED
|
@@ -72,6 +72,34 @@ import { Rectangle as Rectangle6, SizeSchema } from "@flowgram.ai/utils";
|
|
|
72
72
|
import { bindConfigEntity } from "@flowgram.ai/core";
|
|
73
73
|
import { delay } from "@flowgram.ai/utils";
|
|
74
74
|
|
|
75
|
+
// src/utils/build-group-json.ts
|
|
76
|
+
import { FlowNodeBaseType } from "@flowgram.ai/document";
|
|
77
|
+
var buildGroupJSON = (json) => {
|
|
78
|
+
const { nodes, edges } = json;
|
|
79
|
+
const groupJSONs = nodes.filter(
|
|
80
|
+
(nodeJSON) => nodeJSON.type === FlowNodeBaseType.GROUP
|
|
81
|
+
);
|
|
82
|
+
const nodeJSONMap = new Map(nodes.map((n) => [n.id, n]));
|
|
83
|
+
const groupNodeJSONs = groupJSONs.map((groupJSON) => {
|
|
84
|
+
const groupBlocks = (groupJSON.data.blockIDs ?? []).map((blockID) => nodeJSONMap.get(blockID)).filter(Boolean);
|
|
85
|
+
const groupEdges = edges?.filter(
|
|
86
|
+
(edge) => groupBlocks.some((block) => block.id === edge.sourceNodeID || block.id === edge.targetNodeID)
|
|
87
|
+
);
|
|
88
|
+
const groupNodeJSON = {
|
|
89
|
+
...groupJSON,
|
|
90
|
+
blocks: groupBlocks,
|
|
91
|
+
edges: groupEdges
|
|
92
|
+
};
|
|
93
|
+
return groupNodeJSON;
|
|
94
|
+
});
|
|
95
|
+
const groupBlockSet = new Set(groupJSONs.map((groupJSON) => groupJSON.data.blockIDs).flat());
|
|
96
|
+
const processedNodes = nodes.filter((nodeJSON) => !groupBlockSet.has(nodeJSON.id)).concat(groupNodeJSONs);
|
|
97
|
+
return {
|
|
98
|
+
nodes: processedNodes,
|
|
99
|
+
edges
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
|
|
75
103
|
// src/utils/nanoid.ts
|
|
76
104
|
import { nanoid as nanoidOrigin } from "nanoid";
|
|
77
105
|
function nanoid(n) {
|
|
@@ -1185,7 +1213,7 @@ import {
|
|
|
1185
1213
|
FlowNodeTransformData as FlowNodeTransformData6,
|
|
1186
1214
|
FlowOperationBaseService
|
|
1187
1215
|
} from "@flowgram.ai/document";
|
|
1188
|
-
import { FlowNodeBaseType as
|
|
1216
|
+
import { FlowNodeBaseType as FlowNodeBaseType3 } from "@flowgram.ai/document";
|
|
1189
1217
|
import {
|
|
1190
1218
|
CommandService,
|
|
1191
1219
|
MouseTouchEvent,
|
|
@@ -1625,7 +1653,7 @@ import { Emitter as Emitter4 } from "@flowgram.ai/utils";
|
|
|
1625
1653
|
import { NodeEngineContext } from "@flowgram.ai/form-core";
|
|
1626
1654
|
import {
|
|
1627
1655
|
FlowDocument,
|
|
1628
|
-
FlowNodeBaseType,
|
|
1656
|
+
FlowNodeBaseType as FlowNodeBaseType2,
|
|
1629
1657
|
FlowNodeTransformData as FlowNodeTransformData5
|
|
1630
1658
|
} from "@flowgram.ai/document";
|
|
1631
1659
|
import {
|
|
@@ -1918,7 +1946,7 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
1918
1946
|
toJSON: () => this.toNodeJSON(node)
|
|
1919
1947
|
});
|
|
1920
1948
|
node.onDispose(() => {
|
|
1921
|
-
if (!node.parent || node.parent.flowNodeType ===
|
|
1949
|
+
if (!node.parent || node.parent.flowNodeType === FlowNodeBaseType2.ROOT) {
|
|
1922
1950
|
return;
|
|
1923
1951
|
}
|
|
1924
1952
|
const parentTransform = node.parent.getData(FlowNodeTransformData5);
|
|
@@ -2086,10 +2114,10 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
2086
2114
|
);
|
|
2087
2115
|
}
|
|
2088
2116
|
getAllNodes() {
|
|
2089
|
-
return this.entityManager.getEntities(WorkflowNodeEntity).filter((n) => n.id !==
|
|
2117
|
+
return this.entityManager.getEntities(WorkflowNodeEntity).filter((n) => n.id !== FlowNodeBaseType2.ROOT);
|
|
2090
2118
|
}
|
|
2091
2119
|
getAllPorts() {
|
|
2092
|
-
return this.entityManager.getEntities(WorkflowPortEntity).filter((p) => p.node.id !==
|
|
2120
|
+
return this.entityManager.getEntities(WorkflowPortEntity).filter((p) => p.node.id !== FlowNodeBaseType2.ROOT);
|
|
2093
2121
|
}
|
|
2094
2122
|
/**
|
|
2095
2123
|
* 获取画布中的非游离节点
|
|
@@ -2244,10 +2272,11 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
2244
2272
|
*/
|
|
2245
2273
|
toJSON() {
|
|
2246
2274
|
const rootJSON = this.toNodeJSON(this.root);
|
|
2247
|
-
|
|
2275
|
+
const json = {
|
|
2248
2276
|
nodes: rootJSON.blocks ?? [],
|
|
2249
2277
|
edges: rootJSON.edges ?? []
|
|
2250
2278
|
};
|
|
2279
|
+
return json;
|
|
2251
2280
|
}
|
|
2252
2281
|
dispose() {
|
|
2253
2282
|
super.dispose();
|
|
@@ -2259,10 +2288,11 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
2259
2288
|
renderJSON(json, options) {
|
|
2260
2289
|
const { parent = this.root, isClone = false } = options ?? {};
|
|
2261
2290
|
const containerID = this.getNodeSubCanvas(parent)?.canvasNode.id ?? parent.id;
|
|
2262
|
-
const
|
|
2291
|
+
const processedJSON = buildGroupJSON(json);
|
|
2292
|
+
const nodes = processedJSON.nodes.map(
|
|
2263
2293
|
(nodeJSON) => this.createWorkflowNode(nodeJSON, isClone, containerID)
|
|
2264
2294
|
);
|
|
2265
|
-
const edges =
|
|
2295
|
+
const edges = processedJSON.edges.map((edge) => this.createWorkflowLine(edge, containerID)).filter(Boolean);
|
|
2266
2296
|
return { nodes, edges };
|
|
2267
2297
|
}
|
|
2268
2298
|
getNodeSubCanvas(node) {
|
|
@@ -2272,13 +2302,19 @@ var WorkflowDocument = class extends FlowDocument {
|
|
|
2272
2302
|
return subCanvas;
|
|
2273
2303
|
}
|
|
2274
2304
|
getNodeChildren(node) {
|
|
2275
|
-
if (!node) return [];
|
|
2305
|
+
if (!node || node.flowNodeType === FlowNodeBaseType2.GROUP) return [];
|
|
2276
2306
|
const subCanvas = this.getNodeSubCanvas(node);
|
|
2277
|
-
const
|
|
2278
|
-
const
|
|
2307
|
+
const realChildren = subCanvas ? subCanvas.canvasNode.blocks : node.blocks;
|
|
2308
|
+
const childrenWithoutSubCanvas = realChildren.filter((child) => {
|
|
2279
2309
|
const childMeta = child.getNodeMeta();
|
|
2280
2310
|
return !childMeta.subCanvas?.(node)?.isCanvas;
|
|
2281
2311
|
}).filter(Boolean);
|
|
2312
|
+
const children = childrenWithoutSubCanvas.map((child) => {
|
|
2313
|
+
if (child.flowNodeType === FlowNodeBaseType2.GROUP) {
|
|
2314
|
+
return [child, ...child.blocks];
|
|
2315
|
+
}
|
|
2316
|
+
return child;
|
|
2317
|
+
}).flat();
|
|
2282
2318
|
return children;
|
|
2283
2319
|
}
|
|
2284
2320
|
toLineJSON(line) {
|
|
@@ -2410,7 +2446,7 @@ var WorkflowDragService = class {
|
|
|
2410
2446
|
}
|
|
2411
2447
|
this.isDragging = true;
|
|
2412
2448
|
const sameParent = this.childrenOfContainer(selectedNodes);
|
|
2413
|
-
if (sameParent && sameParent.flowNodeType !==
|
|
2449
|
+
if (sameParent && sameParent.flowNodeType !== FlowNodeBaseType3.ROOT) {
|
|
2414
2450
|
selectedNodes = [sameParent];
|
|
2415
2451
|
}
|
|
2416
2452
|
let startPosition = this.getNodesPosition(selectedNodes);
|
|
@@ -2580,7 +2616,7 @@ var WorkflowDragService = class {
|
|
|
2580
2616
|
if (!mousePos) {
|
|
2581
2617
|
return { x: 0, y: 0 };
|
|
2582
2618
|
}
|
|
2583
|
-
if (!subNodeType || !containerNode || containerNode.flowNodeType ===
|
|
2619
|
+
if (!subNodeType || !containerNode || containerNode.flowNodeType === FlowNodeBaseType3.ROOT) {
|
|
2584
2620
|
return mousePos;
|
|
2585
2621
|
}
|
|
2586
2622
|
const isParentEmpty = !containerNode.children || containerNode.children.length === 0;
|
|
@@ -3502,6 +3538,7 @@ export {
|
|
|
3502
3538
|
WorkflowSelectService,
|
|
3503
3539
|
WorkflowSimpleLineContribution,
|
|
3504
3540
|
bindConfigEntity,
|
|
3541
|
+
buildGroupJSON,
|
|
3505
3542
|
compose,
|
|
3506
3543
|
composeAsync,
|
|
3507
3544
|
delay,
|