@flowgram.ai/free-layout-core 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/{chunk-E7ZUQ7LV.js → chunk-5BT3ZR4D.js} +2 -1
- package/dist/esm/chunk-5BT3ZR4D.js.map +1 -0
- package/dist/esm/index.js +34 -78
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/typings/index.js +1 -1
- package/dist/esm/typings/workflow-line.js +1 -1
- package/dist/index.d.mts +15 -28
- package/dist/index.d.ts +15 -28
- package/dist/index.js +35 -78
- package/dist/index.js.map +1 -1
- package/dist/typings/index.d.mts +1 -1
- package/dist/typings/index.d.ts +1 -1
- package/dist/typings/index.js +1 -0
- package/dist/typings/index.js.map +1 -1
- package/dist/typings/workflow-drag.d.mts +1 -1
- package/dist/typings/workflow-drag.d.ts +1 -1
- package/dist/typings/workflow-json.d.mts +1 -1
- package/dist/typings/workflow-json.d.ts +1 -1
- package/dist/typings/workflow-line.d.mts +1 -1
- package/dist/typings/workflow-line.d.ts +1 -1
- package/dist/typings/workflow-line.js +1 -0
- package/dist/typings/workflow-line.js.map +1 -1
- package/dist/typings/workflow-node.d.mts +1 -1
- package/dist/typings/workflow-node.d.ts +1 -1
- package/dist/typings/workflow-registry.d.mts +1 -1
- package/dist/typings/workflow-registry.d.ts +1 -1
- package/dist/{workflow-line-entity-DSC3qPV1.d.mts → workflow-line-entity-CX-IYcAX.d.mts} +25 -3
- package/dist/{workflow-line-entity-I_VrhJ_t.d.ts → workflow-line-entity-DEns_IoW.d.ts} +25 -3
- package/package.json +9 -9
- package/dist/esm/chunk-E7ZUQ7LV.js.map +0 -1
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
|
|
6
|
-
export {
|
|
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
|
|
6
|
-
export {
|
|
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) => {
|
|
@@ -2473,9 +2496,18 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2473
2496
|
this._onReloadEmitter.dispose();
|
|
2474
2497
|
}
|
|
2475
2498
|
/**
|
|
2476
|
-
*
|
|
2499
|
+
* 批量添加节点
|
|
2500
|
+
* @deprecated use 'batchAddFromJSON' instead
|
|
2501
|
+
* @param json
|
|
2502
|
+
* @param options
|
|
2477
2503
|
*/
|
|
2478
2504
|
renderJSON(json, options) {
|
|
2505
|
+
return this.batchAddFromJSON(json, options);
|
|
2506
|
+
}
|
|
2507
|
+
/**
|
|
2508
|
+
* 批量添加节点
|
|
2509
|
+
*/
|
|
2510
|
+
batchAddFromJSON(json, options) {
|
|
2479
2511
|
const { parent = this.root, isClone = false } = options ?? {};
|
|
2480
2512
|
const containerID = this.getNodeSubCanvas(parent)?.canvasNode.id ?? parent.id;
|
|
2481
2513
|
const processedJSON = buildGroupJSON(json);
|
|
@@ -3634,81 +3666,6 @@ var WorkflowDocumentContainerModule = new import_inversify10.ContainerModule(
|
|
|
3634
3666
|
bind(WorkflowDocumentProvider).toDynamicValue((ctx) => () => ctx.container.get(WorkflowDocument)).inSingletonScope();
|
|
3635
3667
|
}
|
|
3636
3668
|
);
|
|
3637
|
-
|
|
3638
|
-
// src/utils/simple-line.ts
|
|
3639
|
-
var import_utils21 = require("@flowgram.ai/utils");
|
|
3640
|
-
var LINE_PADDING = 12;
|
|
3641
|
-
var WorkflowSimpleLineContribution = class {
|
|
3642
|
-
constructor(entity) {
|
|
3643
|
-
this.entity = entity;
|
|
3644
|
-
}
|
|
3645
|
-
get path() {
|
|
3646
|
-
return this.data?.path ?? "";
|
|
3647
|
-
}
|
|
3648
|
-
calcDistance(pos) {
|
|
3649
|
-
if (!this.data) {
|
|
3650
|
-
return Number.MAX_SAFE_INTEGER;
|
|
3651
|
-
}
|
|
3652
|
-
const [start, end] = this.data.points;
|
|
3653
|
-
return import_utils21.Point.getDistance(pos, this.projectPointOnLine(pos, start, end));
|
|
3654
|
-
}
|
|
3655
|
-
get bounds() {
|
|
3656
|
-
if (!this.data) {
|
|
3657
|
-
return new import_utils21.Rectangle();
|
|
3658
|
-
}
|
|
3659
|
-
return this.data.bbox;
|
|
3660
|
-
}
|
|
3661
|
-
update(params) {
|
|
3662
|
-
const { fromPos, toPos } = params;
|
|
3663
|
-
const { vertical } = this.entity;
|
|
3664
|
-
const sourceOffset = {
|
|
3665
|
-
x: vertical ? 0 : POINT_RADIUS,
|
|
3666
|
-
y: vertical ? POINT_RADIUS : 0
|
|
3667
|
-
};
|
|
3668
|
-
const targetOffset = {
|
|
3669
|
-
x: vertical ? 0 : -POINT_RADIUS,
|
|
3670
|
-
y: vertical ? -POINT_RADIUS : 0
|
|
3671
|
-
};
|
|
3672
|
-
const points = [
|
|
3673
|
-
{
|
|
3674
|
-
x: fromPos.x + sourceOffset.x,
|
|
3675
|
-
y: fromPos.y + sourceOffset.y
|
|
3676
|
-
},
|
|
3677
|
-
{
|
|
3678
|
-
x: toPos.x + targetOffset.x,
|
|
3679
|
-
y: toPos.y + targetOffset.y
|
|
3680
|
-
}
|
|
3681
|
-
];
|
|
3682
|
-
const bbox = import_utils21.Rectangle.createRectangleWithTwoPoints(points[0], points[1]);
|
|
3683
|
-
const adjustedPoints = points.map((p) => ({
|
|
3684
|
-
x: p.x - bbox.x + LINE_PADDING,
|
|
3685
|
-
y: p.y - bbox.y + LINE_PADDING
|
|
3686
|
-
}));
|
|
3687
|
-
const path = `M ${adjustedPoints[0].x} ${adjustedPoints[0].y} L ${adjustedPoints[1].x} ${adjustedPoints[1].y}`;
|
|
3688
|
-
this.data = {
|
|
3689
|
-
points,
|
|
3690
|
-
path,
|
|
3691
|
-
bbox
|
|
3692
|
-
};
|
|
3693
|
-
}
|
|
3694
|
-
projectPointOnLine(point, lineStart, lineEnd) {
|
|
3695
|
-
const dx = lineEnd.x - lineStart.x;
|
|
3696
|
-
const dy = lineEnd.y - lineStart.y;
|
|
3697
|
-
if (dx === 0) {
|
|
3698
|
-
return { x: lineStart.x, y: point.y };
|
|
3699
|
-
}
|
|
3700
|
-
if (dy === 0) {
|
|
3701
|
-
return { x: point.x, y: lineStart.y };
|
|
3702
|
-
}
|
|
3703
|
-
const t = ((point.x - lineStart.x) * dx + (point.y - lineStart.y) * dy) / (dx * dx + dy * dy);
|
|
3704
|
-
const clampedT = Math.max(0, Math.min(1, t));
|
|
3705
|
-
return {
|
|
3706
|
-
x: lineStart.x + clampedT * dx,
|
|
3707
|
-
y: lineStart.y + clampedT * dy
|
|
3708
|
-
};
|
|
3709
|
-
}
|
|
3710
|
-
};
|
|
3711
|
-
WorkflowSimpleLineContribution.type = "WorkflowSimpleLineContribution";
|
|
3712
3669
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3713
3670
|
0 && (module.exports = {
|
|
3714
3671
|
EditorCursorState,
|
|
@@ -3740,7 +3697,6 @@ WorkflowSimpleLineContribution.type = "WorkflowSimpleLineContribution";
|
|
|
3740
3697
|
WorkflowPortEntity,
|
|
3741
3698
|
WorkflowResetLayoutService,
|
|
3742
3699
|
WorkflowSelectService,
|
|
3743
|
-
WorkflowSimpleLineContribution,
|
|
3744
3700
|
bindConfigEntity,
|
|
3745
3701
|
buildGroupJSON,
|
|
3746
3702
|
compose,
|
|
@@ -3749,6 +3705,7 @@ WorkflowSimpleLineContribution.type = "WorkflowSimpleLineContribution";
|
|
|
3749
3705
|
domReactToBounds,
|
|
3750
3706
|
fitView,
|
|
3751
3707
|
getAntiOverlapPosition,
|
|
3708
|
+
getLineCenter,
|
|
3752
3709
|
getPortEntityId,
|
|
3753
3710
|
nanoid,
|
|
3754
3711
|
useConfigEntity,
|