@flowgram.ai/free-layout-core 0.4.3 → 0.4.5

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.
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  LineColors,
13
13
  LineType
14
- } from "../chunk-E7ZUQ7LV.js";
14
+ } from "../chunk-5BT3ZR4D.js";
15
15
  import "../chunk-DDJTYHXN.js";
16
16
  import {
17
17
  WorkflowOperationBaseService
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  LineColors,
3
3
  LineType
4
- } from "../chunk-E7ZUQ7LV.js";
4
+ } from "../chunk-5BT3ZR4D.js";
5
5
  import "../chunk-EUXUH3YW.js";
6
6
  export {
7
7
  LineColors,
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 WorkflowJSON, i as WorkflowPorts, j as WorkflowPortType, k as LinePoint, l as WorkflowPort, m as LineRenderType, n as WorkflowLineRenderContribution, o as LinePosition } from './workflow-line-entity-CauIz5GH.mjs';
6
- export { Q as HoverPosition, E as LINE_HOVER_DISTANCE, x as LineColor, y as LineColors, w as LinePointLocation, v as LineType, B as NodesDragEndEvent, A as NodesDragStartEvent, C as NodesDraggingEvent, P as POINT_RADIUS, J as PORT_SIZE, q as WORKFLOW_LINE_ENTITY, R as WorkfloEntityHoverable, t as WorkflowContentChangeEvent, s as WorkflowContentChangeType, T as WorkflowDocumentOptionsDefault, S as WorkflowDocumentProvider, M as WorkflowEntityHoverable, G as WorkflowLineEntityOpts, H as WorkflowLineInfo, F as WorkflowLinePortInfo, z as WorkflowLineRenderContributionFactory, I as WorkflowLineUIState, u as WorkflowNodeMeta, K as WorkflowPortEntityOpts, r as domReactToBounds, p as getPortEntityId, D as onDragLineEndParams } from './workflow-line-entity-CauIz5GH.mjs';
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-CX-IYcAX.mjs';
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-CX-IYcAX.mjs';
7
7
  import { W as WorkflowNodeEntity } from './workflow-sub-canvas-IQzlYvPD.mjs';
8
8
  export { a as WorkflowSubCanvas } from './workflow-sub-canvas-IQzlYvPD.mjs';
9
9
  import * as _flowgram_ai_utils from '@flowgram.ai/utils';
@@ -330,6 +330,13 @@ declare function usePlaygroundReadonlyState(listenChange?: boolean): boolean;
330
330
 
331
331
  declare const buildGroupJSON: (json: WorkflowJSON) => WorkflowJSON;
332
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
+
333
340
  /**
334
341
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
335
342
  * SPDX-License-Identifier: MIT
@@ -487,6 +494,7 @@ declare class WorkflowNodeLinesData extends EntityData<WorkflowNodeLines> {
487
494
  */
488
495
  get outputLines(): WorkflowLineEntity[];
489
496
  get allLines(): WorkflowLineEntity[];
497
+ get availableLines(): WorkflowLineEntity[];
490
498
  /**
491
499
  * 输入节点
492
500
  */
@@ -533,6 +541,10 @@ declare class WorkflowLineRenderData extends EntityData<WorkflowLineRenderDataSc
533
541
  */
534
542
  update(): void;
535
543
  private get lineType();
