import { useState, useEffect } from "react"; import { createRoot } from "react-dom/client"; import { App } from "./app"; import "./styles/app.css"; // ghostty-web requires WASM initialisation before any Terminal is created. // Instead of blocking the React tree on init(), we render immediately and // show a loading screen until the WASM module is ready. import { init } from "ghostty-web"; function Root() { const [wasmReady, setWasmReady] = useState(false); const [wasmError, setWasmError] = useState(null); useEffect(() => { init() .then(() => setWasmReady(true)) .catch((err: unknown) => { const msg = err instanceof Error ? err.message : String(err); setWasmError(msg); }); }, []); if (wasmError) { return (
Failed to initialize terminal: {wasmError}
); } if (!wasmReady) { return (
Initializing terminal…
); } return ; } const el = document.getElementById("root"); if (!el) throw new Error("Missing #root element"); createRoot(el).render();