svger-cli 2.0.1 → 2.0.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.
Files changed (84) hide show
  1. package/dist/cli.js +0 -0
  2. package/dist/core/error-handler.d.ts +63 -0
  3. package/dist/core/error-handler.js +224 -0
  4. package/dist/core/framework-templates.d.ts +17 -0
  5. package/{src/core/framework-templates.ts → dist/core/framework-templates.js} +100 -137
  6. package/dist/core/logger.d.ts +22 -0
  7. package/dist/core/logger.js +85 -0
  8. package/dist/core/performance-engine.d.ts +67 -0
  9. package/dist/core/performance-engine.js +251 -0
  10. package/dist/core/plugin-manager.d.ts +56 -0
  11. package/dist/core/plugin-manager.js +189 -0
  12. package/dist/core/style-compiler.d.ts +88 -0
  13. package/dist/core/style-compiler.js +466 -0
  14. package/dist/core/template-manager.d.ts +64 -0
  15. package/{src/core/template-manager.ts → dist/core/template-manager.js} +172 -255
  16. package/dist/index.d.ts +151 -0
  17. package/{src/index.ts → dist/index.js} +30 -108
  18. package/dist/processors/svg-processor.d.ts +67 -0
  19. package/dist/processors/svg-processor.js +225 -0
  20. package/dist/services/config.d.ts +55 -0
  21. package/dist/services/config.js +209 -0
  22. package/dist/services/file-watcher.d.ts +54 -0
  23. package/dist/services/file-watcher.js +180 -0
  24. package/dist/services/svg-service.d.ts +81 -0
  25. package/dist/services/svg-service.js +383 -0
  26. package/dist/types/index.d.ts +140 -0
  27. package/dist/types/index.js +4 -0
  28. package/dist/utils/native.d.ts +74 -0
  29. package/dist/utils/native.js +305 -0
  30. package/package.json +9 -10
  31. package/.svgconfig.json +0 -3
  32. package/CODE_OF_CONDUCT.md +0 -79
  33. package/CONTRIBUTING.md +0 -146
  34. package/TESTING.md +0 -143
  35. package/cli-framework.test.js +0 -16
  36. package/cli-test-angular/Arrowbenddownleft.component.ts +0 -27
  37. package/cli-test-angular/Vite.component.ts +0 -27
  38. package/cli-test-angular/index.ts +0 -25
  39. package/cli-test-output/Arrowbenddownleft.vue +0 -33
  40. package/cli-test-output/Vite.vue +0 -33
  41. package/cli-test-output/index.ts +0 -25
  42. package/cli-test-react/Arrowbenddownleft.tsx +0 -39
  43. package/cli-test-react/Vite.tsx +0 -39
  44. package/cli-test-react/index.ts +0 -25
  45. package/cli-test-svelte/Arrowbenddownleft.svelte +0 -22
  46. package/cli-test-svelte/Vite.svelte +0 -22
  47. package/cli-test-svelte/index.ts +0 -25
  48. package/docs/ADR-SVG-INTRGRATION-METHODS-001.adr.md +0 -157
  49. package/docs/ADR-SVG-INTRGRATION-METHODS-002.adr.md +0 -550
  50. package/docs/FRAMEWORK-GUIDE.md +0 -768
  51. package/docs/IMPLEMENTATION-SUMMARY.md +0 -376
  52. package/docs/TDR-SVG-INTRGRATION-METHODS-001.tdr.md +0 -115
  53. package/frameworks.test.js +0 -170
  54. package/my-svgs/ArrowBendDownLeft.svg +0 -6
  55. package/my-svgs/vite.svg +0 -1
  56. package/src/builder.ts +0 -104
  57. package/src/clean.ts +0 -21
  58. package/src/cli.ts +0 -221
  59. package/src/config.ts +0 -81
  60. package/src/core/error-handler.ts +0 -303
  61. package/src/core/logger.ts +0 -104
  62. package/src/core/performance-engine.ts +0 -327
  63. package/src/core/plugin-manager.ts +0 -228
  64. package/src/core/style-compiler.ts +0 -605
  65. package/src/lock.ts +0 -74
  66. package/src/processors/svg-processor.ts +0 -288
  67. package/src/services/config.ts +0 -241
  68. package/src/services/file-watcher.ts +0 -218
  69. package/src/services/svg-service.ts +0 -468
  70. package/src/templates/ComponentTemplate.ts +0 -57
  71. package/src/types/index.ts +0 -169
  72. package/src/utils/native.ts +0 -352
  73. package/src/watch.ts +0 -88
  74. package/test-output-mulit/TestIcon-angular-module.component.ts +0 -26
  75. package/test-output-mulit/TestIcon-angular-standalone.component.ts +0 -27
  76. package/test-output-mulit/TestIcon-lit.ts +0 -35
  77. package/test-output-mulit/TestIcon-preact.tsx +0 -38
  78. package/test-output-mulit/TestIcon-react.tsx +0 -35
  79. package/test-output-mulit/TestIcon-solid.tsx +0 -27
  80. package/test-output-mulit/TestIcon-svelte.svelte +0 -22
  81. package/test-output-mulit/TestIcon-vanilla.ts +0 -37
  82. package/test-output-mulit/TestIcon-vue-composition.vue +0 -33
  83. package/test-output-mulit/TestIcon-vue-options.vue +0 -31
  84. package/tsconfig.json +0 -18
