@graph-render/core 1.0.1

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 (161) hide show
  1. package/.eslintrc.json +6 -0
  2. package/CHANGELOG.md +45 -0
  3. package/dist/edges/collision.d.ts +8 -0
  4. package/dist/edges/collision.d.ts.map +1 -0
  5. package/dist/edges/collision.js +26 -0
  6. package/dist/edges/collision.js.map +1 -0
  7. package/dist/edges/geometry.d.ts +22 -0
  8. package/dist/edges/geometry.d.ts.map +1 -0
  9. package/dist/edges/geometry.js +75 -0
  10. package/dist/edges/geometry.js.map +1 -0
  11. package/dist/edges/index.d.ts +4 -0
  12. package/dist/edges/index.d.ts.map +1 -0
  13. package/dist/edges/index.js +4 -0
  14. package/dist/edges/index.js.map +1 -0
  15. package/dist/edges/pathBuilder.d.ts +11 -0
  16. package/dist/edges/pathBuilder.d.ts.map +1 -0
  17. package/dist/edges/pathBuilder.js +114 -0
  18. package/dist/edges/pathBuilder.js.map +1 -0
  19. package/dist/edges/pathCalculation.d.ts +14 -0
  20. package/dist/edges/pathCalculation.d.ts.map +1 -0
  21. package/dist/edges/pathCalculation.js +47 -0
  22. package/dist/edges/pathCalculation.js.map +1 -0
  23. package/dist/edges/routing.d.ts +6 -0
  24. package/dist/edges/routing.d.ts.map +1 -0
  25. package/dist/edges/routing.js +243 -0
  26. package/dist/edges/routing.js.map +1 -0
  27. package/dist/edges/sideSelection.d.ts +17 -0
  28. package/dist/edges/sideSelection.d.ts.map +1 -0
  29. package/dist/edges/sideSelection.js +45 -0
  30. package/dist/edges/sideSelection.js.map +1 -0
  31. package/dist/index.d.ts +7 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +6 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/layouts/centered.d.ts +6 -0
  36. package/dist/layouts/centered.d.ts.map +1 -0
  37. package/dist/layouts/centered.js +69 -0
  38. package/dist/layouts/centered.js.map +1 -0
  39. package/dist/layouts/compactBracket.d.ts +3 -0
  40. package/dist/layouts/compactBracket.d.ts.map +1 -0
  41. package/dist/layouts/compactBracket.js +7 -0
  42. package/dist/layouts/compactBracket.js.map +1 -0
  43. package/dist/layouts/dag.d.ts +3 -0
  44. package/dist/layouts/dag.d.ts.map +1 -0
  45. package/dist/layouts/dag.js +52 -0
  46. package/dist/layouts/dag.js.map +1 -0
  47. package/dist/layouts/forceDirected.d.ts +3 -0
  48. package/dist/layouts/forceDirected.d.ts.map +1 -0
  49. package/dist/layouts/forceDirected.js +176 -0
  50. package/dist/layouts/forceDirected.js.map +1 -0
  51. package/dist/layouts/grid.d.ts +6 -0
  52. package/dist/layouts/grid.d.ts.map +1 -0
  53. package/dist/layouts/grid.js +34 -0
  54. package/dist/layouts/grid.js.map +1 -0
  55. package/dist/layouts/index.d.ts +12 -0
  56. package/dist/layouts/index.d.ts.map +1 -0
  57. package/dist/layouts/index.js +88 -0
  58. package/dist/layouts/index.js.map +1 -0
  59. package/dist/layouts/orthogonalFlow.d.ts +3 -0
  60. package/dist/layouts/orthogonalFlow.d.ts.map +1 -0
  61. package/dist/layouts/orthogonalFlow.js +81 -0
  62. package/dist/layouts/orthogonalFlow.js.map +1 -0
  63. package/dist/layouts/radialTree.d.ts +3 -0
  64. package/dist/layouts/radialTree.d.ts.map +1 -0
  65. package/dist/layouts/radialTree.js +45 -0
  66. package/dist/layouts/radialTree.js.map +1 -0
  67. package/dist/layouts/tree.d.ts +6 -0
  68. package/dist/layouts/tree.d.ts.map +1 -0
  69. package/dist/layouts/tree.js +19 -0
  70. package/dist/layouts/tree.js.map +1 -0
  71. package/dist/layouts/treeAlignment.d.ts +10 -0
  72. package/dist/layouts/treeAlignment.d.ts.map +1 -0
  73. package/dist/layouts/treeAlignment.js +69 -0
  74. package/dist/layouts/treeAlignment.js.map +1 -0
  75. package/dist/layouts/treePositioning.d.ts +14 -0
  76. package/dist/layouts/treePositioning.d.ts.map +1 -0
  77. package/dist/layouts/treePositioning.js +30 -0
  78. package/dist/layouts/treePositioning.js.map +1 -0
  79. package/dist/layouts/treeTopology.d.ts +29 -0
  80. package/dist/layouts/treeTopology.d.ts.map +1 -0
  81. package/dist/layouts/treeTopology.js +137 -0
  82. package/dist/layouts/treeTopology.js.map +1 -0
  83. package/dist/rendering/defaultRenderers.d.ts +10 -0
  84. package/dist/rendering/defaultRenderers.d.ts.map +1 -0
  85. package/dist/rendering/defaultRenderers.js +85 -0
  86. package/dist/rendering/defaultRenderers.js.map +1 -0
  87. package/dist/rendering/index.d.ts +4 -0
  88. package/dist/rendering/index.d.ts.map +1 -0
  89. package/dist/rendering/index.js +4 -0
  90. package/dist/rendering/index.js.map +1 -0
  91. package/dist/rendering/svg.d.ts +7 -0
  92. package/dist/rendering/svg.d.ts.map +1 -0
  93. package/dist/rendering/svg.js +256 -0
  94. package/dist/rendering/svg.js.map +1 -0
  95. package/dist/rendering/utils.d.ts +5 -0
  96. package/dist/rendering/utils.d.ts.map +1 -0
  97. package/dist/rendering/utils.js +33 -0
  98. package/dist/rendering/utils.js.map +1 -0
  99. package/dist/utils/config.d.ts +36 -0
  100. package/dist/utils/config.d.ts.map +1 -0
  101. package/dist/utils/config.js +115 -0
  102. package/dist/utils/config.js.map +1 -0
  103. package/dist/utils/constants.d.ts +15 -0
  104. package/dist/utils/constants.d.ts.map +1 -0
  105. package/dist/utils/constants.js +19 -0
  106. package/dist/utils/constants.js.map +1 -0
  107. package/dist/utils/graphParser.d.ts +16 -0
  108. package/dist/utils/graphParser.d.ts.map +1 -0
  109. package/dist/utils/graphParser.js +277 -0
  110. package/dist/utils/graphParser.js.map +1 -0
  111. package/dist/utils/graphTraversal.d.ts +13 -0
  112. package/dist/utils/graphTraversal.d.ts.map +1 -0
  113. package/dist/utils/graphTraversal.js +28 -0
  114. package/dist/utils/graphTraversal.js.map +1 -0
  115. package/dist/utils/index.d.ts +8 -0
  116. package/dist/utils/index.d.ts.map +1 -0
  117. package/dist/utils/index.js +7 -0
  118. package/dist/utils/index.js.map +1 -0
  119. package/dist/utils/nodeMetrics.d.ts +8 -0
  120. package/dist/utils/nodeMetrics.d.ts.map +1 -0
  121. package/dist/utils/nodeMetrics.js +12 -0
  122. package/dist/utils/nodeMetrics.js.map +1 -0
  123. package/dist/utils/nodeSizing.d.ts +3 -0
  124. package/dist/utils/nodeSizing.d.ts.map +1 -0
  125. package/dist/utils/nodeSizing.js +77 -0
  126. package/dist/utils/nodeSizing.js.map +1 -0
  127. package/package.json +29 -0
  128. package/project.json +32 -0
  129. package/src/edges/collision.ts +31 -0
  130. package/src/edges/geometry.ts +85 -0
  131. package/src/edges/index.ts +3 -0
  132. package/src/edges/pathBuilder.ts +136 -0
  133. package/src/edges/pathCalculation.ts +69 -0
  134. package/src/edges/routing.ts +459 -0
  135. package/src/edges/sideSelection.ts +67 -0
  136. package/src/index.ts +50 -0
  137. package/src/layouts/centered.ts +114 -0
  138. package/src/layouts/compactBracket.ts +14 -0
  139. package/src/layouts/dag.ts +76 -0
  140. package/src/layouts/forceDirected.ts +224 -0
  141. package/src/layouts/grid.ts +50 -0
  142. package/src/layouts/index.ts +148 -0
  143. package/src/layouts/orthogonalFlow.ts +112 -0
  144. package/src/layouts/radialTree.ts +77 -0
  145. package/src/layouts/tree.ts +35 -0
  146. package/src/layouts/treeAlignment.ts +107 -0
  147. package/src/layouts/treePositioning.ts +55 -0
  148. package/src/layouts/treeTopology.ts +184 -0
  149. package/src/rendering/defaultRenderers.ts +110 -0
  150. package/src/rendering/index.ts +3 -0
  151. package/src/rendering/svg.ts +346 -0
  152. package/src/rendering/utils.ts +41 -0
  153. package/src/utils/config.ts +198 -0
  154. package/src/utils/constants.ts +24 -0
  155. package/src/utils/graphParser.ts +495 -0
  156. package/src/utils/graphTraversal.ts +32 -0
  157. package/src/utils/index.ts +19 -0
  158. package/src/utils/nodeMetrics.ts +23 -0
  159. package/src/utils/nodeSizing.ts +97 -0
  160. package/tsconfig.json +11 -0
  161. package/tsconfig.tsbuildinfo +1 -0
