@flowgram.ai/free-layout-core 0.4.18 → 0.5.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.
@@ -1,4 +1,4 @@
1
- export { l as LineCenterPoint, x as LineColor, y as LineColors, L as LineEventProps, w as LinePoint, v as LinePointLocation, k as LinePosition, i as LineRenderType, u as LineType, C as NodesDragEndEvent, N as NodesDragEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, O as OnDragLineEnd, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, m as WorkflowJSON, j as WorkflowLineRenderContribution, z as WorkflowLineRenderContributionFactory, e as WorkflowNodeJSON, t as WorkflowNodeMeta, A as WorkflowSubCanvas, E as onDragLineEndParams } from '../workflow-node-entity-DtPEYn6-.mjs';
1
+ export { L as LineCenterPoint, x as LineColor, y as LineColors, g as LineEventProps, w as LinePoint, v as LinePointLocation, m as LinePosition, k as LineRenderType, u as LineType, C as NodesDragEndEvent, N as NodesDragEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, O as OnDragLineEnd, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, W as WorkflowJSON, l as WorkflowLineRenderContribution, z as WorkflowLineRenderContributionFactory, h as WorkflowNodeJSON, t as WorkflowNodeMeta, A as WorkflowSubCanvas, E as onDragLineEndParams } from '../workflow-node-entity-lKu00Aj4.mjs';
2
2
  export { WorkflowEdgeJSON } from './workflow-edge.mjs';
3
3
  export { WorkflowNodeFormMeta, WorkflowNodeRegistry, WorkflowNodeRenderProps } from './workflow-registry.mjs';
4
4
  export { NodePostionUpdateEvent, WorkflowOperationBaseService } from './workflow-operation.mjs';
@@ -1,4 +1,4 @@
1
- export { l as LineCenterPoint, x as LineColor, y as LineColors, L as LineEventProps, w as LinePoint, v as LinePointLocation, k as LinePosition, i as LineRenderType, u as LineType, C as NodesDragEndEvent, N as NodesDragEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, O as OnDragLineEnd, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, m as WorkflowJSON, j as WorkflowLineRenderContribution, z as WorkflowLineRenderContributionFactory, e as WorkflowNodeJSON, t as WorkflowNodeMeta, A as WorkflowSubCanvas, E as onDragLineEndParams } from '../workflow-node-entity-GyY_PHY6.js';
1
+ export { L as LineCenterPoint, x as LineColor, y as LineColors, g as LineEventProps, w as LinePoint, v as LinePointLocation, m as LinePosition, k as LineRenderType, u as LineType, C as NodesDragEndEvent, N as NodesDragEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, O as OnDragLineEnd, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, W as WorkflowJSON, l as WorkflowLineRenderContribution, z as WorkflowLineRenderContributionFactory, h as WorkflowNodeJSON, t as WorkflowNodeMeta, A as WorkflowSubCanvas, E as onDragLineEndParams } from '../workflow-node-entity-Cnte2phX.js';
2
2
  export { WorkflowEdgeJSON } from './workflow-edge.js';
3
3
  export { WorkflowNodeFormMeta, WorkflowNodeRegistry, WorkflowNodeRenderProps } from './workflow-registry.js';
4
4
  export { NodePostionUpdateEvent, WorkflowOperationBaseService } from './workflow-operation.js';
@@ -2,6 +2,6 @@ import 'react';
2
2
  import '@flowgram.ai/utils';
3
3
  import '@flowgram.ai/document';
4
4
  import '@flowgram.ai/core';
5
- export { L as LineEventProps, C as NodesDragEndEvent, N as NodesDragEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, O as OnDragLineEnd, E as onDragLineEndParams } from '../workflow-node-entity-DtPEYn6-.mjs';
5
+ export { g as LineEventProps, C as NodesDragEndEvent, N as NodesDragEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, O as OnDragLineEnd, E as onDragLineEndParams } from '../workflow-node-entity-lKu00Aj4.mjs';
6
6
  import '@flowgram.ai/form-core';
7
7
  import './workflow-edge.mjs';
@@ -2,6 +2,6 @@ import 'react';
2
2
  import '@flowgram.ai/utils';
3
3
  import '@flowgram.ai/document';
4
4
  import '@flowgram.ai/core';
5
- export { L as LineEventProps, C as NodesDragEndEvent, N as NodesDragEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, O as OnDragLineEnd, E as onDragLineEndParams } from '../workflow-node-entity-GyY_PHY6.js';
5
+ export { g as LineEventProps, C as NodesDragEndEvent, N as NodesDragEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, O as OnDragLineEnd, E as onDragLineEndParams } from '../workflow-node-entity-Cnte2phX.js';
6
6
  import '@flowgram.ai/form-core';
