@neo4j-nvl/base 0.3.9 → 1.0.0-28b0f5db

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 (39) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/base.mjs +1 -1
  3. package/dist/types/index.d.ts +84 -76
  4. package/dist/types/layouts/animatedlayout/animationUtils.d.ts +3 -3
  5. package/dist/types/layouts/circularLayout/CircularLayout.d.ts +18 -0
  6. package/dist/types/layouts/d3forcelayout/circularLayout.test.d.ts +1 -0
  7. package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +19 -19
  8. package/dist/types/modules/CallbackHelper.d.ts +5 -5
  9. package/dist/types/modules/ExternalCallbackHandler.d.ts +7 -0
  10. package/dist/types/modules/NvlController.d.ts +6 -5
  11. package/dist/types/modules/dataset.d.ts +1 -1
  12. package/dist/types/modules/state/state.d.ts +2 -2
  13. package/dist/types/modules/state/types.d.ts +61 -55
  14. package/dist/types/modules/state/utils.d.ts +8 -6
  15. package/dist/types/renderers/canvasrenderer/Animation.d.ts +8 -11
  16. package/dist/types/renderers/canvasrenderer/AnimationHandler.d.ts +15 -16
  17. package/dist/types/renderers/canvasrenderer/CanvasRenderer.d.ts +10 -10
  18. package/dist/types/renderers/canvasrenderer/arrows/ArrowBundle.d.ts +15 -15
  19. package/dist/types/renderers/canvasrenderer/arrows/ArrowBundler.d.ts +8 -8
  20. package/dist/types/renderers/canvasrenderer/arrows/arrows.d.ts +26 -26
  21. package/dist/types/renderers/canvasrenderer/nodes/nodes.d.ts +9 -9
  22. package/dist/types/renderers/canvasrenderer/types.d.ts +6 -4
  23. package/dist/types/renderers/canvasrenderer/util.d.ts +20 -21
  24. package/dist/types/renderers/canvasrenderer/wordwrap.d.ts +13 -13
  25. package/dist/types/types/graph-element.d.ts +15 -6
  26. package/dist/types/utils/canvasManagement.d.ts +17 -1
  27. package/dist/types/utils/circularUtils.d.ts +3 -0
  28. package/dist/types/utils/circularUtils.test.d.ts +1 -0
  29. package/dist/types/utils/colorUtils.d.ts +3 -3
  30. package/dist/types/utils/constants.d.ts +3 -3
  31. package/dist/types/utils/errors.d.ts +2 -1
  32. package/dist/types/utils/geometry.d.ts +31 -30
  33. package/dist/types/utils/graphObjectUtils.d.ts +3 -3
  34. package/dist/types/utils/hittest.d.ts +2 -0
  35. package/dist/types/utils/jsDriverResultTransformer.d.ts +13 -6
  36. package/dist/types/utils/segmentAnalytics.d.ts +8 -8
  37. package/dist/types/utils/zoomFunctions.d.ts +30 -23
  38. package/package.json +5 -4
  39. package/dist/types/modules/performance.d.ts +0 -93
@@ -1,6 +1,6 @@
1
1
  import type { ExternalCallbacks } from './modules/ExternalCallbackHandler';
2
- import type { ForceDirectedOptions, HierarchicalOptions, Layout, LayoutOptions, NvlOptions, NvlState, Renderer, ZoomOptions } from './modules/state/types';
3
- import { CanvasRendererType, ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, WebGLRendererType, d3ForceLayoutType } from './modules/state/types';
2
+ import type { CircularOptions, ForceDirectedOptions, HierarchicalOptions, Layout, LayoutOptions, NvlOptions, NvlState, Renderer, ZoomOptions } from './modules/state/types';
3
+ import { CanvasRendererType, CircularLayoutType, ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, WebGLRendererType, d3ForceLayoutType } from './modules/state/types';
4
4
  import type { StyledCaption } from './renderers/canvasrenderer/types';
5
5
  import { drawCircleBand } from './renderers/canvasrenderer/util';
6
6
  import type { Node, PartialNode, PartialRelationship, Relationship } from './types/graph-element';
@@ -11,9 +11,10 @@ import { nvlResultTransformer } from './utils/jsDriverResultTransformer';
11
11
  import { getZoomTargetForNodePositions } from './utils/zoomFunctions';
