@neo4j-nvl/base 0.3.5 → 0.3.6-02e96ab6

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 (48) hide show
  1. package/dist/base.mjs +1 -1
  2. package/dist/base.mjs.LICENSE.txt +11 -0
  3. package/dist/types/index.d.ts +8 -4
  4. package/dist/types/layouts/animatedlayout/AnimatedLayout.d.ts +1 -1
  5. package/dist/types/layouts/forcedirectedlayout/cosebilkentlayout/CoseBilkentLayout.d.ts +3 -3
  6. package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +1 -1
  7. package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.d.ts +1 -1
  8. package/dist/types/layouts/freeLayout/FreeLayout.d.ts +1 -1
  9. package/dist/types/layouts/gridLayout/GridLayout.d.ts +1 -1
  10. package/dist/types/layouts/hierarchicallayout/HierarchicalLayout.d.ts +2 -2
  11. package/dist/types/layouts/hierarchicallayout/constants.d.ts +1 -1
  12. package/dist/types/modules/ExternalCallbackHandler.d.ts +3 -0
  13. package/dist/types/modules/NvlController.d.ts +4 -2
  14. package/dist/types/modules/ZoomTransitionHandler.d.ts +3 -5
  15. package/dist/types/modules/performance.d.ts +2 -2
  16. package/dist/types/modules/state/constants.d.ts +9 -0
  17. package/dist/types/modules/state/state.d.ts +8 -0
  18. package/dist/types/modules/{state.d.ts → state/types.d.ts} +72 -16
  19. package/dist/types/modules/state/utils.d.ts +44 -0
  20. package/dist/types/modules/state/utils.test.d.ts +1 -0
  21. package/dist/types/renderers/canvasrenderer/CanvasRenderer.d.ts +2 -1
  22. package/dist/types/renderers/canvasrenderer/arrows/arrows.d.ts +8 -5
  23. package/dist/types/renderers/canvasrenderer/arrows/constants.d.ts +1 -6
  24. package/dist/types/renderers/canvasrenderer/nodes/nodes.d.ts +3 -2
  25. package/dist/types/renderers/canvasrenderer/util.d.ts +2 -2
  26. package/dist/types/renderers/canvasrenderer/wordwrap.d.ts +1 -1
  27. package/dist/types/renderers/webglrenderer/Controller.d.ts +1 -1
  28. package/dist/types/renderers/webglrenderer/Renderer.d.ts +1 -1
  29. package/dist/types/renderers/webglrenderer/node-fragment-point.d.ts +1 -1
  30. package/dist/types/renderers/webglrenderer/node-vertex-point.d.ts +1 -1
  31. package/dist/types/renderers/webglrenderer/viewport-box-fragment.d.ts +1 -1
  32. package/dist/types/renderers/webglrenderer/viewport-box-vertex.d.ts +1 -1
  33. package/dist/types/types/graph-element.d.ts +8 -2
  34. package/dist/types/utils/ariaUtils.d.ts +3 -0
  35. package/dist/types/utils/ariaUtils.test.d.ts +1 -0
  36. package/dist/types/utils/colorUtils.d.ts +14 -0
  37. package/dist/types/utils/colorUtils.test.d.ts +1 -0
  38. package/dist/types/utils/constants.d.ts +9 -2
  39. package/dist/types/utils/graphObjectUtils.d.ts +2 -1
  40. package/dist/types/utils/hittest.d.ts +1 -1
  41. package/dist/types/utils/jsDriverResultTransformer.d.ts +32 -0
  42. package/dist/types/utils/jsDriverResultTransformer.test.d.ts +1 -0
  43. package/dist/types/utils/webWorkerUtils.d.ts +3 -0
  44. package/dist/types/utils/webWorkerUtils.test.d.ts +1 -0
  45. package/dist/types/utils/zoomFunctions.d.ts +32 -1
  46. package/package.json +9 -4
  47. package/dist/types/utils/colorMapperFunctions.d.ts +0 -6
  48. /package/dist/types/modules/{state.test.d.ts → state/state.test.d.ts} +0 -0
@@ -1,5 +1,16 @@
1
+ /*!
2
+ * The buffer module from node.js, for the browser.
3
+ *
4
+ * @author Feross Aboukhadijeh <https://feross.org>
5
+ * @license MIT
6
+ */
7
+
8
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
9
+
1
10
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
2
11
 
12
+ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
13
+
3
14
  /**
4
15
  * @license
5
16
  * Lodash <https://lodash.com/>
@@ -1,12 +1,14 @@
1
1
  import type { ExternalCallbacks } from './modules/ExternalCallbackHandler';
2
- import type { ForceDirectedOptions, HierarchicalOptions, Layout, LayoutOptions, NvlOptions, NvlState, Renderer, ZoomOptions } from './modules/state';
3
- import { CanvasRendererType, ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, WebGLRendererType, d3ForceLayoutType } from './modules/state';
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';
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';
7
7
  import { CompatibilityError } from './utils/errors';
8
8
  import type { Point } from './utils/geometry';
9
9
  import type { HitTargetNode, HitTargetRelationship, HitTargets } from './utils/hittest';
10
+ import { nvlResultTransformer } from './utils/jsDriverResultTransformer';
11
+ import { getZoomTargetForNodePositions } from './utils/zoomFunctions';
10
12
  /**
11
13
  * Extends the MouseEvent interface with the {@link HitTargets} property.
12
14
  * The result of a _.{@link NVL.getHits} call.
@@ -185,7 +187,7 @@ declare class NVL {
185
187
  * the zoom level will be set to the closest valid zoom level,
186
188
  * even if the given nodes do not fit the viewport yet.
187
189
  */
