@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.
Files changed (140) hide show
  1. package/README.md +35 -0
  2. package/cjs/geometry/Line.d.ts +21 -0
  3. package/cjs/geometry/Line.d.ts.map +1 -0
  4. package/cjs/geometry/Line.js +88 -0
  5. package/cjs/geometry/Point.d.ts +49 -0
  6. package/cjs/geometry/Point.d.ts.map +1 -0
  7. package/cjs/geometry/Point.js +94 -0
  8. package/cjs/geometry/Rectangle.d.ts +41 -0
  9. package/cjs/geometry/Rectangle.d.ts.map +1 -0
  10. package/cjs/geometry/Rectangle.js +65 -0
  11. package/cjs/geometry/index.d.ts +4 -0
  12. package/cjs/geometry/index.d.ts.map +1 -0
  13. package/cjs/geometry/index.js +26 -0
  14. package/cjs/getManHattanPath.d.ts +60 -0
  15. package/cjs/getManHattanPath.d.ts.map +1 -0
  16. package/cjs/getManHattanPath.js +285 -0
  17. package/cjs/index.d.ts +16 -0
  18. package/cjs/index.d.ts.map +1 -0
  19. package/cjs/index.js +117 -0
  20. package/cjs/obstacle/ObstacleMap.d.ts +28 -0
  21. package/cjs/obstacle/ObstacleMap.d.ts.map +1 -0
  22. package/cjs/obstacle/ObstacleMap.js +171 -0
  23. package/cjs/obstacle/index.d.ts +2 -0
  24. package/cjs/obstacle/index.d.ts.map +1 -0
  25. package/cjs/obstacle/index.js +12 -0
  26. package/cjs/options/defaults.d.ts +16 -0
  27. package/cjs/options/defaults.d.ts.map +1 -0
  28. package/cjs/options/defaults.js +39 -0
  29. package/cjs/options/index.d.ts +4 -0
  30. package/cjs/options/index.d.ts.map +1 -0
  31. package/cjs/options/index.js +38 -0
  32. package/cjs/options/resolver.d.ts +10 -0
  33. package/cjs/options/resolver.d.ts.map +1 -0
  34. package/cjs/options/resolver.js +118 -0
  35. package/cjs/options/types.d.ts +156 -0
  36. package/cjs/options/types.d.ts.map +1 -0
  37. package/cjs/options/types.js +5 -0
  38. package/cjs/pathfinder/SortedSet.d.ts +35 -0
  39. package/cjs/pathfinder/SortedSet.d.ts.map +1 -0
  40. package/cjs/pathfinder/SortedSet.js +95 -0
  41. package/cjs/pathfinder/findRoute.d.ts +8 -0
  42. package/cjs/pathfinder/findRoute.d.ts.map +1 -0
  43. package/cjs/pathfinder/findRoute.js +156 -0
  44. package/cjs/pathfinder/index.d.ts +3 -0
  45. package/cjs/pathfinder/index.d.ts.map +1 -0
  46. package/cjs/pathfinder/index.js +19 -0
  47. package/cjs/svg/index.d.ts +2 -0
  48. package/cjs/svg/index.d.ts.map +1 -0
  49. package/cjs/svg/index.js +18 -0
  50. package/cjs/svg/pathConverter.d.ts +10 -0
  51. package/cjs/svg/pathConverter.d.ts.map +1 -0
  52. package/cjs/svg/pathConverter.js +105 -0
  53. package/cjs/utils/direction.d.ts +24 -0
  54. package/cjs/utils/direction.d.ts.map +1 -0
  55. package/cjs/utils/direction.js +54 -0
  56. package/cjs/utils/grid.d.ts +26 -0
  57. package/cjs/utils/grid.d.ts.map +1 -0
  58. package/cjs/utils/grid.js +78 -0
  59. package/cjs/utils/index.d.ts +6 -0
  60. package/cjs/utils/index.d.ts.map +1 -0
  61. package/cjs/utils/index.js +60 -0
  62. package/cjs/utils/node.d.ts +27 -0
  63. package/cjs/utils/node.d.ts.map +1 -0
  64. package/cjs/utils/node.js +36 -0
  65. package/cjs/utils/rect.d.ts +9 -0
  66. package/cjs/utils/rect.d.ts.map +1 -0
  67. package/cjs/utils/rect.js +103 -0
  68. package/cjs/utils/route.d.ts +19 -0
  69. package/cjs/utils/route.d.ts.map +1 -0
  70. package/cjs/utils/route.js +76 -0
  71. package/esm/geometry/Line.d.ts +21 -0
  72. package/esm/geometry/Line.d.ts.map +1 -0
  73. package/esm/geometry/Line.js +96 -0
  74. package/esm/geometry/Point.d.ts +49 -0
  75. package/esm/geometry/Point.d.ts.map +1 -0
  76. package/esm/geometry/Point.js +117 -0
  77. package/esm/geometry/Rectangle.d.ts +41 -0
  78. package/esm/geometry/Rectangle.d.ts.map +1 -0
  79. package/esm/geometry/Rectangle.js +81 -0
  80. package/esm/geometry/index.d.ts +4 -0
  81. package/esm/geometry/index.d.ts.map +1 -0
  82. package/esm/geometry/index.js +3 -0
  83. package/esm/getManHattanPath.d.ts +60 -0
  84. package/esm/getManHattanPath.d.ts.map +1 -0
  85. package/esm/getManHattanPath.js +291 -0
  86. package/esm/index.d.ts +16 -0
  87. package/esm/index.d.ts.map +1 -0
  88. package/esm/index.js +24 -0
  89. package/esm/obstacle/ObstacleMap.d.ts +28 -0
  90. package/esm/obstacle/ObstacleMap.d.ts.map +1 -0
  91. package/esm/obstacle/ObstacleMap.js +183 -0
  92. package/esm/obstacle/index.d.ts +2 -0
  93. package/esm/obstacle/index.d.ts.map +1 -0
  94. package/esm/obstacle/index.js +1 -0
  95. package/esm/options/defaults.d.ts +16 -0
  96. package/esm/options/defaults.d.ts.map +1 -0
  97. package/esm/options/defaults.js +33 -0
  98. package/esm/options/index.d.ts +4 -0
  99. package/esm/options/index.d.ts.map +1 -0
  100. package/esm/options/index.js +3 -0
  101. package/esm/options/resolver.d.ts +10 -0
  102. package/esm/options/resolver.d.ts.map +1 -0
  103. package/esm/options/resolver.js +114 -0
  104. package/esm/options/types.d.ts +156 -0
  105. package/esm/options/types.d.ts.map +1 -0
  106. package/esm/options/types.js +1 -0
  107. package/esm/pathfinder/SortedSet.d.ts +35 -0
  108. package/esm/pathfinder/SortedSet.d.ts.map +1 -0
  109. package/esm/pathfinder/SortedSet.js +110 -0
  110. package/esm/pathfinder/findRoute.d.ts +8 -0
  111. package/esm/pathfinder/findRoute.d.ts.map +1 -0
  112. package/esm/pathfinder/findRoute.js +189 -0
  113. package/esm/pathfinder/index.d.ts +3 -0
  114. package/esm/pathfinder/index.d.ts.map +1 -0
  115. package/esm/pathfinder/index.js +2 -0
  116. package/esm/svg/index.d.ts +2 -0
  117. package/esm/svg/index.d.ts.map +1 -0
  118. package/esm/svg/index.js +1 -0
  119. package/esm/svg/pathConverter.d.ts +10 -0
  120. package/esm/svg/pathConverter.d.ts.map +1 -0
  121. package/esm/svg/pathConverter.js +107 -0
  122. package/esm/utils/direction.d.ts +24 -0
  123. package/esm/utils/direction.d.ts.map +1 -0
  124. package/esm/utils/direction.js +46 -0
  125. package/esm/utils/grid.d.ts +26 -0
  126. package/esm/utils/grid.d.ts.map +1 -0
  127. package/esm/utils/grid.js +70 -0
  128. package/esm/utils/index.d.ts +6 -0
  129. package/esm/utils/index.d.ts.map +1 -0
  130. package/esm/utils/index.js +5 -0
  131. package/esm/utils/node.d.ts +27 -0
  132. package/esm/utils/node.d.ts.map +1 -0
  133. package/esm/utils/node.js +30 -0
  134. package/esm/utils/rect.d.ts +9 -0
  135. package/esm/utils/rect.d.ts.map +1 -0
  136. package/esm/utils/rect.js +121 -0
  137. package/esm/utils/route.d.ts +19 -0
  138. package/esm/utils/route.d.ts.map +1 -0
  139. package/esm/utils/route.js +80 -0
  140. package/package.json +43 -0
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.directionMap = exports.defaults = void 0;
7
+ var _geometry = require("../geometry");
8
+ /**
9
+ * Default configuration for Manhattan router
10
+ */
11
+ const defaults = exports.defaults = {
12
+ step: 10,
13
+ maxLoopCount: 2000,
14
+ precision: 1,
15
+ maxDirectionChange: 90,
16
+ startDirections: ['top', 'right', 'bottom', 'left'],
17
+ endDirections: ['top', 'right', 'bottom', 'left'],
18
+ excludeNodes: [],
19
+ excludeShapes: [],
20
+ excludeTerminals: [],
21
+ padding: 0,
22
+ snapToGrid: true,
23
+ borderRadius: 5,
24
+ penalties: {
25
+ 0: 0,
26
+ 45: 5,
27
+ 90: 5
28
+ }
29
+ };
30
+
31
+ /**
32
+ * Direction map - maps direction names to unit vectors
33
+ */
34
+ const directionMap = exports.directionMap = {
35
+ top: new _geometry.Point(0, -1),
36
+ right: new _geometry.Point(1, 0),
37
+ bottom: new _geometry.Point(0, 1),
38
+ left: new _geometry.Point(-1, 0)
39
+ };
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export * from './defaults';
3
+ export * from './resolver';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -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,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _types = require("./types");
7
+ Object.keys(_types).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _types[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _types[key];
14
+ }
15
+ });
16
+ });
17
+ var _defaults = require("./defaults");
18
+ Object.keys(_defaults).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _defaults[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _defaults[key];
25
+ }
26
+ });
27
+ });
28
+ var _resolver = require("./resolver");
29
+ Object.keys(_resolver).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _resolver[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _resolver[key];
36
+ }
37
+ });
38
+ });
@@ -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,118 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.normalizeAngle = normalizeAngle;
7
+ exports.resolveOptions = resolveOptions;
8
+ var _geometry = require("../geometry");
9
+ var _defaults = require("./defaults");
10
+ /**
11
+ * Normalize padding value to box format
12
+ */
13
+ function normalizePadding(padding) {
14
+ if (typeof padding === 'number') {
15
+ return {
16
+ top: padding,
17
+ right: padding,
18
+ bottom: padding,
19
+ left: padding
20
+ };
21
+ }
22
+ return padding;
23
+ }
24
+
25
+ /**
26
+ * Normalize angle to 0-360 range
27
+ */
28
+ function normalizeAngle(angle) {
29
+ while (angle < 0) {
30
+ angle += 360;
31
+ }
32
+ while (angle >= 360) {
33
+ angle -= 360;
34
+ }
35
+ return angle;
36
+ }
37
+
38
+ /**
39
+ * Resolve options by merging user options with defaults
40
+ */
41
+ function resolveOptions(options = {}) {
42
+ const step = options.step ?? _defaults.defaults.step;
43
+ const maxLoopCount = options.maxLoopCount ?? _defaults.defaults.maxLoopCount;
44
+ const precision = options.precision ?? _defaults.defaults.precision;
45
+ const maxDirectionChange = options.maxDirectionChange ?? _defaults.defaults.maxDirectionChange;
46
+ const startDirections = options.startDirections ?? _defaults.defaults.startDirections;
47
+ const endDirections = options.endDirections ?? _defaults.defaults.endDirections;
48
+ const excludeNodes = options.excludeNodes ?? _defaults.defaults.excludeNodes;
49
+ const excludeShapes = options.excludeShapes ?? _defaults.defaults.excludeShapes;
50
+ const excludeTerminals = options.excludeTerminals ?? _defaults.defaults.excludeTerminals;
51
+ const snapToGrid = options.snapToGrid ?? _defaults.defaults.snapToGrid;
52
+ const borderRadius = options.borderRadius ?? _defaults.defaults.borderRadius;
53
+ const penalties = options.penalties ?? _defaults.defaults.penalties;
54
+ const fallbackRoute = options.fallbackRoute;
55
+
56
+ // Convert padding to paddingBox
57
+ const padding = options.padding ?? _defaults.defaults.padding;
58
+ const sides = normalizePadding(padding);
59
+ const paddingBox = {
60
+ x: -sides.left,
61
+ y: -sides.top,
62
+ width: sides.left + sides.right,
63
+ height: sides.top + sides.bottom
64
+ };
65
+
66
+ // Calculate cost (same as step)
67
+ const cost = step;
68
+
69
+ // Calculate directions array with offsets and costs
70
+ const directions = [{
71
+ cost,
72
+ offsetX: step,
73
+ offsetY: 0,
74
+ angle: 0
75
+ }, {
76
+ cost,
77
+ offsetX: -step,
78
+ offsetY: 0,
79
+ angle: 0
80
+ }, {
81
+ cost,
82
+ offsetX: 0,
83
+ offsetY: step,
84
+ angle: 0
85
+ }, {
86
+ cost,
87
+ offsetX: 0,
88
+ offsetY: -step,
89
+ angle: 0
90
+ }];
91
+
92
+ // Calculate angle for each direction
93
+ directions.forEach(direction => {
94
+ const point1 = new _geometry.Point(0, 0);
95
+ const point2 = new _geometry.Point(direction.offsetX, direction.offsetY);
96
+ direction.angle = normalizeAngle(point1.theta(point2));
97
+ });
98
+ return {
99
+ step,
100
+ maxLoopCount,
101
+ precision,
102
+ maxDirectionChange,
103
+ startDirections,
104
+ endDirections,
105
+ excludeNodes,
106
+ excludeShapes,
107
+ excludeTerminals,
108
+ paddingBox,
109
+ snapToGrid,
110
+ borderRadius,
111
+ directionMap: _defaults.directionMap,
112
+ directions,
113
+ penalties,
114
+ cost,
115
+ fallbackRoute,
116
+ previousDirectionAngle: undefined
117
+ };
118
+ }
@@ -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,GA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KAAK,CAAA;KACZ,CAAA;IACD,UAAU,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;QACf,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAC,CAAA;IACF,SAAS,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,KAAK,KAAK,EAAE,CAAA;IACnD,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACvC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,35 @@
1
+ /**
2
+ * SortedSet class for managing open and closed sets in A* algorithm
3
+ * Maintains items sorted by their values
4
+ */
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,95 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SortedSet = void 0;
7
+ const OPEN = 1;
8
+ const CLOSE = 2;
9
+
10
+ /**
11
+ * SortedSet class for managing open and closed sets in A* algorithm
12
+ * Maintains items sorted by their values
13
+ */
14
+ class SortedSet {
15
+ items;
16
+ hash;
17
+ values;
18
+ constructor() {
19
+ this.items = [];
20
+ this.hash = new Map();
21
+ this.values = new Map();
22
+ }
23
+
24
+ /**
25
+ * Add an item with its value, maintaining sorted order
26
+ */
27
+ add(item, value) {
28
+ if (this.hash.get(item)) {
29
+ // Item removal - remove from items array
30
+ const index = this.items.indexOf(item);
31
+ if (index !== -1) {
32
+ this.items.splice(index, 1);
33
+ }
34
+ } else {
35
+ this.hash.set(item, OPEN);
36
+ }
37
+ this.values.set(item, value);
38
+
39
+ // Find insertion index using binary search
40
+ const index = this.sortedIndexBy(item);
41
+ this.items.splice(index, 0, item);
42
+ }
43
+
44
+ /**
45
+ * Pop the item with minimum value and mark it as closed
46
+ */
47
+ pop() {
48
+ const item = this.items.shift();
49
+ if (item) {
50
+ this.hash.set(item, CLOSE);
51
+ }
52
+ return item;
53
+ }
54
+
55
+ /**
56
+ * Check if item is in open set
57
+ */
58
+ isOpen(item) {
59
+ return this.hash.get(item) === OPEN;
60
+ }
61
+
62
+ /**
63
+ * Check if item is in closed set
64
+ */
65
+ isClose(item) {
66
+ return this.hash.get(item) === CLOSE;
67
+ }
68
+
69
+ /**
70
+ * Check if open set is empty
71
+ */
72
+ isEmpty() {
73
+ return this.items.length === 0;
74
+ }
75
+
76
+ /**
77
+ * Find sorted insertion index for an item
78
+ */
79
+ sortedIndexBy(item) {
80
+ const value = this.values.get(item);
81
+ let low = 0;
82
+ let high = this.items.length;
83
+ while (low < high) {
84
+ const mid = low + high >>> 1;
85
+ const midValue = this.values.get(this.items[mid]);
86
+ if (midValue < value) {
87
+ low = mid + 1;
88
+ } else {
89
+ high = mid;
90
+ }
91
+ }
92
+ return low;
93
+ }
94
+ }
95
+ exports.SortedSet = SortedSet;
@@ -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"}