@iconify/tools 3.0.6 → 4.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 (77) hide show
  1. package/lib/colors/detect.cjs +1 -1
  2. package/lib/colors/detect.d.ts +1 -0
  3. package/lib/colors/detect.mjs +2 -2
  4. package/lib/colors/parse.cjs +131 -275
  5. package/lib/colors/parse.d.ts +8 -15
  6. package/lib/colors/parse.mjs +135 -278
  7. package/lib/colors/validate.cjs +2 -11
  8. package/lib/colors/validate.d.ts +5 -11
  9. package/lib/colors/validate.mjs +4 -12
  10. package/lib/export/directory.d.ts +1 -0
  11. package/lib/export/icon-package.d.ts +4 -1
  12. package/lib/export/json-package.cjs +1 -0
  13. package/lib/export/json-package.d.ts +2 -0
  14. package/lib/export/json-package.mjs +1 -0
  15. package/lib/icon-set/index.d.ts +1 -0
  16. package/lib/icon-set/match.d.ts +1 -0
  17. package/lib/icon-set/merge.d.ts +1 -0
  18. package/lib/icon-set/modified.d.ts +1 -0
  19. package/lib/icon-set/tags.d.ts +1 -0
  20. package/lib/import/directory.d.ts +1 -0
  21. package/lib/import/figma/index.d.ts +1 -0
  22. package/lib/import/figma/nodes.d.ts +1 -0
  23. package/lib/import/figma/query.d.ts +1 -0
  24. package/lib/import/figma/types/nodes.d.ts +1 -0
  25. package/lib/import/figma/types/options.d.ts +1 -0
  26. package/lib/import/figma/types/result.d.ts +1 -0
  27. package/lib/index.cjs +0 -6
  28. package/lib/index.d.ts +5 -5
  29. package/lib/index.mjs +4 -5
  30. package/lib/misc/cheerio.d.ts +4 -2
  31. package/lib/optimise/figma.d.ts +1 -0
  32. package/lib/optimise/flags.cjs +2 -2
  33. package/lib/optimise/flags.d.ts +2 -1
  34. package/lib/optimise/flags.mjs +2 -2
  35. package/lib/optimise/global-style.cjs +6 -6
  36. package/lib/optimise/global-style.d.ts +2 -1
  37. package/lib/optimise/global-style.mjs +6 -6
  38. package/lib/optimise/mask.cjs +10 -10
  39. package/lib/optimise/mask.d.ts +1 -0
  40. package/lib/optimise/mask.mjs +11 -11
  41. package/lib/optimise/origin.d.ts +1 -0
  42. package/lib/optimise/scale.d.ts +1 -0
  43. package/lib/optimise/svgo.cjs +1 -1
  44. package/lib/optimise/svgo.d.ts +1 -0
  45. package/lib/optimise/svgo.mjs +1 -1
  46. package/lib/svg/analyse/error.d.ts +2 -0
  47. package/lib/svg/analyse/types.d.ts +4 -1
  48. package/lib/svg/analyse.cjs +1 -1
  49. package/lib/svg/analyse.d.ts +2 -0
  50. package/lib/svg/analyse.mjs +3 -3
  51. package/lib/svg/cleanup/attribs.cjs +1 -1
  52. package/lib/svg/cleanup/attribs.d.ts +1 -0
  53. package/lib/svg/cleanup/attribs.mjs +2 -2
  54. package/lib/svg/cleanup/bad-tags.cjs +1 -1
  55. package/lib/svg/cleanup/bad-tags.d.ts +1 -0
  56. package/lib/svg/cleanup/bad-tags.mjs +2 -2
  57. package/lib/svg/cleanup/inline-style.cjs +1 -1
  58. package/lib/svg/cleanup/inline-style.d.ts +1 -0
  59. package/lib/svg/cleanup/inline-style.mjs +2 -2
  60. package/lib/svg/cleanup/root-style.cjs +1 -1
  61. package/lib/svg/cleanup/root-style.d.ts +1 -0
  62. package/lib/svg/cleanup/root-style.mjs +2 -2
  63. package/lib/svg/cleanup/root-svg.d.ts +1 -0
  64. package/lib/svg/cleanup/svgo-style.cjs +1 -1
  65. package/lib/svg/cleanup/svgo-style.d.ts +1 -0
  66. package/lib/svg/cleanup/svgo-style.mjs +2 -2
  67. package/lib/svg/cleanup.d.ts +1 -0
  68. package/lib/svg/index.cjs +13 -3
  69. package/lib/svg/index.d.ts +2 -1
  70. package/lib/svg/index.mjs +1 -1
  71. package/lib/svg/parse-style.cjs +178 -235
  72. package/lib/svg/parse-style.d.ts +4 -9
  73. package/lib/svg/parse-style.mjs +180 -236
  74. package/lib/svg/parse.cjs +26 -58
  75. package/lib/svg/parse.d.ts +4 -10
  76. package/lib/svg/parse.mjs +27 -58
  77. package/package.json +12 -10
