@emasoft/svg-matrix 1.0.18 → 1.0.20
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 +256 -759
- package/bin/svg-matrix.js +171 -2
- package/bin/svglinter.cjs +1162 -0
- package/package.json +8 -2
- package/scripts/postinstall.js +6 -9
- package/src/animation-optimization.js +394 -0
- package/src/animation-references.js +440 -0
- package/src/arc-length.js +940 -0
- package/src/bezier-analysis.js +1626 -0
- package/src/bezier-intersections.js +1369 -0
- package/src/clip-path-resolver.js +110 -2
- package/src/convert-path-data.js +583 -0
- package/src/css-specificity.js +443 -0
- package/src/douglas-peucker.js +356 -0
- package/src/flatten-pipeline.js +109 -4
- package/src/geometry-to-path.js +126 -16
- package/src/gjk-collision.js +840 -0
- package/src/index.js +175 -2
- package/src/off-canvas-detection.js +1222 -0
- package/src/path-analysis.js +1241 -0
- package/src/path-data-plugins.js +928 -0
- package/src/path-optimization.js +825 -0
- package/src/path-simplification.js +1140 -0
- package/src/polygon-clip.js +376 -99
- package/src/svg-boolean-ops.js +898 -0
- package/src/svg-collections.js +910 -0
- package/src/svg-parser.js +175 -16
- package/src/svg-rendering-context.js +627 -0
- package/src/svg-toolbox.js +7495 -0
- package/src/svg-validation-data.js +944 -0
- package/src/transform-decomposition.js +810 -0
- package/src/transform-optimization.js +936 -0
- package/src/use-symbol-resolver.js +75 -7
package/src/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* SVG path conversion, and 2D/3D affine transformations using Decimal.js.
|
|
6
6
|
*
|
|
7
7
|
* @module @emasoft/svg-matrix
|
|
8
|
-
* @version 1.0.
|
|
8
|
+
* @version 1.0.20
|
|
9
9
|
* @license MIT
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
@@ -49,6 +49,34 @@ import * as FlattenPipeline from './flatten-pipeline.js';
|
|
|
49
49
|
import * as Verification from './verification.js';
|
|
50
50
|
import { Logger, LogLevel, setLogLevel, getLogLevel as getLoggerLevel, enableFileLogging, disableFileLogging } from './logger.js';
|
|
51
51
|
|
|
52
|
+
// SVGO-inspired precision modules
|
|
53
|
+
import * as PathSimplification from './path-simplification.js';
|
|
54
|
+
import * as TransformDecomposition from './transform-decomposition.js';
|
|
55
|
+
import * as GJKCollision from './gjk-collision.js';
|
|
56
|
+
import * as PathOptimization from './path-optimization.js';
|
|
57
|
+
import * as TransformOptimization from './transform-optimization.js';
|
|
58
|
+
import * as OffCanvasDetection from './off-canvas-detection.js';
|
|
59
|
+
import * as CSSSpecificity from './css-specificity.js';
|
|
60
|
+
|
|
61
|
+
// Animation-aware reference tracking (FIXES SVGO's animation destruction bug)
|
|
62
|
+
import * as AnimationReferences from './animation-references.js';
|
|
63
|
+
|
|
64
|
+
// SVG Toolbox - SVGO-equivalent functions with simple API
|
|
65
|
+
import * as SVGToolbox from './svg-toolbox.js';
|
|
66
|
+
|
|
67
|
+
// Bezier Curve Analysis - svgpathtools-equivalent with 80-digit arbitrary precision
|
|
68
|
+
// These modules provide superior precision compared to Python's float64 svgpathtools
|
|
69
|
+
import * as BezierAnalysis from './bezier-analysis.js';
|
|
70
|
+
import * as ArcLength from './arc-length.js';
|
|
71
|
+
import * as PathAnalysis from './path-analysis.js';
|
|
72
|
+
import * as BezierIntersections from './bezier-intersections.js';
|
|
73
|
+
|
|
74
|
+
// SVG Boolean Operations - fill-rule and stroke-aware geometric operations
|
|
75
|
+
import * as SVGBooleanOps from './svg-boolean-ops.js';
|
|
76
|
+
|
|
77
|
+
// SVG Rendering Context - tracks ALL SVG properties affecting rendered geometry
|
|
78
|
+
import * as SVGRenderingContext from './svg-rendering-context.js';
|
|
79
|
+
|
|
52
80
|
// Set high-precision default (80 significant digits) on module load
|
|
53
81
|
// This is the same precision used internally by all svg-matrix modules
|
|
54
82
|
// Users can increase further with setPrecision() or Decimal.set() - max is 1e9
|
|
@@ -58,7 +86,7 @@ Decimal.set({ precision: 80 });
|
|
|
58
86
|
* Library version
|
|
59
87
|
* @constant {string}
|
|
60
88
|
*/
|
|
61
|
-
export const VERSION = '1.0.
|
|
89
|
+
export const VERSION = '1.0.20';
|
|
62
90
|
|
|
63
91
|
/**
|
|
64
92
|
* Default precision for path output (decimal places)
|
|
@@ -94,6 +122,130 @@ export { UseSymbolResolver, MarkerResolver };
|
|
|
94
122
|
export { MeshGradient, TextToPath };
|
|
95
123
|
export { SVGParser, FlattenPipeline, Verification };
|
|
96
124
|
|
|
125
|
+
// ============================================================================
|
|
126
|
+
// SVGO-INSPIRED PRECISION MODULES
|
|
127
|
+
// ============================================================================
|
|
128
|
+
|
|
129
|
+
export { PathSimplification, TransformDecomposition, GJKCollision };
|
|
130
|
+
export { PathOptimization, TransformOptimization };
|
|
131
|
+
export { OffCanvasDetection, CSSSpecificity };
|
|
132
|
+
|
|
133
|
+
// Animation-aware reference tracking (FIXES SVGO's animation destruction)
|
|
134
|
+
export { AnimationReferences };
|
|
135
|
+
|
|
136
|
+
// ============================================================================
|
|
137
|
+
// SVG TOOLBOX: SVGO-Equivalent Functions with Simple API
|
|
138
|
+
// ============================================================================
|
|
139
|
+
|
|
140
|
+
export { SVGToolbox };
|
|
141
|
+
|
|
142
|
+
// ============================================================================
|
|
143
|
+
// BEZIER CURVE ANALYSIS: svgpathtools-equivalent with 80-digit precision
|
|
144
|
+
// Superior to Python's float64 svgpathtools - exact mathematical verification
|
|
145
|
+
// ============================================================================
|
|
146
|
+
|
|
147
|
+
export { BezierAnalysis, ArcLength, PathAnalysis, BezierIntersections };
|
|
148
|
+
|
|
149
|
+
// ============================================================================
|
|
150
|
+
// SVG BOOLEAN OPERATIONS: Fill-rule and stroke-aware geometric operations
|
|
151
|
+
// ============================================================================
|
|
152
|
+
|
|
153
|
+
export { SVGBooleanOps };
|
|
154
|
+
|
|
155
|
+
// ============================================================================
|
|
156
|
+
// SVG RENDERING CONTEXT: Tracks ALL SVG properties affecting geometry
|
|
157
|
+
// Critical for off-canvas detection, collision, merging, simplification
|
|
158
|
+
// ============================================================================
|
|
159
|
+
|
|
160
|
+
export { SVGRenderingContext };
|
|
161
|
+
|
|
162
|
+
// Re-export all svg-toolbox functions for direct access
|
|
163
|
+
export {
|
|
164
|
+
// Input/Output types
|
|
165
|
+
InputType,
|
|
166
|
+
OutputFormat,
|
|
167
|
+
detectInputType,
|
|
168
|
+
loadInput,
|
|
169
|
+
generateOutput,
|
|
170
|
+
// Cleanup functions
|
|
171
|
+
cleanupIds,
|
|
172
|
+
cleanupNumericValues,
|
|
173
|
+
cleanupListOfValues,
|
|
174
|
+
cleanupAttributes,
|
|
175
|
+
cleanupEnableBackground,
|
|
176
|
+
removeUnknownsAndDefaults,
|
|
177
|
+
removeNonInheritableGroupAttrs,
|
|
178
|
+
removeUselessDefs,
|
|
179
|
+
removeHiddenElements,
|
|
180
|
+
removeEmptyText,
|
|
181
|
+
removeEmptyContainers,
|
|
182
|
+
// Removal functions
|
|
183
|
+
removeDoctype,
|
|
184
|
+
removeXMLProcInst,
|
|
185
|
+
removeComments,
|
|
186
|
+
removeMetadata,
|
|
187
|
+
removeTitle,
|
|
188
|
+
removeDesc,
|
|
189
|
+
removeEditorsNSData,
|
|
190
|
+
removeEmptyAttrs,
|
|
191
|
+
removeViewBox,
|
|
192
|
+
removeXMLNS,
|
|
193
|
+
removeRasterImages,
|
|
194
|
+
removeScriptElement,
|
|
195
|
+
// Conversion functions
|
|
196
|
+
convertShapesToPath,
|
|
197
|
+
convertPathData,
|
|
198
|
+
convertTransform,
|
|
199
|
+
convertColors,
|
|
200
|
+
convertStyleToAttrs,
|
|
201
|
+
convertEllipseToCircle,
|
|
202
|
+
collapseGroups,
|
|
203
|
+
mergePaths,
|
|
204
|
+
moveGroupAttrsToElems,
|
|
205
|
+
moveElemsAttrsToGroup,
|
|
206
|
+
// Optimization functions
|
|
207
|
+
minifyStyles,
|
|
208
|
+
inlineStyles,
|
|
209
|
+
sortAttrs,
|
|
210
|
+
sortDefsChildren,
|
|
211
|
+
reusePaths,
|
|
212
|
+
removeOffCanvasPath,
|
|
213
|
+
removeStyleElement,
|
|
214
|
+
removeXlink,
|
|
215
|
+
// Adding/Modification functions
|
|
216
|
+
addAttributesToSVGElement,
|
|
217
|
+
addClassesToSVGElement,
|
|
218
|
+
prefixIds,
|
|
219
|
+
removeDimensions,
|
|
220
|
+
removeAttributesBySelector,
|
|
221
|
+
removeAttrs,
|
|
222
|
+
removeElementsByAttr,
|
|
223
|
+
// Presets
|
|
224
|
+
preset_default,
|
|
225
|
+
preset_none,
|
|
226
|
+
applyPreset,
|
|
227
|
+
optimize,
|
|
228
|
+
createConfig,
|
|
229
|
+
// Bonus functions (SVGO doesn't have these)
|
|
230
|
+
flattenClipPaths,
|
|
231
|
+
flattenMasks,
|
|
232
|
+
flattenGradients,
|
|
233
|
+
flattenPatterns,
|
|
234
|
+
flattenFilters,
|
|
235
|
+
flattenUseElements,
|
|
236
|
+
textToPath,
|
|
237
|
+
imageToPath,
|
|
238
|
+
detectCollisions,
|
|
239
|
+
measureDistance,
|
|
240
|
+
validateSVG,
|
|
241
|
+
validateSvg,
|
|
242
|
+
fixInvalidSvg,
|
|
243
|
+
ValidationSeverity,
|
|
244
|
+
flattenAll,
|
|
245
|
+
simplifyPath,
|
|
246
|
+
decomposeTransform,
|
|
247
|
+
} from './svg-toolbox.js';
|
|
248
|
+
|
|
97
249
|
// ============================================================================
|
|
98
250
|
// LOGGING: Configurable logging control
|
|
99
251
|
// ============================================================================
|
|
@@ -436,6 +588,27 @@ export default {
|
|
|
436
588
|
enableFileLogging,
|
|
437
589
|
disableFileLogging,
|
|
438
590
|
|
|
591
|
+
// SVGO-inspired precision modules
|
|
592
|
+
PathSimplification,
|
|
593
|
+
TransformDecomposition,
|
|
594
|
+
GJKCollision,
|
|
595
|
+
PathOptimization,
|
|
596
|
+
TransformOptimization,
|
|
597
|
+
OffCanvasDetection,
|
|
598
|
+
CSSSpecificity,
|
|
599
|
+
|
|
600
|
+
// Animation-aware reference tracking (FIXES SVGO's animation destruction)
|
|
601
|
+
AnimationReferences,
|
|
602
|
+
|
|
603
|
+
// SVG Toolbox (SVGO-equivalent functions)
|
|
604
|
+
SVGToolbox,
|
|
605
|
+
|
|
606
|
+
// Bezier Curve Analysis (svgpathtools-equivalent with 80-digit precision)
|
|
607
|
+
BezierAnalysis,
|
|
608
|
+
ArcLength,
|
|
609
|
+
PathAnalysis,
|
|
610
|
+
BezierIntersections,
|
|
611
|
+
|
|
439
612
|
// Convenience functions
|
|
440
613
|
translate2D,
|
|
441
614
|
rotate2D,
|