@neo4j-nvl/base 0.3.1-854a900a

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 +54 -0
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Specific error that is being thrown by NVL when web browser is not WebGL compatible.
3
+ * @internal
4
+ */
5
+ export declare class CompatibilityError extends Error {
6
+ /**
7
+ * Returns the error message of the compatibility error.
8
+ * @returns {string} the error message
9
+ */
10
+ toString(): string;
11
+ }
@@ -0,0 +1,122 @@
1
+ import type { Node } from '../types/graph-element';
2
+ /**
3
+ * An object representing a point in 2D space.
4
+ */
5
+ export interface Point {
6
+ /** The x coordinate of the point. */
7
+ x: number;
8
+ /** The y coordinate of the point. */
9
+ y: number;
10
+ }
11
+ /**
12
+ * This function checks if the coordinates are defined.
13
+ * @param {Point} from - The node the edge starts from.
14
+ * @param {Point} to - The node the edge ends at.
15
+ * @returns {boolean} True if the coordinates are defined.
16
+ */
17
+ export declare const areCoordinateDefined: (from: Point, to: Point) => boolean;
18
+ /**
19
+ * Returns true if the two points are within PointDelta pixels of each other
20
+ * This function is used to determine if a new point is close enough to an
21
+ * existing point to be considered the same point
22
+ * @param {Node} p1 - The first point.
23
+ * @param {Node} p2 - The second point.
24
+ * @returns {boolean} True if the two points are within PointDelta pixels of each other.
25
+ */
26
+ export declare const pointEqual: (p1: Node | Point, p2: Node | Point) => boolean;
27
+ /**
28
+ * A class representing a line segment between two points in 2D space.
29
+ * @param {Point} p1 - The first point of the segment.
30
+ * @param {Point} p2 - The second point of the segment.
31
+ */
32
+ export declare class Segment {
33
+ /** The first point of the segment. */
34
+ readonly p1: Point;
35
+ /** The second point of the segment. */
36
+ readonly p2: Point;
37
+ /** The unit vector of the segment. */
38
+ readonly unit: Point;
39
+ /** The unit normal vector of the segment. */
40
+ readonly norm: Point;
41
+ /** The length of the segment. */
42
+ readonly length: number;
43
+ /** The vector between the two points of the segment. */
44
+ readonly vector: Point;
45
+ constructor(p1: Point, p2: Point);
46
+ /**
47
+ * Get the vector between the two points of the segment.
48
+ * @returns {Point} The vector between the two points of the segment.
49
+ * @private
50
+ * @see {@link https://en.wikipedia.org/wiki/Vector_(spatial)}
51
+ */
52
+ private getVector;
53
+ /**
54
+ * Get the length of the vector between the two points of the segment.
55
+ * @returns {number} The length of the segment.
56
+ * @private
57
+ * @see {@link https://en.wikipedia.org/wiki/Vector_(spatial)#Length}
58
+ */
59
+ private getLength;
60
+ /**
61
+ * Get the unit vector of the two points of the segment.
62
+ * @returns {Point} The unit vector of the segment.
63
+ * @private
64
+ * @see {@link https://en.wikipedia.org/wiki/Euclidean_vector#Unit_vector}
65
+ * @see {@link https://en.wikipedia.org/wiki/Unit_vector}
66
+ */
67
+ private getUnitVector;
68
+ /**
69
+ * Get the unit normal vector of the two points of the segment.
70
+ * @returns {Point} The unit normal vector of the segment.
71
+ * @private
72
+ * @see {@link https://en.wikipedia.org/wiki/Normal_(geometry)}
73
+ */
74
+ private getUnitNormalVector;
75
+ }
76
+ /**
77
+ * Calculates the projection ratio between two vectors.
78
+ * @param {Point} lineStartToPointVector - The vector from the start of the line to the point.
79
+ * @param {Point} lineVector - The vector of the line.
80
+ * @returns {number} The projection of the point onto the line.
81
+ * @note The projection ratio is a value between 0 and 1.
82
+ * @note The projection ratio is 0 if the point is closest to the start of the line.
83
+ * @note The projection ratio is 1 if the point is closest to the end of the line.
84
+ * @see {@link https://en.wikipedia.org/wiki/Vector_projection}
85
+ */
86
+ export declare const getProjectionRatio: (lineStartToPointVector: Point, lineVector: Point) => number;
87
+ /**
88
+ * Calculates the shortest distance between a point and a line.
89
+ * @param {Point} lineStart - The first point of the line.
90
+ * @param {Point} lineEnd - The second point of the line.
91
+ * @param {Point} point - The point to calculate the distance to.
92
+ * @returns {number} The distance between the point and the line.
93
+ * @note If the actual distance does not matter,
94
+ * if you only want to compare what this function
95
+ * returns to other results of this function, you
96
+ * can just return the squared distance instead
97
+ * (i.e. remove the sqrt) to gain a little performance.
98
+ */
99
+ export declare const getDistanceToLine: (lineStart: Point, lineEnd: Point, point: Point) => number;
100
+ /**
101
+ * Get the intersection point of two lines
102
+ * @param {Point} p0 - First point of first line
103
+ * @param {Point} p1 - Second point of first line
104
+ * @param {Point} p2 - First point of second line
105
+ * @param {Point} p3 - Second point of second line
106
+ * @returns {Point | null} Intersection point
107
+ * @see https://github.com/bit101/CodingMath/blob/master/episode33/parallel.js
108
+ * @note Returns null if lines are parallel
109
+ */
110
+ export declare const getIntersection: (p0: Point, p1: Point, p2: Point, p3: Point) => Point | null;
111
+ /**
112
+ * This is a function to calculate the distance between a point and a quadratic curve.
113
+ * The curve is defined by three points (from, to, control).
114
+ * The point is defined by an object with x and y properties (point).
115
+ * The function returns the distance between the point and the curve.
116
+ * @param {Point} fromCoordinates - The first point of the curve.
117
+ * @param {Point} toCoordinates - The second point of the curve.
118
+ * @param {Point} control - The control point of the curve.
119
+ * @param {Point} point - The point to calculate the distance to.
120
+ * @returns {number} The distance between the point and the curve.
121
+ */
122
+ export declare const getDistanceToQuadratic: (fromCoordinates: Point, toCoordinates: Point, control: Point, point: Point) => number;
@@ -0,0 +1,9 @@
1
+ export function relItemsToFlatList(relItems: any[]): any[];
2
+ export function getAdjNodesMapAndRelMap(rels: any): {
3
+ adjNodesMap: {};
4
+ relMap: {};
5
+ };
6
+ export function getConnectedNodesAndRels(addedNodes: any, addedRels: any, nodes: any, rels: any): {
7
+ connectedNodes: {};
8
+ connectedRels: {};
9
+ };
@@ -0,0 +1,56 @@
1
+ import type { NvlState } from '../modules/state';
2
+ import type { Node, Relationship } from '../types/graph-element';
3
+ import type { Point } from './geometry';
4
+ /**
5
+ * A node that has been hit by a pointer event
6
+ */
7
+ export interface HitTargetNode {
8
+ /** The node that was hit */
9
+ data: Node;
10
+ /** The coordinates of the node that was hit */
11
+ targetCoordinates: Point;
12
+ /** The coordinates of the pointer event */
13
+ pointerCoordinates: Point;
14
+ /** The distance vector between the node and the pointer event */
15
+ distanceVector: Point;
16
+ /** The distance between the node and the pointer event */
17
+ distance: number;
18
+ /** Whether the pointer event is inside the node */
19
+ insideNode: boolean;
20
+ }
21
+ /**
22
+ * A relationship that has been hit by a pointer event
23
+ */
24
+ export interface HitTargetRelationship {
25
+ /** The relationship that was hit */
26
+ data: Relationship;
27
+ /** The coordinates of the source node of the relationship that was hit */
28
+ fromTargetCoordinates: Point;
29
+ /** The coordinates of the target node of the relationship that was hit */
30
+ toTargetCoordinates: Point;
31
+ /** The coordinates of the pointer event */
32
+ pointerCoordinates: Point;
33
+ /** The distance between the relationship and the pointer event */
34
+ distance: number;
35
+ }
36
+ /**
37
+ * A collection of nodes and relationships that have been hit by a pointer event
38
+ * Part of the result of a {@link NVL}.{@link NVL.getHits} call
39
+ */
40
+ export type HitTargets = {
41
+ nodes: HitTargetNode[];
42
+ relationships: HitTargetRelationship[];
43
+ };
44
+ export declare const hitTest: (x: number, y: number, state: NvlState, targets?: string[], options?: {
45
+ hitNodeMarginWidth?: number;
46
+ }) => HitTargets;
47
+ export declare const hitTestCanvas: (x: number, y: number, parentHandler: {
48
+ getCanvasNodesAt: (c: Point, m: number) => HitTargetNode[];
49
+ getCanvasRelsAt: (c: Point) => HitTargetRelationship[];
50
+ }, targets?: string[], options?: {
51
+ hitNodeMarginWidth?: number;
52
+ }) => HitTargets;
53
+ export declare const hitTestBox: (x1: number, y1: number, x2: number, y2: number, state: NvlState, targets?: string[]) => {
54
+ nodes: Node[];
55
+ rels: Relationship[];
56
+ };
@@ -0,0 +1,9 @@
1
+ export declare const getMouseElementCoordinates: (evt: MouseEvent, element: HTMLElement) => {
2
+ offsetX: number;
3
+ offsetY: number;
4
+ };
5
+ export declare const getMousePosition: (evt: MouseEvent, canvas: HTMLElement, zoom?: number, panX?: number, panY?: number) => {
6
+ x: number;
7
+ y: number;
8
+ };
9
+ export declare const getNewZoom: (evt: WheelEvent, currentZoom?: number) => number;
@@ -0,0 +1,20 @@
1
+ import type { Node } from '../index';
2
+ import type { Point } from './geometry';
3
+ declare const getExtremeLimits: (nodePositions: Point[] | Node[]) => Point[];
4
+ declare const getMaxDistance: (extremeLimits?: Point[]) => number;
5
+ declare const getPositionBoundaries: (nodePositions?: Point[] | Node[], maxNodeRadius?: number) => {
6
+ centerX: number;
7
+ centerY: number;
8
+ nodesWidth: number;
9
+ nodesHeight: number;
10
+ };
11
+ declare const getZoomLevel: (viewWidth: number, viewHeight: number, sceneWidth: number, sceneHeight: number) => {
12
+ zoomX: number;
13
+ zoomY: number;
14
+ };
15
+ declare const createZoomTarget: (zoomX: number, zoomY: number, minZoom?: number, maxZoom?: number) => number;
16
+ declare const getFlexibleZoomLimit: (nodePositions: Point[] | Node[], rect: HTMLCanvasElement, maxNodeRadius: number) => number;
17
+ declare const getNewZoomWithinLimits: (newZoom: number, oldZoom: number, minZoom: number, maxZoom: number) => number;
18
+ declare const isZoomOutAtLimit: (newZoom: number, oldZoom: number, zoomOutLimit: number) => boolean;
19
+ declare const getDynamicZoom: (nodePositions: Point[] | Node[], minZoom: number, maxZoom: number, rect: HTMLCanvasElement, newZoom: number, currentZoom: number) => number;
20
+ export { getFlexibleZoomLimit, isZoomOutAtLimit, getNewZoomWithinLimits, getExtremeLimits, getMaxDistance, getPositionBoundaries, getZoomLevel, createZoomTarget, getDynamicZoom };
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@neo4j-nvl/base",
3
+ "version": "0.3.1-854a900a",
4
+ "license": "SEE LICENSE IN 'LICENSE.txt'",
5
+ "main": "dist/base.mjs",
6
+ "types": "dist/types/index.d.ts",
7
+ "files": [
8
+ "LICENSE.txt",
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "rm -rf lib/ dist/ && tsc && webpack",
13
+ "test": "jest",
14
+ "coverage": "yarn test --coverage --silent",
15
+ "prepack": "cp ../../LICENSE.txt ./",
16
+ "postpack": "rm LICENSE.txt"
17
+ },
18
+ "typedoc": {
19
+ "entryPoint": "./src/index.ts",
20
+ "readmeFile": "./README.md",
21
+ "displayName": "Base",
22
+ "tsconfig": "./tsconfig.json"
23
+ },
24
+ "dependencies": {
25
+ "@neo4j-nvl/layout-workers": "^0.3.1-854a900a",
26
+ "color-string": "^1.9.1",
27
+ "contrast": "1.0.1",
28
+ "d3-force": "^3.0.0",
29
+ "gl-matrix": "^3.3.0",
30
+ "glsl-inject-defines": "^1.0.3",
31
+ "lodash": "4.17.21",
32
+ "loglevel": "^1.8.0",
33
+ "mobx": "^3.2.2",
34
+ "node-pid-controller": "^1.0.1",
35
+ "resizelistener": "^1.1.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/color-string": "^1.5.5",
39
+ "@types/d3-force": "^3.0.3",
40
+ "@types/lodash": "4.14.202",
41
+ "babel-loader": "^8.2.5",
42
+ "copy-webpack-plugin": "^11.0.0",
43
+ "jest": "^29.7.0",
44
+ "typedoc": "^0.23.15",
45
+ "typescript": "^5.4.5",
46
+ "webpack": "^5.75.0",
47
+ "webpack-cli": "^5.0.0"
48
+ },
49
+ "peerDependencies": {
50
+ "jest": "*",
51
+ "typescript": "*"
52
+ },
53
+ "stableVersion": "0.3.1"
54
+ }