@iconify/tools 4.0.0-beta.9 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/lib/colors/attribs.d.cts +27 -0
  2. package/lib/colors/attribs.d.mts +27 -0
  3. package/lib/colors/attribs.d.ts +1 -1
  4. package/lib/colors/detect.d.cts +16 -0
  5. package/lib/colors/detect.d.mts +16 -0
  6. package/lib/colors/parse.d.cts +60 -0
  7. package/lib/colors/parse.d.mts +60 -0
  8. package/lib/colors/parse.d.ts +1 -1
  9. package/lib/colors/validate.d.cts +20 -0
  10. package/lib/colors/validate.d.mts +20 -0
  11. package/lib/css/parse.d.cts +6 -0
  12. package/lib/css/parse.d.mts +6 -0
  13. package/lib/css/parser/error.d.cts +13 -0
  14. package/lib/css/parser/error.d.mts +13 -0
  15. package/lib/css/parser/error.d.ts +1 -1
  16. package/lib/css/parser/export.d.cts +8 -0
  17. package/lib/css/parser/export.d.mts +8 -0
  18. package/lib/css/parser/strings.d.cts +16 -0
  19. package/lib/css/parser/strings.d.mts +16 -0
  20. package/lib/css/parser/text.d.cts +20 -0
  21. package/lib/css/parser/text.d.mts +20 -0
  22. package/lib/css/parser/tokens.d.cts +9 -0
  23. package/lib/css/parser/tokens.d.mts +9 -0
  24. package/lib/css/parser/tree.d.cts +8 -0
  25. package/lib/css/parser/tree.d.mts +8 -0
  26. package/lib/css/parser/types.d.cts +52 -0
  27. package/lib/css/parser/types.d.mts +52 -0
  28. package/lib/css/parser/types.d.ts +1 -1
  29. package/lib/download/api/cache.d.cts +20 -0
  30. package/lib/download/api/cache.d.mts +20 -0
  31. package/lib/download/api/config.d.cts +18 -0
  32. package/lib/download/api/config.d.mts +18 -0
  33. package/lib/download/api/download.d.cts +8 -0
  34. package/lib/download/api/download.d.mts +8 -0
  35. package/lib/download/api/index.d.cts +8 -0
  36. package/lib/download/api/index.d.mts +8 -0
  37. package/lib/download/api/queue.d.cts +32 -0
  38. package/lib/download/api/queue.d.mts +32 -0
  39. package/lib/download/api/queue.d.ts +1 -1
  40. package/lib/download/api/types.d.cts +17 -0
  41. package/lib/download/api/types.d.mts +17 -0
  42. package/lib/download/api/types.d.ts +1 -1
  43. package/lib/download/git/branch.d.cts +8 -0
  44. package/lib/download/git/branch.d.mts +8 -0
  45. package/lib/download/git/hash.d.cts +8 -0
  46. package/lib/download/git/hash.d.mts +8 -0
  47. package/lib/download/git/index.d.cts +29 -0
  48. package/lib/download/git/index.d.mts +29 -0
  49. package/lib/download/git/index.d.ts +1 -1
  50. package/lib/download/git/reset.d.cts +6 -0
  51. package/lib/download/git/reset.d.mts +6 -0
  52. package/lib/download/github/hash.d.cts +8 -0
  53. package/lib/download/github/hash.d.mts +8 -0
  54. package/lib/download/github/index.d.cts +31 -0
  55. package/lib/download/github/index.d.mts +31 -0
  56. package/lib/download/github/index.d.ts +1 -1
  57. package/lib/download/github/types.d.cts +11 -0
  58. package/lib/download/github/types.d.mts +11 -0
  59. package/lib/download/github/types.d.ts +1 -1
  60. package/lib/download/gitlab/hash.d.cts +8 -0
  61. package/lib/download/gitlab/hash.d.mts +8 -0
  62. package/lib/download/gitlab/index.d.cts +31 -0
  63. package/lib/download/gitlab/index.d.mts +31 -0
  64. package/lib/download/gitlab/index.d.ts +1 -1
  65. package/lib/download/gitlab/types.d.cts +15 -0
  66. package/lib/download/gitlab/types.d.mts +15 -0
  67. package/lib/download/gitlab/types.d.ts +1 -1
  68. package/lib/download/helpers/untar.d.cts +6 -0
  69. package/lib/download/helpers/untar.d.mts +6 -0
  70. package/lib/download/helpers/unzip.d.cts +6 -0
  71. package/lib/download/helpers/unzip.d.mts +6 -0
  72. package/lib/download/index.d.cts +48 -0
  73. package/lib/download/index.d.mts +48 -0
  74. package/lib/download/index.d.ts +1 -1
  75. package/lib/download/npm/index.d.cts +30 -0
  76. package/lib/download/npm/index.d.mts +30 -0
  77. package/lib/download/npm/index.d.ts +1 -1
  78. package/lib/download/npm/types.d.cts +9 -0
  79. package/lib/download/npm/types.d.mts +9 -0
  80. package/lib/download/npm/types.d.ts +1 -1
  81. package/lib/download/npm/version.d.cts +16 -0
  82. package/lib/download/npm/version.d.mts +16 -0
  83. package/lib/download/npm/version.d.ts +1 -1
  84. package/lib/download/types/modified.d.cts +6 -0
  85. package/lib/download/types/modified.d.mts +6 -0
  86. package/lib/download/types/modified.d.ts +1 -1
  87. package/lib/download/types/sources.d.cts +12 -0
  88. package/lib/download/types/sources.d.mts +12 -0
  89. package/lib/download/types/sources.d.ts +1 -1
  90. package/lib/export/directory.d.cts +26 -0
  91. package/lib/export/directory.d.mts +26 -0
  92. package/lib/export/directory.d.ts +1 -1
  93. package/lib/export/helpers/custom-files.d.cts +12 -0
  94. package/lib/export/helpers/custom-files.d.mts +12 -0
  95. package/lib/export/helpers/custom-files.d.ts +1 -1
  96. package/lib/export/helpers/prepare.d.cts +19 -0
  97. package/lib/export/helpers/prepare.d.mts +19 -0
  98. package/lib/export/helpers/prepare.d.ts +1 -1
  99. package/lib/export/helpers/types-version.d.cts +6 -0
  100. package/lib/export/helpers/types-version.d.mts +6 -0
  101. package/lib/export/icon-package.d.cts +26 -0
  102. package/lib/export/icon-package.d.mts +26 -0
  103. package/lib/export/icon-package.d.ts +1 -3
  104. package/lib/export/json-package.d.cts +25 -0
  105. package/lib/export/json-package.d.mts +25 -0
  106. package/lib/export/json-package.d.ts +1 -1
  107. package/lib/icon-set/index.cjs +22 -0
  108. package/lib/icon-set/index.d.cts +162 -0
  109. package/lib/icon-set/index.d.mts +162 -0
  110. package/lib/icon-set/index.mjs +22 -0
  111. package/lib/icon-set/match.d.cts +15 -0
  112. package/lib/icon-set/match.d.mts +15 -0
  113. package/lib/icon-set/merge.d.cts +14 -0
  114. package/lib/icon-set/merge.d.mts +14 -0
  115. package/lib/icon-set/modified.d.cts +16 -0
  116. package/lib/icon-set/modified.d.mts +16 -0
  117. package/lib/icon-set/props.d.cts +13 -0
  118. package/lib/icon-set/props.d.mts +13 -0
  119. package/lib/icon-set/tags.d.cts +23 -0
  120. package/lib/icon-set/tags.d.mts +23 -0
  121. package/lib/icon-set/types.d.cts +75 -0
  122. package/lib/icon-set/types.d.mts +75 -0
  123. package/lib/icon-set/types.d.ts +1 -1
  124. package/lib/import/directory.d.cts +52 -0
  125. package/lib/import/directory.d.mts +52 -0
  126. package/lib/import/directory.d.ts +1 -1
  127. package/lib/import/figma/index.d.cts +20 -0
  128. package/lib/import/figma/index.d.mts +20 -0
  129. package/lib/import/figma/nodes.d.cts +18 -0
  130. package/lib/import/figma/nodes.d.mts +18 -0
  131. package/lib/import/figma/query.d.cts +42 -0
  132. package/lib/import/figma/query.d.mts +42 -0
  133. package/lib/import/figma/query.d.ts +1 -1
  134. package/lib/import/figma/types/api.d.cts +53 -0
  135. package/lib/import/figma/types/api.d.mts +53 -0
  136. package/lib/import/figma/types/api.d.ts +1 -1
  137. package/lib/import/figma/types/nodes.d.cts +44 -0
  138. package/lib/import/figma/types/nodes.d.mts +44 -0
  139. package/lib/import/figma/types/nodes.d.ts +1 -1
  140. package/lib/import/figma/types/options.d.cts +59 -0
  141. package/lib/import/figma/types/options.d.mts +59 -0
  142. package/lib/import/figma/types/options.d.ts +1 -1
  143. package/lib/import/figma/types/result.d.cts +44 -0
  144. package/lib/import/figma/types/result.d.mts +44 -0
  145. package/lib/import/figma/types/result.d.ts +1 -1
  146. package/lib/index.cjs +7 -5
  147. package/lib/index.d.cts +78 -0
  148. package/lib/index.d.mts +78 -0
  149. package/lib/index.d.ts +1 -0
  150. package/lib/index.mjs +6 -5
  151. package/lib/misc/bump-version.d.cts +6 -0
  152. package/lib/misc/bump-version.d.mts +6 -0
  153. package/lib/misc/cheerio.d.cts +9 -0
  154. package/lib/misc/cheerio.d.mts +9 -0
  155. package/lib/misc/cheerio.d.ts +1 -1
  156. package/lib/misc/compare-dirs.d.cts +11 -0
  157. package/lib/misc/compare-dirs.d.mts +11 -0
  158. package/lib/misc/compare-dirs.d.ts +1 -1
  159. package/lib/misc/exec.d.cts +12 -0
  160. package/lib/misc/exec.d.mts +12 -0
  161. package/lib/misc/exec.d.ts +1 -1
  162. package/lib/misc/keyword.d.cts +6 -0
  163. package/lib/misc/keyword.d.mts +6 -0
  164. package/lib/misc/scan.d.cts +33 -0
  165. package/lib/misc/scan.d.mts +33 -0
  166. package/lib/misc/scan.d.ts +1 -1
  167. package/lib/misc/write-json.d.cts +6 -0
  168. package/lib/misc/write-json.d.mts +6 -0
  169. package/lib/optimise/figma.d.cts +11 -0
  170. package/lib/optimise/figma.d.mts +11 -0
  171. package/lib/optimise/flags.d.cts +11 -0
  172. package/lib/optimise/flags.d.mts +11 -0
  173. package/lib/optimise/global-style.d.cts +11 -0
  174. package/lib/optimise/global-style.d.mts +11 -0
  175. package/lib/optimise/mask.d.cts +24 -0
  176. package/lib/optimise/mask.d.mts +24 -0
  177. package/lib/optimise/origin.d.cts +11 -0
  178. package/lib/optimise/origin.d.mts +11 -0
  179. package/lib/optimise/scale.d.cts +11 -0
  180. package/lib/optimise/scale.d.mts +11 -0
  181. package/lib/optimise/svgo.d.cts +37 -0
  182. package/lib/optimise/svgo.d.mts +37 -0
  183. package/lib/svg/analyse/error.d.cts +10 -0
  184. package/lib/svg/analyse/error.d.mts +10 -0
  185. package/lib/svg/analyse/types.d.cts +92 -0
  186. package/lib/svg/analyse/types.d.mts +92 -0
  187. package/lib/svg/analyse/types.d.ts +1 -1
  188. package/lib/svg/analyse.d.cts +15 -0
  189. package/lib/svg/analyse.d.mts +15 -0
  190. package/lib/svg/cleanup/attribs.d.cts +11 -0
  191. package/lib/svg/cleanup/attribs.d.mts +11 -0
  192. package/lib/svg/cleanup/bad-tags.d.cts +17 -0
  193. package/lib/svg/cleanup/bad-tags.d.mts +17 -0
  194. package/lib/svg/cleanup/bad-tags.d.ts +1 -1
  195. package/lib/svg/cleanup/inline-style.d.cts +11 -0
  196. package/lib/svg/cleanup/inline-style.d.mts +11 -0
  197. package/lib/svg/cleanup/root-style.d.cts +17 -0
  198. package/lib/svg/cleanup/root-style.d.mts +17 -0
  199. package/lib/svg/cleanup/root-svg.d.cts +11 -0
  200. package/lib/svg/cleanup/root-svg.d.mts +11 -0
  201. package/lib/svg/cleanup/svgo-style.d.cts +11 -0
  202. package/lib/svg/cleanup/svgo-style.d.mts +11 -0
  203. package/lib/svg/cleanup.d.cts +16 -0
  204. package/lib/svg/cleanup.d.mts +16 -0
  205. package/lib/svg/cleanup.d.ts +1 -1
  206. package/lib/svg/data/attributes.d.cts +77 -0
  207. package/lib/svg/data/attributes.d.mts +77 -0
  208. package/lib/svg/data/tags.d.cts +95 -0
  209. package/lib/svg/data/tags.d.mts +95 -0
  210. package/lib/svg/index.cjs +17 -0
  211. package/lib/svg/index.d.cts +52 -0
  212. package/lib/svg/index.d.mts +52 -0
  213. package/lib/svg/index.d.ts +5 -1
  214. package/lib/svg/index.mjs +18 -1
  215. package/lib/svg/parse-style.d.cts +58 -0
  216. package/lib/svg/parse-style.d.mts +58 -0
  217. package/lib/svg/parse-style.d.ts +1 -1
  218. package/lib/svg/parse.d.cts +30 -0
  219. package/lib/svg/parse.d.mts +30 -0
  220. package/lib/svg/parse.d.ts +1 -1
  221. package/package.json +14 -17
