@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.
package/dist/index.d.ts CHANGED
@@ -1,13 +1,11 @@
1
1
  import { PlaygroundConfigEntity, CommandService, PlaygroundDragEvent, EntityData } from '@flowgram.ai/core';
2
- export { bindConfigEntity, useConfigEntity, useEntities, useEntityDataFromContext, useEntityFromContext, useListenEvents, usePlayground, usePlaygroundContainer, usePlaygroundContext, usePlaygroundLatest, useRefresh, useService } from '@flowgram.ai/core';
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 { 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 WorkflowJSON, i as LineCenterPoint, j as WorkflowPorts, k as WorkflowPortType, l as LinePoint, m as WorkflowPort, n as LineRenderType, o as WorkflowLineRenderContribution, p as LinePosition } from './workflow-line-entity-DcecHiNc.js';
6
- export { R as HoverPosition, F as LINE_HOVER_DISTANCE, y as LineColor, z as LineColors, x as LinePointLocation, w as LineType, C as NodesDragEndEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, P as POINT_RADIUS, K as PORT_SIZE, r as WORKFLOW_LINE_ENTITY, S as WorkfloEntityHoverable, u as WorkflowContentChangeEvent, t as WorkflowContentChangeType, U as WorkflowDocumentOptionsDefault, T as WorkflowDocumentProvider, Q as WorkflowEntityHoverable, H as WorkflowLineEntityOpts, I as WorkflowLineInfo, G as WorkflowLinePortInfo, A as WorkflowLineRenderContributionFactory, J as WorkflowLineUIState, v as WorkflowNodeMeta, M as WorkflowPortEntityOpts, s as domReactToBounds, q as getPortEntityId, E as onDragLineEndParams } from './workflow-line-entity-DcecHiNc.js';
7
- import { W as WorkflowNodeEntity } from './workflow-sub-canvas-IQzlYvPD.js';
8
- export { a as WorkflowSubCanvas } from './workflow-sub-canvas-IQzlYvPD.js';
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-DvBGZ5Ve.js';
6
+ export { X as HoverPosition, F as LINE_HOVER_DISTANCE, x as LineColor, y as LineColors, w as LinePoint, v as LinePointLocation, u as LineType, C as NodesDragEndEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, P as POINT_RADIUS, K as PORT_SIZE, p as WORKFLOW_LINE_ENTITY, Y as WorkfloEntityHoverable, s as WorkflowContentChangeEvent, r as WorkflowContentChangeType, _ as WorkflowDocumentOptionsDefault, Z as WorkflowDocumentProvider, V as WorkflowEntityHoverable, H as WorkflowLineEntityOpts, I as WorkflowLineInfo, G as WorkflowLinePortInfo, z as WorkflowLineRenderContributionFactory, J as WorkflowLineUIState, T as WorkflowNodeLines, U as WorkflowNodeLinesData, t as WorkflowNodeMeta, S as WorkflowNodePortsData, M as WorkflowPort, R as WorkflowPortEntityOpts, n as WorkflowPortType, Q as WorkflowPorts, A as WorkflowSubCanvas, q as domReactToBounds, o as getPortEntityId, E as onDragLineEndParams } from './workflow-node-entity-DvBGZ5Ve.js';
9
7
  import * as _flowgram_ai_utils from '@flowgram.ai/utils';
10
- import { DisposableCollection, IPoint, Disposable, Rectangle } from '@flowgram.ai/utils';
8
+ import { IPoint, Rectangle, DisposableCollection, Disposable } from '@flowgram.ai/utils';
11
9
  export { compose, composeAsync, delay } from '@flowgram.ai/utils';
12
10
  export { URLParams } from './typings/index.js';
13
11
  import React$1 from 'react';
@@ -31,6 +29,45 @@ declare enum WorkflowCommands {
31
29
  REDO = "REDO"
32
30
  }
33
31
 
