@iconify/tools 2.0.14 → 2.0.15

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 (309) hide show
  1. package/lib/colors/attribs.cjs +30 -0
  2. package/lib/colors/attribs.d.ts +13 -10
  3. package/lib/colors/attribs.mjs +7 -13
  4. package/lib/colors/parse.cjs +269 -0
  5. package/lib/colors/parse.d.ts +15 -11
  6. package/lib/colors/parse.mjs +27 -31
  7. package/lib/colors/validate.cjs +52 -0
  8. package/lib/colors/validate.d.ts +11 -4
  9. package/lib/colors/validate.mjs +19 -6
  10. package/lib/css/parse.cjs +26 -0
  11. package/lib/css/parse.d.ts +3 -1
  12. package/lib/css/parse.mjs +8 -6
  13. package/lib/css/parser/error.cjs +25 -0
  14. package/lib/css/parser/error.d.ts +4 -2
  15. package/lib/css/parser/error.mjs +2 -4
  16. package/lib/css/parser/export.cjs +48 -0
  17. package/lib/css/parser/export.d.ts +5 -2
  18. package/lib/css/parser/export.mjs +4 -6
  19. package/lib/css/parser/strings.cjs +77 -0
  20. package/lib/css/parser/strings.d.ts +6 -3
  21. package/lib/css/parser/strings.mjs +4 -6
  22. package/lib/css/parser/text.cjs +135 -0
  23. package/lib/css/parser/text.d.ts +8 -5
  24. package/lib/css/parser/text.mjs +3 -8
  25. package/lib/css/parser/tokens.cjs +184 -0
  26. package/lib/css/parser/tokens.d.ts +6 -3
  27. package/lib/css/parser/tokens.mjs +7 -13
  28. package/lib/css/parser/tree.cjs +42 -0
  29. package/lib/css/parser/tree.d.ts +5 -2
  30. package/lib/css/parser/tree.mjs +2 -4
  31. package/lib/css/parser/types.cjs +2 -0
  32. package/lib/css/parser/types.d.ts +13 -11
  33. package/lib/css/parser/types.mjs +1 -0
  34. package/lib/download/api/cache.cjs +86 -0
  35. package/lib/download/api/cache.d.ts +8 -5
  36. package/lib/download/api/cache.mjs +14 -19
  37. package/lib/download/api/download.cjs +28 -0
  38. package/lib/download/api/download.d.ts +5 -2
  39. package/lib/download/api/download.mjs +8 -9
  40. package/lib/download/api/index.cjs +51 -0
  41. package/lib/download/api/index.d.ts +5 -2
  42. package/lib/download/api/index.mjs +8 -6
  43. package/lib/download/api/types.cjs +2 -0
  44. package/lib/download/api/types.d.ts +4 -2
  45. package/lib/download/api/types.mjs +1 -0
  46. package/lib/download/git/branch.cjs +22 -0
  47. package/lib/download/git/branch.d.ts +5 -2
  48. package/lib/download/git/branch.mjs +5 -5
  49. package/lib/download/git/hash.cjs +15 -0
  50. package/lib/download/git/hash.d.ts +5 -2
  51. package/lib/download/git/hash.mjs +5 -5
  52. package/lib/download/git/index.cjs +76 -0
  53. package/lib/download/git/index.d.ts +10 -8
  54. package/lib/download/git/index.mjs +41 -26
  55. package/lib/download/git/reset.cjs +41 -0
  56. package/lib/download/git/reset.d.ts +3 -1
  57. package/lib/download/git/reset.mjs +29 -5
  58. package/lib/download/github/hash.cjs +32 -0
  59. package/lib/download/github/hash.d.ts +5 -2
  60. package/lib/download/github/hash.mjs +10 -7
  61. package/lib/download/github/index.cjs +98 -0
  62. package/lib/download/github/index.d.ts +11 -9
  63. package/lib/download/github/index.mjs +23 -17
  64. package/lib/download/github/types.cjs +2 -0
  65. package/lib/download/github/types.d.ts +3 -1
  66. package/lib/download/github/types.mjs +1 -0
  67. package/lib/download/gitlab/hash.cjs +32 -0
  68. package/lib/download/gitlab/hash.d.ts +5 -2
  69. package/lib/download/gitlab/hash.mjs +10 -6
  70. package/lib/download/gitlab/index.cjs +98 -0
  71. package/lib/download/gitlab/index.d.ts +11 -9
  72. package/lib/download/gitlab/index.mjs +24 -18
  73. package/lib/download/gitlab/types.cjs +7 -0
  74. package/lib/download/gitlab/types.d.ts +4 -2
  75. package/lib/download/gitlab/types.mjs +3 -5
  76. package/lib/download/helpers/untar.cjs +14 -0
  77. package/lib/download/helpers/untar.d.ts +3 -1
  78. package/lib/download/helpers/untar.mjs +4 -5
  79. package/lib/download/helpers/unzip.cjs +19 -0
  80. package/lib/download/helpers/unzip.d.ts +3 -1
  81. package/lib/download/helpers/unzip.mjs +6 -7
  82. package/lib/download/index.cjs +64 -0
  83. package/lib/download/index.d.ts +18 -13
  84. package/lib/download/index.mjs +46 -19
  85. package/lib/download/npm/index.cjs +82 -0
  86. package/lib/download/npm/index.d.ts +10 -8
  87. package/lib/download/npm/index.mjs +16 -13
  88. package/lib/download/npm/types.cjs +2 -0
  89. package/lib/download/npm/types.d.ts +3 -1
  90. package/lib/download/npm/types.mjs +1 -0
  91. package/lib/download/npm/version.cjs +23 -0
  92. package/lib/download/npm/version.d.ts +7 -4
  93. package/lib/download/npm/version.mjs +8 -10
  94. package/lib/download/types/modified.cjs +2 -0
  95. package/lib/download/types/modified.d.ts +3 -1
  96. package/lib/download/types/modified.mjs +1 -0
  97. package/lib/download/types/sources.cjs +2 -0
  98. package/lib/download/types/sources.d.ts +4 -2
  99. package/lib/download/types/sources.mjs +1 -0
  100. package/lib/export/directory.cjs +45 -0
  101. package/lib/export/directory.d.ts +11 -4
  102. package/lib/export/directory.mjs +8 -8
  103. package/lib/export/helpers/custom-files.cjs +28 -0
  104. package/lib/export/helpers/custom-files.d.ts +4 -2
  105. package/lib/export/helpers/custom-files.mjs +8 -9
  106. package/lib/export/helpers/prepare.cjs +36 -0
  107. package/lib/export/helpers/prepare.d.ts +5 -3
  108. package/lib/export/helpers/prepare.mjs +7 -9
  109. package/lib/export/helpers/types-version.cjs +22 -0
  110. package/lib/export/helpers/types-version.d.ts +3 -1
  111. package/lib/export/helpers/types-version.mjs +15 -37
  112. package/lib/export/icon-package.cjs +59 -0
  113. package/lib/export/icon-package.d.ts +12 -5
  114. package/lib/export/icon-package.mjs +15 -16
  115. package/lib/export/json-package.cjs +133 -0
  116. package/lib/export/json-package.d.ts +12 -5
  117. package/lib/export/json-package.mjs +20 -21
  118. package/lib/icon-set/index.cjs +589 -0
  119. package/lib/icon-set/index.d.ts +9 -6
  120. package/lib/icon-set/index.mjs +40 -53
  121. package/lib/icon-set/match.cjs +58 -0
  122. package/lib/icon-set/match.d.ts +10 -3
  123. package/lib/icon-set/match.mjs +5 -6
  124. package/lib/icon-set/merge.cjs +83 -0
  125. package/lib/icon-set/merge.d.ts +9 -2
  126. package/lib/icon-set/merge.mjs +15 -10
  127. package/lib/icon-set/props.cjs +28 -0
  128. package/lib/icon-set/props.d.ts +8 -4
  129. package/lib/icon-set/props.mjs +7 -10
  130. package/lib/icon-set/types.cjs +2 -0
  131. package/lib/icon-set/types.d.ts +19 -17
  132. package/lib/icon-set/types.mjs +1 -0
  133. package/lib/import/directory.cjs +76 -0
  134. package/lib/import/directory.d.ts +11 -5
  135. package/lib/import/directory.mjs +36 -11
  136. package/lib/import/figma/index.cjs +105 -0
  137. package/lib/import/figma/index.d.ts +15 -5
  138. package/lib/import/figma/index.mjs +40 -13
  139. package/lib/import/figma/nodes.cjs +86 -0
  140. package/lib/import/figma/nodes.d.ts +13 -4
  141. package/lib/import/figma/nodes.mjs +3 -11
  142. package/lib/import/figma/query.cjs +218 -0
  143. package/lib/import/figma/query.d.ts +18 -9
  144. package/lib/import/figma/query.mjs +9 -12
  145. package/lib/import/figma/types/api.cjs +2 -0
  146. package/lib/import/figma/types/api.d.ts +8 -7
  147. package/lib/import/figma/types/api.mjs +1 -0
  148. package/lib/import/figma/types/nodes.cjs +2 -0
  149. package/lib/import/figma/types/nodes.d.ts +16 -9
  150. package/lib/import/figma/types/nodes.mjs +1 -0
  151. package/lib/import/figma/types/options.cjs +2 -0
  152. package/lib/import/figma/types/options.d.ts +17 -10
  153. package/lib/import/figma/types/options.mjs +1 -0
  154. package/lib/import/figma/types/result.cjs +2 -0
  155. package/lib/import/figma/types/result.d.ts +12 -5
  156. package/lib/import/figma/types/result.mjs +1 -0
  157. package/lib/index.cjs +137 -0
  158. package/lib/index.d.ts +65 -44
  159. package/lib/index.mjs +83 -94
  160. package/lib/misc/bump-version.cjs +17 -0
  161. package/lib/misc/bump-version.d.ts +3 -1
  162. package/lib/misc/bump-version.mjs +2 -4
  163. package/lib/misc/compare-dirs.cjs +75 -0
  164. package/lib/misc/compare-dirs.d.ts +4 -2
  165. package/lib/misc/compare-dirs.mjs +12 -12
  166. package/lib/misc/exec.cjs +25 -0
  167. package/lib/misc/exec.d.ts +6 -4
  168. package/lib/misc/exec.mjs +4 -5
  169. package/lib/misc/keyword.cjs +19 -0
  170. package/lib/misc/keyword.d.ts +3 -1
  171. package/lib/misc/keyword.mjs +2 -4
  172. package/lib/misc/scan.cjs +51 -0
  173. package/lib/misc/scan.d.ts +7 -6
  174. package/lib/misc/scan.mjs +6 -7
  175. package/lib/misc/write-json.cjs +11 -0
  176. package/lib/misc/write-json.d.ts +3 -1
  177. package/lib/misc/write-json.mjs +5 -6
  178. package/lib/optimise/flags.cjs +252 -0
  179. package/lib/optimise/flags.d.ts +7 -2
  180. package/lib/optimise/flags.mjs +18 -19
  181. package/lib/optimise/global-style.cjs +154 -0
  182. package/lib/optimise/global-style.d.ts +7 -2
  183. package/lib/optimise/global-style.mjs +18 -15
  184. package/lib/optimise/scale.cjs +26 -0
  185. package/lib/optimise/scale.d.ts +7 -2
  186. package/lib/optimise/scale.mjs +5 -5
  187. package/lib/optimise/svgo.cjs +83 -0
  188. package/lib/optimise/svgo.d.ts +10 -6
  189. package/lib/optimise/svgo.mjs +6 -9
  190. package/lib/svg/analyse/error.cjs +18 -0
  191. package/lib/svg/analyse/error.d.ts +5 -2
  192. package/lib/svg/analyse/error.mjs +2 -4
  193. package/lib/svg/analyse/types.cjs +2 -0
  194. package/lib/svg/analyse/types.d.ts +11 -11
  195. package/lib/svg/analyse/types.mjs +1 -0
  196. package/lib/svg/analyse.cjs +291 -0
  197. package/lib/svg/analyse.d.ts +8 -3
  198. package/lib/svg/analyse.mjs +15 -30
  199. package/lib/svg/cleanup/attribs.cjs +41 -0
  200. package/lib/svg/cleanup/attribs.d.ts +7 -2
  201. package/lib/svg/cleanup/attribs.mjs +6 -12
  202. package/lib/svg/cleanup/bad-tags.cjs +51 -0
  203. package/lib/svg/cleanup/bad-tags.d.ts +7 -2
  204. package/lib/svg/cleanup/bad-tags.mjs +10 -25
  205. package/lib/svg/cleanup/inline-style.cjs +64 -0
  206. package/lib/svg/cleanup/inline-style.d.ts +7 -2
  207. package/lib/svg/cleanup/inline-style.mjs +14 -19
  208. package/lib/svg/cleanup/root-svg.cjs +81 -0
  209. package/lib/svg/cleanup/root-svg.d.ts +7 -2
  210. package/lib/svg/cleanup/root-svg.mjs +7 -18
  211. package/lib/svg/cleanup/svgo-style.cjs +38 -0
  212. package/lib/svg/cleanup/svgo-style.d.ts +7 -2
  213. package/lib/svg/cleanup/svgo-style.mjs +16 -11
  214. package/lib/svg/cleanup.cjs +32 -0
  215. package/lib/svg/cleanup.d.ts +7 -2
  216. package/lib/svg/cleanup.mjs +21 -9
  217. package/lib/svg/data/attributes.cjs +355 -0
  218. package/lib/svg/data/attributes.d.ts +27 -25
  219. package/lib/svg/data/attributes.mjs +90 -115
  220. package/lib/svg/data/tags.cjs +137 -0
  221. package/lib/svg/data/tags.d.ts +25 -23
  222. package/lib/svg/data/tags.mjs +25 -49
  223. package/lib/svg/index.cjs +130 -0
  224. package/lib/svg/index.d.ts +16 -5
  225. package/lib/svg/index.mjs +48 -14
  226. package/lib/svg/parse-style.cjs +134 -0
  227. package/lib/svg/parse-style.d.ts +12 -8
  228. package/lib/svg/parse-style.mjs +11 -9
  229. package/lib/svg/parse.cjs +42 -0
  230. package/lib/svg/parse.d.ts +11 -7
  231. package/lib/svg/parse.mjs +2 -4
  232. package/package.json +99 -94
  233. package/lib/colors/attribs.js +0 -26
  234. package/lib/colors/parse.js +0 -341
  235. package/lib/colors/validate.js +0 -48
  236. package/lib/css/parse.js +0 -23
  237. package/lib/css/parser/error.js +0 -27
  238. package/lib/css/parser/export.js +0 -69
  239. package/lib/css/parser/strings.js +0 -93
  240. package/lib/css/parser/text.js +0 -171
  241. package/lib/css/parser/tokens.js +0 -200
  242. package/lib/css/parser/tree.js +0 -44
  243. package/lib/css/parser/types.js +0 -2
  244. package/lib/download/api/cache.js +0 -108
  245. package/lib/download/api/download.js +0 -27
  246. package/lib/download/api/index.js +0 -52
  247. package/lib/download/api/types.js +0 -2
  248. package/lib/download/git/branch.js +0 -22
  249. package/lib/download/git/hash.js +0 -14
  250. package/lib/download/git/index.js +0 -75
  251. package/lib/download/git/reset.js +0 -16
  252. package/lib/download/github/hash.js +0 -28
  253. package/lib/download/github/index.js +0 -116
  254. package/lib/download/github/types.js +0 -2
  255. package/lib/download/gitlab/hash.js +0 -27
  256. package/lib/download/gitlab/index.js +0 -115
  257. package/lib/download/gitlab/types.js +0 -7
  258. package/lib/download/helpers/untar.js +0 -14
  259. package/lib/download/helpers/unzip.js +0 -18
  260. package/lib/download/index.js +0 -27
  261. package/lib/download/npm/index.js +0 -91
  262. package/lib/download/npm/types.js +0 -2
  263. package/lib/download/npm/version.js +0 -27
  264. package/lib/download/types/modified.js +0 -2
  265. package/lib/download/types/sources.js +0 -2
  266. package/lib/export/directory.js +0 -52
  267. package/lib/export/helpers/custom-files.js +0 -32
  268. package/lib/export/helpers/prepare.js +0 -49
  269. package/lib/export/helpers/types-version.js +0 -12
  270. package/lib/export/icon-package.js +0 -77
  271. package/lib/export/json-package.js +0 -156
  272. package/lib/icon-set/index.js +0 -749
  273. package/lib/icon-set/match.js +0 -66
  274. package/lib/icon-set/merge.js +0 -90
  275. package/lib/icon-set/props.js +0 -34
  276. package/lib/icon-set/types.js +0 -2
  277. package/lib/import/directory.js +0 -59
  278. package/lib/import/figma/index.js +0 -90
  279. package/lib/import/figma/nodes.js +0 -106
  280. package/lib/import/figma/query.js +0 -244
  281. package/lib/import/figma/types/api.js +0 -12
  282. package/lib/import/figma/types/nodes.js +0 -2
  283. package/lib/import/figma/types/options.js +0 -2
  284. package/lib/import/figma/types/result.js +0 -2
  285. package/lib/index.js +0 -103
  286. package/lib/misc/bump-version.js +0 -19
  287. package/lib/misc/compare-dirs.js +0 -84
  288. package/lib/misc/exec.js +0 -26
  289. package/lib/misc/keyword.js +0 -31
  290. package/lib/misc/scan.js +0 -55
  291. package/lib/misc/write-json.js +0 -11
  292. package/lib/optimise/flags.js +0 -312
  293. package/lib/optimise/global-style.js +0 -185
  294. package/lib/optimise/scale.js +0 -42
  295. package/lib/optimise/svgo.js +0 -99
  296. package/lib/svg/analyse/error.js +0 -22
  297. package/lib/svg/analyse/types.js +0 -2
  298. package/lib/svg/analyse.js +0 -352
  299. package/lib/svg/cleanup/attribs.js +0 -51
  300. package/lib/svg/cleanup/bad-tags.js +0 -65
  301. package/lib/svg/cleanup/inline-style.js +0 -77
  302. package/lib/svg/cleanup/root-svg.js +0 -107
  303. package/lib/svg/cleanup/svgo-style.js +0 -35
  304. package/lib/svg/cleanup.js +0 -24
  305. package/lib/svg/data/attributes.js +0 -403
  306. package/lib/svg/data/tags.js +0 -188
  307. package/lib/svg/index.js +0 -134
  308. package/lib/svg/parse-style.js +0 -151
  309. package/lib/svg/parse.js +0 -49
