@iconify/tools 2.0.12 → 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 (308) 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 +42 -20
  55. package/lib/download/git/reset.cjs +41 -0
  56. package/lib/download/git/reset.d.ts +6 -0
  57. package/lib/download/git/reset.mjs +37 -0
  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 +24 -22
  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 +47 -57
  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 +9 -12
  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 +6 -16
  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 -43
  159. package/lib/index.mjs +83 -92
  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 +68 -47
  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 -11
  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 +102 -93
  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 -63
  251. package/lib/download/github/hash.js +0 -28
  252. package/lib/download/github/index.js +0 -116
  253. package/lib/download/github/types.js +0 -2
  254. package/lib/download/gitlab/hash.js +0 -27
  255. package/lib/download/gitlab/index.js +0 -115
  256. package/lib/download/gitlab/types.js +0 -7
  257. package/lib/download/helpers/untar.js +0 -14
  258. package/lib/download/helpers/unzip.js +0 -18
  259. package/lib/download/index.js +0 -27
  260. package/lib/download/npm/index.js +0 -91
  261. package/lib/download/npm/types.js +0 -2
  262. package/lib/download/npm/version.js +0 -27
  263. package/lib/download/types/modified.js +0 -2
  264. package/lib/download/types/sources.js +0 -2
  265. package/lib/export/directory.js +0 -52
  266. package/lib/export/helpers/custom-files.js +0 -32
  267. package/lib/export/helpers/prepare.js +0 -49
  268. package/lib/export/helpers/types-version.js +0 -12
  269. package/lib/export/icon-package.js +0 -77
  270. package/lib/export/json-package.js +0 -151
  271. package/lib/icon-set/index.js +0 -746
  272. package/lib/icon-set/match.js +0 -66
  273. package/lib/icon-set/merge.js +0 -90
  274. package/lib/icon-set/props.js +0 -33
  275. package/lib/icon-set/types.js +0 -2
  276. package/lib/import/directory.js +0 -59
  277. package/lib/import/figma/index.js +0 -90
  278. package/lib/import/figma/nodes.js +0 -108
  279. package/lib/import/figma/query.js +0 -244
  280. package/lib/import/figma/types/api.js +0 -12
  281. package/lib/import/figma/types/nodes.js +0 -2
  282. package/lib/import/figma/types/options.js +0 -2
  283. package/lib/import/figma/types/result.js +0 -2
  284. package/lib/index.js +0 -101
  285. package/lib/misc/bump-version.js +0 -19
  286. package/lib/misc/compare-dirs.js +0 -84
  287. package/lib/misc/exec.js +0 -26
  288. package/lib/misc/keyword.js +0 -31
  289. package/lib/misc/scan.js +0 -55
  290. package/lib/misc/write-json.js +0 -11
  291. package/lib/optimise/flags.js +0 -312
  292. package/lib/optimise/global-style.js +0 -158
  293. package/lib/optimise/scale.js +0 -42
  294. package/lib/optimise/svgo.js +0 -99
  295. package/lib/svg/analyse/error.js +0 -22
  296. package/lib/svg/analyse/types.js +0 -2
  297. package/lib/svg/analyse.js +0 -352
  298. package/lib/svg/cleanup/attribs.js +0 -51
  299. package/lib/svg/cleanup/bad-tags.js +0 -65
  300. package/lib/svg/cleanup/inline-style.js +0 -77
  301. package/lib/svg/cleanup/root-svg.js +0 -107
  302. package/lib/svg/cleanup/svgo-style.js +0 -35
  303. package/lib/svg/cleanup.js +0 -24
  304. package/lib/svg/data/attributes.js +0 -403
  305. package/lib/svg/data/tags.js +0 -188
  306. package/lib/svg/index.js +0 -125
  307. package/lib/svg/parse-style.js +0 -151
  308. package/lib/svg/parse.js +0 -49
