@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
@@ -19,7 +19,7 @@ export type CosmosGraphProps = {
19
19
  /** Optional index of the point to focus on */
20
20
  focusedPointIndex?: number | undefined;
21
21
  /** Optional function to render custom tooltip content for a point */
22
- getPointTooltip?: (index: number) => React.ReactNode;
22
+ renderPointTooltip?: (index: number) => React.ReactNode;
23
23
  /** Optional child elements to render inside the graph container */
24
24
  children?: React.ReactNode;
25
25
  };
@@ -30,7 +30,7 @@ export type CosmosGraphProps = {
30
30
  * - Renders points and optional links in a WebGL canvas
31
31
  * - Supports point hovering with customizable tooltips
32
32
  * - Handles point focusing
33
- * - Provides graph context to child components
33
+ * - Provides graph state to child components through zustand store
34
34
  *
35
35
  * @example
36
36
  * ```tsx
@@ -51,7 +51,7 @@ export type CosmosGraphProps = {
51
51
  * pointPositions={new Float32Array([0, 0, 1, 1])}
52
52
  * pointColors={new Float32Array([1, 0, 0, 1, 0, 1, 0, 1])}
53
53
  * pointSizes={new Float32Array([5, 5])}
54
- * getPointTooltip={(index) => `Point ${index}`}
54
+ * renderPointTooltip={(index) => `Point ${index}`}
55
55
  * >
56
56
  * <GraphControls />
57
57
  * </CosmosGraph>
@@ -1 +1 @@
1
- {"version":3,"file":"CosmosGraph.d.ts","sourceRoot":"","sources":["../src/CosmosGraph.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAC,EAAE,EAAS,MAAM,OAAO,CAAC;AAIjC;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,4EAA4E;IAC5E,MAAM,EAAE,oBAAoB,CAAC;IAC7B,kFAAkF;IAClF,cAAc,EAAE,YAAY,CAAC;IAC7B,6EAA6E;IAC7E,UAAU,EAAE,YAAY,CAAC;IACzB,8EAA8E;IAC9E,WAAW,EAAE,YAAY,CAAC;IAC1B,6EAA6E;IAC7E,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,qFAAqF;IACrF,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,8CAA8C;IAC9C,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,qEAAqE;IACrE,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IACrD,mEAAmE;IACnE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA6D5C,CAAC"}
1
+ {"version":3,"file":"CosmosGraph.d.ts","sourceRoot":"","sources":["../src/CosmosGraph.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAC,EAAE,EAAoB,MAAM,OAAO,CAAC;AAI5C;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,4EAA4E;IAC5E,MAAM,EAAE,oBAAoB,CAAC;IAC7B,kFAAkF;IAClF,cAAc,EAAE,YAAY,CAAC;IAC7B,6EAA6E;IAC7E,UAAU,EAAE,YAAY,CAAC;IACzB,8EAA8E;IAC9E,WAAW,EAAE,YAAY,CAAC;IAC1B,6EAA6E;IAC7E,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,qFAAqF;IACrF,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,8CAA8C;IAC9C,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IACxD,mEAAmE;IACnE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAoF5C,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn, useRelativeCoordinates } from '@sqlrooms/ui';
3
- import { useRef } from 'react';
4
- import { CosmosGraphProvider } from './CosmosGraphContext';
5
- import { useGraph, useHoverState, useGraphConfig } from './hooks';
3
+ import { useEffect, useRef } from 'react';
4
+ import { useStoreWithCosmos } from './CosmosSlice';
5
+ import { useHoverState } from './hooks/useHoverState';
6
6
  /**
7
7
  * A React component that renders an interactive graph visualization using Cosmos.
8
8
  *
@@ -10,7 +10,7 @@ import { useGraph, useHoverState, useGraphConfig } from './hooks';
10
10
  * - Renders points and optional links in a WebGL canvas
11
11
  * - Supports point hovering with customizable tooltips
12
12
  * - Handles point focusing
13
- * - Provides graph context to child components
13
+ * - Provides graph state to child components through zustand store
14
14
  *
15
15
  * @example
16
16
  * ```tsx
@@ -31,7 +31,7 @@ import { useGraph, useHoverState, useGraphConfig } from './hooks';
31
31
  * pointPositions={new Float32Array([0, 0, 1, 1])}
32
32
  * pointColors={new Float32Array([1, 0, 0, 1, 0, 1, 0, 1])}
33
33
  * pointSizes={new Float32Array([5, 5])}
34
- * getPointTooltip={(index) => `Point ${index}`}
34
+ * renderPointTooltip={(index) => `Point ${index}`}
35
35
  * >
36
36
  * <GraphControls />
37
37
  * </CosmosGraph>
@@ -40,15 +40,53 @@ import { useGraph, useHoverState, useGraphConfig } from './hooks';
40
40
  * };
