/** * @example Injected API — headless I/O * * Shows how to pass a pre-booted EmceptionAPI into so the component * skips its own boot phase. Useful when you need to share one API instance * across multiple components or when you want to intercept stdout/stderr. * * Prerequisites: * npm install @gameguild/emception-ide @gameguild/emception-browser react react-dom */ import { createEmception } from '@gameguild/emception-browser'; import { Ide, type InjectedEmceptionAPI } from '@gameguild/emception-ide'; import { useEffect, useRef, useState } from 'react'; import { createRoot } from 'react-dom/client'; function App() { const [api, setApi] = useState(null); const [log, setLog] = useState([]); const logRef = useRef(log); logRef.current = log; useEffect(() => { let disposed = false; createEmception({ manifestUrl: '/cdn/manifest.json', tty: 'none', }).then((em) => { if (disposed) { em.dispose(); return; } setApi(em); }); return () => { disposed = true; }; }, []); if (!api) return
Booting…
; return (
setLog((prev) => [...prev, `[out] ${line}`])} onStderr={(line) => setLog((prev) => [...prev, `[err] ${line}`])} />
                {log.join('\n')}
            
); } const root = createRoot(document.getElementById('root')!); root.render();