@flowgram.ai/free-layout-core 0.1.0-alpha.15 → 0.1.0-alpha.17

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,11 +1,34 @@
1
+ import { FlowNodeJSON, FlowNodeMeta, FlowDocumentOptions, FlowNodeType, FlowLayout, FlowDocumentProvider, FlowDocument, FlowNodeEntity, AddNodeData } from '@flowgram.ai/document';
2
+ import { EntityManager, SelectionService, Playground, Entity, PlaygroundConfigEntity, PlaygroundContext, PlaygroundDragEvent, PlaygroundDrag, EntityOpts, EntityData } from '@flowgram.ai/core';
1
3
  import * as _flowgram_ai_utils from '@flowgram.ai/utils';
2
- import { IPoint, Rectangle, PositionSchema, Emitter, Event, PaddingSchema, SizeSchema, ScrollSchema, DisposableCollection } from '@flowgram.ai/utils';
3
- import { PlaygroundDragEvent, PlaygroundDrag, EntityManager, SelectionService, Playground, Entity, PlaygroundConfigEntity, PlaygroundContext, EntityOpts } from '@flowgram.ai/core';
4
- import { FlowNodeJSON, FlowNodeMeta, FlowNodeEntity, FlowDocumentOptions, FlowNodeType, FlowLayout, FlowDocumentProvider, FlowDocument, AddNodeData } from '@flowgram.ai/document';
5
- import { W as WorkflowNodeEntity, a as WorkflowSubCanvas } from './workflow-sub-canvas-IQzlYvPD.js';
4
+ import { Rectangle, IPoint, Emitter, PositionSchema, Event, PaddingSchema, SizeSchema, ScrollSchema, DisposableCollection } from '@flowgram.ai/utils';
5
+ import React$1 from 'react';
6
6
  import { NodeEngineContext } from '@flowgram.ai/form-core';
7
7
  import { WorkflowEdgeJSON } from './typings/workflow-edge.js';
8
- import React$1 from 'react';
8
+
9
+ /**
10
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
11
+ * SPDX-License-Identifier: MIT
12
+ */
13
+
14
+ type WorkflowPortType = 'input' | 'output';
15
+ declare const getPortEntityId: (node: WorkflowNodeEntity, portType: WorkflowPortType, portID?: string | number) => string;
16
+ declare const WORKFLOW_LINE_ENTITY = "WorkflowLineEntity";
17
+ declare function domReactToBounds(react: DOMRect): Rectangle;
18
+
19
+ /**
20
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
21
+ * SPDX-License-Identifier: MIT
22
+ */
23
+
24
+ /**
25
+ * 子画布配置
26
+ */
27
+ type WorkflowSubCanvas = {
28
+ isCanvas: boolean;
29
+ parentNode: WorkflowNodeEntity;
30
+ canvasNode: WorkflowNodeEntity;
31
+ };
9
32
 
