* Build children from ComponentArrayReference * In streaming mode, tracks pending child components that are not yet defined
(
props: Record<string, unknown>,
surface: Surface,
visited: Set<string>,
streamingState?: StreamingState,
)
| 713 | * In streaming mode, tracks pending child components that are not yet defined |
| 714 | */ |
| 715 | private buildChildren( |
| 716 | props: Record<string, unknown>, |
| 717 | surface: Surface, |
| 718 | visited: Set<string>, |
| 719 | streamingState?: StreamingState, |
| 720 | ): AnyComponentNode[] { |
| 721 | const childrenRef = props.children as ComponentArrayReference | undefined; |
| 722 | if (!childrenRef) { |
| 723 | return []; |
| 724 | } |
| 725 | |
| 726 | const children: AnyComponentNode[] = []; |
| 727 | |
| 728 | // Handle explicit list |
| 729 | if (childrenRef.explicitList) { |
| 730 | for (const childId of childrenRef.explicitList) { |
| 731 | const childDef = surface.components.get(childId); |
| 732 | if (!childDef) { |
| 733 | // In streaming mode, track pending components |
| 734 | if (streamingState) { |
| 735 | streamingState.pendingComponentIds.add(childId); |
| 736 | streamingState.isStreaming = true; |
| 737 | } |
| 738 | console.warn(`Child component ${childId} not found. Skipping.`); |
| 739 | continue; |
| 740 | } |
| 741 | const childNode = this.buildComponentNode(childDef, surface, visited, streamingState); |
| 742 | if (childNode) { |
| 743 | children.push(childNode); |
| 744 | } |
| 745 | } |
| 746 | } |
| 747 | |
| 748 | // Handle template |
| 749 | if (childrenRef.template) { |
| 750 | const { componentId, dataBinding } = childrenRef.template; |
| 751 | const templateDef = surface.components.get(componentId); |
| 752 | if (!templateDef) { |
| 753 | // In streaming mode, track pending template component |
| 754 | if (streamingState) { |
| 755 | streamingState.pendingComponentIds.add(componentId); |
| 756 | streamingState.isStreaming = true; |
| 757 | } |
| 758 | console.warn(`Template component ${componentId} not found.`); |
| 759 | return children; |
| 760 | } |
| 761 | |
| 762 | // Get data array from binding |
| 763 | const dataArray = getData(surface.dataModel, dataBinding); |
| 764 | if (!Array.isArray(dataArray)) { |
| 765 | return children; |
| 766 | } |
| 767 | |
| 768 | // Create instance for each data item |
| 769 | for (let i = 0; i < dataArray.length; i++) { |
| 770 | const itemPath = `${dataBinding}/${i}`; |
| 771 | const childNode = this.buildTemplateInstance( |
| 772 | templateDef, |
no test coverage detected