544
+ /**
545
+ * 获取 center 位置
546
+ */
547
+ get center(): LineCenterPoint;
536
548
  /**
537
549
  * 更新版本
538
550
  * WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
@@ -550,29 +562,4 @@ declare class WorkflowLineRenderData extends EntityData<WorkflowLineRenderDataSc
550
562
 
551
563
  declare const WorkflowDocumentContainerModule: ContainerModule;
552
564
 
553
- /**
554
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
555
- * SPDX-License-Identifier: MIT
556
- */
557
-
558
- interface StraightData {
559
- points: IPoint[];
560
- path: string;
561
- bbox: Rectangle;
562
- }
563
- declare class WorkflowSimpleLineContribution implements WorkflowLineRenderContribution {
564
- static type: string;
565
- entity: WorkflowLineEntity;
566
- constructor(entity: WorkflowLineEntity);
567
- private data?;
568
- get path(): string;
569
- calcDistance(pos: IPoint): number;
570
- get bounds(): Rectangle;
571
- update(params: {
572
- fromPos: IPoint;
573
- toPos: IPoint;
574
- }): void;
575
- private projectPointOnLine;
576
- }
577
-
578
- export { EditorCursorState, InteractiveType, LineEventProps, LinePoint, LinePosition, LineRenderType, NodePostionUpdateEvent, type NodeRenderReturnType, NodesDragEvent, OnDragLineEnd, type PositionMap, type StraightData, 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, WorkflowSimpleLineContribution, buildGroupJSON, fitView, getAntiOverlapPosition, nanoid, useCurrentDomNode, useCurrentEntity, useNodeRender, usePlaygroundReadonlyState, useWorkflowDocument };
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 };
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 WorkflowJSON, i as WorkflowPorts, j as WorkflowPortType, k as LinePoint, l as WorkflowPort, m as LineRenderType, n as WorkflowLineRenderContribution, o as LinePosition } from './workflow-line-entity-DqPb9Odw.js';
6
- export { Q as HoverPosition, E as LINE_HOVER_DISTANCE, x as LineColor, y as LineColors, w as LinePointLocation, v as LineType, B as NodesDragEndEvent, A as NodesDragStartEvent, C as NodesDraggingEvent, P as POINT_RADIUS, J as PORT_SIZE, q as WORKFLOW_LINE_ENTITY, R as WorkfloEntityHoverable, t as WorkflowContentChangeEvent, s as WorkflowContentChangeType, T as WorkflowDocumentOptionsDefault, S as WorkflowDocumentProvider, M as WorkflowEntityHoverable, G as WorkflowLineEntityOpts, H as WorkflowLineInfo, F as WorkflowLinePortInfo, z as WorkflowLineRenderContributionFactory, I as WorkflowLineUIState, u as WorkflowNodeMeta, K as WorkflowPortEntityOpts, r as domReactToBounds, p as getPortEntityId, D as onDragLineEndParams } from './workflow-line-entity-DqPb9Odw.js';
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-DEns_IoW.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-DEns_IoW.js';
7
7
  import { W as WorkflowNodeEntity } from './workflow-sub-canvas-IQzlYvPD.js';
8
8
  export { a as WorkflowSubCanvas } from './workflow-sub-canvas-IQzlYvPD.js';
9
9
  import * as _flowgram_ai_utils from '@flowgram.ai/utils';
@@ -330,6 +330,13 @@ declare function usePlaygroundReadonlyState(listenChange?: boolean): boolean;
330
330
 
331
331
  declare const buildGroupJSON: (json: WorkflowJSON) => WorkflowJSON;
332
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
+
333
340
  /**
334
341
  * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
335
342
  * SPDX-License-Identifier: MIT
@@ -487,6 +494,7 @@ declare class WorkflowNodeLinesData extends EntityData<WorkflowNodeLines> {
487
494
  */
488
495
  get outputLines(): WorkflowLineEntity[];
489
496
  get allLines(): WorkflowLineEntity[];
497
+ get availableLines(): WorkflowLineEntity[];
490
498
  /**
491
499
  * 输入节点
492
500
  */
@@ -533,6 +541,10 @@ declare class WorkflowLineRenderData extends EntityData<WorkflowLineRenderDataSc
533
541
  */
534
542
  update(): void;
535
543
  private get lineType();