7
7
  import './workflow-edge.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/typings/workflow-drag.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport type React from 'react';\n\nimport { type PositionSchema } from '@flowgram.ai/utils';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\nimport { PlaygroundDrag, type PlaygroundDragEvent } from '@flowgram.ai/core';\n\nimport { type WorkflowLineEntity, type WorkflowPortEntity } from '../entities';\n\nexport interface LineEventProps {\n type: 'onDrag' | 'onDragEnd';\n onDragNodeId?: string;\n event?: MouseEvent;\n}\n\ninterface INodesDragEvent {\n type: string;\n nodes: FlowNodeEntity[];\n startPositions: PositionSchema[];\n dragEvent: PlaygroundDragEvent;\n triggerEvent: MouseEvent | React.MouseEvent;\n dragger: PlaygroundDrag;\n}\n\nexport interface NodesDragStartEvent extends INodesDragEvent {\n type: 'onDragStart';\n}\n\nexport interface NodesDragEndEvent extends INodesDragEvent {\n type: 'onDragEnd';\n}\n\nexport interface NodesDraggingEvent extends INodesDragEvent {\n type: 'onDragging';\n positions: PositionSchema[];\n}\n\nexport type NodesDragEvent = NodesDragStartEvent | NodesDraggingEvent | NodesDragEndEvent;\n\nexport type onDragLineEndParams = {\n fromPort: WorkflowPortEntity;\n toPort?: WorkflowPortEntity;\n mousePos: PositionSchema;\n line?: WorkflowLineEntity;\n originLine?: WorkflowLineEntity;\n event: PlaygroundDragEvent;\n};\n\nexport type OnDragLineEnd = (params: onDragLineEndParams) => Promise<void>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/typings/workflow-drag.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport type React from 'react';\n\nimport { type PositionSchema } from '@flowgram.ai/utils';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\nimport { PlaygroundDrag, type PlaygroundDragEvent } from '@flowgram.ai/core';\n\nimport { type WorkflowLineEntity, type WorkflowPortEntity } from '../entities';\n\nexport interface LineEventProps {\n type: 'onDrag' | 'onDragEnd';\n onDragNodeId?: string;\n event?: MouseEvent;\n}\n\ninterface INodesDragEvent {\n type: string;\n nodes: FlowNodeEntity[];\n startPositions: PositionSchema[];\n dragEvent: PlaygroundDragEvent;\n triggerEvent: MouseEvent | React.MouseEvent;\n dragger: PlaygroundDrag;\n}\n\nexport interface NodesDragStartEvent extends INodesDragEvent {\n type: 'onDragStart';\n}\n\nexport interface NodesDragEndEvent extends INodesDragEvent {\n type: 'onDragEnd';\n}\n\nexport interface NodesDraggingEvent extends INodesDragEvent {\n type: 'onDragging';\n positions: PositionSchema[];\n}\n\nexport type NodesDragEvent = NodesDragStartEvent | NodesDraggingEvent | NodesDragEndEvent;\n\nexport type onDragLineEndParams = {\n fromPort?: WorkflowPortEntity;\n toPort?: WorkflowPortEntity;\n mousePos: PositionSchema;\n line?: WorkflowLineEntity;\n originLine?: WorkflowLineEntity;\n event: PlaygroundDragEvent;\n};\n\nexport type OnDragLineEnd = (params: onDragLineEndParams) => Promise<void>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,4 +1,4 @@
1
- export { s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, m as WorkflowJSON } from '../workflow-node-entity-DtPEYn6-.mjs';
1
+ export { s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, W as WorkflowJSON } from '../workflow-node-entity-lKu00Aj4.mjs';
2
2
  import './workflow-edge.mjs';
3
3
  import '@flowgram.ai/document';
4
4
  import '@flowgram.ai/core';
@@ -1,4 +1,4 @@
1
- export { s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, m as WorkflowJSON } from '../workflow-node-entity-GyY_PHY6.js';
1
+ export { s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, W as WorkflowJSON } from '../workflow-node-entity-Cnte2phX.js';
2
2
  import './workflow-edge.js';
3
3
  import '@flowgram.ai/document';
4
4
  import '@flowgram.ai/core';
@@ -1,5 +1,5 @@
1
1
  import '@flowgram.ai/utils';
2
- export { l as LineCenterPoint, x as LineColor, y as LineColors, w as LinePoint, v as LinePointLocation, k as LinePosition, i as LineRenderType, u as LineType, j as WorkflowLineRenderContribution, z as WorkflowLineRenderContributionFactory } from '../workflow-node-entity-DtPEYn6-.mjs';
2
+ export { L as LineCenterPoint, x as LineColor, y as LineColors, w as LinePoint, v as LinePointLocation, m as LinePosition, k as LineRenderType, u as LineType, l as WorkflowLineRenderContribution, z as WorkflowLineRenderContributionFactory } from '../workflow-node-entity-lKu00Aj4.mjs';
3
3
  import '@flowgram.ai/document';
4
4
  import '@flowgram.ai/core';
5
5
  import 'react';
@@ -1,5 +1,5 @@
1
1
  import '@flowgram.ai/utils';
2
- export { l as LineCenterPoint, x as LineColor, y as LineColors, w as LinePoint, v as LinePointLocation, k as LinePosition, i as LineRenderType, u as LineType, j as WorkflowLineRenderContribution, z as WorkflowLineRenderContributionFactory } from '../workflow-node-entity-GyY_PHY6.js';
2
+ export { L as LineCenterPoint, x as LineColor, y as LineColors, w as LinePoint, v as LinePointLocation, m as LinePosition, k as LineRenderType, u as LineType, l as WorkflowLineRenderContribution, z as WorkflowLineRenderContributionFactory } from '../workflow-node-entity-Cnte2phX.js';
3
3
  import '@flowgram.ai/document';
