@flowuent-org/diagramming-core 1.0.7 → 1.0.8
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/package.json
CHANGED
|
@@ -379,6 +379,22 @@ With `onNodeUpdate`:
|
|
|
379
379
|
- ✅ Visual feedback as nodes execute
|
|
380
380
|
- ✅ Proper React state synchronization
|
|
381
381
|
|
|
382
|
+
**Important**: The engine creates new object references when calling `onNodeUpdate` to ensure React detects changes. Make sure your callback updates state properly:
|
|
383
|
+
|
|
384
|
+
```typescript
|
|
385
|
+
const handleNodeUpdate = (nodeId: string, updatedData: any) => {
|
|
386
|
+
setNodes((nds) =>
|
|
387
|
+
nds.map((node) => {
|
|
388
|
+
if (node.id === nodeId) {
|
|
389
|
+
// This creates a new node object with updated data
|
|
390
|
+
return { ...node, data: updatedData };
|
|
391
|
+
}
|
|
392
|
+
return node;
|
|
393
|
+
})
|
|
394
|
+
);
|
|
395
|
+
};
|
|
396
|
+
```
|
|
397
|
+
|
|
382
398
|
### Using AutomationExecutionEngine Directly
|
|
383
399
|
|
|
384
400
|
You can also use the execution engine programmatically:
|
|
@@ -93,7 +93,12 @@ export class AutomationExecutionEngine {
|
|
|
93
93
|
|
|
94
94
|
// Notify the parent component about the node update
|
|
95
95
|
if (this.onNodeUpdate) {
|
|
96
|
-
|
|
96
|
+
// Create new object reference with deep clone of formData so React detects the change
|
|
97
|
+
const updatedData = {
|
|
98
|
+
...node.data,
|
|
99
|
+
...(node.data.formData ? { formData: { ...node.data.formData } } : {}),
|
|
100
|
+
};
|
|
101
|
+
this.onNodeUpdate(nodeId, updatedData);
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
104
|
|
|
@@ -1094,22 +1099,28 @@ Execution Details:
|
|
|
1094
1099
|
|
|
1095
1100
|
// Update node status to running
|
|
1096
1101
|
(currentNode.data as Record<string, unknown>).status = 'Running';
|
|
1097
|
-
if (this.onNodeUpdate)
|
|
1098
|
-
|
|
1102
|
+
if (this.onNodeUpdate) {
|
|
1103
|
+
// Create new object reference so React detects the change
|
|
1104
|
+
this.onNodeUpdate(currentNode.id, { ...currentNode.data });
|
|
1105
|
+
}
|
|
1099
1106
|
|
|
1100
1107
|
try {
|
|
1101
1108
|
currentData = await this.executeNode(currentNode, currentData);
|
|
1102
1109
|
(currentNode.data as Record<string, unknown>).status = 'Completed';
|
|
1103
1110
|
(currentNode.data as Record<string, unknown>).lastRun =
|
|
1104
1111
|
new Date().toISOString();
|
|
1105
|
-
if (this.onNodeUpdate)
|
|
1106
|
-
|
|
1112
|
+
if (this.onNodeUpdate) {
|
|
1113
|
+
// Create new object reference so React detects the change
|
|
1114
|
+
this.onNodeUpdate(currentNode.id, { ...currentNode.data });
|
|
1115
|
+
}
|
|
1107
1116
|
} catch (error) {
|
|
1108
1117
|
(currentNode.data as Record<string, unknown>).status = 'Error';
|
|
1109
1118
|
(currentNode.data as Record<string, unknown>).lastRun =
|
|
1110
1119
|
new Date().toISOString();
|
|
1111
|
-
if (this.onNodeUpdate)
|
|
1112
|
-
|
|
1120
|
+
if (this.onNodeUpdate) {
|
|
1121
|
+
// Create new object reference so React detects the change
|
|
1122
|
+
this.onNodeUpdate(currentNode.id, { ...currentNode.data });
|
|
1123
|
+
}
|
|
1113
1124
|
throw error;
|
|
1114
1125
|
}
|
|
1115
1126
|
|