Skip to main content

Module macros

Module macros 

Source
Expand description

The macro expander: applies catalog/macros.json (plus extension macros) to a normalized tree until every node is native. Mirrors src/macros.ts; fixtures/catalog-macros.json locks the output.

Round 1 (docs/round-1-contract.md §1–2): a $if/$any that cannot be decided at expansion time (a bound input) emits the part WITH visible = the bound condition; "$slot:name" children splice an author slot in place and a template slots entry may be a template node; a RESPONSIVE prop ({base, sm?, md?…}) is expanded per breakpoint into @media (min-width: $breakpoint.<bp>) blocks on every part whose style it changes; a $set on a part whose macro prop is BOUND adds the set write-back to that part’s action (two-way binding without a host round trip); a part’s $a11y becomes the node’s accessibility (role, states, name: §6).

Statics§

BREAKPOINTS
The breakpoint names in ascending order (tokens.json breakpoint).

Functions§

expand_macros
The normalized tree with every macro (core + extensions) expanded into natives, recipes attached. Pure: the input is not mutated. Err when an expansion nests deeper than 16 macros. Expansion problems are dropped; see expand_macros_with_issues.
expand_macros_with_issues
expand_macros plus the expansion problems (an author function that replaces a $set write-back), deduplicated per node: the TS expandMacros(root, {issues}).
is_responsive_value
{base, sm?, md?, lg?, xl?}: an object with base and only breakpoint keys besides.
props_at
The author’s props with every responsive object replaced by its value at breakpoint (None = base).
responsive_at
The value a responsive prop takes at a breakpoint: the nearest defined key at or below it, base under the first one. None = the base.