@@ -1,28 +1,26 @@
1
- // src/icon-set/index.ts
2
- import { fullIcon } from "@iconify/utils/lib/icon";
3
- import { iconToSVG } from "@iconify/utils/lib/svg/build";
4
- import {
5
- defaults
6
- } from "@iconify/utils/lib/customisations";
7
- import { minifyIconSet } from "@iconify/utils/lib/icon-set/minify";
8
- import { convertIconSetInfo } from "@iconify/utils/lib/icon-set/convert-info";
9
- import { extraDefaultProps, filterProps } from "./props.mjs";
10
- import { SVG } from "../svg/index.mjs";
11
- function assertNever(v) {
12
- }
13
- var maxIteration = 6;
14
- var themeKeys = ["prefixes", "suffixes"];
1
+ import { fullIcon } from '@iconify/utils/lib/icon';
2
+ import { iconToSVG } from '@iconify/utils/lib/svg/build';
3
+ import { defaults } from '@iconify/utils/lib/customisations';
4
+ import { minifyIconSet } from '@iconify/utils/lib/icon-set/minify';
5
+ import { convertIconSetInfo } from '@iconify/utils/lib/icon-set/convert-info';
6
+ import { filterProps, extraDefaultProps } from './props.mjs';
7
+ import { SVG } from '../svg/index.mjs';
8
+ import 'cheerio';
9
+ import '@iconify/utils';
10
+
11
+ const maxIteration = 6;
12
+ const themeKeys = ["prefixes", "suffixes"];
15
13
  function sortThemeKeys(keys) {
16
14
  return keys.sort((a, b) => a.length === b.length ? a.localeCompare(b) : b.length - a.length);
17
15
  }