@@ -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
+
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const fs = require('fs');
6
+ const iconSet_index = require('../icon-set/index.cjs');
7
+ const misc_keyword = require('../misc/keyword.cjs');
8
+ const misc_scan = require('../misc/scan.cjs');
9
+ const svg_index = require('../svg/index.cjs');
10
+ const svg_cleanup = require('../svg/cleanup.cjs');
11
+ require('@iconify/utils/lib/icon');
12
+ require('@iconify/utils/lib/svg/build');
13
+ require('@iconify/utils/lib/customisations');
14
+ require('@iconify/utils/lib/icon-set/minify');
15
+ require('@iconify/utils/lib/icon-set/convert-info');
16
+ require('../icon-set/props.cjs');
17
+ require('cheerio');
18
+ require('@iconify/utils');
19
+ require('../svg/cleanup/attribs.cjs');
20
+ require('../svg/data/attributes.cjs');
21
+ require('../svg/data/tags.cjs');
22
+ require('../svg/parse.cjs');
23
+ require('../svg/cleanup/bad-tags.cjs');
24
+ require('../svg/cleanup/inline-style.cjs');
25
+ require('../css/parse.cjs');
26
+ require('../css/parser/tokens.cjs');
27
+ require('../css/parser/error.cjs');
28
+ require('../css/parser/strings.cjs');
29
+ require('../css/parser/text.cjs');
30
+ require('../svg/cleanup/root-svg.cjs');
31
+ require('../svg/cleanup/svgo-style.cjs');
32
+ require('../svg/parse-style.cjs');
33
+ require('../css/parser/export.cjs');
34
+ require('../css/parser/tree.cjs');
35
+ require('../optimise/svgo.cjs');
36
+ require('svgo');
37
+
38
+ async function importDirectory(path, options = {}) {
39
+ const files = await misc_scan.scanDirectory(path, (ext, file, subdir, path2) => {
40
+ if (ext.toLowerCase() === ".svg") {
41
+ const result = {
42
+ file,
43
+ ext,
44
+ subdir,
45
+ path: path2
46
+ };
47
+ return result;
48
+ }
49
+ return false;
50
+ });
51
+ const iconSet = iconSet_index.blankIconSet(options.prefix || "");
52
+ for (let i = 0; i < files.length; i++) {
53
+ const file = files[i];
54
+ const defaultKeyword = misc_keyword.cleanupIconKeyword(file.file);
55
+ let keyword = options.keyword ? options.keyword(file, defaultKeyword, iconSet) : defaultKeyword;
56
+ if (keyword instanceof Promise) {
57
+ keyword = await keyword;
58
+ }
59
+ if (typeof keyword !== "string" || !keyword.length) {
60
+ continue;
61
+ }
62
+ try {
63
+ const content = await fs.promises.readFile(file.path + file.subdir + file.file + file.ext, "utf8");
64
+ const svg = new svg_index.SVG(content);
65
+ await svg_cleanup.cleanupSVG(svg);
66
+ iconSet.fromSVG(keyword, svg);
67
+ } catch (err) {
68
+ if (options.ignoreImportErrors !== false) {
69
+ throw err;
70
+ }
71
+ }
72
+ }
73
+ return iconSet;
74
+ }
75
+
76
+ exports.importDirectory = importDirectory;
@@ -1,8 +1,13 @@
1
- import { IconSet } from '../icon-set';
1
+ import { IconSet } from '../icon-set/index.js';
2
+ import '@iconify/types';
3
+ import '@iconify/utils/lib/customisations';
4
+ import '../icon-set/types.js';
5
+ import '../svg/index.js';
6
+
2
7
  /**
3
8
  * Entry for file
4
9
  */
