@emasoft/svg-matrix 1.0.6 → 1.0.7
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/README.md +85 -0
- package/bin/svg-matrix.js +1000 -0
- package/package.json +12 -2
- package/scripts/bootstrap_repo.sh +99 -0
- package/scripts/postinstall.js +252 -0
- package/src/clip-path-resolver.js +2 -1
- package/src/index.js +15 -1
- package/src/logger.js +302 -0
package/README.md
CHANGED
|
@@ -31,6 +31,11 @@ High-precision matrix, vector, and SVG transformation library for JavaScript. Bu
|
|
|
31
31
|
- Text-to-path conversion with font support
|
|
32
32
|
- Browser verification against Chrome's native W3C SVG2 implementation
|
|
33
33
|
|
|
34
|
+
## Requirements
|
|
35
|
+
|
|
36
|
+
- **Node.js 24.0.0** or higher (ES modules, modern JavaScript features)
|
|
37
|
+
- **Playwright** (optional) - for browser verification features
|
|
38
|
+
|
|
34
39
|
## Precision
|
|
35
40
|
|
|
36
41
|
| Scenario | Float Error | This Library | Improvement |
|
|
@@ -65,6 +70,58 @@ import { Matrix, Vector, Transforms2D, Transforms3D, SVGFlatten } from '@emasoft
|
|
|
65
70
|
</script>
|
|
66
71
|
```
|
|
67
72
|
|
|
73
|
+
## CLI
|
|
74
|
+
|
|
75
|
+
The library includes a command-line interface for batch processing SVG files.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Process single file
|
|
79
|
+
svg-matrix flatten input.svg -o output.svg
|
|
80
|
+
|
|
81
|
+
# Batch process folder
|
|
82
|
+
svg-matrix flatten ./svgs/ -o ./output/
|
|
83
|
+
|
|
84
|
+
# Process files from list
|
|
85
|
+
svg-matrix flatten --list files.txt -o ./output/
|
|
86
|
+
|
|
87
|
+
# Convert shapes to paths
|
|
88
|
+
svg-matrix convert input.svg -o output.svg
|
|
89
|
+
|
|
90
|
+
# Normalize paths to cubic Beziers
|
|
91
|
+
svg-matrix normalize input.svg -o output.svg
|
|
92
|
+
|
|
93
|
+
# Show SVG file info
|
|
94
|
+
svg-matrix info input.svg
|
|
95
|
+
|
|
96
|
+
# Show help
|
|
97
|
+
svg-matrix help
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### CLI Options
|
|
101
|
+
|
|
102
|
+
| Option | Description |
|
|
103
|
+
|--------|-------------|
|
|
104
|
+
| `-o, --output <path>` | Output file or directory |
|
|
105
|
+
| `-l, --list <file>` | Read input files from text file |
|
|
106
|
+
| `-r, --recursive` | Process directories recursively |
|
|
107
|
+
| `-p, --precision <n>` | Decimal precision (default: 6) |
|
|
108
|
+
| `-f, --force` | Overwrite existing files |
|
|
109
|
+
| `-n, --dry-run` | Show what would be done |
|
|
110
|
+
| `-q, --quiet` | Suppress all output except errors |
|
|
111
|
+
| `-v, --verbose` | Enable verbose/debug output |
|
|
112
|
+
| `--log-file <path>` | Write log to file |
|
|
113
|
+
|
|
114
|
+
### File List Format
|
|
115
|
+
|
|
116
|
+
Create a text file with one path per line:
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
# This is a comment
|
|
120
|
+
./folder1/file1.svg
|
|
121
|
+
./folder2/file2.svg
|
|
122
|
+
./entire-folder/
|
|
123
|
+
```
|
|
124
|
+
|
|
68
125
|
## Quick Start
|
|
69
126
|
|
|
70
127
|
```js
|
|
@@ -447,6 +504,34 @@ import {
|
|
|
447
504
|
} from '@emasoft/svg-matrix';
|
|
448
505
|
```
|
|
449
506
|
|
|
507
|
+
### Logging
|
|
508
|
+
|
|
509
|
+
Control library logging output:
|
|
510
|
+
|
|
511
|
+
```js
|
|
512
|
+
import { Logger, LogLevel, setLogLevel, enableFileLogging } from '@emasoft/svg-matrix';
|
|
513
|
+
|
|
514
|
+
// Suppress all logging
|
|
515
|
+
setLogLevel(LogLevel.SILENT);
|
|
516
|
+
|
|
517
|
+
// Enable only errors
|
|
518
|
+
setLogLevel(LogLevel.ERROR);
|
|
519
|
+
|
|
520
|
+
// Enable warnings and errors (default)
|
|
521
|
+
setLogLevel(LogLevel.WARN);
|
|
522
|
+
|
|
523
|
+
// Enable all logging including debug
|
|
524
|
+
setLogLevel(LogLevel.DEBUG);
|
|
525
|
+
|
|
526
|
+
// Write logs to file
|
|
527
|
+
enableFileLogging('/path/to/log.txt');
|
|
528
|
+
|
|
529
|
+
// Direct Logger access
|
|
530
|
+
Logger.level = LogLevel.INFO;
|
|
531
|
+
Logger.warn('Custom warning');
|
|
532
|
+
Logger.debug('Debug info');
|
|
533
|
+
```
|
|
534
|
+
|
|
450
535
|
## License
|
|
451
536
|
|
|
452
537
|
MIT
|