18
- var IconSet = class {
16
+ class IconSet {
19
17
  constructor(data) {
20
18
  this.load(data);
21
19
  }
22
20
  load(data) {
23
21
  this.prefix = data.prefix;
24
22
  const defaultProps = filterProps(data, true);
25
- this.entries = Object.create(null);
23
+ this.entries = /* @__PURE__ */ Object.create(null);
26
24
  const entries = this.entries;
27
25
  for (const name in data.icons) {
28
26
  const item = data.icons[name];
@@ -33,8 +31,8 @@ var IconSet = class {
33
31
  ...defaultProps,
34
32
  ...item
35
33
  }, true),
36
- chars: new Set(),
37
- categories: new Set()
34
+ chars: /* @__PURE__ */ new Set(),
35
+ categories: /* @__PURE__ */ new Set()
38
36
  };
39
37
  entries[name] = entry;
40
38
  }
@@ -43,7 +41,7 @@ var IconSet = class {
43
41
  const item = data.aliases[name];
44
42
  const parent = item.parent;
45
43
  const props = filterProps(item, false);
46
- const chars = new Set();
44
+ const chars = /* @__PURE__ */ new Set();
47
45
  if (Object.keys(props).length) {
48
46
  const entry = {
49
47
  type: "variation",
@@ -73,7 +71,7 @@ var IconSet = class {
73
71
  }
74
72
  }
75
73
  }
76
- this.categories = new Set();
74
+ this.categories = /* @__PURE__ */ new Set();
77
75
  if (data.categories) {
78
76
  for (const category in data.categories) {
79
77
  const item = {
@@ -82,7 +80,7 @@ var IconSet = class {
82
80
  };
83
81
  data.categories[category].forEach((iconName) => {
84
82
  const icon = entries[iconName];
85
- switch (icon == null ? void 0 : icon.type) {
83
+ switch (icon?.type) {
86
84
  case "icon":
87
85
  icon.categories.add(item);
88
86
  }
@@ -91,8 +89,8 @@ var IconSet = class {
91
89
  this.listCategory(item);
92
90
  }
93
91
  }
94
- const prefixes = this.prefixes = Object.create(null);
95
- const suffixes = this.suffixes = Object.create(null);
92
+ const prefixes = this.prefixes = /* @__PURE__ */ Object.create(null);
93
+ const suffixes = this.suffixes = /* @__PURE__ */ Object.create(null);
96
94
  if (data.themes) {
97
95
  for (const key in data.themes) {
98
96
  const item = data.themes[key];
@@ -113,7 +111,7 @@ var IconSet = class {
113
111
  themeKeys.forEach((prop) => {
114
112
  const items = data[prop];
115
113
  if (items) {
116
- this[prop] = Object.create(null);
114
+ this[prop] = /* @__PURE__ */ Object.create(null);
117
115
  for (const key in items) {
118
116
  this[prop][key] = items[key];
119
117
  }
@@ -189,7 +187,6 @@ var IconSet = class {
189
187
  return parent;
190
188
  }
191
189
  default:
192
- assertNever(item);
193
190
  return null;
194
191
  }
195
192
  }
@@ -216,8 +213,8 @@ var IconSet = class {
216
213
  return html ? new SVG(html) : null;
217
214
  }
218
215
  export(validate = true) {
219
- const icons = Object.create(null);
220
- const aliases = Object.create(null);
216
+ const icons = /* @__PURE__ */ Object.create(null);
217
+ const aliases = /* @__PURE__ */ Object.create(null);
221
218
  const names = Object.keys(this.entries);
222
219
  names.sort((a, b) => a.localeCompare(b));
223
220
  names.forEach((name) => {
@@ -244,9 +241,6 @@ var IconSet = class {
244
241
  aliases[name] = alias;
245
242
  break;
246
243
  }
247
- default: {
248
- assertNever(item);
249
- }
250
244
  }
251
245
  });
252
246
  let info;
@@ -268,7 +262,7 @@ var IconSet = class {
268
262
  if (Object.keys(chars).length) {
269
263
  result.chars = chars;
270
264
  }
271
- const categories = Object.create(null);
265
+ const categories = /* @__PURE__ */ Object.create(null);
272
266
  Array.from(this.categories).sort((a, b) => a.title.localeCompare(b.title)).forEach((item) => {
273
267
  const names2 = this.listCategory(item);
274
268
  if (names2) {
@@ -284,7 +278,7 @@ var IconSet = class {
284
278
  const keys = Object.keys(items);
285
279
  if (keys.length) {
286
280
  sortThemeKeys(keys);
287
- const sortedTheme = Object.create(null);
281
+ const sortedTheme = /* @__PURE__ */ Object.create(null);
288
282
  const tested = this.checkTheme(prop === "prefixes");
289
283
  keys.forEach((key) => {
290
284
  if (tested.valid[key].length) {
@@ -300,7 +294,7 @@ var IconSet = class {
300
294
  return result;
301
295
  }
302
296
  chars(names) {
303
- const chars = Object.create(null);
297
+ const chars = /* @__PURE__ */ Object.create(null);
304
298
  if (!names) {
305
299
  names = Object.keys(this.entries);
306
300
  }
@@ -338,7 +332,7 @@ var IconSet = class {
338
332
  }
339
333
  count() {
340
334
  return this._filter((_key, item, icon) => {
341
- if (item.type === "alias" || item.props.hidden || (icon == null ? void 0 : icon.hidden)) {
335
+ if (item.type === "alias" || item.props.hidden || icon?.hidden) {
342
336
  return false;
343
337
  }
344
338
  return true;
@@ -383,7 +377,7 @@ var IconSet = class {
383
377
  }
384
378
  remove(name, removeDependencies = true) {
385
379
  const entries = this.entries;
386
- const names = new Set();
380
+ const names = /* @__PURE__ */ new Set();
387
381
  if (typeof removeDependencies === "string") {
388
382
  if (name === removeDependencies || !entries[removeDependencies]) {
389
383
  return 0;
@@ -413,8 +407,6 @@ var IconSet = class {
413
407
  item.parent = removeDependencies;
414
408
  }
415
409
  break;
416
- default:
417
- assertNever(item);
418
410
  }
419
411
  }
420
412
  }
@@ -454,8 +446,6 @@ var IconSet = class {
454
446
  item.parent = newName;
455
447
  }
456
448
  break;
457
- default:
458
- assertNever(item);
459
449
  }
460
450
  }
461
451
  return true;
@@ -477,15 +467,15 @@ var IconSet = class {
477
467
  type: "icon",
478
468
  body: icon.body,
479
469
  props: filterProps(icon, true),
480
- chars: new Set(),
481
- categories: new Set()
470
+ chars: /* @__PURE__ */ new Set(),
471
+ categories: /* @__PURE__ */ new Set()
482
472
  });
483
473
  }
484
474
  setAlias(name, parent) {
485
475
  return this.setItem(name, {
486
476
  type: "alias",
487
477
  parent,
488
- chars: new Set()
478
+ chars: /* @__PURE__ */ new Set()
489
479
  });
490
480
  }
491
481
  setVariation(name, parent, props) {
@@ -493,14 +483,14 @@ var IconSet = class {
493
483
  type: "variation",
494
484
  parent,
495
485
  props,
496
- chars: new Set()
486
+ chars: /* @__PURE__ */ new Set()
497
487
  });
498
488
  }
499
489
  fromSVG(name, svg) {
500
490
  const props = svg.viewBox;
501
491
  const body = svg.getBody();
502
492
  const item = this.entries[name];
503
- switch (item == null ? void 0 : item.type) {
493
+ switch (item?.type) {
504
494
  case "icon":
505
495
  case "variation": {
506
496
  for (const key in extraDefaultProps) {
@@ -514,7 +504,7 @@ var IconSet = class {
514
504
  body,
515
505
  props,
516
506
  chars: item.chars,
517
- categories: item.type === "icon" ? item.categories : new Set()
507
+ categories: item.type === "icon" ? item.categories : /* @__PURE__ */ new Set()
518
508
  });
519
509
  }
520
510
  }
@@ -554,14 +544,14 @@ var IconSet = class {
554
544
  const themes = prefix ? this.prefixes : this.suffixes;
555
545
  const keys = sortThemeKeys(Object.keys(themes));
556
546
  const results = {
557
- valid: Object.create(null),
547
+ valid: /* @__PURE__ */ Object.create(null),
558
548
  invalid: []
559
549
  };
560
550
  keys.forEach((key) => {
561
551
  results.valid[key] = [];
562
552
  });
563
553
  results.invalid = this._filter((name, item, icon) => {
564
- if (item.type === "alias" || item.props.hidden || (icon == null ? void 0 : icon.hidden)) {
554
+ if (item.type === "alias" || item.props.hidden || icon?.hidden) {
565
555
  return false;
566
556
  }
567
557
  for (let i = 0; i < keys.length; i++) {
@@ -582,15 +572,12 @@ var IconSet = class {
582
572
  });
583
573
  return results;
584
574
  }
585
- };
575
+ }
586
576
  function blankIconSet(prefix) {
587
577
  return new IconSet({
588
578
  prefix,
589
579
  icons: {}
590
580
  });
591
581
  }
592
- export {
593
- IconSet,
594
- blankIconSet,
595
- sortThemeKeys
596
- };
582
+
583
+ export { IconSet, blankIconSet, sortThemeKeys };
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const icon = require('@iconify/utils/lib/icon');
6
+
7
+ const maxIteration = 5;
8
+ function findMatchingIcon(iconSet, icon$1) {
9
+ const body = icon$1.body;
10
+ let hiddenMatch = null;
11
+ function isMatching(data) {
12
+ for (const key in icon.iconDefaults) {
13
+ const attr = key;
14
+ if (data[attr] !== icon$1[attr]) {
15
+ return false;
16
+ }
17
+ }
18
+ return true;
19
+ }
20
+ function test(name, iteration) {
21
+ const data = iconSet.resolve(name, true);
22
+ if (!data) {
23
+ return null;
24
+ }
25
+ if (isMatching(data)) {
26
+ if (data.hidden) {
27
+ hiddenMatch = name;
28
+ } else {
29
+ return name;
30
+ }
31
+ }
32
+ if (iteration > maxIteration) {
33
+ return null;
34
+ }
35
+ for (const key in iconSet.entries) {
36
+ const item = iconSet.entries[key];
37
+ if (item.type === "variation" && item.parent === name) {
38
+ const result = test(key, iteration + 1);
39
+ if (typeof result === "string") {
40
+ return result;
41
+ }
42
+ }
43
+ }
44
+ return null;
45
+ }
46
+ for (const key in iconSet.entries) {
47
+ const item = iconSet.entries[key];
48
+ if (item.type === "icon" && item.body === body) {
49
+ const result = test(key, 0);
50
+ if (typeof result === "string") {
51
+ return result;
52
+ }
53
+ }
54
+ }
55
+ return hiddenMatch;
56
+ }
57
+
58
+ exports.findMatchingIcon = findMatchingIcon;
@@ -1,6 +1,13 @@
1
- import type { FullIconifyIcon } from '@iconify/utils/lib/icon';
2
- import type { IconSet } from '.';
1
+ import { FullIconifyIcon } from '@iconify/utils/lib/icon';
2
+ import { IconSet } from './index.js';
3
+ import '@iconify/types';
4
+ import '@iconify/utils/lib/customisations';
5
+ import './types.js';
6
+ import '../svg/index.js';
7
+
3
8
  /**
4
9
  * Find matching icon in icon set
5
10
  */
6
- export declare function findMatchingIcon(iconSet: IconSet, icon: FullIconifyIcon): string | null;
11
+ declare function findMatchingIcon(iconSet: IconSet, icon: FullIconifyIcon): string | null;
12
+
13
+ export { findMatchingIcon };
@@ -1,6 +1,6 @@
1
- // src/icon-set/match.ts
2
- import { iconDefaults } from "@iconify/utils/lib/icon";
3
- var maxIteration = 5;
1
+ import { iconDefaults } from '@iconify/utils/lib/icon';
2
+
3
+ const maxIteration = 5;
4
4
  function findMatchingIcon(iconSet, icon) {
5
5
  const body = icon.body;
6
6
  let hiddenMatch = null;
@@ -50,6 +50,5 @@ function findMatchingIcon(iconSet, icon) {
50
50
  }
51
51
  return hiddenMatch;
52
52
  }
53
- export {
54
- findMatchingIcon
55
- };
53
+
54
+ export { findMatchingIcon };
@@ -0,0 +1,83 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const iconSet_index = require('./index.cjs');
6
+ const iconSet_match = require('./match.cjs');
7
+ require('@iconify/utils/lib/icon');
8
+ require('@iconify/utils/lib/svg/build');
9
+ require('@iconify/utils/lib/customisations');
10
+ require('@iconify/utils/lib/icon-set/minify');
11
+ require('@iconify/utils/lib/icon-set/convert-info');
12
+ require('./props.cjs');
13
+ require('../svg/index.cjs');
14
+ require('cheerio');
15
+ require('@iconify/utils');
16
+
17
+ function mergeIconSets(oldIcons, newIcons) {
18
+ const mergedIcons = new iconSet_index.IconSet(newIcons.export());
19
+ const oldEntries = oldIcons.entries;
20
+ const entries = mergedIcons.entries;
21
+ function add(name) {
22
+ if (entries[name]) {
23
+ return true;
24
+ }
25
+ const item = oldEntries[name];
26
+ switch (item.type) {
27
+ case "icon": {
28
+ const fullIcon = oldIcons.resolve(name, true);
29
+ const parent = fullIcon ? iconSet_match.findMatchingIcon(mergedIcons, fullIcon) : null;
30
+ if (parent !== null) {
31
+ mergedIcons.setAlias(name, parent);
32
+ return true;
33
+ }
34
+ const props = item.props;
35
+ mergedIcons.setItem(name, {
36
+ ...item,
37
+ props: {
38
+ ...props,
39
+ hidden: true
40
+ },
41
+ categories: /* @__PURE__ */ new Set()
42
+ });
43
+ return true;
44
+ }
45
+ case "variation":
46
+ case "alias": {
47
+ let parent = item.parent;
48
+ if (!add(parent)) {
49
+ return false;
50
+ }
51
+ const parentItem = entries[parent];
52
+ if (parentItem.type === "alias") {
53
+ parent = parentItem.parent;
54
+ }
55
+ if (item.type === "variation") {
56
+ const props = item.props;
57
+ mergedIcons.setItem(name, {
58
+ ...item,
59
+ parent,
60
+ props: {
61
+ ...props,
62
+ hidden: true
63
+ }
64
+ });
65
+ } else {
66
+ mergedIcons.setItem(name, {
67
+ ...item,
68
+ parent
69
+ });
70
+ }
71
+ return true;
72
+ }
73
+ default:
74
+ return false;
75
+ }
76
+ }
77
+ for (const name in oldEntries) {
78
+ add(name);
79
+ }
80
+ return mergedIcons;
81
+ }
82
+
83
+ exports.mergeIconSets = mergeIconSets;
@@ -1,5 +1,12 @@
1
- import { IconSet } from '.';
1
+ import { IconSet } from './index.js';
2
+ import '@iconify/types';
3
+ import '@iconify/utils/lib/customisations';
4
+ import './types.js';
5
+ import '../svg/index.js';
6
+
2
7
  /**
3
8
  * Merge icon sets
4
9
  */
5
- export declare function mergeIconSets(oldIcons: IconSet, newIcons: IconSet): IconSet;
10
+ declare function mergeIconSets(oldIcons: IconSet, newIcons: IconSet): IconSet;
11
+
12
+ export { mergeIconSets };
@@ -1,8 +1,15 @@
1
- // src/icon-set/merge.ts
2
- import { IconSet } from "./index.mjs";
3
- import { findMatchingIcon } from "./match.mjs";
4
- function assertNever(v) {
5
- }
1
+ import { IconSet } from './index.mjs';
2
+ import { findMatchingIcon } from './match.mjs';
3
+ import '@iconify/utils/lib/icon';
4
+ import '@iconify/utils/lib/svg/build';
5
+ import '@iconify/utils/lib/customisations';
6
+ import '@iconify/utils/lib/icon-set/minify';
7
+ import '@iconify/utils/lib/icon-set/convert-info';
8
+ import './props.mjs';
9
+ import '../svg/index.mjs';
10
+ import 'cheerio';
11
+ import '@iconify/utils';
12
+
6
13
  function mergeIconSets(oldIcons, newIcons) {
7
14
  const mergedIcons = new IconSet(newIcons.export());
8
15
  const oldEntries = oldIcons.entries;
@@ -27,7 +34,7 @@ function mergeIconSets(oldIcons, newIcons) {
27
34
  ...props,
28
35
  hidden: true
29
36
  },
30
- categories: new Set()
37
+ categories: /* @__PURE__ */ new Set()
31
38
  });
32
39
  return true;
33
40
  }
@@ -60,7 +67,6 @@ function mergeIconSets(oldIcons, newIcons) {
60
67
  return true;
61
68
  }
62
69
  default:
63
- assertNever(item);
64
70
  return false;
65
71
  }
66
72
  }
@@ -69,6 +75,5 @@ function mergeIconSets(oldIcons, newIcons) {
69
75
  }
70
76
  return mergedIcons;
71
77
  }
72
- export {
73
- mergeIconSets
74
- };
78
+
79
+ export { mergeIconSets };
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const icon = require('@iconify/utils/lib/icon');
6
+
7
+ const extraDefaultProps = {
8
+ hidden: false
9
+ };
10
+ const defaultCommonProps = {
11
+ ...icon.iconDefaults,
12
+ ...extraDefaultProps
13
+ };
14
+ const props = Object.keys(defaultCommonProps);
15
+ function filterProps(data, compareDefaultValues) {
16
+ const result = {};
17
+ props.forEach((attr) => {
18
+ const value = data[attr];
19
+ if (value !== void 0 && (!compareDefaultValues || value !== defaultCommonProps[attr])) {
20
+ result[attr] = value;
21
+ }
22
+ });
23
+ return result;
24
+ }
25
+
26
+ exports.defaultCommonProps = defaultCommonProps;
27
+ exports.extraDefaultProps = extraDefaultProps;
28
+ exports.filterProps = filterProps;
@@ -1,10 +1,14 @@
1
- import type { CommonIconProps, ExtraIconProps } from './types';
1
+ import { ExtraIconProps, CommonIconProps } from './types.js';
2
+ import '@iconify/types';
3
+
2
4
  /**
3
5
  * Default properties
4
6
  */
5
- export declare const extraDefaultProps: Required<ExtraIconProps>;
6
- export declare const defaultCommonProps: Required<CommonIconProps>;
7
+ declare const extraDefaultProps: Required<ExtraIconProps>;
8
+ declare const defaultCommonProps: Required<CommonIconProps>;
7
9
  /**
8
10
  * Filter icon props: copies properties, removing undefined and default entries
9
11
  */
10
- export declare function filterProps(data: CommonIconProps, compareDefaultValues: boolean): CommonIconProps;
12
+ declare function filterProps(data: CommonIconProps, compareDefaultValues: boolean): CommonIconProps;
13
+
14
+ export { defaultCommonProps, extraDefaultProps, filterProps };
@@ -1,13 +1,13 @@
1
- // src/icon-set/props.ts
2
- import { iconDefaults } from "@iconify/utils/lib/icon";
3
- var extraDefaultProps = {
1
+ import { iconDefaults } from '@iconify/utils/lib/icon';
2
+
3
+ const extraDefaultProps = {
4
4
  hidden: false
5
5
  };
6
- var defaultCommonProps = {
6
+ const defaultCommonProps = {
7
7
  ...iconDefaults,
8
8
  ...extraDefaultProps
9
9
  };
10
- var props = Object.keys(defaultCommonProps);
10
+ const props = Object.keys(defaultCommonProps);
11
11
  function filterProps(data, compareDefaultValues) {
12
12
  const result = {};
13
13
  props.forEach((attr) => {
@@ -18,8 +18,5 @@ function filterProps(data, compareDefaultValues) {
18
18
  });
19
19
  return result;
20
20
  }
21
- export {
22
- defaultCommonProps,
23
- extraDefaultProps,
24
- filterProps
25
- };
21
+
22
+ export { defaultCommonProps, extraDefaultProps, filterProps };
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -1,8 +1,9 @@
1
- import type { IconifyIcon, ExtendedIconifyIcon, ExtendedIconifyAlias, IconifyOptional } from '@iconify/types';
1
+ import { ExtendedIconifyIcon, ExtendedIconifyAlias, IconifyOptional, IconifyIcon } from '@iconify/types';
2
+
2
3
  /**
3
4
  * Category item
4
5
  */
5
- export interface IconCategory {
6
+ interface IconCategory {
6
7
  title: string;
7
8
  count: number;
8
9
  }
@@ -12,53 +13,53 @@ export interface IconCategory {
12
13
  declare type CommonProps<A, B> = {
13
14
  [K in keyof A & keyof B]?: A[K] extends B[K] ? A[K] : never;
14
15
  };
15
- export declare type CommonIconProps = CommonProps<ExtendedIconifyIcon, ExtendedIconifyAlias>;
16
+ declare type CommonIconProps = CommonProps<ExtendedIconifyIcon, ExtendedIconifyAlias>;
16
17
  /**
17
18
  * Exclude IconifyOptional from CommonIconProps
18
19
  */
19
- export declare type ExtraIconProps = Omit<CommonIconProps, keyof IconifyOptional>;
20
+ declare type ExtraIconProps = Omit<CommonIconProps, keyof IconifyOptional>;
20
21
  /**
21
22
  * Partials
22
23
  */
23
- export interface IconWithChars {
24
+ interface IconWithChars {
24
25
  chars: Set<string>;
25
26
  }
26
- export interface IconWithPropsData extends IconWithChars {
27
+ interface IconWithPropsData extends IconWithChars {
27
28
  props: CommonIconProps;
28
29
  }
29
- export interface IconWithCategories {
30
+ interface IconWithCategories {
30
31
  categories: Set<IconCategory>;
31
32
  }
32
- export interface IconParentData {
33
+ interface IconParentData {
33
34
  parent: string;
34
35
  }
35
36
  /**
36
37
  * Icon types
37
38
  */
38
- export interface IconSetIcon extends IconWithPropsData, IconWithCategories {
39
+ interface IconSetIcon extends IconWithPropsData, IconWithCategories {
39
40
  type: 'icon';
40
41
  body: string;
41
42
  }
42
- export interface IconSetIconAlias extends IconWithChars, IconParentData {
43
+ interface IconSetIconAlias extends IconWithChars, IconParentData {
43
44
  type: 'alias';
44
45
  }
45
- export interface IconSetIconVariation extends IconWithPropsData, IconParentData {
46
+ interface IconSetIconVariation extends IconWithPropsData, IconParentData {
46
47
  type: 'variation';
47
48
  }
48
49
  /**
49
50
  * All icon types
50
51
  */
51
- export declare type IconSetIconEntry = IconSetIcon | IconSetIconAlias | IconSetIconVariation;
52
- export declare type IconSetIconType = IconSetIconEntry['type'];
52
+ declare type IconSetIconEntry = IconSetIcon | IconSetIconAlias | IconSetIconVariation;
53
+ declare type IconSetIconType = IconSetIconEntry['type'];
53
54
  /**
54
55
  * Full icon with extra stuff
55
56
  */
56
- export interface ResolvedIconifyIcon extends IconifyIcon, ExtraIconProps {
57
+ interface ResolvedIconifyIcon extends IconifyIcon, ExtraIconProps {
57
58
  }
58
59
  /**
59
60
  * Result for checking theme: list of names for each theme
60
61
  */
61
- export interface CheckThemeResult {
62
+ interface CheckThemeResult {
62
63
  valid: Record<string, string[]>;
63
64
  invalid: string[];
64
65
  }
@@ -68,5 +69,6 @@ export interface CheckThemeResult {
68
69
  * Return false to stop loop
69
70
  */
70
71
  declare type IconSetAsyncForEachCallbackResult = void | false;
71
- export declare type IconSetAsyncForEachCallback = (name: string, type: IconSetIconEntry['type']) => Promise<IconSetAsyncForEachCallbackResult> | IconSetAsyncForEachCallbackResult;
72
- export {};
72
+ declare type IconSetAsyncForEachCallback = (name: string, type: IconSetIconEntry['type']) => Promise<IconSetAsyncForEachCallbackResult> | IconSetAsyncForEachCallbackResult;
73
+
74
+ export { CheckThemeResult, CommonIconProps, ExtraIconProps, IconCategory, IconParentData, IconSetAsyncForEachCallback, IconSetIcon, IconSetIconAlias, IconSetIconEntry, IconSetIconType, IconSetIconVariation, IconWithCategories, IconWithChars, IconWithPropsData, ResolvedIconifyIcon };
@@ -0,0 +1 @@
1
+