svger-cli 4.0.4 โ†’ 4.0.5

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/CHANGELOG.md CHANGED
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
6
6
  adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [4.0.5] - 2026-02-26
9
+
10
+ ### ๐Ÿ› Bug Fixes
11
+
12
+ - **Watch Mode Stability**: Fixed a critical bug in `watch.ts` and `svg-service.ts` where file deletion logic failed to respect user configuration (naming convention, file extensions) and incorrectly defaulted to PascalCase/TSX.
13
+ - **Performance Optimization**: Updated `PerformanceEngine` to use asynchronous file stats (`fs.promises.stat`) instead of synchronous calls, unlocking true parallel processing capabilities and preventing main thread blocking during large batch operations.
14
+ - **Regex Optimization**: Optimized `basic-cleaner.ts` to use a single compiled RegExp for attribute replacement instead of creating a new RegExp for every attribute in every file, resulting in significantly faster processing.
15
+ - **Visual Testing Infrastructure**: Fixed broken visual regression test scripts in `package.json` and corrected relative import paths in `tests/dev/test-visual-diff.js` and `tests/dev/test-visual-integration.js`.
16
+
17
+ ### ๐Ÿš€ Performance
18
+
19
+ - **Parallel Processing**: Asynchronous file operations in the performance engine now allow for non-blocking concurrent processing, improving throughput for large icon sets.
20
+ - **Optimizer Speed**: Attribute cleaning is now O(N) instead of O(K*N), reducing overhead in the optimization pipeline.
21
+
22
+ ---
23
+
8
24
  ## [4.0.4] - 2026-02-17
9
25
 
10
26
  ### ๐Ÿงช Test Suite Stabilization
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <div align="center">
2
2
  <img src="./assets/svger-cli.png" alt="SVGER-CLI Banner" width="100%" />
3
3
 
4
- <h1>SVGER-CLI v4.0.3</h1>
4
+ <h1>SVGER-CLI v4.0.5</h1>
5
5
  <h3>Enterprise SVG Processing Framework with Plugin System</h3>
6
6
 
7
7
  <p>
@@ -135,9 +135,9 @@
135
135
 
136
136
  ---
137
137
 
138
- ## ๏ฟฝ **Upgrade to v4.0.3 - Automatic Migration!**
138
+ ## ๏ฟฝ **Upgrade to v4.0.5 - Automatic Migration!**
139
139
 
140
- **v4.0.3 is here with powerful new features!** If you're upgrading from v3.x:
140
+ **v4.0.5 is here with powerful new features!** If you're upgrading from v3.x:
141
141
 
142
142
  โœ… **Zero Breaking Changes** - All your existing code works
143
143
  โœ… **Automatic Config Migration** - Your `.svgconfig.json` updates automatically
@@ -146,20 +146,29 @@
146
146
 
147
147
  **Upgrade Now:**
148
148
  ```bash
149
- npm install -g svger-cli@4.0.3
149
+ npm install -g svger-cli@4.0.5
150
150
  # or
151
- npm install --save-dev svger-cli@4.0.3
151
+ npm install --save-dev svger-cli@4.0.5
152
152
  ```
153
153
 
