Skip to main content

Module schema

Module schema 

Source
Expand description

The prop schema: the one table of node props, elements, events and readings that every kui binding is generated from or checked against.

A Rust app does not read this module; it builds a NodeSpec with its methods. The tables here are for the bindings and for tooling. Each PROPS row names a prop (camelCase, with the snake_case spelling derived), its wire id, its value kind, how it applies to a NodeSpec and its documentation: kui-node parses JSON and its binary stream by kind and generates the TypeScript types from the rows, kui-lua looks each table key up by name, and kui-ffi mirrors the rows in a C struct that a parity test pins to this table. CUSTOM lists the composite props a binding extracts itself (padding shorthands, border, overflow, floats), ELEMENTS the props each element lowers, DOORS the verbs (calls rather than props) with their spelling in every binding, and known_prop answers whether a name is any of these, which is what an unknown-prop warning checks against.

use kui_core::schema::{PROPS, P_WIDTH};

let width = PROPS.iter().find(|p| p.id == P_WIDTH).expect("a core prop");
assert_eq!(width.name, "width");
assert!(!width.doc.is_empty());

Adding a simple prop is one row here (plus npm run gen for the TS types, and a field in the C struct when the parity test says so). Composite props need per-binding extraction but not per-binding decisions: what a shorthand means lives in one place in spec, and crate::conformance makes every binding agree on behaviour.

Structs§

CustomProp
A prop every binding handles by hand (a composite with real logic, or a constructor-order special), with its wire id so transports agree on identity and its per-binding spelling so the docs can say so.
Door
One verb.
ElementDef
An element (node type) and its spelling in each binding. Elements are hand-lowered per binding (their shapes differ: JSX children, Lua tables, C calls with body callbacks), so this table is documentation and a checklist, not a code generator’s input.
EnvFacts
Everything an env reading is taken from: the stored Env and the frame’s own facts beside it (Core::env_facts).
EnvField
One value in the host-environment reading a view gets — ui.env() in Rust, view(env) in Lua, ctx.env() / win.env() in Node — and the key each binding puts it under. C has no reading: a C host is the frame driver, so it is the writer (kui_env_set, kui_env_set_window), and its column names the argument that carries the fact in.
EventDef
An event kind hosts receive, with its payload shape.
MetricRole
One size the stock widgets are built from (crate::metrics::Metrics), pinned the way ThemeRole pins a colour: a binding iterates the rows to read or write a set, so a field added to Metrics is one row here and nothing anywhere else. The test below destructures the struct exhaustively.
PlatformValue
A metric’s value per platform (see MetricRole::platform).
PropDef
PropsOut
Everything a prop list can carry; elements pick the parts they use.
ResourceDef
A host-registered resource and how each binding registers it.
ThemeRole
One colour role in a crate::theme::Theme, with the spelling each binding reads it under and the reading itself.

Enums§

Apply
Where a parsed value lands. PropDef::target derives from this.
Cell
One binding’s cell.
Identity
Which key a prop list opens its node under: the next auto key, the key label, or — beating the label when a binding is handed both — the index a virtual list opens its rows by.
Kind
How a prop’s value is parsed (per transport) and encoded (binary slots).
Parsed
A parsed prop value, transport-independent.
Spelling
The spelling a binding writes prop names in: JSX’s camelCase rows, or the snake_case ones a Lua table takes. The allow-list below is per spelling, so hover_bg in JSX and hoverBg in Lua are each as unknown as a typo — which is what they are: neither binding reads the other’s spelling.
Target

Constants§