12
12
  /**
13
13
  * Extends the MouseEvent interface with the {@link HitTargets} property.
14
- * The result of a _.{@link NVL.getHits} call.
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. */
17
18
  nvlTargets: HitTargets;
18
19
  }
19
20
  /**
@@ -39,24 +40,24 @@ declare class NVL {
39
40
  #private;
40
41
  /**
41
42
  * Creates a new NVL instance.
42
- * @param {HTMLElement} frame - The DOM element to display the graph in
43
- * @param {Node[]} nvlNodes - An Array of nodes
44
- * @param {Relationship[]} nvlRels - An Array of relationships
45
- * @param {NvlOptions} options - Options for the NVL instance
46
- * @param {ExternalCallbackHandler} callbacks - Callbacks triggered on NVL events
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.
47
48
  */
48
49
  constructor(frame: HTMLElement, nvlNodes?: Node[], nvlRels?: Relationship[], options?: NvlOptions, callbacks?: ExternalCallbacks);
49
50
  /**
50
51
  * Restarts the NVL instance.
51
- * @param {NvlOptions} options - new options for the NVL instance
52
- * @param {boolean} retainPositions - whether or not to retain the current node positions
52
+ * @param options - New {@link NvlOptions} for the NVL instance.
53
+ * @param retainPositions - Whether or not to retain the current node positions.
53
54
  * New options will be merged with current options
54
55
  */
55
56
  restart(options?: NvlOptions, retainPositions?: boolean): void;
56
57
  /**
57
58
  * Adds nodes and relationships to NVL and updates existing nodes and relationships.
58
- * @param {Node[] | PartialNode[]} nodes - An Array of nodes to be added or updated
59
- * @param {Relationship[] | PartialRelationship[]} relationships - An Array of relationships to be added or updated
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.
60
61
  * To update nodes or relationships, they must have an id that matches the id of the
61
62
  * node or relationship to be updated.
62
63
  * Only the properties that are provided will be updated.
@@ -84,18 +85,18 @@ declare class NVL {
84
85
  addAndUpdateElementsInGraph(nodes?: Node[] | PartialNode[], relationships?: Relationship[] | PartialRelationship[]): void;
85
86
  /**
86
87
  * Gets the currently selected nodes.
87
- * @returns {(Node & Point)[]} An array of all currently selected nodes and their positions.
88
+ * @returns An array of all currently selected {@link Node nodes} and their positions.
88
89
  */
89
90
  getSelectedNodes(): (Node & Point)[];
90
91
  /**
91
92
  * Gets the currently selected relationships.
92
- * @returns {Relationship[]} An array of all currently selected relationships.
93
+ * @returns An array of all currently selected {@link Relationship relationships}.
93
94
  */
94
95
  getSelectedRelationships(): Relationship[];
95
96
  /**
96
97
  * Updates relationships in the current scene with the provided array of nodes and relationships.
97
- * @param {Node[] | PartialNode[]} nodes The updated nodes.
98
- * @param {Relationship[] | PartialRelationship[]} relationships The updated relationships.
98
+ * @param nodes - The updated {@link Node nodes}.
99
+ * @param relationships - The updated {@link Relationship relationships}.
99
100
  * Ignores any nodes or relationships that do not exist in the current scene.
100
101
  * To update nodes or relationships, they must have an id that matches the id of the
101
102
  * node or relationship to be updated.
@@ -121,54 +122,53 @@ declare class NVL {
121
122
  updateElementsInGraph(nodes: Node[] | PartialNode[], relationships: Relationship[] | PartialRelationship[]): void;
122
123
  /**
123
124
  * Adds nodes and relationships in the current scene.
124
- * @param {Node[]} nodes The nodes to be added.
125
- * @param {Relationship[]} relationships The relationships to be added.
125
+ * @param nodes - The nodes to be added.
126
+ * @param relationships - The relationships to be added.
126
127
  */
127
128
  addElementsToGraph(nodes: Node[], relationships: Relationship[]): void;
128
129
  /**
129
130
  * Removes the specified nodes from the current scene.
130
- * @param {string[]} nodeIds The node ids to be removed.
131
+ * @param nodeIds - The node ids to be removed.
131
132
  * Adjacent relationships will also be removed.
132
133
  */
