@cognitap/radiant 0.0.91 → 0.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/library/a2ui/A2uiPlaceholder.d.ts +14 -0
  3. package/dist/library/a2ui/A2uiPlaceholder.d.ts.map +1 -0
  4. package/dist/library/a2ui/A2uiPlaceholder.js +44 -0
  5. package/dist/library/a2ui/A2uiPlaceholder.js.map +1 -0
  6. package/dist/library/a2ui/A2uiSurface.d.ts +33 -0
  7. package/dist/library/a2ui/A2uiSurface.d.ts.map +1 -0
  8. package/dist/library/a2ui/A2uiSurface.js +542 -0
  9. package/dist/library/a2ui/A2uiSurface.js.map +1 -0
  10. package/dist/library/a2ui/accessibility.d.ts +31 -0
  11. package/dist/library/a2ui/accessibility.d.ts.map +1 -0
  12. package/dist/library/a2ui/accessibility.js +108 -0
  13. package/dist/library/a2ui/accessibility.js.map +1 -0
  14. package/dist/library/a2ui/accessibilityRules.d.ts +28 -0
  15. package/dist/library/a2ui/accessibilityRules.d.ts.map +1 -0
  16. package/dist/library/a2ui/accessibilityRules.js +73 -0
  17. package/dist/library/a2ui/accessibilityRules.js.map +1 -0
  18. package/dist/library/a2ui/catalogGenerator.d.ts +29 -0
  19. package/dist/library/a2ui/catalogGenerator.d.ts.map +1 -0
  20. package/dist/library/a2ui/catalogGenerator.js +578 -0
  21. package/dist/library/a2ui/catalogGenerator.js.map +1 -0
  22. package/dist/library/a2ui/coerce.d.ts +16 -0
  23. package/dist/library/a2ui/coerce.d.ts.map +1 -0
  24. package/dist/library/a2ui/coerce.js +254 -0
  25. package/dist/library/a2ui/coerce.js.map +1 -0
  26. package/dist/library/a2ui/entries.d.ts +6 -0
  27. package/dist/library/a2ui/entries.d.ts.map +1 -0
  28. package/dist/library/a2ui/entries.js +277 -0
  29. package/dist/library/a2ui/entries.js.map +1 -0
  30. package/dist/library/a2ui/fixtures.d.ts +38 -0
  31. package/dist/library/a2ui/fixtures.d.ts.map +1 -0
  32. package/dist/library/a2ui/fixtures.js +389 -0
  33. package/dist/library/a2ui/fixtures.js.map +1 -0
  34. package/dist/library/a2ui/index.d.ts +17 -0
  35. package/dist/library/a2ui/index.d.ts.map +1 -0
  36. package/dist/library/a2ui/index.js +9 -0
  37. package/dist/library/a2ui/index.js.map +1 -0
  38. package/dist/library/a2ui/protocolErrors.d.ts +13 -0
  39. package/dist/library/a2ui/protocolErrors.d.ts.map +1 -0
  40. package/dist/library/a2ui/protocolErrors.js +48 -0
  41. package/dist/library/a2ui/protocolErrors.js.map +1 -0
  42. package/dist/library/a2ui/registry.d.ts +58 -0
  43. package/dist/library/a2ui/registry.d.ts.map +1 -0
  44. package/dist/library/a2ui/registry.js +128 -0
  45. package/dist/library/a2ui/registry.js.map +1 -0
  46. package/dist/library/a2ui/sanitize.d.ts +7 -0
  47. package/dist/library/a2ui/sanitize.d.ts.map +1 -0
  48. package/dist/library/a2ui/sanitize.js +54 -0
  49. package/dist/library/a2ui/sanitize.js.map +1 -0
  50. package/dist/library/a2ui/surfaceRuntime.d.ts +34 -0
  51. package/dist/library/a2ui/surfaceRuntime.d.ts.map +1 -0
  52. package/dist/library/a2ui/surfaceRuntime.js +284 -0
  53. package/dist/library/a2ui/surfaceRuntime.js.map +1 -0
  54. package/dist/library/catalog/actions.d.ts +40 -0
  55. package/dist/library/catalog/actions.d.ts.map +1 -0
  56. package/dist/library/catalog/actions.js +70 -0
  57. package/dist/library/catalog/actions.js.map +1 -0
  58. package/dist/library/catalog/coerce.d.ts +70 -0
  59. package/dist/library/catalog/coerce.d.ts.map +1 -0
  60. package/dist/library/catalog/coerce.js +332 -0
  61. package/dist/library/catalog/coerce.js.map +1 -0
  62. package/dist/library/catalog/index.d.ts +9 -0
  63. package/dist/library/catalog/index.d.ts.map +1 -0
  64. package/dist/library/catalog/index.js +6 -0
  65. package/dist/library/catalog/index.js.map +1 -0
  66. package/dist/library/catalog/radiantCatalog.d.ts +9 -0
  67. package/dist/library/catalog/radiantCatalog.d.ts.map +1 -0
  68. package/dist/library/catalog/radiantCatalog.js +902 -0
  69. package/dist/library/catalog/radiantCatalog.js.map +1 -0
  70. package/dist/library/catalog/types.d.ts +113 -0
  71. package/dist/library/catalog/types.d.ts.map +1 -0
  72. package/dist/library/catalog/types.js +27 -0
  73. package/dist/library/catalog/types.js.map +1 -0
  74. package/dist/library/catalog/validate.d.ts +31 -0
  75. package/dist/library/catalog/validate.d.ts.map +1 -0
  76. package/dist/library/catalog/validate.js +420 -0
  77. package/dist/library/catalog/validate.js.map +1 -0
  78. package/dist/library/components/Card/Card.d.ts +6 -2
  79. package/dist/library/components/Card/Card.d.ts.map +1 -1
  80. package/dist/library/components/Card/Card.js +12 -4
  81. package/dist/library/components/Card/Card.js.map +1 -1
  82. package/dist/library/components/Table/Table.d.ts +6 -2
  83. package/dist/library/components/Table/Table.d.ts.map +1 -1
  84. package/dist/library/components/Table/Table.js +10 -4
  85. package/dist/library/components/Table/Table.js.map +1 -1
  86. package/dist/library/index.d.ts +1 -1
  87. package/dist/library/index.d.ts.map +1 -1
  88. package/dist/library/presentation.d.ts +3 -0
  89. package/dist/library/presentation.d.ts.map +1 -1
  90. package/dist/library/styles.css +1 -1
  91. package/dist/library/themes/components.d.ts +6 -0
  92. package/dist/library/themes/components.d.ts.map +1 -1
  93. package/dist/library/themes/components.js +6 -0
  94. package/dist/library/themes/components.js.map +1 -1
  95. package/dist/library/themes/tokens.d.ts +4 -0
  96. package/dist/library/themes/tokens.d.ts.map +1 -1
  97. package/dist/library/themes/tokens.js +3 -0
  98. package/dist/library/themes/tokens.js.map +1 -1
  99. package/docs/accessibility.md +6 -0
  100. package/docs/architecture.md +13 -1
  101. package/docs/theming.md +13 -0
  102. package/package.json +17 -5
  103. package/src/a2ui/A2uiPlaceholder.tsx +64 -0
  104. package/src/a2ui/A2uiSurface.tsx +790 -0
  105. package/src/a2ui/accessibility.ts +145 -0
  106. package/src/a2ui/accessibilityRules.ts +106 -0
  107. package/src/a2ui/catalog.json +317 -0
  108. package/src/a2ui/catalogGenerator.ts +717 -0
  109. package/src/a2ui/coerce.ts +379 -0
  110. package/src/a2ui/entries.tsx +519 -0
  111. package/src/a2ui/fixtures.ts +402 -0
  112. package/src/a2ui/index.ts +50 -0
  113. package/src/a2ui/protocolErrors.ts +63 -0
  114. package/src/a2ui/registry.ts +221 -0
  115. package/src/a2ui/sanitize.ts +51 -0
  116. package/src/a2ui/surfaceRuntime.ts +317 -0
  117. package/src/catalog/actions.ts +108 -0
  118. package/src/catalog/coerce.ts +447 -0
  119. package/src/catalog/index.ts +67 -0
  120. package/src/catalog/radiantCatalog.ts +949 -0
  121. package/src/catalog/types.ts +159 -0
  122. package/src/catalog/validate.ts +454 -0
  123. package/src/components/Card/Card.tsx +35 -19
  124. package/src/components/Table/Table.tsx +16 -3
  125. package/src/index.ts +1 -1
  126. package/src/presentation.ts +3 -0
  127. package/src/themes/baseline.css +3 -0
  128. package/src/themes/components.ts +6 -0
  129. package/src/themes/tokens.ts +7 -0
