wasm

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package wasm provides WASM component helpers for Vango.

Deprecated: The v1 Developer Guide exposes WASM components via `el.WASMComponent`. This package is retained for legacy/internal use only.

WASM components run client-side and communicate with the server via message passing.

Usage (v1 canonical):

Div(
	WASMComponent("canvas", map[string]any{"tool": "pen"}),
)

Client modules are loaded from /js/wasm/<id>.js by default unless overridden with WASMModule. Modules should export a mount(el, props, api) function that can optionally return {update, destroy, onMessage}.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnMessage added in v0.0.2

func OnMessage(handler func(vango.WasmMessage)) vdom.Attr

OnMessage registers a per-instance handler for messages emitted by this wasm boundary.

This attaches the handler to the wasm element itself (keyed by HID), so multiple wasm boundaries with the same name can coexist on a page without conflicting message routing.

func OnMessageValidated added in v0.2.0

func OnMessageValidated(validate vango.WasmMessageValidator, handler func(vango.WasmMessage)) vdom.Attr

OnMessageValidated registers a per-instance handler with exact-sink validation metadata for this mounted WASM boundary.

func SendToWASM

func SendToWASM(id string, payload any)

SendToWASM sends a message to the client-side WASM component.

func SendToWASMHID added in v0.0.2

func SendToWASMHID(hid string, payload any)

SendToWASMHID sends a message to a specific wasm instance (addressed by HID).

func SetupOnWASMMessage

func SetupOnWASMMessage[P any](s *vango.SetupCtx[P], id string, handler func(vango.WasmMessage))

SetupOnWASMMessage registers a handler for messages from the WASM component during Setup. This is the spec-aligned Setup-only variant.

func SetupOnWASMMessageValidated added in v0.2.0

func SetupOnWASMMessageValidated[P any](s *vango.SetupCtx[P], id string, validate vango.WasmMessageValidator, handler func(vango.WasmMessage))

SetupOnWASMMessageValidated registers a handler with validation for WASM messages. When the runtime supports exact-sink validator registration, the validator is preserved for strict non-dev enforcement.

func WASMComponent

func WASMComponent(id string, props any) []vdom.Attr

WASMComponent marks an element as a WASM component boundary. For custom module paths, set WASMModule on the same element.

func WASMModule

func WASMModule(path string) vdom.Attr

WASMModule overrides the default module path for a WASM component.

Types

This section is empty.

Jump to

Keyboard shortcuts

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