(value: unknown, paramMap: ParamMap, collector: StatementCollector)
| 122 | // ─── Value serializer ──────────────────────────────────────────────────────── |
| 123 | |
| 124 | function serializeValue(value: unknown, paramMap: ParamMap, collector: StatementCollector): string { |
| 125 | if (value === null || value === undefined) return "null"; |
| 126 | if (typeof value === "string") return JSON.stringify(value); |
| 127 | if (typeof value === "number") return String(value); |
| 128 | if (typeof value === "boolean") return value ? "true" : "false"; |
| 129 | |
| 130 | // ElementNode — check before isASTNode (they don't overlap, but order is clear) |
| 131 | if (isElementNode(value)) { |
| 132 | return serializeElementValue(value, paramMap, collector); |
| 133 | } |
| 134 | |
| 135 | // ASTNode (surviving runtime expressions in dynamic props) |
| 136 | if (isASTNode(value)) { |
| 137 | return serializeASTNode(value); |
| 138 | } |
| 139 | |
| 140 | // Array |
| 141 | if (Array.isArray(value)) { |
| 142 | const items = value.map((el) => serializeValue(el, paramMap, collector)); |
| 143 | return "[" + items.join(", ") + "]"; |
| 144 | } |
| 145 | |
| 146 | // Plain object |
| 147 | if (typeof value === "object") { |
| 148 | const obj = value as Record<string, unknown>; |
| 149 | const entries = Object.entries(obj).map( |
| 150 | ([k, v]) => `${k}: ${serializeValue(v, paramMap, collector)}`, |
| 151 | ); |
| 152 | return "{" + entries.join(", ") + "}"; |
| 153 | } |
| 154 | |
| 155 | return "null"; |
| 156 | } |
| 157 | |
| 158 | /** Serialize an ElementNode — either as a reference (if it has statementId) or inline. */ |
| 159 | function serializeElementValue( |
no test coverage detected