@rxflow/manhattan 0.0.2-alpha.8 → 0.0.2
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/README.md +214 -10
- package/esm/getManHattanPath.js +92 -69
- package/esm/obstacle/ObstacleMap.js +218 -99
- package/esm/obstacle/QuadTree.js +488 -0
- package/esm/options/resolver.js +147 -18
- package/esm/pathfinder/PathCache.js +278 -0
- package/esm/pathfinder/findRoute.js +98 -44
- package/esm/pathfinder/index.js +2 -1
- package/esm/svg/pathConverter.js +170 -1
- package/esm/utils/AdaptiveStepCalculator.js +252 -0
- package/esm/utils/ErrorRecovery.js +499 -0
- package/esm/utils/GlobalGrid.js +259 -0
- package/esm/utils/PerformanceMonitor.js +360 -0
- package/esm/utils/getAnchorPoints.js +0 -4
- package/esm/utils/grid.js +18 -13
- package/esm/utils/heuristics.js +144 -0
- package/esm/utils/index.js +7 -1
- package/esm/utils/pathProcessing.js +270 -0
- package/esm/utils/pathValidation.js +0 -1
- package/esm/utils/rect.js +11 -4
- package/esm/utils/route.js +18 -2
- package/package.json +10 -2
- package/cjs/geometry/Line.d.ts +0 -21
- package/cjs/geometry/Line.d.ts.map +0 -1
- package/cjs/geometry/Line.js +0 -88
- package/cjs/geometry/Point.d.ts +0 -49
- package/cjs/geometry/Point.d.ts.map +0 -1
- package/cjs/geometry/Point.js +0 -94
- package/cjs/geometry/Rectangle.d.ts +0 -41
- package/cjs/geometry/Rectangle.d.ts.map +0 -1
- package/cjs/geometry/Rectangle.js +0 -65
- package/cjs/geometry/collision.d.ts +0 -15
- package/cjs/geometry/collision.d.ts.map +0 -1
- package/cjs/geometry/collision.js +0 -81
- package/cjs/geometry/index.d.ts +0 -5
- package/cjs/geometry/index.d.ts.map +0 -1
- package/cjs/geometry/index.js +0 -45
- package/cjs/getManHattanPath.d.ts +0 -53
- package/cjs/getManHattanPath.d.ts.map +0 -1
- package/cjs/getManHattanPath.js +0 -418
- package/cjs/index.d.ts +0 -16
- package/cjs/index.d.ts.map +0 -1
- package/cjs/index.js +0 -117
- package/cjs/obstacle/ObstacleMap.d.ts +0 -34
- package/cjs/obstacle/ObstacleMap.d.ts.map +0 -1
- package/cjs/obstacle/ObstacleMap.js +0 -223
- package/cjs/obstacle/index.d.ts +0 -2
- package/cjs/obstacle/index.d.ts.map +0 -1
- package/cjs/obstacle/index.js +0 -12
- package/cjs/options/defaults.d.ts +0 -16
- package/cjs/options/defaults.d.ts.map +0 -1
- package/cjs/options/defaults.js +0 -39
- package/cjs/options/index.d.ts +0 -4
- package/cjs/options/index.d.ts.map +0 -1
- package/cjs/options/index.js +0 -38
- package/cjs/options/resolver.d.ts +0 -10
- package/cjs/options/resolver.d.ts.map +0 -1
- package/cjs/options/resolver.js +0 -120
- package/cjs/options/types.d.ts +0 -169
- package/cjs/options/types.d.ts.map +0 -1
- package/cjs/options/types.js +0 -5
- package/cjs/pathfinder/SortedSet.d.ts +0 -35
- package/cjs/pathfinder/SortedSet.d.ts.map +0 -1
- package/cjs/pathfinder/SortedSet.js +0 -95
- package/cjs/pathfinder/findRoute.d.ts +0 -8
- package/cjs/pathfinder/findRoute.d.ts.map +0 -1
- package/cjs/pathfinder/findRoute.js +0 -330
- package/cjs/pathfinder/index.d.ts +0 -3
- package/cjs/pathfinder/index.d.ts.map +0 -1
- package/cjs/pathfinder/index.js +0 -19
- package/cjs/svg/index.d.ts +0 -3
- package/cjs/svg/index.d.ts.map +0 -1
- package/cjs/svg/index.js +0 -31
- package/cjs/svg/pathConverter.d.ts +0 -10
- package/cjs/svg/pathConverter.d.ts.map +0 -1
- package/cjs/svg/pathConverter.js +0 -116
- package/cjs/svg/pathParser.d.ts +0 -11
- package/cjs/svg/pathParser.d.ts.map +0 -1
- package/cjs/svg/pathParser.js +0 -76
- package/cjs/utils/direction.d.ts +0 -24
- package/cjs/utils/direction.d.ts.map +0 -1
- package/cjs/utils/direction.js +0 -54
- package/cjs/utils/getAnchorPoints.d.ts +0 -15
- package/cjs/utils/getAnchorPoints.d.ts.map +0 -1
- package/cjs/utils/getAnchorPoints.js +0 -75
- package/cjs/utils/grid.d.ts +0 -27
- package/cjs/utils/grid.d.ts.map +0 -1
- package/cjs/utils/grid.js +0 -66
- package/cjs/utils/index.d.ts +0 -8
- package/cjs/utils/index.d.ts.map +0 -1
- package/cjs/utils/index.js +0 -82
- package/cjs/utils/node.d.ts +0 -27
- package/cjs/utils/node.d.ts.map +0 -1
- package/cjs/utils/node.js +0 -36
- package/cjs/utils/pathValidation.d.ts +0 -11
- package/cjs/utils/pathValidation.d.ts.map +0 -1
- package/cjs/utils/pathValidation.js +0 -130
- package/cjs/utils/rect.d.ts +0 -9
- package/cjs/utils/rect.d.ts.map +0 -1
- package/cjs/utils/rect.js +0 -103
- package/cjs/utils/route.d.ts +0 -19
- package/cjs/utils/route.d.ts.map +0 -1
- package/cjs/utils/route.js +0 -76
- package/esm/geometry/Line.d.ts +0 -21
- package/esm/geometry/Line.d.ts.map +0 -1
- package/esm/geometry/Point.d.ts +0 -49
- package/esm/geometry/Point.d.ts.map +0 -1
- package/esm/geometry/Rectangle.d.ts +0 -41
- package/esm/geometry/Rectangle.d.ts.map +0 -1
- package/esm/geometry/collision.d.ts +0 -15
- package/esm/geometry/collision.d.ts.map +0 -1
- package/esm/geometry/index.d.ts +0 -5
- package/esm/geometry/index.d.ts.map +0 -1
- package/esm/getManHattanPath.d.ts +0 -53
- package/esm/getManHattanPath.d.ts.map +0 -1
- package/esm/index.d.ts +0 -16
- package/esm/index.d.ts.map +0 -1
- package/esm/obstacle/ObstacleMap.d.ts +0 -34
- package/esm/obstacle/ObstacleMap.d.ts.map +0 -1
- package/esm/obstacle/index.d.ts +0 -2
- package/esm/obstacle/index.d.ts.map +0 -1
- package/esm/options/defaults.d.ts +0 -16
- package/esm/options/defaults.d.ts.map +0 -1
- package/esm/options/index.d.ts +0 -4
- package/esm/options/index.d.ts.map +0 -1
- package/esm/options/resolver.d.ts +0 -10
- package/esm/options/resolver.d.ts.map +0 -1
- package/esm/options/types.d.ts +0 -169
- package/esm/options/types.d.ts.map +0 -1
- package/esm/pathfinder/SortedSet.d.ts +0 -35
- package/esm/pathfinder/SortedSet.d.ts.map +0 -1
- package/esm/pathfinder/findRoute.d.ts +0 -8
- package/esm/pathfinder/findRoute.d.ts.map +0 -1
- package/esm/pathfinder/index.d.ts +0 -3
- package/esm/pathfinder/index.d.ts.map +0 -1
- package/esm/svg/index.d.ts +0 -3
- package/esm/svg/index.d.ts.map +0 -1
- package/esm/svg/pathConverter.d.ts +0 -10
- package/esm/svg/pathConverter.d.ts.map +0 -1
- package/esm/svg/pathParser.d.ts +0 -11
- package/esm/svg/pathParser.d.ts.map +0 -1
- package/esm/utils/direction.d.ts +0 -24
- package/esm/utils/direction.d.ts.map +0 -1
- package/esm/utils/getAnchorPoints.d.ts +0 -15
- package/esm/utils/getAnchorPoints.d.ts.map +0 -1
- package/esm/utils/grid.d.ts +0 -27
- package/esm/utils/grid.d.ts.map +0 -1
- package/esm/utils/index.d.ts +0 -8
- package/esm/utils/index.d.ts.map +0 -1
- package/esm/utils/node.d.ts +0 -27
- package/esm/utils/node.d.ts.map +0 -1
- package/esm/utils/pathValidation.d.ts +0 -11
- package/esm/utils/pathValidation.d.ts.map +0 -1
- package/esm/utils/rect.d.ts +0 -9
- package/esm/utils/rect.d.ts.map +0 -1
- package/esm/utils/route.d.ts +0 -19
- package/esm/utils/route.d.ts.map +0 -1
package/cjs/svg/pathParser.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Point } from '../geometry';
|
|
2
|
-
/**
|
|
3
|
-
* Parse SVG path string to extract points
|
|
4
|
-
* Simplified parser that handles M, L, Q commands
|
|
5
|
-
*/
|
|
6
|
-
export declare function parseSVGPath(pathString: string): Point[];
|
|
7
|
-
/**
|
|
8
|
-
* Simplify path by removing collinear intermediate points
|
|
9
|
-
*/
|
|
10
|
-
export declare function simplifyPath(points: Point[]): Point[];
|
|
11
|
-
//# sourceMappingURL=pathParser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pathParser.d.ts","sourceRoot":"","sources":["../../src/svg/pathParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC;;;GAGG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,EAAE,CA2CxD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CA0BrD"}
|
package/cjs/svg/pathParser.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.parseSVGPath = parseSVGPath;
|
|
7
|
-
exports.simplifyPath = simplifyPath;
|
|
8
|
-
var _geometry = require("../geometry");
|
|
9
|
-
/**
|
|
10
|
-
* Parse SVG path string to extract points
|
|
11
|
-
* Simplified parser that handles M, L, Q commands
|
|
12
|
-
*/
|
|
13
|
-
function parseSVGPath(pathString) {
|
|
14
|
-
const points = [];
|
|
15
|
-
const commands = pathString.match(/[MLQ][^MLQ]*/g);
|
|
16
|
-
if (!commands) return points;
|
|
17
|
-
for (const command of commands) {
|
|
18
|
-
const type = command[0];
|
|
19
|
-
const coords = command.slice(1).trim().split(/[\s,]+/).map(Number);
|
|
20
|
-
if (type === 'M' || type === 'L') {
|
|
21
|
-
// MoveTo or LineTo: x, y
|
|
22
|
-
if (coords.length >= 2) {
|
|
23
|
-
points.push(new _geometry.Point(coords[0], coords[1]));
|
|
24
|
-
}
|
|
25
|
-
} else if (type === 'Q') {
|
|
26
|
-
// Quadratic Bezier: cx, cy, x, y
|
|
27
|
-
// We sample points along the curve for collision detection
|
|
28
|
-
if (coords.length >= 4) {
|
|
29
|
-
const prevPoint = points[points.length - 1];
|
|
30
|
-
if (prevPoint) {
|
|
31
|
-
const cx = coords[0];
|
|
32
|
-
const cy = coords[1];
|
|
33
|
-
const x = coords[2];
|
|
34
|
-
const y = coords[3];
|
|
35
|
-
|
|
36
|
-
// Sample 10 points along the bezier curve for better accuracy
|
|
37
|
-
// This ensures we don't miss intersections with obstacles
|
|
38
|
-
for (let t = 0.1; t <= 1; t += 0.1) {
|
|
39
|
-
const bx = (1 - t) * (1 - t) * prevPoint.x + 2 * (1 - t) * t * cx + t * t * x;
|
|
40
|
-
const by = (1 - t) * (1 - t) * prevPoint.y + 2 * (1 - t) * t * cy + t * t * y;
|
|
41
|
-
points.push(new _geometry.Point(bx, by));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return points;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Simplify path by removing collinear intermediate points
|
|
52
|
-
*/
|
|
53
|
-
function simplifyPath(points) {
|
|
54
|
-
if (points.length <= 2) {
|
|
55
|
-
return points;
|
|
56
|
-
}
|
|
57
|
-
const simplified = [points[0]];
|
|
58
|
-
for (let i = 1; i < points.length - 1; i++) {
|
|
59
|
-
const prev = simplified[simplified.length - 1];
|
|
60
|
-
const current = points[i];
|
|
61
|
-
const next = points[i + 1];
|
|
62
|
-
|
|
63
|
-
// Check if current point is collinear with prev and next
|
|
64
|
-
const isHorizontalLine = prev.y === current.y && current.y === next.y;
|
|
65
|
-
const isVerticalLine = prev.x === current.x && current.x === next.x;
|
|
66
|
-
|
|
67
|
-
// Only keep the point if it's not collinear (i.e., it's a corner)
|
|
68
|
-
if (!isHorizontalLine && !isVerticalLine) {
|
|
69
|
-
simplified.push(current);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Always add the last point
|
|
74
|
-
simplified.push(points[points.length - 1]);
|
|
75
|
-
return simplified;
|
|
76
|
-
}
|
package/cjs/utils/direction.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Point } from '../geometry';
|
|
2
|
-
import type { ResolvedOptions } from '../options';
|
|
3
|
-
import type { Grid } from './grid';
|
|
4
|
-
/**
|
|
5
|
-
* Get direction angle from start point to end point
|
|
6
|
-
* Corrects for grid deformation between start and end
|
|
7
|
-
*/
|
|
8
|
-
export declare function getDirectionAngle(start: Point, end: Point, directionCount: number, grid: Grid, options: ResolvedOptions): number;
|
|
9
|
-
/**
|
|
10
|
-
* Get the change in direction between two direction angles
|
|
11
|
-
*/
|
|
12
|
-
export declare function getDirectionChange(angle1: number, angle2: number): number;
|
|
13
|
-
/**
|
|
14
|
-
* Fix direction offsets according to current grid
|
|
15
|
-
*/
|
|
16
|
-
export declare function getGridOffsets(grid: Grid, options: ResolvedOptions): {
|
|
17
|
-
cost: number;
|
|
18
|
-
offsetX: number;
|
|
19
|
-
offsetY: number;
|
|
20
|
-
angle?: number | undefined;
|
|
21
|
-
gridOffsetX?: number | undefined;
|
|
22
|
-
gridOffsetY?: number | undefined;
|
|
23
|
-
}[];
|
|
24
|
-
//# sourceMappingURL=direction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"direction.d.ts","sourceRoot":"","sources":["../../src/utils/direction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAyBlC;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,KAAK,EACV,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,eAAe,GACvB,MAAM,CAKR;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGzE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe;;;;;;;IASlE"}
|
package/cjs/utils/direction.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getDirectionAngle = getDirectionAngle;
|
|
7
|
-
exports.getDirectionChange = getDirectionChange;
|
|
8
|
-
exports.getGridOffsets = getGridOffsets;
|
|
9
|
-
var _geometry = require("../geometry");
|
|
10
|
-
var _resolver = require("../options/resolver");
|
|
11
|
-
/**
|
|
12
|
-
* Fix angle end point to account for grid deformation
|
|
13
|
-
*/
|
|
14
|
-
function fixAngleEnd(start, end, grid, options) {
|
|
15
|
-
const step = options.step;
|
|
16
|
-
const diffX = end.x - start.x;
|
|
17
|
-
const diffY = end.y - start.y;
|
|
18
|
-
const gridStepsX = diffX / grid.x;
|
|
19
|
-
const gridStepsY = diffY / grid.y;
|
|
20
|
-
const distanceX = gridStepsX * step;
|
|
21
|
-
const distanceY = gridStepsY * step;
|
|
22
|
-
return new _geometry.Point(start.x + distanceX, start.y + distanceY);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get direction angle from start point to end point
|
|
27
|
-
* Corrects for grid deformation between start and end
|
|
28
|
-
*/
|
|
29
|
-
function getDirectionAngle(start, end, directionCount, grid, options) {
|
|
30
|
-
const quadrant = 360 / directionCount;
|
|
31
|
-
const angleTheta = start.theta(fixAngleEnd(start, end, grid, options));
|
|
32
|
-
const normalizedAngle = (0, _resolver.normalizeAngle)(angleTheta + quadrant / 2);
|
|
33
|
-
return quadrant * Math.floor(normalizedAngle / quadrant);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Get the change in direction between two direction angles
|
|
38
|
-
*/
|
|
39
|
-
function getDirectionChange(angle1, angle2) {
|
|
40
|
-
const change = Math.abs(angle1 - angle2);
|
|
41
|
-
return change > 180 ? 360 - change : change;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Fix direction offsets according to current grid
|
|
46
|
-
*/
|
|
47
|
-
function getGridOffsets(grid, options) {
|
|
48
|
-
const step = options.step;
|
|
49
|
-
options.directions.forEach(direction => {
|
|
50
|
-
direction.gridOffsetX = direction.offsetX / step * grid.x;
|
|
51
|
-
direction.gridOffsetY = direction.offsetY / step * grid.y;
|
|
52
|
-
});
|
|
53
|
-
return options.directions;
|
|
54
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Point } from '../geometry';
|
|
2
|
-
import type { ObstacleMap } from '../obstacle';
|
|
3
|
-
import type { Direction } from '../options';
|
|
4
|
-
/**
|
|
5
|
-
* Get accessible anchor points using binary search optimization
|
|
6
|
-
*
|
|
7
|
-
* @param anchor - The anchor point (on node edge)
|
|
8
|
-
* @param position - The position/direction (right, left, top, bottom)
|
|
9
|
-
* @param extensionDistance - The preferred extension distance
|
|
10
|
-
* @param step - The step size for binary search
|
|
11
|
-
* @param obstacleMap - The obstacle map for accessibility checking
|
|
12
|
-
* @returns Array of accessible points, prioritized by distance
|
|
13
|
-
*/
|
|
14
|
-
export declare function getAnchorPoints(anchor: Point, position: Direction, extensionDistance: number, step: number, obstacleMap: ObstacleMap): Point[];
|
|
15
|
-
//# sourceMappingURL=getAnchorPoints.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAnchorPoints.d.ts","sourceRoot":"","sources":["../../src/utils/getAnchorPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,KAAK,EACb,QAAQ,EAAE,SAAS,EACnB,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,WAAW,GACvB,KAAK,EAAE,CA0DT"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getAnchorPoints = getAnchorPoints;
|
|
7
|
-
var _geometry = require("../geometry");
|
|
8
|
-
/**
|
|
9
|
-
* Get accessible anchor points using binary search optimization
|
|
10
|
-
*
|
|
11
|
-
* @param anchor - The anchor point (on node edge)
|
|
12
|
-
* @param position - The position/direction (right, left, top, bottom)
|
|
13
|
-
* @param extensionDistance - The preferred extension distance
|
|
14
|
-
* @param step - The step size for binary search
|
|
15
|
-
* @param obstacleMap - The obstacle map for accessibility checking
|
|
16
|
-
* @returns Array of accessible points, prioritized by distance
|
|
17
|
-
*/
|
|
18
|
-
function getAnchorPoints(anchor, position, extensionDistance, step, obstacleMap) {
|
|
19
|
-
const points = [];
|
|
20
|
-
|
|
21
|
-
// Determine direction vector based on position
|
|
22
|
-
const directionMap = {
|
|
23
|
-
'right': {
|
|
24
|
-
dx: 1,
|
|
25
|
-
dy: 0
|
|
26
|
-
},
|
|
27
|
-
'left': {
|
|
28
|
-
dx: -1,
|
|
29
|
-
dy: 0
|
|
30
|
-
},
|
|
31
|
-
'top': {
|
|
32
|
-
dx: 0,
|
|
33
|
-
dy: -1
|
|
34
|
-
},
|
|
35
|
-
'bottom': {
|
|
36
|
-
dx: 0,
|
|
37
|
-
dy: 1
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const dir = directionMap[position];
|
|
41
|
-
if (!dir) {
|
|
42
|
-
console.warn(`[getAnchorPoints] Invalid position: ${position}`);
|
|
43
|
-
return [anchor];
|
|
44
|
-
}
|
|
45
|
-
console.log(`[getAnchorPoints] Finding points for position '${position}' from (${anchor.x}, ${anchor.y})`);
|
|
46
|
-
|
|
47
|
-
// 1. First try extensionDistance
|
|
48
|
-
const extensionPoint = new _geometry.Point(anchor.x + dir.dx * extensionDistance, anchor.y + dir.dy * extensionDistance);
|
|
49
|
-
if (obstacleMap.isAccessible(extensionPoint)) {
|
|
50
|
-
console.log(`[getAnchorPoints] Extension point (${extensionPoint.x}, ${extensionPoint.y}) is accessible`);
|
|
51
|
-
points.push(extensionPoint);
|
|
52
|
-
return points;
|
|
53
|
-
}
|
|
54
|
-
console.log(`[getAnchorPoints] Extension point (${extensionPoint.x}, ${extensionPoint.y}) is blocked, trying binary search`);
|
|
55
|
-
|
|
56
|
-
// 2. If extensionDistance point is blocked, use binary search with step
|
|
57
|
-
// Try: step -> step/2 -> step/4 -> ... -> 1px
|
|
58
|
-
let distance = step;
|
|
59
|
-
while (distance >= 1) {
|
|
60
|
-
const testPoint = new _geometry.Point(anchor.x + dir.dx * distance, anchor.y + dir.dy * distance);
|
|
61
|
-
if (obstacleMap.isAccessible(testPoint)) {
|
|
62
|
-
console.log(`[getAnchorPoints] Found accessible point at distance ${distance}px: (${testPoint.x}, ${testPoint.y})`);
|
|
63
|
-
points.push(testPoint);
|
|
64
|
-
return points;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Halve the distance for next iteration
|
|
68
|
-
distance = Math.floor(distance / 2);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// 3. If still no accessible point found, return the anchor itself
|
|
72
|
-
console.warn(`[getAnchorPoints] No accessible point found, using anchor itself: (${anchor.x}, ${anchor.y})`);
|
|
73
|
-
points.push(anchor);
|
|
74
|
-
return points;
|
|
75
|
-
}
|
package/cjs/utils/grid.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Point } from '../geometry';
|
|
2
|
-
/**
|
|
3
|
-
* Grid interface for dynamic grid system
|
|
4
|
-
*/
|
|
5
|
-
export interface Grid {
|
|
6
|
-
source: Point;
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Get grid size in x and y dimensions, adapted to source and target positions
|
|
12
|
-
* Uses global grid system with origin at (0, 0) for path alignment
|
|
13
|
-
*/
|
|
14
|
-
export declare function getGrid(step: number, source: Point, target: Point): Grid;
|
|
15
|
-
/**
|
|
16
|
-
* Snap a value to grid
|
|
17
|
-
*/
|
|
18
|
-
export declare function snapToGrid(value: number, gridSize: number): number;
|
|
19
|
-
/**
|
|
20
|
-
* Align point to grid and apply precision
|
|
21
|
-
*/
|
|
22
|
-
export declare function align(point: Point, grid: Grid, precision: number): Point;
|
|
23
|
-
/**
|
|
24
|
-
* Round point coordinates
|
|
25
|
-
*/
|
|
26
|
-
export declare function round(point: Point, precision: number): Point;
|
|
27
|
-
//# sourceMappingURL=grid.d.ts.map
|
package/cjs/utils/grid.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../src/utils/grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,KAAK,CAAA;IACb,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAWD;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,IAAI,CAMxE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAYD;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK,CAExE;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK,CAE5D"}
|
package/cjs/utils/grid.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.align = align;
|
|
7
|
-
exports.getGrid = getGrid;
|
|
8
|
-
exports.round = round;
|
|
9
|
-
exports.snapToGrid = snapToGrid;
|
|
10
|
-
var _geometry = require("../geometry");
|
|
11
|
-
/**
|
|
12
|
-
* Grid interface for dynamic grid system
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Get grid dimension for a single axis
|
|
17
|
-
*/
|
|
18
|
-
function getGridDimension(diff, step) {
|
|
19
|
-
// Always return fixed step size to maintain consistent padding
|
|
20
|
-
// This ensures paths stay at least 'padding' distance from obstacles
|
|
21
|
-
return step;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Get grid size in x and y dimensions, adapted to source and target positions
|
|
26
|
-
* Uses global grid system with origin at (0, 0) for path alignment
|
|
27
|
-
*/
|
|
28
|
-
function getGrid(step, source, target) {
|
|
29
|
-
return {
|
|
30
|
-
source: new _geometry.Point(0, 0),
|
|
31
|
-
// Use global origin for consistent grid alignment
|
|
32
|
-
x: getGridDimension(target.x - source.x, step),
|
|
33
|
-
y: getGridDimension(target.y - source.y, step)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Snap a value to grid
|
|
39
|
-
*/
|
|
40
|
-
function snapToGrid(value, gridSize) {
|
|
41
|
-
return Math.round(value / gridSize) * gridSize;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Snap a point to grid
|
|
46
|
-
*/
|
|
47
|
-
function snapPointToGrid(point, grid) {
|
|
48
|
-
const source = grid.source;
|
|
49
|
-
const x = snapToGrid(point.x - source.x, grid.x) + source.x;
|
|
50
|
-
const y = snapToGrid(point.y - source.y, grid.y) + source.y;
|
|
51
|
-
return new _geometry.Point(x, y);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Align point to grid and apply precision
|
|
56
|
-
*/
|
|
57
|
-
function align(point, grid, precision) {
|
|
58
|
-
return snapPointToGrid(point.clone(), grid).round(precision);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Round point coordinates
|
|
63
|
-
*/
|
|
64
|
-
function round(point, precision) {
|
|
65
|
-
return point.round(precision);
|
|
66
|
-
}
|
package/cjs/utils/index.d.ts
DELETED
package/cjs/utils/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA"}
|
package/cjs/utils/index.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _grid = require("./grid");
|
|
7
|
-
Object.keys(_grid).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _grid[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _grid[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _direction = require("./direction");
|
|
18
|
-
Object.keys(_direction).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _direction[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _direction[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _rect = require("./rect");
|
|
29
|
-
Object.keys(_rect).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _rect[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _rect[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _route = require("./route");
|
|
40
|
-
Object.keys(_route).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _route[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _route[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
var _node = require("./node");
|
|
51
|
-
Object.keys(_node).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _node[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _node[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
var _pathValidation = require("./pathValidation");
|
|
62
|
-
Object.keys(_pathValidation).forEach(function (key) {
|
|
63
|
-
if (key === "default" || key === "__esModule") return;
|
|
64
|
-
if (key in exports && exports[key] === _pathValidation[key]) return;
|
|
65
|
-
Object.defineProperty(exports, key, {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function () {
|
|
68
|
-
return _pathValidation[key];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
var _getAnchorPoints = require("./getAnchorPoints");
|
|
73
|
-
Object.keys(_getAnchorPoints).forEach(function (key) {
|
|
74
|
-
if (key === "default" || key === "__esModule") return;
|
|
75
|
-
if (key in exports && exports[key] === _getAnchorPoints[key]) return;
|
|
76
|
-
Object.defineProperty(exports, key, {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function () {
|
|
79
|
-
return _getAnchorPoints[key];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
package/cjs/utils/node.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { InternalNode } from '../options';
|
|
2
|
-
/**
|
|
3
|
-
* Node dimensions interface
|
|
4
|
-
*/
|
|
5
|
-
export interface NodeDimensions {
|
|
6
|
-
width: number;
|
|
7
|
-
height: number;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Get node dimensions following ReactFlow's internal logic
|
|
11
|
-
* Priority: measured > direct property > initialWidth/Height > 0
|
|
12
|
-
*
|
|
13
|
-
* @param node - ReactFlow internal node
|
|
14
|
-
* @returns Node dimensions with width and height
|
|
15
|
-
*/
|
|
16
|
-
export declare function getNodeDimensions(node: InternalNode): NodeDimensions;
|
|
17
|
-
/**
|
|
18
|
-
* Get node absolute position from internals
|
|
19
|
-
*
|
|
20
|
-
* @param node - ReactFlow internal node
|
|
21
|
-
* @returns Absolute position { x, y }
|
|
22
|
-
*/
|
|
23
|
-
export declare function getNodePosition(node: InternalNode): {
|
|
24
|
-
x: number;
|
|
25
|
-
y: number;
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=node.d.ts.map
|
package/cjs/utils/node.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/utils/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,cAAc,CAKpE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAE5E"}
|
package/cjs/utils/node.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getNodeDimensions = getNodeDimensions;
|
|
7
|
-
exports.getNodePosition = getNodePosition;
|
|
8
|
-
/**
|
|
9
|
-
* Node dimensions interface
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Get node dimensions following ReactFlow's internal logic
|
|
14
|
-
* Priority: measured > direct property > initialWidth/Height > 0
|
|
15
|
-
*
|
|
16
|
-
* @param node - ReactFlow internal node
|
|
17
|
-
* @returns Node dimensions with width and height
|
|
18
|
-
*/
|
|
19
|
-
function getNodeDimensions(node) {
|
|
20
|
-
const width = node.measured?.width ?? node.width ?? node.initialWidth ?? 0;
|
|
21
|
-
const height = node.measured?.height ?? node.height ?? node.initialHeight ?? 0;
|
|
22
|
-
return {
|
|
23
|
-
width,
|
|
24
|
-
height
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Get node absolute position from internals
|
|
30
|
-
*
|
|
31
|
-
* @param node - ReactFlow internal node
|
|
32
|
-
* @returns Absolute position { x, y }
|
|
33
|
-
*/
|
|
34
|
-
function getNodePosition(node) {
|
|
35
|
-
return node.internals.positionAbsolute;
|
|
36
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Point } from '../geometry';
|
|
2
|
-
import type { NodeLookup } from '../options';
|
|
3
|
-
/**
|
|
4
|
-
* Check if a path intersects with any obstacles (nodes)
|
|
5
|
-
* A path is considered to intersect if it has >= 2 unique intersection points with a node
|
|
6
|
-
*
|
|
7
|
-
* Note: pathPoints should be pre-processed by parseSVGPath which samples bezier curves
|
|
8
|
-
* into line segments, so this function works correctly with curved paths
|
|
9
|
-
*/
|
|
10
|
-
export declare function pathIntersectsObstacles(pathPoints: Point[], nodeLookup: NodeLookup): boolean;
|
|
11
|
-
//# sourceMappingURL=pathValidation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pathValidation.d.ts","sourceRoot":"","sources":["../../src/utils/pathValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAa,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAyF5C;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAoC5F"}
|