@@ -0,0 +1,27 @@
1
+ import { Color } from '@iconify/utils/lib/colors/types';
2
+
3
+ /**
4
+ * Color attributes
5
+ */
6
+ type CommonColorAttributes = 'color';
7
+ declare const commonColorAttributes: CommonColorAttributes[];
8
+ type ShapeColorAttributes = 'fill' | 'stroke';
9
+ declare const shapeColorAttributes: ShapeColorAttributes[];
10
+ type SpecialColorAttributes = 'stop-color' | 'flood-color';
11
+ declare const specialColorAttributes: SpecialColorAttributes[];
12
+ type ColorAttributes = CommonColorAttributes | ShapeColorAttributes | SpecialColorAttributes;
13
+ /**
14
+ * Default values
15
+ */
16
+ declare const defaultBlackColor: Color;
17
+ declare const defaultColorValues: Record<ColorAttributes, Color>;
18
+ /**
19
+ * Ignore default color for some tags:
20
+ * - If value is true, allow default color
21
+ * - If value is attribute name, allow default color if attribute is set
22
+ *
23
+ * Parent elements are not checked for these tags!
24
+ */
25
+ declare const allowDefaultColorValue: Partial<Record<ColorAttributes, string | true>>;
26
+
27
+ export { type ColorAttributes, type CommonColorAttributes, type ShapeColorAttributes, type SpecialColorAttributes, allowDefaultColorValue, commonColorAttributes, defaultBlackColor, defaultColorValues, shapeColorAttributes, specialColorAttributes };
@@ -0,0 +1,27 @@
1
+ import { Color } from '@iconify/utils/lib/colors/types';
2
+
3
+ /**
4
+ * Color attributes
5
+ */
6
+ type CommonColorAttributes = 'color';
7
+ declare const commonColorAttributes: CommonColorAttributes[];
8
+ type ShapeColorAttributes = 'fill' | 'stroke';
9
+ declare const shapeColorAttributes: ShapeColorAttributes[];
10
+ type SpecialColorAttributes = 'stop-color' | 'flood-color';
11
+ declare const specialColorAttributes: SpecialColorAttributes[];
12
+ type ColorAttributes = CommonColorAttributes | ShapeColorAttributes | SpecialColorAttributes;
13
+ /**
14
+ * Default values
15
+ */
16
+ declare const defaultBlackColor: Color;
17
+ declare const defaultColorValues: Record<ColorAttributes, Color>;
18
+ /**
19
+ * Ignore default color for some tags:
20
+ * - If value is true, allow default color
21
+ * - If value is attribute name, allow default color if attribute is set
22
+ *
23
+ * Parent elements are not checked for these tags!
24
+ */
25
+ declare const allowDefaultColorValue: Partial<Record<ColorAttributes, string | true>>;
26
+
27
+ export { type ColorAttributes, type CommonColorAttributes, type ShapeColorAttributes, type SpecialColorAttributes, allowDefaultColorValue, commonColorAttributes, defaultBlackColor, defaultColorValues, shapeColorAttributes, specialColorAttributes };
@@ -24,4 +24,4 @@ declare const defaultColorValues: Record<ColorAttributes, Color>;
24
24
  */
