@neo4j-nvl/base 2.0.0 → 2.1.0-2b3838b9

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 (230) hide show
  1. package/README.md +12 -0
  2. package/dist/base.mjs +35969 -2
  3. package/dist/types/index.d.ts +417 -387
  4. package/dist/types/layouts/animatedlayout/AnimatedLayout.d.ts +23 -23
  5. package/dist/types/layouts/animatedlayout/animationUtils.d.ts +3 -3
  6. package/dist/types/layouts/circularLayout/CircularLayout.d.ts +14 -14
  7. package/dist/types/layouts/d3forcelayout/circularLayout.d.ts +4 -4
  8. package/dist/types/layouts/d3forcelayout/constants.d.ts +3 -3
  9. package/dist/types/layouts/d3forcelayout/d3ForceLayout.d.ts +31 -31
  10. package/dist/types/layouts/d3forcelayout/types.d.ts +7 -7
  11. package/dist/types/layouts/forcedirectedlayout/PhysLayout.d.ts +305 -261
  12. package/dist/types/layouts/forcedirectedlayout/clustering/ClusterByMerger.d.ts +52 -52
  13. package/dist/types/layouts/forcedirectedlayout/clustering/SolarMerger.d.ts +49 -49
  14. package/dist/types/layouts/forcedirectedlayout/clustering/clustering-utils.d.ts +35 -35
  15. package/dist/types/layouts/forcedirectedlayout/clustering/types.d.ts +39 -39
  16. package/dist/types/layouts/forcedirectedlayout/glwrapper.d.ts +3 -3
  17. package/dist/types/layouts/forcedirectedlayout/shaders/multilevel-fragment.d.ts +1 -1
  18. package/dist/types/layouts/forcedirectedlayout/shaders/multilevel-repulsive-fragment.d.ts +1 -1
  19. package/dist/types/layouts/forcedirectedlayout/shaders/multilevel-update-fragment.d.ts +1 -1
  20. package/dist/types/layouts/forcedirectedlayout/shaders/sim-vertex.d.ts +1 -1
  21. package/dist/types/layouts/freeLayout/FreeLayout.d.ts +23 -23
  22. package/dist/types/layouts/gridLayout/GridLayout.d.ts +26 -26
  23. package/dist/types/layouts/hierarchicallayout/HierarchicalLayout.d.ts +28 -28
  24. package/dist/types/layouts/hierarchicallayout/constants.d.ts +2 -2
  25. package/dist/types/modules/CallbackHelper.d.ts +23 -23
  26. package/dist/types/modules/ExternalCallbackHandler.d.ts +46 -33
  27. package/dist/types/modules/NvlController.d.ts +220 -209
  28. package/dist/types/modules/Shader.d.ts +17 -17
  29. package/dist/types/modules/ZoomTransitionHandler.d.ts +24 -24
  30. package/dist/types/modules/dataset.d.ts +26 -26
  31. package/dist/types/modules/logging.d.ts +4 -4
  32. package/dist/types/modules/state/constants.d.ts +2 -2
  33. package/dist/types/modules/state/state.d.ts +2 -2
  34. package/dist/types/modules/state/types.d.ts +316 -281
  35. package/dist/types/modules/state/utils.d.ts +36 -36
  36. package/dist/types/renderers/ClusterOverlay.d.ts +67 -67
  37. package/dist/types/renderers/domrenderer/BaseRenderer.d.ts +69 -69
  38. package/dist/types/renderers/domrenderer/canvasrenderer/Animation.d.ts +57 -57
  39. package/dist/types/renderers/domrenderer/canvasrenderer/AnimationHandler.d.ts +65 -65
  40. package/dist/types/renderers/domrenderer/canvasrenderer/CanvasRenderer.d.ts +89 -85
  41. package/dist/types/renderers/domrenderer/canvasrenderer/arrowDrawing.d.ts +31 -31
  42. package/dist/types/renderers/domrenderer/canvasrenderer/nodeDrawing.d.ts +32 -32
  43. package/dist/types/renderers/domrenderer/shared/ImageCache.d.ts +16 -16
  44. package/dist/types/renderers/domrenderer/shared/arrows/ArrowBundle.d.ts +89 -89
  45. package/dist/types/renderers/domrenderer/shared/arrows/ArrowBundler.d.ts +42 -42
  46. package/dist/types/renderers/domrenderer/shared/arrows/arrows.d.ts +84 -49
  47. package/dist/types/renderers/domrenderer/shared/arrows/constants.d.ts +4 -4
  48. package/dist/types/renderers/domrenderer/shared/nodes/nodes.d.ts +21 -21
  49. package/dist/types/renderers/domrenderer/shared/types.d.ts +29 -29
  50. package/dist/types/renderers/domrenderer/shared/util.d.ts +4 -4
  51. package/dist/types/renderers/domrenderer/shared/vectorUtils.d.ts +10 -10
  52. package/dist/types/renderers/domrenderer/shared/wordwrap.d.ts +10 -10
  53. package/dist/types/renderers/domrenderer/svgrenderer/SvgRenderer.d.ts +18 -19
  54. package/dist/types/renderers/domrenderer/svgrenderer/arrowDrawing.d.ts +15 -15
  55. package/dist/types/renderers/domrenderer/svgrenderer/nodeDrawing.d.ts +4 -4
  56. package/dist/types/renderers/domrenderer/svgrenderer/svgUtils.d.ts +21 -21
  57. package/dist/types/renderers/webglrenderer/Controller.d.ts +83 -82
  58. package/dist/types/renderers/webglrenderer/IconLayerRegistry.d.ts +8 -8
  59. package/dist/types/renderers/webglrenderer/Renderer.d.ts +89 -89
  60. package/dist/types/renderers/webglrenderer/node-animation-fragment.d.ts +1 -1
  61. package/dist/types/renderers/webglrenderer/node-animation-vertex.d.ts +1 -1
  62. package/dist/types/renderers/webglrenderer/node-fragment-point.d.ts +1 -1
  63. package/dist/types/renderers/webglrenderer/node-vertex-point.d.ts +1 -1
  64. package/dist/types/renderers/webglrenderer/rel-fragment-line.d.ts +1 -1
  65. package/dist/types/renderers/webglrenderer/rel-glsl-utils.d.ts +1 -1
  66. package/dist/types/renderers/webglrenderer/rel-vertex-arrow.d.ts +1 -1
  67. package/dist/types/renderers/webglrenderer/rel-vertex-line.d.ts +1 -1
  68. package/dist/types/renderers/webglrenderer/viewport-box-fragment.d.ts +1 -1
  69. package/dist/types/renderers/webglrenderer/viewport-box-vertex.d.ts +1 -1
  70. package/dist/types/types/graph-element.d.ts +133 -104
  71. package/dist/types/types/nvl-window-functions.d.ts +28 -13
  72. package/dist/types/types/utils.d.ts +1 -1
  73. package/dist/types/utils/ariaUtils.d.ts +2 -2
  74. package/dist/types/utils/canvasManagement.d.ts +7 -1
  75. package/dist/types/utils/circularUtils.d.ts +2 -2
  76. package/dist/types/utils/clusterGeometry.d.ts +3 -3
  77. package/dist/types/utils/clusterHitRegions.d.ts +12 -12
  78. package/dist/types/utils/colorUtils.d.ts +2 -2
  79. package/dist/types/utils/constants.d.ts +6 -6
  80. package/dist/types/utils/errors.d.ts +6 -6
  81. package/dist/types/utils/geometry.d.ts +48 -48
  82. package/dist/types/utils/graphObjectUtils.d.ts +9 -9
  83. package/dist/types/utils/hitTest.d.ts +87 -0
  84. package/dist/types/utils/jsDriverResultTransformer.d.ts +27 -17
  85. package/dist/types/utils/layoutSeeding.d.ts +2 -2
  86. package/dist/types/utils/mouseUtils.d.ts +5 -5
  87. package/dist/types/utils/segmentAnalytics.d.ts +42 -42
  88. package/dist/types/utils/webWorkerUtils.d.ts +1 -1
  89. package/dist/types/utils/zoomFunctions.d.ts +17 -17
  90. package/package.json +20 -22
  91. package/skills/neo4j-nvl-skill/README.md +39 -0
  92. package/skills/neo4j-nvl-skill/SKILL.md +300 -0
  93. package/skills/neo4j-nvl-skill/references/api/base/classes/NVL.md +1020 -0
  94. package/skills/neo4j-nvl-skill/references/api/base/functions/getZoomTargetForNodePositions.md +37 -0
  95. package/skills/neo4j-nvl-skill/references/api/base/index.md +72 -0
  96. package/skills/neo4j-nvl-skill/references/api/base/interfaces/CircularOptions.md +11 -0
  97. package/skills/neo4j-nvl-skill/references/api/base/interfaces/ClusteringOptions.md +31 -0
  98. package/skills/neo4j-nvl-skill/references/api/base/interfaces/ExternalCallbacks.md +18 -0
  99. package/skills/neo4j-nvl-skill/references/api/base/interfaces/ForceDirectedOptions.md +12 -0
  100. package/skills/neo4j-nvl-skill/references/api/base/interfaces/HierarchicalOptions.md +13 -0
  101. package/skills/neo4j-nvl-skill/references/api/base/interfaces/HitTargetCluster.md +13 -0
  102. package/skills/neo4j-nvl-skill/references/api/base/interfaces/HitTargetNode.md +16 -0
  103. package/skills/neo4j-nvl-skill/references/api/base/interfaces/HitTargetRelationship.md +15 -0
  104. package/skills/neo4j-nvl-skill/references/api/base/interfaces/Node.md +32 -0
  105. package/skills/neo4j-nvl-skill/references/api/base/interfaces/NvlMouseEvent.md +16 -0
  106. package/skills/neo4j-nvl-skill/references/api/base/interfaces/NvlOptions.md +38 -0
  107. package/skills/neo4j-nvl-skill/references/api/base/interfaces/NvlWindow.md +18 -0
  108. package/skills/neo4j-nvl-skill/references/api/base/interfaces/Point.md +12 -0
  109. package/skills/neo4j-nvl-skill/references/api/base/interfaces/Relationship.md +36 -0
  110. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/CanvasRendererType.md +14 -0
  111. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/Cluster.md +20 -0
  112. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/ClusterByFn.md +20 -0
  113. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/ClusterId.md +10 -0
  114. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/HitTargets.md +22 -0
  115. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/HitTestTarget.md +9 -0
  116. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/Layout.md +15 -0
  117. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/LayoutOptions.md +12 -0
  118. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/NodeWithClientPosition.md +24 -0
  119. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/PartialNode.md +17 -0
  120. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/PartialRelationship.md +17 -0
  121. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/Renderer.md +11 -0
  122. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/StyledCaption.md +21 -0
  123. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/WebGLRendererType.md +14 -0
  124. package/skills/neo4j-nvl-skill/references/api/base/type-aliases/ZoomOptions.md +25 -0
  125. package/skills/neo4j-nvl-skill/references/api/base/variables/CircularLayoutType.md +11 -0
  126. package/skills/neo4j-nvl-skill/references/api/base/variables/ForceDirectedLayoutType.md +9 -0
  127. package/skills/neo4j-nvl-skill/references/api/base/variables/FreeLayoutType.md +9 -0
  128. package/skills/neo4j-nvl-skill/references/api/base/variables/GridLayoutType.md +9 -0
  129. package/skills/neo4j-nvl-skill/references/api/base/variables/HierarchicalLayoutType.md +9 -0
  130. package/skills/neo4j-nvl-skill/references/api/base/variables/d3ForceLayoutType.md +9 -0
  131. package/skills/neo4j-nvl-skill/references/api/base/variables/nvlResultTransformer.md +49 -0
  132. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/classes/BoxSelectInteraction.md +163 -0
  133. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/classes/ClickInteraction.md +163 -0
  134. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/classes/DragNodeInteraction.md +164 -0
  135. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/classes/HoverInteraction.md +166 -0
  136. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/classes/KeyboardInteraction.md +185 -0
  137. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/classes/LassoInteraction.md +163 -0
  138. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/classes/PanInteraction.md +197 -0
  139. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/classes/ZoomInteraction.md +169 -0
  140. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/index.md +37 -0
  141. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/BoxSelectInteractionCallbacks.md +19 -0
  142. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/BoxSelectInteractionOptions.md +17 -0
  143. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/ClickInteractionCallbacks.md +39 -0
  144. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/ClickInteractionOptions.md +17 -0
  145. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/DragNodeInteractionCallbacks.md +21 -0
  146. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/DrawInteractionOptions.md +22 -0
  147. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/HoverInteractionCallbacks.md +17 -0
  148. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/HoverInteractionOptions.md +17 -0
  149. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/KeyboardInteractionCallbacks.md +35 -0
  150. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/KeyboardInteractionOptions.md +55 -0
  151. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/LassoInteractionCallbacks.md +19 -0
  152. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/LassoInteractionOptions.md +17 -0
  153. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/PanInteractionCallbacks.md +17 -0
  154. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/PanInteractionOptions.md +19 -0
  155. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/ZoomInteractionCallbacks.md +17 -0
  156. package/skills/neo4j-nvl-skill/references/api/interaction-handlers/type-aliases/ZoomInteractionOptions.md +17 -0
  157. package/skills/neo4j-nvl-skill/references/api/react/functions/StaticPictureWrapper.md +42 -0
  158. package/skills/neo4j-nvl-skill/references/api/react/index.md +34 -0
  159. package/skills/neo4j-nvl-skill/references/api/react/interfaces/BasicReactWrapperProps.md +24 -0
  160. package/skills/neo4j-nvl-skill/references/api/react/interfaces/InteractiveNvlWrapperProps.md +27 -0
  161. package/skills/neo4j-nvl-skill/references/api/react/type-aliases/InteractionOptions.md +10 -0
  162. package/skills/neo4j-nvl-skill/references/api/react/type-aliases/KeyboardEvent.md +10 -0
  163. package/skills/neo4j-nvl-skill/references/api/react/type-aliases/KeyboardEventCallbacks.md +10 -0
  164. package/skills/neo4j-nvl-skill/references/api/react/type-aliases/MouseEvent.md +10 -0
  165. package/skills/neo4j-nvl-skill/references/api/react/type-aliases/MouseEventCallbacks.md +19 -0
  166. package/skills/neo4j-nvl-skill/references/api/react/type-aliases/StaticPictureWrapperProps.md +27 -0
  167. package/skills/neo4j-nvl-skill/references/api/react/variables/BasicNvlWrapper.md +65 -0
  168. package/skills/neo4j-nvl-skill/references/api/react/variables/InteractiveNvlWrapper.md +18 -0
  169. package/skills/neo4j-nvl-skill/references/clustering.md +87 -0
  170. package/skills/neo4j-nvl-skill/references/data-from-neo4j.md +67 -0
  171. package/skills/neo4j-nvl-skill/references/labels-and-overlays.md +89 -0
  172. package/skills/neo4j-nvl-skill/references/layouts-and-positions.md +65 -0
  173. package/skills/neo4j-nvl-skill/references/lifecycle-and-updates.md +65 -0
  174. package/skills/neo4j-nvl-skill/references/migrating-1x-to-2.md +50 -0
  175. package/skills/neo4j-nvl-skill/references/react-wrappers.md +92 -0
  176. package/skills/neo4j-nvl-skill/references/verifying-nvl-apps.md +52 -0
  177. package/skills/neo4j-nvl-skill/references/vite-and-bundlers.md +62 -0
  178. package/CHANGELOG.md +0 -313
  179. package/dist/base.mjs.LICENSE.txt +0 -21
  180. package/dist/types/layouts/animatedlayout/AnimatedLayout.test.d.ts +0 -1
  181. package/dist/types/layouts/animatedlayout/animationUtils.test.d.ts +0 -1
  182. package/dist/types/layouts/d3forcelayout/__mocks__/d3ForceLayout.d.ts +0 -10
  183. package/dist/types/layouts/d3forcelayout/circularLayout.test.d.ts +0 -1
  184. package/dist/types/layouts/d3forcelayout/d3ForceLayout.test.d.ts +0 -1
  185. package/dist/types/layouts/forcedirectedlayout/PhysLayout.test.d.ts +0 -1
  186. package/dist/types/layouts/forcedirectedlayout/clustering/ClusterByMerger.test.d.ts +0 -1
  187. package/dist/types/layouts/forcedirectedlayout/clustering/SolarMerger.bench.d.ts +0 -1
  188. package/dist/types/layouts/forcedirectedlayout/clustering/SolarMerger.test.d.ts +0 -1
  189. package/dist/types/layouts/forcedirectedlayout/clustering/clustering-utils.test.d.ts +0 -1
  190. package/dist/types/modules/NvlController.test.d.ts +0 -1
  191. package/dist/types/modules/ZoomTransitionHandler.test.d.ts +0 -1
  192. package/dist/types/modules/dataset.test.d.ts +0 -1
  193. package/dist/types/modules/state/state.test.d.ts +0 -1
  194. package/dist/types/modules/state/utils.test.d.ts +0 -1
  195. package/dist/types/renderers/ClusterOverlay.test.d.ts +0 -1
  196. package/dist/types/renderers/domrenderer/BaseRenderer.test.d.ts +0 -1
  197. package/dist/types/renderers/domrenderer/canvasrenderer/Animation.test.d.ts +0 -1
  198. package/dist/types/renderers/domrenderer/canvasrenderer/CanvasRenderer.test.d.ts +0 -1
  199. package/dist/types/renderers/domrenderer/canvasrenderer/arrowDrawing.test.d.ts +0 -1
  200. package/dist/types/renderers/domrenderer/canvasrenderer/nodeDrawing.test.d.ts +0 -1
  201. package/dist/types/renderers/domrenderer/shared/ImageCache.test.d.ts +0 -1
  202. package/dist/types/renderers/domrenderer/shared/arrows/ArrowBundle.test.d.ts +0 -1
  203. package/dist/types/renderers/domrenderer/shared/arrows/ArrowBundler.test.d.ts +0 -1
  204. package/dist/types/renderers/domrenderer/shared/arrows/arrows.test.d.ts +0 -1
  205. package/dist/types/renderers/domrenderer/shared/nodes/nodes.test.d.ts +0 -1
  206. package/dist/types/renderers/domrenderer/shared/util.test.d.ts +0 -1
  207. package/dist/types/renderers/domrenderer/shared/wordwrap.test.d.ts +0 -1
  208. package/dist/types/renderers/domrenderer/svgrenderer/SvgRenderer.test.d.ts +0 -1
  209. package/dist/types/renderers/domrenderer/svgrenderer/arrowDrawing.test.d.ts +0 -1
  210. package/dist/types/renderers/domrenderer/svgrenderer/nodeDrawing.test.d.ts +0 -1
  211. package/dist/types/renderers/domrenderer/svgrenderer/svgUtils.test.d.ts +0 -1
  212. package/dist/types/renderers/webglrenderer/Controller.test.d.ts +0 -1
  213. package/dist/types/renderers/webglrenderer/IconLayerRegistry.test.d.ts +0 -1
  214. package/dist/types/renderers/webglrenderer/Renderer.test.d.ts +0 -1
  215. package/dist/types/utils/ariaUtils.test.d.ts +0 -1
  216. package/dist/types/utils/canvasManagement.test.d.ts +0 -1
  217. package/dist/types/utils/circularUtils.test.d.ts +0 -1
  218. package/dist/types/utils/clusterGeometry.test.d.ts +0 -1
  219. package/dist/types/utils/clusterHitRegions.test.d.ts +0 -1
  220. package/dist/types/utils/colorUtils.test.d.ts +0 -1
  221. package/dist/types/utils/errors.test.d.ts +0 -1
  222. package/dist/types/utils/geometry.test.d.ts +0 -1
  223. package/dist/types/utils/graphObjectUtils.test.d.ts +0 -1
  224. package/dist/types/utils/hittest.d.ts +0 -84
  225. package/dist/types/utils/hittest.test.d.ts +0 -1
  226. package/dist/types/utils/jsDriverResultTransformer.test.d.ts +0 -1
  227. package/dist/types/utils/layoutSeeding.test.d.ts +0 -1
  228. package/dist/types/utils/mouseUtils.test.d.ts +0 -1
  229. package/dist/types/utils/webWorkerUtils.test.d.ts +0 -1
  230. package/dist/types/utils/zoomFunctions.test.d.ts +0 -1