41
41
  * ```
42
42
  */
43
- export const CosmosGraph = ({ config, pointPositions, pointSizes, pointColors, linkIndexes, linkColors, focusedPointIndex, getPointTooltip, children, }) => {
43
+ export const CosmosGraph = ({ config, pointPositions, pointSizes, pointColors, linkIndexes, linkColors, focusedPointIndex, renderPointTooltip, children, }) => {
44
44
  const containerRef = useRef(null);
45
45
  const calcRelativeCoordinates = useRelativeCoordinates(containerRef);
46
- const { hoveredPoint, onPointMouseOver, clearHoverState } = useHoverState(calcRelativeCoordinates);
47
- const configWithCallbacks = useGraphConfig(config, onPointMouseOver, clearHoverState);
48
- const graphRef = useGraph(containerRef, configWithCallbacks, pointPositions, pointColors, pointSizes, linkIndexes, linkColors, focusedPointIndex);
49
- return (_jsx(CosmosGraphProvider, { graphRef: graphRef, children: _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: {
50
- transform: `translate(${hoveredPoint?.position?.[0] ?? 0}px, ${hoveredPoint?.position?.[1] ?? 0}px) translate(-50%, 5px)`,
51
- visibility: hoveredPoint ? 'visible' : 'hidden',
52
- }, children: _jsx("div", { children: getPointTooltip?.(hoveredPoint?.index ?? 0) }) })) : null, children] }) }));
46
+ const { hoveredPoint, eventHandlers } = useHoverState(calcRelativeCoordinates);
47
+ const createGraph = useStoreWithCosmos((s) => s.cosmos.createGraph);
48
+ const destroyGraph = useStoreWithCosmos((s) => s.cosmos.destroyGraph);
49
+ const updateGraphConfig = useStoreWithCosmos((s) => s.cosmos.updateGraphConfig);
50
+ const updateGraphData = useStoreWithCosmos((s) => s.cosmos.updateGraphData);
51
+ const setFocusedPoint = useStoreWithCosmos((s) => s.cosmos.setFocusedPoint);
52
+ // Create graph instance and clean up on unmount
53
+ useEffect(() => {
54
+ if (!containerRef.current)
55
+ return;
56
+ createGraph(containerRef.current);
57
+ return () => destroyGraph();
58
+ }, [createGraph, destroyGraph]);
59
+ // Update graph config when it changes
60
+ useEffect(() => {
61
+ updateGraphConfig({
62
+ ...config,
63
+ ...eventHandlers,
64
+ });
65
+ }, [config, eventHandlers, updateGraphConfig]);
66
+ // Update graph data when props change
67
+ useEffect(() => {
68
+ updateGraphData({
69
+ pointPositions,
70
+ pointColors,
71
+ pointSizes,
72
+ linkIndexes,
73
+ linkColors,
74
+ });
75
+ }, [
76
+ updateGraphData,
77
+ pointPositions,
78
+ pointColors,
79
+ pointSizes,
80
+ linkIndexes,
81
+ linkColors,
82
+ ]);
83
+ // Update focus when it changes
84
+ useEffect(() => {
85
+ setFocusedPoint(focusedPointIndex);
86
+ }, [setFocusedPoint, focusedPointIndex]);
87
+ return (_jsxs("div", { className: "relative w-full h-full", children: [_jsx("div", { ref: containerRef, className: "absolute w-full h-full" }), renderPointTooltip ? (_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: {
88
+ transform: `translate(${hoveredPoint?.position?.[0] ?? 0}px, ${hoveredPoint?.position?.[1] ?? 0}px) translate(-50%, 5px)`,
89
+ visibility: hoveredPoint ? 'visible' : 'hidden',
90
+ }, children: _jsx("div", { children: renderPointTooltip?.(hoveredPoint?.index ?? 0) }) })) : null, children] }));
53
91
  };
54
92
  //# sourceMappingURL=CosmosGraph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CosmosGraph.js","sourceRoot":"","sources":["../src/CosmosGraph.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,EAAE,EAAE,sBAAsB,EAAC,MAAM,cAAc,CAAC;AACxD,OAAO,EAAK,MAAM,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,EAAC,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAC,MAAM,SAAS,CAAC;AA0BhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,MAAM,WAAW,GAAyB,CAAC,EAChD,MAAM,EACN,cAAc,EACd,UAAU,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAClD,MAAM,uBAAuB,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAC;IAErE,MAAM,EAAC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAC,GAAG,aAAa,CACrE,uBAAuB,CACxB,CAAC;IAEF,MAAM,mBAAmB,GAAG,cAAc,CACxC,MAAM,EACN,gBAAgB,EAChB,eAAe,CAChB,CAAC;IAEF,MAAM,QAAQ,GAAG,QAAQ,CACvB,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,UAAU,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,CAClB,CAAC;IAEF,OAAO,CACL,KAAC,mBAAmB,IAAC,QAAQ,EAAE,QAAQ,YACrC,eAAK,SAAS,EAAC,wBAAwB,aACrC,cAAK,GAAG,EAAE,YAAY,EAAE,SAAS,EAAC,wBAAwB,GAA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;QACf,cAAc;QACd,WAAW;QACX,UAAU;QACV,WAAW;QACX,UAAU;KACX,CAAC,CAAC;IAEH,+BAA+B;IAC/B,SAAS,CAAC,GAAG,EAAE;QACb,eAAe,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC,EAAE,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEzC,OAAO,CACL,eAAK,SAAS,EAAC,wBAAwB,aACrC,cAAK,GAAG,EAAE,YAAY,EAAE,SAAS,EAAC,wBAAwB,GAAG,EAC5D,kBAAkB,CAAC,CAAC,CAAC,CACpB,cACE,SAAS,EAAE,EAAE,CACX,wBAAwB,EACxB,0DAA0D,EAC1D,qFAAqF,EACrF,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAC3C,EACD,KAAK,EAAE;oBACL,SAAS,EAAE,aAAa,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OACtD,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CACjC,0BAA0B;oBAC1B,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ;iBAChD,YAED,wBAAM,kBAAkB,EAAE,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,CAAC,GAAO,GACvD,CACP,CAAC,CAAC,CAAC,IAAI,EACP,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -13,7 +13,7 @@ interface CosmosGraphControlsProps {
13
13
  }
14
14
  /**
15
15
  * A flexible control panel component for CosmosGraph that provides view controls.
16
- * Must be used within a CosmosGraph component as it relies on the CosmosGraphContext.
16
+ * Must be used within a CosmosGraph component as it relies on the graph state from the store.
17
17
  *
18
18
  * The component shows the default fit view control and allows adding custom controls as children.
19
19
  * For simulation controls, use the CosmosSimulationControls component.
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button, cn } from '@sqlrooms/ui';
3
3
  import { Maximize2 } from 'lucide-react';
4
- import { useCosmosGraph } from './CosmosGraphContext';
4
+ import { useStoreWithCosmos } from './CosmosSlice';
5
5
  /**
6
6
  * A flexible control panel component for CosmosGraph that provides view controls.
7
- * Must be used within a CosmosGraph component as it relies on the CosmosGraphContext.
7
+ * Must be used within a CosmosGraph component as it relies on the graph state from the store.
8
8
  *
9
9
  * The component shows the default fit view control and allows adding custom controls as children.
10
10
  * For simulation controls, use the CosmosSimulationControls component.
@@ -35,7 +35,7 @@ import { useCosmosGraph } from './CosmosGraphContext';
35
35
  * ```
