From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Web Agent Date: Fri, 16 Oct 2026 12:46:28 +0200 Subject: [PATCH 1/3] feat: build for js/wasm Bubble Tea doesn't compile for GOOS=js: initInput, listenForResize, suspendProcess and suspendSupported are defined only in tty_unix.go and tty_windows.go. None of the four means anything in a browser, where a program runs in a terminal emulator such as xterm.js: there is no tty to put in raw mode, since the emulator delivers its input decoded; no SIGWINCH, since the page sends a WindowSizeMsg when the emulator resizes; and no job control to suspend into. tty_js.go defines them as no-ops, so a program builds with GOOS=js GOARCH=wasm (Go or TinyGo) and runs with WithInput and WithOutput wired to the emulator. --- tty_js.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tty_js.go diff --git a/tty_js.go b/tty_js.go new file mode 100644 index 0000000..1efbd44 --- /dev/null +++ b/tty_js.go @@ -0,0 +1,19 @@ +//go:build js + +package tea + +// GOOS=js has no tty: initInput, listenForResize, suspendProcess and +// suspendSupported, defined only in tty_unix.go and tty_windows.go, mean +// nothing in a browser. There is no terminal to put in raw mode (a +// terminal emulator such as xterm.js delivers its input already decoded), +// no SIGWINCH (the page sends a WindowSizeMsg when the emulator resizes), +// and no job control to suspend into. The program's input and output are +// whatever the page wires to WithInput and WithOutput. + +func (p *Program) initInput() error { return nil } + +const suspendSupported = false + +func suspendProcess() {} + +func (p *Program) listenForResize(done chan struct{}) { close(done) }