@iconify/tools 2.2.6 → 3.0.0-beta.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 (85) hide show
  1. package/README.md +8 -2
  2. package/lib/colors/detect.cjs +4 -4
  3. package/lib/colors/detect.d.ts +1 -1
  4. package/lib/colors/detect.mjs +5 -5
  5. package/lib/colors/parse.cjs +275 -129
  6. package/lib/colors/parse.d.ts +14 -5
  7. package/lib/colors/parse.mjs +278 -133
  8. package/lib/colors/validate.cjs +11 -2
  9. package/lib/colors/validate.d.ts +10 -2
  10. package/lib/colors/validate.mjs +12 -4
  11. package/lib/css/parser/export.cjs +1 -10
  12. package/lib/css/parser/export.mjs +1 -10
  13. package/lib/css/parser/text.cjs +6 -25
  14. package/lib/css/parser/text.mjs +6 -25
  15. package/lib/css/parser/types.d.ts +2 -3
  16. package/lib/download/api/download.cjs +4 -4
  17. package/lib/download/api/download.mjs +4 -4
  18. package/lib/download/api/index.cjs +0 -1
  19. package/lib/download/api/index.mjs +0 -1
  20. package/lib/download/git/index.cjs +1 -1
  21. package/lib/download/git/index.mjs +1 -1
  22. package/lib/download/git/reset.cjs +1 -1
  23. package/lib/download/git/reset.mjs +1 -1
  24. package/lib/download/github/hash.cjs +0 -1
  25. package/lib/download/github/hash.mjs +0 -1
  26. package/lib/download/github/index.cjs +1 -1
  27. package/lib/download/github/index.mjs +1 -1
  28. package/lib/download/gitlab/hash.cjs +0 -1
  29. package/lib/download/gitlab/hash.mjs +0 -1
  30. package/lib/download/gitlab/index.cjs +1 -1
  31. package/lib/download/gitlab/index.mjs +1 -1
  32. package/lib/download/helpers/unzip.cjs +5 -1
  33. package/lib/download/index.cjs +1 -1
  34. package/lib/download/index.mjs +1 -1
  35. package/lib/download/npm/index.cjs +1 -1
  36. package/lib/download/npm/index.mjs +1 -1
  37. package/lib/icon-set/index.cjs +18 -0
  38. package/lib/icon-set/index.d.ts +7 -1
  39. package/lib/icon-set/index.mjs +18 -0
  40. package/lib/icon-set/tags.cjs +2 -2
  41. package/lib/icon-set/tags.d.ts +1 -1
  42. package/lib/icon-set/tags.mjs +2 -2
  43. package/lib/icon-set/types.d.ts +5 -4
  44. package/lib/import/directory.cjs +101 -28
  45. package/lib/import/directory.d.ts +12 -5
  46. package/lib/import/directory.mjs +103 -31
  47. package/lib/import/figma/index.cjs +1 -2
  48. package/lib/import/figma/index.mjs +1 -2
  49. package/lib/import/figma/query.cjs +0 -1
  50. package/lib/import/figma/query.mjs +0 -1
  51. package/lib/index.cjs +7 -1
  52. package/lib/index.d.ts +6 -6
  53. package/lib/index.mjs +7 -7
  54. package/lib/misc/scan.cjs +61 -8
  55. package/lib/misc/scan.d.ts +12 -6
  56. package/lib/misc/scan.mjs +62 -10
  57. package/lib/svg/analyse.cjs +2 -2
  58. package/lib/svg/analyse.d.ts +1 -1
  59. package/lib/svg/analyse.mjs +4 -4
  60. package/lib/svg/cleanup/attribs.cjs +2 -2
  61. package/lib/svg/cleanup/attribs.d.ts +1 -1
  62. package/lib/svg/cleanup/attribs.mjs +3 -3
  63. package/lib/svg/cleanup/bad-tags.cjs +2 -2
  64. package/lib/svg/cleanup/bad-tags.d.ts +1 -1
  65. package/lib/svg/cleanup/bad-tags.mjs +3 -3
  66. package/lib/svg/cleanup/inline-style.cjs +2 -2
  67. package/lib/svg/cleanup/inline-style.d.ts +1 -1
  68. package/lib/svg/cleanup/inline-style.mjs +3 -3
  69. package/lib/svg/cleanup/root-style.cjs +19 -8
  70. package/lib/svg/cleanup/root-style.d.ts +5 -5
  71. package/lib/svg/cleanup/root-style.mjs +20 -9
  72. package/lib/svg/cleanup/svgo-style.cjs +5 -2
  73. package/lib/svg/cleanup/svgo-style.d.ts +1 -1
  74. package/lib/svg/cleanup/svgo-style.mjs +6 -3
  75. package/lib/svg/cleanup.cjs +6 -6
  76. package/lib/svg/cleanup.d.ts +1 -1
  77. package/lib/svg/cleanup.mjs +6 -6
  78. package/lib/svg/index.cjs +5 -1
  79. package/lib/svg/parse-style.cjs +266 -103
  80. package/lib/svg/parse-style.d.ts +21 -3
  81. package/lib/svg/parse-style.mjs +267 -105
  82. package/lib/svg/parse.cjs +56 -18
  83. package/lib/svg/parse.d.ts +8 -2
  84. package/lib/svg/parse.mjs +56 -19
  85. package/package.json +15 -17
