@fxhash/open-form-graph 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/OpenFormGraph-0EqYrhjv.d.ts +17 -0
- package/dist/OpenFormGraph-wo_Y20C6.js +1277 -0
- package/dist/OpenFormGraph-wo_Y20C6.js.map +1 -0
- package/dist/components.d.ts +2 -0
- package/dist/components.js +4 -0
- package/dist/constants-DU_wYtaU.d.ts +242 -0
- package/dist/index.d.ts +111 -133
- package/dist/index.js +3 -2098
- package/dist/provider-CTDz6ZQd.js +103 -0
- package/dist/provider-CTDz6ZQd.js.map +1 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.js +3 -0
- package/package.json +14 -7
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
@@ -1,139 +1,117 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import * as
|
4
|
-
import { ReactNode } from 'react';
|
1
|
+
import { OpenFormGraph$1 as OpenFormGraph } from "./OpenFormGraph-0EqYrhjv.js";
|
2
|
+
import { ColorHandler, ColorTransform, DEFAULT_GRAPH_CONFIG$1 as DEFAULT_GRAPH_CONFIG, GraphConfig, GraphData, Link, NestedRawNode, Node, NodeState, OpenFormGraphApi, OpenFormGraphProvider$1 as OpenFormGraphProvider, RGB, RawGraphData, RawLink, RawNode, RootNodeImageSources, SimLink, SimNode, ThemeMode, VOID_ROOT_ID$1 as VOID_ROOT_ID, color$1 as color, dim$1 as dim, useOpenFormGraph$1 as useOpenFormGraph } from "./constants-DU_wYtaU.js";
|
3
|
+
import * as d3_force2 from "d3-force";
|
5
4
|
|
6
|
-
|
7
|
-
id: string;
|
8
|
-
label?: string;
|
9
|
-
imgSrc?: string;
|
10
|
-
};
|
11
|
-
type RawLink = {
|
12
|
-
source: string;
|
13
|
-
target: string;
|
14
|
-
};
|
15
|
-
type Link = {
|
16
|
-
source: Node;
|
17
|
-
target: Node;
|
18
|
-
};
|
19
|
-
type Node = {
|
20
|
-
id: string;
|
21
|
-
collapsed: boolean;
|
22
|
-
hide: boolean;
|
23
|
-
clusterSize: number;
|
24
|
-
level?: number;
|
25
|
-
childLinks: Link[];
|
26
|
-
image?: HTMLImageElement;
|
27
|
-
} & RawNode;
|
28
|
-
type RawGraphData = {
|
29
|
-
nodes: RawNode[];
|
30
|
-
links: RawLink[];
|
31
|
-
};
|
32
|
-
type GraphData = {
|
33
|
-
nodes: Node[];
|
34
|
-
links: Link[];
|
35
|
-
};
|
36
|
-
type RGB = [number, number, number];
|
37
|
-
type ColorTransform = (rgb: RGB) => RGB;
|
38
|
-
|
39
|
-
interface GraphConfig {
|
40
|
-
debug: false;
|
41
|
-
nodeSize: number;
|
42
|
-
minClusterSize: number;
|
43
|
-
maxClusterSize: number;
|
44
|
-
minZoom: number;
|
45
|
-
maxZoom: number;
|
46
|
-
focusPadding: number;
|
47
|
-
minDagLevelDistance: number;
|
48
|
-
maxDagLevelDistance: number;
|
49
|
-
theme: {
|
50
|
-
dark: [number, number, number];
|
51
|
-
light: [number, number, number];
|
52
|
-
};
|
53
|
-
}
|
54
|
-
interface LayoutConfig {
|
55
|
-
velocityDecay: number;
|
56
|
-
alphaDecay: number;
|
57
|
-
alphaMin: number;
|
58
|
-
dagLevelDistance: number;
|
59
|
-
}
|
60
|
-
type _ForceGraphMethods = ForceGraphMethods<Node, Link> | ForceGraphMethods$1<Node, Link>;
|
61
|
-
interface OpenFormGraphApi {
|
62
|
-
ref: React.MutableRefObject<_ForceGraphMethods | undefined>;
|
63
|
-
rootId: string;
|
64
|
-
data: GraphData;
|
65
|
-
onClickNode: (nodeId: string) => void;
|
66
|
-
hasNodeChildren: (nodeId: string) => boolean;
|
67
|
-
clusterSizeRange: [number, number];
|
68
|
-
graphLevelRange: [number, number];
|
69
|
-
setLayoutConfig: React.Dispatch<React.SetStateAction<LayoutConfig>>;
|
70
|
-
layoutConfig: LayoutConfig;
|
71
|
-
selectedNode: Node | null;
|
72
|
-
selectedNodeId: string | null;
|
73
|
-
setSelectedNodeId: (node: string | null) => void;
|
74
|
-
highlights: GraphData;
|
75
|
-
theme: "dark" | "light";
|
76
|
-
setTheme: (theme: "dark" | "light") => void;
|
77
|
-
config: GraphConfig;
|
78
|
-
setConfig: React.Dispatch<React.SetStateAction<GraphConfig>>;
|
79
|
-
getNodeSize: (nodeId: string) => number;
|
80
|
-
getNodeForce: (nodeId: string) => number;
|
81
|
-
search: (startNodeId: string, rootId: string) => {
|
82
|
-
nodes: Node[];
|
83
|
-
links: Link[];
|
84
|
-
};
|
85
|
-
}
|
5
|
+
//#region src/util/canvas.d.ts
|
86
6
|
|
87
|
-
interface ProjectGraphProps$1 {
|
88
|
-
width: number;
|
89
|
-
height: number;
|
90
|
-
}
|
91
|
-
declare function OpenFormGraph(props: ProjectGraphProps$1): react_jsx_runtime.JSX.Element;
|
92
|
-
|
93
|
-
interface ProjectGraphProps {
|
94
|
-
width: number;
|
95
|
-
height: number;
|
96
|
-
}
|
97
|
-
declare function OpenFormGraph3D(props: ProjectGraphProps): react_jsx_runtime.JSX.Element;
|
98
|
-
|
99
|
-
interface OpenFormGraphProviderProps {
|
100
|
-
config?: Partial<GraphConfig>;
|
101
|
-
theme: "dark" | "light";
|
102
|
-
children: ReactNode;
|
103
|
-
data: {
|
104
|
-
nodes: RawNode[];
|
105
|
-
links: RawLink[];
|
106
|
-
};
|
107
|
-
rootId: string;
|
108
|
-
}
|
109
|
-
declare function OpenFormGraphProvider({ config, theme, data, rootId: _rootId, children, }: OpenFormGraphProviderProps): react_jsx_runtime.JSX.Element;
|
110
|
-
declare function useOpenFormGraph(): OpenFormGraphApi;
|
111
|
-
|
112
|
-
declare const VOID_ROOT_ID = "void-root";
|
113
|
-
declare const DEFAULT_GRAPH_CONFIG: GraphConfig;
|
114
|
-
|
115
|
-
declare function normalize(val: number, min: number, max: number, minOut: number, maxOut: number): number;
|
116
|
-
|
117
|
-
interface ColorHandler {
|
118
|
-
(arg?: number): string;
|
119
|
-
(arg: ColorTransform): ColorHandler;
|
120
|
-
rgb: RGB;
|
121
|
-
}
|
122
|
-
declare function color(rgb: RGB): ColorHandler;
|
123
7
|
/**
|
124
|
-
*
|
125
|
-
* @param
|
126
|
-
* @param
|
127
|
-
* @
|
8
|
+
* draws a circle on the canvas
|
9
|
+
* @param ctx - The canvas rendering context
|
10
|
+
* @param x - The x-coordinate of the circle's center
|
11
|
+
* @param y - The y-coordinate of the circle's center
|
12
|
+
* @param radius - The radius of the circle (default is 5)
|
13
|
+
* @param options - Optional parameters for styling the circle
|
14
|
+
* @param options.fill - Whether to fill the circle (default is true)
|
15
|
+
* @param options.fillStyle - The fill color of the circle
|
16
|
+
* @param options.stroke - Whether to stroke the circle (default is false)
|
17
|
+
* @param options.strokeStyle - The stroke color of the circle
|
18
|
+
* @param options.lineWidth - The width of the stroke (default is 0.2)
|
19
|
+
* @returns void
|
128
20
|
*/
|
129
|
-
declare function
|
130
|
-
|
21
|
+
declare function circle(ctx: CanvasRenderingContext2D, x: number, y: number, radius?: number, options?: {
|
22
|
+
fill?: boolean;
|
23
|
+
fillStyle?: string;
|
24
|
+
stroke?: boolean;
|
25
|
+
strokeStyle?: string;
|
26
|
+
lineWidth?: number;
|
27
|
+
}): void;
|
28
|
+
/**
|
29
|
+
* draws a rectangle on the canvas
|
30
|
+
* @param ctx - The canvas rendering context
|
31
|
+
* @param x - The x-coordinate of the rectangle's top-left corner
|
32
|
+
* @param y - The y-coordinate of the rectangle's top-left corner
|
33
|
+
* @param width - The width of the rectangle
|
34
|
+
* @param height - The height of the rectangle
|
35
|
+
* @param options - Optional parameters for styling the rectangle
|
36
|
+
* @param options.fill - Whether to fill the rectangle (default is true)
|
37
|
+
* @param options.fillStyle - The fill color of the rectangle
|
38
|
+
* @param options.stroke - Whether to stroke the rectangle (default is false)
|
39
|
+
* @param options.strokeStyle - The stroke color of the rectangle
|
40
|
+
* @param options.lineWidth - The width of the stroke (default is 0.2)
|
41
|
+
* @param options.borderRadius - The radius of the corners (default is 0)
|
42
|
+
* @returns void
|
43
|
+
*/
|
44
|
+
declare function rect(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, options?: {
|
45
|
+
fill?: boolean;
|
46
|
+
fillStyle?: string;
|
47
|
+
stroke?: boolean;
|
48
|
+
strokeStyle?: string;
|
49
|
+
lineWidth?: number;
|
50
|
+
borderRadius?: number;
|
51
|
+
}): void;
|
52
|
+
/**
|
53
|
+
* draws an image on the canvas with optional border radius and opacity
|
54
|
+
* @param ctx - The canvas rendering context
|
55
|
+
* @param image - The HTMLImageElement to draw
|
56
|
+
* @param x - The x-coordinate of the image's top-left corner
|
57
|
+
* @param y - The y-coordinate of the image's top-left corner
|
58
|
+
* @param width - The width of the image
|
59
|
+
* @param height - The height of the image
|
60
|
+
* @param borderRadius - The radius of the corners (default is 0)
|
61
|
+
* @param opacity - The opacity of the image (default is 1.0)
|
62
|
+
* @param bgColor - Optional background color to fill the clipped area
|
63
|
+
* @returns void
|
64
|
+
*/
|
65
|
+
declare function img(ctx: CanvasRenderingContext2D, image: HTMLImageElement, x: number, y: number, width: number, height: number, borderRadius?: number, opacity?: number, bgColor?: string): void;
|
66
|
+
declare function hexagon(ctx: CanvasRenderingContext2D, x: number, y: number, radius: number, options?: {
|
67
|
+
fill?: boolean;
|
68
|
+
fillStyle?: string;
|
69
|
+
stroke?: boolean;
|
70
|
+
strokeStyle?: string;
|
71
|
+
lineWidth?: number;
|
72
|
+
rotation?: number;
|
73
|
+
borderRadius?: number;
|
74
|
+
}): void;
|
75
|
+
//#endregion
|
76
|
+
//#region src/util/data.d.ts
|
131
77
|
declare function generateTree(maxNodes: number, maxChildren: number): RawGraphData;
|
132
|
-
declare function
|
133
|
-
|
134
|
-
|
78
|
+
declare function getPrunedData(startId: string, nodes: SimNode[], links: SimLink[]): {
|
79
|
+
nodes: SimNode[];
|
80
|
+
links: d3_force2.SimulationLinkDatum<SimNode>[];
|
135
81
|
};
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
82
|
+
/**
|
83
|
+
* Automatically identifies root nodes and builds a nested structure
|
84
|
+
* @param nodes Array of raw nodes
|
85
|
+
* @param links Array of links between nodes
|
86
|
+
* @returns Array of nested nodes starting from identified roots
|
87
|
+
*/
|
88
|
+
declare function buildTreeFromGraphData(nodes: RawNode[], links: RawLink[]): NestedRawNode<RawNode>[];
|
89
|
+
/**
|
90
|
+
* Recursively retrieves all parents of a node from a graph data structure
|
91
|
+
* @param {string} nodeHash - The hash of the node to find parents for
|
92
|
+
* @param {RawNode[]} nodes - Array of nodes in the graph
|
93
|
+
* @param {RawLink[]} links - Array of links connecting the nodes
|
94
|
+
* @returns {RawNode[]} - Array of parent nodes
|
95
|
+
*/
|
96
|
+
declare function searchParents(nodeHash: string, nodes: RawNode[], links: RawLink[]): RawNode[];
|
97
|
+
//#endregion
|
98
|
+
//#region src/util/graph.d.ts
|
99
|
+
declare function getNodeId(n: any): any;
|
100
|
+
declare function getParents(id: string, links: SimLink[]): string[];
|
101
|
+
declare function getChildren(id: string, links: SimLink[]): string[];
|
102
|
+
declare function getClusterSize(id: string, links: RawLink[]): number;
|
103
|
+
declare function hasOnlyLeafs(id: string, links: RawLink[]): boolean;
|
104
|
+
declare function getNodeSubgraph(nodeId: string, nodes: SimNode[], links: SimLink[], rootId: string): {
|
105
|
+
nodes: SimNode[];
|
106
|
+
links: SimLink[];
|
107
|
+
};
|
108
|
+
//#endregion
|
109
|
+
//#region src/util/img.d.ts
|
110
|
+
declare function loadImage(src: string): Promise<HTMLImageElement>;
|
111
|
+
//#endregion
|
112
|
+
//#region src/util/types.d.ts
|
113
|
+
declare function isSimNode(node: SimNode | string | number): node is SimNode;
|
114
|
+
declare function isSimLink(link: SimLink): link is SimLink;
|
115
|
+
//#endregion
|
116
|
+
export { ColorHandler, ColorTransform, DEFAULT_GRAPH_CONFIG, GraphConfig, GraphData, Link, NestedRawNode, Node, NodeState, OpenFormGraph, OpenFormGraphApi, OpenFormGraphProvider, RGB, RawGraphData, RawLink, RawNode, RootNodeImageSources, SimLink, SimNode, ThemeMode, VOID_ROOT_ID, buildTreeFromGraphData, circle, color, dim, generateTree, getChildren, getClusterSize, getNodeId, getNodeSubgraph, getParents, getPrunedData, hasOnlyLeafs, hexagon, img, isSimLink, isSimNode, loadImage, rect, searchParents, useOpenFormGraph };
|
117
|
+
//# sourceMappingURL=index.d.ts.map
|