@neo4j-nvl/base 0.3.1-3ce43a8b

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 (69) hide show
  1. package/LICENSE.txt +49 -0
  2. package/README.md +43 -0
  3. package/dist/base.mjs +2 -0
  4. package/dist/base.mjs.LICENSE.txt +10 -0
  5. package/dist/types/index.d.ts +379 -0
  6. package/dist/types/layouts/animatedlayout/AnimatedLayout.d.ts +25 -0
  7. package/dist/types/layouts/animatedlayout/animationUtils.d.ts +9 -0
  8. package/dist/types/layouts/d3forcelayout/circularLayout.d.ts +5 -0
  9. package/dist/types/layouts/d3forcelayout/constants.d.ts +18 -0
  10. package/dist/types/layouts/d3forcelayout/d3ForceLayout.d.ts +29 -0
  11. package/dist/types/layouts/d3forcelayout/types.d.ts +9 -0
  12. package/dist/types/layouts/forcedirectedlayout/ForceCytoLayout.d.ts +24 -0
  13. package/dist/types/layouts/forcedirectedlayout/cosebilkentlayout/CoseBilkentLayout.d.ts +32 -0
  14. package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +167 -0
  15. package/dist/types/layouts/forcedirectedlayout/physlayout/glwrapper.d.ts +4 -0
  16. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment.d.ts +2 -0
  17. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment.d.ts +2 -0
  18. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-update-fragment.d.ts +2 -0
  19. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/sim-vertex.d.ts +2 -0
  20. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/workaround-fragment.d.ts +2 -0
  21. package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.d.ts +43 -0
  22. package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/solar-placer.d.ts +4 -0
  23. package/dist/types/layouts/freeLayout/FreeLayout.d.ts +26 -0
  24. package/dist/types/layouts/gridLayout/GridLayout.d.ts +16 -0
  25. package/dist/types/layouts/hierarchicallayout/HierarchicalLayout.d.ts +26 -0
  26. package/dist/types/layouts/hierarchicallayout/constants.d.ts +11 -0
  27. package/dist/types/modules/CallbackHelper.d.ts +38 -0
  28. package/dist/types/modules/ExternalCallbackHandler.d.ts +25 -0
  29. package/dist/types/modules/NvlController.d.ts +119 -0
  30. package/dist/types/modules/Shader.d.ts +18 -0
  31. package/dist/types/modules/ZoomTransitionHandler.d.ts +27 -0
  32. package/dist/types/modules/dataset.d.ts +37 -0
  33. package/dist/types/modules/logging.d.ts +5 -0
  34. package/dist/types/modules/performance.d.ts +93 -0
  35. package/dist/types/modules/state.d.ts +232 -0
  36. package/dist/types/renderers/canvasrenderer/Animation.d.ts +64 -0
  37. package/dist/types/renderers/canvasrenderer/AnimationHandler.d.ts +72 -0
  38. package/dist/types/renderers/canvasrenderer/CanvasRenderer.d.ts +92 -0
  39. package/dist/types/renderers/canvasrenderer/ImageCache.d.ts +11 -0
  40. package/dist/types/renderers/canvasrenderer/arrows/ArrowBundle.d.ts +79 -0
  41. package/dist/types/renderers/canvasrenderer/arrows/ArrowBundler.d.ts +33 -0
  42. package/dist/types/renderers/canvasrenderer/arrows/arrows.d.ts +50 -0
  43. package/dist/types/renderers/canvasrenderer/arrows/constants.d.ts +54 -0
  44. package/dist/types/renderers/canvasrenderer/nodes/nodes.d.ts +58 -0
  45. package/dist/types/renderers/canvasrenderer/types.d.ts +47 -0
  46. package/dist/types/renderers/canvasrenderer/util.d.ts +69 -0
  47. package/dist/types/renderers/canvasrenderer/vectorUtils.d.ts +21 -0
  48. package/dist/types/renderers/canvasrenderer/wordwrap.d.ts +42 -0
  49. package/dist/types/renderers/webglrenderer/Controller.d.ts +66 -0
  50. package/dist/types/renderers/webglrenderer/Renderer.d.ts +52 -0
  51. package/dist/types/renderers/webglrenderer/node-animation-fragment.d.ts +2 -0
  52. package/dist/types/renderers/webglrenderer/node-animation-vertex.d.ts +2 -0
  53. package/dist/types/renderers/webglrenderer/node-fragment-point.d.ts +2 -0
  54. package/dist/types/renderers/webglrenderer/node-vertex-point.d.ts +2 -0
  55. package/dist/types/renderers/webglrenderer/rel-fragment-line.d.ts +2 -0
  56. package/dist/types/renderers/webglrenderer/rel-vertex-line.d.ts +2 -0
  57. package/dist/types/renderers/webglrenderer/viewport-box-fragment.d.ts +2 -0
  58. package/dist/types/renderers/webglrenderer/viewport-box-vertex.d.ts +2 -0
  59. package/dist/types/types/graph-element.d.ts +88 -0
  60. package/dist/types/utils/canvasManagement.d.ts +15 -0
  61. package/dist/types/utils/colorMapperFunctions.d.ts +6 -0
  62. package/dist/types/utils/constants.d.ts +30 -0
  63. package/dist/types/utils/errors.d.ts +11 -0
  64. package/dist/types/utils/geometry.d.ts +122 -0
  65. package/dist/types/utils/graphObjectUtils.d.ts +9 -0
  66. package/dist/types/utils/hittest.d.ts +56 -0
  67. package/dist/types/utils/mouseUtils.d.ts +9 -0
  68. package/dist/types/utils/zoomFunctions.d.ts +20 -0
  69. package/package.json +63 -0
