@iconify/tools 2.1.0-beta.5 → 2.1.0

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 (62) hide show
  1. package/lib/colors/attribs.cjs +5 -0
  2. package/lib/colors/attribs.d.ts +9 -1
  3. package/lib/colors/attribs.mjs +5 -1
  4. package/lib/colors/parse.cjs +7 -1
  5. package/lib/colors/parse.d.ts +1 -1
  6. package/lib/colors/parse.mjs +8 -2
  7. package/lib/colors/validate.d.ts +1 -1
  8. package/lib/export/directory.d.ts +1 -1
  9. package/lib/export/icon-package.d.ts +1 -1
  10. package/lib/export/json-package.d.ts +1 -1
  11. package/lib/icon-set/index.d.ts +1 -1
  12. package/lib/icon-set/match.d.ts +1 -1
  13. package/lib/icon-set/merge.d.ts +1 -1
  14. package/lib/icon-set/modified.d.ts +1 -1
  15. package/lib/icon-set/props.d.ts +1 -1
  16. package/lib/icon-set/types.d.ts +1 -1
  17. package/lib/import/directory.cjs +3 -2
  18. package/lib/import/directory.d.ts +1 -1
  19. package/lib/import/directory.mjs +3 -2
  20. package/lib/import/figma/index.cjs +3 -2
  21. package/lib/import/figma/index.d.ts +1 -1
  22. package/lib/import/figma/index.mjs +3 -2
  23. package/lib/import/figma/nodes.d.ts +1 -1
  24. package/lib/import/figma/query.d.ts +1 -1
  25. package/lib/import/figma/types/nodes.d.ts +1 -1
  26. package/lib/import/figma/types/options.d.ts +1 -1
  27. package/lib/import/figma/types/result.d.ts +1 -1
  28. package/lib/index.cjs +2 -0
  29. package/lib/index.d.ts +2 -1
  30. package/lib/index.mjs +1 -0
  31. package/lib/misc/keyword.cjs +1 -1
  32. package/lib/misc/keyword.mjs +1 -1
  33. package/lib/optimise/flags.d.ts +1 -1
  34. package/lib/optimise/global-style.d.ts +1 -1
  35. package/lib/optimise/scale.d.ts +1 -1
  36. package/lib/optimise/svgo.d.ts +1 -1
  37. package/lib/svg/analyse.d.ts +1 -1
  38. package/lib/svg/cleanup/attribs.d.ts +1 -1
  39. package/lib/svg/cleanup/bad-tags.d.ts +1 -1
  40. package/lib/svg/cleanup/inline-style.cjs +4 -0
  41. package/lib/svg/cleanup/inline-style.d.ts +1 -1
  42. package/lib/svg/cleanup/inline-style.mjs +5 -1
  43. package/lib/svg/cleanup/root-style.cjs +24 -0
  44. package/lib/svg/cleanup/root-style.d.ts +16 -0
  45. package/lib/svg/cleanup/root-style.mjs +20 -0
  46. package/lib/svg/cleanup/root-svg.cjs +2 -2
  47. package/lib/svg/cleanup/root-svg.d.ts +2 -2
  48. package/lib/svg/cleanup/root-svg.mjs +2 -2
  49. package/lib/svg/cleanup/svgo-style.d.ts +1 -1
  50. package/lib/svg/cleanup.cjs +3 -1
  51. package/lib/svg/cleanup.d.ts +1 -1
  52. package/lib/svg/cleanup.mjs +3 -1
  53. package/lib/svg/data/attributes.cjs +4 -0
  54. package/lib/svg/data/attributes.d.ts +5 -1
  55. package/lib/svg/data/attributes.mjs +4 -1
  56. package/lib/svg/index.d.ts +2 -2
  57. package/lib/svg/parse-style.cjs +1 -1
  58. package/lib/svg/parse-style.d.ts +1 -1
  59. package/lib/svg/parse-style.mjs +1 -1
  60. package/lib/svg/parse.d.ts +1 -1
  61. package/lib/{types-f0980297.d.ts → types-6360d61e.d.ts} +3 -0
  62. package/package.json +8 -4
@@ -22,7 +22,12 @@ const defaultColorValues = {
22
22
  "stop-color": defaultBlackColor,
23
23
  "flood-color": defaultBlackColor
24
24
  };
25
+ const allowDefaultColorValue = {
26
+ "stop-color": true,
27
+ "flood-color": "flood-opacity"
28
+ };
25
29
 
30
+ exports.allowDefaultColorValue = allowDefaultColorValue;
26
31
  exports.commonColorAttributes = commonColorAttributes;
27
32
  exports.defaultBlackColor = defaultBlackColor;
28
33
  exports.defaultColorValues = defaultColorValues;
@@ -15,5 +15,13 @@ declare type ColorAttributes = CommonColorAttributes | ShapeColorAttributes | Sp
15
15
  */
16
16
  declare const defaultBlackColor: Color;
17
17
  declare const defaultColorValues: Record<ColorAttributes, Color>;
18
+ /**
19
+ * Ignore default color for some tags:
20
+ * - If value is true, allow default color
21
+ * - If value is attribute name, allow default color if attribute is set
22
+ *
23
+ * Parent elements are not checked for these tags!
24
+ */
25
+ declare const allowDefaultColorValue: Partial<Record<ColorAttributes, string | true>>;
18
26
 
19
- export { ColorAttributes, CommonColorAttributes, ShapeColorAttributes, SpecialColorAttributes, commonColorAttributes, defaultBlackColor, defaultColorValues, shapeColorAttributes, specialColorAttributes };
27
+ export { ColorAttributes, CommonColorAttributes, ShapeColorAttributes, SpecialColorAttributes, allowDefaultColorValue, commonColorAttributes, defaultBlackColor, defaultColorValues, shapeColorAttributes, specialColorAttributes };
@@ -18,5 +18,9 @@ const defaultColorValues = {
18
18
  "stop-color": defaultBlackColor,
19
19
  "flood-color": defaultBlackColor
20
20
  };