@@ -1,235 +1,157 @@
1
1
  /**
2
2
  * SVGER-CLI - Zero-Dependency SVG to React Component Generator
3
- *
3
+ *
4
4
  * A high-performance, framework-agnostic SVG processing toolkit with enterprise-grade
5
5
  * architecture and comprehensive styling capabilities.
6
- *
6
+ *
7
7
  * @version 2.0.0
8
8
  * @author SVGER-CLI Development Team
9
9
  * @license MIT
10
10
  */
11
-
12
11
  // ============================================================================
13
12
  // CORE SERVICES
14
13
  // ============================================================================
15
-
16
14
  /**
17
15
  * Logger Service - Professional logging with configurable levels and color formatting
18
16
  * Provides: debug, info, warn, error, success methods with timestamp and context
19
17
  */
20
18
  export { LoggerService, logger } from './core/logger.js';
21
-
22
19
  /**
23
20
  * Configuration Management Service - Centralized configuration with validation and caching
24
21
  * Provides: config loading, validation, defaults, and file-based persistence
25
22
  */
26
23
  export { ConfigService, configService } from './services/config.js';
27
-
28
24
  /**
29
25
  * Error Handler - Comprehensive error management with recovery strategies
30
26
  * Provides: structured error handling, recovery mechanisms, and user-friendly messages
31
27
  */
32
28
  export { SVGErrorHandler, errorHandler, withErrorHandling, handleErrors } from './core/error-handler.js';
33
-
34
29
  // ============================================================================
35
30
  // PROCESSING ENGINES
36
31
  // ============================================================================
37
-
38
32
  /**
39
33
  * SVG Processor - Core SVG content processing and React component generation
40
34
  * Provides: SVG parsing, optimization, React component generation, and batch processing
41
35
  */
42
36
  export { SVGProcessor, svgProcessor } from './processors/svg-processor.js';
43
-
44
37
  /**
45
38
  * Performance Engine - Advanced optimization for batch processing and parallel execution
46
39
  * Provides: batch processing, caching, memory optimization, and performance monitoring
47
40
  */
48
41
  export { PerformanceEngine, performanceEngine } from './core/performance-engine.js';
49
-
50
42
  /**
51
43
  * Style Compiler - Comprehensive styling system with responsive design and theming
52
44
  * Provides: CSS generation, theme management, responsive values, and style optimization
53
45
  */
54
46
  export { SVGStyleCompiler, styleCompiler } from './core/style-compiler.js';
55
-
56
47
  // ============================================================================
57
48
  // TEMPLATE SYSTEMS
58
49
  // ============================================================================
59
-
60
50
  /**
61
51
  * Template Manager - Extensible template system for React component generation
62
52
  * Provides: multiple component patterns (functional, class, forwardRef, styled-components)
63
53
  */
