plushie/node
Tree node types for plushie’s UI tree.
PropValue is a JSON-like union representing wire-compatible values.
Node is the fundamental tree building block – widget builders produce
these, tree operations consume them, and the protocol encoder serializes
them to wire format.
Types
A node in the UI tree. Produced by widget builders, consumed by tree operations and the protocol encoder.
id: widget identifier (scoped during normalization)kind: widget type string (“button”, “column”, etc.)props: encoded property values (string-keyed)children: child nodes
pub type Node {
Node(
id: String,
kind: String,
props: dict.Dict(String, PropValue),
children: List(Node),
)
}
Constructors
A wire-compatible value. Covers all JSON/MessagePack primitive types.
Widget builders convert typed Gleam values (Length, Padding, Color, etc.)
into PropValue at build() time.
pub type PropValue {
StringVal(String)
IntVal(Int)
FloatVal(Float)
BoolVal(Bool)
NullVal
BinaryVal(BitArray)
ListVal(List(PropValue))
DictVal(dict.Dict(String, PropValue))
}
Constructors
-
StringVal(String) -
IntVal(Int) -
FloatVal(Float) -
BoolVal(Bool) -
NullVal -
BinaryVal(BitArray)Raw binary data. Encoded as base64 on the JSON wire format and as raw bytes on the MessagePack wire format.
-
ListVal(List(PropValue)) -
Values
pub fn empty_container() -> Node
An empty container node, useful as a default root.