133
134
  removeNodesWithIds(nodeIds: string[]): void;
134
135
  /**
135
136
  * Removes the specified relationships from the current scene.
136
- * @param {string[]} relationshipIds The relationship ids to be removed.
137
+ * @param relationshipIds - The relationship ids to be removed.
137
138
  */
138
139
  removeRelationshipsWithIds(relationshipIds: string[]): void;
139
140
  /**
140
141
  * Returns all nodes that is currently stored in the visualisation.
141
- * @returns {Node[]} The array of nodes.
142
+ * @returns The array of {@link Node nodes}.
142
143
  */
143
144
  getNodes(): Node[];
144
145
  /**
145
146
  * Returns the relationships that are currently in the visualization.
146
- * @returns {Relationship[]} An array of the relationships in the visualization.
147
+ * @returns An array of the {@link Relationship relationships} in the visualization.
147
148
  */
148
149
  getRelationships(): Relationship[];
149
150
  /**
150
151
  * Returns the node data that is currently stored in the visualisation for a given id.
151
- * @param {string} id The id of the node that should be returned.
152
- * @returns {Node} The node or undefined if there is no node with the given id.
152
+ * @param id - The id of the {@link Node node} that should be returned.
153
+ * @returns The {@link Node node} or undefined if there is no node with the given id.
153
154
  */
154
155
  getNodeById(id: string): Node;
155
156
  /**
156
157
  * Returns the relationship data that is currently stored in the visualisation for a given id.
157
- * @param {string} id The id of the relationship that should be returned.
158
- * @returns {Relationship} The relationship or undefined if there is no relationship with the given id.
158
+ * @param id - The id of the {@link Relationship relationship} that should be returned.
159
+ * @returns The {@link Relationship relationship} or undefined if there is no relationship with the given id.
159
160
  */
160
161
  getRelationshipById(id: string): Relationship;
161
162
  /**
162
163
  * Returns the node position that is currently stored in the visualisation for a given id.
163
- * @param {string} id The id of the node position that should be returned.
164
- * @returns {Node} The position information for the given id, or undefined if there is no such node
164
+ * @param id - The id of the node position that should be returned.
165
+ * @returns The position information for the given id, or undefined if there is no such {@link Node node}.
165
166
  * or the layout has not yet run with that node.
166
167
  */
167
168
  getPositionById(id: string): Node;
168
169
  /**
169
170
  * Returns the current options.
170
- * @returns {NvlOptions} The current options.
171
- * @internal
171
+ * @returns The current options.
172
172
  */
173
173
  getCurrentOptions(): NvlOptions;
174
174
  /** Removes the graph visualization from the DOM and cleans up everything. */
