@cocorof/graphier 1.3.3 → 1.4.1
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/README.md +26 -0
- package/dist/index.cjs +585 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +104 -0
- package/dist/index.js +585 -51
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
|
4
4
|
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
6
|
import { RefAttributes } from 'react';
|
|
7
|
+
import { RefObject } from 'react';
|
|
7
8
|
import * as THREE from 'three';
|
|
8
9
|
|
|
9
10
|
/** Smoothly animate camera to a new position/target using ease-out */
|
|
@@ -66,6 +67,29 @@ export declare interface GraphLink {
|
|
|
66
67
|
[key: string]: unknown;
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
export declare function GraphMinimap({ graphRef, width, height, backgroundColor, viewportColor, dotRadius, fps, padding, className, style, }: GraphMinimapProps): JSX_2.Element;
|
|
71
|
+
|
|
72
|
+
export declare interface GraphMinimapProps {
|
|
73
|
+
/** Ref to the NetworkGraph3D instance to mirror */
|
|
74
|
+
graphRef: RefObject<NetworkGraph3DRef | null>;
|
|
75
|
+
/** Canvas CSS width in px (default: 200) */
|
|
76
|
+
width?: number;
|
|
77
|
+
/** Canvas CSS height in px (default: 140) */
|
|
78
|
+
height?: number;
|
|
79
|
+
/** Background fill (default: transparent) */
|
|
80
|
+
backgroundColor?: string;
|
|
81
|
+
/** Viewport rectangle stroke color (default: "#94a3b8") */
|
|
82
|
+
viewportColor?: string;
|
|
83
|
+
/** Dot radius in px (default: 1.5) */
|
|
84
|
+
dotRadius?: number;
|
|
85
|
+
/** Redraw rate in frames per second (default: 15) */
|
|
86
|
+
fps?: number;
|
|
87
|
+
/** Fraction of canvas kept as padding around the graph (default: 0.08) */
|
|
88
|
+
padding?: number;
|
|
89
|
+
className?: string;
|
|
90
|
+
style?: CSSProperties;
|
|
91
|
+
}
|
|
92
|
+
|
|
69
93
|
/**
|
|
70
94
|
* Core graph data types — domain-agnostic.
|
|
71
95
|
* Users provide any `type` string ("person", "server", "repo", etc.)
|
|
@@ -86,6 +110,20 @@ export declare interface GraphNode {
|
|
|
86
110
|
[key: string]: unknown;
|
|
87
111
|
}
|
|
88
112
|
|
|
113
|
+
/** Raw per-frame node buffers for lightweight overlays (e.g. minimap) */
|
|
114
|
+
export declare interface GraphSnapshot {
|
|
115
|
+
/** xyz triplets, one per node (live buffer — do not mutate) */
|
|
116
|
+
positions: Float32Array;
|
|
117
|
+
/** Node count */
|
|
118
|
+
count: number;
|
|
119
|
+
/** rgb triplets per node from the instanced mesh (live buffer) */
|
|
120
|
+
colors: Float32Array | null;
|
|
121
|
+
/** 1 = hidden by the visibility filter (live buffer) */
|
|
122
|
+
hidden: Uint8Array | null;
|
|
123
|
+
/** Index of the selected node, -1 if none */
|
|
124
|
+
selectedIndex: number;
|
|
125
|
+
}
|
|
126
|
+
|
|
89
127
|
/**
|
|
90
128
|
* Layout engine configuration.
|
|
91
129
|
*/
|
|
@@ -109,6 +147,21 @@ export declare interface LayoutConfig {
|
|
|
109
147
|
* (default: "auto")
|
|
110
148
|
*/
|
|
111
149
|
spreadFactor?: "auto" | number;
|
|
150
|
+
/**
|
|
151
|
+
* Layout dimensionality (default: 3).
|
|
152
|
+
* 2 = flat Obsidian-style plane: the simulation runs in 2D (z is locked
|
|
153
|
+
* to 0), the camera is locked to pan/zoom (no rotation), and dragging
|
|
154
|
+
* stays on the plane.
|
|
155
|
+
*/
|
|
156
|
+
dimensions?: 2 | 3;
|
|
157
|
+
/**
|
|
158
|
+
* Pull nodes that share the same key toward a common centroid so
|
|
159
|
+
* categories form visible clusters ("type" reads node.type, "group"
|
|
160
|
+
* reads node.group). null/undefined = off (default).
|
|
161
|
+
*/
|
|
162
|
+
clusterBy?: "type" | "group" | null;
|
|
163
|
+
/** Cluster attraction strength 0..1 (default: 0.05). */
|
|
164
|
+
clusterStrength?: number;
|
|
112
165
|
}
|
|
113
166
|
|
|
114
167
|
/** Layout settled callback */
|
|
@@ -164,6 +217,31 @@ export declare interface NetworkGraph3DProps {
|
|
|
164
217
|
labelFormatter?: (node: GraphNode) => string;
|
|
165
218
|
/** Custom node size accessor (overrides node.val) */
|
|
166
219
|
nodeValueAccessor?: (node: GraphNode) => number;
|
|
220
|
+
/**
|
|
221
|
+
* Client-side filter: IDs of nodes to keep visible. Hidden nodes (and
|
|
222
|
+
* their edges/labels) vanish WITHOUT re-running the force layout —
|
|
223
|
+
* positions are preserved, so toggling filters never reheats the graph.
|
|
224
|
+
* null/undefined shows everything.
|
|
225
|
+
*/
|
|
226
|
+
visibleNodeIds?: ReadonlySet<string> | string[] | null;
|
|
227
|
+
/**
|
|
228
|
+
* Client-side edge filter: return false to hide a link (e.g. by type).
|
|
229
|
+
* Same reheat-free mechanism as visibleNodeIds — collapsed segments,
|
|
230
|
+
* simulation untouched. null/undefined shows all edges.
|
|
231
|
+
*/
|
|
232
|
+
linkVisibility?: ((link: GraphLink) => boolean) | null;
|
|
233
|
+
/**
|
|
234
|
+
* Allow dragging individual nodes (default: true). Set false on dense
|
|
235
|
+
* graphs so left-drag always pans/orbits the camera instead of grabbing
|
|
236
|
+
* whichever node happens to be under the pointer.
|
|
237
|
+
*/
|
|
238
|
+
enableNodeDrag?: boolean;
|
|
239
|
+
/** Fly the camera to a node on single-click (default: true) */
|
|
240
|
+
clickToFocus?: boolean;
|
|
241
|
+
/** Highlight a node's neighborhood on hover when nothing is selected (default: false) */
|
|
242
|
+
hoverHighlight?: boolean;
|
|
243
|
+
/** Hops highlighted around the hovered node (default: 1) */
|
|
244
|
+
hoverHighlightHops?: number;
|
|
167
245
|
}
|
|
168
246
|
|
|
169
247
|
export declare interface NetworkGraph3DRef {
|
|
@@ -201,6 +279,12 @@ export declare interface NetworkGraph3DRef {
|
|
|
201
279
|
captureScreenshot(): string | null;
|
|
202
280
|
/** Re-run force layout from current positions (useful after changing spreadFactor) */
|
|
203
281
|
reheatLayout(): void;
|
|
282
|
+
/** Pan the camera to world (x, y), keeping the current zoom (2D-friendly) */
|
|
283
|
+
panTo(x: number, y: number, duration?: number): void;
|
|
284
|
+
/** Node position/color/visibility buffers for overlays like GraphMinimap */
|
|
285
|
+
getGraphSnapshot(): GraphSnapshot | null;
|
|
286
|
+
/** Current camera footprint on the z=0 plane (meaningful in 2D mode) */
|
|
287
|
+
getViewportRect(): ViewportRect | null;
|
|
204
288
|
}
|
|
205
289
|
|
|
206
290
|
export declare function NodeDetailPanel(props: NodeDetailPanelProps): JSX_2.Element;
|
|
@@ -237,6 +321,8 @@ export declare type NullableLinkEventHandler = (link: GraphLink | null) => void;
|
|
|
237
321
|
|
|
238
322
|
export declare type NullableNodeEventHandler = (node: GraphNode | null) => void;
|
|
239
323
|
|
|
324
|
+
export declare const paper: ThemeConfig;
|
|
325
|
+
|
|
240
326
|
/** Runtime node with layout positions (internal) */
|
|
241
327
|
export declare interface PositionedNode extends GraphNode {
|
|
242
328
|
x?: number;
|
|
@@ -262,6 +348,10 @@ export declare interface ResolvedTheme {
|
|
|
262
348
|
nodeColorBright(type?: string): string;
|
|
263
349
|
linkColor(type?: string): string;
|
|
264
350
|
backgroundColor: string;
|
|
351
|
+
/** True when the background is light — flips highlight/dim direction */
|
|
352
|
+
isLight: boolean;
|
|
353
|
+
/** Whether edges should use additive blending (dark backgrounds only) */
|
|
354
|
+
additiveEdges: boolean;
|
|
265
355
|
}
|
|
266
356
|
|
|
267
357
|
export declare function resolveTheme(theme?: ThemeConfig | string): ResolvedTheme;
|
|
@@ -357,6 +447,20 @@ export declare interface ThemeConfig {
|
|
|
357
447
|
backgroundColor?: string;
|
|
358
448
|
/** Color palette for auto-assignment when type has no explicit mapping */
|
|
359
449
|
palette?: string[];
|
|
450
|
+
/**
|
|
451
|
+
* Edge blend mode. "additive" glows on dark backgrounds; "normal" is
|
|
452
|
+
* required for light backgrounds (additive lines vanish on white).
|
|
453
|
+
* Default: "additive" on dark backgrounds, "normal" on light ones.
|
|
454
|
+
*/
|
|
455
|
+
blending?: "additive" | "normal";
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/** Camera frustum footprint on the z=0 plane (world units) */
|
|
459
|
+
export declare interface ViewportRect {
|
|
460
|
+
cx: number;
|
|
461
|
+
cy: number;
|
|
462
|
+
halfW: number;
|
|
463
|
+
halfH: number;
|
|
360
464
|
}
|
|
361
465
|
|
|
362
466
|
/** Compute camera position to fit all nodes in view */
|