@iconify/tools 2.2.0 → 2.2.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.
@@ -39,6 +39,7 @@ async function cleanupGlobalStyle(svg) {
39
39
  });
40
40
  });
41
41
  });
42
+ const removeClasses = /* @__PURE__ */ new Set();
42
43
  try {
43
44
  await svg_parseStyle.parseSVGStyle(svg, async (styleItem) => {
44
45
  const returnValue = styleItem.value;
@@ -123,28 +124,26 @@ async function cleanupGlobalStyle(svg) {
123
124
  );
124
125
  containsTempAttr = true;
125
126
  });
126
- const classMatches = matches.filter((item) => item.type === "class").map((item) => item.value);
127
- if (classMatches.length && styleItem.nextTokens[0]?.type === "close") {
128
- await svg_parse.parseSVG(svg, (svgItem) => {
129
- const $element = svgItem.$element;
130
- if (!isMatch("", $element)) {
131
- return;
132
- }
133
- const classList = getClassList($element.attr("class"));
134
- if (!classList) {
135
- return;
136
- }
137
- const filtered = classList.filter(
138
- (item) => classMatches.indexOf(item) === -1
139
- );
140
- if (!filtered.length) {
141
- $element.removeAttr("class");
142
- } else {
143
- $element.attr("class", filtered.join(" "));
144
- }
145
- });
127
+ matches.forEach((match) => {
128
+ if (match.type === "class") {
129
+ removeClasses.add(match.value);
130
+ }
131
+ });
132
+ });
133
+ await svg_parse.parseSVG(svg, (svgItem) => {
134
+ const $element = svgItem.$element;
135
+ const classList = getClassList($element.attr("class"));
136
+ if (!classList) {
137
+ return;
138
+ }
139
+ const filtered = classList.filter(
140
+ (item) => !removeClasses.has(item)
141
+ );
142
+ if (!filtered.length) {
143
+ $element.removeAttr("class");
144
+ } else {
145
+ $element.attr("class", filtered.join(" "));
146
146
  }
147
- return;
148
147
  });
149
148
  if (containsTempAttr) {
150
149
  await svg_parse.parseSVG(svg, (item) => {
@@ -37,6 +37,7 @@ async function cleanupGlobalStyle(svg) {
37
37
  });
38
38
  });
39
39
  });
40
+ const removeClasses = /* @__PURE__ */ new Set();
40
41
  try {
41
42
  await parseSVGStyle(svg, async (styleItem) => {
42
43
  const returnValue = styleItem.value;
@@ -121,28 +122,26 @@ async function cleanupGlobalStyle(svg) {
121
122
  );
122
123
  containsTempAttr = true;
123
124
  });
124
- const classMatches = matches.filter((item) => item.type === "class").map((item) => item.value);
125
- if (classMatches.length && styleItem.nextTokens[0]?.type === "close") {
126
- await parseSVG(svg, (svgItem) => {
127
- const $element = svgItem.$element;
128
- if (!isMatch("", $element)) {
129
- return;
130
- }
131
- const classList = getClassList($element.attr("class"));
132
- if (!classList) {
133
- return;
134
- }
135
- const filtered = classList.filter(
136
- (item) => classMatches.indexOf(item) === -1
137
- );
138
- if (!filtered.length) {
139
- $element.removeAttr("class");
140
- } else {
141
- $element.attr("class", filtered.join(" "));
142
- }
143
- });
125
+ matches.forEach((match) => {
126
+ if (match.type === "class") {
127
+ removeClasses.add(match.value);
128
+ }
129
+ });
130
+ });
131
+ await parseSVG(svg, (svgItem) => {
132
+ const $element = svgItem.$element;
133
+ const classList = getClassList($element.attr("class"));
134
+ if (!classList) {
135
+ return;
136
+ }
137
+ const filtered = classList.filter(
138
+ (item) => !removeClasses.has(item)
139
+ );
140
+ if (!filtered.length) {
141
+ $element.removeAttr("class");
142
+ } else {
143
+ $element.attr("class", filtered.join(" "));
144
144
  }
145
- return;
146
145
  });