64
54
  export { TemplateManager, templateManager } from './core/template-manager.js';
65
-
66
55
  /**
67
56
  * Framework Template Engine - Universal template generator supporting multiple UI frameworks
68
57
  * Provides: React, Vue, Svelte, Angular, Solid, Preact, Lit, and Vanilla JS components
69
58
  */
70
- export {
71
- FrameworkTemplateEngine,
72
- frameworkTemplateEngine,
73
- type FrameworkType,
74
- type FrameworkOptions
75
- } from './core/framework-templates.js';
76
-
59
+ export { FrameworkTemplateEngine, frameworkTemplateEngine } from './core/framework-templates.js';
77
60
  // ============================================================================
78
61
  // PLUGIN ARCHITECTURE
79
62
  // ============================================================================
80
-
81
63
  /**
82
64
  * Plugin Manager - Extensible plugin system for SVG processing enhancements
83
65
  * Provides: plugin registration, lifecycle management, and content processing pipeline
84
66
  */
85
67
  export { PluginManager, pluginManager } from './core/plugin-manager.js';
86
-
87
68
  // ============================================================================
88
69
  // UTILITY SERVICES
89
70
  // ============================================================================
90
-
91
71
  /**
92
72
  * Native Node.js Utilities - Zero-dependency replacements for external libraries
93
73
  * Provides: file operations, string manipulation, CLI parsing, and file watching
94
74
  */
95
- export {
96
- toPascalCase,
97
- FileSystem,
98
- CLI,
99
- FileWatcher
100
- } from './utils/native.js';
101
-
75
+ export { toPascalCase, FileSystem, CLI, FileWatcher } from './utils/native.js';
102
76
  /**
103
77
  * File System Lock Functions - Concurrent file operation safety with advisory locking
104
78
  * Provides: file locking, unlocking, and lock status checking for safe concurrent access
105
79
  */
106
80
  export { lockFiles, unlockFiles, isLocked } from './lock.js';
107
-
108
81
  /**
109
82
  * File System Watcher - Real-time file system monitoring with change detection
110
83
  * Provides: directory watching, file change detection, and event-driven processing
111
84
  */
112
85
  export { watchSVGs } from './watch.js';
113
-
114
86
  /**
115
87
  * Project Builder - Automated project structure creation and dependency management
116
88
  * Provides: project scaffolding, dependency resolution, and build automation
117
89
  */
118
90
  export { buildAll, generateSVG } from './builder.js';
119
-
120
91
  /**
121
92
  * Content Cleaner - SVG content optimization and sanitization utilities
122
93
  * Provides: SVG cleaning, attribute normalization, and content optimization
123
94
  */
124
95
  export { clean } from './clean.js';
125
-
126
- // ============================================================================
127
- // TYPE DEFINITIONS
128
- // ============================================================================
129
-
130
- /**
131
- * TypeScript Type Definitions - Comprehensive type system for all interfaces and configurations
132
- * Provides: complete type safety for all operations, configurations, and data structures
133
- */
134
- export type {
135
- // Core configuration types
136
- SVGConfig,
137
- ComponentGenerationOptions,
138
-
139
- // Processing types
140
- SVGProcessorResult,
141
- ProcessingJob,
142
- ProcessingStatus,
143
-
144
- // Plugin system types
145
- Plugin,
146
- PluginConfig,
147
-
148
- // Template system types
149
- Template,
150
- TemplateConfig,
151
-
152
- // File operation types
153
- WatchOptions
154
- } from './types/index.js';
155
-
156
- /**
157
- * Error handling types - Available from core error handler
158
- */
159
- export type { SVGError, ErrorRecoveryStrategy } from './core/error-handler.js';
160
-
161
96
  // ============================================================================
162
97
  // TEMPLATES
163
98
  // ============================================================================
164
-
165
99
  /**
166
100
  * Component Templates - Pre-built component templates for various use cases
167
101
  * Provides: functional React component template with TypeScript support
168
102
  */
169
103
  export { reactTemplate } from './templates/ComponentTemplate.js';
170
-
171
104
  // ============================================================================
172
105
  // CONVENIENCE API
