@iconify/tools 2.1.2 → 2.2.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 (82) hide show
  1. package/lib/colors/attribs.cjs +0 -2
  2. package/lib/colors/detect.cjs +0 -2
  3. package/lib/colors/parse.cjs +0 -2
  4. package/lib/colors/validate.cjs +0 -2
  5. package/lib/css/parse.cjs +0 -2
  6. package/lib/css/parser/error.cjs +0 -2
  7. package/lib/css/parser/export.cjs +0 -2
  8. package/lib/css/parser/strings.cjs +0 -2
  9. package/lib/css/parser/text.cjs +0 -2
  10. package/lib/css/parser/tokens.cjs +0 -2
  11. package/lib/css/parser/tree.cjs +0 -2
  12. package/lib/download/api/cache.cjs +0 -2
  13. package/lib/download/api/download.cjs +1 -7
  14. package/lib/download/api/index.cjs +1 -7
  15. package/lib/download/git/branch.cjs +0 -2
  16. package/lib/download/git/hash.cjs +0 -2
  17. package/lib/download/git/index.cjs +1 -2
  18. package/lib/download/git/index.mjs +1 -0
  19. package/lib/download/git/reset.cjs +1 -2
  20. package/lib/download/git/reset.mjs +1 -0
  21. package/lib/download/github/hash.cjs +0 -2
  22. package/lib/download/github/index.cjs +0 -2
  23. package/lib/download/gitlab/hash.cjs +0 -2
  24. package/lib/download/gitlab/index.cjs +0 -2
  25. package/lib/download/gitlab/types.cjs +0 -2
  26. package/lib/download/helpers/untar.cjs +0 -2
  27. package/lib/download/helpers/unzip.cjs +1 -7
  28. package/lib/download/index.cjs +1 -2
  29. package/lib/download/index.mjs +1 -0
  30. package/lib/download/npm/index.cjs +0 -2
  31. package/lib/download/npm/version.cjs +0 -2
  32. package/lib/export/directory.cjs +0 -2
  33. package/lib/export/helpers/custom-files.cjs +0 -2
  34. package/lib/export/helpers/prepare.cjs +0 -2
  35. package/lib/export/helpers/types-version.cjs +0 -2
  36. package/lib/export/icon-package.cjs +0 -2
  37. package/lib/export/json-package.cjs +0 -2
  38. package/lib/icon-set/index.cjs +0 -2
  39. package/lib/icon-set/match.cjs +0 -2
  40. package/lib/icon-set/merge.cjs +0 -2
  41. package/lib/icon-set/modified.cjs +0 -2
  42. package/lib/icon-set/props.cjs +0 -2
  43. package/lib/icon-set/tags.cjs +0 -2
  44. package/lib/import/directory.cjs +1 -2
  45. package/lib/import/directory.mjs +1 -0
  46. package/lib/import/figma/index.cjs +1 -2
  47. package/lib/import/figma/index.mjs +1 -0
  48. package/lib/import/figma/nodes.cjs +0 -2
  49. package/lib/import/figma/query.cjs +0 -2
  50. package/lib/index.cjs +1 -2
  51. package/lib/index.mjs +1 -0
  52. package/lib/misc/bump-version.cjs +0 -2
  53. package/lib/misc/compare-dirs.cjs +0 -2
  54. package/lib/misc/exec.cjs +0 -2
  55. package/lib/misc/keyword.cjs +0 -2
  56. package/lib/misc/scan.cjs +0 -2
  57. package/lib/misc/write-json.cjs +0 -2
  58. package/lib/optimise/flags.cjs +0 -2
  59. package/lib/optimise/global-style.cjs +0 -2
  60. package/lib/optimise/scale.cjs +1 -2
  61. package/lib/optimise/scale.mjs +1 -0
  62. package/lib/optimise/svgo.cjs +15 -12
  63. package/lib/optimise/svgo.d.ts +5 -5
  64. package/lib/optimise/svgo.mjs +15 -10
  65. package/lib/svg/analyse/error.cjs +0 -2
  66. package/lib/svg/analyse.cjs +0 -2
  67. package/lib/svg/cleanup/attribs.cjs +0 -2
  68. package/lib/svg/cleanup/bad-tags.cjs +0 -2
  69. package/lib/svg/cleanup/inline-style.cjs +0 -2
  70. package/lib/svg/cleanup/root-style.cjs +0 -2
  71. package/lib/svg/cleanup/root-svg.cjs +0 -2
  72. package/lib/svg/cleanup/svgo-style.cjs +1 -2
  73. package/lib/svg/cleanup/svgo-style.mjs +1 -0
  74. package/lib/svg/cleanup.cjs +1 -2
  75. package/lib/svg/cleanup.mjs +1 -0
  76. package/lib/svg/data/attributes.cjs +0 -2
  77. package/lib/svg/data/tags.cjs +0 -2
  78. package/lib/svg/index.cjs +1 -7
  79. package/lib/svg/parse-style.cjs +0 -2
  80. package/lib/svg/parse.cjs +0 -2
  81. package/license.txt +0 -0
  82. package/package.json +533 -516