ALIGNS
The mainAlign / crossAlign rows and a float’s attach points, in Align’s order. Append-only: the Lua and Node wires carry the index, and C’s KUI_ALIGN_* is it. The spreads mean something on mainAlign and baseline on a row’s crossAlign only.
APPEARANCES
The OS light/dark setting (crate::env::Appearance::name spellings, in Appearance::ALL order — an env.rs test pins the two together). Like ORIENTATIONS this is not a prop’s enum: it is a fact a host pushes and every binding spells the same way. Index 0 is unknown, so a zeroed C call reports what it actually knows.
ASSISTIVE
Whether assistive technology is listening (crate::env::Assistive::name spellings, in Assistive::ALL order), unknown first for the same reason: a host with no bridge reports that it cannot tell.
AUDIO_DEVICES
The audio output device’s state (crate::env::AudioDevice::name spellings, in AudioDevice::ALL order), closed first so a zeroed C call reports the default.
BACKDROPS
What is behind a window’s transparent pixels (crate::window::Backdrop::name spellings, in Backdrop::ALL order), opaque first so a zeroed C call reports the default.
BUTTON_ROWS_JSX
The rows the stock button reads (ElementDef::jsx_rows / lua_rows): the click, the identity (key, or index in a virtual list — declared beside key the index wins, as on a box), the access rows — what a button is and what a reader says of it — and the one paint row it takes, accent, which is not a colour but a question put to the OS. The two lists are the same rows in each spelling, index for index.
BUTTON_ROWS_LUA
CURSORS
The pointer shapes a view can declare (CursorShape::name spellings, in CursorShape::ALL order — a cursor.rs test pins the two together).
CUSTOM
C_FIELDS
Where a schema row lands in C when it is not simply the KuiSpec / KuiTextStyle field of the row’s snake_case name (c_field).
DERIVED_ONLY
The roles no view can declare, because the core derives them itself, with what derives each one. Every Role::ALL variant is on this list or in ROLES, and every_role_is_declarable_or_derived keeps both halves honest: a role exempted here has to be one a frame really does derive, so the list cannot absorb a variant that was simply forgotten from ROLES.
DOORS
EASINGS
The easing curves (Easing::name spellings, in Easing::ALL order — the test below pins the two together, as CURSORS is pinned).
ELEMENTS
ENV_FIELDS
EVENTS
EXPANDED
expanded names its state rather than being a flag: a disclosure that is shut has to say “collapsed”, and an absent flag cannot — absent has to keep meaning “this node does not expand” (AccessKit’s expanded, ARIA’s aria-expanded, are three-state for the same reason).
FAMILIES
The stock families (FontFamily::name spellings, in FontFamily::ALL order); a registered font travels as the font row’s handle instead.
GUEST
The reason most of Lua’s column is No: a script’s env is a reading the host hands it for one view, not a handle on the host. It declares a tree and answers events; what it registers, drives, times or reads back is the host’s.
LIVE
How urgently a reader should read a change it was not asked to read (crate::access::Live::name spellings, in wire order — a binding sends the index). off is the default and means “not a live region”.
LUA_ALIASES
A name one binding takes for a row it cannot spell the usual way, with the row’s own snake_case name: repeat is a Lua keyword, so that row also answers to CSS’s own name for it. The Lua binding remaps through this table, and the check below accepts both sides of it.
METRIC_ROLES
MOTIONS
The OS reduce-motion setting (crate::env::MotionPref::name spellings, in MotionPref::ALL order), unknown first for the same reason.
ORIENTATIONS
How a composite container arranges its items (crate::access::Orientation::name spellings), in wire order. Derived from the container’s dir and reported on its access node, never declared — so unlike ROLES this is not a prop’s enum, only a list the C header restates.
OVERSCROLLS
The overscroll row, in Overscroll::ALL’s order: a scroll gesture starting over a scroller at its limit goes on to the one around it, or stays. C spells it as the index plus one (KUI_OVERSCROLL_*), a zeroed field being auto.
PROPS
P_ACCENT
P_ALWAYS_ON_TOP
P_ANCHOR
P_ANIMATE
P_ASPECT_RATIO
P_BACKDROP_BLUR
P_BG
P_BORDER
P_BOUNCE
P_BUTTONS
P_CARET
P_CARET_SOLID
P_CENTER
P_CHECKED
P_CLICK_SOUND
P_COLOR
P_CROSS_ALIGN
P_CROSS_GAP
P_CURSOR
P_DELAY
P_DESCRIPTION
P_DIR
P_DISABLED
P_DROP_BG
P_EASING
P_ELLIPSIS
P_ENTER
P_EXIT
P_EXPANDED
P_FAMILY
P_FEATURES
P_FLOAT
P_FOCUSABLE
P_FOCUS_BG
P_FOCUS_REGION
P_FONT
P_GAP
P_GRADIENT
P_HEIGHT
P_HOVERABLE
P_HOVER_BG
P_HOVER_GROUP
P_HOVER_SOUND
P_IME_OFF
P_INDEX
P_INITIAL_FOCUS
P_KEEP_FOCUS
P_KEY
P_KEYFRAMES
P_KEY_FOCUS
P_KEY_UP
P_LABEL
P_LINE_HEIGHT
P_LIVE
P_MAIN_ALIGN
P_MAX_H
P_MAX_LINES
P_MAX_W
P_MIN_H
P_MIN_W
P_MIXED
P_MODAL
P_MODIFIER_KEYS
P_ON_BUTTON
P_ON_CHANGE
P_ON_CLICK
P_ON_CONTEXT_MENU
P_ON_DRAG
P_ON_DROP
P_ON_FOCUS
P_ON_FORCE_CLICK
P_ON_HOVER
P_ON_KEY
P_ON_LAYOUT
P_ON_SCROLL
P_OPACITY
P_OPTION_AS_ALT
P_OVERFLOW
P_OVERSCROLL
P_PAD
P_PIXEL_SNAP
P_PRESSED_BG
P_RADIUS
P_RADIUS_BL
P_RADIUS_BR
P_RADIUS_TL
P_RADIUS_TR
P_REPEAT
P_ROLE
P_ROW_COUNT
P_RULES
P_RULE_WIDTH
P_SCROLLBAR
P_SCROLLBAR_ACTIVE_COLOR
P_SCROLLBAR_COLOR
P_SCROLLBAR_WIDTH
P_SCROLL_AXES
P_SCROLL_MODS
P_SECURE_INPUT
P_SELECTABLE
P_SELECTED
P_SELECTION_ANCHOR
P_SHADOW_BLUR
P_SHADOW_COLOR
P_SHADOW_SPREAD
P_SHADOW_X
P_SHADOW_Y
P_SIZE
P_SLIDE
P_STRIKETHROUGH
P_TITLE
P_TOOLTIP
P_TRANSITION
P_UNDERLINE
P_UNDERLINE_COLOR
P_UNDERLINE_STYLE
P_VALUE_MAX
P_VALUE_MIN
P_VALUE_NOW
P_VALUE_STEP
P_VALUE_TEXT
P_WIDTH
P_WINDOW
P_WINDOWS
P_WRAP
P_WRAP_CHILDREN
REPEATS
CSS’s animation-direction values, in Repeat::ALL’s order.
RESOURCES
ROLES
The roles a view can declare (crate::access::Role::name spellings), in wire order — a binding sends the index. The purely derived roles are the ones DERIVED_ONLY names, and every other Role::ALL variant is here; textInput, multilineTextInput and line are, because an app that draws its own text declares them.
SCROLLBARS
The scrollbar row, in ScrollbarMode::ALL’s order: the stock overlay bar, none, or one that fades out when the scroll state has not changed. C spells it as the index plus one (KUI_SCROLLBAR_*), so a zeroed field is “unset”.
SCROLL_AXES
The scrollAxes row, in ScrollAxes::ALL’s order: the axes an onScroll node takes. C spells it as the index plus one (KUI_SCROLL_AXES_*), a zeroed field being both.
SIZE_MODE_CALC
The mode a sizing’s, a min’s or a max’s first binary slot holds for a size expression, whose spelling follows as a strref (v19).
SIZE_MODE_TREE
The mode for a size expression as data: a count of slots follows, then the expression in prefix code (crate::calc::from_code) — what the Node encoder sends for { clamp: [...] }, so the addon reads numbers and parses no text (v19).
SLIDER_ROWS_JSX
The rows the stock slider reads (widgets::slider_with): the value rows, its change tag, the access rows, and its width — the one piece of its look an app sizes.
SLIDER_ROWS_LUA
TEXT_ROWS_JSX
The rows a text reads (ElementDef::jsx_rows / lua_rows): the TextStyle rows and size, the composite the style is built from — and nothing else, because every door lowers a text as content plus a style and no spec (Core::text_node), so a container or access row on it reaches no tree. Before AR13 the element admitted every shared row, and <text live="polite">, <text role="heading">, <text label> and <text onClick> were dropped silently by all four bindings — no unknown-prop, and live-region-without-name could never fire for them. Pinned equal to the Target::Style rows by a test, so a style row added to PROPS is a row here or a red test.
TEXT_ROWS_LUA
THEME_ROLES
TOGGLE_ROWS_JSX
The rows a stock toggle — checkbox, radio, switch — reads (widgets::toggle_with): the button’s access rows, its state and no layout or paint row, since its look is its spec. mixed means something on a checkbox alone.
TOGGLE_ROWS_LUA
UNDERLINE_STYLES
underlineStyle / underline_style; UnderlineStyle::NAMES.
WINDOW_ROLES
WRAPS

