@neo4j-nvl/base 0.3.8 → 0.3.9-1ef8ccc1

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.
@@ -7,7 +7,7 @@
7
7
 
8
8
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
9
9
 
10
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
10
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
11
11
 
12
12
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
13
13
 
@@ -37,6 +37,7 @@ interface NvlMouseEvent extends MouseEvent {
37
37
  */
38
38
  declare class NVL {
39
39
  #private;
40
+ readonly performance: any;
40
41
  /**
41
42
  * Creates a new NVL instance.
42
43
  * @param {HTMLElement} frame - The DOM element to display the graph in
@@ -267,10 +268,13 @@ declare class NVL {
267
268
  * @param {string} options.backgroundColor - The background color of the png file.
268
269
  * The size of the png file will be the size of the canvas in the DOM.
269
270
  */
270
- saveToFile(options: {
271
+ saveToFile(options?: {
271
272
  filename?: string;
272
273
  backgroundColor?: string;
273
274
  }): void;
275
+ getImageDataUrl(options?: {
276
+ backgroundColor?: string;
277
+ }): string;
274
278
  /**
275
279
  * Saves the entire graph visualization canvas as a png to the client.
276
280
  * @param {{ filename: string, backgroundColor: string }} options The filename and background color of the png.
@@ -279,17 +283,17 @@ declare class NVL {
279
283
  * The size of the png file will be as large as the entire graph at the default zoom level.
280
284
  * Can result in a very large file.
281
285
  */
282
- saveFullGraphToLargeFile(options: {
286
+ saveFullGraphToLargeFile(options?: {
283
287
  filename?: string;
284
288
  backgroundColor?: string;
285
289
  }): void;
286
290
  /**
287
291
  * Sets the zoom of the viewport to a specific value.
288
292
  * @param {number} absolute The desired zoom level.
289
- * When updating both the zoom level and pan coordinates,
293
+ * @note When updating both the zoom level and pan coordinates,
290
294
  * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan}
291
295
  * separately to avoid jittering.
292
- * If the zoom level is outside of the range provided by the
296
+ * @note If the zoom level is outside of the range provided by the
293
297
  * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
294
298
  * the zoom level will be set to the closest valid zoom level.
295
299
  * If {@link NvlOptions.allowDynamicMinZoom} is set to true,
@@ -300,9 +304,8 @@ declare class NVL {
300
304
  * Sets the zoom of the viewport to a specific value.
301
305
  * @param {number} panX The desired panX value.
302
306
  * @param {number} panY The desired panY value.
303
- * When updating both the zoom level and pan coordinates,
304
- * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan}
305
- * separately to avoid jittering.
307
+ * @note When updating both the zoom level and pan coordinates,
308
+ * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan} separately to avoid jittering.
306
309
  */
307
310
  setPan(panX: number, panY: number): void;
308
311
  /**
@@ -310,8 +313,8 @@ declare class NVL {
310
313
  * @param {number} zoom The desired zoom level.
311
314
  * @param {number} panX The desired panX value.
312
315
  * @param {number} panY The desired panY value.
313
- * When only updating the zoom level or pan coordinates, use {@link setZoom} or {@link setPan} instead.
314
- * If the zoom level is outside of the range provided by the
316
+ * @note When only updating zoom level or pan coordinates, use {@link setZoom} or {@link setPan} instead.
317
+ * @note If the zoom level is outside of the range provided by the
315
318
  * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
316
319
  * the zoom level will be set to the closest valid zoom level.
317
320
  * If {@link NvlOptions.allowDynamicMinZoom} is set to true,
@@ -25,6 +25,7 @@ export declare class PhysLayout {
25
25
  private force;
26
26
  private nodeIdToIndex;
27
27
  private nodeIndexToId;
28
+ private flatRelationshipKeys;
28
29
  private numNodes;
29
30
  private solarMerger;
30
31
  private subGraphs;
@@ -126,11 +127,23 @@ export declare class PhysLayout {
126
127
  }, nodeChanges: {
127
128
  adds: Record<string, Node>;
128
129
  removes: Record<string, Node>;
130
+ }, relationshipChanges: {
131
+ adds: Record<string, Relationship>;
132
+ removes: Record<string, Relationship>;
129
133
  }): any;
130
134
  /**
131
135
  * Destroys the class and all buffers and textures.
132
136
  */
133
137
  destroy(): void;
138
+ /**
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
141
+ * and whether added relationships were already in the old flat key set.
142
+ * @param newFlatKeySet The new flat key set of relationships.
143
+ * @param relationshipChanges The changes in the relationships.
144
+ * @returns {boolean} Whether the relationship flat map has changed.
145
+ */
146
+ private hasRelationshipFlatMapChanged;
134
147
  private dumpTexture;
135
148
  private getScaleNumber;
136
149
  private getBaseLength;
@@ -1,5 +1,5 @@
1
1
  import { type ExternalCallbacks } from './ExternalCallbackHandler';
2
- type CallbackFunction = ExternalCallbacks['onError'] | ExternalCallbacks['onLayoutComputing'] | ExternalCallbacks['onLayoutDone'] | ExternalCallbacks['onLayoutStep'];
2
+ type CallbackFunction = ExternalCallbacks[keyof ExternalCallbacks];
3
3
  /**
4
4
  * A class for registering and calling callbacks
5
5
  * @example
@@ -9,6 +9,8 @@ export interface ExternalCallbacks {
9
9
  onLayoutStep?: (p: Node[]) => void;
10
10
  /** Triggered when NVL throws an error after initialization. */
11
11
  onError?: (error: Error) => void;
12
+ /** Triggered when NVL is initialized. */
13
+ onInitialization?: () => void;
12
14
  /** Triggered when a asynchronous layout calculation starts/stops. */
13
15
  onLayoutComputing?: (isComputing: boolean) => void;
14
16
  onWebGLContextLost?: (webGLContextEvent: WebGLContextEvent) => void;
@@ -20,6 +22,7 @@ export declare const isExternalCallback: (callback: unknown) => callback is keyo
20
22
  export default class ExternalCallbackHandler {
21
23
  callbacks: ExternalCallbacks;
22
24
  constructor(externalCallbacks?: ExternalCallbacks);
25
+ onInitialization(): void;
23
26
  onZoomTransitionDone(): void;
24
27
  onLayoutDone(): void;
25
28
  onLayoutStep(p: Node[]): void;
@@ -109,9 +109,13 @@ export default class NvlController {
109
109
  private getLayout;
110
110
  setLayout(layoutType: Layout): void;
111
111
  setLayoutOptions(options: LayoutOptions): void;
112
- createDownloadLink(filename: string, canvas: HTMLCanvasElement): HTMLAnchorElement;
112
+ private getDataUrlForCanvas;
113
+ private initiateFileDownload;
114
+ private updateLayoutAndPositions;
113
115
  saveToFile(options: SaveToFileOptions): void;
114
- prepareLargeFileForDownload(options: SaveToFileOptions): Promise<unknown>;
116
+ getImageDataURL(options: SaveToFileOptions): string;
117
+ private prepareLargeFileForDownload;
118
+ private createCanvasAndRenderImage;
115
119
  saveFullGraphToLargeFile(options: SaveToFileOptions): Promise<void>;
116
120
  }
117
121
  export {};
@@ -12,9 +12,7 @@ export interface LabelGeometry {
12
12
  */
13
13
  export default class ArrowBundle {
14
14
  key: string;
15
- rels: {
16
- rel: Relationship;
17
- }[];
15
+ rels: Map<string, Relationship>;
18
16
  waypointPath: WaypointPath;
19
17
  readonly selfReferring: boolean;
20
18
  fromId: string;
@@ -33,6 +31,7 @@ export default class ArrowBundle {
33
31
  */
34
32
  insert(rel: Relationship): void;
35
33
  setLabelInfo(relId: string, labelInfo: LabelGeometry): void;
34
+ has({ id }: Relationship): boolean;
36
35
  /**
37
36
  * Remove an arrow from the bundle
38
37
  * @param {Relationship} rel - The arrow to remove
@@ -43,6 +42,7 @@ export default class ArrowBundle {
43
42
  * @returns {number} The size of the arrow bundle
44
43
  */
45
44
  size(): number;
45
+ relArray(): Relationship[];
46
46
  /**
47
47
  * Get the maximum font size of the arrows in the bundle
48
48
  * @returns {number} The maximum font size of the arrows in the bundle
@@ -17,7 +17,7 @@ export default class ArrowBundler {
17
17
  * @param {Record<string, Relationship>} removedRels - The removed relations
18
18
  * @param {Record<string, WaypointPath>} waypoints - The waypoints
19
19
  */
20
- updateData(addedRels: Record<string, Relationship>, removedRels: Record<string, Relationship>, waypoints: Record<string, WaypointPath>): void;
20
+ updateData(addedRels: Record<string, Relationship>, removedRels: Record<string, Relationship>, updatedRels: Record<string, Relationship>, waypoints: Record<string, WaypointPath>): void;
21
21
  /**
22
22
  * Updates the positions of the arrow bundles based on the provided `positionMap`.
23
23
  * @param positionMap A map of node IDs to positions.
@@ -26,7 +26,7 @@ export declare const tryWithNumberOfLines: (text: string, measureWidth: (text: s
26
26
  export declare const tryBreakingOnSpaces: (text: string, measureWidth: (text: string) => number, getAvailableWidth: (a: number, b: number) => number, numberOfLines: number) => TextSegment[];
27
27
  /**
28
28
  * @param {object} ctx = Canvas.2dContext
29
- * @param {object} text - The text to display
29
+ * @param {object} rtlAdjustedText - The text to display
30
30
  *
31
31
  * @return array of text lines
32
32
  */
@@ -3,6 +3,8 @@
3
3
  * @param canvas The canvas to fix the size of.
4
4
  *
5
5
  * Make sure canvas pixel buffer is 1 to 1 vs screen pixels
6
+ *
7
+ * @note If the parent element is not connected to the DOM, it will use the width and height from the style properties.
6
8
  */
7
9
  export declare const fitCanvasSizeToParent: (canvas: HTMLCanvasElement) => void;
8
10
  export declare const addWebGLContextLostListener: (canvas: HTMLCanvasElement, contextLostCallback?: (e: WebGLContextEvent) => void) => void;
@@ -11,6 +11,7 @@ export declare const DefaultNodeSize = 25;
11
11
  export declare const DefaultNodeColor = "#FFDF81";
12
12
  export declare const DefaultRelColor = "#818790";
13
13
  export declare const DefaultRelWidth = 1;
14
+ export declare const MaxFlatRelWidth = 20;
14
15
  export declare const DisabledItemColor = "#EDEDED";
15
16
  export declare const DisabledItemFontColor = "#DDDDDD";
16
17
  export declare const DefaultShadowColor = "#CFD1D4";
@@ -4,6 +4,8 @@ export type FlatRel = Omit<Relationship & {
4
4
  bundledRels: Omit<Relationship, 'from' | 'to'>[];
5
5
  key: string;
6
6
  }, 'id'>;
7
+ export declare const getRelItemKey: (from: Node['id'], to: Node['id']) => string;
8
+ export declare const relItemsToFlatKeySet: (relItems: Relationship[]) => Set<string>;
7
9
  /**
8
10
  * Flattens a list of relationships so only one relationship remains between two nodes.
9
11
  * Falls back to default rel color when relationships between two nodes have varying colors.
@@ -28,7 +28,7 @@ export declare abstract class AnalyticsFunction {
28
28
  /**
29
29
  * Track arbitrary event
30
30
  */
31
- abstract trackEvent(payload: AnalyticsTrackPayload): void;
31
+ abstract trackEvent(payload: AnalyticsTrackPayload): Promise<void>;
32
32
  }
33
33
  /**
34
34
  * Analytics adapter for Segment Analytics.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-nvl/base",
3
- "version": "0.3.8",
3
+ "version": "0.3.9-1ef8ccc1",
4
4
  "license": "SEE LICENSE IN 'LICENSE.txt'",
5
5
  "homepage": "https://neo4j.com/docs/nvl/current/",
6
6
  "description": "Base library for the Neo4j Visualization Library",
@@ -20,7 +20,8 @@
20
20
  ],
21
21
  "scripts": {
22
22
  "build": "yarn global:tsc && webpack",
23
- "watch": "concurrently 'tsc -w' 'webpack -w' -k -n 'tsc,webpack' -c 'cyan,magenta'",
23
+ "build:dev": "yarn global:tsc && webpack --mode development",
24
+ "watch": "concurrently 'tsc -w' 'webpack -w --mode development' -k -n 'tsc,webpack' -c 'cyan,magenta'",
24
25
  "test": "yarn global:jest",
25
26
  "eslint": "yarn global:eslint ./src/",
26
27
  "coverage": "yarn test --coverage --silent",
@@ -28,7 +29,7 @@
28
29
  "postpack": "rm LICENSE.txt && rm CHANGELOG.md"
29
30
  },
30
31
  "dependencies": {
31
- "@neo4j-nvl/layout-workers": "0.3.8",
32
+ "@neo4j-nvl/layout-workers": "0.3.9-1ef8ccc1",
32
33
  "@segment/analytics-next": "^1.70.0",
33
34
  "color-string": "^1.9.1",
34
35
  "d3-force": "^3.0.0",
@@ -43,6 +44,7 @@
43
44
  "uuid": "^8.3.2"
44
45
  },
45
46
  "devDependencies": {
47
+ "@babel/core": "^7.21.4",
46
48
  "@types/color-string": "^1.5.5",
47
49
  "@types/d3-force": "^3.0.3",
48
50
  "@types/lodash": "4.14.202",
@@ -51,11 +53,11 @@
51
53
  "babel-loader": "^8.2.5",
52
54
  "copy-webpack-plugin": "^11.0.0",
53
55
  "neo4j-driver": "^5.26.0",
54
- "typedoc": "^0.23.15",
55
56
  "webpack": "^5.75.0",
56
57
  "webpack-cli": "^5.0.0"
57
58
  },
58
59
  "peerDependencies": {
59
60
  "neo4j-driver": "*"
60
- }
61
+ },
62
+ "stableVersion": "0.3.9"
61
63
  }