Download source/src/ui/DebugPanel.jsx from FormaLau/microduck-reachy-simulator: direct link, hf CLI and curl.
- Browser
- Download file 3.07 kB
-
https://huggingface.co/spaces/FormaLau/microduck-reachy-simulator/resolve/main/source/src/ui/DebugPanel.jsx
- Command line
-
hf download hf://spaces/FormaLau/microduck-reachy-simulator/source/src/ui/DebugPanel.jsx
-
curl -L -o DebugPanel.jsx https://huggingface.co/spaces/FormaLau/microduck-reachy-simulator/resolve/main/source/src/ui/DebugPanel.jsx
3.07 kB
| 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) => <DebugValue value={value} path={path} scope={scope} expanded={expanded} toggle={toggle} inspectArray={inspectArray} fr={fr} />; | |
| return <section className="debug-panel" aria-label="Debugger"> | |
| <div className="debug-controls"> | |
| <strong>{fr ? 'Débogueur' : 'Debugger'}</strong> | |
| <button disabled={!paused} onClick={() => resume('continue')} title="F5">{fr ? 'Continuer' : 'Continue'}</button> | |
| <button disabled={!paused} onClick={() => resume('over')} title="F10">{fr ? 'Ligne suivante' : 'Step over'}</button> | |
| <button disabled={!paused} onClick={() => resume('into')} title="F11">{fr ? 'Entrer dans la fonction' : 'Step into'}</button> | |
| <button disabled={!paused} onClick={() => resume('out')} title="Shift+F11">{fr ? 'Sortir de la fonction' : 'Step out'}</button> | |
| <span>{paused && point ? `${point.function} · ${fr ? 'ligne' : 'line'} ${point.line}` : (fr ? 'Exécution en cours…' : 'Running…')}</span> | |
| </div> | |
| <div className="debug-values" aria-live="polite"> | |
| <div><strong>{fr ? 'Variables visibles' : 'Visible variables'}</strong> | |
| <table aria-label="Variables"><thead><tr><th>{fr ? 'Nom' : 'Name'}</th><th>Type</th><th>{fr ? 'Valeur' : 'Value'}</th></tr></thead> | |
| <tbody>{paused && variables.map(v => <tr key={v.name}><td>{v.name}</td><td>{v.type}</td><td>{renderValue(v.value, v.name, 'locals')}</td></tr>)}</tbody></table> | |
| {paused && !variables.length && <span>{fr ? 'Aucune variable dans cette portée.' : 'No variables in scope.'}</span>} | |
| </div> | |
| <div><strong>Watch</strong> | |
| <form onSubmit={e => { e.preventDefault(); const value = name.trim(); if (/^[A-Za-z_]\w*$/.test(value)) { setWatch(items => [...new Set([...items, value])]); setName(''); } }}> | |
| <input aria-label="Watch variable" placeholder={fr ? 'Nom de variable' : 'Variable name'} pattern="[A-Za-z_][A-Za-z_0-9]*" value={name} onChange={e => setName(e.target.value)} /> | |
| <button>{fr ? 'Ajouter' : 'Add'}</button> | |
| </form> | |
| {watch.map(item => { const value = variables.find(v => v.name === item); return <div className="debug-watch" key={item}><div className="debug-watch-value"><code>{item} = </code>{paused ? value ? renderValue(value.value, item, 'watch') : <code>{fr ? 'hors portée' : 'out of scope'}</code> : <code>…</code>}</div><button aria-label={`Remove watch ${item}`} onClick={() => setWatch(items => items.filter(v => v !== item))}>×</button></div>; })} | |
| </div> | |
| </div> | |
| </section>; | |
| } | |