@@ -1,5 +1,6 @@
1
1
  import { runSVGO } from './svgo.mjs';
2
2
  import 'svgo';
3
+ import '@iconify/utils/lib/svg/id';
3
4
 
4
5
  function scaleSVG(svg, scale) {
5
6
  const viewBox = svg.viewBox;
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const svgo = require('svgo');
4
+ const id = require('@iconify/utils/lib/svg/id');
6
5
 
7
6
  function getSVGOPlugins(options) {
8
7
  return [
@@ -45,15 +44,7 @@ function getSVGOPlugins(options) {
45
44
  }
46
45
  },
47
46
  "reusePaths"
48
- ],
49
- ...options.cleanupIDs !== false ? [
50
- {
51
- name: "cleanupIDs",
52
- params: {
53
- prefix: typeof options.cleanupIDs === "string" ? options.cleanupIDs : "svgID"
54
- }
55
- }
56
- ] : []
47
+ ]
57
48
  ];
58
49
  }
59
50
  function runSVGO(svg, options = {}) {
@@ -77,7 +68,19 @@ function runSVGO(svg, options = {}) {
77
68
  if (typeof result.error === "string") {
78
69
  throw new Error(result.error);
79
70
  }
80
- const content = result.data.replace(/<defs\/>/g, "");
71
+ let content = result.data.replace(/<defs\/>/g, "");
72
+ if (!options.plugins) {
73
+ const prefix = options.cleanupIDs !== void 0 ? options.cleanupIDs : "svgID";
74
+ if (prefix !== false) {
75
+ let counter = 0;
76
+ content = id.replaceIDs(
77
+ content,
78
+ typeof prefix === "string" ? () => {
79
+ return prefix + (counter++).toString(36);
80
+ } : prefix
81
+ );
82
+ }
83
+ }
81
84
  svg.load(content);
82
85
  }
83
86
 
@@ -1,19 +1,19 @@
1
- import { Plugin } from 'svgo';
1
+ import { PluginConfig } from 'svgo';
2
2
  import { SVG } from '../svg/index.js';
3
3
  import '@iconify/types';
4
4
  import '@iconify/utils/lib/customisations/defaults';
5
5
 
6
6
  interface CleanupIDsOption {
7
- cleanupIDs?: string | false;
7
+ cleanupIDs?: string | ((id: string) => string) | false;
8
8
  }
9
- interface GetSVGOPluingOptions extends CleanupIDsOption {
9
+ interface GetSVGOPluginOptions extends CleanupIDsOption {
10
10
  animated?: boolean;
11
11
  keepShapes?: boolean;
12
12
  }
13
13
  /**
14
14
  * Get list of plugins
15
15
  */
16
- declare function getSVGOPlugins(options: GetSVGOPluingOptions): Plugin[];
16
+ declare function getSVGOPlugins(options: GetSVGOPluginOptions): PluginConfig[];
17
17
  /**
18
18
  * Options
19
19
  */
@@ -21,7 +21,7 @@ interface SVGOCommonOptions {
21
21
  multipass?: boolean;
22
22
  }
23
23
  interface SVGOOptionsWithPlugin extends SVGOCommonOptions {
24
- plugins: Plugin[];
24
+ plugins: PluginConfig[];
25
25
  }
26
26
  interface SVGOptionsWithoutPlugin extends SVGOCommonOptions, CleanupIDsOption {
27
27
  plugins?: undefined;
@@ -1,4 +1,5 @@
1
1
  import { optimize } from 'svgo';
2
+ import { replaceIDs } from '@iconify/utils/lib/svg/id';
2
3
 
3
4
  function getSVGOPlugins(options) {
4
5
  return [
@@ -41,15 +42,7 @@ function getSVGOPlugins(options) {
41
42
  }
42
43
  },
43
44
  "reusePaths"
44
- ],
45
- ...options.cleanupIDs !== false ? [
46
- {
47
- name: "cleanupIDs",
48
- params: {
49
- prefix: typeof options.cleanupIDs === "string" ? options.cleanupIDs : "svgID"
50
- }
51
- }
52
- ] : []
45
+ ]
53
46
  ];
54
47
  }
