@flowgram.ai/free-layout-core 0.5.2 → 0.5.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/index.js +46 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +46 -5
- 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/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-node.d.mts +1 -1
- package/dist/typings/workflow-node.d.ts +1 -1
- package/dist/typings/workflow-operation.d.mts +1 -1
- package/dist/typings/workflow-operation.d.ts +1 -1
- package/dist/typings/workflow-registry.d.mts +1 -1
- package/dist/typings/workflow-registry.d.ts +1 -1
- package/dist/typings/workflow-sub-canvas.d.mts +1 -1
- package/dist/typings/workflow-sub-canvas.d.ts +1 -1
- package/dist/{workflow-node-entity-DgQT-wl9.d.mts → workflow-node-entity-DH5qlw7I.d.mts} +25 -4
- package/dist/{workflow-node-entity-kGsp2Roz.d.ts → workflow-node-entity-DWVtlA2a.d.ts} +25 -4
- package/package.json +9 -9
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, 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 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-
|
|
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-
|
|
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-DH5qlw7I.mjs';
|
|
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-DH5qlw7I.mjs';
|
|
7
7
|
import * as _flowgram_ai_utils from '@flowgram.ai/utils';
|
|
8
8
|
import { IPoint, Rectangle, DisposableCollection, Disposable } from '@flowgram.ai/utils';
|
|
9
9
|
export { compose, composeAsync, delay } from '@flowgram.ai/utils';
|
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, 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 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-
|
|
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-
|
|
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-DWVtlA2a.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-DWVtlA2a.js';
|
|
7
7
|
import * as _flowgram_ai_utils from '@flowgram.ai/utils';
|
|
8
8
|
import { IPoint, Rectangle, DisposableCollection, Disposable } from '@flowgram.ai/utils';
|
|
9
9
|
export { compose, composeAsync, delay } from '@flowgram.ai/utils';
|
package/dist/index.js
CHANGED
|
@@ -225,6 +225,27 @@ var import_core5 = require("@flowgram.ai/core");
|
|
|
225
225
|
var import_utils5 = require("@flowgram.ai/utils");
|
|
226
226
|
var import_document3 = require("@flowgram.ai/document");
|
|
227
227
|
var import_core4 = require("@flowgram.ai/core");
|
|
228
|
+
|
|
229
|
+
// src/utils/location-config-to-point.ts
|
|
230
|
+
function locationConfigToPoint(bounds, config, _offset = { x: 0, y: 0 }) {
|
|
231
|
+
const offset = { ..._offset };
|
|
232
|
+
if (config.left !== void 0) {
|
|
233
|
+
offset.x += typeof config.left === "string" ? parseFloat(config.left) * 0.01 * bounds.width : config.left;
|
|
234
|
+
} else if (config.right !== void 0) {
|
|
235
|
+
offset.x += bounds.width - (typeof config.right === "string" ? parseFloat(config.right) * 0.01 * bounds.width : config.right);
|
|
236
|
+
}
|
|
237
|
+
if (config.top !== void 0) {
|
|
238
|
+
offset.y += typeof config.top === "string" ? parseFloat(config.top) * 0.01 * bounds.height : config.top;
|
|
239
|
+
} else if (config.bottom !== void 0) {
|
|
240
|
+
offset.y += bounds.height - (typeof config.bottom === "string" ? parseFloat(config.bottom) * 0.01 * bounds.height : config.bottom);
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
x: bounds.x + offset.x,
|
|
244
|
+
y: bounds.y + offset.y
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// src/entities/workflow-port-entity.ts
|
|
228
249
|
var PORT_SIZE = 24;
|
|
229
250
|
var WorkflowPortEntity = class extends import_core4.Entity {
|
|
230
251
|
constructor(opts) {
|
|
@@ -237,6 +258,7 @@ var WorkflowPortEntity = class extends import_core4.Entity {
|
|
|
237
258
|
this.portType = opts.type;
|
|
238
259
|
this._disabled = opts.disabled;
|
|
239
260
|
this._offset = opts.offset;
|
|
261
|
+
this._locationConfig = opts.locationConfig;
|
|
240
262
|
this._location = opts.location;
|
|
241
263
|
this._size = opts.size;
|
|
242
264
|
this.node = opts.node;
|
|
@@ -284,7 +306,7 @@ var WorkflowPortEntity = class extends import_core4.Entity {
|
|
|
284
306
|
return "right";
|
|
285
307
|
}
|
|
286
308
|
get point() {
|
|
287
|
-
const { targetElement } = this;
|
|
309
|
+
const { targetElement, _locationConfig } = this;
|
|
288
310
|
const { bounds } = this.node.getData(import_document3.FlowNodeTransformData);
|
|
289
311
|
const location2 = this.location;
|
|
290
312
|
if (targetElement) {
|
|
@@ -299,8 +321,14 @@ var WorkflowPortEntity = class extends import_core4.Entity {
|
|
|
299
321
|
location: location2
|
|
300
322
|
};
|
|
301
323
|
}
|
|
302
|
-
|
|
324
|
+
if (_locationConfig) {
|
|
325
|
+
return {
|
|
326
|
+
...locationConfigToPoint(bounds, _locationConfig, this._offset),
|
|
327
|
+
location: location2
|
|
328
|
+
};
|
|
329
|
+
}
|
|
303
330
|
const offset = this._offset || { x: 0, y: 0 };
|
|
331
|
+
let point = { x: 0, y: 0 };
|
|
304
332
|
switch (location2) {
|
|
305
333
|
case "left":
|
|
306
334
|
point = bounds.leftCenter;
|
|
@@ -413,6 +441,10 @@ var WorkflowPortEntity = class extends import_core4.Entity {
|
|
|
413
441
|
this._offset = data.offset;
|
|
414
442
|
changed = true;
|
|
415
443
|
}
|
|
444
|
+
if (import_utils5.Compare.isChanged(data.locationConfig, this._locationConfig)) {
|
|
445
|
+
this._locationConfig = data.locationConfig;
|
|
446
|
+
changed = true;
|
|
447
|
+
}
|
|
416
448
|
if (import_utils5.Compare.isChanged(data.size, this._size)) {
|
|
417
449
|
this._size = data.size;
|
|
418
450
|
changed = true;
|
|
@@ -2584,12 +2616,14 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2584
2616
|
* 批量添加节点
|
|
2585
2617
|
*/
|
|
2586
2618
|
batchAddFromJSON(json, options) {
|
|
2587
|
-
const { parent = this.root } = options ?? {};
|
|
2619
|
+
const { parent = this.root, onNodeCreated, onEdgeCreated } = options ?? {};
|
|
2588
2620
|
const parentID = this.getNodeSubCanvas(parent)?.canvasNode.id ?? parent.id;
|
|
2589
2621
|
const processedJSON = buildGroupJSON(json);
|
|
2590
2622
|
const nodes = processedJSON.nodes.map(
|
|
2591
2623
|
(nodeJSON) => this._createWorkflowNode(nodeJSON, {
|
|
2592
|
-
parentID
|
|
2624
|
+
parentID,
|
|
2625
|
+
onNodeCreated,
|
|
2626
|
+
onEdgeCreated
|
|
2593
2627
|
})
|
|
2594
2628
|
);
|
|
2595
2629
|
const edges = processedJSON.edges.map((edge) => this.createWorkflowLine(edge, parentID)).filter(Boolean);
|
|
@@ -3611,6 +3645,7 @@ var WorkflowOperationBaseServiceImpl = class extends import_document12.FlowOpera
|
|
|
3611
3645
|
edges: json.edges ?? []
|
|
3612
3646
|
};
|
|
3613
3647
|
const oldNodes = this.document.getAllNodes();
|
|
3648
|
+
const oldEdges = this.linesManager.getAllLines();
|
|
3614
3649
|
const oldPositionMap = new Map(
|
|
3615
3650
|
oldNodes.map((node) => [
|
|
3616
3651
|
node.id,
|
|
@@ -3622,11 +3657,17 @@ var WorkflowOperationBaseServiceImpl = class extends import_document12.FlowOpera
|
|
|
3622
3657
|
);
|
|
3623
3658
|
const newNodes = [];
|
|
3624
3659
|
const newEdges = [];
|
|
3625
|
-
this.linesManager.getAllLines().map((line) => line.dispose());
|
|
3626
3660
|
this.document.batchAddFromJSON(workflowJSON, {
|
|
3627
3661
|
onNodeCreated: (node) => newNodes.push(node),
|
|
3628
3662
|
onEdgeCreated: (edge) => newEdges.push(edge)
|
|
3629
3663
|
});
|
|
3664
|
+
const newEdgeIDSet = new Set(newEdges.map((edge) => edge.id));
|
|
3665
|
+
oldEdges.forEach((edge) => {
|
|
3666
|
+
if (!newEdgeIDSet.has(edge.id)) {
|
|
3667
|
+
edge.dispose();
|
|
3668
|
+
return;
|
|
3669
|
+
}
|
|
3670
|
+
});
|
|
3630
3671
|
const newNodeIDSet = new Set(newNodes.map((node) => node.id));
|
|
3631
3672
|
oldNodes.forEach((node) => {
|
|
3632
3673
|
if (!newNodeIDSet.has(node.id)) {
|