(node: Protocol, state: GraphState, assetFilesList: string, progressInfo: string)
| 108 | * Frames compose multiple child components based on layout |
| 109 | */ |
| 110 | export async function generateFrame(node: Protocol, state: GraphState, assetFilesList: string, progressInfo: string): Promise<void> { |
| 111 | const frameName = node.data.name; |
| 112 | logger.printInfoLog(`${progressInfo} 🖼️ Generating Frame: ${frameName}`); |
| 113 | |
| 114 | // Build children imports information |
| 115 | const childrenImports = (node.children || []).map(child => ({ |
| 116 | name: child.data.name || '', |
| 117 | path: child.data.path, |
| 118 | })); |
| 119 | |
| 120 | // Detect rendering modes |
| 121 | const renderingModes = detectRenderingModes(node); |
| 122 | |
| 123 | // Generate prompt |
| 124 | const prompt = generateFramePrompt({ |
| 125 | frameDetails: JSON.stringify(node.data), |
| 126 | childrenImports: JSON.stringify(childrenImports), |
| 127 | styling: JSON.stringify(DEFAULT_STYLING), |
| 128 | assetFiles: assetFilesList, |
| 129 | renderingModes, |
| 130 | }); |
| 131 | |
| 132 | // Call AI model |
| 133 | const code = await callModel({ |
| 134 | question: prompt, |
| 135 | imageUrls: state.figmaInfo.thumbnail, |
| 136 | }); |
| 137 | |
| 138 | // Save generated files |
| 139 | const componentPath = node.data.path || ''; |
| 140 | const filePath = workspaceManager.resolveAppSrc(state.workspace, workspaceManager.resolveComponentPath(componentPath)); |
| 141 | saveGeneratedCode(code, filePath); |
| 142 | logger.printSuccessLog(`Successfully generated frame: ${frameName}`); |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Generate a component (leaf or reusable) |
no test coverage detected