173
106
  // ============================================================================
174
-
175
107
  // Import instances for the convenience API
176
108
  import { svgProcessor } from './processors/svg-processor.js';
177
109
  import { watchSVGs } from './watch.js';
178
110
  import { clean } from './clean.js';
179
111
  import { buildAll } from './builder.js';
180
-
181
112
  /**
182
113
  * Quick Start API - Simplified API for common operations
183
114
  * High-level functions for typical SVG processing workflows
184
115
  */
185
116
  export const SVGER = {
186
- /**
187
- * Process single SVG file to React component
188
- */
189
- processFile: svgProcessor.processSVGFile.bind(svgProcessor),
190
-
191
- /**
192
- * Process multiple SVG files in batch
193
- */
194
- processBatch: svgProcessor.processBatch.bind(svgProcessor),
195
-
196
- /**
197
- * Generate framework-agnostic component
198
- */
199
- generateFrameworkComponent: svgProcessor.generateFrameworkComponent.bind(svgProcessor),
200
-
201
- /**
202
- * Watch directory for changes
203
- */
204
- watch: watchSVGs,
205
-
206
- /**
207
- * Clean and optimize directory
208
- */
209
- clean,
210
-
211
- /**
212
- * Build all SVG files in directory
213
- */
214
- build: buildAll
215
- } as const;
216
-
117
+ /**
118
+ * Process single SVG file to React component
119
+ */
120
+ processFile: svgProcessor.processSVGFile.bind(svgProcessor),
121
+ /**
122
+ * Process multiple SVG files in batch
123
+ */
124
+ processBatch: svgProcessor.processBatch.bind(svgProcessor),
125
+ /**
126
+ * Generate framework-agnostic component
127
+ */
128
+ generateFrameworkComponent: svgProcessor.generateFrameworkComponent.bind(svgProcessor),
129
+ /**
130
+ * Watch directory for changes
131
+ */
132
+ watch: watchSVGs,
133
+ /**
134
+ * Clean and optimize directory
135
+ */
136
+ clean,
137
+ /**
138
+ * Build all SVG files in directory
139
+ */
140
+ build: buildAll
141
+ };
217
142
  // ============================================================================
218
143
  // VERSION INFORMATION
219
144
  // ============================================================================
220
-
221
145
  /**
222
146
  * Package Version Information
223
147
  */
224
148
  export const VERSION = '2.0.0';
225
149
  export const PACKAGE_NAME = 'svger-cli';
226
-
227
150
  // ============================================================================
228
151
  // DEFAULT EXPORT
229
152
  // ============================================================================
230
-
231
153
  /**
232
154
  * Default export - Primary SVG processor instance for quick access
233
155
  * Most common entry point for programmatic usage
234
156
  */
