(el: ElementNode, evalCtx: EvalContext)
| 32 | * Uses the unified evaluator with schema context for reactive-aware evaluation. |
| 33 | */ |
| 34 | export function evaluateElementProps(el: ElementNode, evalCtx: EvalContext): ElementNode { |
| 35 | if (el.hasDynamicProps === false) return el; |
| 36 | |
| 37 | const schemaCtx: SchemaContext = { library: evalCtx.library }; |
| 38 | const def = evalCtx.library.components[el.typeName]; |
| 39 | const evaluated: Record<string, unknown> = {}; |
| 40 | |
| 41 | for (const [key, value] of Object.entries(el.props)) { |
| 42 | const propSchema = def?.props?.shape?.[key]; |
| 43 | try { |
| 44 | evaluated[key] = evaluatePropValue(value, evalCtx, schemaCtx, propSchema); |
| 45 | } catch (e) { |
| 46 | // Use raw value as fallback for this prop, collect structured error |
| 47 | evaluated[key] = value; |
| 48 | const msg = e instanceof Error ? e.message : String(e); |
| 49 | evalCtx.errors?.push({ |
| 50 | source: "runtime", |
| 51 | code: "runtime-error", |
| 52 | component: el.typeName, |
| 53 | statementId: el.statementId, |
| 54 | message: `Evaluating prop "${key}" on ${el.typeName} failed: ${msg}`, |
| 55 | hint: `Check the expression used for prop "${key}"`, |
| 56 | }); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | return { ...el, props: evaluated }; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Evaluate a single prop value with schema awareness. |
no test coverage detected