From 563256c08c31ae68413ee93e049b25d0cdb81f61 Mon Sep 17 00:00:00 2001 From: Moses Narrow <36607567+0pcom@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:41:04 -0500 Subject: [PATCH] add GOOS=js (wasm) build support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide the tty platform layer for the js build tag so the package compiles for browser (wasm) targets: init/restore/close are no-ops (there is no terminal to configure) and openInputTTY reports that no controlling terminal exists — callers supply input through explicit readers. Lets TUI libraries that depend on this package build unchanged for wasm. --- tty_js.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tty_js.go diff --git a/tty_js.go b/tty_js.go new file mode 100644 index 0000000..ca0fbf3 --- /dev/null +++ b/tty_js.go @@ -0,0 +1,23 @@ +//go:build js + +package keyboard + +import ( + "errors" + "os" +) + +// initInput is a no-op on js/wasm: there is no terminal to configure. +func initInput() error { return nil } + +// restoreInput is a no-op on js/wasm. +func restoreInput() error { return nil } + +// closeInput is a no-op on js/wasm. +func closeInput() {} + +// openInputTTY reports that no controlling terminal exists on js/wasm; +// callers supply input through explicit readers instead. +func openInputTTY() (*os.File, error) { + return nil, errors.New("keyboard: no /dev/tty on js/wasm") +}