@iconify/tools 2.1.0 → 2.1.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 (123) hide show
  1. package/lib/colors/attribs.d.ts +4 -4
  2. package/lib/colors/detect.cjs +68 -0
  3. package/lib/colors/detect.d.ts +15 -0
  4. package/lib/colors/detect.mjs +64 -0
  5. package/lib/colors/parse.cjs +31 -7
  6. package/lib/colors/parse.d.ts +5 -5
  7. package/lib/colors/parse.mjs +31 -7
  8. package/lib/colors/validate.cjs +9 -3
  9. package/lib/colors/validate.d.ts +1 -1
  10. package/lib/colors/validate.mjs +9 -3
  11. package/lib/css/parser/error.cjs +1 -1
  12. package/lib/css/parser/error.mjs +1 -1
  13. package/lib/css/parser/strings.cjs +10 -2
  14. package/lib/css/parser/strings.mjs +10 -2
  15. package/lib/css/parser/tokens.cjs +133 -109
  16. package/lib/css/parser/tokens.mjs +133 -109
  17. package/lib/css/parser/types.d.ts +4 -4
  18. package/lib/download/api/cache.cjs +28 -21
  19. package/lib/download/api/cache.mjs +28 -21
  20. package/lib/download/git/branch.cjs +1 -1
  21. package/lib/download/git/branch.mjs +1 -1
  22. package/lib/download/git/hash.cjs +1 -1
  23. package/lib/download/git/hash.mjs +1 -1
  24. package/lib/download/git/index.cjs +7 -4
  25. package/lib/download/git/index.mjs +7 -4
  26. package/lib/download/git/reset.cjs +1 -2
  27. package/lib/download/git/reset.mjs +1 -2
  28. package/lib/download/github/index.cjs +10 -7
  29. package/lib/download/github/index.mjs +10 -7
  30. package/lib/download/gitlab/hash.cjs +3 -1
  31. package/lib/download/gitlab/hash.mjs +3 -1
  32. package/lib/download/gitlab/index.cjs +9 -6
  33. package/lib/download/gitlab/index.mjs +9 -6
  34. package/lib/download/index.cjs +4 -3
  35. package/lib/download/index.d.ts +4 -4
  36. package/lib/download/index.mjs +4 -3
  37. package/lib/download/npm/index.cjs +12 -8
  38. package/lib/download/npm/index.mjs +12 -8
  39. package/lib/download/npm/version.cjs +4 -2
  40. package/lib/download/npm/version.mjs +4 -2
  41. package/lib/download/types/modified.d.ts +1 -1
  42. package/lib/download/types/sources.d.ts +1 -1
  43. package/lib/export/directory.d.ts +1 -1
  44. package/lib/export/helpers/types-version.cjs +3 -1
  45. package/lib/export/helpers/types-version.mjs +3 -1
  46. package/lib/export/icon-package.d.ts +1 -1
  47. package/lib/export/json-package.cjs +13 -3
  48. package/lib/export/json-package.d.ts +1 -1
  49. package/lib/export/json-package.mjs +13 -3
  50. package/lib/icon-set/index.cjs +20 -8
  51. package/lib/icon-set/index.d.ts +1 -1
  52. package/lib/icon-set/index.mjs +20 -8
  53. package/lib/icon-set/match.d.ts +1 -1
  54. package/lib/icon-set/merge.d.ts +1 -1
  55. package/lib/icon-set/modified.d.ts +1 -1
  56. package/lib/icon-set/props.d.ts +1 -1
  57. package/lib/icon-set/tags.cjs +97 -0
  58. package/lib/icon-set/tags.d.ts +22 -0
  59. package/lib/icon-set/tags.mjs +91 -0
  60. package/lib/icon-set/types.d.ts +8 -8
  61. package/lib/import/directory.cjs +4 -1
  62. package/lib/import/directory.d.ts +3 -3
  63. package/lib/import/directory.mjs +4 -1
  64. package/lib/import/figma/index.cjs +5 -2
  65. package/lib/import/figma/index.d.ts +1 -1
  66. package/lib/import/figma/index.mjs +5 -2
  67. package/lib/import/figma/nodes.cjs +6 -2
  68. package/lib/import/figma/nodes.d.ts +2 -2
  69. package/lib/import/figma/nodes.mjs +6 -2
  70. package/lib/import/figma/query.cjs +29 -15
  71. package/lib/import/figma/query.d.ts +1 -1
  72. package/lib/import/figma/query.mjs +29 -15
  73. package/lib/import/figma/types/api.d.ts +1 -1
  74. package/lib/import/figma/types/nodes.d.ts +6 -6
  75. package/lib/import/figma/types/options.d.ts +2 -2
  76. package/lib/import/figma/types/result.d.ts +1 -1
  77. package/lib/index.cjs +6 -3
  78. package/lib/index.d.ts +3 -1
  79. package/lib/index.mjs +4 -3
  80. package/lib/misc/cheerio.d.ts +2 -2
  81. package/lib/misc/compare-dirs.cjs +3 -1
  82. package/lib/misc/compare-dirs.mjs +3 -1
  83. package/lib/misc/exec.cjs +7 -8
  84. package/lib/misc/exec.mjs +7 -8
  85. package/lib/misc/keyword.cjs +4 -1
  86. package/lib/misc/keyword.mjs +4 -1
  87. package/lib/misc/scan.cjs +3 -1
  88. package/lib/misc/scan.d.ts +5 -5
  89. package/lib/misc/scan.mjs +3 -1
  90. package/lib/optimise/flags.cjs +9 -3
  91. package/lib/optimise/flags.d.ts +1 -1
  92. package/lib/optimise/flags.mjs +9 -3
  93. package/lib/optimise/global-style.cjs +10 -3
  94. package/lib/optimise/global-style.d.ts +1 -1
  95. package/lib/optimise/global-style.mjs +10 -3
  96. package/lib/optimise/scale.d.ts +1 -1
  97. package/lib/optimise/svgo.d.ts +2 -2
  98. package/lib/svg/analyse/types.d.ts +1 -1
  99. package/lib/svg/analyse.cjs +20 -6
  100. package/lib/svg/analyse.d.ts +1 -1
  101. package/lib/svg/analyse.mjs +20 -6
  102. package/lib/svg/cleanup/attribs.d.ts +1 -1
  103. package/lib/svg/cleanup/bad-tags.cjs +7 -2
  104. package/lib/svg/cleanup/bad-tags.d.ts +1 -1
  105. package/lib/svg/cleanup/bad-tags.mjs +7 -2
  106. package/lib/svg/cleanup/inline-style.cjs +12 -4
  107. package/lib/svg/cleanup/inline-style.d.ts +1 -1
  108. package/lib/svg/cleanup/inline-style.mjs +12 -4
  109. package/lib/svg/cleanup/root-style.d.ts +1 -1
  110. package/lib/svg/cleanup/root-svg.d.ts +1 -1
  111. package/lib/svg/cleanup/svgo-style.d.ts +1 -1
  112. package/lib/svg/cleanup.d.ts +1 -1
  113. package/lib/svg/data/attributes.cjs +0 -1
  114. package/lib/svg/data/attributes.mjs +0 -1
  115. package/lib/svg/index.cjs +12 -3
  116. package/lib/svg/index.d.ts +2 -2
  117. package/lib/svg/index.mjs +12 -3
  118. package/lib/svg/parse-style.cjs +13 -8
  119. package/lib/svg/parse-style.d.ts +4 -4
  120. package/lib/svg/parse-style.mjs +13 -8
  121. package/lib/svg/parse.d.ts +2 -2
  122. package/package.json +209 -100
  123. package/lib/types-6360d61e.d.ts +0 -261
