@flowgram.ai/free-layout-core 1.0.10 → 1.0.11
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 +125 -49
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +124 -43
- 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-operation.d.mts +1 -1
- package/dist/typings/workflow-operation.d.ts +1 -1
- package/dist/typings/workflow-registry.d.mts +1 -1
- package/dist/typings/workflow-registry.d.ts +1 -1
- package/dist/typings/workflow-sub-canvas.d.mts +1 -1
- package/dist/typings/workflow-sub-canvas.d.ts +1 -1
- package/dist/{workflow-node-entity-C_A53MW2.d.ts → workflow-node-entity-03Q7Fvv6.d.ts} +10 -1
- package/dist/{workflow-node-entity-BpXZTWZe.d.mts → workflow-node-entity-C6bFzfXc.d.mts} +10 -1
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import { PlaygroundConfigEntity, CommandService, PlaygroundDragEvent, EntityData
|
|
|
2
2
|
export { bindConfigEntity, useConfigEntity, useEntities, useEntityDataFromContext, useEntityFromContext, useListenEvents, usePlayground, usePlaygroundContainer, usePlaygroundContext, useRefresh, useService } from '@flowgram.ai/core';
|
|
3
3
|
import { NodeFormProps } from '@flowgram.ai/node';
|
|
4
4
|
import { FlowNodeType, FlowOperationBaseServiceImpl, FlowNodeEntityOrId, FlowNodeEntity } from '@flowgram.ai/document';
|
|
5
|
-
import { W as WorkflowJSON, L as LineCenterPoint, a as WorkflowDocument, b as WorkflowNodeEntity, c as WorkflowHoverService, d as WorkflowLinesManager, e as WorkflowSelectService, f as WorkflowDocumentOptions, g as LineEventProps, N as NodesDragEvent, h as WorkflowNodeJSON, i as WorkflowPortEntity, j as WorkflowLineEntity, O as OnDragLineEnd, k as LineRenderType, l as WorkflowLineRenderContribution, m as LinePosition } from './workflow-node-entity-
|
|
6
|
-
export {
|
|
5
|
+
import { W as WorkflowJSON, L as LineCenterPoint, a as WorkflowDocument, b as WorkflowNodeEntity, c as WorkflowHoverService, d as WorkflowLinesManager, e as WorkflowSelectService, f as WorkflowDocumentOptions, g as LineEventProps, N as NodesDragEvent, h as WorkflowNodeJSON, i as WorkflowPortEntity, j as WorkflowLineEntity, O as OnDragLineEnd, k as LineRenderType, l as WorkflowLineRenderContribution, m as LinePosition } from './workflow-node-entity-C6bFzfXc.mjs';
|
|
6
|
+
export { Y as HoverPosition, G as LINE_HOVER_DISTANCE, y as LineColor, z as LineColors, x as LinePoint, w as LinePointLocation, v as LineType, D as NodesDragEndEvent, C as NodesDragStartEvent, E as NodesDraggingEvent, P as POINT_RADIUS, M as PORT_SIZE, q as WORKFLOW_LINE_ENTITY, Z as WorkfloEntityHoverable, t as WorkflowContentChangeEvent, s as WorkflowContentChangeType, $ as WorkflowDocumentOptionsDefault, _ as WorkflowDocumentProvider, X as WorkflowEntityHoverable, I as WorkflowLineEntityOpts, J as WorkflowLineInfo, H as WorkflowLinePortInfo, A as WorkflowLineRenderContributionFactory, K as WorkflowLineUIState, U as WorkflowNodeLines, V as WorkflowNodeLinesData, u as WorkflowNodeMeta, T as WorkflowNodePortsData, Q as WorkflowPort, S as WorkflowPortEntityOpts, n as WorkflowPortType, R as WorkflowPorts, B as WorkflowSubCanvas, r as domReactToBounds, p as getPortEntityId, o as getPortEntityIdByNodeId, F as onDragLineEndParams } from './workflow-node-entity-C6bFzfXc.mjs';
|
|
7
7
|
import * as _flowgram_ai_utils from '@flowgram.ai/utils';
|
|
8
8
|
import { IPoint, Rectangle, DisposableCollection, Disposable } from '@flowgram.ai/utils';
|
|
9
9
|
export { compose, composeAsync, delay } from '@flowgram.ai/utils';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { PlaygroundConfigEntity, CommandService, PlaygroundDragEvent, EntityData
|
|
|
2
2
|
export { bindConfigEntity, useConfigEntity, useEntities, useEntityDataFromContext, useEntityFromContext, useListenEvents, usePlayground, usePlaygroundContainer, usePlaygroundContext, useRefresh, useService } from '@flowgram.ai/core';
|
|
3
3
|
import { NodeFormProps } from '@flowgram.ai/node';
|
|
4
4
|
import { FlowNodeType, FlowOperationBaseServiceImpl, FlowNodeEntityOrId, FlowNodeEntity } from '@flowgram.ai/document';
|
|
5
|
-
import { W as WorkflowJSON, L as LineCenterPoint, a as WorkflowDocument, b as WorkflowNodeEntity, c as WorkflowHoverService, d as WorkflowLinesManager, e as WorkflowSelectService, f as WorkflowDocumentOptions, g as LineEventProps, N as NodesDragEvent, h as WorkflowNodeJSON, i as WorkflowPortEntity, j as WorkflowLineEntity, O as OnDragLineEnd, k as LineRenderType, l as WorkflowLineRenderContribution, m as LinePosition } from './workflow-node-entity-
|
|
6
|
-
export {
|
|
5
|
+
import { W as WorkflowJSON, L as LineCenterPoint, a as WorkflowDocument, b as WorkflowNodeEntity, c as WorkflowHoverService, d as WorkflowLinesManager, e as WorkflowSelectService, f as WorkflowDocumentOptions, g as LineEventProps, N as NodesDragEvent, h as WorkflowNodeJSON, i as WorkflowPortEntity, j as WorkflowLineEntity, O as OnDragLineEnd, k as LineRenderType, l as WorkflowLineRenderContribution, m as LinePosition } from './workflow-node-entity-03Q7Fvv6.js';
|
|
6
|
+
export { Y as HoverPosition, G as LINE_HOVER_DISTANCE, y as LineColor, z as LineColors, x as LinePoint, w as LinePointLocation, v as LineType, D as NodesDragEndEvent, C as NodesDragStartEvent, E as NodesDraggingEvent, P as POINT_RADIUS, M as PORT_SIZE, q as WORKFLOW_LINE_ENTITY, Z as WorkfloEntityHoverable, t as WorkflowContentChangeEvent, s as WorkflowContentChangeType, $ as WorkflowDocumentOptionsDefault, _ as WorkflowDocumentProvider, X as WorkflowEntityHoverable, I as WorkflowLineEntityOpts, J as WorkflowLineInfo, H as WorkflowLinePortInfo, A as WorkflowLineRenderContributionFactory, K as WorkflowLineUIState, U as WorkflowNodeLines, V as WorkflowNodeLinesData, u as WorkflowNodeMeta, T as WorkflowNodePortsData, Q as WorkflowPort, S as WorkflowPortEntityOpts, n as WorkflowPortType, R as WorkflowPorts, B as WorkflowSubCanvas, r as domReactToBounds, p as getPortEntityId, o as getPortEntityIdByNodeId, F as onDragLineEndParams } from './workflow-node-entity-03Q7Fvv6.js';
|
|
7
7
|
import * as _flowgram_ai_utils from '@flowgram.ai/utils';
|
|
8
8
|
import { IPoint, Rectangle, DisposableCollection, Disposable } from '@flowgram.ai/utils';
|
|
9
9
|
export { compose, composeAsync, delay } from '@flowgram.ai/utils';
|
package/dist/index.js
CHANGED
|
@@ -67,6 +67,7 @@ __export(index_exports, {
|
|
|
67
67
|
getAntiOverlapPosition: () => getAntiOverlapPosition,
|
|
68
68
|
getLineCenter: () => getLineCenter,
|
|
69
69
|
getPortEntityId: () => getPortEntityId,
|
|
70
|
+
getPortEntityIdByNodeId: () => getPortEntityIdByNodeId,
|
|
70
71
|
nanoid: () => nanoid,
|
|
71
72
|
useConfigEntity: () => import_core25.useConfigEntity,
|
|
72
73
|
useCurrentDomNode: () => useCurrentDomNode,
|
|
@@ -201,7 +202,8 @@ function getAntiOverlapPosition(doc, position, containerNode) {
|
|
|
201
202
|
|
|
202
203
|
// src/utils/statics.ts
|
|
203
204
|
var import_utils3 = require("@flowgram.ai/utils");
|
|
204
|
-
var
|
|
205
|
+
var getPortEntityIdByNodeId = (nodeId, portType, portID = "") => `port_${portType}_${nodeId}_${portID}`;
|
|
206
|
+
var getPortEntityId = (node, portType, portID = "") => getPortEntityIdByNodeId(node.id, portType, portID);
|
|
205
207
|
var WORKFLOW_LINE_ENTITY = "WorkflowLineEntity";
|
|
206
208
|
function domReactToBounds(react) {
|
|
207
209
|
return new import_utils3.Rectangle(react.x, react.y, react.width, react.height);
|
|
@@ -416,16 +418,8 @@ var WorkflowPortEntity = class extends import_core4.Entity {
|
|
|
416
418
|
* 当前点位上连接的线条(包含 isDrawing === true 的线条)
|
|
417
419
|
*/
|
|
418
420
|
get allLines() {
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
type: WORKFLOW_LINE_ENTITY
|
|
422
|
-
});
|
|
423
|
-
allLines.forEach((line) => {
|
|
424
|
-
if (line.toPort === this || line.fromPort === this) {
|
|
425
|
-
lines.push(line);
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
return lines;
|
|
421
|
+
const document2 = this.node.document;
|
|
422
|
+
return document2.linesManager.getLinesByPortId(this.id);
|
|
429
423
|
}
|
|
430
424
|
update(data) {
|
|
431
425
|
let changed = false;
|
|
@@ -935,6 +929,9 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends import_core8.Entity
|
|
|
935
929
|
this.toPort?.validate();
|
|
936
930
|
});
|
|
937
931
|
this.toDispose.push(this._onLineDataChangeEmitter);
|
|
932
|
+
this.preDispose.push(
|
|
933
|
+
import_utils8.Disposable.create(() => this.linesManager.rebindLinePorts(this, this.info, void 0))
|
|
934
|
+
);
|
|
938
935
|
}
|
|
939
936
|
/**
|
|
940
937
|
* 转成线条 id
|
|
@@ -1044,19 +1041,20 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends import_core8.Entity
|
|
|
1044
1041
|
const prePort = this.toPort;
|
|
1045
1042
|
if (toPort && toPort.portType === "input" && this.linesManager.canAddLine(this.fromPort, toPort, true)) {
|
|
1046
1043
|
const { node, portID } = toPort;
|
|
1047
|
-
this.
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1044
|
+
this.updateInfo((nextInfo) => {
|
|
1045
|
+
nextInfo.drawingTo = void 0;
|
|
1046
|
+
nextInfo.to = node.id;
|
|
1047
|
+
nextInfo.toPort = portID;
|
|
1048
|
+
});
|
|
1051
1049
|
} else {
|
|
1052
|
-
this.
|
|
1053
|
-
|
|
1054
|
-
|
|
1050
|
+
this.updateInfo((nextInfo) => {
|
|
1051
|
+
nextInfo.to = void 0;
|
|
1052
|
+
nextInfo.toPort = "";
|
|
1053
|
+
});
|
|
1055
1054
|
}
|
|
1056
1055
|
if (prePort) {
|
|
1057
1056
|
prePort.validate();
|
|
1058
1057
|
}
|
|
1059
|
-
this.fireChange();
|
|
1060
1058
|
}
|
|
1061
1059
|
setFromPort(fromPort) {
|
|
1062
1060
|
if (!this.isDrawing) {
|
|
@@ -1068,19 +1066,20 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends import_core8.Entity
|
|
|
1068
1066
|
const prePort = this.fromPort;
|
|
1069
1067
|
if (fromPort && fromPort.portType === "output" && this.linesManager.canAddLine(fromPort, this.toPort, true)) {
|
|
1070
1068
|
const { node, portID } = fromPort;
|
|
1071
|
-
this.
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1069
|
+
this.updateInfo((nextInfo) => {
|
|
1070
|
+
nextInfo.drawingFrom = void 0;
|
|
1071
|
+
nextInfo.from = node.id;
|
|
1072
|
+
nextInfo.fromPort = portID;
|
|
1073
|
+
});
|
|
1075
1074
|
} else {
|
|
1076
|
-
this.
|
|
1077
|
-
|
|
1078
|
-
|
|
1075
|
+
this.updateInfo((nextInfo) => {
|
|
1076
|
+
nextInfo.from = void 0;
|
|
1077
|
+
nextInfo.fromPort = "";
|
|
1078
|
+
});
|
|
1079
1079
|
}
|
|
1080
1080
|
if (prePort) {
|
|
1081
1081
|
prePort.validate();
|
|
1082
1082
|
}
|
|
1083
|
-
this.fireChange();
|
|
1084
1083
|
}
|
|
1085
1084
|
/**
|
|
1086
1085
|
* 设置线条画线时的目标位置
|
|
@@ -1088,27 +1087,41 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends import_core8.Entity
|
|
|
1088
1087
|
set drawingTo(pos) {
|
|
1089
1088
|
const oldDrawingTo = this.info.drawingTo;
|
|
1090
1089
|
if (!pos) {
|
|
1091
|
-
|
|
1092
|
-
|
|
1090
|
+
if (oldDrawingTo === void 0) {
|
|
1091
|
+
this.fireChange();
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
this.updateInfo((nextInfo) => {
|
|
1095
|
+
nextInfo.drawingTo = void 0;
|
|
1096
|
+
});
|
|
1093
1097
|
return;
|
|
1094
1098
|
}
|
|
1095
1099
|
if (!oldDrawingTo || pos.x !== oldDrawingTo.x || pos.y !== oldDrawingTo.y) {
|
|
1096
|
-
this.
|
|
1097
|
-
|
|
1098
|
-
|
|
1100
|
+
this.updateInfo((nextInfo) => {
|
|
1101
|
+
nextInfo.to = void 0;
|
|
1102
|
+
nextInfo.toPort = "";
|
|
1103
|
+
nextInfo.drawingTo = pos;
|
|
1104
|
+
});
|
|
1099
1105
|
}
|
|
1100
1106
|
}
|
|
1101
1107
|
set drawingFrom(pos) {
|
|
1102
1108
|
const oldDrawingFrom = this.info.drawingFrom;
|
|
1103
1109
|
if (!pos) {
|
|
1104
|
-
|
|
1105
|
-
|
|
1110
|
+
if (oldDrawingFrom === void 0) {
|
|
1111
|
+
this.fireChange();
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
this.updateInfo((nextInfo) => {
|
|
1115
|
+
nextInfo.drawingFrom = void 0;
|
|
1116
|
+
});
|
|
1106
1117
|
return;
|
|
1107
1118
|
}
|
|
1108
1119
|
if (!oldDrawingFrom || pos.x !== oldDrawingFrom.x || pos.y !== oldDrawingFrom.y) {
|
|
1109
|
-
this.
|
|
1110
|
-
|
|
1111
|
-
|
|
1120
|
+
this.updateInfo((nextInfo) => {
|
|
1121
|
+
nextInfo.from = void 0;
|
|
1122
|
+
nextInfo.fromPort = "";
|
|
1123
|
+
nextInfo.drawingFrom = pos;
|
|
1124
|
+
});
|
|
1112
1125
|
}
|
|
1113
1126
|
}
|
|
1114
1127
|
get drawingFrom() {
|
|
@@ -1219,13 +1232,26 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends import_core8.Entity
|
|
|
1219
1232
|
* @param info 线条信息
|
|
1220
1233
|
*/
|
|
1221
1234
|
initInfo(info) {
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
this.
|
|
1227
|
-
|
|
1235
|
+
this.applyInfo(info);
|
|
1236
|
+
}
|
|
1237
|
+
updateInfo(mutator) {
|
|
1238
|
+
const nextInfo = {
|
|
1239
|
+
...this.info
|
|
1240
|
+
};
|
|
1241
|
+
mutator(nextInfo);
|
|
1242
|
+
this.applyInfo(nextInfo);
|
|
1243
|
+
}
|
|
1244
|
+
applyInfo(nextInfo) {
|
|
1245
|
+
if ((0, import_lodash_es2.isEqual)(nextInfo, this.info)) {
|
|
1246
|
+
return;
|
|
1228
1247
|
}
|
|
1248
|
+
const prevInfo = this.info;
|
|
1249
|
+
this.info = nextInfo;
|
|
1250
|
+
this._from = nextInfo.from ? this.document.getNode(nextInfo.from) : void 0;
|
|
1251
|
+
this._to = nextInfo.to ? this.document.getNode(nextInfo.to) : void 0;
|
|
1252
|
+
this._lineData = nextInfo.data;
|
|
1253
|
+
this.linesManager.rebindLinePorts(this, prevInfo, nextInfo);
|
|
1254
|
+
this.fireChange();
|
|
1229
1255
|
}
|
|
1230
1256
|
// 校验连线是否为错误态
|
|
1231
1257
|
validate() {
|
|
@@ -1589,6 +1615,7 @@ var WorkflowDocumentOptionsDefault = {
|
|
|
1589
1615
|
var WorkflowLinesManager = class {
|
|
1590
1616
|
constructor() {
|
|
1591
1617
|
this.toDispose = new import_utils12.DisposableCollection();
|
|
1618
|
+
this.portLineMap = /* @__PURE__ */ new Map();
|
|
1592
1619
|
// 线条类型
|
|
1593
1620
|
this._lineType = 0 /* BEZIER */;
|
|
1594
1621
|
this.onAvailableLinesChangeEmitter = new import_utils12.Emitter();
|
|
@@ -1653,6 +1680,58 @@ var WorkflowLinesManager = class {
|
|
|
1653
1680
|
getAllLines() {
|
|
1654
1681
|
return this.entityManager.getEntities(WorkflowLineEntity);
|
|
1655
1682
|
}
|
|
1683
|
+
getLinesByPortId(portId) {
|
|
1684
|
+
return Array.from(this.portLineMap.get(portId) || []);
|
|
1685
|
+
}
|
|
1686
|
+
rebindLinePorts(line, prevInfo, nextInfo) {
|
|
1687
|
+
const prevFromPortId = this.getLinePortId(prevInfo, "output");
|
|
1688
|
+
const prevToPortId = this.getLinePortId(prevInfo, "input");
|
|
1689
|
+
const nextFromPortId = this.getLinePortId(nextInfo, "output");
|
|
1690
|
+
const nextToPortId = this.getLinePortId(nextInfo, "input");
|
|
1691
|
+
if (prevFromPortId !== nextFromPortId) {
|
|
1692
|
+
this.detachLineFromPortId(line, prevFromPortId);
|
|
1693
|
+
this.attachLineToPortId(line, nextFromPortId);
|
|
1694
|
+
}
|
|
1695
|
+
if (prevToPortId !== nextToPortId) {
|
|
1696
|
+
this.detachLineFromPortId(line, prevToPortId);
|
|
1697
|
+
this.attachLineToPortId(line, nextToPortId);
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
attachLineToPortId(line, portId) {
|
|
1701
|
+
if (!portId) {
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
1704
|
+
let lines = this.portLineMap.get(portId);
|
|
1705
|
+
if (!lines) {
|
|
1706
|
+
lines = /* @__PURE__ */ new Set();
|
|
1707
|
+
this.portLineMap.set(portId, lines);
|
|
1708
|
+
}
|
|
1709
|
+
lines.add(line);
|
|
1710
|
+
}
|
|
1711
|
+
detachLineFromPortId(line, portId) {
|
|
1712
|
+
if (!portId) {
|
|
1713
|
+
return;
|
|
1714
|
+
}
|
|
1715
|
+
const lines = this.portLineMap.get(portId);
|
|
1716
|
+
if (!lines) {
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
lines.delete(line);
|
|
1720
|
+
if (!lines.size) {
|
|
1721
|
+
this.portLineMap.delete(portId);
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
getLinePortId(info, portType) {
|
|
1725
|
+
if (!info) {
|
|
1726
|
+
return void 0;
|
|
1727
|
+
}
|
|
1728
|
+
const nodeId = portType === "output" ? info.from : info.to;
|
|
1729
|
+
if (!nodeId) {
|
|
1730
|
+
return void 0;
|
|
1731
|
+
}
|
|
1732
|
+
const portId = portType === "output" ? info.fromPort : info.toPort;
|
|
1733
|
+
return getPortEntityIdByNodeId(nodeId, portType, portId);
|
|
1734
|
+
}
|
|
1656
1735
|
getAllAvailableLines() {
|
|
1657
1736
|
return this.getAllLines().filter((l) => !l.isDrawing && !l.isHidden);
|
|
1658
1737
|
}
|
|
@@ -1757,6 +1836,7 @@ var WorkflowLinesManager = class {
|
|
|
1757
1836
|
return targetLine;
|
|
1758
1837
|
}
|
|
1759
1838
|
dispose() {
|
|
1839
|
+
this.portLineMap.clear();
|
|
1760
1840
|
this.toDispose.dispose();
|
|
1761
1841
|
}
|
|
1762
1842
|
get disposed() {
|
|
@@ -4040,6 +4120,7 @@ var WorkflowDocumentContainerModule = new import_inversify10.ContainerModule(
|
|
|
4040
4120
|
getAntiOverlapPosition,
|
|
4041
4121
|
getLineCenter,
|
|
4042
4122
|
getPortEntityId,
|
|
4123
|
+
getPortEntityIdByNodeId,
|
|
4043
4124
|
nanoid,
|
|
4044
4125
|
useConfigEntity,
|
|
4045
4126
|
useCurrentDomNode,
|