Skip to main content

Module expr

Module expr 

Source
Expand description

The macro template’s value language (catalog/macros.json $comment): {props.x} paths with |fallback, len(path), range(n), !path, string interpolation, and the $map / $cond / $eq / $lt / $add / $sub / $clamp / $percent / $coalesce / $text / $not / $fill value objects. Mirrors src/expr.ts line by line.

Round 1 (docs/round-1-contract.md §1): an input may be an A2UI DYNAMIC value — a data binding {path} or a function call {call, args} — which has no value at expansion time. The evaluator then EMITS a call over the core functions that the renderer evaluates at bind time (data::bind_tree) instead of computing. A whole-string {props.x} that is a MEMBER passes a dynamic value through unchanged (two-way binding survives); as an OPERAND of a $-object a |fallback is kept as fallback{value, default}. $fill ALWAYS emits fill (its template is a $string.<id> the surface’s string table resolves at bind time).

JavaScript’s undefined is None; JSON null is Some(Value::Null).

Structs§

ExprContext
What a template expression can see: the node id, its props, and the $each loop variables (item, index, …).

Enums§

Decided
A condition decided now (Bool) or the dynamic value it depends on.

Constants§

CORE_FUNCTION_NAMES
The core function names in catalog order (set = the action; the format functions live in format).
MAX_RANGE_ITEMS
The most indexes range(n) yields (R8 F51): a Rating’s max of 1e8 or 1e300 would otherwise allocate that many items before the component budget could refuse them. Equals limits::MAX_TEMPLATE_ITEMS; a larger n is silently clamped (the reducer’s maxComponents reports the overflow). Mirrors MAX_RANGE_ITEMS in src/expr.ts.

Functions§

call
{call: name, args} with undefined args dropped (the TS call).
clamp_number
clamp: the value as a number held inside [min, max]; a missing bound (undefined or null) does not clamp; min wins when max < min.
core_function
The core value functions (core.catalog.json functions.core; set is an action, data::run_action) once the arguments are resolved: the reference every client function table mirrors (src/expr.ts CORE_FUNCTIONS). Outer None = not a core function; inner None = undefined.
eval_condition
A condition decided NOW: a dynamic condition counts as true (the part exists; visible carries the bound test, see macros).
eval_condition_value
A condition: a string expression or a value object ($eq …). Bool when it can be decided now; the dynamic value when it cannot.
eval_expr
One expression: len(path), range(n), path|fallback, !path, path. The function forms wrap the whole expression and are tried first, so a fallback inside their parentheses stays theirs.
eval_value
Any template value: strings interpolate, arrays and objects recurse, the $-objects compute (or emit a call when an input is dynamic). None (undefined) results are dropped from objects and arrays; null is kept.
fill_template
fill: the template (already resolved through the string table) with its {name} placeholders filled from params (strings::format_string).
filter_items
Round 4 (VAPP-103) filter (src/expr.ts filterItems): the items of an array that match, in order. where = field → value, every entry must hold (eq equality); an entry whose value is null or “” does NOT constrain. query = a case-insensitive substring of ANY of fields (the item’s own string and number values when fields is absent; a string or number item matches itself); a missing or blank query does not constrain. Not an array → [].
is_binding
An A2UI data binding: an object with exactly one key, path (a string).
is_call
An A2UI function call: an object with a string call.
is_dynamic
A value the expander cannot evaluate: the renderer will.
js_round
JS Math.round (half rounds UP, also for negatives).
percent
$percent’s arithmetic, shared with the core percent function: the share of max as “N%”, clamped to 0..100, two decimals.
to_number
The TS toNumber: numbers stay, everything else Number(v ?? 0) || 0.
truthy
undefined, null, false and "" are false; 0 is TRUE (a count of zero still shows).
truthy_opt
truthy over an optional (None = undefined = false).
values_equal
eq (and $eq): strict equality, except that a NUMBER and a string spelling that number are equal (5 vs "5": form and URL state arrive as strings). Nothing else coerces (0 vs "", 1 vs true differ).