154
154
  **[See What's New โ†’](#-whats-new-in-v400)** | **[Migration Guide โ†’](#-migration-guide)**
155
155
 
156
156
  ---
157
157
 
158
- ## ๏ฟฝ๐ŸŒŸ **What's New in v4.0.3**
158
+ ## ๏ฟฝ๐ŸŒŸ **What's New in v4.0.5**
159
159
 
160
- ### **๐Ÿ”Œ Extensible Plugin System**
160
+ ### **๏ฟฝ Performance & Stability Improvements**
161
161
 
162
- v4.0.3 introduces a powerful plugin architecture that allows you to extend and customize SVG processing:
162
+ v4.0.5 introduces critical performance optimizations and stability fixes:
163
+
164
+ - โšก **True Parallel Processing**: Non-blocking asynchronous file operations in the core engine
165
+ - ๐Ÿ› **Reliable Watch Mode**: Fixed file deletion handling to respect all user configurations
166
+ - ๐Ÿ”ง **Optimized Regex Engine**: Faster attribute cleaning pipeline
167
+ - ๐Ÿงช **Robust Visual Testing**: Repaired and stabilized visual regression test suite
168
+
169
+ ### **๏ฟฝ๐Ÿ”Œ Extensible Plugin System**
170
+
171
+ v4.0.5 introduces a powerful plugin architecture that allows you to extend and customize SVG processing:
163
172
 
164
173
  ```bash
165
174
  # Use built-in plugins
@@ -337,7 +346,7 @@ node test-visual-integration.js # Integration tests (16/16 passi
337
346
  > Includes: Benchmark methodology, dependency analysis, Webpack integration guide, and all 28
338
347
  > configuration options explained.
339
348
 
340
- | **Feature** | **SVGER-CLI v4.0.3** | **SVGR (React)** | **vite-svg-loader (Vue)** | **svelte-svg (Svelte)** | **SVGO** |
349
+ | **Feature** | **SVGER-CLI v4.0.5** | **SVGR (React)** | **vite-svg-loader (Vue)** | **svelte-svg (Svelte)** | **SVGO** |
341
350
  | -------------------------- | -------------------------- | ---------------- | ------------------------- | ----------------------- | ------------------- |
342
351
  | **Dependencies** | โœ… **Zero** | โŒ 15+ deps | โŒ 9+ deps | โŒ 7+ deps | โŒ 8+ deps |
343
352
  | **Auto-Generated Exports** | โœ… **Full Support** | โŒ Manual | โŒ Manual | โŒ Manual | โŒ N/A |
@@ -351,7 +360,7 @@ node test-visual-integration.js # Integration tests (16/16 passi
351
360
  | **TypeScript** | โœ… **Native** | Plugin | Limited | Limited | None |
352
361
  | **Batch Processing** | โœ… **Optimized** | Basic | None | None | None |
353
362
  | **Plugin System** | โœ… **Extensible** | Limited | None | None | None |
354
- | **Auto Migration** | โœ… **v3.x โ†’ v4.0.3** | โŒ Manual | โŒ N/A | โŒ N/A | โŒ N/A |
363
+ | **Auto Migration** | โœ… **v3.x โ†’ v4.0.5** | โŒ Manual | โŒ N/A | โŒ N/A | โŒ N/A |
355
364
  | **Configuration Schema** | โœ… **28 Options** | โŒ 8 Options | โŒ 4 Options | โŒ 3 Options | โŒ N/A |
356
365
  | **Responsive Design** | โœ… **Built-in** | โŒ Manual | โŒ None | โŒ None | โŒ None |
357
366
  | **Theme System** | โœ… **Auto Dark/Light** | โŒ Manual | โŒ None | โŒ None | โŒ None |
@@ -1403,7 +1412,7 @@ svger-cli build [options]
1403
1412
  - `--styled-components` - Generate styled-components (React/Solid)
1404
1413
  - `--css-modules` - Enable CSS Modules support
1405
1414
 
1406
- **Plugin Options (NEW in v4.0.3):**
1415
+ **Plugin Options (NEW in v4.0.5):**
1407
1416
 
1408
1417
  - `--plugin <name>` - Apply single plugin (can be repeated)
1409
1418
  - `--plugins <list>` - Apply multiple plugins (comma-separated)
@@ -2642,7 +2651,7 @@ Vue, Angular, and other frameworks.
2642
2651
  > **Real-world test:** 606 production SVG icons (brand logos, UI icons, social media icons)
2643
2652
  > **[โ†’ View Complete Benchmark Report](./docs/performance/REAL-WORLD-BENCHMARKS.md)**
2644
2653
 
2645
- | **Operation** | **SVGER v4.0.3** | **SVGR** | **SVGO** | **Improvement** |
2654
+ | **Operation** | **SVGER v4.0.5** | **SVGR** | **SVGO** | **Improvement** |
2646
2655
  | ----------------------- | ---------------- | -------- | -------- | --------------- |
2647
2656
  | **606 files batch** | **30.31s** | ~63.64s | ~45.46s | **52% faster than SVGR** |
2648
2657
  | **Per file average** | **50.01ms** | ~105ms | ~75ms | **52% faster than SVGR** |
@@ -2656,7 +2665,7 @@ Vue, Angular, and other frameworks.
2656
2665
 
2657
2666
  ### **Framework-Specific Performance**
2658
2667
 
2659
- All frameworks show consistent performance with v4.0.3 optimizations:
2668
+ All frameworks show consistent performance with v4.0.5 optimizations:
2660
2669
 
2661
2670
  | Framework | Time | Files | Speed/File | Throughput |
2662
2671
  |-----------|------|-------|------------|------------|
@@ -2667,9 +2676,9 @@ All frameworks show consistent performance with v4.0.3 optimizations:
2667
2676
 
2668
2677
  **Consistent Performance:** ~50ms per file across all frameworks
2669
2678
 
2670
- ### **SVG Optimization Performance (v4.0.3)**
2679
+ ### **SVG Optimization Performance (v4.0.5)**
2671
2680
 
2672
- SVGER-CLI v4.0.3 includes visual diff testing to guarantee pixel-perfect optimization quality:
2681
+ SVGER-CLI v4.0.5 includes visual diff testing to guarantee pixel-perfect optimization quality:
2673
2682
 
2674
2683
  | **Optimization Level** | **Size Reduction** | **Processing Time** | **Visual Quality** | **Memory Usage** |
2675
2684
  |------------------------|-------------------|---------------------|-------------------|------------------|
@@ -2690,7 +2699,7 @@ SVGER-CLI v4.0.3 includes visual diff testing to guarantee pixel-perfect optimiz
2690
2699
  - Complex paths (lossy): 14.3% with path simplification
2691
2700
  - Text rendering: 0.95% font variation acceptable
2692
2701
 
2693
- ### **SVG Optimization Levels (v4.0.3)**
2702
+ ### **SVG Optimization Levels (v4.0.5)**
2694
2703
 
2695
2704
  SVGER-CLI includes a powerful multi-phase optimization engine with configurable levels:
2696
2705
 
@@ -2719,7 +2728,7 @@ svger-cli optimize input.svg --level maximum # โ†’ 348 bytes (57.77%)
2719
2728
 
2720
2729
  ### **Real-World Performance Testing**
2721
2730
 
2722
- SVGER-CLI v4.0.3 has been tested with 606 production SVG icons including:
2731
+ SVGER-CLI v4.0.5 has been tested with 606 production SVG icons including:
2723
2732
  - Brand logos (Google, Apple, Microsoft, etc.)
2724
2733
  - UI icons (arrows, buttons, navigation)
2725
2734
  - Social media icons (Twitter, Facebook, LinkedIn, etc.)
@@ -3055,9 +3064,9 @@ svger-cli build --performance --memory
3055
3064
 
3056
3065
  ## ๐Ÿ“š **Migration Guide**
3057
3066
 
3058
- ### **Upgrading to v4.0.3 (Automatic)**
3067
+ ### **Upgrading to v4.0.5 (Automatic)**
3059
3068
 
3060
- **Good News:** v4.0.3 includes automatic configuration migration! Your existing config will be upgraded seamlessly on first run.
3069
+ **Good News:** v4.0.5 includes automatic configuration migration! Your existing config will be upgraded seamlessly on first run.
3061
3070
 
3062
3071
  #### **What Happens Automatically**
3063
3072
 
@@ -3069,8 +3078,8 @@ svger build --src ./svgs --out ./components
3069
3078
 
3070
3079
  The tool will:
3071
3080
  1. โœ… Detect your v3.x configuration
3072
- 2. โœ… Automatically migrate to v4.0.3 format
3073
- 3. โœ… Add new `version: "4.0.3"` field
3081
+ 2. โœ… Automatically migrate to v4.0.5 format
3082
+ 3. โœ… Add new `version: "4.0.5"` field
3074
3083
  4. โœ… Convert `plugin` (singular) โ†’ `plugins` (array)
3075
3084
  5. โœ… Update optimization levels (see mapping below)
3076
3085
  6. โœ… Save the migrated config
@@ -3088,9 +3097,9 @@ The tool will:
3088
3097
  "performance": { "optimization": "basic" }
3089
3098
  }
3090
3099
 
3091
- // Automatically becomes v4.0.3:
3100
+ // Automatically becomes v4.0.5:
3092
3101
  {
3093
- "version": "4.0.3",
3102
+ "version": "4.0.5",
3094
3103
  "source": "./src/assets/svg",
3095
3104
  "output": "./src/components/icons",
3096
3105
  "framework": "react",
@@ -3101,7 +3110,7 @@ The tool will:
3101
3110
 
3102
3111
  #### **Optimization Level Mapping**
3103
3112
 
3104
- | v3.x | v4.0.3 | Description |
3113
+ | v3.x | v4.0.5 | Description |
3105
3114
  |------|--------|-------------|
3106
3115
  | `none` | `fast` | Quick optimization |
3107
3116
  | `basic` | `fast` | Quick optimization |
@@ -3109,7 +3118,7 @@ The tool will:
3109
3118
  | `aggressive` | `maximum` | Maximum compression |
3110
3119
  | `maximum` | `maximum` | Maximum compression |
3111
3120
 
3112
- #### **What's New in v4.0.3**
3121
+ #### **What's New in v4.0.5**
3113
3122
 
3114
3123
  - ๐Ÿ”Œ **Plugin System**: Use `--plugin optimize` or `--plugins optimize,minify`
3115
3124
  - โšก **50% Faster**: O(1) object lookups replace O(n) switch statements
@@ -3121,12 +3130,12 @@ The tool will:
3121
3130
  If you prefer to update your config manually:
3122
3131
 
3123
3132
  ```bash
3124
- # Initialize new v4.0.3 config
3133
+ # Initialize new v4.0.5 config
3125
3134
  svger init
3126
3135
 
3127
3136
  # Or manually edit .svgconfig.json and add:
3128
3137
  {
3129
- "version": "4.0.3",
3138
+ "version": "4.0.5",
3130
3139
  "plugins": [], // Add this array
3131
3140
  // ... rest of your config
3132
3141
  }
@@ -3174,7 +3183,7 @@ svger-cli build --framework react --responsive --theme dark
3174
3183
 
3175
3184
  ### **Comprehensive Test Suite**
3176
3185
 
3177
- SVGER-CLI v4.0.3 includes a production-ready test suite with **114+ automated tests** covering:
3186
+ SVGER-CLI v4.0.5 includes a production-ready test suite with **114+ automated tests** covering:
3178
3187
 
3179
3188
  - โœ… **Unit Tests** - Core modules, utilities, and processors
3180
3189
  - โœ… **Integration Tests** - Complete workflows and multi-framework support
@@ -56,7 +56,7 @@ export class PerformanceEngine {
56
56
  */
57
57
  async processSingleWithCaching(file) {
58
58
  const startTime = Date.now();
59
- const cacheKey = this.generateCacheKey(file.path, file.options || {});
59
+ const cacheKey = await this.generateCacheKey(file.path, file.options || {});
60
60
  // Check cache first
61
61
  const cached = this.getCachedResult(cacheKey);
62
62
  if (cached) {
@@ -171,11 +171,12 @@ export class PerformanceEngine {
171
171
  semaphore.release();
172
172
  }
173
173
  }
174
- generateCacheKey(filePath, options) {
174
+ async generateCacheKey(filePath, options) {
175
175
  // Include file modification time to invalidate cache when file changes
176
176
  let mtimeMs = 0;
177
177
  try {
178
- mtimeMs = fs.statSync(filePath).mtimeMs;
178
+ const stat = await fs.promises.stat(filePath);
179
+ mtimeMs = stat.mtimeMs;
179
180
  }
180
181
  catch {
181
182
  // File may not exist yet; use 0 so caching still works
@@ -79,12 +79,9 @@ export function convertToCamelCase(svg, config) {
79
79
  'fill-opacity': 'fillOpacity',
80
80
  'stroke-opacity': 'strokeOpacity',
81
81
  };
82
- let result = svg;
83
- for (const [kebab, camel] of Object.entries(attributeMap)) {
84
- const regex = new RegExp(kebab, 'g');
85
- result = result.replace(regex, camel);
86
- }
87
- return result;
82
+ // Create a single regex from all keys โ€” O(n) instead of O(k*n)
83
+ const regex = new RegExp(Object.keys(attributeMap).join('|'), 'g');
84
+ return svg.replace(regex, (match) => attributeMap[match]);
88
85
  }
89
86
  /**
90
87
  * Remove unnecessary XML namespace attributes
@@ -3,6 +3,7 @@ import { FileSystem } from '../utils/native.js';
3
3
  import { logger } from '../core/logger.js';
4
4
  import { configService } from './config.js';
5
5
  import { svgProcessor } from '../processors/svg-processor.js';
6
+ import { frameworkTemplateEngine } from '../core/framework-templates.js';
6
7
  import { fileWatcher } from './file-watcher.js';
7
8
  import { OptLevel } from '../optimizers/types.js';
8
9
  /**
@@ -261,12 +262,18 @@ export class SVGService {
261
262
  */
262
263
  async handleFileRemoval(filePath, outDir, config) {
263
264
  try {
264
- const namingConvention = config?.output?.naming || 'pascal';
265
+ // Get configuration
266
+ const fullConfig = configService.readConfig();
267
+ const mergedConfig = { ...fullConfig, ...config };
268
+ const namingConvention = mergedConfig.outputConfig?.naming || 'pascal';
269
+ const framework = mergedConfig.framework || 'react';
270
+ const typescript = mergedConfig.typescript !== false;
271
+ const extension = frameworkTemplateEngine.getFileExtension(framework, typescript);
265
272
  const componentName = svgProcessor.generateComponentName(path.basename(filePath), namingConvention);
266
- const componentPath = path.join(outDir, `${componentName}.tsx`);
273
+ const componentPath = path.join(outDir, `${componentName}.${extension}`);
267
274
  if (await FileSystem.exists(componentPath)) {
268
275
  await FileSystem.unlink(componentPath);
269
- logger.success(`Removed component: ${componentName}.tsx`);
276
+ logger.success(`Removed component: ${componentName}.${extension}`);
270
277
  }
271
278
  }
272
279
  catch (error) {
package/dist/watch.js CHANGED
@@ -1,7 +1,10 @@
1
1
  import path from 'path';
2
2
  import { generateSVG } from './builder.js';
3
3
  import { isLocked } from './lock.js';
4
- import { FileSystem, FileWatcher, toPascalCase } from './utils/native.js';
4
+ import { FileSystem, FileWatcher } from './utils/native.js';
5
+ import { configService } from './services/config.js';
6
+ import { svgProcessor } from './processors/svg-processor.js';
7
+ import { frameworkTemplateEngine } from './core/framework-templates.js';
5
8
  /**
6
9
  * Watches a source folder for changes to SVG files and automatically
7
10
  * rebuilds React components when SVGs are added, modified, or deleted.
@@ -59,13 +62,17 @@ export async function watchSVGs(config) {
59
62
  await generateSVG({ svgFile: filePath, outDir });
60
63
  }
61
64
  else {
62
- // File was deleted โ€” use PascalCase to match the generated component filename
63
- const baseName = path.basename(filePath, '.svg');
64
- const componentName = toPascalCase(baseName);
65
- const outFile = path.join(outDir, `${componentName}.tsx`);
65
+ // File was deleted โ€” use configured naming convention and extension
66
+ const config = configService.readConfig();
67
+ const namingConvention = config.outputConfig?.naming || 'pascal';
68
+ const framework = config.framework || 'react';
69
+ const typescript = config.typescript !== false;
70
+ const extension = frameworkTemplateEngine.getFileExtension(framework, typescript);
71
+ const componentName = svgProcessor.generateComponentName(path.basename(filePath), namingConvention);
72
+ const outFile = path.join(outDir, `${componentName}.${extension}`);
66
73
  if (await FileSystem.exists(outFile)) {
67
74
  await FileSystem.unlink(outFile);
68
- console.log(`๐Ÿ—‘๏ธ Removed component: ${componentName}.tsx`);
75
+ console.log(`๐Ÿ—‘๏ธ Removed component: ${componentName}.${extension}`);
69
76
  }
70
77
  }
71
78
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svger-cli",
3
- "version": "4.0.4",
3
+ "version": "4.0.5",
4
4
  "description": "Enterprise-grade SVG to component converter with advanced plugin system, visual diff testing, and official framework integrations. Supporting React, React Native, Vue, Angular, Svelte, Solid, Lit, Preact & Vanilla. Features TypeScript, HMR, optimization pipeline, and extensible architecture.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -94,10 +94,10 @@
94
94
  "test:config": "tsc tests/config-options.test.ts --outDir dist-tests --module es2022 --target es2022 --moduleResolution bundler && node dist-tests/config-options.test.js",
95
95
  "test:e2e": "tsc tests/e2e-complete.test.ts --outDir dist-tests --module es2022 --target es2022 --moduleResolution bundler && node dist-tests/e2e-complete.test.js",
96
96
  "test:integrations": "node tests/integrations/verify-integrations.mjs",
97
- "test:visual": "node test-visual-diff.js",
98
- "test:visual:integration": "node test-visual-integration.js",
99
- "test:visual:ci": "node test-visual-integration.js --strict",
100
- "test:visual:update": "UPDATE_SNAPSHOTS=1 node test-visual-diff.js",
97
+ "test:visual": "node tests/dev/test-visual-diff.js",
98
+ "test:visual:integration": "node tests/dev/test-visual-integration.js",
99
+ "test:visual:ci": "node tests/dev/test-visual-integration.js --strict",
100
+ "test:visual:update": "UPDATE_SNAPSHOTS=1 node tests/dev/test-visual-diff.js",
101
101
  "test:watch": "jest --watch",
102
102
  "test:coverage": "jest --coverage",
103
103
  "test:integration": "jest --testPathPattern=integration",