wasm

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Rendered for js/wasm

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(model tea.Model, opts ...tea.ProgramOption) error

Run creates a BubbleTea program from the given model, registers the JavaScript bridge functions, and blocks until the program exits.

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.

func (*Program) Kill

func (p *Program) Kill()

func (*Program) Printf

func (p *Program) Printf(t string, args ...any)

func (*Program) Println

func (p *Program) Println(args ...any)

func (*Program) Quit

func (p *Program) Quit()

func (*Program) ReleaseTerminal

func (p *Program) ReleaseTerminal() error

func (*Program) RestoreTerminal

func (p *Program) RestoreTerminal() error

func (*Program) Run

func (p *Program) Run() (tea.Model, error)

Run starts the program and blocks until it exits.

func (*Program) Send

func (p *Program) Send(msg tea.Msg)

func (*Program) Wait

func (p *Program) Wait()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL