@flowgram.ai/free-layout-core 0.5.1 → 0.5.3
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-O4WKIIW2.js → chunk-3UW6BHP2.js} +1 -1
- package/dist/esm/chunk-3UW6BHP2.js.map +1 -0
- package/dist/esm/index.js +111 -31
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/typings/index.js +1 -1
- package/dist/esm/typings/workflow-operation.js +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +110 -30
- 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.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-node.d.mts +1 -1
- package/dist/typings/workflow-node.d.ts +1 -1
- package/dist/typings/workflow-operation.d.mts +9 -0
- package/dist/typings/workflow-operation.d.ts +9 -0
- package/dist/typings/workflow-operation.js.map +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-lKu00Aj4.d.mts → workflow-node-entity-DgQT-wl9.d.mts} +16 -3
- package/dist/{workflow-node-entity-Cnte2phX.d.ts → workflow-node-entity-kGsp2Roz.d.ts} +16 -3
- package/package.json +9 -9
- package/dist/esm/chunk-O4WKIIW2.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, 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-DgQT-wl9.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-DgQT-wl9.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';
|
|
@@ -228,9 +228,11 @@ declare class WorkflowResetLayoutService {
|
|
|
228
228
|
|
|
229
229
|
declare class WorkflowOperationBaseServiceImpl extends FlowOperationBaseServiceImpl implements WorkflowOperationBaseService {
|
|
230
230
|
protected document: WorkflowDocument;
|
|
231
|
+
linesManager: WorkflowLinesManager;
|
|
231
232
|
private onNodePostionUpdateEmitter;
|
|
232
233
|
readonly onNodePostionUpdate: _flowgram_ai_utils.Event<NodePostionUpdateEvent>;
|
|
233
234
|
updateNodePosition(nodeOrId: FlowNodeEntityOrId, position: IPoint): void;
|
|
235
|
+
fromJSON(json: WorkflowJSON): void;
|
|
234
236
|
}
|
|
235
237
|
|
|
236
238
|
/**
|
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-kGsp2Roz.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-kGsp2Roz.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';
|
|
@@ -228,9 +228,11 @@ declare class WorkflowResetLayoutService {
|
|
|
228
228
|
|
|
229
229
|
declare class WorkflowOperationBaseServiceImpl extends FlowOperationBaseServiceImpl implements WorkflowOperationBaseService {
|
|
230
230
|
protected document: WorkflowDocument;
|
|
231
|
+
linesManager: WorkflowLinesManager;
|
|
231
232
|
private onNodePostionUpdateEmitter;
|
|
232
233
|
readonly onNodePostionUpdate: _flowgram_ai_utils.Event<NodePostionUpdateEvent>;
|
|
233
234
|
updateNodePosition(nodeOrId: FlowNodeEntityOrId, position: IPoint): void;
|
|
235
|
+
fromJSON(json: WorkflowJSON): void;
|
|
234
236
|
}
|
|
235
237
|
|
|
236
238
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2105,6 +2105,9 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2105
2105
|
this._loading = false;
|
|
2106
2106
|
this.onLoadedEmitter.fire();
|
|
2107
2107
|
}
|
|
2108
|
+
/**
|
|
2109
|
+
* @deprecated use `ctx.operation.fromJSON` instead
|
|
2110
|
+
*/
|
|
2108
2111
|
async reload(json, delayTime = 0) {
|
|
2109
2112
|
if (this.disposed) return;
|
|
2110
2113
|
this._loading = true;
|
|
@@ -2125,7 +2128,7 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2125
2128
|
edges: json.edges ?? []
|
|
2126
2129
|
};
|
|
2127
2130
|
this.entityManager.changeEntityLocked = true;
|
|
2128
|
-
this.
|
|
2131
|
+
this.batchAddFromJSON(workflowJSON);
|
|
2129
2132
|
this.entityManager.changeEntityLocked = false;
|
|
2130
2133
|
this.transformer.loading = false;
|
|
2131
2134
|
if (fireRender) {
|
|
@@ -2145,9 +2148,17 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2145
2148
|
* 创建流程节点
|
|
2146
2149
|
* @param json
|
|
2147
2150
|
*/
|
|
2148
|
-
createWorkflowNode(json, isClone = false,
|
|
2151
|
+
createWorkflowNode(json, isClone = false, parentID) {
|
|
2152
|
+
return this._createWorkflowNode(json, { parentID });
|
|
2153
|
+
}
|
|
2154
|
+
/**
|
|
2155
|
+
* 创建流程节点
|
|
2156
|
+
* @param json
|
|
2157
|
+
*/
|
|
2158
|
+
_createWorkflowNode(json, options) {
|
|
2159
|
+
const { parentID, onNodeCreated, onEdgeCreated } = options ?? {};
|
|
2149
2160
|
const isExistedNode = this.getNode(json.id);
|
|
2150
|
-
const parent = this.getNode(
|
|
2161
|
+
const parent = this.getNode(parentID ?? this.root.id) ?? this.root;
|
|
2151
2162
|
const node = this.addNode(
|
|
2152
2163
|
{
|
|
2153
2164
|
...json,
|
|
@@ -2174,15 +2185,19 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2174
2185
|
node.getData(import_core14.TransformData).update({
|
|
2175
2186
|
position
|
|
2176
2187
|
});
|
|
2177
|
-
if (formMeta && formData
|
|
2178
|
-
formData.
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2188
|
+
if (formMeta && formData) {
|
|
2189
|
+
if (!formData.formModel.initialized) {
|
|
2190
|
+
formData.createForm(formMeta, json.data);
|
|
2191
|
+
formData.onDataChange(() => {
|
|
2192
|
+
this.fireContentChange({
|
|
2193
|
+
type: "NODE_DATA_CHANGE" /* NODE_DATA_CHANGE */,
|
|
2194
|
+
toJSON: () => formData.toJSON(),
|
|
2195
|
+
entity: node
|
|
2196
|
+
});
|
|
2184
2197
|
});
|
|
2185
|
-
}
|
|
2198
|
+
} else {
|
|
2199
|
+
formData.updateFormValues(json.data);
|
|
2200
|
+
}
|
|
2186
2201
|
}
|
|
2187
2202
|
const positionData = node.getData(import_core14.PositionData);
|
|
2188
2203
|
if (!isExistedNode) {
|
|
@@ -2221,11 +2236,12 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2221
2236
|
});
|
|
2222
2237
|
}
|
|
2223
2238
|
if (json.blocks) {
|
|
2224
|
-
this.
|
|
2239
|
+
this.batchAddFromJSON(
|
|
2225
2240
|
{ nodes: json.blocks, edges: json.edges ?? [] },
|
|
2226
2241
|
{
|
|
2227
2242
|
parent: node,
|
|
2228
|
-
|
|
2243
|
+
onNodeCreated,
|
|
2244
|
+
onEdgeCreated
|
|
2229
2245
|
}
|
|
2230
2246
|
);
|
|
2231
2247
|
}
|
|
@@ -2357,7 +2373,7 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2357
2373
|
throw new Error(`[WorkflowDocument.createWorkflowNodeByType] Node Id "${id}" duplicated.`);
|
|
2358
2374
|
}
|
|
2359
2375
|
}
|
|
2360
|
-
return this.
|
|
2376
|
+
return this._createWorkflowNode(
|
|
2361
2377
|
{
|
|
2362
2378
|
...json,
|
|
2363
2379
|
id,
|
|
@@ -2368,13 +2384,15 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2368
2384
|
blocks: json?.blocks,
|
|
2369
2385
|
edges: json?.edges
|
|
2370
2386
|
},
|
|
2371
|
-
|
|
2372
|
-
parentID
|
|
2387
|
+
{ parentID }
|
|
2373
2388
|
);
|
|
2374
2389
|
}
|
|
2375
2390
|
getAllNodes() {
|
|
2376
2391
|
return this.entityManager.getEntities(WorkflowNodeEntity).filter((n) => n.id !== import_document8.FlowNodeBaseType.ROOT);
|
|
2377
2392
|
}
|
|
2393
|
+
getAllEdges() {
|
|
2394
|
+
return this.entityManager.getEntities(WorkflowLineEntity);
|
|
2395
|
+
}
|
|
2378
2396
|
getAllPorts() {
|
|
2379
2397
|
return this.entityManager.getEntities(WorkflowPortEntity).filter((p) => p.node.id !== import_document8.FlowNodeBaseType.ROOT);
|
|
2380
2398
|
}
|
|
@@ -2475,7 +2493,7 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2475
2493
|
x: json.meta.position.x + 30,
|
|
2476
2494
|
y: json.meta.position.y + 30
|
|
2477
2495
|
};
|
|
2478
|
-
return this.
|
|
2496
|
+
return this._createWorkflowNode(
|
|
2479
2497
|
{
|
|
2480
2498
|
id: newNodeId || `1${nanoid2()}`,
|
|
2481
2499
|
type: node.flowNodeType,
|
|
@@ -2487,16 +2505,17 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2487
2505
|
blocks: json.blocks,
|
|
2488
2506
|
edges: json.edges
|
|
2489
2507
|
},
|
|
2490
|
-
|
|
2491
|
-
|
|
2508
|
+
{
|
|
2509
|
+
parentID: node.parent?.id
|
|
2510
|
+
}
|
|
2492
2511
|
);
|
|
2493
2512
|
}
|
|
2494
|
-
copyNodeFromJSON(flowNodeType, nodeJSON, newNodeId, position,
|
|
2513
|
+
copyNodeFromJSON(flowNodeType, nodeJSON, newNodeId, position, parentID) {
|
|
2495
2514
|
position = position || {
|
|
2496
2515
|
x: nodeJSON.meta.position.x + 30,
|
|
2497
2516
|
y: nodeJSON.meta.position.y + 30
|
|
2498
2517
|
};
|
|
2499
|
-
return this.
|
|
2518
|
+
return this._createWorkflowNode(
|
|
2500
2519
|
{
|
|
2501
2520
|
id: newNodeId || `1${nanoid2()}`,
|
|
2502
2521
|
type: flowNodeType,
|
|
@@ -2508,8 +2527,9 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2508
2527
|
blocks: nodeJSON.blocks,
|
|
2509
2528
|
edges: nodeJSON.edges
|
|
2510
2529
|
},
|
|
2511
|
-
|
|
2512
|
-
|
|
2530
|
+
{
|
|
2531
|
+
parentID
|
|
2532
|
+
}
|
|
2513
2533
|
);
|
|
2514
2534
|
}
|
|
2515
2535
|
canRemove(node, silent) {
|
|
@@ -2564,13 +2584,19 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2564
2584
|
* 批量添加节点
|
|
2565
2585
|
*/
|
|
2566
2586
|
batchAddFromJSON(json, options) {
|
|
2567
|
-
const { parent = this.root,
|
|
2568
|
-
const
|
|
2587
|
+
const { parent = this.root, onNodeCreated, onEdgeCreated } = options ?? {};
|
|
2588
|
+
const parentID = this.getNodeSubCanvas(parent)?.canvasNode.id ?? parent.id;
|
|
2569
2589
|
const processedJSON = buildGroupJSON(json);
|
|
2570
2590
|
const nodes = processedJSON.nodes.map(
|
|
2571
|
-
(nodeJSON) => this.
|
|
2591
|
+
(nodeJSON) => this._createWorkflowNode(nodeJSON, {
|
|
2592
|
+
parentID,
|
|
2593
|
+
onNodeCreated,
|
|
2594
|
+
onEdgeCreated
|
|
2595
|
+
})
|
|
2572
2596
|
);
|
|
2573
|
-
const edges = processedJSON.edges.map((edge) => this.createWorkflowLine(edge,
|
|
2597
|
+
const edges = processedJSON.edges.map((edge) => this.createWorkflowLine(edge, parentID)).filter(Boolean);
|
|
2598
|
+
nodes.forEach((node) => options?.onNodeCreated?.(node));
|
|
2599
|
+
edges.forEach((edge) => options?.onEdgeCreated?.(edge));
|
|
2574
2600
|
return { nodes, edges };
|
|
2575
2601
|
}
|
|
2576
2602
|
getNodeSubCanvas(node) {
|
|
@@ -2619,7 +2645,7 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2619
2645
|
}
|
|
2620
2646
|
return lineJSON;
|
|
2621
2647
|
}
|
|
2622
|
-
createWorkflowLine(json,
|
|
2648
|
+
createWorkflowLine(json, parentID) {
|
|
2623
2649
|
const fromNode = this.getNode(json.sourceNodeID);
|
|
2624
2650
|
const toNode = this.getNode(json.targetNodeID);
|
|
2625
2651
|
if (!fromNode || !toNode) {
|
|
@@ -2632,10 +2658,10 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2632
2658
|
toPort: json.targetPortID,
|
|
2633
2659
|
data: json.data
|
|
2634
2660
|
};
|
|
2635
|
-
if (!
|
|
2661
|
+
if (!parentID) {
|
|
2636
2662
|
return this.linesManager.createLine(lineInfo);
|
|
2637
2663
|
}
|
|
2638
|
-
const canvasNode = this.getNode(
|
|
2664
|
+
const canvasNode = this.getNode(parentID);
|
|
2639
2665
|
if (!canvasNode) {
|
|
2640
2666
|
return this.linesManager.createLine(lineInfo);
|
|
2641
2667
|
}
|
|
@@ -3580,10 +3606,64 @@ var WorkflowOperationBaseServiceImpl = class extends import_document12.FlowOpera
|
|
|
3580
3606
|
newPosition: position
|
|
3581
3607
|
});
|
|
3582
3608
|
}
|
|
3609
|
+
fromJSON(json) {
|
|
3610
|
+
if (this.document.disposed) return;
|
|
3611
|
+
const workflowJSON = {
|
|
3612
|
+
nodes: json.nodes ?? [],
|
|
3613
|
+
edges: json.edges ?? []
|
|
3614
|
+
};
|
|
3615
|
+
const oldNodes = this.document.getAllNodes();
|
|
3616
|
+
const oldEdges = this.linesManager.getAllLines();
|
|
3617
|
+
const oldPositionMap = new Map(
|
|
3618
|
+
oldNodes.map((node) => [
|
|
3619
|
+
node.id,
|
|
3620
|
+
{
|
|
3621
|
+
x: node.transform.transform.position.x,
|
|
3622
|
+
y: node.transform.transform.position.y
|
|
3623
|
+
}
|
|
3624
|
+
])
|
|
3625
|
+
);
|
|
3626
|
+
const newNodes = [];
|
|
3627
|
+
const newEdges = [];
|
|
3628
|
+
this.document.batchAddFromJSON(workflowJSON, {
|
|
3629
|
+
onNodeCreated: (node) => newNodes.push(node),
|
|
3630
|
+
onEdgeCreated: (edge) => newEdges.push(edge)
|
|
3631
|
+
});
|
|
3632
|
+
const newEdgeIDSet = new Set(newEdges.map((edge) => edge.id));
|
|
3633
|
+
oldEdges.forEach((edge) => {
|
|
3634
|
+
if (!newEdgeIDSet.has(edge.id)) {
|
|
3635
|
+
edge.dispose();
|
|
3636
|
+
return;
|
|
3637
|
+
}
|
|
3638
|
+
});
|
|
3639
|
+
const newNodeIDSet = new Set(newNodes.map((node) => node.id));
|
|
3640
|
+
oldNodes.forEach((node) => {
|
|
3641
|
+
if (!newNodeIDSet.has(node.id)) {
|
|
3642
|
+
node.dispose();
|
|
3643
|
+
return;
|
|
3644
|
+
}
|
|
3645
|
+
const oldPosition = oldPositionMap.get(node.id);
|
|
3646
|
+
const newPosition = {
|
|
3647
|
+
x: node.transform.transform.position.x,
|
|
3648
|
+
y: node.transform.transform.position.y
|
|
3649
|
+
};
|
|
3650
|
+
if (oldPosition && (oldPosition.x !== newPosition.x || oldPosition.y !== newPosition.y)) {
|
|
3651
|
+
this.onNodePostionUpdateEmitter.fire({
|
|
3652
|
+
node,
|
|
3653
|
+
oldPosition,
|
|
3654
|
+
newPosition
|
|
3655
|
+
});
|
|
3656
|
+
}
|
|
3657
|
+
});
|
|
3658
|
+
this.document.fireRender();
|
|
3659
|
+
}
|
|
3583
3660
|
};
|
|
3584
3661
|
__decorateClass([
|
|
3585
3662
|
(0, import_inversify8.inject)(WorkflowDocument)
|
|
3586
3663
|
], WorkflowOperationBaseServiceImpl.prototype, "document", 2);
|
|
3664
|
+
__decorateClass([
|
|
3665
|
+
(0, import_inversify8.inject)(WorkflowLinesManager)
|
|
3666
|
+
], WorkflowOperationBaseServiceImpl.prototype, "linesManager", 2);
|
|
3587
3667
|
|
|
3588
3668
|
// src/hooks/use-playground-readonly-state.ts
|
|
3589
3669
|
var import_react = require("react");
|