@@ -179,26 +179,21 @@ declare class NVL {
179
179
  deselectAll(): void;
180
180
  /**
181
181
  * Updates pan and zoom fit the specified nodes in the viewport.
182
- * @param {string[]} nodeIds The ids of the nodes to fit on the screen,
183
- * @param {NvlState['zoomOptions']} zoomOptions specific options on how to transition the zoom
182
+ * @param nodeIds - The ids of the nodes to fit on the screen.
183
+ * @param zoomOptions - Specific options on how to transition the zoom.
184
+ *
185
+ * @remarks
184
186
  * If the zoom level required to fit the provided nodes is outside of the range provided by the
185
- * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
186
- * and {@link NvlOptions.allowDynamicMinZoom} is set to `false`,
187
+ * {@link NvlOptions.minZoom minZoom} and {@link NvlOptions.maxZoom maxZoom} options, and the
188
+ * {@link NvlOptions.allowDynamicMinZoom allowDynamicMinZoom} option is set to `false`,
187
189
  * the zoom level will be set to the closest valid zoom level,
188
190
  * even if the given nodes do not fit the viewport yet.
189
191
  */
190
192
  fit(nodeIds: string[], zoomOptions?: NvlState['zoomOptions']): void;
191
193
  /**
192
- * Resets the zoom of the viewport back to the default zoom level of 0.75
194
+ * Resets the zoom of the viewport back to the default zoom level of 0.75.
193
195
  */
194
196
  resetZoom(): void;
195
- /**
196
- * Toggles between the WebGL and Canvas rendering.
197
- * @deprecated use {@link setRenderer} instead.
198
- * @param {boolean} enabled Whether or not WebGL renderer should be used.
199
- * @internal
200
- */
201
- setUseWebGLRenderer(enabled: boolean): void;
202
197
  /**
203
198
  * Switches between rendering methods
204
199
  * @param renderer - which rendering method to use
@@ -206,79 +201,88 @@ declare class NVL {
206
201
  setRenderer(renderer: string): void;
207
202
  /**
208
203
  * Restarts NVL with or without WebGL support.
209
- * @param {boolean} disabled Whether or not WebGL should be disabled.
210
- * Not to be confused with {@link setUseWebGLRenderer}, which only affects the rendering method
204
+ * @param disabled - Whether or not WebGL should be disabled.
211
205
  * @experimental
212
206
  */
213
207
  setDisableWebGL(disabled?: boolean): void;
214
208
  /**
215
209
  * Pins the specified node so it is not affected by layout forces.
216
- * @param {string} nodeId The id of the node to be pinned.
210
+ * @param nodeId - The id of the node to be pinned.
217
211
  */
218
212
  pinNode(nodeId: string): void;
219
213
  /**
220
214
  * Un-pins the specified nodes so it is affected by layout forces again.
221
- * @param {string[]} nodeIds The ids of the nodes to be un-pinned.
215
+ * @param nodeIds The ids of the nodes to be un-pinned.
222
216
  */
223
217
  unPinNode(nodeIds: string[]): void;
224
218
  /**
225
219
  * Changes the layout type.
226
- * @param {Layout} layout The layout type.
220
+ * @param layout - The {@link Layout} type.
227
221
  */
228
222
  setLayout(layout: Layout): void;
229
223
  /**
230
224
  * Updates the configuration of the current layout.
231
- * @param {LayoutOptions} options The layout configuration.
225
+ * @param options - The {@link LayoutOptions} configuration.
232
226
  */
233
227
  setLayoutOptions(options: LayoutOptions): void;
234
228
  /**
235
229
  * Returns the nodes that are currently in the visualization.
236
230
  * The `rels` property of the returned object is always empty.
237
- * @returns {{ nodes: Node[], rels: Relationship [] }} An array of the nodes in the visualization.
231
+ * @returns An object containing the nodes and relationships in the visualization.
238
232
  */
239
233
  getNodesOnScreen(): {
234
+ /** The nodes in the visualization. */
240
235
  nodes: Node[];
236
+ /** The relationships in the visualization. */
241
237
  rels: Relationship[];
242
238
  };
243
239
  /**
244
240
  * Fetches and returns the current positions of all nodes as an array of coordinates.
245
- * @returns {(Node & Point)[]} An array of node positions.
241
+ * @returns An array of {@link Node node} positions.
246
242
  */
247
243
  getNodePositions(): (Node & Point)[];
248
244
  /**
249
- * Sets the node positions based on data provided
250
- * @param {Node[]} data The positions that the nodes should be set to.
251
- * @param {boolean} updateLayout whether or not the current layout algorithm
245
+ * Sets the node positions based on data provided.
246
+ * @param data - The positions that the nodes should be set to.
247
+ * @param updateLayout - Whether or not the current layout algorithm
252
248
  * should update the graph after setting the node positions.
253
- * For node positions to be unaffected by layout algorithms, use the {@link FreeLayoutType}
249
+ *
250
+ * @remarks
251
+ * For node positions to be unaffected by layout algorithms, use the 'free' layout type
254
252
  * or use {@link pinNode} to pin the nodes that should remain still.
255
253
  * False by default.
256
254
  */
257
255
  setNodePositions(data: Node[], updateLayout?: boolean): void;
258
256
  /**
259
257
  * Checks and returns whether the current layout is still in flux.
260
- * @returns {boolean} Whether or not the layout is moving.
258
+ * @returns Whether or not the layout is moving.
261
259
  */
262
260
  isLayoutMoving(): boolean;
263
261
  /**
264
262
  * Saves the current view of the graph visualization canvas as a png to the client.
265
263
  * @param {{ filename: string, backgroundColor: string }} options The filename and background color of the png.
266
- * @param {string} options.filename The filename of the png file.
267
- * @param {string} options.backgroundColor - The background color of the png file.
264
+ * @param options.filename - The filename of the png file.
265
+ * @param options.backgroundColor - The background color of the png file.
268
266
  * The size of the png file will be the size of the canvas in the DOM.
269
267
  */
270
268
  saveToFile(options?: {
271
269
  filename?: string;
272
270
  backgroundColor?: string;
273
271
  }): void;
272
+ /**
273
+ * Returns the current view of the graph visualization canvas as a data URL.
274
+ * @param options - The options for the image.
275
+ * @param options.backgroundColor - The background color of the data URL.
276
+ * @returns A data URL of the current view of the graph visualization canvas.
277
+ */
274
278
  getImageDataUrl(options?: {
275
279
  backgroundColor?: string;
276
280
  }): string;
277
281
  /**
278
282
  * Saves the entire graph visualization canvas as a png to the client.
279
283
  * @param {{ filename: string, backgroundColor: string }} options The filename and background color of the png.
280
- * @param {string} options.filename The filename of the png file.
281
- * @param {string} options.backgroundColor - The background color of the png file.
284
+ * @param options.filename - The filename of the png file.
285
+ * @param options.backgroundColor - The background color of the png file.
282
286
  * The size of the png file will be as large as the entire graph at the default zoom level.
283
287
  * Can result in a very large file.
284
288
  */
@@ -288,32 +292,35 @@ declare class NVL {
288
292
  }): void;
