@rxflow/manhattan 0.0.2 → 0.0.3
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/cjs/geometry/Line.d.ts +21 -0
- package/cjs/geometry/Line.d.ts.map +1 -0
- package/cjs/geometry/Line.js +88 -0
- package/cjs/geometry/Point.d.ts +49 -0
- package/cjs/geometry/Point.d.ts.map +1 -0
- package/cjs/geometry/Point.js +94 -0
- package/cjs/geometry/Rectangle.d.ts +41 -0
- package/cjs/geometry/Rectangle.d.ts.map +1 -0
- package/cjs/geometry/Rectangle.js +65 -0
- package/cjs/geometry/collision.d.ts +15 -0
- package/cjs/geometry/collision.d.ts.map +1 -0
- package/cjs/geometry/collision.js +81 -0
- package/cjs/geometry/index.d.ts +5 -0
- package/cjs/geometry/index.d.ts.map +1 -0
- package/cjs/geometry/index.js +45 -0
- package/cjs/getManHattanPath.d.ts +53 -0
- package/cjs/getManHattanPath.d.ts.map +1 -0
- package/cjs/getManHattanPath.js +449 -0
- package/cjs/index.d.ts +16 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +117 -0
- package/cjs/obstacle/ObstacleMap.d.ts +66 -0
- package/cjs/obstacle/ObstacleMap.d.ts.map +1 -0
- package/cjs/obstacle/ObstacleMap.js +328 -0
- package/cjs/obstacle/QuadTree.d.ts +119 -0
- package/cjs/obstacle/QuadTree.d.ts.map +1 -0
- package/cjs/obstacle/QuadTree.js +334 -0
- package/cjs/obstacle/index.d.ts +2 -0
- package/cjs/obstacle/index.d.ts.map +1 -0
- package/cjs/obstacle/index.js +12 -0
- package/cjs/options/defaults.d.ts +16 -0
- package/cjs/options/defaults.d.ts.map +1 -0
- package/cjs/options/defaults.js +39 -0
- package/cjs/options/index.d.ts +4 -0
- package/cjs/options/index.d.ts.map +1 -0
- package/cjs/options/index.js +38 -0
- package/cjs/options/resolver.d.ts +10 -0
- package/cjs/options/resolver.d.ts.map +1 -0
- package/cjs/options/resolver.js +248 -0
- package/cjs/options/types.d.ts +210 -0
- package/cjs/options/types.d.ts.map +1 -0
- package/cjs/options/types.js +5 -0
- package/cjs/pathfinder/PathCache.d.ts +92 -0
- package/cjs/pathfinder/PathCache.d.ts.map +1 -0
- package/cjs/pathfinder/PathCache.js +249 -0
- package/cjs/pathfinder/SortedSet.d.ts +35 -0
- package/cjs/pathfinder/SortedSet.d.ts.map +1 -0
- package/cjs/pathfinder/SortedSet.js +95 -0
- package/cjs/pathfinder/findRoute.d.ts +8 -0
- package/cjs/pathfinder/findRoute.d.ts.map +1 -0
- package/cjs/pathfinder/findRoute.js +395 -0
- package/cjs/pathfinder/index.d.ts +4 -0
- package/cjs/pathfinder/index.d.ts.map +1 -0
- package/cjs/pathfinder/index.js +44 -0
- package/cjs/svg/index.d.ts +3 -0
- package/cjs/svg/index.d.ts.map +1 -0
- package/cjs/svg/index.js +31 -0
- package/cjs/svg/pathConverter.d.ts +23 -0
- package/cjs/svg/pathConverter.d.ts.map +1 -0
- package/cjs/svg/pathConverter.js +285 -0
- package/cjs/svg/pathParser.d.ts +11 -0
- package/cjs/svg/pathParser.d.ts.map +1 -0
- package/cjs/svg/pathParser.js +76 -0
- package/cjs/utils/AdaptiveStepCalculator.d.ts +90 -0
- package/cjs/utils/AdaptiveStepCalculator.d.ts.map +1 -0
- package/cjs/utils/AdaptiveStepCalculator.js +224 -0
- package/cjs/utils/ErrorRecovery.d.ts +182 -0
- package/cjs/utils/ErrorRecovery.d.ts.map +1 -0
- package/cjs/utils/ErrorRecovery.js +413 -0
- package/cjs/utils/GlobalGrid.d.ts +99 -0
- package/cjs/utils/GlobalGrid.d.ts.map +1 -0
- package/cjs/utils/GlobalGrid.js +224 -0
- package/cjs/utils/PerformanceMonitor.d.ts +139 -0
- package/cjs/utils/PerformanceMonitor.d.ts.map +1 -0
- package/cjs/utils/PerformanceMonitor.js +305 -0
- package/cjs/utils/direction.d.ts +24 -0
- package/cjs/utils/direction.d.ts.map +1 -0
- package/cjs/utils/direction.js +54 -0
- package/cjs/utils/getAnchorPoints.d.ts +15 -0
- package/cjs/utils/getAnchorPoints.d.ts.map +1 -0
- package/cjs/utils/getAnchorPoints.js +71 -0
- package/cjs/utils/grid.d.ts +42 -0
- package/cjs/utils/grid.d.ts.map +1 -0
- package/cjs/utils/grid.js +73 -0
- package/cjs/utils/heuristics.d.ts +61 -0
- package/cjs/utils/heuristics.d.ts.map +1 -0
- package/cjs/utils/heuristics.js +141 -0
- package/cjs/utils/index.d.ts +14 -0
- package/cjs/utils/index.d.ts.map +1 -0
- package/cjs/utils/index.js +148 -0
- package/cjs/utils/node.d.ts +27 -0
- package/cjs/utils/node.d.ts.map +1 -0
- package/cjs/utils/node.js +36 -0
- package/cjs/utils/pathProcessing.d.ts +45 -0
- package/cjs/utils/pathProcessing.d.ts.map +1 -0
- package/cjs/utils/pathProcessing.js +270 -0
- package/cjs/utils/pathValidation.d.ts +11 -0
- package/cjs/utils/pathValidation.d.ts.map +1 -0
- package/cjs/utils/pathValidation.js +129 -0
- package/cjs/utils/rect.d.ts +9 -0
- package/cjs/utils/rect.d.ts.map +1 -0
- package/cjs/utils/rect.js +110 -0
- package/cjs/utils/route.d.ts +19 -0
- package/cjs/utils/route.d.ts.map +1 -0
- package/cjs/utils/route.js +92 -0
- package/esm/geometry/Line.d.ts +21 -0
- package/esm/geometry/Line.d.ts.map +1 -0
- package/esm/geometry/Point.d.ts +49 -0
- package/esm/geometry/Point.d.ts.map +1 -0
- package/esm/geometry/Rectangle.d.ts +41 -0
- package/esm/geometry/Rectangle.d.ts.map +1 -0
- package/esm/geometry/collision.d.ts +15 -0
- package/esm/geometry/collision.d.ts.map +1 -0
- package/esm/geometry/index.d.ts +5 -0
- package/esm/geometry/index.d.ts.map +1 -0
- package/esm/getManHattanPath.d.ts +53 -0
- package/esm/getManHattanPath.d.ts.map +1 -0
- package/esm/index.d.ts +16 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/obstacle/ObstacleMap.d.ts +66 -0
- package/esm/obstacle/ObstacleMap.d.ts.map +1 -0
- package/esm/obstacle/QuadTree.d.ts +119 -0
- package/esm/obstacle/QuadTree.d.ts.map +1 -0
- package/esm/obstacle/index.d.ts +2 -0
- package/esm/obstacle/index.d.ts.map +1 -0
- package/esm/options/defaults.d.ts +16 -0
- package/esm/options/defaults.d.ts.map +1 -0
- package/esm/options/index.d.ts +4 -0
- package/esm/options/index.d.ts.map +1 -0
- package/esm/options/resolver.d.ts +10 -0
- package/esm/options/resolver.d.ts.map +1 -0
- package/esm/options/types.d.ts +210 -0
- package/esm/options/types.d.ts.map +1 -0
- package/esm/pathfinder/PathCache.d.ts +92 -0
- package/esm/pathfinder/PathCache.d.ts.map +1 -0
- package/esm/pathfinder/SortedSet.d.ts +35 -0
- package/esm/pathfinder/SortedSet.d.ts.map +1 -0
- package/esm/pathfinder/findRoute.d.ts +8 -0
- package/esm/pathfinder/findRoute.d.ts.map +1 -0
- package/esm/pathfinder/index.d.ts +4 -0
- package/esm/pathfinder/index.d.ts.map +1 -0
- package/esm/svg/index.d.ts +3 -0
- package/esm/svg/index.d.ts.map +1 -0
- package/esm/svg/pathConverter.d.ts +23 -0
- package/esm/svg/pathConverter.d.ts.map +1 -0
- package/esm/svg/pathParser.d.ts +11 -0
- package/esm/svg/pathParser.d.ts.map +1 -0
- package/esm/utils/AdaptiveStepCalculator.d.ts +90 -0
- package/esm/utils/AdaptiveStepCalculator.d.ts.map +1 -0
- package/esm/utils/ErrorRecovery.d.ts +182 -0
- package/esm/utils/ErrorRecovery.d.ts.map +1 -0
- package/esm/utils/GlobalGrid.d.ts +99 -0
- package/esm/utils/GlobalGrid.d.ts.map +1 -0
- package/esm/utils/PerformanceMonitor.d.ts +139 -0
- package/esm/utils/PerformanceMonitor.d.ts.map +1 -0
- package/esm/utils/direction.d.ts +24 -0
- package/esm/utils/direction.d.ts.map +1 -0
- package/esm/utils/getAnchorPoints.d.ts +15 -0
- package/esm/utils/getAnchorPoints.d.ts.map +1 -0
- package/esm/utils/grid.d.ts +42 -0
- package/esm/utils/grid.d.ts.map +1 -0
- package/esm/utils/heuristics.d.ts +61 -0
- package/esm/utils/heuristics.d.ts.map +1 -0
- package/esm/utils/index.d.ts +14 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/node.d.ts +27 -0
- package/esm/utils/node.d.ts.map +1 -0
- package/esm/utils/pathProcessing.d.ts +45 -0
- package/esm/utils/pathProcessing.d.ts.map +1 -0
- package/esm/utils/pathValidation.d.ts +11 -0
- package/esm/utils/pathValidation.d.ts.map +1 -0
- package/esm/utils/rect.d.ts +9 -0
- package/esm/utils/rect.d.ts.map +1 -0
- package/esm/utils/route.d.ts +19 -0
- package/esm/utils/route.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,CAsDT"}
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
|
|
46
|
+
// 1. First try extensionDistance
|
|
47
|
+
const extensionPoint = new _geometry.Point(anchor.x + dir.dx * extensionDistance, anchor.y + dir.dy * extensionDistance);
|
|
48
|
+
if (obstacleMap.isAccessible(extensionPoint)) {
|
|
49
|
+
points.push(extensionPoint);
|
|
50
|
+
return points;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 2. If extensionDistance point is blocked, use binary search with step
|
|
54
|
+
// Try: step -> step/2 -> step/4 -> ... -> 1px
|
|
55
|
+
let distance = step;
|
|
56
|
+
while (distance >= 1) {
|
|
57
|
+
const testPoint = new _geometry.Point(anchor.x + dir.dx * distance, anchor.y + dir.dy * distance);
|
|
58
|
+
if (obstacleMap.isAccessible(testPoint)) {
|
|
59
|
+
points.push(testPoint);
|
|
60
|
+
return points;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Halve the distance for next iteration
|
|
64
|
+
distance = Math.floor(distance / 2);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 3. If still no accessible point found, return the anchor itself
|
|
68
|
+
console.warn(`[getAnchorPoints] No accessible point found, using anchor itself: (${anchor.x}, ${anchor.y})`);
|
|
69
|
+
points.push(anchor);
|
|
70
|
+
return points;
|
|
71
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Point } from '../geometry';
|
|
2
|
+
import { GlobalGrid } from './GlobalGrid';
|
|
3
|
+
/**
|
|
4
|
+
* Grid interface for dynamic grid system
|
|
5
|
+
*/
|
|
6
|
+
export interface Grid {
|
|
7
|
+
source: Point;
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Get grid size in x and y dimensions, adapted to source and target positions
|
|
13
|
+
* Uses global grid system with origin at (0, 0) for path alignment
|
|
14
|
+
*
|
|
15
|
+
* @param step - The grid step size
|
|
16
|
+
* @param source - Source point (used for reference, not as origin)
|
|
17
|
+
* @param target - Target point (used for reference, not as origin)
|
|
18
|
+
* @returns Grid configuration with global origin
|
|
19
|
+
*/
|
|
20
|
+
export declare function getGrid(step: number, source: Point, target: Point): Grid;
|
|
21
|
+
/**
|
|
22
|
+
* Create a GlobalGrid instance from step size
|
|
23
|
+
* This is the preferred way to create grids for new code
|
|
24
|
+
*/
|
|
25
|
+
export declare function createGlobalGrid(step: number): GlobalGrid;
|
|
26
|
+
/**
|
|
27
|
+
* Snap a value to grid
|
|
28
|
+
*/
|
|
29
|
+
export declare function snapToGrid(value: number, gridSize: number): number;
|
|
30
|
+
/**
|
|
31
|
+
* Snap a point to grid using global origin
|
|
32
|
+
*/
|
|
33
|
+
export declare function snapPointToGrid(point: Point, grid: Grid): Point;
|
|
34
|
+
/**
|
|
35
|
+
* Align point to grid and apply precision
|
|
36
|
+
*/
|
|
37
|
+
export declare function align(point: Point, grid: Grid, precision: number): Point;
|
|
38
|
+
/**
|
|
39
|
+
* Round point coordinates
|
|
40
|
+
*/
|
|
41
|
+
export declare function round(point: Point, precision: number): Point;
|
|
42
|
+
//# sourceMappingURL=grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../src/utils/grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,KAAK,CAAA;IACb,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,IAAI,CAMxE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAEzD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,CAK/D;AAED;;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"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.align = align;
|
|
7
|
+
exports.createGlobalGrid = createGlobalGrid;
|
|
8
|
+
exports.getGrid = getGrid;
|
|
9
|
+
exports.round = round;
|
|
10
|
+
exports.snapPointToGrid = snapPointToGrid;
|
|
11
|
+
exports.snapToGrid = snapToGrid;
|
|
12
|
+
var _geometry = require("../geometry");
|
|
13
|
+
var _GlobalGrid = require("./GlobalGrid");
|
|
14
|
+
/**
|
|
15
|
+
* Grid interface for dynamic grid system
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get grid size in x and y dimensions, adapted to source and target positions
|
|
20
|
+
* Uses global grid system with origin at (0, 0) for path alignment
|
|
21
|
+
*
|
|
22
|
+
* @param step - The grid step size
|
|
23
|
+
* @param source - Source point (used for reference, not as origin)
|
|
24
|
+
* @param target - Target point (used for reference, not as origin)
|
|
25
|
+
* @returns Grid configuration with global origin
|
|
26
|
+
*/
|
|
27
|
+
function getGrid(step, source, target) {
|
|
28
|
+
return {
|
|
29
|
+
source: new _geometry.Point(0, 0),
|
|
30
|
+
// Use global origin for consistent grid alignment
|
|
31
|
+
x: step,
|
|
32
|
+
y: step
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Create a GlobalGrid instance from step size
|
|
38
|
+
* This is the preferred way to create grids for new code
|
|
39
|
+
*/
|
|
40
|
+
function createGlobalGrid(step) {
|
|
41
|
+
return _GlobalGrid.GlobalGrid.uniform(step);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Snap a value to grid
|
|
46
|
+
*/
|
|
47
|
+
function snapToGrid(value, gridSize) {
|
|
48
|
+
return Math.round(value / gridSize) * gridSize;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Snap a point to grid using global origin
|
|
53
|
+
*/
|
|
54
|
+
function snapPointToGrid(point, grid) {
|
|
55
|
+
const source = grid.source;
|
|
56
|
+
const x = snapToGrid(point.x - source.x, grid.x) + source.x;
|
|
57
|
+
const y = snapToGrid(point.y - source.y, grid.y) + source.y;
|
|
58
|
+
return new _geometry.Point(x, y);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Align point to grid and apply precision
|
|
63
|
+
*/
|
|
64
|
+
function align(point, grid, precision) {
|
|
65
|
+
return snapPointToGrid(point.clone(), grid).round(precision);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Round point coordinates
|
|
70
|
+
*/
|
|
71
|
+
function round(point, precision) {
|
|
72
|
+
return point.round(precision);
|
|
73
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heuristics - 启发式函数模块
|
|
3
|
+
*
|
|
4
|
+
* 提供多种启发式函数用于 A* 算法:
|
|
5
|
+
* - Manhattan: 曼哈顿距离(默认)
|
|
6
|
+
* - Euclidean: 欧几里得距离
|
|
7
|
+
* - Octile: 八方向距离
|
|
8
|
+
*
|
|
9
|
+
* Implements: Requirements 3.1
|
|
10
|
+
*/
|
|
11
|
+
import { Point } from '../geometry';
|
|
12
|
+
/**
|
|
13
|
+
* 启发式函数类型
|
|
14
|
+
*/
|
|
15
|
+
export type HeuristicType = 'manhattan' | 'euclidean' | 'octile';
|
|
16
|
+
/**
|
|
17
|
+
* 启发式函数配置
|
|
18
|
+
*/
|
|
19
|
+
export interface HeuristicConfig {
|
|
20
|
+
/** 启发式函数类型 */
|
|
21
|
+
type: HeuristicType;
|
|
22
|
+
/** 启发式权重(> 1 加速但可能不是最优) */
|
|
23
|
+
weight: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 默认启发式配置
|
|
27
|
+
*/
|
|
28
|
+
export declare const DEFAULT_HEURISTIC_CONFIG: HeuristicConfig;
|
|
29
|
+
/**
|
|
30
|
+
* 计算曼哈顿距离
|
|
31
|
+
* 适用于只能水平或垂直移动的场景
|
|
32
|
+
*/
|
|
33
|
+
export declare function manhattanDistance(from: Point, to: Point): number;
|
|
34
|
+
/**
|
|
35
|
+
* 计算欧几里得距离
|
|
36
|
+
* 适用于可以任意方向移动的场景
|
|
37
|
+
*/
|
|
38
|
+
export declare function euclideanDistance(from: Point, to: Point): number;
|
|
39
|
+
/**
|
|
40
|
+
* 计算八方向距离(Octile/Chebyshev)
|
|
41
|
+
* 适用于可以对角移动的场景
|
|
42
|
+
*/
|
|
43
|
+
export declare function octileDistance(from: Point, to: Point): number;
|
|
44
|
+
/**
|
|
45
|
+
* 根据配置计算启发式值
|
|
46
|
+
*/
|
|
47
|
+
export declare function calculateHeuristic(from: Point, to: Point, config?: HeuristicConfig): number;
|
|
48
|
+
/**
|
|
49
|
+
* 计算到多个目标点的最小启发式值
|
|
50
|
+
*/
|
|
51
|
+
export declare function calculateMinHeuristic(from: Point, targets: Point[], config?: HeuristicConfig): number;
|
|
52
|
+
/**
|
|
53
|
+
* 方向优先级计算
|
|
54
|
+
* 优先考虑与目标方向一致的移动
|
|
55
|
+
*/
|
|
56
|
+
export declare function calculateDirectionPriority(current: Point, neighbor: Point, target: Point, weight?: number): number;
|
|
57
|
+
/**
|
|
58
|
+
* 创建启发式函数
|
|
59
|
+
*/
|
|
60
|
+
export declare function createHeuristicFunction(config?: HeuristicConfig): (from: Point, targets: Point[]) => number;
|
|
61
|
+
//# sourceMappingURL=heuristics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heuristics.d.ts","sourceRoot":"","sources":["../../src/utils/heuristics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAA;AAEhE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,cAAc;IACd,IAAI,EAAE,aAAa,CAAA;IACnB,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,eAGtC,CAAA;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,CAEhE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,CAIhE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,CAO7D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,KAAK,EACX,EAAE,EAAE,KAAK,EACT,MAAM,GAAE,eAA0C,GACjD,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,KAAK,EAAE,EAChB,MAAM,GAAE,eAA0C,GACjD,MAAM,CAWR;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,KAAK,EACd,QAAQ,EAAE,KAAK,EACf,MAAM,EAAE,KAAK,EACb,MAAM,GAAE,MAAY,GACnB,MAAM,CAuBR;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,GAAE,eAA0C,GACjD,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,MAAM,CAI3C"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DEFAULT_HEURISTIC_CONFIG = void 0;
|
|
7
|
+
exports.calculateDirectionPriority = calculateDirectionPriority;
|
|
8
|
+
exports.calculateHeuristic = calculateHeuristic;
|
|
9
|
+
exports.calculateMinHeuristic = calculateMinHeuristic;
|
|
10
|
+
exports.createHeuristicFunction = createHeuristicFunction;
|
|
11
|
+
exports.euclideanDistance = euclideanDistance;
|
|
12
|
+
exports.manhattanDistance = manhattanDistance;
|
|
13
|
+
exports.octileDistance = octileDistance;
|
|
14
|
+
/**
|
|
15
|
+
* Heuristics - 启发式函数模块
|
|
16
|
+
*
|
|
17
|
+
* 提供多种启发式函数用于 A* 算法:
|
|
18
|
+
* - Manhattan: 曼哈顿距离(默认)
|
|
19
|
+
* - Euclidean: 欧几里得距离
|
|
20
|
+
* - Octile: 八方向距离
|
|
21
|
+
*
|
|
22
|
+
* Implements: Requirements 3.1
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 启发式函数类型
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 启发式函数配置
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 默认启发式配置
|
|
35
|
+
*/
|
|
36
|
+
const DEFAULT_HEURISTIC_CONFIG = exports.DEFAULT_HEURISTIC_CONFIG = {
|
|
37
|
+
type: 'manhattan',
|
|
38
|
+
weight: 1.0
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 计算曼哈顿距离
|
|
43
|
+
* 适用于只能水平或垂直移动的场景
|
|
44
|
+
*/
|
|
45
|
+
function manhattanDistance(from, to) {
|
|
46
|
+
return Math.abs(from.x - to.x) + Math.abs(from.y - to.y);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 计算欧几里得距离
|
|
51
|
+
* 适用于可以任意方向移动的场景
|
|
52
|
+
*/
|
|
53
|
+
function euclideanDistance(from, to) {
|
|
54
|
+
const dx = from.x - to.x;
|
|
55
|
+
const dy = from.y - to.y;
|
|
56
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 计算八方向距离(Octile/Chebyshev)
|
|
61
|
+
* 适用于可以对角移动的场景
|
|
62
|
+
*/
|
|
63
|
+
function octileDistance(from, to) {
|
|
64
|
+
const dx = Math.abs(from.x - to.x);
|
|
65
|
+
const dy = Math.abs(from.y - to.y);
|
|
66
|
+
// D = 1, D2 = sqrt(2) ≈ 1.414
|
|
67
|
+
const D = 1;
|
|
68
|
+
const D2 = Math.SQRT2;
|
|
69
|
+
return D * (dx + dy) + (D2 - 2 * D) * Math.min(dx, dy);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 根据配置计算启发式值
|
|
74
|
+
*/
|
|
75
|
+
function calculateHeuristic(from, to, config = DEFAULT_HEURISTIC_CONFIG) {
|
|
76
|
+
let distance;
|
|
77
|
+
switch (config.type) {
|
|
78
|
+
case 'euclidean':
|
|
79
|
+
distance = euclideanDistance(from, to);
|
|
80
|
+
break;
|
|
81
|
+
case 'octile':
|
|
82
|
+
distance = octileDistance(from, to);
|
|
83
|
+
break;
|
|
84
|
+
case 'manhattan':
|
|
85
|
+
default:
|
|
86
|
+
distance = manhattanDistance(from, to);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
return distance * config.weight;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 计算到多个目标点的最小启发式值
|
|
94
|
+
*/
|
|
95
|
+
function calculateMinHeuristic(from, targets, config = DEFAULT_HEURISTIC_CONFIG) {
|
|
96
|
+
let min = Infinity;
|
|
97
|
+
for (const target of targets) {
|
|
98
|
+
const h = calculateHeuristic(from, target, config);
|
|
99
|
+
if (h < min) {
|
|
100
|
+
min = h;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return min;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 方向优先级计算
|
|
108
|
+
* 优先考虑与目标方向一致的移动
|
|
109
|
+
*/
|
|
110
|
+
function calculateDirectionPriority(current, neighbor, target, weight = 0.1) {
|
|
111
|
+
// 计算当前到邻居的方向
|
|
112
|
+
const moveX = neighbor.x - current.x;
|
|
113
|
+
const moveY = neighbor.y - current.y;
|
|
114
|
+
|
|
115
|
+
// 计算当前到目标的方向
|
|
116
|
+
const targetX = target.x - current.x;
|
|
117
|
+
const targetY = target.y - current.y;
|
|
118
|
+
|
|
119
|
+
// 如果移动方向与目标方向一致,给予奖励(负惩罚)
|
|
120
|
+
let bonus = 0;
|
|
121
|
+
|
|
122
|
+
// 水平方向一致
|
|
123
|
+
if (moveX > 0 && targetX > 0 || moveX < 0 && targetX < 0) {
|
|
124
|
+
bonus -= weight;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// 垂直方向一致
|
|
128
|
+
if (moveY > 0 && targetY > 0 || moveY < 0 && targetY < 0) {
|
|
129
|
+
bonus -= weight;
|
|
130
|
+
}
|
|
131
|
+
return bonus;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 创建启发式函数
|
|
136
|
+
*/
|
|
137
|
+
function createHeuristicFunction(config = DEFAULT_HEURISTIC_CONFIG) {
|
|
138
|
+
return (from, targets) => {
|
|
139
|
+
return calculateMinHeuristic(from, targets, config);
|
|
140
|
+
};
|
|
141
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './grid';
|
|
2
|
+
export * from './GlobalGrid';
|
|
3
|
+
export * from './direction';
|
|
4
|
+
export * from './rect';
|
|
5
|
+
export * from './route';
|
|
6
|
+
export * from './node';
|
|
7
|
+
export * from './pathValidation';
|
|
8
|
+
export * from './getAnchorPoints';
|
|
9
|
+
export * from './AdaptiveStepCalculator';
|
|
10
|
+
export * from './PerformanceMonitor';
|
|
11
|
+
export * from './ErrorRecovery';
|
|
12
|
+
export * from './heuristics';
|
|
13
|
+
export * from './pathProcessing';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,148 @@
|
|
|
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 _GlobalGrid = require("./GlobalGrid");
|
|
18
|
+
Object.keys(_GlobalGrid).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _GlobalGrid[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _GlobalGrid[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _direction = require("./direction");
|
|
29
|
+
Object.keys(_direction).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _direction[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _direction[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _rect = require("./rect");
|
|
40
|
+
Object.keys(_rect).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _rect[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _rect[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _route = require("./route");
|
|
51
|
+
Object.keys(_route).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _route[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _route[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _node = require("./node");
|
|
62
|
+
Object.keys(_node).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _node[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _node[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
var _pathValidation = require("./pathValidation");
|
|
73
|
+
Object.keys(_pathValidation).forEach(function (key) {
|
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
|
75
|
+
if (key in exports && exports[key] === _pathValidation[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return _pathValidation[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
var _getAnchorPoints = require("./getAnchorPoints");
|
|
84
|
+
Object.keys(_getAnchorPoints).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _getAnchorPoints[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _getAnchorPoints[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
var _AdaptiveStepCalculator = require("./AdaptiveStepCalculator");
|
|
95
|
+
Object.keys(_AdaptiveStepCalculator).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _AdaptiveStepCalculator[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _AdaptiveStepCalculator[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
var _PerformanceMonitor = require("./PerformanceMonitor");
|
|
106
|
+
Object.keys(_PerformanceMonitor).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _PerformanceMonitor[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _PerformanceMonitor[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
var _ErrorRecovery = require("./ErrorRecovery");
|
|
117
|
+
Object.keys(_ErrorRecovery).forEach(function (key) {
|
|
118
|
+
if (key === "default" || key === "__esModule") return;
|
|
119
|
+
if (key in exports && exports[key] === _ErrorRecovery[key]) return;
|
|
120
|
+
Object.defineProperty(exports, key, {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return _ErrorRecovery[key];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
var _heuristics = require("./heuristics");
|
|
128
|
+
Object.keys(_heuristics).forEach(function (key) {
|
|
129
|
+
if (key === "default" || key === "__esModule") return;
|
|
130
|
+
if (key in exports && exports[key] === _heuristics[key]) return;
|
|
131
|
+
Object.defineProperty(exports, key, {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function () {
|
|
134
|
+
return _heuristics[key];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
var _pathProcessing = require("./pathProcessing");
|
|
139
|
+
Object.keys(_pathProcessing).forEach(function (key) {
|
|
140
|
+
if (key === "default" || key === "__esModule") return;
|
|
141
|
+
if (key in exports && exports[key] === _pathProcessing[key]) return;
|
|
142
|
+
Object.defineProperty(exports, key, {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
get: function () {
|
|
145
|
+
return _pathProcessing[key];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|