@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.
- package/dist/canvas/components/Edges/CanvasEdge.cjs +197 -0
- package/dist/canvas/components/Edges/CanvasEdge.d.ts +3 -0
- package/dist/canvas/components/Edges/CanvasEdge.d.ts.map +1 -0
- package/dist/canvas/components/Edges/CanvasEdge.js +163 -0
- package/dist/canvas/components/Edges/SequenceEdge.cjs +18 -200
- package/dist/canvas/components/Edges/SequenceEdge.d.ts +2 -2
- package/dist/canvas/components/Edges/SequenceEdge.d.ts.map +1 -1
- package/dist/canvas/components/Edges/SequenceEdge.js +19 -201
- package/dist/canvas/components/Edges/index.cjs +32 -3
- package/dist/canvas/components/Edges/index.d.ts +4 -0
- package/dist/canvas/components/Edges/index.d.ts.map +1 -1
- package/dist/canvas/components/Edges/index.js +3 -0
- package/dist/canvas/components/Edges/shared/areEdgePropsEqual.cjs +54 -0
- package/dist/canvas/components/Edges/shared/areEdgePropsEqual.d.ts +3 -0
- package/dist/canvas/components/Edges/shared/areEdgePropsEqual.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/areEdgePropsEqual.js +20 -0
- package/dist/canvas/components/Edges/shared/constants.cjs +107 -0
- package/dist/canvas/components/Edges/shared/constants.d.ts +33 -0
- package/dist/canvas/components/Edges/shared/constants.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/constants.js +55 -0
- package/dist/canvas/components/Edges/shared/geometry.cjs +489 -0
- package/dist/canvas/components/Edges/shared/geometry.d.ts +20 -0
- package/dist/canvas/components/Edges/shared/geometry.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/geometry.js +416 -0
- package/dist/canvas/components/Edges/shared/hooks/index.cjs +48 -0
- package/dist/canvas/components/Edges/shared/hooks/index.d.ts +5 -0
- package/dist/canvas/components/Edges/shared/hooks/index.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/hooks/index.js +5 -0
- package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.cjs +103 -0
- package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.d.ts +30 -0
- package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.js +69 -0
- package/dist/canvas/components/Edges/shared/hooks/useEdgeWaypointWriter.cjs +69 -0
- package/dist/canvas/components/Edges/shared/hooks/useEdgeWaypointWriter.d.ts +3 -0
- package/dist/canvas/components/Edges/shared/hooks/useEdgeWaypointWriter.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/hooks/useEdgeWaypointWriter.js +35 -0
- package/dist/canvas/components/Edges/shared/hooks/useExecutionEdge.cjs +57 -0
- package/dist/canvas/components/Edges/shared/hooks/useExecutionEdge.d.ts +13 -0
- package/dist/canvas/components/Edges/shared/hooks/useExecutionEdge.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/hooks/useExecutionEdge.js +23 -0
- package/dist/canvas/components/Edges/shared/hooks/useNodeDragRebalance.cjs +98 -0
- package/dist/canvas/components/Edges/shared/hooks/useNodeDragRebalance.d.ts +18 -0
- package/dist/canvas/components/Edges/shared/hooks/useNodeDragRebalance.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/hooks/useNodeDragRebalance.js +64 -0
- package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.cjs +184 -0
- package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.d.ts +23 -0
- package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.js +150 -0
- package/dist/canvas/components/Edges/shared/primitives/EdgeArrow.cjs +57 -0
- package/dist/canvas/components/Edges/shared/primitives/EdgeArrow.d.ts +10 -0
- package/dist/canvas/components/Edges/shared/primitives/EdgeArrow.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/primitives/EdgeArrow.js +23 -0
- package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.cjs +66 -0
- package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.d.ts +8 -0
- package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.js +32 -0
- package/dist/canvas/components/Edges/shared/primitives/EdgePath.cjs +84 -0
- package/dist/canvas/components/Edges/shared/primitives/EdgePath.d.ts +16 -0
- package/dist/canvas/components/Edges/shared/primitives/EdgePath.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/primitives/EdgePath.js +50 -0
- package/dist/canvas/components/Edges/shared/primitives/SegmentDragHandle.cjs +117 -0
- package/dist/canvas/components/Edges/shared/primitives/SegmentDragHandle.d.ts +9 -0
- package/dist/canvas/components/Edges/shared/primitives/SegmentDragHandle.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/primitives/SegmentDragHandle.js +83 -0
- package/dist/canvas/components/Edges/shared/primitives/WaypointHandle.cjs +75 -0
- package/dist/canvas/components/Edges/shared/primitives/WaypointHandle.d.ts +10 -0
- package/dist/canvas/components/Edges/shared/primitives/WaypointHandle.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/primitives/WaypointHandle.js +41 -0
- package/dist/canvas/components/Edges/shared/primitives/index.cjs +52 -0
- package/dist/canvas/components/Edges/shared/primitives/index.d.ts +11 -0
- package/dist/canvas/components/Edges/shared/primitives/index.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/primitives/index.js +6 -0
- package/dist/canvas/components/Edges/shared/resolveEdgeColor.cjs +46 -0
- package/dist/canvas/components/Edges/shared/resolveEdgeColor.d.ts +11 -0
- package/dist/canvas/components/Edges/shared/resolveEdgeColor.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/resolveEdgeColor.js +12 -0
- package/dist/canvas/components/Edges/shared/routing/defaultEdgeRouter.cjs +51 -0
- package/dist/canvas/components/Edges/shared/routing/defaultEdgeRouter.d.ts +3 -0
- package/dist/canvas/components/Edges/shared/routing/defaultEdgeRouter.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/routing/defaultEdgeRouter.js +17 -0
- package/dist/canvas/components/Edges/shared/routing/index.cjs +43 -0
- package/dist/canvas/components/Edges/shared/routing/index.d.ts +4 -0
- package/dist/canvas/components/Edges/shared/routing/index.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/routing/index.js +3 -0
- package/dist/canvas/components/Edges/shared/routing/types.cjs +18 -0
- package/dist/canvas/components/Edges/shared/routing/types.d.ts +33 -0
- package/dist/canvas/components/Edges/shared/routing/types.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/routing/types.js +0 -0
- package/dist/canvas/components/Edges/shared/routing/useGraphRouter.cjs +175 -0
- package/dist/canvas/components/Edges/shared/routing/useGraphRouter.d.ts +5 -0
- package/dist/canvas/components/Edges/shared/routing/useGraphRouter.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/routing/useGraphRouter.js +138 -0
- package/dist/canvas/components/Edges/shared/types.cjs +18 -0
- package/dist/canvas/components/Edges/shared/types.d.ts +36 -0
- package/dist/canvas/components/Edges/shared/types.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/types.js +0 -0
- package/dist/canvas/components/Edges/shared/waypoints.cjs +216 -0
- package/dist/canvas/components/Edges/shared/waypoints.d.ts +17 -0
- package/dist/canvas/components/Edges/shared/waypoints.d.ts.map +1 -0
- package/dist/canvas/components/Edges/shared/waypoints.js +158 -0
- package/dist/canvas/controls/NodePropertyTrigger/NodePropertyTrigger.cjs +60 -49
- package/dist/canvas/controls/NodePropertyTrigger/NodePropertyTrigger.d.ts.map +1 -1
- package/dist/canvas/controls/NodePropertyTrigger/NodePropertyTrigger.js +60 -49
- package/dist/canvas/hooks/useEdgePath.cjs +6 -22
- package/dist/canvas/hooks/useEdgePath.d.ts +1 -1
- package/dist/canvas/hooks/useEdgePath.d.ts.map +1 -1
- package/dist/canvas/hooks/useEdgePath.js +5 -21
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,489 @@
|
|
|
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
|
+
snapPointToGrid: ()=>snapPointToGrid,
|
|
28
|
+
isSegmentPerpendicular: ()=>isSegmentPerpendicular,
|
|
29
|
+
calculateAutoWaypoints: ()=>calculateAutoWaypoints,
|
|
30
|
+
consolidateWaypoints: ()=>consolidateWaypoints,
|
|
31
|
+
getSegmentLength: ()=>getSegmentLength,
|
|
32
|
+
isSegmentInteractable: ()=>isSegmentInteractable,
|
|
33
|
+
getSegmentOrientation: ()=>getSegmentOrientation,
|
|
34
|
+
buildPathVertices: ()=>buildPathVertices,
|
|
35
|
+
createRoundedPath: ()=>createRoundedPath,
|
|
36
|
+
extractSegments: ()=>extractSegments,
|
|
37
|
+
getPathArcMidpoint: ()=>getPathArcMidpoint,
|
|
38
|
+
getSegmentMidpoint: ()=>getSegmentMidpoint,
|
|
39
|
+
isHorizontalPosition: ()=>isHorizontalPosition,
|
|
40
|
+
routeAnchorToPoint: ()=>routeAnchorToPoint
|
|
41
|
+
});
|
|
42
|
+
const NodeUtils_cjs_namespaceObject = require("../../../utils/NodeUtils.cjs");
|
|
43
|
+
const external_constants_cjs_namespaceObject = require("./constants.cjs");
|
|
44
|
+
const { BORDER_RADIUS, MIN_SEGMENT_LENGTH, COLLINEAR_TOLERANCE: TOL } = external_constants_cjs_namespaceObject.EDGE_CONSTANTS;
|
|
45
|
+
function snapPointToGrid(point) {
|
|
46
|
+
return {
|
|
47
|
+
x: (0, NodeUtils_cjs_namespaceObject.snapToGrid)(point.x),
|
|
48
|
+
y: (0, NodeUtils_cjs_namespaceObject.snapToGrid)(point.y)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function getDirection(position) {
|
|
52
|
+
switch(position){
|
|
53
|
+
case 'left':
|
|
54
|
+
return {
|
|
55
|
+
dx: -1,
|
|
56
|
+
dy: 0
|
|
57
|
+
};
|
|
58
|
+
case 'right':
|
|
59
|
+
return {
|
|
60
|
+
dx: 1,
|
|
61
|
+
dy: 0
|
|
62
|
+
};
|
|
63
|
+
case 'top':
|
|
64
|
+
return {
|
|
65
|
+
dx: 0,
|
|
66
|
+
dy: -1
|
|
67
|
+
};
|
|
68
|
+
case 'bottom':
|
|
69
|
+
return {
|
|
70
|
+
dx: 0,
|
|
71
|
+
dy: 1
|
|
72
|
+
};
|
|
73
|
+
default:
|
|
74
|
+
return {
|
|
75
|
+
dx: 1,
|
|
76
|
+
dy: 0
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function isHorizontalPosition(position) {
|
|
81
|
+
return 0 !== getDirection(position).dx;
|
|
82
|
+
}
|
|
83
|
+
function calculateAutoWaypoints(sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition) {
|
|
84
|
+
const sourceOffset = external_constants_cjs_namespaceObject.ARROW_OFFSETS[sourcePosition];
|
|
85
|
+
const targetOffset = external_constants_cjs_namespaceObject.ARROW_OFFSETS[targetPosition];
|
|
86
|
+
const startX = sourceX + sourceOffset.x;
|
|
87
|
+
const startY = sourceY + sourceOffset.y;
|
|
88
|
+
const endX = targetX + targetOffset.x;
|
|
89
|
+
const endY = targetY + targetOffset.y;
|
|
90
|
+
const isSourceHorizontal = isHorizontalPosition(sourcePosition);
|
|
91
|
+
const isTargetHorizontal = isHorizontalPosition(targetPosition);
|
|
92
|
+
const waypoints = [];
|
|
93
|
+
if (isSourceHorizontal && isTargetHorizontal) {
|
|
94
|
+
const midX = (0, NodeUtils_cjs_namespaceObject.snapToGrid)((startX + endX) / 2);
|
|
95
|
+
if (Math.abs(startY - endY) > MIN_SEGMENT_LENGTH / 2) {
|
|
96
|
+
waypoints.push({
|
|
97
|
+
x: midX,
|
|
98
|
+
y: startY
|
|
99
|
+
});
|
|
100
|
+
waypoints.push({
|
|
101
|
+
x: midX,
|
|
102
|
+
y: endY
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
} else if (isSourceHorizontal || isTargetHorizontal) if (isSourceHorizontal && !isTargetHorizontal) waypoints.push({
|
|
106
|
+
x: endX,
|
|
107
|
+
y: startY
|
|
108
|
+
});
|
|
109
|
+
else waypoints.push({
|
|
110
|
+
x: startX,
|
|
111
|
+
y: endY
|
|
112
|
+
});
|
|
113
|
+
else {
|
|
114
|
+
const midY = (0, NodeUtils_cjs_namespaceObject.snapToGrid)((startY + endY) / 2);
|
|
115
|
+
if (Math.abs(startX - endX) > MIN_SEGMENT_LENGTH / 2) {
|
|
116
|
+
waypoints.push({
|
|
117
|
+
x: startX,
|
|
118
|
+
y: midY
|
|
119
|
+
});
|
|
120
|
+
waypoints.push({
|
|
121
|
+
x: endX,
|
|
122
|
+
y: midY
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return waypoints;
|
|
127
|
+
}
|
|
128
|
+
function routeAnchorToPoint(anchor, anchorPosition, point) {
|
|
129
|
+
const dir = getDirection(anchorPosition);
|
|
130
|
+
const isHorizontal = 0 !== dir.dx;
|
|
131
|
+
const forward = isHorizontal ? (point.x - anchor.x) * dir.dx : (point.y - anchor.y) * dir.dy;
|
|
132
|
+
let elbows;
|
|
133
|
+
if (forward >= 0) elbows = isHorizontal ? [
|
|
134
|
+
{
|
|
135
|
+
x: point.x,
|
|
136
|
+
y: anchor.y
|
|
137
|
+
}
|
|
138
|
+
] : [
|
|
139
|
+
{
|
|
140
|
+
x: anchor.x,
|
|
141
|
+
y: point.y
|
|
142
|
+
}
|
|
143
|
+
];
|
|
144
|
+
else {
|
|
145
|
+
const { STUB_OFFSET } = external_constants_cjs_namespaceObject.EDGE_CONSTANTS;
|
|
146
|
+
elbows = isHorizontal ? [
|
|
147
|
+
{
|
|
148
|
+
x: anchor.x + dir.dx * STUB_OFFSET,
|
|
149
|
+
y: anchor.y
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
x: anchor.x + dir.dx * STUB_OFFSET,
|
|
153
|
+
y: point.y
|
|
154
|
+
}
|
|
155
|
+
] : [
|
|
156
|
+
{
|
|
157
|
+
x: anchor.x,
|
|
158
|
+
y: anchor.y + dir.dy * STUB_OFFSET
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
x: point.x,
|
|
162
|
+
y: anchor.y + dir.dy * STUB_OFFSET
|
|
163
|
+
}
|
|
164
|
+
];
|
|
165
|
+
}
|
|
166
|
+
const result = [];
|
|
167
|
+
let prev = anchor;
|
|
168
|
+
for (const elbow of elbows){
|
|
169
|
+
const samePrev = Math.abs(elbow.x - prev.x) < TOL && Math.abs(elbow.y - prev.y) < TOL;
|
|
170
|
+
const samePoint = Math.abs(elbow.x - point.x) < TOL && Math.abs(elbow.y - point.y) < TOL;
|
|
171
|
+
if (!samePrev && !samePoint) {
|
|
172
|
+
result.push(elbow);
|
|
173
|
+
prev = elbow;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
function connectorElbow(from, to, incoming) {
|
|
179
|
+
const alignedX = Math.abs(from.x - to.x) < TOL;
|
|
180
|
+
const alignedY = Math.abs(from.y - to.y) < TOL;
|
|
181
|
+
if (alignedX || alignedY) return null;
|
|
182
|
+
return 'horizontal' === incoming ? {
|
|
183
|
+
x: from.x,
|
|
184
|
+
y: to.y
|
|
185
|
+
} : {
|
|
186
|
+
x: to.x,
|
|
187
|
+
y: from.y
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function buildPathVertices(sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, waypoints = []) {
|
|
191
|
+
const sourceOffset = external_constants_cjs_namespaceObject.ARROW_OFFSETS[sourcePosition];
|
|
192
|
+
const targetOffset = external_constants_cjs_namespaceObject.ARROW_OFFSETS[targetPosition];
|
|
193
|
+
const start = {
|
|
194
|
+
x: sourceX + sourceOffset.x,
|
|
195
|
+
y: sourceY + sourceOffset.y
|
|
196
|
+
};
|
|
197
|
+
const end = {
|
|
198
|
+
x: targetX + targetOffset.x,
|
|
199
|
+
y: targetY + targetOffset.y
|
|
200
|
+
};
|
|
201
|
+
const derived = (p)=>({
|
|
202
|
+
x: p.x,
|
|
203
|
+
y: p.y,
|
|
204
|
+
waypointIndex: -1
|
|
205
|
+
});
|
|
206
|
+
if (0 === waypoints.length) {
|
|
207
|
+
const autoWaypoints = calculateAutoWaypoints(sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition);
|
|
208
|
+
return [
|
|
209
|
+
start,
|
|
210
|
+
...autoWaypoints,
|
|
211
|
+
end
|
|
212
|
+
].map(derived);
|
|
213
|
+
}
|
|
214
|
+
const startVertex = derived(start);
|
|
215
|
+
const endVertex = derived(end);
|
|
216
|
+
const path = [
|
|
217
|
+
startVertex
|
|
218
|
+
];
|
|
219
|
+
for (const elbow of routeAnchorToPoint(start, sourcePosition, waypoints[0]))path.push(derived(elbow));
|
|
220
|
+
path.push({
|
|
221
|
+
x: waypoints[0].x,
|
|
222
|
+
y: waypoints[0].y,
|
|
223
|
+
waypointIndex: 0
|
|
224
|
+
});
|
|
225
|
+
for(let i = 1; i < waypoints.length; i++){
|
|
226
|
+
const from = path[path.length - 1];
|
|
227
|
+
const incoming = path.length >= 2 ? getSegmentOrientation(path[path.length - 2], from) : null;
|
|
228
|
+
const elbow = connectorElbow(from, waypoints[i], incoming);
|
|
229
|
+
if (elbow) path.push(derived(elbow));
|
|
230
|
+
path.push({
|
|
231
|
+
x: waypoints[i].x,
|
|
232
|
+
y: waypoints[i].y,
|
|
233
|
+
waypointIndex: i
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
const targetStub = routeAnchorToPoint(end, targetPosition, waypoints[waypoints.length - 1]);
|
|
237
|
+
for(let j = targetStub.length - 1; j >= 0; j--)path.push(derived(targetStub[j]));
|
|
238
|
+
const interior = consolidateWaypoints(path.slice(1), start, end, (v)=>v.waypointIndex >= 0);
|
|
239
|
+
return [
|
|
240
|
+
startVertex,
|
|
241
|
+
...interior,
|
|
242
|
+
endVertex
|
|
243
|
+
];
|
|
244
|
+
}
|
|
245
|
+
function consolidateWaypoints(points, pathStart, pathEnd, isProtected = ()=>false) {
|
|
246
|
+
let current = points;
|
|
247
|
+
let changed = true;
|
|
248
|
+
while(changed && current.length > 0){
|
|
249
|
+
changed = false;
|
|
250
|
+
const before = current.length;
|
|
251
|
+
if (current.length > 1) {
|
|
252
|
+
const deduped = [
|
|
253
|
+
current[0]
|
|
254
|
+
];
|
|
255
|
+
for(let i = 1; i < current.length; i++){
|
|
256
|
+
const prev = deduped[deduped.length - 1];
|
|
257
|
+
const curr = current[i];
|
|
258
|
+
if (Math.abs(curr.x - prev.x) > TOL || Math.abs(curr.y - prev.y) > TOL) deduped.push(curr);
|
|
259
|
+
else if (isProtected(curr) && !isProtected(prev)) deduped[deduped.length - 1] = curr;
|
|
260
|
+
}
|
|
261
|
+
current = deduped;
|
|
262
|
+
}
|
|
263
|
+
if (current.length > 2) {
|
|
264
|
+
const result = [
|
|
265
|
+
current[0]
|
|
266
|
+
];
|
|
267
|
+
for(let i = 1; i < current.length - 1; i++){
|
|
268
|
+
const prev = result[result.length - 1];
|
|
269
|
+
const curr = current[i];
|
|
270
|
+
const next = current[i + 1];
|
|
271
|
+
const horizontalLine = Math.abs(prev.y - curr.y) <= TOL && Math.abs(curr.y - next.y) <= TOL;
|
|
272
|
+
const verticalLine = Math.abs(prev.x - curr.x) <= TOL && Math.abs(curr.x - next.x) <= TOL;
|
|
273
|
+
if (!horizontalLine && !verticalLine || isProtected(curr)) result.push(curr);
|
|
274
|
+
}
|
|
275
|
+
result.push(current[current.length - 1]);
|
|
276
|
+
current = result;
|
|
277
|
+
}
|
|
278
|
+
if (current.length >= 2) {
|
|
279
|
+
const first = current[0];
|
|
280
|
+
const second = current[1];
|
|
281
|
+
const collinearH = Math.abs(pathStart.y - first.y) <= TOL && Math.abs(first.y - second.y) <= TOL;
|
|
282
|
+
const collinearV = Math.abs(pathStart.x - first.x) <= TOL && Math.abs(first.x - second.x) <= TOL;
|
|
283
|
+
if ((collinearH || collinearV) && !isProtected(first)) current = current.slice(1);
|
|
284
|
+
}
|
|
285
|
+
if (current.length >= 2) {
|
|
286
|
+
const last = current[current.length - 1];
|
|
287
|
+
const secondLast = current[current.length - 2];
|
|
288
|
+
const collinearH = Math.abs(secondLast.y - last.y) <= TOL && Math.abs(last.y - pathEnd.y) <= TOL;
|
|
289
|
+
const collinearV = Math.abs(secondLast.x - last.x) <= TOL && Math.abs(last.x - pathEnd.x) <= TOL;
|
|
290
|
+
if ((collinearH || collinearV) && !isProtected(last)) current = current.slice(0, -1);
|
|
291
|
+
}
|
|
292
|
+
if (1 === current.length) {
|
|
293
|
+
const wp = current[0];
|
|
294
|
+
const collinearH = Math.abs(pathStart.y - wp.y) <= TOL && Math.abs(wp.y - pathEnd.y) <= TOL;
|
|
295
|
+
const collinearV = Math.abs(pathStart.x - wp.x) <= TOL && Math.abs(wp.x - pathEnd.x) <= TOL;
|
|
296
|
+
if ((collinearH || collinearV) && !isProtected(wp)) current = [];
|
|
297
|
+
}
|
|
298
|
+
if (current.length >= 2) {
|
|
299
|
+
const cleaned = [];
|
|
300
|
+
for(let i = 0; i < current.length; i++){
|
|
301
|
+
const curr = current[i];
|
|
302
|
+
const prev = cleaned[cleaned.length - 1];
|
|
303
|
+
const next = current[i + 1];
|
|
304
|
+
if (!isProtected(curr)) {
|
|
305
|
+
if (prev && Math.abs(curr.x - prev.x) <= TOL && Math.abs(curr.y - prev.y) <= TOL) continue;
|
|
306
|
+
if (next && Math.abs(curr.x - next.x) <= TOL && Math.abs(curr.y - next.y) <= TOL) continue;
|
|
307
|
+
}
|
|
308
|
+
cleaned.push(curr);
|
|
309
|
+
}
|
|
310
|
+
current = cleaned;
|
|
311
|
+
}
|
|
312
|
+
changed = current.length !== before;
|
|
313
|
+
}
|
|
314
|
+
return current;
|
|
315
|
+
}
|
|
316
|
+
function getSegmentOrientation(start, end) {
|
|
317
|
+
return Math.abs(end.x - start.x) > Math.abs(end.y - start.y) ? 'horizontal' : 'vertical';
|
|
318
|
+
}
|
|
319
|
+
function isSegmentPerpendicular(segment) {
|
|
320
|
+
const dx = Math.abs(segment.end.x - segment.start.x);
|
|
321
|
+
const dy = Math.abs(segment.end.y - segment.start.y);
|
|
322
|
+
return dx < TOL || dy < TOL;
|
|
323
|
+
}
|
|
324
|
+
function extractSegments(pathPoints) {
|
|
325
|
+
const segments = [];
|
|
326
|
+
const interiorCount = Math.max(0, pathPoints.length - 2);
|
|
327
|
+
for(let i = 0; i < pathPoints.length - 1; i++){
|
|
328
|
+
const start = pathPoints[i];
|
|
329
|
+
const end = pathPoints[i + 1];
|
|
330
|
+
segments.push({
|
|
331
|
+
id: `seg-${i}`,
|
|
332
|
+
start: {
|
|
333
|
+
x: start.x,
|
|
334
|
+
y: start.y
|
|
335
|
+
},
|
|
336
|
+
end: {
|
|
337
|
+
x: end.x,
|
|
338
|
+
y: end.y
|
|
339
|
+
},
|
|
340
|
+
orientation: getSegmentOrientation(start, end),
|
|
341
|
+
waypointIndexBefore: i - 1,
|
|
342
|
+
waypointIndexAfter: i < interiorCount ? i : interiorCount
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
return segments;
|
|
346
|
+
}
|
|
347
|
+
function createRoundedPath(points, borderRadius = BORDER_RADIUS) {
|
|
348
|
+
if (points.length < 2) return '';
|
|
349
|
+
const firstPoint = points[0];
|
|
350
|
+
const path = [
|
|
351
|
+
`M ${firstPoint.x} ${firstPoint.y}`
|
|
352
|
+
];
|
|
353
|
+
if (2 === points.length) {
|
|
354
|
+
const secondPoint = points[1];
|
|
355
|
+
path.push(`L ${secondPoint.x} ${secondPoint.y}`);
|
|
356
|
+
return path.join(' ');
|
|
357
|
+
}
|
|
358
|
+
for(let i = 1; i < points.length - 1; i++){
|
|
359
|
+
const prev = points[i - 1];
|
|
360
|
+
const curr = points[i];
|
|
361
|
+
const next = points[i + 1];
|
|
362
|
+
const v1 = {
|
|
363
|
+
x: curr.x - prev.x,
|
|
364
|
+
y: curr.y - prev.y
|
|
365
|
+
};
|
|
366
|
+
const v2 = {
|
|
367
|
+
x: next.x - curr.x,
|
|
368
|
+
y: next.y - curr.y
|
|
369
|
+
};
|
|
370
|
+
const len1 = Math.sqrt(v1.x * v1.x + v1.y * v1.y);
|
|
371
|
+
const len2 = Math.sqrt(v2.x * v2.x + v2.y * v2.y);
|
|
372
|
+
const radius = Math.min(borderRadius, Math.min(len1, len2) / 2);
|
|
373
|
+
if (radius < 1) {
|
|
374
|
+
path.push(`L ${curr.x} ${curr.y}`);
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
const n1 = {
|
|
378
|
+
x: v1.x / len1,
|
|
379
|
+
y: v1.y / len1
|
|
380
|
+
};
|
|
381
|
+
const n2 = {
|
|
382
|
+
x: v2.x / len2,
|
|
383
|
+
y: v2.y / len2
|
|
384
|
+
};
|
|
385
|
+
const cornerStart = {
|
|
386
|
+
x: curr.x - n1.x * radius,
|
|
387
|
+
y: curr.y - n1.y * radius
|
|
388
|
+
};
|
|
389
|
+
const cornerEnd = {
|
|
390
|
+
x: curr.x + n2.x * radius,
|
|
391
|
+
y: curr.y + n2.y * radius
|
|
392
|
+
};
|
|
393
|
+
path.push(`L ${cornerStart.x} ${cornerStart.y}`);
|
|
394
|
+
path.push(`Q ${curr.x} ${curr.y} ${cornerEnd.x} ${cornerEnd.y}`);
|
|
395
|
+
}
|
|
396
|
+
const lastPoint = points[points.length - 1];
|
|
397
|
+
path.push(`L ${lastPoint.x} ${lastPoint.y}`);
|
|
398
|
+
return path.join(' ');
|
|
399
|
+
}
|
|
400
|
+
function getSegmentMidpoint(segment) {
|
|
401
|
+
return {
|
|
402
|
+
x: (segment.start.x + segment.end.x) / 2,
|
|
403
|
+
y: (segment.start.y + segment.end.y) / 2
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
function getSegmentLength(segment) {
|
|
407
|
+
const dx = segment.end.x - segment.start.x;
|
|
408
|
+
const dy = segment.end.y - segment.start.y;
|
|
409
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
410
|
+
}
|
|
411
|
+
function isSegmentInteractable(segment) {
|
|
412
|
+
return getSegmentLength(segment) >= MIN_SEGMENT_LENGTH;
|
|
413
|
+
}
|
|
414
|
+
function getPathArcMidpoint(points) {
|
|
415
|
+
if (0 === points.length) return {
|
|
416
|
+
x: 0,
|
|
417
|
+
y: 0
|
|
418
|
+
};
|
|
419
|
+
if (1 === points.length) return {
|
|
420
|
+
x: points[0].x,
|
|
421
|
+
y: points[0].y
|
|
422
|
+
};
|
|
423
|
+
const lengths = [];
|
|
424
|
+
let total = 0;
|
|
425
|
+
for(let i = 0; i < points.length - 1; i++){
|
|
426
|
+
const dx = points[i + 1].x - points[i].x;
|
|
427
|
+
const dy = points[i + 1].y - points[i].y;
|
|
428
|
+
const len = Math.sqrt(dx * dx + dy * dy);
|
|
429
|
+
lengths.push(len);
|
|
430
|
+
total += len;
|
|
431
|
+
}
|
|
432
|
+
if (0 === total) return {
|
|
433
|
+
x: points[0].x,
|
|
434
|
+
y: points[0].y
|
|
435
|
+
};
|
|
436
|
+
const target = total / 2;
|
|
437
|
+
let acc = 0;
|
|
438
|
+
for(let i = 0; i < lengths.length; i++){
|
|
439
|
+
const segLen = lengths[i];
|
|
440
|
+
if (acc + segLen >= target) {
|
|
441
|
+
const t = (target - acc) / segLen;
|
|
442
|
+
const start = points[i];
|
|
443
|
+
const end = points[i + 1];
|
|
444
|
+
return {
|
|
445
|
+
x: start.x + t * (end.x - start.x),
|
|
446
|
+
y: start.y + t * (end.y - start.y)
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
acc += segLen;
|
|
450
|
+
}
|
|
451
|
+
const last = points[points.length - 1];
|
|
452
|
+
return {
|
|
453
|
+
x: last.x,
|
|
454
|
+
y: last.y
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
exports.buildPathVertices = __webpack_exports__.buildPathVertices;
|
|
458
|
+
exports.calculateAutoWaypoints = __webpack_exports__.calculateAutoWaypoints;
|
|
459
|
+
exports.consolidateWaypoints = __webpack_exports__.consolidateWaypoints;
|
|
460
|
+
exports.createRoundedPath = __webpack_exports__.createRoundedPath;
|
|
461
|
+
exports.extractSegments = __webpack_exports__.extractSegments;
|
|
462
|
+
exports.getPathArcMidpoint = __webpack_exports__.getPathArcMidpoint;
|
|
463
|
+
exports.getSegmentLength = __webpack_exports__.getSegmentLength;
|
|
464
|
+
exports.getSegmentMidpoint = __webpack_exports__.getSegmentMidpoint;
|
|
465
|
+
exports.getSegmentOrientation = __webpack_exports__.getSegmentOrientation;
|
|
466
|
+
exports.isHorizontalPosition = __webpack_exports__.isHorizontalPosition;
|
|
467
|
+
exports.isSegmentInteractable = __webpack_exports__.isSegmentInteractable;
|
|
468
|
+
exports.isSegmentPerpendicular = __webpack_exports__.isSegmentPerpendicular;
|
|
469
|
+
exports.routeAnchorToPoint = __webpack_exports__.routeAnchorToPoint;
|
|
470
|
+
exports.snapPointToGrid = __webpack_exports__.snapPointToGrid;
|
|
471
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
472
|
+
"buildPathVertices",
|
|
473
|
+
"calculateAutoWaypoints",
|
|
474
|
+
"consolidateWaypoints",
|
|
475
|
+
"createRoundedPath",
|
|
476
|
+
"extractSegments",
|
|
477
|
+
"getPathArcMidpoint",
|
|
478
|
+
"getSegmentLength",
|
|
479
|
+
"getSegmentMidpoint",
|
|
480
|
+
"getSegmentOrientation",
|
|
481
|
+
"isHorizontalPosition",
|
|
482
|
+
"isSegmentInteractable",
|
|
483
|
+
"isSegmentPerpendicular",
|
|
484
|
+
"routeAnchorToPoint",
|
|
485
|
+
"snapPointToGrid"
|
|
486
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
487
|
+
Object.defineProperty(exports, '__esModule', {
|
|
488
|
+
value: true
|
|
489
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Position } from '../../../xyflow/react.ts';
|
|
2
|
+
import type { PathVertex, Point, Segment, SegmentOrientation, Waypoint } from './types';
|
|
3
|
+
export declare function snapPointToGrid(point: Point): Point;
|
|
4
|
+
export declare function isHorizontalPosition(position: Position): boolean;
|
|
5
|
+
export declare function calculateAutoWaypoints(sourceX: number, sourceY: number, sourcePosition: Position, targetX: number, targetY: number, targetPosition: Position): Point[];
|
|
6
|
+
export declare function routeAnchorToPoint(anchor: Point, anchorPosition: Position, point: Point): Point[];
|
|
7
|
+
export declare function buildPathVertices(sourceX: number, sourceY: number, sourcePosition: Position, targetX: number, targetY: number, targetPosition: Position, waypoints?: Waypoint[]): PathVertex[];
|
|
8
|
+
export declare function consolidateWaypoints<T extends Point>(points: T[], pathStart: Point, pathEnd: Point, isProtected?: (point: T) => boolean): T[];
|
|
9
|
+
export declare function getSegmentOrientation(start: Point, end: Point): SegmentOrientation;
|
|
10
|
+
export declare function isSegmentPerpendicular(segment: {
|
|
11
|
+
start: Point;
|
|
12
|
+
end: Point;
|
|
13
|
+
}): boolean;
|
|
14
|
+
export declare function extractSegments(pathPoints: PathVertex[]): Segment[];
|
|
15
|
+
export declare function createRoundedPath(points: Point[], borderRadius?: number): string;
|
|
16
|
+
export declare function getSegmentMidpoint(segment: Segment): Point;
|
|
17
|
+
export declare function getSegmentLength(segment: Segment): number;
|
|
18
|
+
export declare function isSegmentInteractable(segment: Segment): boolean;
|
|
19
|
+
export declare function getPathArcMidpoint(points: Point[]): Point;
|
|
20
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/Edges/shared/geometry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAGzE,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxF,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAEnD;AAmBD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAEhE;AAMD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,QAAQ,EACxB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,QAAQ,GACvB,KAAK,EAAE,CAiCT;AAyBD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE,CAoCjG;AAkCD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,QAAQ,EACxB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,QAAQ,EACxB,SAAS,GAAE,QAAQ,EAAO,GACzB,UAAU,EAAE,CAwDd;AAiBD,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,KAAK,EAClD,MAAM,EAAE,CAAC,EAAE,EACX,SAAS,EAAE,KAAK,EAChB,OAAO,EAAE,KAAK,EACd,WAAW,GAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAqB,GAC/C,CAAC,EAAE,CAsFL;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,kBAAkB,CAElF;AAKD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,KAAK,CAAA;CAAE,GAAG,OAAO,CAIrF;AAUD,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,CAgBnE;AAMD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,YAAY,GAAE,MAAsB,GAAG,MAAM,CAyC/F;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK,CAK1D;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAIzD;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAE/D;AAOD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAkCzD"}
|