@uipath/apollo-react 4.45.0 → 4.46.0

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.
Files changed (109) hide show
  1. package/dist/canvas/components/Edges/CanvasEdge.cjs +197 -0
  2. package/dist/canvas/components/Edges/CanvasEdge.d.ts +3 -0
  3. package/dist/canvas/components/Edges/CanvasEdge.d.ts.map +1 -0
  4. package/dist/canvas/components/Edges/CanvasEdge.js +163 -0
  5. package/dist/canvas/components/Edges/SequenceEdge.cjs +18 -200
  6. package/dist/canvas/components/Edges/SequenceEdge.d.ts +2 -2
  7. package/dist/canvas/components/Edges/SequenceEdge.d.ts.map +1 -1
  8. package/dist/canvas/components/Edges/SequenceEdge.js +19 -201
  9. package/dist/canvas/components/Edges/index.cjs +32 -3
  10. package/dist/canvas/components/Edges/index.d.ts +4 -0
  11. package/dist/canvas/components/Edges/index.d.ts.map +1 -1
  12. package/dist/canvas/components/Edges/index.js +3 -0
  13. package/dist/canvas/components/Edges/shared/areEdgePropsEqual.cjs +54 -0
  14. package/dist/canvas/components/Edges/shared/areEdgePropsEqual.d.ts +3 -0
  15. package/dist/canvas/components/Edges/shared/areEdgePropsEqual.d.ts.map +1 -0
  16. package/dist/canvas/components/Edges/shared/areEdgePropsEqual.js +20 -0
  17. package/dist/canvas/components/Edges/shared/constants.cjs +107 -0
  18. package/dist/canvas/components/Edges/shared/constants.d.ts +33 -0
  19. package/dist/canvas/components/Edges/shared/constants.d.ts.map +1 -0
  20. package/dist/canvas/components/Edges/shared/constants.js +55 -0
  21. package/dist/canvas/components/Edges/shared/geometry.cjs +489 -0
  22. package/dist/canvas/components/Edges/shared/geometry.d.ts +20 -0
  23. package/dist/canvas/components/Edges/shared/geometry.d.ts.map +1 -0
  24. package/dist/canvas/components/Edges/shared/geometry.js +416 -0
  25. package/dist/canvas/components/Edges/shared/hooks/index.cjs +48 -0
  26. package/dist/canvas/components/Edges/shared/hooks/index.d.ts +5 -0
  27. package/dist/canvas/components/Edges/shared/hooks/index.d.ts.map +1 -0
  28. package/dist/canvas/components/Edges/shared/hooks/index.js +5 -0
  29. package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.cjs +103 -0
  30. package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.d.ts +30 -0
  31. package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.d.ts.map +1 -0
  32. package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.js +69 -0
  33. package/dist/canvas/components/Edges/shared/hooks/useEdgeWaypointWriter.cjs +69 -0
  34. package/dist/canvas/components/Edges/shared/hooks/useEdgeWaypointWriter.d.ts +3 -0
  35. package/dist/canvas/components/Edges/shared/hooks/useEdgeWaypointWriter.d.ts.map +1 -0
  36. package/dist/canvas/components/Edges/shared/hooks/useEdgeWaypointWriter.js +35 -0
  37. package/dist/canvas/components/Edges/shared/hooks/useExecutionEdge.cjs +57 -0
  38. package/dist/canvas/components/Edges/shared/hooks/useExecutionEdge.d.ts +13 -0
  39. package/dist/canvas/components/Edges/shared/hooks/useExecutionEdge.d.ts.map +1 -0
  40. package/dist/canvas/components/Edges/shared/hooks/useExecutionEdge.js +23 -0
  41. package/dist/canvas/components/Edges/shared/hooks/useNodeDragRebalance.cjs +98 -0
  42. package/dist/canvas/components/Edges/shared/hooks/useNodeDragRebalance.d.ts +18 -0
  43. package/dist/canvas/components/Edges/shared/hooks/useNodeDragRebalance.d.ts.map +1 -0
  44. package/dist/canvas/components/Edges/shared/hooks/useNodeDragRebalance.js +64 -0
  45. package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.cjs +184 -0
  46. package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.d.ts +23 -0
  47. package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.d.ts.map +1 -0
  48. package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.js +150 -0
  49. package/dist/canvas/components/Edges/shared/primitives/EdgeArrow.cjs +57 -0
  50. package/dist/canvas/components/Edges/shared/primitives/EdgeArrow.d.ts +10 -0
  51. package/dist/canvas/components/Edges/shared/primitives/EdgeArrow.d.ts.map +1 -0
  52. package/dist/canvas/components/Edges/shared/primitives/EdgeArrow.js +23 -0
  53. package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.cjs +66 -0
  54. package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.d.ts +8 -0
  55. package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.d.ts.map +1 -0
  56. package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.js +32 -0
  57. package/dist/canvas/components/Edges/shared/primitives/EdgePath.cjs +84 -0
  58. package/dist/canvas/components/Edges/shared/primitives/EdgePath.d.ts +16 -0
  59. package/dist/canvas/components/Edges/shared/primitives/EdgePath.d.ts.map +1 -0
  60. package/dist/canvas/components/Edges/shared/primitives/EdgePath.js +50 -0
  61. package/dist/canvas/components/Edges/shared/primitives/SegmentDragHandle.cjs +117 -0
  62. package/dist/canvas/components/Edges/shared/primitives/SegmentDragHandle.d.ts +9 -0
  63. package/dist/canvas/components/Edges/shared/primitives/SegmentDragHandle.d.ts.map +1 -0
  64. package/dist/canvas/components/Edges/shared/primitives/SegmentDragHandle.js +83 -0
  65. package/dist/canvas/components/Edges/shared/primitives/WaypointHandle.cjs +75 -0
  66. package/dist/canvas/components/Edges/shared/primitives/WaypointHandle.d.ts +10 -0
  67. package/dist/canvas/components/Edges/shared/primitives/WaypointHandle.d.ts.map +1 -0
  68. package/dist/canvas/components/Edges/shared/primitives/WaypointHandle.js +41 -0
  69. package/dist/canvas/components/Edges/shared/primitives/index.cjs +52 -0
  70. package/dist/canvas/components/Edges/shared/primitives/index.d.ts +11 -0
  71. package/dist/canvas/components/Edges/shared/primitives/index.d.ts.map +1 -0
  72. package/dist/canvas/components/Edges/shared/primitives/index.js +6 -0
  73. package/dist/canvas/components/Edges/shared/resolveEdgeColor.cjs +46 -0
  74. package/dist/canvas/components/Edges/shared/resolveEdgeColor.d.ts +11 -0
  75. package/dist/canvas/components/Edges/shared/resolveEdgeColor.d.ts.map +1 -0
  76. package/dist/canvas/components/Edges/shared/resolveEdgeColor.js +12 -0
  77. package/dist/canvas/components/Edges/shared/routing/defaultEdgeRouter.cjs +51 -0
  78. package/dist/canvas/components/Edges/shared/routing/defaultEdgeRouter.d.ts +3 -0
  79. package/dist/canvas/components/Edges/shared/routing/defaultEdgeRouter.d.ts.map +1 -0
  80. package/dist/canvas/components/Edges/shared/routing/defaultEdgeRouter.js +17 -0
  81. package/dist/canvas/components/Edges/shared/routing/index.cjs +43 -0
  82. package/dist/canvas/components/Edges/shared/routing/index.d.ts +4 -0
  83. package/dist/canvas/components/Edges/shared/routing/index.d.ts.map +1 -0
  84. package/dist/canvas/components/Edges/shared/routing/index.js +3 -0
  85. package/dist/canvas/components/Edges/shared/routing/types.cjs +18 -0
  86. package/dist/canvas/components/Edges/shared/routing/types.d.ts +33 -0
  87. package/dist/canvas/components/Edges/shared/routing/types.d.ts.map +1 -0
  88. package/dist/canvas/components/Edges/shared/routing/types.js +0 -0
  89. package/dist/canvas/components/Edges/shared/routing/useGraphRouter.cjs +175 -0
  90. package/dist/canvas/components/Edges/shared/routing/useGraphRouter.d.ts +5 -0
  91. package/dist/canvas/components/Edges/shared/routing/useGraphRouter.d.ts.map +1 -0
  92. package/dist/canvas/components/Edges/shared/routing/useGraphRouter.js +138 -0
  93. package/dist/canvas/components/Edges/shared/types.cjs +18 -0
  94. package/dist/canvas/components/Edges/shared/types.d.ts +36 -0
  95. package/dist/canvas/components/Edges/shared/types.d.ts.map +1 -0
  96. package/dist/canvas/components/Edges/shared/types.js +0 -0
  97. package/dist/canvas/components/Edges/shared/waypoints.cjs +216 -0
  98. package/dist/canvas/components/Edges/shared/waypoints.d.ts +17 -0
  99. package/dist/canvas/components/Edges/shared/waypoints.d.ts.map +1 -0
  100. package/dist/canvas/components/Edges/shared/waypoints.js +158 -0
  101. package/dist/canvas/controls/NodePropertyTrigger/NodePropertyTrigger.cjs +60 -49
  102. package/dist/canvas/controls/NodePropertyTrigger/NodePropertyTrigger.d.ts.map +1 -1
  103. package/dist/canvas/controls/NodePropertyTrigger/NodePropertyTrigger.js +60 -49
  104. package/dist/canvas/hooks/useEdgePath.cjs +6 -22
  105. package/dist/canvas/hooks/useEdgePath.d.ts +1 -1
  106. package/dist/canvas/hooks/useEdgePath.d.ts.map +1 -1
  107. package/dist/canvas/hooks/useEdgePath.js +5 -21
  108. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  109. package/package.json +1 -1
