// import { useMemo, useEffect, useState } from "react"; // import ReactFlow, { Background, Controls, MarkerType } from "reactflow"; // import type { NodeProps, Node, Edge } from "reactflow"; // import "reactflow/dist/style.css"; // import styles from "./Dashboard.module.css"; import type { MachineData, UIOrchestrator } from "./types"; // // Type for React Flow Node Data // interface CustomNodeData { // instance: MachineData; // label: string; // currentTick?: number; // } // const MachineNode = ({ data }: NodeProps) => { // const machine = data.instance as MachineData; // return ( //
//
// {machine.recipe.name} // // {machine.isCrafting ? "CRAFTING" : "HALTED"} // //
//
//
//
//
//
// IN: // {Object.entries(machine.inputBuffer).map(([k, v]) => ( // // {v} // // ))} //
//
// OUT: // {Object.entries(machine.outputBuffer).map(([k, v]) => { // const isFull = v >= (machine.outputBlockLimits[k] || 0); // return ( // // {v} // // ); // })} //
//
//
// ); // }; // const ChestNode = ({ data }: NodeProps) => ( //
// {data.label} //
// ); // const nodeTypes = { machine: MachineNode, chest: ChestNode }; interface GraphViewProps { orchestrator: UIOrchestrator; tick: number; } export default function GraphView({ orchestrator, tick }: GraphViewProps) { return
; } // export default function GraphView({ orchestrator, tick }: GraphViewProps) { // const { initialNodes, initialEdges } = useMemo(() => { // const nodes: Node[] = []; // const edges: Edge[] = []; // const objToId = new Map(); // let idCounter = 0; // const getId = (obj: any, type: string, label: string): string => { // if (!objToId.has(obj)) { // const id = `node_${idCounter++}`; // objToId.set(obj, id); // nodes.push({ // id, // type, // position: { x: (idCounter % 3) * 300, y: Math.floor(idCounter / 3) * 150 }, // data: { instance: obj, label }, // }); // } // return objToId.get(obj)!; // }; // orchestrator.getInserters().forEach((ins, i) => { // edges.push({ // id: `edge_${i}`, // source: getId(ins.source, ins.source.recipe ? "machine" : "chest", "Source"), // target: getId(ins.destination, ins.destination.recipe ? "machine" : "chest", "Destination"), // label: ins.targetItemId, // animated: false, // style: { stroke: "#8e8e8e", strokeWidth: 2 }, // markerEnd: { type: MarkerType.ArrowClosed, color: "#8e8e8e" }, // }); // }); // return { initialNodes: nodes, initialEdges: edges }; // }, [orchestrator]); // const [nodes, setNodes] = useState[]>(initialNodes); // const [edges, setEdges] = useState(initialEdges); // useEffect(() => { // setNodes((nds) => nds.map((n) => ({ ...n, data: { ...n.data, currentTick: tick } }))); // setEdges((eds) => // eds.map((edge, i) => { // const ins = orchestrator.getInserters()[i]; // const isSwinging = ins.state > 0 && ins.state < 4; // return { // ...edge, // animated: isSwinging, // style: { stroke: isSwinging ? "#5eb663" : "#8e8e8e", strokeWidth: isSwinging ? 3 : 2 }, // markerEnd: { type: MarkerType.ArrowClosed, color: isSwinging ? "#5eb663" : "#8e8e8e" }, // }; // }), // ); // }, [tick, orchestrator]); // return ( //
// // // // //
// ); // }