4
4
  import '@flowgram.ai/core';
5
5
  import 'react';
@@ -1,6 +1,6 @@
1
1
  import '@flowgram.ai/utils';
2
2
  import '@flowgram.ai/document';
3
- export { e as WorkflowNodeJSON, t as WorkflowNodeMeta } from '../workflow-node-entity-DtPEYn6-.mjs';
3
+ export { h as WorkflowNodeJSON, t as WorkflowNodeMeta } from '../workflow-node-entity-lKu00Aj4.mjs';
4
4
  import './workflow-edge.mjs';
5
5
  import '@flowgram.ai/core';
6
6
  import 'react';
@@ -1,6 +1,6 @@
1
1
  import '@flowgram.ai/utils';
2
2
  import '@flowgram.ai/document';
3
- export { e as WorkflowNodeJSON, t as WorkflowNodeMeta } from '../workflow-node-entity-GyY_PHY6.js';
3
+ export { h as WorkflowNodeJSON, t as WorkflowNodeMeta } from '../workflow-node-entity-Cnte2phX.js';
4
4
  import './workflow-edge.js';
5
5
  import '@flowgram.ai/core';
6
6
  import 'react';
@@ -1,7 +1,7 @@
1
1
  import { FormMeta } from '@flowgram.ai/node';
2
2
  import { FormMetaOrFormMetaGenerator } from '@flowgram.ai/form-core';
3
3
  import { FlowNodeRegistry } from '@flowgram.ai/document';
4
- import { t as WorkflowNodeMeta, g as WorkflowPortEntity, b as WorkflowLinesManager, f as WorkflowNodeEntity } from '../workflow-node-entity-DtPEYn6-.mjs';
4
+ import { t as WorkflowNodeMeta, i as WorkflowPortEntity, d as WorkflowLinesManager, b as WorkflowNodeEntity } from '../workflow-node-entity-lKu00Aj4.mjs';
5
5
  import '@flowgram.ai/core';
6
6
  import '@flowgram.ai/utils';
7
7
  import 'react';
@@ -1,7 +1,7 @@
1
1
  import { FormMeta } from '@flowgram.ai/node';
2
2
  import { FormMetaOrFormMetaGenerator } from '@flowgram.ai/form-core';
3
3
  import { FlowNodeRegistry } from '@flowgram.ai/document';
4
- import { t as WorkflowNodeMeta, g as WorkflowPortEntity, b as WorkflowLinesManager, f as WorkflowNodeEntity } from '../workflow-node-entity-GyY_PHY6.js';
4
+ import { t as WorkflowNodeMeta, i as WorkflowPortEntity, d as WorkflowLinesManager, b as WorkflowNodeEntity } from '../workflow-node-entity-Cnte2phX.js';
5
5
  import '@flowgram.ai/core';
6
6
  import '@flowgram.ai/utils';
7
7
  import 'react';
@@ -1,4 +1,4 @@
1
- export { A as WorkflowSubCanvas } from '../workflow-node-entity-DtPEYn6-.mjs';
1
+ export { A as WorkflowSubCanvas } from '../workflow-node-entity-lKu00Aj4.mjs';
2
2
  import '@flowgram.ai/document';
3
3
  import '@flowgram.ai/core';
4
4
  import '@flowgram.ai/utils';
@@ -1,4 +1,4 @@
1
- export { A as WorkflowSubCanvas } from '../workflow-node-entity-GyY_PHY6.js';
1
+ export { A as WorkflowSubCanvas } from '../workflow-node-entity-Cnte2phX.js';
2
2
  import '@flowgram.ai/document';
3
3
  import '@flowgram.ai/core';
4
4
  import '@flowgram.ai/utils';
@@ -144,10 +144,12 @@ interface WorkflowDocumentOptions extends FlowDocumentOptions {
144
144
  grab?: string;
145
145
  grabbing?: string;
146
146
  };
147
+ /** 双向连接 */
148
+ twoWayConnection?: boolean;
147
149
  /** 线条颜色 */
148
150
  lineColor?: Partial<LineColor>;
149
151
  /** 是否显示错误线条 */
150
- isErrorLine?: (fromPort: WorkflowPortEntity, toPort: WorkflowPortEntity | undefined, lines: WorkflowLinesManager) => boolean;
152
+ isErrorLine?: (fromPort: WorkflowPortEntity | undefined, toPort: WorkflowPortEntity | undefined, lines: WorkflowLinesManager) => boolean;
151
153
  /** 是否错误端口 */
152
154
  isErrorPort?: (port: WorkflowPortEntity) => boolean;
153
155
  /** 是否禁用端口 */
