( sceneNode: Array<SceneNode>, settings: PluginSettings, isPreview: boolean = false, )
| 309 | } |
| 310 | |
| 311 | export const htmlMain = async ( |
| 312 | sceneNode: Array<SceneNode>, |
| 313 | settings: PluginSettings, |
| 314 | isPreview: boolean = false, |
| 315 | ): Promise<HtmlOutput> => { |
| 316 | isPreviewGlobal = isPreview; |
| 317 | previousExecutionCache = []; |
| 318 | cssCollection = {}; |
| 319 | resetClassNameCounters(); // Reset counters for each new generation |
| 320 | |
| 321 | let htmlContent = await htmlWidgetGenerator(sceneNode, settings); |
| 322 | |
| 323 | // remove the initial \n that is made in Container. |
| 324 | if (htmlContent.length > 0 && htmlContent.startsWith("\n")) { |
| 325 | htmlContent = htmlContent.slice(1, htmlContent.length); |
| 326 | } |
| 327 | |
| 328 | // Always return an object with html property |
| 329 | const output: HtmlOutput = { html: htmlContent }; |
| 330 | |
| 331 | // Handle different HTML generation modes |
| 332 | const mode = settings.htmlGenerationMode || "html"; |
| 333 | |
| 334 | if (mode !== "html") { |
| 335 | // Generate component code for non-html modes |
| 336 | output.html = generateComponentCode(htmlContent, sceneNode, mode); |
| 337 | |
| 338 | // For svelte mode, we don't need separate CSS as it's included in the component |
| 339 | if (mode === "svelte" && Object.keys(cssCollection).length > 0) { |
| 340 | // CSS is already included in the Svelte component |
| 341 | } |
| 342 | } else if (Object.keys(cssCollection).length > 0) { |
| 343 | // For plain HTML with CSS, include CSS separately |
| 344 | output.css = getCollectedCSS(); |
| 345 | } |
| 346 | |
| 347 | return output; |
| 348 | }; |
| 349 | |
| 350 | export const generateHTMLPreview = async ( |
| 351 | nodes: SceneNode[], |
no test coverage detected