36
36
  */
37
37
  export const CosmosGraphControls = ({ className, children }) => {
38
- const { handleFitView } = useCosmosGraph();
39
- return (_jsxs("div", { className: cn('absolute top-1 left-1 flex gap-2', className), children: [_jsx(Button, { onClick: handleFitView, variant: "outline", size: "sm", children: _jsx(Maximize2, { className: "h-4 w-4" }) }), children] }));
38
+ const { fitView } = useStoreWithCosmos((s) => s.cosmos);
39
+ return (_jsxs("div", { className: cn('absolute top-1 left-1 flex gap-2', className), children: [_jsx(Button, { onClick: fitView, variant: "outline", size: "sm", children: _jsx(Maximize2, { className: "h-4 w-4" }) }), children] }));
40
40
  };
41
41
  //# sourceMappingURL=CosmosGraphControls.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CosmosGraphControls.js","sourceRoot":"","sources":["../src/CosmosGraphControls.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,EAAE,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAepD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAE5B,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAC,EAAE,EAAE;IAC5B,MAAM,EAAC,aAAa,EAAC,GAAG,cAAc,EAAE,CAAC;IAEzC,OAAO,CACL,eAAK,SAAS,EAAE,EAAE,CAAC,kCAAkC,EAAE,SAAS,CAAC,aAC/D,KAAC,MAAM,IAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,IAAI,YACzD,KAAC,SAAS,IAAC,SAAS,EAAC,SAAS,GAAG,GAC1B,EACR,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"CosmosGraphControls.js","sourceRoot":"","sources":["../src/CosmosGraphControls.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,EAAE,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAejD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAE5B,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAC,EAAE,EAAE;IAC5B,MAAM,EAAC,OAAO,EAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAEtD,OAAO,CACL,eAAK,SAAS,EAAE,EAAE,CAAC,kCAAkC,EAAE,SAAS,CAAC,aAC/D,KAAC,MAAM,IAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,IAAI,YACnD,KAAC,SAAS,IAAC,SAAS,EAAC,SAAS,GAAG,GAC1B,EACR,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -17,7 +17,7 @@ interface CosmosSimulationControlsProps {
17
17
  }
