@neo4j-nvl/base 1.1.0-e61ddd81 → 1.2.0-090ec876

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 (41) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/base.mjs +1 -1
  3. package/dist/types/layouts/d3forcelayout/__mocks__/d3ForceLayout.d.ts +10 -0
  4. package/dist/types/layouts/d3forcelayout/constants.d.ts +0 -1
  5. package/dist/types/layouts/d3forcelayout/d3ForceLayout.d.ts +2 -6
  6. package/dist/types/layouts/d3forcelayout/d3ForceLayout.test.d.ts +1 -0
  7. package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +17 -13
  8. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment.d.ts +1 -1
  9. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment.d.ts +1 -1
  10. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-update-fragment.d.ts +1 -1
  11. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/sim-vertex.d.ts +1 -1
  12. package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.bench.d.ts +1 -0
  13. package/dist/types/modules/NvlController.d.ts +11 -2
  14. package/dist/types/modules/NvlController.test.d.ts +1 -0
  15. package/dist/types/modules/Shader.d.ts +1 -1
  16. package/dist/types/modules/state/types.d.ts +32 -13
  17. package/dist/types/renderers/domrenderer/shared/ImageCache.d.ts +3 -2
  18. package/dist/types/renderers/domrenderer/shared/arrows/ArrowBundler.d.ts +9 -0
  19. package/dist/types/renderers/domrenderer/shared/nodes/nodes.d.ts +7 -0
  20. package/dist/types/renderers/domrenderer/shared/util.d.ts +6 -1
  21. package/dist/types/renderers/domrenderer/shared/wordwrap.d.ts +12 -1
  22. package/dist/types/renderers/domrenderer/svgrenderer/svgUtils.d.ts +0 -11
  23. package/dist/types/renderers/webglrenderer/Renderer.d.ts +1 -2
  24. package/dist/types/renderers/webglrenderer/node-animation-fragment.d.ts +1 -1
  25. package/dist/types/renderers/webglrenderer/node-animation-vertex.d.ts +1 -1
  26. package/dist/types/renderers/webglrenderer/node-fragment-point.d.ts +1 -1
  27. package/dist/types/renderers/webglrenderer/node-vertex-point.d.ts +1 -1
  28. package/dist/types/renderers/webglrenderer/rel-fragment-line.d.ts +1 -1
  29. package/dist/types/renderers/webglrenderer/rel-vertex-line.d.ts +1 -1
  30. package/dist/types/renderers/webglrenderer/viewport-box-fragment.d.ts +1 -1
  31. package/dist/types/renderers/webglrenderer/viewport-box-vertex.d.ts +1 -1
  32. package/dist/types/utils/canvasManagement.d.ts +1 -1
  33. package/dist/types/utils/constants.d.ts +8 -2
  34. package/dist/types/utils/geometry.d.ts +4 -0
  35. package/dist/types/utils/layoutSeeding.d.ts +7 -0
  36. package/dist/types/utils/layoutSeeding.test.d.ts +1 -0
  37. package/dist/types/utils/segmentAnalytics.d.ts +2 -2
  38. package/package.json +5 -4
  39. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment-verlet.d.ts +0 -2
  40. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment-verlet.d.ts +0 -2
  41. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/workaround-fragment.d.ts +0 -2
@@ -0,0 +1,10 @@
1
+ export declare class D3ForceLayout {
2
+ update(): void;
3
+ getNodePositions(items: unknown[]): unknown[];
4
+ getShouldUpdate(): boolean;
5
+ getComputing(): boolean;
6
+ destroy(): void;
7
+ setOptions(): void;
8
+ updateNodes(): void;
9
+ terminateUpdate(): void;
10
+ }
@@ -12,7 +12,6 @@ export declare const BARNES_HUT_THETA = 1.2;
12
12
  export declare const FORCE_LINK_DISTANCE: (relationship: SimulationLinkDatum<D3Node>) => number;
13
13
  export declare const FORCE_LINK_STRENGTH: (link: SimulationLinkDatum<SimulationNodeDatum>, count: number[]) => number;
14
14
  export declare const FORCE_COLLIDE_RADIUS: (node: D3Node) => number;
15
- export declare const LAYOUT_RADIUS: (numberOfNodes: number) => number;
16
15
  export declare const FORCE_CHARGE: () => number;
17
16
  export declare const FORCE_CHARGE_START: () => number;
18
17
  export declare const FORCE_CENTER_X = 0.03;
@@ -1,4 +1,4 @@
1
- import type { Simulation, SimulationNodeDatum } from 'd3-force';
1
+ import type { Simulation, SimulationLinkDatum, SimulationNodeDatum } from 'd3-force';
2
2
  import type { NvlState } from '../../modules/state/types';
3
3
  import type { Node, Relationship } from '../../types/graph-element';
4
4
  import type { Point } from '../../utils/geometry';
