* Generate children rendering instructions based on detected modes
(modes: { hasStates: boolean; hasIndependentChildren: boolean })
| 96 | * Generate children rendering instructions based on detected modes |
| 97 | */ |
| 98 | function generateChildrenPropsInstructions(modes: { hasStates: boolean; hasIndependentChildren: boolean }): string { |
| 99 | const instructions: string[] = []; |
| 100 | |
| 101 | if (modes.hasStates) { |
| 102 | instructions.push(` |
| 103 | - **List Rendering (States-based)**: |
| 104 | - Check if \`<frame_details>\` contains a \`states\` property (array). |
| 105 | - Each state entry has: \`state\` (data array), \`componentName\`, \`componentPath\`. |
| 106 | - Implementation: |
| 107 | \`\`\`tsx |
| 108 | import ComponentName from 'path'; |
| 109 | |
| 110 | {states[0].state.map((item, index) => ( |
| 111 | <ComponentName key={index} {...item} /> |
| 112 | ))} |
| 113 | \`\`\` |
| 114 | - **CRITICAL - Only Use State Data**: |
| 115 | - **ONLY** pass props that exist in the state data objects. |
| 116 | - **DO NOT** add extra props like \`content\`, \`className\`, or any other fields not present in state. |
| 117 | - **DO NOT** create or invent additional data - use exactly what's in the state array. |
| 118 | - Example: If state has \`{iconSrc, title, description}\`, only pass those three props. |
| 119 | - **Asset Imports**: If state data contains image paths (e.g., \`imageSrc\`, \`iconSrc\`), |
| 120 | import them at the top and pass as values.`); |
| 121 | } |
| 122 | |
| 123 | if (modes.hasIndependentChildren) { |
| 124 | instructions.push(` |
| 125 | - **Independent Components (No Props) - CRITICAL**: |
| 126 | - If a child has NO \`componentName\` and NO \`properties\`, render as \`<ComponentName />\` without any props. |
| 127 | - These components use default values or hardcoded content internally.`); |
| 128 | } |
| 129 | |
| 130 | return instructions.join('\n'); |
| 131 | } |
| 132 | |
| 133 | export const generateFramePrompt = ({ |
| 134 | childrenImports, |
no test coverage detected