18
18
  /**
19
19
  * A component that provides fine-grained controls for adjusting graph simulation parameters.
20
- * Must be used within a CosmosGraph component as it relies on the CosmosGraphContext.
20
+ * Uses the zustand store to access and control the graph state.
21
21
  *
22
22
  * Features:
23
23
  * - Slider controls for all simulation parameters
@@ -40,11 +40,9 @@ interface CosmosSimulationControlsProps {
40
40
  *
41
41
  * const MyGraph = () => {
42
42
  * return (
43
- * <div style={{ width: '800px', height: '600px' }}>
44
43
  * <CosmosGraph {...graphProps}>
45
44
  * <CosmosSimulationControls />
46
45
  * </CosmosGraph>
47
- * </div>
48
46
  * );
49
47
  * };
50
48
  * ```
@@ -55,12 +53,10 @@ interface CosmosSimulationControlsProps {
55
53
  *
56
54
  * const MyGraph = () => {
57
55
  * return (
58
- * <div style={{ width: '800px', height: '600px' }}>
59
56
  * <CosmosGraph {...graphProps}>
60
57
  * <CosmosGraphControls className="absolute top-4 left-4" />
61
58
  * <CosmosSimulationControls className="absolute top-4 right-4" />
62
59
  * </CosmosGraph>
63
- * </div>
64
60
  * );
65
61
  * };
66
62
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"CosmosSimulationControls.d.ts","sourceRoot":"","sources":["../src/CosmosSimulationControls.tsx"],"names":[],"mappings":"AASA,OAAO,EAAC,EAAE,EAAW,MAAM,OAAO,CAAC;AAMnC;;GAEG;AACH,UAAU,6BAA6B;IACrC;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA8DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,eAAO,MAAM,wBAAwB,EAAE,EAAE,CAAC,6BAA6B,CA4GtE,CAAC"}
1
+ {"version":3,"file":"CosmosSimulationControls.d.ts","sourceRoot":"","sources":["../src/CosmosSimulationControls.tsx"],"names":[],"mappings":"AASA,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AAKzB;;GAEG;AACH,UAAU,6BAA6B;IACrC;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAuDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,wBAAwB,EAAE,EAAE,CAAC,6BAA6B,CA+FtE,CAAC"}
@@ -1,9 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn, Slider, Label, Tooltip, TooltipContent, TooltipTrigger, Button, } from '@sqlrooms/ui';
3
- import { useState } from 'react';
4
- import { useCosmosGraph } from './CosmosGraphContext';
5
3
  import { Info, Pause, Play, Wind } from 'lucide-react';
6
- import { CosmosSimulationConfigSchema } from './config';
4
+ import { useStoreWithCosmos } from './CosmosSlice';
5
+ import { CosmosSliceConfig } from './CosmosSliceConfig';
7
6
  /**
8
7
  * Configuration for each simulation parameter slider.
9
8
  * These values define the range and step size for each parameter.
@@ -17,7 +16,6 @@ const simulationSliders = [
17
16
  min: 0,
18
17
  max: 0.5,
19
18
  step: 0.01,
20
- default: 0.25,
21
19
  },
22
20
  {
23
21
  key: 'simulationRepulsion',
@@ -25,7 +23,6 @@ const simulationSliders = [
25
23
  min: 0,
26
24
  max: 2,
27
25
  step: 0.01,
28
- default: 1.0,
29
26
  },
30
27
  {
31
28
  key: 'simulationLinkSpring',
@@ -33,7 +30,6 @@ const simulationSliders = [
33
30
  min: 0,
34
31
  max: 2,
35
32
  step: 0.01,
36
- default: 1,
37
33
  },
38
34
  {
39
35
  key: 'simulationLinkDistance',
@@ -41,7 +37,6 @@ const simulationSliders = [
41
37
  min: 1,
42
38
  max: 20,
43
39
  step: 1,
44
- default: 10,
45
40
  },
46
41
  {
47
42
  key: 'simulationFriction',
@@ -49,7 +44,6 @@ const simulationSliders = [
49
44
  min: 0,
50
45
  max: 1,
51
46
  step: 0.01,
52
- default: 0.85,
53
47
  },
54
48
  {
55
49
  key: 'simulationDecay',
@@ -57,12 +51,11 @@ const simulationSliders = [
57
51
  min: 100,
58
52
  max: 10000,
59
53
  step: 100,
60
- default: 1000,
61
54
  },
62
55
  ];
63
56
  /**
64
57
  * A component that provides fine-grained controls for adjusting graph simulation parameters.
65
- * Must be used within a CosmosGraph component as it relies on the CosmosGraphContext.
58
+ * Uses the zustand store to access and control the graph state.
66
59
  *
67
60
  * Features:
68
61
  * - Slider controls for all simulation parameters
@@ -85,11 +78,9 @@ const simulationSliders = [
85
78
  *
86
79
  * const MyGraph = () => {
87
80
  * return (
88
- * <div style={{ width: '800px', height: '600px' }}>
89
81
  * <CosmosGraph {...graphProps}>
90
82
  * <CosmosSimulationControls />
91
83
  * </CosmosGraph>
92
- * </div>
93
84
  * );
94
85
  * };
95
86
  * ```
@@ -100,12 +91,10 @@ const simulationSliders = [
100
91
  *
101
92
  * const MyGraph = () => {
102
93
  * return (
103
- * <div style={{ width: '800px', height: '600px' }}>
104
94
  * <CosmosGraph {...graphProps}>
105
95
  * <CosmosGraphControls className="absolute top-4 left-4" />
106
96
  * <CosmosSimulationControls className="absolute top-4 right-4" />
107
97
  * </CosmosGraph>
108
- * </div>
109
98
  * );
110
99
  * };
111
100
  * ```
@@ -120,21 +109,11 @@ const simulationSliders = [
120
109
  * ```
121
110
  */
