@neo4j-nvl/base 1.0.0 → 1.1.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 +25 -0
- package/dist/base.mjs +1 -1
- package/dist/types/index.d.ts +25 -11
- package/dist/types/layouts/circularLayout/CircularLayout.d.ts +18 -0
- package/dist/types/layouts/forcedirectedlayout/ForceCytoLayout.d.ts +1 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +8 -3
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment-verlet.d.ts +1 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.d.ts +17 -39
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/types.d.ts +49 -0
- package/dist/types/modules/NvlController.d.ts +6 -2
- package/dist/types/modules/state/types.d.ts +30 -9
- package/dist/types/modules/state/utils.d.ts +2 -2
- package/dist/types/renderers/domrenderer/BaseRenderer.d.ts +75 -0
- package/dist/types/renderers/domrenderer/canvasrenderer/CanvasRenderer.d.ts +120 -0
- package/dist/types/renderers/{canvasrenderer/util.d.ts → domrenderer/canvasrenderer/canvasUtils.d.ts} +2 -14
- package/dist/types/renderers/domrenderer/shared/ImageCache.d.ts +16 -0
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/ArrowBundle.d.ts +2 -2
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/ArrowBundler.d.ts +1 -1
- package/dist/types/renderers/domrenderer/shared/arrows/arrows.d.ts +175 -0
- package/dist/types/renderers/domrenderer/shared/nodes/nodeUtils.d.ts +29 -0
- package/dist/types/renderers/domrenderer/shared/nodes/nodes.d.ts +58 -0
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/types.d.ts +2 -2
- package/dist/types/renderers/domrenderer/shared/util.d.ts +11 -0
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/vectorUtils.d.ts +1 -1
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/wordwrap.d.ts +10 -0
- package/dist/types/renderers/domrenderer/shared/wordwrap.test.d.ts +1 -0
- package/dist/types/renderers/domrenderer/svgrenderer/SvgRenderer.d.ts +22 -0
- package/dist/types/renderers/domrenderer/svgrenderer/SvgRenderer.test.d.ts +1 -0
- package/dist/types/renderers/domrenderer/svgrenderer/svgUtils.d.ts +175 -0
- package/dist/types/renderers/webglrenderer/Renderer.d.ts +5 -1
- package/dist/types/renderers/webglrenderer/Renderer.test.d.ts +1 -0
- package/dist/types/types/graph-element.d.ts +1 -1
- package/dist/types/utils/canvasManagement.d.ts +16 -1
- package/dist/types/utils/circularUtils.d.ts +3 -0
- package/dist/types/utils/circularUtils.test.d.ts +1 -0
- package/dist/types/utils/constants.d.ts +4 -1
- package/dist/types/utils/geometry.d.ts +2 -1
- package/dist/types/utils/graphObjectUtils.d.ts +2 -2
- package/dist/types/utils/jsDriverResultTransformer.d.ts +1 -1
- package/package.json +23 -23
- package/dist/types/modules/performance.d.ts +0 -93
- package/dist/types/renderers/canvasrenderer/CanvasRenderer.d.ts +0 -93
- package/dist/types/renderers/canvasrenderer/ImageCache.d.ts +0 -11
- package/dist/types/renderers/canvasrenderer/arrows/arrows.d.ts +0 -55
- package/dist/types/renderers/canvasrenderer/nodes/nodes.d.ts +0 -59
- /package/dist/types/{renderers/canvasrenderer/Animation.test.d.ts → layouts/d3forcelayout/circularLayout.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/canvasrenderer}/Animation.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer/CanvasRenderer.test.d.ts → domrenderer/canvasrenderer/Animation.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/canvasrenderer}/AnimationHandler.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer/ImageCache.test.d.ts → domrenderer/canvasrenderer/CanvasRenderer.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer/arrows/ArrowBundle.test.d.ts → domrenderer/shared/ImageCache.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer/arrows/ArrowBundler.test.d.ts → domrenderer/shared/arrows/ArrowBundle.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer/arrows/arrows.test.d.ts → domrenderer/shared/arrows/ArrowBundler.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer/nodes/nodes.test.d.ts → domrenderer/shared/arrows/arrows.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/constants.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer/util.test.d.ts → domrenderer/shared/nodes/nodes.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer/wordwrap.test.d.ts → domrenderer/shared/util.test.d.ts} +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Cache } from '../shared/types';
|
|
2
|
+
declare class ImageCache {
|
|
3
|
+
cache: Cache;
|
|
4
|
+
constructor();
|
|
5
|
+
getImage(src: string, inverted?: boolean): HTMLCanvasElement;
|
|
6
|
+
private getOrCreateEntry;
|
|
7
|
+
private invertCanvas;
|
|
8
|
+
private loadImage;
|
|
9
|
+
private drawIfNeeded;
|
|
10
|
+
/**
|
|
11
|
+
* Returns a promise that resolves when all images currently in the cache have finished loading.
|
|
12
|
+
* Useful before export operations to ensure all icons are available.
|
|
13
|
+
*/
|
|
14
|
+
waitForImages(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export default ImageCache;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Relationship } from '
|
|
2
|
-
import type { Point } from '
|
|
1
|
+
import type { Relationship } from '../../../../types/graph-element';
|
|
2
|
+
import type { Point } from '../../../../utils/geometry';
|
|
3
3
|
import type { WaypointPath } from '../types';
|
|
4
4
|
export interface LabelGeometry {
|
|
5
5
|
position: Point;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node, Relationship } from '
|
|
1
|
+
import type { Node, Relationship } from '../../../../types/graph-element';
|
|
2
2
|
import type { WaypointPath } from '../types';
|
|
3
3
|
import ArrowBundle from './ArrowBundle';
|
|
4
4
|
export default class ArrowBundler {
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { BorderStyle } from '../../../../modules/state/types';
|
|
2
|
+
import type { Node, Relationship } from '../../../../types/graph-element';
|
|
3
|
+
import type { Point } from '../../../../utils/geometry';
|
|
4
|
+
import type ArrowBundle from './ArrowBundle';
|
|
5
|
+
/**
|
|
6
|
+
* This function calculates the difference in radius between two nodes.
|
|
7
|
+
* @param toArrowGap - The gap between the node and the arrow on the to side.
|
|
8
|
+
* @param fromArrowGap - The gap between the node and the arrow on the from side.
|
|
9
|
+
* @returns The difference in radius between the two nodes.
|
|
10
|
+
* @comment can be affected for example by the label crust and selected ring
|
|
11
|
+
* as well as a gap between the node and the arrow on it's side.
|
|
12
|
+
*/
|
|
13
|
+
export declare const getRadiusDifference: (toArrowGap: number, fromArrowGap: number) => number;
|
|
14
|
+
/**
|
|
15
|
+
* Calculates control points for self-referencing relationships
|
|
16
|
+
* @param {Relationship} rel - The relationship
|
|
17
|
+
* @param {Node} node - The node the relationship refers to
|
|
18
|
+
* @param {ArrowBundle} bundle - The arrow bundle
|
|
19
|
+
* @returns Object containing angles and coordinate points for the self-loop
|
|
20
|
+
*/
|
|
21
|
+
export declare const getSelfArrowControlPoints: (rel: Relationship, node: Node, bundle: ArrowBundle) => {
|
|
22
|
+
angle: number;
|
|
23
|
+
startAngle: number;
|
|
24
|
+
endAngle: number;
|
|
25
|
+
startPoint: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
};
|
|
29
|
+
endPoint: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
33
|
+
apexPoint: {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
};
|
|
37
|
+
control1Point: {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
};
|
|
41
|
+
control2Point: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
};
|
|
45
|
+
nodeGap: number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Calculates position, angle and flip for a self-referencing relationship label.
|
|
49
|
+
* Used by both Canvas and SVG renderers to ensure consistent positioning.
|
|
50
|
+
* This function handles all the math internally including headAngle and headSelectedAdjustment calculations.
|
|
51
|
+
*/
|
|
52
|
+
export declare const getSelfArrowLabelPosition: (apexPoint: Point, angle: number, endPoint: Point, control2Point: Point, isSelected: boolean, selectionRings: BorderStyle["rings"], relWidth?: number) => {
|
|
53
|
+
x: number;
|
|
54
|
+
y: number;
|
|
55
|
+
angle: number;
|
|
56
|
+
flip: boolean;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Calculates the padding for selected relationships based on border style
|
|
60
|
+
* @param selectedBorderRings - Array of border rings for selected state
|
|
61
|
+
* @returns The total selection padding
|
|
62
|
+
*/
|
|
63
|
+
export declare const getSelectionPadding: (selectedBorderRings?: BorderStyle["rings"]) => number;
|
|
64
|
+
/**
|
|
65
|
+
* Calculates the position and angle for a relationship label based on the Canvas renderer's logic.
|
|
66
|
+
* This handles both straight lines and curves, with special logic for odd/even number of points.
|
|
67
|
+
*
|
|
68
|
+
* @param points - Array of points defining the relationship line
|
|
69
|
+
* @param fromNode - The source node
|
|
70
|
+
* @param toNode - The target node
|
|
71
|
+
* @param drawCurves - Whether curves are being drawn
|
|
72
|
+
* @param isSelected - Whether the relationship is selected
|
|
73
|
+
* @param captionAlign - Caption alignment ('top' or 'bottom')
|
|
74
|
+
* @param selectedBorderRings - Array of border rings for selected state
|
|
75
|
+
* @returns Object containing x, y position and angle for the label
|
|
76
|
+
*/
|
|
77
|
+
export declare const getRelationshipLabelPosition: (points: Point[], fromNode: Node, toNode: Node, drawCurves: boolean, isSelected: boolean, selectedBorderRings: BorderStyle["rings"], captionAlign?: "top" | "bottom") => {
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
angle: number;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* This function calculates the coordinates of the via point
|
|
84
|
+
* between two nodes. The via point is used to bend the edge
|
|
85
|
+
* between the two nodes.
|
|
86
|
+
* @param fromNode - The node the edge starts from.
|
|
87
|
+
* @param toNode - The node the edge ends at.
|
|
88
|
+
* @param fromArrowGap - The gap between the node and the arrow on the from side.
|
|
89
|
+
* @param toArrowGap - The gap between the node and the arrow on the to side.
|
|
90
|
+
* @returns The coordinates of the via point.
|
|
91
|
+
*/
|
|
92
|
+
export declare const getViaCoordinates: (fromNode: Node, toNode: Node, fromArrowGap: number, toArrowGap: number, rel: Relationship, bundle: ArrowBundle) => Point;
|
|
93
|
+
export declare const getPointsForStraight: (rel: Relationship, bundle: ArrowBundle, fromNode: Node, toNode: Node, showLabel: boolean, curved?: boolean) => Point[];
|
|
94
|
+
export declare const distanceToEdge: (pos: Point, rel: Relationship, fromNode: Node, toNode: Node, bundle: ArrowBundle, showLabel: boolean, drawCurves?: boolean) => number;
|
|
95
|
+
/**
|
|
96
|
+
* Returns the bounding box of the arrow.
|
|
97
|
+
* @param rel - The relationship to get the bounding box for.
|
|
98
|
+
* @param bundle - The arrow bundle the relationship is part of.
|
|
99
|
+
* @param fromNode - The node the relationship is coming from.
|
|
100
|
+
* @param toNode - The node the relationship is going to.
|
|
101
|
+
* @param showLabel - Whether or not a label is shown.
|
|
102
|
+
* @param drawCurves - Whether or the relationship is drawn as a curve.
|
|
103
|
+
* @returns The bounding box of the arrow.
|
|
104
|
+
*/
|
|
105
|
+
export declare const getBoundingBox: (rel: Relationship, bundle: ArrowBundle, fromNode: Node, toNode: Node, showLabel?: boolean, drawCurves?: boolean) => DOMRect | null;
|
|
106
|
+
/**
|
|
107
|
+
* Calculates the width of a relationship including selection factor and pixel ratio
|
|
108
|
+
* @param rel - The relationship
|
|
109
|
+
* @param defaultWidth - The default relationship width
|
|
110
|
+
* @returns The calculated relationship width
|
|
111
|
+
*/
|
|
112
|
+
export declare const getRelationshipWidth: (rel: Relationship, defaultWidth: number) => number;
|
|
113
|
+
/**
|
|
114
|
+
* Adjusts relationship line points to create proper gaps at start and end.
|
|
115
|
+
* The Canvas renderer uses this logic:
|
|
116
|
+
* - End gap (arrowhead): headHeight/2 + headSelectedAdjustment
|
|
117
|
+
* - Start gap (tail): Only for selected relationships, uses getSelectionPadding
|
|
118
|
+
*
|
|
119
|
+
* @param points - Array of points defining the relationship line (will be modified in place)
|
|
120
|
+
* @param isSelected - Whether the relationship is selected
|
|
121
|
+
* @param headHeight - The height of the arrowhead
|
|
122
|
+
* @param headSelectedAdjustment - Additional adjustment for selected relationships
|
|
123
|
+
* @param selectedBorderRings - Array of border rings for selected state
|
|
124
|
+
* @returns Object with adjusted points and the tail offset applied (for label positioning)
|
|
125
|
+
*/
|
|
126
|
+
export declare const adjustPointsForGaps: (points: Point[], isSelected: boolean, headHeight: number, headSelectedAdjustment: number, selectedBorderRings: BorderStyle["rings"]) => {
|
|
127
|
+
tailOffset: Point | null;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Calculates arrowhead scaling and dimensions for rendering.
|
|
131
|
+
*
|
|
132
|
+
* @param width - The raw width of the relationship (before pixel ratio scaling)
|
|
133
|
+
* @param isSelected - Whether the relationship is selected
|
|
134
|
+
* @param selectedBorderRings - Array of border rings for selected state
|
|
135
|
+
* @returns Object containing all calculated arrowhead dimensions and adjustments
|
|
136
|
+
*/
|
|
137
|
+
export declare const calculateArrowheadScaling: (width: number, isSelected: boolean, selectedBorderRings: BorderStyle["rings"]) => {
|
|
138
|
+
headFactor: number;
|
|
139
|
+
headHeight: number;
|
|
140
|
+
headChinHeight: number;
|
|
141
|
+
headWidth: number;
|
|
142
|
+
headSelectedAdjustment: number;
|
|
143
|
+
headPositionOffset: number;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Calculates the dimensions of an arrowhead
|
|
147
|
+
* @param relWidth - The width of the relationship line
|
|
148
|
+
* @param defaultRelWidth - The default relationship width
|
|
149
|
+
* @param isSelected - Whether the relationship is selected
|
|
150
|
+
* @param selectedBorderRings - Array of border rings for selected state
|
|
151
|
+
* @returns Object containing headHeight, headChinHeight, headWidth, and headSelectedAdjustment
|
|
152
|
+
*/
|
|
153
|
+
export declare const getArrowheadDimensions: (relWidth: number, defaultRelWidth: number, isSelected: boolean, selectedBorderRings: BorderStyle["rings"]) => {
|
|
154
|
+
headHeight: number;
|
|
155
|
+
headChinHeight: number;
|
|
156
|
+
headWidth: number;
|
|
157
|
+
headSelectedAdjustment: number;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Calculates the size of an overlay icon on a relationship
|
|
161
|
+
* @param iconSizeFactor - The size factor from the overlay icon configuration
|
|
162
|
+
* @returns The calculated overlay icon size
|
|
163
|
+
*/
|
|
164
|
+
export declare const getOverlayIconSize: (iconSizeFactor: number) => number;
|
|
165
|
+
/**
|
|
166
|
+
* Calculates the alignment offsets for an overlay icon on a relationship
|
|
167
|
+
* @param position - The position array [x, y] from overlay icon configuration
|
|
168
|
+
* @param width - The available width for the icon
|
|
169
|
+
* @param height - The height of the icon
|
|
170
|
+
* @returns Object with widthAlign and heightAlign offsets
|
|
171
|
+
*/
|
|
172
|
+
export declare const getOverlayIconAlignment: (position: [number, number], width: number, height: number) => {
|
|
173
|
+
widthAlign: number;
|
|
174
|
+
heightAlign: number;
|
|
175
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Node } from '../../../../types/graph-element';
|
|
2
|
+
import type { TextSegment } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the caption font size that should be used
|
|
5
|
+
* for the given info level and node diameter.
|
|
6
|
+
* @param infoLevel {number} - The info level.
|
|
7
|
+
* @param nodeRadius {number} - The radius of the node.
|
|
8
|
+
* @param captionSize {number} - The size of the caption.
|
|
9
|
+
* @returns {number} - The font size.
|
|
10
|
+
*/
|
|
11
|
+
export declare const infoLevelToFontSize: (infoLevel: number, nodeRadius?: number, captionSize?: number, hasIcon?: boolean) => number;
|
|
12
|
+
/**
|
|
13
|
+
* Prepares node caption data for rendering (works for both Canvas and SVG)
|
|
14
|
+
* @param node - The node to prepare caption data for
|
|
15
|
+
* @param zoomLevel - Current zoom level
|
|
16
|
+
* @param ctx - Canvas context for text measurement (optional for SVG, will create one if not provided)
|
|
17
|
+
* @returns Caption rendering data including lines, styles, positioning, and font info
|
|
18
|
+
*/
|
|
19
|
+
export declare function prepareNodeCaptionData(node: Node, zoomLevel: number, ctx?: CanvasRenderingContext2D): {
|
|
20
|
+
lines: TextSegment[];
|
|
21
|
+
stylesPerChar: string[][];
|
|
22
|
+
fullCaption: string;
|
|
23
|
+
fontSize: number;
|
|
24
|
+
fontFace: string;
|
|
25
|
+
fontColor: string;
|
|
26
|
+
yPos: number;
|
|
27
|
+
maxNoLines: number;
|
|
28
|
+
hasContent: boolean;
|
|
29
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Node } from '../../../../types/graph-element';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the bounding box of a node with the given x, y, and size properties.
|
|
4
|
+
* If no size is given, the default size is used.
|
|
5
|
+
* @param Node - The node to get the bounding box for.
|
|
6
|
+
* @returns The bounding box of the node.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getBoundingBox: ({ x, y, size }: Node) => DOMRect;
|
|
9
|
+
/**
|
|
10
|
+
* Calculates the size of a node icon based on node properties
|
|
11
|
+
* @param mainFaceRadius - The radius of the node's main face (already adjusted for pixel ratio)
|
|
12
|
+
* @param hasCaption - Whether the node has a caption
|
|
13
|
+
* @param iconInfoLevel - The icon info level (determines size scaling)
|
|
14
|
+
* @param nodeInfoLevel - The node info level (determines whether icon should show with text)
|
|
15
|
+
* @returns The calculated icon size
|
|
16
|
+
*/
|
|
17
|
+
export declare const getNodeIconSize: (mainFaceRadius: number, hasCaption: boolean, iconInfoLevel: number, nodeInfoLevel: number) => number;
|
|
18
|
+
/**
|
|
19
|
+
* Calculates the position of a node icon
|
|
20
|
+
* @param iconSize - The size of the icon
|
|
21
|
+
* @param hasCaption - Whether the node has a caption
|
|
22
|
+
* @param captionAlign - The caption alignment ('center', 'bottom', or 'top')
|
|
23
|
+
* @param iconInfoLevel - The icon info level
|
|
24
|
+
* @param nodeInfoLevel - The node info level
|
|
25
|
+
* @returns Object with iconXPos and iconYPos
|
|
26
|
+
*/
|
|
27
|
+
export declare const getNodeIconPosition: (iconSize: number, hasCaption: boolean, captionAlign: string, iconInfoLevel: number, nodeInfoLevel: number) => {
|
|
28
|
+
iconXPos: number;
|
|
29
|
+
iconYPos: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Calculates the size of a node overlay icon
|
|
33
|
+
* @param mainFaceDiameter - The diameter of the node's main face (already adjusted for pixel ratio)
|
|
34
|
+
* @param overlayIconSizeFactor - The size factor from the overlay icon configuration
|
|
35
|
+
* @returns The calculated overlay icon size
|
|
36
|
+
*/
|
|
37
|
+
export declare const getNodeOverlayIconSize: (mainFaceDiameter: number, overlayIconSizeFactor: number) => number;
|
|
38
|
+
/**
|
|
39
|
+
* Calculates the position of a node overlay icon
|
|
40
|
+
* @param iconSize - The size of the overlay icon
|
|
41
|
+
* @param mainFaceRadius - The radius of the node's main face
|
|
42
|
+
* @param position - The position array [x, y] from overlay icon configuration
|
|
43
|
+
* @returns Object with iconXPos and iconYPos
|
|
44
|
+
*/
|
|
45
|
+
export declare const getNodeOverlayIconPosition: (iconSize: number, mainFaceRadius: number, position: [number, number]) => {
|
|
46
|
+
iconXPos: number;
|
|
47
|
+
iconYPos: number;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Calculates the rendered radius of a node including pixel ratio
|
|
51
|
+
* @param node - The node object with optional size property
|
|
52
|
+
* @param pixelRatio - Device pixel ratio
|
|
53
|
+
* @param defaultNodeSize - Default size to use if node.size is undefined
|
|
54
|
+
* @returns The radius in pixels
|
|
55
|
+
*/
|
|
56
|
+
export declare const getNodeRadius: (node: {
|
|
57
|
+
size?: number;
|
|
58
|
+
}, pixelRatio: number, defaultNodeSize: number) => number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Node, Relationship } from '
|
|
2
|
-
import type { Point } from '
|
|
1
|
+
import type { Node, Relationship } from '../../../types/graph-element';
|
|
2
|
+
import type { Point } from '../../../utils/geometry';
|
|
3
3
|
export type TextSegment = {
|
|
4
4
|
hasEllipsisChar?: boolean;
|
|
5
5
|
hasHyphenChar?: boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const fontThresholds: [number, number][];
|
|
2
|
+
/**
|
|
3
|
+
* This function takes color in hex format or rgb() or rgba() format and overrides the opacity. Returns rgba() string.
|
|
4
|
+
* @param color - * @param opacity - * @returns rgba() string with the given opacity.
|
|
5
|
+
*/
|
|
6
|
+
export declare const overrideOpacity: (color: string, opacity: number) => string;
|
|
7
|
+
export declare function getIndividualInfoLevels(r: number, zoomLevel: number): {
|
|
8
|
+
nodeInfoLevel: number;
|
|
9
|
+
fontInfoLevel: number;
|
|
10
|
+
iconInfoLevel: number;
|
|
11
|
+
};
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { StyledCaption, TextSegment } from './types';
|
|
2
2
|
export declare const hyphenChar = "\u2010";
|
|
3
3
|
export declare const ellipsisChar = "\u2026";
|
|
4
|
+
/**
|
|
5
|
+
* Calculates the maximum width for a relationship caption based on the distance
|
|
6
|
+
* between the two center waypoints. Uses Euclidean distance.
|
|
7
|
+
* @param points - Array of relationship waypoints
|
|
8
|
+
* @returns The maximum width for the caption
|
|
9
|
+
*/
|
|
10
|
+
export declare const getRelationshipCaptionMaxWidth: (points: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
}[]) => number;
|
|
4
14
|
/**
|
|
5
15
|
* This is the main function that tries to fit a text on one or more lines
|
|
6
16
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { NvlState } from '../../../modules/state/types';
|
|
2
|
+
import type { Node } from '../../../types/graph-element';
|
|
3
|
+
import type { RendererOptions } from '../BaseRenderer';
|
|
4
|
+
import BaseRenderer from '../BaseRenderer';
|
|
5
|
+
export default class SvgRenderer extends BaseRenderer {
|
|
6
|
+
private svg;
|
|
7
|
+
private measurementContext;
|
|
8
|
+
constructor(svg: SVGSVGElement, state: NvlState, options?: RendererOptions);
|
|
9
|
+
render(positionArray: Node[], positionBoundaries?: {
|
|
10
|
+
centerX: number;
|
|
11
|
+
centerY: number;
|
|
12
|
+
nodesWidth: number;
|
|
13
|
+
nodesHeight: number;
|
|
14
|
+
}, options?: {
|
|
15
|
+
svg?: SVGSVGElement;
|
|
16
|
+
backgroundColor?: string;
|
|
17
|
+
showCaptions?: boolean;
|
|
18
|
+
}): void;
|
|
19
|
+
private renderNodes;
|
|
20
|
+
private renderRelationships;
|
|
21
|
+
private getSvgTransform;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { Point } from '../../../utils/geometry';
|
|
2
|
+
/**
|
|
3
|
+
* Applies text styles to an SVG tspan element based on a style string
|
|
4
|
+
* @param {SVGTSpanElement} tspanElem - The SVG tspan element to style
|
|
5
|
+
* @param {string} styleStr - Comma-separated style string (e.g., "bold,italic")
|
|
6
|
+
*/
|
|
7
|
+
export declare const applySvgTextStyles: (tspanElem: SVGTSpanElement, styleStr: string) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Builds an SVG path string for a self-referencing loop using quadratic curves
|
|
10
|
+
* @param startPoint - The start point of the loop
|
|
11
|
+
* @param endPoint - The end point of the loop
|
|
12
|
+
* @param apexPoint - The apex (top) point of the loop
|
|
13
|
+
* @param control1Point - The first control point
|
|
14
|
+
* @param control2Point - The second control point
|
|
15
|
+
* @returns SVG path string
|
|
16
|
+
*/
|
|
17
|
+
export declare const buildSelfLoopPath: (startPoint: Point, endPoint: Point, apexPoint: Point, control1Point: Point, control2Point: Point) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Builds an SVG path string for a polyline with quadratic curves between points
|
|
20
|
+
* @param points - Array of points along the path
|
|
21
|
+
* @returns SVG path string
|
|
22
|
+
*/
|
|
23
|
+
export declare const buildQuadraticCurvePath: (points: Point[]) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Converts an array of points to an SVG polyline points attribute string
|
|
26
|
+
* @param points - Array of points
|
|
27
|
+
* @returns String suitable for SVG polyline points attribute
|
|
28
|
+
*/
|
|
29
|
+
export declare const pointsToPolylineString: (points: Point[]) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Creates an SVG arrowhead polygon element with selection rings
|
|
32
|
+
* @param arrowHead - Arrowhead geometry (tip, base1, base2 points)
|
|
33
|
+
* @param fillColor - Fill color for the arrowhead
|
|
34
|
+
* @param rings - Selection rings configuration
|
|
35
|
+
* @param pixelRatio - Device pixel ratio
|
|
36
|
+
* @returns Array of SVG polygon elements [rings..., arrowhead]
|
|
37
|
+
*/
|
|
38
|
+
export declare const createArrowHeadWithRings: (arrowHead: {
|
|
39
|
+
tip: Point;
|
|
40
|
+
base1: Point;
|
|
41
|
+
base2: Point;
|
|
42
|
+
}, fillColor: string, rings: Array<{
|
|
43
|
+
color: string;
|
|
44
|
+
width: number;
|
|
45
|
+
}>, pixelRatio: number) => SVGPolygonElement[];
|
|
46
|
+
/**
|
|
47
|
+
* Creates an SVG text element with styled spans
|
|
48
|
+
* @param options - Configuration options for the text element
|
|
49
|
+
* @param options.x - X coordinate
|
|
50
|
+
* @param options.y - Y coordinate
|
|
51
|
+
* @param options.fontSize - Font size
|
|
52
|
+
* @param options.fontFace - Font family
|
|
53
|
+
* @param options.fontColor - Text color
|
|
54
|
+
* @param options.textAnchor - Text anchor ('start', 'middle', 'end')
|
|
55
|
+
* @param options.dominantBaseline - Dominant baseline ('auto', 'middle', etc.)
|
|
56
|
+
* @param options.lineSpans - Array of text spans with styles
|
|
57
|
+
* @param options.transform - Optional transform attribute
|
|
58
|
+
* @param options.fontWeight - Optional font weight
|
|
59
|
+
* @returns SVG text element with tspan children
|
|
60
|
+
*/
|
|
61
|
+
export declare const createStyledTextElement: (options: {
|
|
62
|
+
x: number;
|
|
63
|
+
y: number;
|
|
64
|
+
fontSize: number;
|
|
65
|
+
fontFace: string;
|
|
66
|
+
fontColor: string;
|
|
67
|
+
textAnchor: string;
|
|
68
|
+
dominantBaseline: string;
|
|
69
|
+
lineSpans: Array<{
|
|
70
|
+
text: string;
|
|
71
|
+
style: string;
|
|
72
|
+
}>;
|
|
73
|
+
transform?: string;
|
|
74
|
+
fontWeight?: string;
|
|
75
|
+
}) => SVGTextElement;
|
|
76
|
+
/**
|
|
77
|
+
* Creates an SVG path element with selection rings
|
|
78
|
+
* @param pathData - SVG path d attribute
|
|
79
|
+
* @param strokeColor - Stroke color for the path
|
|
80
|
+
* @param strokeWidth - Stroke width for the path
|
|
81
|
+
* @param rings - Selection rings configuration
|
|
82
|
+
* @param pixelRatio - Device pixel ratio
|
|
83
|
+
* @returns Array of SVG path elements [rings..., path]
|
|
84
|
+
*/
|
|
85
|
+
export declare const createPathWithRings: (pathData: string, strokeColor: string, strokeWidth: number, rings: Array<{
|
|
86
|
+
color: string;
|
|
87
|
+
width: number;
|
|
88
|
+
}>, pixelRatio: number) => SVGPathElement[];
|
|
89
|
+
/**
|
|
90
|
+
* Creates an SVG polyline element with selection rings
|
|
91
|
+
* @param points - Polyline points string
|
|
92
|
+
* @param strokeColor - Stroke color for the polyline
|
|
93
|
+
* @param strokeWidth - Stroke width for the polyline
|
|
94
|
+
* @param rings - Selection rings configuration
|
|
95
|
+
* @param pixelRatio - Device pixel ratio
|
|
96
|
+
* @returns Array of SVG polyline elements [rings..., polyline]
|
|
97
|
+
*/
|
|
98
|
+
export declare const createPolylineWithRings: (points: string, strokeColor: string, strokeWidth: number, rings: Array<{
|
|
99
|
+
color: string;
|
|
100
|
+
width: number;
|
|
101
|
+
}>, pixelRatio: number) => SVGPolylineElement[];
|
|
102
|
+
/**
|
|
103
|
+
* Calculates arrowhead geometry for relationship endpoints (SVG-specific)
|
|
104
|
+
* @param point1 - First point (direction from)
|
|
105
|
+
* @param point2 - Second point (direction to)
|
|
106
|
+
* @param arrowLength - Length of the arrowhead
|
|
107
|
+
* @param arrowWidth - Width of the arrowhead
|
|
108
|
+
* @param offsetFactor - Factor to offset the tip (default 1/3)
|
|
109
|
+
* @returns Object containing arrowhead points
|
|
110
|
+
*/
|
|
111
|
+
export declare const getArrowheadGeometry: (point1: {
|
|
112
|
+
x: number;
|
|
113
|
+
y: number;
|
|
114
|
+
}, point2: {
|
|
115
|
+
x: number;
|
|
116
|
+
y: number;
|
|
117
|
+
}, arrowLength: number, arrowWidth: number, offsetFactor?: number) => {
|
|
118
|
+
tip: {
|
|
119
|
+
x: number;
|
|
120
|
+
y: number;
|
|
121
|
+
};
|
|
122
|
+
base1: {
|
|
123
|
+
x: number;
|
|
124
|
+
y: number;
|
|
125
|
+
};
|
|
126
|
+
base2: {
|
|
127
|
+
x: number;
|
|
128
|
+
y: number;
|
|
129
|
+
};
|
|
130
|
+
angle: number;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Calculates the proper angle for relationship labels to prevent upside-down text (SVG-specific)
|
|
134
|
+
* @param angle - The original angle in radians
|
|
135
|
+
* @returns The corrected angle in degrees
|
|
136
|
+
*/
|
|
137
|
+
export declare const getCorrectLabelAngle: (angle: number) => number;
|
|
138
|
+
/**
|
|
139
|
+
* Processes caption data for SVG rendering
|
|
140
|
+
* @param captions - Array of caption objects with value and styles
|
|
141
|
+
* @param caption - Legacy single caption string
|
|
142
|
+
* @returns Object with fullCaption and stylesPerChar array
|
|
143
|
+
*/
|
|
144
|
+
/**
|
|
145
|
+
* Groups consecutive characters with the same style into text spans
|
|
146
|
+
* @param lineText - The text of the line
|
|
147
|
+
* @param stylesPerChar - Array of style arrays for each character
|
|
148
|
+
* @param startCharIndex - The starting character index in the overall caption
|
|
149
|
+
* @returns Array of text spans with their styles
|
|
150
|
+
*/
|
|
151
|
+
export declare const getGroupedTextSpans: (lineText: string, stylesPerChar: string[][], startCharIndex: number) => {
|
|
152
|
+
text: string;
|
|
153
|
+
style: string;
|
|
154
|
+
}[];
|
|
155
|
+
/**
|
|
156
|
+
* Creates an SVG image element for node icons
|
|
157
|
+
* @param options - Configuration options for the icon element
|
|
158
|
+
* @param options.nodeX - X coordinate of the node center
|
|
159
|
+
* @param options.nodeY - Y coordinate of the node center
|
|
160
|
+
* @param options.iconXPos - X offset from node center to icon position
|
|
161
|
+
* @param options.iconYPos - Y offset from node center to icon position
|
|
162
|
+
* @param options.iconSize - Size (width and height) of the icon
|
|
163
|
+
* @param options.image - The image from cache (HTMLCanvasElement)
|
|
164
|
+
* @param options.isDisabled - Whether the node is disabled
|
|
165
|
+
* @returns SVG image element
|
|
166
|
+
*/
|
|
167
|
+
export declare const createSvgIconElement: (options: {
|
|
168
|
+
nodeX: number;
|
|
169
|
+
nodeY: number;
|
|
170
|
+
iconXPos: number;
|
|
171
|
+
iconYPos: number;
|
|
172
|
+
iconSize: number;
|
|
173
|
+
image: HTMLCanvasElement;
|
|
174
|
+
isDisabled: boolean;
|
|
175
|
+
}) => SVGImageElement;
|
|
@@ -27,13 +27,17 @@ export default class Renderer {
|
|
|
27
27
|
private relBuffer;
|
|
28
28
|
private nodeBuffer;
|
|
29
29
|
private posTexture;
|
|
30
|
+
private nodeVao;
|
|
31
|
+
private relVao;
|
|
32
|
+
private nodeAnimVao;
|
|
33
|
+
private vaoExt;
|
|
30
34
|
constructor(gl: WebGLRenderingContext, nodes: DataSet<Node>, rels: DataSet<Relationship>, state: NvlState);
|
|
31
35
|
private setShaderUniforms;
|
|
32
36
|
setData(data: {
|
|
33
37
|
nodes: Node[];
|
|
34
38
|
rels: Relationship[];
|
|
35
39
|
}): void;
|
|
36
|
-
render(positionArray: Node[]
|
|
40
|
+
render(positionArray: Node[]): void;
|
|
37
41
|
renderViewbox(): void;
|
|
38
42
|
updateNodes(updates: Node[]): void;
|
|
39
43
|
updateRelationships(relItems: Relationship[]): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -13,6 +13,21 @@ export declare const createCanvasForScreenshot: (fullWidth: number, fullHeight:
|
|
|
13
13
|
export declare const createCanvasForRenderer: (parent?: HTMLElement, onContextLostCallback?: (e: WebGLContextEvent) => void) => HTMLCanvasElement;
|
|
14
14
|
export declare const removeCanvas: (canvas: HTMLCanvasElement) => void;
|
|
15
15
|
export declare const getCanvas2DContext: (canvas: HTMLCanvasElement) => CanvasRenderingContext2D;
|
|
16
|
-
export declare const getWebGLContext: (canvas: HTMLCanvasElement) => WebGLRenderingContext
|
|
16
|
+
export declare const getWebGLContext: (canvas: HTMLCanvasElement) => WebGLRenderingContext;
|
|
17
17
|
export declare const removeWebGLContext: (webGLCtx: WebGLRenderingContext) => void;
|
|
18
18
|
export declare const checkWebGLAvailability: (canvas?: HTMLCanvasElement) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Measures the width of text with caching to avoid expensive measureText operations.
|
|
21
|
+
*
|
|
22
|
+
* The cache key is based on the current font, so that measurements are accurate
|
|
23
|
+
* even when font properties change.
|
|
24
|
+
*
|
|
25
|
+
* @param ctx - The canvas rendering context
|
|
26
|
+
* @param text - The text to measure
|
|
27
|
+
* @returns The width of the text in pixels
|
|
28
|
+
*/
|
|
29
|
+
export declare const measureTextCached: (ctx: CanvasRenderingContext2D, text: string) => number;
|
|
30
|
+
/**
|
|
31
|
+
* Clears the text measurement cache.
|
|
32
|
+
*/
|
|
33
|
+
export declare const clearTextMeasurementCache: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,7 +2,7 @@ export declare const PhysTextureSize = 256;
|
|
|
2
2
|
export declare const SpringTextureSize = 4096;
|
|
3
3
|
export declare const MaxIndexBuffer = 65536;
|
|
4
4
|
export declare const MinRelLength = 100;
|
|
5
|
-
export declare const Gravity =
|
|
5
|
+
export declare const Gravity = 25;
|
|
6
6
|
export declare const SimulationStopVelocity = 100;
|
|
7
7
|
export declare const VerletSimulationStopVelocity = 0.25;
|
|
8
8
|
export declare const MappingEnd = 999999;
|
|
@@ -12,6 +12,7 @@ export declare const DefaultNodeColor = "#FFDF81";
|
|
|
12
12
|
export declare const DefaultRelColor = "#818790";
|
|
13
13
|
export declare const DefaultRelWidth = 1;
|
|
14
14
|
export declare const MaxFlatRelWidth = 20;
|
|
15
|
+
export declare const DefaultRelationshipThreshold = 0;
|
|
15
16
|
export declare const DisabledItemColor = "#EDEDED";
|
|
16
17
|
export declare const DisabledItemFontColor = "#DDDDDD";
|
|
17
18
|
export declare const DefaultShadowColor = "#CFD1D4";
|
|
@@ -19,6 +20,8 @@ export declare const DefaultSelectedInnerColor = "#F5F6F6";
|
|
|
19
20
|
export declare const DefaultSelectedOuterColor = "#8FE3E8";
|
|
20
21
|
export declare const TextColor = "#1A1B1D";
|
|
21
22
|
export declare const TextColorInverse = "#FFFFFF";
|
|
23
|
+
export declare const MaxArrowCountWithShadows = 500;
|
|
24
|
+
export declare const DefaultFontFace = "\"Open Sans\", sans-serif";
|
|
22
25
|
export declare const absFillStyle: {
|
|
23
26
|
position: string;
|
|
24
27
|
top: number;
|
|
@@ -8,13 +8,14 @@ export interface Point {
|
|
|
8
8
|
/** The y coordinate of the point. */
|
|
9
9
|
y: number;
|
|
10
10
|
}
|
|
11
|
+
export declare const isPointDefined: (point: Point | Node) => boolean;
|
|
11
12
|
/**
|
|
12
13
|
* This function checks if the coordinates are defined.
|
|
13
14
|
* @param from - The {@link Node} the edge starts from.
|
|
14
15
|
* @param to - The {@link Node} the edge ends at.
|
|
15
16
|
* @returns True if the coordinates are defined.
|
|
16
17
|
*/
|
|
17
|
-
export declare const
|
|
18
|
+
export declare const areEndpointsDefined: (from: Point | Node, to: Point | Node) => boolean;
|
|
18
19
|
/**
|
|
19
20
|
* Returns true if the two points are within PointDelta pixels of each other
|
|
20
21
|
* This function is used to determine if a new point is close enough to an
|