@uipath/apollo-react 4.15.0-pr605.6f11404 → 4.15.1
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/canvas/components/AddNodePanel/AddNodeManager.cjs +11 -116
- package/dist/canvas/components/AddNodePanel/AddNodeManager.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/AddNodeManager.js +12 -117
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.cjs +4 -28
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts +1 -2
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.js +4 -28
- package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts +0 -1
- package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.cjs +5 -11
- package/dist/canvas/components/BaseNode/BaseNode.d.ts +1 -2
- package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.js +6 -9
- package/dist/canvas/components/BaseNode/BaseNode.types.d.ts +0 -3
- package/dist/canvas/components/BaseNode/BaseNode.types.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/ButtonHandle.cjs +13 -222
- package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts +5 -10
- package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/ButtonHandle.js +14 -223
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.cjs +2 -10
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.d.ts +0 -2
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.js +3 -5
- package/dist/canvas/components/ButtonHandle/HandleButton.cjs +2 -17
- package/dist/canvas/components/ButtonHandle/HandleButton.d.ts +1 -10
- package/dist/canvas/components/ButtonHandle/HandleButton.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/HandleButton.js +2 -17
- package/dist/canvas/components/ButtonHandle/useButtonHandles.cjs +2 -4
- package/dist/canvas/components/ButtonHandle/useButtonHandles.d.ts +1 -2
- package/dist/canvas/components/ButtonHandle/useButtonHandles.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/useButtonHandles.js +2 -4
- package/dist/canvas/components/Edges/SequenceEdge.cjs +4 -8
- package/dist/canvas/components/Edges/SequenceEdge.js +4 -8
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.cjs +25 -34
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts +2 -8
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.js +27 -36
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.cjs +2 -9
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.js +3 -10
- package/dist/canvas/components/HierarchicalCanvas/index.d.ts +1 -1
- package/dist/canvas/components/HierarchicalCanvas/index.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNodeHeader.cjs +3 -1
- package/dist/canvas/components/StageNode/StageNodeHeader.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNodeHeader.js +3 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/EdgeToolbar.cjs +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/EdgeToolbar.js +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.cjs +24 -41
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.d.ts.map +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.js +26 -43
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.cjs +3 -10
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.d.ts +1 -1
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.d.ts.map +1 -1
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.js +3 -10
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.types.d.ts +0 -1
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.types.d.ts.map +1 -1
- package/dist/canvas/components/index.cjs +20 -27
- package/dist/canvas/components/index.d.ts +0 -1
- package/dist/canvas/components/index.d.ts.map +1 -1
- package/dist/canvas/components/index.js +0 -1
- package/dist/canvas/constants.cjs +0 -4
- package/dist/canvas/constants.d.ts +0 -1
- package/dist/canvas/constants.d.ts.map +1 -1
- package/dist/canvas/constants.js +1 -2
- package/dist/canvas/core/NodeTypeRegistry.cjs +27 -56
- package/dist/canvas/core/NodeTypeRegistry.d.ts +5 -10
- package/dist/canvas/core/NodeTypeRegistry.d.ts.map +1 -1
- package/dist/canvas/core/NodeTypeRegistry.js +28 -57
- package/dist/canvas/core/useNodeTypeRegistry.cjs +3 -13
- package/dist/canvas/core/useNodeTypeRegistry.d.ts +1 -2
- package/dist/canvas/core/useNodeTypeRegistry.d.ts.map +1 -1
- package/dist/canvas/core/useNodeTypeRegistry.js +4 -11
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.cjs +23 -22
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.d.ts.map +1 -1
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.js +24 -23
- package/dist/canvas/hooks/usePreviewNode.cjs +3 -7
- package/dist/canvas/hooks/usePreviewNode.d.ts.map +1 -1
- package/dist/canvas/hooks/usePreviewNode.js +3 -7
- package/dist/canvas/schema/node-definition/handle.cjs +2 -10
- package/dist/canvas/schema/node-definition/handle.d.ts +0 -9
- package/dist/canvas/schema/node-definition/handle.d.ts.map +1 -1
- package/dist/canvas/schema/node-definition/handle.js +1 -6
- package/dist/canvas/schema/node-definition/index.cjs +1 -4
- package/dist/canvas/schema/node-definition/index.d.ts +3 -3
- package/dist/canvas/schema/node-definition/index.d.ts.map +1 -1
- package/dist/canvas/schema/node-definition/index.js +2 -2
- package/dist/canvas/schema/node-definition/node-manifest.d.ts +0 -4
- package/dist/canvas/schema/node-definition/node-manifest.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/hooks/useCanvasStory.d.ts +0 -6
- package/dist/canvas/storybook-utils/hooks/useCanvasStory.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/manifests/index.d.ts +0 -1
- package/dist/canvas/storybook-utils/manifests/index.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/manifests/node-definitions.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/mocks/nodes.d.ts +1 -1
- package/dist/canvas/storybook-utils/mocks/nodes.d.ts.map +1 -1
- package/dist/canvas/styles/reactflow-reset.css +2 -2
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/canvas/utils/NodeUtils.cjs +9 -25
- package/dist/canvas/utils/NodeUtils.d.ts +0 -7
- package/dist/canvas/utils/NodeUtils.d.ts.map +1 -1
- package/dist/canvas/utils/NodeUtils.js +6 -13
- package/dist/canvas/utils/collapse.cjs +6 -13
- package/dist/canvas/utils/collapse.d.ts +2 -2
- package/dist/canvas/utils/collapse.d.ts.map +1 -1
- package/dist/canvas/utils/collapse.js +2 -9
- package/dist/canvas/utils/createPreviewNode.cjs +12 -59
- package/dist/canvas/utils/createPreviewNode.d.ts +2 -10
- package/dist/canvas/utils/createPreviewNode.d.ts.map +1 -1
- package/dist/canvas/utils/createPreviewNode.js +12 -50
- package/dist/canvas/utils/index.cjs +26 -47
- package/dist/canvas/utils/index.d.ts +1 -4
- package/dist/canvas/utils/index.d.ts.map +1 -1
- package/dist/canvas/utils/index.js +1 -4
- package/dist/canvas/utils/manifest-resolver.cjs +0 -8
- package/dist/canvas/utils/manifest-resolver.d.ts +0 -1
- package/dist/canvas/utils/manifest-resolver.d.ts.map +1 -1
- package/dist/canvas/utils/manifest-resolver.js +1 -6
- package/package.json +1 -1
- package/dist/canvas/components/LoopNode/LoopCanvasNode.cjs +0 -86
- package/dist/canvas/components/LoopNode/LoopCanvasNode.d.ts +0 -6
- package/dist/canvas/components/LoopNode/LoopCanvasNode.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopCanvasNode.js +0 -52
- package/dist/canvas/components/LoopNode/LoopNode.cjs +0 -434
- package/dist/canvas/components/LoopNode/LoopNode.constants.cjs +0 -93
- package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts +0 -16
- package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopNode.constants.js +0 -17
- package/dist/canvas/components/LoopNode/LoopNode.d.ts +0 -5
- package/dist/canvas/components/LoopNode/LoopNode.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopNode.helpers.cjs +0 -185
- package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts +0 -58
- package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopNode.helpers.js +0 -124
- package/dist/canvas/components/LoopNode/LoopNode.js +0 -400
- package/dist/canvas/components/LoopNode/LoopNode.sequence.cjs +0 -433
- package/dist/canvas/components/LoopNode/LoopNode.sequence.d.ts +0 -57
- package/dist/canvas/components/LoopNode/LoopNode.sequence.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopNode.sequence.js +0 -387
- package/dist/canvas/components/LoopNode/LoopNode.types.cjs +0 -18
- package/dist/canvas/components/LoopNode/LoopNode.types.d.ts +0 -22
- package/dist/canvas/components/LoopNode/LoopNode.types.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopNode.types.js +0 -0
- package/dist/canvas/components/LoopNode/LoopNodePreview.cjs +0 -60
- package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts +0 -9
- package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopNodePreview.js +0 -26
- package/dist/canvas/components/LoopNode/index.cjs +0 -79
- package/dist/canvas/components/LoopNode/index.d.ts +0 -5
- package/dist/canvas/components/LoopNode/index.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/index.js +0 -4
- package/dist/canvas/components/NodeViewportOverlay.cjs +0 -63
- package/dist/canvas/components/NodeViewportOverlay.d.ts +0 -22
- package/dist/canvas/components/NodeViewportOverlay.d.ts.map +0 -1
- package/dist/canvas/components/NodeViewportOverlay.js +0 -29
- package/dist/canvas/utils/container-sizing.cjs +0 -169
- package/dist/canvas/utils/container-sizing.d.ts +0 -23
- package/dist/canvas/utils/container-sizing.d.ts.map +0 -1
- package/dist/canvas/utils/container-sizing.js +0 -132
- package/dist/canvas/utils/createPreviewGraph.cjs +0 -126
- package/dist/canvas/utils/createPreviewGraph.d.ts +0 -37
- package/dist/canvas/utils/createPreviewGraph.d.ts.map +0 -1
- package/dist/canvas/utils/createPreviewGraph.js +0 -83
- package/dist/canvas/utils/preview-connection-handles.cjs +0 -55
- package/dist/canvas/utils/preview-connection-handles.d.ts +0 -14
- package/dist/canvas/utils/preview-connection-handles.d.ts.map +0 -1
- package/dist/canvas/utils/preview-connection-handles.js +0 -15
|
@@ -32,32 +32,12 @@ const external_CategoryTreeAdapter_cjs_namespaceObject = require("./CategoryTree
|
|
|
32
32
|
class NodeTypeRegistry {
|
|
33
33
|
categoryById = new Map();
|
|
34
34
|
nodeByType = new Map();
|
|
35
|
-
|
|
36
|
-
nodeHandlesByTypeVersion = new Map();
|
|
35
|
+
nodeHandles = new Map();
|
|
37
36
|
categoriesByParent = new Map();
|
|
38
37
|
nodesByCategory = new Map();
|
|
39
38
|
categoryAncestors = new Map();
|
|
40
39
|
categoryDescendants = new Map();
|
|
41
40
|
categoryTree = null;
|
|
42
|
-
getNodeHandles(manifest) {
|
|
43
|
-
if (!manifest) return {};
|
|
44
|
-
const manifestKey = this.getTypeVersionKey(manifest.nodeType, manifest.version);
|
|
45
|
-
const cachedHandles = this.nodeHandlesByTypeVersion.get(manifestKey);
|
|
46
|
-
if (cachedHandles) return cachedHandles;
|
|
47
|
-
return this.computeNodeHandles(manifest);
|
|
48
|
-
}
|
|
49
|
-
computeNodeHandles(manifest) {
|
|
50
|
-
const handlesByType = {};
|
|
51
|
-
for (const group of manifest.handleConfiguration)for (const handle of group.handles){
|
|
52
|
-
const handles = handlesByType[handle.type] ?? [];
|
|
53
|
-
handles.push(handle);
|
|
54
|
-
handlesByType[handle.type] = handles;
|
|
55
|
-
}
|
|
56
|
-
return handlesByType;
|
|
57
|
-
}
|
|
58
|
-
getTypeVersionKey(nodeType, version) {
|
|
59
|
-
return `${nodeType}:${version}`;
|
|
60
|
-
}
|
|
61
41
|
registerNodeManifests(nodes) {
|
|
62
42
|
const categoryMap = new Map();
|
|
63
43
|
for (const node of nodes){
|
|
@@ -79,16 +59,18 @@ class NodeTypeRegistry {
|
|
|
79
59
|
c.id,
|
|
80
60
|
c
|
|
81
61
|
]));
|
|
82
|
-
this.nodeByType = new Map()
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
62
|
+
this.nodeByType = new Map(nodeManifests.map((n)=>[
|
|
63
|
+
n.nodeType,
|
|
64
|
+
n
|
|
65
|
+
]));
|
|
66
|
+
this.nodeHandles = new Map(nodeManifests.map((n)=>[
|
|
67
|
+
n.nodeType,
|
|
68
|
+
n.handleConfiguration.flatMap((hc)=>hc.handles).reduce((acc, handle)=>{
|
|
69
|
+
if (!acc[handle.type]) acc[handle.type] = [];
|
|
70
|
+
acc[handle.type]?.push(handle);
|
|
71
|
+
return acc;
|
|
72
|
+
}, {})
|
|
73
|
+
]));
|
|
92
74
|
this.categoriesByParent = new Map();
|
|
93
75
|
for (const cat of categoryManifests){
|
|
94
76
|
const siblings = this.categoriesByParent.get(cat.parentId) ?? [];
|
|
@@ -122,22 +104,18 @@ class NodeTypeRegistry {
|
|
|
122
104
|
this.categoryDescendants.set(cat.id, descendants);
|
|
123
105
|
}
|
|
124
106
|
this.nodesByCategory = new Map();
|
|
125
|
-
for (const node of
|
|
107
|
+
for (const node of nodeManifests){
|
|
126
108
|
const categoryKey = node.category ?? void 0;
|
|
127
109
|
const nodes = this.nodesByCategory.get(categoryKey) ?? [];
|
|
128
110
|
nodes.push(node);
|
|
129
111
|
this.nodesByCategory.set(categoryKey, nodes);
|
|
130
112
|
}
|
|
131
|
-
this.categoryTree = new external_CategoryTree_cjs_namespaceObject.CategoryTree(categoryManifests,
|
|
113
|
+
this.categoryTree = new external_CategoryTree_cjs_namespaceObject.CategoryTree(categoryManifests, nodeManifests);
|
|
132
114
|
}
|
|
133
|
-
getManifest(nodeType
|
|
134
|
-
|
|
135
|
-
return this.nodeByTypeVersion.get(this.getTypeVersionKey(nodeType, version));
|
|
115
|
+
getManifest(nodeType) {
|
|
116
|
+
return this.nodeByType.get(nodeType);
|
|
136
117
|
}
|
|
137
118
|
getAllManifests() {
|
|
138
|
-
return Array.from(this.nodeByTypeVersion.values());
|
|
139
|
-
}
|
|
140
|
-
getDefaultManifests() {
|
|
141
119
|
return Array.from(this.nodeByType.values());
|
|
142
120
|
}
|
|
143
121
|
getAllCategories() {
|
|
@@ -146,19 +124,18 @@ class NodeTypeRegistry {
|
|
|
146
124
|
getAllNodeTypes() {
|
|
147
125
|
return Array.from(this.nodeByType.keys());
|
|
148
126
|
}
|
|
149
|
-
getHandlesByNodeType(nodeType
|
|
150
|
-
|
|
151
|
-
return this.getNodeHandles(manifest);
|
|
127
|
+
getHandlesByNodeType(nodeType) {
|
|
128
|
+
return this.nodeHandles.get(nodeType) ?? {};
|
|
152
129
|
}
|
|
153
|
-
getDefaultHandle(nodeType, handleType
|
|
154
|
-
const handles = this.
|
|
130
|
+
getDefaultHandle(nodeType, handleType) {
|
|
131
|
+
const handles = this.nodeHandles.get(nodeType)?.[handleType];
|
|
155
132
|
return handles?.find((h)=>h.isDefaultForType) ?? handles?.[0];
|
|
156
133
|
}
|
|
157
|
-
createDefaultData(nodeType, label
|
|
158
|
-
const manifest = this.getManifest(nodeType
|
|
134
|
+
createDefaultData(nodeType, label) {
|
|
135
|
+
const manifest = this.getManifest(nodeType);
|
|
159
136
|
if (!manifest) return {
|
|
160
137
|
nodeType,
|
|
161
|
-
|
|
138
|
+
version: '1.0.0',
|
|
162
139
|
display: {
|
|
163
140
|
label: label || nodeType
|
|
164
141
|
}
|
|
@@ -174,7 +151,7 @@ class NodeTypeRegistry {
|
|
|
174
151
|
};
|
|
175
152
|
return {
|
|
176
153
|
nodeType,
|
|
177
|
-
|
|
154
|
+
version: manifest.version,
|
|
178
155
|
parameters: manifest.defaultProperties ?? {},
|
|
179
156
|
display: display
|
|
180
157
|
};
|
|
@@ -184,9 +161,8 @@ class NodeTypeRegistry {
|
|
|
184
161
|
}
|
|
185
162
|
clear() {
|
|
186
163
|
this.nodesByCategory.clear();
|
|
164
|
+
this.nodeHandles.clear();
|
|
187
165
|
this.nodeByType.clear();
|
|
188
|
-
this.nodeByTypeVersion.clear();
|
|
189
|
-
this.nodeHandlesByTypeVersion.clear();
|
|
190
166
|
this.categoryById.clear();
|
|
191
167
|
this.categoryAncestors.clear();
|
|
192
168
|
this.categoryDescendants.clear();
|
|
@@ -225,12 +201,7 @@ class NodeTypeRegistry {
|
|
|
225
201
|
type: nodeItemManifest.nodeType,
|
|
226
202
|
category: nodeItemManifest.category
|
|
227
203
|
};
|
|
228
|
-
const defaultNodeItemHandle = (
|
|
229
|
-
manifest: nodeItemManifest,
|
|
230
|
-
connection,
|
|
231
|
-
connections: previewNodeConnectionInfo,
|
|
232
|
-
getDefaultHandle: (handleType)=>this.getDefaultHandle(nodeType, handleType)
|
|
233
|
-
});
|
|
204
|
+
const defaultNodeItemHandle = this.getDefaultHandle(nodeType, connection.addNewNodeAsSource ? 'source' : 'target');
|
|
234
205
|
if (!defaultNodeItemHandle) return false;
|
|
235
206
|
const connectionValidationData = connection.addNewNodeAsSource ? {
|
|
236
207
|
sourceNode: nodeToValidateData,
|
|
@@ -9,26 +9,21 @@ interface NodeHandles {
|
|
|
9
9
|
export declare class NodeTypeRegistry {
|
|
10
10
|
private categoryById;
|
|
11
11
|
private nodeByType;
|
|
12
|
-
private
|
|
13
|
-
private nodeHandlesByTypeVersion;
|
|
12
|
+
private nodeHandles;
|
|
14
13
|
private categoriesByParent;
|
|
15
14
|
private nodesByCategory;
|
|
16
15
|
private categoryAncestors;
|
|
17
16
|
private categoryDescendants;
|
|
18
17
|
private categoryTree;
|
|
19
|
-
private getNodeHandles;
|
|
20
|
-
private computeNodeHandles;
|
|
21
|
-
private getTypeVersionKey;
|
|
22
18
|
registerNodeManifests(nodes: NodeManifest[]): void;
|
|
23
19
|
registerManifest(nodeManifests: NodeManifest[], categoryManifests: CategoryManifest[]): void;
|
|
24
|
-
getManifest(nodeType: string
|
|
20
|
+
getManifest(nodeType: string): NodeManifest | undefined;
|
|
25
21
|
getAllManifests(): NodeManifest[];
|
|
26
|
-
getDefaultManifests(): NodeManifest[];
|
|
27
22
|
getAllCategories(): string[];
|
|
28
23
|
getAllNodeTypes(): string[];
|
|
29
|
-
getHandlesByNodeType(nodeType: string
|
|
30
|
-
getDefaultHandle(nodeType: string, handleType: 'source' | 'target'
|
|
31
|
-
createDefaultData(nodeType: string, label?: string
|
|
24
|
+
getHandlesByNodeType(nodeType: string): NodeHandles;
|
|
25
|
+
getDefaultHandle(nodeType: string, handleType: 'source' | 'target'): HandleManifest | undefined;
|
|
26
|
+
createDefaultData(nodeType: string, label?: string): BaseNodeData;
|
|
32
27
|
getCategoryTree(): CategoryTree | null;
|
|
33
28
|
clear(): void;
|
|
34
29
|
isValidCategoryForConnection(categoryId: string, previewNodeConnectionInfo: PreviewNodeConnectionInfo[] | null | undefined): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTypeRegistry.d.ts","sourceRoot":"","sources":["../../../src/canvas/core/NodeTypeRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"NodeTypeRegistry.d.ts","sourceRoot":"","sources":["../../../src/canvas/core/NodeTypeRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAMhG,OAAO,EAAE,YAAY,EAA4B,MAAM,gBAAgB,CAAC;AAGxE,UAAU,WAAW;IACnB,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;CAC3B;AAMD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,YAAY,CAAuC;IAC3D,OAAO,CAAC,UAAU,CAAmC;IACrD,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,kBAAkB,CAAqD;IAC/E,OAAO,CAAC,eAAe,CAAiD;IACxE,OAAO,CAAC,iBAAiB,CAA+B;IACxD,OAAO,CAAC,mBAAmB,CAA+B;IAC1D,OAAO,CAAC,YAAY,CAA6B;IAUjD,qBAAqB,CAAC,KAAK,EAAE,YAAY,EAAE;IA8B3C,gBAAgB,CAAC,aAAa,EAAE,YAAY,EAAE,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;IA0ErF,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAQvD,eAAe,IAAI,YAAY,EAAE;IAQjC,gBAAgB,IAAI,MAAM,EAAE;IAQ5B,eAAe,IAAI,MAAM,EAAE;IAO3B,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW;IAOnD,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,GAAG,QAAQ,GAAG,cAAc,GAAG,SAAS;IAW/F,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,YAAY;IAqCjE,eAAe,IAAI,YAAY,GAAG,IAAI;IAOtC,KAAK,IAAI,IAAI;IAwBb,4BAA4B,CAC1B,UAAU,EAAE,MAAM,EAClB,yBAAyB,EAAE,yBAAyB,EAAE,GAAG,IAAI,GAAG,SAAS,GACxE,OAAO;IA6CV,wBAAwB,CACtB,QAAQ,EAAE,MAAM,EAChB,yBAAyB,EAAE,yBAAyB,EAAE,GAAG,IAAI,GAAG,SAAS;IAgE3E,OAAO,CAAC,yBAAyB;IAqCjC,cAAc,CAAC,OAAO,EAAE;QACtB,WAAW,CAAC,EAAE,yBAAyB,EAAE,GAAG,IAAI,CAAC;QACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;KAC7B,GAAG,QAAQ,EAAE;CAyCf"}
|
|
@@ -1,35 +1,15 @@
|
|
|
1
|
-
import { checkCategoryConstraint,
|
|
1
|
+
import { checkCategoryConstraint, validateConnection } from "../utils/index.js";
|
|
2
2
|
import { CategoryTree } from "./CategoryTree.js";
|
|
3
3
|
import { CategoryTreeAdapter } from "./CategoryTreeAdapter.js";
|
|
4
4
|
class NodeTypeRegistry {
|
|
5
5
|
categoryById = new Map();
|
|
6
6
|
nodeByType = new Map();
|
|
7
|
-
|
|
8
|
-
nodeHandlesByTypeVersion = new Map();
|
|
7
|
+
nodeHandles = new Map();
|
|
9
8
|
categoriesByParent = new Map();
|
|
10
9
|
nodesByCategory = new Map();
|
|
11
10
|
categoryAncestors = new Map();
|
|
12
11
|
categoryDescendants = new Map();
|
|
13
12
|
categoryTree = null;
|
|
14
|
-
getNodeHandles(manifest) {
|
|
15
|
-
if (!manifest) return {};
|
|
16
|
-
const manifestKey = this.getTypeVersionKey(manifest.nodeType, manifest.version);
|
|
17
|
-
const cachedHandles = this.nodeHandlesByTypeVersion.get(manifestKey);
|
|
18
|
-
if (cachedHandles) return cachedHandles;
|
|
19
|
-
return this.computeNodeHandles(manifest);
|
|
20
|
-
}
|
|
21
|
-
computeNodeHandles(manifest) {
|
|
22
|
-
const handlesByType = {};
|
|
23
|
-
for (const group of manifest.handleConfiguration)for (const handle of group.handles){
|
|
24
|
-
const handles = handlesByType[handle.type] ?? [];
|
|
25
|
-
handles.push(handle);
|
|
26
|
-
handlesByType[handle.type] = handles;
|
|
27
|
-
}
|
|
28
|
-
return handlesByType;
|
|
29
|
-
}
|
|
30
|
-
getTypeVersionKey(nodeType, version) {
|
|
31
|
-
return `${nodeType}:${version}`;
|
|
32
|
-
}
|
|
33
13
|
registerNodeManifests(nodes) {
|
|
34
14
|
const categoryMap = new Map();
|
|
35
15
|
for (const node of nodes){
|
|
@@ -51,16 +31,18 @@ class NodeTypeRegistry {
|
|
|
51
31
|
c.id,
|
|
52
32
|
c
|
|
53
33
|
]));
|
|
54
|
-
this.nodeByType = new Map()
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
34
|
+
this.nodeByType = new Map(nodeManifests.map((n)=>[
|
|
35
|
+
n.nodeType,
|
|
36
|
+
n
|
|
37
|
+
]));
|
|
38
|
+
this.nodeHandles = new Map(nodeManifests.map((n)=>[
|
|
39
|
+
n.nodeType,
|
|
40
|
+
n.handleConfiguration.flatMap((hc)=>hc.handles).reduce((acc, handle)=>{
|
|
41
|
+
if (!acc[handle.type]) acc[handle.type] = [];
|
|
42
|
+
acc[handle.type]?.push(handle);
|
|
43
|
+
return acc;
|
|
44
|
+
}, {})
|
|
45
|
+
]));
|
|
64
46
|
this.categoriesByParent = new Map();
|
|
65
47
|
for (const cat of categoryManifests){
|
|
66
48
|
const siblings = this.categoriesByParent.get(cat.parentId) ?? [];
|
|
@@ -94,22 +76,18 @@ class NodeTypeRegistry {
|
|
|
94
76
|
this.categoryDescendants.set(cat.id, descendants);
|
|
95
77
|
}
|
|
96
78
|
this.nodesByCategory = new Map();
|
|
97
|
-
for (const node of
|
|
79
|
+
for (const node of nodeManifests){
|
|
98
80
|
const categoryKey = node.category ?? void 0;
|
|
99
81
|
const nodes = this.nodesByCategory.get(categoryKey) ?? [];
|
|
100
82
|
nodes.push(node);
|
|
101
83
|
this.nodesByCategory.set(categoryKey, nodes);
|
|
102
84
|
}
|
|
103
|
-
this.categoryTree = new CategoryTree(categoryManifests,
|
|
85
|
+
this.categoryTree = new CategoryTree(categoryManifests, nodeManifests);
|
|
104
86
|
}
|
|
105
|
-
getManifest(nodeType
|
|
106
|
-
|
|
107
|
-
return this.nodeByTypeVersion.get(this.getTypeVersionKey(nodeType, version));
|
|
87
|
+
getManifest(nodeType) {
|
|
88
|
+
return this.nodeByType.get(nodeType);
|
|
108
89
|
}
|
|
109
90
|
getAllManifests() {
|
|
110
|
-
return Array.from(this.nodeByTypeVersion.values());
|
|
111
|
-
}
|
|
112
|
-
getDefaultManifests() {
|
|
113
91
|
return Array.from(this.nodeByType.values());
|
|
114
92
|
}
|
|
115
93
|
getAllCategories() {
|
|
@@ -118,19 +96,18 @@ class NodeTypeRegistry {
|
|
|
118
96
|
getAllNodeTypes() {
|
|
119
97
|
return Array.from(this.nodeByType.keys());
|
|
120
98
|
}
|
|
121
|
-
getHandlesByNodeType(nodeType
|
|
122
|
-
|
|
123
|
-
return this.getNodeHandles(manifest);
|
|
99
|
+
getHandlesByNodeType(nodeType) {
|
|
100
|
+
return this.nodeHandles.get(nodeType) ?? {};
|
|
124
101
|
}
|
|
125
|
-
getDefaultHandle(nodeType, handleType
|
|
126
|
-
const handles = this.
|
|
102
|
+
getDefaultHandle(nodeType, handleType) {
|
|
103
|
+
const handles = this.nodeHandles.get(nodeType)?.[handleType];
|
|
127
104
|
return handles?.find((h)=>h.isDefaultForType) ?? handles?.[0];
|
|
128
105
|
}
|
|
129
|
-
createDefaultData(nodeType, label
|
|
130
|
-
const manifest = this.getManifest(nodeType
|
|
106
|
+
createDefaultData(nodeType, label) {
|
|
107
|
+
const manifest = this.getManifest(nodeType);
|
|
131
108
|
if (!manifest) return {
|
|
132
109
|
nodeType,
|
|
133
|
-
|
|
110
|
+
version: '1.0.0',
|
|
134
111
|
display: {
|
|
135
112
|
label: label || nodeType
|
|
136
113
|
}
|
|
@@ -146,7 +123,7 @@ class NodeTypeRegistry {
|
|
|
146
123
|
};
|
|
147
124
|
return {
|
|
148
125
|
nodeType,
|
|
149
|
-
|
|
126
|
+
version: manifest.version,
|
|
150
127
|
parameters: manifest.defaultProperties ?? {},
|
|
151
128
|
display: display
|
|
152
129
|
};
|
|
@@ -156,9 +133,8 @@ class NodeTypeRegistry {
|
|
|
156
133
|
}
|
|
157
134
|
clear() {
|
|
158
135
|
this.nodesByCategory.clear();
|
|
136
|
+
this.nodeHandles.clear();
|
|
159
137
|
this.nodeByType.clear();
|
|
160
|
-
this.nodeByTypeVersion.clear();
|
|
161
|
-
this.nodeHandlesByTypeVersion.clear();
|
|
162
138
|
this.categoryById.clear();
|
|
163
139
|
this.categoryAncestors.clear();
|
|
164
140
|
this.categoryDescendants.clear();
|
|
@@ -197,12 +173,7 @@ class NodeTypeRegistry {
|
|
|
197
173
|
type: nodeItemManifest.nodeType,
|
|
198
174
|
category: nodeItemManifest.category
|
|
199
175
|
};
|
|
200
|
-
const defaultNodeItemHandle =
|
|
201
|
-
manifest: nodeItemManifest,
|
|
202
|
-
connection,
|
|
203
|
-
connections: previewNodeConnectionInfo,
|
|
204
|
-
getDefaultHandle: (handleType)=>this.getDefaultHandle(nodeType, handleType)
|
|
205
|
-
});
|
|
176
|
+
const defaultNodeItemHandle = this.getDefaultHandle(nodeType, connection.addNewNodeAsSource ? 'source' : 'target');
|
|
206
177
|
if (!defaultNodeItemHandle) return false;
|
|
207
178
|
const connectionValidationData = connection.addNewNodeAsSource ? {
|
|
208
179
|
sourceNode: nodeToValidateData,
|
|
@@ -24,7 +24,6 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
useDefaultNodeManifests: ()=>useDefaultNodeManifests,
|
|
28
27
|
useNodeManifests: ()=>useNodeManifests,
|
|
29
28
|
useOptionalNodeTypeRegistry: ()=>useOptionalNodeTypeRegistry,
|
|
30
29
|
useNodeManifest: ()=>useNodeManifest,
|
|
@@ -48,29 +47,20 @@ const useNodeManifests = ()=>{
|
|
|
48
47
|
registry
|
|
49
48
|
]);
|
|
50
49
|
};
|
|
51
|
-
const
|
|
50
|
+
const useNodeManifest = (nodeType)=>{
|
|
52
51
|
const registry = useNodeTypeRegistry();
|
|
53
|
-
return (0, external_react_namespaceObject.useMemo)(()=>registry.
|
|
54
|
-
registry
|
|
55
|
-
]);
|
|
56
|
-
};
|
|
57
|
-
const useNodeManifest = (nodeType, version)=>{
|
|
58
|
-
const registry = useNodeTypeRegistry();
|
|
59
|
-
return (0, external_react_namespaceObject.useMemo)(()=>registry.getManifest(nodeType, version), [
|
|
52
|
+
return (0, external_react_namespaceObject.useMemo)(()=>registry.getManifest(nodeType), [
|
|
60
53
|
registry,
|
|
61
|
-
nodeType
|
|
62
|
-
version
|
|
54
|
+
nodeType
|
|
63
55
|
]);
|
|
64
56
|
};
|
|
65
57
|
exports.NodeRegistryContext = __webpack_exports__.NodeRegistryContext;
|
|
66
|
-
exports.useDefaultNodeManifests = __webpack_exports__.useDefaultNodeManifests;
|
|
67
58
|
exports.useNodeManifest = __webpack_exports__.useNodeManifest;
|
|
68
59
|
exports.useNodeManifests = __webpack_exports__.useNodeManifests;
|
|
69
60
|
exports.useNodeTypeRegistry = __webpack_exports__.useNodeTypeRegistry;
|
|
70
61
|
exports.useOptionalNodeTypeRegistry = __webpack_exports__.useOptionalNodeTypeRegistry;
|
|
71
62
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
72
63
|
"NodeRegistryContext",
|
|
73
|
-
"useDefaultNodeManifests",
|
|
74
64
|
"useNodeManifest",
|
|
75
65
|
"useNodeManifests",
|
|
76
66
|
"useNodeTypeRegistry",
|
|
@@ -7,7 +7,6 @@ export declare const NodeRegistryContext: import("react").Context<NodeRegistryCo
|
|
|
7
7
|
export declare const useNodeTypeRegistry: () => NodeTypeRegistry;
|
|
8
8
|
export declare const useOptionalNodeTypeRegistry: () => NodeTypeRegistry | null;
|
|
9
9
|
export declare const useNodeManifests: () => NodeManifest[];
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const useNodeManifest: (nodeType: string, version?: string) => NodeManifest | undefined;
|
|
10
|
+
export declare const useNodeManifest: (nodeType: string) => NodeManifest | undefined;
|
|
12
11
|
export {};
|
|
13
12
|
//# sourceMappingURL=useNodeTypeRegistry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNodeTypeRegistry.d.ts","sourceRoot":"","sources":["../../../src/canvas/core/useNodeTypeRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,UAAU,wBAAwB;IAChC,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAED,eAAO,MAAM,mBAAmB,0DAAuD,CAAC;AAOxF,eAAO,MAAM,mBAAmB,QAAO,gBAMtC,CAAC;AAMF,eAAO,MAAM,2BAA2B,QAAO,gBAAgB,GAAG,IAGjE,CAAC;AAMF,eAAO,MAAM,gBAAgB,QAAO,YAAY,EAG/C,CAAC;AAOF,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"useNodeTypeRegistry.d.ts","sourceRoot":"","sources":["../../../src/canvas/core/useNodeTypeRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,UAAU,wBAAwB;IAChC,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAED,eAAO,MAAM,mBAAmB,0DAAuD,CAAC;AAOxF,eAAO,MAAM,mBAAmB,QAAO,gBAMtC,CAAC;AAMF,eAAO,MAAM,2BAA2B,QAAO,gBAAgB,GAAG,IAGjE,CAAC;AAMF,eAAO,MAAM,gBAAgB,QAAO,YAAY,EAG/C,CAAC;AAOF,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,KAAG,YAAY,GAAG,SAGjE,CAAC"}
|
|
@@ -15,18 +15,11 @@ const useNodeManifests = ()=>{
|
|
|
15
15
|
registry
|
|
16
16
|
]);
|
|
17
17
|
};
|
|
18
|
-
const
|
|
18
|
+
const useNodeManifest = (nodeType)=>{
|
|
19
19
|
const registry = useNodeTypeRegistry();
|
|
20
|
-
return useMemo(()=>registry.
|
|
21
|
-
registry
|
|
22
|
-
]);
|
|
23
|
-
};
|
|
24
|
-
const useNodeManifest = (nodeType, version)=>{
|
|
25
|
-
const registry = useNodeTypeRegistry();
|
|
26
|
-
return useMemo(()=>registry.getManifest(nodeType, version), [
|
|
20
|
+
return useMemo(()=>registry.getManifest(nodeType), [
|
|
27
21
|
registry,
|
|
28
|
-
nodeType
|
|
29
|
-
version
|
|
22
|
+
nodeType
|
|
30
23
|
]);
|
|
31
24
|
};
|
|
32
|
-
export { NodeRegistryContext,
|
|
25
|
+
export { NodeRegistryContext, useNodeManifest, useNodeManifests, useNodeTypeRegistry, useOptionalNodeTypeRegistry };
|
|
@@ -30,33 +30,34 @@ const react_cjs_namespaceObject = require("../xyflow/react.cjs");
|
|
|
30
30
|
const external_react_namespaceObject = require("react");
|
|
31
31
|
const index_cjs_namespaceObject = require("../utils/index.cjs");
|
|
32
32
|
const EMPTY_IGNORED_NODE_TYPES = [];
|
|
33
|
-
function getClientPosition(event) {
|
|
34
|
-
if ('clientX' in event) return {
|
|
35
|
-
x: event.clientX,
|
|
36
|
-
y: event.clientY
|
|
37
|
-
};
|
|
38
|
-
const touch = event.changedTouches?.[0] ?? event.touches?.[0];
|
|
39
|
-
return touch ? {
|
|
40
|
-
x: touch.clientX,
|
|
41
|
-
y: touch.clientY
|
|
42
|
-
} : null;
|
|
43
|
-
}
|
|
44
33
|
function useAddNodeOnConnectEnd(ignoredNodeTypes = EMPTY_IGNORED_NODE_TYPES) {
|
|
45
34
|
const reactFlowInstance = (0, react_cjs_namespaceObject.useReactFlow)();
|
|
46
35
|
return (0, external_react_namespaceObject.useCallback)((event, connectionState)=>{
|
|
47
36
|
if (!(reactFlowInstance && connectionState.fromNode && connectionState.fromHandle) || connectionState.toHandle) return;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
37
|
+
let clientX;
|
|
38
|
+
let clientY;
|
|
39
|
+
if ('clientX' in event) {
|
|
40
|
+
clientX = event.clientX;
|
|
41
|
+
clientY = event.clientY;
|
|
42
|
+
} else {
|
|
43
|
+
const touchEvent = event;
|
|
44
|
+
if (touchEvent.changedTouches?.[0]) {
|
|
45
|
+
const touch = touchEvent.changedTouches[0];
|
|
46
|
+
clientX = touch.clientX;
|
|
47
|
+
clientY = touch.clientY;
|
|
48
|
+
} else {
|
|
49
|
+
if (!touchEvent.touches?.[0]) return;
|
|
50
|
+
const touch = touchEvent.touches[0];
|
|
51
|
+
clientX = touch.clientX;
|
|
52
|
+
clientY = touch.clientY;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const flowDropPosition = reactFlowInstance.screenToFlowPosition({
|
|
56
|
+
x: clientX,
|
|
57
|
+
y: clientY
|
|
59
58
|
});
|
|
59
|
+
const preview = (0, index_cjs_namespaceObject.createPreviewNode)(connectionState.fromNode.id, connectionState.fromHandle.id ?? 'output', reactFlowInstance, flowDropPosition, void 0, connectionState.fromHandle.type, void 0, connectionState.fromHandle.position, ignoredNodeTypes);
|
|
60
|
+
if (preview) (0, index_cjs_namespaceObject.applyPreviewToReactFlow)(preview, reactFlowInstance);
|
|
60
61
|
}, [
|
|
61
62
|
reactFlowInstance,
|
|
62
63
|
ignoredNodeTypes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAddNodeOnConnectEnd.d.ts","sourceRoot":"","sources":["../../../src/canvas/hooks/useAddNodeOnConnectEnd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"useAddNodeOnConnectEnd.d.ts","sourceRoot":"","sources":["../../../src/canvas/hooks/useAddNodeOnConnectEnd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,0CAA0C,CAAC;AAW3F,wBAAgB,sBAAsB,CAAC,gBAAgB,GAAE,MAAM,EAA6B,gBAyD3F"}
|
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
import { useReactFlow } from "../xyflow/react.js";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { applyPreviewToReactFlow, createPreviewNode } from "../utils/index.js";
|
|
4
4
|
const EMPTY_IGNORED_NODE_TYPES = [];
|
|
5
|
-
function getClientPosition(event) {
|
|
6
|
-
if ('clientX' in event) return {
|
|
7
|
-
x: event.clientX,
|
|
8
|
-
y: event.clientY
|
|
9
|
-
};
|
|
10
|
-
const touch = event.changedTouches?.[0] ?? event.touches?.[0];
|
|
11
|
-
return touch ? {
|
|
12
|
-
x: touch.clientX,
|
|
13
|
-
y: touch.clientY
|
|
14
|
-
} : null;
|
|
15
|
-
}
|
|
16
5
|
function useAddNodeOnConnectEnd(ignoredNodeTypes = EMPTY_IGNORED_NODE_TYPES) {
|
|
17
6
|
const reactFlowInstance = useReactFlow();
|
|
18
7
|
return useCallback((event, connectionState)=>{
|
|
19
8
|
if (!(reactFlowInstance && connectionState.fromNode && connectionState.fromHandle) || connectionState.toHandle) return;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
9
|
+
let clientX;
|
|
10
|
+
let clientY;
|
|
11
|
+
if ('clientX' in event) {
|
|
12
|
+
clientX = event.clientX;
|
|
13
|
+
clientY = event.clientY;
|
|
14
|
+
} else {
|
|
15
|
+
const touchEvent = event;
|
|
16
|
+
if (touchEvent.changedTouches?.[0]) {
|
|
17
|
+
const touch = touchEvent.changedTouches[0];
|
|
18
|
+
clientX = touch.clientX;
|
|
19
|
+
clientY = touch.clientY;
|
|
20
|
+
} else {
|
|
21
|
+
if (!touchEvent.touches?.[0]) return;
|
|
22
|
+
const touch = touchEvent.touches[0];
|
|
23
|
+
clientX = touch.clientX;
|
|
24
|
+
clientY = touch.clientY;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const flowDropPosition = reactFlowInstance.screenToFlowPosition({
|
|
28
|
+
x: clientX,
|
|
29
|
+
y: clientY
|
|
31
30
|
});
|
|
31
|
+
const preview = createPreviewNode(connectionState.fromNode.id, connectionState.fromHandle.id ?? 'output', reactFlowInstance, flowDropPosition, void 0, connectionState.fromHandle.type, void 0, connectionState.fromHandle.position, ignoredNodeTypes);
|
|
32
|
+
if (preview) applyPreviewToReactFlow(preview, reactFlowInstance);
|
|
32
33
|
}, [
|
|
33
34
|
reactFlowInstance,
|
|
34
35
|
ignoredNodeTypes
|
|
@@ -31,13 +31,11 @@ const external_react_namespaceObject = require("react");
|
|
|
31
31
|
const shallow_namespaceObject = require("zustand/shallow");
|
|
32
32
|
const external_constants_cjs_namespaceObject = require("../constants.cjs");
|
|
33
33
|
const index_cjs_namespaceObject = require("../core/index.cjs");
|
|
34
|
-
const createPreviewNode_cjs_namespaceObject = require("../utils/createPreviewNode.cjs");
|
|
35
|
-
const manifest_resolver_cjs_namespaceObject = require("../utils/manifest-resolver.cjs");
|
|
36
34
|
const previewNodeSelectedSelector = (state)=>{
|
|
37
35
|
const node = state.nodes.find((n)=>n.id === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID);
|
|
38
36
|
return node?.selected ?? false;
|
|
39
37
|
};
|
|
40
|
-
const edgesConnectedToPreviewSelector = (state)=>state.edges.filter(
|
|
38
|
+
const edgesConnectedToPreviewSelector = (state)=>state.edges.filter((edge)=>edge.source === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID || edge.target === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID).map((edge)=>({
|
|
41
39
|
id: edge.id,
|
|
42
40
|
source: edge.source,
|
|
43
41
|
target: edge.target,
|
|
@@ -55,10 +53,8 @@ const usePreviewNode = ()=>{
|
|
|
55
53
|
const connections = previewEdges.map((previewEdge)=>{
|
|
56
54
|
const sourceIsPreviewNode = previewEdge.source === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID;
|
|
57
55
|
const existingNodeId = sourceIsPreviewNode ? previewEdge.target : previewEdge.source;
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const existingNodeVersion = (0, manifest_resolver_cjs_namespaceObject.getNodeTypeVersion)(existingNode?.data);
|
|
61
|
-
const existingNodeManifest = existingNodeType ? registry?.getManifest(existingNodeType, existingNodeVersion) : void 0;
|
|
56
|
+
const existingNodeType = reactFlowInstance.getNode(existingNodeId)?.type;
|
|
57
|
+
const existingNodeManifest = existingNodeType ? registry?.getManifest(existingNodeType) : void 0;
|
|
62
58
|
const existingHandleId = sourceIsPreviewNode ? previewEdge.targetHandle || 'input' : previewEdge.sourceHandle || 'output';
|
|
63
59
|
const existingHandleManifest = existingNodeManifest?.handleConfiguration.flatMap((hg)=>hg.handles).find((h)=>{
|
|
64
60
|
if (h.id === existingHandleId) return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePreviewNode.d.ts","sourceRoot":"","sources":["../../../src/canvas/hooks/usePreviewNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAIV,MAAM,0CAA0C,CAAC;AAKlD,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"usePreviewNode.d.ts","sourceRoot":"","sources":["../../../src/canvas/hooks/usePreviewNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAIV,MAAM,0CAA0C,CAAC;AAKlD,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAQ9E,MAAM,WAAW,yBAAyB;IAExC,cAAc,EAAE,MAAM,CAAC;IAEvB,gBAAgB,EAAE,MAAM,CAAC;IAEzB,oBAAoB,EAAE,YAAY,GAAG,SAAS,CAAC;IAE/C,sBAAsB,EAAE,cAAc,GAAG,SAAS,CAAC;IAEnD,kBAAkB,EAAE,OAAO,CAAC;IAE5B,aAAa,EAAE,MAAM,CAAC;CACvB;AAsBD,UAAU,oBAAoB;IAE5B,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IAKzB,yBAAyB,EAAE,KAAK,CAAC,yBAAyB,CAAC,GAAG,IAAI,CAAC;CACpE;AAcD,eAAO,MAAM,cAAc,QAAO,oBA8DjC,CAAC"}
|
|
@@ -3,13 +3,11 @@ import { useMemo } from "react";
|
|
|
3
3
|
import { shallow } from "zustand/shallow";
|
|
4
4
|
import { PREVIEW_NODE_ID } from "../constants.js";
|
|
5
5
|
import { useOptionalNodeTypeRegistry } from "../core/index.js";
|
|
6
|
-
import { isPreviewEdge } from "../utils/createPreviewNode.js";
|
|
7
|
-
import { getNodeTypeVersion } from "../utils/manifest-resolver.js";
|
|
8
6
|
const previewNodeSelectedSelector = (state)=>{
|
|
9
7
|
const node = state.nodes.find((n)=>n.id === PREVIEW_NODE_ID);
|
|
10
8
|
return node?.selected ?? false;
|
|
11
9
|
};
|
|
12
|
-
const edgesConnectedToPreviewSelector = (state)=>state.edges.filter(
|
|
10
|
+
const edgesConnectedToPreviewSelector = (state)=>state.edges.filter((edge)=>edge.source === PREVIEW_NODE_ID || edge.target === PREVIEW_NODE_ID).map((edge)=>({
|
|
13
11
|
id: edge.id,
|
|
14
12
|
source: edge.source,
|
|
15
13
|
target: edge.target,
|
|
@@ -27,10 +25,8 @@ const usePreviewNode = ()=>{
|
|
|
27
25
|
const connections = previewEdges.map((previewEdge)=>{
|
|
28
26
|
const sourceIsPreviewNode = previewEdge.source === PREVIEW_NODE_ID;
|
|
29
27
|
const existingNodeId = sourceIsPreviewNode ? previewEdge.target : previewEdge.source;
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const existingNodeVersion = getNodeTypeVersion(existingNode?.data);
|
|
33
|
-
const existingNodeManifest = existingNodeType ? registry?.getManifest(existingNodeType, existingNodeVersion) : void 0;
|
|
28
|
+
const existingNodeType = reactFlowInstance.getNode(existingNodeId)?.type;
|
|
29
|
+
const existingNodeManifest = existingNodeType ? registry?.getManifest(existingNodeType) : void 0;
|
|
34
30
|
const existingHandleId = sourceIsPreviewNode ? previewEdge.targetHandle || 'input' : previewEdge.sourceHandle || 'output';
|
|
35
31
|
const existingHandleManifest = existingNodeManifest?.handleConfiguration.flatMap((hg)=>hg.handles).find((h)=>{
|
|
36
32
|
if (h.id === existingHandleId) return true;
|