@@ -178,7 +180,7 @@ interface WorkflowDocumentOptions extends FlowDocumentOptions {
178
180
  * @param newToPort - 新的连接点
179
181
  * @param lines - 线条管理器
180
182
  */
181
- canResetLine?: (fromPort: WorkflowPortEntity, oldToPort: WorkflowPortEntity, newToPort: WorkflowPortEntity, lines: WorkflowLinesManager) => boolean;
183
+ canResetLine?: (oldLine: WorkflowLineEntity, newLineInfo: Required<WorkflowLinePortInfo>, lines: WorkflowLinesManager) => boolean;
182
184
  /**
183
185
  * 是否允许拖入子画布 (loop or group)
184
186
  * Whether to allow dragging into the sub-canvas (loop or group)
@@ -238,8 +240,13 @@ declare class WorkflowHoverService {
238
240
  isSomeHovered(): boolean;
239
241
  /**
240
242
  * 获取被 hover 的节点或线条
243
+ * @deprecated use 'someHovered' instead
241
244
  */
242
- get hoveredNode(): WorkfloEntityHoverable | undefined;
245
+ get hoveredNode(): WorkflowEntityHoverable | undefined;
246
+ /**
247
+ * 获取被 hover 的节点或线条
248
+ */
249
+ get someHovered(): WorkflowEntityHoverable | undefined;
243
250
  }
244
251
 
245
252
  /**
@@ -542,7 +549,7 @@ interface NodesDraggingEvent extends INodesDragEvent {
542
549
  }
543
550
  type NodesDragEvent = NodesDragStartEvent | NodesDraggingEvent | NodesDragEndEvent;
544
551
  type onDragLineEndParams = {
545
- fromPort: WorkflowPortEntity;
552
+ fromPort?: WorkflowPortEntity;
546
553
  toPort?: WorkflowPortEntity;
547
554
  mousePos: PositionSchema;
548
555
  line?: WorkflowLineEntity;
@@ -579,12 +586,14 @@ declare class WorkflowLinesManager {
579
586
  get lineColor(): LineColor;
580
587
  switchLineType(newType?: LineRenderType): LineRenderType;
581
588
  getAllLines(): WorkflowLineEntity[];
589
+ getAllAvailableLines(): WorkflowLineEntity[];
582
590
  hasLine(portInfo: Omit<WorkflowLinePortInfo, 'data'>): boolean;
583
591
  getLine(portInfo: Omit<WorkflowLinePortInfo, 'data'>): WorkflowLineEntity | undefined;
584
592
  getLineById(id: string): WorkflowLineEntity | undefined;
585
593
  replaceLine(oldPortInfo: Omit<WorkflowLinePortInfo, 'data'>, newPortInfo: Omit<WorkflowLinePortInfo, 'data'>): WorkflowLineEntity;
586
594
  createLine(options: {
587
595
  drawingTo?: LinePoint;
596
+ drawingFrom?: LinePoint;
588
597
  key?: string;
589
598
  } & WorkflowLinePortInfo): WorkflowLineEntity | undefined;
590
599
  /**
@@ -600,7 +609,7 @@ declare class WorkflowLinesManager {
600
609
  isDrawing: boolean;
601
610
  dispose(): void;
602
611
  get disposed(): boolean;
603
- isErrorLine(fromPort: WorkflowPortEntity, toPort?: WorkflowPortEntity, defaultValue?: boolean): boolean;
612
+ isErrorLine(fromPort?: WorkflowPortEntity, toPort?: WorkflowPortEntity, defaultValue?: boolean): boolean;
604
613
  isReverseLine(line: WorkflowLineEntity, defaultValue?: boolean): boolean;
605
614
  isHideArrowLine(line: WorkflowLineEntity, defaultValue?: boolean): boolean;
606
615
  isFlowingLine(line: WorkflowLineEntity, defaultValue?: boolean): boolean;
@@ -612,12 +621,12 @@ declare class WorkflowLinesManager {
612
621
  toJSON(): WorkflowEdgeJSON[];
613
622
  getPortById(portId: string): WorkflowPortEntity | undefined;
614
623
  canRemove(line: WorkflowLineEntity, newLineInfo?: Required<Omit<WorkflowLinePortInfo, 'data'>>, silent?: boolean): boolean;
615
- canReset(fromPort: WorkflowPortEntity, oldToPort: WorkflowPortEntity, newToPort: WorkflowPortEntity): boolean;
624
+ canReset(oldLine: WorkflowLineEntity, newLineInfo: Required<WorkflowLinePortInfo>): boolean;
616
625
  /**
617
626
  * 根据鼠标位置找到 port
618
627
  * @param pos
619
628
  */