25
25
  declare const allowDefaultColorValue: Partial<Record<ColorAttributes, string | true>>;
26
26
 
27
- export { ColorAttributes, CommonColorAttributes, ShapeColorAttributes, SpecialColorAttributes, allowDefaultColorValue, commonColorAttributes, defaultBlackColor, defaultColorValues, shapeColorAttributes, specialColorAttributes };
27
+ export { type ColorAttributes, type CommonColorAttributes, type ShapeColorAttributes, type SpecialColorAttributes, allowDefaultColorValue, commonColorAttributes, defaultBlackColor, defaultColorValues, shapeColorAttributes, specialColorAttributes };
@@ -0,0 +1,16 @@
1
+ import { IconSet } from '../icon-set/index.cjs';
2
+ import '@iconify/types';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
+ import '../icon-set/types.cjs';
5
+ import '../svg/index.cjs';
6
+ import 'cheerio';
7
+ import '@iconify/utils/lib/icon-set/tree';
8
+
9
+ /**
10
+ * Detect palette
11
+ *
12
+ * Returns null if icon set has mixed colors
13
+ */
14
+ declare function detectIconSetPalette(iconSet: IconSet): boolean | null;
15
+
16
+ export { detectIconSetPalette };
@@ -0,0 +1,16 @@
1
+ import { IconSet } from '../icon-set/index.mjs';
2
+ import '@iconify/types';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
+ import '../icon-set/types.mjs';
5
+ import '../svg/index.mjs';
6
+ import 'cheerio';
7
+ import '@iconify/utils/lib/icon-set/tree';
8
+
9
+ /**
10
+ * Detect palette
11
+ *
12
+ * Returns null if icon set has mixed colors
13
+ */
14
+ declare function detectIconSetPalette(iconSet: IconSet): boolean | null;
15
+
16
+ export { detectIconSetPalette };
@@ -0,0 +1,60 @@
1
+ import { Color } from '@iconify/utils/lib/colors/types';
2
+ import { SVG } from '../svg/index.cjs';
3
+ import { ColorAttributes } from './attribs.cjs';
4
+ import { ElementsTreeItem, AnalyseSVGStructureResult, AnalyseSVGStructureOptions, ExtendedTagElement } from '../svg/analyse/types.cjs';
5
+ import 'cheerio';
6
+ import '@iconify/types';
7
+ import '@iconify/utils/lib/customisations/defaults';
8
+ import '../misc/cheerio.cjs';
9
+
10
+ /**
11
+ * Result
12
+ */
13
+ interface FindColorsResult {
14
+ colors: (Color | string)[];
15
+ hasUnsetColor: boolean;
16
+ hasGlobalStyle: boolean;
17
+ }
18
+ /**
19
+ * Callback to call for each found color
20
+ *
21
+ * Callback should return:
22
+ * - new color value to change color
23
+ * - first parameter to keep old value
24
+ * - 'unset' to delete old value
25
+ * - 'remove' to remove shape or rule
26
+ */
27
+ type ParseColorsCallbackResult = Color | string | 'remove' | 'unset';
28
+ type ParseColorsCallback = (attr: ColorAttributes, colorString: string, parsedColor: Color | null, tagName?: string, item?: ExtendedTagElementWithColors) => ParseColorsCallbackResult;
29
+ /**
30
+ * Callback for default color
31
+ */
32
+ type ParseColorOptionsDefaultColorCallback = (prop: string, item: ExtendedTagElementWithColors, treeItem: ElementsTreeItem, iconData: AnalyseSVGStructureResult) => Color;
33
+ /**
34
+ * Options
35
+ */
36
+ interface ParseColorsOptions extends AnalyseSVGStructureOptions {
37
+ callback?: ParseColorsCallback;
38
+ defaultColor?: Color | string | ParseColorOptionsDefaultColorCallback;
39
+ }
40
+ /**
41
+ * Extend properties for element
42
+ */
43
+ type ItemColors = Partial<Record<ColorAttributes, Color | string>>;
44
+ interface ExtendedTagElementWithColors extends ExtendedTagElement {
45
+ _colors?: ItemColors;
46
+ _removed?: boolean;
47
+ }
48
+ /**
49
+ * Find colors in icon
50
+ *
51
+ * Clean up icon before running this function to convert style to attributes using
52
+ * cleanupInlineStyle() or cleanupSVG(), otherwise results might be inaccurate
53
+ */
54
+ declare function parseColors(svg: SVG, options?: ParseColorsOptions): FindColorsResult;
55
+ /**
56
+ * Check if color is empty, such as 'none' or 'transparent'
57
+ */
58
+ declare function isEmptyColor(color: Color): boolean;
59
+
60
+ export { type ExtendedTagElementWithColors, type FindColorsResult, type ParseColorOptionsDefaultColorCallback, type ParseColorsOptions, isEmptyColor, parseColors };
@@ -0,0 +1,60 @@
1
+ import { Color } from '@iconify/utils/lib/colors/types';
2
+ import { SVG } from '../svg/index.mjs';
3
+ import { ColorAttributes } from './attribs.mjs';
4
+ import { ElementsTreeItem, AnalyseSVGStructureResult, AnalyseSVGStructureOptions, ExtendedTagElement } from '../svg/analyse/types.mjs';
5
+ import 'cheerio';
6
+ import '@iconify/types';
7
+ import '@iconify/utils/lib/customisations/defaults';
8
+ import '../misc/cheerio.mjs';
9
+
10
+ /**
11
+ * Result
12
+ */
13
+ interface FindColorsResult {
14
+ colors: (Color | string)[];
15
+ hasUnsetColor: boolean;
16
+ hasGlobalStyle: boolean;
17
+ }
18
+ /**
19
+ * Callback to call for each found color
20
+ *
21
+ * Callback should return:
22
+ * - new color value to change color
23
+ * - first parameter to keep old value
24
+ * - 'unset' to delete old value
25
+ * - 'remove' to remove shape or rule
26
+ */
27
+ type ParseColorsCallbackResult = Color | string | 'remove' | 'unset';
28
+ type ParseColorsCallback = (attr: ColorAttributes, colorString: string, parsedColor: Color | null, tagName?: string, item?: ExtendedTagElementWithColors) => ParseColorsCallbackResult;
29
+ /**
30
+ * Callback for default color
31
+ */
32
+ type ParseColorOptionsDefaultColorCallback = (prop: string, item: ExtendedTagElementWithColors, treeItem: ElementsTreeItem, iconData: AnalyseSVGStructureResult) => Color;
33
+ /**
34
+ * Options
35
+ */
36
+ interface ParseColorsOptions extends AnalyseSVGStructureOptions {
37
+ callback?: ParseColorsCallback;
38
+ defaultColor?: Color | string | ParseColorOptionsDefaultColorCallback;
39
+ }
40
+ /**
41
+ * Extend properties for element
42
+ */
43
+ type ItemColors = Partial<Record<ColorAttributes, Color | string>>;
44
+ interface ExtendedTagElementWithColors extends ExtendedTagElement {
45
+ _colors?: ItemColors;
46
+ _removed?: boolean;
47
+ }
48
+ /**
49
+ * Find colors in icon
50
+ *
51
+ * Clean up icon before running this function to convert style to attributes using
52
+ * cleanupInlineStyle() or cleanupSVG(), otherwise results might be inaccurate
53
+ */
54
+ declare function parseColors(svg: SVG, options?: ParseColorsOptions): FindColorsResult;
55
+ /**
56
+ * Check if color is empty, such as 'none' or 'transparent'
57
+ */
58
+ declare function isEmptyColor(color: Color): boolean;
59
+
60
+ export { type ExtendedTagElementWithColors, type FindColorsResult, type ParseColorOptionsDefaultColorCallback, type ParseColorsOptions, isEmptyColor, parseColors };
@@ -57,4 +57,4 @@ declare function parseColors(svg: SVG, options?: ParseColorsOptions): FindColors
57
57
  */
