import { useState } from 'react'; import DebugValue from './DebugValue.jsx'; export default function DebugPanel({ point, paused, resume, language, watch, setWatch, inspectArray }) { const [name, setName] = useState(''); const [expanded, setExpanded] = useState(() => new Set()); const toggle = key => setExpanded(current => { const next = new Set(current); if (next.has(key)) next.delete(key); else next.add(key); return next; }); const fr = language === 'fr'; const variables = point?.variables || []; const renderValue = (value, path, scope) => ; return
{fr ? 'Débogueur' : 'Debugger'} {paused && point ? `${point.function} · ${fr ? 'ligne' : 'line'} ${point.line}` : (fr ? 'Exécution en cours…' : 'Running…')}
{fr ? 'Variables visibles' : 'Visible variables'} {paused && variables.map(v => )}
{fr ? 'Nom' : 'Name'}Type{fr ? 'Valeur' : 'Value'}
{v.name}{v.type}{renderValue(v.value, v.name, 'locals')}
{paused && !variables.length && {fr ? 'Aucune variable dans cette portée.' : 'No variables in scope.'}}
Watch
{ e.preventDefault(); const value = name.trim(); if (/^[A-Za-z_]\w*$/.test(value)) { setWatch(items => [...new Set([...items, value])]); setName(''); } }}> setName(e.target.value)} />
{watch.map(item => { const value = variables.find(v => v.name === item); return
{item} = {paused ? value ? renderValue(value.value, item, 'watch') : {fr ? 'hors portée' : 'out of scope'} : …}
; })}
; }