@flowgram.ai/free-layout-core 0.1.5 → 0.1.7

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.
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  LineColors,
10
10
  LineType
11
- } from "../chunk-KAL7YCC2.js";
11
+ } from "../chunk-PT4ZVDZZ.js";
12
12
  import "../chunk-EUXUH3YW.js";
13
13
  import "../chunk-DDJTYHXN.js";
14
14
  import "../chunk-KNYZRMIO.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  LineColors,
3
3
  LineType
4
- } from "../chunk-KAL7YCC2.js";
4
+ } from "../chunk-PT4ZVDZZ.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, FlowNodeEntity } from '@flowgram.ai/document';
5
- import { W as WorkflowHoverService, a as WorkflowDocument, b as WorkflowLinesManager, c as WorkflowSelectService, d as WorkflowNodeJSON, e as WorkflowPortEntity, f as WorkflowLineEntity, g as WorkflowPorts, h as WorkflowPortType, i as WorkflowPort } from './workflow-line-entity-1qT4aXVU.mjs';
6
- export { B as BezierLine, L as LINE_HOVER_DISTANCE, P as POINT_RADIUS, t as PORT_SIZE, k as WORKFLOW_LINE_ENTITY, v as WorkfloEntityHoverable, o as WorkflowContentChangeEvent, n as WorkflowContentChangeType, x as WorkflowDocumentOptions, y as WorkflowDocumentOptionsDefault, w as WorkflowDocumentProvider, m as WorkflowJSON, r as WorkflowLineEntityOpts, s as WorkflowLineInfo, q as WorkflowLinePortInfo, p as WorkflowNodeMeta, u as WorkflowPortEntityOpts, l as domReactToBounds, j as getPortEntityId } from './workflow-line-entity-1qT4aXVU.mjs';
5
+ import { W as WorkflowHoverService, a as WorkflowDocument, b as WorkflowLinesManager, c as WorkflowSelectService, d as WorkflowNodeJSON, e as WorkflowPortEntity, f as WorkflowLineEntity, g as WorkflowPorts, h as WorkflowPortType, i as WorkflowPort, L as LineRenderType, j as WorkflowLineRenderContribution, k as LinePosition } from './workflow-line-entity-DZGrnBuq.mjs';
6
+ export { w as LINE_HOVER_DISTANCE, t as LineColor, u as LineColors, s as LineType, P as POINT_RADIUS, A as PORT_SIZE, m as WORKFLOW_LINE_ENTITY, C as WorkfloEntityHoverable, q as WorkflowContentChangeEvent, p as WorkflowContentChangeType, E as WorkflowDocumentOptions, F as WorkflowDocumentOptionsDefault, D as WorkflowDocumentProvider, o as WorkflowJSON, y as WorkflowLineEntityOpts, z as WorkflowLineInfo, x as WorkflowLinePortInfo, v as WorkflowLineRenderContributionFactory, r as WorkflowNodeMeta, B as WorkflowPortEntityOpts, n as domReactToBounds, l as getPortEntityId } from './workflow-line-entity-DZGrnBuq.mjs';
7
7
  import { W as WorkflowNodeEntity } from './workflow-sub-canvas-DOVla1mw.mjs';
8
8
  export { a as WorkflowSubCanvas } from './workflow-sub-canvas-DOVla1mw.mjs';
9
9
  import * as _flowgram_ai_utils from '@flowgram.ai/utils';
@@ -14,8 +14,6 @@ import React$1 from 'react';
14
14
  import { ContainerModule } from 'inversify';
15
15
  export { WorkflowEdgeJSON } from './typings/workflow-edge.mjs';
16
16
  export { WorkflowNodeFormMeta, WorkflowNodeRegistry, WorkflowNodeRenderProps } from './typings/workflow-registry.mjs';
17
- export { LineColor, LineColors, LinePosition, LineType } from './typings/workflow-line.mjs';
18
- import 'bezier-js';
19
17
  import '@flowgram.ai/form-core';
20
18
 