122
111
  export const CosmosSimulationControls = ({ className, }) => {
123
- const { graphRef, isSimulationRunning, handleToggleSimulation, handleStartWithEnergy, } = useCosmosGraph();
124
- const [values, setValues] = useState(() => Object.fromEntries(simulationSliders.map(({ key, default: defaultValue }) => [
125
- key,
126
- defaultValue,
127
- ])));
112
+ const { isSimulationRunning, toggleSimulation, startWithEnergy, updateSimulationConfig, } = useStoreWithCosmos((s) => s.cosmos);
113
+ const config = useStoreWithCosmos((s) => s.project.config.cosmos);
128
114
  const handleParameterChange = (paramKey, value) => {
129
- if (!graphRef?.current)
130
- return;
131
- const newValues = { ...values, [paramKey]: value[0] };
132
- setValues(newValues);
133
- const config = {
134
- [paramKey]: value[0],
135
- };
136
- graphRef.current.setConfig(config);
115
+ updateSimulationConfig({ [paramKey]: value[0] });
137
116
  };
138
- return (_jsxs("div", { className: cn('absolute top-1 right-1 w-48 bg-card/90 dark:bg-card/90 rounded-lg shadow-lg p-3 space-y-4', className), children: [_jsxs("div", { className: "flex gap-2", children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { onClick: handleToggleSimulation, variant: "outline", size: "sm", className: "flex-1", children: isSimulationRunning ? (_jsx(Pause, { className: "h-4 w-4" })) : (_jsx(Play, { className: "h-4 w-4" })) }) }), _jsx(TooltipContent, { side: "bottom", children: isSimulationRunning ? 'Pause simulation' : 'Start simulation' })] }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { onClick: handleStartWithEnergy, variant: "outline", size: "sm", className: "flex-1", children: _jsx(Wind, { className: "h-4 w-4" }) }) }), _jsx(TooltipContent, { side: "bottom", children: "Push energy into simulation" })] })] }), simulationSliders.map(({ key, label, min, max, step }) => (_jsxs("div", { className: "space-y-2", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs(Label, { htmlFor: key, className: "text-xs font-medium flex items-center gap-1 cursor-help", children: [label, _jsx(Info, { className: "w-3 h-3 text-muted-foreground" })] }) }), _jsx(TooltipContent, { side: "left", className: "max-w-[200px]", children: CosmosSimulationConfigSchema.shape[key].description })] }), _jsx("span", { className: "text-xs tabular-nums text-muted-foreground", children: values[key].toFixed(2) })] }), _jsx(Slider, { id: key, min: min, max: max, step: step, value: [values[key]], onValueChange: (value) => handleParameterChange(key, value), className: "w-full" })] }, key)))] }));
117
+ return (_jsxs("div", { className: cn('w-48 bg-card/90 dark:bg-card/90 rounded-lg shadow-lg p-3 space-y-4', className), children: [_jsxs("div", { className: "flex gap-2", children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { onClick: toggleSimulation, variant: "outline", size: "sm", className: "flex-1", children: isSimulationRunning ? (_jsx(Pause, { className: "h-4 w-4" })) : (_jsx(Play, { className: "h-4 w-4" })) }) }), _jsx(TooltipContent, { side: "bottom", children: isSimulationRunning ? 'Pause simulation' : 'Start simulation' })] }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { onClick: startWithEnergy, variant: "outline", size: "sm", className: "flex-1", children: _jsx(Wind, { className: "h-4 w-4" }) }) }), _jsx(TooltipContent, { side: "bottom", children: "Push energy into simulation" })] })] }), simulationSliders.map(({ key, label, min, max, step }) => (_jsxs("div", { className: "space-y-2", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs(Label, { htmlFor: key, className: "text-xs font-medium flex items-center gap-1 cursor-help", children: [_jsx(Info, { className: "w-3 h-3 text-muted-foreground/50" }), label] }) }), _jsx(TooltipContent, { side: "left", className: "max-w-[200px]", children: CosmosSliceConfig.shape.cosmos.shape[key].description })] }), _jsx("span", { className: "text-xs tabular-nums text-muted-foreground", children: config[key].toFixed(2) })] }), _jsx(Slider, { id: key, min: min, max: max, step: step, value: [config[key]], onValueChange: (value) => handleParameterChange(key, value), className: "w-full" })] }, key)))] }));
139
118
  };
