Documentation
¶
Overview ¶
Package wasmhost is the desktop shell's wasmbox (wasmdesk) backend: it drives a go-widgets widget tree as an external wasmbox client, painting into the compositor's shared surface and translating wasmbox input messages into toolkit events.
It is the browser analogue of github.com/go-widgets/window's native X11 / Wayland backend. window v0.4.0 has no js/wasm backend yet (its Open returns ErrUnsupported off Linux), so the desktop shell supplies its own wasmbox host here; the platform split mirrors window's exactly — Run on js/wasm, an ErrUnsupported stub elsewhere — so the same clients/desktop entry point cross-builds on every target.
The rendering core (Host) is platform-independent and fully unit-tested on native: only the thin syscall/js glue in host_js.go is browser-only. Host reuses the shell's incremental-present root (scene.HostRoot): each frame it repaints just the damaged rectangles and reports their bounding box as the wasmbox commit{damage}, so the small-rect present the native window backend does flows through the compositor's blit too.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupported = errors.New("wasmhost: the wasmbox backend is only available on js/wasm")
ErrUnsupported is returned by Open on platforms other than js/wasm, mirroring window.ErrUnsupported so a cross-build stays green everywhere.
Functions ¶
func Run ¶
Run is unavailable off js/wasm: there is no wasmbox compositor to attach to, so it returns ErrUnsupported. The rendering core (Host) and the input mapping stay compiled and unit-tested on every platform; only this entry point is gated, mirroring window.Open's Linux-only gating so cross-builds stay green.
Types ¶
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host binds a go-widgets root widget to a persistent RGBA framebuffer and drives it: Frame renders the next frame (incrementally when the root opts in) and returns the damage to present; Input dispatches a decoded wasmbox event into the tree. It owns no js state, so it is exercised end-to-end on native.
func NewHost ¶
NewHost builds a Host over a fresh w×h framebuffer bound to root. When root implements the incremental seam (RenderDamaged) frames present only the damaged rectangles; otherwise every frame is a full repaint.
func (*Host) Frame ¶
Frame renders the next frame into the framebuffer and returns the rectangle to present. The first frame (the initial map) always reports the whole surface; afterwards an incremental root reports the bounding box of the rectangles it repainted (empty when nothing changed), and a plain root always repaints and reports the whole surface.
func (*Host) Input ¶
func (h *Host) Input(in InputEvent) bool
Input dispatches a decoded wasmbox event into the widget tree, returning whether it produced any toolkit event (so the js glue can skip a needless frame for an event the shell ignores).
type InputEvent ¶
InputEvent is one decoded wasmbox input message (the fields the compositor puts on event objects it posts to a client: kind, surface-local x/y, the keyboard key/code, and the wheel deltaY). host_js.go decodes the js value into this struct so the mapping logic stays pure and testable.