21
+ const allowDefaultColorValue = {
22
+ "stop-color": true,
23
+ "flood-color": "flood-opacity"
24
+ };
21
25
 
22
- export { commonColorAttributes, defaultBlackColor, defaultColorValues, shapeColorAttributes, specialColorAttributes };
26
+ export { allowDefaultColorValue, commonColorAttributes, defaultBlackColor, defaultColorValues, shapeColorAttributes, specialColorAttributes };
@@ -54,12 +54,18 @@ async function parseColors(svg, options = {}) {
54
54
  function getElementColor(prop, item, elements2) {
55
55
  function find(prop2) {
56
56
  let currentItem = item;
57
+ const allowDefaultColor = colors_attribs.allowDefaultColorValue[prop2];
57
58
  while (currentItem) {
58
59
  const element = elements2.get(currentItem.index);
59
60
  const color = element._colors?.[prop2];
60
61
  if (color !== void 0) {
61
62
  return color;
62
63
  }
64
+ if (allowDefaultColor) {
65
+ if (allowDefaultColor === true || element.attribs[allowDefaultColor]) {
66
+ return null;
67
+ }
68
+ }
63
69
  currentItem = currentItem.parent;
64
70
  if (currentItem?.usedAsMask) {
65
71
  return colors_attribs.defaultColorValues[prop2];
@@ -68,7 +74,7 @@ async function parseColors(svg, options = {}) {
68
74
  return colors_attribs.defaultColorValues[prop2];
69
75
  }
70
76
  let propColor = find(prop);
71
- if (typeof propColor === "object" && propColor.type === "current" && prop !== "color") {
77
+ if (propColor !== null && typeof propColor === "object" && propColor.type === "current" && prop !== "color") {
72
78
  propColor = find("color");
73
79
  }
74
80
  return propColor;
@@ -2,7 +2,7 @@ import { Color } from '@iconify/utils/lib/colors/types';
2
2
  import { SVG } from '../svg/index.js';
3
3
  import { ColorAttributes } from './attribs.js';
4
4
  import { ElementsTreeItem, AnalyseSVGStructureResult, AnalyseSVGStructureOptions, ExtendedTagElement } from '../svg/analyse/types.js';
5
- import '../types-f0980297.js';
5
+ import '../types-6360d61e.js';
6
6
  import '@iconify/utils/lib/customisations/defaults';
7
7
 
8
8
  /**
@@ -1,7 +1,7 @@
1
1
  import { stringToColor, colorToString, compareColors } from '@iconify/utils/lib/colors';
2
2
  import { animateTags, shapeTags } from '../svg/data/tags.mjs';
3
3
  import { parseSVGStyle } from '../svg/parse-style.mjs';
4
- import { specialColorAttributes, defaultBlackColor, defaultColorValues, shapeColorAttributes } from './attribs.mjs';
4
+ import { specialColorAttributes, defaultBlackColor, defaultColorValues, shapeColorAttributes, allowDefaultColorValue } from './attribs.mjs';
5
5
  import { tagSpecificPresentationalAttributes } from '../svg/data/attributes.mjs';
6
6
  import { analyseSVGStructure } from '../svg/analyse.mjs';
7
7
  import '../css/parse.mjs';
@@ -50,12 +50,18 @@ async function parseColors(svg, options = {}) {
50
50
  function getElementColor(prop, item, elements2) {
51
51
  function find(prop2) {
52
52
  let currentItem = item;
53
+ const allowDefaultColor = allowDefaultColorValue[prop2];
53
54
  while (currentItem) {
54
55
  const element = elements2.get(currentItem.index);
55
56
  const color = element._colors?.[prop2];
56
57
  if (color !== void 0) {
57
58
  return color;
58
59
  }
60
+ if (allowDefaultColor) {
61
+ if (allowDefaultColor === true || element.attribs[allowDefaultColor]) {
62
+ return null;
63
+ }
64
+ }
59
65
  currentItem = currentItem.parent;
60
66
  if (currentItem?.usedAsMask) {
61
67
  return defaultColorValues[prop2];
@@ -64,7 +70,7 @@ async function parseColors(svg, options = {}) {
64
70
  return defaultColorValues[prop2];
65
71
  }
66
72
  let propColor = find(prop);
67
- if (typeof propColor === "object" && propColor.type === "current" && prop !== "color") {
73
+ if (propColor !== null && typeof propColor === "object" && propColor.type === "current" && prop !== "color") {
68
74
  propColor = find("color");
69
75
  }
70
76
  return propColor;
@@ -1,6 +1,6 @@
1
1
  import { SVG } from '../svg/index.js';
2
2
  import { ParseColorsOptions, FindColorsResult } from './parse.js';
3
- import '../types-f0980297.js';
3
+ import '../types-6360d61e.js';
4
4
  import '@iconify/utils/lib/customisations/defaults';
5
5
  import '@iconify/utils/lib/colors/types';
6
6
  import './attribs.js';
@@ -1,6 +1,6 @@
1
1
  import { IconSet } from '../icon-set/index.js';
2
2
  import { ExportTargetOptions } from './helpers/prepare.js';
3
- import '../types-f0980297.js';
3
+ import '../types-6360d61e.js';
4
4
  import '@iconify/utils/lib/customisations/defaults';
5
5
  import '../icon-set/types.js';
6
6
  import '../svg/index.js';
@@ -1,7 +1,7 @@
1
1
  import { IconSet } from '../icon-set/index.js';
2
2
  import { ExportTargetOptions } from './helpers/prepare.js';
3
3
  import { ExportOptionsWithCustomFiles } from './helpers/custom-files.js';
4
- import '../types-f0980297.js';
4
+ import '../types-6360d61e.js';
5
5
  import '@iconify/utils/lib/customisations/defaults';
6
6
  import '../icon-set/types.js';
7
7
  import '../svg/index.js';
@@ -1,7 +1,7 @@
1
1
  import { IconSet } from '../icon-set/index.js';
2
2
  import { ExportTargetOptions } from './helpers/prepare.js';
3
3
  import { ExportOptionsWithCustomFiles } from './helpers/custom-files.js';
4
- import '../types-f0980297.js';
4
+ import '../types-6360d61e.js';
5
5
  import '@iconify/utils/lib/customisations/defaults';
6
6
  import '../icon-set/types.js';
7
7
  import '../svg/index.js';
@@ -1,4 +1,4 @@
1
- import { a as IconifyInfo, b as IconifyJSON } from '../types-f0980297.js';
1
+ import { a as IconifyInfo, b as IconifyJSON } from '../types-6360d61e.js';
2
2
  import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
3
3
  import { IconSetIconEntry, IconCategory, IconSetIconType, IconSetAsyncForEachCallback, ResolvedIconifyIcon, CommonIconProps, CheckThemeResult } from './types.js';
4
4
  import { SVG } from '../svg/index.js';
@@ -1,6 +1,6 @@
1
1
  import { FullIconifyIcon } from '@iconify/utils/lib/icon/defaults';
2
2
  import { IconSet } from './index.js';
3
- import '../types-f0980297.js';
3
+ import '../types-6360d61e.js';
4
4
  import '@iconify/utils/lib/customisations/defaults';
5
5
  import './types.js';
6
6
  import '../svg/index.js';
@@ -1,5 +1,5 @@
1
1
  import { IconSet } from './index.js';
2
- import '../types-f0980297.js';
2
+ import '../types-6360d61e.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import './types.js';
5
5
  import '../svg/index.js';
@@ -1,5 +1,5 @@
1
1
  import { IconSet } from './index.js';
2
- import '../types-f0980297.js';
2
+ import '../types-6360d61e.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import './types.js';
5
5
  import '../svg/index.js';
@@ -1,5 +1,5 @@
1
1
  import { CommonIconProps } from './types.js';
2
- import '../types-f0980297.js';
2
+ import '../types-6360d61e.js';
3
3
 
4
4
  /**
5
5
  * Common properties for icon and alias
@@ -1,4 +1,4 @@
1
- import { E as ExtendedIconifyIcon, c as ExtendedIconifyAlias, d as IconifyOptional, I as IconifyIcon } from '../types-f0980297.js';
1
+ import { E as ExtendedIconifyIcon, c as ExtendedIconifyAlias, d as IconifyOptional, I as IconifyIcon } from '../types-6360d61e.js';
2
2
 
3
3
  /**
4
4
  * Category item
@@ -27,11 +27,12 @@ require('../css/parser/tokens.cjs');
27
27
  require('../css/parser/error.cjs');
28
28
  require('../css/parser/strings.cjs');
29
29
  require('../css/parser/text.cjs');
30
- require('../svg/cleanup/root-svg.cjs');
31
- require('../svg/cleanup/svgo-style.cjs');
30
+ require('../svg/cleanup/root-style.cjs');
32
31
  require('../svg/parse-style.cjs');
33
32
  require('../css/parser/export.cjs');
34
33
  require('../css/parser/tree.cjs');
34
+ require('../svg/cleanup/root-svg.cjs');
35
+ require('../svg/cleanup/svgo-style.cjs');
35
36
  require('../optimise/svgo.cjs');
36
37
  require('svgo');
37
38
 
@@ -1,5 +1,5 @@
1
1
  import { IconSet } from '../icon-set/index.js';
2
- import '../types-f0980297.js';
2
+ import '../types-6360d61e.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import '../icon-set/types.js';
5
5
  import '../svg/index.js';
@@ -23,11 +23,12 @@ import '../css/parser/tokens.mjs';
23
23
  import '../css/parser/error.mjs';
24
24
  import '../css/parser/strings.mjs';
25
25
  import '../css/parser/text.mjs';
26
- import '../svg/cleanup/root-svg.mjs';
27
- import '../svg/cleanup/svgo-style.mjs';
26
+ import '../svg/cleanup/root-style.mjs';
28
27
  import '../svg/parse-style.mjs';
29
28
  import '../css/parser/export.mjs';
30
29
  import '../css/parser/tree.mjs';
30
+ import '../svg/cleanup/root-svg.mjs';
31
+ import '../svg/cleanup/svgo-style.mjs';
31
32
  import '../optimise/svgo.mjs';
32
33
  import 'svgo';
33
34
 
@@ -26,11 +26,12 @@ require('../../css/parser/tokens.cjs');
26
26
  require('../../css/parser/error.cjs');
27
27
  require('../../css/parser/strings.cjs');
28
28
  require('../../css/parser/text.cjs');
29
- require('../../svg/cleanup/root-svg.cjs');
30
- require('../../svg/cleanup/svgo-style.cjs');
29
+ require('../../svg/cleanup/root-style.cjs');
31
30
  require('../../svg/parse-style.cjs');
32
31
  require('../../css/parser/export.cjs');
33
32
  require('../../css/parser/tree.cjs');
33
+ require('../../svg/cleanup/root-svg.cjs');
34
+ require('../../svg/cleanup/svgo-style.cjs');
34
35
  require('../../optimise/svgo.cjs');
35
36
  require('svgo');
36
37
  require('../../download/api/index.cjs');
@@ -2,7 +2,7 @@ import { DocumentNotModified } from '../../download/types/modified.js';
2
2
  import { FigmaIfModifiedSinceOption, FigmaImportOptions } from './types/options.js';
3
3
  import { FigmaImportResult } from './types/result.js';
4
4
  import '../../icon-set/index.js';
5
- import '../../types-f0980297.js';
5
+ import '../../types-6360d61e.js';
6
6
  import '@iconify/utils/lib/customisations/defaults';
7
7
  import '../../icon-set/types.js';
8
8
  import '../../svg/index.js';
@@ -22,11 +22,12 @@ import '../../css/parser/tokens.mjs';
22
22
  import '../../css/parser/error.mjs';
23
23
  import '../../css/parser/strings.mjs';
24
24
  import '../../css/parser/text.mjs';
25
- import '../../svg/cleanup/root-svg.mjs';
26
- import '../../svg/cleanup/svgo-style.mjs';
25
+ import '../../svg/cleanup/root-style.mjs';
27
26
  import '../../svg/parse-style.mjs';
28
27
  import '../../css/parser/export.mjs';
29
28
  import '../../css/parser/tree.mjs';
29
+ import '../../svg/cleanup/root-svg.mjs';
30
+ import '../../svg/cleanup/svgo-style.mjs';
30
31
  import '../../optimise/svgo.mjs';
31
32
  import 'svgo';
32
33
  import '../../download/api/index.mjs';
@@ -2,7 +2,7 @@ import { FigmaDocument } from './types/api.js';
2
2
  import { FigmaGetIconNodesOptions } from './types/options.js';
3
3
  import { FigmaNodesImportResult } from './types/result.js';
4
4
  import '../../icon-set/index.js';
5
- import '../../types-f0980297.js';
5
+ import '../../types-6360d61e.js';
6
6
  import '@iconify/utils/lib/customisations/defaults';
7
7
  import '../../icon-set/types.js';
8
8
  import '../../svg/index.js';
@@ -4,7 +4,7 @@ import { FigmaDocument } from './types/api.js';
4
4
  import { FigmaIfModifiedSinceOption, FigmaFilesQueryOptions, FigmaImagesQueryOptions } from './types/options.js';
5
5
  import { FigmaNodesImportResult } from './types/result.js';
6
6
  import '../../icon-set/index.js';
7
- import '../../types-f0980297.js';
7
+ import '../../types-6360d61e.js';
8
8
  import '@iconify/utils/lib/customisations/defaults';
9
9
  import '../../icon-set/types.js';
10
10
  import '../../svg/index.js';
@@ -1,7 +1,7 @@
1
1
  import { IconFigmaNode, FigmaDocument } from './api.js';
2
2
  import { FigmaNodesImportResult, FigmaIconNode } from './result.js';
3
3
  import '../../../icon-set/index.js';
4
- import '../../../types-f0980297.js';
4
+ import '../../../types-6360d61e.js';
5
5
  import '@iconify/utils/lib/customisations/defaults';
6
6
  import '../../../icon-set/types.js';
7
7
  import '../../../svg/index.js';
@@ -1,7 +1,7 @@
1
1
  import { IconSet } from '../../../icon-set/index.js';
2
2
  import { FigmaImportParentNodeFilter, FigmaImportNodeFilter } from './nodes.js';
3
3
  import { FigmaIconNode } from './result.js';
4
- import '../../../types-f0980297.js';
4
+ import '../../../types-6360d61e.js';
5
5
  import '@iconify/utils/lib/customisations/defaults';
6
6
  import '../../../icon-set/types.js';
7
7
  import '../../../svg/index.js';
@@ -1,5 +1,5 @@
1
1
  import { IconSet } from '../../../icon-set/index.js';
2
- import '../../../types-f0980297.js';
2
+ import '../../../types-6360d61e.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import '../../../icon-set/types.js';
5
5
  import '../../../svg/index.js';
package/lib/index.cjs CHANGED
@@ -9,6 +9,7 @@ const svg_analyse = require('./svg/analyse.cjs');
9
9
  const svg_cleanup = require('./svg/cleanup.cjs');
10
10
  const svg_cleanup_attribs = require('./svg/cleanup/attribs.cjs');
11
11
  const svg_cleanup_badTags = require('./svg/cleanup/bad-tags.cjs');
12
+ const svg_cleanup_rootStyle = require('./svg/cleanup/root-style.cjs');
12
13
  const svg_cleanup_inlineStyle = require('./svg/cleanup/inline-style.cjs');
13
14
  const svg_cleanup_rootSvg = require('./svg/cleanup/root-svg.cjs');
14
15
  const svg_cleanup_svgoStyle = require('./svg/cleanup/svgo-style.cjs');
@@ -95,6 +96,7 @@ exports.analyseSVGStructure = svg_analyse.analyseSVGStructure;
95
96
  exports.cleanupSVG = svg_cleanup.cleanupSVG;
96
97
  exports.removeBadAttributes = svg_cleanup_attribs.removeBadAttributes;
97
98
  exports.checkBadTags = svg_cleanup_badTags.checkBadTags;
99
+ exports.cleanupRootStyle = svg_cleanup_rootStyle.cleanupRootStyle;
98
100
  exports.cleanupInlineStyle = svg_cleanup_inlineStyle.cleanupInlineStyle;
99
101
  exports.cleanupSVGRoot = svg_cleanup_rootSvg.cleanupSVGRoot;
100
102
  exports.convertStyleToAttrs = svg_cleanup_svgoStyle.convertStyleToAttrs;
package/lib/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export { analyseSVGStructure } from './svg/analyse.js';
5
5
  export { cleanupSVG } from './svg/cleanup.js';
6
6
  export { removeBadAttributes } from './svg/cleanup/attribs.js';
7
7
  export { checkBadTags } from './svg/cleanup/bad-tags.js';
8
+ export { cleanupRootStyle } from './svg/cleanup/root-style.js';
8
9
  export { cleanupInlineStyle } from './svg/cleanup/inline-style.js';
9
10
  export { cleanupSVGRoot } from './svg/cleanup/root-svg.js';
10
11
  export { convertStyleToAttrs } from './svg/cleanup/svgo-style.js';
@@ -43,7 +44,7 @@ export { execAsync } from './misc/exec.js';
43
44
  export { cleanupIconKeyword } from './misc/keyword.js';
44
45
  export { bumpVersion } from './misc/bump-version.js';
45
46
  export { sendAPIQuery } from './download/api/index.js';
46
- import './types-f0980297.js';
47
+ import './types-6360d61e.js';
47
48
  import '@iconify/utils/lib/customisations/defaults';
48
49
  import './misc/cheerio.js';
49
50
  import './css/parser/types.js';
package/lib/index.mjs CHANGED
@@ -5,6 +5,7 @@ export { analyseSVGStructure } from './svg/analyse.mjs';
5
5
  export { cleanupSVG } from './svg/cleanup.mjs';
6
6
  export { removeBadAttributes } from './svg/cleanup/attribs.mjs';
7
7
  export { checkBadTags } from './svg/cleanup/bad-tags.mjs';
8
+ export { cleanupRootStyle } from './svg/cleanup/root-style.mjs';
8
9
  export { cleanupInlineStyle } from './svg/cleanup/inline-style.mjs';
9
10
  export { cleanupSVGRoot } from './svg/cleanup/root-svg.mjs';
10
11
  export { convertStyleToAttrs } from './svg/cleanup/svgo-style.mjs';
@@ -6,7 +6,7 @@ function cleanupIconKeyword(keyword, convertCamelCase = false) {
6
6
  if (convertCamelCase) {
7
7
  keyword = keyword.replace(/[A-Z]+/g, (chars) => "_" + chars.toLowerCase());
8
8
  }
9
- keyword = keyword.toLowerCase().trim().replace(/[_.:]/g, "-").replace(/[^a-z0-9-]/g, "").replace(/[-]+/g, "-");
9
+ keyword = keyword.toLowerCase().trim().replace(/[\s_.:]/g, "-").replace(/[^a-z0-9-]/g, "").replace(/[-]+/g, "-");
10
10
  if (keyword.slice(0, 1) === "-") {
11
11
  keyword = keyword.slice(1);
12
12
  }
@@ -2,7 +2,7 @@ function cleanupIconKeyword(keyword, convertCamelCase = false) {
2
2
  if (convertCamelCase) {
3
3
  keyword = keyword.replace(/[A-Z]+/g, (chars) => "_" + chars.toLowerCase());
4
4
  }
5
- keyword = keyword.toLowerCase().trim().replace(/[_.:]/g, "-").replace(/[^a-z0-9-]/g, "").replace(/[-]+/g, "-");
5
+ keyword = keyword.toLowerCase().trim().replace(/[\s_.:]/g, "-").replace(/[^a-z0-9-]/g, "").replace(/[-]+/g, "-");
6
6
  if (keyword.slice(0, 1) === "-") {
7
7
  keyword = keyword.slice(1);
8
8
  }
@@ -1,5 +1,5 @@
1
1
  import { SVG } from '../svg/index.js';
2
- import '../types-f0980297.js';
2
+ import '../types-6360d61e.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { SVG } from '../svg/index.js';
2
- import '../types-f0980297.js';
2
+ import '../types-6360d61e.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { SVG } from '../svg/index.js';
2
- import '../types-f0980297.js';
2
+ import '../types-6360d61e.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from 'svgo';
2
2
  import { SVG } from '../svg/index.js';
3
- import '../types-f0980297.js';
3
+ import '../types-6360d61e.js';
4
4
  import '@iconify/utils/lib/customisations/defaults';
5
5
 
6
6
  interface CleanupIDsOption {
@@ -1,6 +1,6 @@
1
1
  import { SVG } from './index.js';
2
2
  import { AnalyseSVGStructureOptions, AnalyseSVGStructureResult } from './analyse/types.js';
3
- import '../types-f0980297.js';
3
+ import '../types-6360d61e.js';
4
4
  import '@iconify/utils/lib/customisations/defaults';
5
5
 
6
6
  /**
@@ -1,5 +1,5 @@
1
1
  import { SVG } from '../index.js';
2
- import '../../types-f0980297.js';
2
+ import '../../types-6360d61e.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { SVG } from '../index.js';
2
- import '../../types-f0980297.js';
2
+ import '../../types-6360d61e.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
@@ -33,6 +33,10 @@ async function cleanupInlineStyle(svg) {
33
33
  $element.attr(prop, value);
34
34
  return;
35
35
  }
36
+ if (svg_data_attributes.tagSpecificInlineStyles[tagName]?.has(prop)) {
37
+ newStyle[prop] = value;
38
+ return;
39
+ }
36
40
  if (svg_data_attributes.insideClipPathAttributes.has(prop)) {
37
41
  if (item.parents.find((item2) => item2.tagName === "clipPath")) {
38
42
  $element.attr(prop, value);
@@ -1,5 +1,5 @@
1
1
  import { SVG } from '../index.js';
2
- import '../../types-f0980297.js';
2
+ import '../../types-6360d61e.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { parseInlineStyle } from '../../css/parse.mjs';
2
- import { badAttributes, tagSpecificNonPresentationalAttributes, tagSpecificAnimatedAttributes, tagSpecificPresentationalAttributes, insideClipPathAttributes, badSoftwareAttributes, badAttributePrefixes } from '../data/attributes.mjs';
2
+ import { badAttributes, tagSpecificNonPresentationalAttributes, tagSpecificAnimatedAttributes, tagSpecificPresentationalAttributes, tagSpecificInlineStyles, insideClipPathAttributes, badSoftwareAttributes, badAttributePrefixes } from '../data/attributes.mjs';
3
3
  import { parseSVG } from '../parse.mjs';
4
4
  import '../../css/parser/tokens.mjs';
5
5
  import '../../css/parser/error.mjs';
@@ -29,6 +29,10 @@ async function cleanupInlineStyle(svg) {
29
29
  $element.attr(prop, value);
30
30
  return;
31
31
  }
32
+ if (tagSpecificInlineStyles[tagName]?.has(prop)) {
33
+ newStyle[prop] = value;
34
+ return;
35
+ }
32
36
  if (insideClipPathAttributes.has(prop)) {
33
37
  if (item.parents.find((item2) => item2.tagName === "clipPath")) {
34
38
  $element.attr(prop, value);
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const svg_parseStyle = require('../parse-style.cjs');
6
+ require('../../css/parse.cjs');
7
+ require('../../css/parser/tokens.cjs');
8
+ require('../../css/parser/error.cjs');
9
+ require('../../css/parser/strings.cjs');
10
+ require('../../css/parser/text.cjs');
11
+ require('../../css/parser/export.cjs');
12
+ require('../../css/parser/tree.cjs');
13
+ require('../parse.cjs');
14
+
15
+ function cleanupRootStyle(svg) {
16
+ return svg_parseStyle.parseSVGStyle(svg, (item) => {
17
+ if (item.type === "global" && item.selectorTokens.find((token) => token.type === "at-rule")) {
18
+ return;
19
+ }
20
+ return item.value;
21
+ });
22
+ }
23
+
24
+ exports.cleanupRootStyle = cleanupRootStyle;
@@ -0,0 +1,16 @@
1
+ import { SVG } from '../index.js';
2
+ import { parseSVGStyle } from '../parse-style.js';
3
+ import '../../types-6360d61e.js';
4
+ import '@iconify/utils/lib/customisations/defaults';
5
+ import '../../css/parser/types.js';
6
+ import '../parse.js';
7
+ import '../../misc/cheerio.js';
8
+
9
+ /**
10
+ * Clean up root style
11
+ *
12
+ * This function removes all at-rule tokens, such as `@font-face`, `@media`
13
+ */
14
+ declare function cleanupRootStyle(svg: SVG): ReturnType<typeof parseSVGStyle>;
15
+
16
+ export { cleanupRootStyle };
@@ -0,0 +1,20 @@
1
+ import { parseSVGStyle } from '../parse-style.mjs';
2
+ import '../../css/parse.mjs';
3
+ import '../../css/parser/tokens.mjs';
4
+ import '../../css/parser/error.mjs';
5
+ import '../../css/parser/strings.mjs';
6
+ import '../../css/parser/text.mjs';
7
+ import '../../css/parser/export.mjs';
8
+ import '../../css/parser/tree.mjs';
9
+ import '../parse.mjs';
10
+
11
+ function cleanupRootStyle(svg) {
12
+ return parseSVGStyle(svg, (item) => {
13
+ if (item.type === "global" && item.selectorTokens.find((token) => token.type === "at-rule")) {
14
+ return;
15
+ }
16
+ return item.value;
17
+ });
18
+ }
19
+
20
+ export { cleanupRootStyle };
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const svg_data_attributes = require('../data/attributes.cjs');
6
6
  const svg_data_tags = require('../data/tags.cjs');
7
7
 
8
- async function cleanupSVGRoot(svg) {
8
+ function cleanupSVGRoot(svg) {
9
9
  const cheerio = svg.$svg;
10
10
  const $root = svg.$svg(":root");
11
11
  const root = $root.get(0);
@@ -26,7 +26,7 @@ async function cleanupSVGRoot(svg) {
26
26
  case "height":
27
27
  if (value.slice(-2) === "px") {
28
28
  const num = value.replace("px", "");
29
- if (parseFloat(num) + "" === num) {
29
+ if (parseFloat(num).toString() === num) {
30
30
  $root.attr(attr, num);
31
31
  }
32
32
  }
@@ -1,10 +1,10 @@
1
1
  import { SVG } from '../index.js';
2
- import '../../types-f0980297.js';
2
+ import '../../types-6360d61e.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
6
6
  * Clean up SVG
7
7
  */
8
- declare function cleanupSVGRoot(svg: SVG): Promise<void>;
8
+ declare function cleanupSVGRoot(svg: SVG): void;
9
9
 
10
10
  export { cleanupSVGRoot };
@@ -1,7 +1,7 @@
1
1
  import { commonAttributes, badAttributes, junkSVGAttributes, badSoftwareAttributes, badAttributePrefixes, tagSpecificNonPresentationalAttributes, tagSpecificPresentationalAttributes, stylingAttributes } from '../data/attributes.mjs';
2
2
  import { reusableElementsWithPalette, maskTags } from '../data/tags.mjs';
3
3
 
4
- async function cleanupSVGRoot(svg) {
4
+ function cleanupSVGRoot(svg) {
5
5
  const cheerio = svg.$svg;
6
6
  const $root = svg.$svg(":root");
7
7
  const root = $root.get(0);
@@ -22,7 +22,7 @@ async function cleanupSVGRoot(svg) {
22
22
  case "height":
23
23
  if (value.slice(-2) === "px") {
24
24
  const num = value.replace("px", "");
25
- if (parseFloat(num) + "" === num) {
25
+ if (parseFloat(num).toString() === num) {
26
26
  $root.attr(attr, num);
27
27
  }
28
28
  }
@@ -1,5 +1,5 @@
1
1
  import { SVG } from '../index.js';
2
- import '../../types-f0980297.js';
2
+ import '../../types-6360d61e.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const svg_cleanup_attribs = require('./cleanup/attribs.cjs');
6
6
  const svg_cleanup_badTags = require('./cleanup/bad-tags.cjs');
7
7
  const svg_cleanup_inlineStyle = require('./cleanup/inline-style.cjs');
8
+ const svg_cleanup_rootStyle = require('./cleanup/root-style.cjs');
8
9
  const svg_cleanup_rootSvg = require('./cleanup/root-svg.cjs');
9
10
  const svg_cleanup_svgoStyle = require('./cleanup/svgo-style.cjs');
10
11
  require('./data/attributes.cjs');
@@ -24,9 +25,10 @@ require('svgo');
24
25
  async function cleanupSVG(svg) {
25
26
  await svg_cleanup_inlineStyle.cleanupInlineStyle(svg);
26
27
  await svg_cleanup_svgoStyle.convertStyleToAttrs(svg);
27
- await svg_cleanup_rootSvg.cleanupSVGRoot(svg);
28
+ svg_cleanup_rootSvg.cleanupSVGRoot(svg);
28
29
  await svg_cleanup_badTags.checkBadTags(svg);
29
30
  await svg_cleanup_attribs.removeBadAttributes(svg);
31
+ await svg_cleanup_rootStyle.cleanupRootStyle(svg);
30
32
  }
31
33
 
32
34
  exports.cleanupSVG = cleanupSVG;
@@ -1,5 +1,5 @@
1
1
  import { SVG } from './index.js';
2
- import '../types-f0980297.js';
2
+ import '../types-6360d61e.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
@@ -1,6 +1,7 @@
1
1
  import { removeBadAttributes } from './cleanup/attribs.mjs';
2
2
  import { checkBadTags } from './cleanup/bad-tags.mjs';
3
3
  import { cleanupInlineStyle } from './cleanup/inline-style.mjs';
4
+ import { cleanupRootStyle } from './cleanup/root-style.mjs';
4
5
  import { cleanupSVGRoot } from './cleanup/root-svg.mjs';
5
6
  import { convertStyleToAttrs } from './cleanup/svgo-style.mjs';
6
7
  import './data/attributes.mjs';
@@ -20,9 +21,10 @@ import 'svgo';
20
21
  async function cleanupSVG(svg) {
21
22
  await cleanupInlineStyle(svg);
22
23
  await convertStyleToAttrs(svg);
23
- await cleanupSVGRoot(svg);
24
+ cleanupSVGRoot(svg);
24
25
  await checkBadTags(svg);
25
26
  await removeBadAttributes(svg);
27
+ await cleanupRootStyle(svg);
26
28
  }
27
29
 
28
30
  export { cleanupSVG };
@@ -327,6 +327,9 @@ const tagSpecificNonPresentationalAttributes = {
327
327
  "type"
328
328
  ])
329
329
  };
330
+ const tagSpecificInlineStyles = {
331
+ mask: /* @__PURE__ */ new Set(["mask-type"])
332
+ };
330
333
 
331
334
  exports.animationTimingAttributes = animationTimingAttributes;
332
335
  exports.animationValueAttributes = animationValueAttributes;
@@ -349,6 +352,7 @@ exports.presentationalAttributes = presentationalAttributes;
349
352
  exports.strokePresentationalAttributes = strokePresentationalAttributes;
350
353
  exports.stylingAttributes = stylingAttributes;
351
354
  exports.tagSpecificAnimatedAttributes = tagSpecificAnimatedAttributes;
355
+ exports.tagSpecificInlineStyles = tagSpecificInlineStyles;
352
356
  exports.tagSpecificNonPresentationalAttributes = tagSpecificNonPresentationalAttributes;
353
357
  exports.tagSpecificPresentationalAttributes = tagSpecificPresentationalAttributes;
354
358
  exports.urlPresentationalAttributes = urlPresentationalAttributes;
@@ -69,5 +69,9 @@ declare const feFuncAttributes: Set<string>;
69
69
  declare const tagSpecificAnimatedAttributes: Record<string, Set<string>>;
70
70
  declare const tagSpecificPresentationalAttributes: Record<string, Set<string>>;
71
71
  declare const tagSpecificNonPresentationalAttributes: Record<string, Set<string>>;
72
+ /**
73
+ * Styles to keep in tags
74
+ */
75
+ declare const tagSpecificInlineStyles: Record<string, Set<string>>;
72
76
 
73
- export { animationTimingAttributes, animationValueAttributes, badAttributePrefixes, badAttributes, badSoftwareAttributes, commonAttributes, commonColorPresentationalAttributes, commonFeAttributes, commonGradientAttributes, feFuncAttributes, fillPresentationalAttributes, insideClipPathAttributes, junkSVGAttributes, markerAttributes, otherAnimationAttributes, otherPresentationalAttributes, otherShapeAttributes, presentationalAttributes, strokePresentationalAttributes, stylingAttributes, tagSpecificAnimatedAttributes, tagSpecificNonPresentationalAttributes, tagSpecificPresentationalAttributes, urlPresentationalAttributes, visibilityPresentationalAttributes };
77
+ export { animationTimingAttributes, animationValueAttributes, badAttributePrefixes, badAttributes, badSoftwareAttributes, commonAttributes, commonColorPresentationalAttributes, commonFeAttributes, commonGradientAttributes, feFuncAttributes, fillPresentationalAttributes, insideClipPathAttributes, junkSVGAttributes, markerAttributes, otherAnimationAttributes, otherPresentationalAttributes, otherShapeAttributes, presentationalAttributes, strokePresentationalAttributes, stylingAttributes, tagSpecificAnimatedAttributes, tagSpecificInlineStyles, tagSpecificNonPresentationalAttributes, tagSpecificPresentationalAttributes, urlPresentationalAttributes, visibilityPresentationalAttributes };
@@ -323,5 +323,8 @@ const tagSpecificNonPresentationalAttributes = {
323
323
  "type"
324
324
  ])
325
325
  };
326
+ const tagSpecificInlineStyles = {
327
+ mask: /* @__PURE__ */ new Set(["mask-type"])
328
+ };
326
329
 
327
- export { animationTimingAttributes, animationValueAttributes, badAttributePrefixes, badAttributes, badSoftwareAttributes, commonAttributes, commonColorPresentationalAttributes, commonFeAttributes, commonGradientAttributes, feFuncAttributes, fillPresentationalAttributes, insideClipPathAttributes, junkSVGAttributes, markerAttributes, otherAnimationAttributes, otherPresentationalAttributes, otherShapeAttributes, presentationalAttributes, strokePresentationalAttributes, stylingAttributes, tagSpecificAnimatedAttributes, tagSpecificNonPresentationalAttributes, tagSpecificPresentationalAttributes, urlPresentationalAttributes, visibilityPresentationalAttributes };
330
+ export { animationTimingAttributes, animationValueAttributes, badAttributePrefixes, badAttributes, badSoftwareAttributes, commonAttributes, commonColorPresentationalAttributes, commonFeAttributes, commonGradientAttributes, feFuncAttributes, fillPresentationalAttributes, insideClipPathAttributes, junkSVGAttributes, markerAttributes, otherAnimationAttributes, otherPresentationalAttributes, otherShapeAttributes, presentationalAttributes, strokePresentationalAttributes, stylingAttributes, tagSpecificAnimatedAttributes, tagSpecificInlineStyles, tagSpecificNonPresentationalAttributes, tagSpecificPresentationalAttributes, urlPresentationalAttributes, visibilityPresentationalAttributes };
@@ -1,5 +1,5 @@
1
- import { I as IconifyIcon } from '../types-f0980297.js';
2
- export { I as IconifyIcon } from '../types-f0980297.js';
1
+ import { I as IconifyIcon } from '../types-6360d61e.js';
2
+ export { I as IconifyIcon } from '../types-6360d61e.js';
3
3
  import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
4
4
  export { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
5
5
 
@@ -16,7 +16,7 @@ async function parseSVGStyle(svg, callback) {
16
16
  const tagName = item.tagName;
17
17
  const $element = item.$element;
18
18
  if (tagName === "style") {
19
- const content = $element.html();
19
+ const content = $element.text();
20
20
  if (typeof content !== "string") {
21
21
  $element.remove();
22
22
  return;
@@ -1,7 +1,7 @@
1
1
  import { SVG } from './index.js';
2
2
  import { CSSRuleToken, CSSToken } from '../css/parser/types.js';
3
3
  import { ParseSVGCallbackItem } from './parse.js';
4
- import '../types-f0980297.js';
4
+ import '../types-6360d61e.js';
5
5
  import '@iconify/utils/lib/customisations/defaults';
6
6
  import '../misc/cheerio.js';
7
7
 
@@ -12,7 +12,7 @@ async function parseSVGStyle(svg, callback) {
12
12
  const tagName = item.tagName;
13
13
  const $element = item.$element;
14
14
  if (tagName === "style") {
15
- const content = $element.html();
15
+ const content = $element.text();
16
16
  if (typeof content !== "string") {
17
17
  $element.remove();
18
18
  return;
@@ -1,6 +1,6 @@
1
1
  import { CheerioElement, WrappedCheerioElement } from '../misc/cheerio.js';
2
2
  import { SVG } from './index.js';
3
- import '../types-f0980297.js';
3
+ import '../types-6360d61e.js';
4
4
  import '@iconify/utils/lib/customisations/defaults';
5
5
 
6
6
  /**
@@ -154,6 +154,9 @@ interface IconifyInfo {
154
154
  // Category on Iconify collections list.
155
155
  category?: string;
156
156
 
157
+ // List of tags to group similar icon sets.
158
+ tags?: string[];
159
+
157
160
  // Palette status. True if icons have predefined color scheme, false if icons use currentColor.
158
161
  // Ideally, icon set should not mix icons with and without palette to simplify search.
159
162
  palette?: boolean;
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.1.0-beta.5",
6
+ "version": "2.1.0",
7
7
  "license": "MIT",
8
8
  "bugs": "https://github.com/iconify/tools/issues",
9
9
  "homepage": "https://github.com/iconify/tools",
@@ -25,16 +25,16 @@
25
25
  "test": "npm run test:jest-cjs && npm run test:jest-esm && npm run test:jasmine"
26
26
  },
27
27
  "dependencies": {
28
- "@iconify/utils": "^2.0.0-beta.4",
28
+ "@iconify/utils": "^2.0.0",
29
29
  "@types/cheerio": "^0.22.30",
30
30
  "@types/node-fetch": "^2.5.12",
31
31
  "@types/svgo": "^2.6.0",
32
32
  "@types/tar": "^6.1.0",
33
33
  "cheerio": "^1.0.0-rc.10",
34
34
  "extract-zip": "^2.0.1",
35
- "local-pkg": "^0.4.1",
35
+ "local-pkg": "^0.4.2",
36
36
  "node-fetch": "^2.6.7",
37
- "pathe": "^0.2.0",
37
+ "pathe": "^0.3.7",
38
38
  "svgo": "^2.8.0",
39
39
  "tar": "^6.1.11"
40
40
  },
@@ -368,6 +368,10 @@
368
368
  "require": "./lib/svg/cleanup/inline-style.cjs",
369
369
  "import": "./lib/svg/cleanup/inline-style.mjs"
370
370
  },
371
+ "./lib/svg/cleanup/root-style": {
372
+ "require": "./lib/svg/cleanup/root-style.cjs",
373
+ "import": "./lib/svg/cleanup/root-style.mjs"
374
+ },
371
375
  "./lib/svg/cleanup/root-svg": {
372
376
  "require": "./lib/svg/cleanup/root-svg.cjs",
373
377
  "import": "./lib/svg/cleanup/root-svg.mjs"