@sqlrooms/cosmos 0.4.2 → 0.5.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.
Files changed (56) hide show
  1. package/dist/CosmosGraph.d.ts +3 -3
  2. package/dist/CosmosGraph.d.ts.map +1 -1
  3. package/dist/CosmosGraph.js +51 -13
  4. package/dist/CosmosGraph.js.map +1 -1
  5. package/dist/CosmosGraphControls.d.ts +1 -1
  6. package/dist/CosmosGraphControls.js +4 -4
  7. package/dist/CosmosGraphControls.js.map +1 -1
  8. package/dist/CosmosSimulationControls.d.ts +1 -5
  9. package/dist/CosmosSimulationControls.d.ts.map +1 -1
  10. package/dist/CosmosSimulationControls.js +7 -28
  11. package/dist/CosmosSimulationControls.js.map +1 -1
  12. package/dist/CosmosSlice.d.ts +75 -0
  13. package/dist/CosmosSlice.d.ts.map +1 -0
  14. package/dist/CosmosSlice.js +153 -0
  15. package/dist/CosmosSlice.js.map +1 -0
  16. package/dist/CosmosSliceConfig.d.ts +209 -0
  17. package/dist/CosmosSliceConfig.d.ts.map +1 -0
  18. package/dist/CosmosSliceConfig.js +187 -0
  19. package/dist/CosmosSliceConfig.js.map +1 -0
  20. package/dist/hooks/useHoverState.d.ts +11 -8
  21. package/dist/hooks/useHoverState.d.ts.map +1 -1
  22. package/dist/hooks/useHoverState.js +13 -9
  23. package/dist/hooks/useHoverState.js.map +1 -1
  24. package/dist/index.d.ts +61 -27
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +62 -26
  27. package/dist/index.js.map +1 -1
  28. package/package.json +8 -4
  29. package/dist/CosmosGraphContext.d.ts +0 -76
  30. package/dist/CosmosGraphContext.d.ts.map +0 -1
  31. package/dist/CosmosGraphContext.js +0 -95
  32. package/dist/CosmosGraphContext.js.map +0 -1
  33. package/dist/components/CosmosGraph.d.ts +0 -14
  34. package/dist/components/CosmosGraph.d.ts.map +0 -1
  35. package/dist/components/CosmosGraph.js +0 -130
  36. package/dist/components/CosmosGraph.js.map +0 -1
  37. package/dist/config.d.ts +0 -24
  38. package/dist/config.d.ts.map +0 -1
  39. package/dist/config.js +0 -18
  40. package/dist/config.js.map +0 -1
  41. package/dist/hooks/index.d.ts +0 -29
  42. package/dist/hooks/index.d.ts.map +0 -1
  43. package/dist/hooks/index.js +0 -29
  44. package/dist/hooks/index.js.map +0 -1
  45. package/dist/hooks/useGraph.d.ts +0 -49
  46. package/dist/hooks/useGraph.d.ts.map +0 -1
  47. package/dist/hooks/useGraph.js +0 -93
  48. package/dist/hooks/useGraph.js.map +0 -1
  49. package/dist/hooks/useGraphConfig.d.ts +0 -101
  50. package/dist/hooks/useGraphConfig.d.ts.map +0 -1
  51. package/dist/hooks/useGraphConfig.js +0 -53
  52. package/dist/hooks/useGraphConfig.js.map +0 -1
  53. package/dist/hooks/useRelativeCoordinates.d.ts +0 -2
  54. package/dist/hooks/useRelativeCoordinates.d.ts.map +0 -1
  55. package/dist/hooks/useRelativeCoordinates.js +0 -10
  56. package/dist/hooks/useRelativeCoordinates.js.map +0 -1
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * This package provides React components and hooks for creating interactive graph visualizations
5
5
  * using the Cosmograph WebGL-based graph visualization library. It includes components for
6
- * rendering graphs, managing graph state, and controlling graph interactions.
6
+ * rendering graphs, managing graph state through zustand, and controlling graph interactions.
7
7
  *
