Documentation
¶
Index ¶
Constants ¶
View Source
const ( OpRedraw = "redraw" OpText = "text" OpFacts = "facts" OpAppend = "append" OpRemoveLast = "remove-last" OpRemove = "remove" OpReorder = "reorder" OpPlugin = "plugin" OpLazy = "lazy" )
Patch op names sent over the wire — bridge.js dispatches on these.
Variables ¶
This section is empty.
Functions ¶
func EncodeInitTreeMessage ¶
func EncodeInitTreeMessage(root vdom.Node) (*gproto.ServerMessage, error)
EncodeInitTreeMessage builds a ServerMessage for init using a tree description instead of HTML. The bridge builds DOM directly from this.
func EncodePatchMessage ¶
func EncodePatchMessage(patches []vdom.Patch) *gproto.ServerMessage
EncodePatchMessage builds a VDomMessage with patches from a diff.
Types ¶
type WireFactsDiff ¶
type WireFactsDiff struct {
Props map[string]any `json:"p,omitempty"` // properties
Attrs map[string]string `json:"a,omitempty"` // attributes
AttrsNS map[string]wireNSAttr `json:"an,omitempty"` // namespaced attributes
Styles map[string]string `json:"s,omitempty"` // styles
Events map[string]*wireEvent `json:"e,omitempty"` // events
}
WireFactsDiff is the JSON structure sent to the bridge.
type WireNode ¶
type WireNode struct {
ID int `json:"id"`
Type string `json:"t"` // "text", "el", "keyed"
Tag string `json:"tag,omitempty"` // element tag name
NS string `json:"ns,omitempty"` // namespace (SVG)
Text string `json:"x,omitempty"` // text content (text nodes)
Props map[string]any `json:"p,omitempty"` // DOM properties
Attrs map[string]string `json:"a,omitempty"` // HTML attributes
AttrsNS map[string]wireNSAttr `json:"an,omitempty"` // namespaced attributes
Styles map[string]string `json:"s,omitempty"` // CSS styles
Events []*WireNodeEvent `json:"ev,omitempty"` // event listeners
Children []*WireNode `json:"c,omitempty"` // child nodes
Keys []string `json:"k,omitempty"` // keys for keyed children (parallel to children)
Plugin string `json:"plug,omitempty"` // plugin name
PlugData any `json:"pd,omitempty"` // plugin data
}
WireNode is the JSON structure sent to the bridge for building DOM directly. The bridge creates DOM nodes from this and maintains nodeMap[id] → DOM node.
func EncodeTree ¶
EncodeTree converts a vdom.Node tree to a WireNode tree suitable for JSON transport.
type WireNodeEvent ¶
type WireNodeEvent struct {
On string `json:"on"` // event type: "click", "input", etc.
Key string `json:"key,omitempty"` // key filter for keydown
Method string `json:"method"` // Go method name (or "__bind__" for g-bind)
Args [][]byte `json:"args,omitempty"` // JSON-encoded arguments
SP bool `json:"sp,omitempty"` // stopPropagation
PD bool `json:"pd,omitempty"` // preventDefault
}
WireNodeEvent describes an event listener for the bridge to register.
Click to show internal directories.
Click to hide internal directories.