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 ¶
- func OnMessage(handler func(vango.WasmMessage)) vdom.Attr
- func OnMessageValidated(validate vango.WasmMessageValidator, handler func(vango.WasmMessage)) vdom.Attr
- func SendToWASM(id string, payload any)
- func SendToWASMHID(hid string, payload any)
- func SetupOnWASMMessage[P any](s *vango.SetupCtx[P], id string, handler func(vango.WasmMessage))
- func SetupOnWASMMessageValidated[P any](s *vango.SetupCtx[P], id string, validate vango.WasmMessageValidator, ...)
- func WASMComponent(id string, props any) []vdom.Attr
- func WASMModule(path string) vdom.Attr
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 ¶
SendToWASM sends a message to the client-side WASM component.
func SendToWASMHID ¶ added in v0.0.2
SendToWASMHID sends a message to a specific wasm instance (addressed by HID).
func SetupOnWASMMessage ¶
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 ¶
WASMComponent marks an element as a WASM component boundary. For custom module paths, set WASMModule on the same element.
func WASMModule ¶
WASMModule overrides the default module path for a WASM component.
Types ¶
This section is empty.