Functions§

align_idx
apply
Applies one parsed value through its row. Errors on a kind mismatch, which can only come from a transport bug (each transport parses by the same Kind).
by_id
by_name
by_snake_name
c_field
The C spelling of a schema row, for docs.
color_hex_str
#rgb / #rrggbb / #rrggbbaa.
color_num
0 = transparent, anything else 0xRRGGBBAA.
cursor_idx
easing_idx
element_own
The props only this element takes, in spelling. An element the table does not know has none.
element_rows
The schema rows element reads, in spelling, when it does not read them all (ElementDef::jsx_rows); None for an element that takes every row, and for one the table does not know.
enum_index
Looks an enum name up in its row’s list.
known_prop
Is name a prop element reads — a schema row, a composite, an alias, or one of the element’s own? A binding drops everything else on the floor, so everything else is a diag::UNKNOWN_PROP warning. An element that names its rows reads those and its own, and nothing else.
lua_alias
direction → repeat: the schema name a Lua table key stands for, when it is not the name itself.
max_str
The string forms of a max: a size expression.
min_num
Binary min or max decode: (mode, value) → a clamp, the first two sizing modes (SIZE_MODE_CALC is read by the transport, which holds the strref).
min_str
The string forms of a min: "fit", or a size expression (crate::calc). A number arrives as a number.
odin_field
The Odin spelling of a schema row: the Spec or Text_Style field of its snake_case name, which is what the Odin generator names every field.
odin_from_c
A C cell in Odin’s words, for the rows where Odin’s door is C’s: the binding’s procedures are kui.h’s functions under kui. without their kui_, and its node and text fields are Spec. / Text_Style.. RESOURCES and ENV_FIELDS take their Odin column from here, and the Odin generator checks each name it produces.
repeat_idx
role_idx
The role at wire index i — ROLES’ order is the protocol, so this and ROLES are pinned to each other by every_declarable_role_name_is_a_real_role.
shared_prop
Is name a row every element reads — a schema row, a composite, an alias — as opposed to a misspelling? What known_prop answers for an element that admits only some rows still depends on this: a row the element does not read is dropped like a misspelling, but the warning can say so instead of hunting for a nearer spelling.
sizing_num
Binary sizing decode: (mode, value) → Sizing.
sizing_str
The string forms of a sizing: “fit” | “grow” | “N%” | a size expression (crate::calc).
snake_case
minWidth → min_width, radiusTL → radius_tl (a run of capitals is one word); names without capitals pass through.
suggest
The name an unknown one was probably meant to be: the same word in the other convention (hoverBg for hover_bg, onClick for onclick), which is what a wrong spelling almost always is. Nothing fuzzier — a confident suggestion or none.