@cocorof/graphier 0.1.0

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.
@@ -0,0 +1,310 @@
1
+ import { CSSProperties } from 'react';
2
+ import { ForwardRefExoticComponent } from 'react';
3
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
4
+ import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
5
+ import { ReactNode } from 'react';
6
+ import { RefAttributes } from 'react';
7
+ import * as THREE from 'three';
8
+
9
+ /** Smoothly animate camera to a new position/target using ease-out */
10
+ export declare function animateCamera(camera: THREE.PerspectiveCamera, controls: OrbitControls, targetPos: CameraTarget, targetLookAt: CameraTarget, duration: number): void;
11
+
12
+ export declare type BackgroundClickHandler = () => void;
13
+
14
+ /** Build adjacency map from links */
15
+ export declare function buildAdjacencyMapFromLinks(links: GraphLink[]): Map<string, string[]>;
16
+
17
+ /**
18
+ * Build a subgraph of N-hop neighborhood around a center node.
19
+ * Uses budget-based pruning: all hop 0-1 nodes are kept,
20
+ * then top nodes by `val` for remaining hops.
21
+ */
22
+ export declare function buildSubgraph(data: GraphData, centerNodeId: string, adjacencyMap: Map<string, string[]>, options?: SubgraphOptions): SubgraphResult;
23
+
24
+ declare interface CameraTarget {
25
+ x: number;
26
+ y: number;
27
+ z: number;
28
+ }
29
+
30
+ export declare const celestial: ThemeConfig;
31
+
32
+ /** BFS to find nodes within N hops of a root node */
33
+ export declare function computeHighlightSet(rootId: string, adjacencyMap: Map<string, string[]>, maxHops: number): Map<string, number>;
34
+
35
+ export declare interface ConnectionGroup {
36
+ title: string;
37
+ type: string;
38
+ nodes: GraphNode[];
39
+ }
40
+
41
+ export declare const DEFAULT_LAYOUT: Required<LayoutConfig>;
42
+
43
+ export declare const DEFAULT_STYLE: Required<StyleConfig>;
44
+
45
+ export declare interface GraphData {
46
+ nodes: GraphNode[];
47
+ links: GraphLink[];
48
+ }
49
+
50
+ export declare interface GraphLink {
51
+ /** Source node id */
52
+ source: string;
53
+ /** Target node id */
54
+ target: string;
55
+ /** Relationship type — maps to theme colors (e.g. "follows", "owns") */
56
+ type?: string;
57
+ /** Edge weight (default: 1) */
58
+ weight?: number;
59
+ /** User-defined extra data */
60
+ [key: string]: unknown;
61
+ }
62
+
63
+ /**
64
+ * Core graph data types — domain-agnostic.
65
+ * Users provide any `type` string ("person", "server", "repo", etc.)
66
+ * and the theme system maps them to colors automatically.
67
+ */
68
+ export declare interface GraphNode {
69
+ /** Unique identifier */
70
+ id: string;
71
+ /** Node category — maps to theme colors (e.g. "person", "repo") */
72
+ type?: string;
73
+ /** Display label (falls back to id) */
74
+ label?: string;
75
+ /** Size weight — higher values render larger (default: 1) */
76
+ val?: number;
77
+ /** Grouping key for color auto-assignment (alternative to type) */
78
+ group?: string;
79
+ /** User-defined extra data (accessible in callbacks) */
80
+ [key: string]: unknown;
81
+ }
82
+
83
+ /**
84
+ * Layout engine configuration.
85
+ */
86
+ export declare interface LayoutConfig {
87
+ /** Layout algorithm (currently only "force-3d") */
88
+ type?: "force-3d";
89
+ /** Many-body charge strength — "auto" adapts to graph size, or provide a number (default: "auto") */
90
+ charge?: "auto" | number;
91
+ /** Link distance — "auto" adapts to graph size, or provide a number (default: "auto") */
92
+ linkDistance?: "auto" | number;
93
+ /** Alpha decay rate — "auto" adapts to graph size (default: "auto") */
94
+ alphaDecay?: "auto" | number;
95
+ /** Velocity damping 0..1 (default: 0.4) */
96
+ velocityDecay?: number;
97
+ /** Convergence threshold — simulation stops when alpha drops below this (default: 0.005) */
98
+ settledThreshold?: number;
99
+ }
100
+
101
+ export declare type LinkEventHandler = (link: GraphLink) => void;
102
+
103
+ export declare const minimal: ThemeConfig;
104
+
105
+ export declare const neon: ThemeConfig;
106
+
107
+ export declare const NetworkGraph3D: ForwardRefExoticComponent<NetworkGraph3DProps & RefAttributes<NetworkGraph3DRef>>;
108
+
109
+ export declare interface NetworkGraph3DProps {
110
+ /** Graph data: nodes and links */
111
+ data: GraphData;
112
+ /** Single-click on a node (null = background click / deselect) */
113
+ onNodeClick?: NullableNodeEventHandler;
114
+ /** Double-click on a node */
115
+ onNodeDoubleClick?: NodeEventHandler;
116
+ /** Hover on a node (null = hover out) */
117
+ onNodeHover?: NullableNodeEventHandler;
118
+ /** Currently selected node ID (controlled mode) */
119
+ selectedNodeId?: string | null;
120
+ /** Number of hops to highlight around selected node (default: 3) */
121
+ highlightHops?: number;
122
+ /** Theme configuration or preset name */
123
+ theme?: ThemeConfig | string;
124
+ /** Visual style overrides */
125
+ style?: StyleConfig;
126
+ /** Force layout configuration */
127
+ layout?: LayoutConfig;
128
+ /** WebGL renderer configuration */
129
+ renderer?: RendererConfig;
130
+ /** Custom label text formatter */
131
+ labelFormatter?: (node: GraphNode) => string;
132
+ /** Custom node size accessor (overrides node.val) */
133
+ nodeValueAccessor?: (node: GraphNode) => number;
134
+ }
135
+
136
+ export declare interface NetworkGraph3DRef {
137
+ /** Animate camera to position, looking at target */
138
+ cameraPosition(pos: {
139
+ x: number;
140
+ y: number;
141
+ z: number;
142
+ }, lookAt: {
143
+ x: number;
144
+ y: number;
145
+ z: number;
146
+ }, duration?: number): void;
147
+ /** Zoom to fit all nodes in view */
148
+ zoomToFit(duration?: number, padding?: number): void;
149
+ /** Zoom in toward center */
150
+ zoomIn(): void;
151
+ /** Zoom out from center */
152
+ zoomOut(): void;
153
+ /** Focus camera on a specific node */
154
+ focusNode(nodeId: string, duration?: number): void;
155
+ /**
156
+ * Incrementally add nodes and links without full rebuild.
157
+ * Existing node positions are preserved; new nodes spawn near their neighbors.
158
+ * Returns the number of new nodes actually added (deduped by ID).
159
+ */
160
+ appendData(nodes: GraphNode[], links: GraphLink[]): number;
161
+ /** Access the Three.js scene */
162
+ getScene(): THREE.Scene | null;
163
+ /** Access the Three.js renderer */
164
+ getRenderer(): THREE.WebGLRenderer | null;
165
+ /** Access the Three.js camera */
166
+ getCamera(): THREE.PerspectiveCamera | null;
167
+ /** Capture a screenshot as a Blob */
168
+ screenshot(): Promise<Blob | null>;
169
+ }
170
+
171
+ export declare function NodeDetailPanel(props: NodeDetailPanelProps): JSX_2.Element;
172
+
173
+ export declare interface NodeDetailPanelProps {
174
+ node: GraphNode;
175
+ data: GraphData;
176
+ adjacencyMap?: Map<string, string[]>;
177
+ onClose: () => void;
178
+ onNodeNavigate: (node: GraphNode) => void;
179
+ theme?: ThemeConfig | string;
180
+ labelFormatter?: (node: GraphNode) => string;
181
+ maxHops?: number;
182
+ maxNodes?: number;
183
+ renderNodeMeta?: (node: GraphNode) => ReactNode;
184
+ groupConnections?: (directNeighbors: GraphNode[], links: GraphLink[]) => ConnectionGroup[];
185
+ connectionLabel?: (node: GraphNode) => string;
186
+ connectionSecondary?: (node: GraphNode) => ReactNode;
187
+ modal?: boolean;
188
+ className?: string;
189
+ style?: CSSProperties;
190
+ }
191
+
192
+ export declare type NodeEventHandler = (node: GraphNode) => void;
193
+
194
+ export declare type NullableNodeEventHandler = (node: GraphNode | null) => void;
195
+
196
+ /** Runtime node with layout positions (internal) */
197
+ export declare interface PositionedNode extends GraphNode {
198
+ x?: number;
199
+ y?: number;
200
+ z?: number;
201
+ }
202
+
203
+ export declare interface RendererConfig {
204
+ /** WebGL antialiasing (default: false for performance) */
205
+ antialias?: boolean;
206
+ /** Max device pixel ratio (default: 1.5) */
207
+ pixelRatioMax?: number;
208
+ }
209
+
210
+ export declare interface ResolvedTheme {
211
+ nodeColor(type?: string): string;
212
+ nodeColorBright(type?: string): string;
213
+ linkColor(type?: string): string;
214
+ backgroundColor: string;
215
+ }
216
+
217
+ export declare function resolveTheme(theme?: ThemeConfig | string): ResolvedTheme;
218
+
219
+ export declare interface StyleConfig {
220
+ /** Minimum node sphere radius (default: 1) */
221
+ nodeMinSize?: number;
222
+ /** Maximum node sphere radius (default: 15) */
223
+ nodeMaxSize?: number;
224
+ /** Edge line opacity 0..1 (default: 0.15) */
225
+ edgeOpacity?: number;
226
+ /** Bloom glow strength (default: 0.6) */
227
+ bloomStrength?: number;
228
+ /** Bloom glow radius (default: 0.1) */
229
+ bloomRadius?: number;
230
+ /** Bloom brightness threshold (default: 0.1) */
231
+ bloomThreshold?: number;
232
+ /** Show background star field (default: true) */
233
+ starField?: boolean;
234
+ /** Exponential fog density (default: 0.0006, 0 = disabled) */
235
+ fogDensity?: number;
236
+ /** Auto-orbit camera rotation (default: false) */
237
+ autoOrbit?: boolean;
238
+ /** Label text scale multiplier (default: 1.0) */
239
+ labelScale?: number;
240
+ /** Label visibility distance threshold 0..1 (default: 0.8) */
241
+ labelThreshold?: number;
242
+ /** Show labels at all (default: true) */
243
+ showLabels?: boolean;
244
+ /** Maximum visible labels at once (default: 150) */
245
+ maxLabels?: number;
246
+ /** Edge line width multiplier (default: 1.0). Note: WebGL limits linewidth to 1 on most platforms. */
247
+ edgeWidthScale?: number;
248
+ }
249
+
250
+ export declare interface SubgraphOptions {
251
+ maxHops?: number;
252
+ maxNodes?: number;
253
+ }
254
+
255
+ export declare interface SubgraphResult {
256
+ nodes: GraphNode[];
257
+ links: GraphLink[];
258
+ /** Map of node ID → hop distance from center */
259
+ hops: Map<string, number>;
260
+ }
261
+
262
+ export declare function SubgraphView2D(props: SubgraphView2DProps): JSX_2.Element;
263
+
264
+ export declare interface SubgraphView2DProps {
265
+ /** Full graph data */
266
+ data: GraphData;
267
+ /** Center node ID to build subgraph around */
268
+ centerNodeId: string;
269
+ /** Max hops from center (default: 3) */
270
+ maxHops?: number;
271
+ /** Max nodes in subgraph (default: 250) */
272
+ maxNodes?: number;
273
+ /** Theme config or preset name */
274
+ theme?: ThemeConfig | string;
275
+ /** Click on a node */
276
+ onNodeClick?: (node: GraphNode) => void;
277
+ /** Hover on a node */
278
+ onNodeHover?: (node: GraphNode | null) => void;
279
+ /** Custom label formatter */
280
+ labelFormatter?: (node: GraphNode) => string;
281
+ /** Container style overrides */
282
+ style?: CSSProperties;
283
+ /** Container class name */
284
+ className?: string;
285
+ }
286
+
287
+ /**
288
+ * Theme configuration — controls all visual appearance.
289
+ */
290
+ export declare interface ThemeConfig {
291
+ /** Node colors by type string (e.g. { person: "#58a6ff", repo: "#3fb950" }) */
292
+ nodeColors?: Record<string, string>;
293
+ /** Brighter node colors for highlights (auto-generated if omitted) */
294
+ nodeColorsBright?: Record<string, string>;
295
+ /** Edge colors by type string (e.g. { follows: "#8b949e" }) */
296
+ linkColors?: Record<string, string>;
297
+ /** Fallback color for unmapped node types */
298
+ defaultNodeColor?: string;
299
+ /** Fallback color for unmapped link types */
300
+ defaultLinkColor?: string;
301
+ /** Scene background color */
302
+ backgroundColor?: string;
303
+ /** Color palette for auto-assignment when type has no explicit mapping */
304
+ palette?: string[];
305
+ }
306
+
307
+ /** Compute camera position to fit all nodes in view */
308
+ export declare function zoomToFitPositions(camera: THREE.PerspectiveCamera, controls: OrbitControls, positions: Float32Array, duration: number, padding: number): void;
309
+
310
+ export { }