@neo4j-nvl/base 1.1.0 → 1.2.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/base.mjs +1 -1
  3. package/dist/types/index.d.ts +20 -1
  4. package/dist/types/layouts/d3forcelayout/__mocks__/d3ForceLayout.d.ts +10 -0
  5. package/dist/types/layouts/d3forcelayout/d3ForceLayout.d.ts +20 -20
  6. package/dist/types/layouts/d3forcelayout/d3ForceLayout.test.d.ts +1 -0
  7. package/dist/types/layouts/d3forcelayout/types.d.ts +5 -6
  8. package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +0 -1
  9. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment.d.ts +1 -1
  10. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment.d.ts +1 -1
  11. package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.bench.d.ts +1 -0
  12. package/dist/types/layouts/gridLayout/GridLayout.d.ts +25 -9
  13. package/dist/types/modules/NvlController.d.ts +17 -3
  14. package/dist/types/modules/NvlController.test.d.ts +1 -0
  15. package/dist/types/modules/state/types.d.ts +2 -6
  16. package/dist/types/renderers/domrenderer/BaseRenderer.d.ts +1 -1
  17. package/dist/types/renderers/domrenderer/BaseRenderer.test.d.ts +1 -0
  18. package/dist/types/renderers/domrenderer/canvasrenderer/CanvasRenderer.d.ts +2 -36
  19. package/dist/types/renderers/domrenderer/canvasrenderer/arrowDrawing.d.ts +168 -0
  20. package/dist/types/renderers/domrenderer/canvasrenderer/arrowDrawing.test.d.ts +1 -0
  21. package/dist/types/renderers/domrenderer/canvasrenderer/nodeDrawing.d.ts +109 -0
  22. package/dist/types/renderers/domrenderer/canvasrenderer/nodeDrawing.test.d.ts +1 -0
  23. package/dist/types/renderers/domrenderer/shared/ImageCache.d.ts +3 -2
  24. package/dist/types/renderers/domrenderer/shared/arrows/ArrowBundle.d.ts +18 -2
  25. package/dist/types/renderers/domrenderer/shared/arrows/ArrowBundler.d.ts +10 -0
  26. package/dist/types/renderers/domrenderer/shared/nodes/nodes.d.ts +53 -1
  27. package/dist/types/renderers/domrenderer/shared/util.d.ts +6 -1
  28. package/dist/types/renderers/domrenderer/shared/wordwrap.d.ts +12 -1
  29. package/dist/types/renderers/domrenderer/svgrenderer/SvgRenderer.d.ts +1 -3
  30. package/dist/types/renderers/domrenderer/svgrenderer/arrowDrawing.d.ts +59 -0
  31. package/dist/types/renderers/domrenderer/svgrenderer/arrowDrawing.test.d.ts +1 -0
  32. package/dist/types/renderers/domrenderer/svgrenderer/nodeDrawing.d.ts +16 -0
  33. package/dist/types/renderers/domrenderer/svgrenderer/nodeDrawing.test.d.ts +1 -0
  34. package/dist/types/renderers/domrenderer/svgrenderer/svgUtils.d.ts +33 -141
  35. package/dist/types/renderers/domrenderer/svgrenderer/svgUtils.test.d.ts +1 -0
  36. package/dist/types/utils/constants.d.ts +3 -2
  37. package/dist/types/utils/geometry.d.ts +4 -0
  38. package/dist/types/utils/segmentAnalytics.d.ts +2 -2
  39. package/package.json +6 -5
  40. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment-verlet.d.ts +0 -2
  41. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment-verlet.d.ts +0 -2
  42. package/dist/types/renderers/domrenderer/canvasrenderer/canvasUtils.d.ts +0 -56
  43. package/dist/types/renderers/domrenderer/shared/nodes/nodeUtils.d.ts +0 -29
