Playground

The same authored app, running in this browser.

The terminal below is a real TerminalUI App compiled to WASI and mounted onto a canvas via the WebTUIGUI host. There is no terminal-emulator dependency — the browser draws raster surface output directly. Resize the frame, switch scenes from the picker, and try the keybindings.

The full embedding pattern lives in Examples/WebExample — about 60 lines of load-bearing code (COI shim + createWebTUIApp mount + scene runtime factory). The rest of that example is page chrome.

Adopt this pattern

The minimum a host page needs:

  1. A WASI build of a TerminalUI App. The WASI runner page covers the toolchain and build command.
  2. A static scene-manifest.json generated by TerminalWASIAppRunner in manifest mode.
  3. The COI service-worker shim if hosting on a platform that can't set COOP/COEP headers itself (GitHub Pages, most CDNs).
  4. bun add webtuigui in the host workspace.
  5. The mount sequence from WebExample/src/frontend.ts (createWebTUIApp + createWasmSceneRuntimeFactory).

The decision behind keeping host packages as peers (rather than folding them into the root package) is documented in ADR-0007.

If the demo doesn't load

The frame above requires cross-origin isolation to use SharedArrayBuffer-backed stdin. The example installs a service-worker COOP/COEP shim and reloads when needed, but if you have a service-worker policy that blocks it, open the hosted URL directly:

https://goodhatsllc.github.io/swift-terminal-ui/webexample/ ↗