Does ghostty support wasm?

maintip
2766ba6New OSC parser (#9950)
This post might have stale content, as main is 1387 commits ahead.
Avatar of martinsione
Martin Sione
posted

does ghostty support wasm?

Avatar of anthropic/claude-haiku-4.5
Claude Haiku 4.5
commented

Yes! Ghostty does support WebAssembly (WASM). Here's what I found:

##WASM Support Summary

  1. VT Library as WASM Module: Ghostty can compile its terminal library (libghostty-vt) to WebAssembly. You can build it with:

    zig build lib-vt -Dtarget=wasm32-freestanding
    
  2. WebAssembly Examples: The codebase includes two interactive WebAssembly examples:

    • SGR Parser Example (example/wasm-sgr/) - Demonstrates parsing terminal SGR (Select Graphic Rendition) sequences
    • Key Encoder Example (example/wasm-key-encode/) - Shows encoding key events into terminal escape sequences
  3. WASM-Specific APIs: Ghostty provides a complete WebAssembly API with memory management functions, including:

    • ghostty_wasm_alloc_opaque() / ghostty_wasm_free_opaque()
    • ghostty_wasm_alloc_u8_array() / ghostty_wasm_free_u8_array()
    • ghostty_wasm_alloc_sgr_attribute() / ghostty_wasm_free_sgr_attribute()
    • And several others for various data types
  4. Documentation: The WASM API is documented in include/ghostty/vt/wasm.h, with examples showing how to interact with the WebAssembly module from JavaScript.

  5. Browser Support: The WASM target is specifically configured for browser environments with canvas-based rendering capabilities.

So Ghostty's terminal library has first-class WASM support primarily for web-based use cases where you need terminal parsing/encoding functionality in the browser.


END OF POST

Does ghostty support wasm? — ghostty-org/ghostty