@@ -0,0 +1,109 @@
1
+ import type { BorderStyle, DisabledItemStyles, ShadowStyle } from '../../../modules/state/types';
2
+ import type { Node } from '../../../types/graph-element';
3
+ import type { TextSegment } from '../shared/types';
4
+ import type AnimationHandler from './AnimationHandler';
5
+ /**
6
+ * Draws borders around a node with a given array of border styles
7
+ * @param ctx - The canvas context.
8
+ * @param x - The x coordinate of the node.
9
+ * @param y - The y coordinate of the node.
10
+ * @param innerRadius - The inner radius of the node without any border.
11
+ * @param borderStyles - An array of border styles.
12
+ * @internal
13
+ * @hidden
14
+ */
15
+ export declare const drawCircleBand: (ctx: CanvasRenderingContext2D, x: number, y: number, innerRadius: number, borderStyles: {
16
+ width: number;
17
+ color: string;
18
+ }[]) => void;
19
+ /**
20
+ * Fill a circle band with a gradient from a certain color to transparent
21
+ * @param ctx - The canvas context.
22
+ * @param x - The x coordinate of the node.
23
+ * @param y - The y coordinate of the node.
24
+ * @param color - The color of the gradient.
25
+ * @param radius - The inner radius of the node without any border.
26
+ * @param blur - The blur radius of the gradient.
27
+ * @param maxOpacity - The maximum opacity of the gradient.
28
+ */
29
+ export declare const drawGradientCircleBand: (ctx: CanvasRenderingContext2D, x: number, y: number, color: string, radius: number, blur: number, maxOpacity?: number) => void;
30
+ /**
31
+ * Draw a circle shape with a solid color
32
+ */
33
+ export declare const drawSolidCircle: (ctx: CanvasRenderingContext2D, x: number, y: number, color: string, size: number) => void;
34
+ /**
35
+ * Prints the caption for a node
36
+ */
37
+ 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;
38
+ /**
39
+ * Calculate pulse animation parameters based on current animation state.
40
+ * The pulse grows from the node center to 1.88x the node radius, then fades out.
41
+ * This creates an expanding circle effect.
42
+ *
43
+ * @param nodeId - The unique identifier of the node
44
+ * @param animationHandler - The animation handler managing animation state
45
+ * @param mainFaceRadius - The radius of the main node circle in pixels
46
+ * @returns The calculated pulse radius
47
+ */
48
+ export declare const calculatePulseAnimation: (mainFaceRadius: number) => {
49
+ pulseRadius: number;
50
+ pulseVisibility: number;
51
+ };
52
+ /**
53
+ * Calculate shadow animation parameters based on node state.
54
+ * Animates shadow width from 0 to target based on selected/hovered state.
55
+ *
56
+ * @param nodeId - The unique identifier of the node
57
+ * @param animationHandler - The animation handler managing animation state
58
+ * @param selected - Whether the node is selected
59
+ * @param hovered - Whether the node is hovered
60
+ * @param shadowStyle - The shadow style configuration
61
+ * @returns Object with shadowWidth, shadowFade, and shadowColor, or null if no shadow needed
62
+ */
63
+ export declare const calculateShadowAnimation: (nodeId: string, animationHandler: AnimationHandler, selected: boolean, hovered: boolean, shadowStyle: ShadowStyle) => {
64
+ shadowWidth: number;
65
+ shadowColor: string;
66
+ shadowFade: number;
67
+ };
68
+ /**
69
+ * Returns an array of styles for the rings of a node.
70
+ * If the node is selected, it uses the selected ring styles.
71
+ * Otherwise, it uses the default ring styles.
72
+ * When no rings are configured, existing ring animations are wound down.
73
+ *
74
+ * @param node - The node to get the ring styles for.
75
+ * @param animationHandler - The animation handler.
76
+ * @param nodeBorderStyles - The node border styles.
77
+ * @returns An array of ring styles with computed widths.
78
+ */
79
+ export type NodeRenderParamsInput = {
80
+ node: Node;
81
+ mainFaceRadius: number;
82
+ disabled: boolean;
83
+ disabledItemStyles: DisabledItemStyles;
84
+ selectedBorderStyle: BorderStyle;
85
+ animationHandler: AnimationHandler;
86
+ defaultNodeColor: string;
87
+ };
88
+ /**
89
+ * Calculate all node render parameters at once.
90
+ * This is the main entry point for preparing node rendering calculations.
91
+ *
92
+ * @param input - The input parameters object
93
+ * @returns object with node render parameters
94
+ */
95
+ export declare const calculateNodeRenderParams: (input: NodeRenderParamsInput) => {
96
+ nodeColor: string;
97
+ fontColor: string;
98
+ shouldRenderPulse: boolean;
99
+ pulseAnimation: {
100
+ pulseColor: string;
101
+ pulseRadius: number;
102
+ };
103
+ shouldRenderShadow: boolean;
104
+ shadowAnimation: {
105
+ shadowWidth: number;
106
+ shadowFade: number;
107
+ shadowColor: string;
108
+ };
109
+ };
@@ -1,7 +1,8 @@
1
1
  import type { Cache } from '../shared/types';