58
58
  declare function isEmptyColor(color: Color): boolean;
59
59
 
60
- export { ExtendedTagElementWithColors, FindColorsResult, ParseColorOptionsDefaultColorCallback, ParseColorsOptions, isEmptyColor, parseColors };
60
+ export { type ExtendedTagElementWithColors, type FindColorsResult, type ParseColorOptionsDefaultColorCallback, type ParseColorsOptions, isEmptyColor, parseColors };
@@ -0,0 +1,20 @@
1
+ import { SVG } from '../svg/index.cjs';
2
+ import { ParseColorsOptions, FindColorsResult } from './parse.cjs';
3
+ import 'cheerio';
4
+ import '@iconify/types';
5
+ import '@iconify/utils/lib/customisations/defaults';
6
+ import '@iconify/utils/lib/colors/types';
7
+ import './attribs.cjs';
8
+ import '../svg/analyse/types.cjs';
9
+ import '../misc/cheerio.cjs';
10
+
11
+ /**
12
+ * Validate colors in icon
13
+ *
14
+ * If icon is monotone,
15
+ *
16
+ * Throws exception on error
17
+ */
18
+ declare function validateColors(svg: SVG, expectMonotone: boolean, options?: ParseColorsOptions): FindColorsResult;
19
+
20
+ export { validateColors };
@@ -0,0 +1,20 @@
1
+ import { SVG } from '../svg/index.mjs';
2
+ import { ParseColorsOptions, FindColorsResult } from './parse.mjs';
3
+ import 'cheerio';
4
+ import '@iconify/types';
5
+ import '@iconify/utils/lib/customisations/defaults';
6
+ import '@iconify/utils/lib/colors/types';
7
+ import './attribs.mjs';
8
+ import '../svg/analyse/types.mjs';
9
+ import '../misc/cheerio.mjs';
10
+
11
+ /**
12
+ * Validate colors in icon
13
+ *
14
+ * If icon is monotone,
15
+ *
16
+ * Throws exception on error
17
+ */
18
+ declare function validateColors(svg: SVG, expectMonotone: boolean, options?: ParseColorsOptions): FindColorsResult;
19
+
20
+ export { validateColors };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Parse inline style
3
+ */
4
+ declare function parseInlineStyle(style: string): Record<string, string> | null;
5
+
6
+ export { parseInlineStyle };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Parse inline style
3
+ */
4
+ declare function parseInlineStyle(style: string): Record<string, string> | null;
5
+
6
+ export { parseInlineStyle };
@@ -0,0 +1,13 @@
1
+ interface StyleParseError {
2
+ type: 'style-parse-error';
3
+ message: string;
4
+ code: string;
5
+ index?: number;
6
+ fullMessage: string;
7
+ }
8
+ /**
9
+ * Create error message
10
+ */
11
+ declare function styleParseError(message: string, code: string, index?: number): StyleParseError;
12
+
13
+ export { type StyleParseError, styleParseError };
@@ -0,0 +1,13 @@
1
+ interface StyleParseError {
2
+ type: 'style-parse-error';
3
+ message: string;
4
+ code: string;
5
+ index?: number;
6
+ fullMessage: string;
7
+ }
8
+ /**
9
+ * Create error message
10
+ */
11
+ declare function styleParseError(message: string, code: string, index?: number): StyleParseError;
12
+
13
+ export { type StyleParseError, styleParseError };
@@ -10,4 +10,4 @@ interface StyleParseError {
10
10
  */
11
11
  declare function styleParseError(message: string, code: string, index?: number): StyleParseError;
12
12
 
13
- export { StyleParseError, styleParseError };
13
+ export { type StyleParseError, styleParseError };
@@ -0,0 +1,8 @@
1
+ import { CSSTreeToken } from './types.cjs';
2
+
3
+ /**
4
+ * Convert tokens tree to string
5
+ */
6
+ declare function tokensToString(tree: CSSTreeToken[]): string;
7
+
8
+ export { tokensToString };
@@ -0,0 +1,8 @@
1
+ import { CSSTreeToken } from './types.mjs';
2
+
3
+ /**
4
+ * Convert tokens tree to string
5
+ */
6
+ declare function tokensToString(tree: CSSTreeToken[]): string;
7
+
8
+ export { tokensToString };
@@ -0,0 +1,16 @@
1
+ import { StyleParseError } from './error.cjs';
2
+
3
+ /**
4
+ * Find end of quoted string
5
+ *
6
+ * Returns index of character after quote
7
+ */
8
+ declare function findEndOfQuotedString(code: string, quote: string, start: number): number | null;
9
+ /**
10
+ * Find end of url
11
+ *
12
+ * Returns index of character after end of URL
13
+ */
14
+ declare function findEndOfURL(code: string, start: number): number | StyleParseError;
15
+
16
+ export { findEndOfQuotedString, findEndOfURL };
@@ -0,0 +1,16 @@
1
+ import { StyleParseError } from './error.mjs';
2
+
3
+ /**
4
+ * Find end of quoted string
5
+ *
6
+ * Returns index of character after quote
7
+ */
8
+ declare function findEndOfQuotedString(code: string, quote: string, start: number): number | null;
9
+ /**
10
+ * Find end of url
11
+ *
12
+ * Returns index of character after end of URL
13
+ */
14
+ declare function findEndOfURL(code: string, start: number): number | StyleParseError;
15
+
16
+ export { findEndOfQuotedString, findEndOfURL };
@@ -0,0 +1,20 @@
1
+ import { TextToken, CSSRuleToken, CSSTokenWithSelector } from './types.cjs';
2
+
3
+ /**
4
+ * Merge text tokens to string
5
+ */
6
+ declare function mergeTextTokens(tokens: TextToken[]): string;
7
+ /**
8
+ * Get list of selectors from list of words
9
+ */
10
+ declare function getSelectors(tokens: TextToken[]): string[];
11
+ /**
12
+ * Convert text token to rule
13
+ */
14
+ declare function textTokensToRule(tokens: TextToken[]): CSSRuleToken | null;
15
+ /**
16
+ * Create at-rule or selector token from text tokens
17
+ */
18
+ declare function textTokensToSelector(tokens: TextToken[]): CSSTokenWithSelector | null;
19
+
20
+ export { getSelectors, mergeTextTokens, textTokensToRule, textTokensToSelector };
@@ -0,0 +1,20 @@
1
+ import { TextToken, CSSRuleToken, CSSTokenWithSelector } from './types.mjs';
2
+
3
+ /**
4
+ * Merge text tokens to string
5
+ */
6
+ declare function mergeTextTokens(tokens: TextToken[]): string;
7
+ /**
8
+ * Get list of selectors from list of words
9
+ */
10
+ declare function getSelectors(tokens: TextToken[]): string[];
11
+ /**
12
+ * Convert text token to rule
13
+ */
14
+ declare function textTokensToRule(tokens: TextToken[]): CSSRuleToken | null;
15
+ /**
16
+ * Create at-rule or selector token from text tokens
17
+ */
18
+ declare function textTokensToSelector(tokens: TextToken[]): CSSTokenWithSelector | null;
19
+
20
+ export { getSelectors, mergeTextTokens, textTokensToRule, textTokensToSelector };
@@ -0,0 +1,9 @@
1
+ import { StyleParseError } from './error.cjs';
2
+ import { CSSToken } from './types.cjs';
3
+
4
+ /**
5
+ * Get tokens
6
+ */
7
+ declare function getTokens(css: string): CSSToken[] | StyleParseError;
8
+
9
+ export { getTokens };
@@ -0,0 +1,9 @@
1
+ import { StyleParseError } from './error.mjs';
2
+ import { CSSToken } from './types.mjs';
3
+
4
+ /**
5
+ * Get tokens
6
+ */
7
+ declare function getTokens(css: string): CSSToken[] | StyleParseError;
8
+
9
+ export { getTokens };
@@ -0,0 +1,8 @@
1
+ import { CSSToken, CSSTreeToken } from './types.cjs';
2
+
3
+ /**
4
+ * Convert tokens list to tree
5
+ */
6
+ declare function tokensTree(tokens: CSSToken[]): CSSTreeToken[];
7
+
8
+ export { tokensTree };
@@ -0,0 +1,8 @@
1
+ import { CSSToken, CSSTreeToken } from './types.mjs';
2
+
3
+ /**
4
+ * Convert tokens list to tree
5
+ */
6
+ declare function tokensTree(tokens: CSSToken[]): CSSTreeToken[];
7
+
8
+ export { tokensTree };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Text tokens, to be split combined into correct tokens later
3
+ */
4
+ interface TextToken {
5
+ type: 'chunk' | 'url' | 'quoted-string';
6
+ index: number;
7
+ text: string;
8
+ }
9
+ /**
10
+ * Values
11
+ */
12
+ type CSSATValue = string | string[];
13
+ /**
14
+ * Tokens
15
+ */
16
+ interface CSSRuleToken {
17
+ type: 'rule';
18
+ index: number;
19
+ prop: string;
20
+ value: string;
21
+ important?: boolean;
22
+ }
23
+ interface CSSSelectorToken {
24
+ type: 'selector';
25
+ index: number;
26
+ code: string;
27
+ selectors: string[];
28
+ }
29
+ interface CSSAtRuleToken {
30
+ type: 'at-rule';
31
+ index: number;
32
+ rule: string;
33
+ value: string;
34
+ }
35
+ interface CSSCloseToken {
36
+ type: 'close';
37
+ index: number;
38
+ }
39
+ type CSSTokenWithSelector = CSSSelectorToken | CSSAtRuleToken;
40
+ type CSSToken = CSSRuleToken | CSSSelectorToken | CSSAtRuleToken | CSSCloseToken;
41
+ /**
42
+ * Tree tokens
43
+ */
44
+ interface CSSSelectorTreeToken extends CSSSelectorToken {
45
+ children: CSSTreeToken[];
46
+ }
47
+ interface CSSAtRuleTreeToken extends CSSAtRuleToken {
48
+ children: CSSTreeToken[];
49
+ }
50
+ type CSSTreeToken = CSSRuleToken | CSSSelectorTreeToken | CSSAtRuleTreeToken;
51
+
52
+ export type { CSSATValue, CSSAtRuleToken, CSSAtRuleTreeToken, CSSCloseToken, CSSRuleToken, CSSSelectorToken, CSSSelectorTreeToken, CSSToken, CSSTokenWithSelector, CSSTreeToken, TextToken };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Text tokens, to be split combined into correct tokens later
3
+ */
4
+ interface TextToken {
5
+ type: 'chunk' | 'url' | 'quoted-string';
6
+ index: number;
7
+ text: string;
8
+ }
9
+ /**
10
+ * Values
11
+ */
12
+ type CSSATValue = string | string[];
13
+ /**
14
+ * Tokens
15
+ */
16
+ interface CSSRuleToken {
17
+ type: 'rule';
18
+ index: number;
19
+ prop: string;
20
+ value: string;
21
+ important?: boolean;
22
+ }
23
+ interface CSSSelectorToken {
24
+ type: 'selector';
25
+ index: number;
26
+ code: string;
27
+ selectors: string[];
28
+ }
29
+ interface CSSAtRuleToken {
30
+ type: 'at-rule';
31
+ index: number;
32
+ rule: string;
33
+ value: string;
34
+ }
35
+ interface CSSCloseToken {
36
+ type: 'close';
37
+ index: number;
38
+ }
39
+ type CSSTokenWithSelector = CSSSelectorToken | CSSAtRuleToken;
40
+ type CSSToken = CSSRuleToken | CSSSelectorToken | CSSAtRuleToken | CSSCloseToken;
41
+ /**
42
+ * Tree tokens
43
+ */
44
+ interface CSSSelectorTreeToken extends CSSSelectorToken {
45
+ children: CSSTreeToken[];
46
+ }
47
+ interface CSSAtRuleTreeToken extends CSSAtRuleToken {
48
+ children: CSSTreeToken[];
49
+ }
50
+ type CSSTreeToken = CSSRuleToken | CSSSelectorTreeToken | CSSAtRuleTreeToken;
51
+
52
+ export type { CSSATValue, CSSAtRuleToken, CSSAtRuleTreeToken, CSSCloseToken, CSSRuleToken, CSSSelectorToken, CSSSelectorTreeToken, CSSToken, CSSTokenWithSelector, CSSTreeToken, TextToken };
@@ -49,4 +49,4 @@ interface CSSAtRuleTreeToken extends CSSAtRuleToken {
49
49
  }
50
50
  type CSSTreeToken = CSSRuleToken | CSSSelectorTreeToken | CSSAtRuleTreeToken;
51
51
 
52
- export { CSSATValue, CSSAtRuleToken, CSSAtRuleTreeToken, CSSCloseToken, CSSRuleToken, CSSSelectorToken, CSSSelectorTreeToken, CSSToken, CSSTokenWithSelector, CSSTreeToken, TextToken };
52
+ export type { CSSATValue, CSSAtRuleToken, CSSAtRuleTreeToken, CSSCloseToken, CSSRuleToken, CSSSelectorToken, CSSSelectorTreeToken, CSSToken, CSSTokenWithSelector, CSSTreeToken, TextToken };
@@ -0,0 +1,20 @@
1
+ import { APIQueryParams, APICacheOptions } from './types.cjs';
2
+
3
+ /**
4
+ * Unique key
5
+ */
6
+ declare function apiCacheKey(query: APIQueryParams): string;
7
+ /**
8
+ * Store cache
9
+ */
10
+ declare function storeAPICache(options: APICacheOptions, key: string, data: string): Promise<void>;
11
+ /**
12
+ * Get item from cache
13
+ */
14
+ declare function getAPICache(dir: string, key: string): Promise<string | null>;
15
+ /**
16
+ * Clear cache
17
+ */
18
+ declare function clearAPICache(dir: string): Promise<void>;
19
+
20
+ export { apiCacheKey, clearAPICache, getAPICache, storeAPICache };
@@ -0,0 +1,20 @@
1
+ import { APIQueryParams, APICacheOptions } from './types.mjs';
2
+
3
+ /**
4
+ * Unique key
5
+ */
6
+ declare function apiCacheKey(query: APIQueryParams): string;
7
+ /**
8
+ * Store cache
9
+ */
10
+ declare function storeAPICache(options: APICacheOptions, key: string, data: string): Promise<void>;
11
+ /**
12
+ * Get item from cache
13
+ */
14
+ declare function getAPICache(dir: string, key: string): Promise<string | null>;
15
+ /**
16
+ * Clear cache
17
+ */
18
+ declare function clearAPICache(dir: string): Promise<void>;
19
+
20
+ export { apiCacheKey, clearAPICache, getAPICache, storeAPICache };
@@ -0,0 +1,18 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { APIQueryParams } from './types.cjs';
3
+
4
+ /**
5
+ * Axios config, customisable
6
+ */
7
+ declare const axiosConfig: Omit<AxiosRequestConfig, 'headers' | 'responseType' | 'url' | 'method' | 'data'>;
8
+ interface AxiosCallbacks {
9
+ onStart?: (url: string, params: APIQueryParams) => void;
10
+ onSuccess?: (url: string, params: APIQueryParams) => void;
11
+ onError?: (url: string, params: APIQueryParams, errorCode?: number) => void;
12
+ }
13
+ /**
14
+ * Customisable callbacks, used for logging
15
+ */
16
+ declare const fetchCallbacks: AxiosCallbacks;
17
+
18
+ export { axiosConfig, fetchCallbacks };
@@ -0,0 +1,18 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { APIQueryParams } from './types.mjs';
3
+
4
+ /**
5
+ * Axios config, customisable
6
+ */
7
+ declare const axiosConfig: Omit<AxiosRequestConfig, 'headers' | 'responseType' | 'url' | 'method' | 'data'>;
8
+ interface AxiosCallbacks {
9
+ onStart?: (url: string, params: APIQueryParams) => void;
10
+ onSuccess?: (url: string, params: APIQueryParams) => void;
11
+ onError?: (url: string, params: APIQueryParams, errorCode?: number) => void;
12
+ }
13
+ /**
14
+ * Customisable callbacks, used for logging
15
+ */
16
+ declare const fetchCallbacks: AxiosCallbacks;
17
+
18
+ export { axiosConfig, fetchCallbacks };
@@ -0,0 +1,8 @@
1
+ import { APIQueryParams } from './types.cjs';
2
+
3
+ /**
4
+ * Download file
5
+ */
6
+ declare function downloadFile(query: APIQueryParams, target: string): Promise<void>;
7
+
8
+ export { downloadFile };