import type { Node as FigmaDocumentNode, Style } from "@figma/rest-api-spec"; import type { SimplifiedTextStyle } from "../transformers/text.js"; import type { SimplifiedLayout } from "../transformers/layout.js"; import type { SimplifiedFill, SimplifiedStroke } from "../transformers/style.js"; import type { SimplifiedEffects } from "../transformers/effects.js"; import type { ComponentProperties, SimplifiedComponentDefinition, SimplifiedComponentSetDefinition } from "../transformers/component.js"; export type StyleTypes = SimplifiedTextStyle | SimplifiedFill[] | SimplifiedLayout | SimplifiedStroke | SimplifiedEffects | string; export type GlobalVars = { styles: Record; }; /** * Optimization options for reducing output size and context window usage. * All options default to false to preserve backward compatibility. */ export interface OptimizationOptions { /** Remove all styling info (fills, strokes, effects, textStyle, opacity, borderRadius) */ excludeStyles?: boolean; /** Convert TABLE nodes to markdown format */ tablesToMarkdown?: boolean; /** Simplify CONNECTOR nodes to just endpoints (startNodeId, endNodeId) */ simplifyConnectors?: boolean; /** Keep componentId and componentProperties but remove visual styling from INSTANCE nodes */ simplifyComponentInstances?: boolean; } export interface TraversalContext { globalVars: GlobalVars & { extraStyles?: Record; }; currentDepth: number; parent?: FigmaDocumentNode; } export interface TraversalOptions { maxDepth?: number; nodeFilter?: (node: FigmaDocumentNode) => boolean; /** * Called after children are processed, allowing modification of the parent node * and control over which children to include in the output. * * @param node - Original Figma node * @param result - SimplifiedNode being built (can be mutated) * @param children - Processed children * @returns Children to include (return empty array to omit children) */ afterChildren?: (node: FigmaDocumentNode, result: SimplifiedNode, children: SimplifiedNode[]) => SimplifiedNode[]; /** Optimization options for reducing output size */ optimization?: OptimizationOptions; } /** * An extractor function that can modify a SimplifiedNode during traversal. * * @param node - The current Figma node being processed * @param result - SimplifiedNode object being built—this can be mutated inside the extractor * @param context - Traversal context including globalVars and parent info. This can also be mutated inside the extractor. */ export type ExtractorFn = (node: FigmaDocumentNode, result: SimplifiedNode, context: TraversalContext) => void; export interface SimplifiedDesign { name: string; nodes: SimplifiedNode[]; components: Record; componentSets: Record; globalVars: GlobalVars; } export interface SimplifiedNode { id: string; name: string; type: string; text?: string; textStyle?: string; fills?: string; styles?: string; strokes?: string; strokeWeight?: string; strokeDashes?: number[]; strokeWeights?: string; effects?: string; opacity?: number; borderRadius?: string; layout?: string; componentId?: string; componentProperties?: ComponentProperties[]; startNodeId?: string; endNodeId?: string; children?: SimplifiedNode[]; } /** * Simplified representation of a markdown table (used when tablesToMarkdown is true). * Replaces the nested TABLE node structure with a compact markdown string. */ export interface MarkdownTableNode { id: string; name: string; type: "TABLE_MARKDOWN"; /** Markdown representation of the table */ markdown: string; /** Original row count for reference */ rowCount: number; /** Original column count for reference */ columnCount: number; } export interface BoundingBox { x: number; y: number; width: number; height: number; } //# sourceMappingURL=types.d.ts.map