MCPcopy Create free account
hub / github.com/MigoXLab/coderio / simplifyFigmaNodeForContent

Function simplifyFigmaNodeForContent

src/nodes/process/structure/utils.ts:17–59  ·  view source on GitHub ↗
(node: FigmaFrameInfo)

Source from the content-addressed store, hash-verified

15 * @returns Simplified node with only essential fields
16 */
17export function simplifyFigmaNodeForContent(node: FigmaFrameInfo): SimplifiedFigmaNode {
18 const simple: SimplifiedFigmaNode = {
19 id: node.id,
20 name: node.name,
21 type: node.type,
22 };
23
24 // Check both url (set by Asset node) and thumbnailUrl (original Figma field)
25 const imageUrl = (node as FigmaFrameInfo & { url?: string }).url || node.thumbnailUrl;
26 if (imageUrl) {
27 simple.url = imageUrl;
28 }
29
30 if (node.cornerRadius !== undefined) {
31 simple.cornerRadius = node.cornerRadius;
32 }
33
34 if (node.characters !== undefined && node.characters !== null) {
35 simple.characters = node.characters;
36 }
37
38 if (node.visible !== undefined) simple.visible = node.visible;
39
40 if (node.absoluteBoundingBox) simple.absoluteBoundingBox = node.absoluteBoundingBox;
41
42 if (node.children && Array.isArray(node.children)) {
43 simple.children = node.children.map(simplifyFigmaNodeForContent);
44 }
45
46 if (node.inlineStyles) {
47 simple.inlineStyles = node.inlineStyles as Record<string, unknown>;
48 }
49
50 if (node.style) {
51 simple.style = node.style as unknown as Record<string, unknown>;
52 }
53
54 if (node.strokes && Array.isArray(node.strokes) && node.strokes.length > 0) {
55 simple.hasStrokes = true;
56 }
57
58 return simple;
59}
60
61/**
62 * Extract node positions with hierarchical structure preserved

Callers 3

populateComponentPropsFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected