@neo4j-nvl/base 0.3.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/base.mjs +1 -1
- package/dist/types/index.d.ts +85 -72
- package/dist/types/layouts/animatedlayout/animationUtils.d.ts +3 -3
- package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +19 -19
- package/dist/types/modules/CallbackHelper.d.ts +5 -5
- package/dist/types/modules/ExternalCallbackHandler.d.ts +7 -0
- package/dist/types/modules/NvlController.d.ts +5 -5
- package/dist/types/modules/dataset.d.ts +1 -1
- package/dist/types/modules/state/state.d.ts +2 -2
- package/dist/types/modules/state/types.d.ts +43 -52
- package/dist/types/modules/state/utils.d.ts +8 -6
- package/dist/types/renderers/canvasrenderer/Animation.d.ts +8 -11
- package/dist/types/renderers/canvasrenderer/AnimationHandler.d.ts +15 -16
- package/dist/types/renderers/canvasrenderer/CanvasRenderer.d.ts +10 -10
- package/dist/types/renderers/canvasrenderer/arrows/ArrowBundle.d.ts +15 -15
- package/dist/types/renderers/canvasrenderer/arrows/ArrowBundler.d.ts +8 -8
- package/dist/types/renderers/canvasrenderer/arrows/arrows.d.ts +26 -26
- package/dist/types/renderers/canvasrenderer/nodes/nodes.d.ts +9 -9
- package/dist/types/renderers/canvasrenderer/types.d.ts +6 -4
- package/dist/types/renderers/canvasrenderer/util.d.ts +20 -21
- package/dist/types/renderers/canvasrenderer/wordwrap.d.ts +13 -13
- package/dist/types/types/graph-element.d.ts +15 -6
- package/dist/types/utils/canvasManagement.d.ts +2 -1
- package/dist/types/utils/colorUtils.d.ts +3 -3
- package/dist/types/utils/constants.d.ts +3 -3
- package/dist/types/utils/errors.d.ts +2 -1
- package/dist/types/utils/geometry.d.ts +31 -30
- package/dist/types/utils/graphObjectUtils.d.ts +3 -3
- package/dist/types/utils/hittest.d.ts +2 -0
- package/dist/types/utils/jsDriverResultTransformer.d.ts +13 -6
- package/dist/types/utils/segmentAnalytics.d.ts +8 -8
- package/dist/types/utils/zoomFunctions.d.ts +30 -23
- package/package.json +3 -3
|
@@ -3,9 +3,7 @@ import type { TextSegment } from './types';
|
|
|
3
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
|
-
* @param
|
|
7
|
-
* @param {number} opacity
|
|
8
|
-
* @returns {string} rgba() string with the given opacity
|
|
6
|
+
* @param color - * @param opacity - * @returns rgba() string with the given opacity.
|
|
9
7
|
*/
|
|
10
8
|
export declare const overrideOpacity: (color: string, opacity: number) => string;
|
|
11
9
|
/**
|
|
@@ -20,22 +18,23 @@ type ArrowHeadParameters = {
|
|
|
20
18
|
};
|
|
21
19
|
/**
|
|
22
20
|
* Creates an arrowhead shape using a polygon.
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
21
|
+
* @param ctx - The canvas context to draw on.
|
|
22
|
+
* @param headLineWidth - The width of the arrowhead's outline.
|
|
23
|
+
* @param color - The color of the arrowhead.
|
|
24
|
+
* @param arrowHeadParameters - The parameters for the arrowhead.
|
|
25
|
+
* @param fill - Whether or not to fill the triangle.
|
|
26
|
+
* @param stroke - Whether or not to stroke the triangle.
|
|
29
27
|
*/
|
|
30
28
|
export declare const drawArrowHead: (ctx: CanvasRenderingContext2D, headLineWidth: number, color: string, arrowHeadParameters: ArrowHeadParameters, fill?: boolean, stroke?: boolean) => void;
|
|
31
29
|
/**
|
|
32
30
|
* Draws borders around a node with a given array of border styles
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
31
|
+
* @param ctx - The canvas context.
|
|
32
|
+
* @param x - The x coordinate of the node.
|
|
33
|
+
* @param y - The y coordinate of the node.
|
|
34
|
+
* @param innerRadius - The inner radius of the node without any border.
|
|
35
|
+
* @param borderStyles - An array of border styles.
|
|
38
36
|
* @internal
|
|
37
|
+
* @hidden
|
|
39
38
|
*/
|
|
40
39
|
export declare const drawCircleBand: (ctx: CanvasRenderingContext2D, x: number, y: number, innerRadius: number, borderStyles: {
|
|
41
40
|
width: number;
|
|
@@ -44,13 +43,13 @@ export declare const drawCircleBand: (ctx: CanvasRenderingContext2D, x: number,
|
|
|
44
43
|
export declare const drawCircle: (ctx: CanvasRenderingContext2D, x: number, y: number, r: number) => void;
|
|
45
44
|
/**
|
|
46
45
|
* Fill a circle band with a gradient from a certain color to transparent
|
|
47
|
-
* @param
|
|
48
|
-
* @param
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
52
|
-
* @param
|
|
53
|
-
* @param
|
|
46
|
+
* @param ctx - The canvas context.
|
|
47
|
+
* @param x - The x coordinate of the node.
|
|
48
|
+
* @param y - The y coordinate of the node.
|
|
49
|
+
* @param color - The color of the gradient.
|
|
50
|
+
* @param radius - The inner radius of the node without any border.
|
|
51
|
+
* @param blur - The blur radius of the gradient.
|
|
52
|
+
* @param maxOpacity - The maximum opacity of the gradient.
|
|
54
53
|
*/
|
|
55
54
|
export declare const drawGradientCircleBand: (ctx: CanvasRenderingContext2D, x: number, y: number, color: string, radius: number, blur: number, maxOpacity?: number) => void;
|
|
56
55
|
/**
|
|
@@ -4,11 +4,11 @@ export declare const ellipsisChar = "\u2026";
|
|
|
4
4
|
/**
|
|
5
5
|
* This is the main function that tries to fit a text on one or more lines
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
7
|
+
* @param text - = The full string to place.
|
|
8
|
+
* @param measureWidth - A function that returns the width of a string as pixels on the canvas.
|
|
9
|
+
* @param getAvailableWidth - A function providing the pixel width for a line index.
|
|
10
|
+
* @param numberOfLines - How many lines is available for this placement.
|
|
11
|
+
* @param allowedToGiveUp - If cannot fit on last available line - should we give up or place as much as we can.
|
|
12
12
|
*
|
|
13
13
|
* @return array of text lines
|
|
14
14
|
*/
|
|
@@ -16,24 +16,24 @@ export declare const tryWithNumberOfLines: (text: string, measureWidth: (text: s
|
|
|
16
16
|
/**
|
|
17
17
|
* This functions tries to fit the text in a given number of lines and only linebreak on whitespace
|
|
18
18
|
*
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
19
|
+
* @param text - = The full string to place.
|
|
20
|
+
* @param measureWidth - A function that returns the width of a string as pixels on the canvas.
|
|
21
|
+
* @param getAvailableWidth - A function providing the pixel width for a line index.
|
|
22
|
+
* @param numberOfLines - How many lines is available for this placement.
|
|
23
23
|
*
|
|
24
24
|
* @return array of text lines
|
|
25
25
|
*/
|
|
26
26
|
export declare const tryBreakingOnSpaces: (text: string, measureWidth: (text: string) => number, getAvailableWidth: (a: number, b: number) => number, numberOfLines: number) => TextSegment[];
|
|
27
27
|
/**
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
28
|
+
* @param ctx - = Canvas.2dContext
|
|
29
|
+
* @param rtlAdjustedText - The text to display
|
|
30
30
|
*
|
|
31
31
|
* @return array of text lines
|
|
32
32
|
*/
|
|
33
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
|
-
* Returns the styles by char for a group of property values
|
|
36
|
-
* @param
|
|
35
|
+
* Returns the styles by char for a group of property values.
|
|
36
|
+
* @param captions - = array of captions
|
|
37
37
|
* @return array of list of styles by char
|
|
38
38
|
*/
|
|
39
39
|
export declare const getStylesByChar: (captions?: StyledCaption[]) => {
|
|
@@ -3,6 +3,7 @@ import type { StyledCaption } from '../renderers/canvasrenderer/types';
|
|
|
3
3
|
* The base type for graph elements.
|
|
4
4
|
* @private
|
|
5
5
|
* @internal
|
|
6
|
+
* @hidden
|
|
6
7
|
*/
|
|
7
8
|
interface GraphElement {
|
|
8
9
|
/**
|
|
@@ -11,11 +12,15 @@ interface GraphElement {
|
|
|
11
12
|
* Ids need to be strings and cannot be empty.
|
|
12
13
|
*/
|
|
13
14
|
readonly id: string;
|
|
15
|
+
/** The color of the graph element.*/
|
|
14
16
|
color?: string;
|
|
15
17
|
/** Whether or not the current node or relationship is selected.*/
|
|
16
18
|
selected?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
+
/**
|
|
20
|
+
* The text to display inside on node or relationship.
|
|
21
|
+
* @note: If both caption and captions are provided, captions takes precedence.
|
|
22
|
+
* @note: To provide multiple captions with custom styles, use the {@link captions} property.
|
|
23
|
+
* @note: Captions are only visible when using the 'canvas' renderer.
|
|
19
24
|
*/
|
|
20
25
|
caption?: string;
|
|
21
26
|
/** Whether or not the current node or relationship is disabled.*/
|
|
@@ -30,8 +35,9 @@ interface GraphElement {
|
|
|
30
35
|
*/
|
|
31
36
|
captionAlign?: 'top' | 'bottom' | 'center';
|
|
32
37
|
/**
|
|
33
|
-
* The caption text and font
|
|
34
|
-
*
|
|
38
|
+
* The caption text and font styles.
|
|
39
|
+
* @note: To provide a single caption without custom styles, you can also use the {@link caption} property.
|
|
40
|
+
* @note: Captions are only visible when using the 'canvas' renderer.
|
|
35
41
|
*/
|
|
36
42
|
captions?: StyledCaption[];
|
|
37
43
|
/**
|
|
@@ -39,6 +45,7 @@ interface GraphElement {
|
|
|
39
45
|
* Icons are expected to be square.
|
|
40
46
|
*/
|
|
41
47
|
overlayIcon?: {
|
|
48
|
+
/** The url to the icon.*/
|
|
42
49
|
url: string;
|
|
43
50
|
/**
|
|
44
51
|
* The position of the icon relative to the node or relationship.
|
|
@@ -91,9 +98,10 @@ interface Node extends GraphElement {
|
|
|
91
98
|
html?: HTMLElement;
|
|
92
99
|
}
|
|
93
100
|
/**
|
|
94
|
-
*
|
|
101
|
+
* A node with only a subset of its properties.
|
|
95
102
|
*/
|
|
96
103
|
type PartialNode = Partial<Node> & {
|
|
104
|
+
/** The id of the node. */
|
|
97
105
|
id: string;
|
|
98
106
|
};
|
|
99
107
|
export declare const isValidRelationship: (relationship: unknown) => relationship is Relationship;
|
|
@@ -118,9 +126,10 @@ interface Relationship extends GraphElement {
|
|
|
118
126
|
captionHtml?: HTMLElement;
|
|
119
127
|
}
|
|
120
128
|
/**
|
|
121
|
-
*
|
|
129
|
+
* A relationship with only a subset of its properties.
|
|
122
130
|
*/
|
|
123
131
|
type PartialRelationship = Partial<Relationship> & {
|
|
132
|
+
/** The id of the relationship. */
|
|
124
133
|
id: string;
|
|
125
134
|
};
|
|
126
135
|
export type { Node, Relationship, PartialNode, PartialRelationship };
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Make sure canvas pixel buffer is 1 to 1 vs screen pixels
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @remarks If the parent element is not connected to the DOM,
|
|
8
|
+
* it will use the width and height from the style properties.
|
|
8
9
|
*/
|
|
9
10
|
export declare const fitCanvasSizeToParent: (canvas: HTMLCanvasElement) => void;
|
|
10
11
|
export declare const addWebGLContextLostListener: (canvas: HTMLCanvasElement, contextLostCallback?: (e: WebGLContextEvent) => void) => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import colorString from 'color-string';
|
|
2
2
|
/**
|
|
3
|
-
* Determines whether a black or white font color is more readable for a given background color
|
|
4
|
-
* @param
|
|
5
|
-
* @returns
|
|
3
|
+
* Determines whether a black or white font color is more readable for a given background color.
|
|
4
|
+
* @param color - The background color.
|
|
5
|
+
* @returns The font color that should be used @defaultValue '#fff'.
|
|
6
6
|
*/
|
|
7
7
|
export declare const textColorForBackground: (color: string) => string;
|
|
8
8
|
export declare const colorToRGB: (color: string) => colorString.Color;
|
|
@@ -28,12 +28,12 @@ export declare const absFillStyle: {
|
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
30
|
* Factor to make nodes same size in WebGL renderer and Canvas.
|
|
31
|
-
* @returns
|
|
31
|
+
* @returns The adjustment factor.
|
|
32
32
|
*/
|
|
33
33
|
export declare const GlAdjust: number;
|
|
34
34
|
/**
|
|
35
|
-
* Get the pixel ratio of the device
|
|
36
|
-
* @returns
|
|
35
|
+
* Get the pixel ratio of the device.
|
|
36
|
+
* @returns The pixel ratio of the device.
|
|
37
37
|
*/
|
|
38
38
|
export declare const getDevicePixelRatio: () => number;
|
|
39
39
|
export declare const HtmlCaptionMinWidthThreshold = 5;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Specific error that is being thrown by NVL when web browser is not WebGL compatible.
|
|
3
3
|
* @internal
|
|
4
|
+
* @hidden
|
|
4
5
|
*/
|
|
5
6
|
export declare class CompatibilityError extends Error {
|
|
6
7
|
/**
|
|
7
8
|
* Returns the error message of the compatibility error.
|
|
8
|
-
* @returns
|
|
9
|
+
* @returns The error message.
|
|
9
10
|
*/
|
|
10
11
|
toString(): string;
|
|
11
12
|
}
|
|
@@ -10,24 +10,24 @@ export interface Point {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* This function checks if the coordinates are defined.
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @returns
|
|
13
|
+
* @param from - The {@link Node} the edge starts from.
|
|
14
|
+
* @param to - The {@link Node} the edge ends at.
|
|
15
|
+
* @returns True if the coordinates are defined.
|
|
16
16
|
*/
|
|
17
17
|
export declare const areCoordinateDefined: (from: Point | Node, to: Point | Node) => boolean;
|
|
18
18
|
/**
|
|
19
19
|
* Returns true if the two points are within PointDelta pixels of each other
|
|
20
20
|
* This function is used to determine if a new point is close enough to an
|
|
21
|
-
* existing point to be considered the same point
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
24
|
-
* @returns
|
|
21
|
+
* existing point to be considered the same point.
|
|
22
|
+
* @param p1 - The first {@link Point}.
|
|
23
|
+
* @param p2 - The second {@link Point}.
|
|
24
|
+
* @returns True if the two points are within PointDelta pixels of each other.
|
|
25
25
|
*/
|
|
26
26
|
export declare const pointEqual: (p1: Node | Point, p2: Node | Point) => boolean;
|
|
27
27
|
/**
|
|
28
28
|
* A class representing a line segment between two points in 2D space.
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
29
|
+
* @param p1 - The first point of the segment.
|
|
30
|
+
* @param p2 - The second point of the segment.
|
|
31
31
|
*/
|
|
32
32
|
export declare class Segment {
|
|
33
33
|
/** The first point of the segment. */
|
|
@@ -45,21 +45,21 @@ export declare class Segment {
|
|
|
45
45
|
constructor(p1: Point, p2: Point);
|
|
46
46
|
/**
|
|
47
47
|
* Get the vector between the two points of the segment.
|
|
48
|
-
* @returns
|
|
48
|
+
* @returns The vector between the two points of the segment.
|
|
49
49
|
* @private
|
|
50
50
|
* @see {@link https://en.wikipedia.org/wiki/Vector_(spatial)}
|
|
51
51
|
*/
|
|
52
52
|
private getVector;
|
|
53
53
|
/**
|
|
54
54
|
* Get the length of the vector between the two points of the segment.
|
|
55
|
-
* @returns
|
|
55
|
+
* @returns The length of the segment.
|
|
56
56
|
* @private
|
|
57
57
|
* @see {@link https://en.wikipedia.org/wiki/Vector_(spatial)#Length}
|
|
58
58
|
*/
|
|
59
59
|
private getLength;
|
|
60
60
|
/**
|
|
61
61
|
* Get the unit vector of the two points of the segment.
|
|
62
|
-
* @returns
|
|
62
|
+
* @returns The unit vector of the segment.
|
|
63
63
|
* @private
|
|
64
64
|
* @see {@link https://en.wikipedia.org/wiki/Euclidean_vector#Unit_vector}
|
|
65
65
|
* @see {@link https://en.wikipedia.org/wiki/Unit_vector}
|
|
@@ -67,7 +67,7 @@ export declare class Segment {
|
|
|
67
67
|
private getUnitVector;
|
|
68
68
|
/**
|
|
69
69
|
* Get the unit normal vector of the two points of the segment.
|
|
70
|
-
* @returns
|
|
70
|
+
* @returns The unit normal vector of the segment.
|
|
71
71
|
* @private
|
|
72
72
|
* @see {@link https://en.wikipedia.org/wiki/Normal_(geometry)}
|
|
73
73
|
*/
|
|
@@ -75,9 +75,9 @@ export declare class Segment {
|
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Calculates the projection ratio between two vectors.
|
|
78
|
-
* @param
|
|
79
|
-
* @param
|
|
80
|
-
* @returns
|
|
78
|
+
* @param lineStartToPointVector - The vector from the start of the line to the point.
|
|
79
|
+
* @param lineVector - The vector of the line.
|
|
80
|
+
* @returns The projection of the point onto the line.
|
|
81
81
|
* The projection ratio is a value between 0 and 1.
|
|
82
82
|
* The projection ratio is 0 if the point is closest to the start of the line.
|
|
83
83
|
* The projection ratio is 1 if the point is closest to the end of the line.
|
|
@@ -86,10 +86,11 @@ export declare class Segment {
|
|
|
86
86
|
export declare const getProjectionRatio: (lineStartToPointVector: Point, lineVector: Point) => number;
|
|
87
87
|
/**
|
|
88
88
|
* Calculates the shortest distance between a point and a line.
|
|
89
|
-
* @param
|
|
90
|
-
* @param
|
|
91
|
-
* @param
|
|
92
|
-
* @returns
|
|
89
|
+
* @param lineStart - The first point of the line.
|
|
90
|
+
* @param lineEnd - The second point of the line.
|
|
91
|
+
* @param point - The point to calculate the distance to.
|
|
92
|
+
* @returns The distance between the point and the line.
|
|
93
|
+
* @remarks
|
|
93
94
|
* If the actual distance does not matter,
|
|
94
95
|
* if you only want to compare what this function
|
|
95
96
|
* returns to other results of this function, you
|
|
@@ -99,11 +100,11 @@ export declare const getProjectionRatio: (lineStartToPointVector: Point, lineVec
|
|
|
99
100
|
export declare const getDistanceToLine: (lineStart: Point, lineEnd: Point, point: Point) => number;
|
|
100
101
|
/**
|
|
101
102
|
* Get the intersection point of two lines
|
|
102
|
-
* @param
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
105
|
-
* @param
|
|
106
|
-
* @returns
|
|
103
|
+
* @param p0 - First point of first line.
|
|
104
|
+
* @param p1 - Second point of first line.
|
|
105
|
+
* @param p2 - First point of second line.
|
|
106
|
+
* @param p3 - Second point of second line.
|
|
107
|
+
* @returns Intersection point.
|
|
107
108
|
* @see https://github.com/bit101/CodingMath/blob/master/episode33/parallel.js
|
|
108
109
|
* Returns null if lines are parallel
|
|
109
110
|
*/
|
|
@@ -113,10 +114,10 @@ export declare const getIntersection: (p0: Point, p1: Point, p2: Point, p3: Poin
|
|
|
113
114
|
* The curve is defined by three points (from, to, control).
|
|
114
115
|
* The point is defined by an object with x and y properties (point).
|
|
115
116
|
* The function returns the distance between the point and the curve.
|
|
116
|
-
* @param
|
|
117
|
-
* @param
|
|
118
|
-
* @param
|
|
119
|
-
* @param
|
|
120
|
-
* @returns
|
|
117
|
+
* @param fromCoordinates - The first point of the curve.
|
|
118
|
+
* @param toCoordinates - The second point of the curve.
|
|
119
|
+
* @param control - The control point of the curve.
|
|
120
|
+
* @param point - The point to calculate the distance to.
|
|
121
|
+
* @returns The distance between the point and the curve.
|
|
121
122
|
*/
|
|
122
123
|
export declare const getDistanceToQuadratic: (fromCoordinates: Point, toCoordinates: Point, control: Point, point: Point) => number;
|
|
@@ -10,9 +10,9 @@ export declare const relItemsToFlatKeySet: (relItems: Relationship[]) => Set<str
|
|
|
10
10
|
* Flattens a list of relationships so only one relationship remains between two nodes.
|
|
11
11
|
* Falls back to default rel color when relationships between two nodes have varying colors.
|
|
12
12
|
* Sums widths of relationships when more than one relationship exists between two nodes.
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @
|
|
13
|
+
* @param relItems - List of all relationships and their connected ids.
|
|
14
|
+
* @param disabledItemColor - The color to use for the disabled relationships.
|
|
15
|
+
* @returns A flattened list of relationships.
|
|
16
16
|
*/
|
|
17
17
|
export declare const relItemsToFlatList: (relItems: Relationship[], disabledItemColor?: string) => FlatRel[];
|
|
18
18
|
export declare const getAdjNodesMapAndRelMap: (rels: Relationship[]) => {
|
|
@@ -38,7 +38,9 @@ export interface HitTargetRelationship {
|
|
|
38
38
|
* Part of the result of a {@link NVL}.{@link NVL.getHits} call
|
|
39
39
|
*/
|
|
40
40
|
export type HitTargets = {
|
|
41
|
+
/** The nodes that have been hit by the pointer event. */
|
|
41
42
|
nodes: HitTargetNode[];
|
|
43
|
+
/** The relationships that have been hit by the pointer event. */
|
|
42
44
|
relationships: HitTargetRelationship[];
|
|
43
45
|
};
|
|
44
46
|
export declare const hitTest: (x: number, y: number, state: NvlState, targets?: string[], options?: {
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { Node as DriverNode, Relationship as DriverRelationship, Path, Record } from 'neo4j-driver';
|
|
2
|
+
import type { Node as NvlNode, Relationship as NvlRelationship } from '../types/graph-element';
|
|
2
3
|
export declare const recordMapper: (record: Record) => any[];
|
|
3
4
|
type GraphElement = DriverNode | DriverRelationship | Path;
|
|
4
5
|
type NestedGraphElements = GraphElement | NestedGraphElements[];
|
|
5
6
|
export declare const recordCollector: (graphElements: NestedGraphElements[]) => {
|
|
6
|
-
|
|
7
|
-
nodes:
|
|
8
|
-
relationships
|
|
7
|
+
/** The nodes of the graph. */
|
|
8
|
+
nodes: NvlNode[];
|
|
9
|
+
/** The relationships of the graph. */
|
|
10
|
+
relationships: NvlRelationship[];
|
|
11
|
+
/** A map from element id to the driver graph element. */
|
|
12
|
+
recordObjectMap: Map<string, DriverNode | DriverRelationship | Path>;
|
|
9
13
|
};
|
|
10
14
|
/**
|
|
11
15
|
* Result transformer for the Neo4j JavaScript driver results to NVL graph elements.
|
|
@@ -28,8 +32,11 @@ export declare const recordCollector: (graphElements: NestedGraphElements[]) =>
|
|
|
28
32
|
* @see {@link https://neo4j.com/docs/api/javascript-driver/current/class/lib6/result-transformers.js~ResultTransformers.html|ResultTransformers on Neo4j JS Driver API Docs}
|
|
29
33
|
*/
|
|
30
34
|
export declare const nvlResultTransformer: import("neo4j-driver-core/types/result-transformers").ResultTransformer<{
|
|
31
|
-
|
|
32
|
-
nodes:
|
|
33
|
-
relationships
|
|
35
|
+
/** The nodes of the graph. */
|
|
36
|
+
nodes: NvlNode[];
|
|
37
|
+
/** The relationships of the graph. */
|
|
38
|
+
relationships: NvlRelationship[];
|
|
39
|
+
/** A map from element id to the driver graph element. */
|
|
40
|
+
recordObjectMap: Map<string, DriverNode | DriverRelationship | Path>;
|
|
34
41
|
}>;
|
|
35
42
|
export {};
|
|
@@ -6,32 +6,32 @@ type AnalyticsTrackPayload = {
|
|
|
6
6
|
};
|
|
7
7
|
export declare abstract class AnalyticsFunction {
|
|
8
8
|
/**
|
|
9
|
-
* Perform asynchronous bootstrapping
|
|
9
|
+
* Perform asynchronous bootstrapping.
|
|
10
10
|
*/
|
|
11
11
|
abstract init(apiKey: string): void;
|
|
12
12
|
/**
|
|
13
|
-
* Associate session with known user identifier
|
|
13
|
+
* Associate session with known user identifier.
|
|
14
14
|
*/
|
|
15
15
|
abstract identify(): void;
|
|
16
16
|
/**
|
|
17
|
-
* Load unique segment Id in the localstorage
|
|
17
|
+
* Load unique segment Id in the localstorage.
|
|
18
18
|
*/
|
|
19
19
|
abstract loadSavedSegmentId(): string;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Save unique segment Id in the localstorage.
|
|
22
22
|
*/
|
|
23
23
|
abstract saveTrackingId(segmentId: string): void;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Get/fetch unique segment Id from the localstorage.
|
|
26
26
|
*/
|
|
27
27
|
abstract getSegmentTrackingId(): Record<string, unknown>;
|
|
28
28
|
/**
|
|
29
|
-
* Track arbitrary event
|
|
29
|
+
* Track arbitrary event.
|
|
30
30
|
*/
|
|
31
|
-
abstract trackEvent(payload: AnalyticsTrackPayload): void
|
|
31
|
+
abstract trackEvent(payload: AnalyticsTrackPayload): Promise<void>;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* Analytics adapter for Segment Analytics.js
|
|
34
|
+
* Analytics adapter for Segment Analytics.js.
|
|
35
35
|
*/
|
|
36
36
|
export declare class SegmentAnalytics implements AnalyticsFunction {
|
|
37
37
|
private analytics;
|
|
@@ -3,10 +3,10 @@ import type { Point } from './geometry';
|
|
|
3
3
|
declare const getExtremeLimits: (nodePositions: Point[]) => Point[];
|
|
4
4
|
declare const getMaxDistance: (extremeLimits?: Point[]) => number;
|
|
5
5
|
/**
|
|
6
|
-
* Gets the center
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @returns An object with the center x and y coordinates and the width and height
|
|
6
|
+
* Gets the center coordinates and the width and height for the given node positions.
|
|
7
|
+
* @param nodePositions - The node positions.
|
|
8
|
+
* @param maxNodeRadius - The maximum node radius.
|
|
9
|
+
* @returns An object with the center x and y coordinates and the width and height.
|
|
10
10
|
*/
|
|
11
11
|
declare const getPositionBoundaries: (nodePositions?: Point[] | Node[], maxNodeRadius?: number) => {
|
|
12
12
|
centerX: number;
|
|
@@ -15,35 +15,42 @@ declare const getPositionBoundaries: (nodePositions?: Point[] | Node[], maxNodeR
|
|
|
15
15
|
nodesHeight: number;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* Gets the required zoom level for the given view and scene dimensions to fit the scene into the view
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
23
|
-
* @returns An object with the zoom level for the x and y axis
|
|
18
|
+
* Gets the required zoom level for the given view and scene dimensions to fit the scene into the view.
|
|
19
|
+
* @param viewWidth - The width of the required view.
|
|
20
|
+
* @param viewHeight - The height of the required view.
|
|
21
|
+
* @param sceneWidth - The width of the canvas scene.
|
|
22
|
+
* @param sceneHeight - The height of the canvas scene.
|
|
23
|
+
* @returns An object with the zoom level for the x and y axis.
|
|
24
24
|
*/
|
|
25
25
|
declare const getZoomLevel: (viewWidth: number, viewHeight: number, sceneWidth: number, sceneHeight: number) => {
|
|
26
26
|
zoomX: number;
|
|
27
27
|
zoomY: number;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
* Creates a zoom target based on the given zoom levels and the min and max zoom level
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
35
|
-
* @returns The zoom target
|
|
30
|
+
* Creates a zoom target based on the given zoom levels and the min and max zoom level.
|
|
31
|
+
* @param zoomX - The zoom level for the x axis.
|
|
32
|
+
* @param zoomY - The zoom level for the y axis.
|
|
33
|
+
* @param minZoom - The minimum zoom level.
|
|
34
|
+
* @param maxZoom - The maximum zoom level.
|
|
35
|
+
* @returns The zoom target.
|
|
36
36
|
*/
|
|
37
37
|
declare const createZoomTarget: (zoomX: number, zoomY: number, minZoom?: number, maxZoom?: number) => number;
|
|
38
38
|
/**
|
|
39
|
-
* Gets the zoom target to fit the given node positions into the scene
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @returns
|
|
39
|
+
* Gets the zoom target to fit the given node positions into the scene.
|
|
40
|
+
* @param nodePositions - The node positions.
|
|
41
|
+
* @param containerWidth - The width of the container NVL is displayed in.
|
|
42
|
+
* @param containerHeight - The height of the container NVL is displayed in.
|
|
43
|
+
* @param maxNodeRadius - The maximum node radius, which is added as margin to the scene (defaults to `50`).
|
|
44
|
+
* @returns The zoom and pan targets.
|
|
45
45
|
*/
|
|
46
|
-
declare const getZoomTargetForNodePositions: (nodePositions: Point[], containerWidth: number, containerHeight: number, maxNodeRadius?: number) =>
|
|
46
|
+
declare const getZoomTargetForNodePositions: (nodePositions: Point[], containerWidth: number, containerHeight: number, maxNodeRadius?: number) => {
|
|
47
|
+
/** The zoom level. */
|
|
48
|
+
zoom: number;
|
|
49
|
+
/** The x-coordinate of the pan. */
|
|
50
|
+
panX: number;
|
|
51
|
+
/** The y-coordinate of the pan. */
|
|
52
|
+
panY: number;
|
|
53
|
+
};
|
|
47
54
|
declare const getFlexibleZoomLimit: (nodePositions: Point[], rect: HTMLCanvasElement, maxNodeRadius: number) => number;
|
|
48
55
|
declare const getNewZoomWithinLimits: (newZoom: number, oldZoom: number, minZoom: number, maxZoom: number) => number;
|
|
49
56
|
declare const isZoomOutAtLimit: (newZoom: number, oldZoom: number, zoomOutLimit: number) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-nvl/base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
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",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"postpack": "rm LICENSE.txt && rm CHANGELOG.md"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@neo4j-nvl/layout-workers": "0.
|
|
32
|
+
"@neo4j-nvl/layout-workers": "1.0.0",
|
|
33
33
|
"@segment/analytics-next": "^1.70.0",
|
|
34
34
|
"color-string": "^1.9.1",
|
|
35
35
|
"d3-force": "^3.0.0",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"uuid": "^8.3.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
+
"@babel/core": "^7.21.4",
|
|
47
48
|
"@types/color-string": "^1.5.5",
|
|
48
49
|
"@types/d3-force": "^3.0.3",
|
|
49
50
|
"@types/lodash": "4.14.202",
|
|
@@ -52,7 +53,6 @@
|
|
|
52
53
|
"babel-loader": "^8.2.5",
|
|
53
54
|
"copy-webpack-plugin": "^11.0.0",
|
|
54
55
|
"neo4j-driver": "^5.26.0",
|
|
55
|
-
"typedoc": "^0.23.15",
|
|
56
56
|
"webpack": "^5.75.0",
|
|
57
57
|
"webpack-cli": "^5.0.0"
|
|
58
58
|
},
|