10
33
  /**
11
34
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
@@ -107,105 +130,6 @@ interface WorkflowContentChangeEvent {
107
130
  entity: WorkflowNodeEntity | WorkflowLineEntity;
108
131
  }
109
132
 
110
- /**
111
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
112
- * SPDX-License-Identifier: MIT
113
- */
114
-
115
- declare enum LineType {
116
- BEZIER = 0,// 贝塞尔曲线
117
- LINE_CHART = 1,// 折叠线
118
- STRAIGHT = 2
119
- }
120
- type LineRenderType = LineType | string;
121
- type LinePointLocation = 'left' | 'top' | 'right' | 'bottom';
122
- interface LinePoint {
123
- x: number;
124
- y: number;
125
- location: LinePointLocation;
126
- }
127
- interface LinePosition {
128
- from: LinePoint;
129
- to: LinePoint;
130
- }
131
- interface LineColor {
132
- hidden: string;
133
- default: string;
134
- drawing: string;
135
- hovered: string;
136
- selected: string;
137
- error: string;
138
- flowing: string;
139
- }
140
- declare enum LineColors {
141
- HIDDEN = "var(--g-workflow-line-color-hidden,transparent)",// 隐藏线条
142
- DEFUALT = "var(--g-workflow-line-color-default,#4d53e8)",
143
- DRAWING = "var(--g-workflow-line-color-drawing, #5DD6E3)",// '#b5bbf8', // '#9197F1',
144
- HOVER = "var(--g-workflow-line-color-hover,#37d0ff)",
145
- SELECTED = "var(--g-workflow-line-color-selected,#37d0ff)",
146
- ERROR = "var(--g-workflow-line-color-error,red)",
147
- FLOWING = "var(--g-workflow-line-color-flowing,#4d53e8)"
148
- }
149
- interface LineCenterPoint {
150
- x: number;
151
- y: number;
152
- labelX: number;
153
- labelY: number;
154
- }
155
- interface WorkflowLineRenderContribution {
156
- entity: WorkflowLineEntity;
157
- path: string;
158
- center?: LineCenterPoint;
159
- bounds: Rectangle;
160
- update: (params: {
161
- fromPos: LinePoint;
162
- toPos: LinePoint;
163
- }) => void;
164
- calcDistance: (pos: IPoint) => number;
165
- }
166
- type WorkflowLineRenderContributionFactory = (new (entity: WorkflowLineEntity) => WorkflowLineRenderContribution) & {
167
- type: LineRenderType;
168
- };
169
-
170
- /**
171
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
172
- * SPDX-License-Identifier: MIT
173
- */
174
-
175
- interface LineEventProps {
176
- type: 'onDrag' | 'onDragEnd';
177
- onDragNodeId?: string;
178
- event?: MouseEvent;
179
- }
180
- interface INodesDragEvent {
181
- type: string;
182
- nodes: FlowNodeEntity[];
183
- startPositions: PositionSchema[];
184
- dragEvent: PlaygroundDragEvent;
185
- triggerEvent: MouseEvent | React$1.MouseEvent;
186
- dragger: PlaygroundDrag;
187
- }
188
- interface NodesDragStartEvent extends INodesDragEvent {
189
- type: 'onDragStart';
190
- }
191
- interface NodesDragEndEvent extends INodesDragEvent {
192
- type: 'onDragEnd';
193
- }
194
- interface NodesDraggingEvent extends INodesDragEvent {
195
- type: 'onDragging';
196
- positions: PositionSchema[];
197
- }
198
- type NodesDragEvent = NodesDragStartEvent | NodesDraggingEvent | NodesDragEndEvent;
199
- type onDragLineEndParams = {
200
- fromPort: WorkflowPortEntity;
201
- toPort?: WorkflowPortEntity;
202
- mousePos: PositionSchema;
203
- line?: WorkflowLineEntity;
204
- originLine?: WorkflowLineEntity;
205
- event: PlaygroundDragEvent;
206
- };
207
- type OnDragLineEnd = (params: onDragLineEndParams) => Promise<void>;
208
-
209
133
  /**
210
134
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
211
135
  * SPDX-License-Identifier: MIT
@@ -220,10 +144,12 @@ interface WorkflowDocumentOptions extends FlowDocumentOptions {
220
144
  grab?: string;
221
145
  grabbing?: string;
222
146
  };
147
+ /** 双向连接 */
148
+ twoWayConnection?: boolean;
223
149
  /** 线条颜色 */
224
150
  lineColor?: Partial<LineColor>;
225
151
  /** 是否显示错误线条 */
226
- isErrorLine?: (fromPort: WorkflowPortEntity, toPort: WorkflowPortEntity | undefined, lines: WorkflowLinesManager) => boolean;
152
+ isErrorLine?: (fromPort: WorkflowPortEntity | undefined, toPort: WorkflowPortEntity | undefined, lines: WorkflowLinesManager) => boolean;
227
153
  /** 是否错误端口 */
228
154
  isErrorPort?: (port: WorkflowPortEntity) => boolean;
229
155
  /** 是否禁用端口 */
