Documentation
¶
Overview ¶
Package wasm provides a bridge for running BubbleTea programs in the browser. It registers three JavaScript functions on the global object (bubbletea_read, bubbletea_write, bubbletea_resize) and leaves the page to drive them: bubbletea_write takes terminal input bytes, bubbletea_read drains the program's ANSI output, and bubbletea_resize delivers a tea.WindowSizeMsg.
The page is the caller's. sip's own static/terminal.js is a client for the socket protocol and has no adapter for these globals, so a wasm build ships its own index.html and its own terminal emulator or renderer. static/mobile.js is standalone and can be used from one.
Usage:
//go:build js && wasm
package main
import "github.com/Gaurav-Gosain/sip/wasm"
func main() {
wasm.Run(initialModel())
}
Index ¶
- func Run(model tea.Model, opts ...tea.ProgramOption) error
- type Program
- func (p *Program) Kill()
- func (p *Program) Printf(t string, args ...any)
- func (p *Program) Println(args ...any)
- func (p *Program) Quit()
- func (p *Program) ReleaseTerminal() error
- func (p *Program) RestoreTerminal() error
- func (p *Program) Run() (tea.Model, error)
- func (p *Program) Send(msg tea.Msg)
- func (p *Program) Wait()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program wraps a BubbleTea program for the browser.
func NewProgram ¶
func NewProgram(model tea.Model, opts ...tea.ProgramOption) *Program
NewProgram creates a new BubbleTea program for the browser. It registers the JavaScript bridge functions but does not start the program.