svger-cli 2.0.1 → 2.0.3
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/.svgerconfig.example.json +38 -0
- package/CHANGELOG.md +64 -0
- package/DEVELOPMENT.md +353 -0
- package/README.md +24 -5
- package/SECURITY.md +69 -0
- package/dist/builder.js +16 -16
- package/dist/clean.js +2 -2
- package/dist/cli.js +38 -38
- package/dist/config.js +11 -11
- package/dist/core/error-handler.d.ts +63 -0
- package/dist/core/error-handler.js +227 -0
- package/dist/core/framework-templates.d.ts +17 -0
- package/{src/core/framework-templates.ts → dist/core/framework-templates.js} +104 -139
- package/dist/core/logger.d.ts +22 -0
- package/dist/core/logger.js +85 -0
- package/dist/core/performance-engine.d.ts +67 -0
- package/dist/core/performance-engine.js +252 -0
- package/dist/core/plugin-manager.d.ts +56 -0
- package/dist/core/plugin-manager.js +191 -0
- package/dist/core/style-compiler.d.ts +88 -0
- package/dist/core/style-compiler.js +468 -0
- package/dist/core/template-manager.d.ts +64 -0
- package/{src/core/template-manager.ts → dist/core/template-manager.js} +172 -255
- package/dist/index.d.ts +153 -0
- package/{src/index.ts → dist/index.js} +32 -110
- package/dist/lock.js +7 -7
- package/dist/processors/svg-processor.d.ts +73 -0
- package/dist/processors/svg-processor.js +261 -0
- package/dist/services/config.d.ts +55 -0
- package/dist/services/config.js +211 -0
- package/dist/services/file-watcher.d.ts +54 -0
- package/dist/services/file-watcher.js +180 -0
- package/dist/services/svg-service.d.ts +81 -0
- package/dist/services/svg-service.js +395 -0
- package/dist/templates/ComponentTemplate.js +25 -25
- package/dist/types/index.d.ts +146 -0
- package/dist/types/index.js +4 -0
- package/dist/utils/native.d.ts +104 -0
- package/dist/utils/native.js +340 -0
- package/dist/watch.d.ts +1 -1
- package/dist/watch.js +14 -14
- package/package.json +154 -14
- package/.svgconfig.json +0 -3
- package/CODE_OF_CONDUCT.md +0 -79
- package/CONTRIBUTING.md +0 -146
- package/TESTING.md +0 -143
- package/cli-framework.test.js +0 -16
- package/cli-test-angular/Arrowbenddownleft.component.ts +0 -27
- package/cli-test-angular/Vite.component.ts +0 -27
- package/cli-test-angular/index.ts +0 -25
- package/cli-test-output/Arrowbenddownleft.vue +0 -33
- package/cli-test-output/Vite.vue +0 -33
- package/cli-test-output/index.ts +0 -25
- package/cli-test-react/Arrowbenddownleft.tsx +0 -39
- package/cli-test-react/Vite.tsx +0 -39
- package/cli-test-react/index.ts +0 -25
- package/cli-test-svelte/Arrowbenddownleft.svelte +0 -22
- package/cli-test-svelte/Vite.svelte +0 -22
- package/cli-test-svelte/index.ts +0 -25
- package/frameworks.test.js +0 -170
- package/my-svgs/ArrowBendDownLeft.svg +0 -6
- package/my-svgs/vite.svg +0 -1
- package/src/builder.ts +0 -104
- package/src/clean.ts +0 -21
- package/src/cli.ts +0 -221
- package/src/config.ts +0 -81
- package/src/core/error-handler.ts +0 -303
- package/src/core/logger.ts +0 -104
- package/src/core/performance-engine.ts +0 -327
- package/src/core/plugin-manager.ts +0 -228
- package/src/core/style-compiler.ts +0 -605
- package/src/lock.ts +0 -74
- package/src/processors/svg-processor.ts +0 -288
- package/src/services/config.ts +0 -241
- package/src/services/file-watcher.ts +0 -218
- package/src/services/svg-service.ts +0 -468
- package/src/templates/ComponentTemplate.ts +0 -57
- package/src/types/index.ts +0 -169
- package/src/utils/native.ts +0 -352
- package/src/watch.ts +0 -88
- package/test-output-mulit/TestIcon-angular-module.component.ts +0 -26
- package/test-output-mulit/TestIcon-angular-standalone.component.ts +0 -27
- package/test-output-mulit/TestIcon-lit.ts +0 -35
- package/test-output-mulit/TestIcon-preact.tsx +0 -38
- package/test-output-mulit/TestIcon-react.tsx +0 -35
- package/test-output-mulit/TestIcon-solid.tsx +0 -27
- package/test-output-mulit/TestIcon-svelte.svelte +0 -22
- package/test-output-mulit/TestIcon-vanilla.ts +0 -37
- package/test-output-mulit/TestIcon-vue-composition.vue +0 -33
- package/test-output-mulit/TestIcon-vue-options.vue +0 -31
- package/tsconfig.json +0 -18
|
@@ -1,89 +1,65 @@
|
|
|
1
|
-
import { ComponentGenerationOptions, FrameworkType, FrameworkOptions } from '../types/index.js';
|
|
2
|
-
|
|
3
|
-
// Re-export types for convenience
|
|
4
|
-
export type { FrameworkType, FrameworkOptions } from '../types/index.js';
|
|
5
|
-
|
|
6
|
-
interface SVGAttributes {
|
|
7
|
-
viewBox?: string;
|
|
8
|
-
width?: string;
|
|
9
|
-
height?: string;
|
|
10
|
-
fill?: string;
|
|
11
|
-
stroke?: string;
|
|
12
|
-
xmlns?: string;
|
|
13
|
-
[key: string]: string | undefined;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
1
|
export class FrameworkTemplateEngine {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
throw new Error(`Unsupported framework: ${framework}`);
|
|
2
|
+
generateComponent(options) {
|
|
3
|
+
const { framework, componentName, svgContent, typescript = true, frameworkOptions = {}, } = options;
|
|
4
|
+
switch (framework) {
|
|
5
|
+
case 'react':
|
|
6
|
+
return this.generateReactComponent(componentName, svgContent, typescript, frameworkOptions);
|
|
7
|
+
case 'vue':
|
|
8
|
+
return this.generateVueComponent(componentName, svgContent, typescript, frameworkOptions);
|
|
9
|
+
case 'svelte':
|
|
10
|
+
return this.generateSvelteComponent(componentName, svgContent, typescript);
|
|
11
|
+
case 'angular':
|
|
12
|
+
return this.generateAngularComponent(componentName, svgContent, typescript, frameworkOptions);
|
|
13
|
+
case 'solid':
|
|
14
|
+
return this.generateSolidComponent(componentName, svgContent, typescript);
|
|
15
|
+
case 'preact':
|
|
16
|
+
return this.generatePreactComponent(componentName, svgContent, typescript);
|
|
17
|
+
case 'lit':
|
|
18
|
+
return this.generateLitComponent(componentName, svgContent, typescript);
|
|
19
|
+
case 'vanilla':
|
|
20
|
+
return this.generateVanillaComponent(componentName, svgContent, typescript);
|
|
21
|
+
default:
|
|
22
|
+
throw new Error(`Unsupported framework: ${framework}`);
|
|
23
|
+
}
|
|
40
24
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
default:
|
|
61
|
-
return `${tsExt}`;
|
|
25
|
+
getFileExtension(framework, typescript = true) {
|
|
26
|
+
const tsExt = typescript ? 'ts' : 'js';
|
|
27
|
+
switch (framework) {
|
|
28
|
+
case 'react':
|
|
29
|
+
case 'preact':
|
|
30
|
+
case 'solid':
|
|
31
|
+
return typescript ? 'tsx' : 'jsx';
|
|
32
|
+
case 'vue':
|
|
33
|
+
return 'vue';
|
|
34
|
+
case 'svelte':
|
|
35
|
+
return 'svelte';
|
|
36
|
+
case 'angular':
|
|
37
|
+
return `component.${tsExt}`;
|
|
38
|
+
case 'lit':
|
|
39
|
+
case 'vanilla':
|
|
40
|
+
return `${tsExt}`;
|
|
41
|
+
default:
|
|
42
|
+
return `${tsExt}`;
|
|
43
|
+
}
|
|
62
44
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
45
|
+
parseSVG(svgContent) {
|
|
46
|
+
const svgMatch = svgContent.match(/<svg([^>]*)>([\s\S]*?)<\/svg>/);
|
|
47
|
+
if (!svgMatch) {
|
|
48
|
+
return { attributes: {}, innerContent: svgContent };
|
|
49
|
+
}
|
|
50
|
+
const attributesString = svgMatch[1];
|
|
51
|
+
const innerContent = svgMatch[2].trim();
|
|
52
|
+
const attributes = {};
|
|
53
|
+
const attrRegex = /(\w+(?:-\w+)*)="([^"]*)"/g;
|
|
54
|
+
let match;
|
|
55
|
+
while ((match = attrRegex.exec(attributesString)) !== null) {
|
|
56
|
+
attributes[match[1]] = match[2];
|
|
57
|
+
}
|
|
58
|
+
return { attributes, innerContent };
|
|
69
59
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const attributes: SVGAttributes = {};
|
|
74
|
-
|
|
75
|
-
const attrRegex = /(\w+(?:-\w+)*)="([^"]*)"/g;
|
|
76
|
-
let match;
|
|
77
|
-
while ((match = attrRegex.exec(attributesString)) !== null) {
|
|
78
|
-
attributes[match[1]] = match[2];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return { attributes, innerContent };
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private generateReactComponent(componentName: string, svgContent: string, typescript: boolean, options: FrameworkOptions): string {
|
|
85
|
-
const { attributes, innerContent } = this.parseSVG(svgContent);
|
|
86
|
-
return `import React from "react";
|
|
60
|
+
generateReactComponent(componentName, svgContent, typescript, options) {
|
|
61
|
+
const { attributes, innerContent } = this.parseSVG(svgContent);
|
|
62
|
+
return `import React from "react";
|
|
87
63
|
import type { SVGProps } from "react";
|
|
88
64
|
|
|
89
65
|
export interface ${componentName}Props extends SVGProps<SVGSVGElement> {
|
|
@@ -119,14 +95,12 @@ ${componentName}.displayName = "${componentName}";
|
|
|
119
95
|
|
|
120
96
|
export default ${componentName};
|
|
121
97
|
`;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (scriptSetup && typescript) {
|
|
129
|
-
return `<template>
|
|
98
|
+
}
|
|
99
|
+
generateVueComponent(componentName, svgContent, typescript, options) {
|
|
100
|
+
const { attributes, innerContent } = this.parseSVG(svgContent);
|
|
101
|
+
const { scriptSetup = true } = options;
|
|
102
|
+
if (scriptSetup && typescript) {
|
|
103
|
+
return `<template>
|
|
130
104
|
<svg
|
|
131
105
|
:class="className"
|
|
132
106
|
:style="style"
|
|
@@ -160,9 +134,8 @@ withDefaults(defineProps<Props>(), {
|
|
|
160
134
|
});
|
|
161
135
|
</script>
|
|
162
136
|
`;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return `<template>
|
|
137
|
+
}
|
|
138
|
+
return `<template>
|
|
166
139
|
<svg
|
|
167
140
|
:class="className"
|
|
168
141
|
:style="style"
|
|
@@ -194,11 +167,10 @@ export default defineComponent({
|
|
|
194
167
|
});
|
|
195
168
|
</script>
|
|
196
169
|
`;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
return `<script${typescript ? ' lang="ts"' : ''}>
|
|
170
|
+
}
|
|
171
|
+
generateSvelteComponent(componentName, svgContent, typescript) {
|
|
172
|
+
const { attributes, innerContent } = this.parseSVG(svgContent);
|
|
173
|
+
return `<script${typescript ? ' lang="ts"' : ''}>
|
|
202
174
|
export let className${typescript ? ': string' : ''} = '';
|
|
203
175
|
export let style${typescript ? ': string' : ''} = '';
|
|
204
176
|
export let width${typescript ? ': string | number' : ''} = ${attributes.width || 24};
|
|
@@ -221,14 +193,12 @@ export default defineComponent({
|
|
|
221
193
|
${innerContent}
|
|
222
194
|
</svg>
|
|
223
195
|
`;
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return `import { Component, Input${standalone ? ', ChangeDetectionStrategy' : ''} } from '@angular/core';
|
|
196
|
+
}
|
|
197
|
+
generateAngularComponent(componentName, svgContent, typescript, options) {
|
|
198
|
+
const { attributes, innerContent } = this.parseSVG(svgContent);
|
|
199
|
+
const { standalone = true } = options;
|
|
200
|
+
const kebabName = this.toKebabCase(componentName);
|
|
201
|
+
return `import { Component, Input${standalone ? ', ChangeDetectionStrategy' : ''} } from '@angular/core';
|
|
232
202
|
|
|
233
203
|
@Component({
|
|
234
204
|
selector: '${kebabName}',
|
|
@@ -245,8 +215,10 @@ export default defineComponent({
|
|
|
245
215
|
>
|
|
246
216
|
${innerContent}
|
|
247
217
|
</svg>
|
|
248
|
-
\`,${standalone
|
|
249
|
-
|
|
218
|
+
\`,${standalone
|
|
219
|
+
? `
|
|
220
|
+
changeDetection: ChangeDetectionStrategy.OnPush`
|
|
221
|
+
: ''}
|
|
250
222
|
})
|
|
251
223
|
export class ${componentName}Component {
|
|
252
224
|
@Input() className: string = '';
|
|
@@ -256,11 +228,10 @@ export class ${componentName}Component {
|
|
|
256
228
|
@Input() stroke: string = '';
|
|
257
229
|
}
|
|
258
230
|
`;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return `import { Component, JSX } from 'solid-js';
|
|
231
|
+
}
|
|
232
|
+
generateSolidComponent(componentName, svgContent, typescript) {
|
|
233
|
+
const { attributes, innerContent } = this.parseSVG(svgContent);
|
|
234
|
+
return `import { Component, JSX } from 'solid-js';
|
|
264
235
|
|
|
265
236
|
export interface ${componentName}Props extends JSX.SvgSVGAttributes<SVGSVGElement> {
|
|
266
237
|
className?: string;
|
|
@@ -288,11 +259,10 @@ const ${componentName}: Component<${componentName}Props> = (props) => (
|
|
|
288
259
|
|
|
289
260
|
export default ${componentName};
|
|
290
261
|
`;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
return `import { h, FunctionComponent } from 'preact';
|
|
262
|
+
}
|
|
263
|
+
generatePreactComponent(componentName, svgContent, typescript) {
|
|
264
|
+
const { attributes, innerContent } = this.parseSVG(svgContent);
|
|
265
|
+
return `import { h, FunctionComponent } from 'preact';
|
|
296
266
|
import { JSX } from 'preact/jsx-runtime';
|
|
297
267
|
|
|
298
268
|
export interface ${componentName}Props extends JSX.SVGAttributes<SVGSVGElement> {
|
|
@@ -331,13 +301,11 @@ const ${componentName}: FunctionComponent<${componentName}Props> = ({
|
|
|
331
301
|
|
|
332
302
|
export default ${componentName};
|
|
333
303
|
`;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
return `import { LitElement, html, css, svg } from 'lit';
|
|
304
|
+
}
|
|
305
|
+
generateLitComponent(componentName, svgContent, typescript) {
|
|
306
|
+
const { attributes, innerContent } = this.parseSVG(svgContent);
|
|
307
|
+
const kebabName = this.toKebabCase(componentName);
|
|
308
|
+
return `import { LitElement, html, css, svg } from 'lit';
|
|
341
309
|
import { customElement, property } from 'lit/decorators.js';
|
|
342
310
|
|
|
343
311
|
@customElement('${kebabName}')
|
|
@@ -373,11 +341,10 @@ declare global {
|
|
|
373
341
|
}
|
|
374
342
|
}
|
|
375
343
|
`;
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
return `export interface ${componentName}Options {
|
|
344
|
+
}
|
|
345
|
+
generateVanillaComponent(componentName, svgContent, typescript) {
|
|
346
|
+
const { attributes, innerContent } = this.parseSVG(svgContent);
|
|
347
|
+
return `export interface ${componentName}Options {
|
|
381
348
|
className?: string;
|
|
382
349
|
width?: string | number;
|
|
383
350
|
height?: string | number;
|
|
@@ -415,14 +382,12 @@ export function ${componentName}(options: ${componentName}Options = {}): SVGSVGE
|
|
|
415
382
|
return svg;
|
|
416
383
|
}
|
|
417
384
|
`;
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
385
|
+
}
|
|
386
|
+
toKebabCase(str) {
|
|
387
|
+
return str
|
|
388
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
389
|
+
.replace(/([A-Z])([A-Z])([a-z])/g, '$1-$2$3')
|
|
390
|
+
.toLowerCase();
|
|
391
|
+
}
|
|
426
392
|
}
|
|
427
|
-
|
|
428
393
|
export const frameworkTemplateEngine = new FrameworkTemplateEngine();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Logger, LogLevel } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Professional logging service with configurable levels and formatted output
|
|
4
|
+
*/
|
|
5
|
+
export declare class LoggerService implements Logger {
|
|
6
|
+
private static instance;
|
|
7
|
+
private logLevel;
|
|
8
|
+
private enableColors;
|
|
9
|
+
private constructor();
|
|
10
|
+
static getInstance(): LoggerService;
|
|
11
|
+
setLogLevel(level: LogLevel): void;
|
|
12
|
+
setColors(enabled: boolean): void;
|
|
13
|
+
private shouldLog;
|
|
14
|
+
private formatMessage;
|
|
15
|
+
private getPrefix;
|
|
16
|
+
debug(message: string, ...args: any[]): void;
|
|
17
|
+
info(message: string, ...args: any[]): void;
|
|
18
|
+
warn(message: string, ...args: any[]): void;
|
|
19
|
+
error(message: string, ...args: any[]): void;
|
|
20
|
+
success(message: string, ...args: any[]): void;
|
|
21
|
+
}
|
|
22
|
+
export declare const logger: LoggerService;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Professional logging service with configurable levels and formatted output
|
|
3
|
+
*/
|
|
4
|
+
export class LoggerService {
|
|
5
|
+
static instance;
|
|
6
|
+
logLevel = 'info';
|
|
7
|
+
enableColors = true;
|
|
8
|
+
constructor() { }
|
|
9
|
+
static getInstance() {
|
|
10
|
+
if (!LoggerService.instance) {
|
|
11
|
+
LoggerService.instance = new LoggerService();
|
|
12
|
+
}
|
|
13
|
+
return LoggerService.instance;
|
|
14
|
+
}
|
|
15
|
+
setLogLevel(level) {
|
|
16
|
+
this.logLevel = level;
|
|
17
|
+
}
|
|
18
|
+
setColors(enabled) {
|
|
19
|
+
this.enableColors = enabled;
|
|
20
|
+
}
|
|
21
|
+
shouldLog(level) {
|
|
22
|
+
const levels = ['debug', 'info', 'warn', 'error'];
|
|
23
|
+
const currentIndex = levels.indexOf(this.logLevel);
|
|
24
|
+
const messageIndex = levels.indexOf(level);
|
|
25
|
+
return messageIndex >= currentIndex;
|
|
26
|
+
}
|
|
27
|
+
formatMessage(level, message) {
|
|
28
|
+
const timestamp = new Date().toISOString();
|
|
29
|
+
const prefix = this.getPrefix(level);
|
|
30
|
+
return `${timestamp} ${prefix} ${message}`;
|
|
31
|
+
}
|
|
32
|
+
getPrefix(level) {
|
|
33
|
+
if (!this.enableColors) {
|
|
34
|
+
return `[${level.toUpperCase()}]`;
|
|
35
|
+
}
|
|
36
|
+
const colors = {
|
|
37
|
+
debug: '\x1b[36m', // Cyan
|
|
38
|
+
info: '\x1b[34m', // Blue
|
|
39
|
+
warn: '\x1b[33m', // Yellow
|
|
40
|
+
error: '\x1b[31m', // Red
|
|
41
|
+
success: '\x1b[32m', // Green
|
|
42
|
+
};
|
|
43
|
+
const reset = '\x1b[0m';
|
|
44
|
+
const color = colors[level] || colors.info;
|
|
45
|
+
const icons = {
|
|
46
|
+
debug: '🔍',
|
|
47
|
+
info: 'ℹ️',
|
|
48
|
+
warn: '⚠️',
|
|
49
|
+
error: '❌',
|
|
50
|
+
success: '✅',
|
|
51
|
+
};
|
|
52
|
+
const icon = icons[level] || icons.info;
|
|
53
|
+
return `${color}${icon} [${level.toUpperCase()}]${reset}`;
|
|
54
|
+
}
|
|
55
|
+
debug(message, ...args) {
|
|
56
|
+
if (this.shouldLog('debug')) {
|
|
57
|
+
console.debug(this.formatMessage('debug', message), ...args);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
info(message, ...args) {
|
|
61
|
+
if (this.shouldLog('info')) {
|
|
62
|
+
console.info(this.formatMessage('info', message), ...args);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
warn(message, ...args) {
|
|
66
|
+
if (this.shouldLog('warn')) {
|
|
67
|
+
console.warn(this.formatMessage('warn', message), ...args);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
error(message, ...args) {
|
|
71
|
+
if (this.shouldLog('error')) {
|
|
72
|
+
console.error(this.formatMessage('error', message), ...args);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
success(message, ...args) {
|
|
76
|
+
if (this.shouldLog('info')) {
|
|
77
|
+
const timestamp = new Date().toISOString();
|
|
78
|
+
const prefix = this.getPrefix('info');
|
|
79
|
+
const successPrefix = this.enableColors ? '✅ [SUCCESS]' : '[SUCCESS]';
|
|
80
|
+
console.log(`${timestamp} ${successPrefix} ${message}`, ...args);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Export singleton instance
|
|
85
|
+
export const logger = LoggerService.getInstance();
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ComponentGenerationOptions } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Performance optimization engine for batch processing and parallel execution
|
|
4
|
+
*/
|
|
5
|
+
export declare class PerformanceEngine {
|
|
6
|
+
private static instance;
|
|
7
|
+
private processingCache;
|
|
8
|
+
private readonly cacheTimeout;
|
|
9
|
+
private constructor();
|
|
10
|
+
static getInstance(): PerformanceEngine;
|
|
11
|
+
/**
|
|
12
|
+
* Process multiple SVG files in parallel with optimized batching
|
|
13
|
+
*/
|
|
14
|
+
processBatch(files: Array<{
|
|
15
|
+
path: string;
|
|
16
|
+
outputDir: string;
|
|
17
|
+
options?: Partial<ComponentGenerationOptions>;
|
|
18
|
+
}>, config?: {
|
|
19
|
+
batchSize?: number;
|
|
20
|
+
parallel?: boolean;
|
|
21
|
+
maxConcurrency?: number;
|
|
22
|
+
}): Promise<Array<{
|
|
23
|
+
success: boolean;
|
|
24
|
+
filePath: string;
|
|
25
|
+
error?: Error;
|
|
26
|
+
duration: number;
|
|
27
|
+
}>>;
|
|
28
|
+
/**
|
|
29
|
+
* Process single file with caching support
|
|
30
|
+
*/
|
|
31
|
+
private processSingleWithCaching;
|
|
32
|
+
/**
|
|
33
|
+
* Optimize SVG content with performance considerations
|
|
34
|
+
*/
|
|
35
|
+
optimizeSVGContent(content: string, level?: 'fast' | 'balanced' | 'maximum'): string;
|
|
36
|
+
/**
|
|
37
|
+
* Memory usage monitoring and optimization
|
|
38
|
+
*/
|
|
39
|
+
monitorMemoryUsage(): {
|
|
40
|
+
heapUsed: number;
|
|
41
|
+
heapTotal: number;
|
|
42
|
+
external: number;
|
|
43
|
+
cacheSize: number;
|
|
44
|
+
recommendations: string[];
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Clear processing cache
|
|
48
|
+
*/
|
|
49
|
+
clearCache(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Get performance metrics
|
|
52
|
+
*/
|
|
53
|
+
getPerformanceMetrics(): {
|
|
54
|
+
cacheHitRate: number;
|
|
55
|
+
averageProcessingTime: number;
|
|
56
|
+
memoryUsage: any;
|
|
57
|
+
};
|
|
58
|
+
private createBatches;
|
|
59
|
+
private withSemaphore;
|
|
60
|
+
private generateCacheKey;
|
|
61
|
+
private getCachedResult;
|
|
62
|
+
private setCachedResult;
|
|
63
|
+
private applyFastOptimizations;
|
|
64
|
+
private applyBalancedOptimizations;
|
|
65
|
+
private applyMaximumOptimizations;
|
|
66
|
+
}
|
|
67
|
+
export declare const performanceEngine: PerformanceEngine;
|