@@ -6,11 +6,7 @@ import type { D3Node } from './types';
6
6
  export declare class D3ForceLayout {
7
7
  state: NvlState;
8
8
  d3Nodes: Record<string, D3Node>;
9
- d3RelList: {
10
- index: number;
11
- source: string;
12
- target: string;
13
- }[];
9
+ d3RelList: SimulationLinkDatum<D3Node>[];
14
10
  computing: boolean;
15
11
  center: Point;
16
12
  nodeRelCount: number[];
@@ -7,7 +7,6 @@ export declare class PhysLayout {
7
7
  private physProjection;
8
8
  private physSmallProjection;
9
9
  private gl;
10
- private useReadpixelWorkaround;
11
10
  private averageNodeSize;
12
11
  private shouldUpdate;
13
12
  private iterationCount;
@@ -19,7 +18,6 @@ export declare class PhysLayout {
19
18
  private stateDisposers;
20
19
  private state;
21
20
  private dpr;
22
- private intelWorkaround;
23
21
  private simulationStopVelocitySquared;
24
22
  private gravity;
25
23
  private force;
@@ -31,6 +29,9 @@ export declare class PhysLayout {
31
29
  private subGraphs;
32
30
  private nodeSortMap;
33
31
  private firstUpdate;
32
+ private precomputeMs;
33
+ private precomputeStarted;
34
+ private precomputing;
34
35
  private curPhysData;
35
36
  private apprxRepForceShader;
36
37
  private levelsClusterTexture;
@@ -40,26 +41,22 @@ export declare class PhysLayout {
40
41
  private collisionDetectionMultiplier;
41
42
  private physShader;
42
43
  private physData;
43
- private workaroundData;
44
44
  private pinData;
45
45
  private updateData;
46
46
  private updateShader;
47
- private workaroundShader;
48
47
  private physPositions;
49
48
  private springTexture;
50
49
  private sizeTexture;
51
50
  private offsetTexture;
52
51
  private pinTexture;
53
52
  private addedNodes;
53
+ private seedingMethod;
54
54
  private updateTexture;
55
- private vaoExt;
56
55
  private physVao;
57
56
  private physSmallVao;
58
57
  private updateVao;
59
- private workaroundVao;
60
- enableVerlet: boolean;
61
58
  constructor(config: ForceDirectedOptions & {
62
- webGLContext: WebGLRenderingContext;
59
+ webGLContext: WebGL2RenderingContext;
63
60
  state: NvlState;
64
61
  });
65
62
  /**
@@ -77,6 +74,17 @@ export declare class PhysLayout {
77
74
  nodes: Node[];
78
75
  rels: Relationship[];
79
76
  }): import("./solarmerger/types").CoarsenedGraph;
77
+ /**
78
+ * Synchronously runs physics simulation for the configured time budget before
79
+ * the layout is first rendered.
80
+ * Sets `getComputing()` to `true` while running and clears
81
+ * it when precompute finishes (including early exit when the layout halts).
82
+ */
83
+ private runPrecompute;
84
+ private isPrecomputeEnabled;
85
+ private hasPendingPrecompute;
86
+ private hasInteractingNodes;
87
+ private shouldRunPrecompute;
80
88
  /**
81
89
  * Updates the node's positions for the next step in the physics layout iterations if the layout needs to update
82
90
  * @param refreshPositions whether the entire layout should be reheated
@@ -93,9 +101,7 @@ export declare class PhysLayout {
93
101
  */
94
102
  getShouldUpdate(): boolean;
95
103
  /**
96
- * Returns whether the current layout is computing.
97
- * Always returns false because the force-directed layout has no computing step
98
- * @returns Whether the layout is computing.
104
+ * @returns Whether the layout is running the precompute step.
99
105
  */
100
106
  getComputing(): boolean;
101
107
  /**
@@ -169,7 +175,5 @@ export declare class PhysLayout {
169
175
  private setupPhysicsForCoarse;
170
176
  private setupPinData;
171
177
  private setupUpdates;
172
- private setupReadpixelWorkaround;
173
- private doReadpixelWorkaround;
174
178
  private definePhysicsArrays;
175
179
  }
@@ -1,2 +1,2 @@
1
- declare const _default: "precision mediump float;\n\nuniform sampler2D u_physData;\nuniform sampler2D u_connections;\nuniform sampler2D u_connectionOffsets;\nuniform sampler2D u_pinnedNodes;\nuniform sampler2D u_sizeTexture;\nuniform float u_baseLength;\nuniform float u_curIteration;\nuniform float u_iterationMultiplier;\nuniform vec2 u_gravityCenter;\nuniform float u_numNodes;\nuniform float u_gravity;\n\nuniform sampler2D u_clusterData;\nuniform sampler2D u_prevForce;\nuniform float u_collisionMultiplier;\n\nfloat TIMESTEP = 1.0 / 30.0;\nfloat VELOCITYDECAY = 0.6;\nfloat accLimitLow = 500000.0;\nfloat accLimitHigh = 750000.0;\nfloat accLimitPosHigh = 10000000.0;\n\nconst float denseNodeThreshold = 1000.0;\nconst float MIN_DISTANCE = 0.00000001;\nconst float MAX_DISTANCE = 1000000000.0;\nconst float MAX_ACCELERATION = 500000.0;\n\nvec4 getTextureData(sampler2D texture, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture2D(texture, vec2(x + 0.5, y + 0.5) / base);\n}\n\nbool isNan(float val) {\n return (val < 0.0 || 0.0 < val || val == 0.0) ? false : true;\n}\n\nconst float BIG_NUMBER = 999999999999999999.0;\nbool isInf(float val) {\n return val > BIG_NUMBER || val < -BIG_NUMBER;\n}\n\nvec2 getDelta(vec2 v1, vec2 v2) {\n vec2 delta = v1 - v2;\n float dist = length(delta);\n if (dist < MIN_DISTANCE || isNan(dist)) {\n return vec2(MIN_DISTANCE, MIN_DISTANCE);\n }\n if (dist > MAX_DISTANCE) {\n vec2 normDelta = delta / dist;\n return normDelta * MAX_DISTANCE;\n }\n return delta;\n}\n\nvec4 getOtherNodePosition(float i) {\n return getTextureData(u_physData, i, 256.0);\n}\n\nfloat getCombinedNodeSize(float i, float nodeSize) {\n float otherNodeSize = getTextureData(u_sizeTexture, i, 256.0).a;\n return nodeSize + otherNodeSize;\n}\n\nvec2 getSpringForce(float curConnection, float numConnections, float springFScale, vec4 myPosition, float i) {\n float curSpring = getTextureData(u_connections, curConnection + i, 4096.0).a;\n\n vec4 otherPosition = getTextureData(u_physData, curSpring, 256.0);\n float otherDataPosition = getTextureData(u_connectionOffsets, curSpring, 256.0).a;\n float avgDegree;\n#if INTEL_WORKAROUND\n avgDegree = max(numConnections, 4.0);\n#else\n float otherNumConnections = getTextureData(u_connections, otherDataPosition, 4096.0).a;\n avgDegree = max((otherNumConnections + numConnections * 3.0) / 4.0, 4.0);\n#endif\n\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n\n float F = (dist * dist * springFScale) / (u_baseLength * avgDegree);\n if (u_collisionMultiplier > 0.0) {\n F *= u_collisionMultiplier;\n }\n return (-delta / dist) * F;\n}\n\nvec2 getCollisionForce(float combinedNodeSize, float dist, float fScale, vec2 delta) {\n float collisionForce = ((combinedNodeSize - dist) / dist);\n if (u_collisionMultiplier > 0.0) {\n collisionForce *= u_collisionMultiplier;\n }\n return (delta * collisionForce * fScale * combinedNodeSize) / (combinedNodeSize + 1.0);\n}\n\nvec2 getRepulsionForce(float dist, float fScale, vec2 delta) {\n float F = (u_baseLength * u_baseLength * (fScale / 1.5)) / dist;\n return (delta / dist) * F * 0.05;\n}\n\nvoid main(void) {\n float textureSide = 256.0; //#TEXTURE_SIDE#;\n float index = (gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * textureSide;\n\n if (index >= u_numNodes) {\n discard;\n }\n\n vec4 clusterData = getTextureData(u_clusterData, index, 256.0);\n\n float clusterIndex = clusterData.x;\n float clusterStartIndex = clusterData.y;\n float clusterSize = clusterData.z;\n float clusterWeight = clusterData.w;\n\n vec4 myPosition = getTextureData(u_physData, index, 256.0);\n vec4 previousForce = getTextureData(u_prevForce, clusterIndex, 256.0);\n\n vec2 acceleration = previousForce.xy;\n\n float isPinned = getTextureData(u_pinnedNodes, index, 256.0).a;\n float nodeSize = getTextureData(u_sizeTexture, index, 256.0).a;\n\n if (isPinned > 0.5) {\n gl_FragColor = vec4(myPosition.xy, 0.0, 0.0);\n return;\n }\n\n float curConnection = getTextureData(u_connectionOffsets, index, 256.0).a;\n float numConnections = getTextureData(u_connections, curConnection, 4096.0).a;\n\n float fScale = 1.0 + sqrt(u_iterationMultiplier);\n float springFScale = fScale;\n\n if (numConnections > denseNodeThreshold) {\n springFScale = sqrt(fScale);\n }\n\n float numOfRels = 0.0;\n\n // Springs\n for (float i = 1.0; i <= 256.0 * 256.0; i++) {\n if (numOfRels >= numConnections) {\n break;\n }\n acceleration += getSpringForce(curConnection, numConnections, springFScale, myPosition, i);\n numOfRels += 1.0;\n }\n\n // Repulsion && collision detection\n if (u_collisionMultiplier > 0.0) {\n float number_of_collisions = 0.0;\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= u_numNodes) {\n break;\n }\n\n if (i == index) {\n continue;\n }\n\n vec4 otherPosition = getOtherNodePosition(i);\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n float combinedNodeSize = getCombinedNodeSize(i, nodeSize) * 2.0;\n\n if (dist < combinedNodeSize && number_of_collisions < 40.0) {\n number_of_collisions++;\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n if (i >= clusterStartIndex && i < clusterStartIndex + clusterSize) {\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n } else {\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= clusterStartIndex + clusterSize || i >= u_numNodes) {\n break;\n }\n\n if (i < clusterStartIndex || i == index) {\n continue;\n }\n\n vec4 otherPosition = getOtherNodePosition(i);\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n float combinedNodeSize = getCombinedNodeSize(i, nodeSize);\n\n if (dist < combinedNodeSize) {\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n\n // Gravity\n vec2 delta = getDelta(u_gravityCenter, myPosition.xy);\n float dist = length(delta);\n\n vec2 grav = (delta / dist) * u_gravity * fScale;\n acceleration += grav * smoothstep(0.0, 500.0, dist);\n\n float accMagnitude = length(acceleration);\n acceleration *= min(MAX_ACCELERATION, accMagnitude) / accMagnitude;\n\n float iterationFrictionThreshold = 1000.0;\n\n if (u_curIteration > iterationFrictionThreshold) {\n float friction = 1.0 + pow((u_curIteration - iterationFrictionThreshold), 2.0) / 100.0;\n acceleration *= 1.0 / friction;\n }\n\n if (u_curIteration == 0.0) {\n gl_FragColor = vec4(myPosition.xy, acceleration * TIMESTEP * 0.5);\n } else {\n myPosition.zw = myPosition.zw * VELOCITYDECAY;\n gl_FragColor = vec4(myPosition.xy + myPosition.zw * TIMESTEP, myPosition.zw + acceleration * TIMESTEP);\n }\n}";
1
+ declare const _default: "#version 300 es\nprecision mediump float;\n\nuniform sampler2D u_physData;\nuniform sampler2D u_connections;\nuniform sampler2D u_connectionOffsets;\nuniform sampler2D u_pinnedNodes;\nuniform sampler2D u_sizeTexture;\nuniform float u_baseLength;\nuniform float u_curIteration;\nuniform float u_iterationMultiplier;\nuniform vec2 u_gravityCenter;\nuniform float u_numNodes;\nuniform float u_gravity;\n\nuniform sampler2D u_clusterData;\nuniform sampler2D u_prevForce;\nuniform float u_collisionMultiplier;\n\nout vec4 fragColor;\n\nfloat DAMP = 0.6;\nfloat COOL = 0.99998;\nfloat TIMESTEP = 1.0 / 30.0;\nfloat VELOCITYDECAY = 0.6;\nfloat accLimitLow = 500000.0;\nfloat accLimitHigh = 750000.0;\nfloat accLimitPosHigh = 10000000.0;\n\nconst float denseNodeThreshold = 1000.0;\nconst float MIN_DISTANCE = 0.00000001;\nconst float MAX_DISTANCE = 1000000000.0;\nconst float MAX_ACCELERATION = 50000.0;\n\nvec4 getTextureData(sampler2D tex, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture(tex, vec2(x + 0.5, y + 0.5) / base);\n}\n\nbool isNan(float val) {\n return (val < 0.0 || 0.0 < val || val == 0.0) ? false : true;\n}\n\nconst float BIG_NUMBER = 999999999999999999.0;\nbool isInf(float val) {\n return val > BIG_NUMBER || val < -BIG_NUMBER;\n}\n\nvec2 getDelta(vec2 v1, vec2 v2) {\n vec2 delta = v1 - v2;\n float dist = length(delta);\n if (dist < MIN_DISTANCE || isNan(dist)) {\n return vec2(MIN_DISTANCE, MIN_DISTANCE);\n }\n if (dist > MAX_DISTANCE) {\n vec2 normDelta = delta / dist;\n return normDelta * MAX_DISTANCE;\n }\n return delta;\n}\n\nvec4 getOtherNodePosition(float i) {\n return getTextureData(u_physData, i, 256.0);\n}\n\nfloat getCombinedNodeSize(float i, float nodeSize) {\n float otherNodeSize = getTextureData(u_sizeTexture, i, 256.0).r;\n return nodeSize + otherNodeSize;\n}\n\nvec2 getSpringForce(float curConnection, float numConnections, float springFScale, vec4 myPosition, float i) {\n float curSpring = getTextureData(u_connections, curConnection + i, 4096.0).r;\n\n vec4 otherPosition = getTextureData(u_physData, curSpring, 256.0);\n float otherDataPosition = getTextureData(u_connectionOffsets, curSpring, 256.0).r;\n float otherNumConnections = getTextureData(u_connections, otherDataPosition, 4096.0).r;\n float avgDegree = max((otherNumConnections + numConnections * 3.0) / 4.0, 4.0);\n\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n\n float F = (dist * dist * springFScale) / (u_baseLength * avgDegree);\n if (u_collisionMultiplier > 0.0) {\n F *= u_collisionMultiplier;\n }\n return (-delta / dist) * F;\n}\n\nvec2 getCollisionForce(float combinedNodeSize, float dist, float fScale, vec2 delta) {\n float collisionForce = (combinedNodeSize - dist) / (dist);\n if (u_collisionMultiplier > 0.0) {\n collisionForce *= u_collisionMultiplier;\n }\n return (delta * collisionForce * fScale * combinedNodeSize) / (combinedNodeSize + 1.0);\n}\n\nvec2 getRepulsionForce(float dist, float fScale, vec2 delta) {\n float F = (u_baseLength * u_baseLength * fScale) / (dist);\n return (delta / dist) * F * 0.05;\n}\n\nvoid main(void) {\n float textureSide = 256.0; //#TEXTURE_SIDE#;\n float index = (gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * textureSide;\n\n if (index >= u_numNodes) {\n discard;\n }\n\n vec4 clusterData = getTextureData(u_clusterData, index, 256.0);\n\n float clusterIndex = clusterData.x;\n float clusterStartIndex = clusterData.y;\n float clusterSize = clusterData.z;\n float clusterWeight = clusterData.w;\n\n vec4 myPosition = getTextureData(u_physData, index, 256.0);\n vec4 previousForce = getTextureData(u_prevForce, clusterIndex, 256.0);\n\n vec2 acceleration = previousForce.xy;\n\n float isPinned = getTextureData(u_pinnedNodes, index, 256.0).r;\n float nodeSize = getTextureData(u_sizeTexture, index, 256.0).r;\n\n if (isPinned > 0.5) {\n fragColor = vec4(myPosition.xy, 0.0, 0.0);\n return;\n }\n\n float curConnection = getTextureData(u_connectionOffsets, index, 256.0).r;\n float numConnections = getTextureData(u_connections, curConnection, 4096.0).r;\n\n float fScale = 1.0 + sqrt(u_iterationMultiplier);\n float springFScale = fScale;\n\n if (numConnections > denseNodeThreshold) {\n springFScale = sqrt(fScale);\n }\n\n float numOfRels = 0.0;\n\n // Springs\n for (float i = 1.0; i <= 256.0 * 256.0; i++) {\n if (numOfRels >= numConnections) {\n break;\n }\n acceleration += getSpringForce(curConnection, numConnections, springFScale, myPosition, i);\n numOfRels += 1.0;\n }\n\n // Repulsion && collision detection\n if (u_collisionMultiplier > 0.0) {\n float number_of_collisions = 0.0;\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= u_numNodes) {\n break;\n }\n\n if (i == index) {\n continue;\n }\n\n vec4 otherPosition = getOtherNodePosition(i);\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n float combinedNodeSize = getCombinedNodeSize(i, nodeSize) * 2.0;\n\n if (dist < combinedNodeSize && number_of_collisions < 40.0) {\n number_of_collisions++;\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n if (i >= clusterStartIndex && i < clusterStartIndex + clusterSize) {\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n } else {\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= clusterStartIndex + clusterSize || i >= u_numNodes) {\n break;\n }\n\n if (i < clusterStartIndex || i == index) {\n continue;\n }\n\n vec4 otherPosition = getOtherNodePosition(i);\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n float combinedNodeSize = getCombinedNodeSize(i, nodeSize);\n\n if (dist < combinedNodeSize) {\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n\n // Gravity\n vec2 delta = getDelta(u_gravityCenter, myPosition.xy);\n float dist = length(delta);\n\n vec2 grav = (delta / dist) * u_gravity * fScale * (dist / 1000.0);\n acceleration += grav;\n\n float accMagnitude = length(acceleration);\n acceleration *= min(MAX_ACCELERATION, accMagnitude) / accMagnitude;\n\n float iterationFrictionThreshold = 1000.0;\n\n if (u_curIteration > iterationFrictionThreshold) {\n float friction = 1.0 + pow((u_curIteration - iterationFrictionThreshold), 2.0) / 100.0;\n acceleration *= 1.0 / friction;\n }\n\n if (u_curIteration == 0.0) {\n fragColor = vec4(myPosition.xy, myPosition.zw);\n } else {\n float TEMP = max(0.02, pow(COOL, u_curIteration));\n vec2 prevVelocity = myPosition.zw;\n vec2 currentPos = myPosition.xy;\n\n vec2 newPos = currentPos + TEMP * ( DAMP * (prevVelocity) + acceleration * TIMESTEP * TIMESTEP);\n vec2 newVelocity = newPos - currentPos;\n fragColor = vec4(newPos, newVelocity);\n }\n}";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "precision mediump float;\nuniform sampler2D u_physData;\nuniform sampler2D u_clusterData;\nuniform sampler2D u_finestIndexes;\nuniform sampler2D u_prevForce;\n\nuniform float u_baseLength;\nuniform float u_numNodes;\nuniform float u_iterationMultiplier;\nuniform float u_isTopLevel;\n\nfloat TIMESTEP = 1.0 / 30.0;\nfloat VELOCITYDECAY = 0.6;\n\nvec4 getTextureData(sampler2D texture, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture2D(texture, vec2(x + 0.5, y + 0.5) / base);\n}\n\nfloat getLogClusterWeight(float value) {\n return value / max(log(value), 1.0);\n}\n\nvoid main(void) {\n float index = (gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * 256.0;\n\n if (index >= u_numNodes) {\n discard;\n }\n\n vec4 clusterData = getTextureData(u_clusterData, index, 256.0);\n\n float clusterIndex = clusterData.x;\n float clusterStartIndex = clusterData.y;\n float clusterSize = clusterData.z;\n\n float finestIndex = getTextureData(u_finestIndexes, index, 256.0).a;\n vec4 myPosition = getTextureData(u_physData, finestIndex, 256.0);\n vec4 previousForce = getTextureData(u_prevForce, clusterIndex, 256.0);\n float fScale = 1.0 + sqrt(u_iterationMultiplier);\n\n vec2 acceleration = previousForce.xy;\n\n // Repulsion & Collision Detection\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= clusterStartIndex + clusterSize || i >= u_numNodes) {\n break;\n }\n if (i < clusterStartIndex || i == index) {\n continue;\n }\n\n vec4 otherClusterData = getTextureData(u_clusterData, i, 256.0);\n float otherClusterWeight = getLogClusterWeight(otherClusterData.w);\n\n float otherFinestIndex = getTextureData(u_finestIndexes, i, 256.0).a;\n vec4 otherPosition = getTextureData(u_physData, otherFinestIndex, 256.0);\n\n vec2 delta = myPosition.xy - otherPosition.xy;\n float dist = max(length(delta), 0.0000001);\n float maxDist = 25.0;\n float repulsionForceScale = 0.1;\n\n float F = ((u_baseLength * u_baseLength) * (fScale / 1.5)) / dist;\n\n if (u_isTopLevel == 1.0) {\n repulsionForceScale = 0.3;\n }\n\n acceleration += ((delta / dist) * F) * repulsionForceScale * otherClusterWeight;\n\n if (dist < maxDist) {\n float collide = (maxDist - dist) / dist;\n acceleration += delta * collide * fScale * maxDist / (maxDist + 1.0);\n }\n }\n\n gl_FragColor = vec4(acceleration, vec2(finestIndex, 0));\n}";
1
+ declare const _default: "#version 300 es\nprecision mediump float;\nuniform sampler2D u_physData;\nuniform sampler2D u_clusterData;\nuniform sampler2D u_finestIndexes;\nuniform sampler2D u_prevForce;\n\nuniform float u_baseLength;\nuniform float u_numNodes;\nuniform float u_iterationMultiplier;\nuniform float u_isTopLevel;\n\nout vec4 fragColor;\n\nfloat PI = 3.1415926535897932384626433832795;\nfloat TIMESTEP = 1.0 / 30.0;\nfloat VELOCITYDECAY = 1.0;\n\nvec4 getTextureData(sampler2D tex, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture(tex, vec2(x + 0.5, y + 0.5) / base);\n}\n\nfloat getSquaredLogClusterWeight(float value) {\n return pow(log(value), 2.0);\n}\n\nvoid main(void) {\n float index = (gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * 256.0;\n\n if (index >= u_numNodes) {\n discard;\n }\n\n vec4 clusterData = getTextureData(u_clusterData, index, 256.0);\n\n float clusterIndex = clusterData.x;\n float clusterStartIndex = clusterData.y;\n float clusterSize = clusterData.z;\n float clusterArea = pow(clusterSize + u_baseLength * 2.0, 2.0);\n\n float finestIndex = getTextureData(u_finestIndexes, index, 256.0).r;\n vec4 myPosition = getTextureData(u_physData, finestIndex, 256.0);\n vec4 previousForce = getTextureData(u_prevForce, clusterIndex, 256.0);\n float fScale = 1.0 + sqrt(u_iterationMultiplier);\n\n vec2 acceleration = previousForce.xy;\n\n // Repulsion & Collision Detection\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= clusterStartIndex + clusterSize || i >= u_numNodes) {\n break;\n }\n if (i < clusterStartIndex || i == index) {\n continue;\n }\n\n vec4 otherClusterData = getTextureData(u_clusterData, i, 256.0);\n float otherClusterWeight = getSquaredLogClusterWeight(otherClusterData.w);\n\n float otherFinestIndex = getTextureData(u_finestIndexes, i, 256.0).r;\n vec4 otherPosition = getTextureData(u_physData, otherFinestIndex, 256.0);\n\n vec2 delta = myPosition.xy - otherPosition.xy;\n float dist = max(length(delta), 0.0000001);\n float maxDist = 25.0;\n float repulsionForceScale = 0.1;\n\n float F = (clusterArea * fScale) / (dist * dist);\n\n if (u_isTopLevel == 1.0) {\n repulsionForceScale = 0.2;\n }\n\n acceleration += ((delta / sqrt(dist)) * F) * repulsionForceScale * otherClusterWeight;\n\n if (dist < maxDist) {\n float collide = (maxDist - dist) / (dist * dist);\n acceleration += delta * collide * fScale * maxDist / (maxDist + 1.0);\n }\n }\n\n fragColor = vec4(acceleration, vec2(finestIndex, 0));\n}";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "precision mediump float;\n\nuniform sampler2D u_physData;\nuniform sampler2D u_updateData;\nuniform float u_numNodesNew;\n\nconst float INDEX_FLAG = 999999.0;\n\nvec4 getTextureData(sampler2D texture, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture2D(texture, vec2(x + 0.5, y + 0.5) / base);\n}\n\nvoid main(void) {\n float textureSide = 256.0; //#TEXTURE_SIDE#;\n float index = (gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5)*textureSide;\n\n if (index >= u_numNodesNew) {\n discard;\n }\n\n float firstValue = getTextureData(u_updateData, index * 2.0, 256.0).a;\n float secondValue = getTextureData(u_updateData, index * 2.0 + 1.0, 256.0).a;\n\n if (secondValue == INDEX_FLAG) {\n vec4 myPosition = getTextureData(u_physData, firstValue, 256.0);\n gl_FragColor = myPosition;\n } else {\n gl_FragColor = vec4(firstValue, secondValue, 0.0, 0.0);\n }\n}\n";
1
+ declare const _default: "#version 300 es\nprecision mediump float;\n\nuniform sampler2D u_physData;\nuniform sampler2D u_updateData;\nuniform float u_numNodesNew;\n\nout vec4 fragColor;\n\nconst float INDEX_FLAG = 999999.0;\n\nvec4 getTextureData(sampler2D tex, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture(tex, vec2(x + 0.5, y + 0.5) / base);\n}\n\nvoid main(void) {\n float textureSide = 256.0; //#TEXTURE_SIDE#;\n float index = (gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5)*textureSide;\n\n if (index >= u_numNodesNew) {\n discard;\n }\n\n float firstValue = getTextureData(u_updateData, index * 2.0, 256.0).r;\n float secondValue = getTextureData(u_updateData, index * 2.0 + 1.0, 256.0).r;\n\n if (secondValue == INDEX_FLAG) {\n vec4 myPosition = getTextureData(u_physData, firstValue, 256.0);\n fragColor = myPosition;\n } else {\n fragColor = vec4(firstValue, secondValue, 0.0, 0.0);\n }\n}\n";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "uniform mat4 u_projection;\n\nattribute vec2 a_position;\n//attribute float a_index;\n\n//varying highp float index;\n\nvoid main() {\n// index = a_index;\n gl_Position = u_projection * vec4(a_position, 0.0, 1.0);\n}";
1
+ declare const _default: "#version 300 es\nuniform mat4 u_projection;\n\nin vec2 a_position;\n//in float a_index;\n\n//out highp float index;\n\nvoid main() {\n// index = a_index;\n gl_Position = u_projection * vec4(a_position, 0.0, 1.0);\n}";
2
2
  export default _default;
@@ -46,12 +46,16 @@ export default class NvlController {
46
46
  private readonly stateDisposers;
47
47
  private readonly zoomTransitionHandler;
48
48
  private currentLayout;
49
+ private lastTimestamp;
50
+ private accumulator;
49
51
  private readonly layoutTimeLimit;
52
+ private readonly smoothFrameBudgetMs;
50
53
  private pixelRatio;
51
54
  private readonly removeResizeListener;
52
55
  private readonly removeMinimapResizeListener;
53
- private pendingZoomOperation;
54
- private layoutRunner;
56
+ private pendingZoom;
57
+ private pendingPan;
58
+ private pendingViewportOverride;
55
59
  private animationRequestId;
56
60
  private layoutDoneCallback;
57
61
  private layoutComputingCallback;
@@ -59,8 +63,13 @@ export default class NvlController {
59
63
  private descriptionElement;
60
64
  constructor(state: NvlState, frame: HTMLElement, options: NvlOptions);
61
65
  private onWebGLContextLost;
66
+ private fpsToFrameBudgetMs;
67
+ private getLayoutNeedsToUpdate;
68
+ private isWithinBudget;
62
69
  private updateMinimapZoom;
63
70
  private startMainLoop;
71
+ private renderNodeHtmlOverlays;
72
+ private renderRelationshipHtmlOverlays;
64
73
  updateHtmlOverlay(): void;
65
74
  dumpNodes(): Node[];
66
75
  dumpRelationships(): Relationship[];
@@ -0,0 +1 @@
1
+ export {};
@@ -4,7 +4,7 @@ export default class Shader {
4
4
  private curTexture;
5
5
  private attributeInfo;
6
6
  private uniformInfo;
7
- constructor(gl: WebGLRenderingContext, vsSource: string, fsSource: string, defines?: {});
7
+ constructor(gl: WebGL2RenderingContext, vsSource: string, fsSource: string, defines?: {});
8
8
  setUniform(name: string, value: any): void;
9
9
  setAttributePointer(name: string, size: number, start: number, stride: number): void;
10
10
  setAttributePointerFloat(name: string, size: number, start: number, stride: number): void;
@@ -38,25 +38,31 @@ export type DisabledItemStyles = {
38
38
  */
39
39
  export interface ForceDirectedOptions {
40
40
  /**
41
- * Enables a workaround for Intel GPU compatibility issues in WebGL shader compilation.
42
- * When enabled, this flag modifies how physics simulation shaders are compiled to avoid
43
- * rendering problems on Intel graphics hardware.
44
- *
45
- * @remarks Requires a restart of NVL as shaders need to be recompiled.
41
+ * @deprecated No longer has any effect. The physics layout now uses WebGL2 which does not
42
+ * require the Intel GPU shader workaround. This option will be removed in a future release.
46
43
  */
47
44
  intelWorkaround?: boolean;
48
45
  /**
46
+ * @deprecated This option will be removed in a future release. For small datasets, use the d3Force layout instead.
49
47
  * Whether to enable automatic switching to CoseBilkent layout for small graphs.
50
48
  * When enabled, small graphs will automatically use the CoseBilkent layout algorithm
51
49
  * which can provide better initial positioning for smaller datasets.
50
+ * @defaultValue true
52
51
  */
53
52
  enableCytoscape?: boolean;
54
53
  /**
55
- * Wether to use the new physics engine instead of the legacy one.
56
- * @defaultValue true
57
- * @internal
54
+ * How initial node positions are seeded before the physics simulation runs.
55
+ * @defaultValue 'box'
58
56
  */
59
- enableVerlet?: boolean;
57
+ seedingMethod?: 'box' | 'circle';
58
+ /**
59
+ * @experimental
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.
64
+ */
65
+ precomputeMs?: number;
60
66
  }
61
67
  /**
62
68
  * The options for the hierarchical layout
@@ -231,11 +237,24 @@ export interface NvlOptions {
231
237
  minimapViewportBoxColor?: string;
232
238
  };
233
239
  /**
234
- * @internal
235
- * @hidden
236
- * Defines a time limit for how long layout iterations may run
240
+ * Target minimum presentation rate (fps) while layout is active.
241
+ * Rendering will not drop below this rate at the cost of stabilization speed.
242
+ *
243
+ * @defaultValue 3
244
+ *
245
+ * @note Must be within range of 1 and 120.
246
+ */
247
+ minFps?: number;
248
+ /**
249
+ * Target maximum presentation rate (fps) while layout is active.
250
+ * Rendering will not go above with rate. Any additional
251
+ * computation available is used to speed up layout stabilization.
252
+ *
253
+ * @defaultValue 30
254
+ *
255
+ * @note Must be within range of 1 and 120.
237
256
  */
238
- layoutTimeLimit?: number;
257
+ maxFps?: number;
239
258
  /**
240
259
  * Disables tracking of library usage
241
260
  * @defaultValue false
@@ -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;
@@ -24,6 +24,15 @@ export default class ArrowBundler {
24
24
  * @param positionMap A map of node IDs to positions.
25
25
  */
26
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;
27
36
  /**
28
37
  * Get a unique ID for a pair of IDs
29
38
  * @param id1 - The first ID.
@@ -2,6 +2,13 @@ import type { BorderStyles } from '../../../../modules/state/types';
2
2
  import type { Node } from '../../../../types/graph-element';
3
3
  import type AnimationHandler from '../../canvasrenderer/AnimationHandler';
4
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;
5
12
  /**
6
13
  * Returns the bounding box of a node with the given x, y, and size properties.
7
14
  * If no size is given, the default size is used.
@@ -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
@@ -65,14 +65,3 @@ export declare const createStyledTextElement: (options: {
65
65
  transform?: string;
66
66
  fontWeight?: string;
67
67
  }) => SVGTextElement;
68
- /**
69
- * Groups consecutive characters with the same style into text spans
70
- * @param lineText - The text of the line
71
- * @param stylesPerChar - Array of style arrays for each character
72
- * @param startCharIndex - The starting character index in the overall caption
73
- * @returns Array of text spans with their styles
74
- */
75
- export declare const getGroupedTextSpans: (lineText: string, stylesPerChar: string[][], startCharIndex: number) => {
76
- text: string;
77
- style: string;
78
- }[];
@@ -30,8 +30,7 @@ export default class Renderer {
30
30
  private nodeVao;
31
31
  private relVao;
32
32
  private nodeAnimVao;
33
- private vaoExt;
34
- constructor(gl: WebGLRenderingContext, nodes: DataSet<Node>, rels: DataSet<Relationship>, state: NvlState);
33
+ constructor(gl: WebGL2RenderingContext, nodes: DataSet<Node>, rels: DataSet<Relationship>, state: NvlState);
35
34
  private setShaderUniforms;
36
35
  setData(data: {
37
36
  nodes: Node[];
@@ -1,2 +1,2 @@
1
- declare const _default: "uniform mediump float u_zoom;\nuniform lowp float u_animPos;\nuniform mediump float u_glAdjust;\n\nvarying lowp vec4 color;\nvarying lowp float varNodeSize;\nmediump float circleSize = 0.50;\n\nvoid main(void) {\n\n lowp float dist = distance(gl_PointCoord, vec2(0.5));\n\n if (dist > 0.51) {\n discard;\n }\n else {\n lowp float alpha = 1.0 - smoothstep(circleSize - (1.0 / (varNodeSize * 2.0 * u_zoom * u_glAdjust)), circleSize, dist);\n lowp float pulseAlpha = 0.9 - 0.9 * u_animPos;\n gl_FragColor = vec4(color.xyz, 1.0) * alpha * pulseAlpha;\n }\n}\n";
1
+ declare const _default: "#version 300 es\nprecision lowp float;\n\nuniform mediump float u_zoom;\nuniform lowp float u_animPos;\nuniform mediump float u_glAdjust;\n\nin lowp vec4 color;\nin lowp float varNodeSize;\n\nout vec4 fragColor;\n\nmediump float circleSize = 0.50;\n\nvoid main(void) {\n\n lowp float dist = distance(gl_PointCoord, vec2(0.5));\n\n if (dist > 0.51) {\n discard;\n }\n else {\n lowp float alpha = 1.0 - smoothstep(circleSize - (1.0 / (varNodeSize * 2.0 * u_zoom * u_glAdjust)), circleSize, dist);\n lowp float pulseAlpha = 0.9 - 0.9 * u_animPos;\n fragColor = vec4(color.xyz, 1.0) * alpha * pulseAlpha;\n }\n}\n";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "uniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform lowp float u_animPos;\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\n\nattribute float a_size;\nattribute lowp vec2 a_index;\nattribute lowp vec4 a_color;\nattribute lowp float a_active;\n\nvarying lowp float varNodeSize;\nvarying lowp vec4 color;\n\nvoid main(void) {\n vec4 data = texture2D(u_positions, a_index);\n\n gl_Position = u_projection * vec4(data.xy, 0.0, 1.0);\n\n float nodeSize = a_size * u_zoom * u_glAdjust;\n nodeSize = nodeSize * (0.4 / 0.5); // Remove extra space added for shadow and selection ring\n\n gl_PointSize = a_active > 0.5\n ? nodeSize + 0.88 * nodeSize * u_animPos\n : 0.0;\n\n color = a_color;\n varNodeSize = a_size;\n}";
1
+ declare const _default: "#version 300 es\nuniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform lowp float u_animPos;\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\n\nin float a_size;\nin lowp vec2 a_index;\nin lowp vec4 a_color;\nin lowp float a_active;\n\nout lowp float varNodeSize;\nout lowp vec4 color;\n\nvoid main(void) {\n vec4 data = texture(u_positions, a_index);\n\n gl_Position = u_projection * vec4(data.xy, 0.0, 1.0);\n\n float nodeSize = a_size * u_zoom * u_glAdjust;\n nodeSize = nodeSize * (0.4 / 0.5); // Remove extra space added for shadow and selection ring\n\n gl_PointSize = a_active > 0.5\n ? nodeSize + 0.88 * nodeSize * u_animPos\n : 0.0;\n\n color = a_color;\n varNodeSize = a_size;\n}";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "uniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\n\nvarying lowp vec4 color;\nvarying lowp float drawDefaultBorder;\nvarying lowp vec3 nodeBorderColor;\nvarying lowp vec3 selectedBorderColor;\nvarying lowp vec3 selectedInnerBorderColor;\nvarying lowp vec3 shadowColor;\nvarying lowp float selected;\nvarying lowp float hovered;\nvarying lowp float varNodeSize;\n\nmediump float circleSize = 0.40;\nmediump float defaultBoderSize = 0.42;\nmediump float innerSelectedRingSize = 0.43;\nmediump float outerSelectedRingSize = 0.47;\nmediump float shadowSize = 0.51;\n\nlowp float getShadowAlpha(lowp float size, lowp float dist) {\n return (1.0 - smoothstep(size, shadowSize, dist)) * 0.25;\n}\n\nlowp float getCircleAlpha(lowp float ringSize, lowp float nodeSize, lowp float dist) {\n return color.w - smoothstep(ringSize - nodeSize, ringSize, dist);\n}\n\nvoid main() {\n lowp float dist = distance(gl_PointCoord, vec2(0.5));\n\n if (dist > 0.51) {\n discard;\n }\n else {\n lowp float nodeSize = 1.0 / varNodeSize;\n lowp float nodeAlpha = getCircleAlpha(circleSize, nodeSize, dist);\n lowp float borderAlpha = getCircleAlpha(defaultBoderSize, nodeSize, dist);\n lowp float ringAlpha = getCircleAlpha(innerSelectedRingSize, nodeSize, dist);\n lowp vec3 finalColor = color.xyz;\n lowp float finalAlpha = nodeAlpha;\n\n if (selected > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(outerSelectedRingSize, dist);\n lowp float ringAlpha2 = getCircleAlpha(outerSelectedRingSize, nodeSize, dist);\n\n if (drawDefaultBorder > 0.0) {\n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(selectedInnerBorderColor, finalColor, borderAlpha);\n finalColor = mix(selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(borderAlpha, ringAlpha2)));\n } else {\n finalColor = mix(selectedInnerBorderColor, finalColor, nodeAlpha);\n finalColor = mix(selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(ringAlpha, ringAlpha2)));\n }\n } else if (hovered > 0.0) {\n if (drawDefaultBorder > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(defaultBoderSize, dist);\n \n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(shadowColor, finalColor, borderAlpha);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, ringAlpha));\n } else {\n lowp float shadowAlpha = getShadowAlpha(circleSize, dist);\n\n finalColor = mix(shadowColor, finalColor, nodeAlpha);\n finalAlpha = max(shadowAlpha, nodeAlpha);\n }\n } else {\n if (drawDefaultBorder > 0.0) {\n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalAlpha = borderAlpha;\n }\n }\n gl_FragColor = vec4(finalColor, 1.0) * finalAlpha;\n }\n}\n";
1
+ declare const _default: "#version 300 es\nprecision lowp float;\n\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\n\nin lowp vec4 color;\nin lowp float drawDefaultBorder;\nin lowp vec3 nodeBorderColor;\nin lowp vec3 selectedBorderColor;\nin lowp vec3 selectedInnerBorderColor;\nin lowp vec3 shadowColor;\nin lowp float selected;\nin lowp float hovered;\nin lowp float varNodeSize;\n\nout vec4 fragColor;\n\nmediump float circleSize = 0.40;\nmediump float defaultBoderSize = 0.42;\nmediump float innerSelectedRingSize = 0.43;\nmediump float outerSelectedRingSize = 0.47;\nmediump float shadowSize = 0.51;\n\nlowp float getShadowAlpha(lowp float size, lowp float dist) {\n return (1.0 - smoothstep(size, shadowSize, dist)) * 0.25;\n}\n\nlowp float getCircleAlpha(lowp float ringSize, lowp float nodeSize, lowp float dist) {\n return color.w - smoothstep(ringSize - nodeSize, ringSize, dist);\n}\n\nvoid main() {\n lowp float dist = distance(gl_PointCoord, vec2(0.5));\n\n if (dist > 0.51) {\n discard;\n }\n else {\n lowp float nodeSize = 1.0 / varNodeSize;\n lowp float nodeAlpha = getCircleAlpha(circleSize, nodeSize, dist);\n lowp float borderAlpha = getCircleAlpha(defaultBoderSize, nodeSize, dist);\n lowp float ringAlpha = getCircleAlpha(innerSelectedRingSize, nodeSize, dist);\n lowp vec3 finalColor = color.xyz;\n lowp float finalAlpha = nodeAlpha;\n\n if (selected > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(outerSelectedRingSize, dist);\n lowp float ringAlpha2 = getCircleAlpha(outerSelectedRingSize, nodeSize, dist);\n\n if (drawDefaultBorder > 0.0) {\n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(selectedInnerBorderColor, finalColor, borderAlpha);\n finalColor = mix(selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(borderAlpha, ringAlpha2)));\n } else {\n finalColor = mix(selectedInnerBorderColor, finalColor, nodeAlpha);\n finalColor = mix(selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(ringAlpha, ringAlpha2)));\n }\n } else if (hovered > 0.0) {\n if (drawDefaultBorder > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(defaultBoderSize, dist);\n \n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(shadowColor, finalColor, borderAlpha);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, ringAlpha));\n } else {\n lowp float shadowAlpha = getShadowAlpha(circleSize, dist);\n\n finalColor = mix(shadowColor, finalColor, nodeAlpha);\n finalAlpha = max(shadowAlpha, nodeAlpha);\n }\n } else {\n if (drawDefaultBorder > 0.0) {\n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalAlpha = borderAlpha;\n }\n }\n fragColor = vec4(finalColor, 1.0) * finalAlpha;\n }\n}\n";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "uniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\nuniform lowp vec3 u_nodeBorderColor;\nuniform lowp vec3 u_selectedBorderColor;\nuniform lowp vec3 u_selectedInnerBorderColor;\nuniform lowp vec3 u_shadowColor;\nuniform lowp float u_drawDefaultBorder;\n\nattribute float a_size;\nattribute lowp vec2 a_index;\nattribute lowp vec4 a_color;\nattribute lowp float a_selected;\nattribute lowp float a_hovered;\n\nvarying lowp float window;\nvarying lowp vec4 color;\nvarying lowp float selected;\nvarying lowp float hovered;\nvarying lowp float varNodeSize;\nvarying lowp vec3 nodeBorderColor;\nvarying lowp vec3 selectedBorderColor;\nvarying lowp vec3 selectedInnerBorderColor;\nvarying lowp vec3 shadowColor;\nvarying lowp float drawDefaultBorder;\n\nlowp float MinNodeSize = 5.0;\n\nvoid main(void) {\n vec4 data = texture2D(u_positions, a_index);\n gl_Position = u_projection * vec4(data.xy, 0.0, 1.0);\n\n lowp float nodeSize = a_size * u_zoom * u_glAdjust;\n if (nodeSize < MinNodeSize) {\n gl_PointSize = MinNodeSize;\n varNodeSize = MinNodeSize;\n } else {\n gl_PointSize = nodeSize;\n varNodeSize = nodeSize;\n }\n\n color = a_color;\n selected = a_selected;\n hovered = a_hovered;\n nodeBorderColor = u_nodeBorderColor;\n selectedBorderColor = u_selectedBorderColor;\n selectedInnerBorderColor = u_selectedInnerBorderColor;\n shadowColor = u_shadowColor;\n drawDefaultBorder = u_drawDefaultBorder;\n}";
1
+ declare const _default: "#version 300 es\nuniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\nuniform lowp vec3 u_nodeBorderColor;\nuniform lowp vec3 u_selectedBorderColor;\nuniform lowp vec3 u_selectedInnerBorderColor;\nuniform lowp vec3 u_shadowColor;\nuniform lowp float u_drawDefaultBorder;\n\nin float a_size;\nin lowp vec2 a_index;\nin lowp vec4 a_color;\nin lowp float a_selected;\nin lowp float a_hovered;\n\nout lowp vec4 color;\nout lowp float selected;\nout lowp float hovered;\nout lowp float varNodeSize;\nout lowp vec3 nodeBorderColor;\nout lowp vec3 selectedBorderColor;\nout lowp vec3 selectedInnerBorderColor;\nout lowp vec3 shadowColor;\nout lowp float drawDefaultBorder;\n\nlowp float MinNodeSize = 5.0;\n\nvoid main(void) {\n vec4 data = texture(u_positions, a_index);\n gl_Position = u_projection * vec4(data.xy, 0.0, 1.0);\n\n lowp float nodeSize = a_size * u_zoom * u_glAdjust;\n if (nodeSize < MinNodeSize) {\n gl_PointSize = MinNodeSize;\n varNodeSize = MinNodeSize;\n } else {\n gl_PointSize = nodeSize;\n varNodeSize = nodeSize;\n }\n\n color = a_color;\n selected = a_selected;\n hovered = a_hovered;\n nodeBorderColor = u_nodeBorderColor;\n selectedBorderColor = u_selectedBorderColor;\n selectedInnerBorderColor = u_selectedInnerBorderColor;\n shadowColor = u_shadowColor;\n drawDefaultBorder = u_drawDefaultBorder;\n}";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "varying lowp vec4 color;\n\nvoid main(void) {\n gl_FragColor = vec4(color.xyz, 1.0) * color.w;\n}\n";
1
+ declare const _default: "#version 300 es\nprecision lowp float;\n\nin lowp vec4 color;\n\nout vec4 fragColor;\n\nvoid main(void) {\n fragColor = vec4(color.xyz, 1.0) * color.w;\n}\n";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "uniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_glAdjust;\n\nattribute vec2 a_from;\nattribute vec2 a_to;\nattribute lowp vec4 a_color;\nattribute lowp float a_triside;\nattribute float a_width;\n\nvarying lowp vec4 color;\n\nvoid main(void) {\n vec4 from = texture2D(u_positions, a_from);\n vec4 to = texture2D(u_positions, a_to);\n vec2 direction = normalize(to.xy - from.xy);\n direction = vec2(-direction.y, direction.x);\n\n float width = a_width * u_glAdjust * 0.5;\n\n if (a_triside == 0.0) {\n from.y += (width / 2.0) * direction.y;\n from.x += (width / 2.0) * direction.x;\n } else {\n from.y -= (width / 2.0) * direction.y;\n from.x -= (width / 2.0) * direction.x;\n }\n\n color = a_color;\n gl_Position = u_projection * vec4(from.xy, 0.0, 1.0);\n}\n";
1
+ declare const _default: "#version 300 es\nuniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_glAdjust;\n\nin vec2 a_from;\nin vec2 a_to;\nin lowp vec4 a_color;\nin lowp float a_triside;\nin float a_width;\n\nout lowp vec4 color;\n\nvoid main(void) {\n vec4 from = texture(u_positions, a_from);\n vec4 to = texture(u_positions, a_to);\n vec2 direction = normalize(to.xy - from.xy);\n direction = vec2(-direction.y, direction.x);\n\n float width = a_width * u_glAdjust * 0.5;\n\n if (a_triside == 0.0) {\n from.y += (width / 2.0) * direction.y;\n from.x += (width / 2.0) * direction.x;\n } else {\n from.y -= (width / 2.0) * direction.y;\n from.x -= (width / 2.0) * direction.x;\n }\n\n color = a_color;\n gl_Position = u_projection * vec4(from.xy, 0.0, 1.0);\n}\n";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "\nvarying lowp vec4 minimapViewportBoxColor;\n\nvoid main(void) {\n gl_FragColor = minimapViewportBoxColor;\n}\n";
1
+ declare const _default: "#version 300 es\nprecision lowp float;\n\nin lowp vec4 minimapViewportBoxColor;\n\nout vec4 fragColor;\n\nvoid main(void) {\n fragColor = minimapViewportBoxColor;\n}\n";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "\nattribute vec2 coordinates;\nuniform mat4 u_projection;\nuniform lowp vec4 u_minimapViewportBoxColor;\n\nvarying lowp vec4 minimapViewportBoxColor;\n\nvoid main(void) {\n gl_Position = u_projection * vec4(coordinates, 0.0, 1.0);\n minimapViewportBoxColor = u_minimapViewportBoxColor;\n}\n";
1
+ declare const _default: "#version 300 es\nin vec2 coordinates;\nuniform mat4 u_projection;\nuniform lowp vec4 u_minimapViewportBoxColor;\n\nout lowp vec4 minimapViewportBoxColor;\n\nvoid main(void) {\n gl_Position = u_projection * vec4(coordinates, 0.0, 1.0);\n minimapViewportBoxColor = u_minimapViewportBoxColor;\n}\n";
2
2
  export default _default;
@@ -13,7 +13,7 @@ export declare const createCanvasForScreenshot: (fullWidth: number, fullHeight:
13
13
  export declare const createCanvasForRenderer: (parent?: HTMLElement, onContextLostCallback?: (e: WebGLContextEvent) => void) => HTMLCanvasElement;
14
14
  export declare const removeCanvas: (canvas: HTMLCanvasElement) => void;
15
15
  export declare const getCanvas2DContext: (canvas: HTMLCanvasElement) => CanvasRenderingContext2D;
16
- export declare const getWebGLContext: (canvas: HTMLCanvasElement) => WebGLRenderingContext;
16
+ export declare const getWebGLContext: (canvas: HTMLCanvasElement) => WebGL2RenderingContext | null;
17
17
  export declare const removeWebGLContext: (webGLCtx: WebGLRenderingContext) => void;
18
18
  export declare const checkWebGLAvailability: (canvas?: HTMLCanvasElement) => boolean;
19
19
  /**
@@ -3,9 +3,13 @@ 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;
8
+ export declare const LayoutStepIntervalMs = 13;
9
+ export declare const DefaultMaxFps = 30;
10
+ export declare const DefaultMinFps = 3;
11
+ export declare const MinAllowedFps = 1;
12
+ export declare const MaxAllowedFps = 120;
9
13
  export declare const ActiveAnimDuration = 1000;
10
14
  export declare const DefaultNodeSize = 25;
11
15
  export declare const DefaultNodeColor = "#FFDF81";
@@ -40,4 +44,6 @@ export declare const GlAdjust: number;
40
44
  */
41
45
  export declare const getDevicePixelRatio: () => number;
42
46
  export declare const HtmlCaptionMinWidthThreshold = 5;
47
+ /** Min on-screen icon size (px) before we skip drawing; avoids unreadable bitmaps when zoomed out. */
48
+ export declare const MinNodeIconScreenPx = 10;
43
49
  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.
@@ -0,0 +1,7 @@
1
+ import type { Point } from './geometry';
2
+ export type SeedingMethod = 'box' | 'circle';
3
+ export declare const getCircleSeedRadius: (nodeCount: number, seedSpacing: number) => number;
4
+ export declare const getBoxStartSize: (nodeCount: number) => number;
5
+ export declare const getCirclePositionsForNodeCount: (nodeCount: number, center: Point, radius: number) => Point[];
6
+ export declare const getBoxPositionsForNodeCount: (nodeCount: number, center: Point) => Point[];
7
+ export declare const getSeedPositions: (nodeCount: number, seedingMethod: SeedingMethod, center?: Point) => Point[];
@@ -0,0 +1 @@
1
+ export {};
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-nvl/base",
3
- "version": "1.1.0-e61ddd81",
3
+ "version": "1.2.0-090ec876",
4
4
  "license": "SEE LICENSE IN 'LICENSE.txt'",
5
5
  "homepage": "https://neo4j.com/docs/nvl/current/",
6
6
  "description": "Base library for the Neo4j Visualization Library",
@@ -23,13 +23,14 @@
23
23
  "build:dev": "yarn global:tsc && webpack --mode development",
24
24
  "watch": "concurrently 'tsc -w' 'webpack -w --mode development' -k -n 'tsc,webpack' -c 'cyan,magenta'",
25
25
  "test": "yarn global:jest",
26
+ "test:perf": "yarn global:jest --testPathPattern='.bench.' --testPathIgnorePatterns=",
26
27
  "eslint": "yarn global:eslint ./src/",
27
28
  "coverage": "yarn test --coverage --silent",
28
29
  "prepack": "cp ../../LICENSE.txt ./ && cp ../../CHANGELOG.md ./",
29
30
  "postpack": "rm LICENSE.txt && rm CHANGELOG.md"
30
31
  },
31
32
  "dependencies": {
32
- "@neo4j-nvl/layout-workers": "1.1.0-e61ddd81",
33
+ "@neo4j-nvl/layout-workers": "1.2.0-090ec876",
33
34
  "@segment/analytics-next": "1.81.1",
34
35
  "color-string": "1.9.1",
35
36
  "d3-force": "3.0.0",
@@ -41,7 +42,7 @@
41
42
  "node-pid-controller": "1.0.1",
42
43
  "resizelistener": "1.1.0",
43
44
  "tinycolor2": "1.6.0",
44
- "uuid": "8.3.2"
45
+ "uuid": "14.0.0"
45
46
  },
46
47
  "devDependencies": {
47
48
  "@babel/core": "7.28.5",
@@ -59,5 +60,5 @@
59
60
  "peerDependencies": {
60
61
  "neo4j-driver": "*"
61
62
  },
62
- "stableVersion": "1.1.0"
63
+ "stableVersion": "1.2.0"
63
64
  }