@kortexya/nodus 0.1.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 (252) hide show
  1. package/LICENSE +37 -0
  2. package/README.md +60 -0
  3. package/__vite-plugin-wasm-helper-1Aiokjk5.js +24 -0
  4. package/assets/hypergraphWorker-DV0aFI3L.js +1 -0
  5. package/assets/layoutWorker-DwDJwbgr.js +285 -0
  6. package/assets/nodus_wasm-C0vDfO5K.js +1 -0
  7. package/chunk-DmhlhrBa.js +11 -0
  8. package/nodus.src.bundle.js +33577 -0
  9. package/nodus_render_wasm-Bs6hlsx-.js +2617 -0
  10. package/nodus_wasm-DKYQVSUZ.js +2789 -0
  11. package/package.json +61 -0
  12. package/types/Nodus.d.ts +100 -0
  13. package/types/algorithms/concentric/index.d.ts +29 -0
  14. package/types/algorithms/concentricFactory.d.ts +43 -0
  15. package/types/algorithms/force/Alea.d.ts +13 -0
  16. package/types/algorithms/force/BVH.d.ts +35 -0
  17. package/types/algorithms/force/LayoutData.d.ts +40 -0
  18. package/types/algorithms/force/Packing.d.ts +31 -0
  19. package/types/algorithms/force/Physics.d.ts +61 -0
  20. package/types/algorithms/force/SEC.d.ts +14 -0
  21. package/types/algorithms/force/Topology.d.ts +3 -0
  22. package/types/algorithms/force/index.d.ts +54 -0
  23. package/types/algorithms/force-gpu/ParticleSystem.d.ts +45 -0
  24. package/types/algorithms/force-gpu/Settings.d.ts +60 -0
  25. package/types/algorithms/force-gpu/Simulation.d.ts +7 -0
  26. package/types/algorithms/force-gpu/getGlContext.d.ts +10 -0
  27. package/types/algorithms/force-gpu/gpuLayout.d.ts +14 -0
  28. package/types/algorithms/force-gpu/index.d.ts +2 -0
  29. package/types/algorithms/force-gpu/kernels/index.d.ts +176 -0
  30. package/types/algorithms/force-gpu/kernels/utils.d.ts +31 -0
  31. package/types/algorithms/force-gpu/shaders/aabb.d.ts +2 -0
  32. package/types/algorithms/force-gpu/shaders/bhExpand.d.ts +2 -0
  33. package/types/algorithms/force-gpu/shaders/bhTranslate.d.ts +2 -0
  34. package/types/algorithms/force-gpu/shaders/cellLookup.d.ts +2 -0
  35. package/types/algorithms/force-gpu/shaders/index.d.ts +9 -0
  36. package/types/algorithms/force-gpu/shaders/integrate.d.ts +2 -0
  37. package/types/algorithms/force-gpu/shaders/morton.d.ts +2 -0
  38. package/types/algorithms/force-gpu/shaders/sortIntervals.d.ts +2 -0
  39. package/types/algorithms/force-gpu/shaders/sortKeys.d.ts +2 -0
  40. package/types/algorithms/force-gpu/shaders/types.d.ts +10 -0
  41. package/types/algorithms/force-gpu/webgl/helpers.d.ts +24 -0
  42. package/types/algorithms/force-gpu/webgl/index.d.ts +4 -0
  43. package/types/algorithms/force-gpu/webgl/program.d.ts +15 -0
  44. package/types/algorithms/forceFactory.d.ts +55 -0
  45. package/types/algorithms/forceLinkFactory.d.ts +40 -0
  46. package/types/algorithms/grid/index.d.ts +26 -0
  47. package/types/algorithms/gridFactory.d.ts +30 -0
  48. package/types/algorithms/hierarchical/index.d.ts +80 -0
  49. package/types/algorithms/hierarchical/sugiyama.d.ts +144 -0
  50. package/types/algorithms/hierarchicalFactory.d.ts +49 -0
  51. package/types/algorithms/index.d.ts +13 -0
  52. package/types/algorithms/radial/index.d.ts +33 -0
  53. package/types/algorithms/radialFactory.d.ts +54 -0
  54. package/types/algorithms/sequential/index.d.ts +37 -0
  55. package/types/algorithms/sequentialFactory.d.ts +37 -0
  56. package/types/core/Edge.d.ts +67 -0
  57. package/types/core/EdgeList.d.ts +86 -0
  58. package/types/core/Node.d.ts +89 -0
  59. package/types/core/NodeList.d.ts +105 -0
  60. package/types/core/Transformation.d.ts +108 -0
  61. package/types/core/enums.d.ts +16 -0
  62. package/types/geometry/BoundingBox.d.ts +41 -0
  63. package/types/geometry/index.d.ts +276 -0
  64. package/types/geometry/types.d.ts +27 -0
  65. package/types/hypergraph/Hypergraph.d.ts +74 -0
  66. package/types/hypergraph/KoenigGraph.d.ts +29 -0
  67. package/types/hypergraph/Simplifier.d.ts +39 -0
  68. package/types/hypergraph/Statistics.d.ts +55 -0
  69. package/types/hypergraph/forbidden/StrangledHyperedge.d.ts +12 -0
  70. package/types/hypergraph/forbidden/StrangledVertex.d.ts +16 -0
  71. package/types/hypergraph/forbidden/ThreeAdjacentCluster2.d.ts +10 -0
  72. package/types/hypergraph/forbidden/TwoAdjacentCluster3.d.ts +14 -0
  73. package/types/hypergraph/forbidden/index.d.ts +22 -0
  74. package/types/hypergraph/index.d.ts +21 -0
  75. package/types/hypergraph/layout/Adam.d.ts +12 -0
  76. package/types/hypergraph/layout/Energy.d.ts +55 -0
  77. package/types/hypergraph/layout/LBFGS.d.ts +32 -0
  78. package/types/hypergraph/layout/Optimizer.d.ts +60 -0
  79. package/types/hypergraph/layout/Reverser.d.ts +42 -0
  80. package/types/hypergraph/operations/AtomicOperation.d.ts +54 -0
  81. package/types/hypergraph/operations/HyperedgeMerger.d.ts +30 -0
  82. package/types/hypergraph/operations/HyperedgeRemoval.d.ts +27 -0
  83. package/types/hypergraph/operations/VertexMerger.d.ts +32 -0
  84. package/types/hypergraph/operations/VertexRemoval.d.ts +30 -0
  85. package/types/hypergraph/operations/index.d.ts +19 -0
  86. package/types/hypergraph/osfkb/adapter.d.ts +315 -0
  87. package/types/hypergraph/render/Interaction.d.ts +40 -0
  88. package/types/hypergraph/render/PolygonRenderer.d.ts +50 -0
  89. package/types/hypergraph/render/SVGPolygonRenderer.d.ts +7 -0
  90. package/types/hypergraph/types.d.ts +170 -0
  91. package/types/index.d.ts +21 -0
  92. package/types/internals/Algorithms.d.ts +68 -0
  93. package/types/internals/AlgorithmsPrimitives.d.ts +18 -0
  94. package/types/internals/Animations.d.ts +39 -0
  95. package/types/internals/AttributePathPrimitives.d.ts +2 -0
  96. package/types/internals/Brand.d.ts +22 -0
  97. package/types/internals/Camera.d.ts +115 -0
  98. package/types/internals/CameraInteractions.d.ts +15 -0
  99. package/types/internals/CameraInteractionsPrimitives.d.ts +18 -0
  100. package/types/internals/Captor.d.ts +56 -0
  101. package/types/internals/CaptorPrimitives.d.ts +9 -0
  102. package/types/internals/ClassModule.d.ts +42 -0
  103. package/types/internals/ConnectNodes.d.ts +23 -0
  104. package/types/internals/CurvatureManager.d.ts +14 -0
  105. package/types/internals/DataModule.d.ts +29 -0
  106. package/types/internals/Disabled.d.ts +27 -0
  107. package/types/internals/DomModule.d.ts +87 -0
  108. package/types/internals/DragModule.d.ts +14 -0
  109. package/types/internals/ElementSet.d.ts +17 -0
  110. package/types/internals/EventsModule.d.ts +41 -0
  111. package/types/internals/FlexArray.d.ts +54 -0
  112. package/types/internals/Geo.d.ts +127 -0
  113. package/types/internals/Graph.d.ts +109 -0
  114. package/types/internals/Graphics.d.ts +112 -0
  115. package/types/internals/GraphicsEngine.d.ts +96 -0
  116. package/types/internals/Hover.d.ts +32 -0
  117. package/types/internals/Hypergraph.d.ts +112 -0
  118. package/types/internals/IndexList.d.ts +28 -0
  119. package/types/internals/IndividualAttributes.d.ts +27 -0
  120. package/types/internals/Interactions.d.ts +45 -0
  121. package/types/internals/Keyboard.d.ts +25 -0
  122. package/types/internals/LabelManager.d.ts +56 -0
  123. package/types/internals/Lasso.d.ts +22 -0
  124. package/types/internals/Layers.d.ts +79 -0
  125. package/types/internals/LayersPrimitives.d.ts +5 -0
  126. package/types/internals/Layouts.d.ts +35 -0
  127. package/types/internals/LayoutsInternal.d.ts +37 -0
  128. package/types/internals/LayoutsPrimitives.d.ts +23 -0
  129. package/types/internals/Legend.d.ts +33 -0
  130. package/types/internals/LegendPrimitives.d.ts +3 -0
  131. package/types/internals/Locate.d.ts +43 -0
  132. package/types/internals/LocatePrimitives.d.ts +20 -0
  133. package/types/internals/MappingManager.d.ts +27 -0
  134. package/types/internals/MappingPrimitives.d.ts +29 -0
  135. package/types/internals/Module.d.ts +23 -0
  136. package/types/internals/Mouse.d.ts +42 -0
  137. package/types/internals/NodusModules.d.ts +99 -0
  138. package/types/internals/PositionModule.d.ts +10 -0
  139. package/types/internals/PulseModule.d.ts +29 -0
  140. package/types/internals/Quadtree.d.ts +100 -0
  141. package/types/internals/RectangleSelect.d.ts +18 -0
  142. package/types/internals/Resizing.d.ts +48 -0
  143. package/types/internals/Rewiring.d.ts +64 -0
  144. package/types/internals/SchemaWatchPrimitives.d.ts +75 -0
  145. package/types/internals/Selection.d.ts +52 -0
  146. package/types/internals/SelectionModule.d.ts +27 -0
  147. package/types/internals/Settings.d.ts +20 -0
  148. package/types/internals/Snapping.d.ts +54 -0
  149. package/types/internals/Spatial.d.ts +50 -0
  150. package/types/internals/SpatialPrimitives.d.ts +75 -0
  151. package/types/internals/Storage.d.ts +46 -0
  152. package/types/internals/StyleRulesModule.d.ts +21 -0
  153. package/types/internals/Synchronizer.d.ts +17 -0
  154. package/types/internals/Tooltip.d.ts +25 -0
  155. package/types/internals/TooltipPrimitives.d.ts +21 -0
  156. package/types/internals/Topology.d.ts +50 -0
  157. package/types/internals/Touch.d.ts +16 -0
  158. package/types/internals/Transformations.d.ts +36 -0
  159. package/types/internals/VirtualMouse.d.ts +52 -0
  160. package/types/internals/WasmHGrid.d.ts +25 -0
  161. package/types/internals/WatcherModule.d.ts +25 -0
  162. package/types/internals/Workers.d.ts +79 -0
  163. package/types/internals/algorithmExports.d.ts +333 -0
  164. package/types/internals/algorithmHelpers.d.ts +36 -0
  165. package/types/internals/attributes/AttributesManager.d.ts +216 -0
  166. package/types/internals/attributes/ElementAttributesManager.d.ts +119 -0
  167. package/types/internals/attributes/attributeHelpers.d.ts +70 -0
  168. package/types/internals/attributes/flexArrayFactories.d.ts +277 -0
  169. package/types/internals/easing.d.ts +15 -0
  170. package/types/internals/helpers.d.ts +79 -0
  171. package/types/internals/hypergraphWorker.d.ts +37 -0
  172. package/types/internals/hypergraphWorkerHost.d.ts +40 -0
  173. package/types/internals/labels/SpatialGrid.d.ts +29 -0
  174. package/types/internals/labels/fillEdgeTexts.d.ts +25 -0
  175. package/types/internals/labels/fillNodeTexts.d.ts +24 -0
  176. package/types/internals/labels/helpers.d.ts +180 -0
  177. package/types/internals/layoutWorker.d.ts +21 -0
  178. package/types/internals/rendering/BoundariesManager.d.ts +53 -0
  179. package/types/internals/rendering/Buffer2.d.ts +91 -0
  180. package/types/internals/rendering/BufferList.d.ts +86 -0
  181. package/types/internals/rendering/CpuRenderer.d.ts +128 -0
  182. package/types/internals/rendering/EasingManager.d.ts +40 -0
  183. package/types/internals/rendering/EdgeDrawer.d.ts +54 -0
  184. package/types/internals/rendering/ElementGroup.d.ts +66 -0
  185. package/types/internals/rendering/MemoryManager.d.ts +71 -0
  186. package/types/internals/rendering/NodeDrawer.d.ts +49 -0
  187. package/types/internals/rendering/PatternManager.d.ts +29 -0
  188. package/types/internals/rendering/RENDER_MAPPING.d.ts +5 -0
  189. package/types/internals/rendering/RendererBase.d.ts +127 -0
  190. package/types/internals/rendering/ShapeManager.d.ts +46 -0
  191. package/types/internals/rendering/TextManager.d.ts +112 -0
  192. package/types/internals/rendering/canvasHelpers.d.ts +5 -0
  193. package/types/internals/rendering/constants.d.ts +125 -0
  194. package/types/internals/rendering/curveHelpers.d.ts +96 -0
  195. package/types/internals/rendering/drawerHelpers.d.ts +32 -0
  196. package/types/internals/rendering/float16.d.ts +25 -0
  197. package/types/internals/rendering/hitDetection.d.ts +89 -0
  198. package/types/internals/rendering/loadGraph.d.ts +103 -0
  199. package/types/internals/rendering/objectInfo.d.ts +46 -0
  200. package/types/internals/rendering/packing.d.ts +46 -0
  201. package/types/internals/rendering/shapeHelpers.d.ts +26 -0
  202. package/types/internals/rendering/types.d.ts +143 -0
  203. package/types/internals/renderingBinaryPrimitives.d.ts +110 -0
  204. package/types/internals/utilsExports.d.ts +408 -0
  205. package/types/internals/wasmBackend.d.ts +38 -0
  206. package/types/internals/wasmColumns.d.ts +61 -0
  207. package/types/internals/wasmInit.d.ts +1 -0
  208. package/types/modules/APIModule.d.ts +8 -0
  209. package/types/modules/AlgorithmsAPI.d.ts +15 -0
  210. package/types/modules/BrandAPI.d.ts +6 -0
  211. package/types/modules/CaptorAPI.d.ts +9 -0
  212. package/types/modules/ClassesAPI.d.ts +9 -0
  213. package/types/modules/DebugAPI.d.ts +18 -0
  214. package/types/modules/DisabledAPI.d.ts +11 -0
  215. package/types/modules/DomAPI.d.ts +9 -0
  216. package/types/modules/EventsAPI.d.ts +16 -0
  217. package/types/modules/ExportAPI.d.ts +23 -0
  218. package/types/modules/GeneratorsAPI.d.ts +12 -0
  219. package/types/modules/GeoAPI.d.ts +20 -0
  220. package/types/modules/GraphAPI.d.ts +26 -0
  221. package/types/modules/GraphicsAPI.d.ts +8 -0
  222. package/types/modules/HypergraphAPI.d.ts +71 -0
  223. package/types/modules/KeyboardAPI.d.ts +6 -0
  224. package/types/modules/LayersAPI.d.ts +7 -0
  225. package/types/modules/LayoutsAPI.d.ts +25 -0
  226. package/types/modules/LegendAPI.d.ts +9 -0
  227. package/types/modules/MouseAPI.d.ts +16 -0
  228. package/types/modules/ParseAPI.d.ts +83 -0
  229. package/types/modules/RulesAPI.d.ts +7 -0
  230. package/types/modules/SchemaAPI.d.ts +9 -0
  231. package/types/modules/SelectionAPI.d.ts +12 -0
  232. package/types/modules/SettingsAPI.d.ts +9 -0
  233. package/types/modules/StylesAPI.d.ts +64 -0
  234. package/types/modules/ToolsAPI.d.ts +68 -0
  235. package/types/modules/TransformationsAPI.d.ts +30 -0
  236. package/types/modules/ViewAPI.d.ts +52 -0
  237. package/types/publicTypes.d.ts +56 -0
  238. package/types/renderers/CanvasRenderer.d.ts +86 -0
  239. package/types/renderers/Renderer.d.ts +13 -0
  240. package/types/renderers/SVGRenderer.d.ts +57 -0
  241. package/types/renderers/WasmGraphRenderer.d.ts +118 -0
  242. package/types/renderers/WasmRendererAdapter.d.ts +38 -0
  243. package/types/tools/ConnectNodesAPI.d.ts +42 -0
  244. package/types/tools/LassoAPI.d.ts +78 -0
  245. package/types/tools/RectangleSelectAPI.d.ts +51 -0
  246. package/types/tools/ResizingAPI.d.ts +62 -0
  247. package/types/tools/RewiringAPI.d.ts +78 -0
  248. package/types/tools/SnappingAPI.d.ts +71 -0
  249. package/types/tools/ToolsAPI.d.ts +46 -0
  250. package/types/tools/TooltipAPI.d.ts +141 -0
  251. package/types/transformations/TransformationsEngine.d.ts +602 -0
  252. package/types/utils/index.d.ts +6 -0
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Rendering curve helpers.
3
+ *
4
+ * These functions handle animation interpolation, color mixing, edge text
5
+ * angle computation, line dash patterns, and curve segment length approximation.
6
+ */
7
+ /**
8
+ * Compute the animation progress ratio for a given time, using polynomial
9
+ * easing coefficients looked up from the easing manager.
10
+ *
11
+ * @param currentTime - Current timestamp.
12
+ * @param beginTime - Animation start timestamp.
13
+ * @param duration - Total animation duration.
14
+ * @param easing - Name of the easing function.
15
+ * @returns A value in [0, 1] representing the animation progress.
16
+ */
17
+ export declare function computeAnimationRatio(currentTime: number, beginTime: number, duration: number, easing: string): number;
18
+ /**
19
+ * Linearly interpolate between two CSS colour values.
20
+ *
21
+ * @param colorA - Start colour (CSS string).
22
+ * @param colorB - End colour (CSS string).
23
+ * @param ratio - Interpolation ratio for RGB channels.
24
+ * @param alphaRatio - Interpolation ratio for the alpha channel.
25
+ * @returns An `rgba(…)` CSS colour string.
26
+ */
27
+ export declare function mixColor(colorA: string, colorB: string, ratio: number, alphaRatio: number): string;
28
+ interface Point {
29
+ x: number;
30
+ y: number;
31
+ }
32
+ /**
33
+ * Compute the angle at which edge label text should be drawn.
34
+ *
35
+ * The tangent vector is flipped when necessary so that the text always reads
36
+ * left-to-right and respects self-loop and offset-angle orientation.
37
+ *
38
+ * @param tangent - Tangent vector at the label position (mutated in place).
39
+ * @param isSelfLoop - Whether the edge is a self-loop.
40
+ * @param offsetAngle - The view rotation offset angle.
41
+ * @returns The text drawing angle in radians.
42
+ */
43
+ export declare function computeEdgeTextAngle(tangent: Point, isSelfLoop: boolean, offsetAngle: number): number;
44
+ /**
45
+ * Compute the line-dash array for a dashed edge of a given total length.
46
+ *
47
+ * The dash/gap pattern is tiled to fill the available space between the
48
+ * source and target clips, then a final partial segment is appended.
49
+ *
50
+ * @param totalLength - Total edge length in pixels.
51
+ * @param thickness - Edge thickness (multiplies dash/gap lengths).
52
+ * @param sourceClip - Clip length at the source end.
53
+ * @param targetClip - Clip length at the target end.
54
+ * @param dashLength - Dash length (in multiples of thickness).
55
+ * @param gapLength - Gap length (in multiples of thickness).
56
+ * @returns An array suitable for `setLineDash`.
57
+ */
58
+ export declare function computeLineDash(totalLength: number, thickness: number, sourceClip: number, targetClip: number, dashLength: number, gapLength: number): number[];
59
+ /**
60
+ * Approximate the arc length of a cubic Bézier curve using Gaussian
61
+ * quadrature (7-point rule).
62
+ *
63
+ * For curves that are nearly flat (control points nearly collinear) a
64
+ * cheaper one-sided estimate is used; otherwise a two-sided symmetric
65
+ * estimate is computed.
66
+ *
67
+ * @param p0 - Start point.
68
+ * @param p1 - First control point.
69
+ * @param p2 - Second control point.
70
+ * @param p3 - End point.
71
+ * @returns Approximate arc length.
72
+ */
73
+ export declare function getCubicSegmentLength(p0: Point, p1: Point, p2: Point, p3: Point): number;
74
+ /**
75
+ * Compute the arc length of a quadratic Bézier curve segment using a
76
+ * closed-form analytical solution.
77
+ *
78
+ * @param curvature - Edge curvature value.
79
+ * @param chordLength - Straight-line distance between endpoints.
80
+ * @param tScale - Parameter-space extent (usually 1 for the full curve).
81
+ * @returns Approximate arc length.
82
+ */
83
+ export declare function getQuadraticSegmentLength(curvature: number, chordLength: number, tScale: number): number;
84
+ /**
85
+ * Approximate the arc length of a self-loop cubic Bézier by treating the
86
+ * control-point triangle's circumradius as a circle and scaling by π.
87
+ *
88
+ * @param p0 - Start point.
89
+ * @param p1 - First control point.
90
+ * @param p2 - Second control point.
91
+ * @param _p3 - End point (unused, kept for API consistency).
92
+ * @param scale - Scale factor.
93
+ * @returns Approximate arc length.
94
+ */
95
+ export declare function getSelfLoopSegmentLengthApprox(p0: Point, p1: Point, p2: Point, _p3: Point, scale: number): number;
96
+ export {};
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Shared helpers used by both NodeDrawer and EdgeDrawer.
3
+ *
4
+ * Provides depth/layer math, color inheritance resolution, text wrapping,
5
+ * and the shape-name/sentinel constants consumed across the rendering layer.
6
+ */
7
+ import { NB_BLOCK_PER_INDEX } from './constants';
8
+ export { NB_BLOCK_PER_INDEX };
9
+ export interface DepthInfo {
10
+ edgeHalo: number;
11
+ nodeHaloStroke: number;
12
+ nodeHalo: number;
13
+ edgeBody: number;
14
+ edgeTextBackground: number;
15
+ edgeText: number;
16
+ nodeBody: number;
17
+ nodeTextBackground: number;
18
+ nodeText: number;
19
+ }
20
+ export declare function createDepthInfo(): DepthInfo;
21
+ export declare function layerToDepth(layer: number, depth?: DepthInfo): DepthInfo;
22
+ export declare function inheritColor(value: string, parentColor: string | string[], angle?: number): string;
23
+ export declare function inheritSourceTargetColor(value: string, sourceColor: string | string[], targetColor: string | string[]): string;
24
+ export declare const isValidTextContent: (value: any) => boolean;
25
+ export declare function splitText(text: string, maxLineLength: number): string;
26
+ export declare const SHIFTED = "shifted";
27
+ export declare const OPEN_ARROW = "open-arrow";
28
+ export declare const OPEN_ARROW_TAIL = "arrow-tail-open";
29
+ export declare const OPEN_ARROW_HEAD = "arrow-head-open";
30
+ export declare const OPEN_ARROW_NONE = "arrow-none-ex-open";
31
+ export declare const OPEN_ARROW_BOTH = "arrow-both-open";
32
+ export declare const SDF_TEXT = -1;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * IEEE 754 half-precision (float16) conversion utilities and a simple
3
+ * `isNumber` guard.
4
+ */
5
+ /**
6
+ * Check whether a value is a finite number.
7
+ *
8
+ * @param value - The value to test.
9
+ * @returns `true` when `value` is a finite JS number.
10
+ */
11
+ export declare function isNumber(value: unknown): value is number;
12
+ /**
13
+ * Encode a 64-bit JavaScript number into a 16-bit half-precision float (IEEE 754).
14
+ *
15
+ * @param value - The number to encode.
16
+ * @returns A 16-bit unsigned integer representing the half-float.
17
+ */
18
+ export declare const toFloat16: (value: number) => number;
19
+ /**
20
+ * Decode a 16-bit half-precision float back into a JavaScript number.
21
+ *
22
+ * @param bits - The 16-bit unsigned integer to decode.
23
+ * @returns The corresponding 64-bit float value.
24
+ */
25
+ export declare const fromFloat16: (bits: number) => number;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Hit-detection functions for nodes and edges.
3
+ *
4
+ * Provides three routines:
5
+ * - detectNode - finds the topmost node under a screen point.
6
+ * - checkBadge - internal helper that tests a node's corner badges.
7
+ * - detectEdge - finds the topmost edge under a screen point.
8
+ *
9
+ * These functions test whether a screen-space point hits a node or edge,
10
+ * accounting for shape, curvature, self-loops, bent edges, badges, and text.
11
+ */
12
+ interface Point {
13
+ x: number;
14
+ y: number;
15
+ }
16
+ /** Something that has graphToScreenCoordinates, getZoom, getAngle, etc. */
17
+ interface ViewTransformProvider {
18
+ getZoom(): number;
19
+ getAngle(): number;
20
+ graphToScreenCoordinates(pt: Point): Point;
21
+ screenToGraphCoordinates(pt: Point): Point;
22
+ getCornerCos(index: number): number;
23
+ getCornerSin(index: number): number;
24
+ }
25
+ /** The data-store (FlexArrays) provider. */
26
+ interface DataStoreProvider {
27
+ update(): void;
28
+ getFlexArrays(): any;
29
+ }
30
+ /** Shape hit-testing + text measurement provider. */
31
+ interface ShapeHitProvider {
32
+ checkShapeHit(shape: string | number, normalizedX: number, normalizedY: number): boolean;
33
+ measureText(text: string, font: any, style: any, scale: number): {
34
+ width: number;
35
+ height: number;
36
+ };
37
+ }
38
+ /** The graph object provider (nodes, edges, object lists). */
39
+ interface GraphObjectProvider {
40
+ getNodes(): {
41
+ _indexes: number[];
42
+ };
43
+ getEdges(): {
44
+ _indexes: number[];
45
+ };
46
+ getObjectList(isNode: boolean): {
47
+ get(index: number): any | null;
48
+ };
49
+ getAttribute(isNode: boolean, name: string): {
50
+ get(index: number): any;
51
+ };
52
+ }
53
+ /**
54
+ * Find the topmost node at screen position (`screenX`, `screenY`).
55
+ *
56
+ * @param screenX - X coordinate in screen/pixel space.
57
+ * @param screenY - Y coordinate in screen/pixel space.
58
+ * @param checkText - Whether to also check text bounding boxes.
59
+ * @param checkBadges - Whether to also check badge hit-areas.
60
+ * @param tolerance - Extra pixel tolerance around the node shape.
61
+ * @param candidateIndexes - Pre-filtered array of node indices to test (or null for all).
62
+ * @param graphObjects - Graph object provider (nodes, edges, object lists).
63
+ * @param dataStore - Data store for flex-array access.
64
+ * @param viewTransform - View/camera transform.
65
+ * @param shapeHitProvider - Shape hit-testing + text measurement.
66
+ * @param excludedNodes - Set of node indices to skip.
67
+ * @param getTextContent - Callback resolving a text reference to a string.
68
+ * @returns The graph object at that position, or null.
69
+ */
70
+ export declare function detectNode(screenX: number, screenY: number, checkText: boolean, checkBadges: boolean, tolerance: number, candidateIndexes: number[] | null, graphObjects: GraphObjectProvider, dataStore: DataStoreProvider, viewTransform: ViewTransformProvider, shapeHitProvider: ShapeHitProvider, excludedNodes: Set<number>, getTextContent: (ref: any) => string | null): any | null;
71
+ /**
72
+ * Find the topmost edge at screen position (`screenX`, `screenY`).
73
+ *
74
+ * @param screenX - X coordinate in screen/pixel space.
75
+ * @param screenY - Y coordinate in screen/pixel space.
76
+ * @param _checkText - Reserved (unused in current implementation).
77
+ * @param tolerance - Extra pixel tolerance around the edge shape.
78
+ * @param candidateIndexes - Pre-filtered array of edge indices to test (or null for all).
79
+ * @param graphObjects - Graph object provider.
80
+ * @param viewTransform - View/camera transform.
81
+ * @param dataStore - Data store for flex-array access.
82
+ * @param bentEnable - Whether bent edges are enabled (or the bend config).
83
+ * @param bentVertical - Bent-edge vertical layout flag.
84
+ * @param excludedNodes - Set of node indices whose edges should be skipped.
85
+ * @param excludedNodeId - A single node id whose self-loop edges should be skipped.
86
+ * @returns The graph edge object at that position, or null.
87
+ */
88
+ export declare function detectEdge(screenX: number, screenY: number, _checkText: boolean, tolerance: number, candidateIndexes: number[] | null, graphObjects: GraphObjectProvider, viewTransform: ViewTransformProvider, movingNodes: Set<number>, dataStore: DataStoreProvider, bentEnable: any, bentVertical: any, excludedNodeId: number | undefined): any | null;
89
+ export {};
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Functions that load graph data into the graphics engine's GPU buffer system.
3
+ *
4
+ * - `loadGraphInGraphicsEngine` iterates changed nodes/edges, encoding visual
5
+ * attributes into buffer memory via NodeDrawer / EdgeDrawer.
6
+ * - `loadRequiredShapes` ensures every shape referenced by any element is
7
+ * registered in the engine.
8
+ * - `setRoundness` updates polygon shapes with rounded corners.
9
+ */
10
+ import type { Graph } from '../Graph';
11
+ import type { ShapeDefinition } from './shapeHelpers';
12
+ interface ImageManager {
13
+ getImage(url: string): any;
14
+ }
15
+ /** Options passed to `loadGraphInGraphicsEngine`. */
16
+ export interface LoadGraphOptions {
17
+ graph: Graph;
18
+ elements: {
19
+ nodes: ElementList;
20
+ edges: ElementList;
21
+ };
22
+ engine: GraphicsEngine;
23
+ imageManager: ImageManager;
24
+ fontManager: FontManager;
25
+ view: ViewState;
26
+ attributes: AttributesSnapshot;
27
+ boundaries: BoundaryInfo;
28
+ formatText: (text: string | null) => string;
29
+ }
30
+ interface ElementList {
31
+ size: number;
32
+ _indexes: number[];
33
+ }
34
+ interface GraphicsEngine {
35
+ setGlobalBoundaries(params: GlobalBoundaryParams): boolean;
36
+ createGroup(): any;
37
+ storeGroup(blockId: number, group: any): void;
38
+ freeBlock(blockId: number): void;
39
+ getBentEdges(): {
40
+ bentEnable: boolean;
41
+ bentVertical: boolean;
42
+ };
43
+ registerShape(name: string, shape: ShapeDefinition): void;
44
+ updateShape(name: string, shape: ShapeDefinition): void;
45
+ measureText(text: string, font: string, style: string, scale?: number): {
46
+ width: number;
47
+ height: number;
48
+ };
49
+ }
50
+ interface FontManager {
51
+ getFont(name: string): string;
52
+ }
53
+ interface ViewState {
54
+ angle?: number;
55
+ }
56
+ interface AttributesSnapshot {
57
+ nodes: {
58
+ current: any;
59
+ previous: any;
60
+ };
61
+ edges: {
62
+ current: any;
63
+ previous: any;
64
+ };
65
+ }
66
+ interface BoundaryInfo {
67
+ maxSize: number;
68
+ maxMinVisibleSize: number;
69
+ }
70
+ interface GlobalBoundaryParams {
71
+ maxBlockId: number;
72
+ maxScaledSize: number;
73
+ maxMinVisibleSize: number;
74
+ maxSymbolicSize: number;
75
+ maxDashLength: number;
76
+ maxGapLength: number;
77
+ maxPatternScale: number;
78
+ maxCoord: number;
79
+ }
80
+ /**
81
+ * Loads changed graph elements into the rendering engine's GPU buffers.
82
+ *
83
+ * For every changed node / edge it creates the corresponding Drawer, computes
84
+ * visual attributes, and writes them into buffer memory via the engine.
85
+ */
86
+ export declare function loadGraphInGraphicsEngine({ graph, elements, engine, imageManager, fontManager, view, attributes, boundaries, formatText, }: LoadGraphOptions): void;
87
+ /**
88
+ * Registers all shapes that are referenced by the current graph attributes
89
+ * with the graphics engine.
90
+ *
91
+ * Common shapes (circle, square, triangle, …) are always registered.
92
+ * Uncommon node shapes and edge extremity shapes are registered only if they
93
+ * appear in the current attribute values.
94
+ */
95
+ export declare function loadRequiredShapes(engine: GraphicsEngine, attributes: AttributesSnapshot): void;
96
+ /**
97
+ * Recomputes polygon shapes with rounded corners at the given `radius` and
98
+ * pushes the updated shapes to the engine.
99
+ *
100
+ * Affects: star, pentagon, hexagon, square, cross, diamond.
101
+ */
102
+ export declare function setRoundness(engine: GraphicsEngine, radius: number): void;
103
+ export {};
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Factory and reset helpers for the rendering data structures
3
+ * (ObjectInfo, AnimationInfo, ElementInfo).
4
+ */
5
+ import type { ObjectInfo, AnimationInfo, ElementInfo } from './types';
6
+ /**
7
+ * Create a fresh {@link ObjectInfo} with sensible defaults.
8
+ * Every numeric field starts at 0, colours at null, and booleans at false.
9
+ */
10
+ export declare function createGenericObjectInfo(): ObjectInfo;
11
+ /**
12
+ * Reset an existing {@link ObjectInfo} in-place, re-using the allocated
13
+ * `pattern` sub-object when possible to reduce GC pressure.
14
+ *
15
+ * @param info - The object info to reset (defaults to a new empty object).
16
+ * @returns The same reference, now zeroed out.
17
+ */
18
+ export declare function resetObjectInfo(info?: Partial<ObjectInfo>): ObjectInfo;
19
+ /**
20
+ * Reset an existing {@link AnimationInfo} in-place.
21
+ *
22
+ * @param info - The animation info to reset (defaults to a new empty object).
23
+ * @returns The same reference, now reset to "no animation".
24
+ */
25
+ export declare function resetAnimationInfo(info?: Partial<AnimationInfo>): AnimationInfo;
26
+ /**
27
+ * Create a complete {@link ElementInfo} with default start / end states
28
+ * and a zeroed-out animation.
29
+ */
30
+ export declare function createElementInfo(): ElementInfo;
31
+ /**
32
+ * Resize an HTML canvas element, accounting for a device-pixel ratio.
33
+ *
34
+ * @param canvas - The canvas element to resize.
35
+ * @param width - Desired CSS width in pixels.
36
+ * @param height - Desired CSS height in pixels.
37
+ * @param dpr - Device pixel ratio (e.g. `window.devicePixelRatio`).
38
+ */
39
+ export declare function resizeCanvas(canvas: HTMLCanvasElement, width: number, height: number, dpr: number): void;
40
+ /**
41
+ * Standard sigmoid function.
42
+ *
43
+ * @param x - Input value.
44
+ * @returns A value in (0, 1).
45
+ */
46
+ export declare function sigmoid(x: number): number;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Pure GPU instance-buffer packing primitives (the renderer's CPU-side data layer).
3
+ *
4
+ * Extracted from MemoryManager so they are a single, exported, testable source of truth and
5
+ * can be differentially gated against the Rust port (`nodus-core::render_pack`). Each is pure
6
+ * integer/bit arithmetic — no DOM, no store — so it is byte-exact across JS and WASM.
7
+ */
8
+ /** Extract the bit field `[low, high)` from `value`. `(value % 2^high) >> low`. */
9
+ export declare function extractBits(value: number, low: number, high: number): number;
10
+ /** `value - 128` (decode a u8 as a signed byte). */
11
+ export declare function unsignedToSignedByte(value: number): number;
12
+ /** `value - 32768` (decode a u16 as a signed int16). */
13
+ export declare function unsignedToSignedInt16(value: number): number;
14
+ /**
15
+ * Pack rgba (each in [0,1]) into a 16-bit value: 4 bits per channel,
16
+ * `r | g<<4 | b<<8 | a<<12`, each channel `round(15·c)`. Mirrors MemoryManager's
17
+ * `_colorToBytes` (minus the colour PARSE, which stays JS-side / DOM-coupled).
18
+ */
19
+ export declare function colorRgbaToBytes(r: number, g: number, b: number, a: number): number;
20
+ /**
21
+ * Decode a packed rgba16 into its four channel values: `[r255, g255, b255, alpha]` where the
22
+ * RGB are `(255·channel/15)|0` integers and alpha is the raw `channel/15` fraction. The CSS
23
+ * string assembly + zero→null stays in MemoryManager (JS number→string formatting is not a
24
+ * portable parity surface). Mirrors the numeric core of `bytesToColor`.
25
+ */
26
+ export declare function bytesToColorComponents(value: number): [number, number, number, number];
27
+ /** `round(min(value, max) · factor)` — the dash/gap/symbolic/min-visible/pattern-scale shape. */
28
+ export declare function quantizeRound(value: number, max: number, factor: number): number;
29
+ /** `ceil(min(value, max) · factor)` — the scaled-size shape. */
30
+ export declare function quantizeCeil(value: number, max: number, factor: number): number;
31
+ /** Quantize an angle to one of 8 buckets: `round(((θ + 2π) mod 2π) · 8/2π)`. */
32
+ export declare function offsetAngleToBytes(value: number): number;
33
+ /** `round(15 · min(value, 1))` (4-bit opacity). */
34
+ export declare function opacityToBytes(value: number): number;
35
+ /** `clamp(value, -128, 127) + 128` (signed byte → unsigned). */
36
+ export declare function signedToUnsignedByte(value: number): number;
37
+ /** `clamp(value, -32768, 32767) + 32768` (signed int16 → unsigned). */
38
+ export declare function signedToUnsignedInt16(value: number): number;
39
+ /** word0: shapeId(4) | pieceId(4) | dash(2) | gap(2) | head(1) | tail(1) | bodyTri/rotate(1) | selfLoop(1). */
40
+ export declare function packWord0(shapeId: number, pieceId: number, dash: number, gap: number, hasHead: number, hasTail: number, bodyTri: number, selfLoop: number): number;
41
+ /** word1: patternScale(8) | offsetAngle(3) | isText(1) | adjustAngle(1) | isBadge(1) | bentEnable(1) | bentVertical(1). */
42
+ export declare function packWord1(patternScale: number, offsetAngle: number, isText: number, adjustAngle: number, isBadge: number, bentEnable: number, bentVertical: number): number;
43
+ /** word2: opacity(4) | globalMinVisible(4) | strokeMinVisible(4) | patternMinVisible(4). */
44
+ export declare function packWord2(opacity: number, globalMin: number, strokeMin: number, patternMin: number): number;
45
+ /** word3: symbolicSize(8) | curvature(8). */
46
+ export declare function packWord3(symbolicSize: number, curvature: number): number;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Shape geometry helper functions used by the rendering layer.
3
+ *
4
+ * Provides polygon generation (regular/star polygons), point-in-polygon and
5
+ * signed-distance-field (SDF) queries, rounded-corner expansion, and open-arrow
6
+ * point construction.
7
+ */
8
+ export interface ShapePoint {
9
+ x: number;
10
+ y: number;
11
+ r?: number;
12
+ }
13
+ export interface ShapeDefinition {
14
+ getDistanceFromStrokeVertically: (x: number, y: number) => number;
15
+ getDistanceFromStrokeHorizontally: (x: number, y: number) => number;
16
+ points: ShapePoint[];
17
+ hole?: ShapePoint[];
18
+ isSimple: boolean;
19
+ }
20
+ export declare function isPointInPolygon(px: number, py: number, polygon: ShapePoint[]): boolean;
21
+ export declare function distanceToPolygon(px: number, py: number, polygon: ShapePoint[]): number;
22
+ export declare function computeCircularPolygon(sides: number, innerRadius?: number, startAngle?: number): ShapePoint[];
23
+ export declare function createPolygonShape(points: ShapePoint[], isSimple?: boolean): ShapeDefinition;
24
+ export declare function roundedCorners(points: ShapePoint[], radius: number, steps?: number): ShapePoint[];
25
+ export declare function segmentSDF(x1: number, y1: number, x2: number, y2: number, halfWidth: number, px: number, py: number): number;
26
+ export declare function getOpenArrowPoints(angle: number, length: number, strokeWidth: number, tipWidth: number): ShapePoint[];
@@ -0,0 +1,143 @@
1
+ /**
2
+ * TypeScript interfaces for the rendering data structures used by
3
+ * Buffer2, BufferList, ElementGroup, and MemoryManager.
4
+ */
5
+ /** Describes a pattern applied to a rendered element (image, text, icon…). */
6
+ export interface PatternInfo {
7
+ /** Internal pattern identifier */
8
+ id: string | number | undefined;
9
+ /** Discriminator for the kind of pattern (see PATTERN_* constants) */
10
+ type: number;
11
+ /** Arbitrary attributes bag consumed by the pattern renderer */
12
+ attributes: Record<string, unknown>;
13
+ }
14
+ /** Full visual description of a single rendered object (node body, edge, etc.). */
15
+ export interface ObjectInfo {
16
+ /** Identifier of the piece this object belongs to (see PIECE_* constants) */
17
+ pieceId: number;
18
+ /** Shape name (e.g. "circle", "square", "diamond"…) */
19
+ shape: string;
20
+ x1: number;
21
+ y1: number;
22
+ x2: number;
23
+ y2: number;
24
+ rectWidthOrSourceRadiusScaled: number;
25
+ rectWidthOrSourceRadiusFixed: number;
26
+ rectHeightOrTargetRadiusScaled: number;
27
+ rectHeightOrTargetRadiusFixed: number;
28
+ thicknessOrFontSizeScaled: number;
29
+ thicknessOrFontSizeFixed: number;
30
+ strokeWidthScaled: number;
31
+ strokeWidthFixed: number;
32
+ offsetScaled: number;
33
+ offsetFixed: number;
34
+ /** Pattern info (image, icon, text, pie-chart…) */
35
+ pattern: PatternInfo;
36
+ /** Overall opacity [0..1] */
37
+ opacity: number;
38
+ /** Fill colour as a CSS string, or null for transparent */
39
+ fillColor: string | null;
40
+ /** Stroke colour as a CSS string, or null */
41
+ strokeColor: string | null;
42
+ /** Pattern colour as a CSS string, or null */
43
+ patternColor: string | null;
44
+ /** Minimum pixel size below which the whole element is hidden */
45
+ globalMinVisibleSize: number;
46
+ /** Minimum pixel size below which the stroke is hidden */
47
+ strokeMinVisibleSize: number;
48
+ /** Minimum pixel size below which the pattern is hidden */
49
+ patternMinVisibleSize: number;
50
+ /** Rotation offset (radians) for badge / pattern placement */
51
+ offsetAngle: number;
52
+ /** Scale factor for the pattern texture */
53
+ patternScale: number;
54
+ /** When ≥ 0 the element keeps a constant screen-space size (symbolic) */
55
+ symbolicSize: number;
56
+ /** Curvature of an edge body (0 = straight) */
57
+ curvature: number;
58
+ /** Dash length in world units (0 = solid) */
59
+ dashLength: number;
60
+ /** Gap length in world units (0 = solid) */
61
+ gapLength: number;
62
+ hasHead: boolean;
63
+ hasTail: boolean;
64
+ isBodyTriangle: boolean;
65
+ isSelfLoop: boolean;
66
+ isText: boolean;
67
+ adjustTextAngle: boolean;
68
+ isBadge: boolean;
69
+ bentEnable: boolean;
70
+ bentVertical: boolean;
71
+ rotateWithEdge: boolean;
72
+ }
73
+ /** Animation timing metadata for a single element. */
74
+ export interface AnimationInfo {
75
+ /** Duration of the animation in milliseconds */
76
+ duration: number;
77
+ /** Start time of the animation (−1 means not started) */
78
+ beginTime: number;
79
+ /** Name of the easing function (key into EasingManager) */
80
+ easing: string;
81
+ }
82
+ /**
83
+ * Full information for one element in an {@link ElementGroup}:
84
+ * start state, end state, and the animation that interpolates between them.
85
+ */
86
+ export interface ElementInfo {
87
+ /** Whether this element has been populated with valid data */
88
+ valid: boolean;
89
+ /** External identifier (node id / edge id) */
90
+ id: string | number | undefined;
91
+ /** Visual state at the end of the animation (or current state if static) */
92
+ end: ObjectInfo;
93
+ /** Visual state at the start of the animation (only used when animated) */
94
+ start: ObjectInfo;
95
+ /** Animation timing that interpolates between `start` and `end` */
96
+ animation: AnimationInfo;
97
+ }
98
+ /**
99
+ * Describes a contiguous allocation within a {@link Buffer2}.
100
+ * Returned by {@link BufferList.allocateBlock} and {@link BufferList.getBlockInfo}.
101
+ */
102
+ export interface BlockInfo {
103
+ /** The buffer this block lives in (null before first use) */
104
+ buffer: import('./Buffer2').Buffer2 | null;
105
+ /** Offset (in elements) within the buffer */
106
+ offset: number;
107
+ /** Number of elements in this block */
108
+ size: number;
109
+ /** Encoded address that can be decoded back to buffer / offset / size */
110
+ address: number;
111
+ }
112
+ /** Constructor options for {@link Buffer2}. */
113
+ export interface BufferOptions {
114
+ /** Byte size of a single element (ELEMENT_BYTESIZE or ELEMENT_BYTESIZE_ANIMATED) */
115
+ elementSize: number;
116
+ /** Byte size of a single side-element */
117
+ sideElementSize: number;
118
+ /** Number of side-elements attached to each main element */
119
+ nbSideElementsPerMainElement: number;
120
+ /** Unique buffer id (index in BufferList._buffersById) */
121
+ id: number;
122
+ /** Depth / layer used for draw-order sorting */
123
+ depth: number;
124
+ /** Element type (ELT_GENERIC, ELT_TEXT, ELT_CURVE) */
125
+ elementType: number;
126
+ /** Whether the buffer holds animated elements */
127
+ animated: boolean;
128
+ /** Stencil mode (STENCIL_IGNORE, STENCIL_DEFINE_MASK, STENCIL_USE_MASK) */
129
+ stencilUsage: number;
130
+ }
131
+ /** Scale factors for converting byte-packed values back to world-space. */
132
+ export interface ExtractionScaleFactors {
133
+ bytesToActualCoord: number;
134
+ bytesToActualScaledSize: number;
135
+ bytesToActualMinVisibleSize: number;
136
+ bytesToActualPatternScale: number;
137
+ bytesToActualSymbolicSize: number;
138
+ bytesToActualDashLength: number;
139
+ bytesToActualGapLength: number;
140
+ }
141
+ export type PatternType = number;
142
+ export type PatternDefinition = PatternInfo;
143
+ export type GenericObjectInfo = ObjectInfo;