8
8
  * @example Basic usage
9
9
  * ```tsx
@@ -32,7 +32,7 @@ export { CosmosGraph } from './CosmosGraph';
32
32
  export { CosmosGraphControls } from './CosmosGraphControls';
33
33
  /**
34
34
  * A component that provides fine-grained controls for the graph simulation parameters.
35
- * Must be used within a CosmosGraph component as it relies on the CosmosGraphContext.
35
+ * Uses the zustand store to access and control the graph state.
36
36
  *
37
37
  * Features:
38
38
  * - Slider controls for gravity, repulsion, link strength, link distance, friction, and decay
@@ -55,38 +55,74 @@ export { CosmosGraphControls } from './CosmosGraphControls';
55
55
  * ```
56
56
  */
57
57
  export { CosmosSimulationControls } from './CosmosSimulationControls';
58
- // Context and hooks
59
- export { useCosmosGraph } from './CosmosGraphContext';
60
- export { useGraph, useHoverState, useGraphConfig } from './hooks';
61
- export { hasClientCoordinates } from './utils/coordinates';
58
+ // State management
59
+ export { useHoverState } from './hooks/useHoverState';
60
+ export { createCosmosSlice, useStoreWithCosmos, } from './CosmosSlice';
61
+ export { CosmosSliceConfig, createDefaultCosmosConfig, } from './CosmosSliceConfig';
62
62
  // Configuration
63
63
  /**
64
- * Zod schema for validating and describing graph simulation configuration parameters.
64
+ * Configuration schema for the Cosmos graph visualization system.
65
+ * Provides type-safe validation and configuration options for both visual and physics aspects of the graph.
65
66
  *
66
- * Available parameters:
67
- * - `simulationGravity` (number): Gravity force in the simulation. Controls how strongly nodes are pulled toward the center.
68
- * - `simulationRepulsion` (number): Repulsion force between nodes. Higher values make nodes push away from each other more strongly.
69
- * - `simulationLinkSpring` (number): Spring force for links between nodes. Higher values make connected nodes pull together more strongly.
70
- * - `simulationLinkDistance` (number): Target distance between linked nodes. Defines the natural length of links in the simulation.
71
- * - `simulationFriction` (number): Friction coefficient in the simulation. Higher values make node movement more damped.
72
- * - `simulationDecay` (number): Decay coefficient in the simulation. Lower values make the simulation "cool down" more slowly.
67
+ * Configuration Categories:
73
68
  *
74
- * @example
69
+ * 1. Visual Appearance
70
+ * - Node styling: size scaling and zoom behavior
71
+ * - Link styling: visibility, width, arrows, and curve options
72
+ *
73
+ * 2. Physics Simulation
74
+ * - Gravity: Central force pulling nodes toward center
75
+ * - Repulsion: Force pushing nodes apart
76
+ * - Link Forces: Spring forces and distances between connected nodes
77
+ * - Dynamics: Friction and decay rates for movement
78
+ *
79
+ * Key Parameters:
80
+ * - `pointSizeScale` (number): Base scale for node sizes (default: 1.1)
81
+ * - `scalePointsOnZoom` (boolean): Dynamic node sizing with zoom (default: true)
82
+ * - `renderLinks` (boolean): Toggle link visibility (default: true)
83
+ * - `linkArrows` (boolean): Show directional arrows (default: false)
84
+ * - `curvedLinks` (boolean): Use curved or straight links (default: false)
85
+ * - `simulationGravity` (number): Center attraction strength (default: 0.25)
86
+ * - `simulationRepulsion` (number): Node repulsion strength (default: 1.0)
87
+ * - `simulationLinkSpring` (number): Link elasticity (default: 1.0)
88
+ * - `simulationFriction` (number): Movement damping (default: 0.85)
89
+ * - `simulationDecay` (number): Simulation cooling rate (default: 1000)
90
+ *
91
+ * @example Typical usage with default-like values
75
92
  * ```tsx
76
- * import { CosmosSimulationConfigSchema } from '@sqlrooms/cosmos';
93
+ * import { CosmosGraph, createDefaultCosmosConfig } from '@sqlrooms/cosmos';
94
+ *
95
+ * const config = createDefaultCosmosConfig();
96
+ *
97
+ * function MyGraph() {
98
+ * return (
99
+ * <CosmosGraph
100
+ * config={config}
101
+ * data={graphData}
102
+ * />
103
+ * );
104
+ * }
105
+ * ```
77
106
  *
107
+ * @example Custom configuration for directed graph
108
+ * ```tsx
78
109
  * const config = {
79
- * simulationGravity: 0.1,
80
- * simulationRepulsion: 1.0,
81
- * simulationLinkSpring: 1.0,
82
- * simulationLinkDistance: 10,
83
- * simulationFriction: 0.85,
84
- * simulationDecay: 1000
85
- * };
110
+ * cosmos: {
111
+ * // Visual settings
112
+ * pointSizeScale: 1.2,
113
+ * linkArrows: true,
114
+ * curvedLinks: true,
86
115
  *
87
- * // Validate the config
88
- * const validConfig = CosmosSimulationConfigSchema.parse(config);
116
+ * // Physics settings
117
+ * simulationGravity: 0.2,
118
+ * simulationLinkDistance: 15,
119
+ * simulationLinkSpring: 1.2
120
+ * }
121
+ * };
89
122
  * ```
123
+ *
124
+ * @see {@link CosmosGraph} For the main graph component
125
+ * @see {@link CosmosSimulationControls} For runtime control of simulation parameters
90
126
  */
