(node: FigmaFrameInfo)
| 15 | * @returns Simplified node with only essential fields |
| 16 | */ |
| 17 | export 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 |
no outgoing calls
no test coverage detected