package/lib/misc/scan.mjs CHANGED
@@ -1,15 +1,31 @@
1
- import { promises } from 'fs';
1
+ import { promises, readdirSync, statSync } from 'fs';
2
2
 
3
- async function scanDirectory(path, callback, subdirs = true) {
4
- const results = [];
3
+ function cleanPath(path) {
5
4
  if (path.length && path.slice(-1) !== "/") {
6
- path += "/";
5
+ return path + "/";
7
6
  }
7
+ return path;
8
+ }
9
+ function isHidden(filename) {
10
+ return filename.slice(0, 1) === ".";
11
+ }
12
+ function split(filename) {
13
+ const parts = filename.split(".");
14
+ const ext = parts.length > 1 ? "." + parts.pop() : "";
15
+ const file = parts.join(".");
16
+ return { ext, file };
17
+ }
18
+ function isIgnoredResult(result) {
19
+ return result === void 0 || result === false || result === null;
20
+ }
21
+ async function scanDirectory(path, callback, subdirs = true) {
22
+ const results = [];
23
+ path = cleanPath(path);
8
24
  async function scan(subdir) {
9
25
  const files = await promises.readdir(path + subdir);
10
26
  for (let i = 0; i < files.length; i++) {
11
27
  const filename = files[i];
12
- if (filename.slice(0, 1) === ".") {
28
+ if (isHidden(filename)) {
13
29
  continue;
14
30
  }
15
31
  const stat = await promises.stat(path + subdir + filename);
@@ -22,16 +38,14 @@ async function scanDirectory(path, callback, subdirs = true) {
22
38
  if (!stat.isFile()) {
23
39
  continue;
24
40
  }
25
- const parts = filename.split(".");
26
- const ext = parts.length > 1 ? "." + parts.pop() : "";
27
- const file = parts.join(".");
41
+ const { ext, file } = split(filename);
28
42
  let callbackResult;
29
43
  if (callback) {
30
44
  callbackResult = callback(ext, file, subdir, path, stat);
31
45
  if (callbackResult instanceof Promise) {
32
46
  callbackResult = await callbackResult;
33
47
  }
34
- if (callbackResult === void 0 || callbackResult === false || callbackResult === null) {
48
+ if (isIgnoredResult(callbackResult)) {
35
49
  continue;
36
50
  }
37
51
  } else {
@@ -45,5 +59,43 @@ async function scanDirectory(path, callback, subdirs = true) {
45
59
  await scan("");
46
60
  return results;
47
61
  }
62
+ function scanDirectorySync(path, callback, subdirs = true) {
63
+ const results = [];
64
+ path = cleanPath(path);
65
+ function scan(subdir) {
66
+ const files = readdirSync(path + subdir);
67
+ for (let i = 0; i < files.length; i++) {
68
+ const filename = files[i];
69
+ if (isHidden(filename)) {
70
+ continue;
71
+ }
72
+ const stat = statSync(path + subdir + filename);
73
+ if (stat.isDirectory()) {
74
+ if (subdirs) {
75
+ scan(subdir + filename + "/");
76
+ }
77
+ continue;
78
+ }
79
+ if (!stat.isFile()) {
80
+ continue;
81
+ }
82
+ const { ext, file } = split(filename);
83
+ let callbackResult;
84
+ if (callback) {
85
+ callbackResult = callback(ext, file, subdir, path, stat);
86
+ if (isIgnoredResult(callbackResult)) {
87
+ continue;
88
+ }
89
+ } else {
90
+ callbackResult = true;
91
+ }
92
+ results.push(
93
+ callbackResult === true ? subdir + filename : callbackResult
94
+ );
95
+ }
96
+ }
97
+ scan("");
98
+ return results;
99
+ }
48
100
 
49
- export { scanDirectory };
101
+ export { scanDirectory, scanDirectorySync };
@@ -5,7 +5,7 @@ const svg_data_attributes = require('./data/attributes.cjs');
5
5
  const svg_data_tags = require('./data/tags.cjs');
6
6
  const svg_analyse_error = require('./analyse/error.cjs');
7
7
 
8
- async function analyseSVGStructure(svg, options = {}) {
8
+ function analyseSVGStructure(svg, options = {}) {
9
9
  const fixErrors = options.fixErrors;
10
10
  let root = svg.$svg(":root").get(0);
11
11
  if (root._parsed) {
@@ -83,7 +83,7 @@ async function analyseSVGStructure(svg, options = {}) {
83
83
  element._linksTo.push(link);
84
84
  }
85
85
  let index = 0;
86
- await svg_parse.parseSVG(svg, (item) => {
86
+ svg_parse.parseSVGSync(svg, (item) => {
87
87
  const { tagName, parents } = item;
88
88
  if (svg_data_tags.styleTag.has(tagName)) {
89
89
  item.testChildren = false;
@@ -8,6 +8,6 @@ import '@iconify/utils/lib/customisations/defaults';
8
8
  *
9
9
  * Before running this function run cleanup functions to change inline style to attributes and fix attributes
10
10
  */
11
- declare function analyseSVGStructure(svg: SVG, options?: AnalyseSVGStructureOptions): Promise<AnalyseSVGStructureResult>;
11
+ declare function analyseSVGStructure(svg: SVG, options?: AnalyseSVGStructureOptions): AnalyseSVGStructureResult;
12
12
 
13
13
  export { analyseSVGStructure };
@@ -1,9 +1,9 @@
1
- import { parseSVG } from './parse.mjs';
1
+ import { parseSVGSync } from './parse.mjs';
2
2
  import { tagSpecificNonPresentationalAttributes, urlPresentationalAttributes, commonColorPresentationalAttributes, markerAttributes } from './data/attributes.mjs';
3
- import { styleTag, maskTags, reusableElementsWithPalette, defsTag, useTag } from './data/tags.mjs';
3
+ import { useTag, styleTag, maskTags, reusableElementsWithPalette, defsTag } from './data/tags.mjs';
4
4
  import { analyseTagError } from './analyse/error.mjs';
5
5
 
6
- async function analyseSVGStructure(svg, options = {}) {
6
+ function analyseSVGStructure(svg, options = {}) {
7
7
  const fixErrors = options.fixErrors;
8
8
  let root = svg.$svg(":root").get(0);
9
9
  if (root._parsed) {
@@ -81,7 +81,7 @@ async function analyseSVGStructure(svg, options = {}) {
81
81
  element._linksTo.push(link);
82
82
  }
83
83
  let index = 0;
84
- await parseSVG(svg, (item) => {
84
+ parseSVGSync(svg, (item) => {
85
85
  const { tagName, parents } = item;
86
86
  if (styleTag.has(tagName)) {
87
87
  item.testChildren = false;
@@ -4,8 +4,8 @@ const svg_data_attributes = require('../data/attributes.cjs');
4
4
  const svg_data_tags = require('../data/tags.cjs');
5
5
  const svg_parse = require('../parse.cjs');
6
6
 
7
- async function removeBadAttributes(svg) {
8
- await svg_parse.parseSVG(svg, (item) => {
7
+ function removeBadAttributes(svg) {
8
+ svg_parse.parseSVGSync(svg, (item) => {
9
9
  const tagName = item.tagName;
10
10
  const attribs = item.element.attribs;
11
11
  const $element = item.$element;
@@ -5,6 +5,6 @@ import '@iconify/utils/lib/customisations/defaults';
5
5
  /**
6
6
  * Remove useless attributes
7
7
  */
8
- declare function removeBadAttributes(svg: SVG): Promise<void>;
8
+ declare function removeBadAttributes(svg: SVG): void;
9
9
 
10
10
  export { removeBadAttributes };
@@ -1,9 +1,9 @@
1
1
  import { badAttributes, badSoftwareAttributes, badAttributePrefixes, tagSpecificPresentationalAttributes } from '../data/attributes.mjs';
2
2
  import { defsTag } from '../data/tags.mjs';
3
- import { parseSVG } from '../parse.mjs';
3
+ import { parseSVGSync } from '../parse.mjs';
4
4
 
5
- async function removeBadAttributes(svg) {
6
- await parseSVG(svg, (item) => {
5
+ function removeBadAttributes(svg) {
6
+ parseSVGSync(svg, (item) => {
7
7
  const tagName = item.tagName;
8
8
  const attribs = item.element.attribs;
9
9
  const $element = item.$element;
@@ -13,8 +13,8 @@ requiredParentTags.set(svg_data_tags.feLightningTags, svg_data_tags.feLightningC
13
13
  requiredParentTags.set(svg_data_tags.filterTag, svg_data_tags.filterChildTags);
14
14
  requiredParentTags.set(svg_data_tags.gradientTags, svg_data_tags.gradientChildTags);
15
15
  requiredParentTags.set(/* @__PURE__ */ new Set(["animateMotion"]), svg_data_tags.animateMotionChildTags);
16
- async function checkBadTags(svg) {
17
- await svg_parse.parseSVG(svg, (item) => {
16
+ function checkBadTags(svg) {
17
+ svg_parse.parseSVGSync(svg, (item) => {
18
18
  const tagName = item.tagName;
19
19
  const $element = item.$element;
20
20
  if (tagName === "svg") {
@@ -5,6 +5,6 @@ import '@iconify/utils/lib/customisations/defaults';
5
5
  /**
6
6
  * Test for bag tags
7
7
  */
8
- declare function checkBadTags(svg: SVG): Promise<void>;
8
+ declare function checkBadTags(svg: SVG): void;
9
9
 
10
10
  export { checkBadTags };
@@ -1,4 +1,4 @@
1
- import { parseSVG } from '../parse.mjs';
1
+ import { parseSVGSync } from '../parse.mjs';
2
2
  import { feComponentTransferChildTag, feMergeChildTags, feLightningTags, feLightningChildTags, filterTag, filterChildTags, gradientTags, gradientChildTags, animateMotionChildTags, unsupportedTags, badTags, allValidTags } from '../data/tags.mjs';
3
3
 
4
4
  const requiredParentTags = /* @__PURE__ */ new Map();
@@ -11,8 +11,8 @@ requiredParentTags.set(feLightningTags, feLightningChildTags);
11
11
  requiredParentTags.set(filterTag, filterChildTags);
12
12
  requiredParentTags.set(gradientTags, gradientChildTags);
13
13
  requiredParentTags.set(/* @__PURE__ */ new Set(["animateMotion"]), animateMotionChildTags);
14
- async function checkBadTags(svg) {
15
- await parseSVG(svg, (item) => {
14
+ function checkBadTags(svg) {
15
+ parseSVGSync(svg, (item) => {
16
16
  const tagName = item.tagName;
17
17
  const $element = item.$element;
18
18
  if (tagName === "svg") {
@@ -9,8 +9,8 @@ require('../../css/parser/strings.cjs');
9
9
  require('../../css/parser/text.cjs');
10
10
  require('../data/tags.cjs');
11
11
 
12
- async function cleanupInlineStyle(svg) {
13
- await svg_parse.parseSVG(svg, (item) => {
12
+ function cleanupInlineStyle(svg) {
13
+ svg_parse.parseSVGSync(svg, (item) => {
14
14
  const $element = item.$element;
15
15
  const attribs = item.element.attribs;
16
16
  const tagName = item.tagName;
@@ -5,6 +5,6 @@ import '@iconify/utils/lib/customisations/defaults';
5
5
  /**
6
6
  * Expand inline style
7
7
  */
8
- declare function cleanupInlineStyle(svg: SVG): Promise<void>;
8
+ declare function cleanupInlineStyle(svg: SVG): void;
9
9
 
10
10
  export { cleanupInlineStyle };
@@ -1,14 +1,14 @@
1
1
  import { parseInlineStyle } from '../../css/parse.mjs';
2
2
  import { badAttributes, tagSpecificNonPresentationalAttributes, tagSpecificAnimatedAttributes, tagSpecificPresentationalAttributes, tagSpecificInlineStyles, insideClipPathAttributes, badSoftwareAttributes, badAttributePrefixes } from '../data/attributes.mjs';
3
- import { parseSVG } from '../parse.mjs';
3
+ import { parseSVGSync } from '../parse.mjs';
4
4
  import '../../css/parser/tokens.mjs';
5
5
  import '../../css/parser/error.mjs';
6
6
  import '../../css/parser/strings.mjs';
7
7
  import '../../css/parser/text.mjs';
8
8
  import '../data/tags.mjs';
9
9
 
10
- async function cleanupInlineStyle(svg) {
11
- await parseSVG(svg, (item) => {
10
+ function cleanupInlineStyle(svg) {
11
+ parseSVGSync(svg, (item) => {
12
12
  const $element = item.$element;
13
13
  const attribs = item.element.attribs;
14
14
  const tagName = item.tagName;
@@ -11,16 +11,27 @@ require('../../css/parser/tree.cjs');
11
11
  require('../parse.cjs');
12
12
 
13
13
  function cleanupRootStyle(svg) {
14
- return svg_parseStyle.parseSVGStyle(svg, (item) => {
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
- ) {
20
- return;
14
+ const result = {};
15
+ svg_parseStyle.parseSVGStyleSync(svg, (item) => {
16
+ switch (item.type) {
17
+ case "inline":
18
+ return item.value;
19
+ case "global":
20
+ return item.value;
21
+ case "at-rule":
22
+ if (item.prop === "supports") {
23
+ return item.value;
24
+ }
25
+ (result.removedAtRules || (result.removedAtRules = /* @__PURE__ */ new Set())).add(item.prop);
26
+ return;
27
+ case "keyframes":
28
+ (result.animations || (result.animations = /* @__PURE__ */ new Set())).add(
29
+ item.value
30
+ );
31
+ return item.value;
21
32
  }
22
- return item.value;
23
33
  });
34
+ return result;
24
35
  }
25
36
 
26
37
  exports.cleanupRootStyle = cleanupRootStyle;
@@ -1,16 +1,16 @@
1
1
  import { SVG } from '../index.js';
2
- import { parseSVGStyle } from '../parse-style.js';
3
2
  import '@iconify/types';
4
3
  import '@iconify/utils/lib/customisations/defaults';
5
- import '../../css/parser/types.js';
6
- import '../parse.js';
7
- import '../../misc/cheerio.js';
8
4
 
5
+ interface CleanupRootStyleResult {
6
+ animations?: Set<string>;
7
+ removedAtRules?: Set<string>;
8
+ }
9
9
  /**
10
10
  * Clean up root style
11
11
  *
12
12
  * This function removes all at-rule tokens, such as `@font-face`, `@media`
13
13
  */
14
- declare function cleanupRootStyle(svg: SVG): ReturnType<typeof parseSVGStyle>;
14
+ declare function cleanupRootStyle(svg: SVG): CleanupRootStyleResult;
15
15
 
16
16
  export { cleanupRootStyle };
@@ -1,4 +1,4 @@
1
- import { parseSVGStyle } from '../parse-style.mjs';
1
+ import { parseSVGStyleSync } from '../parse-style.mjs';
2
2
  import '../../css/parse.mjs';
3
3
  import '../../css/parser/tokens.mjs';
4
4
  import '../../css/parser/error.mjs';
@@ -9,16 +9,27 @@ import '../../css/parser/tree.mjs';
9
9
  import '../parse.mjs';
10
10
 
11
11
  function cleanupRootStyle(svg) {
12
- return parseSVGStyle(svg, (item) => {
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
- ) {
18
- return;
12
+ const result = {};
13
+ parseSVGStyleSync(svg, (item) => {
14
+ switch (item.type) {
15
+ case "inline":
16
+ return item.value;
17
+ case "global":
18
+ return item.value;
19
+ case "at-rule":
20
+ if (item.prop === "supports") {
21
+ return item.value;
22
+ }
23
+ (result.removedAtRules || (result.removedAtRules = /* @__PURE__ */ new Set())).add(item.prop);
24
+ return;
25
+ case "keyframes":
26
+ (result.animations || (result.animations = /* @__PURE__ */ new Set())).add(
27
+ item.value
28
+ );
29
+ return item.value;
19
30
  }
20
- return item.value;
21
31
  });
32
+ return result;
22
33
  }
23
34
 
24
35
  export { cleanupRootStyle };
@@ -15,9 +15,12 @@ require('../parse.cjs');
15
15
  require('svgo');
16
16
  require('@iconify/utils/lib/svg/id');
17
17
 
18
- async function convertStyleToAttrs(svg) {
18
+ function convertStyleToAttrs(svg) {
19
19
  let hasStyle = false;
20
- await svg_parseStyle.parseSVGStyle(svg, (item) => {
20
+ svg_parseStyle.parseSVGStyleSync(svg, (item) => {
21
+ if (item.type !== "inline" && item.type !== "global") {
22
+ return item.value;
23
+ }
21
24
  const prop = item.prop;
22
25
  if (
23
26
  // Attributes / properties now allowed
@@ -5,6 +5,6 @@ import '@iconify/utils/lib/customisations/defaults';
5
5
  /**
6
6
  * Expand inline style
7
7
  */
8
- declare function convertStyleToAttrs(svg: SVG): Promise<void>;
8
+ declare function convertStyleToAttrs(svg: SVG): void;
9
9
 
10
10
  export { convertStyleToAttrs };
@@ -1,5 +1,5 @@
1
1
  import { badAttributes, badSoftwareAttributes, badAttributePrefixes } from '../data/attributes.mjs';
2
- import { parseSVGStyle } from '../parse-style.mjs';
2
+ import { parseSVGStyleSync } from '../parse-style.mjs';
3
3
  import { runSVGO } from '../../optimise/svgo.mjs';
4
4
  import '../data/tags.mjs';
5
5
  import '../../css/parse.mjs';
@@ -13,9 +13,12 @@ import '../parse.mjs';
13
13
  import 'svgo';
14
14
  import '@iconify/utils/lib/svg/id';
15
15
 
16
- async function convertStyleToAttrs(svg) {
16
+ function convertStyleToAttrs(svg) {
17
17
  let hasStyle = false;
18
- await parseSVGStyle(svg, (item) => {
18
+ parseSVGStyleSync(svg, (item) => {
19
+ if (item.type !== "inline" && item.type !== "global") {
20
+ return item.value;
21
+ }
19
22
  const prop = item.prop;
20
23
  if (
21
24
  // Attributes / properties now allowed
@@ -21,13 +21,13 @@ require('../optimise/svgo.cjs');
21
21
  require('svgo');
22
22
  require('@iconify/utils/lib/svg/id');
23
23
 
24
- async function cleanupSVG(svg) {
25
- await svg_cleanup_inlineStyle.cleanupInlineStyle(svg);
26
- await svg_cleanup_svgoStyle.convertStyleToAttrs(svg);
24
+ function cleanupSVG(svg) {
25
+ svg_cleanup_inlineStyle.cleanupInlineStyle(svg);
26
+ svg_cleanup_svgoStyle.convertStyleToAttrs(svg);
27
27
  svg_cleanup_rootSvg.cleanupSVGRoot(svg);
28
- await svg_cleanup_badTags.checkBadTags(svg);
29
- await svg_cleanup_attribs.removeBadAttributes(svg);
30
- await svg_cleanup_rootStyle.cleanupRootStyle(svg);
28
+ svg_cleanup_badTags.checkBadTags(svg);
29
+ svg_cleanup_attribs.removeBadAttributes(svg);
30
+ svg_cleanup_rootStyle.cleanupRootStyle(svg);
31
31
  }
32
32
 
33
33
  exports.cleanupSVG = cleanupSVG;
@@ -5,6 +5,6 @@ import '@iconify/utils/lib/customisations/defaults';
5
5
  /**
6
6
  * Clean up SVG before parsing/optimising it
7
7
  */
8
- declare function cleanupSVG(svg: SVG): Promise<void>;
8
+ declare function cleanupSVG(svg: SVG): void;
9
9
 
10
10
  export { cleanupSVG };
@@ -19,13 +19,13 @@ import '../optimise/svgo.mjs';
19
19
  import 'svgo';
20
20
  import '@iconify/utils/lib/svg/id';
21
21
 
22
- async function cleanupSVG(svg) {
23
- await cleanupInlineStyle(svg);
24
- await convertStyleToAttrs(svg);
22
+ function cleanupSVG(svg) {
23
+ cleanupInlineStyle(svg);
24
+ convertStyleToAttrs(svg);
25
25
  cleanupSVGRoot(svg);
26
- await checkBadTags(svg);
27
- await removeBadAttributes(svg);
28
- await cleanupRootStyle(svg);
26
+ checkBadTags(svg);
27
+ removeBadAttributes(svg);
28
+ cleanupRootStyle(svg);
29
29
  }
30
30
 
31
31
  export { cleanupSVG };
package/lib/svg/index.cjs CHANGED
@@ -3,6 +3,10 @@
3
3
  const cheerio = require('cheerio');
4
4
  const utils = require('@iconify/utils');
5
5
 
6
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
7
+
8
+ const cheerio__default = /*#__PURE__*/_interopDefaultCompat(cheerio);
9
+
6
10
  class SVG {
7
11
  /**
8
12
  * Constructor
@@ -104,7 +108,7 @@ class SVG {
104
108
  );
105
109
  remove('xml:space="preserve"', "", "");
106
110
  content = content.replace(/<g>\s*<\/g>/g, "");
107
- this.$svg = cheerio.load(content.trim(), {
111
+ this.$svg = cheerio__default.load(content.trim(), {
108
112
  lowerCaseAttributeNames: false,
109
113
  xmlMode: true
110
114
  });