@flowgram.ai/free-layout-core 0.1.24 → 0.1.26
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 +55 -18
- 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 +51 -14
- 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-DgCmDX1d.d.mts → workflow-line-entity-CJVb7UCW.d.mts} +51 -4
- package/dist/{workflow-line-entity-B8wC-OVt.d.ts → workflow-line-entity-Civfgdcf.d.ts} +51 -4
- 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,
|
|
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-CJVb7UCW.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, J as WorkfloEntityHoverable, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, M as WorkflowDocumentOptionsDefault, K as WorkflowDocumentProvider, I as WorkflowEntityHoverable, 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-CJVb7UCW.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,
|
|
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-Civfgdcf.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, J as WorkfloEntityHoverable, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, M as WorkflowDocumentOptionsDefault, K as WorkflowDocumentProvider, I as WorkflowEntityHoverable, 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-Civfgdcf.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
|
@@ -1089,8 +1089,8 @@ WorkflowSelectService = __decorateClass([
|
|
|
1089
1089
|
|
|
1090
1090
|
// src/service/workflow-hover-service.ts
|
|
1091
1091
|
var import_inversify2 = require("inversify");
|
|
1092
|
-
var import_core10 = require("@flowgram.ai/core");
|
|
1093
1092
|
var import_utils11 = require("@flowgram.ai/utils");
|
|
1093
|
+
var import_core10 = require("@flowgram.ai/core");
|
|
1094
1094
|
var WorkflowHoverService = class {
|
|
1095
1095
|
constructor() {
|
|
1096
1096
|
this.onHoveredChangeEmitter = new import_utils11.Emitter();
|
|
@@ -1604,9 +1604,9 @@ var import_core14 = require("@flowgram.ai/core");
|
|
|
1604
1604
|
|
|
1605
1605
|
// src/layout/free-layout.ts
|
|
1606
1606
|
var import_inversify4 = require("inversify");
|
|
1607
|
+
var import_utils13 = require("@flowgram.ai/utils");
|
|
1607
1608
|
var import_document6 = require("@flowgram.ai/document");
|
|
1608
1609
|
var import_core13 = require("@flowgram.ai/core");
|
|
1609
|
-
var import_utils13 = require("@flowgram.ai/utils");
|
|
1610
1610
|
var FREE_LAYOUT_KEY = "free-layout";
|
|
1611
1611
|
var FreeLayout = class {
|
|
1612
1612
|
constructor() {
|
|
@@ -1641,6 +1641,21 @@ var FreeLayout = class {
|
|
|
1641
1641
|
const parentTransform = node.parent.getData(import_document6.FlowNodeTransformData);
|
|
1642
1642
|
parentTransform.transform.fireChange();
|
|
1643
1643
|
}
|
|
1644
|
+
/**
|
|
1645
|
+
* 更新所有受影响的上下游节点
|
|
1646
|
+
*/
|
|
1647
|
+
updateAffectedTransform(node) {
|
|
1648
|
+
const transformData = node.transform;
|
|
1649
|
+
if (!transformData.localDirty) {
|
|
1650
|
+
return;
|
|
1651
|
+
}
|
|
1652
|
+
const allParents = this.getAllParents(node);
|
|
1653
|
+
const allBlocks = this.getAllBlocks(node).reverse();
|
|
1654
|
+
const affectedNodes = [...allBlocks, ...allParents];
|
|
1655
|
+
affectedNodes.forEach((node2) => {
|
|
1656
|
+
this.fireChange(node2);
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1644
1659
|
/**
|
|
1645
1660
|
* 获取节点的 padding 数据
|
|
1646
1661
|
* @param node
|
|
@@ -1686,6 +1701,30 @@ var FreeLayout = class {
|
|
|
1686
1701
|
getDefaultNodeOrigin() {
|
|
1687
1702
|
return { x: 0.5, y: 0 };
|
|
1688
1703
|
}
|
|
1704
|
+
getAllParents(node) {
|
|
1705
|
+
const parents = [];
|
|
1706
|
+
let current = node.parent;
|
|
1707
|
+
while (current) {
|
|
1708
|
+
parents.push(current);
|
|
1709
|
+
current = current.parent;
|
|
1710
|
+
}
|
|
1711
|
+
return parents;
|
|
1712
|
+
}
|
|
1713
|
+
getAllBlocks(node) {
|
|
1714
|
+
return node.blocks.reduce(
|
|
1715
|
+
(acc, child) => [...acc, ...this.getAllBlocks(child)],
|
|
1716
|
+
[node]
|
|
1717
|
+
);
|
|
1718
|
+
}
|
|
1719
|
+
fireChange(node) {
|
|
1720
|
+
const transformData = node?.transform;
|
|
1721
|
+
if (!node || !transformData?.localDirty) {
|
|
1722
|
+
return;
|
|
1723
|
+
}
|
|
1724
|
+
node.clearMemoGlobal();
|
|
1725
|
+
node.clearMemoLocal();
|
|
1726
|
+
transformData.transform.fireChange();
|
|
1727
|
+
}
|
|
1689
1728
|
};
|
|
1690
1729
|
__decorateClass([
|
|
1691
1730
|
(0, import_inversify4.inject)(import_core13.PlaygroundConfigEntity)
|
|
@@ -1880,6 +1919,13 @@ var WorkflowDocument = class extends import_document7.FlowDocument {
|
|
|
1880
1919
|
});
|
|
1881
1920
|
return node;
|
|
1882
1921
|
}
|
|
1922
|
+
get layout() {
|
|
1923
|
+
const layout = this.layouts.find((layout2) => layout2.name == this.currentLayoutKey);
|
|
1924
|
+
if (!layout) {
|
|
1925
|
+
throw new Error(`Unknown flow layout: ${this.currentLayoutKey}`);
|
|
1926
|
+
}
|
|
1927
|
+
return layout;
|
|
1928
|
+
}
|
|
1883
1929
|
/**
|
|
1884
1930
|
* 获取默认的 x y 坐标, 默认为当前画布可视区域中心
|
|
1885
1931
|
* @param type
|
|
@@ -2293,15 +2339,10 @@ var WorkflowDragService = class {
|
|
|
2293
2339
|
x: nodeStartPosition.x + offset.x,
|
|
2294
2340
|
y: nodeStartPosition.y + offset.y
|
|
2295
2341
|
};
|
|
2296
|
-
if (node.collapsedChildren?.length > 0) {
|
|
2297
|
-
node.collapsedChildren.forEach((childNode) => {
|
|
2298
|
-
const childNodeTransformData = childNode.getData(import_document8.FlowNodeTransformData);
|
|
2299
|
-
childNodeTransformData.fireChange();
|
|
2300
|
-
});
|
|
2301
|
-
}
|
|
2302
2342
|
transform.update({
|
|
2303
2343
|
position: newPosition
|
|
2304
2344
|
});
|
|
2345
|
+
this.document.layout.updateAffectedTransform(node);
|
|
2305
2346
|
positions.push(newPosition);
|
|
2306
2347
|
});
|
|
2307
2348
|
this._nodesDragEmitter.fire({
|
|
@@ -2822,18 +2863,14 @@ var layoutToPositions = async (nodes, nodePositionMap) => {
|
|
|
2822
2863
|
const transform = node.getData(import_core16.TransformData);
|
|
2823
2864
|
const deltaX = (nodePositionMap[node.id].x - transform.position.x) * v.d / 100;
|
|
2824
2865
|
const deltaY = (nodePositionMap[node.id].y - transform.bounds.height / 2 - transform.position.y) * v.d / 100;
|
|
2825
|
-
if (node.collapsedChildren?.length > 0) {
|
|
2826
|
-
node.collapsedChildren.forEach((childNode) => {
|
|
2827
|
-
const childNodeTransformData = childNode.getData(import_document10.FlowNodeTransformData);
|
|
2828
|
-
childNodeTransformData.fireChange();
|
|
2829
|
-
});
|
|
2830
|
-
}
|
|
2831
2866
|
transform.update({
|
|
2832
2867
|
position: {
|
|
2833
2868
|
x: transform.position.x + deltaX,
|
|
2834
2869
|
y: transform.position.y + deltaY
|
|
2835
2870
|
}
|
|
2836
2871
|
});
|
|
2872
|
+
const document2 = node.document;
|
|
2873
|
+
document2.layout.updateAffectedTransform(node);
|
|
2837
2874
|
});
|
|
2838
2875
|
},
|
|
2839
2876
|
onComplete: () => {
|