vectify 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +679 -0
- package/README.zh-CN.md +683 -0
- package/dist/chunk-4BWKFV7W.mjs +1311 -0
- package/dist/chunk-CIKTK6HI.mjs +96 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1483 -0
- package/dist/cli.mjs +56 -0
- package/dist/helpers-UPZEBRGK.mjs +26 -0
- package/dist/index.d.mts +281 -0
- package/dist/index.d.ts +281 -0
- package/dist/index.js +1463 -0
- package/dist/index.mjs +27 -0
- package/dist/templates/angular/component.ts.hbs +121 -0
- package/dist/templates/angular/createIcon.ts.hbs +116 -0
- package/dist/templates/astro/component.astro.hbs +110 -0
- package/dist/templates/astro/createIcon.astro.hbs +111 -0
- package/dist/templates/lit/component.js.hbs +12 -0
- package/dist/templates/lit/component.ts.hbs +19 -0
- package/dist/templates/lit/createIcon.js.hbs +98 -0
- package/dist/templates/lit/createIcon.ts.hbs +99 -0
- package/dist/templates/preact/component.jsx.hbs +8 -0
- package/dist/templates/preact/component.tsx.hbs +11 -0
- package/dist/templates/preact/createIcon.jsx.hbs +101 -0
- package/dist/templates/preact/createIcon.tsx.hbs +121 -0
- package/dist/templates/qwik/component.jsx.hbs +7 -0
- package/dist/templates/qwik/component.tsx.hbs +8 -0
- package/dist/templates/qwik/createIcon.jsx.hbs +100 -0
- package/dist/templates/qwik/createIcon.tsx.hbs +111 -0
- package/dist/templates/react/component.jsx.hbs +8 -0
- package/dist/templates/react/component.tsx.hbs +11 -0
- package/dist/templates/react/createIcon.jsx.hbs +100 -0
- package/dist/templates/react/createIcon.tsx.hbs +117 -0
- package/dist/templates/solid/component.tsx.hbs +10 -0
- package/dist/templates/solid/createIcon.jsx.hbs +127 -0
- package/dist/templates/solid/createIcon.tsx.hbs +139 -0
- package/dist/templates/svelte/component.js.svelte.hbs +9 -0
- package/dist/templates/svelte/component.ts.svelte.hbs +10 -0
- package/dist/templates/svelte/icon.js.svelte.hbs +123 -0
- package/dist/templates/svelte/icon.ts.svelte.hbs +124 -0
- package/dist/templates/template-engine.ts +107 -0
- package/dist/templates/vanilla/component.ts.hbs +8 -0
- package/dist/templates/vanilla/createIcon.js.hbs +111 -0
- package/dist/templates/vanilla/createIcon.ts.hbs +124 -0
- package/dist/templates/vue/component.js.vue.hbs +21 -0
- package/dist/templates/vue/component.ts.vue.hbs +22 -0
- package/dist/templates/vue/icon.js.vue.hbs +155 -0
- package/dist/templates/vue/icon.ts.vue.hbs +157 -0
- package/package.json +78 -0
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
generate,
|
|
4
|
+
init,
|
|
5
|
+
watch
|
|
6
|
+
} from "./chunk-4BWKFV7W.mjs";
|
|
7
|
+
import "./chunk-CIKTK6HI.mjs";
|
|
8
|
+
|
|
9
|
+
// src/cli.ts
|
|
10
|
+
import { readFileSync } from "fs";
|
|
11
|
+
import { dirname, join } from "path";
|
|
12
|
+
import { fileURLToPath } from "url";
|
|
13
|
+
import chalk from "chalk";
|
|
14
|
+
import { Command } from "commander";
|
|
15
|
+
function getPackageJson() {
|
|
16
|
+
let pkgPath;
|
|
17
|
+
if (typeof __dirname !== "undefined") {
|
|
18
|
+
pkgPath = join(__dirname, "../package.json");
|
|
19
|
+
} else {
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
const __dirname2 = dirname(__filename);
|
|
22
|
+
pkgPath = join(__dirname2, "../package.json");
|
|
23
|
+
}
|
|
24
|
+
return JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
25
|
+
}
|
|
26
|
+
var packageJson = getPackageJson();
|
|
27
|
+
var program = new Command();
|
|
28
|
+
program.name("svg-icon").description(packageJson.description).version(packageJson.version, "-v, --version", "Output the current version");
|
|
29
|
+
program.command("init").description("Initialize a new configuration file").option("--force", "Overwrite existing configuration").option("--config <path>", "Custom config file path").action(async (options) => {
|
|
30
|
+
try {
|
|
31
|
+
await init(options);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
program.command("generate").description("Generate icon components from SVG files").option("-c, --config <path>", "Path to config file").option("--dry-run", "Preview what will be generated without writing files").action(async (options) => {
|
|
38
|
+
try {
|
|
39
|
+
await generate(options);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
program.command("watch").description("Watch for changes and regenerate automatically").option("-c, --config <path>", "Path to config file").action(async (options) => {
|
|
46
|
+
try {
|
|
47
|
+
await watch(options);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
program.parse(process.argv);
|
|
54
|
+
if (!process.argv.slice(2).length) {
|
|
55
|
+
program.outputHelp();
|
|
56
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ensureDir,
|
|
3
|
+
fileExists,
|
|
4
|
+
findProjectRoot,
|
|
5
|
+
formatAttributes,
|
|
6
|
+
getComponentName,
|
|
7
|
+
getSvgFiles,
|
|
8
|
+
mergeClasses,
|
|
9
|
+
readFile,
|
|
10
|
+
toKebabCase,
|
|
11
|
+
toPascalCase,
|
|
12
|
+
writeFile
|
|
13
|
+
} from "./chunk-CIKTK6HI.mjs";
|
|
14
|
+
export {
|
|
15
|
+
ensureDir,
|
|
16
|
+
fileExists,
|
|
17
|
+
findProjectRoot,
|
|
18
|
+
formatAttributes,
|
|
19
|
+
getComponentName,
|
|
20
|
+
getSvgFiles,
|
|
21
|
+
mergeClasses,
|
|
22
|
+
readFile,
|
|
23
|
+
toKebabCase,
|
|
24
|
+
toPascalCase,
|
|
25
|
+
writeFile
|
|
26
|
+
};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
interface GenerateOptions {
|
|
2
|
+
config?: string;
|
|
3
|
+
dryRun?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Generate icon components
|
|
7
|
+
*/
|
|
8
|
+
declare function generate(options?: GenerateOptions): Promise<void>;
|
|
9
|
+
|
|
10
|
+
interface InitOptions {
|
|
11
|
+
force?: boolean;
|
|
12
|
+
config?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Initialize configuration file
|
|
16
|
+
*/
|
|
17
|
+
declare function init(options?: InitOptions): Promise<void>;
|
|
18
|
+
|
|
19
|
+
interface WatchOptions {
|
|
20
|
+
config?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Watch for SVG file changes and regenerate
|
|
24
|
+
*/
|
|
25
|
+
declare function watch(options?: WatchOptions): Promise<void>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* SVG element types supported by the parser
|
|
29
|
+
*/
|
|
30
|
+
type SVGElementType = 'circle' | 'ellipse' | 'line' | 'path' | 'polygon' | 'polyline' | 'rect' | 'g';
|
|
31
|
+
/**
|
|
32
|
+
* Icon node representing an SVG element and its attributes
|
|
33
|
+
* Format: [elementType, attributes, children?]
|
|
34
|
+
*/
|
|
35
|
+
type IconNode = [
|
|
36
|
+
SVGElementType,
|
|
37
|
+
Record<string, string | number>,
|
|
38
|
+
IconNode[]?
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* Icon component props
|
|
42
|
+
*/
|
|
43
|
+
interface IconProps {
|
|
44
|
+
'size'?: number | string;
|
|
45
|
+
'color'?: string;
|
|
46
|
+
'strokeWidth'?: number | string;
|
|
47
|
+
'className'?: string;
|
|
48
|
+
'title'?: string;
|
|
49
|
+
'aria-label'?: string;
|
|
50
|
+
'aria-hidden'?: boolean | 'true' | 'false';
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Framework types supported
|
|
55
|
+
*/
|
|
56
|
+
type Framework = 'react' | 'vue' | 'svelte' | 'solid' | 'preact' | 'lit' | 'angular' | 'qwik' | 'astro' | 'vanilla';
|
|
57
|
+
/**
|
|
58
|
+
* Main configuration interface
|
|
59
|
+
*/
|
|
60
|
+
interface IconForgeConfig {
|
|
61
|
+
/**
|
|
62
|
+
* Target framework
|
|
63
|
+
*/
|
|
64
|
+
framework: Framework;
|
|
65
|
+
/**
|
|
66
|
+
* Config file directory relative to project root
|
|
67
|
+
* Used for resolving input/output paths when config is in a subdirectory
|
|
68
|
+
* @default '.'
|
|
69
|
+
* @example
|
|
70
|
+
* // Config at root
|
|
71
|
+
* { configDir: '.' }
|
|
72
|
+
*
|
|
73
|
+
* // Config in config/icons/ subdirectory
|
|
74
|
+
* { configDir: '../..' }
|
|
75
|
+
*/
|
|
76
|
+
configDir?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Input directory containing SVG files
|
|
79
|
+
* @default './icons'
|
|
80
|
+
*/
|
|
81
|
+
input: string;
|
|
82
|
+
/**
|
|
83
|
+
* Output directory for generated components
|
|
84
|
+
* @default './src/icons'
|
|
85
|
+
*/
|
|
86
|
+
output: string;
|
|
87
|
+
/**
|
|
88
|
+
* Enable TypeScript generation
|
|
89
|
+
* @default true
|
|
90
|
+
*/
|
|
91
|
+
typescript?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Enable SVG optimization with SVGO
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
optimize?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Keep original colors from SVG files
|
|
99
|
+
* When true, preserves fill and stroke colors from the original SVG
|
|
100
|
+
* When false, uses currentColor for single-color icons
|
|
101
|
+
* @default false
|
|
102
|
+
*/
|
|
103
|
+
keepColors?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Prefix for component names
|
|
106
|
+
* @default ''
|
|
107
|
+
* @example 'Icon' -> IconArrowRight
|
|
108
|
+
*/
|
|
109
|
+
prefix?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Suffix for component names
|
|
112
|
+
* @default ''
|
|
113
|
+
* @example 'Icon' -> ArrowRightIcon
|
|
114
|
+
*/
|
|
115
|
+
suffix?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Custom name transformation function
|
|
118
|
+
*/
|
|
119
|
+
transform?: (name: string) => string;
|
|
120
|
+
/**
|
|
121
|
+
* SVGO configuration
|
|
122
|
+
*/
|
|
123
|
+
svgoConfig?: {
|
|
124
|
+
plugins?: any[];
|
|
125
|
+
[key: string]: any;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Generation options
|
|
129
|
+
*/
|
|
130
|
+
generateOptions?: {
|
|
131
|
+
/**
|
|
132
|
+
* Generate index file
|
|
133
|
+
* @default true
|
|
134
|
+
*/
|
|
135
|
+
index?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Generate type definitions
|
|
138
|
+
* @default true
|
|
139
|
+
*/
|
|
140
|
+
types?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Generate preview.html to visualize icons
|
|
143
|
+
* @default false
|
|
144
|
+
*/
|
|
145
|
+
preview?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Clean output directory before generating
|
|
148
|
+
* Removes icon components that no longer have corresponding SVG files
|
|
149
|
+
* @default false
|
|
150
|
+
*/
|
|
151
|
+
cleanOutput?: boolean;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Watch mode settings
|
|
155
|
+
*/
|
|
156
|
+
watch?: {
|
|
157
|
+
/**
|
|
158
|
+
* Enable watch mode
|
|
159
|
+
* @default false
|
|
160
|
+
*/
|
|
161
|
+
enabled?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Patterns to ignore
|
|
164
|
+
*/
|
|
165
|
+
ignore?: string[];
|
|
166
|
+
/**
|
|
167
|
+
* Debounce delay in milliseconds
|
|
168
|
+
* @default 300
|
|
169
|
+
*/
|
|
170
|
+
debounce?: number;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Lifecycle hooks
|
|
174
|
+
*/
|
|
175
|
+
hooks?: {
|
|
176
|
+
/**
|
|
177
|
+
* Called before parsing SVG
|
|
178
|
+
*/
|
|
179
|
+
beforeParse?: (svg: string, fileName: string) => Promise<string> | string;
|
|
180
|
+
/**
|
|
181
|
+
* Called after generating component code
|
|
182
|
+
*/
|
|
183
|
+
afterGenerate?: (code: string, iconName: string) => Promise<string> | string;
|
|
184
|
+
/**
|
|
185
|
+
* Called after all icons are generated
|
|
186
|
+
*/
|
|
187
|
+
onComplete?: (stats: GenerationStats) => Promise<void> | void;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Generation statistics
|
|
192
|
+
*/
|
|
193
|
+
interface GenerationStats {
|
|
194
|
+
success: number;
|
|
195
|
+
failed: number;
|
|
196
|
+
total: number;
|
|
197
|
+
errors: Array<{
|
|
198
|
+
file: string;
|
|
199
|
+
error: string;
|
|
200
|
+
}>;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Config definition helper
|
|
204
|
+
*/
|
|
205
|
+
declare function defineConfig(config: IconForgeConfig): IconForgeConfig;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Load configuration from file
|
|
209
|
+
*/
|
|
210
|
+
declare function loadConfig(configPath: string): Promise<IconForgeConfig>;
|
|
211
|
+
/**
|
|
212
|
+
* Find config file in current directory
|
|
213
|
+
*/
|
|
214
|
+
declare function findConfig(): Promise<string | null>;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Generate all icon components
|
|
218
|
+
*/
|
|
219
|
+
declare function generateIcons(config: IconForgeConfig, dryRun?: boolean): Promise<GenerationStats>;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Framework strategy interface
|
|
223
|
+
*/
|
|
224
|
+
interface FrameworkStrategy {
|
|
225
|
+
/**
|
|
226
|
+
* Framework name
|
|
227
|
+
*/
|
|
228
|
+
name: Framework;
|
|
229
|
+
/**
|
|
230
|
+
* File extension for components
|
|
231
|
+
*/
|
|
232
|
+
getComponentExtension: (typescript: boolean) => string;
|
|
233
|
+
/**
|
|
234
|
+
* File extension for index files
|
|
235
|
+
*/
|
|
236
|
+
getIndexExtension: (typescript: boolean) => string;
|
|
237
|
+
/**
|
|
238
|
+
* Generate component code
|
|
239
|
+
*/
|
|
240
|
+
generateComponent: (componentName: string, iconNode: IconNode[], typescript: boolean, keepColors?: boolean) => string;
|
|
241
|
+
/**
|
|
242
|
+
* Generate base component (Icon/createIcon)
|
|
243
|
+
*/
|
|
244
|
+
generateBaseComponent: (typescript: boolean) => {
|
|
245
|
+
code: string;
|
|
246
|
+
fileName: string;
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Framework strategy registry
|
|
251
|
+
*/
|
|
252
|
+
declare class FrameworkRegistry {
|
|
253
|
+
private strategies;
|
|
254
|
+
constructor();
|
|
255
|
+
/**
|
|
256
|
+
* Register a framework strategy
|
|
257
|
+
*/
|
|
258
|
+
register(strategy: FrameworkStrategy): void;
|
|
259
|
+
/**
|
|
260
|
+
* Get a framework strategy
|
|
261
|
+
*/
|
|
262
|
+
get(framework: Framework): FrameworkStrategy;
|
|
263
|
+
/**
|
|
264
|
+
* Check if a framework is supported
|
|
265
|
+
*/
|
|
266
|
+
has(framework: Framework): boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Get all supported frameworks
|
|
269
|
+
*/
|
|
270
|
+
getSupportedFrameworks(): Framework[];
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Global framework registry instance
|
|
274
|
+
*/
|
|
275
|
+
declare const frameworkRegistry: FrameworkRegistry;
|
|
276
|
+
/**
|
|
277
|
+
* Get framework strategy
|
|
278
|
+
*/
|
|
279
|
+
declare function getFrameworkStrategy(framework: Framework): FrameworkStrategy;
|
|
280
|
+
|
|
281
|
+
export { type Framework, type FrameworkStrategy, type GenerationStats, type IconForgeConfig, type IconNode, type IconProps, type SVGElementType, defineConfig, findConfig, frameworkRegistry, generate, generateIcons, getFrameworkStrategy, init, loadConfig, watch };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
interface GenerateOptions {
|
|
2
|
+
config?: string;
|
|
3
|
+
dryRun?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Generate icon components
|
|
7
|
+
*/
|
|
8
|
+
declare function generate(options?: GenerateOptions): Promise<void>;
|
|
9
|
+
|
|
10
|
+
interface InitOptions {
|
|
11
|
+
force?: boolean;
|
|
12
|
+
config?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Initialize configuration file
|
|
16
|
+
*/
|
|
17
|
+
declare function init(options?: InitOptions): Promise<void>;
|
|
18
|
+
|
|
19
|
+
interface WatchOptions {
|
|
20
|
+
config?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Watch for SVG file changes and regenerate
|
|
24
|
+
*/
|
|
25
|
+
declare function watch(options?: WatchOptions): Promise<void>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* SVG element types supported by the parser
|
|
29
|
+
*/
|
|
30
|
+
type SVGElementType = 'circle' | 'ellipse' | 'line' | 'path' | 'polygon' | 'polyline' | 'rect' | 'g';
|
|
31
|
+
/**
|
|
32
|
+
* Icon node representing an SVG element and its attributes
|
|
33
|
+
* Format: [elementType, attributes, children?]
|
|
34
|
+
*/
|
|
35
|
+
type IconNode = [
|
|
36
|
+
SVGElementType,
|
|
37
|
+
Record<string, string | number>,
|
|
38
|
+
IconNode[]?
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* Icon component props
|
|
42
|
+
*/
|
|
43
|
+
interface IconProps {
|
|
44
|
+
'size'?: number | string;
|
|
45
|
+
'color'?: string;
|
|
46
|
+
'strokeWidth'?: number | string;
|
|
47
|
+
'className'?: string;
|
|
48
|
+
'title'?: string;
|
|
49
|
+
'aria-label'?: string;
|
|
50
|
+
'aria-hidden'?: boolean | 'true' | 'false';
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Framework types supported
|
|
55
|
+
*/
|
|
56
|
+
type Framework = 'react' | 'vue' | 'svelte' | 'solid' | 'preact' | 'lit' | 'angular' | 'qwik' | 'astro' | 'vanilla';
|
|
57
|
+
/**
|
|
58
|
+
* Main configuration interface
|
|
59
|
+
*/
|
|
60
|
+
interface IconForgeConfig {
|
|
61
|
+
/**
|
|
62
|
+
* Target framework
|
|
63
|
+
*/
|
|
64
|
+
framework: Framework;
|
|
65
|
+
/**
|
|
66
|
+
* Config file directory relative to project root
|
|
67
|
+
* Used for resolving input/output paths when config is in a subdirectory
|
|
68
|
+
* @default '.'
|
|
69
|
+
* @example
|
|
70
|
+
* // Config at root
|
|
71
|
+
* { configDir: '.' }
|
|
72
|
+
*
|
|
73
|
+
* // Config in config/icons/ subdirectory
|
|
74
|
+
* { configDir: '../..' }
|
|
75
|
+
*/
|
|
76
|
+
configDir?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Input directory containing SVG files
|
|
79
|
+
* @default './icons'
|
|
80
|
+
*/
|
|
81
|
+
input: string;
|
|
82
|
+
/**
|
|
83
|
+
* Output directory for generated components
|
|
84
|
+
* @default './src/icons'
|
|
85
|
+
*/
|
|
86
|
+
output: string;
|
|
87
|
+
/**
|
|
88
|
+
* Enable TypeScript generation
|
|
89
|
+
* @default true
|
|
90
|
+
*/
|
|
91
|
+
typescript?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Enable SVG optimization with SVGO
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
optimize?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Keep original colors from SVG files
|
|
99
|
+
* When true, preserves fill and stroke colors from the original SVG
|
|
100
|
+
* When false, uses currentColor for single-color icons
|
|
101
|
+
* @default false
|
|
102
|
+
*/
|
|
103
|
+
keepColors?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Prefix for component names
|
|
106
|
+
* @default ''
|
|
107
|
+
* @example 'Icon' -> IconArrowRight
|
|
108
|
+
*/
|
|
109
|
+
prefix?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Suffix for component names
|
|
112
|
+
* @default ''
|
|
113
|
+
* @example 'Icon' -> ArrowRightIcon
|
|
114
|
+
*/
|
|
115
|
+
suffix?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Custom name transformation function
|
|
118
|
+
*/
|
|
119
|
+
transform?: (name: string) => string;
|
|
120
|
+
/**
|
|
121
|
+
* SVGO configuration
|
|
122
|
+
*/
|
|
123
|
+
svgoConfig?: {
|
|
124
|
+
plugins?: any[];
|
|
125
|
+
[key: string]: any;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Generation options
|
|
129
|
+
*/
|
|
130
|
+
generateOptions?: {
|
|
131
|
+
/**
|
|
132
|
+
* Generate index file
|
|
133
|
+
* @default true
|
|
134
|
+
*/
|
|
135
|
+
index?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Generate type definitions
|
|
138
|
+
* @default true
|
|
139
|
+
*/
|
|
140
|
+
types?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Generate preview.html to visualize icons
|
|
143
|
+
* @default false
|
|
144
|
+
*/
|
|
145
|
+
preview?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Clean output directory before generating
|
|
148
|
+
* Removes icon components that no longer have corresponding SVG files
|
|
149
|
+
* @default false
|
|
150
|
+
*/
|
|
151
|
+
cleanOutput?: boolean;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Watch mode settings
|
|
155
|
+
*/
|
|
156
|
+
watch?: {
|
|
157
|
+
/**
|
|
158
|
+
* Enable watch mode
|
|
159
|
+
* @default false
|
|
160
|
+
*/
|
|
161
|
+
enabled?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Patterns to ignore
|
|
164
|
+
*/
|
|
165
|
+
ignore?: string[];
|
|
166
|
+
/**
|
|
167
|
+
* Debounce delay in milliseconds
|
|
168
|
+
* @default 300
|
|
169
|
+
*/
|
|
170
|
+
debounce?: number;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Lifecycle hooks
|
|
174
|
+
*/
|
|
175
|
+
hooks?: {
|
|
176
|
+
/**
|
|
177
|
+
* Called before parsing SVG
|
|
178
|
+
*/
|
|
179
|
+
beforeParse?: (svg: string, fileName: string) => Promise<string> | string;
|
|
180
|
+
/**
|
|
181
|
+
* Called after generating component code
|
|
182
|
+
*/
|
|
183
|
+
afterGenerate?: (code: string, iconName: string) => Promise<string> | string;
|
|
184
|
+
/**
|
|
185
|
+
* Called after all icons are generated
|
|
186
|
+
*/
|
|
187
|
+
onComplete?: (stats: GenerationStats) => Promise<void> | void;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Generation statistics
|
|
192
|
+
*/
|
|
193
|
+
interface GenerationStats {
|
|
194
|
+
success: number;
|
|
195
|
+
failed: number;
|
|
196
|
+
total: number;
|
|
197
|
+
errors: Array<{
|
|
198
|
+
file: string;
|
|
199
|
+
error: string;
|
|
200
|
+
}>;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Config definition helper
|
|
204
|
+
*/
|
|
205
|
+
declare function defineConfig(config: IconForgeConfig): IconForgeConfig;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Load configuration from file
|
|
209
|
+
*/
|
|
210
|
+
declare function loadConfig(configPath: string): Promise<IconForgeConfig>;
|
|
211
|
+
/**
|
|
212
|
+
* Find config file in current directory
|
|
213
|
+
*/
|
|
214
|
+
declare function findConfig(): Promise<string | null>;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Generate all icon components
|
|
218
|
+
*/
|
|
219
|
+
declare function generateIcons(config: IconForgeConfig, dryRun?: boolean): Promise<GenerationStats>;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Framework strategy interface
|
|
223
|
+
*/
|
|
224
|
+
interface FrameworkStrategy {
|
|
225
|
+
/**
|
|
226
|
+
* Framework name
|
|
227
|
+
*/
|
|
228
|
+
name: Framework;
|
|
229
|
+
/**
|
|
230
|
+
* File extension for components
|
|
231
|
+
*/
|
|
232
|
+
getComponentExtension: (typescript: boolean) => string;
|
|
233
|
+
/**
|
|
234
|
+
* File extension for index files
|
|
235
|
+
*/
|
|
236
|
+
getIndexExtension: (typescript: boolean) => string;
|
|
237
|
+
/**
|
|
238
|
+
* Generate component code
|
|
239
|
+
*/
|
|
240
|
+
generateComponent: (componentName: string, iconNode: IconNode[], typescript: boolean, keepColors?: boolean) => string;
|
|
241
|
+
/**
|
|
242
|
+
* Generate base component (Icon/createIcon)
|
|
243
|
+
*/
|
|
244
|
+
generateBaseComponent: (typescript: boolean) => {
|
|
245
|
+
code: string;
|
|
246
|
+
fileName: string;
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Framework strategy registry
|
|
251
|
+
*/
|
|
252
|
+
declare class FrameworkRegistry {
|
|
253
|
+
private strategies;
|
|
254
|
+
constructor();
|
|
255
|
+
/**
|
|
256
|
+
* Register a framework strategy
|
|
257
|
+
*/
|
|
258
|
+
register(strategy: FrameworkStrategy): void;
|
|
259
|
+
/**
|
|
260
|
+
* Get a framework strategy
|
|
261
|
+
*/
|
|
262
|
+
get(framework: Framework): FrameworkStrategy;
|
|
263
|
+
/**
|
|
264
|
+
* Check if a framework is supported
|
|
265
|
+
*/
|
|
266
|
+
has(framework: Framework): boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Get all supported frameworks
|
|
269
|
+
*/
|
|
270
|
+
getSupportedFrameworks(): Framework[];
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Global framework registry instance
|
|
274
|
+
*/
|
|
275
|
+
declare const frameworkRegistry: FrameworkRegistry;
|
|
276
|
+
/**
|
|
277
|
+
* Get framework strategy
|
|
278
|
+
*/
|
|
279
|
+
declare function getFrameworkStrategy(framework: Framework): FrameworkStrategy;
|
|
280
|
+
|
|
281
|
+
export { type Framework, type FrameworkStrategy, type GenerationStats, type IconForgeConfig, type IconNode, type IconProps, type SVGElementType, defineConfig, findConfig, frameworkRegistry, generate, generateIcons, getFrameworkStrategy, init, loadConfig, watch };
|