2
2
  declare class ImageCache {
3
- cache: Cache;
4
- constructor();
3
+ readonly cache: Cache;
4
+ private readonly onImageLoadedCb?;
5
+ constructor(onImageLoaded?: () => void);
5
6
  getImage(src: string, inverted?: boolean): HTMLCanvasElement;
6
7
  private getOrCreateEntry;
7
8
  private invertCanvas;
@@ -19,12 +19,28 @@ export default class ArrowBundle {
19
19
  toId: string;
20
20
  angles: number[];
21
21
  labelInfo: Record<string, LabelGeometry>;
22
+ relIndexCache: Map<string, number>;
23
+ relDirectionCache: Map<string, boolean>;
24
+ private cachedMaxFontSize;
22
25
  /**
23
26
  * @param key - The key of the arrow bundle.
24
27
  * @param fromId - The source node of the arrow bundle.
25
28
  * @param toId - The target node of the arrow bundle.
26
29
  */
27
30
  constructor(key: string, fromId: string, toId: string);
31
+ /**
32
+ * Recalculate and cache the maximum font size
33
+ */
34
+ updateMaxFontSize(): void;
35
+ /**
36
+ * Updates the relationship direction cache with a given relationship
37
+ * @param rel - The relationship to update the direction for.
38
+ */
39
+ updateRelDirection(rel: Relationship): void;
40
+ /**
41
+ * Regenerates index cache for rel ids in bundle
42
+ */
43
+ updateIndexCache(): void;
28
44
  /**
29
45
  * Insert a new arrow to the bundle
30
46
  * @param rel - The relationship to insert.
@@ -53,7 +69,7 @@ export default class ArrowBundle {
53
69
  * @param rel - The relationship to check.
54
70
  * @returns True if the relationship is in opposite direction to the bundle.
55
71
  */
56
- relIsOppositeDirection({ from, to }: Relationship): boolean;
72
+ relIsOppositeDirection({ id }: Relationship): boolean;
57
73
  /**
58
74
  * Get the index of a given arrow in the bundle
59
75
  * @param rel - The arrow to look for.
@@ -65,7 +81,7 @@ export default class ArrowBundle {
65
81
  * @param index - The index of the arrow to get.
66
82
  * @returns The arrow at the given index.
67
83
  */
68
- getRel(index: number): Relationship | null;
84
+ getRel(index: number): Relationship;
69
85
  /**
70
86
  * Set the waypoints for the arrow bundle
71
87
  * @param waypoints - The waypoints for the arrow bundle.
@@ -4,6 +4,7 @@ import ArrowBundle from './ArrowBundle';
4
4
  export default class ArrowBundler {
5
5
  bundles: Record<string, ArrowBundle>;
6
6
  nodeToBundles: Record<string, ArrowBundle[]>;
7
+ relToBundleKey: Map<string, string>;
7
8
  constructor(rels: Relationship[], waypoints: Record<string, WaypointPath>);
8
9
  /**
9
10
  * Get the arrow bundle for a given relation
@@ -23,6 +24,15 @@ export default class ArrowBundler {
23
24
  * @param positionMap A map of node IDs to positions.
24
25
  */
25
26
  updatePositions(positionMap: Record<string, Node>): void;
27
+ /**
28
+ * Remove a bundle reference from the node→bundles index for one node id.
29
+ */
30
+ private removeNodeFromMap;
31
+ /**
32
+ * Remove a relationship from a bundle.
33
+ * If the bundle is now empty, remove it from `bundles` and the node index.
34
+ */
35
+ private removeRelFromBundle;
26
36
  /**
27
37
  * Get a unique ID for a pair of IDs
28
38
  * @param id1 - The first ID.
@@ -1,4 +1,14 @@
1
+ import type { BorderStyles } from '../../../../modules/state/types';
1
2
  import type { Node } from '../../../../types/graph-element';
3
+ import type AnimationHandler from '../../canvasrenderer/AnimationHandler';
4
+ import type { TextSegment } from '../types';
5
+ /**
6
+ * Returns the effective node size, which is either the provided size
7
+ * if it's a positive and finite number, or the default node size otherwise.
8
+ * @param size
9
+ * @returns The effective node size.
10
+ */
11
+ export declare const getEffectiveNodeSize: (size?: number) => number;
2
12
  /**
3
13
  * Returns the bounding box of a node with the given x, y, and size properties.
4
14
  * If no size is given, the default size is used.
@@ -46,6 +56,16 @@ export declare const getNodeOverlayIconPosition: (iconSize: number, mainFaceRadi
46
56
  iconXPos: number;
47
57
  iconYPos: number;
48
58
  };
59
+ /**
60
+ * Returns the caption font size that should be used
61
+ * for the given info level and node diameter.
62
+ * @param infoLevel {number} - The info level.
63
+ * @param nodeRadius {number} - The radius of the node.
64
+ * @param captionSize {number} - The size of the caption.
65
+ * @param hasIcon {boolean} - Whether the node has an icon.
66
+ * @returns {number} - The font size.
67
+ */
68
+ export declare const infoLevelToFontSize: (infoLevel: number, nodeRadius?: number, captionSize?: number, hasIcon?: boolean) => number;
49
69
  /**
50
70
  * Calculates the rendered radius of a node including pixel ratio
51
71
  * @param node - The node object with optional size property
@@ -55,4 +75,36 @@ export declare const getNodeOverlayIconPosition: (iconSize: number, mainFaceRadi
55
75
  */
56
76
  export declare const getNodeRadius: (node: {
57
77
  size?: number;
58
- }, pixelRatio: number, defaultNodeSize: number) => number;
78
+ }) => number;
79
+ /**
80
+ * Prepares node caption data for rendering (works for both Canvas and SVG)
81
+ * @param node - The node to prepare caption data for
82
+ * @param zoomLevel - Current zoom level
83
+ * @param ctx - Canvas context for text measurement (optional for SVG, will create one if not provided)
84
+ * @returns Caption rendering data including lines, styles, positioning, and font info
85
+ */
86
+ export declare const prepareNodeCaptionData: (node: Node, zoomLevel: number, ctx?: CanvasRenderingContext2D) => {
87
+ lines: TextSegment[];
88
+ stylesPerChar: string[][];
89
+ fullCaption: string;
90
+ fontSize: number;
91
+ fontFace: string;
92
+ fontColor: string;
93
+ yPos: number;
94
+ maxNoLines: number;
95
+ hasContent: boolean;
96
+ };
97
+ /**
98
+ * Returns an array of styles for the rings of a node.
99
+ * If the node is selected, it uses the selected ring styles.
100
+ * Otherwise, it uses the default ring styles.
101
+ *
102
+ * @param node - The node to get the ring styles for.
103
+ * @param nodeBorderStyles - The node border styles.
104
+ * @param animationHandler - Optional animation handler for animating ring width changes.
105
+ * @returns An array of ring styles with computed widths.
106
+ */
107
+ export declare const getRingStyles: (node: Node, nodeBorderStyles: BorderStyles, animationHandler?: AnimationHandler) => {
108
+ width: number;
109
+ color: string;
110
+ }[];
@@ -4,8 +4,13 @@ export declare const fontThresholds: [number, number][];
4
4
  * @param color - * @param opacity - * @returns rgba() string with the given opacity.
