@emasoft/svg-matrix 1.3.4 → 1.3.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/dist/version.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "1.3.4",
3
- "buildTime": "2026-01-25T12:44:06.936Z",
2
+ "version": "1.3.5",
3
+ "buildTime": "2026-01-25T12:44:03.807Z",
4
4
  "bundles": {
5
5
  "esm": [
6
6
  {
@@ -11,14 +11,14 @@
11
11
  },
12
12
  {
13
13
  "name": "svg-toolbox.min.js",
14
- "size": 577298,
15
- "gzipSize": 152361,
14
+ "size": 578044,
15
+ "gzipSize": 152616,
16
16
  "description": "ESM bundle for bundlers/Node.js (includes decimal.js)"
17
17
  },
18
18
  {
19
19
  "name": "svgm.min.js",
20
- "size": 602600,
21
- "gzipSize": 159489,
20
+ "size": 603346,
21
+ "gzipSize": 159757,
22
22
  "description": "ESM bundle for bundlers/Node.js (includes decimal.js)"
23
23
  }
24
24
  ],
@@ -31,8 +31,8 @@
31
31
  },
32
32
  {
33
33
  "name": "svg-toolbox.global.min.js",
34
- "size": 577427,
35
- "gzipSize": 151728,
34
+ "size": 578173,
35
+ "gzipSize": 151976,
36
36
  "description": "IIFE bundle for browsers via <script> (includes decimal.js)"
37
37
  },
38
38
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emasoft/svg-matrix",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Arbitrary-precision matrix, vector and affine transformation library for JavaScript using decimal.js",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -384,6 +384,12 @@ export function optimizeAnimationValues(values, precision = 3) {
384
384
  );
385
385
  }
386
386
 
387
+ // Preserve data URIs exactly (they contain semicolons that shouldn't be split)
388
+ // Data URIs have format: data:[<mediatype>][;base64],<data>
389
+ if (values.startsWith("data:")) {
390
+ return values;
391
+ }
392
+
387
393
  // Split by semicolon
388
394
  const parts = values.split(";");
389
395
 
@@ -398,6 +404,29 @@ export function optimizeAnimationValues(values, precision = 3) {
398
404
  return trimmed;
399
405
  }
400
406
 