289
293
  /**
290
294
  * Sets the zoom of the viewport to a specific value.
291
- * @param {number} absolute The desired zoom level.
295
+ * @param zoomValue - The desired zoom level.
296
+ * @remarks
297
+ *
292
298
  * When updating both the zoom level and pan coordinates,
293
299
  * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan}
294
300
  * separately to avoid jittering.
301
+ *
295
302
  * If the zoom level is outside of the range provided by the
296
303
  * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
297
304
  * the zoom level will be set to the closest valid zoom level.
298
305
  * If {@link NvlOptions.allowDynamicMinZoom} is set to true,
299
306
  * the {@link NvlOptions.minZoom} option will be ignored of the current graph does not fit the viewport.
300
307
  */
301
- setZoom(absolute: number): void;
308
+ setZoom(zoomValue: number): void;
302
309
  /**
303
310
  * Sets the zoom of the viewport to a specific value.
304
- * @param {number} panX The desired panX value.
305
- * @param {number} panY The desired panY value.
306
- * When updating both the zoom level and pan coordinates,
307
- * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan}
308
- * separately to avoid jittering.
311
+ * @param panX - The desired panX value.
312
+ * @param panY - The desired panY value.
313
+ * @remarks When updating both the zoom level and pan coordinates,
314
+ * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan} separately to avoid jittering.
309
315
  */
310
316
  setPan(panX: number, panY: number): void;
311
317
  /**
312
318
  * Sets the zoom and pan of the viewport to specific values.
313
- * @param {number} zoom The desired zoom level.
314
- * @param {number} panX The desired panX value.
315
- * @param {number} panY The desired panY value.
316
- * When only updating the zoom level or pan coordinates, use {@link setZoom} or {@link setPan} instead.
319
+ * @param zoom - The desired zoom level.
320
+ * @param panX - The desired panX value.
321
+ * @param panY - The desired panY value.
322
+ * @remarks When only updating zoom level or pan coordinates, use {@link setZoom} or {@link setPan} instead.
323
+ *
317
324
  * If the zoom level is outside of the range provided by the
318
325
  * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
319
326
  * the zoom level will be set to the closest valid zoom level.
@@ -323,18 +330,18 @@ declare class NVL {
323
330
  setZoomAndPan(zoom: number, panX: number, panY: number): void;
324
331
  /**
325
332
  * Get the current zoom level of the viewport.
326
- * @returns {number} The current zoom level
333
+ * @returns The current zoom level.
327
334
  */
328
335
  getScale(): number;
329
336
  /**
330
337
  * Returns the current pan of the viewport.
331
- * @returns {Point} The current pan of the viewport.
338
+ * @returns The current pan of the viewport.
332
339
  */
333
340
  getPan(): Point;