5
5
  */
6
6
  export declare const overrideOpacity: (color: string, opacity: number) => string;
7
- export declare function getIndividualInfoLevels(r: number, zoomLevel: number): {
7
+ export declare const getIndividualInfoLevels: (r: number, zoomLevel: number) => {
8
8
  nodeInfoLevel: number;
9
9
  fontInfoLevel: number;
10
10
  iconInfoLevel: number;
11
11
  };
12
+ /**
13
+ * On-screen size for a node icon drawn at `iconDrawSize` in graph space
14
+ * under a uniform `scale(zoom)` viewport transform.
15
+ */
16
+ export declare const getNodeIconScreenPx: (iconDrawSize: number, zoom: number) => number;
@@ -36,11 +36,22 @@ export declare const tryWithNumberOfLines: (text: string, measureWidth: (text: s
36
36
  export declare const tryBreakingOnSpaces: (text: string, measureWidth: (text: string) => number, getAvailableWidth: (a: number, b: number) => number, numberOfLines: number) => TextSegment[];
37
37
  /**
38
38
  * @param ctx - = Canvas.2dContext
39
- * @param rtlAdjustedText - The text to display
39
+ * @param text - The text to display
40
40
  *
41
41
  * @return array of text lines
42
42
  */
43
43
  export declare const getLines: (ctx: CanvasRenderingContext2D, text: string, fontFace: string, fontSize: string | number, maxWidth: number, hasIcon: boolean, maxNoLines: number, align: string) => TextSegment[];
44
+ /**
45
+ * Groups consecutive characters with the same style into text spans.
46
+ * @param lineText - The text of the line to process.
47
+ * @param stylesPerChar - A 2D array where each entry corresponds to a character.
48
+ * @param startCharIndex - The index of the first character of lineText in the full caption.
49
+ * @returns An array of objects, each containing a text span and its associated style string.
50
+ */
51
+ export declare const getGroupedTextSpans: (lineText: string, stylesPerChar: string[][], startCharIndex: number) => {
52
+ text: string;
53
+ style: string;
54
+ }[];
44
55
  /**
45
56
  * Returns the styles by char for a group of property values.
46
57
  * @param captions - = array of captions
@@ -6,6 +6,7 @@ export default class SvgRenderer extends BaseRenderer {
6
6
  private svg;
7
7
  private measurementContext;
8
8
  constructor(svg: SVGSVGElement, state: NvlState, options?: RendererOptions);
9
+ clear(): void;
9
10
  render(positionArray: Node[], positionBoundaries?: {
10
11
  centerX: number;
11
12
  centerY: number;
@@ -16,7 +17,4 @@ export default class SvgRenderer extends BaseRenderer {
16
17
  backgroundColor?: string;
17
18
  showCaptions?: boolean;
18
19
  }): void;
19
- private renderNodes;
20
- private renderRelationships;
21
- private getSvgTransform;
22
20
  }
@@ -0,0 +1,59 @@
1
+ import type { BorderStyles, DisabledItemStyles } from '../../../modules/state/types';
2
+ import type { Point } from '../../../utils/geometry';
3
+ import type ImageCache from '../shared/ImageCache';
4
+ import type ArrowBundler from '../shared/arrows/ArrowBundler';
5
+ import type { RelationshipToRender } from '../shared/types';
6
+ /**
7
+ * Builds an SVG path string for a self-referencing loop using quadratic curves
8
+ */
9
+ export declare const buildSelfLoopPath: (startPoint: Point, endPoint: Point, apexPoint: Point, control1Point: Point, control2Point: Point) => string;
10
+ /**
11
+ * Builds an SVG path string for a polyline with quadratic curves between points
12
+ */
13
+ export declare const buildQuadraticCurvePath: (points: Point[]) => string;
14
+ /**
15
+ * Converts an array of points to an SVG polyline points attribute string
16
+ */
17
+ export declare const pointsToPolylineString: (points: Point[]) => string;
18
+ /**
19
+ * Creates an SVG arrowhead polygon element with selection rings
20
+ */
21
+ export declare const createArrowHeadWithRings: (arrowHead: {
22
+ tip: Point;
23
+ base1: Point;
24
+ base2: Point;
25
+ }, fillColor: string, rings: {
26
+ color: string;
27
+ width: number;
28
+ }[]) => SVGPolygonElement[];
29
+ /**
30
+ * Creates an SVG path element with selection rings
31
+ */
32
+ export declare const createPathWithRings: (pathData: string, strokeColor: string, strokeWidth: number, rings: {
33
+ color: string;
34
+ width: number;
35
+ }[]) => SVGPathElement[];
36
+ /**
37
+ * Creates an SVG polyline element with selection rings
38
+ */
39
+ export declare const createPolylineWithRings: (points: string, strokeColor: string, strokeWidth: number, rings: {
40
+ color: string;
41
+ width: number;
42
+ }[]) => SVGPolylineElement[];
43
+ /**
44
+ * Calculates the proper angle for relationship labels to prevent upside-down text (SVG-specific)
45
+ */
46
+ export declare const getCorrectLabelAngle: (angle: number) => number;
47
+ /**
48
+ * Renders an array of relationships to an SVG element.
49
+ *
50
+ * @param relationshipsToRender - Relationships with endpoint data to render
51
+ * @param svg - The SVG element to append relationship elements to
52
+ * @param drawCurves - Whether to draw curved paths (true) or polylines (false)
53
+ * @param arrowBundler - The arrow bundler for resolving relationship bundles
54
+ * @param disabledItemStyles - Styles for disabled relationships
55
+ * @param defaultRelationshipColor - Default relationship color
56
+ * @param relationshipBorderStyles - Border/ring styles for relationships
57
+ * @param measurementContext - Canvas 2D context for text measurement
58
+ */
59
+ export declare const renderSvgRelationships: (relationshipsToRender: RelationshipToRender[], svg: SVGElement, drawCurves: boolean, arrowBundler: ArrowBundler, disabledItemStyles: DisabledItemStyles, defaultRelationshipColor: string, relationshipBorderStyles: BorderStyles, measurementContext: CanvasRenderingContext2D, imageCache: ImageCache) => void;
@@ -0,0 +1,16 @@
1
+ import type { BorderStyles, DisabledItemStyles } from '../../../modules/state/types';
2
+ import type { Node } from '../../../types/graph-element';
3
+ import type ImageCache from '../shared/ImageCache';
4
+ /**
5
+ * Renders an array of nodes to an SVG element.
6
+ *
7
+ * @param nodesToRender - Nodes with position data to render
8
+ * @param svg - The SVG element to append node groups to
9
+ * @param zoom - Current zoom level
10
+ * @param idToItem - Map from node IDs to full node data
11
+ * @param disabledItemStyles - Styles for disabled nodes
12
+ * @param defaultNodeColor - Default node color
13
+ * @param nodeBorderStyles - Border/ring styles for nodes
14
+ * @param imageCache - Image cache for node icons
15
+ */
16
+ export declare const renderSvgNodes: (nodesToRender: Node[], svg: SVGElement, zoom: number, idToItem: Record<string, Node>, disabledItemStyles: DisabledItemStyles, defaultNodeColor: string, nodeBorderStyles: BorderStyles, imageCache: ImageCache) => void;
@@ -1,48 +1,40 @@
1
- import type { Point } from '../../../utils/geometry';
2
1
  /**
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
2
+ * Creates an SVG image element for an icon
3
+ *
4
+ * @param nodeX - The x-coordinate of the node
5
+ * @param nodeY - The y-coordinate of the node
6
+ * @param iconXPos - The x-position of the icon relative to the node
7
+ * @param iconYPos - The y-position of the icon relative to the node
8
+ * @param iconSize - The size of the icon
9
+ * @param image - The image to use for the icon
10
+ * @param isDisabled - Whether the icon should be disabled
16
11
  */
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;
12
+ export declare const createSvgIconElement: (options: {
13
+ nodeX: number;
14
+ nodeY: number;
15
+ iconXPos: number;
16
+ iconYPos: number;
17
+ iconSize: number;
18
+ image: HTMLCanvasElement;
19
+ isDisabled: boolean;
20
+ }) => SVGImageElement;
24
21
  /**
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
22
+ * Calculates the SVG transform string for viewport positioning
23
+ *
24
+ * @param width - SVG viewport width
25
+ * @param height - SVG viewport height
26
+ * @param zoom - Zoom level multiplier
27
+ * @param panX - Pan offset in X direction
28
+ * @param panY - Pan offset in Y direction
29
+ * @returns SVG transform string with translate and scale operations
28
30
  */
29
- export declare const pointsToPolylineString: (points: Point[]) => string;
31
+ export declare const calculateSvgTransform: (width: number, height: number, zoom: number, panX: number, panY: number) => string;
30
32
  /**
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]
33
+ * Applies text styles to an SVG tspan element based on a style string
34
+ * @param {SVGTSpanElement} tspanElem - The SVG tspan element to style
35
+ * @param {string} styleStr - Comma-separated style string (e.g., "bold,italic")
37
36
  */
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[];
37
+ export declare const applySvgTextStyles: (tspanElem: SVGTSpanElement, styleStr: string) => void;
46
38
  /**
47
39
  * Creates an SVG text element with styled spans
48
40
  * @param options - Configuration options for the text element
@@ -66,110 +58,10 @@ export declare const createStyledTextElement: (options: {
66
58
  fontColor: string;
67
59
  textAnchor: string;
68
60
  dominantBaseline: string;
69
- lineSpans: Array<{
61
+ lineSpans: {
70
62
  text: string;
71
63
  style: string;
72
- }>;
64
+ }[];
73
65
  transform?: string;
74
66
  fontWeight?: string;
75
67
  }) => 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;
@@ -3,8 +3,7 @@ export declare const SpringTextureSize = 4096;
3
3
  export declare const MaxIndexBuffer = 65536;
4
4
  export declare const MinRelLength = 100;
5
5
  export declare const Gravity = 25;
6
- export declare const SimulationStopVelocity = 100;
7
- export declare const VerletSimulationStopVelocity = 0.25;
6
+ export declare const SimulationStopVelocity = 0.25;
8
7
  export declare const MappingEnd = 999999;
9
8
  export declare const ActiveAnimDuration = 1000;
10
9
  export declare const DefaultNodeSize = 25;
@@ -40,4 +39,6 @@ export declare const GlAdjust: number;
40
39
  */
41
40
  export declare const getDevicePixelRatio: () => number;
42
41
  export declare const HtmlCaptionMinWidthThreshold = 5;
42
+ /** Min on-screen icon size (px) before we skip drawing; avoids unreadable bitmaps when zoomed out. */
43
+ export declare const MinNodeIconScreenPx = 10;
43
44
  export declare const allowedWrappers: string[];
@@ -9,6 +9,10 @@ export interface Point {
9
9
  y: number;
10
10
  }
11
11
  export declare const isPointDefined: (point: Point | Node) => boolean;
12
+ /**
13
+ * Returns true when value is a finite number (not NaN or Infinity).
14
+ */
15
+ export declare const isValidFiniteNumber: (value: unknown) => value is number;
12
16
  /**
13
17
  * This function checks if the coordinates are defined.
14
18
  * @param from - The {@link Node} the edge starts from.
@@ -24,7 +24,7 @@ export declare abstract class AnalyticsFunction {
24
24
  /**
25
25
  * Get/fetch unique segment Id from the localstorage.
26
26
  */
27
- abstract getSegmentTrackingId(): Record<string, unknown>;
27
+ abstract getSegmentTrackingId(): string;
28
28
  /**
29
29
  * Track arbitrary event.
30
30
  */
@@ -44,7 +44,7 @@ export declare class SegmentAnalytics implements AnalyticsFunction {
44
44
  }): Promise<void>;
45
45
  identify(): void;
46
46
  loadSavedSegmentId(): string;
47
- getSegmentTrackingId(): any;
47
+ getSegmentTrackingId(): string;
48
48
  saveTrackingId(segmentId: string): void;
49
49
  private ready;
50
50
  }