@@ -0,0 +1,416 @@
1
+ import { snapToGrid } from "../../../utils/NodeUtils.js";
2
+ import { ARROW_OFFSETS, EDGE_CONSTANTS } from "./constants.js";
3
+ const { BORDER_RADIUS, MIN_SEGMENT_LENGTH, COLLINEAR_TOLERANCE: TOL } = EDGE_CONSTANTS;
4
+ function snapPointToGrid(point) {
5
+ return {
6
+ x: snapToGrid(point.x),
7
+ y: snapToGrid(point.y)
8
+ };
9
+ }
10
+ function getDirection(position) {
11
+ switch(position){
12
+ case 'left':
13
+ return {
14
+ dx: -1,
15
+ dy: 0
16
+ };
17
+ case 'right':
18
+ return {
19
+ dx: 1,
20
+ dy: 0
21
+ };
22
+ case 'top':
23
+ return {
24
+ dx: 0,
25
+ dy: -1
26
+ };
27
+ case 'bottom':
28
+ return {
29
+ dx: 0,
30
+ dy: 1
31
+ };
32
+ default:
33
+ return {
34
+ dx: 1,
35
+ dy: 0
36
+ };
37
+ }
38
+ }
39
+ function isHorizontalPosition(position) {
40
+ return 0 !== getDirection(position).dx;
41
+ }
42
+ function calculateAutoWaypoints(sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition) {
43
+ const sourceOffset = ARROW_OFFSETS[sourcePosition];
44
+ const targetOffset = ARROW_OFFSETS[targetPosition];
45
+ const startX = sourceX + sourceOffset.x;
46
+ const startY = sourceY + sourceOffset.y;
47
+ const endX = targetX + targetOffset.x;
48
+ const endY = targetY + targetOffset.y;
49
+ const isSourceHorizontal = isHorizontalPosition(sourcePosition);
50
+ const isTargetHorizontal = isHorizontalPosition(targetPosition);
51
+ const waypoints = [];
52
+ if (isSourceHorizontal && isTargetHorizontal) {
53
+ const midX = snapToGrid((startX + endX) / 2);
54
+ if (Math.abs(startY - endY) > MIN_SEGMENT_LENGTH / 2) {
55
+ waypoints.push({
56
+ x: midX,
57
+ y: startY
58
+ });
59
+ waypoints.push({
60
+ x: midX,
61
+ y: endY
62
+ });
63
+ }
64
+ } else if (isSourceHorizontal || isTargetHorizontal) if (isSourceHorizontal && !isTargetHorizontal) waypoints.push({
65
+ x: endX,
66
+ y: startY
67
+ });
68
+ else waypoints.push({
69
+ x: startX,
70
+ y: endY
71
+ });
72
+ else {
73
+ const midY = snapToGrid((startY + endY) / 2);
74
+ if (Math.abs(startX - endX) > MIN_SEGMENT_LENGTH / 2) {
75
+ waypoints.push({
76
+ x: startX,
77
+ y: midY
78
+ });
79
+ waypoints.push({
80
+ x: endX,
81
+ y: midY
82
+ });
83
+ }
84
+ }
85
+ return waypoints;
86
+ }
87
+ function routeAnchorToPoint(anchor, anchorPosition, point) {
88
+ const dir = getDirection(anchorPosition);
89
+ const isHorizontal = 0 !== dir.dx;
90
+ const forward = isHorizontal ? (point.x - anchor.x) * dir.dx : (point.y - anchor.y) * dir.dy;
91
+ let elbows;
92
+ if (forward >= 0) elbows = isHorizontal ? [
93
+ {
94
+ x: point.x,
95
+ y: anchor.y
96
+ }
97
+ ] : [
98
+ {
99
+ x: anchor.x,
100
+ y: point.y
101
+ }
102
+ ];
103
+ else {
104
+ const { STUB_OFFSET } = EDGE_CONSTANTS;
105
+ elbows = isHorizontal ? [
106
+ {
107
+ x: anchor.x + dir.dx * STUB_OFFSET,
108
+ y: anchor.y
109
+ },
110
+ {
111
+ x: anchor.x + dir.dx * STUB_OFFSET,
112
+ y: point.y
113
+ }
114
+ ] : [
115
+ {
116
+ x: anchor.x,
117
+ y: anchor.y + dir.dy * STUB_OFFSET
118
+ },
119
+ {
120
+ x: point.x,
121
+ y: anchor.y + dir.dy * STUB_OFFSET
122
+ }
123
+ ];
124
+ }
125
+ const result = [];
126
+ let prev = anchor;
127
+ for (const elbow of elbows){
128
+ const samePrev = Math.abs(elbow.x - prev.x) < TOL && Math.abs(elbow.y - prev.y) < TOL;
129
+ const samePoint = Math.abs(elbow.x - point.x) < TOL && Math.abs(elbow.y - point.y) < TOL;
130
+ if (!samePrev && !samePoint) {
131
+ result.push(elbow);
132
+ prev = elbow;
133
+ }
134
+ }
135
+ return result;
136
+ }
137
+ function connectorElbow(from, to, incoming) {
138
+ const alignedX = Math.abs(from.x - to.x) < TOL;
139
+ const alignedY = Math.abs(from.y - to.y) < TOL;
140
+ if (alignedX || alignedY) return null;
141
+ return 'horizontal' === incoming ? {
142
+ x: from.x,
143
+ y: to.y
144
+ } : {
145
+ x: to.x,
146
+ y: from.y
147
+ };
148
+ }
149
+ function buildPathVertices(sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, waypoints = []) {
150
+ const sourceOffset = ARROW_OFFSETS[sourcePosition];
151
+ const targetOffset = ARROW_OFFSETS[targetPosition];
152
+ const start = {
153
+ x: sourceX + sourceOffset.x,
154
+ y: sourceY + sourceOffset.y
155
+ };
156
+ const end = {
157
+ x: targetX + targetOffset.x,
158
+ y: targetY + targetOffset.y
159
+ };
160
+ const derived = (p)=>({
161
+ x: p.x,
162
+ y: p.y,
163
+ waypointIndex: -1
164
+ });
165
+ if (0 === waypoints.length) {
166
+ const autoWaypoints = calculateAutoWaypoints(sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition);
167
+ return [
168
+ start,
169
+ ...autoWaypoints,
170
+ end
171
+ ].map(derived);
172
+ }
173
+ const startVertex = derived(start);
174
+ const endVertex = derived(end);
175
+ const path = [
176
+ startVertex
177
+ ];
178
+ for (const elbow of routeAnchorToPoint(start, sourcePosition, waypoints[0]))path.push(derived(elbow));
179
+ path.push({
180
+ x: waypoints[0].x,
181
+ y: waypoints[0].y,
182
+ waypointIndex: 0
183
+ });
184
+ for(let i = 1; i < waypoints.length; i++){
185
+ const from = path[path.length - 1];
186
+ const incoming = path.length >= 2 ? getSegmentOrientation(path[path.length - 2], from) : null;
187
+ const elbow = connectorElbow(from, waypoints[i], incoming);
188
+ if (elbow) path.push(derived(elbow));
189
+ path.push({
190
+ x: waypoints[i].x,
191
+ y: waypoints[i].y,
192
+ waypointIndex: i
193
+ });
194
+ }
195
+ const targetStub = routeAnchorToPoint(end, targetPosition, waypoints[waypoints.length - 1]);
196
+ for(let j = targetStub.length - 1; j >= 0; j--)path.push(derived(targetStub[j]));
197
+ const interior = consolidateWaypoints(path.slice(1), start, end, (v)=>v.waypointIndex >= 0);
198
+ return [
199
+ startVertex,
200
+ ...interior,
201
+ endVertex
202
+ ];
203
+ }
204
+ function consolidateWaypoints(points, pathStart, pathEnd, isProtected = ()=>false) {
205
+ let current = points;
206
+ let changed = true;
207
+ while(changed && current.length > 0){
208
+ changed = false;
209
+ const before = current.length;
210
+ if (current.length > 1) {
211
+ const deduped = [
212
+ current[0]
213
+ ];
214
+ for(let i = 1; i < current.length; i++){
215
+ const prev = deduped[deduped.length - 1];
216
+ const curr = current[i];
217
+ if (Math.abs(curr.x - prev.x) > TOL || Math.abs(curr.y - prev.y) > TOL) deduped.push(curr);
218
+ else if (isProtected(curr) && !isProtected(prev)) deduped[deduped.length - 1] = curr;
219
+ }
220
+ current = deduped;
221
+ }
222
+ if (current.length > 2) {
223
+ const result = [
224
+ current[0]
225
+ ];
226
+ for(let i = 1; i < current.length - 1; i++){
227
+ const prev = result[result.length - 1];
228
+ const curr = current[i];
229
+ const next = current[i + 1];
230
+ const horizontalLine = Math.abs(prev.y - curr.y) <= TOL && Math.abs(curr.y - next.y) <= TOL;
231
+ const verticalLine = Math.abs(prev.x - curr.x) <= TOL && Math.abs(curr.x - next.x) <= TOL;
232
+ if (!horizontalLine && !verticalLine || isProtected(curr)) result.push(curr);
233
+ }
234
+ result.push(current[current.length - 1]);
235
+ current = result;
236
+ }
237
+ if (current.length >= 2) {
238
+ const first = current[0];
239
+ const second = current[1];
240
+ const collinearH = Math.abs(pathStart.y - first.y) <= TOL && Math.abs(first.y - second.y) <= TOL;
241
+ const collinearV = Math.abs(pathStart.x - first.x) <= TOL && Math.abs(first.x - second.x) <= TOL;
242
+ if ((collinearH || collinearV) && !isProtected(first)) current = current.slice(1);
243
+ }
244
+ if (current.length >= 2) {
245
+ const last = current[current.length - 1];
246
+ const secondLast = current[current.length - 2];
247
+ const collinearH = Math.abs(secondLast.y - last.y) <= TOL && Math.abs(last.y - pathEnd.y) <= TOL;
248
+ const collinearV = Math.abs(secondLast.x - last.x) <= TOL && Math.abs(last.x - pathEnd.x) <= TOL;
249
+ if ((collinearH || collinearV) && !isProtected(last)) current = current.slice(0, -1);
250
+ }
251
+ if (1 === current.length) {
252
+ const wp = current[0];
253
+ const collinearH = Math.abs(pathStart.y - wp.y) <= TOL && Math.abs(wp.y - pathEnd.y) <= TOL;
254
+ const collinearV = Math.abs(pathStart.x - wp.x) <= TOL && Math.abs(wp.x - pathEnd.x) <= TOL;
255
+ if ((collinearH || collinearV) && !isProtected(wp)) current = [];
256
+ }
257
+ if (current.length >= 2) {
258
+ const cleaned = [];
259
+ for(let i = 0; i < current.length; i++){
260
+ const curr = current[i];
261
+ const prev = cleaned[cleaned.length - 1];
262
+ const next = current[i + 1];
263
+ if (!isProtected(curr)) {
264
+ if (prev && Math.abs(curr.x - prev.x) <= TOL && Math.abs(curr.y - prev.y) <= TOL) continue;
265
+ if (next && Math.abs(curr.x - next.x) <= TOL && Math.abs(curr.y - next.y) <= TOL) continue;
266
+ }
267
+ cleaned.push(curr);
268
+ }
269
+ current = cleaned;
270
+ }
271
+ changed = current.length !== before;
272
+ }
273
+ return current;
274
+ }
275
+ function getSegmentOrientation(start, end) {
276
+ return Math.abs(end.x - start.x) > Math.abs(end.y - start.y) ? 'horizontal' : 'vertical';
277
+ }
278
+ function isSegmentPerpendicular(segment) {
279
+ const dx = Math.abs(segment.end.x - segment.start.x);
280
+ const dy = Math.abs(segment.end.y - segment.start.y);
281
+ return dx < TOL || dy < TOL;
282
+ }
283
+ function extractSegments(pathPoints) {
284
+ const segments = [];
285
+ const interiorCount = Math.max(0, pathPoints.length - 2);
286
+ for(let i = 0; i < pathPoints.length - 1; i++){
287
+ const start = pathPoints[i];
288
+ const end = pathPoints[i + 1];
289
+ segments.push({
290
+ id: `seg-${i}`,
291
+ start: {
292
+ x: start.x,
293
+ y: start.y
294
+ },
295
+ end: {
296
+ x: end.x,
297
+ y: end.y
298
+ },
299
+ orientation: getSegmentOrientation(start, end),
300
+ waypointIndexBefore: i - 1,
301
+ waypointIndexAfter: i < interiorCount ? i : interiorCount
302
+ });
303
+ }
304
+ return segments;
305
+ }
306
+ function createRoundedPath(points, borderRadius = BORDER_RADIUS) {
307
+ if (points.length < 2) return '';
308
+ const firstPoint = points[0];
309
+ const path = [
310
+ `M ${firstPoint.x} ${firstPoint.y}`
311
+ ];
312
+ if (2 === points.length) {
313
+ const secondPoint = points[1];
314
+ path.push(`L ${secondPoint.x} ${secondPoint.y}`);
315
+ return path.join(' ');
316
+ }
317
+ for(let i = 1; i < points.length - 1; i++){
318
+ const prev = points[i - 1];
319
+ const curr = points[i];
320
+ const next = points[i + 1];
321
+ const v1 = {
322
+ x: curr.x - prev.x,
323
+ y: curr.y - prev.y
324
+ };
325
+ const v2 = {
326
+ x: next.x - curr.x,
327
+ y: next.y - curr.y
328
+ };
329
+ const len1 = Math.sqrt(v1.x * v1.x + v1.y * v1.y);
330
+ const len2 = Math.sqrt(v2.x * v2.x + v2.y * v2.y);
331
+ const radius = Math.min(borderRadius, Math.min(len1, len2) / 2);
332
+ if (radius < 1) {
333
+ path.push(`L ${curr.x} ${curr.y}`);
334
+ continue;
335
+ }
336
+ const n1 = {
337
+ x: v1.x / len1,
338
+ y: v1.y / len1
339
+ };
340
+ const n2 = {
341
+ x: v2.x / len2,
342
+ y: v2.y / len2
343
+ };
344
+ const cornerStart = {
345
+ x: curr.x - n1.x * radius,
346
+ y: curr.y - n1.y * radius
347
+ };
348
+ const cornerEnd = {
349
+ x: curr.x + n2.x * radius,
350
+ y: curr.y + n2.y * radius
351
+ };
352
+ path.push(`L ${cornerStart.x} ${cornerStart.y}`);
353
+ path.push(`Q ${curr.x} ${curr.y} ${cornerEnd.x} ${cornerEnd.y}`);
354
+ }
355
+ const lastPoint = points[points.length - 1];
356
+ path.push(`L ${lastPoint.x} ${lastPoint.y}`);
357
+ return path.join(' ');
358
+ }
359
+ function getSegmentMidpoint(segment) {
360
+ return {
361
+ x: (segment.start.x + segment.end.x) / 2,
362
+ y: (segment.start.y + segment.end.y) / 2
363
+ };
364
+ }
365
+ function getSegmentLength(segment) {
366
+ const dx = segment.end.x - segment.start.x;
367
+ const dy = segment.end.y - segment.start.y;
368
+ return Math.sqrt(dx * dx + dy * dy);
369
+ }
370
+ function isSegmentInteractable(segment) {
371
+ return getSegmentLength(segment) >= MIN_SEGMENT_LENGTH;
372
+ }
373
+ function getPathArcMidpoint(points) {
374
+ if (0 === points.length) return {
375
+ x: 0,
376
+ y: 0
377
+ };
378
+ if (1 === points.length) return {
379
+ x: points[0].x,
380
+ y: points[0].y
381
+ };
382
+ const lengths = [];
383
+ let total = 0;
384
+ for(let i = 0; i < points.length - 1; i++){
385
+ const dx = points[i + 1].x - points[i].x;
386
+ const dy = points[i + 1].y - points[i].y;
387
+ const len = Math.sqrt(dx * dx + dy * dy);
388
+ lengths.push(len);
389
+ total += len;
390
+ }
391
+ if (0 === total) return {
392
+ x: points[0].x,
393
+ y: points[0].y
394
+ };
395
+ const target = total / 2;
396
+ let acc = 0;
397
+ for(let i = 0; i < lengths.length; i++){
398
+ const segLen = lengths[i];
399
+ if (acc + segLen >= target) {
400
+ const t = (target - acc) / segLen;
401
+ const start = points[i];
402
+ const end = points[i + 1];
403
+ return {
404
+ x: start.x + t * (end.x - start.x),
405
+ y: start.y + t * (end.y - start.y)
406
+ };
407
+ }
408
+ acc += segLen;
409
+ }
410
+ const last = points[points.length - 1];
411
+ return {
412
+ x: last.x,
413
+ y: last.y
414
+ };
415
+ }
416
+ export { buildPathVertices, calculateAutoWaypoints, consolidateWaypoints, createRoundedPath, extractSegments, getPathArcMidpoint, getSegmentLength, getSegmentMidpoint, getSegmentOrientation, isHorizontalPosition, isSegmentInteractable, isSegmentPerpendicular, routeAnchorToPoint, snapPointToGrid };
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ useExecutionEdge: ()=>external_useExecutionEdge_cjs_namespaceObject.useExecutionEdge,
28
+ useWaypointEditor: ()=>external_useWaypointEditor_cjs_namespaceObject.useWaypointEditor,
29
+ useNodeDragRebalance: ()=>external_useNodeDragRebalance_cjs_namespaceObject.useNodeDragRebalance,
30
+ useEdgeGeometry: ()=>external_useEdgeGeometry_cjs_namespaceObject.useEdgeGeometry
31
+ });
32
+ const external_useEdgeGeometry_cjs_namespaceObject = require("./useEdgeGeometry.cjs");
33
+ const external_useExecutionEdge_cjs_namespaceObject = require("./useExecutionEdge.cjs");
34
+ const external_useNodeDragRebalance_cjs_namespaceObject = require("./useNodeDragRebalance.cjs");
35
+ const external_useWaypointEditor_cjs_namespaceObject = require("./useWaypointEditor.cjs");
36
+ exports.useEdgeGeometry = __webpack_exports__.useEdgeGeometry;
37
+ exports.useExecutionEdge = __webpack_exports__.useExecutionEdge;
38
+ exports.useNodeDragRebalance = __webpack_exports__.useNodeDragRebalance;
39
+ exports.useWaypointEditor = __webpack_exports__.useWaypointEditor;
40
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
41
+ "useEdgeGeometry",
42
+ "useExecutionEdge",
43
+ "useNodeDragRebalance",
44
+ "useWaypointEditor"
45
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
46
+ Object.defineProperty(exports, '__esModule', {
47
+ value: true
48
+ });
@@ -0,0 +1,5 @@
1
+ export { useEdgeGeometry } from './useEdgeGeometry';
2
+ export { useExecutionEdge } from './useExecutionEdge';
3
+ export { useNodeDragRebalance } from './useNodeDragRebalance';
4
+ export { useWaypointEditor } from './useWaypointEditor';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/canvas/components/Edges/shared/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { useEdgeGeometry } from "./useEdgeGeometry.js";
2
+ import { useExecutionEdge } from "./useExecutionEdge.js";
3
+ import { useNodeDragRebalance } from "./useNodeDragRebalance.js";
4
+ import { useWaypointEditor } from "./useWaypointEditor.js";
5
+ export { useEdgeGeometry, useExecutionEdge, useNodeDragRebalance, useWaypointEditor };
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ useEdgeGeometry: ()=>useEdgeGeometry
28
+ });
29
+ const external_react_namespaceObject = require("react");
30
+ const index_cjs_namespaceObject = require("../../../../hooks/index.cjs");
31
+ const external_constants_cjs_namespaceObject = require("../constants.cjs");
32
+ const external_geometry_cjs_namespaceObject = require("../geometry.cjs");
33
+ const EMPTY_VERTICES = [];
34
+ const EMPTY_SEGMENTS = [];
35
+ function useEdgeGeometry(args) {
36
+ const { routing, sourceNodeId, targetNodeId, sourceHandleId, targetHandleId, sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, waypoints, enableSegments = true, hideArrowHead = false } = args;
37
+ const arrowOffset = external_constants_cjs_namespaceObject.ARROW_OFFSETS[targetPosition];
38
+ const isWaypoint = 'waypoint' === routing;
39
+ const isHandle = 'handle' === routing;
40
+ const pathPoints = (0, external_react_namespaceObject.useMemo)(()=>isWaypoint ? (0, external_geometry_cjs_namespaceObject.buildPathVertices)(sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, waypoints) : EMPTY_VERTICES, [
41
+ isWaypoint,
42
+ sourceX,
43
+ sourceY,
44
+ sourcePosition,
45
+ targetX,
46
+ targetY,
47
+ targetPosition,
48
+ waypoints
49
+ ]);
50
+ const segments = (0, external_react_namespaceObject.useMemo)(()=>enableSegments ? (0, external_geometry_cjs_namespaceObject.extractSegments)(pathPoints) : EMPTY_SEGMENTS, [
51
+ enableSegments,
52
+ pathPoints
53
+ ]);
54
+ const waypointPath = (0, external_react_namespaceObject.useMemo)(()=>(0, external_geometry_cjs_namespaceObject.createRoundedPath)(pathPoints, external_constants_cjs_namespaceObject.EDGE_CONSTANTS.BORDER_RADIUS), [
55
+ pathPoints
56
+ ]);
57
+ const handle = (0, index_cjs_namespaceObject.useEdgePath)({
58
+ sourceNodeId: isHandle ? sourceNodeId : '',
59
+ targetNodeId: isHandle ? targetNodeId : '',
60
+ sourceHandleId: isHandle ? sourceHandleId : null,
61
+ targetHandleId: isHandle ? targetHandleId : null,
62
+ sourceX: isHandle ? sourceX : 0,
63
+ sourceY: isHandle ? sourceY : 0,
64
+ sourcePosition,
65
+ targetX: isHandle ? hideArrowHead ? targetX + arrowOffset.x : targetX : 0,
66
+ targetY: isHandle ? hideArrowHead ? targetY + arrowOffset.y : targetY : 0,
67
+ targetPosition
68
+ });
69
+ const labelPoint = (0, external_react_namespaceObject.useMemo)(()=>isHandle ? {
70
+ x: handle.labelX,
71
+ y: handle.labelY
72
+ } : (0, external_geometry_cjs_namespaceObject.getPathArcMidpoint)(pathPoints), [
73
+ isHandle,
74
+ handle.labelX,
75
+ handle.labelY,
76
+ pathPoints
77
+ ]);
78
+ const arrow = {
79
+ angle: external_constants_cjs_namespaceObject.ARROW_ANGLE_MAP[targetPosition],
80
+ offset: arrowOffset
81
+ };
82
+ if (isHandle) return {
83
+ edgePath: handle.edgePath,
84
+ pathPoints: EMPTY_VERTICES,
85
+ segments: EMPTY_SEGMENTS,
86
+ labelPoint,
87
+ arrow
88
+ };
89
+ return {
90
+ edgePath: waypointPath,
91
+ pathPoints,
92
+ segments,
93
+ labelPoint,
94
+ arrow
95
+ };
96
+ }
97
+ exports.useEdgeGeometry = __webpack_exports__.useEdgeGeometry;
98
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
99
+ "useEdgeGeometry"
100
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
101
+ Object.defineProperty(exports, '__esModule', {
102
+ value: true
103
+ });
@@ -0,0 +1,30 @@
1
+ import type { Position } from '../../../../xyflow/react.ts';
2
+ import type { EdgeRouting, PathVertex, Point, Segment, Waypoint } from '../types';
3
+ export type UseEdgeGeometryArgs = {
4
+ routing: EdgeRouting;
5
+ sourceNodeId: string;
6
+ targetNodeId: string;
7
+ sourceHandleId?: string | null;
8
+ targetHandleId?: string | null;
9
+ sourceX: number;
10
+ sourceY: number;
11
+ sourcePosition: Position;
12
+ targetX: number;
13
+ targetY: number;
14
+ targetPosition: Position;
15
+ waypoints: Waypoint[];
16
+ enableSegments?: boolean;
17
+ hideArrowHead?: boolean;
18
+ };
19
+ export type EdgeGeometry = {
20
+ edgePath: string;
21
+ pathPoints: PathVertex[];
22
+ segments: Segment[];
23
+ labelPoint: Point;
24
+ arrow: {
25
+ angle: number;
26
+ offset: Point;
27
+ };
28
+ };
29
+ export declare function useEdgeGeometry(args: UseEdgeGeometryArgs): EdgeGeometry;
30
+ //# sourceMappingURL=useEdgeGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEdgeGeometry.d.ts","sourceRoot":"","sources":["../../../../../../src/canvas/components/Edges/shared/hooks/useEdgeGeometry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAUzE,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKlF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,WAAW,CAAC;IAErB,YAAY,EAAE,MAAM,CAAC;IAErB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,QAAQ,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,QAAQ,CAAC;IAEzB,SAAS,EAAE,QAAQ,EAAE,CAAC;IAMtB,cAAc,CAAC,EAAE,OAAO,CAAC;IAMzB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAEzB,QAAQ,EAAE,MAAM,CAAC;IAEjB,UAAU,EAAE,UAAU,EAAE,CAAC;IAEzB,QAAQ,EAAE,OAAO,EAAE,CAAC;IAEpB,UAAU,EAAE,KAAK,CAAC;IAElB,KAAK,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,KAAK,CAAC;KACf,CAAC;CACH,CAAC;AAUF,wBAAgB,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,YAAY,CAqFvE"}
@@ -0,0 +1,69 @@
1
+ import { useMemo } from "react";
2
+ import { useEdgePath } from "../../../../hooks/index.js";
3
+ import { ARROW_ANGLE_MAP, ARROW_OFFSETS, EDGE_CONSTANTS } from "../constants.js";
4
+ import { buildPathVertices, createRoundedPath, extractSegments, getPathArcMidpoint } from "../geometry.js";
5
+ const EMPTY_VERTICES = [];
6
+ const EMPTY_SEGMENTS = [];
7
+ function useEdgeGeometry(args) {
8
+ const { routing, sourceNodeId, targetNodeId, sourceHandleId, targetHandleId, sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, waypoints, enableSegments = true, hideArrowHead = false } = args;
9
+ const arrowOffset = ARROW_OFFSETS[targetPosition];
10
+ const isWaypoint = 'waypoint' === routing;
11
+ const isHandle = 'handle' === routing;
12
+ const pathPoints = useMemo(()=>isWaypoint ? buildPathVertices(sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, waypoints) : EMPTY_VERTICES, [
13
+ isWaypoint,
14
+ sourceX,
15
+ sourceY,
16
+ sourcePosition,
17
+ targetX,
18
+ targetY,
19
+ targetPosition,
20
+ waypoints
21
+ ]);
22
+ const segments = useMemo(()=>enableSegments ? extractSegments(pathPoints) : EMPTY_SEGMENTS, [
23
+ enableSegments,
24
+ pathPoints
25
+ ]);
26
+ const waypointPath = useMemo(()=>createRoundedPath(pathPoints, EDGE_CONSTANTS.BORDER_RADIUS), [
27
+ pathPoints
28
+ ]);
29
+ const handle = useEdgePath({
30
+ sourceNodeId: isHandle ? sourceNodeId : '',
31
+ targetNodeId: isHandle ? targetNodeId : '',
32
+ sourceHandleId: isHandle ? sourceHandleId : null,
33
+ targetHandleId: isHandle ? targetHandleId : null,
34
+ sourceX: isHandle ? sourceX : 0,
35
+ sourceY: isHandle ? sourceY : 0,
36
+ sourcePosition,
37
+ targetX: isHandle ? hideArrowHead ? targetX + arrowOffset.x : targetX : 0,
38
+ targetY: isHandle ? hideArrowHead ? targetY + arrowOffset.y : targetY : 0,
39
+ targetPosition
40
+ });
41
+ const labelPoint = useMemo(()=>isHandle ? {
42
+ x: handle.labelX,
43
+ y: handle.labelY
44
+ } : getPathArcMidpoint(pathPoints), [
45
+ isHandle,
46
+ handle.labelX,
47
+ handle.labelY,
48
+ pathPoints
49
+ ]);
50
+ const arrow = {
51
+ angle: ARROW_ANGLE_MAP[targetPosition],
52
+ offset: arrowOffset
53
+ };
54
+ if (isHandle) return {
55
+ edgePath: handle.edgePath,
56
+ pathPoints: EMPTY_VERTICES,
57
+ segments: EMPTY_SEGMENTS,
58
+ labelPoint,
59
+ arrow
60
+ };
61
+ return {
62
+ edgePath: waypointPath,
63
+ pathPoints,
64
+ segments,
65
+ labelPoint,
66
+ arrow
67
+ };
68
+ }
69
+ export { useEdgeGeometry };