@@ -3,6 +3,7 @@ import '@iconify/types';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import './types.js';
5
5
  import '../svg/index.js';
6
+ import 'cheerio';
6
7
  import '@iconify/utils/lib/icon-set/tree';
7
8
 
8
9
  /**
@@ -3,6 +3,7 @@ import '@iconify/types';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import './types.js';
5
5
  import '../svg/index.js';
6
+ import 'cheerio';
6
7
  import '@iconify/utils/lib/icon-set/tree';
7
8
 
8
9
  /**
@@ -3,6 +3,7 @@ import '@iconify/types';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import './types.js';
5
5
  import '../svg/index.js';
6
+ import 'cheerio';
6
7
  import '@iconify/utils/lib/icon-set/tree';
7
8
 
8
9
  declare const paletteTags: {
@@ -4,6 +4,7 @@ import '@iconify/types';
4
4
  import '@iconify/utils/lib/customisations/defaults';
5
5
  import '../icon-set/types.js';
6
6
  import '../svg/index.js';
7
+ import 'cheerio';
7
8
  import '@iconify/utils/lib/icon-set/tree';
8
9
  import '../svg/cleanup/bad-tags.js';
9
10
 
@@ -6,6 +6,7 @@ import '@iconify/types';
6
6
  import '@iconify/utils/lib/customisations/defaults';
7
7
  import '../../icon-set/types.js';
8
8
  import '../../svg/index.js';
9
+ import 'cheerio';
9
10
  import '@iconify/utils/lib/icon-set/tree';
10
11
  import './types/nodes.js';
11
12
  import './types/api.js';
@@ -6,6 +6,7 @@ import '@iconify/types';
6
6
  import '@iconify/utils/lib/customisations/defaults';
7
7
  import '../../icon-set/types.js';
8
8
  import '../../svg/index.js';
9
+ import 'cheerio';
9
10
  import '@iconify/utils/lib/icon-set/tree';
10
11
  import './types/nodes.js';
11
12
 
@@ -8,6 +8,7 @@ import '@iconify/types';
8
8
  import '@iconify/utils/lib/customisations/defaults';
9
9
  import '../../icon-set/types.js';
10
10
  import '../../svg/index.js';
11
+ import 'cheerio';
11
12
  import '@iconify/utils/lib/icon-set/tree';
12
13
  import './types/nodes.js';
13
14
 
@@ -5,6 +5,7 @@ import '@iconify/types';
5
5
  import '@iconify/utils/lib/customisations/defaults';
6
6
  import '../../../icon-set/types.js';
7
7
  import '../../../svg/index.js';
8
+ import 'cheerio';
8
9
  import '@iconify/utils/lib/icon-set/tree';
9
10
 
10
11
  type FigmaImportParentNodeType = 'CANVAS' | 'FRAME' | 'GROUP' | 'SECTION';
@@ -5,6 +5,7 @@ import '@iconify/types';
5
5
  import '@iconify/utils/lib/customisations/defaults';
6
6
  import '../../../icon-set/types.js';
7
7
  import '../../../svg/index.js';
8
+ import 'cheerio';
8
9
  import '@iconify/utils/lib/icon-set/tree';
9
10
  import './api.js';
10
11
 
@@ -3,6 +3,7 @@ import '@iconify/types';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import '../../../icon-set/types.js';
5
5
  import '../../../svg/index.js';
6
+ import 'cheerio';
6
7
  import '@iconify/utils/lib/icon-set/tree';
7
8
 
8
9
  /**
package/lib/index.cjs CHANGED
@@ -39,7 +39,6 @@ const optimise_mask = require('./optimise/mask.cjs');
39
39
  const optimise_scale = require('./optimise/scale.cjs');
40
40
  const optimise_globalStyle = require('./optimise/global-style.cjs');
41
41
  const export_directory = require('./export/directory.cjs');
42
- const export_iconPackage = require('./export/icon-package.cjs');
43
42
  const export_jsonPackage = require('./export/json-package.cjs');
44
43
  const misc_writeJson = require('./misc/write-json.cjs');
45
44
  const export_helpers_prepare = require('./export/helpers/prepare.cjs');
@@ -94,9 +93,7 @@ require('./export/helpers/custom-files.cjs');
94
93
 
95
94
  exports.SVG = svg_index.SVG;
96
95
  exports.parseSVG = svg_parse.parseSVG;
97
- exports.parseSVGSync = svg_parse.parseSVGSync;
98
96
  exports.parseSVGStyle = svg_parseStyle.parseSVGStyle;
99
- exports.parseSVGStyleSync = svg_parseStyle.parseSVGStyleSync;
100
97
  exports.analyseSVGStructure = svg_analyse.analyseSVGStructure;
101
98
  exports.cleanupSVG = svg_cleanup.cleanupSVG;
102
99
  exports.removeBadAttributes = svg_cleanup_attribs.removeBadAttributes;
@@ -127,9 +124,7 @@ exports.downloadPackage = download_index.downloadPackage;
127
124
  exports.downloadFile = download_api_download.downloadFile;
128
125
  exports.isEmptyColor = colors_parse.isEmptyColor;
129
126
  exports.parseColors = colors_parse.parseColors;
130
- exports.parseColorsSync = colors_parse.parseColorsSync;
131
127
  exports.validateColors = colors_validate.validateColors;
132
- exports.validateColorsSync = colors_validate.validateColorsSync;
133
128
  exports.detectIconSetPalette = colors_detect.detectIconSetPalette;
134
129
  exports.runSVGO = optimise_svgo.runSVGO;
135
130
  exports.removeFigmaClipPathFromSVG = optimise_figma.removeFigmaClipPathFromSVG;
@@ -139,7 +134,6 @@ exports.convertSVGToMask = optimise_mask.convertSVGToMask;
139
134
  exports.scaleSVG = optimise_scale.scaleSVG;
140
135
  exports.cleanupGlobalStyle = optimise_globalStyle.cleanupGlobalStyle;
141
136
  exports.exportToDirectory = export_directory.exportToDirectory;
142
- exports.exportIconPackage = export_iconPackage.exportIconPackage;
143
137
  exports.exportJSONPackage = export_jsonPackage.exportJSONPackage;
144
138
  exports.writeJSONFile = misc_writeJson.writeJSONFile;
145
139
  exports.prepareDirectoryForExport = export_helpers_prepare.prepareDirectoryForExport;
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { SVG } from './svg/index.js';
2
- export { parseSVG, parseSVGSync } from './svg/parse.js';
3
- export { parseSVGStyle, parseSVGStyleSync } from './svg/parse-style.js';
2
+ export { parseSVG } from './svg/parse.js';
3
+ export { parseSVGStyle } from './svg/parse-style.js';
4
4
  export { analyseSVGStructure } from './svg/analyse.js';
5
5
  export { cleanupSVG } from './svg/cleanup.js';
6
6
  export { removeBadAttributes } from './svg/cleanup/attribs.js';
@@ -26,8 +26,8 @@ export { downloadNPMPackage } from './download/npm/index.js';
26
26
  export { getNPMVersion, getPackageVersion } from './download/npm/version.js';
27
27
  export { downloadPackage } from './download/index.js';
28
28
  export { downloadFile } from './download/api/download.js';
29
- export { isEmptyColor, parseColors, parseColorsSync } from './colors/parse.js';
30
- export { validateColors, validateColorsSync } from './colors/validate.js';
29
+ export { isEmptyColor, parseColors } from './colors/parse.js';
30
+ export { validateColors } from './colors/validate.js';
31
31
  export { detectIconSetPalette } from './colors/detect.js';
32
32
  export { runSVGO } from './optimise/svgo.js';
33
33
  export { removeFigmaClipPathFromSVG } from './optimise/figma.js';
@@ -37,7 +37,6 @@ export { convertSVGToMask } from './optimise/mask.js';
37
37
  export { scaleSVG } from './optimise/scale.js';
38
38
  export { cleanupGlobalStyle } from './optimise/global-style.js';
39
39
  export { exportToDirectory } from './export/directory.js';
40
- export { exportIconPackage } from './export/icon-package.js';
41
40
  export { exportJSONPackage } from './export/json-package.js';
42
41
  export { writeJSONFile } from './misc/write-json.js';
43
42
  export { prepareDirectoryForExport } from './export/helpers/prepare.js';
@@ -49,6 +48,7 @@ export { execAsync } from './misc/exec.js';
49
48
  export { cleanupIconKeyword } from './misc/keyword.js';
50
49
  export { bumpVersion } from './misc/bump-version.js';
51
50
  export { sendAPIQuery } from './download/api/index.js';
51
+ import 'cheerio';
52
52
  import '@iconify/types';
53
53
  import '@iconify/utils/lib/customisations/defaults';
54
54
  import './misc/cheerio.js';
package/lib/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  export { SVG } from './svg/index.mjs';
2
- export { parseSVG, parseSVGSync } from './svg/parse.mjs';
3
- export { parseSVGStyle, parseSVGStyleSync } from './svg/parse-style.mjs';
2
+ export { parseSVG } from './svg/parse.mjs';
3
+ export { parseSVGStyle } from './svg/parse-style.mjs';
4
4
  export { analyseSVGStructure } from './svg/analyse.mjs';
5
5
  export { cleanupSVG } from './svg/cleanup.mjs';
6
6
  export { removeBadAttributes } from './svg/cleanup/attribs.mjs';
@@ -26,8 +26,8 @@ export { downloadNPMPackage } from './download/npm/index.mjs';
26
26
  export { getNPMVersion, getPackageVersion } from './download/npm/version.mjs';
27
27
  export { downloadPackage } from './download/index.mjs';
28
28
  export { downloadFile } from './download/api/download.mjs';
29
- export { isEmptyColor, parseColors, parseColorsSync } from './colors/parse.mjs';
30
- export { validateColors, validateColorsSync } from './colors/validate.mjs';
29
+ export { isEmptyColor, parseColors } from './colors/parse.mjs';
30
+ export { validateColors } from './colors/validate.mjs';
31
31
  export { detectIconSetPalette } from './colors/detect.mjs';
32
32
  export { runSVGO } from './optimise/svgo.mjs';
33
33
  export { removeFigmaClipPathFromSVG } from './optimise/figma.mjs';
@@ -37,7 +37,6 @@ export { convertSVGToMask } from './optimise/mask.mjs';
37
37
  export { scaleSVG } from './optimise/scale.mjs';
38
38
  export { cleanupGlobalStyle } from './optimise/global-style.mjs';
39
39
  export { exportToDirectory } from './export/directory.mjs';
40
- export { exportIconPackage } from './export/icon-package.mjs';
41
40
  export { exportJSONPackage } from './export/json-package.mjs';
42
41
  export { writeJSONFile } from './misc/write-json.mjs';
43
42
  export { prepareDirectoryForExport } from './export/helpers/prepare.mjs';
@@ -1,7 +1,9 @@
1
+ import * as cheerio from 'cheerio';
2
+
1
3
  /**
2
4
  * Shortcuts for Cheerio elements
3
5
  */