32
+ /**
33
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
34
+ * SPDX-License-Identifier: MIT
35
+ */
36
+
37
+ declare const buildGroupJSON: (json: WorkflowJSON) => WorkflowJSON;
38
+
39
+ /**
40
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
41
+ * SPDX-License-Identifier: MIT
42
+ */
43
+
44
+ declare function getLineCenter(from: IPoint, to: IPoint, bbox: Rectangle, linePadding: number): LineCenterPoint;
45
+
46
+ /**
47
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
48
+ * SPDX-License-Identifier: MIT
49
+ */
50
+ declare function nanoid(n?: number): string;
51
+
52
+ /**
53
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
54
+ * SPDX-License-Identifier: MIT
55
+ */
56
+
57
+ declare const fitView: (doc: WorkflowDocument, playgroundConfig: PlaygroundConfigEntity, easing?: boolean) => Promise<void>;
58
+
59
+ /**
60
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
61
+ * SPDX-License-Identifier: MIT
62
+ */
63
+
64
+ /**
65
+ * 获取没有碰撞的位置
66
+ * 距离很小时,xy 各偏移 30
67
+ * @param position
68
+ */
69
+ declare function getAntiOverlapPosition(doc: WorkflowDocument, position: IPoint, containerNode?: WorkflowNodeEntity): IPoint;
70
+
34
71
  declare class WorkflowDragService {
35
72
  protected playgroundConfig: PlaygroundConfigEntity;
36
73
  protected hoverService: WorkflowHoverService;
@@ -115,20 +152,25 @@ declare class WorkflowDragService {
115
152
  private updateDropNode;
116
153
  private clearDrop;
117
154
  private setLineColor;
118
- private handleDragOnNode;
155
+ private checkDraggingPort;
156
+ /**
157
+ * 容器内子节点总体位置重置为0
158
+ */
159
+ private resetContainerInternalPosition;
119
160
  private childrenOfContainer;
120
161
  /**
121
162
  * 绘制线条
122
163
  * @param opts
123
164
  * @param event
124
165
  */
125
- startDrawingLine(fromPort: WorkflowPortEntity, event: {
166
+ startDrawingLine(port: WorkflowPortEntity, event: {
126
167
  clientX: number;
127
168
  clientY: number;
128
169
  }, originLine?: WorkflowLineEntity): Promise<{
129
170
  dragSuccess?: boolean;
130
171
  newLine?: WorkflowLineEntity;
131
172
  }>;
173
+ private updateDrawingLine;
132
174
  /**
133
175
  * 重新连接线条
134
176
  * @param line
@@ -191,6 +233,46 @@ declare class WorkflowOperationBaseServiceImpl extends FlowOperationBaseServiceI
191
233
  updateNodePosition(nodeOrId: FlowNodeEntityOrId, position: IPoint): void;
192
234
  }
193
235
 
236
+ /**
237
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
238
+ * SPDX-License-Identifier: MIT
239
+ */
240
+
241
+ interface WorkflowLineRenderDataSchema {
242
+ version: string;
243
+ contributions: Map<LineRenderType, WorkflowLineRenderContribution>;
244
+ position: LinePosition;
245
+ }
246
+ declare class WorkflowLineRenderData extends EntityData<WorkflowLineRenderDataSchema> {
247
+ static type: string;
248
+ entity: WorkflowLineEntity;
249
+ constructor(entity: WorkflowLineEntity);
250
+ getDefaultData(): WorkflowLineRenderDataSchema;
251
+ get renderVersion(): string;
252
+ get position(): LinePosition;
253
+ get path(): string;
254
+ calcDistance(pos: IPoint): number;
255
+ get bounds(): Rectangle;
256
+ /**
257
+ * 更新数据
258
+ * WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
259
+ */
260
+ update(): void;
261
+ private get lineType();
262
+ /**
263
+ * 获取 center 位置
264
+ */
265
+ get center(): LineCenterPoint;
266
+ /**
267
+ * 更新版本
268
+ * WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
269
+ */
270
+ private updatePosition;
271
+ private get currentLine();
272
+ private syncContributions;
273
+ private registerContribution;
274
+ }
275
+
194
276
  /**
195
277
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
196
278
  * SPDX-License-Identifier: MIT
@@ -323,45 +405,6 @@ declare function useWorkflowDocument(): WorkflowDocument;
323
405
  */
324
406
  declare function usePlaygroundReadonlyState(listenChange?: boolean): boolean;
325
407
 
326
- /**
327
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
328
- * SPDX-License-Identifier: MIT
329
- */
330
-
331
- declare const buildGroupJSON: (json: WorkflowJSON) => WorkflowJSON;
332
-
333
- /**
334
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
335
- * SPDX-License-Identifier: MIT
336
- */
337
-
338
- declare function getLineCenter(from: IPoint, to: IPoint, bbox: Rectangle, linePadding: number): LineCenterPoint;
339
-
340
- /**
341
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
342
- * SPDX-License-Identifier: MIT
343
- */
344
- declare function nanoid(n?: number): string;
345
-
346
- /**
347
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
348
- * SPDX-License-Identifier: MIT
349
- */
350
-
351
- declare const fitView: (doc: WorkflowDocument, playgroundConfig: PlaygroundConfigEntity, easing?: boolean) => Promise<void>;
352
-
353
- /**
354
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
355
- * SPDX-License-Identifier: MIT
356
- */
357
-
358
- /**
359
- * 获取没有碰撞的位置
360
- * 距离很小时,xy 各偏移 30
361
- * @param position
362
- */
363
- declare function getAntiOverlapPosition(doc: WorkflowDocument, position: IPoint, containerNode?: WorkflowNodeEntity): IPoint;
364
-
365
408
  /**
366
409
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
367
410
  * SPDX-License-Identifier: MIT
@@ -377,184 +420,6 @@ declare enum InteractiveType {
377
420
  PAD = "PAD"
378
421
  }
379
422
 
380
- /**
381
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
382
- * SPDX-License-Identifier: MIT
383
- */
384
-
385
- /**
386
- * 节点的点位信息
387
- * portsData 只监听点位的数目和类型,不监听点位的 position 变化
388
- */
389
- declare class WorkflowNodePortsData extends EntityData {
390
- static readonly type = "WorkflowNodePortsData";
391
- readonly entity: WorkflowNodeEntity;
392
- /** 静态的 ports 数据 */
393
- protected _staticPorts: WorkflowPorts;
394
- /** 存储 port 实体的 id,用于判断 port 是否存在 */
395
- protected _portIDSet: Set<string>;
396
- /** 上一次的 ports 数据,用于判断 ports 是否发生变化 */
397
- protected _prePorts: WorkflowPorts;
398
- constructor(entity: WorkflowNodeEntity);
399
- getDefaultData(): any;
400
- /**
401
- * Update all ports data, includes static ports and dynamic ports
402
- * @param ports
403
- */
404
- updateAllPorts(ports?: WorkflowPorts): void;
405
- /**
406
- * @deprecated use `updateAllPorts` instead
407
- */
408
- updateStaticPorts(ports: WorkflowPorts): void;
409
- /**
410
- * 动态计算点位,通过 dom 的 data-port-key
411
- */
412
- updateDynamicPorts(): void;
413
- /**
414
- * 根据 key 获取 port 实体
415
- */
416
- getPortEntityByKey(portType: WorkflowPortType, portKey?: string | number): WorkflowPortEntity;
417
- /**
418
- * 更新 ports 数据
419
- */
420
- protected updatePorts(ports: WorkflowPorts): void;
421
- /**
422
- * 获取所有 port entities
423
- */
424
- get allPorts(): WorkflowPortEntity[];
425
- /**
426
- * 获取输入点位
427
- */
428
- get inputPorts(): WorkflowPortEntity[];
429
- /**
430
- * 获取输出点位
431
- */
432
- get outputPorts(): WorkflowPortEntity[];
433
- /**
434
- * 获取输入点位置
435
- */
436
- get inputPoints(): LinePoint[];
437
- /**
438
- * 获取输出点位置
439
- */
440
- get outputPoints(): LinePoint[];
441
- /**
442
- * 根据 key 获取 输入点位置
443
- */
444
- getInputPoint(key?: string | number): LinePoint;
445
- /**
446
- * 根据 key 获取输出点位置
447
- */
448
- getOutputPoint(key?: string | number): LinePoint;
449
- /**
450
- * 获取 port 实体
451
- */
452
- protected getPortEntity(portId: string): WorkflowPortEntity | undefined;
453
- /**
454
- * 拼接 port 实体的 id
455
- */
456
- protected getPortId(portType: WorkflowPortType, portKey?: string | number): string;
457
- /**
458
- * 创建 port 实体
459
- */
460
- protected createPortEntity(portInfo: WorkflowPort): WorkflowPortEntity;
461
- /**
462
- * 获取或创建 port 实体
463
- */
464
- protected getOrCreatePortEntity(portInfo: WorkflowPort): WorkflowPortEntity;
465
- /**
466
- * 更新 port 实体
467
- */
468
- protected updatePortEntity(portInfo: WorkflowPort): WorkflowPortEntity;
469
- }
470
-
471
- /**
472
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
473
- * SPDX-License-Identifier: MIT
474
- */
475
-
476
- interface WorkflowNodeLines {
477
- inputLines: WorkflowLineEntity[];
478
- outputLines: WorkflowLineEntity[];
479
- }
480
- /**
481
- * 节点的关联的线条
482
- */
483
- declare class WorkflowNodeLinesData extends EntityData<WorkflowNodeLines> {
484
- static type: string;
485
- entity: WorkflowNodeEntity;
486
- getDefaultData(): WorkflowNodeLines;
487
- constructor(entity: WorkflowNodeEntity);
488
- /**
489
- * 输入线条
490
- */
491
- get inputLines(): WorkflowLineEntity[];
492
- /**
493
- * 输出线条
494
- */
495
- get outputLines(): WorkflowLineEntity[];
496
- get allLines(): WorkflowLineEntity[];
497
- get availableLines(): WorkflowLineEntity[];
498
- /**
499
- * 输入节点
500
- */
501
- get inputNodes(): WorkflowNodeEntity[];
502
- /**
503
- * 所有输入节点
504
- */
505
- get allInputNodes(): WorkflowNodeEntity[];
506
- /**
507
- * 输出节点
508
- */
509
- get outputNodes(): WorkflowNodeEntity[];
510
- /**
511
- * 输入输出节点
512
- */
513
- get allOutputNodes(): WorkflowNodeEntity[];
514
- addLine(line: WorkflowLineEntity): void;
515
- removeLine(line: WorkflowLineEntity): void;
516
- }
517
-
518
- /**
519
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
520
- * SPDX-License-Identifier: MIT
521
- */
522
-
523
- interface WorkflowLineRenderDataSchema {
524
- version: string;
525
- contributions: Map<LineRenderType, WorkflowLineRenderContribution>;
526
- position: LinePosition;
527
- }
528
- declare class WorkflowLineRenderData extends EntityData<WorkflowLineRenderDataSchema> {
529
- static type: string;
530
- entity: WorkflowLineEntity;
531
- constructor(entity: WorkflowLineEntity);
532
- getDefaultData(): WorkflowLineRenderDataSchema;
533
- get renderVersion(): string;
534
- get position(): LinePosition;
535
- get path(): string;
536
- calcDistance(pos: IPoint): number;
537
- get bounds(): Rectangle;
538
- /**
539
- * 更新数据
540
- * WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
541
- */
542
- update(): void;
543
- private get lineType();
544
- /**
545
- * 获取 center 位置
546
- */
547
- get center(): LineCenterPoint;
548
- /**
549
- * 更新版本
550
- * WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
551
- */
552
- private updatePosition;
553
- private get currentLine();
554
- private syncContributions;
555
- private registerContribution;
556
- }
557
-
558
423
  /**
559
424
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
560
425
  * SPDX-License-Identifier: MIT
@@ -562,4 +427,4 @@ declare class WorkflowLineRenderData extends EntityData<WorkflowLineRenderDataSc
562
427
 
563
428
  declare const WorkflowDocumentContainerModule: ContainerModule;
564
429
 
565
- export { EditorCursorState, InteractiveType, LineCenterPoint, LineEventProps, LinePoint, LinePosition, LineRenderType, NodePostionUpdateEvent, type NodeRenderReturnType, NodesDragEvent, OnDragLineEnd, type PositionMap, WorkflowCommands, WorkflowDocument, WorkflowDocumentContainerModule, WorkflowDocumentOptions, WorkflowDragService, WorkflowHoverService, WorkflowJSON, WorkflowLineEntity, WorkflowLineRenderContribution, WorkflowLineRenderData, type WorkflowLineRenderDataSchema, WorkflowLinesManager, WorkflowNodeEntity, WorkflowNodeJSON, type WorkflowNodeLines, WorkflowNodeLinesData, WorkflowNodePortsData, WorkflowOperationBaseService, WorkflowOperationBaseServiceImpl, WorkflowPort, WorkflowPortEntity, WorkflowPortType, WorkflowPorts, WorkflowResetLayoutService, WorkflowSelectService, buildGroupJSON, fitView, getAntiOverlapPosition, getLineCenter, nanoid, useCurrentDomNode, useCurrentEntity, useNodeRender, usePlaygroundReadonlyState, useWorkflowDocument };
430
+ export { EditorCursorState, InteractiveType, LineCenterPoint, LineEventProps, LinePosition, LineRenderType, NodePostionUpdateEvent, type NodeRenderReturnType, NodesDragEvent, OnDragLineEnd, type PositionMap, WorkflowCommands, WorkflowDocument, WorkflowDocumentContainerModule, WorkflowDocumentOptions, WorkflowDragService, WorkflowHoverService, WorkflowJSON, WorkflowLineEntity, WorkflowLineRenderContribution, WorkflowLineRenderData, type WorkflowLineRenderDataSchema, WorkflowLinesManager, WorkflowNodeEntity, WorkflowNodeJSON, WorkflowOperationBaseService, WorkflowOperationBaseServiceImpl, WorkflowPortEntity, WorkflowResetLayoutService, WorkflowSelectService, buildGroupJSON, fitView, getAntiOverlapPosition, getLineCenter, nanoid, useCurrentDomNode, useCurrentEntity, useNodeRender, usePlaygroundReadonlyState, useWorkflowDocument };