MCPcopy Index your code
hub / github.com/bernaferrari/FigmaToCode / codegenMode

Function codegenMode

apps/plugin/plugin-src/code.ts:245–441  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

243};
244
245const codegenMode = async () => {
246 console.log("[DEBUG] codegenMode - Starting codegen mode initialization");
247 // figma.showUI(__html__, { visible: false });
248 await getUserSettings();
249
250 figma.codegen.on(
251 "generate",
252 async ({ language, node }: CodegenEvent): Promise<CodegenResult[]> => {
253 console.log(
254 `[DEBUG] codegen.generate - Language: ${language}, Node: id=${node.id}, type=${node.type}`,
255 );
256
257 const convertedSelection = await nodesToJSON([node], userPluginSettings);
258 console.log(
259 "[DEBUG] codegen.generate - Converted selection count:",
260 convertedSelection.length,
261 );
262
263 switch (language) {
264 case "html":
265 return [
266 {
267 title: "Code",
268 code: (
269 await htmlMain(
270 convertedSelection,
271 { ...userPluginSettings, htmlGenerationMode: "html" },
272 true,
273 )
274 ).html,
275 language: "HTML",
276 },
277 {
278 title: "Text Styles",
279 code: htmlCodeGenTextStyles(userPluginSettings),
280 language: "HTML",
281 },
282 ];
283 case "html_jsx":
284 return [
285 {
286 title: "Code",
287 code: (
288 await htmlMain(
289 convertedSelection,
290 { ...userPluginSettings, htmlGenerationMode: "jsx" },
291 true,
292 )
293 ).html,
294 language: "HTML",
295 },
296 {
297 title: "Text Styles",
298 code: htmlCodeGenTextStyles(userPluginSettings),
299 language: "HTML",
300 },
301 ];
302

Callers 1

code.tsFile · 0.85

Calls 11

nodesToJSONFunction · 0.90
htmlMainFunction · 0.90
htmlCodeGenTextStylesFunction · 0.90
tailwindMainFunction · 0.90
flutterMainFunction · 0.90
flutterCodeGenTextStylesFunction · 0.90
swiftuiMainFunction · 0.90
swiftUICodeGenTextStylesFunction · 0.90
getUserSettingsFunction · 0.85

Tested by

no test coverage detected