235
- export default svgProcessor;
157
+ export default svgProcessor;
@@ -0,0 +1,67 @@
1
+ import { ComponentGenerationOptions, SVGProcessorResult } from '../types/index.js';
2
+ /**
3
+ * SVG content processor and component generator
4
+ */
5
+ export declare class SVGProcessor {
6
+ private static instance;
7
+ private processingQueue;
8
+ private jobCounter;
9
+ private constructor();
10
+ static getInstance(): SVGProcessor;
11
+ /**
12
+ * Clean and optimize SVG content
13
+ */
14
+ cleanSVGContent(svgContent: string): string;
15
+ /**
16
+ * Extract viewBox from SVG content
17
+ */
18
+ extractViewBox(svgContent: string): string | null;
19
+ /**
20
+ * Generate component name from filename
21
+ */
22
+ generateComponentName(fileName: string): string;
23
+ /**
24
+ * Generate React component from SVG content
25
+ */
26
+ generateComponent(componentName: string, svgContent: string, options?: Partial<ComponentGenerationOptions>): Promise<string>;
27
+ /**
28
+ * Generate framework-agnostic component from SVG content
29
+ */
30
+ generateFrameworkComponent(componentName: string, svgContent: string, options: ComponentGenerationOptions): Promise<string>;
31
+ /**
32
+ * Process multiple SVG files in batch with performance optimization
33
+ */
34
+ processBatch(files: Array<{
35
+ path: string;
36
+ outputDir: string;
37
+ options?: Partial<ComponentGenerationOptions>;
38
+ }>, config?: {
39
+ batchSize?: number;
40
+ parallel?: boolean;
41
+ maxConcurrency?: number;
42
+ }): Promise<Array<{
43
+ success: boolean;
44
+ filePath: string;
45
+ error?: Error;
46
+ duration: number;
47
+ }>>;
48
+ /**
49
+ * Process a single SVG file
50
+ */
51
+ processSVGFile(svgFilePath: string, outputDir: string, options?: Partial<ComponentGenerationOptions>): Promise<SVGProcessorResult>;
52
+ /**
53
+ * Get processing statistics
54
+ */
55
+ getProcessingStats(): {
56
+ total: number;
57
+ pending: number;
58
+ processing: number;
59
+ completed: number;
60
+ failed: number;
61
+ };
62
+ /**
63
+ * Clear processing queue
64
+ */
65
+ clearQueue(): void;
66
+ }
67
+ export declare const svgProcessor: SVGProcessor;
@@ -0,0 +1,225 @@
1
+ import path from 'path';
2
+ import { toPascalCase, FileSystem } from '../utils/native.js';
3
+ import { logger } from '../core/logger.js';
4
+ import { performanceEngine } from '../core/performance-engine.js';
5
+ import { frameworkTemplateEngine } from '../core/framework-templates.js';
6
+ /**
7
+ * SVG content processor and component generator
8
+ */
9
+ export class SVGProcessor {
10
+ static instance;
11
+ processingQueue = new Map();
12
+ jobCounter = 0;
13
+ constructor() { }
14
+ static getInstance() {
15
+ if (!SVGProcessor.instance) {
16
+ SVGProcessor.instance = new SVGProcessor();
17
+ }
18
+ return SVGProcessor.instance;
19
+ }
20
+ /**
21
+ * Clean and optimize SVG content
22
+ */
23
+ cleanSVGContent(svgContent) {
24
+ logger.debug('Cleaning SVG content');
25
+ return svgContent
26
+ // Remove XML declaration
27
+ .replace(/<\?xml.*?\?>/g, '')
28
+ // Remove DOCTYPE declaration
29
+ .replace(/<!DOCTYPE.*?>/g, '')
30
+ // Remove comments
31
+ .replace(/<!--[\s\S]*?-->/g, '')
32
+ // Normalize whitespace
33
+ .replace(/\r?\n|\r/g, '')
34
+ .replace(/\s{2,}/g, ' ')
35
+ // Remove inline styles (they interfere with React styling)
36
+ .replace(/style="[^"]*"/g, '')
37
+ // Remove xmlns attributes (React will handle these)
38
+ .replace(/\s+xmlns(:xlink)?="[^"]*"/g, '')
39
+ // Convert attributes to camelCase for React
40
+ .replace(/fill-rule/g, 'fillRule')
41
+ .replace(/clip-rule/g, 'clipRule')
42
+ .replace(/stroke-width/g, 'strokeWidth')
43
+ .replace(/stroke-linecap/g, 'strokeLinecap')
44
+ .replace(/stroke-linejoin/g, 'strokeLinejoin')
45
+ .replace(/stroke-miterlimit/g, 'strokeMiterlimit')
46
+ .replace(/stroke-dasharray/g, 'strokeDasharray')
47
+ .replace(/stroke-dashoffset/g, 'strokeDashoffset')
48
+ .replace(/font-family/g, 'fontFamily')
49
+ .replace(/font-size/g, 'fontSize')
50
+ .replace(/font-weight/g, 'fontWeight')
51
+ .replace(/text-anchor/g, 'textAnchor')
52
+ // Remove outer SVG tag and keep inner content
53
+ .trim()
54
+ .replace(/^<svg[^>]*>([\s\S]*)<\/svg>$/i, '$1')
55
+ .trim();
56
+ }
57
+ /**
58
+ * Extract viewBox from SVG content
59
+ */
60
+ extractViewBox(svgContent) {
61
+ const viewBoxMatch = svgContent.match(/viewBox=["']([^"']+)["']/i);
62
+ return viewBoxMatch ? viewBoxMatch[1] : null;
63
+ }
64
+ /**
65
+ * Generate component name from filename
66
+ */
67
+ generateComponentName(fileName) {
68
+ const baseName = path.basename(fileName, '.svg');
69
+ const componentName = toPascalCase(baseName);
70
+ // Ensure component name starts with uppercase letter
71
+ if (!/^[A-Z]/.test(componentName)) {
72
+ return `Svg${componentName}`;
73
+ }
74
+ return componentName;
75
+ }
76
+ /**
77
+ * Generate React component from SVG content
78
+ */
79
+ async generateComponent(componentName, svgContent, options = {}) {
80
+ try {
81
+ // Clean and optimize SVG content
82
+ const cleanedContent = this.cleanSVGContent(svgContent);
83
+ // Apply plugins (no plugin configs for now, just process directly)
84
+ const processedContent = cleanedContent;
85
+ // Create full options object with required fields
86
+ const fullOptions = {
87
+ componentName,
88
+ svgContent: processedContent,
89
+ framework: options.framework || 'react',
90
+ typescript: options.typescript !== undefined ? options.typescript : true,
91
+ ...options
92
+ };
93
+ // Use framework template engine directly
94
+ const component = frameworkTemplateEngine.generateComponent(fullOptions);
95
+ logger.debug(`Generated component: ${componentName}`);
96
+ return component;
97
+ }
98
+ catch (error) {
99
+ logger.error(`Failed to generate component ${componentName}:`, error);
100
+ throw error;
101
+ }
102
+ }
103
+ /**
104
+ * Generate framework-agnostic component from SVG content
105
+ */
106
+ async generateFrameworkComponent(componentName, svgContent, options) {
107
+ try {
108
+ // Optimize SVG content based on framework requirements
109
+ const optimizationLevel = options.framework === 'vanilla' ? 'maximum' : 'balanced';
110
+ const optimizedContent = performanceEngine.optimizeSVGContent(svgContent, optimizationLevel);
111
+ // Generate framework-specific component
112
+ const component = frameworkTemplateEngine.generateComponent({
113
+ ...options,
114
+ componentName,
115
+ svgContent: optimizedContent
116
+ });
117
+ logger.debug(`Generated ${options.framework} component: ${componentName}`);
118
+ return component;
119
+ }
120
+ catch (error) {
121
+ logger.error(`Failed to generate ${options.framework} component ${componentName}:`, error);
122
+ throw error;
123
+ }
124
+ }
125
+ /**
126
+ * Process multiple SVG files in batch with performance optimization
127
+ */
128
+ async processBatch(files, config = {}) {
129
+ logger.info(`Starting batch processing of ${files.length} files`);
130
+ try {
131
+ const results = await performanceEngine.processBatch(files, config);
132
+ // Log performance metrics
133
+ const metrics = performanceEngine.getPerformanceMetrics();
134
+ if (metrics.memoryUsage.recommendations.length > 0) {
135
+ logger.warn('Performance recommendations:', metrics.memoryUsage.recommendations);
136
+ }
137
+ return results;
138
+ }
139
+ catch (error) {
140
+ logger.error('Batch processing failed:', error);
141
+ throw error;
142
+ }
143
+ }
144
+ /**
145
+ * Process a single SVG file
146
+ */
147
+ async processSVGFile(svgFilePath, outputDir, options = {}) {
148
+ const jobId = `job-${++this.jobCounter}`;
149
+ const job = {
150
+ id: jobId,
151
+ filePath: svgFilePath,
152
+ status: 'processing',
153
+ startTime: Date.now()
154
+ };
155
+ this.processingQueue.set(jobId, job);
156
+ logger.debug(`Processing SVG file: ${svgFilePath}`);
157
+ try {
158
+ // Read SVG content
159
+ const svgContent = await FileSystem.readFile(svgFilePath, 'utf-8');
160
+ // Generate component name
161
+ const componentName = this.generateComponentName(path.basename(svgFilePath));
162
+ // Generate component code
163
+ const componentCode = await this.generateComponent(componentName, svgContent, options);
164
+ // Ensure output directory exists
165
+ await FileSystem.ensureDir(outputDir);
166
+ // Get correct file extension based on framework
167
+ const framework = options.framework || 'react';
168
+ const typescript = options.typescript !== undefined ? options.typescript : true;
169
+ const fileExtension = frameworkTemplateEngine.getFileExtension(framework, typescript);
170
+ // Write component file
171
+ const outputFilePath = path.join(outputDir, `${componentName}.${fileExtension}`);
172
+ await FileSystem.writeFile(outputFilePath, componentCode, 'utf-8');
173
+ // Update job status
174
+ job.status = 'completed';
175
+ job.endTime = Date.now();
176
+ const result = {
177
+ success: true,
178
+ componentName,
179
+ filePath: outputFilePath
180
+ };
181
+ logger.success(`Generated component: ${componentName}.${fileExtension}`);
182
+ return result;
183
+ }
184
+ catch (error) {
185
+ job.status = 'failed';
186
+ job.endTime = Date.now();
187
+ job.error = error;
188
+ const result = {
189
+ success: false,
190
+ componentName: '',
191
+ filePath: svgFilePath,
192
+ error: error
193
+ };
194
+ logger.error(`Failed to process ${svgFilePath}:`, error);
195
+ return result;
196
+ }
197
+ finally {
198
+ // Clean up completed jobs after some time
199
+ setTimeout(() => {
200
+ this.processingQueue.delete(jobId);
201
+ }, 30000); // 30 seconds
202
+ }
203
+ }
204
+ /**
205
+ * Get processing statistics
206
+ */
207
+ getProcessingStats() {
208
+ const jobs = Array.from(this.processingQueue.values());
209
+ return {
210
+ total: jobs.length,
211
+ pending: jobs.filter(j => j.status === 'pending').length,
212
+ processing: jobs.filter(j => j.status === 'processing').length,
213
+ completed: jobs.filter(j => j.status === 'completed').length,
214
+ failed: jobs.filter(j => j.status === 'failed').length,
215
+ };
216
+ }
217
+ /**
218
+ * Clear processing queue
219
+ */
220
+ clearQueue() {
221
+ this.processingQueue.clear();
222
+ }
223
+ }
224
+ // Export singleton instance
225
+ export const svgProcessor = SVGProcessor.getInstance();
@@ -0,0 +1,55 @@
1
+ import { SVGConfig } from '../types/index.js';
2
+ /**
3
+ * Professional configuration management service
4
+ */
5
+ export declare class ConfigService {
6
+ private static instance;
7
+ private static readonly CONFIG_FILE;
8
+ private cachedConfig;
9
+ private constructor();
10
+ static getInstance(): ConfigService;
11
+ /**
12
+ * Get the default configuration
13
+ */
14
+ getDefaultConfig(): SVGConfig;
15
+ /**
16
+ * Get configuration file path
17
+ */
18
+ private getConfigPath;
19
+ /**
20
+ * Read configuration from file with caching
21
+ */
22
+ readConfig(): SVGConfig;
23
+ /**
24
+ * Write configuration to file
25
+ */
26
+ writeConfig(config: SVGConfig): void;
27
+ /**
28
+ * Initialize configuration with defaults
29
+ */
30
+ initConfig(): Promise<void>;
31
+ /**
32
+ * Set a specific configuration value
33
+ */
34
+ setConfig(key: string, value: any): void;
35
+ /**
36
+ * Get a specific configuration value
37
+ */
38
+ getConfig(key?: string): any;
39
+ /**
40
+ * Validate configuration
41
+ */
42
+ validateConfig(config?: SVGConfig): {
43
+ valid: boolean;
44
+ errors: string[];
45
+ };
46
+ /**
47
+ * Clear cached configuration (useful for testing)
48
+ */
49
+ clearCache(): void;
50
+ /**
51
+ * Display current configuration
52
+ */
53
+ showConfig(): void;
54
+ }
55
+ export declare const configService: ConfigService;