@uipath/apollo-react 7.15.2 → 7.15.4
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 +4 -2
- package/dist/canvas/components/Edges/CanvasEdge.d.ts.map +1 -1
- package/dist/canvas/components/Edges/CanvasEdge.js +4 -2
- package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.cjs +8 -3
- package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.d.ts +2 -0
- package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.d.ts.map +1 -1
- package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.js +9 -4
- package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.cjs +63 -37
- package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.d.ts +2 -0
- package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.d.ts.map +1 -1
- package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.js +64 -38
- package/dist/canvas/components/Edges/shared/waypoints.cjs +149 -5
- package/dist/canvas/components/Edges/shared/waypoints.d.ts +5 -0
- package/dist/canvas/components/Edges/shared/waypoints.d.ts.map +1 -1
- package/dist/canvas/components/Edges/shared/waypoints.js +133 -1
- package/dist/canvas/components/Guardrails/definitions-copy.cjs +1 -1
- package/dist/canvas/components/Guardrails/definitions-copy.js +1 -1
- package/dist/canvas/locales/en.cjs +1 -1
- package/dist/canvas/locales/en.d.ts.map +1 -1
- package/dist/canvas/locales/en.js +1 -1
- package/dist/canvas/locales/ru.cjs +1 -1
- package/dist/canvas/locales/ru.d.ts.map +1 -1
- package/dist/canvas/locales/ru.js +1 -1
- package/package.json +3 -3
|
@@ -25,14 +25,18 @@ var __webpack_exports__ = {};
|
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
moveWaypoint: ()=>moveWaypoint,
|
|
28
|
-
|
|
28
|
+
moveWaypointConstrained: ()=>moveWaypointConstrained,
|
|
29
29
|
materializePathWaypoints: ()=>materializePathWaypoints,
|
|
30
|
-
|
|
31
|
-
rebalanceWaypoints: ()=>rebalanceWaypoints,
|
|
30
|
+
normalizeWaypoints: ()=>normalizeWaypoints,
|
|
32
31
|
insertWaypoint: ()=>insertWaypoint,
|
|
33
|
-
|
|
32
|
+
rebalanceWaypoints: ()=>rebalanceWaypoints,
|
|
33
|
+
removeWaypoint: ()=>removeWaypoint,
|
|
34
|
+
waypointsEqual: ()=>waypointsEqual,
|
|
34
35
|
moveSegmentByDelta: ()=>moveSegmentByDelta,
|
|
35
|
-
|
|
36
|
+
waypointsPositionallyEqual: ()=>waypointsPositionallyEqual,
|
|
37
|
+
moveCornerWaypoint: ()=>moveCornerWaypoint,
|
|
38
|
+
generateWaypointId: ()=>generateWaypointId,
|
|
39
|
+
isCornerWaypoint: ()=>isCornerWaypoint
|
|
36
40
|
});
|
|
37
41
|
const NodeUtils_cjs_namespaceObject = require("../../../utils/NodeUtils.cjs");
|
|
38
42
|
const external_constants_cjs_namespaceObject = require("./constants.cjs");
|
|
@@ -125,6 +129,138 @@ function moveWaypoint(waypoints, index, newPosition) {
|
|
|
125
129
|
...snapped
|
|
126
130
|
} : wp);
|
|
127
131
|
}
|
|
132
|
+
function runAxis(a, b) {
|
|
133
|
+
const tol = external_constants_cjs_namespaceObject.EDGE_CONSTANTS.COLLINEAR_TOLERANCE;
|
|
134
|
+
const sameX = Math.abs(a.x - b.x) <= tol;
|
|
135
|
+
const sameY = Math.abs(a.y - b.y) <= tol;
|
|
136
|
+
if (sameX === sameY) return null;
|
|
137
|
+
return sameY ? 'horizontal' : 'vertical';
|
|
138
|
+
}
|
|
139
|
+
function vertexIndexOf(path, index) {
|
|
140
|
+
return path.findIndex((v)=>v.waypointIndex === index);
|
|
141
|
+
}
|
|
142
|
+
function isCornerWaypoint(path, index) {
|
|
143
|
+
const i = vertexIndexOf(path, index);
|
|
144
|
+
if (i <= 0) return false;
|
|
145
|
+
const incoming = runAxis(path[i - 1], path[i]);
|
|
146
|
+
const outgoing = runAxis(path[i], path[i + 1]);
|
|
147
|
+
return null !== incoming && null !== outgoing && incoming !== outgoing;
|
|
148
|
+
}
|
|
149
|
+
function moveCornerWaypoint(waypoints, index, desired, path) {
|
|
150
|
+
const i = vertexIndexOf(path, index);
|
|
151
|
+
if (i <= 0 || !waypoints[index]) return waypoints;
|
|
152
|
+
const corner = path[i];
|
|
153
|
+
const next = moveWaypoint(waypoints, index, desired);
|
|
154
|
+
const target = next[index];
|
|
155
|
+
for (const neighbor of [
|
|
156
|
+
path[i - 1],
|
|
157
|
+
path[i + 1]
|
|
158
|
+
]){
|
|
159
|
+
const axis = runAxis(neighbor, corner);
|
|
160
|
+
if (!axis || neighbor.waypointIndex < 0) continue;
|
|
161
|
+
const coord = 'horizontal' === axis ? 'y' : 'x';
|
|
162
|
+
next[neighbor.waypointIndex] = {
|
|
163
|
+
...next[neighbor.waypointIndex],
|
|
164
|
+
[coord]: target[coord]
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const sourceStub = i - 1 === 0 ? waypoints_anchorStub(path[0], corner, target) : [];
|
|
168
|
+
const targetStub = i + 1 === path.length - 1 ? waypoints_anchorStub(path[i + 1], corner, target) : [];
|
|
169
|
+
return [
|
|
170
|
+
...sourceStub,
|
|
171
|
+
...next,
|
|
172
|
+
...targetStub.reverse()
|
|
173
|
+
];
|
|
174
|
+
}
|
|
175
|
+
function waypoints_anchorStub(anchor, corner, target) {
|
|
176
|
+
const axis = runAxis(anchor, corner);
|
|
177
|
+
if (!axis) return [];
|
|
178
|
+
const [along, across] = 'horizontal' === axis ? [
|
|
179
|
+
'x',
|
|
180
|
+
'y'
|
|
181
|
+
] : [
|
|
182
|
+
'y',
|
|
183
|
+
'x'
|
|
184
|
+
];
|
|
185
|
+
if (Math.abs(target[across] - anchor[across]) <= external_constants_cjs_namespaceObject.EDGE_CONSTANTS.COLLINEAR_TOLERANCE) return [];
|
|
186
|
+
const direction = Math.sign(corner[along] - anchor[along]) || 1;
|
|
187
|
+
const stubCoord = (0, NodeUtils_cjs_namespaceObject.snapToGrid)(anchor[along] + direction * external_constants_cjs_namespaceObject.EDGE_CONSTANTS.STUB_OFFSET);
|
|
188
|
+
return makeStubPair(anchor, axis, stubCoord, target[across]);
|
|
189
|
+
}
|
|
190
|
+
function normalizeWaypoints(waypoints, buildPath) {
|
|
191
|
+
let current = waypoints;
|
|
192
|
+
let path = buildPath(current);
|
|
193
|
+
const reference = pathShape(path);
|
|
194
|
+
const keepsRoute = (candidate)=>pointsEqual(pathShape(buildPath(candidate)), reference);
|
|
195
|
+
const skipped = new Set();
|
|
196
|
+
for(let guard = 0; guard <= 3 * waypoints.length; guard++){
|
|
197
|
+
const index = current.findIndex((wp, i)=>!skipped.has(wp.id) && !isCornerWaypoint(path, i));
|
|
198
|
+
if (index < 0) break;
|
|
199
|
+
const fix = runEndCandidates(current, index, path).find(keepsRoute);
|
|
200
|
+
if (fix) {
|
|
201
|
+
current = fix;
|
|
202
|
+
path = buildPath(current);
|
|
203
|
+
} else skipped.add(current[index].id);
|
|
204
|
+
}
|
|
205
|
+
return current;
|
|
206
|
+
}
|
|
207
|
+
function runEndCandidates(waypoints, index, path) {
|
|
208
|
+
const candidates = [
|
|
209
|
+
removeWaypoint(waypoints, index)
|
|
210
|
+
];
|
|
211
|
+
const i = vertexIndexOf(path, index);
|
|
212
|
+
if (i < 0) return candidates;
|
|
213
|
+
const self = path[i];
|
|
214
|
+
const distance = (p)=>Math.abs(p.x - self.x) + Math.abs(p.y - self.y);
|
|
215
|
+
const ends = [
|
|
216
|
+
i - 1,
|
|
217
|
+
i + 1
|
|
218
|
+
].filter((j)=>j > 0 && j < path.length - 1).map((j)=>path[j]).sort((a, b)=>distance(a) - distance(b));
|
|
219
|
+
for (const end of ends)candidates.push(waypoints.map((wp, j)=>j === index ? {
|
|
220
|
+
...wp,
|
|
221
|
+
x: end.x,
|
|
222
|
+
y: end.y
|
|
223
|
+
} : wp));
|
|
224
|
+
return candidates;
|
|
225
|
+
}
|
|
226
|
+
function moveWaypointConstrained(waypoints, index, desired, buildPath) {
|
|
227
|
+
const initial = waypoints[index];
|
|
228
|
+
if (!initial) return waypoints;
|
|
229
|
+
const start = (0, external_geometry_cjs_namespaceObject.snapPointToGrid)(initial);
|
|
230
|
+
const target = (0, external_geometry_cjs_namespaceObject.snapPointToGrid)(desired);
|
|
231
|
+
const movesX = target.x !== start.x;
|
|
232
|
+
const movesY = target.y !== start.y;
|
|
233
|
+
if (!movesX && !movesY) return moveWaypoint(waypoints, index, start);
|
|
234
|
+
const shapeAt = (p)=>pathShape(buildPath(moveWaypoint(waypoints, index, p)));
|
|
235
|
+
const fullShape = shapeAt(target);
|
|
236
|
+
const keepX = movesX && !pointsEqual(fullShape, shapeAt({
|
|
237
|
+
x: start.x,
|
|
238
|
+
y: target.y
|
|
239
|
+
}));
|
|
240
|
+
const keepY = movesY && !pointsEqual(fullShape, shapeAt({
|
|
241
|
+
x: target.x,
|
|
242
|
+
y: start.y
|
|
243
|
+
}));
|
|
244
|
+
return moveWaypoint(waypoints, index, {
|
|
245
|
+
x: keepX ? target.x : start.x,
|
|
246
|
+
y: keepY ? target.y : start.y
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
function pathShape(points) {
|
|
250
|
+
if (points.length <= 2) return points;
|
|
251
|
+
const start = points[0];
|
|
252
|
+
const end = points[points.length - 1];
|
|
253
|
+
return [
|
|
254
|
+
start,
|
|
255
|
+
...(0, external_geometry_cjs_namespaceObject.consolidateWaypoints)(points.slice(1, -1), start, end),
|
|
256
|
+
end
|
|
257
|
+
];
|
|
258
|
+
}
|
|
259
|
+
function pointsEqual(a, b) {
|
|
260
|
+
if (a.length !== b.length) return false;
|
|
261
|
+
const tol = external_constants_cjs_namespaceObject.EDGE_CONSTANTS.COLLINEAR_TOLERANCE;
|
|
262
|
+
return a.every((p, i)=>Math.abs(p.x - b[i].x) <= tol && Math.abs(p.y - b[i].y) <= tol);
|
|
263
|
+
}
|
|
128
264
|
function moveSegmentByDelta(initialWaypoints, initialSegment, delta, initialPathPoints) {
|
|
129
265
|
const moveAxis = 'horizontal' === initialSegment.orientation ? 'y' : 'x';
|
|
130
266
|
const moveValue = 'y' === moveAxis ? delta.y : delta.x;
|
|
@@ -193,9 +329,13 @@ function makeStubPair(anchor, orientation, stubCoord, movedCoordinate) {
|
|
|
193
329
|
}
|
|
194
330
|
exports.generateWaypointId = __webpack_exports__.generateWaypointId;
|
|
195
331
|
exports.insertWaypoint = __webpack_exports__.insertWaypoint;
|
|
332
|
+
exports.isCornerWaypoint = __webpack_exports__.isCornerWaypoint;
|
|
196
333
|
exports.materializePathWaypoints = __webpack_exports__.materializePathWaypoints;
|
|
334
|
+
exports.moveCornerWaypoint = __webpack_exports__.moveCornerWaypoint;
|
|
197
335
|
exports.moveSegmentByDelta = __webpack_exports__.moveSegmentByDelta;
|
|
198
336
|
exports.moveWaypoint = __webpack_exports__.moveWaypoint;
|
|
337
|
+
exports.moveWaypointConstrained = __webpack_exports__.moveWaypointConstrained;
|
|
338
|
+
exports.normalizeWaypoints = __webpack_exports__.normalizeWaypoints;
|
|
199
339
|
exports.rebalanceWaypoints = __webpack_exports__.rebalanceWaypoints;
|
|
200
340
|
exports.removeWaypoint = __webpack_exports__.removeWaypoint;
|
|
201
341
|
exports.waypointsEqual = __webpack_exports__.waypointsEqual;
|
|
@@ -203,9 +343,13 @@ exports.waypointsPositionallyEqual = __webpack_exports__.waypointsPositionallyEq
|
|
|
203
343
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
204
344
|
"generateWaypointId",
|
|
205
345
|
"insertWaypoint",
|
|
346
|
+
"isCornerWaypoint",
|
|
206
347
|
"materializePathWaypoints",
|
|
348
|
+
"moveCornerWaypoint",
|
|
207
349
|
"moveSegmentByDelta",
|
|
208
350
|
"moveWaypoint",
|
|
351
|
+
"moveWaypointConstrained",
|
|
352
|
+
"normalizeWaypoints",
|
|
209
353
|
"rebalanceWaypoints",
|
|
210
354
|
"removeWaypoint",
|
|
211
355
|
"waypointsEqual",
|
|
@@ -13,5 +13,10 @@ export type RebalanceEndpoint = {
|
|
|
13
13
|
};
|
|
14
14
|
export declare function rebalanceWaypoints(waypoints: Waypoint[], source: RebalanceEndpoint, target: RebalanceEndpoint): Waypoint[];
|
|
15
15
|
export declare function moveWaypoint(waypoints: Waypoint[], index: number, newPosition: Point): Waypoint[];
|
|
16
|
+
export type PathBuilder = (waypoints: Waypoint[]) => PathVertex[];
|
|
17
|
+
export declare function isCornerWaypoint(path: PathVertex[], index: number): boolean;
|
|
18
|
+
export declare function moveCornerWaypoint(waypoints: Waypoint[], index: number, desired: Point, path: PathVertex[]): Waypoint[];
|
|
19
|
+
export declare function normalizeWaypoints(waypoints: Waypoint[], buildPath: PathBuilder): Waypoint[];
|
|
20
|
+
export declare function moveWaypointConstrained(waypoints: Waypoint[], index: number, desired: Point, buildPath: PathBuilder): Waypoint[];
|
|
16
21
|
export declare function moveSegmentByDelta(initialWaypoints: Waypoint[], initialSegment: Segment, delta: Point, initialPathPoints: Point[]): Waypoint[];
|
|
17
22
|
//# sourceMappingURL=waypoints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waypoints.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/Edges/shared/waypoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAIzE,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"waypoints.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/Edges/shared/waypoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAIzE,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAsB,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUxF,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAK/F;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAOD,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,CASpE;AAOD,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,CAOhF;AASD,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,UAAU,EAAE,EACtB,MAAM,EAAE,QAAQ,EAAE,EAClB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,KAAK,GACd,QAAQ,EAAE,CASZ;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,EAAE,CAE/E;AAID,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,KAAK,CAAC;IACZ,EAAE,EAAE,KAAK,CAAC;CACX,CAAC;AAqBF,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,QAAQ,EAAE,EACrB,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,iBAAiB,GACxB,QAAQ,EAAE,CA2BZ;AAwBD,wBAAgB,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,GAAG,QAAQ,EAAE,CAGjG;AAGD,MAAM,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,CAAC;AAsBlE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAM3E;AAaD,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,QAAQ,EAAE,EACrB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,KAAK,EACd,IAAI,EAAE,UAAU,EAAE,GACjB,QAAQ,EAAE,CAoBZ;AA2BD,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,WAAW,GAAG,QAAQ,EAAE,CAsB5F;AAoCD,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,QAAQ,EAAE,EACrB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,KAAK,EACd,SAAS,EAAE,WAAW,GACrB,QAAQ,EAAE,CAoBZ;AAwBD,wBAAgB,kBAAkB,CAChC,gBAAgB,EAAE,QAAQ,EAAE,EAC5B,cAAc,EAAE,OAAO,EACvB,KAAK,EAAE,KAAK,EACZ,iBAAiB,EAAE,KAAK,EAAE,GACzB,QAAQ,EAAE,CAiEZ"}
|
|
@@ -89,6 +89,138 @@ function moveWaypoint(waypoints, index, newPosition) {
|
|
|
89
89
|
...snapped
|
|
90
90
|
} : wp);
|
|
91
91
|
}
|
|
92
|
+
function runAxis(a, b) {
|
|
93
|
+
const tol = EDGE_CONSTANTS.COLLINEAR_TOLERANCE;
|
|
94
|
+
const sameX = Math.abs(a.x - b.x) <= tol;
|
|
95
|
+
const sameY = Math.abs(a.y - b.y) <= tol;
|
|
96
|
+
if (sameX === sameY) return null;
|
|
97
|
+
return sameY ? 'horizontal' : 'vertical';
|
|
98
|
+
}
|
|
99
|
+
function vertexIndexOf(path, index) {
|
|
100
|
+
return path.findIndex((v)=>v.waypointIndex === index);
|
|
101
|
+
}
|
|
102
|
+
function isCornerWaypoint(path, index) {
|
|
103
|
+
const i = vertexIndexOf(path, index);
|
|
104
|
+
if (i <= 0) return false;
|
|
105
|
+
const incoming = runAxis(path[i - 1], path[i]);
|
|
106
|
+
const outgoing = runAxis(path[i], path[i + 1]);
|
|
107
|
+
return null !== incoming && null !== outgoing && incoming !== outgoing;
|
|
108
|
+
}
|
|
109
|
+
function moveCornerWaypoint(waypoints, index, desired, path) {
|
|
110
|
+
const i = vertexIndexOf(path, index);
|
|
111
|
+
if (i <= 0 || !waypoints[index]) return waypoints;
|
|
112
|
+
const corner = path[i];
|
|
113
|
+
const next = moveWaypoint(waypoints, index, desired);
|
|
114
|
+
const target = next[index];
|
|
115
|
+
for (const neighbor of [
|
|
116
|
+
path[i - 1],
|
|
117
|
+
path[i + 1]
|
|
118
|
+
]){
|
|
119
|
+
const axis = runAxis(neighbor, corner);
|
|
120
|
+
if (!axis || neighbor.waypointIndex < 0) continue;
|
|
121
|
+
const coord = 'horizontal' === axis ? 'y' : 'x';
|
|
122
|
+
next[neighbor.waypointIndex] = {
|
|
123
|
+
...next[neighbor.waypointIndex],
|
|
124
|
+
[coord]: target[coord]
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const sourceStub = i - 1 === 0 ? waypoints_anchorStub(path[0], corner, target) : [];
|
|
128
|
+
const targetStub = i + 1 === path.length - 1 ? waypoints_anchorStub(path[i + 1], corner, target) : [];
|
|
129
|
+
return [
|
|
130
|
+
...sourceStub,
|
|
131
|
+
...next,
|
|
132
|
+
...targetStub.reverse()
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
function waypoints_anchorStub(anchor, corner, target) {
|
|
136
|
+
const axis = runAxis(anchor, corner);
|
|
137
|
+
if (!axis) return [];
|
|
138
|
+
const [along, across] = 'horizontal' === axis ? [
|
|
139
|
+
'x',
|
|
140
|
+
'y'
|
|
141
|
+
] : [
|
|
142
|
+
'y',
|
|
143
|
+
'x'
|
|
144
|
+
];
|
|
145
|
+
if (Math.abs(target[across] - anchor[across]) <= EDGE_CONSTANTS.COLLINEAR_TOLERANCE) return [];
|
|
146
|
+
const direction = Math.sign(corner[along] - anchor[along]) || 1;
|
|
147
|
+
const stubCoord = snapToGrid(anchor[along] + direction * EDGE_CONSTANTS.STUB_OFFSET);
|
|
148
|
+
return makeStubPair(anchor, axis, stubCoord, target[across]);
|
|
149
|
+
}
|
|
150
|
+
function normalizeWaypoints(waypoints, buildPath) {
|
|
151
|
+
let current = waypoints;
|
|
152
|
+
let path = buildPath(current);
|
|
153
|
+
const reference = pathShape(path);
|
|
154
|
+
const keepsRoute = (candidate)=>pointsEqual(pathShape(buildPath(candidate)), reference);
|
|
155
|
+
const skipped = new Set();
|
|
156
|
+
for(let guard = 0; guard <= 3 * waypoints.length; guard++){
|
|
157
|
+
const index = current.findIndex((wp, i)=>!skipped.has(wp.id) && !isCornerWaypoint(path, i));
|
|
158
|
+
if (index < 0) break;
|
|
159
|
+
const fix = runEndCandidates(current, index, path).find(keepsRoute);
|
|
160
|
+
if (fix) {
|
|
161
|
+
current = fix;
|
|
162
|
+
path = buildPath(current);
|
|
163
|
+
} else skipped.add(current[index].id);
|
|
164
|
+
}
|
|
165
|
+
return current;
|
|
166
|
+
}
|
|
167
|
+
function runEndCandidates(waypoints, index, path) {
|
|
168
|
+
const candidates = [
|
|
169
|
+
removeWaypoint(waypoints, index)
|
|
170
|
+
];
|
|
171
|
+
const i = vertexIndexOf(path, index);
|
|
172
|
+
if (i < 0) return candidates;
|
|
173
|
+
const self = path[i];
|
|
174
|
+
const distance = (p)=>Math.abs(p.x - self.x) + Math.abs(p.y - self.y);
|
|
175
|
+
const ends = [
|
|
176
|
+
i - 1,
|
|
177
|
+
i + 1
|
|
178
|
+
].filter((j)=>j > 0 && j < path.length - 1).map((j)=>path[j]).sort((a, b)=>distance(a) - distance(b));
|
|
179
|
+
for (const end of ends)candidates.push(waypoints.map((wp, j)=>j === index ? {
|
|
180
|
+
...wp,
|
|
181
|
+
x: end.x,
|
|
182
|
+
y: end.y
|
|
183
|
+
} : wp));
|
|
184
|
+
return candidates;
|
|
185
|
+
}
|
|
186
|
+
function moveWaypointConstrained(waypoints, index, desired, buildPath) {
|
|
187
|
+
const initial = waypoints[index];
|
|
188
|
+
if (!initial) return waypoints;
|
|
189
|
+
const start = snapPointToGrid(initial);
|
|
190
|
+
const target = snapPointToGrid(desired);
|
|
191
|
+
const movesX = target.x !== start.x;
|
|
192
|
+
const movesY = target.y !== start.y;
|
|
193
|
+
if (!movesX && !movesY) return moveWaypoint(waypoints, index, start);
|
|
194
|
+
const shapeAt = (p)=>pathShape(buildPath(moveWaypoint(waypoints, index, p)));
|
|
195
|
+
const fullShape = shapeAt(target);
|
|
196
|
+
const keepX = movesX && !pointsEqual(fullShape, shapeAt({
|
|
197
|
+
x: start.x,
|
|
198
|
+
y: target.y
|
|
199
|
+
}));
|
|
200
|
+
const keepY = movesY && !pointsEqual(fullShape, shapeAt({
|
|
201
|
+
x: target.x,
|
|
202
|
+
y: start.y
|
|
203
|
+
}));
|
|
204
|
+
return moveWaypoint(waypoints, index, {
|
|
205
|
+
x: keepX ? target.x : start.x,
|
|
206
|
+
y: keepY ? target.y : start.y
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
function pathShape(points) {
|
|
210
|
+
if (points.length <= 2) return points;
|
|
211
|
+
const start = points[0];
|
|
212
|
+
const end = points[points.length - 1];
|
|
213
|
+
return [
|
|
214
|
+
start,
|
|
215
|
+
...consolidateWaypoints(points.slice(1, -1), start, end),
|
|
216
|
+
end
|
|
217
|
+
];
|
|
218
|
+
}
|
|
219
|
+
function pointsEqual(a, b) {
|
|
220
|
+
if (a.length !== b.length) return false;
|
|
221
|
+
const tol = EDGE_CONSTANTS.COLLINEAR_TOLERANCE;
|
|
222
|
+
return a.every((p, i)=>Math.abs(p.x - b[i].x) <= tol && Math.abs(p.y - b[i].y) <= tol);
|
|
223
|
+
}
|
|
92
224
|
function moveSegmentByDelta(initialWaypoints, initialSegment, delta, initialPathPoints) {
|
|
93
225
|
const moveAxis = 'horizontal' === initialSegment.orientation ? 'y' : 'x';
|
|
94
226
|
const moveValue = 'y' === moveAxis ? delta.y : delta.x;
|
|
@@ -155,4 +287,4 @@ function makeStubPair(anchor, orientation, stubCoord, movedCoordinate) {
|
|
|
155
287
|
}
|
|
156
288
|
];
|
|
157
289
|
}
|
|
158
|
-
export { generateWaypointId, insertWaypoint, materializePathWaypoints, moveSegmentByDelta, moveWaypoint, rebalanceWaypoints, removeWaypoint, waypointsEqual, waypointsPositionallyEqual };
|
|
290
|
+
export { generateWaypointId, insertWaypoint, isCornerWaypoint, materializePathWaypoints, moveCornerWaypoint, moveSegmentByDelta, moveWaypoint, moveWaypointConstrained, normalizeWaypoints, rebalanceWaypoints, removeWaypoint, waypointsEqual, waypointsPositionallyEqual };
|
|
@@ -817,7 +817,7 @@ function buildGuardrailCopy(_) {
|
|
|
817
817
|
}),
|
|
818
818
|
usageNote: _({
|
|
819
819
|
id: 'guardrails.definitions.llm_as_judge.usage-note',
|
|
820
|
-
message: "Judge model calls consume Agent
|
|
820
|
+
message: "Judge model calls consume Platform Units or Agent Units the same way the agent's own LLM calls do. Apply selectively to keep cost predictable, and choose the judge model with cost in mind — rates vary by model."
|
|
821
821
|
}),
|
|
822
822
|
paramLabels: {
|
|
823
823
|
guardrailText: _({
|
|
@@ -786,7 +786,7 @@ function buildGuardrailCopy(_) {
|
|
|
786
786
|
}),
|
|
787
787
|
usageNote: _({
|
|
788
788
|
id: 'guardrails.definitions.llm_as_judge.usage-note',
|
|
789
|
-
message: "Judge model calls consume Agent
|
|
789
|
+
message: "Judge model calls consume Platform Units or Agent Units the same way the agent's own LLM calls do. Apply selectively to keep cost predictable, and choose the judge model with cost in mind — rates vary by model."
|
|
790
790
|
}),
|
|
791
791
|
paramLabels: {
|
|
792
792
|
guardrailText: _({
|