147
146
  if (containsTempAttr) {
148
147
  await parseSVG(svg, (item) => {
@@ -26,7 +26,9 @@ function getSVGOPlugins(options) {
26
26
  "collapseGroups",
27
27
  "sortDefsChildren",
28
28
  "sortAttrs",
29
+ // Plugins that are bugged when using animations
29
30
  ...options.animated ? [] : ["removeUselessStrokeAndFill"],
31
+ // Plugins that modify shapes or are bugged when using animations
30
32
  ...options.animated || options.keepShapes ? [] : [
31
33
  "removeHiddenElems",
32
34
  "convertShapeToPath",
@@ -43,9 +45,12 @@ function getSVGOPlugins(options) {
43
45
  noSpaceAfterFlags: true
44
46
  }
45
47
  },
48
+ // 'removeOffCanvasPaths', // bugged for some icons
46
49
  "reusePaths"
47
50
  ],
48
- ...options.cleanupIDs !== false ? ["cleanupIds"] : []
51
+ // Clean up IDs, first run
52
+ // Sometimes bugs out on animated icons. Do not use with animations!
53
+ ...!options.animated && options.cleanupIDs !== false ? ["cleanupIds"] : []
49
54
  ];
50
55
  }
51
56
  function runSVGO(svg, options = {}) {
@@ -24,7 +24,9 @@ function getSVGOPlugins(options) {
24
24
  "collapseGroups",
25
25
  "sortDefsChildren",
26
26
  "sortAttrs",
27
+ // Plugins that are bugged when using animations
27
28
  ...options.animated ? [] : ["removeUselessStrokeAndFill"],
29
+ // Plugins that modify shapes or are bugged when using animations
28
30
  ...options.animated || options.keepShapes ? [] : [
29
31
  "removeHiddenElems",
30
32
  "convertShapeToPath",
@@ -41,9 +43,12 @@ function getSVGOPlugins(options) {
41
43
  noSpaceAfterFlags: true
42
44
  }
43
45
  },
46
+ // 'removeOffCanvasPaths', // bugged for some icons
44
47
  "reusePaths"
45
48
  ],
46
- ...options.cleanupIDs !== false ? ["cleanupIds"] : []
49
+ // Clean up IDs, first run
50
+ // Sometimes bugs out on animated icons. Do not use with animations!
51
+ ...!options.animated && options.cleanupIDs !== false ? ["cleanupIds"] : []
47
52
  ];
48
53
  }
