A2UI icon indicating copy to clipboard operation
A2UI copied to clipboard

refactor(binders): make component binders schema-driven for child resolution

Open josemontespg opened this issue 6 months ago • 0 comments

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'>()) to ComponentIdSchema to distinguish IDs from arbitrary strings at compile time.
    • Introduced A2uiTypeDef and tagged core schemas (ComponentId, ChildList, Action, etc.) with runtime behavioral tags (a2uiType).
  • Generic Binder (web_core):
    • Updated getFieldBehavior to look up behavior flags using the a2uiType metadata, with a fallback heuristic.
    • Implemented recursive CHILD and STRUCTURAL resolution inside resolveAndBind using resolveNested.
    • Refactored ResolveA2uiProp to recursively map nested object and array properties at compile-time.
  • Angular Binder:
    • Rewrote Angular ComponentBinder to dynamically scrape schema behaviors and resolve nested child component models and actions.
    • Updated Angular types.ts to implement a two-stage recursive type mapping helper (ResolveAngularProp) supporting branded types.
    • Simplified TabsComponent by removing the manual child resolution logic since the binder now outputs fully resolved Child references.
  • Testing:
    • Simplified waitForCondition in test_utils.ts to 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.

Fixes #1528

josemontespg avatar Jun 05 '26 17:06 josemontespg