A2UI
A2UI copied to clipboard
refactor(binders): make component binders schema-driven for child resolution
This PR refactors the component binders (both generic and Angular) to dynamically resolve child component references based on their schema types rather than relying on hardcoded keyword names (like child, children, trigger, content).
Key Changes
- Core Schemas:
- Added branded typing (
.brand<'ComponentId'>()) toComponentIdSchemato distinguish IDs from arbitrary strings at compile time. - Introduced
A2uiTypeDefand tagged core schemas (ComponentId,ChildList,Action, etc.) with runtime behavioral tags (a2uiType).
- Added branded typing (
- Generic Binder (
web_core):- Updated
getFieldBehaviorto look up behavior flags using thea2uiTypemetadata, with a fallback heuristic. - Implemented recursive
CHILDandSTRUCTURALresolution insideresolveAndBindusingresolveNested. - Refactored
ResolveA2uiPropto recursively map nested object and array properties at compile-time.
- Updated
- Angular Binder:
- Rewrote Angular
ComponentBinderto dynamically scrape schema behaviors and resolve nested child component models and actions. - Updated Angular
types.tsto implement a two-stage recursive type mapping helper (ResolveAngularProp) supporting branded types. - Simplified
TabsComponentby removing the manual child resolution logic since the binder now outputs fully resolvedChildreferences.
- Rewrote Angular
- Testing:
- Simplified
waitForConditionintest_utils.tsto use a cleaner timing loop with a final last-chance condition check to prevent race conditions on timeout boundary. - Updated Angular and web_core specs to match the updated typings.
- Simplified
Fixes #1528