@@ -254,7 +180,7 @@ interface WorkflowDocumentOptions extends FlowDocumentOptions {
254
180
  * @param newToPort - 新的连接点
255
181
  * @param lines - 线条管理器
256
182
  */
257
- canResetLine?: (fromPort: WorkflowPortEntity, oldToPort: WorkflowPortEntity, newToPort: WorkflowPortEntity, lines: WorkflowLinesManager) => boolean;
183
+ canResetLine?: (oldLine: WorkflowLineEntity, newLineInfo: Required<WorkflowLinePortInfo>, lines: WorkflowLinesManager) => boolean;
258
184
  /**
259
185
  * 是否允许拖入子画布 (loop or group)
260
186
  * Whether to allow dragging into the sub-canvas (loop or group)
@@ -312,10 +238,15 @@ declare class WorkflowHoverService {
312
238
  */
313
239
  isHovered(nodeId: string): boolean;
314
240
  isSomeHovered(): boolean;
241
+ /**
242
+ * 获取被 hover 的节点或线条
243
+ * @deprecated use 'someHovered' instead
244
+ */
245
+ get hoveredNode(): WorkflowEntityHoverable | undefined;
315
246
  /**
316
247
  * 获取被 hover 的节点或线条
317
248
  */
318
- get hoveredNode(): WorkfloEntityHoverable | undefined;
249
+ get someHovered(): WorkflowEntityHoverable | undefined;
319
250
  }
320
251
 
321
252
  /**
@@ -528,6 +459,105 @@ declare class WorkflowDocument extends FlowDocument {
528
459
  private createWorkflowLine;
529
460
  }
530
461
 
462
+ /**
463
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
464
+ * SPDX-License-Identifier: MIT
465
+ */
466
+
467
+ declare enum LineType {
468
+ BEZIER = 0,// 贝塞尔曲线
469
+ LINE_CHART = 1,// 折叠线
470
+ STRAIGHT = 2
471
+ }
472
+ type LineRenderType = LineType | string;
473
+ type LinePointLocation = 'left' | 'top' | 'right' | 'bottom';
474
+ interface LinePoint {
475
+ x: number;
476
+ y: number;
477
+ location: LinePointLocation;
478
+ }
479
+ interface LinePosition {
480
+ from: LinePoint;
481
+ to: LinePoint;
482
+ }
483
+ interface LineColor {
484
+ hidden: string;
485
+ default: string;
486
+ drawing: string;
487
+ hovered: string;
488
+ selected: string;
489
+ error: string;
490
+ flowing: string;
491
+ }
492
+ declare enum LineColors {
493
+ HIDDEN = "var(--g-workflow-line-color-hidden,transparent)",// 隐藏线条
494
+ DEFUALT = "var(--g-workflow-line-color-default,#4d53e8)",
495
+ DRAWING = "var(--g-workflow-line-color-drawing, #5DD6E3)",// '#b5bbf8', // '#9197F1',
496
+ HOVER = "var(--g-workflow-line-color-hover,#37d0ff)",
497
+ SELECTED = "var(--g-workflow-line-color-selected,#37d0ff)",
498
+ ERROR = "var(--g-workflow-line-color-error,red)",
499
+ FLOWING = "var(--g-workflow-line-color-flowing,#4d53e8)"
500
+ }
501
+ interface LineCenterPoint {
502
+ x: number;
503
+ y: number;
504
+ labelX: number;
505
+ labelY: number;
506
+ }
507
+ interface WorkflowLineRenderContribution {
508
+ entity: WorkflowLineEntity;
509
+ path: string;
510
+ center?: LineCenterPoint;
511
+ bounds: Rectangle;
512
+ update: (params: {
513
+ fromPos: LinePoint;
514
+ toPos: LinePoint;
515
+ }) => void;
516
+ calcDistance: (pos: IPoint) => number;
517
+ }
518
+ type WorkflowLineRenderContributionFactory = (new (entity: WorkflowLineEntity) => WorkflowLineRenderContribution) & {
519
+ type: LineRenderType;
520
+ };
521
+
522
+ /**
523
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
524
+ * SPDX-License-Identifier: MIT
525
+ */
526
+
527
+ interface LineEventProps {
528
+ type: 'onDrag' | 'onDragEnd';
529
+ onDragNodeId?: string;
530
+ event?: MouseEvent;
531
+ }
532
+ interface INodesDragEvent {
533
+ type: string;
534
+ nodes: FlowNodeEntity[];
535
+ startPositions: PositionSchema[];
536
+ dragEvent: PlaygroundDragEvent;
537
+ triggerEvent: MouseEvent | React$1.MouseEvent;
538
+ dragger: PlaygroundDrag;
539
+ }
540
+ interface NodesDragStartEvent extends INodesDragEvent {
541
+ type: 'onDragStart';
542
+ }
543
+ interface NodesDragEndEvent extends INodesDragEvent {
544
+ type: 'onDragEnd';
545
+ }
546
+ interface NodesDraggingEvent extends INodesDragEvent {
547
+ type: 'onDragging';
548
+ positions: PositionSchema[];
549
+ }
550
+ type NodesDragEvent = NodesDragStartEvent | NodesDraggingEvent | NodesDragEndEvent;
551
+ type onDragLineEndParams = {
552
+ fromPort?: WorkflowPortEntity;
553
+ toPort?: WorkflowPortEntity;
554
+ mousePos: PositionSchema;
555
+ line?: WorkflowLineEntity;
556
+ originLine?: WorkflowLineEntity;
557
+ event: PlaygroundDragEvent;
558
+ };
559
+ type OnDragLineEnd = (params: onDragLineEndParams) => Promise<void>;
560
+
531
561
  /**
532
562
  * 线条管理
533
563
  */