544
+ /**
545
+ * 获取 center 位置
546
+ */
547
+ get center(): LineCenterPoint;
536
548
  /**
537
549
  * 更新版本
538
550
  * WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
@@ -550,29 +562,4 @@ declare class WorkflowLineRenderData extends EntityData<WorkflowLineRenderDataSc
550
562
 
551
563
  declare const WorkflowDocumentContainerModule: ContainerModule;
552
564
 
553
- /**
554
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
555
- * SPDX-License-Identifier: MIT
556
- */
557
-
558
- interface StraightData {
559
- points: IPoint[];
560
- path: string;
561
- bbox: Rectangle;
562
- }
563
- declare class WorkflowSimpleLineContribution implements WorkflowLineRenderContribution {
564
- static type: string;
565
- entity: WorkflowLineEntity;
566
- constructor(entity: WorkflowLineEntity);
567
- private data?;
568
- get path(): string;
569
- calcDistance(pos: IPoint): number;
570
- get bounds(): Rectangle;
571
- update(params: {
572
- fromPos: IPoint;
573
- toPos: IPoint;
574
- }): void;
575
- private projectPointOnLine;
576
- }
577
-
578
- export { EditorCursorState, InteractiveType, LineEventProps, LinePoint, LinePosition, LineRenderType, NodePostionUpdateEvent, type NodeRenderReturnType, NodesDragEvent, OnDragLineEnd, type PositionMap, type StraightData, 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, WorkflowSimpleLineContribution, buildGroupJSON, fitView, getAntiOverlapPosition, nanoid, useCurrentDomNode, useCurrentEntity, useNodeRender, usePlaygroundReadonlyState, useWorkflowDocument };
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 };
package/dist/index.js CHANGED
@@ -57,7 +57,6 @@ __export(src_exports, {
57
57
  WorkflowPortEntity: () => WorkflowPortEntity,
58
58
  WorkflowResetLayoutService: () => WorkflowResetLayoutService,
59
59
  WorkflowSelectService: () => WorkflowSelectService,
60
- WorkflowSimpleLineContribution: () => WorkflowSimpleLineContribution,
61
60
  bindConfigEntity: () => import_core3.bindConfigEntity,
62
61
  buildGroupJSON: () => buildGroupJSON,
63
62
  compose: () => import_utils.compose,
@@ -66,6 +65,7 @@ __export(src_exports, {
66
65
  domReactToBounds: () => domReactToBounds,
67
66
  fitView: () => fitView,
68
67
  getAntiOverlapPosition: () => getAntiOverlapPosition,
68
+ getLineCenter: () => getLineCenter,
69
69
  getPortEntityId: () => getPortEntityId,
70
70
  nanoid: () => nanoid,
71
71
  useConfigEntity: () => import_core25.useConfigEntity,
@@ -146,6 +146,16 @@ var buildGroupJSON = (json) => {
146
146
  };
147
147
  };
148
148
 
149
+ // src/utils/get-line-center.ts
150
+ function getLineCenter(from, to, bbox, linePadding) {
151
+ return {
152
+ x: bbox.center.x,
153
+ y: bbox.center.y,
154
+ labelX: bbox.center.x - bbox.x + linePadding,
155
+ labelY: bbox.center.y - bbox.y + linePadding
156
+ };
157
+ }
158
+
149
159
  // src/utils/nanoid.ts
150
160
  var import_nanoid = require("nanoid");
151
161
  function nanoid(n) {
@@ -653,6 +663,9 @@ var _WorkflowNodeLinesData = class _WorkflowNodeLinesData extends import_core6.E
653
663
  get allLines() {
654
664
  return this.data.inputLines.concat(this.data.outputLines);
655
665
  }
666
+ get availableLines() {
667
+ return this.allLines.filter((line) => !line.isDrawing && !line.isHidden);
668
+ }
656
669
  /**
657
670
  * 输入节点
658
671
  */
@@ -794,6 +807,12 @@ var WorkflowLineRenderData = class extends import_core7.EntityData {
794
807
  get lineType() {
795
808
  return this.entity.renderType ?? this.entity.linesManager.lineType;
796
809
  }
810
+ /**
811
+ * 获取 center 位置
812
+ */
813
+ get center() {
814
+ return this.currentLine?.center || { x: 0, y: 0, labelX: 0, labelY: 0 };
815
+ }
797
816
  /**
798
817
  * 更新版本
799
818
  * WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
@@ -1055,6 +1074,9 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends import_core8.Entity
1055
1074
  get bounds() {
1056
1075
  return this.getData(WorkflowLineRenderData).bounds;
1057
1076
  }
1077
+ get center() {
1078
+ return this.getData(WorkflowLineRenderData).center;
1079
+ }
1058
1080
  /**
1059
1081
  * 获取点和线最接近的距离
1060
1082
  */
@@ -1394,6 +1416,7 @@ var WorkflowContentChangeType = /* @__PURE__ */ ((WorkflowContentChangeType2) =>
1394
1416
  var LineType = /* @__PURE__ */ ((LineType2) => {
1395
1417
  LineType2[LineType2["BEZIER"] = 0] = "BEZIER";
1396
1418
  LineType2[LineType2["LINE_CHART"] = 1] = "LINE_CHART";
1419
+ LineType2[LineType2["STRAIGHT"] = 2] = "STRAIGHT";
1397
1420
  return LineType2;
1398
1421
  })(LineType || {});
1399
1422
  var LineColors = /* @__PURE__ */ ((LineColors2) => {
@@ -3643,81 +3666,6 @@ var WorkflowDocumentContainerModule = new import_inversify10.ContainerModule(
3643
3666
  bind(WorkflowDocumentProvider).toDynamicValue((ctx) => () => ctx.container.get(WorkflowDocument)).inSingletonScope();
3644
3667
  }
3645
3668
  );
3646
-
3647
- // src/utils/simple-line.ts
3648
- var import_utils21 = require("@flowgram.ai/utils");
3649
- var LINE_PADDING = 12;
3650
- var WorkflowSimpleLineContribution = class {
3651
- constructor(entity) {
3652
- this.entity = entity;
3653
- }
3654
- get path() {
3655
- return this.data?.path ?? "";
3656
- }
3657
- calcDistance(pos) {
3658
- if (!this.data) {
3659
- return Number.MAX_SAFE_INTEGER;
3660
- }
3661
- const [start, end] = this.data.points;
3662
- return import_utils21.Point.getDistance(pos, this.projectPointOnLine(pos, start, end));
3663
- }
3664
- get bounds() {
3665
- if (!this.data) {
3666
- return new import_utils21.Rectangle();
3667
- }
3668
- return this.data.bbox;
3669
- }
3670
- update(params) {
3671
- const { fromPos, toPos } = params;
3672
- const { vertical } = this.entity;
3673
- const sourceOffset = {
3674
- x: vertical ? 0 : POINT_RADIUS,
3675
- y: vertical ? POINT_RADIUS : 0
3676
- };
3677
- const targetOffset = {
3678
- x: vertical ? 0 : -POINT_RADIUS,
3679
- y: vertical ? -POINT_RADIUS : 0
3680
- };
3681
- const points = [
3682
- {
3683
- x: fromPos.x + sourceOffset.x,
3684
- y: fromPos.y + sourceOffset.y
3685
- },
3686
- {
3687
- x: toPos.x + targetOffset.x,
3688
- y: toPos.y + targetOffset.y
3689
- }
3690
- ];
3691
- const bbox = import_utils21.Rectangle.createRectangleWithTwoPoints(points[0], points[1]);
3692
- const adjustedPoints = points.map((p) => ({
3693
- x: p.x - bbox.x + LINE_PADDING,
3694
- y: p.y - bbox.y + LINE_PADDING
3695
- }));
3696
- const path = `M ${adjustedPoints[0].x} ${adjustedPoints[0].y} L ${adjustedPoints[1].x} ${adjustedPoints[1].y}`;
3697
- this.data = {
3698
- points,
3699
- path,
3700
- bbox
3701
- };
3702
- }
3703
- projectPointOnLine(point, lineStart, lineEnd) {
3704
- const dx = lineEnd.x - lineStart.x;
3705
- const dy = lineEnd.y - lineStart.y;
3706
- if (dx === 0) {
3707
- return { x: lineStart.x, y: point.y };
3708
- }
3709
- if (dy === 0) {
3710
- return { x: point.x, y: lineStart.y };
3711
- }
3712
- const t = ((point.x - lineStart.x) * dx + (point.y - lineStart.y) * dy) / (dx * dx + dy * dy);
3713
- const clampedT = Math.max(0, Math.min(1, t));
3714
- return {
3715
- x: lineStart.x + clampedT * dx,
3716
- y: lineStart.y + clampedT * dy
3717
- };
3718
- }
3719
- };
3720
- WorkflowSimpleLineContribution.type = "WorkflowSimpleLineContribution";
3721
3669
  // Annotate the CommonJS export names for ESM import in node:
3722
3670
  0 && (module.exports = {
3723
3671
  EditorCursorState,
@@ -3749,7 +3697,6 @@ WorkflowSimpleLineContribution.type = "WorkflowSimpleLineContribution";
3749
3697
  WorkflowPortEntity,
3750
3698
  WorkflowResetLayoutService,
3751
3699
  WorkflowSelectService,
3752
- WorkflowSimpleLineContribution,
3753
3700
  bindConfigEntity,
3754
3701
  buildGroupJSON,
3755
3702
  compose,
@@ -3758,6 +3705,7 @@ WorkflowSimpleLineContribution.type = "WorkflowSimpleLineContribution";
3758
3705
  domReactToBounds,
3759
3706
  fitView,
3760
3707
  getAntiOverlapPosition,
3708
+ getLineCenter,
3761
3709
  getPortEntityId,
3762
3710
  nanoid,
3763
3711
  useConfigEntity,