188
- fit(nodeIds: string[], zoomOptions: NvlState['zoomOptions']): void;
190
+ fit(nodeIds: string[], zoomOptions?: NvlState['zoomOptions']): void;
189
191
  /**
190
192
  * Resets the zoom of the viewport back to the default zoom level of 0.75
191
193
  */
@@ -248,6 +250,8 @@ declare class NVL {
248
250
  * @param {Node[]} data The positions that the nodes should be set to.
249
251
  * @param {boolean} updateLayout whether or not the current layout algorithm
250
252
  * should update the graph after setting the node positions.
253
+ * For node positions to be unaffected by layout algorithms, use the {@link FreeLayoutType}
254
+ * or use {@link pinNode} to pin the nodes that should remain still.
251
255
  * False by default.
252
256
  */
253
257
  setNodePositions(data: Node[], updateLayout?: boolean): void;
@@ -363,4 +367,4 @@ declare const colorMapperFunctions: {
363
367
  };
364
368
  export default NVL;
365
369
  export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions, StyledCaption, WebGLRendererType, CanvasRendererType };
366
- export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, drawCircleBand };
370
+ export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, drawCircleBand, nvlResultTransformer, getZoomTargetForNodePositions };
@@ -1,4 +1,4 @@
1
- import type { NvlState } from '../../modules/state';
1
+ import type { NvlState } from '../../modules/state/types';
2
2
  import type { Node } from '../../types/graph-element';