620
- getPortFromMousePos(pos: IPoint): WorkflowPortEntity | undefined;
629
+ getPortFromMousePos(pos: IPoint, portType?: WorkflowPortType): WorkflowPortEntity | undefined;
621
630
  /**
622
631
  * 根据鼠标位置找到 node
623
632
  * @param pos - 鼠标位置
@@ -634,7 +643,7 @@ declare class WorkflowLinesManager {
634
643
  declare const LINE_HOVER_DISTANCE = 8;
635
644
  declare const POINT_RADIUS = 10;
636
645
  interface WorkflowLinePortInfo {
637
- from: string;
646
+ from?: string;
638
647
  to?: string;
639
648
  fromPort?: string | number;
640
649
  toPort?: string | number;
@@ -644,9 +653,11 @@ interface WorkflowLineEntityOpts extends EntityOpts, WorkflowLinePortInfo {
644
653
  document: WorkflowDocument;
645
654
  linesManager: WorkflowLinesManager;
646
655
  drawingTo?: LinePoint;
656
+ drawingFrom?: LinePoint;
647
657
  }
648
658
  interface WorkflowLineInfo extends WorkflowLinePortInfo {
649
659
  drawingTo?: LinePoint;
660
+ drawingFrom?: LinePoint;
650
661
  }
651
662
  interface WorkflowLineUIState {
652
663
  /**
@@ -724,7 +735,7 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
724
735
  oldValue: any;
725
736
  newValue: any;
726
737
  }>;
727
- private _from;
738
+ private _from?;
728
739
  private _to?;
729
740
  private _lineData;
730
741
  private _uiState;
@@ -760,7 +771,7 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
760
771
  /**
761
772
  * 获取线条的前置节点
762
773
  */
763
- get from(): WorkflowNodeEntity;
774
+ get from(): WorkflowNodeEntity | undefined;
764
775
  /**
765
776
  * 获取线条的后置节点
766
777
  */
@@ -783,10 +794,13 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
783
794
  * 设置线条的后置节点
784
795
  */
785
796
  setToPort(toPort?: WorkflowPortEntity): void;
797
+ setFromPort(fromPort?: WorkflowPortEntity): void;
786
798
  /**
787
799
  * 设置线条画线时的目标位置
788
800
  */
789
801
  set drawingTo(pos: LinePoint | undefined);
802
+ set drawingFrom(pos: LinePoint | undefined);
803
+ get drawingFrom(): LinePoint | undefined;
790
804
  /**
791
805
  * 获取线条正在画线的位置
792
806
  */
@@ -804,7 +818,7 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
804
818
  * 获取点和线最接近的距离
805
819
  */
806
820
  getHoverDist(pos: IPoint): number;
807
- get fromPort(): WorkflowPortEntity;
821
+ get fromPort(): WorkflowPortEntity | undefined;
808
822
  get toPort(): WorkflowPortEntity | undefined;
809
823
  /**
810
824
  * 获取线条真实的输入输出节点坐标
@@ -869,7 +883,7 @@ interface WorkflowPort {
869
883
  height: number;
870
884
  };
871
885
  /**
872
- * 相对于 position 的偏移
886
+ * 相对于 location 的偏移
873
887
  */
874
888
  offset?: IPoint;
875
889
  /**
@@ -1096,4 +1110,4 @@ declare module '@flowgram.ai/document' {
1096
1110
  type WorkflowNodeEntity = FlowNodeEntity;
1097
1111
  declare const WorkflowNodeEntity: typeof FlowNodeEntity;
1098
1112
 
1099
- export { type WorkflowSubCanvas as A, type NodesDragStartEvent as B, type NodesDragEndEvent as C, type NodesDraggingEvent as D, type onDragLineEndParams as E, LINE_HOVER_DISTANCE as F, type WorkflowLinePortInfo as G, type WorkflowLineEntityOpts as H, type WorkflowLineInfo as I, type WorkflowLineUIState as J, PORT_SIZE as K, type LineEventProps as L, type WorkflowPort as M, type NodesDragEvent as N, type OnDragLineEnd as O, POINT_RADIUS as P, type WorkflowPorts as Q, type WorkflowPortEntityOpts as R, WorkflowNodePortsData as S, type WorkflowNodeLines as T, WorkflowNodeLinesData as U, type WorkflowEntityHoverable as V, WorkflowHoverService as W, type HoverPosition as X, type WorkfloEntityHoverable as Y, WorkflowDocumentProvider as Z, WorkflowDocumentOptionsDefault as _, WorkflowDocument as a, WorkflowLinesManager as b, WorkflowSelectService as c, WorkflowDocumentOptions as d, type WorkflowNodeJSON as e, WorkflowNodeEntity as f, WorkflowPortEntity as g, WorkflowLineEntity as h, type LineRenderType as i, type WorkflowLineRenderContribution as j, type LinePosition as k, type LineCenterPoint as l, type WorkflowJSON as m, type WorkflowPortType as n, getPortEntityId as o, WORKFLOW_LINE_ENTITY as p, domReactToBounds as q, WorkflowContentChangeType as r, type WorkflowContentChangeEvent as s, type WorkflowNodeMeta as t, LineType as u, type LinePointLocation as v, type LinePoint as w, type LineColor as x, LineColors as y, type WorkflowLineRenderContributionFactory as z };
1113
+ export { type WorkflowSubCanvas as A, type NodesDragStartEvent as B, type NodesDragEndEvent as C, type NodesDraggingEvent as D, type onDragLineEndParams as E, LINE_HOVER_DISTANCE as F, type WorkflowLinePortInfo as G, type WorkflowLineEntityOpts as H, type WorkflowLineInfo as I, type WorkflowLineUIState as J, PORT_SIZE as K, type LineCenterPoint as L, type WorkflowPort as M, type NodesDragEvent as N, type OnDragLineEnd as O, POINT_RADIUS as P, type WorkflowPorts as Q, type WorkflowPortEntityOpts as R, WorkflowNodePortsData as S, type WorkflowNodeLines as T, WorkflowNodeLinesData as U, type WorkflowEntityHoverable as V, type WorkflowJSON as W, type HoverPosition as X, type WorkfloEntityHoverable as Y, WorkflowDocumentProvider as Z, WorkflowDocumentOptionsDefault as _, WorkflowDocument as a, WorkflowNodeEntity as b, WorkflowHoverService as c, WorkflowLinesManager as d, WorkflowSelectService as e, WorkflowDocumentOptions as f, type LineEventProps as g, type WorkflowNodeJSON as h, WorkflowPortEntity as i, WorkflowLineEntity as j, type LineRenderType as k, type WorkflowLineRenderContribution as l, type LinePosition as m, type WorkflowPortType as n, getPortEntityId as o, WORKFLOW_LINE_ENTITY as p, domReactToBounds as q, WorkflowContentChangeType as r, type WorkflowContentChangeEvent as s, type WorkflowNodeMeta as t, LineType as u, type LinePointLocation as v, type LinePoint as w, type LineColor as x, LineColors as y, type WorkflowLineRenderContributionFactory as z };
@@ -144,10 +144,12 @@ interface WorkflowDocumentOptions extends FlowDocumentOptions {
144
144
  grab?: string;
145
145
  grabbing?: string;
146
146
  };
147
+ /** 双向连接 */
148
+ twoWayConnection?: boolean;
147
149
  /** 线条颜色 */