407
+ // Preserve data URIs exactly (e.g., data:image/jpeg;base64,...)
408
+ if (trimmed.startsWith("data:")) {
409
+ return trimmed;
410
+ }
411
+
412
+ // Preserve color functions (rgb, rgba, hsl, hsla, etc.) exactly
413
+ // These contain parentheses and commas that should not be modified
414
+ if (/^(rgb|rgba|hsl|hsla|hwb|lab|lch|oklch|oklab|color)\s*\(/i.test(trimmed)) {
415
+ return trimmed;
416
+ }
417
+
418
+ // Preserve SVG path data (starts with path command M, m, L, l, etc.)
419
+ // Path data format: "M 26.5,32.5 L 33.5,32.5 C 40,50 60,70 80,90 Z"
420
+ if (/^[MmZzLlHhVvCcSsQqTtAa][\s\d.,+-]+/.test(trimmed)) {
421
+ return trimmed;
422
+ }
423
+
424
+ // Preserve font-family values (comma-separated font names with possible quotes)
425
+ // Pattern: word or quoted string, followed by comma and more words/quotes
426
+ if (/^(['"]?[\w\s-]+['"]?,\s*)+['"]?[\w\s-]+['"]?$/.test(trimmed)) {
427
+ return trimmed;
428
+ }
429
+
401
430
  // Try to parse as numbers (could be space-separated like "0 0" for translate)
402
431
  const nums = trimmed.split(/[\s,]+/).filter((n) => n); // Filter empty strings
403
432
  const optimizedNums = nums.map((n) => {
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.3.4
8
+ * @version 1.3.5
9
9
  * @license MIT
10
10
  *
11
11
  * @example
@@ -135,7 +135,7 @@ Decimal.set({ precision: 80 });
135
135
  * Library version
136
136
  * @constant {string}
137
137
  */
138
- export const VERSION = "1.3.4";
138
+ export const VERSION = "1.3.5";
139
139
 
140
140
  /**
141
141
  * Default precision for path output (decimal places)
@@ -5,7 +5,7 @@
5
5
  * Works in both Node.js and browser environments.
6
6
  *
7
7
  * @module svg-matrix-lib
8
- * @version 1.3.4
8
+ * @version 1.3.5
9
9
  * @license MIT
10
10
  *
11
11
  * @example Browser usage:
@@ -32,7 +32,7 @@ Decimal.set({ precision: 80 });
32
32
  /**
33
33
  * Library version
34
34
  */
35
- export const VERSION = "1.3.4";
35
+ export const VERSION = "1.3.5";
36
36
 
37
37
  // Export core classes
38
38
  export { Decimal, Matrix, Vector };
@@ -5,7 +5,7 @@
5
5
  * Provides 69+ operations for cleaning, optimizing, and transforming SVG files.
6
6
  *
7
7
  * @module svg-toolbox-lib
8
- * @version 1.3.4
8
+ * @version 1.3.5
9
9
  * @license MIT
10
10
  *
11
11
  * @example Browser usage:
@@ -34,7 +34,7 @@ import * as SVGToolboxModule from "./svg-toolbox.js";
34
34
  /**
35
35
  * Library version
36
36
  */
37
- export const VERSION = "1.3.4";
37
+ export const VERSION = "1.3.5";
38
38
 
39
39
  /**
40
40
  * Default export for browser global (window.SVGToolbox)
@@ -266,6 +266,7 @@ const SVG11_ATTRIBUTES = new Set([
266
266
  "filter",
267
267
  "filterRes",
268
268
  "filterUnits",
269
+ "filterPrimitiveUnits",
269
270
  "flood-color",
270
271
  "flood-opacity",
271
272
  "font-family",
@@ -14171,6 +14172,7 @@ export const fixInvalidSVG = createOperation((doc, options = {}) => {
14171
14172
  maskUnits: ["userSpaceOnUse", "objectBoundingBox"],
14172
14173
  maskContentUnits: ["userSpaceOnUse", "objectBoundingBox"],
14173
14174
  filterUnits: ["userSpaceOnUse", "objectBoundingBox"],
14175
+ filterPrimitiveUnits: ["userSpaceOnUse", "objectBoundingBox"],
14174
14176
  primitiveUnits: ["userSpaceOnUse", "objectBoundingBox"],
14175
14177
  markerUnits: ["strokeWidth", "userSpaceOnUse"],
14176
14178
  // Other
@@ -16143,11 +16145,20 @@ export async function validateSVGAsync(input, options = {}) {
16143
16145
  // - title/desc (text content for accessibility - not SVG structure)
16144
16146
  // - metadata (can contain arbitrary XML metadata like Dublin Core, RDF)
16145
16147
  // - Namespaced elements (e.g., d:testDescription, rdf:RDF)
16148
+ // - Elements in non-SVG namespaces (e.g., <foo xmlns="http://example.org/foo">)
16146
16149
  const isNamespacedElement = tagName.includes(":");
16150
+ const isNonSvgNamespace =
16151
+ el.namespaceURI && el.namespaceURI !== "http://www.w3.org/2000/svg";
16152
+ // Check for explicit xmlns attribute declaring a non-SVG namespace
16153
+ const xmlns = el.getAttribute ? el.getAttribute("xmlns") : null;
16154
+ const hasNonSvgXmlns =
16155
+ xmlns && xmlns !== "http://www.w3.org/2000/svg";
16147
16156
  const inNonSvgContext =
16148
16157
  insideNonSvgContext ||
16149
16158
  NON_SVG_CONTEXT_ELEMENTS.has(tagLower) ||
16150
- isNamespacedElement;
16159
+ isNamespacedElement ||
16160
+ isNonSvgNamespace ||
16161
+ hasNonSvgXmlns;
16151
16162
 
16152
16163
  // Skip validation entirely if we're in non-SVG context
16153
16164
  if (!inNonSvgContext) {
@@ -16206,11 +16217,20 @@ export async function validateSVGAsync(input, options = {}) {
16206
16217
  // - title/desc (text content elements)
16207
16218
  // - metadata (arbitrary XML metadata content)
16208
16219
  // - Namespaced elements (e.g., d:testDescription, rdf:RDF)
16220
+ // - Elements in non-SVG namespaces (e.g., <foo xmlns="http://example.org/foo">)
16209
16221
  const isNamespacedElement = el.tagName.includes(":");
16222
+ const isNonSvgNamespace =
16223
+ el.namespaceURI && el.namespaceURI !== "http://www.w3.org/2000/svg";
16224
+ // Check for explicit xmlns attribute declaring a non-SVG namespace
16225
+ const xmlns = el.getAttribute ? el.getAttribute("xmlns") : null;
16226
+ const hasNonSvgXmlns =
16227
+ xmlns && xmlns !== "http://www.w3.org/2000/svg";
16210
16228
  const inNonSvgContext =
16211
16229
  insideNonSvgContext ||
16212
16230
  NON_SVG_CONTEXT_ELEMENTS.has(tagName) ||
16213
- isNamespacedElement;
16231
+ isNamespacedElement ||
16232
+ isNonSvgNamespace ||
16233
+ hasNonSvgXmlns;
16214
16234
 
16215
16235
  // Skip attribute validation entirely if we're in non-SVG context
16216
16236
  if (!inNonSvgContext) {
@@ -16446,6 +16466,7 @@ export async function validateSVGAsync(input, options = {}) {
16446
16466
  maskUnits: new Set(["userSpaceOnUse", "objectBoundingBox"]),
16447
16467
  maskContentUnits: new Set(["userSpaceOnUse", "objectBoundingBox"]),
16448
16468
  filterUnits: new Set(["userSpaceOnUse", "objectBoundingBox"]),
16469
+ filterPrimitiveUnits: new Set(["userSpaceOnUse", "objectBoundingBox"]),
16449
16470
  primitiveUnits: new Set(["userSpaceOnUse", "objectBoundingBox"]),
16450
16471
  patternUnits: new Set(["userSpaceOnUse", "objectBoundingBox"]),
16451
16472
  patternContentUnits: new Set(["userSpaceOnUse", "objectBoundingBox"]),
@@ -151,6 +151,7 @@ export const SVG11_ATTRIBUTES = new Set([
151
151
  "filter",
152
152
  "filterres",
153
153
  "filterunits",
154
+ "filterprimitiveunits",
154
155
  "flood-color",
155
156
  "flood-opacity",
156
157
  "font-family",
package/src/svgm-lib.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * comprehensive SVG manipulation (SVGToolbox). Works in Node.js and browser.
6
6
  *
7
7
  * @module svgm-lib
8
- * @version 1.3.4
8
+ * @version 1.3.5
9
9
  * @license MIT
10
10
  *
11
11
  * @example Browser usage:
@@ -49,7 +49,7 @@ Decimal.set({ precision: 80 });
49
49
  /**
50
50
  * Library version
51
51
  */
52
- export const VERSION = "1.3.4";
52
+ export const VERSION = "1.3.5";
53
53
 
54
54
  // Export math classes
55
55
  export { Decimal, Matrix, Vector };