@@ -556,12 +586,14 @@ declare class WorkflowLinesManager {
556
586
  get lineColor(): LineColor;
557
587
  switchLineType(newType?: LineRenderType): LineRenderType;
558
588
  getAllLines(): WorkflowLineEntity[];
589
+ getAllAvailableLines(): WorkflowLineEntity[];
559
590
  hasLine(portInfo: Omit<WorkflowLinePortInfo, 'data'>): boolean;
560
591
  getLine(portInfo: Omit<WorkflowLinePortInfo, 'data'>): WorkflowLineEntity | undefined;
561
592
  getLineById(id: string): WorkflowLineEntity | undefined;
562
593
  replaceLine(oldPortInfo: Omit<WorkflowLinePortInfo, 'data'>, newPortInfo: Omit<WorkflowLinePortInfo, 'data'>): WorkflowLineEntity;
563
594
  createLine(options: {
564
595
  drawingTo?: LinePoint;
596
+ drawingFrom?: LinePoint;
565
597
  key?: string;
566
598
  } & WorkflowLinePortInfo): WorkflowLineEntity | undefined;
567
599
  /**
@@ -577,7 +609,7 @@ declare class WorkflowLinesManager {
577
609
  isDrawing: boolean;
578
610
  dispose(): void;
579
611
  get disposed(): boolean;
580
- isErrorLine(fromPort: WorkflowPortEntity, toPort?: WorkflowPortEntity, defaultValue?: boolean): boolean;
612
+ isErrorLine(fromPort?: WorkflowPortEntity, toPort?: WorkflowPortEntity, defaultValue?: boolean): boolean;
581
613
  isReverseLine(line: WorkflowLineEntity, defaultValue?: boolean): boolean;
582
614
  isHideArrowLine(line: WorkflowLineEntity, defaultValue?: boolean): boolean;
583
615
  isFlowingLine(line: WorkflowLineEntity, defaultValue?: boolean): boolean;
@@ -589,12 +621,12 @@ declare class WorkflowLinesManager {
589
621
  toJSON(): WorkflowEdgeJSON[];
590
622
  getPortById(portId: string): WorkflowPortEntity | undefined;
591
623
  canRemove(line: WorkflowLineEntity, newLineInfo?: Required<Omit<WorkflowLinePortInfo, 'data'>>, silent?: boolean): boolean;
592
- canReset(fromPort: WorkflowPortEntity, oldToPort: WorkflowPortEntity, newToPort: WorkflowPortEntity): boolean;
624
+ canReset(oldLine: WorkflowLineEntity, newLineInfo: Required<WorkflowLinePortInfo>): boolean;
593
625
  /**
594
626
  * 根据鼠标位置找到 port
595
627
  * @param pos
596
628
  */
597
- getPortFromMousePos(pos: IPoint): WorkflowPortEntity | undefined;
629
+ getPortFromMousePos(pos: IPoint, portType?: WorkflowPortType): WorkflowPortEntity | undefined;
598
630
  /**
599
631
  * 根据鼠标位置找到 node
600
632
  * @param pos - 鼠标位置
@@ -608,117 +640,10 @@ declare class WorkflowLinesManager {
608
640
  private getNodeIndex;
609
641
  }
610
642
 
611
- /**
612
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
613
- * SPDX-License-Identifier: MIT
614
- */
615
-
616
- type WorkflowPortType = 'input' | 'output';
617
- declare const getPortEntityId: (node: WorkflowNodeEntity, portType: WorkflowPortType, portID?: string | number) => string;
618
- declare const WORKFLOW_LINE_ENTITY = "WorkflowLineEntity";
619
- declare function domReactToBounds(react: DOMRect): Rectangle;
620
-
621
- declare const PORT_SIZE = 24;
622
- interface WorkflowPort {
623
- /**
624
- * 没有代表 默认连接点,默认 input 类型 为最左边中心,output 类型为最右边中心
625
- */
626
- portID?: string | number;
627
- /**
628
- * 输入或者输出点
629
- */
630
- type: WorkflowPortType;
631
- /**
632
- * 端口位置
633
- */
634
- location?: LinePointLocation;
635
- /**
636
- * 端口热区大小
637
- */
638
- size?: {
639
- width: number;
640
- height: number;
641
- };
642
- /**
643
- * 相对于 position 的偏移
644
- */
645
- offset?: IPoint;
646
- /**
647
- * 禁用端口
648
- */
649
- disabled?: boolean;
650
- /**
651
- * 将点位渲染到该父节点上
652
- */
653
- targetElement?: HTMLElement;
654
- }
655
- type WorkflowPorts = WorkflowPort[];
656
- interface WorkflowPortEntityOpts extends EntityOpts, WorkflowPort {
657
- /**
658
- * port 属于哪个节点
659
- */
660
- node: WorkflowNodeEntity;
661
- }
662
- /**
663
- * Port 抽象的 Entity
664
- */
665
- declare class WorkflowPortEntity extends Entity<WorkflowPortEntityOpts> {
666
- static type: string;
667
- readonly node: WorkflowNodeEntity;
668
- readonly portID: string | number;
669
- readonly portType: WorkflowPortType;
670
- private _disabled?;
671
- private _hasError;
672
- private _location?;
673
- private _size?;
674
- private _offset?;
675
- protected readonly _onErrorChangedEmitter: Emitter<void>;
676
- onErrorChanged: _flowgram_ai_utils.Event<void>;
677
- targetElement?: HTMLElement;
678
- static getPortEntityId(node: WorkflowNodeEntity, portType: WorkflowPortType, portID?: string | number): string;
679
- get position(): LinePointLocation | undefined;
680
- constructor(opts: WorkflowPortEntityOpts);
681
- get hasError(): boolean;
682
- set hasError(hasError: boolean);
683
- validate(): void;
684
- isErrorPort(): boolean;
685
- get location(): LinePointLocation;
686
- get point(): LinePoint;
687
- /**
688
- * 端口热区
689
- */
690
- get bounds(): Rectangle;
691
- isHovered(x: number, y: number): boolean;
692
- /**
693
- * 相对节点左上角的位置
694
- */
695
- get relativePosition(): IPoint;
696
- updateTargetElement(el?: HTMLElement): void;
697
- /**
698
- * 是否被禁用
699
- */
700
- get disabled(): boolean;
701
- /**
702
- * 当前点位上连接的线条
703
- * @deprecated use `availableLines` instead
704
- */
705
- get lines(): WorkflowLineEntity[];
706
- /**
707
- * 当前有效的线条,不包含正在画的线条和隐藏的线条(这个出现在线条重连会先把原来的线条隐藏)
708
- */
709
- get availableLines(): WorkflowLineEntity[];
710
- /**
711
- * 当前点位上连接的线条(包含 isDrawing === true 的线条)
712
- */
713
- get allLines(): WorkflowLineEntity[];
714
- update(data: Exclude<WorkflowPort, 'portID' | 'type'>): void;
715
- dispose(): void;
716
- }
717
-
718
643
  declare const LINE_HOVER_DISTANCE = 8;
719
644
  declare const POINT_RADIUS = 10;
720
645
  interface WorkflowLinePortInfo {
721
- from: string;
646
+ from?: string;
722
647
  to?: string;
723
648
  fromPort?: string | number;
724
649
  toPort?: string | number;
@@ -728,9 +653,11 @@ interface WorkflowLineEntityOpts extends EntityOpts, WorkflowLinePortInfo {
728
653
  document: WorkflowDocument;
729
654
  linesManager: WorkflowLinesManager;
730
655
  drawingTo?: LinePoint;
656
+ drawingFrom?: LinePoint;
731
657
  }
732
658
  interface WorkflowLineInfo extends WorkflowLinePortInfo {
733
659
  drawingTo?: LinePoint;
660
+ drawingFrom?: LinePoint;
734
661
  }
735
662
  interface WorkflowLineUIState {
736
663
  /**
@@ -808,7 +735,7 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
808
735
  oldValue: any;
809
736
  newValue: any;
810
737
  }>;
811
- private _from;
738
+ private _from?;
812
739
  private _to?;
813
740
  private _lineData;
814
741
  private _uiState;
@@ -844,7 +771,7 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
844
771
  /**
845
772
  * 获取线条的前置节点
846
773
  */
847
- get from(): WorkflowNodeEntity;
774
+ get from(): WorkflowNodeEntity | undefined;
848
775
  /**
849
776
  * 获取线条的后置节点
850
777
  */
@@ -867,10 +794,13 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
867
794
  * 设置线条的后置节点
868
795
  */
869
796
  setToPort(toPort?: WorkflowPortEntity): void;
797
+ setFromPort(fromPort?: WorkflowPortEntity): void;
870
798
  /**
871
799
  * 设置线条画线时的目标位置
872
800
  */
873
801
  set drawingTo(pos: LinePoint | undefined);
802
+ set drawingFrom(pos: LinePoint | undefined);
803
+ get drawingFrom(): LinePoint | undefined;
874
804
  /**
875
805
  * 获取线条正在画线的位置
876
806
  */
@@ -888,7 +818,7 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
888
818
  * 获取点和线最接近的距离
889
819
  */
890
820
  getHoverDist(pos: IPoint): number;
891
- get fromPort(): WorkflowPortEntity;
821
+ get fromPort(): WorkflowPortEntity | undefined;
892
822
  get toPort(): WorkflowPortEntity | undefined;
893
823
  /**
894
824
  * 获取线条真实的输入输出节点坐标
@@ -931,4 +861,253 @@ declare class WorkflowLineEntity extends Entity<WorkflowLineEntityOpts> {
931
861
  fireRender(): void;
932
862
  }
933
863
 
934
- export { type WorkflowLineRenderContributionFactory 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 WorkflowPortEntityOpts as M, type NodesDragEvent as N, type OnDragLineEnd as O, POINT_RADIUS as P, type WorkflowEntityHoverable as Q, type HoverPosition as R, type WorkfloEntityHoverable as S, WorkflowDocumentProvider as T, WorkflowDocumentOptionsDefault as U, WorkflowHoverService as W, WorkflowDocument as a, WorkflowLinesManager as b, WorkflowSelectService as c, WorkflowDocumentOptions as d, type WorkflowNodeJSON as e, WorkflowPortEntity as f, WorkflowLineEntity as g, type WorkflowJSON as h, type LineCenterPoint as i, type WorkflowPorts as j, type WorkflowPortType as k, type LinePoint as l, type WorkflowPort as m, type LineRenderType as n, type WorkflowLineRenderContribution as o, type LinePosition as p, getPortEntityId as q, WORKFLOW_LINE_ENTITY as r, domReactToBounds as s, WorkflowContentChangeType as t, type WorkflowContentChangeEvent as u, type WorkflowNodeMeta as v, LineType as w, type LinePointLocation as x, type LineColor as y, LineColors as z };
864
+ declare const PORT_SIZE = 24;
865
+ interface WorkflowPort {
866
+ /**
867
+ * 没有代表 默认连接点,默认 input 类型 为最左边中心,output 类型为最右边中心
868
+ */
869
+ portID?: string | number;
870
+ /**
871
+ * 输入或者输出点
872
+ */
873
+ type: WorkflowPortType;
874
+ /**
875
+ * 端口位置
876
+ */
877
+ location?: LinePointLocation;
878
+ /**
879
+ * 端口热区大小
880
+ */
881
+ size?: {
882
+ width: number;
883
+ height: number;
884
+ };
885
+ /**
886
+ * 相对于 position 的偏移
887
+ */
888
+ offset?: IPoint;
889
+ /**
890
+ * 禁用端口
891
+ */
892
+ disabled?: boolean;
893
+ /**
894
+ * 将点位渲染到该父节点上
895
+ */
896
+ targetElement?: HTMLElement;
897
+ }
898
+ type WorkflowPorts = WorkflowPort[];
899
+ interface WorkflowPortEntityOpts extends EntityOpts, WorkflowPort {
900
+ /**
901
+ * port 属于哪个节点
902
+ */
903
+ node: WorkflowNodeEntity;
904
+ }
905
+ /**
906
+ * Port 抽象的 Entity
907
+ */
908
+ declare class WorkflowPortEntity extends Entity<WorkflowPortEntityOpts> {
909
+ static type: string;
910
+ readonly node: WorkflowNodeEntity;
911
+ readonly portID: string | number;
912
+ readonly portType: WorkflowPortType;
913
+ private _disabled?;
914
+ private _hasError;
915
+ private _location?;
916
+ private _size?;
917
+ private _offset?;
918
+ protected readonly _onErrorChangedEmitter: Emitter<void>;
919
+ onErrorChanged: _flowgram_ai_utils.Event<void>;
920
+ targetElement?: HTMLElement;
921
+ static getPortEntityId(node: WorkflowNodeEntity, portType: WorkflowPortType, portID?: string | number): string;
922
+ get position(): LinePointLocation | undefined;
923
+ constructor(opts: WorkflowPortEntityOpts);
924
+ get hasError(): boolean;
925
+ set hasError(hasError: boolean);
926
+ validate(): void;
927
+ isErrorPort(): boolean;
928
+ get location(): LinePointLocation;
929
+ get point(): LinePoint;
930
+ /**
931
+ * 端口热区
932
+ */
933
+ get bounds(): Rectangle;
934
+ isHovered(x: number, y: number): boolean;
935
+ /**
936
+ * 相对节点左上角的位置
937
+ */
938
+ get relativePosition(): IPoint;
939
+ updateTargetElement(el?: HTMLElement): void;
940
+ /**
941
+ * 是否被禁用
942
+ */
943
+ get disabled(): boolean;
944
+ /**
945
+ * 当前点位上连接的线条
946
+ * @deprecated use `availableLines` instead
947
+ */
948
+ get lines(): WorkflowLineEntity[];
949
+ /**
950
+ * 当前有效的线条,不包含正在画的线条和隐藏的线条(这个出现在线条重连会先把原来的线条隐藏)
951
+ */
952
+ get availableLines(): WorkflowLineEntity[];
953
+ /**
954
+ * 当前点位上连接的线条(包含 isDrawing === true 的线条)
955
+ */
956
+ get allLines(): WorkflowLineEntity[];
957
+ update(data: Exclude<WorkflowPort, 'portID' | 'type'>): void;
958
+ dispose(): void;
959
+ }
960
+
961
+ /**
962
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
963
+ * SPDX-License-Identifier: MIT
964
+ */
965
+
966
+ /**
967
+ * 节点的点位信息
968
+ * portsData 只监听点位的数目和类型,不监听点位的 position 变化
969
+ */
970
+ declare class WorkflowNodePortsData extends EntityData {
971
+ static readonly type = "WorkflowNodePortsData";
972
+ readonly entity: WorkflowNodeEntity;
973
+ /** 静态的 ports 数据 */
974
+ protected _staticPorts: WorkflowPorts;
975
+ /** 存储 port 实体的 id,用于判断 port 是否存在 */
976
+ protected _portIDSet: Set<string>;
977
+ /** 上一次的 ports 数据,用于判断 ports 是否发生变化 */
978
+ protected _prePorts: WorkflowPorts;
979
+ constructor(entity: WorkflowNodeEntity);
980
+ getDefaultData(): any;
981
+ /**
982
+ * Update all ports data, includes static ports and dynamic ports
983
+ * @param ports
984
+ */
985
+ updateAllPorts(ports?: WorkflowPorts): void;
986
+ /**
987
+ * @deprecated use `updateAllPorts` instead
988
+ */
989
+ updateStaticPorts(ports: WorkflowPorts): void;
990
+ /**
991
+ * 动态计算点位,通过 dom 的 data-port-key
992
+ */
993
+ updateDynamicPorts(): void;
994
+ /**
995
+ * 根据 key 获取 port 实体
996
+ */
997
+ getPortEntityByKey(portType: WorkflowPortType, portKey?: string | number): WorkflowPortEntity;
998
+ /**
999
+ * 更新 ports 数据
1000
+ */
1001
+ protected updatePorts(ports: WorkflowPorts): void;
1002
+ /**
1003
+ * 获取所有 port entities
1004
+ */
1005
+ get allPorts(): WorkflowPortEntity[];
1006
+ /**
1007
+ * 获取输入点位
1008
+ */
1009
+ get inputPorts(): WorkflowPortEntity[];
1010
+ /**
1011
+ * 获取输出点位
1012
+ */
1013
+ get outputPorts(): WorkflowPortEntity[];
1014
+ /**
1015
+ * 获取输入点位置
1016
+ */
1017
+ get inputPoints(): LinePoint[];
1018
+ /**
1019
+ * 获取输出点位置
1020
+ */
1021
+ get outputPoints(): LinePoint[];
1022
+ /**
1023
+ * 根据 key 获取 输入点位置
1024
+ */
1025
+ getInputPoint(key?: string | number): LinePoint;
1026
+ /**
1027
+ * 根据 key 获取输出点位置
1028
+ */
1029
+ getOutputPoint(key?: string | number): LinePoint;
1030
+ /**
1031
+ * 获取 port 实体
1032
+ */
1033
+ protected getPortEntity(portId: string): WorkflowPortEntity | undefined;
1034
+ /**
1035
+ * 拼接 port 实体的 id
1036
+ */
1037
+ protected getPortId(portType: WorkflowPortType, portKey?: string | number): string;
1038
+ /**
1039
+ * 创建 port 实体
1040
+ */
1041
+ protected createPortEntity(portInfo: WorkflowPort): WorkflowPortEntity;
1042
+ /**
1043
+ * 获取或创建 port 实体
1044
+ */
1045
+ protected getOrCreatePortEntity(portInfo: WorkflowPort): WorkflowPortEntity;
1046
+ /**
1047
+ * 更新 port 实体
1048
+ */
1049
+ protected updatePortEntity(portInfo: WorkflowPort): WorkflowPortEntity;
1050
+ }
1051
+
1052
+ /**
1053
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1054
+ * SPDX-License-Identifier: MIT
1055
+ */
1056
+
1057
+ interface WorkflowNodeLines {
1058
+ inputLines: WorkflowLineEntity[];
1059
+ outputLines: WorkflowLineEntity[];
1060
+ }
1061
+ /**
1062
+ * 节点的关联的线条
1063
+ */
1064
+ declare class WorkflowNodeLinesData extends EntityData<WorkflowNodeLines> {
1065
+ static type: string;
1066
+ entity: WorkflowNodeEntity;
1067
+ getDefaultData(): WorkflowNodeLines;
1068
+ constructor(entity: WorkflowNodeEntity);
1069
+ /**
1070
+ * 输入线条
1071
+ */
1072
+ get inputLines(): WorkflowLineEntity[];
1073
+ /**
1074
+ * 输出线条
1075
+ */
1076
+ get outputLines(): WorkflowLineEntity[];
1077
+ get allLines(): WorkflowLineEntity[];
1078
+ get availableLines(): WorkflowLineEntity[];
1079
+ /**
1080
+ * 输入节点
1081
+ */
1082
+ get inputNodes(): WorkflowNodeEntity[];
1083
+ /**
1084
+ * 所有输入节点
1085
+ */
1086
+ get allInputNodes(): WorkflowNodeEntity[];
1087
+ /**
1088
+ * 输出节点
1089
+ */
1090
+ get outputNodes(): WorkflowNodeEntity[];
1091
+ /**
1092
+ * 输入输出节点
1093
+ */
1094
+ get allOutputNodes(): WorkflowNodeEntity[];
1095
+ addLine(line: WorkflowLineEntity): void;
1096
+ removeLine(line: WorkflowLineEntity): void;
1097
+ }
1098
+
1099
+ /**
1100
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1101
+ * SPDX-License-Identifier: MIT
1102
+ */
1103
+
1104
+ declare module '@flowgram.ai/document' {
1105
+ interface FlowNodeEntity {
1106
+ lines: WorkflowNodeLinesData;
1107
+ ports: WorkflowNodePortsData;
1108
+ }
1109
+ }
1110
+ type WorkflowNodeEntity = FlowNodeEntity;
1111
+ declare const WorkflowNodeEntity: typeof FlowNodeEntity;
1112
+
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 };