import * as _iconify_tools from '@iconify/tools'; import { IconSet } from '@iconify/tools'; /** * 配置文件结构 */ interface FigmaIconsConfigFile { /** * 图标集前缀 * @example 'local' */ prefix: string; /** * 输出文件路径 * @example 'json/icons.json' */ output: string; /** * 图标来源配置列表 * 可以从多个 Page 收集图标,最终合并到一个文件 */ collections: IconSourceConfig[]; /** * 图标所在的层级深度 * @default 2 */ depth?: number; /** * 缓存目录 * @default '.figma-cache' */ cacheDir?: string; /** * 要从同步中排除的 Figma 节点 ID 列表 * 适用于临时跳过重名或不需要导出的节点 */ excludeNodeIds?: string[]; } /** * 图标来源配置 */ interface IconSourceConfig { /** * 要导出的 Figma Page 名称列表 * @example ['Icons'] */ pages: string[]; /** * 是否转换为 currentColor (单色图标) * @default true */ convertToCurrentColor?: boolean; /** * 要替换为 currentColor 的颜色列表 * 如果不指定,则替换所有颜色 */ colorsToReplace?: string[]; } /** * Figma 图标同步配置 */ interface FigmaIconsConfig { /** * Figma 文件 ID * 从 Figma URL 中获取: https://www.figma.com/file/FILE_ID/... */ fileId: string; /** * Figma API 访问令牌 * 从 Figma 账户设置中获取 */ token: string; /** * 图标集前缀 (例如: "local", "colored") */ prefix: string; /** * 要导出的 Figma Page 名称列表 * 如果为空,则导出所有 pages */ pages?: string[]; /** * 图标所在的层级深度 * 例如: 2 表示 Page > Frame > Icon */ depth?: number; /** * 是否转换为 currentColor (单色图标) * @default true */ convertToCurrentColor?: boolean; /** * 要替换为 currentColor 的颜色列表 * 如果 convertToCurrentColor 为 true,则替换所有颜色 */ colorsToReplace?: string[]; /** * 缓存目录 * @default '.figma-cache' */ cacheDir?: string; /** * 要从同步中排除的 Figma 节点 ID 列表 * 适用于临时跳过重名或不需要导出的节点 */ excludeNodeIds?: string[]; /** * API 缓存时间 (毫秒) * @default 259200000 (3天) */ cacheAPITTL?: number; /** * SVG 缓存时间 (毫秒) * @default 2592000000 (30天) */ cacheSVGTTL?: number; /** * 强制同步,忽略所有缓存 * 设置为 true 时会跳过缓存,直接从 Figma 拉取最新数据 * @default false */ force?: boolean; } /** * 同步结果 */ type SyncResult = { /** * 图标集实例 */ iconSet: IconSet; /** * 同步的图标数量 */ count: number; /** * 是否有更新 */ modified: true; /** * 图标名称列表 */ icons: string[]; } | { /** * 图标集实例 */ iconSet: null; /** * 同步的图标数量 */ count: 0; /** * 是否有更新 */ modified: false; /** * 图标名称列表 */ icons: string[]; }; /** * 导出选项 */ interface ExportOptions { /** * 输出文件路径 */ output: string; /** * 是否美化输出的 JSON * @default true */ pretty?: boolean; } /** * 导出图标集为 Iconify JSON 格式 */ declare function exportIconSet(iconSet: IconSet, options: ExportOptions): Promise; /** * 导出为 UnoCSS collections 格式 * 返回 { iconName: "svg string" } 格式 * * 优化说明: * - 保持原始 viewBox 以维持设计意图 * - 移除固定的 width/height 属性,让 CSS 控制显示尺寸 * - 非正方形 icon(如品牌标识)会保持原始宽高比 */ declare function exportForUnoCSS(iconSet: IconSet): Record; /** * 从 Figma 同步图标 */ declare function syncIconsFromFigma(config: FigmaIconsConfig): Promise; /** * 定义配置文件的辅助函数,提供类型提示 */ declare function defineConfig(config: FigmaIconsConfigFile): FigmaIconsConfigFile; /** * 便捷方法:同步并导出 */ declare function syncAndExport(config: FigmaIconsConfig, outputPath: string): Promise<{ iconSet: _iconify_tools.IconSet; count: number; modified: true; icons: string[]; } | { iconSet: null; count: 0; modified: false; icons: string[]; }>; export { type ExportOptions, type FigmaIconsConfig, type FigmaIconsConfigFile, type IconSourceConfig, type SyncResult, defineConfig, exportForUnoCSS, exportIconSet, syncAndExport, syncIconsFromFigma };