55
48
  function runSVGO(svg, options = {}) {
@@ -73,7 +66,19 @@ function runSVGO(svg, options = {}) {
73
66
  if (typeof result.error === "string") {
74
67
  throw new Error(result.error);
75
68
  }
76
- const content = result.data.replace(/<defs\/>/g, "");
69
+ let content = result.data.replace(/<defs\/>/g, "");
70
+ if (!options.plugins) {
71
+ const prefix = options.cleanupIDs !== void 0 ? options.cleanupIDs : "svgID";
72
+ if (prefix !== false) {
73
+ let counter = 0;
74
+ content = replaceIDs(
75
+ content,
76
+ typeof prefix === "string" ? () => {
77
+ return prefix + (counter++).toString(36);
78
+ } : prefix
79
+ );
80
+ }
81
+ }
77
82
  svg.load(content);
78
83
  }
79
84
 
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  function analyseTagError(element) {
6
4
  let result = "<" + element.tagName;
7
5
  if (element._id) {
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const svg_parse = require('./parse.cjs');
6
4
  const svg_data_attributes = require('./data/attributes.cjs');
7
5
  const svg_data_tags = require('./data/tags.cjs');
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const svg_data_attributes = require('../data/attributes.cjs');
6
4
  const svg_data_tags = require('../data/tags.cjs');
7
5
  const svg_parse = require('../parse.cjs');
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const svg_parse = require('../parse.cjs');
6
4
  const svg_data_tags = require('../data/tags.cjs');
7
5
 
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const css_parse = require('../../css/parse.cjs');
6
4
  const svg_data_attributes = require('../data/attributes.cjs');
7
5
  const svg_parse = require('../parse.cjs');
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const svg_parseStyle = require('../parse-style.cjs');
6
4
  require('../../css/parse.cjs');
7
5
  require('../../css/parser/tokens.cjs');
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const svg_data_attributes = require('../data/attributes.cjs');
6
4
  const svg_data_tags = require('../data/tags.cjs');
7
5
 
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const svg_data_attributes = require('../data/attributes.cjs');
6
4
  const svg_parseStyle = require('../parse-style.cjs');
7
5
  const optimise_svgo = require('../../optimise/svgo.cjs');
@@ -15,6 +13,7 @@ require('../../css/parser/export.cjs');
15
13
  require('../../css/parser/tree.cjs');
16
14
  require('../parse.cjs');
17
15
  require('svgo');
16
+ require('@iconify/utils/lib/svg/id');
18
17
 
19
18
  async function convertStyleToAttrs(svg) {
20
19
  let hasStyle = false;
@@ -11,6 +11,7 @@ import '../../css/parser/export.mjs';
11
11
  import '../../css/parser/tree.mjs';
12
12
  import '../parse.mjs';
13
13
  import 'svgo';
14
+ import '@iconify/utils/lib/svg/id';
14
15
 
15
16
  async function convertStyleToAttrs(svg) {
16
17
  let hasStyle = false;
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const svg_cleanup_attribs = require('./cleanup/attribs.cjs');
6
4
  const svg_cleanup_badTags = require('./cleanup/bad-tags.cjs');
7
5
  const svg_cleanup_inlineStyle = require('./cleanup/inline-style.cjs');
@@ -21,6 +19,7 @@ require('../css/parser/export.cjs');
21
19
  require('../css/parser/tree.cjs');
22
20
  require('../optimise/svgo.cjs');
23
21
  require('svgo');
22
+ require('@iconify/utils/lib/svg/id');
24
23
 
25
24
  async function cleanupSVG(svg) {
26
25
  await svg_cleanup_inlineStyle.cleanupInlineStyle(svg);
@@ -17,6 +17,7 @@ import '../css/parser/export.mjs';
17
17
  import '../css/parser/tree.mjs';
18
18
  import '../optimise/svgo.mjs';
19
19
  import 'svgo';
20
+ import '@iconify/utils/lib/svg/id';
20
21
 
21
22
  async function cleanupSVG(svg) {
22
23
  await cleanupInlineStyle(svg);
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const svg_data_tags = require('./tags.cjs');
6
4
 
7
5
  const badAttributes = /* @__PURE__ */ new Set([
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const badTags = /* @__PURE__ */ new Set([
6
4
  "foreignObject",
7
5
  "script",
package/lib/svg/index.cjs CHANGED
@@ -1,14 +1,8 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const cheerio = require('cheerio');
6
4
  const utils = require('@iconify/utils');
7
5
 
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
9
-
10
- const cheerio__default = /*#__PURE__*/_interopDefaultLegacy(cheerio);
11
-
12
6
  class SVG {
13
7
  constructor(content) {
14
8
  this.load(content);
@@ -90,7 +84,7 @@ class SVG {
90
84
  );
91
85
  remove('xml:space="preserve"', "", "");
92
86
  content = content.replace(/<g>\s*<\/g>/g, "");
93
- this.$svg = cheerio__default.load(content.trim(), {
87
+ this.$svg = cheerio.load(content.trim(), {
94
88
  lowerCaseAttributeNames: false,
95
89
  xmlMode: true
96
90
  });
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const css_parse = require('../css/parse.cjs');
6
4
  const css_parser_export = require('../css/parser/export.cjs');
7
5
  const css_parser_tokens = require('../css/parser/tokens.cjs');
package/lib/svg/parse.cjs CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  async function parseSVG(svg, callback) {
6
4
  async function checkNode(element, parents) {
7
5
  if (element.type !== "tag") {
package/license.txt CHANGED
File without changes