@iconify/tools 5.0.1 → 5.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 (2) hide show
  1. package/lib/svg/index.js +6 -4
  2. package/package.json +4 -4
package/lib/svg/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { iconToSVG, trimSVG } from "@iconify/utils";
1
+ import { iconToSVG, prettifySVG, trimSVG } from "@iconify/utils";
2
2
  import { parseXMLContent, stringifyXMLContent } from "@cyberalien/svg-utils";
3
3
  import { parseViewBox } from "@cyberalien/svg-utils/lib/svg/viewbox/parse.js";
4
4
 
@@ -26,20 +26,22 @@ var SVG = class {
26
26
  const value = data.attributes[key];
27
27
  svgAttributes += " " + key + "=\"" + value + "\"";
28
28
  }
29
- return "<svg" + svgAttributes + ">" + data.body + "</svg>";
29
+ const svg = "<svg" + svgAttributes + ">" + data.body + "</svg>";
30
+ return prettyPrint === true ? prettifySVG(svg) || svg : trimSVG(svg);
30
31
  }
31
32
  const $root = this.$svg;
32
33
  const attribs = $root.attribs;
33
34
  const box = this.viewBox;
34
35
  if (!attribs["viewBox"]) attribs["viewBox"] = `${box.left} ${box.top} ${box.width} ${box.height}`;
35
36
  for (const prop of ["width", "height"]) if (!attribs[prop]) attribs[prop] = box[prop];
36
- return stringifyXMLContent([$root], { prettyPrint });
37
+ const result = stringifyXMLContent([$root], { prettyPrint });
38
+ return prettyPrint === false ? trimSVG(result) : result;
37
39
  }
38
40
  /**
39
41
  * Get SVG as string without whitespaces
40
42
  */
41
43
  toMinifiedString(customisations) {
42
- return trimSVG(this.toString(customisations, false));
44
+ return this.toString(customisations, false);
43
45
  }
44
46
  /**
45
47
  * Get SVG as string with whitespaces
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "description": "Collection of functions for cleaning up and parsing SVG for Iconify project",
5
5
  "author": "Vjacheslav Trushkin",
6
- "version": "5.0.1",
6
+ "version": "5.0.2",
7
7
  "license": "MIT",
8
8
  "bugs": "https://github.com/iconify/tools/issues",
9
9
  "homepage": "https://github.com/iconify/tools",
@@ -27,8 +27,8 @@
27
27
  "@eslint/js": "^9.39.2",
28
28
  "@types/jest": "^30.0.0",
29
29
  "@types/node": "^24.10.4",
30
- "@typescript-eslint/eslint-plugin": "^8.50.0",
31
- "@typescript-eslint/parser": "^8.50.0",
30
+ "@typescript-eslint/eslint-plugin": "^8.50.1",
31
+ "@typescript-eslint/parser": "^8.50.1",
32
32
  "cross-env": "^10.1.0",
33
33
  "eslint": "^9.39.2",
34
34
  "eslint-config-prettier": "^10.1.8",
@@ -36,7 +36,7 @@
36
36
  "globals": "^16.5.0",
37
37
  "prettier": "^3.7.4",
38
38
  "rimraf": "^6.1.2",
39
- "tsdown": "^0.18.0",
39
+ "tsdown": "^0.18.3",
40
40
  "typescript": "^5.9.3",
41
41
  "vitest": "^4.0.16"
42
42
  },