svger-cli 2.0.8 → 3.1.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.
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Test Fixtures
3
+ * Reusable test data for unit tests
4
+ */
5
+ export declare const sampleSVGs: {
6
+ simple: string;
7
+ withFill: string;
8
+ complex: string;
9
+ nested: string;
10
+ multiPath: string;
11
+ withGradient: string;
12
+ withText: string;
13
+ accessibility: string;
14
+ animated: string;
15
+ invalid: string;
16
+ empty: string;
17
+ malformed: string;
18
+ };
19
+ export declare const sampleConfigs: {
20
+ react: {
21
+ framework: string;
22
+ typescript: boolean;
23
+ naming: string;
24
+ generateIndex: boolean;
25
+ };
26
+ vue: {
27
+ framework: string;
28
+ typescript: boolean;
29
+ naming: string;
30
+ generateIndex: boolean;
31
+ };
32
+ angular: {
33
+ framework: string;
34
+ typescript: boolean;
35
+ naming: string;
36
+ generateIndex: boolean;
37
+ };
38
+ minimal: {
39
+ framework: string;
40
+ };
41
+ full: {
42
+ source: string;
43
+ output: string;
44
+ framework: string;
45
+ typescript: boolean;
46
+ naming: string;
47
+ generateIndex: boolean;
48
+ watch: boolean;
49
+ clean: boolean;
50
+ parallel: boolean;
51
+ verbose: boolean;
52
+ responsive: {
53
+ mobile: number;
54
+ tablet: number;
55
+ desktop: number;
56
+ };
57
+ theme: {
58
+ primary: string;
59
+ secondary: string;
60
+ };
61
+ };
62
+ };
63
+ export declare const expectedOutputs: {
64
+ react: {
65
+ js: string;
66
+ ts: string;
67
+ withForwardRef: string;
68
+ };
69
+ vue: {
70
+ composition: string;
71
+ options: string;
72
+ };
73
+ angular: {
74
+ standalone: string;
75
+ };
76
+ svelte: string;
77
+ indexFile: string;
78
+ };
79
+ export declare const mockFileStructure: {
80
+ input: {
81
+ 'home.svg': string;
82
+ 'user.svg': string;
83
+ 'settings.svg': string;
84
+ 'nested/folder/icon.svg': string;
85
+ };
86
+ expected: {
87
+ 'HomeIcon.tsx': string;
88
+ 'UserIcon.tsx': string;
89
+ 'SettingsIcon.tsx': string;
90
+ 'index.ts': string;
91
+ };
92
+ };
93
+ export declare const frameworks: string[];
94
+ export declare const namingConventions: string[];
95
+ export declare const fileExtensions: {
96
+ react: {
97
+ js: string;
98
+ ts: string;
99
+ };
100
+ 'react-native': {
101
+ js: string;
102
+ ts: string;
103
+ };
104
+ vue: {
105
+ js: string;
106
+ ts: string;
107
+ };
108
+ angular: {
109
+ js: string;
110
+ ts: string;
111
+ };
112
+ svelte: {
113
+ js: string;
114
+ ts: string;
115
+ };
116
+ solid: {
117
+ js: string;
118
+ ts: string;
119
+ };
120
+ lit: {
121
+ js: string;
122
+ ts: string;
123
+ };
124
+ preact: {
125
+ js: string;
126
+ ts: string;
127
+ };
128
+ vanilla: {
129
+ js: string;
130
+ ts: string;
131
+ };
132
+ };
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Test Fixtures
3
+ * Reusable test data for unit tests
4
+ */
5
+ export const sampleSVGs = {
6
+ simple: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
7
+ <circle cx="12" cy="12" r="10"/>
8
+ </svg>`,
9
+ withFill: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
10
+ <path d="M12 2L2 7l10 5 10-5-10-5z"/>
11
+ </svg>`,
12
+ complex: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
13
+ <path stroke-linecap="round" stroke-linejoin="round" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/>
14
+ </svg>`,
15
+ nested: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
16
+ <g>
17
+ <circle cx="12" cy="12" r="10"/>
18
+ <path d="M12 2v20"/>
19
+ <path d="M2 12h20"/>
20
+ </g>
21
+ </svg>`,
22
+ multiPath: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
23
+ <path d="M12 2L2 7l10 5 10-5-10-5z"/>
24
+ <path d="M2 17l10 5 10-5M2 12l10 5 10-5"/>
25
+ </svg>`,
26
+ withGradient: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
27
+ <defs>
28
+ <linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
29
+ <stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1" />
30
+ <stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1" />
31
+ </linearGradient>
32
+ </defs>
33
+ <circle cx="12" cy="12" r="10" fill="url(#grad1)"/>
34
+ </svg>`,
35
+ withText: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
36
+ <text x="12" y="12" text-anchor="middle">SVG</text>
37
+ </svg>`,
38
+ accessibility: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-labelledby="iconTitle">
39
+ <title id="iconTitle">Home Icon</title>
40
+ <desc>An icon representing a house</desc>
41
+ <path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/>
42
+ </svg>`,
43
+ animated: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
44
+ <circle cx="12" cy="12" r="10">
45
+ <animate attributeName="r" from="10" to="5" dur="1s" repeatCount="indefinite"/>
46
+ </circle>
47
+ </svg>`,
48
+ invalid: `<svg><unclosed`,
49
+ empty: ``,
50
+ malformed: `<invalid>not an svg</invalid>`
51
+ };
52
+ export const sampleConfigs = {
53
+ react: {
54
+ framework: 'react',
55
+ typescript: true,
56
+ naming: 'pascal',
57
+ generateIndex: true
58
+ },
59
+ vue: {
60
+ framework: 'vue',
61
+ typescript: true,
62
+ naming: 'kebab',
63
+ generateIndex: true
64
+ },
65
+ angular: {
66
+ framework: 'angular',
67
+ typescript: true,
68
+ naming: 'kebab',
69
+ generateIndex: true
70
+ },
71
+ minimal: {
72
+ framework: 'react'
73
+ },
74
+ full: {
75
+ source: './icons',
76
+ output: './components',
77
+ framework: 'react',
78
+ typescript: true,
79
+ naming: 'pascal',
80
+ generateIndex: true,
81
+ watch: false,
82
+ clean: true,
83
+ parallel: true,
84
+ verbose: true,
85
+ responsive: {
86
+ mobile: 16,
87
+ tablet: 20,
88
+ desktop: 24
89
+ },
90
+ theme: {
91
+ primary: '#007bff',
92
+ secondary: '#6c757d'
93
+ }
94
+ }
95
+ };
96
+ export const expectedOutputs = {
97
+ react: {
98
+ js: `import React from 'react';
99
+
100
+ export const TestIcon = (props) => (
101
+ <svg {...props}>
102
+ <circle cx="12" cy="12" r="10"/>
103
+ </svg>
104
+ );
105
+
106
+ export default TestIcon;`,
107
+ ts: `import React from 'react';
108
+
109
+ interface TestIconProps extends React.SVGProps<SVGSVGElement> {}
110
+
111
+ export const TestIcon: React.FC<TestIconProps> = (props) => (
112
+ <svg {...props}>
113
+ <circle cx="12" cy="12" r="10"/>
114
+ </svg>
115
+ );
116
+
117
+ export default TestIcon;`,
118
+ withForwardRef: `import React, { forwardRef } from 'react';
119
+
120
+ interface TestIconProps extends React.SVGProps<SVGSVGElement> {}
121
+
122
+ export const TestIcon = forwardRef<SVGSVGElement, TestIconProps>(
123
+ (props, ref) => (
124
+ <svg ref={ref} {...props}>
125
+ <circle cx="12" cy="12" r="10"/>
126
+ </svg>
127
+ )
128
+ );
129
+
130
+ TestIcon.displayName = 'TestIcon';
131
+
132
+ export default TestIcon;`
133
+ },
134
+ vue: {
135
+ composition: `<template>
136
+ <svg v-bind="$attrs">
137
+ <circle cx="12" cy="12" r="10"/>
138
+ </svg>
139
+ </template>
140
+
141
+ <script setup lang="ts">
142
+ </script>`,
143
+ options: `<template>
144
+ <svg v-bind="$attrs">
145
+ <circle cx="12" cy="12" r="10"/>
146
+ </svg>
147
+ </template>
148
+
149
+ <script lang="ts">
150
+ export default {
151
+ name: 'TestIcon'
152
+ };
153
+ </script>`
154
+ },
155
+ angular: {
156
+ standalone: `import { Component } from '@angular/core';
157
+
158
+ @Component({
159
+ selector: 'app-test-icon',
160
+ standalone: true,
161
+ template: \`
162
+ <svg>
163
+ <circle cx="12" cy="12" r="10"/>
164
+ </svg>
165
+ \`
166
+ })
167
+ export class TestIconComponent {}`
168
+ },
169
+ svelte: `<script lang="ts">
170
+ export let width: number = 24;
171
+ export let height: number = 24;
172
+ </script>
173
+
174
+ <svg {width} {height}>
175
+ <circle cx="12" cy="12" r="10"/>
176
+ </svg>`,
177
+ indexFile: `export { default as HomeIcon } from './HomeIcon';
178
+ export { default as UserIcon } from './UserIcon';
179
+ export { default as SettingsIcon } from './SettingsIcon';
180
+
181
+ /**
182
+ * SVG Components Index
183
+ * Generated by svger-cli
184
+ *
185
+ * Import individual components:
186
+ * import { HomeIcon } from './components';
187
+ *
188
+ * Import all components:
189
+ * import * as Icons from './components';
190
+ */`
191
+ };
192
+ export const mockFileStructure = {
193
+ input: {
194
+ 'home.svg': sampleSVGs.simple,
195
+ 'user.svg': sampleSVGs.withFill,
196
+ 'settings.svg': sampleSVGs.complex,
197
+ 'nested/folder/icon.svg': sampleSVGs.nested
198
+ },
199
+ expected: {
200
+ 'HomeIcon.tsx': expectedOutputs.react.ts,
201
+ 'UserIcon.tsx': expectedOutputs.react.ts,
202
+ 'SettingsIcon.tsx': expectedOutputs.react.ts,
203
+ 'index.ts': expectedOutputs.indexFile
204
+ }
205
+ };
206
+ export const frameworks = [
207
+ 'react',
208
+ 'react-native',
209
+ 'vue',
210
+ 'angular',
211
+ 'svelte',
212
+ 'solid',
213
+ 'lit',
214
+ 'preact',
215
+ 'vanilla'
216
+ ];
217
+ export const namingConventions = ['pascal', 'camel', 'kebab'];
218
+ export const fileExtensions = {
219
+ react: { js: '.jsx', ts: '.tsx' },
220
+ 'react-native': { js: '.jsx', ts: '.tsx' },
221
+ vue: { js: '.vue', ts: '.vue' },
222
+ angular: { js: '.component.ts', ts: '.component.ts' },
223
+ svelte: { js: '.svelte', ts: '.svelte' },
224
+ solid: { js: '.tsx', ts: '.tsx' },
225
+ lit: { js: '.ts', ts: '.ts' },
226
+ preact: { js: '.tsx', ts: '.tsx' },
227
+ vanilla: { js: '.ts', ts: '.ts' }
228
+ };
package/dist/index.d.ts CHANGED
@@ -146,6 +146,36 @@ export declare const SVGER: {
146
146
  */
147
147
  export declare const VERSION = "2.0.0";
148
148
  export declare const PACKAGE_NAME = "svger-cli";
149
+ /**
150
+ * Webpack Plugin - Official webpack integration for SVGER-CLI
151
+ * Provides: HMR support, asset processing, and webpack loader
152
+ */
153
+ export { SvgerWebpackPlugin, svgerLoader, default as webpackPlugin, } from './integrations/webpack.js';
154
+ /**
155
+ * Vite Plugin - Official Vite integration for SVGER-CLI
156
+ * Provides: HMR support, virtual modules, and dev server integration
157
+ */
158
+ export { svgerVitePlugin, default as vitePlugin } from './integrations/vite.js';
159
+ /**
160
+ * Rollup Plugin - Official Rollup integration for SVGER-CLI
161
+ * Provides: Bundle optimization and tree-shaking support
162
+ */
163
+ export { svgerRollupPlugin, default as rollupPlugin, } from './integrations/rollup.js';
164
+ /**
165
+ * Babel Plugin - Official Babel integration for SVGER-CLI
166
+ * Provides: SVG import transformation and component generation
167
+ */
168
+ export { svgerBabelPlugin, createBabelPlugin, default as babelPlugin, } from './integrations/babel.js';
169
+ /**
170
+ * Next.js Plugin - Official Next.js integration for SVGER-CLI
171
+ * Provides: SSR support, webpack integration, and HMR
172
+ */
173
+ export { withSvger, SvgerNextJsPlugin, configureSvgImports, default as nextjsPlugin, } from './integrations/nextjs.js';
174
+ /**
175
+ * Jest Preset - Official Jest integration for SVGER-CLI
176
+ * Provides: SVG transformers and test configuration
177
+ */
178
+ export { svgerJestTransformer, jestPreset, createJestTransformer, default as jestTransformer, } from './integrations/jest-preset.js';
149
179
  /**
150
180
  * Default export - Primary SVG processor instance for quick access
151
181
  * Most common entry point for programmatic usage
package/dist/index.js CHANGED
@@ -148,6 +148,39 @@ export const SVGER = {
148
148
  export const VERSION = '2.0.0';
149
149
  export const PACKAGE_NAME = 'svger-cli';
150
150
  // ============================================================================
151
+ // BUILD TOOL INTEGRATIONS
152
+ // ============================================================================
153
+ /**
154
+ * Webpack Plugin - Official webpack integration for SVGER-CLI
155
+ * Provides: HMR support, asset processing, and webpack loader
156
+ */
157
+ export { SvgerWebpackPlugin, svgerLoader, default as webpackPlugin, } from './integrations/webpack.js';
158
+ /**
159
+ * Vite Plugin - Official Vite integration for SVGER-CLI
160
+ * Provides: HMR support, virtual modules, and dev server integration
161
+ */
162
+ export { svgerVitePlugin, default as vitePlugin } from './integrations/vite.js';
163
+ /**
164
+ * Rollup Plugin - Official Rollup integration for SVGER-CLI
165
+ * Provides: Bundle optimization and tree-shaking support
166
+ */
167
+ export { svgerRollupPlugin, default as rollupPlugin, } from './integrations/rollup.js';
168
+ /**
169
+ * Babel Plugin - Official Babel integration for SVGER-CLI
170
+ * Provides: SVG import transformation and component generation
171
+ */
172
+ export { svgerBabelPlugin, createBabelPlugin, default as babelPlugin, } from './integrations/babel.js';
173
+ /**
174
+ * Next.js Plugin - Official Next.js integration for SVGER-CLI
175
+ * Provides: SSR support, webpack integration, and HMR
176
+ */
177
+ export { withSvger, SvgerNextJsPlugin, configureSvgImports, default as nextjsPlugin, } from './integrations/nextjs.js';
178
+ /**
179
+ * Jest Preset - Official Jest integration for SVGER-CLI
180
+ * Provides: SVG transformers and test configuration
181
+ */
182
+ export { svgerJestTransformer, jestPreset, createJestTransformer, default as jestTransformer, } from './integrations/jest-preset.js';
183
+ // ============================================================================
151
184
  // DEFAULT EXPORT
152
185
  // ============================================================================
153
186
  /**
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Official Babel Plugin for SVGER-CLI
3
+ *
4
+ * Transforms SVG imports into framework components during Babel transpilation.
5
+ * Works with any Babel-based build process including standalone Babel, Create React App,
6
+ * and other tools that use Babel under the hood.
7
+ *
8
+ * @example
9
+ * ```js
10
+ * // babel.config.js
11
+ * const { svgerBabelPlugin } = require('svger-cli/babel');
12
+ *
13
+ * module.exports = {
14
+ * plugins: [
15
+ * [svgerBabelPlugin, {
16
+ * source: './src/icons',
17
+ * output: './src/components/icons',
18
+ * framework: 'react',
19
+ * typescript: true
20
+ * }]
21
+ * ]
22
+ * };
23
+ * ```
24
+ *
25
+ * @example
26
+ * ```js
27
+ * // Direct SVG import transformation
28
+ * import Icon from './icon.svg';
29
+ * // Transforms to:
30
+ * import Icon from './components/icons/Icon';
31
+ * ```
32
+ */
33
+ import type { BabelPluginOptions } from '../types/integrations.js';
34
+ /**
35
+ * Babel Plugin for SVGER-CLI
36
+ *
37
+ * This plugin processes SVG files and transforms SVG imports to component imports.
38
+ * It can run in two modes:
39
+ * - Pre-build: Process all SVGs before Babel transformation
40
+ * - On-demand: Transform SVG imports as they're encountered
41
+ */
42
+ export declare function svgerBabelPlugin(api: any, options?: BabelPluginOptions): any;
43
+ /**
44
+ * Create a Babel plugin instance with preset options
45
+ *
46
+ * @example
47
+ * ```js
48
+ * const plugin = createBabelPlugin({
49
+ * source: './icons',
50
+ * framework: 'react'
51
+ * });
52
+ * ```
53
+ */
54
+ export declare function createBabelPlugin(options?: BabelPluginOptions): (api: any) => any;
55
+ /**
56
+ * Default export for convenient usage
57
+ */
58
+ export default svgerBabelPlugin;