@@ -30,7 +30,7 @@ async function figmaFilesQuery(options, cache) {
30
30
  params.set("version", options.version);
31
31
  }
32
32
  if (options.depth) {
33
- params.set("depth", options.depth + "");
33
+ params.set("depth", options.depth.toString());
34
34
  }
35
35
  const queryParams = {
36
36
  uri: "https://api.figma.com/v1/files/" + options.file,
@@ -97,11 +97,15 @@ async function figmaFilesQuery(options, cache) {
97
97
  }
98
98
  if (typeof parsedData.status === "number") {
99
99
  const figmaError = parsedData;
100
- throw new Error(`Error retrieving document from API: ${figmaError.err}`);
100
+ throw new Error(
101
+ `Error retrieving document from API: ${figmaError.err}`
102
+ );
101
103
  }
102
104
  const document = parsedData;
103
105
  if (document.editorType !== "figma") {
104
- throw new Error(`Error retrieving document from API: document is for ${document.editorType}`);
106
+ throw new Error(
107
+ `Error retrieving document from API: document is for ${document.editorType}`
108
+ );
105
109
  }
106
110
  if (identicalDates(options.ifModifiedSince, document.lastModified)) {
107
111
  return "not_modified";
@@ -133,13 +137,16 @@ async function figmaImagesQuery(options, nodes, cache) {
133
137
  if (svgOptions.useAbsoluteBounds) {
134
138
  params.set("use_absolute_bounds", "true");
135
139
  }
136
- const data = await download_api_index.sendAPIQuery({
137
- uri,
138
- params,
139
- headers: {
140
- "X-FIGMA-TOKEN": options.token
141
- }
142
- }, cache);
140
+ const data = await download_api_index.sendAPIQuery(
141
+ {
142
+ uri,
143
+ params,
144
+ headers: {
145
+ "X-FIGMA-TOKEN": options.token
146
+ }
147
+ },
148
+ cache
149
+ );
143
150
  if (typeof data === "number") {
144
151
  lastError = data;
145
152
  return;
@@ -175,7 +182,9 @@ async function figmaImagesQuery(options, nodes, cache) {
175
182
  }
176
183
  if (!found) {
177
184
  if (lastError) {
178
- throw new Error(`Error retrieving image data from API${lastError ? ": " + lastError : ""}`);
185
+ throw new Error(
186
+ `Error retrieving image data from API${lastError ? ": " + lastError.toString() : ""}`
187
+ );
179
188
  } else {
180
189
  throw new Error("No valid icon layers were found");
181
190
  }
@@ -194,9 +203,12 @@ async function figmaDownloadImages(nodes, cache) {
194
203
  if (!item.url) {
195
204
  continue;
196
205
  }
197
- const result = await download_api_index.sendAPIQuery({
198
- uri: item.url
199
- }, cache);
206
+ const result = await download_api_index.sendAPIQuery(
207
+ {
208
+ uri: item.url
209
+ },
210
+ cache
211
+ );
200
212
  if (typeof result === "number") {
201
213
  lastError = result;
202
214
  continue;
@@ -207,7 +219,9 @@ async function figmaDownloadImages(nodes, cache) {
207
219
  }
208
220
  }
209
221
  if (!count) {
210
- throw new Error(`Error retrieving images${lastError ? ": " + lastError : ""}`);
222
+ throw new Error(
223
+ `Error retrieving images${lastError ? ": " + lastError.toString() : ""}`
224
+ );
211
225
  }
212
226
  nodes.downloadedIconsCount = count;
213
227
  return nodes;
@@ -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-6360d61e.js';
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';
@@ -26,7 +26,7 @@ async function figmaFilesQuery(options, cache) {
26
26
  params.set("version", options.version);
27
27
  }
28
28
  if (options.depth) {
29
- params.set("depth", options.depth + "");
29
+ params.set("depth", options.depth.toString());
30
30
  }
31
31
  const queryParams = {
32
32
  uri: "https://api.figma.com/v1/files/" + options.file,
@@ -93,11 +93,15 @@ async function figmaFilesQuery(options, cache) {
93
93
  }
94
94
  if (typeof parsedData.status === "number") {
95
95
  const figmaError = parsedData;
96
- throw new Error(`Error retrieving document from API: ${figmaError.err}`);
96
+ throw new Error(
97
+ `Error retrieving document from API: ${figmaError.err}`
98
+ );
97
99
  }
98
100
  const document = parsedData;
99
101
  if (document.editorType !== "figma") {
100
- throw new Error(`Error retrieving document from API: document is for ${document.editorType}`);
102
+ throw new Error(
103
+ `Error retrieving document from API: document is for ${document.editorType}`
104
+ );
101
105
  }
102
106
  if (identicalDates(options.ifModifiedSince, document.lastModified)) {
103
107
  return "not_modified";
@@ -129,13 +133,16 @@ async function figmaImagesQuery(options, nodes, cache) {
129
133
  if (svgOptions.useAbsoluteBounds) {
130
134
  params.set("use_absolute_bounds", "true");
131
135
  }
132
- const data = await sendAPIQuery({
133
- uri,
134
- params,
135
- headers: {
136
- "X-FIGMA-TOKEN": options.token
137
- }
138
- }, cache);
136
+ const data = await sendAPIQuery(
137
+ {
138
+ uri,
139
+ params,
140
+ headers: {
141
+ "X-FIGMA-TOKEN": options.token
142
+ }
143
+ },
144
+ cache
145
+ );
139
146
  if (typeof data === "number") {
140
147
  lastError = data;
141
148
  return;
@@ -171,7 +178,9 @@ async function figmaImagesQuery(options, nodes, cache) {
171
178
  }
172
179
  if (!found) {
173
180
  if (lastError) {
174
- throw new Error(`Error retrieving image data from API${lastError ? ": " + lastError : ""}`);
181
+ throw new Error(
182
+ `Error retrieving image data from API${lastError ? ": " + lastError.toString() : ""}`
183
+ );
175
184
  } else {
176
185
  throw new Error("No valid icon layers were found");
177
186
  }
@@ -190,9 +199,12 @@ async function figmaDownloadImages(nodes, cache) {
190
199
  if (!item.url) {
191
200
  continue;
192
201
  }
193
- const result = await sendAPIQuery({
194
- uri: item.url
195
- }, cache);
202
+ const result = await sendAPIQuery(
203
+ {
204
+ uri: item.url
205
+ },
206
+ cache
207
+ );
196
208
  if (typeof result === "number") {
197
209
  lastError = result;
198
210
  continue;
@@ -203,7 +215,9 @@ async function figmaDownloadImages(nodes, cache) {
203
215
  }
204
216
  }
205
217
  if (!count) {
206
- throw new Error(`Error retrieving images${lastError ? ": " + lastError : ""}`);
218
+ throw new Error(
219
+ `Error retrieving images${lastError ? ": " + lastError.toString() : ""}`
220
+ );
207
221
  }
208
222
  nodes.downloadedIconsCount = count;
209
223
  return nodes;
@@ -25,7 +25,7 @@ interface FigmaDocumentNode extends BaseFigmaNode {
25
25
  type: 'DOCUMENT';
26
26
  children: FigmaNode[];
27
27
  }
28
- declare type FigmaNode = GenericFigmaNode | IconFigmaNode;
28
+ type FigmaNode = GenericFigmaNode | IconFigmaNode;
29
29
  /**
30
30
  * Document response from API
31
31
  */
@@ -1,14 +1,14 @@
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-6360d61e.js';
4
+ 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
8
  import '@iconify/utils/lib/icon-set/tree';
9
9
 
10
- declare type FigmaImportParentNodeType = 'CANVAS' | 'FRAME' | 'GROUP';
11
- declare type FigmaImportIconNodeType = IconFigmaNode['type'];
10
+ type FigmaImportParentNodeType = 'CANVAS' | 'FRAME' | 'GROUP';
11
+ type FigmaImportIconNodeType = IconFigmaNode['type'];
12
12
  /**
13
13
  * Node information passed to callback
14
14
  */
@@ -30,14 +30,14 @@ interface FigmaImportNodeData {
30
30
  *
31
31
  * Used to speed up processing by eleminating pages, frames and groups that do not need processing
32
32
  */
33
- declare type FigmaImportParentNodeFilter = (node: FigmaParentNodeData[], document: FigmaDocument) => boolean;
33
+ type FigmaImportParentNodeFilter = (node: FigmaParentNodeData[], document: FigmaDocument) => boolean;
34
34
  /**
35
35
  * Check if node is an icon.
36
36
  *
37
37
  * Returns icon name on success, null or undefined if not should be ignored.
38
38
  * Function can also return FigmaIconNode object, where it can put extra properties that can be used later
39
39
  */
40
- declare type FigmaIconNodeWithKeyword = Partial<FigmaIconNode> & Pick<FigmaIconNode, 'keyword'>;
41
- declare type FigmaImportNodeFilter = (node: FigmaImportNodeData, nodes: FigmaNodesImportResult, document: FigmaDocument) => string | FigmaIconNodeWithKeyword | null | undefined;
40
+ type FigmaIconNodeWithKeyword = Partial<FigmaIconNode> & Pick<FigmaIconNode, 'keyword'>;
41
+ type FigmaImportNodeFilter = (node: FigmaImportNodeData, nodes: FigmaNodesImportResult, document: FigmaDocument) => string | FigmaIconNodeWithKeyword | null | undefined;
42
42
 
43
43
  export { FigmaImportIconNodeType, FigmaImportNodeData, FigmaImportNodeFilter, FigmaImportParentNodeFilter, FigmaImportParentNodeType, FigmaParentNodeData };
@@ -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-6360d61e.js';
4
+ import '@iconify/types';
5
5
  import '@iconify/utils/lib/customisations/defaults';
6
6
  import '../../../icon-set/types.js';
7
7
  import '../../../svg/index.js';
@@ -42,7 +42,7 @@ interface FigmaGetIconNodesOptions {
42
42
  /**
43
43
  * Callback to call before or after importing icon
44
44
  */
45
- declare type FigmaImportedIconCallback = (node: FigmaIconNode, iconSet: IconSet) => void | Promise<void>;
45
+ type FigmaImportedIconCallback = (node: FigmaIconNode, iconSet: IconSet) => void | Promise<void>;
46
46
  /**
47
47
  * Options for main import function
48
48
  */
@@ -1,5 +1,5 @@
1
1
  import { IconSet } from '../../../icon-set/index.js';
2
- import '../../../types-6360d61e.js';
2
+ import '@iconify/types';
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
@@ -15,6 +15,7 @@ const svg_cleanup_rootSvg = require('./svg/cleanup/root-svg.cjs');
15
15
  const svg_cleanup_svgoStyle = require('./svg/cleanup/svgo-style.cjs');
16
16
  const iconSet_index = require('./icon-set/index.cjs');
17
17
  const iconSet_merge = require('./icon-set/merge.cjs');
18
+ const iconSet_tags = require('./icon-set/tags.cjs');
18
19
  const import_figma_index = require('./import/figma/index.cjs');
19
20
  const import_directory = require('./import/directory.cjs');
20
21
  const download_git_index = require('./download/git/index.cjs');
@@ -31,6 +32,7 @@ const download_index = require('./download/index.cjs');
31
32
  const download_api_download = require('./download/api/download.cjs');
32
33
  const colors_parse = require('./colors/parse.cjs');
33
34
  const colors_validate = require('./colors/validate.cjs');
35
+ const colors_detect = require('./colors/detect.cjs');
34
36
  const optimise_svgo = require('./optimise/svgo.cjs');
35
37
  const optimise_flags = require('./optimise/flags.cjs');
36
38
  const optimise_scale = require('./optimise/scale.cjs');
@@ -69,6 +71,8 @@ require('./icon-set/props.cjs');
69
71
  require('@iconify/utils/lib/misc/objects');
70
72
  require('./icon-set/match.cjs');
71
73
  require('./icon-set/modified.cjs');
74
+ require('@iconify/utils/lib/colors');
75
+ require('./colors/attribs.cjs');
72
76
  require('./import/figma/nodes.cjs');
73
77
  require('./import/figma/query.cjs');
74
78
  require('./download/api/cache.cjs');
@@ -76,15 +80,12 @@ require('fs');
76
80
  require('crypto');
77
81
  require('node-fetch');
78
82
  require('pathe');
79
- require('path');
80
83
  require('child_process');
81
84
  require('util');
82
85
  require('stream');
83
86
  require('extract-zip');
84
87
  require('tar');
85
- require('@iconify/utils/lib/colors');
86
88
  require('./download/gitlab/types.cjs');
87
- require('./colors/attribs.cjs');
88
89
  require('./export/helpers/custom-files.cjs');
89
90
 
90
91
 
@@ -103,6 +104,7 @@ exports.convertStyleToAttrs = svg_cleanup_svgoStyle.convertStyleToAttrs;
103
104
  exports.IconSet = iconSet_index.IconSet;
104
105
  exports.blankIconSet = iconSet_index.blankIconSet;
105
106
  exports.mergeIconSets = iconSet_merge.mergeIconSets;
107
+ exports.addTagsToIconSet = iconSet_tags.addTagsToIconSet;
106
108
  exports.importFromFigma = import_figma_index.importFromFigma;
107
109
  exports.importDirectory = import_directory.importDirectory;
108
110
  exports.downloadGitRepo = download_git_index.downloadGitRepo;
@@ -121,6 +123,7 @@ exports.downloadFile = download_api_download.downloadFile;
121
123
  exports.isEmptyColor = colors_parse.isEmptyColor;
122
124
  exports.parseColors = colors_parse.parseColors;
123
125
  exports.validateColors = colors_validate.validateColors;
126
+ exports.detectIconSetPalette = colors_detect.detectIconSetPalette;
124
127
  exports.runSVGO = optimise_svgo.runSVGO;
125
128
  exports.deOptimisePaths = optimise_flags.deOptimisePaths;
126
129
  exports.scaleSVG = optimise_scale.scaleSVG;
package/lib/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export { cleanupSVGRoot } from './svg/cleanup/root-svg.js';
11
11
  export { convertStyleToAttrs } from './svg/cleanup/svgo-style.js';
12
12
  export { IconSet, blankIconSet } from './icon-set/index.js';
13
13
  export { mergeIconSets } from './icon-set/merge.js';
14
+ export { addTagsToIconSet } from './icon-set/tags.js';
14
15
  export { importFromFigma } from './import/figma/index.js';
15
16
  export { importDirectory } from './import/directory.js';
16
17
  export { downloadGitRepo } from './download/git/index.js';
@@ -27,6 +28,7 @@ export { downloadPackage } from './download/index.js';
27
28
  export { downloadFile } from './download/api/download.js';
28
29
  export { isEmptyColor, parseColors } from './colors/parse.js';
29
30
  export { validateColors } from './colors/validate.js';
31
+ export { detectIconSetPalette } from './colors/detect.js';
30
32
  export { runSVGO } from './optimise/svgo.js';
31
33
  export { deOptimisePaths } from './optimise/flags.js';
32
34
  export { scaleSVG } from './optimise/scale.js';
@@ -44,7 +46,7 @@ export { execAsync } from './misc/exec.js';
44
46
  export { cleanupIconKeyword } from './misc/keyword.js';
45
47
  export { bumpVersion } from './misc/bump-version.js';
46
48
  export { sendAPIQuery } from './download/api/index.js';
47
- import './types-6360d61e.js';
49
+ import '@iconify/types';
48
50
  import '@iconify/utils/lib/customisations/defaults';
49
51
  import './misc/cheerio.js';
50
52
  import './css/parser/types.js';
package/lib/index.mjs CHANGED
@@ -11,6 +11,7 @@ export { cleanupSVGRoot } from './svg/cleanup/root-svg.mjs';
11
11
  export { convertStyleToAttrs } from './svg/cleanup/svgo-style.mjs';
12
12
  export { IconSet, blankIconSet } from './icon-set/index.mjs';
13
13
  export { mergeIconSets } from './icon-set/merge.mjs';
14
+ export { addTagsToIconSet } from './icon-set/tags.mjs';
14
15
  export { importFromFigma } from './import/figma/index.mjs';
15
16
  export { importDirectory } from './import/directory.mjs';
16
17
  export { downloadGitRepo } from './download/git/index.mjs';
@@ -27,6 +28,7 @@ export { downloadPackage } from './download/index.mjs';
27
28
  export { downloadFile } from './download/api/download.mjs';
28
29
  export { isEmptyColor, parseColors } from './colors/parse.mjs';
29
30
  export { validateColors } from './colors/validate.mjs';
31
+ export { detectIconSetPalette } from './colors/detect.mjs';
30
32
  export { runSVGO } from './optimise/svgo.mjs';
31
33
  export { deOptimisePaths } from './optimise/flags.mjs';
32
34
  export { scaleSVG } from './optimise/scale.mjs';
@@ -65,6 +67,8 @@ import './icon-set/props.mjs';
65
67
  import '@iconify/utils/lib/misc/objects';
66
68
  import './icon-set/match.mjs';
67
69
  import './icon-set/modified.mjs';
70
+ import '@iconify/utils/lib/colors';
71
+ import './colors/attribs.mjs';
68
72
  import './import/figma/nodes.mjs';
69
73
  import './import/figma/query.mjs';
70
74
  import './download/api/cache.mjs';
@@ -72,13 +76,10 @@ import 'fs';
72
76
  import 'crypto';
73
77
  import 'node-fetch';
74
78
  import 'pathe';
75
- import 'path';
76
79
  import 'child_process';
77
80
  import 'util';
78
81
  import 'stream';
79
82
  import 'extract-zip';
80
83
  import 'tar';
81
- import '@iconify/utils/lib/colors';
82
84
  import './download/gitlab/types.mjs';
83
- import './colors/attribs.mjs';
84
85
  import './export/helpers/custom-files.mjs';
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Shortcuts for Cheerio elements
3
3
  */
4
- declare type CheerioElement = cheerio.TagElement;
5
- declare type WrappedCheerioElement = cheerio.Cheerio;
4
+ type CheerioElement = cheerio.TagElement;
5
+ type WrappedCheerioElement = cheerio.Cheerio;
6
6
 
7
7
  export { CheerioElement, WrappedCheerioElement };
@@ -32,7 +32,9 @@ async function compareDirectories(dir1, dir2, options) {
32
32
  options = options || {};
33
33
  const ignoreNewLine = options.ignoreNewLine !== false;
34
34
  const ignoreVersions = options.ignoreVersions !== false;
35
- const textExtensions = new Set((options.textExtensions || []).concat(textFileExtensions));
35
+ const textExtensions = new Set(
36
+ (options.textExtensions || []).concat(textFileExtensions)
37
+ );
36
38
  for (let i = 0; i < files1.length; i++) {
37
39
  const file = files1[i];
38
40
  if (files2.indexOf(file) === -1) {
@@ -28,7 +28,9 @@ async function compareDirectories(dir1, dir2, options) {
28
28
  options = options || {};
29
29
  const ignoreNewLine = options.ignoreNewLine !== false;
30
30
  const ignoreVersions = options.ignoreVersions !== false;
31
- const textExtensions = new Set((options.textExtensions || []).concat(textFileExtensions));
31
+ const textExtensions = new Set(
32
+ (options.textExtensions || []).concat(textFileExtensions)
33
+ );
32
34
  for (let i = 0; i < files1.length; i++) {
33
35
  const file = files1[i];
34
36
  if (files2.indexOf(file) === -1) {
package/lib/misc/exec.cjs CHANGED
@@ -2,19 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const path = require('path');
5
+ const pathe = require('pathe');
6
6
  const child_process = require('child_process');
7
7
 
8
8
  function execAsync(cmd, options) {
9
9
  return new Promise((fulfill, reject) => {
10
- const fullOptions = {
11
- ...options,
12
- encoding: "utf8"
13
- };
14
- if (fullOptions.cwd) {
15
- fullOptions.cwd = path.resolve(fullOptions.cwd);
10
+ if (typeof options?.cwd === "string") {
11
+ options = {
12
+ ...options,
13
+ cwd: pathe.resolve(options.cwd)
14
+ };
16
15
  }
17
- child_process.exec(cmd, fullOptions, (error, stdout, stderr) => {
16
+ child_process.exec(cmd, options, (error, stdout, stderr) => {
18
17
  if (error) {
19
18
  reject(error);
20
19
  } else {
package/lib/misc/exec.mjs CHANGED
@@ -1,16 +1,15 @@
1
- import { resolve } from 'path';
1
+ import { resolve } from 'pathe';
2
2
  import { exec } from 'child_process';
3
3
 
4
4
  function execAsync(cmd, options) {
5
5
  return new Promise((fulfill, reject) => {
6
- const fullOptions = {
7
- ...options,
8
- encoding: "utf8"
9
- };
10
- if (fullOptions.cwd) {
11
- fullOptions.cwd = resolve(fullOptions.cwd);
6
+ if (typeof options?.cwd === "string") {
7
+ options = {
8
+ ...options,
9
+ cwd: resolve(options.cwd)
10
+ };
12
11
  }
13
- exec(cmd, fullOptions, (error, stdout, stderr) => {
12
+ exec(cmd, options, (error, stdout, stderr) => {
14
13
  if (error) {
15
14
  reject(error);
16
15
  } else {
@@ -4,7 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function cleanupIconKeyword(keyword, convertCamelCase = false) {
6
6
  if (convertCamelCase) {
7
- keyword = keyword.replace(/[A-Z]+/g, (chars) => "_" + chars.toLowerCase());
7
+ keyword = keyword.replace(
8
+ /[A-Z]+/g,
9
+ (chars) => "_" + chars.toLowerCase()
10
+ );
8
11
  }
9
12
  keyword = keyword.toLowerCase().trim().replace(/[\s_.:]/g, "-").replace(/[^a-z0-9-]/g, "").replace(/[-]+/g, "-");
10
13
  if (keyword.slice(0, 1) === "-") {
@@ -1,6 +1,9 @@
1
1
  function cleanupIconKeyword(keyword, convertCamelCase = false) {
2
2
  if (convertCamelCase) {
3
- keyword = keyword.replace(/[A-Z]+/g, (chars) => "_" + chars.toLowerCase());
3
+ keyword = keyword.replace(
4
+ /[A-Z]+/g,
5
+ (chars) => "_" + chars.toLowerCase()
6
+ );
4
7
  }
5
8
  keyword = keyword.toLowerCase().trim().replace(/[\s_.:]/g, "-").replace(/[^a-z0-9-]/g, "").replace(/[-]+/g, "-");
6
9
  if (keyword.slice(0, 1) === "-") {
package/lib/misc/scan.cjs CHANGED
@@ -41,7 +41,9 @@ async function scanDirectory(path, callback, subdirs = true) {
41
41
  } else {
42
42
  callbackResult = true;
43
43
  }
44
- results.push(callbackResult === true ? subdir + filename : callbackResult);
44
+ results.push(
45
+ callbackResult === true ? subdir + filename : callbackResult
46
+ );
45
47
  }
46
48
  }
47
49
  await scan("");
@@ -13,11 +13,11 @@ import { Stats } from 'fs';
13
13
  * - string to include custom string (such as file without extension)
14
14
  * - custom object to return custom object
15
15
  */
16
- declare type ScanDirectoryCallbackFalseResult = boolean | null | undefined;
17
- declare type ScanDirectoryCallbackStringResult = ScanDirectoryCallbackFalseResult | string;
18
- declare type ScanDirectoryCallbackAsString = (ext: string, file: string, subdir: string, path: string, stat: Stats) => ScanDirectoryCallbackStringResult | Promise<ScanDirectoryCallbackStringResult>;
19
- declare type ScanDirectoryCallbackAsCustom<T> = (ext: string, file: string, subdir: string, path: string, stat: Stats) => T | ScanDirectoryCallbackFalseResult | Promise<T | ScanDirectoryCallbackFalseResult>;
20
- declare type ScanDirectoryCallback = ScanDirectoryCallbackAsCustom<unknown> | ScanDirectoryCallbackAsString;
16
+ type ScanDirectoryCallbackFalseResult = boolean | null | undefined;
17
+ type ScanDirectoryCallbackStringResult = ScanDirectoryCallbackFalseResult | string;
18
+ type ScanDirectoryCallbackAsString = (ext: string, file: string, subdir: string, path: string, stat: Stats) => ScanDirectoryCallbackStringResult | Promise<ScanDirectoryCallbackStringResult>;
19
+ type ScanDirectoryCallbackAsCustom<T> = (ext: string, file: string, subdir: string, path: string, stat: Stats) => T | ScanDirectoryCallbackFalseResult | Promise<T | ScanDirectoryCallbackFalseResult>;
20
+ type ScanDirectoryCallback = ScanDirectoryCallbackAsCustom<unknown> | ScanDirectoryCallbackAsString;
21
21
  /**
22
22
  * Find all files in directory
23
23
  */
package/lib/misc/scan.mjs CHANGED
@@ -37,7 +37,9 @@ async function scanDirectory(path, callback, subdirs = true) {
37
37
  } else {
38
38
  callbackResult = true;
39
39
  }
40
- results.push(callbackResult === true ? subdir + filename : callbackResult);
40
+ results.push(
41
+ callbackResult === true ? subdir + filename : callbackResult
42
+ );
41
43
  }
42
44
  }
43
45
  await scan("");
@@ -66,7 +66,9 @@ function cleanPath(path) {
66
66
  }
67
67
  if (currentCommandType === ARC) {
68
68
  if (currentArgs.length < 2 && value <= 0) {
69
- throw new Error(`Expected positive number, got "${value}" at ${i}`);
69
+ throw new Error(
70
+ `Expected positive number, got "${value}" at ${i}`
71
+ );
70
72
  }
71
73
  while (true) {
72
74
  if (currentArgs.length < 3 || currentArgs.length > 4) {
@@ -80,14 +82,18 @@ function cleanPath(path) {
80
82
  const newValue = Number(newNumber);
81
83
  if (slice === "0" || slice === "1") {
82
84
  if (isNaN(newValue)) {
83
- throw new Error(`Invalid number "${currentNumber}" at ${i}`);
85
+ throw new Error(
86
+ `Invalid number "${currentNumber}" at ${i}`
87
+ );
84
88
  }
85
89
  currentArgs.push(slice);
86
90
  currentNumber = newNumber;
87
91
  value = newValue;
88
92
  continue;
89
93
  }
90
- throw new Error(`Expected a flag, got "${currentNumber}" at ${i}`);
94
+ throw new Error(
95
+ `Expected a flag, got "${currentNumber}" at ${i}`
96
+ );
91
97
  }
92
98
  }
93
99
  currentArgs.push(currentNumber);
@@ -1,5 +1,5 @@
1
1
  import { SVG } from '../svg/index.js';
2
- import '../types-6360d61e.js';
2
+ import '@iconify/types';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
@@ -62,7 +62,9 @@ function cleanPath(path) {
62
62
  }
63
63
  if (currentCommandType === ARC) {
64
64
  if (currentArgs.length < 2 && value <= 0) {
65
- throw new Error(`Expected positive number, got "${value}" at ${i}`);
65
+ throw new Error(
66
+ `Expected positive number, got "${value}" at ${i}`
67
+ );
66
68
  }
67
69
  while (true) {
68
70
  if (currentArgs.length < 3 || currentArgs.length > 4) {
@@ -76,14 +78,18 @@ function cleanPath(path) {
76
78
  const newValue = Number(newNumber);
77
79
  if (slice === "0" || slice === "1") {
78
80
  if (isNaN(newValue)) {
79
- throw new Error(`Invalid number "${currentNumber}" at ${i}`);
81
+ throw new Error(
82
+ `Invalid number "${currentNumber}" at ${i}`
83
+ );
80
84
  }
81
85
  currentArgs.push(slice);
82
86
  currentNumber = newNumber;
83
87
  value = newValue;
84
88
  continue;
85
89
  }
86
- throw new Error(`Expected a flag, got "${currentNumber}" at ${i}`);
90
+ throw new Error(
91
+ `Expected a flag, got "${currentNumber}" at ${i}`
92
+ );
87
93
  }
88
94
  }
89
95
  currentArgs.push(currentNumber);
@@ -108,7 +108,9 @@ async function cleanupGlobalStyle(svg) {
108
108
  if (!isMatch(tagName, $element)) {
109
109
  return;
110
110
  }
111
- const addedAttributes = new Set($element.attr(tempDataAttrbiute)?.split(/\s+/));
111
+ const addedAttributes = new Set(
112
+ $element.attr(tempDataAttrbiute)?.split(/\s+/)
113
+ );
112
114
  const prop = styleItem.prop;
113
115
  if ($element.attr(prop) !== void 0) {
114
116
  if (addedAttributes.has(prop)) {
@@ -117,7 +119,10 @@ async function cleanupGlobalStyle(svg) {
117
119
  }
118
120
  $element.attr(prop, styleItem.value);
119
121
  addedAttributes.add(prop);
120
- $element.attr(tempDataAttrbiute, Array.from(addedAttributes).join(" "));
122
+ $element.attr(
123
+ tempDataAttrbiute,
124
+ Array.from(addedAttributes).join(" ")
125
+ );
121
126
  containsTempAttr = true;
122
127
  });
123
128
  const classMatches = matches.filter((item) => item.type === "class").map((item) => item.value);
@@ -131,7 +136,9 @@ async function cleanupGlobalStyle(svg) {
131
136
  if (!classList) {
132
137
  return;
133
138
  }
134
- const filtered = classList.filter((item) => classMatches.indexOf(item) === -1);
139
+ const filtered = classList.filter(
140
+ (item) => classMatches.indexOf(item) === -1
141
+ );
135
142
  if (!filtered.length) {
136
143
  $element.removeAttr("class");
137
144
  } else {
@@ -1,5 +1,5 @@
1
1
  import { SVG } from '../svg/index.js';
2
- import '../types-6360d61e.js';
2
+ import '@iconify/types';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**