@flowgram.ai/free-layout-core 0.1.23 → 0.1.25
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 +12 -105
- 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 +12 -105
- 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-BUw5GrG6.d.ts → workflow-line-entity-B8wC-OVt.d.ts} +7 -10
- package/dist/{workflow-line-entity-BhE94WKf.d.mts → workflow-line-entity-DgCmDX1d.d.mts} +7 -10
- 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, usePlaygroundLatest, useRefresh, useService } from '@flowgram.ai/core';
|
|
3
3
|
import { NodeFormProps } from '@flowgram.ai/node';
|
|
4
4
|
import { FlowOperationBaseService, FlowNodeType, FlowOperationBaseServiceImpl, FlowNodeEntityOrId, FlowNodeEntity } from '@flowgram.ai/document';
|
|
5
|
-
import { W as WorkflowHoverService, a as WorkflowDocument, b as WorkflowLinesManager, c as WorkflowSelectService, d as WorkflowDocumentOptions, L as LineEventProps, N as NodesDragEvent, e as WorkflowNodeJSON, f as WorkflowPortEntity, g as WorkflowLineEntity, O as OnDragLineEnd, h as WorkflowPorts, i as WorkflowPortType, j as WorkflowPort, k as LineRenderType, l as WorkflowLineRenderContribution, m as LinePosition } from './workflow-line-entity-
|
|
6
|
-
export { C as LINE_HOVER_DISTANCE, v as LineColor, w as LineColors, u as LineType, z as NodesDragEndEvent, y as NodesDragStartEvent, A as NodesDraggingEvent, P as POINT_RADIUS, G as PORT_SIZE, o as WORKFLOW_LINE_ENTITY, I as WorkfloEntityHoverable, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, K as WorkflowDocumentOptionsDefault, J as WorkflowDocumentProvider, q as WorkflowJSON, E as WorkflowLineEntityOpts, F as WorkflowLineInfo, D as WorkflowLinePortInfo, x as WorkflowLineRenderContributionFactory, t as WorkflowNodeMeta, H as WorkflowPortEntityOpts, p as domReactToBounds, n as getPortEntityId, B as onDragLineEndParams } from './workflow-line-entity-
|
|
5
|
+
import { W as WorkflowHoverService, a as WorkflowDocument, b as WorkflowLinesManager, c as WorkflowSelectService, d as WorkflowDocumentOptions, L as LineEventProps, N as NodesDragEvent, e as WorkflowNodeJSON, f as WorkflowPortEntity, g as WorkflowLineEntity, O as OnDragLineEnd, h as WorkflowPorts, i as WorkflowPortType, j as WorkflowPort, k as LineRenderType, l as WorkflowLineRenderContribution, m as LinePosition } from './workflow-line-entity-DgCmDX1d.mjs';
|
|
6
|
+
export { C as LINE_HOVER_DISTANCE, v as LineColor, w as LineColors, u as LineType, z as NodesDragEndEvent, y as NodesDragStartEvent, A as NodesDraggingEvent, P as POINT_RADIUS, G as PORT_SIZE, o as WORKFLOW_LINE_ENTITY, I as WorkfloEntityHoverable, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, K as WorkflowDocumentOptionsDefault, J as WorkflowDocumentProvider, q as WorkflowJSON, E as WorkflowLineEntityOpts, F as WorkflowLineInfo, D as WorkflowLinePortInfo, x as WorkflowLineRenderContributionFactory, t as WorkflowNodeMeta, H as WorkflowPortEntityOpts, p as domReactToBounds, n as getPortEntityId, B as onDragLineEndParams } from './workflow-line-entity-DgCmDX1d.mjs';
|
|
7
7
|
import { W as WorkflowNodeEntity } from './workflow-sub-canvas-DOVla1mw.mjs';
|
|
8
8
|
export { a as WorkflowSubCanvas } from './workflow-sub-canvas-DOVla1mw.mjs';
|
|
9
9
|
import * as _flowgram_ai_utils 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, usePlaygroundLatest, useRefresh, useService } from '@flowgram.ai/core';
|
|
3
3
|
import { NodeFormProps } from '@flowgram.ai/node';
|
|
4
4
|
import { FlowOperationBaseService, FlowNodeType, FlowOperationBaseServiceImpl, FlowNodeEntityOrId, FlowNodeEntity } from '@flowgram.ai/document';
|
|
5
|
-
import { W as WorkflowHoverService, a as WorkflowDocument, b as WorkflowLinesManager, c as WorkflowSelectService, d as WorkflowDocumentOptions, L as LineEventProps, N as NodesDragEvent, e as WorkflowNodeJSON, f as WorkflowPortEntity, g as WorkflowLineEntity, O as OnDragLineEnd, h as WorkflowPorts, i as WorkflowPortType, j as WorkflowPort, k as LineRenderType, l as WorkflowLineRenderContribution, m as LinePosition } from './workflow-line-entity-
|
|
6
|
-
export { C as LINE_HOVER_DISTANCE, v as LineColor, w as LineColors, u as LineType, z as NodesDragEndEvent, y as NodesDragStartEvent, A as NodesDraggingEvent, P as POINT_RADIUS, G as PORT_SIZE, o as WORKFLOW_LINE_ENTITY, I as WorkfloEntityHoverable, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, K as WorkflowDocumentOptionsDefault, J as WorkflowDocumentProvider, q as WorkflowJSON, E as WorkflowLineEntityOpts, F as WorkflowLineInfo, D as WorkflowLinePortInfo, x as WorkflowLineRenderContributionFactory, t as WorkflowNodeMeta, H as WorkflowPortEntityOpts, p as domReactToBounds, n as getPortEntityId, B as onDragLineEndParams } from './workflow-line-entity-
|
|
5
|
+
import { W as WorkflowHoverService, a as WorkflowDocument, b as WorkflowLinesManager, c as WorkflowSelectService, d as WorkflowDocumentOptions, L as LineEventProps, N as NodesDragEvent, e as WorkflowNodeJSON, f as WorkflowPortEntity, g as WorkflowLineEntity, O as OnDragLineEnd, h as WorkflowPorts, i as WorkflowPortType, j as WorkflowPort, k as LineRenderType, l as WorkflowLineRenderContribution, m as LinePosition } from './workflow-line-entity-B8wC-OVt.js';
|
|
6
|
+
export { C as LINE_HOVER_DISTANCE, v as LineColor, w as LineColors, u as LineType, z as NodesDragEndEvent, y as NodesDragStartEvent, A as NodesDraggingEvent, P as POINT_RADIUS, G as PORT_SIZE, o as WORKFLOW_LINE_ENTITY, I as WorkfloEntityHoverable, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, K as WorkflowDocumentOptionsDefault, J as WorkflowDocumentProvider, q as WorkflowJSON, E as WorkflowLineEntityOpts, F as WorkflowLineInfo, D as WorkflowLinePortInfo, x as WorkflowLineRenderContributionFactory, t as WorkflowNodeMeta, H as WorkflowPortEntityOpts, p as domReactToBounds, n as getPortEntityId, B as onDragLineEndParams } from './workflow-line-entity-B8wC-OVt.js';
|
|
7
7
|
import { W as WorkflowNodeEntity } from './workflow-sub-canvas-DOVla1mw.js';
|
|
8
8
|
export { a as WorkflowSubCanvas } from './workflow-sub-canvas-DOVla1mw.js';
|
|
9
9
|
import * as _flowgram_ai_utils from '@flowgram.ai/utils';
|
package/dist/index.js
CHANGED
|
@@ -528,7 +528,7 @@ var _WorkflowNodeLinesData = class _WorkflowNodeLinesData extends import_core6.E
|
|
|
528
528
|
constructor(entity) {
|
|
529
529
|
super(entity);
|
|
530
530
|
this.entity = entity;
|
|
531
|
-
this.
|
|
531
|
+
this.entity.preDispose.push(
|
|
532
532
|
import_utils6.Disposable.create(() => {
|
|
533
533
|
this.inputLines.slice().forEach((line) => line.dispose());
|
|
534
534
|
this.outputLines.slice().forEach((line) => line.dispose());
|
|
@@ -1755,10 +1755,12 @@ var WorkflowDocument = class extends import_document7.FlowDocument {
|
|
|
1755
1755
|
* @param json
|
|
1756
1756
|
*/
|
|
1757
1757
|
fromJSON(json, fireRender = true) {
|
|
1758
|
-
const
|
|
1759
|
-
|
|
1758
|
+
const workflowJSON = {
|
|
1759
|
+
nodes: json.nodes ?? [],
|
|
1760
|
+
edges: json.edges ?? []
|
|
1761
|
+
};
|
|
1760
1762
|
this.entityManager.changeEntityLocked = true;
|
|
1761
|
-
this.renderJSON(
|
|
1763
|
+
this.renderJSON(workflowJSON);
|
|
1762
1764
|
this.entityManager.changeEntityLocked = false;
|
|
1763
1765
|
this.transformer.loading = false;
|
|
1764
1766
|
if (fireRender) {
|
|
@@ -2096,112 +2098,17 @@ var WorkflowDocument = class extends import_document7.FlowDocument {
|
|
|
2096
2098
|
this.disposed = true;
|
|
2097
2099
|
this._onReloadEmitter.dispose();
|
|
2098
2100
|
}
|
|
2099
|
-
getEdgeID(edge) {
|
|
2100
|
-
return WorkflowLineEntity.portInfoToLineId({
|
|
2101
|
-
from: edge.sourceNodeID,
|
|
2102
|
-
to: edge.targetNodeID,
|
|
2103
|
-
fromPort: edge.sourcePortID,
|
|
2104
|
-
toPort: edge.targetPortID
|
|
2105
|
-
});
|
|
2106
|
-
}
|
|
2107
|
-
/**
|
|
2108
|
-
* 拍平树形json结构,将结构信息提取到map
|
|
2109
|
-
*/
|
|
2110
|
-
flatJSON(json = { nodes: [], edges: [] }) {
|
|
2111
|
-
const nodeBlocks = /* @__PURE__ */ new Map();
|
|
2112
|
-
const nodeEdges = /* @__PURE__ */ new Map();
|
|
2113
|
-
const rootNodes = json.nodes ?? [];
|
|
2114
|
-
const rootEdges = json.edges ?? [];
|
|
2115
|
-
const flattenNodeJSONs = [...rootNodes];
|
|
2116
|
-
const flattenEdgeJSONs = [...rootEdges];
|
|
2117
|
-
const rootBlockIDs = rootNodes.map((node) => node.id);
|
|
2118
|
-
const rootEdgeIDs = rootEdges.map((edge) => this.getEdgeID(edge));
|
|
2119
|
-
nodeBlocks.set(import_document7.FlowNodeBaseType.ROOT, rootBlockIDs);
|
|
2120
|
-
nodeEdges.set(import_document7.FlowNodeBaseType.ROOT, rootEdgeIDs);
|
|
2121
|
-
rootNodes.forEach((nodeJSON) => {
|
|
2122
|
-
const { blocks, edges } = nodeJSON;
|
|
2123
|
-
if (blocks) {
|
|
2124
|
-
flattenNodeJSONs.push(...blocks);
|
|
2125
|
-
const blockIDs = [];
|
|
2126
|
-
blocks.forEach((block) => {
|
|
2127
|
-
blockIDs.push(block.id);
|
|
2128
|
-
});
|
|
2129
|
-
nodeBlocks.set(nodeJSON.id, blockIDs);
|
|
2130
|
-
delete nodeJSON.blocks;
|
|
2131
|
-
}
|
|
2132
|
-
if (edges) {
|
|
2133
|
-
flattenEdgeJSONs.push(...edges);
|
|
2134
|
-
const edgeIDs = [];
|
|
2135
|
-
edges.forEach((edge) => {
|
|
2136
|
-
const edgeID = this.getEdgeID(edge);
|
|
2137
|
-
edgeIDs.push(edgeID);
|
|
2138
|
-
});
|
|
2139
|
-
nodeEdges.set(nodeJSON.id, edgeIDs);
|
|
2140
|
-
delete nodeJSON.edges;
|
|
2141
|
-
}
|
|
2142
|
-
});
|
|
2143
|
-
const flattenJSON = {
|
|
2144
|
-
nodes: flattenNodeJSONs,
|
|
2145
|
-
edges: flattenEdgeJSONs
|
|
2146
|
-
};
|
|
2147
|
-
return {
|
|
2148
|
-
flattenJSON,
|
|
2149
|
-
nodeBlocks,
|
|
2150
|
-
nodeEdges
|
|
2151
|
-
};
|
|
2152
|
-
}
|
|
2153
|
-
/**
|
|
2154
|
-
* 对JSON进行分层
|
|
2155
|
-
*/
|
|
2156
|
-
nestJSON(flattenJSON, nodeBlocks, nodeEdges) {
|
|
2157
|
-
const nestJSON = {
|
|
2158
|
-
nodes: [],
|
|
2159
|
-
edges: []
|
|
2160
|
-
};
|
|
2161
|
-
const nodeMap = /* @__PURE__ */ new Map();
|
|
2162
|
-
const edgeMap = /* @__PURE__ */ new Map();
|
|
2163
|
-
const rootBlockSet = new Set(nodeBlocks.get(import_document7.FlowNodeBaseType.ROOT) ?? []);
|
|
2164
|
-
const rootEdgeSet = new Set(nodeEdges.get(import_document7.FlowNodeBaseType.ROOT) ?? []);
|
|
2165
|
-
flattenJSON.nodes.forEach((nodeJSON) => {
|
|
2166
|
-
nodeMap.set(nodeJSON.id, nodeJSON);
|
|
2167
|
-
});
|
|
2168
|
-
flattenJSON.edges.forEach((edgeJSON) => {
|
|
2169
|
-
const edgeID = this.getEdgeID(edgeJSON);
|
|
2170
|
-
edgeMap.set(edgeID, edgeJSON);
|
|
2171
|
-
});
|
|
2172
|
-
flattenJSON.nodes.forEach((nodeJSON) => {
|
|
2173
|
-
if (rootBlockSet.has(nodeJSON.id)) {
|
|
2174
|
-
nestJSON.nodes.push(nodeJSON);
|
|
2175
|
-
}
|
|
2176
|
-
if (nodeBlocks.has(nodeJSON.id)) {
|
|
2177
|
-
const blockIDs = nodeBlocks.get(nodeJSON.id);
|
|
2178
|
-
const blockJSONs = blockIDs.map((blockID) => nodeMap.get(blockID)).filter(Boolean);
|
|
2179
|
-
nodeJSON.blocks = blockJSONs;
|
|
2180
|
-
}
|
|
2181
|
-
if (nodeEdges.has(nodeJSON.id)) {
|
|
2182
|
-
const edgeIDs = nodeEdges.get(nodeJSON.id);
|
|
2183
|
-
const edgeJSONs = edgeIDs.map((edgeID) => edgeMap.get(edgeID)).filter(Boolean);
|
|
2184
|
-
nodeJSON.edges = edgeJSONs;
|
|
2185
|
-
}
|
|
2186
|
-
});
|
|
2187
|
-
flattenJSON.edges.forEach((edgeJSON) => {
|
|
2188
|
-
const edgeID = this.getEdgeID(edgeJSON);
|
|
2189
|
-
if (rootEdgeSet.has(edgeID)) {
|
|
2190
|
-
nestJSON.edges.push(edgeJSON);
|
|
2191
|
-
}
|
|
2192
|
-
});
|
|
2193
|
-
return nestJSON;
|
|
2194
|
-
}
|
|
2195
2101
|
/**
|
|
2196
2102
|
* 逐层创建节点和线条
|
|
2197
2103
|
*/
|
|
2198
2104
|
renderJSON(json, options) {
|
|
2199
2105
|
const { parent = this.root, isClone = false } = options ?? {};
|
|
2200
2106
|
const containerID = this.getNodeSubCanvas(parent)?.canvasNode.id ?? parent.id;
|
|
2201
|
-
json.nodes.
|
|
2202
|
-
this.createWorkflowNode(nodeJSON, isClone, containerID)
|
|
2203
|
-
|
|
2204
|
-
json.edges.
|
|
2107
|
+
const nodes = json.nodes.map(
|
|
2108
|
+
(nodeJSON) => this.createWorkflowNode(nodeJSON, isClone, containerID)
|
|
2109
|
+
);
|
|
2110
|
+
const edges = json.edges.map((edge) => this.createWorkflowLine(edge, containerID)).filter(Boolean);
|
|
2111
|
+
return { nodes, edges };
|
|
2205
2112
|
}
|
|
2206
2113
|
getNodeSubCanvas(node) {
|
|
2207
2114
|
if (!node) return;
|
|
@@ -2341,7 +2248,7 @@ var WorkflowDragService = class {
|
|
|
2341
2248
|
* 拖拽选中节点
|
|
2342
2249
|
* @param triggerEvent
|
|
2343
2250
|
*/
|
|
2344
|
-
startDragSelectedNodes(triggerEvent) {
|
|
2251
|
+
async startDragSelectedNodes(triggerEvent) {
|
|
2345
2252
|
let { selectedNodes } = this.selectService;
|
|
2346
2253
|
if (selectedNodes.length === 0 || this.playgroundConfig.readonly || this.playgroundConfig.disabled || this.isDragging) {
|
|
2347
2254
|
return Promise.resolve(false);
|