Skip to content

feat: add support for GOARCH=wasm and GOOS=js | wasip1 - #1693

Open
neomantra wants to merge 7 commits into
charmbracelet:mainfrom
neomantra:nm-wasm
Open

neomantra wants to merge 7 commits into
charmbracelet:mainfrom
neomantra:nm-wasm

Conversation

@neomantra

Copy link
Copy Markdown

These changes add support for compiling BubbleTea under GOARCH=wasm and under GOOS=js or GOOS=wasip1.

I have been experimenting with this for go-booba which helps bridge BubbleTea with the libghostty. I started experimenting with a go tool for monkey-patching BubbleTea for this. That way others could adopt it without changing their code.

But, it makes much more sense to include these upstream.

You can see some browser-base demos I've pretty easily created:

Since all the changes are guarded by build tags, this should not affect any other architectures. Thank you for BubbleTea.

  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

@neomantra

Copy link
Copy Markdown
Author

I added unit tests to the CI/CD. Note there is machinery to omit examples that depend on clipboard, directly or indirectly (e.g. via bubbles.TextArea/TextInput).

neomantra added a commit to NimbleMarkets/ntcharts that referenced this pull request Sep 19, 2026
…space

The neomantra/bubbletea fork only adds js/wasm and wasip1 build stubs,
so it is only needed when cross-compiling the showcase demos. Remove
its replace directive from all four go.mod files and go.work, and move
it into a new wasm.work workspace that cmd/wasm-build selects via
GOWORK when compiling demos with GOOS=js.

Native builds and tests now run against upstream charm.land/bubbletea/v2,
matching exactly what library consumers resolve.

Delete wasm.work and the GOWORK wiring once
charmbracelet/bubbletea#1693 merges upstream.

Signed-off-by: Evan Wies <evan@neomantra.net>
Add platform-specific stubs for WASM builds (js/wasm) to enable BubbleTea
to compile and run on WebAssembly without OS-level dependencies:

  - tty_wasm.go: stub initInput() and suspendProcess() (no TTY on WASM)
  - signals_wasm.go: stub listenForResize() (window events via JS)
  - termios_wasm.go: stub checkOptimizedMovements() (no terminal modes)
  - termios_other.go: exclude WASM from generic fallback

BubbleTea now works with WASM frameworks that provide custom
I/O and window management via JavaScript.

Signed-off-by: Evan Wies <evan@neomantra.net>
Signed-off-by: Evan Wies <evan@neomantra.net>
We have an exclude list due to dependencies that are
incompatible with WASM, eg. clipboard

Signed-off-by: Evan Wies <evan@neomantra.net>
joshw pushed a commit to joshw/zephyrlily that referenced this pull request Oct 2, 2026
2.0.10 includes charmbracelet/bubbletea#1755, which tracks an erase left
pending by ClearScreen or a resize and stops flush from skipping the frame
that draws it. That is the bug 309e7f7 worked around by nudging the view,
so the nudge goes; C-l, the resume repaint and %debug snapshot get a full
repaint from bubbletea itself.

Re-vendored from the published module with the same two additions as
before, tty_other.go and signals_other.go for js/wasm; upstream support for
that is still pending in charmbracelet/bubbletea#1693.

The real-renderer test now checks that a bare ClearScreen on an unchanged
view repaints. It fails against 2.0.8, so it will catch a re-vendoring that
loses the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant