import type { EnrichedAST, EnrichedASTNode } from './ast-enricher.js'; export interface ExportAsset { nodeId: string; name: string; bounds: { width: number; height: number; }; suggestedFormat: 'png' | 'svg' | 'jpg'; } export interface ModuleEntry { index: number; name: string; /** nodeId of the first child in this module group */ nodeId: string; file: string; nodeCount: number; childNodeIds: string[]; bounds: { y: number; height: number; }; } export interface SkeletonChild { nodeId: string; name: string; type: string; bounds: { x: number; y: number; width: number; height: number; }; moduleFile: string; } export interface ModuleMap { fileKey: string; rootNodeId: string; totalNodes: number; splitThreshold: number; viewport: { width: number; height: number; }; skeletonFile: string; modules: ModuleEntry[]; exportAssets: ExportAsset[]; } /** * Convert a Figma node name to a kebab-case file-safe string. * e.g. "Hero Section" → "hero-section", "FeatureCards_v2" → "featurecards-v2" */ export declare function toKebabCase(name: string): string; /** * Recursively count all nodes in an EnrichedASTNode subtree. * Graphic subtrees (flags.isGraphicSubtree) are counted as 1 since their * children are already pruned by the enricher. */ export declare function countSubtreeNodes(node: EnrichedASTNode): number; /** * Find the effective split point: if the root has a single child container * whose subtree exceeds the threshold, "unwrap" one level and split its * children instead. Returns the node whose .children should be grouped. */ export declare function findSplitTarget(root: EnrichedASTNode, threshold: number): EnrichedASTNode; /** * Split root.children into module groups using greedy sequential grouping. * * Algorithm: * - If root has a single large child, "unwrap" to split at the next level * - Iterate children in order * - Accumulate into current group until adding next child would exceed threshold * - A single child whose subtree count > threshold is recursively split into * sub-modules by diving into its children * - Returns { splitTarget, modules } where splitTarget is the actual node being split */ export interface SplitResult { splitTarget: EnrichedASTNode; modules: EnrichedASTNode[][]; } export declare function splitIntoModules(root: EnrichedASTNode, threshold: number): SplitResult; /** * Build a skeleton AST: root node with full layout but children replaced * by lightweight placeholders that reference their module file. */ export declare function generateSkeleton(root: EnrichedASTNode, moduleEntries: ModuleEntry[]): Record; /** * Traverse all nodes and collect graphic/image nodes for export. */ export declare function collectExportAssets(root: EnrichedASTNode): ExportAsset[]; /** * Build the module-map data structure. */ export declare function buildModuleMap(ast: EnrichedAST, moduleGroups: EnrichedASTNode[][], exportAssets: ExportAsset[], threshold: number): ModuleMap; /** * Split an EnrichedAST into modules and write all files to outputDir. * * Files written: * - module-map.json * - skeleton.json * - module-{index}-{name}.ast.json (one per module) * * Returns the ModuleMap for the caller to use as tool response. */ export declare function writeModuleFiles(ast: EnrichedAST, outputDir: string, threshold: number): Promise; //# sourceMappingURL=ast-module-splitter.d.ts.map