svgfusion 1.0.0-beta.2
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/CONTRIBUTING.md +93 -0
- package/LICENSE +21 -0
- package/README.md +297 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.mjs +1 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.d.mts +152 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.js +412 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +374 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +102 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Contributing to SVGFusion
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to SVGFusion! This guide will help you get started.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
1. Fork the repository
|
|
8
|
+
2. Clone your fork:
|
|
9
|
+
```bash
|
|
10
|
+
git clone https://github.com/YOUR_USERNAME/svgfusion.git
|
|
11
|
+
cd svgfusion
|
|
12
|
+
```
|
|
13
|
+
3. Install dependencies:
|
|
14
|
+
```bash
|
|
15
|
+
npm install
|
|
16
|
+
```
|
|
17
|
+
4. Start development:
|
|
18
|
+
```bash
|
|
19
|
+
npm run dev
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Development
|
|
23
|
+
|
|
24
|
+
### Building
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm run build # Build for production
|
|
28
|
+
npm run dev # Watch mode
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Testing
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm test # Run tests
|
|
35
|
+
npm run test:coverage # Run with coverage
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Code Quality
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm run lint # Check code style
|
|
42
|
+
npm run lint:fix # Fix linting issues
|
|
43
|
+
npm run format # Format code
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Making Changes
|
|
47
|
+
|
|
48
|
+
1. Create a feature branch:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
git checkout -b feature/my-feature
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
2. Make your changes
|
|
55
|
+
3. Add tests for new functionality
|
|
56
|
+
4. Run tests and ensure they pass
|
|
57
|
+
5. Commit your changes:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
git commit -m "feat: describe your changes"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
6. Push and create a pull request
|
|
64
|
+
|
|
65
|
+
## Code Style
|
|
66
|
+
|
|
67
|
+
- Use TypeScript for all code
|
|
68
|
+
- Follow existing code patterns
|
|
69
|
+
- Add JSDoc comments for public APIs
|
|
70
|
+
- Write tests for new features
|
|
71
|
+
- Keep commits focused and descriptive
|
|
72
|
+
|
|
73
|
+
## Reporting Issues
|
|
74
|
+
|
|
75
|
+
When reporting bugs, please include:
|
|
76
|
+
|
|
77
|
+
- Clear description of the issue
|
|
78
|
+
- Steps to reproduce
|
|
79
|
+
- Expected vs actual behavior
|
|
80
|
+
- SVG input that causes the issue
|
|
81
|
+
- Environment details
|
|
82
|
+
|
|
83
|
+
## Pull Request Process
|
|
84
|
+
|
|
85
|
+
1. Update documentation if needed
|
|
86
|
+
2. Add tests for new functionality
|
|
87
|
+
3. Ensure all tests pass
|
|
88
|
+
4. Update changelog if needed
|
|
89
|
+
5. Submit pull request with clear description
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 SVGFusion Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# SVGFusion
|
|
2
|
+
|
|
3
|
+
**Transform SVG files into production-ready React and Vue 3 components with TypeScript support, automatic optimization, and intelligent naming.**
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/svgfusion)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://reactjs.org/)
|
|
8
|
+
[](https://vuejs.org/)
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **Dual Framework Support**: Generate both React and Vue 3 components from the same SVG
|
|
13
|
+
- **Optimized Output**: Built-in SVGO optimization with customizable settings
|
|
14
|
+
- **Multi-Color Support**: Preserves gradients, patterns, and complex color schemes
|
|
15
|
+
- **Class-Based Styling**: Supports CSS classes, Tailwind, and framework-specific styling
|
|
16
|
+
- **TypeScript Ready**: Full TypeScript support with proper type definitions
|
|
17
|
+
- **Flexible API**: Both CLI and programmatic usage
|
|
18
|
+
- **Batch Processing**: Convert entire directories of SVG files
|
|
19
|
+
- **Complex Filenames**: Handles design system metadata and special characters
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
### Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install svgfusion
|
|
27
|
+
# or
|
|
28
|
+
yarn add svgfusion
|
|
29
|
+
# or
|
|
30
|
+
pnpm add svgfusion
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### CLI Usage
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Convert to React components
|
|
37
|
+
svgfusion react ./icons --out ./components/react
|
|
38
|
+
|
|
39
|
+
# Convert to Vue 3 components
|
|
40
|
+
svgfusion vue ./icons --out ./components/vue
|
|
41
|
+
|
|
42
|
+
# Single file conversion
|
|
43
|
+
svgfusion react ./star.svg --name StarIcon --out ./components
|
|
44
|
+
|
|
45
|
+
# With optimization and prefix
|
|
46
|
+
svgfusion react ./icons --out ./components --optimize --prefix Icon
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Programmatic Usage
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { convertToReact, convertToVue } from 'svgfusion';
|
|
53
|
+
|
|
54
|
+
// React conversion
|
|
55
|
+
const reactResult = await convertToReact(svgContent, {
|
|
56
|
+
name: 'StarIcon',
|
|
57
|
+
typescript: true,
|
|
58
|
+
memo: true,
|
|
59
|
+
ref: true,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Vue conversion
|
|
63
|
+
const vueResult = await convertToVue(svgContent, {
|
|
64
|
+
name: 'StarIcon',
|
|
65
|
+
typescript: true,
|
|
66
|
+
scriptSetup: true,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
console.log(reactResult.code); // Generated React component
|
|
70
|
+
console.log(vueResult.code); // Generated Vue component
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## API Reference
|
|
74
|
+
|
|
75
|
+
### `convertToReact(svgContent, options)`
|
|
76
|
+
|
|
77
|
+
Convert SVG to React component.
|
|
78
|
+
|
|
79
|
+
**Options:**
|
|
80
|
+
|
|
81
|
+
- `name?: string` - Component name (auto-generated from filename if not provided)
|
|
82
|
+
- `prefix?: string` - Add prefix to component name
|
|
83
|
+
- `suffix?: string` - Add suffix to component name
|
|
84
|
+
- `typescript?: boolean` - Generate TypeScript component (default: `true`)
|
|
85
|
+
- `memo?: boolean` - Wrap with React.memo (default: `true`)
|
|
86
|
+
- `ref?: boolean` - Add forwardRef support (default: `true`)
|
|
87
|
+
- `optimize?: boolean` - Apply SVGO optimization (default: `true`)
|
|
88
|
+
|
|
89
|
+
### `convertToVue(svgContent, options)`
|
|
90
|
+
|
|
91
|
+
Convert SVG to Vue 3 component.
|
|
92
|
+
|
|
93
|
+
**Options:**
|
|
94
|
+
|
|
95
|
+
- `name?: string` - Component name (auto-generated from filename if not provided)
|
|
96
|
+
- `prefix?: string` - Add prefix to component name
|
|
97
|
+
- `suffix?: string` - Add suffix to component name
|
|
98
|
+
- `typescript?: boolean` - Generate TypeScript component (default: `true`)
|
|
99
|
+
- `scriptSetup?: boolean` - Use script setup syntax (default: `true`)
|
|
100
|
+
- `compositionApi?: boolean` - Use Composition API (default: `true`)
|
|
101
|
+
- `optimize?: boolean` - Apply SVGO optimization (default: `true`)
|
|
102
|
+
|
|
103
|
+
### `optimizeSvg(svgContent, config?)`
|
|
104
|
+
|
|
105
|
+
Optimize SVG content using SVGO.
|
|
106
|
+
|
|
107
|
+
### File Utilities
|
|
108
|
+
|
|
109
|
+
- `readSvgFile(filePath)` - Read SVG file
|
|
110
|
+
- `writeSvgFile(filePath, content)` - Write SVG file
|
|
111
|
+
- `readSvgDirectory(dirPath, recursive?)` - Read SVG files from directory
|
|
112
|
+
- `writeComponentFile(filePath, content)` - Write component file
|
|
113
|
+
|
|
114
|
+
## Examples
|
|
115
|
+
|
|
116
|
+
### Input SVG
|
|
117
|
+
|
|
118
|
+
```svg
|
|
119
|
+
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
120
|
+
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"
|
|
121
|
+
fill="currentColor" class="star-fill"/>
|
|
122
|
+
</svg>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Generated React Component
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import { SVGProps } from 'react';
|
|
129
|
+
import { memo } from 'react';
|
|
130
|
+
import { forwardRef } from 'react';
|
|
131
|
+
|
|
132
|
+
const StarIcon = memo(
|
|
133
|
+
forwardRef<SVGSVGElement, SVGProps<SVGSVGElement> & { className?: string }>(
|
|
134
|
+
props => {
|
|
135
|
+
return (
|
|
136
|
+
<svg viewBox="0 0 24 24" {...props}>
|
|
137
|
+
<path
|
|
138
|
+
d="m12 2 3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01z"
|
|
139
|
+
fill="currentColor"
|
|
140
|
+
className="star-fill"
|
|
141
|
+
/>
|
|
142
|
+
</svg>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
StarIcon.displayName = 'StarIcon';
|
|
149
|
+
|
|
150
|
+
export default StarIcon;
|
|
151
|
+
export { StarIcon };
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Generated Vue Component
|
|
155
|
+
|
|
156
|
+
```vue
|
|
157
|
+
<script setup lang="ts">
|
|
158
|
+
interface Props {
|
|
159
|
+
class?: string;
|
|
160
|
+
style?: string | Record<string, any>;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
164
|
+
class: '',
|
|
165
|
+
style: undefined,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// Component name for debugging
|
|
169
|
+
const __name = 'StarIcon';
|
|
170
|
+
</script>
|
|
171
|
+
|
|
172
|
+
<template>
|
|
173
|
+
<svg v-bind="$attrs" viewBox="0 0 24 24">
|
|
174
|
+
<path
|
|
175
|
+
d="m12 2 3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01z"
|
|
176
|
+
fill="currentColor"
|
|
177
|
+
class="star-fill"
|
|
178
|
+
/>
|
|
179
|
+
</svg>
|
|
180
|
+
</template>
|
|
181
|
+
|
|
182
|
+
<style scoped>
|
|
183
|
+
/* Add component-specific styles here */
|
|
184
|
+
</style>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Advanced Configuration
|
|
188
|
+
|
|
189
|
+
### Custom SVGO Configuration
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
import { createSvgoConfig, optimizeSvg } from 'svgfusion';
|
|
193
|
+
|
|
194
|
+
const customConfig = createSvgoConfig({
|
|
195
|
+
removeViewBox: false,
|
|
196
|
+
preserveColors: true,
|
|
197
|
+
preserveClasses: true,
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const optimizedSvg = optimizeSvg(svgContent, customConfig);
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Batch Processing
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
import {
|
|
207
|
+
readSvgDirectory,
|
|
208
|
+
convertToReact,
|
|
209
|
+
writeComponentFile,
|
|
210
|
+
} from 'svgfusion';
|
|
211
|
+
|
|
212
|
+
const svgFiles = await readSvgDirectory('./icons', true); // recursive
|
|
213
|
+
|
|
214
|
+
for (const svgFile of svgFiles) {
|
|
215
|
+
const svgContent = await readSvgFile(svgFile);
|
|
216
|
+
const result = await convertToReact(svgContent, {
|
|
217
|
+
name: path.basename(svgFile, '.svg'),
|
|
218
|
+
prefix: 'Icon',
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
await writeComponentFile(`./components/${result.filename}`, result.code);
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Complex Filename Support
|
|
226
|
+
|
|
227
|
+
SVGFusion handles complex filenames from design systems:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Design system metadata
|
|
231
|
+
"Size=xl, Color=Brand, Type=Glass.svg" → GlassBrandXl
|
|
232
|
+
"User Profile Avatar, Type=Solid.svg" → UserProfileAvatarTypeSolid
|
|
233
|
+
|
|
234
|
+
# Standard patterns
|
|
235
|
+
"icon-star.svg" → IconStar
|
|
236
|
+
"user-profile-avatar.svg" → UserProfileAvatar
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Styling Support
|
|
240
|
+
|
|
241
|
+
### CSS Classes
|
|
242
|
+
|
|
243
|
+
```svg
|
|
244
|
+
<path class="primary-color" />
|
|
245
|
+
<circle class="bg-blue-500" /> <!-- Tailwind -->
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### CSS Variables
|
|
249
|
+
|
|
250
|
+
```svg
|
|
251
|
+
<path fill="var(--primary-color)" />
|
|
252
|
+
<circle fill="currentColor" />
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Gradients & Patterns
|
|
256
|
+
|
|
257
|
+
```svg
|
|
258
|
+
<defs>
|
|
259
|
+
<linearGradient id="gradient">
|
|
260
|
+
<stop offset="0%" style="stop-color:#ff6b6b" />
|
|
261
|
+
<stop offset="100%" style="stop-color:#4ecdc4" />
|
|
262
|
+
</linearGradient>
|
|
263
|
+
</defs>
|
|
264
|
+
<path fill="url(#gradient)" />
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Testing
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
npm test # Run tests
|
|
271
|
+
npm run test:coverage # Run with coverage
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Development
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
npm run dev # Watch mode
|
|
278
|
+
npm run build # Build for production
|
|
279
|
+
npm run lint # Lint code
|
|
280
|
+
npm run format # Format code
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## License
|
|
284
|
+
|
|
285
|
+
MIT © SVGFusion Contributors
|
|
286
|
+
|
|
287
|
+
## Contributing
|
|
288
|
+
|
|
289
|
+
Contributions are welcome! Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
|
|
290
|
+
|
|
291
|
+
## Changelog
|
|
292
|
+
|
|
293
|
+
See [CHANGELOG.md](./CHANGELOG.md) for details.
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
**Made with care for the developer community**
|
package/dist/cli.d.mts
ADDED
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Config } from 'svgo';
|
|
2
|
+
|
|
3
|
+
interface ConversionOptions {
|
|
4
|
+
name?: string;
|
|
5
|
+
prefix?: string;
|
|
6
|
+
suffix?: string;
|
|
7
|
+
optimize?: boolean;
|
|
8
|
+
typescript?: boolean;
|
|
9
|
+
format?: 'esm' | 'cjs';
|
|
10
|
+
}
|
|
11
|
+
interface ReactConversionOptions extends ConversionOptions {
|
|
12
|
+
memo?: boolean;
|
|
13
|
+
ref?: boolean;
|
|
14
|
+
titleProp?: boolean;
|
|
15
|
+
descProp?: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface VueConversionOptions extends ConversionOptions {
|
|
18
|
+
compositionApi?: boolean;
|
|
19
|
+
scriptSetup?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface ConversionResult {
|
|
22
|
+
code: string;
|
|
23
|
+
filename: string;
|
|
24
|
+
componentName: string;
|
|
25
|
+
}
|
|
26
|
+
interface BatchConversionOptions extends ConversionOptions {
|
|
27
|
+
inputDir: string;
|
|
28
|
+
outputDir: string;
|
|
29
|
+
recursive?: boolean;
|
|
30
|
+
extensions?: string[];
|
|
31
|
+
}
|
|
32
|
+
interface BatchConversionResult {
|
|
33
|
+
results: ConversionResult[];
|
|
34
|
+
errors: ConversionError[];
|
|
35
|
+
summary: {
|
|
36
|
+
total: number;
|
|
37
|
+
successful: number;
|
|
38
|
+
failed: number;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
interface ConversionError {
|
|
42
|
+
file: string;
|
|
43
|
+
error: string;
|
|
44
|
+
stack?: string;
|
|
45
|
+
}
|
|
46
|
+
type Framework = 'react' | 'vue';
|
|
47
|
+
interface CliOptions {
|
|
48
|
+
framework: Framework;
|
|
49
|
+
input: string;
|
|
50
|
+
output?: string;
|
|
51
|
+
name?: string;
|
|
52
|
+
prefix?: string;
|
|
53
|
+
suffix?: string;
|
|
54
|
+
optimize?: boolean;
|
|
55
|
+
typescript?: boolean;
|
|
56
|
+
format?: 'esm' | 'cjs';
|
|
57
|
+
recursive?: boolean;
|
|
58
|
+
verbose?: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Convert SVG to React component
|
|
63
|
+
* @param svgContent - SVG content string
|
|
64
|
+
* @param options - Conversion options
|
|
65
|
+
* @returns Conversion result with React component code
|
|
66
|
+
*/
|
|
67
|
+
declare function convertToReact(svgContent: string, options?: ReactConversionOptions): Promise<ConversionResult>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Convert SVG to Vue 3 component
|
|
71
|
+
* @param svgContent - SVG content string
|
|
72
|
+
* @param options - Conversion options
|
|
73
|
+
* @returns Conversion result with Vue component code
|
|
74
|
+
*/
|
|
75
|
+
declare function convertToVue(svgContent: string, options?: VueConversionOptions): ConversionResult;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Optimize SVG content using SVGO
|
|
79
|
+
* @param svgContent - SVG content to optimize
|
|
80
|
+
* @param config - Optional SVGO configuration
|
|
81
|
+
* @returns Optimized SVG content
|
|
82
|
+
*/
|
|
83
|
+
declare function optimizeSvg(svgContent: string, config?: Config): string;
|
|
84
|
+
/**
|
|
85
|
+
* Create custom SVGO configuration
|
|
86
|
+
* @param options - Configuration options
|
|
87
|
+
* @returns SVGO configuration
|
|
88
|
+
*/
|
|
89
|
+
declare function createSvgoConfig(options: {
|
|
90
|
+
removeViewBox?: boolean;
|
|
91
|
+
removeDimensions?: boolean;
|
|
92
|
+
removeTitle?: boolean;
|
|
93
|
+
removeDesc?: boolean;
|
|
94
|
+
preserveAspectRatio?: boolean;
|
|
95
|
+
preserveColors?: boolean;
|
|
96
|
+
preserveClasses?: boolean;
|
|
97
|
+
}): Config;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Read SVG file content
|
|
101
|
+
* @param filePath - Path to the SVG file
|
|
102
|
+
* @returns SVG content as string
|
|
103
|
+
*/
|
|
104
|
+
declare function readSvgFile(filePath: string): Promise<string>;
|
|
105
|
+
/**
|
|
106
|
+
* Write SVG file content
|
|
107
|
+
* @param filePath - Path to write the SVG file
|
|
108
|
+
* @param content - SVG content
|
|
109
|
+
*/
|
|
110
|
+
declare function writeSvgFile(filePath: string, content: string): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Write component file content
|
|
113
|
+
* @param filePath - Path to write the component file
|
|
114
|
+
* @param content - Component content
|
|
115
|
+
*/
|
|
116
|
+
declare function writeComponentFile(filePath: string, content: string): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Read all SVG files from a directory
|
|
119
|
+
* @param dirPath - Directory path
|
|
120
|
+
* @param recursive - Whether to read recursively
|
|
121
|
+
* @returns Array of SVG file paths
|
|
122
|
+
*/
|
|
123
|
+
declare function readSvgDirectory(dirPath: string, recursive?: boolean): Promise<string[]>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Convert SVG filename to a valid React component name
|
|
127
|
+
* @param filename - The SVG filename
|
|
128
|
+
* @returns PascalCase component name
|
|
129
|
+
*/
|
|
130
|
+
declare function svgToComponentName(filename: string): string;
|
|
131
|
+
/**
|
|
132
|
+
* Sanitize component name to ensure it's valid
|
|
133
|
+
* @param name - The component name to sanitize
|
|
134
|
+
* @returns Sanitized component name
|
|
135
|
+
*/
|
|
136
|
+
declare function sanitizeComponentName(name: string): string;
|
|
137
|
+
/**
|
|
138
|
+
* Convert a string to PascalCase
|
|
139
|
+
* @param str - The string to convert
|
|
140
|
+
* @returns PascalCase string
|
|
141
|
+
*/
|
|
142
|
+
declare function pascalCase(str: string): string;
|
|
143
|
+
/**
|
|
144
|
+
* Add prefix/suffix to component name
|
|
145
|
+
* @param name - Base component name
|
|
146
|
+
* @param prefix - Optional prefix
|
|
147
|
+
* @param suffix - Optional suffix
|
|
148
|
+
* @returns Component name with prefix/suffix
|
|
149
|
+
*/
|
|
150
|
+
declare function formatComponentName(name: string, prefix?: string, suffix?: string): string;
|
|
151
|
+
|
|
152
|
+
export { BatchConversionOptions, BatchConversionResult, CliOptions, ConversionError, ConversionOptions, ConversionResult, Framework, ReactConversionOptions, VueConversionOptions, convertToReact, convertToVue, createSvgoConfig, formatComponentName, optimizeSvg, pascalCase, readSvgDirectory, readSvgFile, sanitizeComponentName, svgToComponentName, writeComponentFile, writeSvgFile };
|