@@ -1,21 +1,21 @@
1
- import type { ExternalCallbacks } from './modules/ExternalCallbackHandler';
2
- import type { CircularOptions, Cluster, ClusterByFn, ClusterId, ClusteringOptions, ForceDirectedOptions, HierarchicalOptions, Renderer as InternalRenderer, Layout, LayoutOptions, NvlOptions, NvlState, ZoomOptions } from './modules/state/types';
3
- import { CanvasRendererType, CircularLayoutType, ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, SvgRendererType, WebGLRendererType, d3ForceLayoutType } from './modules/state/types';
4
- import { drawCircleBand } from './renderers/domrenderer/canvasrenderer/nodeDrawing';
5
- import type { StyledCaption } from './renderers/domrenderer/shared/types';
6
- import type { Node, NodeWithClientPosition, PartialNode, PartialRelationship, Relationship } from './types/graph-element';
7
- import { CompatibilityError } from './utils/errors';
8
- import type { Point } from './utils/geometry';
9
- import type { HitTargetCluster, HitTargetNode, HitTargetRelationship, HitTargets, HitTestTarget } from './utils/hittest';
10
- import { nvlResultTransformer } from './utils/jsDriverResultTransformer';
11
- import { getZoomTargetForNodePositions } from './utils/zoomFunctions';
1
+ import { ExternalCallbacks } from "./modules/ExternalCallbackHandler.js";
2
+ import { CanvasRendererType, CircularLayoutType, CircularOptions, Cluster, ClusterByFn, ClusterId, ClusteringOptions, ForceDirectedLayoutType, ForceDirectedOptions, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, HierarchicalOptions, Layout, LayoutOptions, NvlOptions, NvlState, WebGLRendererType, ZoomOptions, d3ForceLayoutType } from "./modules/state/types.js";
3
+ import { drawCircleBand } from "./renderers/domrenderer/canvasrenderer/nodeDrawing.js";
4
+ import { StyledCaption } from "./renderers/domrenderer/shared/types.js";
5
+ import { Node, NodeWithClientPosition, PartialNode, PartialRelationship, Relationship } from "./types/graph-element.js";
6
+ import { NvlWindow } from "./types/nvl-window-functions.js";
7
+ import { CompatibilityError } from "./utils/errors.js";
8
+ import { Point } from "./utils/geometry.js";
9
+ import { HitTargetCluster, HitTargetNode, HitTargetRelationship, HitTargets, HitTestTarget } from "./utils/hitTest.js";
10
+ import { nvlResultTransformer } from "./utils/jsDriverResultTransformer.js";
11
+ import { getZoomTargetForNodePositions } from "./utils/zoomFunctions.js";
12
12
  /**
13
13
  * Extends the MouseEvent interface with the {@link HitTargets} property.
14
14
  * The result of a {@link NVL.getHits} call.
15
15
  */