148
150
  lineColor?: Partial<LineColor>;
149
151
  /** 是否显示错误线条 */
150
- isErrorLine?: (fromPort: WorkflowPortEntity, toPort: WorkflowPortEntity | undefined, lines: WorkflowLinesManager) => boolean;
152
+ isErrorLine?: (fromPort: WorkflowPortEntity | undefined, toPort: WorkflowPortEntity | undefined, lines: WorkflowLinesManager) => boolean;
151
153
  /** 是否错误端口 */
152
154
  isErrorPort?: (port: WorkflowPortEntity) => boolean;
153
155
  /** 是否禁用端口 */
@@ -178,7 +180,7 @@ interface WorkflowDocumentOptions extends FlowDocumentOptions {
178
180
  * @param newToPort - 新的连接点
179
181
  * @param lines - 线条管理器
180
182
  */
181
- canResetLine?: (fromPort: WorkflowPortEntity, oldToPort: WorkflowPortEntity, newToPort: WorkflowPortEntity, lines: WorkflowLinesManager) => boolean;
183
+ canResetLine?: (oldLine: WorkflowLineEntity, newLineInfo: Required<WorkflowLinePortInfo>, lines: WorkflowLinesManager) => boolean;
182
184
  /**
183
185
  * 是否允许拖入子画布 (loop or group)
184
186
  * Whether to allow dragging into the sub-canvas (loop or group)
@@ -238,8 +240,13 @@ declare class WorkflowHoverService {
238
240
  isSomeHovered(): boolean;
239
241
  /**
240
242
  * 获取被 hover 的节点或线条
243
+ * @deprecated use 'someHovered' instead
241
244
  */
242
- get hoveredNode(): WorkfloEntityHoverable | undefined;
245
+ get hoveredNode(): WorkflowEntityHoverable | undefined;
246
+ /**
247
+ * 获取被 hover 的节点或线条
248
+ */
249
+ get someHovered(): WorkflowEntityHoverable | undefined;
243
250
  }
244
251
 
245
252
  /**
@@ -542,7 +549,7 @@ interface NodesDraggingEvent extends INodesDragEvent {
542
549
  }
543
550
  type NodesDragEvent = NodesDragStartEvent | NodesDraggingEvent | NodesDragEndEvent;
544
551
  type onDragLineEndParams = {
545
- fromPort: WorkflowPortEntity;
552
+ fromPort?: WorkflowPortEntity;
546
553
  toPort?: WorkflowPortEntity;
547
554
  mousePos: PositionSchema;
548
555
  line?: WorkflowLineEntity;
@@ -579,12 +586,14 @@ declare class WorkflowLinesManager {
579
586
  get lineColor(): LineColor;
580
587
  switchLineType(newType?: LineRenderType): LineRenderType;
581
588
  getAllLines(): WorkflowLineEntity[];
589
+ getAllAvailableLines(): WorkflowLineEntity[];
582
590
  hasLine(portInfo: Omit<WorkflowLinePortInfo, 'data'>): boolean;
583
591
  getLine(portInfo: Omit<WorkflowLinePortInfo, 'data'>): WorkflowLineEntity | undefined;
584
592
  getLineById(id: string): WorkflowLineEntity | undefined;
585
593
  replaceLine(oldPortInfo: Omit<WorkflowLinePortInfo, 'data'>, newPortInfo: Omit<WorkflowLinePortInfo, 'data'>): WorkflowLineEntity;
586
594
  createLine(options: {
587
595
  drawingTo?: LinePoint;
596
+ drawingFrom?: LinePoint;
588
597
  key?: string;
589
598
  } & WorkflowLinePortInfo): WorkflowLineEntity | undefined;
590
599
  /**
@@ -600,7 +609,7 @@ declare class WorkflowLinesManager {
600
609
  isDrawing: boolean;
601
610
  dispose(): void;
602
611
  get disposed(): boolean;
603
- isErrorLine(fromPort: WorkflowPortEntity, toPort?: WorkflowPortEntity, defaultValue?: boolean): boolean;
612
+ isErrorLine(fromPort?: WorkflowPortEntity, toPort?: WorkflowPortEntity, defaultValue?: boolean): boolean;
604
613
  isReverseLine(line: WorkflowLineEntity, defaultValue?: boolean): boolean;
605
614
  isHideArrowLine(line: WorkflowLineEntity, defaultValue?: boolean): boolean;
606
615
  isFlowingLine(line: WorkflowLineEntity, defaultValue?: boolean): boolean;
@@ -612,12 +621,12 @@ declare class WorkflowLinesManager {
612
621
  toJSON(): WorkflowEdgeJSON[];
613
622
  getPortById(portId: string): WorkflowPortEntity | undefined;
614
623
  canRemove(line: WorkflowLineEntity, newLineInfo?: Required<Omit<WorkflowLinePortInfo, 'data'>>, silent?: boolean): boolean;
615
- canReset(fromPort: WorkflowPortEntity, oldToPort: WorkflowPortEntity, newToPort: WorkflowPortEntity): boolean;
624
+ canReset(oldLine: WorkflowLineEntity, newLineInfo: Required<WorkflowLinePortInfo>): boolean;
616
625
  /**
617
626
  * 根据鼠标位置找到 port
618
627
  * @param pos
619
628
  */
