@neo4j-nvl/base 1.2.0-ec8b9947 → 1.2.0-eea71f07
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 +16 -0
- package/README.md +1 -1
- package/dist/base.mjs +1 -1
- package/dist/types/index.d.ts +6 -5
- package/dist/types/layouts/animatedlayout/AnimatedLayout.d.ts +2 -2
- package/dist/types/layouts/d3forcelayout/d3ForceLayout.d.ts +2 -2
- package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +123 -13
- package/dist/types/layouts/forcedirectedlayout/physlayout/clustering/ClusterByMerger.d.ts +61 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/clustering/SolarMerger.d.ts +56 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/clustering/clustering-utils.d.ts +143 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/clustering/clustering-utils.test.d.ts +1 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/{solarmerger → clustering}/types.d.ts +10 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment.d.ts +1 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment.d.ts +1 -1
- package/dist/types/layouts/freeLayout/FreeLayout.d.ts +2 -4
- package/dist/types/layouts/gridLayout/GridLayout.d.ts +2 -6
- package/dist/types/modules/NvlController.d.ts +74 -4
- package/dist/types/modules/dataset.d.ts +3 -1
- package/dist/types/modules/state/types.d.ts +96 -20
- package/dist/types/modules/state/utils.d.ts +2 -2
- package/dist/types/renderers/ClusterOverlay.d.ts +80 -0
- package/dist/types/renderers/ClusterOverlay.test.d.ts +1 -0
- package/dist/types/renderers/domrenderer/canvasrenderer/arrowDrawing.d.ts +2 -16
- package/dist/types/renderers/domrenderer/shared/ImageCache.d.ts +1 -0
- package/dist/types/renderers/domrenderer/shared/arrows/arrows.d.ts +4 -6
- package/dist/types/renderers/webglrenderer/Controller.d.ts +27 -6
- package/dist/types/renderers/webglrenderer/IconLayerRegistry.d.ts +14 -0
- package/dist/types/renderers/webglrenderer/IconLayerRegistry.test.d.ts +1 -0
- package/dist/types/renderers/webglrenderer/Renderer.d.ts +43 -2
- package/dist/types/renderers/webglrenderer/node-animation-fragment.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/node-animation-vertex.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/node-fragment-point.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/node-vertex-point.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/rel-glsl-utils.d.ts +1 -0
- package/dist/types/renderers/webglrenderer/rel-vertex-arrow.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/rel-vertex-line.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/viewport-box-fragment.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/viewport-box-vertex.d.ts +1 -1
- package/dist/types/types/graph-element.d.ts +9 -1
- package/dist/types/types/nvl-window-functions.d.ts +2 -2
- package/dist/types/utils/clusterGeometry.d.ts +14 -0
- package/dist/types/utils/clusterGeometry.test.d.ts +1 -0
- package/dist/types/utils/constants.d.ts +1 -0
- package/dist/types/utils/geometry.d.ts +29 -0
- package/dist/types/utils/webWorkerUtils.d.ts +1 -1
- package/dist/types/utils/zoomFunctions.d.ts +9 -2
- package/package.json +5 -5
- package/dist/types/layouts/forcedirectedlayout/ForceCytoLayout.d.ts +0 -22
- package/dist/types/layouts/forcedirectedlayout/cosebilkentlayout/CoseBilkentLayout.d.ts +0 -33
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.d.ts +0 -21
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/solar-placer.d.ts +0 -2
- /package/dist/types/layouts/forcedirectedlayout/physlayout/{solarmerger/SolarMerger.bench.d.ts → clustering/ClusterByMerger.test.d.ts} +0 -0
- /package/dist/types/layouts/forcedirectedlayout/physlayout/{solarmerger/SolarMerger.test.d.ts → clustering/SolarMerger.bench.d.ts} +0 -0
- /package/dist/types/layouts/forcedirectedlayout/physlayout/{solarmerger/solar-placer.test.d.ts → clustering/SolarMerger.test.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NvlState } from '../../modules/state/types';
|
|
2
|
-
import type { Node } from '../../types/graph-element';
|
|
2
|
+
import type { Node, PartialNode } from '../../types/graph-element';
|
|
3
3
|
import type { Point } from '../../utils/geometry';
|
|
4
4
|
export declare class FreeLayout {
|
|
5
5
|
private state;
|
|
@@ -10,9 +10,7 @@ export declare class FreeLayout {
|
|
|
10
10
|
state: NvlState;
|
|
11
11
|
});
|
|
12
12
|
setOptions(): any;
|
|
13
|
-
updateNodes(positionList:
|
|
14
|
-
id: string;
|
|
15
|
-
})[]): void;
|
|
13
|
+
updateNodes(positionList: PartialNode[]): void;
|
|
16
14
|
update(refreshPositions?: boolean): void;
|
|
17
15
|
layout(nodes: Node[], nodeIds: Record<string, Node>, idToPosition: Record<string, Node>): void;
|
|
18
16
|
setNodePositions(p: Record<string, Point>): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NvlState } from '../../modules/state/types';
|
|
2
|
-
import type { Node } from '../../types/graph-element';
|
|
2
|
+
import type { Node, PartialNode } from '../../types/graph-element';
|
|
3
3
|
import type { Point } from '../../utils/geometry';
|
|
4
4
|
export declare class GridLayout {
|
|
5
5
|
state: NvlState;
|
|
@@ -10,11 +10,7 @@ export declare class GridLayout {
|
|
|
10
10
|
state: NvlState;
|
|
11
11
|
});
|
|
12
12
|
setOptions(): void;
|
|
13
|
-
updateNodes(positionList:
|
|
14
|
-
id: string;
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
}[]): void;
|
|
13
|
+
updateNodes(positionList: PartialNode[]): void;
|
|
18
14
|
update(refreshPositions?: boolean): void;
|
|
19
15
|
layout(mobxNodes: any): void;
|
|
20
16
|
setNodePositions(idToPosition: Record<string, Node & Point>): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Node, type PartialNode, type PartialRelationship, type Relationship } from '../types/graph-element';
|
|
1
|
+
import { type Node, type NodeWithClientPosition, type PartialNode, type PartialRelationship, type Relationship } from '../types/graph-element';
|
|
2
2
|
import '../types/nvl-window-functions';
|
|
3
3
|
import type { Point } from '../utils/geometry';
|
|
4
4
|
import type { ExternalCallbacks } from './ExternalCallbackHandler';
|
|
@@ -31,10 +31,13 @@ export default class NvlController {
|
|
|
31
31
|
private readonly forceLayout;
|
|
32
32
|
private readonly canvasRenderer;
|
|
33
33
|
private readonly svgRenderer;
|
|
34
|
+
private clusterOverlay;
|
|
34
35
|
private readonly glCanvas;
|
|
35
36
|
private canvasRect;
|
|
36
37
|
private readonly glMinimapCanvas;
|
|
37
38
|
private readonly c2dCanvas;
|
|
39
|
+
private clusterOverlayCanvas;
|
|
40
|
+
private readonly canvasParent;
|
|
38
41
|
private readonly svg;
|
|
39
42
|
private isInRenderSwitchAnimation;
|
|
40
43
|
private previousRenderer;
|
|
@@ -61,15 +64,76 @@ export default class NvlController {
|
|
|
61
64
|
private layoutComputingCallback;
|
|
62
65
|
private currentLayoutType;
|
|
63
66
|
private descriptionElement;
|
|
67
|
+
/** True when a minimap container was provided at construction. */
|
|
68
|
+
private readonly hasMinimap;
|
|
69
|
+
private lastMinimapPositions;
|
|
70
|
+
private lastMinimapCacheVersion;
|
|
64
71
|
constructor(state: NvlState, frame: HTMLElement, options: NvlOptions);
|
|
65
72
|
private onWebGLContextLost;
|
|
66
73
|
private fpsToFrameBudgetMs;
|
|
67
74
|
private getLayoutNeedsToUpdate;
|
|
68
75
|
private isWithinBudget;
|
|
76
|
+
/**
|
|
77
|
+
* Add elapsed frame time to the layout-step accumulator, capped at `layoutTimeLimit`.
|
|
78
|
+
* Prevents a slow frame (e.g. blocked GPU readback) from inflating catch-up debt and
|
|
79
|
+
* scheduling ever more work in a feedback loop; the layout falls behind gracefully instead.
|
|
80
|
+
*/
|
|
81
|
+
private accumulateLayoutElapsedTime;
|
|
82
|
+
/**
|
|
83
|
+
* Whether the GPU force-directed layout is active.
|
|
84
|
+
* @returns `true` when PhysLayout is the current layout.
|
|
85
|
+
*/
|
|
86
|
+
private usesGpuSimulation;
|
|
87
|
+
/**
|
|
88
|
+
* Whether the GPU-texture fast path can be taken this frame.
|
|
89
|
+
* Requires the WebGL renderer, GPU layout active, and no CPU-position consumers
|
|
90
|
+
* (layout-step callback, HTML overlays). A provided minimap no longer blocks this path;
|
|
91
|
+
* the minimap and cluster overlay are updated from the lagged async position cache instead.
|
|
92
|
+
* @returns `true` when rendering directly from the GPU position texture is safe.
|
|
93
|
+
*/
|
|
94
|
+
private canRenderFromGpuTexture;
|
|
95
|
+
/**
|
|
96
|
+
* Uploads lagged PhysLayout cache positions to the minimap when the cache version changed.
|
|
97
|
+
* @returns `true` when positions were refreshed this call.
|
|
98
|
+
*/
|
|
99
|
+
private refreshMinimapFromCacheIfStale;
|
|
100
|
+
/**
|
|
101
|
+
* Fits, renders, and caches minimap positions (and PhysLayout cache version when applicable).
|
|
102
|
+
*/
|
|
103
|
+
private syncMinimap;
|
|
104
|
+
/** Whether either cluster decoration is enabled in the current layout options. */
|
|
105
|
+
private hasClusterDecorations;
|
|
106
|
+
/**
|
|
107
|
+
* Creates the decoration canvas and its overlay.
|
|
108
|
+
* @returns The overlay to draw with.
|
|
109
|
+
*/
|
|
110
|
+
private createClusterOverlay;
|
|
111
|
+
/**
|
|
112
|
+
* Resolves the overlay to draw into, allocating it on first use and tearing it down again
|
|
113
|
+
* while cluster decorations are off.
|
|
114
|
+
* @returns The overlay to draw with, or null when decorations are disabled.
|
|
115
|
+
*/
|
|
116
|
+
private ensureClusterOverlay;
|
|
117
|
+
/** Tears the overlay and its canvas back down once decorations are switched off. */
|
|
118
|
+
private destroyClusterOverlay;
|
|
119
|
+
/**
|
|
120
|
+
* Draws (or clears) cluster decorations on the Canvas2D overlay from explicit positions.
|
|
121
|
+
* @param positions - CPU node positions for this frame, or null to clear.
|
|
122
|
+
*/
|
|
123
|
+
private renderClusterOverlay;
|
|
124
|
+
/**
|
|
125
|
+
* Draws cluster decorations from PhysLayout's lagged async PBO cache without a sync dump.
|
|
126
|
+
* @param forceLayout - The PhysLayout instance to render the cluster overlay from.
|
|
127
|
+
*/
|
|
128
|
+
private renderClusterOverlayFromCache;
|
|
129
|
+
/** Syncs idToPosition from the GPU layout on demand; no-op for CPU layouts. */
|
|
130
|
+
syncPositionsFromLayout(): void;
|
|
69
131
|
private updateMinimapZoom;
|
|
70
132
|
private startMainLoop;
|
|
133
|
+
private renderNodeHtmlOverlays;
|
|
134
|
+
private renderRelationshipHtmlOverlays;
|
|
71
135
|
updateHtmlOverlay(): void;
|
|
72
|
-
dumpNodes():
|
|
136
|
+
dumpNodes(): NodeWithClientPosition[];
|
|
73
137
|
dumpRelationships(): Relationship[];
|
|
74
138
|
/**
|
|
75
139
|
* Map a relative Canvas space to the DOM position
|
|
@@ -98,7 +162,7 @@ export default class NvlController {
|
|
|
98
162
|
};
|
|
99
163
|
registerDoneCallback(cb: NvlController['layoutDoneCallback']): void;
|
|
100
164
|
registerComputingCallback(cb: NvlController['layoutComputingCallback']): void;
|
|
101
|
-
getPosition(nodeId: string): Node;
|
|
165
|
+
getPosition(nodeId: string): Node & Point;
|
|
102
166
|
getScale(): number;
|
|
103
167
|
getPan(): {
|
|
104
168
|
x: number;
|
|
@@ -118,10 +182,16 @@ export default class NvlController {
|
|
|
118
182
|
getCanvasNodesAt(point: Point, hitNodeMarginWidth?: number): import("..").HitTargetNode[];
|
|
119
183
|
private getLayout;
|
|
120
184
|
setLayout(layoutType: Layout): void;
|
|
121
|
-
setLayoutOptions(options
|
|
185
|
+
setLayoutOptions(options?: LayoutOptions): void;
|
|
186
|
+
/**
|
|
187
|
+
* Syncs positions if needed and redraws (or clears) the cluster overlay from current state.
|
|
188
|
+
*/
|
|
189
|
+
private refreshClusterOverlay;
|
|
122
190
|
private getDataUrlForCanvas;
|
|
123
191
|
private initiateFileDownload;
|
|
124
192
|
private updateLayoutAndPositions;
|
|
193
|
+
private getAndUpdatePositions;
|
|
194
|
+
private getLayoutPositions;
|
|
125
195
|
saveToFile(options: SaveToFileOptions): void;
|
|
126
196
|
private createSvgString;
|
|
127
197
|
saveToSvg(options?: SaveToFileOptions): Promise<void>;
|
|
@@ -8,6 +8,7 @@ export interface DataSet<T> {
|
|
|
8
8
|
idToPosition: Record<string, Node & Point>;
|
|
9
9
|
idToHtmlOverlay?: Record<string, HTMLElement>;
|
|
10
10
|
version: number;
|
|
11
|
+
maxDimension: number;
|
|
11
12
|
addChannel: (this: DataSet<T>, channelName: string) => void;
|
|
12
13
|
removeChannel: (this: DataSet<T>, channelName: string) => void;
|
|
13
14
|
clearChannel: (this: DataSet<T>, channelName: string) => void;
|
|
@@ -29,7 +30,8 @@ export interface Channel<T> {
|
|
|
29
30
|
updates: Record<string, T>;
|
|
30
31
|
removes: Record<string, T>;
|
|
31
32
|
}
|
|
32
|
-
export declare const
|
|
33
|
+
export declare const getHtmlKey: (item: Node | Relationship) => "html" | "captionHtml";
|
|
34
|
+
export declare const getHtmlProperty: (item: Node | Relationship) => HTMLElement | undefined;
|
|
33
35
|
/**
|
|
34
36
|
* Creates an empty dataset in which a graph be stored and updated using mobx actions.
|
|
35
37
|
* @returns A new and empty {@link DataSet}.
|
|
@@ -34,28 +34,96 @@ export type DisabledItemStyles = {
|
|
|
34
34
|
fontColor: string;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Identifier returned by {@link ClusterByFn} to group nodes into physical clusters.
|
|
38
|
+
* Nodes sharing the same string or number are clustered together.
|
|
38
39
|
*/
|
|
39
|
-
export
|
|
40
|
+
export type ClusterId = string | number;
|
|
41
|
+
/**
|
|
42
|
+
* Function that maps a node id to a {@link ClusterId} for force-directed clustering.
|
|
43
|
+
* Returns `undefined` for nodes that should remain independent.
|
|
44
|
+
*/
|
|
45
|
+
export type ClusterByFn = (nodeId: string) => ClusterId | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Options that control physical clustering and cluster decorations for the force-directed layout.
|
|
48
|
+
*/
|
|
49
|
+
export interface ClusteringOptions {
|
|
40
50
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
51
|
+
* Optional function to group nodes into physical clusters based on a custom identifier.
|
|
52
|
+
* Nodes returning the same string or number will be grouped together in the layout.
|
|
53
|
+
* Nodes returning undefined will be treated as independent.
|
|
54
|
+
*
|
|
55
|
+
* @note Ensure this function has a stable reference to avoid evaluation on every render.
|
|
43
56
|
*/
|
|
44
|
-
|
|
57
|
+
clusterBy?: ClusterByFn;
|
|
45
58
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @
|
|
59
|
+
* Draws a convex-hull outline around each cluster.
|
|
60
|
+
*
|
|
61
|
+
* @note Outline color is the same as the nodes in the cluster.
|
|
62
|
+
* If the nodes in the cluster have different colors, the outline uses
|
|
63
|
+
* {@link NvlOptions.styling.overlayLineColor}.
|
|
64
|
+
* @defaultValue false
|
|
65
|
+
*/
|
|
66
|
+
drawOutline?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Fills a soft glowing halo around each cluster.
|
|
69
|
+
*
|
|
70
|
+
* @note Halo color is the same as the nodes in the cluster.
|
|
71
|
+
* If the nodes in the cluster have different colors, the halo won't be shown.
|
|
72
|
+
* @defaultValue false
|
|
51
73
|
*/
|
|
52
|
-
|
|
74
|
+
drawHalo?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Spring force multiplier for relationships that cross a {@link ClusteringOptions.clusterBy}
|
|
77
|
+
* cluster boundary.
|
|
78
|
+
* Capped between `0` and `1`.
|
|
79
|
+
* `0` disables cross-cluster spring pull. `1` is full strength. Intra-cluster edges are always
|
|
80
|
+
* full strength. Only applies when {@link ClusteringOptions.clusterBy} is set.
|
|
81
|
+
* @defaultValue 0
|
|
82
|
+
* @experimental
|
|
83
|
+
* @note Can cause unstable layouts when set to close to `1` in highly connected graphs.
|
|
84
|
+
*/
|
|
85
|
+
crossClusterRelationshipMultiplier?: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The options for the force directed layout
|
|
89
|
+
*/
|
|
90
|
+
export interface ForceDirectedOptions {
|
|
53
91
|
/**
|
|
54
92
|
* How initial node positions are seeded before the physics simulation runs.
|
|
55
93
|
* @defaultValue 'box'
|
|
56
94
|
*/
|
|
57
95
|
seedingMethod?: 'box' | 'circle';
|
|
96
|
+
/**
|
|
97
|
+
* @experimental
|
|
98
|
+
* Milliseconds of synchronous physics simulation to run before the layout is first rendered.
|
|
99
|
+
* Precompute stops early if the simulation stabilizes before the time budget is reached.
|
|
100
|
+
* @defaultValue 0
|
|
101
|
+
* @note Blocks the main thread, so use sparingly. Will be capped at 1000.
|
|
102
|
+
*/
|
|
103
|
+
precomputeMs?: number;
|
|
104
|
+
/**
|
|
105
|
+
* Physical clustering and cluster decoration options.
|
|
106
|
+
*/
|
|
107
|
+
clustering?: ClusteringOptions;
|
|
58
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns the clustering options from force-directed layout options, if present.
|
|
111
|
+
* @param layoutOptions - The layout options to read from.
|
|
112
|
+
* @returns The clustering options, or undefined when absent / not force-directed.
|
|
113
|
+
*/
|
|
114
|
+
export declare const getClusteringOptions: (layoutOptions?: LayoutOptions) => ClusteringOptions | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Whether {@link ClusteringOptions.drawOutline} is enabled on the given layout options.
|
|
117
|
+
* @param layoutOptions - The layout options to check.
|
|
118
|
+
* @returns Whether {@link ClusteringOptions.drawOutline} is enabled on the given layout options.
|
|
119
|
+
*/
|
|
120
|
+
export declare const isDrawClusterOutlineEnabled: (layoutOptions?: LayoutOptions) => boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Whether {@link ClusteringOptions.drawHalo} is enabled on the given layout options.
|
|
123
|
+
* @param layoutOptions - The layout options to check.
|
|
124
|
+
* @returns Whether {@link ClusteringOptions.drawHalo} is enabled on the given layout options.
|
|
125
|
+
*/
|
|
126
|
+
export declare const isDrawClusterHaloEnabled: (layoutOptions?: LayoutOptions) => boolean;
|
|
59
127
|
/**
|
|
60
128
|
* The options for the hierarchical layout
|
|
61
129
|
*/
|
|
@@ -225,26 +293,34 @@ export interface NvlOptions {
|
|
|
225
293
|
disabledItemColor?: string;
|
|
226
294
|
/** The color to use for the labels of the disabled nodes and relationships */
|
|
227
295
|
disabledItemFontColor?: string;
|
|
228
|
-
/**
|
|
296
|
+
/**
|
|
297
|
+
* Stroke color for overlay UI lines (e.g. minimap viewport box).
|
|
298
|
+
* Use a dark color on light backgrounds and a light color on dark backgrounds.
|
|
299
|
+
* @defaultValue `#1A1B1D`
|
|
300
|
+
*/
|
|
301
|
+
overlayLineColor?: string;
|
|
302
|
+
/**
|
|
303
|
+
* The color to use for the viewport box in the minimap.
|
|
304
|
+
* @deprecated Use {@link overlayLineColor}.
|
|
305
|
+
*/
|
|
229
306
|
minimapViewportBoxColor?: string;
|
|
230
307
|
};
|
|
231
308
|
/**
|
|
232
|
-
* Target minimum presentation
|
|
233
|
-
*
|
|
309
|
+
* Target minimum presentation fps while layout is active, at the cost of stabilization speed when set higher.
|
|
310
|
+
* Budgets layout steps only. Actual fps may undershoot when rendering is expensive.
|
|
234
311
|
*
|
|
235
312
|
* @defaultValue 3
|
|
236
313
|
*
|
|
237
|
-
* @note
|
|
314
|
+
* @note Will be capped between 1 and 120.
|
|
238
315
|
*/
|
|
239
316
|
minFps?: number;
|
|
240
317
|
/**
|
|
241
|
-
* Target maximum presentation
|
|
242
|
-
*
|
|
243
|
-
* computation available is used to speed up layout stabilization.
|
|
318
|
+
* Target maximum presentation fps while layout is active; extra time in the tick goes to layout stabilization.
|
|
319
|
+
* Budgets layout steps only. Actual fps may undershoot when rendering is expensive.
|
|
244
320
|
*
|
|
245
321
|
* @defaultValue 30
|
|
246
322
|
*
|
|
247
|
-
* @note
|
|
323
|
+
* @note Will be capped between 1 and 120.
|
|
248
324
|
*/
|
|
249
325
|
maxFps?: number;
|
|
250
326
|
/**
|
|
@@ -332,6 +408,6 @@ export interface NvlState {
|
|
|
332
408
|
disabledItemStyles: DisabledItemStyles;
|
|
333
409
|
defaultNodeColor: string;
|
|
334
410
|
defaultRelationshipColor: string;
|
|
335
|
-
|
|
411
|
+
overlayLineColor: string;
|
|
336
412
|
}
|
|
337
413
|
export {};
|
|
@@ -6,7 +6,7 @@ import type { NvlOptions } from './types';
|
|
|
6
6
|
* If both caption and captions are provided, captions takes precedence.
|
|
7
7
|
*/
|
|
8
8
|
export declare const processCaptions: (item: Partial<Node | Relationship>) => StyledCaption[];
|
|
9
|
-
export declare const processColorStyles: (styling
|
|
9
|
+
export declare const processColorStyles: (styling?: NvlOptions["styling"]) => {
|
|
10
10
|
nodeBorderStyles: {
|
|
11
11
|
default: {
|
|
12
12
|
rings?: {
|
|
@@ -42,5 +42,5 @@ export declare const processColorStyles: (styling: NvlOptions["styling"]) => {
|
|
|
42
42
|
};
|
|
43
43
|
defaultNodeColor: string;
|
|
44
44
|
defaultRelationshipColor: string;
|
|
45
|
-
|
|
45
|
+
overlayLineColor: string;
|
|
46
46
|
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type CoarsenedGraph } from '../layouts/forcedirectedlayout/physlayout/clustering/types';
|
|
2
|
+
import { type NvlState } from '../modules/state/types';
|
|
3
|
+
import type { Node } from '../types/graph-element';
|
|
4
|
+
import { type Point } from '../utils/geometry';
|
|
5
|
+
type ClusterPositions = Readonly<Record<string, Point>> | (() => (Node & Point)[]);
|
|
6
|
+
/**
|
|
7
|
+
* Canvas2D overlay for cluster decorations.
|
|
8
|
+
*/
|
|
9
|
+
export default class ClusterOverlay {
|
|
10
|
+
private readonly canvas;
|
|
11
|
+
private readonly context;
|
|
12
|
+
private readonly state;
|
|
13
|
+
private readonly stateDisposers;
|
|
14
|
+
private readonly clusterColors;
|
|
15
|
+
private clusterColorsDirty;
|
|
16
|
+
private cachedFirstSubGraphLevel;
|
|
17
|
+
private cachedIdToPosition;
|
|
18
|
+
private cachedPositionListVersion;
|
|
19
|
+
private readonly clusterGeometry;
|
|
20
|
+
private geometryPositionsVersion;
|
|
21
|
+
constructor(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D, state: NvlState);
|
|
22
|
+
/** Clears the overlay. */
|
|
23
|
+
clear(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Draws cluster decorations for a given multi-member first-level sun system and positions.
|
|
26
|
+
* @param subGraphs - Layout coarsening hierarchy (`subGraphs[1]` = first-level suns).
|
|
27
|
+
* @param positions - Node id to position map, or a getter for a lagged position list.
|
|
28
|
+
* @param cacheVersion - PhysLayout positions-cache version.
|
|
29
|
+
*/
|
|
30
|
+
render(subGraphs: CoarsenedGraph[], positions: ClusterPositions, cacheVersion: number): void;
|
|
31
|
+
destroy(): void;
|
|
32
|
+
private resetClusterColorCache;
|
|
33
|
+
private resetGeometryCache;
|
|
34
|
+
private syncGeometryCacheVersion;
|
|
35
|
+
private resetPositionCache;
|
|
36
|
+
/**
|
|
37
|
+
* Returns an id to position map. Records are used as-is. Getters are converted once per `cacheVersion`.
|
|
38
|
+
* @param positions - Node id to position map, or a getter for a lagged position list.
|
|
39
|
+
* @param cacheVersion - PhysLayout positions-cache version; ignored for maps.
|
|
40
|
+
* @returns An id to position map.
|
|
41
|
+
*/
|
|
42
|
+
private resolveIdToPosition;
|
|
43
|
+
/**
|
|
44
|
+
* Rebuilds {@link clusterColors} for every multi-member first-level sun.
|
|
45
|
+
* @param firstSubGraphLevel - `subGraphs[1]` from the current layout coarsening hierarchy.
|
|
46
|
+
*/
|
|
47
|
+
private rebuildClusterColors;
|
|
48
|
+
/**
|
|
49
|
+
* Visits each multi-member first-level sun system.
|
|
50
|
+
* @param firstSubGraphLevel - `subGraphs[1]` from the current layout coarsening hierarchy.
|
|
51
|
+
* @param onCluster - Called with the sun and its original member node ids.
|
|
52
|
+
*/
|
|
53
|
+
private forEachDecoratableCluster;
|
|
54
|
+
private collectMemberDisks;
|
|
55
|
+
/**
|
|
56
|
+
* Returns fitted world-space hull for a cluster, reusing the last fit while the
|
|
57
|
+
* positions cache version is unchanged (e.g. pan/zoom-only frames while layout is stable).
|
|
58
|
+
* @param sunId - Original id of the sun the hull belongs to.
|
|
59
|
+
* @param collectMembers - Builds the member disks to fit; only called on a cache miss.
|
|
60
|
+
* @returns The fitted hull, or null when the cluster cannot be fitted.
|
|
61
|
+
*/
|
|
62
|
+
private getCachedHull;
|
|
63
|
+
private fillHalo;
|
|
64
|
+
private strokeOutline;
|
|
65
|
+
/**
|
|
66
|
+
* Traces a closed rounded path along the given points.
|
|
67
|
+
* @param points - The points to trace the path along.
|
|
68
|
+
*/
|
|
69
|
+
private traceSmoothClosedPath;
|
|
70
|
+
private applyZoomAndPan;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the shared member color when color is consistent; otherwise null.
|
|
73
|
+
* @param nodeIds - The IDs of the nodes in the cluster.
|
|
74
|
+
* @param idToItem - The map of node IDs to items.
|
|
75
|
+
* @param defaultNodeColor - The default node color.
|
|
76
|
+
* @returns The shared member color when color is consistent; otherwise null.
|
|
77
|
+
*/
|
|
78
|
+
private resolveUnanimousClusterColor;
|
|
79
|
+
}
|
|
80
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -18,20 +18,6 @@ export declare const calculateLabelDimensions: (fullCaption: string, measureWidt
|
|
|
18
18
|
label: string;
|
|
19
19
|
width: number;
|
|
20
20
|
};
|
|
21
|
-
/**
|
|
22
|
-
* Calculate label transform including rotation and flip adjustments.
|
|
23
|
-
*
|
|
24
|
-
* @param angle - The base rotation angle in radians
|
|
25
|
-
* @param fontSize - The font size in pixels (including pixel ratio scaling)
|
|
26
|
-
* @param flip - Whether to flip the label (applies additional rotation)
|
|
27
|
-
* @param point - The base point (used to calculate offset in flip case)
|
|
28
|
-
* @returns object with final position and angle
|
|
29
|
-
*/
|
|
30
|
-
export declare const calculateLabelTransform: (angle: number, fontSize: number, flip: boolean, point: Point) => {
|
|
31
|
-
finalX: number;
|
|
32
|
-
finalY: number;
|
|
33
|
-
finalAngle: number;
|
|
34
|
-
};
|
|
35
21
|
/**
|
|
36
22
|
* Calculate vertical alignment offset for label based on caption alignment.
|
|
37
23
|
*
|
|
@@ -55,7 +41,7 @@ export declare const calculateLabelHeightAlign: (captionAlign: string, fontSize:
|
|
|
55
41
|
* @param flip - Whether the label is flipped
|
|
56
42
|
* @returns object with position, rotation, width, and height for hit detection
|
|
57
43
|
*/
|
|
58
|
-
export declare const calculateLabelGeometry: (point: Point, angle: number, maxWidth: number, fontSize: number, heightAlign: number, padding: number, pixelRatio: number
|
|
44
|
+
export declare const calculateLabelGeometry: (point: Point, angle: number, maxWidth: number, fontSize: number, heightAlign: number, padding: number, pixelRatio: number) => {
|
|
59
45
|
position: {
|
|
60
46
|
x: number;
|
|
61
47
|
y: number;
|
|
@@ -164,5 +150,5 @@ export declare const drawLoop: (ctx: CanvasRenderingContext2D, fromPoint: Point,
|
|
|
164
150
|
* @param fontColor - The font color to use
|
|
165
151
|
* @param flip - Whether to flip the label orientation (default false)
|
|
166
152
|
*/
|
|
167
|
-
export declare const drawLabel: (ctx: CanvasRenderingContext2D, point: Point, angle: number, maxWidth: number, rel: Relationship, bundle: ArrowBundle, disabledItemStyles: DisabledItemStyles, fontColor: string
|
|
153
|
+
export declare const drawLabel: (ctx: CanvasRenderingContext2D, point: Point, angle: number, maxWidth: number, rel: Relationship, bundle: ArrowBundle, disabledItemStyles: DisabledItemStyles, fontColor: string) => void;
|
|
168
154
|
export {};
|
|
@@ -4,6 +4,7 @@ declare class ImageCache {
|
|
|
4
4
|
private readonly onImageLoadedCb?;
|
|
5
5
|
constructor(onImageLoaded?: () => void);
|
|
6
6
|
getImage(src: string, inverted?: boolean): HTMLCanvasElement;
|
|
7
|
+
isDrawn(src: string, inverted?: boolean): boolean;
|
|
7
8
|
private getOrCreateEntry;
|
|
8
9
|
private invertCanvas;
|
|
9
10
|
private loadImage;
|
|
@@ -44,12 +44,8 @@ export declare const getSelfArrowControlPoints: (rel: Relationship, node: Node,
|
|
|
44
44
|
};
|
|
45
45
|
nodeGap: number;
|
|
46
46
|
};
|
|
47
|
-
/**
|
|
48
|
-
|
|
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) => {
|
|
47
|
+
/** Calculates anchor position and readable rotation for a self-referencing relationship label. */
|
|
48
|
+
export declare const getSelfArrowLabelPosition: (apexPoint: Point, angle: number, endPoint: Point, control2Point: Point, isSelected: boolean, selectionRings: BorderStyle["rings"], relWidth?: number, captionSize?: number) => {
|
|
53
49
|
x: number;
|
|
54
50
|
y: number;
|
|
55
51
|
angle: number;
|
|
@@ -173,3 +169,5 @@ export declare const getOverlayIconAlignment: (position: [number, number], width
|
|
|
173
169
|
widthAlign: number;
|
|
174
170
|
heightAlign: number;
|
|
175
171
|
};
|
|
172
|
+
/** Vertical offset for a self-loop caption; `top`/`bottom` mean outside/inside the loop. */
|
|
173
|
+
export declare const getSelfLoopHeightAlign: (captionAlign: string, fontSize: number, lineWidth: number, padding: number, flip: 1 | -1) => number;
|
|
@@ -10,8 +10,10 @@ export interface ControllerInterface {
|
|
|
10
10
|
stateDisposers: NvlState['autorun'][];
|
|
11
11
|
state: NvlState;
|
|
12
12
|
needsToRun: () => boolean;
|
|
13
|
-
renderMainScene: (positionArray: Node[]) => void;
|
|
14
|
-
|
|
13
|
+
renderMainScene: (positionArray: Node[], positionsChanged?: boolean) => void;
|
|
14
|
+
renderMainSceneFromTexture: (positionTexture: WebGLTexture) => void;
|
|
15
|
+
setPositionTexelIndices: (map: Readonly<Record<string, number>> | null) => void;
|
|
16
|
+
renderMinimap: (positionArray: Node[], positionsChanged?: boolean) => void;
|
|
15
17
|
checkForUpdates: (nodes: DataSet<Node>, rels: DataSet<Relationship>) => void;
|
|
16
18
|
onResize: () => void;
|
|
17
19
|
updateMainViewport: (zoom: number, panX: number, panY: number) => void;
|
|
@@ -34,8 +36,25 @@ export default class Controller implements ControllerInterface {
|
|
|
34
36
|
state?: NvlState;
|
|
35
37
|
});
|
|
36
38
|
needsToRun(): boolean;
|
|
37
|
-
renderMainScene(positionArray: Node[]): void;
|
|
38
|
-
|
|
39
|
+
renderMainScene(positionArray: Node[], positionsChanged?: boolean): void;
|
|
40
|
+
/**
|
|
41
|
+
* Renders the main scene from a GPU position texture instead of a
|
|
42
|
+
* CPU position array, avoiding the readback + upload round trip.
|
|
43
|
+
* @param positionTexture - Live GPU node-position texture to render from.
|
|
44
|
+
*/
|
|
45
|
+
renderMainSceneFromTexture(positionTexture: WebGLTexture): void;
|
|
46
|
+
/**
|
|
47
|
+
* Sets the node-id -> texel-index map for the main scene renderer so it
|
|
48
|
+
* samples a shared position texture in the layout's order. Pass null to use
|
|
49
|
+
* insertion order.
|
|
50
|
+
* @param map - The node-id-to-texel-index map, or null.
|
|
51
|
+
*
|
|
52
|
+
* @note The minimap keeps insertion-order sampling and uploads lagged CPU
|
|
53
|
+
* positions (async PhysLayout cache) while the main scene may sample the
|
|
54
|
+
* shared GPU texture.
|
|
55
|
+
*/
|
|
56
|
+
setPositionTexelIndices(map: Readonly<Record<string, number>> | null): void;
|
|
57
|
+
renderMinimap(positionArray: Node[], positionsChanged?: boolean): void;
|
|
39
58
|
checkForUpdates(nodes: DataSet<Node>, rels: DataSet<Relationship>): void;
|
|
40
59
|
onResize(): void;
|
|
41
60
|
updateMainViewport(zoom: number, panX: number, panY: number): void;
|
|
@@ -52,8 +71,10 @@ export declare class DummyController implements ControllerInterface {
|
|
|
52
71
|
minimapMouseDown: boolean;
|
|
53
72
|
stateDisposers: NvlState['autorun'][];
|
|
54
73
|
state: NvlState;
|
|
55
|
-
renderMainScene(positionArray: Node[]): void;
|
|
56
|
-
|
|
74
|
+
renderMainScene(positionArray: Node[], positionsChanged?: boolean): void;
|
|
75
|
+
renderMainSceneFromTexture(positionTexture: WebGLTexture): void;
|
|
76
|
+
setPositionTexelIndices(map: Readonly<Record<string, number>> | null): void;
|
|
77
|
+
renderMinimap(positionArray: Node[], positionsChanged?: boolean): void;
|
|
57
78
|
checkForUpdates(nodes: DataSet<Node>, rels: DataSet<Relationship>): void;
|
|
58
79
|
onResize(): void;
|
|
59
80
|
updateMainViewport(zoom: number, panX: number, panY: number): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const MaxIconLayers = 256;
|
|
2
|
+
/**
|
|
3
|
+
* Maps icon URLs to stable layer indices for a WebGL `sampler2DArray`.
|
|
4
|
+
* Delegates image loading and rasterization to {@link ImageCache}.
|
|
5
|
+
*/
|
|
6
|
+
export declare class IconLayerRegistry {
|
|
7
|
+
private readonly imageCache;
|
|
8
|
+
private readonly layerMap;
|
|
9
|
+
constructor(onImageLoaded?: () => void);
|
|
10
|
+
getLayer(url: string, inverted: boolean): number | null;
|
|
11
|
+
hasLoadingLayers(): boolean;
|
|
12
|
+
layerCount(): number;
|
|
13
|
+
getAvailableCanvases(): Map<number, HTMLCanvasElement>;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|