5
- export interface ImportDirectpryFileEntry {
10
+ interface ImportDirectpryFileEntry {
6
11
  path: string;
7
12
  subdir: string;
8
13
  file: string;
@@ -18,7 +23,7 @@ export interface ImportDirectpryFileEntry {
18
23
  * Callback can be asynchronous
19
24
  */
20
25
  declare type ImportDirectoryKeywordCallbackResult = string | undefined;
21
- export declare type ImportDirectoryKeywordCallback = (file: ImportDirectpryFileEntry, defaultKeyword: string, iconSet: IconSet) => ImportDirectoryKeywordCallbackResult | Promise<ImportDirectoryKeywordCallbackResult>;
26
+ declare type ImportDirectoryKeywordCallback = (file: ImportDirectpryFileEntry, defaultKeyword: string, iconSet: IconSet) => ImportDirectoryKeywordCallbackResult | Promise<ImportDirectoryKeywordCallbackResult>;
22
27
  /**
23
28
  * Options
24
29
  */
@@ -31,5 +36,6 @@ interface ImportDirectoryOptions {
31
36
  /**
32
37
  * Import all icons from directory
33
38
  */
34
- export declare function importDirectory(path: string, options?: ImportDirectoryOptions): Promise<IconSet>;
35
- export {};
39
+ declare function importDirectory(path: string, options?: ImportDirectoryOptions): Promise<IconSet>;
40
+
41
+ export { ImportDirectoryKeywordCallback, ImportDirectpryFileEntry, importDirectory };
@@ -1,10 +1,36 @@
1
- // src/import/directory.ts
2
- import { promises as fs } from "fs";
3
- import { blankIconSet } from "../icon-set/index.mjs";
4
- import { cleanupIconKeyword } from "../misc/keyword.mjs";
5
- import { scanDirectory } from "../misc/scan.mjs";
6
- import { SVG } from "../svg/index.mjs";
7
- import { cleanupSVG } from "../svg/cleanup.mjs";
1
+ import { promises } from 'fs';
2
+ import { blankIconSet } from '../icon-set/index.mjs';
3
+ import { cleanupIconKeyword } from '../misc/keyword.mjs';
4
+ import { scanDirectory } from '../misc/scan.mjs';
5
+ import { SVG } from '../svg/index.mjs';
6
+ import { cleanupSVG } from '../svg/cleanup.mjs';
7
+ import '@iconify/utils/lib/icon';
8
+ import '@iconify/utils/lib/svg/build';
9
+ import '@iconify/utils/lib/customisations';
10
+ import '@iconify/utils/lib/icon-set/minify';
11
+ import '@iconify/utils/lib/icon-set/convert-info';
12
+ import '../icon-set/props.mjs';
13
+ import 'cheerio';
14
+ import '@iconify/utils';
15
+ import '../svg/cleanup/attribs.mjs';
16
+ import '../svg/data/attributes.mjs';
17
+ import '../svg/data/tags.mjs';
18
+ import '../svg/parse.mjs';
19
+ import '../svg/cleanup/bad-tags.mjs';
20
+ import '../svg/cleanup/inline-style.mjs';
21
+ import '../css/parse.mjs';
22
+ import '../css/parser/tokens.mjs';
23
+ import '../css/parser/error.mjs';
24
+ import '../css/parser/strings.mjs';
25
+ import '../css/parser/text.mjs';
26
+ import '../svg/cleanup/root-svg.mjs';
27
+ import '../svg/cleanup/svgo-style.mjs';
28
+ import '../svg/parse-style.mjs';
29
+ import '../css/parser/export.mjs';
30
+ import '../css/parser/tree.mjs';
31
+ import '../optimise/svgo.mjs';
32
+ import 'svgo';
33
+
8
34
  async function importDirectory(path, options = {}) {
9
35
  const files = await scanDirectory(path, (ext, file, subdir, path2) => {
10
36
  if (ext.toLowerCase() === ".svg") {
@@ -30,7 +56,7 @@ async function importDirectory(path, options = {}) {
30
56
  continue;
31
57
  }
32
58
  try {
33
- const content = await fs.readFile(file.path + file.subdir + file.file + file.ext, "utf8");
59
+ const content = await promises.readFile(file.path + file.subdir + file.file + file.ext, "utf8");
34
60
  const svg = new SVG(content);
35
61
  await cleanupSVG(svg);
36
62
  iconSet.fromSVG(keyword, svg);
@@ -42,6 +68,5 @@ async function importDirectory(path, options = {}) {
42
68
  }
43
69
  return iconSet;
44
70
  }
45
- export {
46
- importDirectory
47
- };
71
+
72
+ export { importDirectory };
@@ -0,0 +1,105 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const iconSet_index = require('../../icon-set/index.cjs');
6
+ const svg_index = require('../../svg/index.cjs');
7
+ const svg_cleanup = require('../../svg/cleanup.cjs');
8
+ const import_figma_nodes = require('./nodes.cjs');
9
+ const import_figma_query = require('./query.cjs');
10
+ require('@iconify/utils/lib/icon');
11
+ require('@iconify/utils/lib/svg/build');
12
+ require('@iconify/utils/lib/customisations');
13
+ require('@iconify/utils/lib/icon-set/minify');
14
+ require('@iconify/utils/lib/icon-set/convert-info');
15
+ require('../../icon-set/props.cjs');
16
+ require('cheerio');
17
+ require('@iconify/utils');
18
+ require('../../svg/cleanup/attribs.cjs');
19
+ require('../../svg/data/attributes.cjs');
20
+ require('../../svg/data/tags.cjs');
21
+ require('../../svg/parse.cjs');
22
+ require('../../svg/cleanup/bad-tags.cjs');
23
+ require('../../svg/cleanup/inline-style.cjs');
24
+ require('../../css/parse.cjs');
25
+ require('../../css/parser/tokens.cjs');
26
+ require('../../css/parser/error.cjs');
27
+ require('../../css/parser/strings.cjs');
28
+ require('../../css/parser/text.cjs');
29
+ require('../../svg/cleanup/root-svg.cjs');
30
+ require('../../svg/cleanup/svgo-style.cjs');
31
+ require('../../svg/parse-style.cjs');
32
+ require('../../css/parser/export.cjs');
33
+ require('../../css/parser/tree.cjs');
34
+ require('../../optimise/svgo.cjs');
35
+ require('svgo');
36
+ require('../../download/api/index.cjs');
37
+ require('node-fetch');
38
+ require('../../download/api/cache.cjs');
39
+ require('fs');
40
+ require('crypto');
41
+ require('../../misc/scan.cjs');
42
+
43
+ async function importFromFigma(options) {
44
+ const cacheOptions = options.cacheDir ? {
45
+ ttl: options.cacheAPITTL || 60 * 60 * 24,
46
+ dir: options.cacheDir
47
+ } : void 0;
48
+ const cacheSVGOptions = options.cacheDir ? {
49
+ ttl: options.cacheSVGTTL || 60 * 60 * 24 * 30,
50
+ dir: options.cacheDir
51
+ } : void 0;
52
+ const document = await import_figma_query.figmaFilesQuery(options, cacheOptions);
53
+ if (document === "not_modified") {
54
+ return document;
55
+ }
56
+ options.version = document.version;
57
+ const nodes = await import_figma_nodes.getFigmaIconNodes(document, options);
58
+ await import_figma_query.figmaImagesQuery(options, nodes, cacheOptions);
59
+ await import_figma_query.figmaDownloadImages(nodes, cacheSVGOptions);
60
+ const iconSet = iconSet_index.blankIconSet(options.prefix);
61
+ const icons = nodes.icons;
62
+ const missing = [];
63
+ const iconIDs = Object.keys(icons);
64
+ for (let i = 0; i < iconIDs.length; i++) {
65
+ const id = iconIDs[i];
66
+ const item = icons[id];
67
+ if (typeof item.content !== "string") {
68
+ missing.push(item);
69
+ continue;
70
+ }
71
+ if (options.beforeImportingIcon) {
72
+ const callbackResult = options.beforeImportingIcon(item, iconSet);
73
+ if (callbackResult instanceof Promise) {
74
+ await callbackResult;
75
+ }
76
+ }
77
+ try {
78
+ const svg = new svg_index.SVG(item.content);
79
+ await svg_cleanup.cleanupSVG(svg);
80
+ iconSet.fromSVG(item.keyword, svg);
81
+ } catch (err) {
82
+ missing.push(item);
83
+ continue;
84
+ }
85
+ if (options.afterImportingIcon) {
86
+ const callbackResult = options.afterImportingIcon(item, iconSet);
87
+ if (callbackResult instanceof Promise) {
88
+ await callbackResult;
89
+ }
90
+ }
91
+ }
92
+ const result = {
93
+ name: document.name,
94
+ version: document.version,
95
+ lastModified: document.lastModified,
96
+ nodesCount: nodes.nodesCount,
97
+ generatedIconsCount: nodes.generatedIconsCount,
98
+ downloadedIconsCount: nodes.downloadedIconsCount,
99
+ iconSet,
100
+ missing
101
+ };
102
+ return result;
103
+ }
104
+
105
+ exports.importFromFigma = importFromFigma;
@@ -1,8 +1,18 @@
1
- import type { DocumentNotModified } from '../../download/types/modified';
2
- import type { FigmaImportOptions, FigmaIfModifiedSinceOption } from './types/options';
3
- import type { FigmaImportResult } from './types/result';
1
+ import { DocumentNotModified } from '../../download/types/modified.js';
2
+ import { FigmaIfModifiedSinceOption, FigmaImportOptions } from './types/options.js';
3
+ import { FigmaImportResult } from './types/result.js';
4
+ import '../../icon-set/index.js';
5
+ import '@iconify/types';
6
+ import '@iconify/utils/lib/customisations';
7
+ import '../../icon-set/types.js';
8
+ import '../../svg/index.js';
9
+ import './types/nodes.js';
10
+ import './types/api.js';
11
+
4
12
  /**
5
13
  * Import icon set from Figma
6
14
  */
7
- export declare function importFromFigma<T extends FigmaIfModifiedSinceOption & FigmaImportOptions>(options: T): Promise<FigmaImportResult | DocumentNotModified>;
8
- export declare function importFromFigma(options: FigmaImportOptions): Promise<FigmaImportResult>;
15
+ declare function importFromFigma<T extends FigmaIfModifiedSinceOption & FigmaImportOptions>(options: T): Promise<FigmaImportResult | DocumentNotModified>;
16
+ declare function importFromFigma(options: FigmaImportOptions): Promise<FigmaImportResult>;
17
+
18
+ export { importFromFigma };
@@ -1,13 +1,41 @@
1
- // src/import/figma/index.ts
2
- import { blankIconSet } from "../../icon-set/index.mjs";
3
- import { SVG } from "../../svg/index.mjs";
4
- import { cleanupSVG } from "../../svg/cleanup.mjs";
5
- import { getFigmaIconNodes } from "./nodes.mjs";
6
- import {
7
- figmaDownloadImages,
8
- figmaFilesQuery,
9
- figmaImagesQuery
10
- } from "./query.mjs";
1
+ import { blankIconSet } from '../../icon-set/index.mjs';
2
+ import { SVG } from '../../svg/index.mjs';
3
+ import { cleanupSVG } from '../../svg/cleanup.mjs';
4
+ import { getFigmaIconNodes } from './nodes.mjs';
5
+ import { figmaFilesQuery, figmaImagesQuery, figmaDownloadImages } from './query.mjs';
6
+ import '@iconify/utils/lib/icon';
7
+ import '@iconify/utils/lib/svg/build';
8
+ import '@iconify/utils/lib/customisations';
9
+ import '@iconify/utils/lib/icon-set/minify';
10
+ import '@iconify/utils/lib/icon-set/convert-info';
11
+ import '../../icon-set/props.mjs';
12
+ import 'cheerio';
13
+ import '@iconify/utils';
14
+ import '../../svg/cleanup/attribs.mjs';
15
+ import '../../svg/data/attributes.mjs';
16
+ import '../../svg/data/tags.mjs';
17
+ import '../../svg/parse.mjs';
18
+ import '../../svg/cleanup/bad-tags.mjs';
19
+ import '../../svg/cleanup/inline-style.mjs';
20
+ import '../../css/parse.mjs';
21
+ import '../../css/parser/tokens.mjs';
22
+ import '../../css/parser/error.mjs';
23
+ import '../../css/parser/strings.mjs';
24
+ import '../../css/parser/text.mjs';
25
+ import '../../svg/cleanup/root-svg.mjs';
26
+ import '../../svg/cleanup/svgo-style.mjs';
27
+ import '../../svg/parse-style.mjs';
28
+ import '../../css/parser/export.mjs';
29
+ import '../../css/parser/tree.mjs';
30
+ import '../../optimise/svgo.mjs';
31
+ import 'svgo';
32
+ import '../../download/api/index.mjs';
33
+ import 'node-fetch';
34
+ import '../../download/api/cache.mjs';
35
+ import 'fs';
36
+ import 'crypto';
37
+ import '../../misc/scan.mjs';
38
+
11
39
  async function importFromFigma(options) {
12
40
  const cacheOptions = options.cacheDir ? {
13
41
  ttl: options.cacheAPITTL || 60 * 60 * 24,
@@ -69,6 +97,5 @@ async function importFromFigma(options) {
69
97
  };
70
98
  return result;
71
99
  }
72
- export {
73
- importFromFigma
74
- };
100
+
101
+ export { importFromFigma };
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ async function getFigmaIconNodes(document, options) {
6
+ const nodes = {
7
+ icons: /* @__PURE__ */ Object.create(null)
8
+ };
9
+ let found = 0;
10
+ const check = (node, parents) => {
11
+ const iconNodeType = node.type;
12
+ switch (iconNodeType) {
13
+ case "COMPONENT":
14
+ case "INSTANCE":
15
+ case "FRAME": {
16
+ const iconNode = node;
17
+ if (iconNode.absoluteBoundingBox) {
18
+ const box = iconNode.absoluteBoundingBox;
19
+ const item = {
20
+ ...node,
21
+ type: iconNodeType,
22
+ width: box.width,
23
+ height: box.height,
24
+ parents
25
+ };
26
+ const keyword = options.iconNameForNode(item, nodes, document);
27
+ if (typeof keyword === "string") {
28
+ found++;
29
+ nodes.icons[node.id] = {
30
+ id: node.id,
31
+ name: node.name,
32
+ keyword
33
+ };
34
+ return;
35
+ }
36
+ if (keyword && typeof keyword === "object" && typeof keyword.keyword === "string") {
37
+ found++;
38
+ nodes.icons[node.id] = {
39
+ ...keyword,
40
+ id: node.id,
41
+ name: node.name
42
+ };
43
+ return;
44
+ }
45
+ }
46
+ break;
47
+ }
48
+ }
49
+ if (!node.children) {
50
+ return;
51
+ }
52
+ const parentNodeType = node.type;
53
+ switch (parentNodeType) {
54
+ case "CANVAS":
55
+ case "FRAME":
56
+ case "GROUP": {
57
+ const parentItem = {
58
+ ...node,
59
+ type: parentNodeType
60
+ };
61
+ const newParents = parents.concat([parentItem]);
62
+ if (!parents.length && options.pages) {
63
+ const allowedPages = options.pages;
64
+ if (allowedPages.indexOf(node.id) === -1 && allowedPages.indexOf(node.name.trim()) === -1) {
65
+ return;
66
+ }
67
+ } else {
68
+ if (options.filterParentNode && !options.filterParentNode(newParents, document)) {
69
+ return;
70
+ }
71
+ }
72
+ node.children.forEach((childNode) => {
73
+ check(childNode, newParents);
74
+ });
75
+ break;
76
+ }
77
+ }
78
+ };
79
+ document.document.children.forEach((node) => {
80
+ check(node, []);
81
+ });
82
+ nodes.nodesCount = found;
83
+ return nodes;
84
+ }
85
+
86
+ exports.getFigmaIconNodes = getFigmaIconNodes;
@@ -1,7 +1,16 @@
1
- import type { FigmaDocument } from './types/api';
2
- import type { FigmaGetIconNodesOptions } from './types/options';
3
- import type { FigmaNodesImportResult } from './types/result';
1
+ import { FigmaDocument } from './types/api.js';
2
+ import { FigmaGetIconNodesOptions } from './types/options.js';
3
+ import { FigmaNodesImportResult } from './types/result.js';
4
+ import '../../icon-set/index.js';
5
+ import '@iconify/types';
6
+ import '@iconify/utils/lib/customisations';
7
+ import '../../icon-set/types.js';
8
+ import '../../svg/index.js';
9
+ import './types/nodes.js';
10
+
4
11
  /**
5
12
  * Get node ids for icons
6
13
  */
7
- export declare function getFigmaIconNodes(document: FigmaDocument, options: FigmaGetIconNodesOptions): Promise<FigmaNodesImportResult>;
14
+ declare function getFigmaIconNodes(document: FigmaDocument, options: FigmaGetIconNodesOptions): Promise<FigmaNodesImportResult>;
15
+
16
+ export { getFigmaIconNodes };
@@ -1,9 +1,6 @@
1
- // src/import/figma/nodes.ts
2
- function assertNever(v) {
3
- }
4
1
  async function getFigmaIconNodes(document, options) {
5
2
  const nodes = {
6
- icons: Object.create(null)
3
+ icons: /* @__PURE__ */ Object.create(null)
7
4
  };
8
5
  let found = 0;
9
6
  const check = (node, parents) => {
@@ -16,9 +13,8 @@ async function getFigmaIconNodes(document, options) {
16
13
  if (iconNode.absoluteBoundingBox) {
17
14
  const box = iconNode.absoluteBoundingBox;
18
15
  const item = {
19
- id: node.id,
16
+ ...node,
20
17
  type: iconNodeType,
21
- name: node.name,
22
18
  width: box.width,
23
19
  height: box.height,
24
20
  parents
@@ -45,8 +41,6 @@ async function getFigmaIconNodes(document, options) {
45
41
  }
46
42
  break;
47
43
  }
48
- default:
49
- assertNever(iconNodeType);
50
44
  }
51
45
  if (!node.children) {
52
46
  return;
@@ -57,9 +51,8 @@ async function getFigmaIconNodes(document, options) {
57
51
  case "FRAME":
58
52
  case "GROUP": {
59
53
  const parentItem = {
60
- id: node.id,
61
- type: parentNodeType,
62
- name: node.name
54
+ ...node,
55
+ type: parentNodeType
63
56
  };
64
57
  const newParents = parents.concat([parentItem]);
65
58
  if (!parents.length && options.pages) {
@@ -77,8 +70,6 @@ async function getFigmaIconNodes(document, options) {
77
70
  });
78
71
  break;
79
72
  }
80
- default:
81
- assertNever(parentNodeType);
82
73
  }
83
74
  };
84
75
  document.document.children.forEach((node) => {
@@ -87,6 +78,5 @@ async function getFigmaIconNodes(document, options) {
87
78
  nodes.nodesCount = found;
88
79
  return nodes;
89
80
  }
90
- export {
91
- getFigmaIconNodes
92
- };
81
+
82
+ export { getFigmaIconNodes };