620
- getPortFromMousePos(pos: IPoint): WorkflowPortEntity | undefined;
629
+ getPortFromMousePos(pos: IPoint, portType?: WorkflowPortType): WorkflowPortEntity | undefined;
621
630
  /**
622
631
  * 根据鼠标位置找到 node
623
632
  * @param pos - 鼠标位置
@@ -634,7 +643,7 @@ declare class WorkflowLinesManager {
634
643
  declare const LINE_HOVER_DISTANCE = 8;
635
644
  declare const POINT_RADIUS = 10;
636
645
  interface WorkflowLinePortInfo {
637
- from: string;
646
+ from?: string;
638
647
  to?: string;
639
648
  fromPort?: string | number;
640
649
  toPort?: string | number;
@@ -644,9 +653,11 @@ interface WorkflowLineEntityOpts extends EntityOpts, WorkflowLinePortInfo {
644
653
  document: WorkflowDocument;
645
654
  linesManager: WorkflowLinesManager;
646
655
  drawingTo?: LinePoint;
656
+ drawingFrom?: LinePoint;
647
657
  }
648
658
  interface WorkflowLineInfo extends WorkflowLinePortInfo {
649
659
  drawingTo?: LinePoint;
660
+ drawingFrom?: LinePoint;
650
661
  }
651
662
  interface WorkflowLineUIState {
652
663
  /**
@@ -724,7 +735,7 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
724
735
  oldValue: any;
725
736
  newValue: any;
726
737
  }>;
727
- private _from;
738
+ private _from?;
728
739
  private _to?;
729
740
  private _lineData;
730
741
  private _uiState;
@@ -760,7 +771,7 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
760
771
  /**
761
772
  * 获取线条的前置节点
762
773
  */
763
- get from(): WorkflowNodeEntity;
774
+ get from(): WorkflowNodeEntity | undefined;
764
775
  /**
765
776
  * 获取线条的后置节点
766
777
  */
@@ -783,10 +794,13 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
783
794
  * 设置线条的后置节点
784
795
  */
785
796
  setToPort(toPort?: WorkflowPortEntity): void;
797
+ setFromPort(fromPort?: WorkflowPortEntity): void;
786
798
  /**
787
799
  * 设置线条画线时的目标位置
788
800
  */
789
801
  set drawingTo(pos: LinePoint | undefined);
802
+ set drawingFrom(pos: LinePoint | undefined);
803
+ get drawingFrom(): LinePoint | undefined;
790
804
  /**
791
805
  * 获取线条正在画线的位置
792
806
  */
@@ -804,7 +818,7 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
804
818
  * 获取点和线最接近的距离
805
819
  */
806
820
  getHoverDist(pos: IPoint): number;
807
- get fromPort(): WorkflowPortEntity;
821
+ get fromPort(): WorkflowPortEntity | undefined;
808
822
  get toPort(): WorkflowPortEntity | undefined;
809
823
  /**
810
824
  * 获取线条真实的输入输出节点坐标
@@ -869,7 +883,7 @@ interface WorkflowPort {
869
883
  height: number;
870
884
  };
871
885
  /**
872
- * 相对于 position 的偏移
886
+ * 相对于 location 的偏移
873
887
  */
874
888
  offset?: IPoint;