16
16
  interface NvlMouseEvent extends MouseEvent {
17
- /** The graph elements that have been hit by the pointer event. */
18
- nvlTargets: HitTargets;
17
+ /** The graph elements that have been hit by the pointer event. */
18
+ nvlTargets: HitTargets;
19
19
  }
20
20
  /**
21
21
  * Class for a NVL instance.
@@ -37,375 +37,407 @@ interface NvlMouseEvent extends MouseEvent {
37
37
  * ```
38
38
  */
39
39
  declare class NVL {
40
- #private;
41
- /**
42
- * Creates a new NVL instance.
43
- * @param frame - The DOM element to display the graph in.
44
- * @param nvlNodes - An array of {@link Node nodes}.
45
- * @param nvlRels - An array of {@link Relationship relationships}.
46
- * @param options - The {@link NvlOptions options} for the NVL instance.
47
- * @param callbacks - Callbacks triggered on NVL events.
48
- */
49
- constructor(frame: HTMLElement, nvlNodes?: Node[], nvlRels?: Relationship[], options?: NvlOptions, callbacks?: ExternalCallbacks);
50
- /**
51
- * Restarts the NVL instance.
52
- * @param options - New {@link NvlOptions} for the NVL instance.
53
- * @param retainPositions - Whether or not to retain the current node positions.
54
- * New options will be merged with current options
55
- */
56
- restart(options?: NvlOptions, retainPositions?: boolean): void;
57
- /**
58
- * Adds nodes and relationships to NVL and updates existing nodes and relationships.
59
- * @param nodes - An Array of {@link Node nodes} to be added or updated.
60
- * @param relationships - An Array of {@link Relationship relationships} to be added or updated.
61
- * To update nodes or relationships, they must have an id that matches the id of the
62
- * node or relationship to be updated.
63
- * Only the properties that are provided will be updated.
64
- * If an existing property is not provided, it will not be changed.
65
- * @example
66
- * Adding and updating nodes and relationships
67
- * ```ts
68
- * import { NVL } from '@neo4j-nvl/base'
69
- *
70
- * const nvl = new NVL(document.getElementById('frame'), [{ id: '0' }], [])
71
- *
72
- * const nodes = [
73
- * { id: '1', label: 'Node 1', color: '#e04141' },
74
- * { id: '2', label: 'Node 2', color: '#e09c41' }
75
- * ]
76
- * const relationships = [
77
- * { id: '12', from: '1', to: '2' }
78
- * ]
79
- * // Adds new nodes and relationships
80
- * nvl.addAndUpdateElementsInGraph(nodes, relationships)
81
- * // Updates an existing relationship
82
- * nvl.addAndUpdateElementsInGraph([], [{ id: '12', color: '#e0df41' }])
83
- * ```
84
- */
85
- addAndUpdateElementsInGraph(nodes?: Node[] | PartialNode[], relationships?: Relationship[] | PartialRelationship[]): void;
86
- /**
87
- * Gets the currently selected nodes.
88
- * @returns An array of all currently selected {@link Node nodes} and their positions.
89
- */
90
- getSelectedNodes(): (Node & Point)[];
91
- /**
92
- * Gets the currently selected relationships.
93
- * @returns An array of all currently selected {@link Relationship relationships}.
94
- */
95
- getSelectedRelationships(): Relationship[];
96
- /**
97
- * Updates relationships in the current scene with the provided array of nodes and relationships.
98
- * @param nodes - The updated {@link Node nodes}.
99
- * @param relationships - The updated {@link Relationship relationships}.
100
- * Ignores any nodes or relationships that do not exist in the current scene.
101
- * To update nodes or relationships, they must have an id that matches the id of the
102
- * node or relationship to be updated.
103
- * Only the properties that are provided will be updated.
104
- * If an existing property is not provided, it will not be changed.
105
- * @example
106
- * Updating nodes and relationships
107
- * ```ts
108
- * import { NVL } from '@neo4j-nvl/base'
109
- *
110
- * const nodes = [
111
- * { id: '1', label: 'Node 1', color: '#e04141' },
112
- * { id: '2', label: 'Node 2', color: '#e09c41' }
113
- * ]
114
- * const relationships = [
115
- * { id: '12', from: '1', to: '2' }
116
- * ]
117
- * const nvl = new NVL(document.getElementById('frame'), nodes, relationships)
118
- * // Updates an existing node and relationship
119
- * nvl.updateElementsInGraph([{ id: '1', selected: true }], [{ id: '12', color: '#e0df41' }])
120
- * ```
121
- */
122
- updateElementsInGraph(nodes: Node[] | PartialNode[], relationships: Relationship[] | PartialRelationship[]): void;
123
- /**
124
- * Adds nodes and relationships in the current scene.
125
- * @param nodes - The nodes to be added.
126
- * @param relationships - The relationships to be added.
127
- */
128
- addElementsToGraph(nodes: Node[], relationships: Relationship[]): void;
129
- /**
130
- * Removes the specified nodes from the current scene.
131
- * @param nodeIds - The node ids to be removed.
132
- * Adjacent relationships will also be removed.
133
- */
134
- removeNodesWithIds(nodeIds: string[]): void;
135
- /**
136
- * Removes the specified relationships from the current scene.
137
- * @param relationshipIds - The relationship ids to be removed.
138
- */
139
- removeRelationshipsWithIds(relationshipIds: string[]): void;
140
- /**
141
- * Returns all nodes that is currently stored in the visualisation.
142
- * Each node includes layout coordinates (`x`, `y`) and a `clientPosition` in screen space.
143
- * @returns The array of {@link NodeWithClientPosition nodes}.
144
- */
145
- getNodes(): NodeWithClientPosition[];
146
- /**
147
- * Returns the relationships that are currently in the visualization.
148
- * @returns An array of the {@link Relationship relationships} in the visualization.
149
- */
150
- getRelationships(): Relationship[];
151
- /**
152
- * Returns the node data that is currently stored in the visualisation for a given id.
153
- * @param id - The id of the {@link Node node} that should be returned.
154
- * @returns The {@link Node node} or undefined if there is no node with the given id.
155
- */
156
- getNodeById(id: string): Node;
157
- /**
158
- * Returns the relationship data that is currently stored in the visualisation for a given id.
159
- * @param id - The id of the {@link Relationship relationship} that should be returned.
160
- * @returns The {@link Relationship relationship} or undefined if there is no relationship with the given id.
161
- */
162
- getRelationshipById(id: string): Relationship;
163
- /**
164
- * Returns the node position that is currently stored in the visualisation for a given id.
165
- * @param id - The id of the node position that should be returned.
166
- * @returns The position information for the given id, or undefined if there is no such {@link Node node}.
167
- * or the layout has not yet run with that node.
168
- */
169
- getPositionById(id: string): Node;
170
- /**
171
- * Returns the current options.
172
- * @returns The current options.
173
- */
174
- getCurrentOptions(): NvlOptions;
175
- /** Removes the graph visualization from the DOM and cleans up everything. */
176
- destroy(): void;
177
- /**
178
- * De-selects all nodes and relationships.
179
- */
180
- deselectAll(): void;
181
- /**
182
- * Updates pan and zoom to fit the specified nodes in the viewport.
183
- * @param nodeIds - The ids of the nodes to fit on the screen.
184
- * @param zoomOptions - Specific options on how to transition the zoom.
185
- *
186
- * @remarks
187
- * If the zoom level required to fit the provided nodes is outside of the range provided by the
188
- * {@link NvlOptions.minZoom minZoom} and {@link NvlOptions.maxZoom maxZoom} options, and the
189
- * {@link NvlOptions.allowDynamicMinZoom allowDynamicMinZoom} option is set to `false`,
190
- * the zoom level will be set to the closest valid zoom level,
191
- * even if the given nodes do not fit the viewport yet.
192
- */
193
- fit(nodeIds: string[], zoomOptions?: NvlState['zoomOptions']): void;
194
- /**
195
- * Resets the zoom of the viewport back to the default zoom level of 0.75.
196
- */
197
- resetZoom(): void;
198
- /**
199
- * Switches between rendering methods
200
- * @param renderer - which rendering method to use
201
- */
202
- setRenderer(renderer: string): void;
203
- /**
204
- * Restarts NVL with or without WebGL support.
205
- * @param disabled - Whether or not WebGL should be disabled.
206
- * @experimental
207
- */
208
- setDisableWebGL(disabled?: boolean): void;
209
- /**
210
- * Pins the specified node so it is not affected by layout forces.
211
- * @param nodeId - The id of the node to be pinned.
212
- */
213
- pinNode(nodeId: string): void;
214
- /**
215
- * Un-pins the specified nodes so it is affected by layout forces again.
216
- * @param nodeIds The ids of the nodes to be un-pinned.
217
- */
218
- unPinNode(nodeIds: string[]): void;
219
- /**
220
- * Changes the layout type.
221
- * @param layout - The {@link Layout} type.
222
- */
223
- setLayout(layout: Layout): void;
224
- /**
225
- * Updates the configuration of the current layout.
226
- * @param options - The {@link LayoutOptions} configuration.
227
- */
228
- setLayoutOptions(options: LayoutOptions): void;
229
- /**
230
- * Returns the nodes that are currently in the visualization.
231
- * The `rels` property of the returned object is always empty.
232
- * @returns An object containing the nodes and relationships in the visualization.
233
- */
234
- getNodesOnScreen(): {
235
- /** The nodes in the visualization. */
236
- nodes: Node[];
237
- /** The relationships in the visualization. */
238
- rels: Relationship[];
239
- };
240
- /**
241
- * Fetches and returns the current positions of all nodes as an array of coordinates.
242
- * @returns An array of {@link Node node} positions.
243
- */
244
- getNodePositions(): (Node & Point)[];
245
- /**
246
- * Sets the node positions based on data provided.
247
- * @param data - The positions that the nodes should be set to.
248
- * @param updateLayout - Whether or not the current layout algorithm
249
- * should update the graph after setting the node positions.
250
- *
251
- * @remarks
252
- * For node positions to be unaffected by layout algorithms, use the 'free' layout type
253
- * or use {@link pinNode} to pin the nodes that should remain still.
254
- * False by default.
255
- */
256
- setNodePositions(data: Node[], updateLayout?: boolean): void;
257
- /**
258
- * Checks and returns whether the current layout is still in flux.
259
- * @returns Whether or not the layout is moving.
260
- */
261
- isLayoutMoving(): boolean;
262
- /**
263
- * Saves the current view of the graph visualization canvas as a png to the client.
264
- * @param {{ filename: string, backgroundColor: string }} options The filename and background color of the png.
265
- * @param options.filename - The filename of the png file.
266
- * @param options.backgroundColor - The background color of the png file.
267
- * The size of the png file will be the size of the canvas in the DOM.
268
- */
269
- saveToFile(options?: {
270
- filename?: string;
271
- backgroundColor?: string;
272
- }): void;
273
- /**
274
- * Saves the entire graph visualization as an SVG file to the client.
275
- * @param options - Options for the SVG export
276
- * @param options.filename - The filename of the SVG file.
277
- * @param options.backgroundColor - The background color of the SVG file.
278
- * @experimental
279
- */
280
- saveToSvg(options?: {
281
- filename?: string;
282
- backgroundColor?: string;
283
- }): void;
284
- /**
285
- * Returns the current view of the graph visualization canvas as a data URL.
286
- * @param options - The options for the image.
287
- * @param options.backgroundColor - The background color of the data URL.
288
- * @returns A data URL of the current view of the graph visualization canvas.
289
- */
290
- getImageDataUrl(options?: {
291
- backgroundColor?: string;
292
- }): string;
293
- /**
294
- * Returns the entire graph visualization as an SVG data URL.
295
- * @param options - Options for the SVG export
296
- * @param options.backgroundColor - The background color of the SVG (defaults to transparent).
297
- * @returns A Promise resolving to a data URL string representing the graph as SVG (data:image/svg+xml;...)
298
- * @experimental
299
- *
300
- * @example
301
- * ```typescript
302
- * import { NVL } from '@neo4j-nvl/base'
303
- *
304
- * const nvl = new NVL(document.getElementById('frame'), [{ id: '0' }], [])
305
- * const renderSvg = async () => {
306
- * const svgDataUrl = await nvl.getSvgDataUrl({ backgroundColor: '#ffffff' })
307
- * const img = document.createElement('img')
308
- * img.src = svgDataUrl
309
- * document.body.appendChild(img)
310
- * }
311
- * ```
312
- */
313
- getSvgDataUrl(options?: {
314
- backgroundColor?: string;
315
- }): Promise<string>;
316
- /**
317
- * Saves the entire graph visualization canvas as a png to the client.
318
- * @param {{ filename: string, backgroundColor: string }} options The filename and background color of the png.
319
- * @param options.filename - The filename of the png file.
320
- * @param options.backgroundColor - The background color of the png file.
321
- * The size of the png file will be as large as the entire graph at the default zoom level.
322
- * Can result in a very large file.
323
- */
324
- saveFullGraphToLargeFile(options?: {
325
- filename?: string;
326
- backgroundColor?: string;
327
- }): void;
328
- getZoomLimits(): {
329
- minZoom: number;
330
- maxZoom: number;
331
- };
332
- /**
333
- * Sets the zoom of the viewport to a specific value.
334
- * @param zoomValue - The desired zoom level.
335
- * @remarks
336
- *
337
- * When updating both the zoom level and pan coordinates,
338
- * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan}
339
- * separately to avoid jittering.
340
- *
341
- * If the zoom level is outside of the range provided by the
342
- * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
343
- * the zoom level will be set to the closest valid zoom level.
344
- * If {@link NvlOptions.allowDynamicMinZoom} is set to true,
345
- * the {@link NvlOptions.minZoom} option will be ignored of the current graph does not fit the viewport.
346
- */
347
- setZoom(zoomValue: number): void;
348
- /**
349
- * Sets the zoom of the viewport to a specific value.
350
- * @param panX - The desired panX value.
351
- * @param panY - The desired panY value.
352
- * @remarks When updating both the zoom level and pan coordinates,
353
- * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan} separately to avoid jittering.
354
- */
355
- setPan(panX: number, panY: number): void;
356
- /**
357
- * Sets the zoom and pan of the viewport to specific values.
358
- * @param zoom - The desired zoom level.
359
- * @param panX - The desired panX value.
360
- * @param panY - The desired panY value.
361
- * @remarks When only updating zoom level or pan coordinates, use {@link setZoom} or {@link setPan} instead.
362
- *
363
- * If the zoom level is outside of the range provided by the
364
- * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
365
- * the zoom level will be set to the closest valid zoom level.
366
- * If {@link NvlOptions.allowDynamicMinZoom} is set to true,
367
- * the {@link NvlOptions.minZoom} option will be ignored of the current graph does not fit the viewport.
368
- */
369
- setZoomAndPan(zoom: number, panX: number, panY: number): void;
370
- /**
371
- * Get the current zoom level of the viewport.
372
- * @returns The current zoom level.
373
- */
374
- getScale(): number;
375
- /**
376
- * Returns the current pan of the viewport.
377
- * @returns The current pan of the viewport.
378
- */
379
- getPan(): Point;
380
- /**
381
- * Gets the nodes, relationships, and clusters that have been hit by a pointer event.
382
- * @param evt - The mouse event.
383
- * @param targets - The graph elements to check for hits. Defaults to ['node', 'relationship', 'cluster'].
384
- * @param hitOptions - Options for the hit test.
385
- * @returns A {@link NvlMouseEvent} with the {@link HitTargets} property
386
- * containing the nodes, relationships, and clusters that have been hit by the pointer event.
387
- *
388
- * @example
389
- * ```js
390
- * const container = document.getElementById('frame')
391
- * const nvl = new NVL(container, [{ id: '0' }], [])
392
- *
393
- * // Get the nodes and relationships that have been hit by a pointer event.
394
- * container?.addEventListener('click', (evt) => {
395
- * const { nvlTargets } = nvl.getHits(evt)
396
- * console.log('clicked elements:', nvlTargets)
397
- * })
398
- * ```
399
- */
400
- getHits(evt: MouseEvent, targets?: HitTestTarget[], hitOptions?: {
401
- hitNodeMarginWidth: number;
402
- }): NvlMouseEvent;
403
- /**
404
- * Provides the container DOM element the graph is rendered in.
405
- * @returns The container element of the NVL instance.
406
- */
407
- getContainer(): HTMLElement;
408
- private checkWebGLCompatibility;
40
+ #private;
41
+ /**
42
+ * Creates a new NVL instance.
43
+ * @param frame - The DOM element to display the graph in.
44
+ * @param nvlNodes - An array of {@link Node nodes}.
45
+ * @param nvlRels - An array of {@link Relationship relationships}.
46
+ * @param options - The {@link NvlOptions options} for the NVL instance.
47
+ * @param callbacks - Callbacks triggered on NVL events.
48
+ */
49
+ constructor(frame: HTMLElement, nvlNodes?: Node[], nvlRels?: Relationship[], options?: NvlOptions, callbacks?: ExternalCallbacks);
50
+ /**
51
+ * Restarts the NVL instance.
52
+ * @param options - New {@link NvlOptions} for the NVL instance.
53
+ * @param retainPositions - Whether or not to retain the current node positions.
54
+ * New options will be merged with current options
55
+ */
56
+ restart(options?: NvlOptions, retainPositions?: boolean): void;
57
+ /**
58
+ * Adds nodes and relationships to NVL and updates existing nodes and relationships.
59
+ * @param nodes - An Array of {@link Node nodes} to be added or updated.
60
+ * @param relationships - An Array of {@link Relationship relationships} to be added or updated.
61
+ * To update nodes or relationships, they must have an id that matches the id of the
62
+ * node or relationship to be updated.
63
+ * Only the properties that are provided will be updated.
64
+ * If an existing property is not provided, it will not be changed.
65
+ * @example
66
+ * Adding and updating nodes and relationships
67
+ * ```ts
68
+ * import { NVL } from '@neo4j-nvl/base'
69
+ *
70
+ * const nvl = new NVL(document.getElementById('frame'), [{ id: '0' }], [])
71
+ *
72
+ * const nodes = [
73
+ * { id: '1', caption: 'Node 1', color: '#e04141' },
74
+ * { id: '2', caption: 'Node 2', color: '#e09c41' }
75
+ * ]
76
+ * const relationships = [{ id: '12', from: '1', to: '2' }]
77
+ * // Adds new nodes and relationships
78
+ * nvl.addAndUpdateElementsInGraph(nodes, relationships)
79
+ * // Updates an existing relationship
80
+ * nvl.addAndUpdateElementsInGraph([], [{ id: '12', color: '#e0df41' }])
81
+ * ```
82
+ */
83
+ addAndUpdateElementsInGraph(nodes?: Node[] | PartialNode[], relationships?: Relationship[] | PartialRelationship[]): void;
84
+ /**
85
+ * Gets the currently selected nodes.
86
+ * @returns An array of all currently selected {@link Node nodes} and their positions.
87
+ */
88
+ getSelectedNodes(): (Node & Point)[];
89
+ /**
90
+ * Gets the currently selected relationships.
91
+ * @returns An array of all currently selected {@link Relationship relationships}.
92
+ */
93
+ getSelectedRelationships(): Relationship[];
94
+ /**
95
+ * Updates relationships in the current scene with the provided array of nodes and relationships.
96
+ * @param nodes - The updated {@link Node nodes}.
97
+ * @param relationships - The updated {@link Relationship relationships}.
98
+ * Ignores any nodes or relationships that do not exist in the current scene.
99
+ * To update nodes or relationships, they must have an id that matches the id of the
100
+ * node or relationship to be updated.
101
+ * Only the properties that are provided will be updated.
102
+ * If an existing property is not provided, it will not be changed.
103
+ * @example
104
+ * Updating nodes and relationships
105
+ * ```ts
106
+ * import { NVL } from '@neo4j-nvl/base'
107
+ *
108
+ * const nodes = [{ id: '1' }, { id: '2' }]
109
+ * const relationships = [{ id: '12', from: '1', to: '2' }]
110
+ * const nvl = new NVL(document.getElementById('frame'), nodes, relationships)
111
+ *
112
+ * // Updates an existing node and relationship
113
+ * nvl.updateElementsInGraph([{ id: '1', selected: true }], [{ id: '12', color: '#e0df41' }])
114
+ * ```
115
+ */
116
+ updateElementsInGraph(nodes: Node[] | PartialNode[], relationships: Relationship[] | PartialRelationship[]): void;
117
+ /**
118
+ * Adds nodes and relationships in the current scene.
119
+ * @param nodes - The nodes to be added.
120
+ * @param relationships - The relationships to be added.
121
+ * @remarks Elements whose id already exists are skipped silently; use
122
+ * {@link addAndUpdateElementsInGraph} to add and update in one call.
123
+ */
124
+ addElementsToGraph(nodes: Node[], relationships: Relationship[]): void;
125
+ /**
126
+ * Removes the specified nodes from the current scene.
127
+ * @param nodeIds - The node ids to be removed.
128
+ * Adjacent relationships will also be removed.
129
+ */
130
+ removeNodesWithIds(nodeIds: string[]): void;
131
+ /**
132
+ * Removes the specified relationships from the current scene.
133
+ * @param relationshipIds - The relationship ids to be removed.
134
+ */
135
+ removeRelationshipsWithIds(relationshipIds: string[]): void;
136
+ /**
137
+ * Returns all nodes that is currently stored in the visualisation.
138
+ * Each node includes layout coordinates (`x`, `y`) and a `clientPosition` in screen space.
139
+ * @returns The array of {@link NodeWithClientPosition nodes}.
140
+ */
141
+ getNodes(): NodeWithClientPosition[];
142
+ /**
143
+ * Returns the relationships that are currently in the visualization.
144
+ * @returns An array of the {@link Relationship relationships} in the visualization.
145
+ */
146
+ getRelationships(): Relationship[];
147
+ /**
148
+ * Returns the node data that is currently stored in the visualisation for a given id.
149
+ * @param id - The id of the {@link Node node} that should be returned.
150
+ * @returns The {@link Node node} or undefined if there is no node with the given id.
151
+ */
152
+ getNodeById(id: string): Node;
153
+ /**
154
+ * Returns the relationship data that is currently stored in the visualisation for a given id.
155
+ * @param id - The id of the {@link Relationship relationship} that should be returned.
156
+ * @returns The {@link Relationship relationship} or undefined if there is no relationship with the given id.
157
+ */
158
+ getRelationshipById(id: string): Relationship;
159
+ /**
160
+ * Returns the node position that is currently stored in the visualisation for a given id.
161
+ * @param id - The id of the node position that should be returned.
162
+ * @returns The position information for the given id, or undefined if there is no such {@link Node node}.
163
+ * or the layout has not yet run with that node.
164
+ */
165
+ getPositionById(id: string): Node;
166
+ /**
167
+ * Returns the current options.
168
+ * @returns The current options.
169
+ */
170
+ getCurrentOptions(): NvlOptions;
171
+ /** Removes the graph visualization from the DOM and cleans up everything. */
172
+ destroy(): void;
173
+ /**
174
+ * De-selects all nodes and relationships.
175
+ */
176
+ deselectAll(): void;
177
+ /**
178
+ * Updates pan and zoom to fit the specified nodes in the viewport.
179
+ * @param nodeIds - The ids of the nodes to fit on the screen. Unknown ids are ignored;
180
+ * an empty array (or only unknown ids) does nothing. Pass every id to fit the whole graph.
181
+ * @param zoomOptions - Specific options on how to transition the zoom.
182
+ *
183
+ * @remarks
184
+ * Zoom is limited by {@link ZoomOptions.minZoom} / {@link ZoomOptions.maxZoom} and the
185
+ * {@link NvlOptions.minZoom minZoom} / {@link NvlOptions.maxZoom maxZoom} /
186
+ * {@link NvlOptions.allowDynamicMinZoom allowDynamicMinZoom} options. See those for details.
187
+ * @example
188
+ * ```ts
189
+ * import { NVL } from '@neo4j-nvl/base'
190
+ *
191
+ * const nodes = [{ id: '1' }, { id: '2' }]
192
+ * const nvl = new NVL(document.getElementById('frame'), nodes, [])
193
+ *
194
+ * // Fit the whole graph
195
+ * nvl.fit(nodes.map((node) => node.id))
196
+ * ```
197
+ */
198
+ fit(nodeIds: string[], zoomOptions?: NvlState['zoomOptions']): void;
199
+ /**
200
+ * Resets the zoom of the viewport back to the default zoom level of 0.75.
201
+ */
202
+ resetZoom(): void;
203
+ /**
204
+ * Switches between rendering methods
205
+ * @param renderer - which rendering method to use
206
+ */
207
+ setRenderer(renderer: string): void;
208
+ /**
209
+ * Restarts NVL with or without WebGL support.
210
+ * @param disabled - Whether or not WebGL should be disabled.
211
+ * @experimental
212
+ */
213
+ setDisableWebGL(disabled?: boolean): void;
214
+ /**
215
+ * Pins the specified node so it is not affected by layout forces.
216
+ * @param nodeId - The id of the node to be pinned.
217
+ */
218
+ pinNode(nodeId: string): void;
219
+ /**
220
+ * Un-pins the specified nodes so they are affected by layout forces again.
221
+ * @param nodeIds - The ids of the nodes to be un-pinned.
222
+ * @remarks A settled force-directed layout does not restart on its own after un-pinning.
223
+ * Call {@link setNodePositions} with `updateLayout: true` to wake it up.
224
+ */
225
+ unPinNode(nodeIds: string[]): void;
226
+ /**
227
+ * Changes the layout type.
228
+ * @param layout - The {@link Layout} type.
229
+ * @remarks The layout is re-run only when the type actually changes. Calling this with the
230
+ * current layout type is a no-op.
231
+ */
232
+ setLayout(layout: Layout): void;
233
+ /**
234
+ * Updates the configuration of the current layout.
235
+ * @param options - The {@link LayoutOptions} configuration. Replaces the previous options.
236
+ */
237
+ setLayoutOptions(options: LayoutOptions): void;
238
+ /**
239
+ * Returns the nodes that are currently in the visualization.
240
+ * The `rels` property of the returned object is always empty.
241
+ * @returns An object containing the nodes and relationships in the visualization.
242
+ */
243
+ getNodesOnScreen(): {
244
+ /** The nodes in the visualization. */
245
+ nodes: Node[];
246
+ /** The relationships in the visualization. */
247
+ rels: Relationship[];
248
+ };
249
+ /**
250
+ * Fetches and returns the current positions of all nodes as an array of coordinates.
251
+ * @returns An array of {@link Node node} positions.
252
+ */
253
+ getNodePositions(): (Node & Point)[];
254
+ /**
255
+ * Sets the node positions based on data provided.
256
+ * @param data - The positions that the nodes should be set to.
257
+ * @param updateLayout - Whether or not the current layout algorithm
258
+ * should update the graph after setting the node positions.
259
+ *
260
+ * @remarks
261
+ * Ids that are not in the graph are skipped with a warning.
262
+ * This is the way to position nodes; do not set `x` and `y` on the nodes passed to
263
+ * {@link addAndUpdateElementsInGraph} or {@link updateElementsInGraph}.
264
+ * For node positions to be unaffected by layout algorithms, use the 'free' layout type
265
+ * or use {@link pinNode} to pin the nodes that should remain still.
266
+ */
267
+ setNodePositions(data: Node[], updateLayout?: boolean): void;
268
+ /**
269
+ * Checks and returns whether the current layout is still in flux.
270
+ * @returns Whether or not the layout is moving.
271
+ */
272
+ isLayoutMoving(): boolean;
273
+ /**
274
+ * Saves the current view of the graph visualization canvas as a png to the client.
275
+ * @param {{ filename: string, backgroundColor: string }} options The filename and background color of the png.
276
+ * @param options.filename - The filename of the png file.
277
+ * @param options.backgroundColor - The background color of the png file.
278
+ * The size of the png file will be the size of the canvas in the DOM.
279
+ */
280
+ saveToFile(options?: {
281
+ filename?: string;
282
+ backgroundColor?: string;
283
+ }): void;
284
+ /**
285
+ * Saves the entire graph visualization as an SVG file to the client.
286
+ * @param options - Options for the SVG export
287
+ * @param options.filename - The filename of the SVG file.
288
+ * @param options.backgroundColor - The background color of the SVG file.
289
+ * @experimental
290
+ */
291
+ saveToSvg(options?: {
292
+ filename?: string;
293
+ backgroundColor?: string;
294
+ }): void;
295
+ /**
296
+ * Returns the current view of the graph visualization canvas as a data URL.
297
+ * @param options - The options for the image.
298
+ * @param options.backgroundColor - The background color of the data URL.
299
+ * @returns A data URL of the current view of the graph visualization canvas.
300
+ */
301
+ getImageDataUrl(options?: {
302
+ backgroundColor?: string;
303
+ }): string;
304
+ /**
305
+ * Returns the entire graph visualization as an SVG data URL.
306
+ * @param options - Options for the SVG export
307
+ * @param options.backgroundColor - The background color of the SVG (defaults to transparent).
308
+ * @returns A Promise resolving to a data URL string representing the graph as SVG (data:image/svg+xml;...)
309
+ * @experimental
310
+ *
311
+ * @example
312
+ * ```ts
313
+ * import { NVL } from '@neo4j-nvl/base'
314
+ *
315
+ * const nvl = new NVL(document.getElementById('frame'), [{ id: '0' }], [])
316
+ *
317
+ * const renderSvg = async () => {
318
+ * const svgDataUrl = await nvl.getSvgDataUrl({ backgroundColor: '#ffffff' })
319
+ * const img = document.createElement('img')
320
+ * img.src = svgDataUrl
321
+ * document.body.appendChild(img)
322
+ * }
323
+ * ```
324
+ */
325
+ getSvgDataUrl(options?: {
326
+ backgroundColor?: string;
327
+ }): Promise<string>;
328
+ /**
329
+ * Saves the entire graph visualization canvas as a png to the client.
330
+ * @param {{ filename: string, backgroundColor: string }} options The filename and background color of the png.
331
+ * @param options.filename - The filename of the png file.
332
+ * @param options.backgroundColor - The background color of the png file.
333
+ * The size of the png file will be as large as the entire graph at the default zoom level.
334
+ * Can result in a very large file.
335
+ */
336
+ saveFullGraphToLargeFile(options?: {
337
+ filename?: string;
338
+ backgroundColor?: string;
339
+ }): void;
340
+ /**
341
+ * Returns the effective zoom limits.
342
+ * @returns The current `minZoom` and `maxZoom`. `minZoom` can be lower than the configured
343
+ * option when {@link NvlOptions.allowDynamicMinZoom} let the graph zoom out further.
344
+ */
345
+ getZoomLimits(): {
346
+ /** The lowest zoom level the graph can currently reach. */
347
+ minZoom: number;
348
+ /** The highest zoom level the graph can currently reach. */
349
+ maxZoom: number;
350
+ };
351
+ /**
352
+ * Sets the zoom of the viewport to a specific value.
353
+ * @param zoomValue - The desired zoom level.
354
+ * @remarks
355
+ *
356
+ * When updating both the zoom level and pan coordinates,
357
+ * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan}
358
+ * separately to avoid jittering.
359
+ *
360
+ * If the zoom level is outside of the range provided by the
361
+ * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
362
+ * the zoom level will be set to the closest valid zoom level.
363
+ * If {@link NvlOptions.allowDynamicMinZoom} is set to true,
364
+ * the {@link NvlOptions.minZoom} option will be ignored of the current graph does not fit the viewport.
365
+ */
366
+ setZoom(zoomValue: number): void;
367
+ /**
368
+ * Sets the zoom of the viewport to a specific value.
369
+ * @param panX - The desired panX value.
370
+ * @param panY - The desired panY value.
371
+ * @remarks When updating both the zoom level and pan coordinates,
372
+ * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan} separately to avoid jittering.
373
+ */
374
+ setPan(panX: number, panY: number): void;
375
+ /**
376
+ * Sets the zoom and pan of the viewport to specific values.
377
+ * @param zoom - The desired zoom level.
378
+ * @param panX - The desired panX value.
379
+ * @param panY - The desired panY value.
380
+ * @remarks When only updating zoom level or pan coordinates, use {@link setZoom} or {@link setPan} instead.
381
+ *
382
+ * If the zoom level is outside of the range provided by the
383
+ * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
384
+ * the zoom level will be set to the closest valid zoom level.
385
+ * If {@link NvlOptions.allowDynamicMinZoom} is set to true,
386
+ * the {@link NvlOptions.minZoom} option will be ignored of the current graph does not fit the viewport.
387
+ */
388
+ setZoomAndPan(zoom: number, panX: number, panY: number): void;
389
+ /**
390
+ * Get the current zoom level of the viewport.
391
+ * @returns The current zoom level.
392
+ * @see {@link NodeWithClientPosition} for the layout-to-screen formula.
393
+ */
394
+ getScale(): number;
395
+ /**
396
+ * Returns the current pan of the viewport, in layout coordinates.
397
+ * @returns The layout-space point shown at the center of the container.
398
+ * @see {@link NodeWithClientPosition} for the layout-to-screen formula.
399
+ */
400
+ getPan(): Point;
401
+ /**
402
+ * Gets the nodes, relationships, and clusters that have been hit by a pointer event.
403
+ * @param evt - The mouse event.
404
+ * @param targets - The graph elements to check for hits. Defaults to ['node', 'relationship', 'cluster'].
405
+ * @param hitOptions - Options for the hit test. `hitNodeMarginWidth` widens the node hit area in layout units.
406
+ * @returns A {@link NvlMouseEvent} with the {@link HitTargets} property
407
+ * containing the nodes, relationships, and clusters that have been hit by the pointer event.
408
+ *
409
+ * @remarks Clusters are hit when the pointer is inside a cluster hull, including over its nodes.
410
+ * This is the way to react to cluster hover; the hover interaction handler only reports nodes and relationships.
411
+ *
412
+ * @example
413
+ * ```ts
414
+ * import { NVL } from '@neo4j-nvl/base'
415
+ *
416
+ * const container = document.createElement('div')
417
+ * const nvl = new NVL(container, [{ id: '0' }], [])
418
+ *
419
+ * // Get the nodes and relationships that have been hit by a pointer event.
420
+ * container.addEventListener('click', (evt) => {
421
+ * const { nvlTargets } = nvl.getHits(evt)
422
+ * console.log('clicked elements:', nvlTargets)
423
+ * })
424
+ *
425
+ * // Cluster hover
426
+ * container.addEventListener('mousemove', (evt) => {
427
+ * const cluster = nvl.getHits(evt, ['cluster']).nvlTargets.clusters[0]?.data
428
+ * console.log('hovered cluster:', cluster?.id)
429
+ * })
430
+ * ```
431
+ */
432
+ getHits(evt: MouseEvent, targets?: HitTestTarget[], hitOptions?: {
433
+ hitNodeMarginWidth: number;
434
+ }): NvlMouseEvent;
435
+ /**
436
+ * Provides the container DOM element the graph is rendered in.
437
+ * @returns The container element of the NVL instance.
438
+ */
439
+ getContainer(): HTMLElement;
440
+ private checkWebGLCompatibility;
409
441
  }
