import { useState, useCallback } from 'react'; import { useEditorStore } from '../store/editorStore'; import { Terminal, ChevronDown, ChevronUp, Play, Wifi } from 'lucide-react'; export default function DevPanel() { const [open, setOpen] = useState(false); const [pathInput, setPathInput] = useState(''); const [testResult, setTestResult] = useState(null); const [testing, setTesting] = useState(false); const { backendUrl, videoPath, loadVideo } = useEditorStore(); const handleLoad = useCallback(() => { const p = pathInput.trim(); if (p) loadVideo(p); }, [pathInput, loadVideo]); const testEndpoint = useCallback(async (endpoint: string) => { setTesting(true); setTestResult(null); try { const url = `${backendUrl}${endpoint}`; const res = await fetch(url); const text = res.headers.get('content-type')?.includes('json') ? JSON.stringify(await res.json(), null, 2) : `${res.status} ${res.statusText} (${res.headers.get('content-type') ?? 'no type'})`; setTestResult(`✓ ${url}\n${text}`); } catch (e) { setTestResult(`✗ ${e}`); } finally { setTesting(false); } }, [backendUrl]); const testWaveform = useCallback(async () => { const p = pathInput.trim() || videoPath; if (!p) { setTestResult('No path to test'); return; } setTesting(true); setTestResult(null); try { const url = `${backendUrl}/audio/waveform?path=${encodeURIComponent(p)}`; const res = await fetch(url); if (res.ok) { const buf = await res.arrayBuffer(); setTestResult(`✓ Waveform OK — ${buf.byteLength} bytes\n${url}`); } else { const body = await res.text().catch(() => ''); setTestResult(`✗ HTTP ${res.status}\n${body}`); } } catch (e) { setTestResult(`✗ ${e}`); } finally { setTesting(false); } }, [backendUrl, pathInput, videoPath]); return (
{/* Header */} {open && (
{/* State */}
backendUrl: {backendUrl}
videoPath: {videoPath ?? 'null'}
{/* Load file by path */}
Load file
setPathInput(e.target.value)} onKeyDown={e => e.key === 'Enter' && handleLoad()} placeholder={videoPath ?? '/path/to/file.wav'} className="flex-1 bg-[#13141f] border border-[#2a2d3e] rounded px-2 py-1 text-white placeholder-[#2a2d3e] focus:outline-none focus:border-[#6366f1]" />
{/* Quick tests */}
Test endpoints
{/* Result */} {testResult && (
              {testResult}
            
)}
)}
); }