875
889
  /**
@@ -1096,4 +1110,4 @@ declare module '@flowgram.ai/document' {
1096
1110
  type WorkflowNodeEntity = FlowNodeEntity;
1097
1111
  declare const WorkflowNodeEntity: typeof FlowNodeEntity;
1098
1112
 
1099
- export { type WorkflowSubCanvas as A, type NodesDragStartEvent as B, type NodesDragEndEvent as C, type NodesDraggingEvent as D, type onDragLineEndParams as E, LINE_HOVER_DISTANCE as F, type WorkflowLinePortInfo as G, type WorkflowLineEntityOpts as H, type WorkflowLineInfo as I, type WorkflowLineUIState as J, PORT_SIZE as K, type LineEventProps as L, type WorkflowPort as M, type NodesDragEvent as N, type OnDragLineEnd as O, POINT_RADIUS as P, type WorkflowPorts as Q, type WorkflowPortEntityOpts as R, WorkflowNodePortsData as S, type WorkflowNodeLines as T, WorkflowNodeLinesData as U, type WorkflowEntityHoverable as V, WorkflowHoverService as W, type HoverPosition as X, type WorkfloEntityHoverable as Y, WorkflowDocumentProvider as Z, WorkflowDocumentOptionsDefault as _, WorkflowDocument as a, WorkflowLinesManager as b, WorkflowSelectService as c, WorkflowDocumentOptions as d, type WorkflowNodeJSON as e, WorkflowNodeEntity as f, WorkflowPortEntity as g, WorkflowLineEntity as h, type LineRenderType as i, type WorkflowLineRenderContribution as j, type LinePosition as k, type LineCenterPoint as l, type WorkflowJSON as m, type WorkflowPortType as n, getPortEntityId as o, WORKFLOW_LINE_ENTITY as p, domReactToBounds as q, WorkflowContentChangeType as r, type WorkflowContentChangeEvent as s, type WorkflowNodeMeta as t, LineType as u, type LinePointLocation as v, type LinePoint as w, type LineColor as x, LineColors as y, type WorkflowLineRenderContributionFactory as z };
1113
+ export { type WorkflowSubCanvas as A, type NodesDragStartEvent as B, type NodesDragEndEvent as C, type NodesDraggingEvent as D, type onDragLineEndParams as E, LINE_HOVER_DISTANCE as F, type WorkflowLinePortInfo as G, type WorkflowLineEntityOpts as H, type WorkflowLineInfo as I, type WorkflowLineUIState as J, PORT_SIZE as K, type LineCenterPoint as L, type WorkflowPort as M, type NodesDragEvent as N, type OnDragLineEnd as O, POINT_RADIUS as P, type WorkflowPorts as Q, type WorkflowPortEntityOpts as R, WorkflowNodePortsData as S, type WorkflowNodeLines as T, WorkflowNodeLinesData as U, type WorkflowEntityHoverable as V, type WorkflowJSON as W, type HoverPosition as X, type WorkfloEntityHoverable as Y, WorkflowDocumentProvider as Z, WorkflowDocumentOptionsDefault as _, WorkflowDocument as a, WorkflowNodeEntity as b, WorkflowHoverService as c, WorkflowLinesManager as d, WorkflowSelectService as e, WorkflowDocumentOptions as f, type LineEventProps as g, type WorkflowNodeJSON as h, WorkflowPortEntity as i, WorkflowLineEntity as j, type LineRenderType as k, type WorkflowLineRenderContribution as l, type LinePosition as m, type WorkflowPortType as n, getPortEntityId as o, WORKFLOW_LINE_ENTITY as p, domReactToBounds as q, WorkflowContentChangeType as r, type WorkflowContentChangeEvent as s, type WorkflowNodeMeta as t, LineType as u, type LinePointLocation as v, type LinePoint as w, type LineColor as x, LineColors as y, type WorkflowLineRenderContributionFactory as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowgram.ai/free-layout-core",
3
- "version": "0.4.18",
3
+ "version": "0.5.0",
4
4
  "homepage": "https://flowgram.ai/",
5
5
  "repository": "https://github.com/bytedance/flowgram.ai",
6
6
  "license": "MIT",
@@ -34,12 +34,12 @@
34
34
  "reflect-metadata": "~0.2.2",
35
35
  "lodash-es": "^4.17.21",
36
36
  "nanoid": "^5.0.9",
37
- "@flowgram.ai/core": "0.4.18",
38
- "@flowgram.ai/document": "0.4.18",
39
- "@flowgram.ai/form-core": "0.4.18",
40
- "@flowgram.ai/node": "0.4.18",
41
- "@flowgram.ai/reactive": "0.4.18",
42
- "@flowgram.ai/utils": "0.4.18"
37
+ "@flowgram.ai/core": "0.5.0",
38
+ "@flowgram.ai/document": "0.5.0",
39
+ "@flowgram.ai/form-core": "0.5.0",
40
+ "@flowgram.ai/node": "0.5.0",
41
+ "@flowgram.ai/reactive": "0.5.0",
42
+ "@flowgram.ai/utils": "0.5.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@testing-library/react": "^12",
@@ -53,8 +53,8 @@
53
53
  "tsup": "^8.0.1",
54
54
  "typescript": "^5.8.3",
55
55
  "vitest": "^3.2.4",
56
- "@flowgram.ai/eslint-config": "0.4.18",
57
- "@flowgram.ai/ts-config": "0.4.18"
56
+ "@flowgram.ai/eslint-config": "0.5.0",
57
+ "@flowgram.ai/ts-config": "0.5.0"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "react": ">=16.8",