@rxflow/manhattan 0.0.1-alpha.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/README.md +35 -0
- 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/index.d.ts +4 -0
- package/cjs/geometry/index.d.ts.map +1 -0
- package/cjs/geometry/index.js +26 -0
- package/cjs/getManHattanPath.d.ts +60 -0
- package/cjs/getManHattanPath.d.ts.map +1 -0
- package/cjs/getManHattanPath.js +285 -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 +28 -0
- package/cjs/obstacle/ObstacleMap.d.ts.map +1 -0
- package/cjs/obstacle/ObstacleMap.js +171 -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 +118 -0
- package/cjs/options/types.d.ts +156 -0
- package/cjs/options/types.d.ts.map +1 -0
- package/cjs/options/types.js +5 -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 +156 -0
- package/cjs/pathfinder/index.d.ts +3 -0
- package/cjs/pathfinder/index.d.ts.map +1 -0
- package/cjs/pathfinder/index.js +19 -0
- package/cjs/svg/index.d.ts +2 -0
- package/cjs/svg/index.d.ts.map +1 -0
- package/cjs/svg/index.js +18 -0
- package/cjs/svg/pathConverter.d.ts +10 -0
- package/cjs/svg/pathConverter.d.ts.map +1 -0
- package/cjs/svg/pathConverter.js +105 -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/grid.d.ts +26 -0
- package/cjs/utils/grid.d.ts.map +1 -0
- package/cjs/utils/grid.js +78 -0
- package/cjs/utils/index.d.ts +6 -0
- package/cjs/utils/index.d.ts.map +1 -0
- package/cjs/utils/index.js +60 -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/rect.d.ts +9 -0
- package/cjs/utils/rect.d.ts.map +1 -0
- package/cjs/utils/rect.js +103 -0
- package/cjs/utils/route.d.ts +19 -0
- package/cjs/utils/route.d.ts.map +1 -0
- package/cjs/utils/route.js +76 -0
- package/esm/geometry/Line.d.ts +21 -0
- package/esm/geometry/Line.d.ts.map +1 -0
- package/esm/geometry/Line.js +96 -0
- package/esm/geometry/Point.d.ts +49 -0
- package/esm/geometry/Point.d.ts.map +1 -0
- package/esm/geometry/Point.js +117 -0
- package/esm/geometry/Rectangle.d.ts +41 -0
- package/esm/geometry/Rectangle.d.ts.map +1 -0
- package/esm/geometry/Rectangle.js +81 -0
- package/esm/geometry/index.d.ts +4 -0
- package/esm/geometry/index.d.ts.map +1 -0
- package/esm/geometry/index.js +3 -0
- package/esm/getManHattanPath.d.ts +60 -0
- package/esm/getManHattanPath.d.ts.map +1 -0
- package/esm/getManHattanPath.js +291 -0
- package/esm/index.d.ts +16 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +24 -0
- package/esm/obstacle/ObstacleMap.d.ts +28 -0
- package/esm/obstacle/ObstacleMap.d.ts.map +1 -0
- package/esm/obstacle/ObstacleMap.js +183 -0
- package/esm/obstacle/index.d.ts +2 -0
- package/esm/obstacle/index.d.ts.map +1 -0
- package/esm/obstacle/index.js +1 -0
- package/esm/options/defaults.d.ts +16 -0
- package/esm/options/defaults.d.ts.map +1 -0
- package/esm/options/defaults.js +33 -0
- package/esm/options/index.d.ts +4 -0
- package/esm/options/index.d.ts.map +1 -0
- package/esm/options/index.js +3 -0
- package/esm/options/resolver.d.ts +10 -0
- package/esm/options/resolver.d.ts.map +1 -0
- package/esm/options/resolver.js +114 -0
- package/esm/options/types.d.ts +156 -0
- package/esm/options/types.d.ts.map +1 -0
- package/esm/options/types.js +1 -0
- package/esm/pathfinder/SortedSet.d.ts +35 -0
- package/esm/pathfinder/SortedSet.d.ts.map +1 -0
- package/esm/pathfinder/SortedSet.js +110 -0
- package/esm/pathfinder/findRoute.d.ts +8 -0
- package/esm/pathfinder/findRoute.d.ts.map +1 -0
- package/esm/pathfinder/findRoute.js +189 -0
- package/esm/pathfinder/index.d.ts +3 -0
- package/esm/pathfinder/index.d.ts.map +1 -0
- package/esm/pathfinder/index.js +2 -0
- package/esm/svg/index.d.ts +2 -0
- package/esm/svg/index.d.ts.map +1 -0
- package/esm/svg/index.js +1 -0
- package/esm/svg/pathConverter.d.ts +10 -0
- package/esm/svg/pathConverter.d.ts.map +1 -0
- package/esm/svg/pathConverter.js +107 -0
- package/esm/utils/direction.d.ts +24 -0
- package/esm/utils/direction.d.ts.map +1 -0
- package/esm/utils/direction.js +46 -0
- package/esm/utils/grid.d.ts +26 -0
- package/esm/utils/grid.d.ts.map +1 -0
- package/esm/utils/grid.js +70 -0
- package/esm/utils/index.d.ts +6 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +5 -0
- package/esm/utils/node.d.ts +27 -0
- package/esm/utils/node.d.ts.map +1 -0
- package/esm/utils/node.js +30 -0
- package/esm/utils/rect.d.ts +9 -0
- package/esm/utils/rect.d.ts.map +1 -0
- package/esm/utils/rect.js +121 -0
- package/esm/utils/route.d.ts +19 -0
- package/esm/utils/route.d.ts.map +1 -0
- package/esm/utils/route.js +80 -0
- package/package.json +43 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Point } from "../geometry";
|
|
2
|
+
/**
|
|
3
|
+
* Default configuration for Manhattan router
|
|
4
|
+
*/
|
|
5
|
+
export var defaults = {
|
|
6
|
+
step: 10,
|
|
7
|
+
maxLoopCount: 2000,
|
|
8
|
+
precision: 1,
|
|
9
|
+
maxDirectionChange: 90,
|
|
10
|
+
startDirections: ['top', 'right', 'bottom', 'left'],
|
|
11
|
+
endDirections: ['top', 'right', 'bottom', 'left'],
|
|
12
|
+
excludeNodes: [],
|
|
13
|
+
excludeShapes: [],
|
|
14
|
+
excludeTerminals: [],
|
|
15
|
+
padding: 0,
|
|
16
|
+
snapToGrid: true,
|
|
17
|
+
borderRadius: 5,
|
|
18
|
+
penalties: {
|
|
19
|
+
0: 0,
|
|
20
|
+
45: 5,
|
|
21
|
+
90: 5
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Direction map - maps direction names to unit vectors
|
|
27
|
+
*/
|
|
28
|
+
export var directionMap = {
|
|
29
|
+
top: new Point(0, -1),
|
|
30
|
+
right: new Point(1, 0),
|
|
31
|
+
bottom: new Point(0, 1),
|
|
32
|
+
left: new Point(-1, 0)
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/options/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ManhattanRouterOptions, ResolvedOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Normalize angle to 0-360 range
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizeAngle(angle: number): number;
|
|
6
|
+
/**
|
|
7
|
+
* Resolve options by merging user options with defaults
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveOptions(options?: ManhattanRouterOptions): ResolvedOptions;
|
|
10
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/options/resolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAetE;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQpD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,sBAA2B,GAAG,eAAe,CA+DpF"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Point } from "../geometry";
|
|
2
|
+
import { defaults, directionMap } from "./defaults";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Normalize padding value to box format
|
|
6
|
+
*/
|
|
7
|
+
function normalizePadding(padding) {
|
|
8
|
+
if (typeof padding === 'number') {
|
|
9
|
+
return {
|
|
10
|
+
top: padding,
|
|
11
|
+
right: padding,
|
|
12
|
+
bottom: padding,
|
|
13
|
+
left: padding
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return padding;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Normalize angle to 0-360 range
|
|
21
|
+
*/
|
|
22
|
+
export function normalizeAngle(angle) {
|
|
23
|
+
while (angle < 0) {
|
|
24
|
+
angle += 360;
|
|
25
|
+
}
|
|
26
|
+
while (angle >= 360) {
|
|
27
|
+
angle -= 360;
|
|
28
|
+
}
|
|
29
|
+
return angle;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Resolve options by merging user options with defaults
|
|
34
|
+
*/
|
|
35
|
+
export function resolveOptions() {
|
|
36
|
+
var _options$step, _options$maxLoopCount, _options$precision, _options$maxDirection, _options$startDirecti, _options$endDirection, _options$excludeNodes, _options$excludeShape, _options$excludeTermi, _options$snapToGrid, _options$borderRadius, _options$penalties, _options$padding;
|
|
37
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
38
|
+
var step = (_options$step = options.step) !== null && _options$step !== void 0 ? _options$step : defaults.step;
|
|
39
|
+
var maxLoopCount = (_options$maxLoopCount = options.maxLoopCount) !== null && _options$maxLoopCount !== void 0 ? _options$maxLoopCount : defaults.maxLoopCount;
|
|
40
|
+
var precision = (_options$precision = options.precision) !== null && _options$precision !== void 0 ? _options$precision : defaults.precision;
|
|
41
|
+
var maxDirectionChange = (_options$maxDirection = options.maxDirectionChange) !== null && _options$maxDirection !== void 0 ? _options$maxDirection : defaults.maxDirectionChange;
|
|
42
|
+
var startDirections = (_options$startDirecti = options.startDirections) !== null && _options$startDirecti !== void 0 ? _options$startDirecti : defaults.startDirections;
|
|
43
|
+
var endDirections = (_options$endDirection = options.endDirections) !== null && _options$endDirection !== void 0 ? _options$endDirection : defaults.endDirections;
|
|
44
|
+
var excludeNodes = (_options$excludeNodes = options.excludeNodes) !== null && _options$excludeNodes !== void 0 ? _options$excludeNodes : defaults.excludeNodes;
|
|
45
|
+
var excludeShapes = (_options$excludeShape = options.excludeShapes) !== null && _options$excludeShape !== void 0 ? _options$excludeShape : defaults.excludeShapes;
|
|
46
|
+
var excludeTerminals = (_options$excludeTermi = options.excludeTerminals) !== null && _options$excludeTermi !== void 0 ? _options$excludeTermi : defaults.excludeTerminals;
|
|
47
|
+
var snapToGrid = (_options$snapToGrid = options.snapToGrid) !== null && _options$snapToGrid !== void 0 ? _options$snapToGrid : defaults.snapToGrid;
|
|
48
|
+
var borderRadius = (_options$borderRadius = options.borderRadius) !== null && _options$borderRadius !== void 0 ? _options$borderRadius : defaults.borderRadius;
|
|
49
|
+
var penalties = (_options$penalties = options.penalties) !== null && _options$penalties !== void 0 ? _options$penalties : defaults.penalties;
|
|
50
|
+
var fallbackRoute = options.fallbackRoute;
|
|
51
|
+
|
|
52
|
+
// Convert padding to paddingBox
|
|
53
|
+
var padding = (_options$padding = options.padding) !== null && _options$padding !== void 0 ? _options$padding : defaults.padding;
|
|
54
|
+
var sides = normalizePadding(padding);
|
|
55
|
+
var paddingBox = {
|
|
56
|
+
x: -sides.left,
|
|
57
|
+
y: -sides.top,
|
|
58
|
+
width: sides.left + sides.right,
|
|
59
|
+
height: sides.top + sides.bottom
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// Calculate cost (same as step)
|
|
63
|
+
var cost = step;
|
|
64
|
+
|
|
65
|
+
// Calculate directions array with offsets and costs
|
|
66
|
+
var directions = [{
|
|
67
|
+
cost: cost,
|
|
68
|
+
offsetX: step,
|
|
69
|
+
offsetY: 0,
|
|
70
|
+
angle: 0
|
|
71
|
+
}, {
|
|
72
|
+
cost: cost,
|
|
73
|
+
offsetX: -step,
|
|
74
|
+
offsetY: 0,
|
|
75
|
+
angle: 0
|
|
76
|
+
}, {
|
|
77
|
+
cost: cost,
|
|
78
|
+
offsetX: 0,
|
|
79
|
+
offsetY: step,
|
|
80
|
+
angle: 0
|
|
81
|
+
}, {
|
|
82
|
+
cost: cost,
|
|
83
|
+
offsetX: 0,
|
|
84
|
+
offsetY: -step,
|
|
85
|
+
angle: 0
|
|
86
|
+
}];
|
|
87
|
+
|
|
88
|
+
// Calculate angle for each direction
|
|
89
|
+
directions.forEach(function (direction) {
|
|
90
|
+
var point1 = new Point(0, 0);
|
|
91
|
+
var point2 = new Point(direction.offsetX, direction.offsetY);
|
|
92
|
+
direction.angle = normalizeAngle(point1.theta(point2));
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
step: step,
|
|
96
|
+
maxLoopCount: maxLoopCount,
|
|
97
|
+
precision: precision,
|
|
98
|
+
maxDirectionChange: maxDirectionChange,
|
|
99
|
+
startDirections: startDirections,
|
|
100
|
+
endDirections: endDirections,
|
|
101
|
+
excludeNodes: excludeNodes,
|
|
102
|
+
excludeShapes: excludeShapes,
|
|
103
|
+
excludeTerminals: excludeTerminals,
|
|
104
|
+
paddingBox: paddingBox,
|
|
105
|
+
snapToGrid: snapToGrid,
|
|
106
|
+
borderRadius: borderRadius,
|
|
107
|
+
directionMap: directionMap,
|
|
108
|
+
directions: directions,
|
|
109
|
+
penalties: penalties,
|
|
110
|
+
cost: cost,
|
|
111
|
+
fallbackRoute: fallbackRoute,
|
|
112
|
+
previousDirectionAngle: undefined
|
|
113
|
+
};
|
|
114
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Point } from '../geometry';
|
|
2
|
+
/**
|
|
3
|
+
* Direction type for routing
|
|
4
|
+
*/
|
|
5
|
+
export type Direction = 'top' | 'right' | 'bottom' | 'left';
|
|
6
|
+
/**
|
|
7
|
+
* ReactFlow internal node structure
|
|
8
|
+
* Based on ReactFlow's InternalNodeBase type
|
|
9
|
+
*/
|
|
10
|
+
export interface InternalNode {
|
|
11
|
+
id: string;
|
|
12
|
+
position: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
};
|
|
16
|
+
internals: {
|
|
17
|
+
positionAbsolute: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
measured?: {
|
|
23
|
+
width?: number;
|
|
24
|
+
height?: number;
|
|
25
|
+
};
|
|
26
|
+
width?: number;
|
|
27
|
+
height?: number;
|
|
28
|
+
initialWidth?: number;
|
|
29
|
+
initialHeight?: number;
|
|
30
|
+
type?: string;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Node lookup map type (ReactFlow's internal structure)
|
|
35
|
+
*/
|
|
36
|
+
export type NodeLookup = Map<string, InternalNode>;
|
|
37
|
+
/**
|
|
38
|
+
* Manhattan router configuration options
|
|
39
|
+
*/
|
|
40
|
+
export interface ManhattanRouterOptions {
|
|
41
|
+
/**
|
|
42
|
+
* The size of step to find a route (the grid of the manhattan pathfinder)
|
|
43
|
+
* @default 10
|
|
44
|
+
*/
|
|
45
|
+
step?: number;
|
|
46
|
+
/**
|
|
47
|
+
* The number of route finding loops that cause the router to abort and return fallback route instead
|
|
48
|
+
* @default 2000
|
|
49
|
+
*/
|
|
50
|
+
maxLoopCount?: number;
|
|
51
|
+
/**
|
|
52
|
+
* The number of decimal places to round floating point coordinates
|
|
53
|
+
* @default 1
|
|
54
|
+
*/
|
|
55
|
+
precision?: number;
|
|
56
|
+
/**
|
|
57
|
+
* The maximum change of direction (in degrees)
|
|
58
|
+
* @default 90
|
|
59
|
+
*/
|
|
60
|
+
maxDirectionChange?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Possible starting directions from a node
|
|
63
|
+
* @default ['top', 'right', 'bottom', 'left']
|
|
64
|
+
*/
|
|
65
|
+
startDirections?: Direction[];
|
|
66
|
+
/**
|
|
67
|
+
* Possible ending directions to a node
|
|
68
|
+
* @default ['top', 'right', 'bottom', 'left']
|
|
69
|
+
*/
|
|
70
|
+
endDirections?: Direction[];
|
|
71
|
+
/**
|
|
72
|
+
* Should certain nodes not be considered as obstacles?
|
|
73
|
+
*/
|
|
74
|
+
excludeNodes?: string[];
|
|
75
|
+
/**
|
|
76
|
+
* Should certain types of nodes not be considered as obstacles?
|
|
77
|
+
*/
|
|
78
|
+
excludeShapes?: string[];
|
|
79
|
+
/**
|
|
80
|
+
* Should the source and/or target not be considered as obstacles?
|
|
81
|
+
*/
|
|
82
|
+
excludeTerminals?: ('source' | 'target')[];
|
|
83
|
+
/**
|
|
84
|
+
* The padding applied on the element bounding boxes
|
|
85
|
+
*/
|
|
86
|
+
padding?: number | {
|
|
87
|
+
top: number;
|
|
88
|
+
right: number;
|
|
89
|
+
bottom: number;
|
|
90
|
+
left: number;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Whether the calculation results are aligned with the grid
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
snapToGrid?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Border radius for rounded corners at path turns (in pixels)
|
|
99
|
+
* Set to 0 for sharp corners
|
|
100
|
+
* @default 5
|
|
101
|
+
*/
|
|
102
|
+
borderRadius?: number;
|
|
103
|
+
/**
|
|
104
|
+
* A penalty received for direction change
|
|
105
|
+
*/
|
|
106
|
+
penalties?: {
|
|
107
|
+
[angle: number]: number;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Fallback route function when pathfinding fails
|
|
111
|
+
*/
|
|
112
|
+
fallbackRoute?: (from: Point, to: Point) => Point[];
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Resolved options with all defaults applied
|
|
116
|
+
*/
|
|
117
|
+
export interface ResolvedOptions {
|
|
118
|
+
step: number;
|
|
119
|
+
maxLoopCount: number;
|
|
120
|
+
precision: number;
|
|
121
|
+
maxDirectionChange: number;
|
|
122
|
+
startDirections: Direction[];
|
|
123
|
+
endDirections: Direction[];
|
|
124
|
+
excludeNodes: string[];
|
|
125
|
+
excludeShapes: string[];
|
|
126
|
+
excludeTerminals: ('source' | 'target')[];
|
|
127
|
+
paddingBox: {
|
|
128
|
+
x: number;
|
|
129
|
+
y: number;
|
|
130
|
+
width: number;
|
|
131
|
+
height: number;
|
|
132
|
+
};
|
|
133
|
+
snapToGrid: boolean;
|
|
134
|
+
borderRadius: number;
|
|
135
|
+
directionMap: {
|
|
136
|
+
top: Point;
|
|
137
|
+
right: Point;
|
|
138
|
+
bottom: Point;
|
|
139
|
+
left: Point;
|
|
140
|
+
};
|
|
141
|
+
directions: Array<{
|
|
142
|
+
cost: number;
|
|
143
|
+
offsetX: number;
|
|
144
|
+
offsetY: number;
|
|
145
|
+
angle?: number;
|
|
146
|
+
gridOffsetX?: number;
|
|
147
|
+
gridOffsetY?: number;
|
|
148
|
+
}>;
|
|
149
|
+
penalties: {
|
|
150
|
+
[angle: number]: number;
|
|
151
|
+
};
|
|
152
|
+
cost: number;
|
|
153
|
+
fallbackRoute?: (from: Point, to: Point) => Point[];
|
|
154
|
+
previousDirectionAngle?: number | null;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/options/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;AAE3D;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAClC,SAAS,EAAE;QACT,gBAAgB,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAC3C,CAAA;IACD,QAAQ,CAAC,EAAE;QACT,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,Y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5
|
+
export declare class SortedSet {
|
|
6
|
+
private items;
|
|
7
|
+
private hash;
|
|
8
|
+
private values;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Add an item with its value, maintaining sorted order
|
|
12
|
+
*/
|
|
13
|
+
add(item: string, value: number): void;
|
|
14
|
+
/**
|
|
15
|
+
* Pop the item with minimum value and mark it as closed
|
|
16
|
+
*/
|
|
17
|
+
pop(): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Check if item is in open set
|
|
20
|
+
*/
|
|
21
|
+
isOpen(item: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Check if item is in closed set
|
|
24
|
+
*/
|
|
25
|
+
isClose(item: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Check if open set is empty
|
|
28
|
+
*/
|
|
29
|
+
isEmpty(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Find sorted insertion index for an item
|
|
32
|
+
*/
|
|
33
|
+
private sortedIndexBy;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=SortedSet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SortedSet.d.ts","sourceRoot":"","sources":["../../src/pathfinder/SortedSet.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,MAAM,CAAqB;;IAQnC;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAkBtC;;OAEG;IACH,GAAG,IAAI,MAAM,GAAG,SAAS;IAQzB;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI7B;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI9B;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,OAAO,CAAC,aAAa;CAiBtB"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
var OPEN = 1;
|
|
9
|
+
var CLOSE = 2;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* SortedSet class for managing open and closed sets in A* algorithm
|
|
13
|
+
* Maintains items sorted by their values
|
|
14
|
+
*/
|
|
15
|
+
export var SortedSet = /*#__PURE__*/function () {
|
|
16
|
+
function SortedSet() {
|
|
17
|
+
_classCallCheck(this, SortedSet);
|
|
18
|
+
_defineProperty(this, "items", void 0);
|
|
19
|
+
_defineProperty(this, "hash", void 0);
|
|
20
|
+
_defineProperty(this, "values", void 0);
|
|
21
|
+
this.items = [];
|
|
22
|
+
this.hash = new Map();
|
|
23
|
+
this.values = new Map();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Add an item with its value, maintaining sorted order
|
|
28
|
+
*/
|
|
29
|
+
_createClass(SortedSet, [{
|
|
30
|
+
key: "add",
|
|
31
|
+
value: function add(item, value) {
|
|
32
|
+
if (this.hash.get(item)) {
|
|
33
|
+
// Item removal - remove from items array
|
|
34
|
+
var _index = this.items.indexOf(item);
|
|
35
|
+
if (_index !== -1) {
|
|
36
|
+
this.items.splice(_index, 1);
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
this.hash.set(item, OPEN);
|
|
40
|
+
}
|
|
41
|
+
this.values.set(item, value);
|
|
42
|
+
|
|
43
|
+
// Find insertion index using binary search
|
|
44
|
+
var index = this.sortedIndexBy(item);
|
|
45
|
+
this.items.splice(index, 0, item);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Pop the item with minimum value and mark it as closed
|
|
50
|
+
*/
|
|
51
|
+
}, {
|
|
52
|
+
key: "pop",
|
|
53
|
+
value: function pop() {
|
|
54
|
+
var item = this.items.shift();
|
|
55
|
+
if (item) {
|
|
56
|
+
this.hash.set(item, CLOSE);
|
|
57
|
+
}
|
|
58
|
+
return item;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Check if item is in open set
|
|
63
|
+
*/
|
|
64
|
+
}, {
|
|
65
|
+
key: "isOpen",
|
|
66
|
+
value: function isOpen(item) {
|
|
67
|
+
return this.hash.get(item) === OPEN;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Check if item is in closed set
|
|
72
|
+
*/
|
|
73
|
+
}, {
|
|
74
|
+
key: "isClose",
|
|
75
|
+
value: function isClose(item) {
|
|
76
|
+
return this.hash.get(item) === CLOSE;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Check if open set is empty
|
|
81
|
+
*/
|
|
82
|
+
}, {
|
|
83
|
+
key: "isEmpty",
|
|
84
|
+
value: function isEmpty() {
|
|
85
|
+
return this.items.length === 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Find sorted insertion index for an item
|
|
90
|
+
*/
|
|
91
|
+
}, {
|
|
92
|
+
key: "sortedIndexBy",
|
|
93
|
+
value: function sortedIndexBy(item) {
|
|
94
|
+
var value = this.values.get(item);
|
|
95
|
+
var low = 0;
|
|
96
|
+
var high = this.items.length;
|
|
97
|
+
while (low < high) {
|
|
98
|
+
var mid = low + high >>> 1;
|
|
99
|
+
var midValue = this.values.get(this.items[mid]);
|
|
100
|
+
if (midValue < value) {
|
|
101
|
+
low = mid + 1;
|
|
102
|
+
} else {
|
|
103
|
+
high = mid;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return low;
|
|
107
|
+
}
|
|
108
|
+
}]);
|
|
109
|
+
return SortedSet;
|
|
110
|
+
}();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Point, Rectangle } from '../geometry';
|
|
2
|
+
import type { ResolvedOptions } from '../options';
|
|
3
|
+
import type { ObstacleMap } from '../obstacle';
|
|
4
|
+
/**
|
|
5
|
+
* Find route between two points using A* algorithm
|
|
6
|
+
*/
|
|
7
|
+
export declare function findRoute(sourceBBox: Rectangle, targetBBox: Rectangle, sourceAnchor: Point, targetAnchor: Point, map: ObstacleMap, options: ResolvedOptions): Point[] | null;
|
|
8
|
+
//# sourceMappingURL=findRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findRoute.d.ts","sourceRoot":"","sources":["../../src/pathfinder/findRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAe9C;;GAEG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,SAAS,EACrB,UAAU,EAAE,SAAS,EACrB,YAAY,EAAE,KAAK,EACnB,YAAY,EAAE,KAAK,EACnB,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,eAAe,GACvB,KAAK,EAAE,GAAG,IAAI,CAsNhB"}
|