package/.eslintrc.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "../../.eslintrc.json",
3
+ "parserOptions": {
4
+ "project": "./tsconfig.json"
5
+ }
6
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,45 @@
1
+ ## @graph-render/core [1.0.1](https://github.com/oleksandr-zhynzher/graph-render/compare/@graph-render/core@1.0.0...@graph-render/core@1.0.1) (2026-03-19)
2
+
3
+ ### 🐛 Bug Fixes
4
+
5
+ * **core:** bound smart routing collision scans ([4987920](https://github.com/oleksandr-zhynzher/graph-render/commit/4987920aa46ca1535ca4b69f2f5d47eb4edbf244))
6
+ * **core:** harden config normalization and stability ([983e372](https://github.com/oleksandr-zhynzher/graph-render/commit/983e372b767f20c12f220ca2206eac87ab31887c))
7
+ * **core:** reject dangling endpoints with explicit node maps ([b64d493](https://github.com/oleksandr-zhynzher/graph-render/commit/b64d493ccaad520d558195861076e11a194228d7))
8
+ * **labels:** cap label work and render multiline defaults ([395c444](https://github.com/oleksandr-zhynzher/graph-render/commit/395c44417df8d9476023090668596f3ec0e68fcc))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * **@graph-render/types:** upgraded to 1.0.1
14
+
15
+ ## @graph-render/core 1.0.0 (2026-03-17)
16
+
17
+ ### 🚀 Features
18
+
19
+ * **core:** add layered radial and flow layouts ([a934bc0](https://github.com/oleksandr-zhynzher/graph-render/commit/a934bc0f06325b2b7b41e044483f8ec487fcdec8))
20
+ * **core:** add node measurement and auto sizing ([721a082](https://github.com/oleksandr-zhynzher/graph-render/commit/721a08206bf26b979f0e5de9e97cfcc34d562e1f))
21
+ * **core:** improve edge routing and labels ([273bdcb](https://github.com/oleksandr-zhynzher/graph-render/commit/273bdcb4e30f47a2d9bd75428739ee03ff5cea10))
22
+
23
+ ### 🐛 Bug Fixes
24
+
25
+ * add numeric parameter validation; extract verticalGap magic constants ([fd70659](https://github.com/oleksandr-zhynzher/graph-render/commit/fd70659cbd4ccdfa38577ce7ad187e69a629fd28))
26
+ * clamp node y-coordinate to prevent layout overflow ([4e53808](https://github.com/oleksandr-zhynzher/graph-render/commit/4e53808070789e53a98f50db33c67d239844f391))
27
+ * compute verticalGap per-column proportional to column max node height ([915ed3b](https://github.com/oleksandr-zhynzher/graph-render/commit/915ed3ba924c7d2e2f9be8f8aab1f4264f4b8d08))
28
+ * correct (height, width) parameter order in orthogonalFlowLayout ([ff8cdc5](https://github.com/oleksandr-zhynzher/graph-render/commit/ff8cdc5b48749f8386dca0311cc5731e8f5a7459))
29
+ * correct RTL variable-width node alignment in orthogonalFlowLayout ([1faac95](https://github.com/oleksandr-zhynzher/graph-render/commit/1faac952b840bf56294216edab115d3187554a8e))
30
+ * replace silent ?? 0 level fallback with throwing assertion ([47a010b](https://github.com/oleksandr-zhynzher/graph-render/commit/47a010b923637517a21868be2df447348f20c6e8))
31
+ * use per-column max width for column pitch and RTL alignment ([2302240](https://github.com/oleksandr-zhynzher/graph-render/commit/2302240d013ce86d598f14ef20fca89de0e623e1))
32
+
33
+ ### ⚡ Performance Improvements
34
+
35
+ * replace O(N^2) spread with push in bucket construction ([178c094](https://github.com/oleksandr-zhynzher/graph-render/commit/178c09418dace9b43a1b243c1daebd598481728f))
36
+
37
+ ### ♻️ Code Refactoring
38
+
39
+ * extract assignDagLevels to treeTopology; remove duplicate buildLevels/assignLayers ([298eeb6](https://github.com/oleksandr-zhynzher/graph-render/commit/298eeb6e19cd2c49266b1560a6409767e1b2611b))
40
+ * make centering y-start overflow fallback explicit ([082a858](https://github.com/oleksandr-zhynzher/graph-render/commit/082a85888125f9beaf987922c64a6dd2b0d273cd))
41
+
42
+
43
+ ### Dependencies
44
+
45
+ * **@graph-render/types:** upgraded to 1.0.0
@@ -0,0 +1,8 @@
1
+ import { Point } from '@graph-render/types';
2
+ export declare const segmentIntersectsRect: (p1: Point, p2: Point, rect: {
3
+ x: number;
4
+ y: number;
5
+ w: number;
6
+ h: number;
7
+ }) => boolean;
8
+ //# sourceMappingURL=collision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collision.d.ts","sourceRoot":"","sources":["../../src/edges/collision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,eAAO,MAAM,qBAAqB,GAChC,IAAI,KAAK,EACT,IAAI,KAAK,EACT,MAAM;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,KACnD,OAwBF,CAAC"}
@@ -0,0 +1,26 @@
1
+ export const segmentIntersectsRect = (p1, p2, rect) => {
2
+ const { x, y, w, h } = rect;
3
+ const minX = Math.min(p1.x, p2.x);
4
+ const maxX = Math.max(p1.x, p2.x);
5
+ const minY = Math.min(p1.y, p2.y);
6
+ const maxY = Math.max(p1.y, p2.y);
7
+ if (maxX < x || minX > x + w || maxY < y || minY > y + h)
8
+ return false;
9
+ const inside = (px, py) => px >= x && px <= x + w && py >= y && py <= y + h;
10
+ if (inside(p1.x, p1.y) || inside(p2.x, p2.y))
11
+ return true;
12
+ const intersectsEdge = (x1, y1, x2, y2) => {
13
+ const denom = (p2.y - p1.y) * (x2 - x1) - (p2.x - p1.x) * (y2 - y1);
14
+ if (denom === 0)
15
+ return false;
16
+ const ua = ((p2.x - p1.x) * (y1 - p1.y) - (p2.y - p1.y) * (x1 - p1.x)) / denom;
17
+ const ub = ((x2 - x1) * (y1 - p1.y) - (y2 - y1) * (x1 - p1.x)) / denom;
18
+ return ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1;
19
+ };
20
+ const r1 = intersectsEdge(x, y, x + w, y);
21
+ const r2 = intersectsEdge(x + w, y, x + w, y + h);
22
+ const r3 = intersectsEdge(x + w, y + h, x, y + h);
23
+ const r4 = intersectsEdge(x, y + h, x, y);
24
+ return r1 || r2 || r3 || r4;
25
+ };
26
+ //# sourceMappingURL=collision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,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D,MAAM,EAAE,GAAG,cAAc,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC9B,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { PositionedNode, Point, Size, NodeSide } from '@graph-render/types';
2
+ /**
3
+ * Calculate the center point of a node
4
+ */
5
+ export declare const getNodeCenter: (node: PositionedNode, size: Size) => Point;
6
+ /**
7
+ * Get the point at the center of a node's side
8
+ */
9
+ export declare const getSideCenter: (node: PositionedNode, size: Size, side: NodeSide) => Point;
10
+ /**
11
+ * Get anchor point on a node's side with offset and inset
12
+ */
13
+ export declare const getAnchorPoint: (node: PositionedNode, size: Size, side: NodeSide, offset: number, inset: number) => Point;
14
+ /**
15
+ * Get the normal vector for a given side
16
+ */
17
+ export declare const getSideNormal: (side: NodeSide) => Point;
18
+ /**
19
+ * Get the inward normal vector for a given side
20
+ */
21
+ export declare const getSideInwardNormal: (side: NodeSide) => Point;
22
+ //# sourceMappingURL=geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/edges/geometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,cAAc,EAAE,MAAM,IAAI,KAAG,KAKhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,cAAc,EAAE,MAAM,IAAI,EAAE,MAAM,QAAQ,KAAG,KAahF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,cAAc,EACpB,MAAM,IAAI,EACV,MAAM,QAAQ,EACd,QAAQ,MAAM,EACd,OAAO,MAAM,KACZ,KAaF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,QAAQ,KAAG,KAW9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,QAAQ,KAAG,KAWpD,CAAC"}
@@ -0,0 +1,75 @@
1
+ import { NodeSide } from '@graph-render/types';
2
+ /**
3
+ * Calculate the center point of a node
4
+ */
5
+ export const getNodeCenter = (node, size) => {
6
+ return {
7
+ x: node.position.x + size.width / 2,
8
+ y: node.position.y + size.height / 2,
9
+ };
10
+ };
11
+ /**
12
+ * Get the point at the center of a node's side
13
+ */
14
+ export const getSideCenter = (node, size, side) => {
15
+ const cx = node.position.x + size.width / 2;
16
+ const cy = node.position.y + size.height / 2;
17
+ switch (side) {
18
+ case NodeSide.Left:
19
+ return { x: node.position.x, y: cy };
20
+ case NodeSide.Right:
21
+ return { x: node.position.x + size.width, y: cy };
22
+ case NodeSide.Top:
23
+ return { x: cx, y: node.position.y };
24
+ case NodeSide.Bottom:
25
+ return { x: cx, y: node.position.y + size.height };
26
+ }
27
+ };
28
+ /**
29
+ * Get anchor point on a node's side with offset and inset
30
+ */
31
+ export const getAnchorPoint = (node, size, side, offset, inset) => {
32
+ const cx = node.position.x + size.width / 2;
33
+ const cy = node.position.y + size.height / 2;
34
+ switch (side) {
35
+ case NodeSide.Left:
36
+ return { x: node.position.x - inset, y: cy + offset };
37
+ case NodeSide.Right:
38
+ return { x: node.position.x + size.width + inset, y: cy + offset };
39
+ case NodeSide.Top:
40
+ return { x: cx + offset, y: node.position.y - inset };
41
+ case NodeSide.Bottom:
42
+ return { x: cx + offset, y: node.position.y + size.height + inset };
43
+ }
44
+ };
45
+ /**
46
+ * Get the normal vector for a given side
47
+ */
48
+ export const getSideNormal = (side) => {
49
+ switch (side) {
50
+ case NodeSide.Left:
51
+ return { x: -1, y: 0 };
52
+ case NodeSide.Right:
53
+ return { x: 1, y: 0 };
54
+ case NodeSide.Top:
55
+ return { x: 0, y: -1 };
56
+ case NodeSide.Bottom:
57
+ return { x: 0, y: 1 };
58
+ }
59
+ };
60
+ /**
61
+ * Get the inward normal vector for a given side
62
+ */
63
+ export const getSideInwardNormal = (side) => {
64
+ switch (side) {
65
+ case NodeSide.Left:
66
+ return { x: 1, y: 0 };
67
+ case NodeSide.Right:
68
+ return { x: -1, y: 0 };
69
+ case NodeSide.Top:
70
+ return { x: 0, y: 1 };
71
+ case NodeSide.Bottom:
72
+ return { x: 0, y: -1 };
73
+ }
74
+ };
75
+ //# sourceMappingURL=geometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/edges/geometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAoB,EAAE,IAAU,EAAS,EAAE;IACvE,OAAO;QACL,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC;QACnC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC;KACrC,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAoB,EAAE,IAAU,EAAE,IAAc,EAAS,EAAE;IACvF,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IAC5C,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAC7C,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ,CAAC,IAAI;YAChB,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;QACvC,KAAK,QAAQ,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QAAQ,CAAC,MAAM;YAClB,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { routeEdges } from './routing';
2
+ export { buildEdgePath } from './pathBuilder';
3
+ export { segmentIntersectsRect } from './collision';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/edges/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { routeEdges } from './routing';
2
+ export { buildEdgePath } from './pathBuilder';
3
+ export { segmentIntersectsRect } from './collision';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/edges/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { PositionedEdge } from '@graph-render/types';
2
+ /**
3
+ * Build an SVG path string from edge points.
4
+ *
5
+ * Returns null (instead of throwing) when the edge has fewer than two points so
6
+ * that a malformed edge from a user-supplied routeEdgesOverride does not crash
7
+ * the React render tree. Both callers (EdgePath and svg.ts) already guard
8
+ * against a falsy return value.
9
+ */
10
+ export declare const buildEdgePath: (edge: PositionedEdge, curveEdges: boolean, curveStrength: number) => string | null;
11
+ //# sourceMappingURL=pathBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathBuilder.d.ts","sourceRoot":"","sources":["../../src/edges/pathBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAS,MAAM,qBAAqB,CAAC;AAiG5D;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GACxB,MAAM,cAAc,EACpB,YAAY,OAAO,EACnB,eAAe,MAAM,KACpB,MAAM,GAAG,IA0BX,CAAC"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Build a straight line path from edge points
3
+ */
4
+ const buildStraightPath = (points) => {
5
+ const [start, ...rest] = points;
6
+ return [`M ${start.x} ${start.y}`, ...rest.map((pt) => `L ${pt.x} ${pt.y}`)].join(' ');
7
+ };
8
+ /**
9
+ * Build a curved path for two-point edges
10
+ */
11
+ const buildTwoPointCurvedPath = (start, end, curveStrength) => {
12
+ if (start.y === end.y) {
13
+ return `M ${start.x} ${start.y} L ${end.x} ${end.y}`;
14
+ }
15
+ const midX = start.x + (end.x - start.x) * 0.55;
16
+ const dirY = Math.sign(end.y - start.y) || 1;
17
+ const dirX = Math.sign(end.x - start.x) || 1;
18
+ const radiusBase = Math.min(Math.abs(end.x - start.x), Math.abs(end.y - start.y));
19
+ const r = Math.max(4, radiusBase * Math.min(Math.max(curveStrength, 0), 0.45));
20
+ const p1x = midX - r * dirX;
21
+ const p1y = start.y;
22
+ const p2x = midX;
23
+ const p2y = start.y + r * dirY;
24
+ const p3x = midX;
25
+ const p3y = end.y - r * dirY;
26
+ const p4x = midX + r * dirX;
27
+ const p4y = end.y;
28
+ return [
29
+ `M ${start.x} ${start.y}`,
30
+ `L ${p1x} ${p1y}`,
31
+ `Q ${midX} ${p1y} ${p2x} ${p2y}`,
32
+ `L ${p3x} ${p3y}`,
33
+ `Q ${midX} ${end.y} ${p4x} ${p4y}`,
34
+ `L ${end.x} ${end.y}`,
35
+ ].join(' ');
36
+ };
37
+ /**
38
+ * Build a quadratic bezier path for three-point edges
39
+ */
40
+ const buildThreePointPath = (start, control, end) => {
41
+ return `M ${start.x} ${start.y} Q ${control.x} ${control.y} ${end.x} ${end.y}`;
42
+ };
43
+ /**
44
+ * Build a cubic bezier path for six-point edges (standard curved edge)
45
+ */
46
+ const buildSixPointPath = (points) => {
47
+ const [start, out, c1, c2, straightIn, end] = points;
48
+ return [
49
+ `M ${start.x} ${start.y}`,
50
+ `L ${out.x} ${out.y}`,
51
+ `C ${c1.x} ${c1.y} ${c2.x} ${c2.y} ${straightIn.x} ${straightIn.y}`,
52
+ `L ${end.x} ${end.y}`,
53
+ ].join(' ');
54
+ };
55
+ /**
56
+ * Build a path with multiple quadratic curves for variable-length edges
57
+ */
58
+ const buildMultiPointPath = (points) => {
59
+ const [start, ...rest] = points;
60
+ const commands = [`M ${start.x} ${start.y}`];
61
+ if (rest.length) {
62
+ commands.push(`L ${rest[0].x} ${rest[0].y}`);
63
+ }
64
+ for (let i = 1; i < rest.length - 1; i += 1) {
65
+ const ctrl = rest[i];
66
+ const next = rest[i + 1];
67
+ const isLastCurve = i === rest.length - 2;
68
+ if (isLastCurve) {
69
+ // FIX: removed the trailing `L rest[last]` that duplicated the Q endpoint.
70
+ // When isLastCurve is true, `next === rest[rest.length - 1]`, so the Q
71
+ // command already terminates at the final point. The extra L produced a
72
+ // zero-length segment that misplaced SVG `marker-end` arrowheads.
73
+ commands.push(`Q ${ctrl.x} ${ctrl.y} ${next.x} ${next.y}`);
74
+ break;
75
+ }
76
+ commands.push(`Q ${ctrl.x} ${ctrl.y} ${next.x} ${next.y}`);
77
+ }
78
+ if (rest.length === 2) {
79
+ const [ctrl, end] = rest;
80
+ commands.push(`Q ${ctrl.x} ${ctrl.y} ${end.x} ${end.y}`);
81
+ }
82
+ return commands.join(' ');
83
+ };
84
+ /**
85
+ * Build an SVG path string from edge points.
86
+ *
87
+ * Returns null (instead of throwing) when the edge has fewer than two points so
88
+ * that a malformed edge from a user-supplied routeEdgesOverride does not crash
89
+ * the React render tree. Both callers (EdgePath and svg.ts) already guard
90
+ * against a falsy return value.
91
+ */
92
+ export const buildEdgePath = (edge, curveEdges, curveStrength) => {
93
+ // FIX: was `throw new Error(...)` — returning null lets callers handle
94
+ // the bad edge gracefully without an unhandled exception in render.
95
+ if (edge.points.length < 2) {
96
+ return null;
97
+ }
98
+ if (!curveEdges) {
99
+ return buildStraightPath(edge.points);
100
+ }
101
+ if (edge.points.length === 2) {
102
+ const [start, end] = edge.points;
103
+ return buildTwoPointCurvedPath(start, end, curveStrength);
104
+ }
105
+ if (edge.points.length === 3) {
106
+ const [start, control, end] = edge.points;
107
+ return buildThreePointPath(start, control, end);
108
+ }
109
+ if (edge.points.length >= 6) {
110
+ return buildSixPointPath(edge.points);
111
+ }
112
+ return buildMultiPointPath(edge.points);
113
+ };
114
+ //# sourceMappingURL=pathBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathBuilder.js","sourceRoot":"","sources":["../../src/edges/pathBuilder.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,iBAAiB,GAAG,CAAC,MAAe,EAAU,EAAE;IACpD,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC;IAChC,OAAO,CAAC,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzF,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,uBAAuB,GAAG,CAAC,KAAY,EAAE,GAAU,EAAE,aAAqB,EAAU,EAAE;IAC1F,IAAI,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;QACtB,OAAO,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC;IACvD,CAAC;IAED,MAAM,IAAI,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point } from '@graph-render/types';
2
+ /**
3
+ * Calculate the lead-out distance based on edge configuration
4
+ */
5
+ export declare const getLeadOutDistance: (straight: boolean, isUndirected: boolean) => number;
6
+ /**
7
+ * Calculate control points for curved edge path
8
+ */
9
+ export declare const calculateControlPoints: (startPoint: Point, endPoint: Point, sourceNormal: Point, targetNormal: Point, leadOut: number, isUndirected: boolean) => Point[];
10
+ /**
11
+ * Calculate straight path points
12
+ */
13
+ export declare const calculateStraightPoints: (startPoint: Point, endPoint: Point, sourceNormal: Point, targetNormal: Point, leadOut: number, isUndirected: boolean) => Point[];
14
+ //# sourceMappingURL=pathCalculation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathCalculation.d.ts","sourceRoot":"","sources":["../../src/edges/pathCalculation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,OAAO,EAAE,cAAc,OAAO,KAAG,MAG7E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,YAAY,KAAK,EACjB,UAAU,KAAK,EACf,cAAc,KAAK,EACnB,cAAc,KAAK,EACnB,SAAS,MAAM,EACf,cAAc,OAAO,KACpB,KAAK,EAuBP,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAClC,YAAY,KAAK,EACjB,UAAU,KAAK,EACf,cAAc,KAAK,EACnB,cAAc,KAAK,EACnB,SAAS,MAAM,EACf,cAAc,OAAO,KACpB,KAAK,EAaP,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Calculate the lead-out distance based on edge configuration
3
+ */
4
+ export const getLeadOutDistance = (straight, isUndirected) => {
5
+ if (straight && !isUndirected)
6
+ return 28;
7
+ return isUndirected ? 8 : 10;
8
+ };
9
+ /**
10
+ * Calculate control points for curved edge path
11
+ */
12
+ export const calculateControlPoints = (startPoint, endPoint, sourceNormal, targetNormal, leadOut, isUndirected) => {
13
+ const outPoint = {
14
+ x: startPoint.x + sourceNormal.x * leadOut,
15
+ y: startPoint.y + sourceNormal.y * leadOut,
16
+ };
17
+ const endStraight = isUndirected ? 10 : 20;
18
+ const endStraightStart = {
19
+ x: endPoint.x - targetNormal.x * endStraight,
20
+ y: endPoint.y - targetNormal.y * endStraight,
21
+ };
22
+ const control1 = {
23
+ x: outPoint.x + sourceNormal.x * (leadOut * 3),
24
+ y: outPoint.y + sourceNormal.y * (leadOut * 3),
25
+ };
26
+ const control2 = {
27
+ x: endStraightStart.x - targetNormal.x * (endStraight * 3),
28
+ y: endStraightStart.y - targetNormal.y * (endStraight * 3),
29
+ };
30
+ return [startPoint, outPoint, control1, control2, endStraightStart, endPoint];
31
+ };
32
+ /**
33
+ * Calculate straight path points
34
+ */
35
+ export const calculateStraightPoints = (startPoint, endPoint, sourceNormal, targetNormal, leadOut, isUndirected) => {
36
+ const outPoint = {
37
+ x: startPoint.x + sourceNormal.x * leadOut,
38
+ y: startPoint.y + sourceNormal.y * leadOut,
39
+ };
40
+ const endStraight = isUndirected ? 10 : 20;
41
+ const endStraightStart = {
42
+ x: endPoint.x - targetNormal.x * endStraight,
43
+ y: endPoint.y - targetNormal.y * endStraight,
44
+ };
45
+ return [startPoint, outPoint, endStraightStart, endPoint];
46
+ };
47
+ //# sourceMappingURL=pathCalculation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathCalculation.js","sourceRoot":"","sources":["../../src/edges/pathCalculation.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAAiB,EAAE,YAAqB,EAAU,EAAE;IACrF,IAAI,QAAQ,IAAI,CAAC,YAAY;QAAE,OAAO,EAAE,CAAC;IACzC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/B,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG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B,EACnB,OAAe,EACf,YAAqB,EACZ,EAAE;IACX,MAAM,QAAQ,GAAG;QACf,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,OAAO;QAC1C,CAAC,EAAE,UAAU,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,OAAO;KAC3C,CAAC;IAEF,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3C,MAAM,gBAAgB,GAAG;QACvB,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,WAAW;QAC5C,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,WAAW;KAC7C,CAAC;IAEF,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC;AAC5D,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { PositionedNode, EdgeData, PositionedEdge, RouteEdgesOptions } from '@graph-render/types';
2
+ /**
3
+ * Route edges between nodes, calculating the path points for each edge
4
+ */
5
+ export declare const routeEdges: (nodes: PositionedNode[], edges: EdgeData[], opts?: RouteEdgesOptions) => PositionedEdge[];
6
+ //# sourceMappingURL=routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/edges/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,QAAQ,EACR,cAAc,EACd,iBAAiB,EAOlB,MAAM,qBAAqB,CAAC;AA2Z7B;;GAEG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,cAAc,EAAE,EACvB,OAAO,QAAQ,EAAE,EACjB,OAAO,iBAAiB,KACvB,cAAc,EA6BhB,CAAC"}