Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

feat: optimized(ish) nodes

dextmorgn2d705929601d
diff --git a/flowsint-api/app/api/routes/sketches.py b/flowsint-api/app/api/routes/sketches.py
index 414f8b03..1ed4394f 100644
--- a/flowsint-api/app/api/routes/sketches.py
+++ b/flowsint-api/app/api/routes/sketches.py
@@ -29,7 +29,7 @@ async def get_sketch_nodes(sketch_id: str):
MATCH (n)
WHERE n.sketch_id = $sketch_id
RETURN elementId(n) as id, labels(n) as labels, properties(n) as data
- LIMIT 500
+ LIMIT 5000
"""
nodes_result = neo4j_connection.query(nodes_query, parameters={"sketch_id": sketch_id})
diff --git a/flowsint-api/app/core/celery.py b/flowsint-api/app/core/celery.py
index 3c584f5e..430000ba 100644
--- a/flowsint-api/app/core/celery.py
+++ b/flowsint-api/app/core/celery.py
@@ -2,7 +2,7 @@ from celery import Celery
celery_app = Celery(
"flowsint",
- broker="redis://redis:6379/0",
- backend="redis://redis:6379/0",
+ broker="redis://127.0.0.1:6379/0",
+ backend="redis://127.0.0.1:6379/0",
include=["app.tasks.transform"]
)
\ No newline at end of file
diff --git a/flowsint-web/package.json b/flowsint-web/package.json
index 30904753..26f4f50d 100644
--- a/flowsint-web/package.json
+++ b/flowsint-web/package.json
@@ -96,6 +96,7 @@
"tailwind-merge": "^3.0.1",
"tailwindcss": "^4.0.3",
"tailwindcss-animate": "^1.0.7",
+ "three": "^0.176.0",
"three-spritetext": "^1.9.6",
"usehooks-ts": "^3.1.1",
"uuid": "^11.1.0",
diff --git a/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/2d-graph.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/2d-graph.tsx
index bf357124..fdd25ef1 100644
--- a/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/2d-graph.tsx
+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/2d-graph.tsx
@@ -1,6 +1,6 @@
"use client"
-import { memo, useCallback, useEffect, useMemo } from "react"
+import { memo, useCallback, useEffect } from "react"
import dynamic from "next/dynamic"
import { Button } from "@/components/ui/button"
import Loader from "@/components/loader"
@@ -8,16 +8,17 @@ import NewActions from "@/components/sketches/new-actions"
import { PlusIcon } from "lucide-react"
import { useSketchStore } from "@/store/sketch-store"
import { shallow } from "zustand/shallow"
-import { ItemType, useNodesDisplaySettings } from "@/store/node-display-settings"
+import { useNodesDisplaySettings } from "@/store/node-display-settings"
import type { NodeData, EdgeData } from "@/types"
import { useGraphControls } from "@/store/graph-controls-store"
+
// @ts-ignore
import { forceCollide } from 'd3'
-const ARROW_COLOR = "rgba(136, 136, 136, 0.21)";
-const LINE_COLOR = "rgba(136, 136, 136, 0.21)";
-const LINE_WIDTH = 0.4;
-const ARROW_HEAD_LENGTH = 1;
+// const ARROW_COLOR = "rgba(136, 136, 136, 0.21)";
+// const LINE_COLOR = "rgba(136, 136, 136, 0.21)";
+// const LINE_WIDTH = 0.4;
+// const ARROW_HEAD_LENGTH = 1;
const ForceGraph2D = dynamic(() => import("react-force-graph-2d").then((mod) => mod), {
ssr: false,
@@ -62,75 +63,70 @@ const stateSelector = (state: {
const Graph = ({ data, isLoading, width, height }: GraphProps) => {
const colors = useNodesDisplaySettings(c => c.colors)
- const getIcon = useNodesDisplaySettings(c => c.getIcon)
- const getSize = useNodesDisplaySettings(c => c.getSize)
const setActions = useGraphControls((s) => s.setActions)
-
const {
currentNode,
selectedNodes,
toggleNodeSelection,
clearSelectedNodes,
- addNode,
setNodes,
setEdges,
nodes,
edges,
isSelected,
- isCurrent,
} = useSketchStore(
stateSelector,
shallow,
)
- // Link canvas object rendering function
- const linkCanvaObject = useCallback((link: any, ctx: any) => {
- const start = link.target as any;
- const end = link.source as any;
- if (
- !start || !end ||
- typeof start.x !== "number" || typeof start.y !== "number" ||
- typeof end.x !== "number" || typeof end.y !== "number"
- ) return;
- const dx = end.x - start.x;
- const dy = end.y - start.y;
- const angle = Math.atan2(dy, dx);
- const targetRadius = getSize(end.type) / 10;
- const tx = end.x - Math.cos(angle) * targetRadius;
- const ty = end.y - Math.sin(angle) * targetRadius;
- ctx.strokeStyle = LINE_COLOR;
- ctx.lineWidth = LINE_WIDTH;
- ctx.beginPath();
- ctx.moveTo(start.x, start.y);
- ctx.lineTo(tx, ty);
- ctx.stroke();
- ctx.fillStyle = ARROW_COLOR;
- ctx.beginPath();
- ctx.moveTo(tx, ty);
- ctx.lineTo(
- tx - ARROW_HEAD_LENGTH * Math.cos(angle - Math.PI / 10),
- ty - ARROW_HEAD_LENGTH * Math.sin(angle - Math.PI / 10)
- );
- ctx.lineTo(
- tx - ARROW_HEAD_LENGTH * Math.cos(angle + Math.PI / 10),
- ty - ARROW_HEAD_LENGTH * Math.sin(angle + Math.PI / 10)
- );
- ctx.closePath();
- ctx.fill();
- if (link.caption) {
- const midX = (start.x + tx) / 2;
- const midY = (start.y + ty) / 2;
- ctx.save();
- ctx.translate(midX, midY);
- ctx.rotate(angle);
- ctx.fillStyle = "#333";
- ctx.font = "1px Sans-Serif";
- ctx.textAlign = "center";
- ctx.textBaseline = "middle";
- ctx.fillText(link.caption, 0, -1);
- ctx.restore();
- }
- }, [getSize])
+ // // Link canvas object rendering function
+ // const linkCanvaObject = useCallback((link: any, ctx: any) => {
+ // const start = link.target as any;
+ // const end = link.source as any;
+ // if (
+ // !start || !end ||
+ // typeof start.x !== "number" || typeof start.y !== "number" ||
+ // typeof end.x !== "number" || typeof end.y !== "number"
+ // ) return;
+ // const dx = end.x - start.x;
+ // const dy = end.y - start.y;
+ // const angle = Math.atan2(dy, dx);
+ // const targetRadius = getSize(end.type) / 10;
+ // const tx = end.x - Math.cos(angle) * targetRadius;
+ // const ty = end.y - Math.sin(angle) * targetRadius;
+ // ctx.strokeStyle = LINE_COLOR;
+ // ctx.lineWidth = LINE_WIDTH;
+ // ctx.beginPath();
+ // ctx.moveTo(start.x, start.y);
+ // ctx.lineTo(tx, ty);
+ // ctx.stroke();
+ // ctx.fillStyle = ARROW_COLOR;
+ // ctx.beginPath();
+ // ctx.moveTo(tx, ty);
+ // ctx.lineTo(
+ // tx - ARROW_HEAD_LENGTH * Math.cos(angle - Math.PI / 10),
+ // ty - ARROW_HEAD_LENGTH * Math.sin(angle - Math.PI / 10)
+ // );
+ // ctx.lineTo(
+ // tx - ARROW_HEAD_LENGTH * Math.cos(angle + Math.PI / 10),
+ // ty - ARROW_HEAD_LENGTH * Math.sin(angle + Math.PI / 10)
+ // );
+ // ctx.closePath();
+ // ctx.fill();
+ // if (link.caption) {
+ // const midX = (start.x + tx) / 2;
+ // const midY = (start.y + ty) / 2;
+ // ctx.save();
+ // ctx.translate(midX, midY);
+ // ctx.rotate(angle);
+ // ctx.fillStyle = "#333";
+ // ctx.font = "1px Sans-Serif";
+ // ctx.textAlign = "center";
+ // ctx.textBaseline = "middle";
+ // ctx.fillText(link.caption, 0, -1);
+ // ctx.restore();
+ // }
+ // }, [getSize])
// Setup graph instance when it's available - using callback approach
const handleGraphRef = useCallback((graphInstance: any) => {
@@ -170,6 +166,7 @@ const Graph = ({ data, isLoading, width, height }: GraphProps) => {
if (isLoading) return;
if (data?.nds) setNodes(data.nds);
if (data?.rls) setEdges(data.rls);
+ console.log(data.rls)
}, [data?.nds, data?.rls, isLoading, setNodes, setEdges]);
// Node click handler
@@ -191,70 +188,51 @@ const Graph = ({ data, isLoading, width, height }: GraphProps) => {
clearSelectedNodes();
}, [clearSelectedNodes]);
- // Node canvas object rendering function
- const nodeCanvasObject = useCallback((node: NodeData, ctx: CanvasRenderingContext2D, globalScale: number) => {
+ const nodeCanvasObject = useCallback((node: any, ctx: CanvasRenderingContext2D, globalScale: number) => {
+ const label = node.label || '';
+ const fontSize = 12 / globalScale;
const isNodeSelected = isSelected(node.id);
- const isNodeCurrent = isCurrent(node.id);
+ const radius = isNodeSelected ? 4 : 4;
const color = colors[node.type as keyof typeof colors] || "#9FAAB8";
- const nodeSize = getSize(node?.type as ItemType) || 25;
- const radius = nodeSize / 10 + (isNodeSelected ? 0.5 : 0);
- const fontSize = globalScale * 0.2462;
-
- // Draw node circle
- ctx.font = `${fontSize}px Sans-Serif`;
- ctx.fillStyle = color;
ctx.beginPath();
- ctx.arc(node.x!, node.y!, radius, 0, 2 * Math.PI, false);
- ctx.fill();
-
- // Draw node outline
- ctx.beginPath();
- ctx.arc(node.x!, node.y!, radius, 0, 2 * Math.PI, false);
- ctx.strokeStyle = color || "black";
- ctx.lineWidth = isNodeSelected ? 0.5 : 0.2;
- ctx.stroke();
- ctx.shadowColor = 'rgba(0, 0, 0, 0.2)';
- ctx.shadowBlur = 1;
- ctx.shadowOffsetX = 1;
- ctx.shadowOffsetY = 2;
-
+ ctx.arc(node.x, node.y, radius, 0, 2 * Math.PI, false);
ctx.fillStyle = color;
- ctx.beginPath();
- ctx.arc(node.x!, node.y!, radius, 0, 2 * Math.PI, false);
ctx.fill();
- // Draw node icon
- const size = nodeSize / 10;
- ctx.drawImage(getIcon(node.type as ItemType), node.x! - size / 2, node.y! - size / 2, size, size);
- // Draw selection highlight
- if (isNodeSelected) {
- ctx.beginPath();
- ctx.arc(node.x!, node.y!, radius + 0.8, 0, 2 * Math.PI, false);
- ctx.strokeStyle = '#FFCC00';
- ctx.lineWidth = 0.3;
- ctx.stroke();
+ // Aucune ombre pour meilleures perfs
+ ctx.shadowColor = 'transparent';
+ ctx.shadowBlur = 0;
- // Draw node label when selected
- if (node.label) {
- ctx.fillStyle = '#FFFFFF';
- ctx.font = `${fontSize}px Sans-Serif`;
- ctx.textAlign = 'center';
- ctx.fillText(node.label, node.x!, node.y! + radius + 4.5);
- }
+ // Pas de texte si trop zoomé
+ if (globalScale > 0.3 && isNodeSelected) {
+ ctx.font = `${fontSize}px sans-serif`;
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'top';
+ ctx.fillStyle = '#fff';
+ ctx.fillText(label, node.x, node.y + radius + 2);
}
+ }, [isSelected, nodeColor]);
+
+ // // ✏️ Dessin des liens (optionnel si peu nombreux)
+ // const linkCanvasObject = useCallback((link: any, ctx: CanvasRenderingContext2D, globalScale: number) => {
+ // const start = link.source;
+ // const end = link.target;
+
+ // if (!start || !end || !('x' in start) || !('x' in end)) return;
+
+ // const x1 = start.x;
+ // const y1 = start.y;
+ // const x2 = end.x;
+ // const y2 = end.y;
+
+ // ctx.beginPath();
+ // ctx.moveTo(x1, y1);
+ // ctx.lineTo(x2, y2);
+ // ctx.strokeStyle = '#999';
+ // ctx.lineWidth = 1;
+ // ctx.stroke();
+ // }, []);
- // Draw current node indicator
- if (isNodeCurrent) {
- ctx.beginPath();
- ctx.arc(node.x!, node.y!, radius + 1.5, 0, 2 * Math.PI, false);
- ctx.strokeStyle = 'white';
- ctx.lineWidth = 0.2;
- ctx.setLineDash([0.5, 0.5]);
- ctx.stroke();
- ctx.setLineDash([]);
- }
- ctx.save(); // Sauvegarde l'état du contexte
- }, [colors, getIcon, getSize, isSelected, isCurrent]);
// Render loading state
if (isLoading) {
@@ -266,7 +244,7 @@ const Graph = ({ data, isLoading, width, height }: GraphProps) => {
return (
<div className="flex relative gap-3 h-full flex-col w-full items-center justify-center">
Your nodes will be displayed here.
- <NewActions addNodes={addNode}>
+ <NewActions>
<Button className="bg-gradient-to-r from-primary to-primary/80 hover:from-primary/90 hover:to-primary transition-all duration-300 px-6 py-2 text-white border-none">
Add your first item <PlusIcon />
</Button>
@@ -298,7 +276,7 @@ const Graph = ({ data, isLoading, width, height }: GraphProps) => {
height={height}
// @ts-ignore
nodeColor={nodeColor}
- linkCanvasObject={linkCanvaObject}
+ // linkCanvasObject={linkCanvaObject}
linkWidth={link => link ? 2 : 1}
// @ts-ignore
onNodeClick={onNodeClick}
diff --git a/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/3d-graph.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/3d-graph.tsx
index 991c362f..9ae59a5e 100644
--- a/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/3d-graph.tsx
+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/3d-graph.tsx
@@ -61,30 +61,6 @@ const Graph: React.FC<GraphProps> = ({ data, isLoading, width, height }) => {
shallow,
)
- const nodeColor = useCallback((node: Node) => {
- switch (node.type) {
- case "organization":
- return "#4ade80" // vert
- case "individual":
- return "#60a5fa" // bleu
- case "email":
- return "#facc15" // jaune
- case "phone":
- return "#f472b6" // rose
- case "social":
- return "#38bdf8" // cyan
- default:
- return "#cbd5e1" // gris clair
- }
- }, [])
-
- const nodeThreeObject = useCallback((node: Node) => {
- const sprite = new SpriteText(node.label || node.id)
- sprite.color = nodeColor(node)
- sprite.textHeight = 8
- return sprite
- }, [nodeColor])
-
useEffect(() => {
if (isLoading) return
if (data?.nds) setNodes(data.nds)
@@ -93,12 +69,14 @@ const Graph: React.FC<GraphProps> = ({ data, isLoading, width, height }) => {
return (
<div className="relative h-full w-full bg-card">
<ForceGraph3D
+ backgroundColor={"white"}
+ // cameraPosition={{ x: 0, y: 0, z: 500 }}
ref={fgRef}
graphData={{ nodes, links: edges }}
nodeId="id"
nodeLabel="label"
nodeAutoColorBy="type"
- nodeThreeObject={nodeThreeObject}
+ // nodeThreeObject={nodeThreeObject}
linkDirectionalArrowLength={4}
linkDirectionalArrowRelPos={1}
width={width}
diff --git a/flowsint-web/src/components/sketches/new-actions.tsx b/flowsint-web/src/components/sketches/new-actions.tsx
index 3ab86c99..890b9064 100644
--- a/flowsint-web/src/components/sketches/new-actions.tsx
+++ b/flowsint-web/src/components/sketches/new-actions.tsx
@@ -3,7 +3,6 @@
import type React from "react"
import { useState } from "react"
import { useParams } from "next/navigation"
-import { supabase } from "@/lib/supabase/client"
import { Button } from "@/components/ui/button"
import { ArrowLeft, ArrowRight } from 'lucide-react'
import { toast } from "sonner"
@@ -17,17 +16,36 @@ import { Badge } from "@/components/ui/badge"
import { saveNode } from "@/lib/actions/sketches"
import { useNodesDisplaySettings } from "@/store/node-display-settings"
import { useSketchStore } from "@/store/sketch-store"
+import { shallow } from 'zustand/shallow'
interface ActionDialogProps {
children: React.ReactNode
- addNodes?: (node: any) => void
setCurrentNode?: (node: any) => void
}
-export default function ActionDialog({ children, addNodes, setCurrentNode }: ActionDialogProps) {
+export default function ActionDialog({ children, setCurrentNode }: ActionDialogProps) {
const { sketch_id } = useParams()
- const { colors } = useNodesDisplaySettings()
- const { handleOpenFormModal, currentNodeType, openMainDialog, setOpenMainDialog, openFormDialog, setOpenFormDialog } = useSketchStore()
+ const colors = useNodesDisplaySettings(s => s.colors)
+ const {
+ handleOpenFormModal,
+ currentNodeType,
+ openMainDialog,
+ setOpenMainDialog,
+ openFormDialog,
+ setOpenFormDialog,
+ addNode,
+ } = useSketchStore(
+ state => ({
+ handleOpenFormModal: state.handleOpenFormModal,
+ currentNodeType: state.currentNodeType,
+ openMainDialog: state.openMainDialog,
+ setOpenMainDialog: state.setOpenMainDialog,
+ openFormDialog: state.openFormDialog,
+ setOpenFormDialog: state.setOpenFormDialog,
+ addNode: state.addNode,
+ }),
+ shallow
+ )
const [currentParent, setCurrentParent] = useState<ActionItem | null>(null)
const [navigationHistory, setNavigationHistory] = useState<ActionItem[]>([])
@@ -52,10 +70,11 @@ export default function ActionDialog({ children, addNodes, setCurrentNode }: Act
type,
},
}
- const resp = await saveNode({ node: newNode, sketch_id })
- if (addNodes) addNodes(resp.data?.node as any)
- if (setCurrentNode) setCurrentNode(newNode)
+ if (addNode) addNode(newNode as any)
setOpenFormDialog(false)
+ toast.success("New node added.")
+ await saveNode({ node: newNode, sketch_id })
+ if (setCurrentNode) setCurrentNode(newNode)
} catch (error) {
toast.error("Unexpected error during node creation.")
} finally {
diff --git a/flowsint-web/src/components/sketches/sketch/create-relation.tsx b/flowsint-web/src/components/sketches/sketch/create-relation.tsx
index 7da32202..5daf5263 100644
--- a/flowsint-web/src/components/sketches/sketch/create-relation.tsx
+++ b/flowsint-web/src/components/sketches/sketch/create-relation.tsx
@@ -12,9 +12,11 @@ import { Badge } from "@/components/ui/badge"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { saveEdge } from "@/lib/actions/sketches"
import { toast } from "sonner"
+import { EdgeData } from "@/types"
export function CreateRelationDialog({ sketchId }: { sketchId: string }) {
const selectedNodes = useSketchStore((state) => state.selectedNodes || [])
+ const addEdge = useSketchStore((state) => state.addEdge)
const openAddRelationDialog = useSketchStore((state) => state.openAddRelationDialog)
const setOpenAddRelationDialog = useSketchStore((state) => state.setOpenAddRelationDialog)
const [relationType, setRelationType] = useState("")
@@ -23,17 +25,18 @@ export function CreateRelationDialog({ sketchId }: { sketchId: string }) {
const handleSubmit = async (e: { preventDefault: () => void }) => {
e.preventDefault()
try {
- const schema = {
+ const newEdge = {
source: selectedNodes[0],
target: selectedNodes[1],
type: direction,
label: relationType,
sketch_id: sketchId
}
- const resp = await saveEdge(schema)
- // if (addEdges) addEdges(schema)
- setOpenAddRelationDialog(false)
+ const newEdgeObject = { type: newEdge.type, label: relationType, from: newEdge.source.id, to: newEdge.target.id } as any
+ if (addEdge) addEdge(newEdgeObject)
toast.success("Relation successfully added.")
+ setOpenAddRelationDialog(false)
+ await saveEdge(newEdge)
} catch (error) {
toast.error("Unexpected error during node creation.")
} finally {
diff --git a/flowsint-web/src/components/ui/dialog.tsx b/flowsint-web/src/components/ui/dialog.tsx
index f0bd7492..4751c461 100644
--- a/flowsint-web/src/components/ui/dialog.tsx
+++ b/flowsint-web/src/components/ui/dialog.tsx
@@ -38,7 +38,7 @@ function DialogOverlay({
<DialogPrimitive.Overlay
data-slot="dialog-overlay"
className={cn(
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[501] bg-black/80",
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80",
className
)}
{...props}
@@ -57,7 +57,7 @@ function DialogContent({
<DialogPrimitive.Content
data-slot="dialog-content"
className={cn(
- "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-[502] grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
className
)}
{...props}
diff --git a/flowsint-web/src/lib/actions/sketches.ts b/flowsint-web/src/lib/actions/sketches.ts
index 8cb0949d..8a368b6d 100644
--- a/flowsint-web/src/lib/actions/sketches.ts
+++ b/flowsint-web/src/lib/actions/sketches.ts
@@ -70,7 +70,7 @@ export async function saveNode(schema: AddNodeSchema) {
}
-type AddEdgeSchema = {
+export type AddEdgeSchema = {
source: NodeData,
target: NodeData,
type: string,
diff --git a/flowsint-web/src/store/sketch-store.ts b/flowsint-web/src/store/sketch-store.ts
index 5a882927..8a61fb98 100644
--- a/flowsint-web/src/store/sketch-store.ts
+++ b/flowsint-web/src/store/sketch-store.ts
@@ -2,7 +2,7 @@
import { create } from "zustand"
import type { EdgeData, NodeData } from "@/types"
-import { ActionItem, actionItems, findActionItemByKey } from "@/lib/action-items"
+import { ActionItem, findActionItemByKey } from "@/lib/action-items"
interface SketchState {
// === Graph ===
@@ -11,6 +11,7 @@ interface SketchState {
setNodes: (nodes: NodeData[]) => void
setEdges: (edges: EdgeData[]) => void
addNode: (newNode: Partial<NodeData>) => NodeData
+ addEdge: (newEdge: Partial<EdgeData>) => EdgeData
// === Selection & Current ===
currentNode: NodeData | null
@@ -55,6 +56,15 @@ export const useSketchStore = create<SketchState>()((set, get) => ({
set({ nodes: [...nodes, nodeWithId] })
return nodeWithId
},
+ addEdge: (newEdge) => {
+ const { edges } = get()
+ const edgeWithId: EdgeData = {
+ id: newEdge.id || `node-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
+ ...newEdge,
+ } as EdgeData
+ set({ edges: [...edges, edgeWithId] })
+ return edgeWithId
+ },
// === Selection & Current ===
currentNode: null,
diff --git a/flowsint-web/yarn.lock b/flowsint-web/yarn.lock
index 46e9f2a1..1ca9ec31 100644
--- a/flowsint-web/yarn.lock
+++ b/flowsint-web/yarn.lock
@@ -7161,7 +7161,7 @@ three-spritetext@^1.9.6:
resolved "https://registry.yarnpkg.com/three-spritetext/-/three-spritetext-1.9.6.tgz#f6e89dfbc158ad2f04392fc012ef390a7d7f7f99"
integrity sha512-+O5hGi6u4nWLefY8+Hlufd0aysWZhS2Ex61LCQVSixbYbykdPUOYYA+V+4xG4mKNDm1AsC0yHINRQS5NQb6mSg==
-"three@>=0.118 <1":
+"three@>=0.118 <1", three@^0.176.0:
version "0.176.0"
resolved "https://registry.yarnpkg.com/three/-/three-0.176.0.tgz#a30c1974e46db5745e4f96dd9ee2028d71e16ecf"
integrity sha512-PWRKYWQo23ojf9oZSlRGH8K09q7nRSWx6LY/HF/UUrMdYgN9i1e2OwJYHoQjwc6HF/4lvvYLC5YC1X8UJL2ZpA==