@@ -0,0 +1,167 @@
1
+ export class PhysLayout {
2
+ constructor(config: any);
3
+ _physVbo: any;
4
+ _physSmallVbo: any;
5
+ _physProjection: mat4;
6
+ _physSmallProjection: mat4;
7
+ _gl: any;
8
+ _averageNodeSize: number;
9
+ shouldUpdate: boolean;
10
+ iterationCount: number;
11
+ lastSpeedValues: any[];
12
+ rollingAvgGraphSpeed: number;
13
+ nodeVariation: number;
14
+ nodeCenterPoint: number[];
15
+ peakIterationMultiplier: number;
16
+ stateDisposers: any[];
17
+ _state: any;
18
+ _dpr: number;
19
+ /**
20
+ * Sets the layout options
21
+ * @param {Object} options the object with the options
22
+ * @param {boolean} options.intelWorkaround whether to use the layout implementation for Intel GPUs
23
+ * @param {Number} options.simulationStopVelocity the graph speed at which to stop the layout
24
+ * @param {Number} options.gravity the force layout's gravity strength
25
+ * @param {boolean} [initial=false] whether this is the first setting of options
26
+ */
27
+ setOptions(options: {
28
+ intelWorkaround: boolean;
29
+ simulationStopVelocity: number;
30
+ gravity: number;
31
+ }, initial?: boolean): void;
32
+ intelWorkaround: boolean;
33
+ simulationStopVelocitySquared: number;
34
+ gravity: number;
35
+ force: any;
36
+ /**
37
+ * Sets graph data to be used
38
+ * @param {Object} data the graph object
39
+ * @param {Array<Object>} data.nodes the nodes in the graph
40
+ * @param {Array<Object>} data.rels the relationships in the graph
41
+ * @returns {Object} the top level graph of the subgraphs created by the solar merger
42
+ */
43
+ setData(data: {
44
+ nodes: Array<any>;
45
+ rels: Array<any>;
46
+ }): any;
47
+ _nodeIdToIndex: {};
48
+ _nodeIndexToId: {};
49
+ _numNodes: any;
50
+ solarMerger: SolarMerger;
51
+ subGraphs: any[];
52
+ nodeSortMap: {};
53
+ _firstUpdate: boolean;
54
+ _curPhysData: any;
55
+ /**
56
+ * Updates the node's positions for the next step in the physics layout iterations if the layout needs to update
57
+ * @param {boolean} refreshPositions whether the entire layout should be reheated
58
+ * @returns {boolean} whether the layout should update in the following step
59
+ */
60
+ update(refreshPositions: boolean): boolean;
61
+ collisionDetectionMultiplier: number;
62
+ /**
63
+ * Stops the layout
64
+ */
65
+ terminateUpdate(): void;
66
+ addedNodes: {};
67
+ /**
68
+ * Returns whether the current layout needs to be updated in the next iteration step.
69
+ * @returns {boolean} Whether the layout should update in the following step.
70
+ */
71
+ getShouldUpdate(): boolean;
72
+ /**
73
+ * Returns whether the current layout is computing.
74
+ * Always returns false because the force-directed layout has no computing step
75
+ * @returns {boolean} Whether the layout is computing.
76
+ */
77
+ getComputing(): boolean;
78
+ /**
79
+ * Adds the current x,y coordinates for each node to a given list of nodes.
80
+ * @param {Array<Object>} nodeList The list of nodes to get positions for.
81
+ * @returns {Array<Object>} The list of nodes containing the x,y coordinates on each node object.
82
+ */
83
+ getNodePositions(nodeList: Array<any>): Array<any>;
84
+ /**
85
+ * Reheats the layout
86
+ * @param {Object} fullData The entire graph object.
87
+ */
88
+ reheat(fullData: any): void;
89
+ /**
90
+ * Updates the existing nodes of a graph with a given list of updates
91
+ * @param {Array<Object>} nodeList The list of updates.
92
+ */
93
+ updateNodes(nodeList: Array<any>): void;
94
+ /**
95
+ * Adds and removes nodes from the graph based on given updates
96
+ * @param {Object} fullData The entire graph object.
97
+ * @param {Array<Object>} fullData.nodes the nodes in the graph
98
+ * @param {Array<Object>} fullData.rels the relationships in the graph
99
+ * @param {Object} nodeChanges The changes in the graph.
100
+ * @param {Array<Object>} nodeChanges.adds A list of nodes to be added.
101
+ * @param {Array<Object>} nodeChanges.removes A list of nodes to be removed.
102
+ */
103
+ addRemoveData(fullData: {
104
+ nodes: Array<any>;
105
+ rels: Array<any>;
106
+ }, nodeChanges: {
107
+ adds: Array<any>;
108
+ removes: Array<any>;
109
+ }): any;
110
+ _pinData: Uint8Array;
111
+ /**
112
+ * Destroys the class and all buffers and textures.
113
+ */
114
+ destroy(): void;
115
+ _physPositions: Float32Array;
116
+ _dumpTexture(framebuffer: any, numItems: any, msg: any): void;
117
+ _getScaleNumber(iterationNo: any, delayedDecayFormula?: (iterationNo: any, p: any, lowerBar: any) => any): any;
118
+ _getBaseLength(subGraphNodeCount: any): number;
119
+ _hasSizeChanged(updates?: any[]): boolean;
120
+ _checkForUpdates(fullRefresh?: boolean): void;
121
+ _getNodePosition(nodeIndex: any): {
122
+ x: any;
123
+ y: any;
124
+ };
125
+ _getMaxSpeedSquared(): number;
126
+ _getMedianSpeedSquared(addedNodes: any): number;
127
+ _getPhysData(offset?: number): any;
128
+ _getLevelData(offset?: number): any;
129
+ _newTexture(gl: any, data: any, side: any, type?: any, internalformat?: any): any;
130
+ _newFramebuffer(gl: any, texture: any): any;
131
+ _checkCompatibility(gl: any): void;
132
+ _useReadpixelWorkaround: boolean;
133
+ _printGlStats(gl: any): void;
134
+ _adjustToGlSize(size: any): number;
135
+ _setupSize(data?: {
136
+ nodes: any[];
137
+ }): void;
138
+ _sizeTexture: any;
139
+ _setupSprings(data: any): void;
140
+ connections: any;
141
+ _offsetTexture: any;
142
+ _springTexture: any;
143
+ _setupPhysics(): void;
144
+ _setupPhysicsForNodes(): void;
145
+ _physData: any[];
146
+ _physShader: Shader;
147
+ _setupPhysicsForCoarse(): void;
148
+ levelsData: any[];
149
+ levelsClusterTexture: any[];
150
+ levelsFinestIndexTexture: any[];
151
+ initalLevelTexture: any;
152
+ _apprxRepForceShader: Shader;
153
+ _setupPinData(): void;
154
+ _pinTexture: any;
155
+ _setupUpdates(): void;
156
+ _updateData: Float32Array;
157
+ _updateTexture: any;
158
+ _updateShader: Shader;
159
+ _setupReadpixelWorkaround(): void;
160
+ _workaroundShader: Shader;
161
+ _workaroundData: any[];
162
+ _doReadpixelWorkaround(): void;
163
+ _definePhysicsArrays(): void;
164
+ }
165
+ import { mat4 } from 'gl-matrix';
166
+ import SolarMerger from './solarmerger/SolarMerger';
167
+ import Shader from '../../../modules/Shader';
@@ -0,0 +1,4 @@
1
+ export default class GlWrapper {
2
+ constructor(gl: any);
3
+ _wrapFunction(gl: any, functionName: any): (...args: any[]) => any;
4
+ }
@@ -0,0 +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}";
2
+ export default _default;
@@ -0,0 +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}";
2
+ export default _default;
@@ -0,0 +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";
2
+ export default _default;
@@ -0,0 +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}";
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: "precision lowp float;\n\nuniform sampler2D u_physData;\nuniform float u_index;\n\nfloat shift_right (float v, float amt) { \n v = floor(v) + 0.5; \n return floor(v / exp2(amt)); \n}\n\nfloat shift_left (float v, float amt) { \n return floor(v * exp2(amt) + 0.5); \n}\n\nfloat mask_last (float v, float bits) { \n return mod(v, shift_left(1.0, bits)); \n}\n\nfloat extract_bits (float num, float from, float to) { \n from = floor(from + 0.5); to = floor(to + 0.5); \n return mask_last(shift_right(num, from), to - from); \n}\n\n// From https://stackoverflow.com/questions/17981163/webgl-read-pixels-from-floating-point-render-target\nvec4 encode_float (float val) { \n if (val == 0.0) return vec4(0, 0, 0, 0); \n float sign = val > 0.0 ? 0.0 : 1.0; \n val = abs(val); \n float exponent = floor(log2(val)); \n float biased_exponent = exponent + 127.0; \n float fraction = ((val / exp2(exponent)) - 1.0) * 8388608.0; \n float t = biased_exponent / 2.0; \n float last_bit_of_biased_exponent = fract(t) * 2.0; \n float remaining_bits_of_biased_exponent = floor(t); \n float byte4 = extract_bits(fraction, 0.0, 8.0) / 255.0; \n float byte3 = extract_bits(fraction, 8.0, 16.0) / 255.0; \n float byte2 = (last_bit_of_biased_exponent * 128.0 + extract_bits(fraction, 16.0, 23.0)) / 255.0; \n float byte1 = (sign * 128.0 + remaining_bits_of_biased_exponent) / 255.0; \n return vec4(byte4, byte3, byte2, byte1); \n}\n\nvoid main(void) {\n vec4 texData = texture2D(u_physData, gl_FragCoord.xy / 255.0);\n float data;\n if (u_index == 0.0) {\n data = texData.x;\n } else if (u_index == 1.0) {\n data = texData.y;\n } else if (u_index == 2.0) {\n data = texData.z;\n } else if (u_index == 3.0) {\n data = texData.w;\n }\n\n gl_FragColor = encode_float(data);\n}\n";
2
+ export default _default;
@@ -0,0 +1,43 @@
1
+ export default class SolarMerger {
2
+ constructor(graph: any, nodeIdToIndex: any);
3
+ graph: {
4
+ nodes: any[];
5
+ relationships: any[];
6
+ idToRel: {};
7
+ };
8
+ subGraphs: any[];
9
+ sunMap: {};
10
+ constructGraphObjects(graph: any, nodeIdToIndex: any): {
11
+ nodes: any[];
12
+ relationships: any[];
13
+ idToRel: {};
14
+ };
15
+ relIdMap: any[];
16
+ coarsenTo(targetSize: any): {
17
+ nodes: any[];
18
+ relationships: any[];
19
+ idToRel: {};
20
+ };
21
+ nodeSortMap: {};
22
+ coarsenBy(level: any): {
23
+ nodes: any[];
24
+ relationships: any[];
25
+ idToRel: {};
26
+ };
27
+ coarsen({ nodes, relationships }: {
28
+ nodes: any;
29
+ relationships: any;
30
+ }, firstIteration: any): {
31
+ output: {
32
+ nodes: {
33
+ id: any;
34
+ }[];
35
+ relationships: any[];
36
+ };
37
+ sortedInput: {
38
+ nodes: any[];
39
+ relationships: any[];
40
+ };
41
+ nodeSortMap: {};
42
+ };
43
+ }
@@ -0,0 +1,4 @@
1
+ export function calculatePositions(centre: any, r: any, noOfChildren: any): {
2
+ x: any;
3
+ y: any;
4
+ }[];
@@ -0,0 +1,26 @@
1
+ import type { NvlState } from '../../modules/state';
2
+ import type { Node } from '../../types/graph-element';
3
+ import type { Point } from '../../utils/geometry';
4
+ export declare class FreeLayout {
5
+ private state;
6
+ private positions;
7
+ private shouldUpdate;
8
+ private stateDisposers;
9
+ constructor(config: {
10
+ state: NvlState;
11
+ });
12
+ setOptions(): any;
13
+ updateNodes(positionList: (Point & {
14
+ id: string;
15
+ })[]): void;
16
+ update(refreshPositions?: boolean): void;
17
+ layout(nodes: Node[], nodeIds: Record<string, Node>, idToPosition: Record<string, Node>): void;
18
+ setNodePositions(p: Record<string, Point>): void;
19
+ getNodePositions(nodeList: Node[]): (Point & {
20
+ id: string;
21
+ })[];
22
+ getShouldUpdate(): boolean;
23
+ getComputing(): boolean;
24
+ terminateUpdate(): any;
25
+ destroy(): void;
26
+ }
@@ -0,0 +1,16 @@
1
+ export class GridLayout {
2
+ constructor(config: any);
3
+ state: any;
4
+ positions: {};
5
+ stateDisposers: any[];
6
+ shouldUpdate: boolean;
7
+ setOptions(options: any): void;
8
+ updateNodes(positionList: any): void;
9
+ update(refreshPositions?: boolean): void;
10
+ layout(nodes: any, nodeIds: any, idToPosition: any, rels: any): void;
11
+ getNodePositions(nodeList: any): any[];
12
+ getShouldUpdate(): boolean;
13
+ getComputing(): boolean;
14
+ terminateUpdate(): void;
15
+ destroy(): void;
16
+ }
@@ -0,0 +1,26 @@
1
+ import type { HierarchicalOptions, NvlState } from '../../modules/state';
2
+ import AnimatedLayout from '../animatedlayout/AnimatedLayout';
3
+ type HierarchicalLayoutConfig = {
4
+ state: NvlState;
5
+ animationCompleteCallback?: () => void;
6
+ } & HierarchicalOptions;
7
+ export declare class HierarchicalLayout extends AnimatedLayout {
8
+ private direction;
9
+ private packing;
10
+ private stateDisposers;
11
+ private oldComputing;
12
+ private computing;
13
+ private pendingLayoutData;
14
+ private worker;
15
+ private directionChanged;
16
+ private packingChanged;
17
+ constructor(config: HierarchicalLayoutConfig);
18
+ setOptions(options: HierarchicalLayoutConfig): void;
19
+ update(refreshPositions?: boolean): void;
20
+ getShouldUpdate(): boolean;
21
+ getComputing(): boolean;
22
+ private layout;
23
+ terminateUpdate(): void;
24
+ destroy(): void;
25
+ }
26
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { HierarchicalOptions } from '../../modules/state';
2
+ export declare const Ranker = "tight-tree";
3
+ export declare const SubGraphSpacing = 100;
4
+ export declare const DirectionUp = "up";
5
+ export declare const DirectionDown = "down";
6
+ export declare const DirectionLeft = "left";
7
+ export declare const DirectionRight = "right";
8
+ export declare const Directions: Record<HierarchicalOptions['direction'], string>;
9
+ export declare const PackingBin = "bin";
10
+ export declare const PackingStack = "stack";
11
+ export declare const Packings: HierarchicalOptions['packing'][];
@@ -0,0 +1,38 @@
1
+ import type { ExternalCallbacks } from './ExternalCallbackHandler';
2
+ type CallbackFunction = ExternalCallbacks['onError'] | ExternalCallbacks['onLayoutComputing'] | ExternalCallbacks['onLayoutDone'] | ExternalCallbacks['onLayoutStep'];
3
+ /**
4
+ * A class for registering and calling callbacks
5
+ * @example
6
+ * ```
7
+ * const callbackHelper = new CallbackHelper()
8
+ * callbackHelper.register('myEvent', (data) => {
9
+ * console.log(data)
10
+ * })
11
+ * callbackHelper.callIfRegistered('myEvent', 'Hello World')
12
+ * // Logs 'Hello World'
13
+ * ```
14
+ */
15
+ export default class CallbackHelper {
16
+ private readonly callbacks;
17
+ constructor();
18
+ /**
19
+ * Register a callback function to be called when an event of that name happens
20
+ * @param {string} name The name of the callback to register
21
+ * @param {function} callback A function that will be called when an event of that name happens
22
+ * @note If other callbacks are already registered for that name it is added to the list
23
+ */
24
+ register(name: keyof ExternalCallbacks, callback: CallbackFunction): void;
25
+ /**
26
+ * Check if a callback function with that name is registered already
27
+ * @param {string} name - The name of the callbacks to check
28
+ * @return {boolean} Whether or not a callback function with that name is registered
29
+ */
30
+ isCallbackRegistered(name: keyof ExternalCallbacks): boolean;
31
+ /**
32
+ * Call all callbacks registered for a given name
33
+ * @param {string} name - The name of the callbacks to call
34
+ * @param {object} data - Data to pass when calling the callbacks
35
+ */
36
+ callIfRegistered(): void;
37
+ }
38
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { Node } from '../types/graph-element';
2
+ /**
3
+ * An object specifying the required callback functions for certain actions
4
+ */
5
+ export interface ExternalCallbacks {
6
+ /** Triggered when a layout is done moving. */
7
+ onLayoutDone?: () => void;
8
+ /** Triggered on each step of a layout. */
9
+ onLayoutStep?: (p: Node[]) => void;
10
+ /** Triggered when NVL throws an error after initialization. */
11
+ onError?: (error: Error) => void;
12
+ /** Triggered when a asynchronous layout calculation starts/stops. */
13
+ onLayoutComputing?: (isComputing: boolean) => void;
14
+ onWebGLContextLost?: (webGLContextEvent: WebGLContextEvent) => void;
15
+ }
16
+ export default class ExternalCallbackHandler {
17
+ callbacks: ExternalCallbacks;
18
+ constructor(externalCallbacks?: ExternalCallbacks);
19
+ onLayoutDone(): void;
20
+ onLayoutStep(p: Node[]): void;
21
+ onLayoutComputing(isComputing: boolean): void;
22
+ onError(error: Error): void;
23
+ onWebGLContextLost(webGLContextEvent: WebGLContextEvent): void;
24
+ private isValidFunction;
25
+ }
@@ -0,0 +1,119 @@
1
+ export const EVENT_ERROR: "onError";
2
+ export const EVENT_LAYOUT_DONE: "onLayoutDone";
3
+ export const EVENT_LAYOUT_STEP: "onLayoutStep";
4
+ export const EVENT_LAYOUT_COMPUTING: "onLayoutComputing";
5
+ export const EVENT_WEBGL_CONTEXT_LOST: "onWebGLContextLost";
6
+ export default class NvlController {
7
+ constructor(state: any, options?: {});
8
+ destroyed: boolean;
9
+ _state: any;
10
+ _callbacks: CallbackHelper;
11
+ instanceId: any;
12
+ _glController: GLController | DummyGLController;
13
+ _webGLContext: RenderingContext;
14
+ _webGLMinimapContext: RenderingContext;
15
+ _htmlOverlay: HTMLDivElement;
16
+ _hasResized: boolean;
17
+ _hierLayout: HierarchicalLayout;
18
+ _gridLayout: GridLayout;
19
+ _freeLayout: FreeLayout;
20
+ _d3ForceLayout: d3ForceLayout;
21
+ _forceLayout: d3ForceLayout | ForceCytoLayout;
22
+ _canvasRenderer: CanvasRenderer;
23
+ _c2dContext: CanvasRenderingContext2D;
24
+ _glCanvas: HTMLCanvasElement;
25
+ _canvasRect: DOMRect;
26
+ _glMinimapCanvas: HTMLCanvasElement;
27
+ _c2dCanvas: HTMLCanvasElement;
28
+ _isInRenderSwitchAnimation: boolean;
29
+ _justSwitchedRenderer: boolean;
30
+ _justSwitchedLayout: boolean;
31
+ _layoutUpdating: boolean;
32
+ _layoutComputing: boolean;
33
+ isRenderingDisabled: boolean;
34
+ setRenderSwitchAnimation: () => void;
35
+ stateDisposers: any[];
36
+ _zoomTransitionHandler: ZoomTransitionHandler;
37
+ layoutTimeLimit: any;
38
+ forceWebGLThreshold: any;
39
+ pixelRatio: number;
40
+ removeResizeListener: any;
41
+ removeMinimapResizeListener: any;
42
+ pendingZoomOperation: (() => any) | (() => any) | (() => any) | (() => any);
43
+ _onWebGLContextLost(webGLContextEvent: any): void;
44
+ _updateMinimapZoom(): void;
45
+ _startMainloop(): void;
46
+ _layoutRunner: NodeJS.Timeout;
47
+ animationRequestId: number;
48
+ updateHtmlOverlay(): void;
49
+ dumpNodes(): any[];
50
+ dumpRelationships(): any;
51
+ /**
52
+ * Map a relative Canvas space to the DOM position
53
+ * @param {number} canvasX X position in the canvas space
54
+ * @param {number} canvasY Y position position in the canvas space
55
+ */
56
+ mapCanvasSpaceToRelativePosition(canvasX: number, canvasY: number): {
57
+ x: number;
58
+ y: number;
59
+ };
60
+ /**
61
+ * Map a relative DOM position to the Canvas space
62
+ * @param {*} clientX relative X position from the top left [0..rect.width]
63
+ * @param {*} clientY relative Y position from the top left [0..rect.height]
64
+ */
65
+ mapRelativePositionToCanvasSpace(clientX: any, clientY: any): {
66
+ x: any;
67
+ y: any;
68
+ };
69
+ getNodePositions(): any[];
70
+ setNodePositions(data: any, updateLayout?: boolean): void;
71
+ isLayoutMoving(): boolean;
72
+ getNodesOnScreen(): {
73
+ nodes: import("..").Node[];
74
+ rels: import("..").Relationship[];
75
+ };
76
+ registerDoneCallback(cb: any): void;
77
+ _layoutDoneCallback: any;
78
+ registerComputingCallback(cb: any): void;
79
+ _layoutComputingCallback: any;
80
+ getPosition(nodeId: any): any;
81
+ addCanvasOptions(options: any): void;
82
+ setNodeInformationLevel(viewLevel: any): void;
83
+ setEdgeInformationLevel(viewLevel: any): void;
84
+ getScale(): any;
85
+ getPan(): {
86
+ x: any;
87
+ y: any;
88
+ };
89
+ setZoomLevel(_newLevel: any): void;
90
+ setPanCoordinates(panX: any, panY: any): void;
91
+ setZoomAndPan(zoom: any, panX: any, panY: any): void;
92
+ fit(nodeIds: any, zoomOptions: any): void;
93
+ resetZoom(): void;
94
+ setRenderer(renderer: any): void;
95
+ on(name: any, callback: any): void;
96
+ destroy(): void;
97
+ callIfRegistered(...args: any[]): void;
98
+ getCanvasRelsAt(point: any): import("../utils/hittest").HitTargetRelationship[];
99
+ getCanvasNodesAt(point: any, hitNodeMarginWidth?: number): import("../utils/hittest").HitTargetNode[];
100
+ _getLayout(layoutType: any): d3ForceLayout | ForceCytoLayout;
101
+ setLayout(layoutType: any): void;
102
+ _currentLayout: d3ForceLayout | ForceCytoLayout;
103
+ _currentLayoutType: any;
104
+ setLayoutOptions(options: any): void;
105
+ createDownloadLink(filename: any, canvas: any): HTMLAnchorElement;
106
+ saveToFile(options: any): void;
107
+ prepareLargeFileForDownload(options: any): Promise<any>;
108
+ saveFullGraphToLargeFile(options: any): Promise<void>;
109
+ }
110
+ import CallbackHelper from './CallbackHelper';
111
+ import GLController from '../renderers/webglrenderer/Controller';
112
+ import { DummyController as DummyGLController } from '../renderers/webglrenderer/Controller';
113
+ import { HierarchicalLayout } from '../layouts/hierarchicallayout/HierarchicalLayout';
114
+ import { GridLayout } from '../layouts/gridLayout/GridLayout';
115
+ import { FreeLayout } from '../layouts/freeLayout/FreeLayout';
116
+ import { d3ForceLayout } from '../layouts/d3forcelayout/d3ForceLayout';
117
+ import { ForceCytoLayout } from '../layouts/forcedirectedlayout/ForceCytoLayout';
118
+ import CanvasRenderer from '../renderers/canvasrenderer/CanvasRenderer';
119
+ import ZoomTransitionHandler from './ZoomTransitionHandler';
@@ -0,0 +1,18 @@
1
+ export default class Shader {
2
+ constructor(gl: any, vsSource: any, fsSource: any, defines?: {});
3
+ _shaderProgram: any;
4
+ _gl: any;
5
+ _curTexture: number;
6
+ _scanAttributes(): void;
7
+ _attributeInfo: {};
8
+ _scanUniforms(): void;
9
+ _uniformInfo: {};
10
+ setUniform(name: any, value: any): void;
11
+ setAttributePointer(name: any, size: any, start: any, stride: any): void;
12
+ setAttributePointerFloat(name: any, size: any, start: any, stride: any): void;
13
+ setAttributePointerUShort(name: any, size: any, start: any, stride: any): void;
14
+ setAttributePointerByteNorm(name: any, size: any, start: any, stride: any): void;
15
+ setAttributePointerByte(name: any, size: any, start: any, stride: any): void;
16
+ use(): void;
17
+ remove(): void;
18
+ }
@@ -0,0 +1,27 @@
1
+ import PIDController from 'node-pid-controller';
2
+ import type { Node } from '../types/graph-element';
3
+ import type { NvlState } from './state';
4
+ export default class ZoomTransitionHandler {
5
+ xCtrl: PIDController;
6
+ yCtrl: PIDController;
7
+ zoomCtrl: PIDController;
8
+ private getNodePositions;
9
+ private firstUpdate;
10
+ private readonly state;
11
+ private readonly canvas;
12
+ private readonly defaultZoomLevel;
13
+ private readonly stateDisposers;
14
+ constructor({ state, getNodePositions, canvas, defaultZoomLevel }: {
15
+ state: NvlState;
16
+ getNodePositions: () => Node[];
17
+ canvas: HTMLCanvasElement;
18
+ defaultZoomLevel: number;
19
+ });
20
+ needsToRun(): boolean;
21
+ update(layoutActive: boolean): void;
22
+ destroy(): void;
23
+ private recalculateTarget;
24
+ private allNodesAreVisible;
25
+ private reset;
26
+ private fitNodes;
27
+ }
@@ -0,0 +1,37 @@
1
+ import type { Node, Relationship } from '../types/graph-element';
2
+ import type { Point } from '../utils/geometry';
3
+ /** A graph stored with mobx. */
4
+ export interface DataSet<T> {
5
+ items: T[];
6
+ idToItem: Record<string, T>;
7
+ channels: Record<string, Channel<T>>;
8
+ idToPosition: Record<string, Node & Point>;
9
+ idToHtmlOverlay?: Record<string, HTMLElement>;
10
+ version: number;
11
+ addChannel: (this: DataSet<T>, channelName: string) => void;
12
+ removeChannel: (this: DataSet<T>, channelName: string) => void;
13
+ clearChannel: (this: DataSet<T>, channelName: string) => void;
14
+ add: (data: T[], result: ActionResult) => void;
15
+ update: (data: Partial<T>[], result: ActionResult) => void;
16
+ remove: (ids: string[], result: ActionResult) => void;
17
+ updatePositions: (data: Node[]) => void;
18
+ updateHtmlOverlay: (overlay: HTMLElement) => void;
19
+ }
20
+ export type NodeDataSet = DataSet<Node>;
21
+ export type RelationshipDataSet = DataSet<Relationship>;
22
+ export interface ActionResult {
23
+ added?: boolean;
24
+ removed?: boolean;
25
+ updated?: boolean;
26
+ }
27
+ export interface Channel<T> {
28
+ adds: Record<string, T>;
29
+ updates: Record<string, T>;
30
+ removes: Record<string, T>;
31
+ }
32
+ export declare const getHtmlProperty: (item: Partial<Node | Relationship>) => HTMLElement | undefined;
33
+ /**
34
+ * Creates an empty dataset in which a graph be stored and updated using mobx actions.
35
+ * @returns A new and empty {@link DataSet}
36
+ */
37
+ export declare const createDataSet: <T extends Node | Relationship>() => DataSet<T>;
@@ -0,0 +1,5 @@
1
+ export function setLogLevel(level: any): void;
2
+ export function setupLogging(logger: any, logging: any): void;
3
+ export { nvlLog as log };
4
+ declare const nvlLog: loglevel.Logger;
5
+ import loglevel from 'loglevel';