334
341
  /**
335
342
  * Gets the nodes and relationships that have been hit by a pointer event.
336
- * @param evt The mouse event.
337
- * @param targets The graph elements to check for hits. Defaults to ['node', 'relationship'].
343
+ * @param evt - The mouse event.
344
+ * @param targets - The graph elements to check for hits. Defaults to ['node', 'relationship'].
338
345
  * @param hitOptions - Options for the hit test.
339
346
  * @returns A {@link NvlMouseEvent} with the {@link HitTargets} property
340
347
  * containing the nodes and relationships that have been hit by the pointer event.
@@ -364,10 +371,11 @@ declare class NVL {
364
371
  /**
365
372
  * Functions for mapping colors.
366
373
  * @internal
374
+ * @hidden
367
375
  */
368
376
  declare const colorMapperFunctions: {
369
377
  textColorForBackground: (color: string) => string;
370
378
  };
371
379
  export default NVL;
372
- export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions, StyledCaption, WebGLRendererType, CanvasRendererType };
373
- export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, drawCircleBand, nvlResultTransformer, getZoomTargetForNodePositions };
380
+ export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, CircularOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions, StyledCaption, WebGLRendererType, CanvasRendererType };
381
+ export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, CircularLayoutType, drawCircleBand, nvlResultTransformer, getZoomTargetForNodePositions };
@@ -2,8 +2,8 @@ import type { Node } from '../../types/graph-element';
2
2
  import type { Point } from '../../utils/geometry';
3
3
  /**
4
4
  * Calculates the average node coordinates for a given set of nodes.
5
- * @param {Node[]} nodes The nodes to calculate the average position for.
6
- * @param {Record<string, Node | Point>} positions The positions of the nodes.
7
- * @returns {number[]} The average node coordinates.
5
+ * @param nodes - The nodes to calculate the average position for.
6
+ * @param positions - The positions of the nodes.
7
+ * @returns The average node coordinates.
8
8
  */
9
9
  export declare const calculateAverageNodePosition: (nodes: Node[], positions: Record<string, Node | Point>) => number[];
@@ -0,0 +1,18 @@
1
+ import type { CircularOptions, LayoutOptions, NvlState } from '../../modules/state/types';
2
+ import AnimatedLayout from '../animatedlayout/AnimatedLayout';
3
+ type CircularLayoutConfig = {
4
+ state: NvlState;
5
+ } & CircularOptions;
6
+ export declare class CircularLayout extends AnimatedLayout {
7
+ private stateDisposers;
8
+ private sortFunction;
9
+ constructor(config: CircularLayoutConfig);
10
+ setOptions(options?: LayoutOptions): void;
11
+ update(refreshPositions?: boolean): void;
12
+ getShouldUpdate(): boolean;
13
+ getComputing(): boolean;
14
+ private layout;
15
+ terminateUpdate(): void;
16
+ destroy(): void;
17
+ }
18
+ export {};
@@ -58,15 +58,15 @@ export declare class PhysLayout {
58
58
  state: NvlState;
59
59
  });
60
60
  /**
61
- * Sets the layout options
62
- * @param {ForceDirectedOptions} options the object with the options
63
- * @param {boolean} [initial=false] whether this is the first setting of options
61
+ * Sets the layout options.
62
+ * @param options - The object with the options.
63
+ * @param initial - Whether this is the first setting of options.
64
64
  */
65
65
  setOptions(options?: ForceDirectedOptions, initial?: boolean): void;
66
66
  /**
67
67
  * Sets graph data to be used
68
68
  * @param {{ nodes: Node[]; rels: Relationship[] }} data the graph object
69
- * @returns the top level graph of the subgraphs created by the solar merger
69
+ * @returns The top level graph of the subgraphs created by the solar merger.
70
70
  */