49
54
  function runSVGO(svg, options = {}) {
@@ -12,7 +12,11 @@ require('../parse.cjs');
12
12
 
13
13
  function cleanupRootStyle(svg) {
14
14
  return svg_parseStyle.parseSVGStyle(svg, (item) => {
15
- if (item.type === "global" && item.selectorTokens.find((token) => token.type === "at-rule")) {
15
+ if (
16
+ // If global style
17
+ item.type === "global" && // If selector tokens contain at-rule
18
+ item.selectorTokens.find((token) => token.type === "at-rule")
19
+ ) {
16
20
  return;
17
21
  }
18
22
  return item.value;
@@ -10,7 +10,11 @@ import '../parse.mjs';
10
10
 
11
11
  function cleanupRootStyle(svg) {
12
12
  return parseSVGStyle(svg, (item) => {
13
- if (item.type === "global" && item.selectorTokens.find((token) => token.type === "at-rule")) {
13
+ if (
14
+ // If global style
15
+ item.type === "global" && // If selector tokens contain at-rule
16
+ item.selectorTokens.find((token) => token.type === "at-rule")
17
+ ) {
14
18
  return;
15
19
  }
16
20
  return item.value;
@@ -48,7 +48,12 @@ function cleanupSVGRoot(svg) {
48
48
  }
49
49
  throw new Error(`Unexpected attribute "${attr}" on <${tagName}>`);
50
50
  }
51
- if (attr.slice(0, 2) === "on" || attr.slice(0, 5) === "aria-" || attr.slice(0, 6) === "xmlns:") {
51
+ if (
52
+ // Events
53
+ attr.slice(0, 2) === "on" || // aria-stuff
54
+ attr.slice(0, 5) === "aria-" || // Junk
55
+ attr.slice(0, 6) === "xmlns:"
56
+ ) {
52
57
  $root.removeAttr(attr);
53
58
  return;
54
59
  }
@@ -46,7 +46,12 @@ function cleanupSVGRoot(svg) {
46
46
  }
47
47
  throw new Error(`Unexpected attribute "${attr}" on <${tagName}>`);
48
48
  }
49
- if (attr.slice(0, 2) === "on" || attr.slice(0, 5) === "aria-" || attr.slice(0, 6) === "xmlns:") {
49
+ if (
50
+ // Events
51
+ attr.slice(0, 2) === "on" || // aria-stuff
52
+ attr.slice(0, 5) === "aria-" || // Junk
53
+ attr.slice(0, 6) === "xmlns:"
54
+ ) {
50
55
  $root.removeAttr(attr);
51
56
  return;
52
57
  }
@@ -19,7 +19,10 @@ async function convertStyleToAttrs(svg) {
19
19
  let hasStyle = false;
20
20
  await svg_parseStyle.parseSVGStyle(svg, (item) => {
21
21
  const prop = item.prop;
22
- if (svg_data_attributes.badAttributes.has(prop) || svg_data_attributes.badSoftwareAttributes.has(prop) || svg_data_attributes.badAttributePrefixes.has(prop.split("-").shift())) {
22
+ if (
23
+ // Attributes / properties now allowed
24
+ svg_data_attributes.badAttributes.has(prop) || svg_data_attributes.badSoftwareAttributes.has(prop) || svg_data_attributes.badAttributePrefixes.has(prop.split("-").shift())
25
+ ) {
23
26
  return void 0;
24
27
  }
25
28
  hasStyle = true;
@@ -17,7 +17,10 @@ async function convertStyleToAttrs(svg) {
17
17
  let hasStyle = false;
18
18
  await parseSVGStyle(svg, (item) => {
19
19
  const prop = item.prop;
20
- if (badAttributes.has(prop) || badSoftwareAttributes.has(prop) || badAttributePrefixes.has(prop.split("-").shift())) {
20
+ if (
21
+ // Attributes / properties now allowed
22
+ badAttributes.has(prop) || badSoftwareAttributes.has(prop) || badAttributePrefixes.has(prop.split("-").shift())
23
+ ) {
21
24
  return void 0;
22
25
  }
23
26
  hasStyle = true;
@@ -29,6 +29,7 @@ const badSoftwareAttributes = /* @__PURE__ */ new Set([
29
29
  "overflow",
30
30
  "marker",
31
31
  "white-space",
32
+ // Font stuff
32
33
  "direction"
33
34
  ]);
34
35
  const badAttributePrefixes = /* @__PURE__ */ new Set([
@@ -37,6 +38,7 @@ const badAttributePrefixes = /* @__PURE__ */ new Set([
37
38
  "block",
38
39
  "data",
39
40
  "aria",
41
+ // Font stuff
40
42
  "text",
41
43
  "font",
42
44
  "letter",
@@ -44,6 +46,7 @@ const badAttributePrefixes = /* @__PURE__ */ new Set([
44
46
  "word",
45
47
  "line",
46
48
  "writing",
49
+ // Prefix for browser specific stuff
47
50
  ""
48
51
  ]);
49
52
  const commonAttributes = /* @__PURE__ */ new Set(["id"]);
@@ -155,12 +158,15 @@ const tagSpecificAnimatedAttributes = {
155
158
  rect: /* @__PURE__ */ new Set(["x", "y", "width", "height", "rx", "ry"])
156
159
  };
157
160
  const tagSpecificPresentationalAttributes = {
161
+ // SVG
158
162
  svg: /* @__PURE__ */ new Set(["width", "height", ...presentationalAttributes]),
163
+ // Defnitions, containers and masks
159
164
  clipPath: /* @__PURE__ */ new Set([...presentationalAttributes]),
160
165
  defs: /* @__PURE__ */ new Set([]),
161
166
  g: /* @__PURE__ */ new Set([...presentationalAttributes]),
162
167
  mask: /* @__PURE__ */ new Set(["x", "y", "width", "height", ...presentationalAttributes]),
163
168
  symbol: /* @__PURE__ */ new Set(["x", "y", "width", "height", ...presentationalAttributes]),
169
+ // Use
164
170
  use: /* @__PURE__ */ new Set([
165
171
  "x",
166
172
  "y",
@@ -170,7 +176,9 @@ const tagSpecificPresentationalAttributes = {
170
176
  "refY",
171
177
  ...presentationalAttributes
172
178
  ]),
179
+ // Marker
173
180
  marker: /* @__PURE__ */ new Set([...presentationalAttributes]),
181
+ // Gradients
174
182
  linearGradient: /* @__PURE__ */ new Set([
175
183
  "x1",
176
184
  "x2",
@@ -188,6 +196,7 @@ const tagSpecificPresentationalAttributes = {
188
196
  ...presentationalAttributes
189
197
  ]),
190
198
  stop: /* @__PURE__ */ new Set(["offset", "stop-color", "stop-opacity"]),
199
+ // Filters
191
200
  feFlood: /* @__PURE__ */ new Set(["flood-color", "flood-opacity"]),
192
201
  feDropShadow: /* @__PURE__ */ new Set(["flood-color", "flood-opacity"])
193
202
  };
@@ -205,10 +214,13 @@ svg_data_tags.filterChildTags.forEach((tag) => {
205
214
  ]);
206
215
  });
207
216
  const tagSpecificNonPresentationalAttributes = {
217
+ // SVG
208
218
  svg: /* @__PURE__ */ new Set(["xmlns", "viewBox", "preserveAspectRatio"]),
219
+ // Defnitions, containers and masks
209
220
  clipPath: /* @__PURE__ */ new Set(["clipPathUnits"]),
210
221
  mask: /* @__PURE__ */ new Set(["maskContentUnits", "maskUnits"]),
211
222
  symbol: /* @__PURE__ */ new Set(["viewBox", "preserveAspectRatio"]),
223
+ // Shapes
212
224
  circle: /* @__PURE__ */ new Set([...otherShapeAttributes]),
213
225
  ellipse: /* @__PURE__ */ new Set([...otherShapeAttributes]),
214
226
  line: /* @__PURE__ */ new Set([...otherShapeAttributes]),
@@ -216,7 +228,9 @@ const tagSpecificNonPresentationalAttributes = {
216
228
  polygon: /* @__PURE__ */ new Set([...otherShapeAttributes]),
217
229
  polyline: /* @__PURE__ */ new Set([...otherShapeAttributes]),
218
230
  rect: /* @__PURE__ */ new Set([...otherShapeAttributes]),
231
+ // Use
219
232
  use: /* @__PURE__ */ new Set(["href"]),
233
+ // Marker
220
234
  marker: /* @__PURE__ */ new Set([
221
235
  "markerHeight",
222
236
  "markerUnits",
@@ -227,6 +241,7 @@ const tagSpecificNonPresentationalAttributes = {
227
241
  "refY",
228
242
  "viewBox"
229
243
  ]),
244
+ // Animations
230
245
  animate: /* @__PURE__ */ new Set([
231
246
  ...animationTimingAttributes,
232
247
  ...animationValueAttributes,
@@ -256,8 +271,10 @@ const tagSpecificNonPresentationalAttributes = {
256
271
  ...otherAnimationAttributes
257
272
  ]),
258
273
  mpath: /* @__PURE__ */ new Set(["href"]),
274
+ // Gradients
259
275
  linearGradient: /* @__PURE__ */ new Set([...commonGradientAttributes]),
260
276
  radialGradient: /* @__PURE__ */ new Set([...commonGradientAttributes]),
277
+ // Filters
261
278
  feSpotLight: /* @__PURE__ */ new Set([
262
279
  "x",
263
280
  "y",
@@ -27,6 +27,7 @@ const badSoftwareAttributes = /* @__PURE__ */ new Set([
27
27
  "overflow",
28
28
  "marker",
29
29
  "white-space",
30
+ // Font stuff
30
31
  "direction"
31
32
  ]);
32
33
  const badAttributePrefixes = /* @__PURE__ */ new Set([
@@ -35,6 +36,7 @@ const badAttributePrefixes = /* @__PURE__ */ new Set([
35
36
  "block",
36
37
  "data",
37
38
  "aria",
39
+ // Font stuff
38
40
  "text",
39
41
  "font",
40
42
  "letter",
@@ -42,6 +44,7 @@ const badAttributePrefixes = /* @__PURE__ */ new Set([
42
44
  "word",
43
45
  "line",
44
46
  "writing",
47
+ // Prefix for browser specific stuff
45
48
  ""
46
49
  ]);
47
50
  const commonAttributes = /* @__PURE__ */ new Set(["id"]);
@@ -153,12 +156,15 @@ const tagSpecificAnimatedAttributes = {
153
156
  rect: /* @__PURE__ */ new Set(["x", "y", "width", "height", "rx", "ry"])
154
157
  };
155
158
  const tagSpecificPresentationalAttributes = {
159
+ // SVG
156
160
  svg: /* @__PURE__ */ new Set(["width", "height", ...presentationalAttributes]),
161
+ // Defnitions, containers and masks
157
162
  clipPath: /* @__PURE__ */ new Set([...presentationalAttributes]),
158
163
  defs: /* @__PURE__ */ new Set([]),
159
164
  g: /* @__PURE__ */ new Set([...presentationalAttributes]),
160
165
  mask: /* @__PURE__ */ new Set(["x", "y", "width", "height", ...presentationalAttributes]),
161
166
  symbol: /* @__PURE__ */ new Set(["x", "y", "width", "height", ...presentationalAttributes]),
167
+ // Use
162
168
  use: /* @__PURE__ */ new Set([
163
169
  "x",
164
170
  "y",
@@ -168,7 +174,9 @@ const tagSpecificPresentationalAttributes = {
168
174
  "refY",
169
175
  ...presentationalAttributes
170
176
  ]),
177
+ // Marker
171
178
  marker: /* @__PURE__ */ new Set([...presentationalAttributes]),
179
+ // Gradients
172
180
  linearGradient: /* @__PURE__ */ new Set([
173
181
  "x1",
174
182
  "x2",
@@ -186,6 +194,7 @@ const tagSpecificPresentationalAttributes = {
186
194
  ...presentationalAttributes
187
195
  ]),
188
196
  stop: /* @__PURE__ */ new Set(["offset", "stop-color", "stop-opacity"]),
197
+ // Filters
189
198
  feFlood: /* @__PURE__ */ new Set(["flood-color", "flood-opacity"]),
190
199
  feDropShadow: /* @__PURE__ */ new Set(["flood-color", "flood-opacity"])
191
200
  };
@@ -203,10 +212,13 @@ filterChildTags.forEach((tag) => {
203
212
  ]);
204
213
  });
205
214
  const tagSpecificNonPresentationalAttributes = {
215
+ // SVG
206
216
  svg: /* @__PURE__ */ new Set(["xmlns", "viewBox", "preserveAspectRatio"]),
217
+ // Defnitions, containers and masks
207
218
  clipPath: /* @__PURE__ */ new Set(["clipPathUnits"]),
208
219
  mask: /* @__PURE__ */ new Set(["maskContentUnits", "maskUnits"]),
209
220
  symbol: /* @__PURE__ */ new Set(["viewBox", "preserveAspectRatio"]),
221
+ // Shapes
210
222
  circle: /* @__PURE__ */ new Set([...otherShapeAttributes]),
211
223
  ellipse: /* @__PURE__ */ new Set([...otherShapeAttributes]),
212
224
  line: /* @__PURE__ */ new Set([...otherShapeAttributes]),
@@ -214,7 +226,9 @@ const tagSpecificNonPresentationalAttributes = {
214
226
  polygon: /* @__PURE__ */ new Set([...otherShapeAttributes]),
215
227
  polyline: /* @__PURE__ */ new Set([...otherShapeAttributes]),
216
228
  rect: /* @__PURE__ */ new Set([...otherShapeAttributes]),
229
+ // Use
217
230
  use: /* @__PURE__ */ new Set(["href"]),
231
+ // Marker
218
232
  marker: /* @__PURE__ */ new Set([
219
233
  "markerHeight",
220
234
  "markerUnits",
@@ -225,6 +239,7 @@ const tagSpecificNonPresentationalAttributes = {
225
239
  "refY",
226
240
  "viewBox"
227
241
  ]),
242
+ // Animations
228
243
  animate: /* @__PURE__ */ new Set([
229
244
  ...animationTimingAttributes,
230
245
  ...animationValueAttributes,
@@ -254,8 +269,10 @@ const tagSpecificNonPresentationalAttributes = {
254
269
  ...otherAnimationAttributes
255
270
  ]),
256
271
  mpath: /* @__PURE__ */ new Set(["href"]),
272
+ // Gradients
257
273
  linearGradient: /* @__PURE__ */ new Set([...commonGradientAttributes]),
258
274
  radialGradient: /* @__PURE__ */ new Set([...commonGradientAttributes]),
275
+ // Filters
259
276
  feSpotLight: /* @__PURE__ */ new Set([
260
277
  "x",
261
278
  "y",
@@ -1,23 +1,29 @@
1
1
  'use strict';
2
2
 
3
3
  const badTags = /* @__PURE__ */ new Set([
4
+ // Nasty stuff or external resource
4
5
  "foreignObject",
5
6
  "script",
6
7
  "image",
7
8
  "feImage",
9
+ // Deprecated
8
10
  "animateColor",
9
11
  "altGlyph",
12
+ // Text
10
13
  "text",
11
14
  "tspan",
12
15
  "switch",
13
16
  "textPath",
17
+ // Font
14
18
  "font",
15
19
  "font-face",
16
20
  "glyph",
17
21
  "missing-glyph",
18
22
  "hkern",
19
23
  "vhern",
24
+ // View
20
25
  "view",
26
+ // Link
21
27
  "a"
22
28
  ]);
23
29
  const unsupportedTags = /* @__PURE__ */ new Set(["metadata", "desc", "title"]);
@@ -1,21 +1,27 @@
1
1
  const badTags = /* @__PURE__ */ new Set([
2
+ // Nasty stuff or external resource
2
3
  "foreignObject",
3
4
  "script",
4
5
  "image",
5
6
  "feImage",
7
+ // Deprecated
6
8
  "animateColor",
7
9
  "altGlyph",
10
+ // Text
8
11
  "text",
9
12
  "tspan",
10
13
  "switch",
11
14
  "textPath",
15
+ // Font
12
16
  "font",
13
17
  "font-face",
14
18
  "glyph",
15
19
  "missing-glyph",
16
20
  "hkern",
17
21
  "vhern",
22
+ // View
18
23
  "view",
24
+ // Link
19
25
  "a"
20
26
  ]);
21
27
  const unsupportedTags = /* @__PURE__ */ new Set(["metadata", "desc", "title"]);
package/lib/svg/index.cjs CHANGED
@@ -4,9 +4,15 @@ const cheerio = require('cheerio');
4
4
  const utils = require('@iconify/utils');
5
5
 
6
6
  class SVG {
7
+ /**
8
+ * Constructor
9
+ */
7
10
  constructor(content) {
8
11
  this.load(content);
9
12
  }
13
+ /**
14
+ * Get SVG as string
15
+ */
10
16
  toString(customisations) {
11
17
  if (customisations) {
12
18
  const data = utils.iconToSVG(this.getIcon(), customisations);
@@ -36,9 +42,15 @@ class SVG {
36
42
  }
37
43
  return this.$svg.html();
38
44
  }
45
+ /**
46
+ * Get SVG as string without whitespaces
47
+ */
39
48
  toMinifiedString(customisations) {
40
49
  return utils.trimSVG(this.toString(customisations));
41
50
  }
51
+ /**
52
+ * Get body
53
+ */
42
54
  getBody() {
43
55
  const $root = this.$svg(":root");
44
56
  const attribs = $root.get(0).attribs;
@@ -54,6 +66,9 @@ class SVG {
54
66
  }
55
67
  return utils.trimSVG(this.$svg("svg").html());
56
68
  }
69
+ /**
70
+ * Get icon as IconifyIcon
71
+ */
57
72
  getIcon() {
58
73
  const props = this.viewBox;
59
74
  const body = this.getBody();
@@ -62,6 +77,11 @@ class SVG {
62
77
  body
63
78
  };
64
79
  }
80
+ /**
81
+ * Load SVG
82
+ *
83
+ * @param {string} content
84
+ */
65
85
  load(content) {
66
86
  function remove(str1, str2, append) {
67
87
  let start = 0;
package/lib/svg/index.mjs CHANGED
@@ -2,9 +2,15 @@ import cheerio from 'cheerio';
2
2
  import { iconToSVG, trimSVG } from '@iconify/utils';
3
3
 
4
4
  class SVG {
5
+ /**
6
+ * Constructor
7
+ */
5
8
  constructor(content) {
6
9
  this.load(content);
7
10
  }
11
+ /**
12
+ * Get SVG as string
13
+ */
8
14
  toString(customisations) {
9
15
  if (customisations) {
10
16
  const data = iconToSVG(this.getIcon(), customisations);
@@ -34,9 +40,15 @@ class SVG {
34
40
  }
35
41
  return this.$svg.html();
36
42
  }
43
+ /**
44
+ * Get SVG as string without whitespaces
45
+ */
37
46
  toMinifiedString(customisations) {
38
47
  return trimSVG(this.toString(customisations));
39
48
  }
49
+ /**
50
+ * Get body
51
+ */
40
52
  getBody() {
41
53
  const $root = this.$svg(":root");
42
54
  const attribs = $root.get(0).attribs;
@@ -52,6 +64,9 @@ class SVG {
52
64
  }
53
65
  return trimSVG(this.$svg("svg").html());
54
66
  }
67
+ /**
68
+ * Get icon as IconifyIcon
69
+ */
55
70
  getIcon() {
56
71
  const props = this.viewBox;
57
72
  const body = this.getBody();
@@ -60,6 +75,11 @@ class SVG {
60
75
  body
61
76
  };
62
77
  }
78
+ /**
79
+ * Load SVG
80
+ *
81
+ * @param {string} content
82
+ */
63
83
  load(content) {
64
84
  function remove(str1, str2, append) {
65
85
  let start = 0;
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": "2.2.0",
6
+ "version": "2.2.2",
7
7
  "license": "MIT",
8
8
  "bugs": "https://github.com/iconify/tools/issues",
9
9
  "homepage": "https://github.com/iconify/tools",
@@ -16,35 +16,35 @@
16
16
  "types": "./lib/index.d.ts",
17
17
  "dependencies": {
18
18
  "@iconify/types": "^2.0.0",
19
- "@iconify/utils": "^2.0.9",
19
+ "@iconify/utils": "^2.1.0",
20
20
  "@types/cheerio": "^0.22.31",
21
21
  "@types/node-fetch": "^2.6.2",
22
22
  "@types/tar": "^6.1.3",
23
23
  "cheerio": "^1.0.0-rc.12",
24
24
  "extract-zip": "^2.0.1",
25
25
  "local-pkg": "^0.4.2",
26
- "node-fetch": "^2.6.7",
26
+ "node-fetch": "^2.6.8",
27
27
  "pathe": "^1.0.0",
28
28
  "svgo": "^3.0.2",
29
29
  "tar": "^6.1.13"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/jest": "^29.2.4",
33
- "@types/node": "^18.11.17",
34
- "@typescript-eslint/eslint-plugin": "^5.47.0",
35
- "@typescript-eslint/parser": "^5.47.0",
32
+ "@types/jest": "^29.2.5",
33
+ "@types/node": "^18.11.18",
34
+ "@typescript-eslint/eslint-plugin": "^5.48.1",
35
+ "@typescript-eslint/parser": "^5.48.1",
36
36
  "cross-env": "^7.0.3",
37
- "eslint": "^8.30.0",
38
- "eslint-config-prettier": "^8.5.0",
37
+ "eslint": "^8.32.0",
38
+ "eslint-config-prettier": "^8.6.0",
39
39
  "eslint-plugin-jasmine": "^4.1.3",
40
40
  "eslint-plugin-prettier": "^4.2.1",
41
41
  "jasmine": "^4.5.0",
42
42
  "jest": "^29.3.1",
43
- "prettier": "^2.8.1",
43
+ "prettier": "^2.8.3",
44
44
  "rimraf": "^3.0.2",
45
- "ts-jest": "^29.0.3",
45
+ "ts-jest": "^29.0.5",
46
46
  "typescript": "^4.9.4",
47
- "unbuild": "^1.0.2"
47
+ "unbuild": "^1.1.1"
48
48
  },
49
49
  "exports": {
50
50
  "./*": "./*",