3
3
  export default class AnimatedLayout {
4
4
  positions: Record<string, Node>;
@@ -1,4 +1,4 @@
1
- import type { NvlState } from '../../../modules/state';
1
+ import type { NvlState } from '../../../modules/state/types';
2
2
  import type { Node, Relationship } from '../../../types/graph-element';
3
3
  import AnimatedLayout from '../../animatedlayout/AnimatedLayout';
4
4
  type LayoutData = {
@@ -15,13 +15,13 @@ export declare class CoseBilkentLayout extends AnimatedLayout {
15
15
  cytoCompleteCallback: () => void;
16
16
  computing: boolean;
17
17
  pendingLayoutData: LayoutData;
18
- worker: SharedWorker | any;
18
+ worker: SharedWorker;
19
+ private workersDisabled;
19
20
  constructor(config: {
20
21
  state: NvlState;
21
22
  cytoCompleteCallback?: () => void;
22
23
  animationCompleteCallback?: () => void;
23
24
  });
24
- setupWorker(): Promise<unknown>;
25
25
  setOptions(): void;
26
26
  update(refreshPositions?: boolean, updateMobXNodes?: Node[], updateMobXRelationships?: Relationship[]): void;
27
27
  getShouldUpdate(): boolean;
@@ -1,4 +1,4 @@
1
- import type { ForceDirectedOptions, NvlState } from '../../../modules/state';
1
+ import type { ForceDirectedOptions, NvlState } from '../../../modules/state/types';
2
2
  import type { Node, Relationship } from '../../../types/graph-element';
3
3
  import type { Point } from '../../../utils/geometry';
4
4
  export declare class PhysLayout {
@@ -19,7 +19,7 @@ export default class SolarMerger {
19
19
  idToRel: {};
20
20
  };
21
21
  nodeSortMap: {};
22
- coarsenBy(level: any): {
22
+ coarsenBy(levelToCoarsenBy: any): {
23
23
  nodes: any[];
24
24
  relationships: any[];
25
25
  idToRel: {};
@@ -1,4 +1,4 @@
1
- import type { NvlState } from '../../modules/state';
1
+ import type { NvlState } from '../../modules/state/types';
2
2
  import type { Node } from '../../types/graph-element';
3
3
  import type { Point } from '../../utils/geometry';
4
4
  export declare class FreeLayout {
@@ -7,7 +7,7 @@ export class GridLayout {
7
7
  setOptions(options: any): void;
8
8
  updateNodes(positionList: any): void;
9
9
  update(refreshPositions?: boolean): void;
10
- layout(nodes: any, nodeIds: any, idToPosition: any, rels: any): void;
10
+ layout(mobxNodes: any, nodeIds: any, idToPosition: any, rels: any): void;
11
11
  getNodePositions(nodeList: any): any[];
12
12
  getShouldUpdate(): boolean;
13
13
  getComputing(): boolean;
@@ -1,4 +1,4 @@
1
- import { type HierarchicalOptions, type LayoutOptions, type NvlState } from '../../modules/state';
1
+ import { type HierarchicalOptions, type LayoutOptions, type NvlState } from '../../modules/state/types';
2
2
  import AnimatedLayout from '../animatedlayout/AnimatedLayout';
3
3
  type HierarchicalLayoutConfig = {
4
4
  state: NvlState;
@@ -14,8 +14,8 @@ export declare class HierarchicalLayout extends AnimatedLayout {
14
14
  private worker;
15
15
  private directionChanged;
16
16
  private packingChanged;
17
+ private workersDisabled;
17
18
  constructor(config: HierarchicalLayoutConfig);
18
- setupWorker(): Promise<unknown>;
19
19
  setOptions(options: LayoutOptions): void;
20
20
  update(refreshPositions?: boolean): void;
21
21
  getShouldUpdate(): boolean;
@@ -1,4 +1,4 @@
1
- import type { HierarchicalOptions } from '../../modules/state';
1
+ import type { HierarchicalOptions } from '../../modules/state/types';
2
2
  export declare const Ranker = "tight-tree";
3
3
  export declare const SubGraphSpacing = 100;
4
4
  export declare const DirectionUp = "up";
@@ -12,12 +12,15 @@ export interface ExternalCallbacks {
12
12
  /** Triggered when a asynchronous layout calculation starts/stops. */
13
13
  onLayoutComputing?: (isComputing: boolean) => void;
14
14
  onWebGLContextLost?: (webGLContextEvent: WebGLContextEvent) => void;
15
+ /** Triggered when a zoom transition (e.g. {@link NVL.fit} or {@link NVL.resetZoom}) function is done. */
16
+ onZoomTransitionDone?: () => void;
15
17
  restart?: () => void;
16
18
  }
17
19
  export declare const isExternalCallback: (callback: unknown) => callback is keyof ExternalCallbacks;
18
20
  export default class ExternalCallbackHandler {
19
21
  callbacks: ExternalCallbacks;
20
22
  constructor(externalCallbacks?: ExternalCallbacks);
23
+ onZoomTransitionDone(): void;
21
24
  onLayoutDone(): void;
22
25
  onLayoutStep(p: Node[]): void;
23
26
  onLayoutComputing(isComputing: boolean): void;
@@ -2,12 +2,13 @@ import type { Node, Relationship } from '../types/graph-element';
2
2
  import '../types/nvl-window-functions';
3
3
  import type { Point } from '../utils/geometry';
4
4
  import type { ExternalCallbacks } from './ExternalCallbackHandler';
5
- import type { Layout, LayoutOptions, NvlOptions, NvlState, ZoomOptions } from './state';
5
+ import type { Layout, LayoutOptions, NvlOptions, NvlState, ZoomOptions } from './state/types';
6
6
  type SaveToFileOptions = {
7
7
  filename?: string;
8
8
  backgroundColor?: string;
9
9
  };
10
10
  export declare const EVENT_ERROR = "onError";
11
+ export declare const EVENT_ZOOM_TRANSITION_DONE = "onZoomTransitionDone";
11
12
  export declare const EVENT_LAYOUT_DONE = "onLayoutDone";
12
13
  export declare const EVENT_LAYOUT_STEP = "onLayoutStep";
13
14
  export declare const EVENT_LAYOUT_COMPUTING = "onLayoutComputing";
@@ -52,6 +53,7 @@ export default class NvlController {
52
53
  private layoutDoneCallback;
53
54
  private layoutComputingCallback;
54
55
  private currentLayoutType;
56
+ private descriptionElement;
55
57
  constructor(state: NvlState, options: NvlOptions);
56
58
  private onWebGLContextLost;
57
59
  private updateMinimapZoom;
@@ -95,7 +97,7 @@ export default class NvlController {
95
97
  setZoomLevel(_newLevel: number): void;
96
98
  setPanCoordinates(panX: number, panY: number): void;
97
99
  setZoomAndPan(zoom: number, panX: number, panY: number): void;
98
- fit(nodeIds: string[], zoomOptions: ZoomOptions): void;
100
+ fit(nodeIds: string[], zoomOptions?: ZoomOptions): void;
99
101
  resetZoom(): void;
100
102
  setRenderer(renderer: string): void;
101
103
  on(name: keyof ExternalCallbacks, callback: (args: unknown) => void): void;
@@ -1,6 +1,6 @@
1
1
  import PIDController from 'node-pid-controller';
2
2
  import type { Node } from '../types/graph-element';
3
- import type { NvlState } from './state';
3
+ import type { NvlState } from './state/types';
4
4
  export default class ZoomTransitionHandler {
5
5
  xCtrl: PIDController;
6
6
  yCtrl: PIDController;
@@ -9,16 +9,14 @@ export default class ZoomTransitionHandler {
9
9
  private firstUpdate;
10
10
  private readonly state;
11
11
  private readonly canvas;
12
- private readonly defaultZoomLevel;
13
12
  private readonly stateDisposers;
14
- constructor({ state, getNodePositions, canvas, defaultZoomLevel }: {
13
+ constructor({ state, getNodePositions, canvas }: {
15
14
  state: NvlState;
16
15
  getNodePositions: (data: Node[]) => Node[];
17
16
  canvas: HTMLCanvasElement;
18
- defaultZoomLevel: number;
19
17
  });
20
18
  needsToRun(): boolean;
21
- update(layoutActive: boolean): void;
19
+ update(layoutActive: boolean, onTransitionCompleted?: () => void): void;
22
20
  destroy(): void;
23
21
  private recalculateTarget;
24
22
  private allNodesAreVisible;
@@ -13,10 +13,10 @@ export default class PerformanceTester {
13
13
  /**
14
14
  * Starts a performance measurement. Every call to this method must be followed
15
15
  * by a call to endTest(). Tests can be nested.
16
- * @param {String} name String identifying this measurement. Only used for printing, so
16
+ * @param {String} measurement String identifying this measurement. Only used for printing, so
17
17
  * keep it human readable.
18
18
  */
19
- startTest(name: string): void;
19
+ startTest(measurement: string): void;
20
20
  /**
21
21
  * Ends the last started test, giving it an end time.
22
22
  */
@@ -0,0 +1,9 @@
1
+ import type { BorderStyles, NvlState } from './types';
2
+ export declare const NodeBorderStyles: BorderStyles;
3
+ export declare const RelationshipBorderStyles: BorderStyles;
4
+ export declare const DefaultZoomLevel = 0.75;
5
+ export declare const DefaultMaxZoom = 10;
6
+ export declare const DefaultMinZoom = 0.075;
7
+ export declare const DefaultMinimapMaxZoom = 0.2;
8
+ export declare const DefaultMinimapMinZoom = 0;
9
+ export declare const DefaultZoomOptions: NvlState['zoomOptions'];
@@ -0,0 +1,8 @@
1
+ import type { NvlOptions, NvlState } from './types';
2
+ /**
3
+ * Create a new NVL state
4
+ *
5
+ * @param {NvlOptions} options - The options for the new state
6
+ * @returns {NvlState} - The state object
7
+ */
8
+ export declare const createState: (options: NvlOptions) => NvlState;
@@ -1,7 +1,7 @@
1
1
  import type { LogLevelDesc } from 'loglevel';
2
- import type { WaypointPath } from '../renderers/canvasrenderer/types';
3
- import type { ExternalCallbacks } from './ExternalCallbackHandler';
4
- import type { NodeDataSet, RelationshipDataSet } from './dataset';
2
+ import type { WaypointPath } from '../../renderers/canvasrenderer/types';
3
+ import type { ExternalCallbacks } from '../ExternalCallbackHandler';
4
+ import type { NodeDataSet, RelationshipDataSet } from '../dataset';
5
5
  type RingStyle = {
6
6
  width?: number;
7
7
  widthFactor?: number;
@@ -23,9 +23,13 @@ export type BorderStyles = {
23
23
  selected: BorderStyle;
24
24
  default: BorderStyle;
25
25
  };
26
- export declare const RelationshipBorderStyles: BorderStyles;
27
- /** The default zoom level in a graph when not specified otherwise. */
28
- export declare const DefaultZoomLevel = 0.75;
26
+ /**
27
+ * @internal
28
+ */
29
+ export type DisabledItemStyles = {
30
+ color: string;
31
+ fontColor: string;
32
+ };
29
33
  /**
30
34
  * The options for the force directed layout
31
35
  */
@@ -130,7 +134,12 @@ export interface NvlOptions {
130
134
  * The DOM element in which to render the graph visualization
131
135
  */
132
136
  frame?: HTMLElement;
133
- /** The DOM container in which to render the minimap */
137
+ /**
138
+ * The DOM container in which to render the minimap.
139
+ *
140
+ * @note When using a React ref, make sure the attached element is rendered before the NVL instance is created.
141
+ * Otherwise, the minimap will not be displayed.
142
+ */
134
143
  minimapContainer?: HTMLElement;
135
144
  /** Configuration for the current layout */
136
145
  layoutOptions?: LayoutOptions;
@@ -171,10 +180,44 @@ export interface NvlOptions {
171
180
  */
172
181
  relationshipThreshold?: number;
173
182
  callbacks?: ExternalCallbacks;
174
- /** The color to use for the default border of nodes */
183
+ styling?: {
184
+ defaultNodeColor?: string;
185
+ defaultRelationshipColor?: string;
186
+ /** The color to use for the default border of nodes */
187
+ nodeDefaultBorderColor?: string;
188
+ /** The color to use for the selected border of nodes and relationships */
189
+ selectedBorderColor?: string;
190
+ /** The color to use for the selected inner border of nodes and relationships */
191
+ selectedInnerBorderColor?: string;
192
+ /** The color to use for the drop shadow of selected/hovered nodes and relationships */
193
+ dropShadowColor?: string;
194
+ /** The color to use for the disabled nodes and relationships */
195
+ disabledItemColor?: string;
196
+ /** The color to use for the labels of the disabled nodes and relationships */
197
+ disabledItemFontColor?: string;
198
+ /** The color to use for the viewport box in the minimap */
199
+ minimapViewportBoxColor?: string;
200
+ };
201
+ /**
202
+ * The color to use for the default border of nodes
203
+ * @deprecated Use {@link styling.nodeDefaultBorderColor} instead
204
+ */
175
205
  nodeDefaultBorderColor?: string;
176
- /** The color to use for the selected border of nodes */
206
+ /**
207
+ * The color to use for the selected border of nodes
208
+ * @deprecated Use {@link styling.selectedBorderColor} instead
209
+ */
177
210
  selectedBorderColor?: string;
211
+ /**
212
+ * The color to use for the disabled nodes and relationships
213
+ * @deprecated Use {@link styling.disabledItemColor} instead
214
+ */
215
+ disabledItemColor?: string;
216
+ /**
217
+ * The color to use for the labels of the disabled nodes and relationships
218
+ * @deprecated Use {@link styling.disabledItemFontColor} instead
219
+ */
220
+ disabledItemFontColor?: string;
178
221
  /**
179
222
  * @internal
180
223
  * Defines a time limit for how long layout iterations may run
@@ -185,6 +228,19 @@ export interface NvlOptions {
185
228
  * @defaultValue false
186
229
  */
187
230
  disableTelemetry?: boolean;
231
+ /**
232
+ * Disables the use of {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers | web workers} for the layout calculations.
233
+ */
234
+ disableWebWorkers?: boolean;
235
+ /**
236
+ * Disables {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA | ARIA} attributes on the graph.
237
+ * By default, NVL adds ARIA attributes to the graph container to make it more accessible.
238
+ * Attributes include `role="image"`, `aria-label="Graph visualization"`
239
+ * and `aria-describedby="nvl-${instanceId}-description"`.
240
+ * The description element is a live region that will announce changes to the graph.
241
+ * @defaultValue false
242
+ */
243
+ disableAria?: boolean;
188
244
  }
189
245
  /** Options that influence how fit-to-zoom should behave */
190
246
  export type ZoomOptions = {
@@ -196,6 +252,8 @@ export type ZoomOptions = {
196
252
  minZoom?: number;
197
253
  /** The maximum zoom value for the fit-to-zoom operation. */
198
254
  maxZoom?: number;
255
+ /** If true, will not animate the zoom/pan transition. */
256
+ animated?: boolean;
199
257
  };
200
258
  export interface NvlState {
201
259
  zoom: number;
@@ -212,6 +270,7 @@ export interface NvlState {
212
270
  webGLVisible: boolean;
213
271
  renderer: Renderer;
214
272
  disableWebGL: boolean;
273
+ disableWebWorkers: boolean;
215
274
  disableTelemetry: boolean;
216
275
  fitMovement: number;
217
276
  layout: Layout;
@@ -247,12 +306,9 @@ export interface NvlState {
247
306
  reaction: Function;
248
307
  nodeBorderStyles: BorderStyles;
249
308
  relationshipBorderStyles: BorderStyles;
309
+ disabledItemStyles: DisabledItemStyles;
310
+ defaultNodeColor: string;
311
+ defaultRelationshipColor: string;
312
+ minimapViewportBoxColor: string;
250
313
  }
251
- /**
252
- * Create a new NVL state
253
- *
254
- * @param {NvlOptions} options - The options for the new state
255
- * @returns {NvlState} - The state object
256
- */
257
- export declare const createState: (options: NvlOptions) => NvlState;
258
314
  export {};
@@ -0,0 +1,44 @@
1
+ import type { NvlOptions } from './types';
2
+ export declare const processColorStyles: (styling: NvlOptions['styling'], { legacyNodeDefaultBorderColor, legacySelectedBorderColor, legacyDisabledItemColor, legacyDisabledItemFontColor }: {
3
+ legacyNodeDefaultBorderColor?: string;
4
+ legacySelectedBorderColor?: string;
5
+ legacyDisabledItemColor?: string;
6
+ legacyDisabledItemFontColor?: string;
7
+ }) => {
8
+ nodeBorderStyles: {
9
+ default: {
10
+ rings?: {
11
+ width?: number;
12
+ widthFactor?: number;
13
+ color: string;
14
+ }[];
15
+ shadow?: import("./types").ShadowStyle;
16
+ };
17
+ selected: {
18
+ rings?: {
19
+ width?: number;
20
+ widthFactor?: number;
21
+ color: string;
22
+ }[];
23
+ shadow?: import("./types").ShadowStyle;
24
+ };
25
+ };
26
+ relationshipBorderStyles: {
27
+ default: import("./types").BorderStyle;
28
+ selected: {
29
+ rings?: {
30
+ width?: number;
31
+ widthFactor?: number;
32
+ color: string;
33
+ }[];
34
+ shadow?: import("./types").ShadowStyle;
35
+ };
36
+ };
37
+ disabledItemStyles: {
38
+ color: string;
39
+ fontColor: string;
40
+ };
41
+ defaultNodeColor: string;
42
+ defaultRelationshipColor: string;
43
+ minimapViewportBoxColor: string;
44
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { NvlState } from '../../modules/state';
1
+ import type { NvlState } from '../../modules/state/types';
2
2
  import type { Node } from '../../types/graph-element';
3
3
  import type { Point } from '../../utils/geometry';
4
4
  import type { HitTargetNode, HitTargetRelationship } from '../../utils/hittest';
@@ -17,6 +17,7 @@ export default class CanvasRenderer {
17
17
  private nodeVersion;
18
18
  private relVersion;
19
19
  private waypointVersion;
20
+ private ellipsisWidth;
20
21
  /**
21
22
  * Creates a new CanvasRenderer.
22
23
  * @param canvas {HTMLCanvasElement} - The canvas to render on.
@@ -1,4 +1,4 @@
1
- import type { BorderStyle } from '../../../modules/state';
1
+ import type { BorderStyle, DisabledItemStyles } from '../../../modules/state/types';
2
2
  import type { Node, Relationship } from '../../../types/graph-element';
3
3
  import type { Point } from '../../../utils/geometry';
4
4
  import type ImageCache from '../ImageCache';
@@ -32,12 +32,15 @@ export declare const getPointsForStraight: (rel: Relationship, bundle: ArrowBund
32
32
  * @param {number} angle - the angle of the label
33
33
  * @param {number} maxWidth - the maximum width of the label
34
34
  * @param {Relationship} rel - the relationship
35
+ * @param {ArrowBundle} bundle - the arrow bundle
36
+ * @param {DisabledItemStyles} disabledItemStyles - the styles for disabled items
37
+ * @param {string} fontColor - the color of the font
35
38
  * @param {boolean} flip - whether to flip the label
36
39
  */
37
- export declare const drawLabel: (ctx: CanvasRenderingContext2D, point: Point, angle: number, maxWidth: number, rel: Relationship, bundle: ArrowBundle, flip?: boolean) => void;
38
- export declare const renderWaypointArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, from: Node, to: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, drawCurves: boolean, selectedBorderStyle: BorderStyle) => void;
39
- export declare const renderSelfArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, node: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, selectedBorderStyle: BorderStyle) => void;
40
- export declare const renderArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, fromNode: Node, toNode: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, selectedBorderStyle: BorderStyle, drawCurves?: boolean) => void;
40
+ export declare const drawLabel: (ctx: CanvasRenderingContext2D, point: Point, angle: number, maxWidth: number, rel: Relationship, bundle: ArrowBundle, disabledItemStyles: DisabledItemStyles, fontColor: string, flip?: boolean) => void;
41
+ export declare const renderWaypointArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, from: Node, to: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, drawCurves: boolean, selectedBorderStyle: BorderStyle, disabledItemStyles: DisabledItemStyles, defaultRelationshipColor?: string) => void;
42
+ export declare const renderSelfArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, node: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, selectedBorderStyle: BorderStyle, disabledItemStyles: DisabledItemStyles, defaultRelationshipColor?: string) => void;
43
+ export declare const renderArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, fromNode: Node, toNode: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, selectedBorderStyle: BorderStyle, disabledItemStyles: DisabledItemStyles, defaultRelationshipColor: string, drawCurves?: boolean) => void;
41
44
  export declare const distanceToEdge: (pos: Point, rel: Relationship, fromNode: Node, toNode: Node, bundle: ArrowBundle, showLabel: boolean, drawCurves?: boolean) => number;
42
45
  /**
43
46
  * Returns the bounding box of the arrow.
@@ -9,7 +9,7 @@ export declare const HeadHeight = 9;
9
9
  /** The chin height of arrows. */
10
10
  export declare const HeadChinHeight = 2;
11
11
  /** The default color of relationships. */
12
- export declare const RelColor = "#848484";
12
+ export declare const RelColor = "#818790";
13
13
  /** The length of the curve of a curved relationship. */
14
14
  export declare const TaperRelLength = 30;
15
15
  /** The distance of the starting points of relationships in a bundle. */
@@ -28,11 +28,6 @@ export declare const SelfRefHeight = 35;
28
28
  export declare const SelfRefLabelMaxWidth = 40;
29
29
  /** Width increase when a relationship is selected. */
30
30
  export declare const SelectedWidthFactor = 1.5;
31
- /** The style properties of a disabled relationship. */
32
- export declare const Disabled: {
33
- color: string;
34
- fontColor: string;
35
- };
36
31
  /** The font styles for relationship captions. */
37
32
  export declare const Font: {
38
33
  size: number;
@@ -1,4 +1,4 @@
1
- import type { BorderStyles } from '../../../modules/state';
1
+ import type { BorderStyles, DisabledItemStyles } from '../../../modules/state/types';
2
2
  import type { Node } from '../../../types/graph-element';
3
3
  import type AnimationHandler from '../AnimationHandler';
4
4
  type RingStyle = {
@@ -52,7 +52,8 @@ export declare const findMinLength: (lines: any[], ctx: CanvasRenderingContext2D
52
52
  * @param imageCache {any} - The image cache to use.
53
53
  * @param animationHandler {AnimationHandler} - The animation handler.
54
54
  * @param nodeBorderStyles {BorderStyles} - The node border styles.
55
+ * @param disabledItemStyles {DisabledItemStyles} - The styles for the disabled items.
55
56
  * @param zoomLevel {number} - The current zoom level.
56
57
  */
57
- export declare const drawNode: (ctx: CanvasRenderingContext2D, node: Node, imageCache: any, animationHandler: AnimationHandler, nodeBorderStyles: BorderStyles, zoomLevel?: number) => void;
58
+ export declare const drawNode: (ctx: CanvasRenderingContext2D, node: Node, imageCache: any, animationHandler: AnimationHandler, nodeBorderStyles: BorderStyles, disabledItemStyles: DisabledItemStyles, defaultNodeColor?: string, ellipsisWidth?: number, zoomLevel?: number) => void;
58
59
  export {};
@@ -1,6 +1,6 @@
1
1
  import type { Point } from '../../utils/geometry';
2
2
  import type { TextSegment } from './types';
3
- export declare const fontThresholds: number[][];
3
+ export declare const fontThresholds: [number, number][];
4
4
  /**
5
5
  * This function takes color in hex format or rgb() or rgba() format and overrides the opacity. Returns rgba() string.
6
6
  * @param {string} color
@@ -65,5 +65,5 @@ export declare function getIndividualInfoLevels(r: number, zoomLevel: number): {
65
65
  /**
66
66
  * Prints the caption for a node
67
67
  */
68
- export declare const drawNodeCaption: (ctx: CanvasRenderingContext2D, lines: TextSegment[], stylesPerChar: string[][], initialYPos: number, fontSize: number, fontFace: string, lineDistance: number, x: number, y: number) => void;
68
+ export declare const drawNodeCaption: (ctx: CanvasRenderingContext2D, lines: TextSegment[], stylesPerChar: string[][], initialYPos: number, fontSize: number, fontFace: string, lineDistance: number, x: number, y: number, ellipsisWidth: number) => void;
69
69
  export {};
@@ -30,7 +30,7 @@ export declare const tryBreakingOnSpaces: (text: string, measureWidth: (text: st
30
30
  *
31
31
  * @return array of text lines
32
32
  */
33
- export declare const getLines: (ctx: CanvasRenderingContext2D, text: string, fontFace: string, fontSize: string | number, maxWidth: number, hasIcon: boolean, fontInfoLevel: number, align: string) => TextSegment[];
33
+ export declare const getLines: (ctx: CanvasRenderingContext2D, text: string, fontFace: string, fontSize: string | number, maxWidth: number, hasIcon: boolean, maxNoLines: number, align: string) => TextSegment[];
34
34
  /**
35
35
  * Returns the styles by char for a group of property values
36
36
  * @param {array} captions = array of captions
@@ -1,6 +1,6 @@
1
1
  import type { Node, Relationship } from '../../index';
2
2
  import type { DataSet } from '../../modules/dataset';
3
- import type { NvlState } from '../../modules/state';
3
+ import type { NvlState } from '../../modules/state/types';
4
4
  import type Renderer from './Renderer';
5
5
  export interface ControllerInterface {
6
6
  mainSceneRenderer: Renderer;
@@ -1,6 +1,6 @@
1
1
  import { mat4 } from 'gl-matrix';
2
2
  import type { DataSet } from '../../modules/dataset';
3
- import type { NvlState } from '../../modules/state';
3
+ import type { NvlState } from '../../modules/state/types';
4
4
  import type { Node, Relationship } from '../../types/graph-element';
5
5
  export default class Renderer {
6
6
  private readonly nodeShader;
@@ -1,2 +1,2 @@
1
- declare const _default: "uniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\n\nvarying lowp vec4 color;\nvarying lowp float drawDefaultBorder;\nvarying lowp vec3 nodeBorderColor;\nvarying lowp vec3 selectedBorderColor;\nvarying lowp float selected;\nvarying lowp float hovered;\nvarying lowp float varNodeSize;\n\nmediump float circleSize = 0.40;\nmediump float ringSize = 0.43;\nmediump float ringSize2 = 0.47;\nmediump float shadowSize = 0.51;\nlowp vec3 shadowColor = vec3(0.73);\nlowp vec3 lineColor = vec3(1.0);\n\nlowp float getShadowAlpha(lowp float size, lowp float dist) {\n return (1.0 - smoothstep(size, shadowSize, dist)) * 0.25;\n}\n\nlowp float getCircleAlpha(lowp float ringSize, lowp float nodeSize, lowp float dist) {\n return color.w - smoothstep(ringSize - nodeSize, ringSize, dist);\n}\n\nvoid main() {\n lowp float dist = distance(gl_PointCoord, vec2(0.5));\n\n if (dist > 0.51) {\n discard;\n }\n else {\n lowp float nodeSize = 1.0 / varNodeSize;\n lowp float nodeAlpha = getCircleAlpha(circleSize, nodeSize, dist);\n lowp float ringAlpha = getCircleAlpha(ringSize, nodeSize, dist);\n lowp vec3 finalColor = color.xyz;\n lowp float finalAlpha = nodeAlpha;\n\n if (selected > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(ringSize2, dist);\n lowp float ringAlpha2 = getCircleAlpha(ringSize2, nodeSize, dist);\n\n finalColor = mix(lineColor, finalColor, nodeAlpha);\n finalColor = mix(selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(ringAlpha, ringAlpha2)));\n } else if (hovered > 0.0) {\n if (drawDefaultBorder > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(ringSize, dist);\n \n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, ringAlpha));\n } else {\n lowp float shadowAlpha = getShadowAlpha(circleSize, dist);\n\n finalColor = mix(shadowColor, finalColor, nodeAlpha);\n finalAlpha = max(shadowAlpha, nodeAlpha);\n }\n } else {\n if (drawDefaultBorder > 0.0) {\n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalAlpha = ringAlpha;\n }\n }\n gl_FragColor = vec4(finalColor, 1.0) * finalAlpha;\n }\n}\n";
1
+ declare const _default: "uniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\n\nvarying lowp vec4 color;\nvarying lowp float drawDefaultBorder;\nvarying lowp vec3 nodeBorderColor;\nvarying lowp vec3 selectedBorderColor;\nvarying lowp vec3 selectedInnerBorderColor;\nvarying lowp vec3 shadowColor;\nvarying lowp float selected;\nvarying lowp float hovered;\nvarying lowp float varNodeSize;\n\nmediump float circleSize = 0.40;\nmediump float defaultBoderSize = 0.42;\nmediump float innerSelectedRingSize = 0.43;\nmediump float outerSelectedRingSize = 0.47;\nmediump float shadowSize = 0.51;\n\nlowp float getShadowAlpha(lowp float size, lowp float dist) {\n return (1.0 - smoothstep(size, shadowSize, dist)) * 0.25;\n}\n\nlowp float getCircleAlpha(lowp float ringSize, lowp float nodeSize, lowp float dist) {\n return color.w - smoothstep(ringSize - nodeSize, ringSize, dist);\n}\n\nvoid main() {\n lowp float dist = distance(gl_PointCoord, vec2(0.5));\n\n if (dist > 0.51) {\n discard;\n }\n else {\n lowp float nodeSize = 1.0 / varNodeSize;\n lowp float nodeAlpha = getCircleAlpha(circleSize, nodeSize, dist);\n lowp float borderAlpha = getCircleAlpha(defaultBoderSize, nodeSize, dist);\n lowp float ringAlpha = getCircleAlpha(innerSelectedRingSize, nodeSize, dist);\n lowp vec3 finalColor = color.xyz;\n lowp float finalAlpha = nodeAlpha;\n\n if (selected > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(outerSelectedRingSize, dist);\n lowp float ringAlpha2 = getCircleAlpha(outerSelectedRingSize, nodeSize, dist);\n\n if (drawDefaultBorder > 0.0) {\n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(selectedInnerBorderColor, finalColor, borderAlpha);\n finalColor = mix(selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(borderAlpha, ringAlpha2)));\n } else {\n finalColor = mix(selectedInnerBorderColor, finalColor, nodeAlpha);\n finalColor = mix(selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(ringAlpha, ringAlpha2)));\n }\n } else if (hovered > 0.0) {\n if (drawDefaultBorder > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(defaultBoderSize, dist);\n \n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(shadowColor, finalColor, borderAlpha);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, ringAlpha));\n } else {\n lowp float shadowAlpha = getShadowAlpha(circleSize, dist);\n\n finalColor = mix(shadowColor, finalColor, nodeAlpha);\n finalAlpha = max(shadowAlpha, nodeAlpha);\n }\n } else {\n if (drawDefaultBorder > 0.0) {\n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalAlpha = borderAlpha;\n }\n }\n gl_FragColor = vec4(finalColor, 1.0) * finalAlpha;\n }\n}\n";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "uniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\nuniform lowp vec3 u_nodeBorderColor;\nuniform lowp vec3 u_selectedBorderColor;\nuniform lowp float u_drawDefaultBorder;\n\nattribute float a_size;\nattribute lowp vec2 a_index;\nattribute lowp vec4 a_color;\nattribute lowp float a_selected;\nattribute lowp float a_hovered;\n\nvarying lowp float window;\nvarying lowp vec4 color;\nvarying lowp float selected;\nvarying lowp float hovered;\nvarying lowp float varNodeSize;\nvarying lowp vec3 nodeBorderColor;\nvarying lowp vec3 selectedBorderColor;\nvarying lowp float drawDefaultBorder;\n\nlowp float MinNodeSize = 5.0;\n\nvoid main(void) {\n vec4 data = texture2D(u_positions, a_index);\n gl_Position = u_projection * vec4(data.xy, 0.0, 1.0);\n\n lowp float nodeSize = a_size * u_zoom * u_glAdjust;\n if (nodeSize < MinNodeSize) {\n gl_PointSize = MinNodeSize;\n varNodeSize = MinNodeSize;\n } else {\n gl_PointSize = nodeSize;\n varNodeSize = nodeSize;\n }\n\n color = a_color;\n selected = a_selected;\n hovered = a_hovered;\n nodeBorderColor = u_nodeBorderColor;\n selectedBorderColor = u_selectedBorderColor;\n drawDefaultBorder = u_drawDefaultBorder;\n}";
1
+ declare const _default: "uniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\nuniform lowp vec3 u_nodeBorderColor;\nuniform lowp vec3 u_selectedBorderColor;\nuniform lowp vec3 u_selectedInnerBorderColor;\nuniform lowp vec3 u_shadowColor;\nuniform lowp float u_drawDefaultBorder;\n\nattribute float a_size;\nattribute lowp vec2 a_index;\nattribute lowp vec4 a_color;\nattribute lowp float a_selected;\nattribute lowp float a_hovered;\n\nvarying lowp float window;\nvarying lowp vec4 color;\nvarying lowp float selected;\nvarying lowp float hovered;\nvarying lowp float varNodeSize;\nvarying lowp vec3 nodeBorderColor;\nvarying lowp vec3 selectedBorderColor;\nvarying lowp vec3 selectedInnerBorderColor;\nvarying lowp vec3 shadowColor;\nvarying lowp float drawDefaultBorder;\n\nlowp float MinNodeSize = 5.0;\n\nvoid main(void) {\n vec4 data = texture2D(u_positions, a_index);\n gl_Position = u_projection * vec4(data.xy, 0.0, 1.0);\n\n lowp float nodeSize = a_size * u_zoom * u_glAdjust;\n if (nodeSize < MinNodeSize) {\n gl_PointSize = MinNodeSize;\n varNodeSize = MinNodeSize;\n } else {\n gl_PointSize = nodeSize;\n varNodeSize = nodeSize;\n }\n\n color = a_color;\n selected = a_selected;\n hovered = a_hovered;\n nodeBorderColor = u_nodeBorderColor;\n selectedBorderColor = u_selectedBorderColor;\n selectedInnerBorderColor = u_selectedInnerBorderColor;\n shadowColor = u_shadowColor;\n drawDefaultBorder = u_drawDefaultBorder;\n}";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "void main(void) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n";
1
+ declare const _default: "\nvarying lowp vec4 minimapViewportBoxColor;\n\nvoid main(void) {\n gl_FragColor = minimapViewportBoxColor;\n}\n";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "attribute vec2 coordinates;\nuniform mat4 u_projection;\n\nvoid main(void) {\n gl_Position = u_projection * vec4(coordinates, 0.0, 1.0);\n}\n";
1
+ declare const _default: "\nattribute vec2 coordinates;\nuniform mat4 u_projection;\nuniform lowp vec4 u_minimapViewportBoxColor;\n\nvarying lowp vec4 minimapViewportBoxColor;\n\nvoid main(void) {\n gl_Position = u_projection * vec4(coordinates, 0.0, 1.0);\n minimapViewportBoxColor = u_minimapViewportBoxColor;\n}\n";
2
2
  export default _default;
@@ -65,9 +65,15 @@ interface Node extends GraphElement {
65
65
  size?: number;
66
66
  /** Whether or not the current node is pinned.*/
67
67
  pinned?: boolean;
68
- /** The x-coordinate for the position of the node.*/
68
+ /**
69
+ * @ignore
70
+ * The x-coordinate for the position of the node.
71
+ */
69
72
  x?: number;
70
- /** The y-coordinate for the position of the node.*/
73
+ /**
74
+ * @ignore
75
+ * The y-coordinate for the position of the node.
76
+ */
71
77
  y?: number;
72
78
  /** Whether or not the current node is activated.*/
73
79
  activated?: boolean;