91
- export { CosmosSimulationConfigSchema } from './config';
127
+ export * from './CosmosSliceConfig';
92
128
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;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2
  "name": "@sqlrooms/cosmos",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -20,9 +20,13 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@cosmograph/cosmos": "2.0.0-beta.22",
23
- "@sqlrooms/ui": "0.4.2",
23
+ "@sqlrooms/project-builder": "0.5.0",
24
+ "@sqlrooms/project-config": "0.5.0",
25
+ "@sqlrooms/ui": "0.5.0",
26
+ "immer": "^10.1.1",
24
27
  "lucide-react": "^0.474.0",
25
- "zod": "^3.24.1"
28
+ "zod": "^3.24.1",
29
+ "zustand": "^5.0.3"
26
30
  },
27
31
  "peerDependencies": {
28
32
  "react": "*",
@@ -34,5 +38,5 @@
34
38
  "lint": "eslint .",
35
39
  "typedoc": "typedoc"
36
40
  },
37
- "gitHead": "c71b75c7c6f391e0760803bcac674b8a59368922"
41
+ "gitHead": "2a27ef8a774f934c8150dce57aac22699fb6d22f"
38
42
  }
@@ -1,76 +0,0 @@
1
- import { Graph } from '@cosmograph/cosmos';
2
- /**
3
- * The shape of the context value provided by CosmosGraphContext.
4
- */
5
- interface CosmosGraphContextValue {
6
- /** Whether the graph simulation is currently running */
7
- isSimulationRunning: boolean;
8
- /** Reference to the Cosmos Graph instance */
9
- graphRef: React.MutableRefObject<Graph | null> | null;
10
- /** Function to toggle the simulation state between running and paused */
11
- handleToggleSimulation: () => void;
12
- /** Function to fit the graph view to show all nodes */
13
- handleFitView: () => void;
14
- /** Function to start simulation with an energy push */
15
- handleStartWithEnergy: () => void;
16
- }
17
- /**
18
- * Hook to access the CosmosGraph context.
19
- *
20
- * Provides access to:
21
- * - Graph simulation state
22
- * - Graph instance reference
23
- * - Control functions for simulation and view
24
- *
25
- * @example
26
- * ```tsx
27
- * const CustomControl = () => {
28
- * const { isSimulationRunning, handleToggleSimulation } = useCosmosGraph();
29
- *
30
- * return (
31
- * <button onClick={handleToggleSimulation}>
32
- * {isSimulationRunning ? 'Pause' : 'Start'}
33
- * </button>
34
- * );
35
- * };
36
- * ```
37
- *
38
- * @throws {Error} If used outside of a CosmosGraphProvider
39
- * @returns The graph context value
40
- */
41
- export declare const useCosmosGraph: () => CosmosGraphContextValue;
42
- /**
43
- * Props for the CosmosGraphProvider component.
44
- */
45
- interface CosmosGraphProviderProps {
46
- /** Child components that will have access to the graph context */
47
- children: React.ReactNode;
48
- /** Reference to the Cosmos Graph instance */
49
- graphRef: React.MutableRefObject<Graph | null>;
50
- }
51
- /**
52
- * Provider component that makes graph state and controls available to its children.
53
- *
54
- * Manages:
55
- * - Simulation running state
56
- * - Graph instance reference
57
- * - Control functions for simulation and view
58
- *
59
- * @example
60
- * ```tsx
61
- * const MyGraph = () => {
62
- * const graphRef = useRef<Graph | null>(null);
63
- *
64
- * return (
65
- * <CosmosGraphProvider graphRef={graphRef}>
66
- * <CosmosGraph {...graphProps} />
67
- * <CosmosGraphControls />
68
- * <CustomControls />
69
- * </CosmosGraphProvider>
70
- * );
71
- * };
72
- * ```
73
- */
74
- export declare const CosmosGraphProvider: React.FC<CosmosGraphProviderProps>;
75
- export {};
76
- //# sourceMappingURL=CosmosGraphContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CosmosGraphContext.d.ts","sourceRoot":"","sources":["../src/CosmosGraphContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAGzC;;GAEG;AACH,UAAU,uBAAuB;IAC/B,wDAAwD;IACxD,mBAAmB,EAAE,OAAO,CAAC;IAC7B,6CAA6C;IAC7C,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IACtD,yEAAyE;IACzE,sBAAsB,EAAE,MAAM,IAAI,CAAC;IACnC,uDAAuD;IACvD,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,uDAAuD;IACvD,qBAAqB,EAAE,MAAM,IAAI,CAAC;CACnC;AAQD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,cAAc,+BAM1B,CAAC;AAEF;;GAEG;AACH,UAAU,wBAAwB;IAChC,kEAAkE;IAClE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,6CAA6C;IAC7C,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAyClE,CAAC"}
@@ -1,95 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useCallback, useContext, useState } from 'react';
3
- /**
4
- * Context for sharing graph state and controls across components.
5
- * @internal
6
- */
7
- const CosmosGraphContext = createContext(null);
8
- /**
9
- * Hook to access the CosmosGraph context.
10
- *
11
- * Provides access to:
12
- * - Graph simulation state
13
- * - Graph instance reference
14
- * - Control functions for simulation and view
15
- *
16
- * @example
17
- * ```tsx
18
- * const CustomControl = () => {
19
- * const { isSimulationRunning, handleToggleSimulation } = useCosmosGraph();
20
- *
21
- * return (
22
- * <button onClick={handleToggleSimulation}>
23
- * {isSimulationRunning ? 'Pause' : 'Start'}
24
- * </button>
25
- * );
26
- * };
27
- * ```
28
- *
29
- * @throws {Error} If used outside of a CosmosGraphProvider
30
- * @returns The graph context value
31
- */
32
- export const useCosmosGraph = () => {
33
- const context = useContext(CosmosGraphContext);
34
- if (!context) {
35
- throw new Error('useCosmosGraph must be used within a CosmosGraphProvider');
36
- }
37
- return context;
38
- };
39
- /**
40
- * Provider component that makes graph state and controls available to its children.
41
- *
42
- * Manages:
43
- * - Simulation running state
44
- * - Graph instance reference
45
- * - Control functions for simulation and view
46
- *
47
- * @example
48
- * ```tsx
49
- * const MyGraph = () => {
50
- * const graphRef = useRef<Graph | null>(null);
51
- *
52
- * return (
53
- * <CosmosGraphProvider graphRef={graphRef}>
54
- * <CosmosGraph {...graphProps} />
55
- * <CosmosGraphControls />
56
- * <CustomControls />
57
- * </CosmosGraphProvider>
58
- * );
59
- * };
60
- * ```
61
- */
62
- export const CosmosGraphProvider = ({ children, graphRef, }) => {
63
- const [isSimulationRunning, setIsSimulationRunning] = useState(true);
64
- const handleStartWithEnergy = useCallback(() => {
65
- if (!graphRef.current)
66
- return;
67
- graphRef.current.start(1);
68
- setIsSimulationRunning(true);
69
- }, [graphRef]);
70
- const handleToggleSimulation = useCallback(() => {
71
- if (!graphRef.current)
72
- return;
73
- if (graphRef.current.isSimulationRunning) {
74
- graphRef.current.pause();
75
- setIsSimulationRunning(false);
76
- }
77
- else {
78
- graphRef.current.restart();
79
- setIsSimulationRunning(true);
80
- }
81
- }, [graphRef]);
82
- const handleFitView = useCallback(() => {
83
- if (!graphRef.current)
84
- return;
85
- graphRef.current.fitView();
86
- }, [graphRef]);
87
- return (_jsx(CosmosGraphContext.Provider, { value: {
88
- isSimulationRunning,
89
- graphRef,
90
- handleToggleSimulation,
91
- handleFitView,
92
- handleStartWithEnergy,
93
- }, children: children }));
94
- };
95
- //# sourceMappingURL=CosmosGraphContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CosmosGraphContext.js","sourceRoot":"","sources":["../src/CosmosGraphContext.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAkBvE;;;GAGG;AACH,MAAM,kBAAkB,GAAG,aAAa,CAAiC,IAAI,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,OAAO,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAC/C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CA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R,sBAAsB;YACtB,aAAa;YACb,qBAAqB;SACtB,YAEA,QAAQ,GACmB,CAC/B,CAAC;AACJ,CAAC,CAAC"}
@@ -1,14 +0,0 @@
1
- import { GraphConfigInterface } from '@cosmograph/cosmos';
2
- import { FC } from 'react';
3
- export type CosmosGraphProps = {
4
- config: GraphConfigInterface;
5
- pointPositions: Float32Array;
6
- pointSizes: Float32Array;
7
- pointColors: Float32Array;
8
- linkIndexes?: Float32Array;
9
- linkColors?: Float32Array;
10
- focusedPointIndex?: number | undefined;
11
- getPointTooltip?: (index: number) => React.ReactNode;
12
- };
13
- export declare const CosmosGraph: FC<CosmosGraphProps>;
14
- //# sourceMappingURL=CosmosGraph.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CosmosGraph.d.ts","sourceRoot":"","sources":["../../src/components/CosmosGraph.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,oBAAoB,EAAC,MAAM,oBAAoB,CAAC;AAG/D,OAAO,EAAC,EAAE,EAAoD,MAAM,OAAO,CAAC;AA+B5E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,oBAAoB,CAAC;IAC7B,cAAc,EAAE,YAAY,CAAC;IAC7B,UAAU,EAAE,YAAY,CAAC;IACzB,WAAW,EAAE,YAAY,CAAC;IAC1B,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;CACtD,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAoK5C,CAAC"}
@@ -1,130 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Graph } from '@cosmograph/cosmos';
3
- import { Button, cn } from '@sqlrooms/ui';
4
- import { Maximize2, Pause, Play } from 'lucide-react';
5
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
6
- const useRelativeCoordinates = (containerRef) => {
7
- return useCallback((x, y) => {
8
- if (!containerRef.current)
9
- return [0, 0];
10
- const rect = containerRef.current.getBoundingClientRect();
11
- return [x - rect.left, y - rect.top];
12
- }, [containerRef]);
13
- };
14
- const hasClientCoordinates = (event) => {
15
- return (typeof event === 'object' &&
16
- event !== null &&
17
- 'clientX' in event &&
18
- 'clientY' in event &&
19
- typeof event.clientX === 'number' &&
20
- typeof event.clientY === 'number');
21
- };
22
- export const CosmosGraph = ({ config, pointPositions, pointSizes, pointColors, linkIndexes, linkColors, focusedPointIndex, getPointTooltip, }) => {
23
- const containerRef = useRef(null);
24
- const graphRef = useRef(null);
25
- const [isSimulationRunning, setIsSimulationRunning] = useState(true);
26
- const [hoveredPoint, setHoveredPoint] = useState(null);
27
- const calcRelativeCoordinates = useRelativeCoordinates(containerRef);
28
- const configWithCallbacks = useMemo(() => {
29
- return {
30
- ...config,
31
- onSimulationStart: () => {
32
- setIsSimulationRunning(true);
33
- config.onSimulationStart?.();
34
- },
35
- onSimulationPause: () => {
36
- setIsSimulationRunning(false);
37
- config.onSimulationPause?.();
38
- },
39
- onSimulationEnd: () => {
40
- setIsSimulationRunning(false);
41
- config.onSimulationEnd?.();
42
- },
43
- onSimulationRestart: () => {
44
- setIsSimulationRunning(true);
45
- config.onSimulationRestart?.();
46
- },
47
- onPointMouseOver: (index, _pointPosition, event) => {
48
- if (hasClientCoordinates(event)) {
49
- setHoveredPoint({
50
- index,
51
- position: calcRelativeCoordinates(event.clientX, event.clientY),
52
- });
53
- }
54
- },
55
- onPointMouseOut: () => {
56
- setHoveredPoint(null);
57
- },
58
- onZoomStart: () => {
59
- setHoveredPoint(null);
60
- },
61
- onDragStart: () => {
62
- setHoveredPoint(null);
63
- },
64
- };
65
- }, [config, calcRelativeCoordinates]);
66
- useEffect(() => {
67
- if (!graphRef.current)
68
- return;
69
- console.log({ focusedPointIndex });
70
- graphRef.current.setFocusedPointByIndex(focusedPointIndex);
71
- }, [focusedPointIndex]);
72
- useEffect(() => {
73
- if (!containerRef.current)
74
- return;
75
- if (!graphRef.current) {
76
- graphRef.current = new Graph(containerRef.current);
77
- }
78
- const graph = graphRef.current;
79
- graph.setPointPositions(pointPositions);
80
- graph.setPointColors(pointColors);
81
- graph.setPointSizes(pointSizes);
82
- if (linkIndexes && linkColors) {
83
- graph.setLinks(linkIndexes);
84
- graph.setLinkColors(linkColors);
85
- }
86
- graph.setConfig(configWithCallbacks);
87
- graph.render();
88
- graph.start();
89
- setIsSimulationRunning(true);
90
- graph.setZoomLevel(0.6);
91
- return () => {
92
- graph.pause();
93
- setIsSimulationRunning(false);
94
- };
95
- }, [
96
- pointPositions,
97
- pointColors,
98
- pointSizes,
99
- linkIndexes,
100
- linkColors,
101
- configWithCallbacks,
102
- ]);
103
- useEffect(() => {
104
- if (!graphRef.current)
105
- return;
106
- graphRef.current.setConfig(configWithCallbacks);
107
- }, [configWithCallbacks]);
108
- const handleFitView = useCallback(() => {
109
- if (!graphRef.current)
110
- return;
111
- graphRef.current.fitView();
112
- }, []);
113
- const handleToggleSimulation = useCallback(() => {
114
- if (!graphRef.current)
115
- return;
116
- if (graphRef.current.isSimulationRunning) {
117
- graphRef.current.pause();
118
- setIsSimulationRunning(false);
119
- }
120
- else {
121
- graphRef.current.start();
122
- setIsSimulationRunning(true);
123
- }
124
- }, []);
125
- return (_jsxs("div", { className: "relative w-full h-full", children: [_jsx("div", { ref: containerRef, className: "absolute w-full h-full" }), getPointTooltip ? (_jsx("div", { className: cn('absolute z-50 max-w-xs', 'bg-white/90 dark:bg-gray-800/90 rounded-md shadow-lg p-2', 'text-xs flex gap-2 items-center pointer-events-none transition-opacity duration-150', hoveredPoint ? 'opacity-100' : 'opacity-0'), style: {
126
- transform: `translate(${hoveredPoint?.position?.[0] ?? 0}px, ${hoveredPoint?.position?.[1] ?? 0}px) translate(-50%, 5px)`,
127
- visibility: hoveredPoint ? 'visible' : 'hidden',
128
- }, children: _jsx("div", { children: getPointTooltip?.(hoveredPoint?.index ?? 0) }) })) : null, _jsxs("div", { className: "absolute top-1 left-1 flex gap-2", children: [!config.disableSimulation && (_jsx(_Fragment, { children: _jsx(Button, { onClick: handleToggleSimulation, variant: "outline", size: "sm", children: isSimulationRunning ? (_jsx(Pause, { className: "h-4 w-4" })) : (_jsx(Play, { className: "h-4 w-4" })) }) })), _jsx(Button, { onClick: handleFitView, variant: "outline", size: "sm", children: _jsx(Maximize2, { className: "h-4 w-4" }) })] })] }));
129
- };
130
- //# sourceMappingURL=CosmosGraph.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CosmosGraph.js","sourceRoot":"","sources":["../../src/components/CosmosGraph.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,KAAK,EAAuB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAC,MAAM,EAAE,EAAE,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,SAAS,EAAE,KAAK,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AACpD,OAAO,EAAK,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE5E,MAAM,sBAAsB,GAAG,CAAC,YAA0C,EAAE,EAAE;IAC5E,OAAO,WAAW,CAChB,CAAC,CAAS,EAAE,CAAS,EAAoB,EAAE;QACzC,IAAI,CAAC,YAAY,CAAC,OAAO;YAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC;QAC1D,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC,EACD,CAAC,YAAY,CAAC,CACf,CAAC;AACJ,CAAC,CAAC;AAOF,MAAM,oBAAoB,GAA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C7B,GACM,GACR,CACJ,EACD,KAAC,MAAM,IAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,IAAI,YACzD,KAAC,SAAS,IAAC,SAAS,EAAC,SAAS,GAAG,GAC1B,IACL,IACF,CACP,CAAC;AACJ,CAAC,CAAC"}
package/dist/config.d.ts DELETED
@@ -1,24 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const CosmosSimulationConfigSchema: z.ZodObject<{
3
- simulationGravity: z.ZodNumber;
4
- simulationRepulsion: z.ZodNumber;
5
- simulationLinkSpring: z.ZodNumber;
6
- simulationLinkDistance: z.ZodNumber;
7
- simulationFriction: z.ZodNumber;
8
- simulationDecay: z.ZodNumber;
9
- }, "strip", z.ZodTypeAny, {
10
- simulationDecay: number;
11
- simulationGravity: number;
12
- simulationRepulsion: number;
13
- simulationLinkSpring: number;
14
- simulationLinkDistance: number;
15
- simulationFriction: number;
16
- }, {
17
- simulationDecay: number;
18
- simulationGravity: number;
19
- simulationRepulsion: number;
20
- simulationLinkSpring: number;
21
- simulationLinkDistance: number;
22
- simulationFriction: number;
23
- }>;
24
- //# sourceMappingURL=config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAGtB,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;EAsBvC,CAAC"}
package/dist/config.js DELETED
@@ -1,18 +0,0 @@
1
- import { z } from 'zod';
2
- export const CosmosSimulationConfigSchema = z.object({
3
- simulationGravity: z.number().describe('Gravity force in the simulation'),
4
- simulationRepulsion: z.number().describe('Repulsion force between nodes'),
5
- simulationLinkSpring: z
6
- .number()
7
- .describe('Spring force for links between nodes'),
8
- simulationLinkDistance: z
9
- .number()
10
- .describe('Target distance between linked nodes'),
11
- simulationFriction: z
12
- .number()
13
- .describe('Friction coefficient in the simulation'),
14
- simulationDecay: z
15
- .number()
16
- .describe('Decay coefficient in the simulation. Use smaller values if you want the simulation to "cool down" slower.'),
17
- });
18
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAGtB,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;IAEzE,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IAEzE,oBAAoB,EAAE,CAAC;SACpB,MAAM,EAAE;SACR,QAAQ,CAAC,sCAAsC,CAAC;IAEnD,sBAAsB,EAAE,CAAC;SACtB,MAAM,EAAE;SACR,QAAQ,CAAC,sCAAsC,CAAC;IAEnD,kBAAkB,EAAE,CAAC;SAClB,MAAM,EAAE;SACR,QAAQ,CAAC,wCAAwC,CAAC;IAErD,eAAe,EAAE,CAAC;SACf,MAAM,EAAE;SACR,QAAQ,CACP,2GAA2G,CAC5G;CACJ,CAAC,CAAC"}
@@ -1,29 +0,0 @@
1
- /**
2
- * React hooks for managing Cosmos graph state and interactions
3
- *
4
- * This module exports several hooks that help manage different aspects of a Cosmos graph:
5
- *
6
- * - `useGraph`: Core hook for managing the graph instance and its lifecycle
7
- * - `useHoverState`: Hook for managing point hover state and coordinates
8
- * - `useGraphConfig`: Hook for creating a memoized graph configuration with event handlers
9
- *
10
- * @example Using multiple hooks together
11
- * ```tsx
12
- * const MyGraph = () => {
13
- * const containerRef = useRef<HTMLDivElement>(null);
14
- * const calcRelativeCoords = useRelativeCoordinates(containerRef);
15
- *
16
- * const { hoveredPoint, onPointMouseOver } = useHoverState(calcRelativeCoords);
17
- * const config = useGraphConfig(baseConfig, onPointMouseOver, clearHoverState);
18
- * const graphRef = useGraph(containerRef, config, positions, colors, sizes);
19
- *
20
- * return <div ref={containerRef} />;
21
- * };
22
- * ```
23
- *
24
- * @packageDocumentation
25
- */
26
- export * from './useGraph';
27
- export * from './useHoverState';
28
- export * from './useGraphConfig';
29
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
@@ -1,29 +0,0 @@
1
- /**
2
- * React hooks for managing Cosmos graph state and interactions
3
- *
4
- * This module exports several hooks that help manage different aspects of a Cosmos graph:
5
- *
6
- * - `useGraph`: Core hook for managing the graph instance and its lifecycle
7
- * - `useHoverState`: Hook for managing point hover state and coordinates
8
- * - `useGraphConfig`: Hook for creating a memoized graph configuration with event handlers
9
- *
10
- * @example Using multiple hooks together
11
- * ```tsx
12
- * const MyGraph = () => {
13
- * const containerRef = useRef<HTMLDivElement>(null);
14
- * const calcRelativeCoords = useRelativeCoordinates(containerRef);
15
- *
16
- * const { hoveredPoint, onPointMouseOver } = useHoverState(calcRelativeCoords);
17
- * const config = useGraphConfig(baseConfig, onPointMouseOver, clearHoverState);
18
- * const graphRef = useGraph(containerRef, config, positions, colors, sizes);
19
- *
20
- * return <div ref={containerRef} />;
21
- * };
22
- * ```
23
- *
24
- * @packageDocumentation
25
- */
26
- export * from './useGraph';
27
- export * from './useHoverState';
28
- export * from './useGraphConfig';
29
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}