@@ -0,0 +1,379 @@
1
+ import { peekValue } from '@a2ui/web_core/reactivity'
2
+ import { isComponentNode, ResolvedBinding, type ComponentNode } from '@a2ui/web_core/resolution'
3
+ import {
4
+ coerceSchemaProps,
5
+ coerceSchemaValue,
6
+ createDiagnosticLogger,
7
+ extractFallbackText,
8
+ humanizeNodeId,
9
+ isPlainRecord,
10
+ synthesizeSchemaFallback,
11
+ type CatalogDiagnostic,
12
+ type CatalogDiagnosticKind,
13
+ type DiagnosticLogger
14
+ } from '../catalog/coerce.js'
15
+ import type { CatalogJsonSchema } from '../catalog/types.js'
16
+ import type { A2uiRegistry, A2uiRegistryEntry } from './registry.js'
17
+ import { sanitizeA2uiMessages, type A2uiMessage } from './sanitize.js'
18
+
19
+ /** Internal action name used when a required A2UI action was missing and coerced to a no-op. */
20
+ export const COERCED_NOOP_ACTION_NAME = '__radiant_coerced_noop__'
21
+
22
+ export type CoerceA2uiMessagesResult = {
23
+ readonly messages: readonly A2uiMessage[]
24
+ readonly diagnostics: readonly CatalogDiagnostic[]
25
+ }
26
+
27
+ const ENVELOPE_KEYS = new Set(['id', 'catalogId', 'checks', 'metadata', 'accessibility'])
28
+
29
+ export const getRegistryEntry = (r: A2uiRegistry, name: string): A2uiRegistryEntry | undefined =>
30
+ Object.hasOwn(r.entries, name) ? r.entries[name] : undefined
31
+
32
+ const isDynamicExpression = (v: unknown): v is Record<string, unknown> =>
33
+ isPlainRecord(v) && ('@path' in v || 'path' in v || '@call' in v || 'call' in v)
34
+
35
+ const refDefName = (s: CatalogJsonSchema): string =>
36
+ typeof s.$ref === 'string' ? s.$ref.slice(s.$ref.lastIndexOf('/') + 1) : ''
37
+
38
+ type RefCoerceContext = {
39
+ readonly nodeId: string
40
+ readonly prop: string
41
+ readonly required: boolean
42
+ readonly rawProps: Readonly<Record<string, unknown>>
43
+ readonly log: DiagnosticLogger
44
+ readonly synthesized: Record<string, unknown>[]
45
+ readonly usedIds: Set<string>
46
+ readonly catalogId: string | undefined
47
+ }
48
+
49
+ type RefCoerceOutcome = {
50
+ readonly handled: true
51
+ readonly value?: unknown
52
+ readonly omit?: boolean
53
+ }
54
+
55
+ function reportRef(
56
+ ctx: RefCoerceContext,
57
+ kind: CatalogDiagnosticKind,
58
+ received: unknown,
59
+ used: unknown,
60
+ reason: string
61
+ ): RefCoerceOutcome {
62
+ ctx.log(kind, ctx.prop, received, used, reason)
63
+ return used === undefined ? { handled: true, omit: true } : { handled: true, value: used }
64
+ }
65
+
66
+ function failRef(
67
+ ctx: RefCoerceContext,
68
+ value: unknown,
69
+ fallback: unknown,
70
+ label: string
71
+ ): RefCoerceOutcome {
72
+ if (!ctx.required) {
73
+ return value === undefined
74
+ ? { handled: true, omit: true }
75
+ : reportRef(ctx, 'stripped', value, undefined, `Invalid ${label}.`)
76
+ }
77
+ return reportRef(
78
+ ctx,
79
+ value === undefined ? 'defaulted' : 'coerced',
80
+ value,
81
+ fallback,
82
+ value === undefined ? `Missing ${label}.` : `Invalid ${label}.`
83
+ )
84
+ }
85
+
86
+ function coercePrimitiveRef(
87
+ value: unknown,
88
+ ctx: RefCoerceContext,
89
+ schema: CatalogJsonSchema,
90
+ allowExpression: boolean,
91
+ canCoerce: (v: unknown) => boolean,
92
+ label: string
93
+ ): RefCoerceOutcome {
94
+ if (allowExpression && isDynamicExpression(value)) return { handled: true, value }
95
+ if (canCoerce(value)) {
96
+ return { handled: true, value: coerceSchemaValue(value, ctx.prop, schema, ctx) }
97
+ }
98
+ return failRef(ctx, value, synthesizeSchemaFallback(ctx.prop, schema, ctx), label)
99
+ }
100
+
101
+ const isCoercibleNumber = (v: unknown) =>
102
+ (typeof v === 'number' && Number.isFinite(v)) ||
103
+ (typeof v === 'string' && v.trim() !== '' && Number.isFinite(Number(v)))
104
+
105
+ const A2UI_REF_COERCERS: Record<
106
+ string,
107
+ (value: unknown, ctx: RefCoerceContext) => RefCoerceOutcome
108
+ > = {
109
+ DynamicString: (value, ctx) =>
110
+ coercePrimitiveRef(
111
+ value,
112
+ ctx,
113
+ ctx.required && ctx.prop === 'label' ? { type: 'string', minLength: 1 } : { type: 'string' },
114
+ true,
115
+ v => typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean',
116
+ 'DynamicString'
117
+ ),
118
+ DynamicNumber: (value, ctx) =>
119
+ coercePrimitiveRef(value, ctx, { type: 'number' }, true, isCoercibleNumber, 'DynamicNumber'),
120
+ Weight: (value, ctx) =>
121
+ coercePrimitiveRef(value, ctx, { type: 'number' }, false, isCoercibleNumber, 'Weight'),
122
+ DynamicBoolean: (value, ctx) =>
123
+ coercePrimitiveRef(
124
+ value,
125
+ ctx,
126
+ { type: 'boolean' },
127
+ true,
128
+ v => typeof v === 'boolean' || v === 'true' || v === 'false',
129
+ 'DynamicBoolean'
130
+ ),
131
+ DynamicStringList(value, ctx) {
132
+ if (
133
+ (Array.isArray(value) && value.every(i => typeof i === 'string')) ||
134
+ isDynamicExpression(value)
135
+ ) {
136
+ return { handled: true, value }
137
+ }
138
+ if (typeof value === 'string')
139
+ return reportRef(ctx, 'coerced', value, [value], 'Wrapped string.')
140
+ if (Array.isArray(value)) {
141
+ const list = value
142
+ .filter(i => typeof i === 'string' || typeof i === 'number' || typeof i === 'boolean')
143
+ .map(String)
144
+ return reportRef(ctx, 'coerced', value, list, 'Filtered DynamicStringList.')
145
+ }
146
+ return failRef(ctx, value, [], 'DynamicStringList')
147
+ },
148
+ Child(value, ctx) {
149
+ if (typeof value === 'string' && value) return { handled: true, value }
150
+ if (!ctx.required) return failRef(ctx, value, undefined, 'Child')
151
+ const base = `__coerced_child_${ctx.nodeId.replace(/[^A-Za-z0-9_]/g, '_') || 'node'}`
152
+ let synthId = base
153
+ for (let n = 2; ctx.usedIds.has(synthId); n++) synthId = `${base}_${n}`
154
+ ctx.usedIds.add(synthId)
155
+ ctx.synthesized.push({
156
+ id: synthId,
157
+ component: 'Text',
158
+ ...(ctx.catalogId ? { catalogId: ctx.catalogId } : {}),
159
+ text: extractFallbackText(ctx.rawProps) || humanizeNodeId(ctx.nodeId)
160
+ })
161
+ return failRef(ctx, value, synthId, 'Child')
162
+ },
163
+ ChildList(value, ctx) {
164
+ if (Array.isArray(value) && value.every(i => typeof i === 'string' && Boolean(i))) {
165
+ return { handled: true, value }
166
+ }
167
+ if (
168
+ isPlainRecord(value) &&
169
+ typeof value.componentId === 'string' &&
170
+ typeof value.path === 'string'
171
+ ) {
172
+ return { handled: true, value }
173
+ }
174
+ if (typeof value === 'string' && value) {
175
+ return reportRef(ctx, 'coerced', value, [value], 'Wrapped child ID.')
176
+ }
177
+ if (Array.isArray(value)) {
178
+ const ids = value.filter((i): i is string => typeof i === 'string' && Boolean(i))
179
+ return reportRef(ctx, 'coerced', value, ids, 'Filtered ChildList.')
180
+ }
181
+ return failRef(ctx, value, [], 'ChildList')
182
+ },
183
+ Action: (value, ctx) =>
184
+ isPlainRecord(value) && ('event' in value || 'functionCall' in value)
185
+ ? { handled: true, value }
186
+ : failRef(ctx, value, { event: { name: COERCED_NOOP_ACTION_NAME } }, 'Action')
187
+ }
188
+
189
+ function coerceUnknownComponent(
190
+ raw: Readonly<Record<string, unknown>>,
191
+ id: string,
192
+ componentName: string,
193
+ diagnostics: CatalogDiagnostic[]
194
+ ): Record<string, unknown> {
195
+ diagnostics.push({
196
+ kind: 'error',
197
+ code: 'UNKNOWN_COMPONENT_TYPE',
198
+ nodeId: id,
199
+ component: componentName || 'unknown',
200
+ prop: 'component',
201
+ received: raw.component,
202
+ used: 'Text',
203
+ reason: 'Unknown component; degraded to Text.'
204
+ })
205
+ return {
206
+ id,
207
+ component: 'Text',
208
+ ...(typeof raw.catalogId === 'string' ? { catalogId: raw.catalogId } : {}),
209
+ text: extractFallbackText(raw)
210
+ }
211
+ }
212
+
213
+ const ACCESSIBLE_NAME_COMPONENTS = new Set(['ChoicePicker', 'Slider'])
214
+
215
+ function hasUsableDynamicLabel(value: unknown): boolean {
216
+ if (isDynamicExpression(value)) return true
217
+ if (typeof value === 'string') return value.trim().length > 0
218
+ return (typeof value === 'number' && Number.isFinite(value)) || typeof value === 'boolean'
219
+ }
220
+
221
+ function coerceKnownComponent(
222
+ raw: Readonly<Record<string, unknown>>,
223
+ id: string,
224
+ entry: A2uiRegistryEntry,
225
+ diagnostics: CatalogDiagnostic[],
226
+ synthesized: Record<string, unknown>[],
227
+ usedIds: Set<string>
228
+ ): Record<string, unknown> {
229
+ const envelope: Record<string, unknown> = {}
230
+ const body: Record<string, unknown> = {}
231
+ for (const [k, v] of Object.entries(raw)) {
232
+ if (ENVELOPE_KEYS.has(k)) envelope[k] = v
233
+ else body[k] = v
234
+ }
235
+ const catalogId = typeof raw.catalogId === 'string' ? raw.catalogId : undefined
236
+ const result = coerceSchemaProps(entry.schema, body, {
237
+ nodeId: id,
238
+ component: entry.name,
239
+ customPropCoercer(value, ctx) {
240
+ const coercer = A2UI_REF_COERCERS[refDefName(ctx.propSchema)]
241
+ return coercer
242
+ ? coercer(value, { ...ctx, synthesized, usedIds, catalogId })
243
+ : { handled: false }
244
+ }
245
+ })
246
+ diagnostics.push(...result.diagnostics)
247
+ const props: Record<string, unknown> = { ...result.props }
248
+ const log = createDiagnosticLogger(diagnostics, id, entry.name)
249
+
250
+ if (entry.name === 'ChoicePicker' && Array.isArray(props.options)) {
251
+ const seen = new Set<string>()
252
+ const deduped: unknown[] = []
253
+ for (const option of props.options) {
254
+ if (isPlainRecord(option) && typeof option.value === 'string') {
255
+ if (seen.has(option.value)) continue
256
+ seen.add(option.value)
257
+ }
258
+ deduped.push(option)
259
+ }
260
+ if (deduped.length !== props.options.length) {
261
+ log('coerced', 'options', props.options, deduped, 'Removed duplicate option values.')
262
+ props.options = deduped
263
+ }
264
+ }
265
+
266
+ if (ACCESSIBLE_NAME_COMPONENTS.has(entry.name)) {
267
+ const accessibility = isPlainRecord(envelope.accessibility) ? envelope.accessibility : undefined
268
+ if (!hasUsableDynamicLabel(props.label) && !hasUsableDynamicLabel(accessibility?.label)) {
269
+ const fallback = humanizeNodeId(id)
270
+ log(
271
+ raw.label === undefined ? 'defaulted' : 'coerced',
272
+ 'label',
273
+ raw.label,
274
+ fallback,
275
+ 'Missing accessible label.'
276
+ )
277
+ props.label = fallback
278
+ }
279
+ }
280
+
281
+ return { ...envelope, ...props, id, component: entry.name }
282
+ }
283
+
284
+ function coerceComponentList(
285
+ rawComponents: readonly unknown[],
286
+ registry: A2uiRegistry,
287
+ diagnostics: CatalogDiagnostic[]
288
+ ): Record<string, unknown>[] {
289
+ const usedIds = new Set<string>()
290
+ for (const item of rawComponents) {
291
+ if (isPlainRecord(item) && typeof item.id === 'string' && item.id) usedIds.add(item.id)
292
+ }
293
+ const output: Record<string, unknown>[] = []
294
+ const synthesized: Record<string, unknown>[] = []
295
+
296
+ for (let i = 0; i < rawComponents.length; i++) {
297
+ const raw = rawComponents[i]
298
+ if (!isPlainRecord(raw)) continue
299
+ const id = typeof raw.id === 'string' && raw.id ? raw.id : `component_${i}`
300
+ const name = typeof raw.component === 'string' ? raw.component : ''
301
+ const entry = getRegistryEntry(registry, name)
302
+ output.push(
303
+ entry
304
+ ? coerceKnownComponent(raw, id, entry, diagnostics, synthesized, usedIds)
305
+ : coerceUnknownComponent(raw, id, name, diagnostics)
306
+ )
307
+ }
308
+
309
+ output.push(...synthesized)
310
+ return output
311
+ }
312
+
313
+ /** Sanitizes and coerces incoming A2UI 1.0 messages against the active registry. */
314
+ export function coerceA2uiMessages(
315
+ messages: readonly A2uiMessage[],
316
+ registry: A2uiRegistry
317
+ ): CoerceA2uiMessagesResult {
318
+ const sanitized = sanitizeA2uiMessages(messages)
319
+ const diagnostics: CatalogDiagnostic[] = []
320
+ const coerced = sanitized.map(m => {
321
+ if (!isPlainRecord(m)) return m
322
+ if (isPlainRecord(m.createSurface) && Array.isArray(m.createSurface.components)) {
323
+ return {
324
+ ...m,
325
+ createSurface: {
326
+ ...m.createSurface,
327
+ components: coerceComponentList(m.createSurface.components, registry, diagnostics)
328
+ }
329
+ }
330
+ }
331
+ if (isPlainRecord(m.updateComponents) && Array.isArray(m.updateComponents.components)) {
332
+ return {
333
+ ...m,
334
+ updateComponents: {
335
+ ...m.updateComponents,
336
+ components: coerceComponentList(m.updateComponents.components, registry, diagnostics)
337
+ }
338
+ }
339
+ }
340
+ return m
341
+ })
342
+ return { messages: coerced, diagnostics }
343
+ }
344
+
345
+ /** Extracts readable fallback text from a resolved `ComponentNode` for error boundaries. */
346
+ export function extractA2uiNodeFallbackText(
347
+ node: ComponentNode,
348
+ props?: Readonly<Record<string, unknown>>,
349
+ visited: Set<ComponentNode> = new Set()
350
+ ): string {
351
+ if (visited.has(node)) return ''
352
+ visited.add(node)
353
+ let resolved = props
354
+ if (!resolved) {
355
+ try {
356
+ resolved = peekValue(node.props)
357
+ } catch {
358
+ return ''
359
+ }
360
+ }
361
+ if (!resolved) return ''
362
+ const unwrapped: Record<string, unknown> = {}
363
+ for (const [k, v] of Object.entries(resolved)) {
364
+ unwrapped[k] = v instanceof ResolvedBinding ? v.value : v
365
+ }
366
+ const own = extractFallbackText(unwrapped)
367
+ if (own) return own
368
+ if (isComponentNode(resolved.child)) {
369
+ return extractA2uiNodeFallbackText(resolved.child, undefined, visited)
370
+ }
371
+ if (Array.isArray(resolved.children)) {
372
+ return resolved.children
373
+ .filter(isComponentNode)
374
+ .map(c => extractA2uiNodeFallbackText(c, undefined, visited))
375
+ .filter(Boolean)
376
+ .join(' ')
377
+ }
378
+ return ''
379
+ }