21
19
  declare enum WorkflowCommands {
@@ -278,43 +276,6 @@ declare function useWorkflowDocument(): WorkflowDocument;
278
276
  */
279
277
  declare function usePlaygroundReadonlyState(listenChange?: boolean): boolean;
280
278
 
281
- declare namespace FoldLine {
282
- function getPoints({ source, target }: {
283
- source: IPoint;
284
- target: IPoint;
285
- }): IPoint[];
286
- /**
287
- * 实现 reactFlow 原本的折叠线交互
288
- */
289
- function getSmoothStepPath(points: IPoint[]): string;
290
- function getBounds(points: IPoint[]): Rectangle;
291
- /**
292
- * 折叠线和点的距离
293
- * @param linePosition
294
- * @param pos
295
- */
296
- function getFoldLineToPointDistance(points: IPoint[], pos: IPoint): number;
297
- }
298
-
299
- declare enum BezierControlType {
300
- RIGHT_TOP = 0,
301
- RIGHT_BOTTOM = 1,
302
- LEFT_TOP = 2,
303
- LEFT_BOTTOM = 3
304
- }
305
- /**
306
- * 获取贝塞尔曲线横向的控制节点
307
- * @param fromPos
308
- * @param toPos
309
- */
310
- declare function getBezierHorizontalControlPoints(fromPos: IPoint, toPos: IPoint): IPoint[];
311
- /**
312
- * 获取贝塞尔曲线垂直方向的控制节点
313
- * @param fromPos 起始点
314
- * @param toPos 终点
315
- */
316
- declare function getBezierVerticalControlPoints(fromPos: IPoint, toPos: IPoint): IPoint[];
317
-
318
279
  declare function nanoid(n?: number): string;
319
280
 
320
281
  declare const fitView: (doc: WorkflowDocument, playgroundConfig: PlaygroundConfigEntity, easing?: boolean) => Promise<void>;
@@ -458,6 +419,57 @@ declare class WorkflowNodeLinesData extends EntityData<WorkflowNodeLines> {
458
419
  removeLine(line: WorkflowLineEntity): void;
459
420
  }
460
421
 
422
+ interface WorkflowLineRenderDataSchema {
423
+ version: string;
424
+ contributions: Map<LineRenderType, WorkflowLineRenderContribution>;
425
+ position: LinePosition;
426
+ }
427
+ declare class WorkflowLineRenderData extends EntityData<WorkflowLineRenderDataSchema> {
428
+ static type: string;
429
+ entity: WorkflowLineEntity;
430
+ constructor(entity: WorkflowLineEntity);
431
+ getDefaultData(): WorkflowLineRenderDataSchema;
432
+ get renderVersion(): string;
433
+ get position(): LinePosition;
434
+ get path(): string;
435
+ calcDistance(pos: IPoint): number;
436
+ get bounds(): Rectangle;
437
+ /**
438
+ * 更新数据
439
+ * WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
440
+ */
441
+ update(): void;
442
+ private get lineType();
443
+ /**
444
+ * 更新版本
445
+ * WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
446
+ */
447
+ private updatePosition;
448
+ private get currentLine();
449
+ private syncContributions;
450
+ private registerContribution;
451
+ }
452
+
461
453
  declare const WorkflowDocumentContainerModule: ContainerModule;
462
454
 
463
- export { BezierControlType, EditorCursorState, FoldLine, InteractiveType, type NodeRenderReturnType, type NodesDragEndEvent, type NodesDragEvent, type PositionMap, WorkflowCommands, WorkflowDocument, WorkflowDocumentContainerModule, WorkflowDragService, WorkflowHoverService, WorkflowLineEntity, WorkflowLinesManager, WorkflowNodeEntity, WorkflowNodeJSON, type WorkflowNodeLines, WorkflowNodeLinesData, WorkflowNodePortsData, WorkflowPort, WorkflowPortEntity, WorkflowPortType, WorkflowPorts, WorkflowResetLayoutService, WorkflowSelectService, fitView, getAntiOverlapPosition, getBezierHorizontalControlPoints, getBezierVerticalControlPoints, nanoid, useCurrentDomNode, useCurrentEntity, useNodeRender, usePlaygroundReadonlyState, useWorkflowDocument };
455
+ interface StraightData {
456
+ points: IPoint[];
457
+ path: string;
458
+ bbox: Rectangle;
459
+ }
460
+ declare class WorkflowSimpleLineContribution implements WorkflowLineRenderContribution {
461
+ static type: string;
462
+ entity: WorkflowLineEntity;
463
+ constructor(entity: WorkflowLineEntity);
464
+ private data?;
465
+ get path(): string;
466
+ calcDistance(pos: IPoint): number;
467
+ get bounds(): Rectangle;
468
+ update(params: {
469
+ fromPos: IPoint;
470
+ toPos: IPoint;
471
+ }): void;
472
+ private projectPointOnLine;
473
+ }
474
+
475
+ export { EditorCursorState, InteractiveType, LinePosition, LineRenderType, type NodeRenderReturnType, type NodesDragEndEvent, type NodesDragEvent, type PositionMap, type StraightData, WorkflowCommands, WorkflowDocument, WorkflowDocumentContainerModule, WorkflowDragService, WorkflowHoverService, WorkflowLineEntity, WorkflowLineRenderContribution, WorkflowLineRenderData, type WorkflowLineRenderDataSchema, WorkflowLinesManager, WorkflowNodeEntity, WorkflowNodeJSON, type WorkflowNodeLines, WorkflowNodeLinesData, WorkflowNodePortsData, WorkflowPort, WorkflowPortEntity, WorkflowPortType, WorkflowPorts, WorkflowResetLayoutService, WorkflowSelectService, WorkflowSimpleLineContribution, fitView, getAntiOverlapPosition, 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, FlowNodeEntity } from '@flowgram.ai/document';
5
- import { W as WorkflowHoverService, a as WorkflowDocument, b as WorkflowLinesManager, c as WorkflowSelectService, d as WorkflowNodeJSON, e as WorkflowPortEntity, f as WorkflowLineEntity, g as WorkflowPorts, h as WorkflowPortType, i as WorkflowPort } from './workflow-line-entity-CG_8mknJ.js';
6
- export { B as BezierLine, L as LINE_HOVER_DISTANCE, P as POINT_RADIUS, t as PORT_SIZE, k as WORKFLOW_LINE_ENTITY, v as WorkfloEntityHoverable, o as WorkflowContentChangeEvent, n as WorkflowContentChangeType, x as WorkflowDocumentOptions, y as WorkflowDocumentOptionsDefault, w as WorkflowDocumentProvider, m as WorkflowJSON, r as WorkflowLineEntityOpts, s as WorkflowLineInfo, q as WorkflowLinePortInfo, p as WorkflowNodeMeta, u as WorkflowPortEntityOpts, l as domReactToBounds, j as getPortEntityId } from './workflow-line-entity-CG_8mknJ.js';
5
+ import { W as WorkflowHoverService, a as WorkflowDocument, b as WorkflowLinesManager, c as WorkflowSelectService, d as WorkflowNodeJSON, e as WorkflowPortEntity, f as WorkflowLineEntity, g as WorkflowPorts, h as WorkflowPortType, i as WorkflowPort, L as LineRenderType, j as WorkflowLineRenderContribution, k as LinePosition } from './workflow-line-entity-BcXJ4GjA.js';
6
+ export { w as LINE_HOVER_DISTANCE, t as LineColor, u as LineColors, s as LineType, P as POINT_RADIUS, A as PORT_SIZE, m as WORKFLOW_LINE_ENTITY, C as WorkfloEntityHoverable, q as WorkflowContentChangeEvent, p as WorkflowContentChangeType, E as WorkflowDocumentOptions, F as WorkflowDocumentOptionsDefault, D as WorkflowDocumentProvider, o as WorkflowJSON, y as WorkflowLineEntityOpts, z as WorkflowLineInfo, x as WorkflowLinePortInfo, v as WorkflowLineRenderContributionFactory, r as WorkflowNodeMeta, B as WorkflowPortEntityOpts, n as domReactToBounds, l as getPortEntityId } from './workflow-line-entity-BcXJ4GjA.js';
7
7
  import { W as WorkflowNodeEntity } from './workflow-sub-canvas-DOVla1mw.js';
8
8
  export { a as WorkflowSubCanvas } from './workflow-sub-canvas-DOVla1mw.js';
9
9
  import * as _flowgram_ai_utils from '@flowgram.ai/utils';
@@ -14,8 +14,6 @@ import React$1 from 'react';
14
14
  import { ContainerModule } from 'inversify';
15
15
  export { WorkflowEdgeJSON } from './typings/workflow-edge.js';
16
16
  export { WorkflowNodeFormMeta, WorkflowNodeRegistry, WorkflowNodeRenderProps } from './typings/workflow-registry.js';
17
- export { LineColor, LineColors, LinePosition, LineType } from './typings/workflow-line.js';
18
- import 'bezier-js';
19
17
  import '@flowgram.ai/form-core';
20
18
 
21
19
  declare enum WorkflowCommands {
@@ -278,43 +276,6 @@ declare function useWorkflowDocument(): WorkflowDocument;
278
276
  */
279
277
  declare function usePlaygroundReadonlyState(listenChange?: boolean): boolean;
280
278
 
281
- declare namespace FoldLine {
282
- function getPoints({ source, target }: {
283
- source: IPoint;
284
- target: IPoint;
285
- }): IPoint[];
286
- /**
287
- * 实现 reactFlow 原本的折叠线交互
288
- */
289
- function getSmoothStepPath(points: IPoint[]): string;
290
- function getBounds(points: IPoint[]): Rectangle;
291
- /**
292
- * 折叠线和点的距离
293
- * @param linePosition
294
- * @param pos
295
- */
296
- function getFoldLineToPointDistance(points: IPoint[], pos: IPoint): number;
297
- }
298
-
299
- declare enum BezierControlType {
300
- RIGHT_TOP = 0,
301
- RIGHT_BOTTOM = 1,
302
- LEFT_TOP = 2,
303
- LEFT_BOTTOM = 3
304
- }
305
- /**
306
- * 获取贝塞尔曲线横向的控制节点
307
- * @param fromPos
308
- * @param toPos
309
- */
310
- declare function getBezierHorizontalControlPoints(fromPos: IPoint, toPos: IPoint): IPoint[];
311
- /**
312
- * 获取贝塞尔曲线垂直方向的控制节点
313
- * @param fromPos 起始点
314
- * @param toPos 终点
315
- */
316
- declare function getBezierVerticalControlPoints(fromPos: IPoint, toPos: IPoint): IPoint[];
317
-
318
279
  declare function nanoid(n?: number): string;
319
280
 
320
281
  declare const fitView: (doc: WorkflowDocument, playgroundConfig: PlaygroundConfigEntity, easing?: boolean) => Promise<void>;
@@ -458,6 +419,57 @@ declare class WorkflowNodeLinesData extends EntityData<WorkflowNodeLines> {
458
419
  removeLine(line: WorkflowLineEntity): void;
459
420
  }
460
421
 
422
+ interface WorkflowLineRenderDataSchema {
423
+ version: string;
424
+ contributions: Map<LineRenderType, WorkflowLineRenderContribution>;
425
+ position: LinePosition;
426
+ }
427
+ declare class WorkflowLineRenderData extends EntityData<WorkflowLineRenderDataSchema> {
428
+ static type: string;
429
+ entity: WorkflowLineEntity;
430
+ constructor(entity: WorkflowLineEntity);
431
+ getDefaultData(): WorkflowLineRenderDataSchema;
432
+ get renderVersion(): string;
433
+ get position(): LinePosition;
434
+ get path(): string;
435
+ calcDistance(pos: IPoint): number;
436
+ get bounds(): Rectangle;
437
+ /**
438
+ * 更新数据
439
+ * WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
440
+ */
441
+ update(): void;
442
+ private get lineType();
443
+ /**
444
+ * 更新版本
445
+ * WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
446
+ */
447
+ private updatePosition;
448
+ private get currentLine();
449
+ private syncContributions;
450
+ private registerContribution;
451
+ }
452
+
461
453
  declare const WorkflowDocumentContainerModule: ContainerModule;
462
454
 
463
- export { BezierControlType, EditorCursorState, FoldLine, InteractiveType, type NodeRenderReturnType, type NodesDragEndEvent, type NodesDragEvent, type PositionMap, WorkflowCommands, WorkflowDocument, WorkflowDocumentContainerModule, WorkflowDragService, WorkflowHoverService, WorkflowLineEntity, WorkflowLinesManager, WorkflowNodeEntity, WorkflowNodeJSON, type WorkflowNodeLines, WorkflowNodeLinesData, WorkflowNodePortsData, WorkflowPort, WorkflowPortEntity, WorkflowPortType, WorkflowPorts, WorkflowResetLayoutService, WorkflowSelectService, fitView, getAntiOverlapPosition, getBezierHorizontalControlPoints, getBezierVerticalControlPoints, nanoid, useCurrentDomNode, useCurrentEntity, useNodeRender, usePlaygroundReadonlyState, useWorkflowDocument };
455
+ interface StraightData {
456
+ points: IPoint[];
457
+ path: string;
458
+ bbox: Rectangle;
459
+ }
460
+ declare class WorkflowSimpleLineContribution implements WorkflowLineRenderContribution {
461
+ static type: string;
462
+ entity: WorkflowLineEntity;
463
+ constructor(entity: WorkflowLineEntity);
464
+ private data?;
465
+ get path(): string;
466
+ calcDistance(pos: IPoint): number;
467
+ get bounds(): Rectangle;
468
+ update(params: {
469
+ fromPos: IPoint;
470
+ toPos: IPoint;
471
+ }): void;
472
+ private projectPointOnLine;
473
+ }
474
+
475
+ export { EditorCursorState, InteractiveType, LinePosition, LineRenderType, type NodeRenderReturnType, type NodesDragEndEvent, type NodesDragEvent, type PositionMap, type StraightData, WorkflowCommands, WorkflowDocument, WorkflowDocumentContainerModule, WorkflowDragService, WorkflowHoverService, WorkflowLineEntity, WorkflowLineRenderContribution, WorkflowLineRenderData, type WorkflowLineRenderDataSchema, WorkflowLinesManager, WorkflowNodeEntity, WorkflowNodeJSON, type WorkflowNodeLines, WorkflowNodeLinesData, WorkflowNodePortsData, WorkflowPort, WorkflowPortEntity, WorkflowPortType, WorkflowPorts, WorkflowResetLayoutService, WorkflowSelectService, WorkflowSimpleLineContribution, fitView, getAntiOverlapPosition, nanoid, useCurrentDomNode, useCurrentEntity, useNodeRender, usePlaygroundReadonlyState, useWorkflowDocument };