410
442
  /**
411
443
  * Functions for mapping colors.
@@ -413,12 +445,10 @@ declare class NVL {
413
445
  * @hidden
414
446
  */
415
447
  declare const colorMapperFunctions: {
416
- textColorForBackground: (color: string) => string;
448
+ textColorForBackground: (color: string) => string;
417
449
  };
418
450
  /**
419
451
  * The different types of renderers available
420
452
  */
421
- type Renderer = Exclude<InternalRenderer, typeof SvgRendererType>;
422
- export default NVL;
423
- export type { NvlOptions, Renderer, Node, NodeWithClientPosition, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, ClusteringOptions, Cluster, ClusterByFn, ClusterId, HierarchicalOptions, CircularOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, HitTargetCluster, HitTestTarget, Point, NvlMouseEvent, ZoomOptions, StyledCaption, WebGLRendererType, CanvasRendererType };
424
- export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, CircularLayoutType, drawCircleBand, nvlResultTransformer, getZoomTargetForNodePositions };
453
+ type Renderer = typeof WebGLRendererType | typeof CanvasRendererType;
454
+ export { type CanvasRendererType, CircularLayoutType, type CircularOptions, type Cluster, type ClusterByFn, type ClusterId, type ClusteringOptions, CompatibilityError, type ExternalCallbacks, ForceDirectedLayoutType, type ForceDirectedOptions, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, type HierarchicalOptions, type HitTargetCluster, type HitTargetNode, type HitTargetRelationship, type HitTargets, type HitTestTarget, type Layout, type LayoutOptions, NVL, NVL as default, type Node, type NodeWithClientPosition, type NvlMouseEvent, type NvlOptions, type NvlWindow, type PartialNode, type PartialRelationship, type Point, type Relationship, type Renderer, type StyledCaption, type WebGLRendererType, type ZoomOptions, colorMapperFunctions, d3ForceLayoutType, drawCircleBand, getZoomTargetForNodePositions, nvlResultTransformer };