71
71
  setData(data: {
72
72
  nodes: Node[];
@@ -75,7 +75,7 @@ export declare class PhysLayout {
75
75
  /**
76
76
  * Updates the node's positions for the next step in the physics layout iterations if the layout needs to update
77
77
  * @param refreshPositions whether the entire layout should be reheated
78
- * @returns whether the layout should update in the following step
78
+ * @returns Whether the layout should update in the following step.
79
79
  */
80
80
  update(refreshPositions?: boolean): boolean;
81
81
  /**
@@ -84,24 +84,24 @@ export declare class PhysLayout {
84
84
  terminateUpdate(): void;
85
85
  /**
86
86
  * Returns whether the current layout needs to be updated in the next iteration step.
87
- * @returns {boolean} Whether the layout should update in the following step.
87
+ * @returns Whether the layout should update in the following step.
88
88
  */
89
89
  getShouldUpdate(): boolean;
90
90
  /**
91
91
  * Returns whether the current layout is computing.
92
92
  * Always returns false because the force-directed layout has no computing step
93
- * @returns {boolean} Whether the layout is computing.
93
+ * @returns Whether the layout is computing.
94
94
  */
95
95
  getComputing(): boolean;
96
96
  /**
97
97
  * Adds the current x,y coordinates for each node to a given list of nodes.
98
- * @param {Node[]} nodeList The list of nodes to get positions for.
99
- * @returns {(Node & Point)[]} The list of nodes containing the x,y coordinates on each node object.
98
+ * @param nodeList - The list of nodes to get positions for.
99
+ * @returns The list of nodes containing the x,y coordinates on each node object.
100
100
  */
101
101
  getNodePositions(nodeList: Node[]): (Node & Point)[];
102
102
  /**
103
103
  * Reheats the layout
104
- * @param {Object} fullData The entire graph object.
104
+ * @param fullData - The entire graph object.
105
105
  */
106
106
  reheat(fullData: {
107
107
  nodes: Node[];
@@ -109,17 +109,17 @@ export declare class PhysLayout {
109
109
  }): void;
110
110
  /**
111
111
  * Updates the existing nodes of a graph with a given list of updates
112
- * @param {Node[]} nodeList The list of updates.
112
+ * @param nodeList - The list of updates.
113
113
  */
114
114
  updateNodes(nodeList: Node[]): void;
115
115
  /**
116
116
  * Adds and removes nodes from the graph based on given updates
117
- * @param {Object} fullData The entire graph object.
118
- * @param {Array<Object>} fullData.nodes the nodes in the graph
119
- * @param {Array<Object>} fullData.rels the relationships in the graph
120
- * @param {Object} nodeChanges The changes in the graph.
121
- * @param {Array<Object>} nodeChanges.adds A list of nodes to be added.
122
- * @param {Array<Object>} nodeChanges.removes A list of nodes to be removed.
117
+ * @param fullData - The entire graph object.
118
+ * @param fullData.nodes - The nodes in the graph.
119
+ * @param fullData.rels - The relationships in the graph.
120
+ * @param nodeChanges - The changes in the graph.
121
+ * @param nodeChanges.adds - A list of nodes to be added.
122
+ * @param nodeChanges.removes - A list of nodes to be removed.
123
123
  */
124
124
  addRemoveData(fullData: {
125
125
  nodes: Node[];
@@ -137,11 +137,11 @@ export declare class PhysLayout {
137
137
  destroy(): void;
138
138
  /**
139
139
  * Takes the new flat key set of relationships and the current relationship changes
140
- * and checks whether removed relationships are still in the new flat key set
140
+ * and checks whether removed relationships are still in the new flat key set.
141
141
  * and whether added relationships were already in the old flat key set.
142
142
  * @param newFlatKeySet The new flat key set of relationships.
143
143
  * @param relationshipChanges The changes in the relationships.
144
- * @returns {boolean} Whether the relationship flat map has changed.
144
+ * @returns Whether the relationship flat map has changed.
145
145
  */
146
146
  private hasRelationshipFlatMapChanged;
147
147
  private dumpTexture;
@@ -17,21 +17,21 @@ export declare class CallbackHelper {
17
17
  constructor();
18
18
  /**
19
19
  * Register a callback function to be called when an event of that name happens
20
- * @param {string} name The name of the callback to register
21
- * @param {function} callback A function that will be called when an event of that name happens
20
+ * @param name - The name of the callback to register.
21
+ * @param callback - A function that will be called when an event of that name happens.
22
22
  * If other callbacks are already registered for that name it is added to the list
23
23
  */
24
24
  register(name: keyof ExternalCallbacks, callback: CallbackFunction): void;
25
25
  /**
26
26
  * Check if a callback function with that name is registered already
27
- * @param {string} name - The name of the callbacks to check
27
+ * @param name - The name of the callbacks to check.
28
28
  * @return {boolean} Whether or not a callback function with that name is registered
29
29
  */
30
30
  isCallbackRegistered(name: keyof ExternalCallbacks): boolean;
31
31
  /**
32
32
  * Call all callbacks registered for a given name
33
- * @param {string} name - The name of the callbacks to call
34
- * @param {object} data - Data to pass when calling the callbacks
33
+ * @param name - The name of the callbacks to call.
34
+ * @param data - Data to pass when calling the callbacks.
35
35
  */
36
36
  callIfRegistered(): void;
37
37
  }
@@ -13,9 +13,16 @@ export interface ExternalCallbacks {
13
13
  onInitialization?: () => void;
14
14
  /** Triggered when a asynchronous layout calculation starts/stops. */
15
15
  onLayoutComputing?: (isComputing: boolean) => void;
16
+ /**
17
+ * Triggered when the WebGL context is lost.
18
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/webglcontextlost_event}
19
+ */
16
20
  onWebGLContextLost?: (webGLContextEvent: WebGLContextEvent) => void;
17
21
  /** Triggered when a zoom transition (e.g. {@link NVL.fit} or {@link NVL.resetZoom}) function is done. */
18
22
  onZoomTransitionDone?: () => void;
23
+ /**
24
+ * Triggered when NVL is restarted.
25
+ */
19
26
  restart?: () => void;
20
27
  }
21
28
  export declare const isExternalCallback: (callback: unknown) => callback is keyof ExternalCallbacks;
@@ -27,6 +27,7 @@ export default class NvlController {
27
27
  private readonly gridLayout;
28
28
  private readonly freeLayout;
29
29
  private readonly d3ForceLayout;
30
+ private readonly circularLayout;
30
31
  private readonly forceLayout;
31
32
  private readonly canvasRenderer;
32
33
  private readonly glCanvas;
@@ -54,7 +55,7 @@ export default class NvlController {
54
55
  private layoutComputingCallback;
55
56
  private currentLayoutType;
56
57
  private descriptionElement;
57
- constructor(state: NvlState, options: NvlOptions);
58
+ constructor(state: NvlState, frame: HTMLElement, options: NvlOptions);
58
59
  private onWebGLContextLost;
59
60
  private updateMinimapZoom;
60
61
  private startMainLoop;
@@ -63,8 +64,8 @@ export default class NvlController {
63
64
  dumpRelationships(): Relationship[];
64
65
  /**
65
66
  * Map a relative Canvas space to the DOM position
66
- * @param {number} canvasX X position in the canvas space
67
- * @param {number} canvasY Y position position in the canvas space
67
+ * @param canvasX - X position in the canvas space.
68
+ * @param canvasY - Y position position in the canvas space.
68
69
  */
69
70
  mapCanvasSpaceToRelativePosition(canvasX: number, canvasY: number): {
70
71
  x: number;
@@ -72,8 +73,8 @@ export default class NvlController {
72
73
  };
73
74
  /**
74
75
  * Map a relative DOM position to the Canvas space
75
- * @param {*} clientX relative X position from the top left [0..rect.width]
76
- * @param {*} clientY relative Y position from the top left [0..rect.height]
76
+ * @param clientX - Relative X position from the top left [0..rect.width].
77
+ * @param clientY - Relative Y position from the top left [0..rect.height].
77
78
  */
78
79
  mapRelativePositionToCanvasSpace(clientX: number, clientY: number): {
79
80
  x: number;
@@ -32,6 +32,6 @@ export interface Channel<T> {
32
32
  export declare const getHtmlProperty: (item: Partial<Node | Relationship>) => HTMLElement | undefined;
33
33
  /**
34
34
  * Creates an empty dataset in which a graph be stored and updated using mobx actions.
35
- * @returns A new and empty {@link DataSet}
35
+ * @returns A new and empty {@link DataSet}.
36
36
  */
37
37
  export declare const createDataSet: <T extends Node | Relationship>() => DataSet<T>;
@@ -2,7 +2,7 @@ import type { NvlOptions, NvlState } from './types';
2
2
  /**
3
3
  * Create a new NVL state
4
4
  *
5
- * @param {NvlOptions} options - The options for the new state
6
- * @returns {NvlState} - The state object
5
+ * @param options - The options for the new state.
6
+ * @returns The state object.
7
7
  */
8
8
  export declare const createState: (options: NvlOptions) => NvlState;