140
119
  //# sourceMappingURL=CosmosSimulationControls.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CosmosSimulationControls.js","sourceRoot":"","sources":["../src/CosmosSimulationControls.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,EAAE,EACF,MAAM,EACN,KAAK,EACL,OAAO,EACP,cAAc,EACd,cAAc,EACd,MAAM,GACP,MAAM,cAAc,CAAC;AACtB,OAAO,EAAK,QAAQ,EAAC,MAAM,OAAO,CAAC;AACnC,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAErD,OAAO,EAAC,4BAA4B,EAAC,MAAM,UAAU,CAAC;AAmBtD;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG;IACxB;QACE,GAAG,EAAE,mBAAmB;QACxB,KAAK,EAAE,SAAS;QAChB,GAA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S,EACjB,IAAI,EAAC,IAAI,EACT,SAAS,EAAC,QAAQ,YAElB,KAAC,IAAI,IAAC,SAAS,EAAC,SAAS,GAAG,GACrB,GACM,EACjB,KAAC,cAAc,IAAC,IAAI,EAAC,QAAQ,4CAEZ,IACT,IACN,EACL,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAC,EAAE,EAAE,CAAC,CACvD,eAAe,SAAS,EAAC,WAAW,aAClC,eAAK,SAAS,EAAC,mCAAmC,aAChD,MAAC,OAAO,eACN,KAAC,cAAc,IAAC,OAAO,kBACrB,MAAC,KAAK,IACJ,OAAO,EAAE,GAAG,EACZ,SAAS,EAAC,yDAAyD,aAElE,KAAK,EACN,KAAC,IAAI,IAAC,SAAS,EAAC,+BAA+B,GAAG,IAC5C,GACO,EACjB,KAAC,cAAc,IAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAC,eAAe,YAClD,4BAA4B,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,WAAW,GACrC,IACT,EACV,eAAM,SAAS,EAAC,4CAA4C,YACzD,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAClB,IACH,EACN,KAAC,MAAM,IACL,EAAE,EAAE,GAAG,EACP,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EACpB,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,qBAAqB,CAAC,GAAG,EAAE,KAAK,CAAC,EAC3D,SAAS,EAAC,QAAQ,GAClB,KA5BM,GAAG,CA6BP,CACP,CAAC,IACE,CACP,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"CosmosSimulationControls.js","sourceRoot":"","sources":["../src/CosmosSimulationControls.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,EA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AC,SAAS,GAAG,GACrB,GACM,EACjB,KAAC,cAAc,IAAC,IAAI,EAAC,QAAQ,4CAEZ,IACT,IACN,EACL,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAC,EAAE,EAAE,CAAC,CACvD,eAAe,SAAS,EAAC,WAAW,aAClC,eAAK,SAAS,EAAC,mCAAmC,aAChD,MAAC,OAAO,eACN,KAAC,cAAc,IAAC,OAAO,kBACrB,MAAC,KAAK,IACJ,OAAO,EAAE,GAAG,EACZ,SAAS,EAAC,yDAAyD,aAEnE,KAAC,IAAI,IAAC,SAAS,EAAC,kCAAkC,GAAG,EACpD,KAAK,IACA,GACO,EACjB,KAAC,cAAc,IAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAC,eAAe,YAClD,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,WAAW,GACvC,IACT,EACV,eAAM,SAAS,EAAC,4CAA4C,YACzD,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAClB,IACH,EACN,KAAC,MAAM,IACL,EAAE,EAAE,GAAG,EACP,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EACpB,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,qBAAqB,CAAC,GAAG,EAAE,KAAK,CAAC,EAC3D,SAAS,EAAC,QAAQ,GAClB,KA5BM,GAAG,CA6BP,CACP,CAAC,IACE,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * @fileoverview Cosmos graph visualization state management using Zustand.
