@neo4j-nvl/base 1.2.0-d88ba7c2 → 1.2.0-dbc13ec2
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 → PhysLayout.d.ts} +106 -26
- package/dist/types/layouts/forcedirectedlayout/clustering/ClusterByMerger.d.ts +61 -0
- package/dist/types/layouts/forcedirectedlayout/clustering/SolarMerger.d.ts +56 -0
- package/dist/types/layouts/forcedirectedlayout/clustering/clustering-utils.d.ts +143 -0
- package/dist/types/layouts/forcedirectedlayout/clustering/clustering-utils.test.d.ts +1 -0
- package/dist/types/layouts/forcedirectedlayout/{physlayout/solarmerger → clustering}/types.d.ts +11 -1
- package/dist/types/layouts/forcedirectedlayout/shaders/multilevel-fragment.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/shaders/multilevel-repulsive-fragment.d.ts +2 -0
- package/dist/types/layouts/freeLayout/FreeLayout.d.ts +2 -4
- package/dist/types/layouts/gridLayout/GridLayout.d.ts +2 -6
- package/dist/types/layouts/hierarchicallayout/HierarchicalLayout.d.ts +5 -0
- package/dist/types/modules/NvlController.d.ts +72 -4
- package/dist/types/modules/dataset.d.ts +1 -0
- package/dist/types/modules/state/types.d.ts +90 -19
- 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/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/shaders/multilevel-fragment.d.ts +0 -2
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment.d.ts +0 -2
- 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/PhysLayout.test.d.ts → PhysLayout.test.d.ts} +0 -0
- /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
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/glwrapper.d.ts → glwrapper.d.ts} +0 -0
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/shaders → shaders}/multilevel-update-fragment.d.ts +0 -0
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/shaders → shaders}/sim-vertex.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 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;
|
|
@@ -7,6 +7,8 @@ type HierarchicalLayoutConfig = {
|
|
|
7
7
|
export declare class HierarchicalLayout extends AnimatedLayout {
|
|
8
8
|
private direction;
|
|
9
9
|
private packing;
|
|
10
|
+
private clusterBy?;
|
|
11
|
+
private lastClusterByAssignments;
|
|
10
12
|
private stateDisposers;
|
|
11
13
|
private oldComputing;
|
|
12
14
|
private computing;
|
|
@@ -14,9 +16,12 @@ export declare class HierarchicalLayout extends AnimatedLayout {
|
|
|
14
16
|
private worker;
|
|
15
17
|
private directionChanged;
|
|
16
18
|
private packingChanged;
|
|
19
|
+
private clusterByChanged;
|
|
17
20
|
private workersDisabled;
|
|
18
21
|
constructor(config: HierarchicalLayoutConfig);
|
|
19
22
|
setOptions(options: LayoutOptions): void;
|
|
23
|
+
private applyClusterByOption;
|
|
24
|
+
private buildClusterAssignments;
|
|
20
25
|
update(refreshPositions?: boolean): void;
|
|
21
26
|
getShouldUpdate(): boolean;
|
|
22
27
|
getComputing(): boolean;
|
|
@@ -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,17 +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;
|
|
71
133
|
private renderNodeHtmlOverlays;
|
|
72
134
|
private renderRelationshipHtmlOverlays;
|
|
73
135
|
updateHtmlOverlay(): void;
|
|
74
|
-
dumpNodes():
|
|
136
|
+
dumpNodes(): NodeWithClientPosition[];
|
|
75
137
|
dumpRelationships(): Relationship[];
|
|
76
138
|
/**
|
|
77
139
|
* Map a relative Canvas space to the DOM position
|
|
@@ -100,7 +162,7 @@ export default class NvlController {
|
|
|
100
162
|
};
|
|
101
163
|
registerDoneCallback(cb: NvlController['layoutDoneCallback']): void;
|
|
102
164
|
registerComputingCallback(cb: NvlController['layoutComputingCallback']): void;
|
|
103
|
-
getPosition(nodeId: string): Node;
|
|
165
|
+
getPosition(nodeId: string): Node & Point;
|
|
104
166
|
getScale(): number;
|
|
105
167
|
getPan(): {
|
|
106
168
|
x: number;
|
|
@@ -120,10 +182,16 @@ export default class NvlController {
|
|
|
120
182
|
getCanvasNodesAt(point: Point, hitNodeMarginWidth?: number): import("..").HitTargetNode[];
|
|
121
183
|
private getLayout;
|
|
122
184
|
setLayout(layoutType: Layout): void;
|
|
123
|
-
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;
|
|
124
190
|
private getDataUrlForCanvas;
|
|
125
191
|
private initiateFileDownload;
|
|
126
192
|
private updateLayoutAndPositions;
|
|
193
|
+
private getAndUpdatePositions;
|
|
194
|
+
private getLayoutPositions;
|
|
127
195
|
saveToFile(options: SaveToFileOptions): void;
|
|
128
196
|
private createSvgString;
|
|
129
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;
|
|
@@ -34,36 +34,88 @@ 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
|
|
73
|
+
*/
|
|
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.
|
|
51
84
|
*/
|
|
52
|
-
|
|
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';
|
|
58
96
|
/**
|
|
59
|
-
*
|
|
60
|
-
* Milliseconds of synchronous physics simulation to run before the layout is first rendered.
|
|
61
|
-
* Precompute stops early if the simulation stabilizes before the time budget is reached.
|
|
62
|
-
* @defaultValue 0
|
|
63
|
-
* @note Blocks the main thread, so use sparingly. Will be capped at 1000.
|
|
97
|
+
* Physical clustering and cluster decoration options.
|
|
64
98
|
*/
|
|
65
|
-
|
|
99
|
+
clustering?: ClusteringOptions;
|
|
66
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns the clustering options from force-directed layout options, if present.
|
|
103
|
+
* @param layoutOptions - The layout options to read from.
|
|
104
|
+
* @returns The clustering options, or undefined when absent / not force-directed.
|
|
105
|
+
*/
|
|
106
|
+
export declare const getClusteringOptions: (layoutOptions?: LayoutOptions) => ClusteringOptions | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Whether {@link ClusteringOptions.drawOutline} is enabled on the given layout options.
|
|
109
|
+
* @param layoutOptions - The layout options to check.
|
|
110
|
+
* @returns Whether {@link ClusteringOptions.drawOutline} is enabled on the given layout options.
|
|
111
|
+
*/
|
|
112
|
+
export declare const isDrawClusterOutlineEnabled: (layoutOptions?: LayoutOptions) => boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Whether {@link ClusteringOptions.drawHalo} is enabled on the given layout options.
|
|
115
|
+
* @param layoutOptions - The layout options to check.
|
|
116
|
+
* @returns Whether {@link ClusteringOptions.drawHalo} is enabled on the given layout options.
|
|
117
|
+
*/
|
|
118
|
+
export declare const isDrawClusterHaloEnabled: (layoutOptions?: LayoutOptions) => boolean;
|
|
67
119
|
/**
|
|
68
120
|
* The options for the hierarchical layout
|
|
69
121
|
*/
|
|
@@ -72,6 +124,16 @@ export interface HierarchicalOptions {
|
|
|
72
124
|
direction?: 'up' | 'down' | 'left' | 'right';
|
|
73
125
|
/** The packing method to be used */
|
|
74
126
|
packing?: 'bin' | 'stack';
|
|
127
|
+
/**
|
|
128
|
+
* Optional function to group nodes into semantic clusters based on a custom identifier.
|
|
129
|
+
* Nodes returning the same string or number will be grouped together in the layout via
|
|
130
|
+
* dagre compound subgraphs. Nodes returning undefined will be treated as independent.
|
|
131
|
+
*
|
|
132
|
+
* @note Ensure this function has a stable reference to avoid evaluation on every render.
|
|
133
|
+
*
|
|
134
|
+
* @experimental
|
|
135
|
+
*/
|
|
136
|
+
clusterBy?: (nodeId: string) => string | number | undefined;
|
|
75
137
|
}
|
|
76
138
|
export declare const isHierarchicalLayoutOptions: (options: LayoutOptions) => options is HierarchicalOptions;
|
|
77
139
|
/**
|
|
@@ -233,7 +295,16 @@ export interface NvlOptions {
|
|
|
233
295
|
disabledItemColor?: string;
|
|
234
296
|
/** The color to use for the labels of the disabled nodes and relationships */
|
|
235
297
|
disabledItemFontColor?: string;
|
|
236
|
-
/**
|
|
298
|
+
/**
|
|
299
|
+
* Stroke color for overlay UI lines (e.g. minimap viewport box).
|
|
300
|
+
* Use a dark color on light backgrounds and a light color on dark backgrounds.
|
|
301
|
+
* @defaultValue `#1A1B1D`
|
|
302
|
+
*/
|
|
303
|
+
overlayLineColor?: string;
|
|
304
|
+
/**
|
|
305
|
+
* The color to use for the viewport box in the minimap.
|
|
306
|
+
* @deprecated Use {@link overlayLineColor}.
|
|
307
|
+
*/
|
|
237
308
|
minimapViewportBoxColor?: string;
|
|
238
309
|
};
|
|
239
310
|
/**
|
|
@@ -339,6 +410,6 @@ export interface NvlState {
|
|
|
339
410
|
disabledItemStyles: DisabledItemStyles;
|
|
340
411
|
defaultNodeColor: string;
|
|
341
412
|
defaultRelationshipColor: string;
|
|
342
|
-
|
|
413
|
+
overlayLineColor: string;
|
|
343
414
|
}
|
|
344
415
|
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/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 {};
|
|
@@ -2,11 +2,17 @@ import { mat4 } from 'gl-matrix';
|
|
|
2
2
|
import type { DataSet } from '../../modules/dataset';
|
|
3
3
|
import type { NvlState } from '../../modules/state/types';
|
|
4
4
|
import type { Node, Relationship } from '../../types/graph-element';
|
|
5
|
+
export type RendererOptions = {
|
|
6
|
+
enableIcons?: boolean;
|
|
7
|
+
};
|
|
5
8
|
export default class Renderer {
|
|
6
9
|
private readonly nodeShader;
|
|
7
10
|
private readonly nodeAnimShader;
|
|
8
11
|
private readonly relShader;
|
|
12
|
+
private readonly arrowShader;
|
|
9
13
|
private relDataBuffer;
|
|
14
|
+
private arrowDataBuffer;
|
|
15
|
+
private arrowData;
|
|
10
16
|
private readonly viewportBoxShader;
|
|
11
17
|
private readonly defaultRelColor;
|
|
12
18
|
private readonly defaultNodeColor;
|
|
@@ -14,38 +20,73 @@ export default class Renderer {
|
|
|
14
20
|
private readonly disableNodeColor;
|
|
15
21
|
private readonly gl;
|
|
16
22
|
activeNodes: Record<string, boolean>;
|
|
23
|
+
numActiveNodes: number;
|
|
17
24
|
readonly canvas: HTMLCanvasElement;
|
|
18
25
|
projection: mat4;
|
|
19
26
|
private idToIndex;
|
|
27
|
+
/** Node-id → texel-index map for GPU-shared rendering; null falls back to insertion order. */
|
|
28
|
+
private texelIndexForId;
|
|
29
|
+
/** texelIndexForId value when vertex buffers were last built; used to detect changes in the texel-index mapping. */
|
|
30
|
+
private texelMapAtBuild;
|
|
31
|
+
private lastNodes;
|
|
32
|
+
private lastBundledRels;
|
|
33
|
+
private idToSize;
|
|
20
34
|
private posBuffer;
|
|
35
|
+
private positionsDirty;
|
|
21
36
|
private numRels;
|
|
22
37
|
private numNodes;
|
|
23
38
|
private nodeDataByte;
|
|
24
39
|
private relIdToIndex;
|
|
25
40
|
private relData;
|
|
26
41
|
private viewportBoxBuffer;
|
|
42
|
+
private readonly viewportBoxVertices;
|
|
27
43
|
private relBuffer;
|
|
44
|
+
private arrowBuffer;
|
|
28
45
|
private nodeBuffer;
|
|
29
46
|
private posTexture;
|
|
47
|
+
private iconTexture;
|
|
30
48
|
private nodeVao;
|
|
31
49
|
private relVao;
|
|
50
|
+
private arrowVao;
|
|
32
51
|
private nodeAnimVao;
|
|
33
|
-
|
|
52
|
+
private readonly iconLayers;
|
|
53
|
+
private uploadedIconLayers;
|
|
54
|
+
private nodeColors;
|
|
55
|
+
private nodeDisabled;
|
|
56
|
+
constructor(gl: WebGL2RenderingContext, nodes: DataSet<Node>, rels: DataSet<Relationship>, state: NvlState, options?: RendererOptions);
|
|
34
57
|
private setShaderUniforms;
|
|
35
58
|
setData(data: {
|
|
36
59
|
nodes: Node[];
|
|
37
60
|
rels: Relationship[];
|
|
38
61
|
}): void;
|
|
39
|
-
|
|
62
|
+
/** Sets the texel-index map for GPU-shared rendering, or null for insertion order. */
|
|
63
|
+
setPositionTexelIndices(map: Readonly<Record<string, number>> | null): void;
|
|
64
|
+
/** Texel index for a node id; falls back to insertion index, or 0 if the id is unknown. */
|
|
65
|
+
private getTexelIndex;
|
|
66
|
+
/**
|
|
67
|
+
* Rebuilds vertex buffers when the texel-index mapping has changed since the last build.
|
|
68
|
+
*/
|
|
69
|
+
private rebuildBuffersIfTexelMappingChanged;
|
|
70
|
+
render(positionArray: Node[], positionsChanged?: boolean): void;
|
|
71
|
+
/** Renders using a GPU position texture directly as `u_positions` */
|
|
72
|
+
renderFromGpuTexture(positionTexture: WebGLTexture): void;
|
|
73
|
+
private renderRelationships;
|
|
40
74
|
renderViewbox(): void;
|
|
41
75
|
updateNodes(updates: Node[]): void;
|
|
42
76
|
updateRelationships(relItems: Relationship[]): void;
|
|
43
77
|
private createPositionTexture;
|
|
78
|
+
private createIconTexture;
|
|
79
|
+
private uploadPendingIconLayers;
|
|
80
|
+
hasPendingIcons(): boolean;
|
|
44
81
|
updateViewportBox(zoom: number, panX: number, panY: number, viewportWidth: number, viewportHeight: number): void;
|
|
45
82
|
updateViewport(zoom: number, panX: number, panY: number): void;
|
|
46
83
|
private setupViewportRendering;
|
|
84
|
+
private resolveNodeColor;
|
|
47
85
|
private setupNodeRendering;
|
|
48
86
|
private setupRelationshipRendering;
|
|
87
|
+
private setupArrowRendering;
|
|
88
|
+
private getRelBufferAttributes;
|
|
89
|
+
private updateEndpointSizesForNode;
|
|
49
90
|
private renderAnimations;
|
|
50
91
|
destroy(): void;
|
|
51
92
|
}
|