4
- type CheerioElement = cheerio.TagElement;
5
- type WrappedCheerioElement = cheerio.Cheerio;
6
+ type CheerioElement = cheerio.Element;
7
+ type WrappedCheerioElement = cheerio.Cheerio<cheerio.Element>;
6
8
 
7
9
  export { CheerioElement, WrappedCheerioElement };
@@ -1,4 +1,5 @@
1
1
  import { SVG } from '../svg/index.js';
2
+ import 'cheerio';
2
3
  import '@iconify/types';
3
4
  import '@iconify/utils/lib/customisations/defaults';
4
5
 
@@ -235,8 +235,8 @@ function cleanPath(path) {
235
235
  });
236
236
  return output;
237
237
  }
238
- async function deOptimisePaths(svg) {
239
- await svg_parse.parseSVG(svg, (item) => {
238
+ function deOptimisePaths(svg) {
239
+ svg_parse.parseSVG(svg, (item) => {
240
240
  if (item.tagName !== "path") {
241
241
  return;
242
242
  }
@@ -1,10 +1,11 @@
1
1
  import { SVG } from '../svg/index.js';
2
+ import 'cheerio';
2
3
  import '@iconify/types';
3
4
  import '@iconify/utils/lib/customisations/defaults';
4
5
 
5
6
  /**
6
7
  * De-optimise paths. Compressed paths are still not supported by some software.
7
8
  */
8
- declare function deOptimisePaths(svg: SVG): Promise<void>;
9
+ declare function deOptimisePaths(svg: SVG): void;
9
10
 
10
11
  export { deOptimisePaths };
@@ -233,8 +233,8 @@ function cleanPath(path) {
233
233
  });
234
234
  return output;
235
235
  }
236
- async function deOptimisePaths(svg) {
237
- await parseSVG(svg, (item) => {
236
+ function deOptimisePaths(svg) {
237
+ parseSVG(svg, (item) => {
238
238
  if (item.tagName !== "path") {
239
239
  return;
240
240
  }
@@ -15,11 +15,11 @@ function getClassList(value) {
15
15
  return value?.split(/\s+/);
16
16
  }
17
17
  const tempDataAttrbiute = "data-gstyle-temp";
18
- async function cleanupGlobalStyle(svg) {
18
+ function cleanupGlobalStyle(svg) {
19
19
  const backup = svg.toString();
20
20
  let containsTempAttr = false;
21
21
  const animatedClasses = /* @__PURE__ */ new Set();
22
- await svg_parse.parseSVG(svg, (item) => {
22
+ svg_parse.parseSVG(svg, (item) => {
23
23
  if (!svg_data_tags.animateTags.has(item.tagName)) {
24
24
  return;
25
25
  }
@@ -41,7 +41,7 @@ async function cleanupGlobalStyle(svg) {
41
41
  });
42
42
  const removeClasses = /* @__PURE__ */ new Set();
43
43
  try {
44
- await svg_parseStyle.parseSVGStyle(svg, async (styleItem) => {
44
+ svg_parseStyle.parseSVGStyle(svg, (styleItem) => {
45
45
  const returnValue = styleItem.value;
46
46
  if (styleItem.type !== "global") {
47
47
  return returnValue;
@@ -101,7 +101,7 @@ async function cleanupGlobalStyle(svg) {
101
101
  }
102
102
  return false;
103
103
  };
104
- await svg_parse.parseSVG(svg, (svgItem) => {
104
+ svg_parse.parseSVG(svg, (svgItem) => {
105
105
  const tagName = svgItem.tagName;
106
106
  const $element = svgItem.$element;
107
107
  if (!isMatch(tagName, $element)) {
@@ -130,7 +130,7 @@ async function cleanupGlobalStyle(svg) {
130
130
  }
131
131
  });
132
132
  });
133
- await svg_parse.parseSVG(svg, (svgItem) => {
133
+ svg_parse.parseSVG(svg, (svgItem) => {
134
134
  const $element = svgItem.$element;
135
135
  const classList = getClassList($element.attr("class"));
136
136
  if (!classList) {
@@ -146,7 +146,7 @@ async function cleanupGlobalStyle(svg) {
146
146
  }
147
147
  });
148
148
  if (containsTempAttr) {
149
- await svg_parse.parseSVG(svg, (item) => {
149
+ svg_parse.parseSVG(svg, (item) => {
150
150
  item.$element.removeAttr(tempDataAttrbiute);
151
151
  });
152
152
  }
@@ -1,10 +1,11 @@
1
1
  import { SVG } from '../svg/index.js';
2
+ import 'cheerio';
2
3
  import '@iconify/types';
3
4
  import '@iconify/utils/lib/customisations/defaults';
4
5
 
5
6
  /**
6
7
  * Expand global style
7
8
  */
8
- declare function cleanupGlobalStyle(svg: SVG): Promise<void>;
9
+ declare function cleanupGlobalStyle(svg: SVG): void;
9
10
 
10
11
  export { cleanupGlobalStyle };
@@ -13,11 +13,11 @@ function getClassList(value) {
13
13
  return value?.split(/\s+/);
14
14
  }
15
15
  const tempDataAttrbiute = "data-gstyle-temp";
16
- async function cleanupGlobalStyle(svg) {
16
+ function cleanupGlobalStyle(svg) {
17
17
  const backup = svg.toString();
18
18
  let containsTempAttr = false;
19
19
  const animatedClasses = /* @__PURE__ */ new Set();
20
- await parseSVG(svg, (item) => {
20
+ parseSVG(svg, (item) => {
21
21
  if (!animateTags.has(item.tagName)) {
22
22
  return;
23
23
  }
@@ -39,7 +39,7 @@ async function cleanupGlobalStyle(svg) {
39
39
  });
40
40
  const removeClasses = /* @__PURE__ */ new Set();
41
41
  try {
42
- await parseSVGStyle(svg, async (styleItem) => {
42
+ parseSVGStyle(svg, (styleItem) => {
43
43
  const returnValue = styleItem.value;
44
44
  if (styleItem.type !== "global") {
45
45
  return returnValue;
@@ -99,7 +99,7 @@ async function cleanupGlobalStyle(svg) {
99
99
  }
100
100
  return false;
101
101
  };
102
- await parseSVG(svg, (svgItem) => {
102
+ parseSVG(svg, (svgItem) => {
103
103
  const tagName = svgItem.tagName;
104
104
  const $element = svgItem.$element;
105
105
  if (!isMatch(tagName, $element)) {
@@ -128,7 +128,7 @@ async function cleanupGlobalStyle(svg) {
128
128
  }
129
129
  });
130
130
  });
131
- await parseSVG(svg, (svgItem) => {
131
+ parseSVG(svg, (svgItem) => {
132
132
  const $element = svgItem.$element;
133
133
  const classList = getClassList($element.attr("class"));
134
134
  if (!classList) {
@@ -144,7 +144,7 @@ async function cleanupGlobalStyle(svg) {
144
144
  }
145
145
  });
146
146
  if (containsTempAttr) {
147
- await parseSVG(svg, (item) => {
147
+ parseSVG(svg, (item) => {
148
148
  item.$element.removeAttr(tempDataAttrbiute);
149
149
  });
150
150
  }
@@ -46,21 +46,13 @@ function convertSVGToMask(svg, options = {}) {
46
46
  let failed = false;
47
47
  let hasCustomValue = false;
48
48
  const backup = svg.toString();
49
- colors_parse.parseColorsSync(svg, {
49
+ colors_parse.parseColors(svg, {
50
50
  callback: (attr, colorStr, color) => {
51
51
  if (!color || colors_parse.isEmptyColor(color)) {
52
52
  return colorStr;
53
53
  }
54
- if (check(props.solid, colorStr, color)) {
55
- foundSolid = true;
56
- return "#fff";
57
- }
58
- if (check(props.transparent, colorStr, color)) {
59
- foundTransparent = true;
60
- return "#000";
61
- }
62
54
  if (props.custom) {
63
- let customValue = props.custom(colorStr, color);
55
+ let customValue = props.custom(colorStr.toLowerCase(), color);
64
56
  if (typeof customValue === "number") {
65
57
  const num = Math.max(
66
58
  Math.min(Math.round(customValue * 255), 255),
@@ -86,6 +78,14 @@ function convertSVGToMask(svg, options = {}) {
86
78
  return customValue;
87
79
  }
88
80
  }
81
+ if (check(props.solid, colorStr, color)) {
82
+ foundSolid = true;
83
+ return "#fff";
84
+ }
85
+ if (check(props.transparent, colorStr, color)) {
86
+ foundTransparent = true;
87
+ return "#000";
88
+ }
89
89
  failed = true;
90
90
  console.warn("Unexpected color:", colorStr);
91
91
  return color;
@@ -1,5 +1,6 @@
1
1
  import { Color } from '@iconify/utils/lib/colors/types';
2
2
  import { SVG } from '../svg/index.js';
3
+ import 'cheerio';
3
4
  import '@iconify/types';
4
5
  import '@iconify/utils/lib/customisations/defaults';
5
6
 
@@ -1,4 +1,4 @@
1
- import { parseColorsSync, isEmptyColor } from '../colors/parse.mjs';
1
+ import { parseColors, isEmptyColor } from '../colors/parse.mjs';
2
2
  import { parseSVGContent, splitSVGDefs, iconToHTML } from '@iconify/utils';
3
3
  import '@iconify/utils/lib/colors';
4
4
  import '../svg/data/tags.mjs';
@@ -44,21 +44,13 @@ function convertSVGToMask(svg, options = {}) {
44
44
  let failed = false;
45
45
  let hasCustomValue = false;
46
46
  const backup = svg.toString();
47
- parseColorsSync(svg, {
47
+ parseColors(svg, {
48
48
  callback: (attr, colorStr, color) => {
49
49
  if (!color || isEmptyColor(color)) {
50
50
  return colorStr;
51
51
  }
52
- if (check(props.solid, colorStr, color)) {
53
- foundSolid = true;
54
- return "#fff";
55
- }
56
- if (check(props.transparent, colorStr, color)) {
57
- foundTransparent = true;
58
- return "#000";
59
- }
60
52
  if (props.custom) {
61
- let customValue = props.custom(colorStr, color);
53
+ let customValue = props.custom(colorStr.toLowerCase(), color);
62
54
  if (typeof customValue === "number") {
63
55
  const num = Math.max(
64
56
  Math.min(Math.round(customValue * 255), 255),
@@ -84,6 +76,14 @@ function convertSVGToMask(svg, options = {}) {
84
76
  return customValue;
85
77
  }
86
78
  }
79
+ if (check(props.solid, colorStr, color)) {
80
+ foundSolid = true;
81
+ return "#fff";
82
+ }
83
+ if (check(props.transparent, colorStr, color)) {
84
+ foundTransparent = true;
85
+ return "#000";
86
+ }
87
87
  failed = true;
88
88
  console.warn("Unexpected color:", colorStr);
89
89
  return color;
@@ -1,4 +1,5 @@
1
1
  import { SVG } from '../svg/index.js';
2
+ import 'cheerio';
2
3
  import '@iconify/types';
3
4
  import '@iconify/utils/lib/customisations/defaults';
4
5
 
@@ -1,4 +1,5 @@
1
1
  import { SVG } from '../svg/index.js';
2
+ import 'cheerio';
2
3
  import '@iconify/types';
3
4
  import '@iconify/utils/lib/customisations/defaults';
4
5
 
@@ -30,7 +30,7 @@ function getSVGOPlugins(options) {
30
30
  ...options.animated ? [] : ["removeUselessStrokeAndFill"],
31
31
  // Plugins that modify shapes or are bugged when using animations
32
32
  ...options.animated || options.keepShapes ? [] : [
33
- "removeHiddenElems",
33
+ // 'removeHiddenElems', // bugged: not working before 3.0.4, created broken icons since 3.0.4
34
34
  "convertShapeToPath",
35
35
  "convertEllipseToCircle",
36
36
  {
@@ -1,5 +1,6 @@
1
1
  import { PluginConfig } from 'svgo';
2
2
  import { SVG } from '../svg/index.js';
3
+ import 'cheerio';
3
4
  import '@iconify/types';
4
5
  import '@iconify/utils/lib/customisations/defaults';
5
6
 
@@ -28,7 +28,7 @@ function getSVGOPlugins(options) {
28
28
  ...options.animated ? [] : ["removeUselessStrokeAndFill"],
29
29
  // Plugins that modify shapes or are bugged when using animations
30
30
  ...options.animated || options.keepShapes ? [] : [
31
- "removeHiddenElems",
31
+ // 'removeHiddenElems', // bugged: not working before 3.0.4, created broken icons since 3.0.4
32
32
  "convertShapeToPath",
33
33
  "convertEllipseToCircle",
34
34
  {
@@ -1,4 +1,6 @@
1
1
  import { ExtendedTagElement } from './types.js';
2
+ import '../../misc/cheerio.js';
3
+ import 'cheerio';
2
4
 
3
5
  /**
4
6
  * Get tag for error message
@@ -1,3 +1,6 @@
1
+ import { CheerioElement } from '../../misc/cheerio.js';
2
+ import 'cheerio';
3
+
1
4
  /**
2
5
  * Options
3
6
  */
@@ -50,7 +53,7 @@ interface ExtendedTagElementRelations {
50
53
  /**
51
54
  * Extended tag
52
55
  */
53
- interface ExtendedTagElement extends cheerio.TagElement, ExtendedTagElementUses, ExtendedTagElementRelations {
56
+ interface ExtendedTagElement extends CheerioElement, ExtendedTagElementUses, ExtendedTagElementRelations {
54
57
  _index: number;
55
58
  _id?: string;
56
59
  _belongsTo?: ElementWithID[];
@@ -83,7 +83,7 @@ function analyseSVGStructure(svg, options = {}) {
83
83
  element._linksTo.push(link);
84
84
  }
85
85
  let index = 0;
86
- svg_parse.parseSVGSync(svg, (item) => {
86
+ svg_parse.parseSVG(svg, (item) => {
87
87
  const { tagName, parents } = item;
88
88
  if (svg_data_tags.styleTag.has(tagName)) {
89
89
  item.testChildren = false;
@@ -1,7 +1,9 @@
1
1
  import { SVG } from './index.js';
2
2
  import { AnalyseSVGStructureOptions, AnalyseSVGStructureResult } from './analyse/types.js';
3
+ import 'cheerio';
3
4
  import '@iconify/types';
4
5
  import '@iconify/utils/lib/customisations/defaults';
6
+ import '../misc/cheerio.js';
5
7
 
6
8
  /**
7
9
  * Find all IDs, links, which elements use palette, which items aren't used
@@ -1,6 +1,6 @@
1
- import { parseSVGSync } from './parse.mjs';
1
+ import { parseSVG } from './parse.mjs';
2
2
  import { tagSpecificNonPresentationalAttributes, urlPresentationalAttributes, commonColorPresentationalAttributes, markerAttributes } from './data/attributes.mjs';
3
- import { useTag, styleTag, maskTags, reusableElementsWithPalette, defsTag } from './data/tags.mjs';
3
+ import { styleTag, maskTags, reusableElementsWithPalette, defsTag, useTag } from './data/tags.mjs';
4
4
  import { analyseTagError } from './analyse/error.mjs';
5
5
 
6
6
  function analyseSVGStructure(svg, options = {}) {
@@ -81,7 +81,7 @@ function analyseSVGStructure(svg, options = {}) {
81
81
  element._linksTo.push(link);
82
82
  }
83
83
  let index = 0;
84
- parseSVGSync(svg, (item) => {
84
+ parseSVG(svg, (item) => {
85
85
  const { tagName, parents } = item;
86
86
  if (styleTag.has(tagName)) {
87
87
  item.testChildren = false;
@@ -5,7 +5,7 @@ const svg_data_tags = require('../data/tags.cjs');
5
5
  const svg_parse = require('../parse.cjs');
6
6
 
7
7
  function removeBadAttributes(svg) {
8
- svg_parse.parseSVGSync(svg, (item) => {
8
+ svg_parse.parseSVG(svg, (item) => {
9
9
  const tagName = item.tagName;
10
10
  const attribs = item.element.attribs;
11
11
  const $element = item.$element;
@@ -1,4 +1,5 @@
1
1
  import { SVG } from '../index.js';
2
+ import 'cheerio';
2
3
  import '@iconify/types';
3
4
  import '@iconify/utils/lib/customisations/defaults';
4
5
 
@@ -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 { parseSVGSync } from '../parse.mjs';
3
+ import { parseSVG } from '../parse.mjs';
4
4
 
5
5
  function removeBadAttributes(svg) {
6
- parseSVGSync(svg, (item) => {
6
+ parseSVG(svg, (item) => {
7
7
  const tagName = item.tagName;
8
8
  const attribs = item.element.attribs;
9
9
  const $element = item.$element;
@@ -21,7 +21,7 @@ function checkBadTags(svg, options) {
21
21
  ...defaultOptions,
22
22
  ...options
23
23
  };
24
- svg_parse.parseSVGSync(svg, (item) => {
24
+ svg_parse.parseSVG(svg, (item) => {
25
25
  const tagName = item.tagName;
26
26
  const $element = item.$element;
27
27
  if (tagName === "svg") {
@@ -1,4 +1,5 @@
1
1
  import { SVG } from '../index.js';
2
+ import 'cheerio';
2
3
  import '@iconify/types';
3
4
  import '@iconify/utils/lib/customisations/defaults';
4
5
 
@@ -1,4 +1,4 @@
1
- import { parseSVGSync } from '../parse.mjs';
1
+ import { parseSVG } 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();
@@ -19,7 +19,7 @@ function checkBadTags(svg, options) {
19
19
  ...defaultOptions,
20
20
  ...options
21
21
  };
22
- parseSVGSync(svg, (item) => {
22
+ parseSVG(svg, (item) => {
23
23
  const tagName = item.tagName;
24
24
  const $element = item.$element;
25
25
  if (tagName === "svg") {
@@ -32,7 +32,7 @@ const knownIgnoredRules = /* @__PURE__ */ new Set([
32
32
  "stop-opacity"
33
33
  ]);
34
34
  function cleanupInlineStyle(svg) {
35
- svg_parse.parseSVGSync(svg, (item) => {
35
+ svg_parse.parseSVG(svg, (item) => {
36
36
  const $element = item.$element;
37
37
  const attribs = item.element.attribs;
38
38
  const tagName = item.tagName;
@@ -1,4 +1,5 @@
1
1
  import { SVG } from '../index.js';
2
+ import 'cheerio';
2
3
  import '@iconify/types';
3
4
  import '@iconify/utils/lib/customisations/defaults';
4
5