3
+ * This module provides state management and control functions for the Cosmos graph visualization.
4
+ */
5
+ import { Graph, GraphConfigInterface } from '@cosmograph/cosmos';
6
+ import { type ProjectState } from '@sqlrooms/project-builder';
7
+ import type { BaseProjectConfig } from '@sqlrooms/project-config';
8
+ import type { StateCreator } from 'zustand';
9
+ import { CosmosSliceConfig } from './CosmosSliceConfig';
10
+ /**
11
+ * Core state interface for the Cosmos graph visualization.
12
+ * Contains the graph instance, simulation state, and all control functions.
13
+ */
14
+ export type CosmosSliceState = {
15
+ cosmos: {
16
+ /** The current graph instance */
17
+ graph: Graph | null;
18
+ /** Whether the physics simulation is currently running */
19
+ isSimulationRunning: boolean;
20
+ /** Creates a new graph instance in the specified container */
21
+ createGraph: (container: HTMLDivElement) => void;
22
+ /** Toggles the physics simulation on/off */
23
+ toggleSimulation: () => void;
24
+ /** Adjusts the view to fit all nodes */
25
+ fitView: () => void;
26
+ /** Starts the simulation with initial energy */
27
+ startWithEnergy: () => void;
28
+ /** Cleans up and removes the current graph */
29
+ destroyGraph: () => void;
30
+ /** Updates the simulation configuration parameters */
31
+ updateSimulationConfig: (config: Partial<CosmosSliceConfig['cosmos']>) => void;
32
+ /** Updates the graph's visual configuration */
33
+ updateGraphConfig: (config: Partial<GraphConfigInterface>) => void;
34
+ /** Updates the graph's data (points, links, colors, etc.) */
35
+ updateGraphData: (data: {
36
+ pointPositions?: Float32Array;
37
+ pointColors?: Float32Array;
38
+ pointSizes?: Float32Array;
39
+ linkIndexes?: Float32Array;
40
+ linkColors?: Float32Array;
41
+ }) => void;
42
+ /** Sets the currently focused point by its index */
43
+ setFocusedPoint: (index: number | undefined) => void;
44
+ /** Sets the zoom level of the graph view */
45
+ setZoomLevel: (level: number) => void;
46
+ };
47
+ };
48
+ /**
49
+ * Combined type representing the full project state including Cosmos functionality.
50
+ * Merges the base project state with Cosmos-specific state and configuration.
51
+ */
52
+ export type ProjectStateWithCosmos = ProjectState<BaseProjectConfig & CosmosSliceConfig> & CosmosSliceState;
53
+ /**
54
+ * Creates a Zustand slice for managing Cosmos graph state.
55
+ * This slice handles graph creation, destruction, configuration, and data updates.
56
+ *
57
+ * @returns A state creator function for the Cosmos slice
58
+ */
59
+ export declare function createCosmosSlice(): StateCreator<CosmosSliceState>;
60
+ /**
61
+ * Hook to access the Cosmos store with proper typing.
62
+ * Provides type-safe access to the combined project and Cosmos state.
63
+ *
64
+ * @template T The type of the selected state slice
65
+ * @param selector A function that selects a portion of the state
66
+ * @returns The selected state portion
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const graph = useStoreWithCosmos(state => state.cosmos.graph);
71
+ * const isRunning = useStoreWithCosmos(state => state.cosmos.isSimulationRunning);
72
+ * ```
73
+ */
74
+ export declare function useStoreWithCosmos<T>(selector: (state: ProjectStateWithCosmos) => T): T;
75
+ //# sourceMappingURL=CosmosSlice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosSlice.d.ts","sourceRoot":"","sources":["../src/CosmosSlice.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,KAAK,EAAE,oBAAoB,EAAC,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAGtD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE;QACN,iCAAiC;QACjC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;QACpB,0DAA0D;QAC1D,mBAAmB,EAAE,OAAO,CAAC;QAC7B,8DAA8D;QAC9D,WAAW,EAAE,CAAC,SAAS,EAAE,cAAc,KAAK,IAAI,CAAC;QACjD,4CAA4C;QAC5C,gBAAgB,EAAE,MAAM,IAAI,CAAC;QAC7B,wCAAwC;QACxC,OAAO,EAAE,MAAM,IAAI,CAAC;QACpB,gDAAgD;QAChD,eAAe,EAAE,MAAM,IAAI,CAAC;QAC5B,8CAA8C;QAC9C,YAAY,EAAE,MAAM,IAAI,CAAC;QACzB,sDAAsD;QACtD,sBAAsB,EAAE,CACtB,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,KACzC,IAAI,CAAC;QACV,+CAA+C;QAC/C,iBAAiB,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;QACnE,6DAA6D;QAC7D,eAAe,EAAE,CAAC,IAAI,EAAE;YACtB,cAAc,CAAC,EAAE,YAAY,CAAC;YAC9B,WAAW,CAAC,EAAE,YAAY,CAAC;YAC3B,UAAU,CAAC,EAAE,YAAY,CAAC;YAC1B,WAAW,CAAC,EAAE,YAAY,CAAC;YAC3B,UAAU,CAAC,EAAE,YAAY,CAAC;SAC3B,KAAK,IAAI,CAAC;QACX,oDAAoD;QACpD,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;QACrD,4CAA4C;QAC5C,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;KACvC,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,YAAY,CAC/C,iBAAiB,GAAG,iBAAiB,CACtC,GACC,gBAAgB,CAAC;AAEnB;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,YAAY,CAAC,gBAAgB,CAAC,CAoJlE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,QAAQ,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,CAAC,GAC7C,CAAC,CAMH"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * @fileoverview Cosmos graph visualization state management using Zustand.
3
+ * This module provides state management and control functions for the Cosmos graph visualization.
4
+ */
5
+ import { Graph } from '@cosmograph/cosmos';
6
+ import { createSlice, useBaseProjectStore, } from '@sqlrooms/project-builder';
7
+ import { produce } from 'immer';
8
+ /**
9
+ * Creates a Zustand slice for managing Cosmos graph state.
10
+ * This slice handles graph creation, destruction, configuration, and data updates.
11
+ *
12
+ * @returns A state creator function for the Cosmos slice
13
+ */
14
+ export function createCosmosSlice() {
15
+ return createSlice((set, get) => ({
16
+ cosmos: {
17
+ graph: null,
18
+ isSimulationRunning: true,
19
+ createGraph: (container) => {
20
+ // Clean up old graph if it exists
21
+ const oldGraph = get().cosmos.graph;
22
+ if (oldGraph) {
23
+ oldGraph.pause();
24
+ oldGraph.destroy();
25
+ }
26
+ // Create and configure new graph
27
+ const graph = new Graph(container);
28
+ const config = get().project.config.cosmos;
29
+ graph.setConfig(config);
30
+ graph.start();
31
+ set((state) => produce(state, (draft) => {
32
+ draft.cosmos.graph = graph;
33
+ }));
34
+ },
35
+ toggleSimulation: () => {
36
+ const { graph } = get().cosmos;
37
+ if (!graph)
38
+ return;
39
+ if (graph.isSimulationRunning) {
40
+ graph.pause();
41
+ set((state) => produce(state, (draft) => {
42
+ draft.cosmos.isSimulationRunning = false;
43
+ }));
44
+ }
45
+ else {
46
+ graph.restart();
47
+ set((state) => produce(state, (draft) => {
48
+ draft.cosmos.isSimulationRunning = true;
49
+ }));
50
+ }
51
+ },
52
+ fitView: () => {
53
+ const { graph } = get().cosmos;
54
+ if (!graph)
55
+ return;
56
+ graph.fitView();
57
+ },
58
+ startWithEnergy: () => {
59
+ const { graph } = get().cosmos;
60
+ if (!graph)
61
+ return;
62
+ graph.start(1);
63
+ set((state) => produce(state, (draft) => {
64
+ draft.cosmos.isSimulationRunning = true;
65
+ }));
66
+ },
67
+ updateSimulationConfig: (config) => {
68
+ const { graph } = get().cosmos;
69
+ set((state) => produce(state, (draft) => {
70
+ Object.assign(draft.project.config.cosmos, config);
71
+ if (graph) {
72
+ graph.setConfig(draft.project.config.cosmos);
73
+ }
74
+ }));
75
+ },
76
+ updateGraphConfig: (config) => {
77
+ const { graph } = get().cosmos;
78
+ set((state) => produce(state, (draft) => {
79
+ Object.assign(draft.project.config.cosmos, config);
80
+ if (graph) {
81
+ graph.setConfig(draft.project.config.cosmos);
82
+ }
83
+ }));
84
+ },
85
+ updateGraphData: (data) => {
86
+ const { graph } = get().cosmos;
87
+ if (!graph)
88
+ return;
89
+ if (data.pointPositions) {
90
+ graph.setPointPositions(data.pointPositions);
91
+ }
92
+ if (data.pointColors) {
93
+ graph.setPointColors(data.pointColors);
94
+ }
95
+ if (data.pointSizes) {
96
+ graph.setPointSizes(data.pointSizes);
97
+ }
98
+ if (data.linkIndexes) {
99
+ graph.setLinks(data.linkIndexes);
100
+ }
101
+ if (data.linkColors) {
102
+ graph.setLinkColors(data.linkColors);
103
+ }
104
+ graph.render();
105
+ },
106
+ setFocusedPoint: (index) => {
107
+ const { graph } = get().cosmos;
108
+ if (!graph)
109
+ return;
110
+ graph.setFocusedPointByIndex(index);
111
+ },
112
+ setZoomLevel: (level) => {
113
+ const { graph } = get().cosmos;
114
+ if (!graph)
115
+ return;
116
+ graph.setZoomLevel(level);
117
+ },
118
+ destroyGraph: () => {
119
+ const { graph } = get().cosmos;
120
+ if (!graph)
121
+ return;
122
+ // TODO: this should be happening in cosmos
123
+ if (graph.store.div?.firstChild) {
124
+ graph.store.div.innerHTML = '';
125
+ }
126
+ graph.pause();
127
+ graph.destroy();
128
+ set((state) => produce(state, (draft) => {
129
+ draft.cosmos.graph = null;
130
+ draft.cosmos.isSimulationRunning = false;
131
+ }));
132
+ },
133
+ },
134
+ }));
135
+ }
136
+ /**
137
+ * Hook to access the Cosmos store with proper typing.
138
+ * Provides type-safe access to the combined project and Cosmos state.
139
+ *
140
+ * @template T The type of the selected state slice
141
+ * @param selector A function that selects a portion of the state
142
+ * @returns The selected state portion
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * const graph = useStoreWithCosmos(state => state.cosmos.graph);
147
+ * const isRunning = useStoreWithCosmos(state => state.cosmos.isSimulationRunning);
148
+ * ```
149
+ */
150
+ export function useStoreWithCosmos(selector) {
151
+ return useBaseProjectStore((state) => selector(state));
152
+ }
153
+ //# sourceMappingURL=CosmosSlice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosSlice.js","sourceRoot":"","sources":["../src/CosmosSlice.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,KAAK,EAAuB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EACL,WAAW,EACX,mBAAmB,GAEpB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAoD9B;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,WAAW,CAChB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QACb,MAAM,EAAE;YACN,KAAK,EAAE,IAAI;YACX,mBAAmB,EAAE,IAAI;YAEzB,WAAW,EAAE,CAAC,SAAyB,EAAE,EAAE;gBACzC,kCAAkC;gBAClC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;gBACpC,IAAI,QAAQ,EAAE,CAAC;oBACb,QAAQ,CAAC,KAAK,EAAE,CAAC;oBACjB,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACrB,CAAC;gBAED,iCAAiC;gBACjC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;gBACnC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;gBAC3C,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;gBACxB,KAAK,CAAC,KAAK,EAAE,CAAC;gBAEd,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACZ,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;oBACvB,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;gBAC7B,CAAC,CAAC,CACH,CAAC;YACJ,CAAC;YAED,gBAAgB,EAAE,GAAG,EAAE;gBAC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