@iconify/tools 3.0.3 → 3.0.4

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 (84) hide show
  1. package/lib/colors/attribs.d.ts +27 -0
  2. package/lib/colors/detect.d.ts +15 -0
  3. package/lib/colors/parse.d.ts +67 -0
  4. package/lib/colors/validate.d.ts +26 -0
  5. package/lib/css/parse.d.ts +6 -0
  6. package/lib/css/parser/error.d.ts +13 -0
  7. package/lib/css/parser/export.d.ts +8 -0
  8. package/lib/css/parser/strings.d.ts +16 -0
  9. package/lib/css/parser/text.d.ts +20 -0
  10. package/lib/css/parser/tokens.d.ts +9 -0
  11. package/lib/css/parser/tree.d.ts +8 -0
  12. package/lib/css/parser/types.d.ts +52 -0
  13. package/lib/download/api/cache.d.ts +20 -0
  14. package/lib/download/api/download.d.ts +8 -0
  15. package/lib/download/api/index.d.ts +8 -0
  16. package/lib/download/api/types.d.ts +17 -0
  17. package/lib/download/git/branch.d.ts +8 -0
  18. package/lib/download/git/hash.d.ts +8 -0
  19. package/lib/download/git/index.d.ts +29 -0
  20. package/lib/download/git/reset.d.ts +6 -0
  21. package/lib/download/github/hash.d.ts +8 -0
  22. package/lib/download/github/index.d.ts +31 -0
  23. package/lib/download/github/types.d.ts +11 -0
  24. package/lib/download/gitlab/hash.d.ts +8 -0
  25. package/lib/download/gitlab/index.d.ts +31 -0
  26. package/lib/download/gitlab/types.d.ts +15 -0
  27. package/lib/download/helpers/untar.d.ts +6 -0
  28. package/lib/download/helpers/unzip.d.ts +6 -0
  29. package/lib/download/index.d.ts +48 -0
  30. package/lib/download/npm/index.d.ts +30 -0
  31. package/lib/download/npm/types.d.ts +9 -0
  32. package/lib/download/npm/version.d.ts +16 -0
  33. package/lib/download/types/modified.d.ts +6 -0
  34. package/lib/download/types/sources.d.ts +12 -0
  35. package/lib/export/directory.d.ts +25 -0
  36. package/lib/export/helpers/custom-files.d.ts +12 -0
  37. package/lib/export/helpers/prepare.d.ts +19 -0
  38. package/lib/export/helpers/types-version.d.ts +6 -0
  39. package/lib/export/icon-package.d.ts +25 -0
  40. package/lib/export/json-package.d.ts +23 -0
  41. package/lib/icon-set/index.d.ts +161 -0
  42. package/lib/icon-set/match.d.ts +14 -0
  43. package/lib/icon-set/merge.d.ts +13 -0
  44. package/lib/icon-set/modified.d.ts +15 -0
  45. package/lib/icon-set/props.d.ts +13 -0
  46. package/lib/icon-set/tags.d.ts +22 -0
  47. package/lib/icon-set/types.d.ts +75 -0
  48. package/lib/import/directory.d.ts +51 -0
  49. package/lib/import/figma/index.d.ts +19 -0
  50. package/lib/import/figma/nodes.d.ts +17 -0
  51. package/lib/import/figma/query.d.ts +28 -0
  52. package/lib/import/figma/types/api.d.ts +53 -0
  53. package/lib/import/figma/types/nodes.d.ts +43 -0
  54. package/lib/import/figma/types/options.d.ts +58 -0
  55. package/lib/import/figma/types/result.d.ts +43 -0
  56. package/lib/index.d.ts +72 -0
  57. package/lib/misc/bump-version.d.ts +6 -0
  58. package/lib/misc/cheerio.d.ts +7 -0
  59. package/lib/misc/compare-dirs.d.ts +11 -0
  60. package/lib/misc/exec.d.ts +12 -0
  61. package/lib/misc/keyword.d.ts +6 -0
  62. package/lib/misc/scan.d.ts +33 -0
  63. package/lib/misc/write-json.d.ts +6 -0
  64. package/lib/optimise/flags.d.ts +10 -0
  65. package/lib/optimise/global-style.d.ts +10 -0
  66. package/lib/optimise/origin.d.ts +10 -0
  67. package/lib/optimise/scale.d.ts +10 -0
  68. package/lib/optimise/svgo.d.ts +36 -0
  69. package/lib/svg/analyse/error.d.ts +8 -0
  70. package/lib/svg/analyse/types.d.ts +89 -0
  71. package/lib/svg/analyse.d.ts +13 -0
  72. package/lib/svg/cleanup/attribs.d.ts +10 -0
  73. package/lib/svg/cleanup/bad-tags.d.ts +16 -0
  74. package/lib/svg/cleanup/inline-style.d.ts +10 -0
  75. package/lib/svg/cleanup/root-style.d.ts +16 -0
  76. package/lib/svg/cleanup/root-svg.d.ts +10 -0
  77. package/lib/svg/cleanup/svgo-style.d.ts +10 -0
  78. package/lib/svg/cleanup.d.ts +15 -0
  79. package/lib/svg/data/attributes.d.ts +77 -0
  80. package/lib/svg/data/tags.d.ts +95 -0
  81. package/lib/svg/index.d.ts +47 -0
  82. package/lib/svg/parse-style.d.ts +63 -0
  83. package/lib/svg/parse.d.ts +36 -0
  84. package/package.json +191 -191
@@ -0,0 +1,95 @@
1
+ /**
2
+ * This list is highly opinionated. It is designed to handle icons that can be safely embedded in HTML and linked as external source.
3
+ * Icons cannot have anything that requires external resources, anything that renders inconsistently.
4
+ */
5
+ /**
6
+ * Bad tags
7
+ *
8
+ * Parser should throw error if one of these tags is found
9
+ *
10
+ * List includes text tags because:
11
+ * - it usuaully uses custom font, which makes things much more complex
12
+ * - it renders differently on different operating systems and browsers
13
+ *
14
+ * View tag is not allowed because it requires targeting view by id from external source, making it unusable in embedded icons.
15
+ */
16
+ declare const badTags: Set<string>;
17
+ /**
18
+ * Deprecated or irrelevant tags
19
+ *
20
+ * Tags that are quietly removed
21
+ */
22
+ declare const unsupportedTags: Set<string>;
23
+ /**
24
+ * Style
25
+ */
26
+ declare const styleTag: Set<string>;
27
+ /**
28
+ * Definitions: reusable elements inside
29
+ */
30
+ declare const defsTag: Set<string>;
31
+ /**
32
+ * Masks: colors are ignored, elements must have id
33
+ */
34
+ declare const maskTags: Set<string>;
35
+ /**
36
+ * Symbol
37
+ */
38
+ declare const symbolTag: Set<string>;
39
+ /**
40
+ * SVG shapes
41
+ */
42
+ declare const shapeTags: Set<string>;
43
+ /**
44
+ * Use
45
+ */
46
+ declare const useTag: Set<string>;
47
+ /**
48
+ * Groups
49
+ */
50
+ declare const groupTag: Set<string>;
51
+ /**
52
+ * Marker, should be inside <defs>
53
+ */
54
+ declare const markerTag: Set<string>;
55
+ /**
56
+ * SVG animations
57
+ */
58
+ declare const animateTags: Set<string>;
59
+ declare const animateMotionChildTags: Set<string>;
60
+ /**
61
+ * Gradients, should be inside <defs>
62
+ */
63
+ declare const gradientTags: Set<string>;
64
+ /**
65
+ * Gradient color, must be inside one of gradientTags
66
+ */
67
+ declare const gradientChildTags: Set<string>;
68
+ /**
69
+ * Pattern, should be inside <defs>
70
+ */
71
+ declare const patternTag: Set<string>;
72
+ /**
73
+ * Filters
74
+ */
75
+ declare const filterTag: Set<string>;
76
+ declare const feLightningTags: Set<string>;
77
+ declare const filterChildTags: Set<string>;
78
+ declare const feComponentTransferChildTag: Set<string>;
79
+ declare const feLightningChildTags: Set<string>;
80
+ declare const feMergeChildTags: Set<string>;
81
+ /***** Combination of tags *****/
82
+ /**
83
+ * Reusable elements that use colors
84
+ *
85
+ * Most are used via color attributes like `fill`
86
+ * Some are used via custom attributes like `marker-start`
87
+ * Filter is used via `filter`
88
+ */
89
+ declare const reusableElementsWithPalette: Set<string>;
90
+ /**
91
+ * All supported tags
92
+ */
93
+ declare const allValidTags: Set<string>;
94
+
95
+ export { allValidTags, animateMotionChildTags, animateTags, badTags, defsTag, feComponentTransferChildTag, feLightningChildTags, feLightningTags, feMergeChildTags, filterChildTags, filterTag, gradientChildTags, gradientTags, groupTag, markerTag, maskTags, patternTag, reusableElementsWithPalette, shapeTags, styleTag, symbolTag, unsupportedTags, useTag };
@@ -0,0 +1,47 @@
1
+ import { IconifyIcon } from '@iconify/types';
2
+ export { IconifyIcon } from '@iconify/types';
3
+ import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
4
+ export { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
5
+
6
+ interface ViewBox {
7
+ left: number;
8
+ top: number;
9
+ width: number;
10
+ height: number;
11
+ }
12
+
13
+ /**
14
+ * SVG class, used to manipulate icon content.
15
+ */
16
+ declare class SVG {
17
+ $svg: cheerio.Root;
18
+ viewBox: ViewBox;
19
+ /**
20
+ * Constructor
21
+ */
22
+ constructor(content: string);
23
+ /**
24
+ * Get SVG as string
25
+ */
26
+ toString(customisations?: IconifyIconCustomisations): string;
27
+ /**
28
+ * Get SVG as string without whitespaces
29
+ */
30
+ toMinifiedString(customisations?: IconifyIconCustomisations): string;
31
+ /**
32
+ * Get body
33
+ */
34
+ getBody(): string;
35
+ /**
36
+ * Get icon as IconifyIcon
37
+ */
38
+ getIcon(): IconifyIcon;
39
+ /**
40
+ * Load SVG
41
+ *
42
+ * @param {string} content
43
+ */
44
+ load(content: string): void;
45
+ }
46
+
47
+ export { SVG, ViewBox };
@@ -0,0 +1,63 @@
1
+ import { SVG } from './index.js';
2
+ import { CSSRuleToken, CSSToken, CSSAtRuleToken } from '../css/parser/types.js';
3
+ import { ParseSVGCallbackItem } from './parse.js';
4
+ import '@iconify/types';
5
+ import '@iconify/utils/lib/customisations/defaults';
6
+ import '../misc/cheerio.js';
7
+
8
+ /**
9
+ * Item in callback
10
+ */
11
+ interface ParseSVGStyleCallbackItemCommon {
12
+ prop: string;
13
+ value: string;
14
+ }
15
+ interface ParseSVGStyleCallbackItemInline extends ParseSVGStyleCallbackItemCommon {
16
+ type: 'inline';
17
+ item: ParseSVGCallbackItem;
18
+ }
19
+ interface ParseSVGStyleCallbackItemGlobal extends ParseSVGStyleCallbackItemCommon {
20
+ type: 'global';
21
+ token: CSSRuleToken;
22
+ selectors: string[];
23
+ selectorTokens: CSSToken[];
24
+ prevTokens: (CSSToken | null)[];
25
+ nextTokens: CSSToken[];
26
+ }
27
+ interface ParseSVGStyleCallbackItemGlobalAtRule extends ParseSVGStyleCallbackItemCommon {
28
+ token: CSSAtRuleToken;
29
+ childTokens: CSSToken[];
30
+ prevTokens: (CSSToken | null)[];
31
+ nextTokens: CSSToken[];
32
+ }
33
+ interface ParseSVGStyleCallbackItemGlobalGenericAtRule extends ParseSVGStyleCallbackItemGlobalAtRule {
34
+ type: 'at-rule';
35
+ }
36
+ interface ParseSVGStyleCallbackItemGlobalKeyframesAtRule extends ParseSVGStyleCallbackItemGlobalAtRule {
37
+ type: 'keyframes';
38
+ from: Record<string, string>;
39
+ }
40
+ type ParseSVGStyleCallbackItem = ParseSVGStyleCallbackItemInline | ParseSVGStyleCallbackItemGlobal | ParseSVGStyleCallbackItemGlobalGenericAtRule | ParseSVGStyleCallbackItemGlobalKeyframesAtRule;
41
+ /**
42
+ * Result: undefined to remove item, string to change/keep item
43
+ */
44
+ type ParseSVGStyleCallbackResult = string | undefined;
45
+ /**
46
+ * Callback function
47
+ */
48
+ type ParseSVGStyleCallback = (item: ParseSVGStyleCallbackItem) => ParseSVGStyleCallbackResult | Promise<ParseSVGStyleCallbackResult>;
49
+ type ParseSVGStyleCallbackSync = (item: ParseSVGStyleCallbackItem) => ParseSVGStyleCallbackResult;
50
+ /**
51
+ * Parse styles in SVG
52
+ *
53
+ * This function finds CSS in SVG, parses it, calls callback for each rule.
54
+ * Callback should return new value (string) or undefined to remove rule.
55
+ * Callback can be asynchronous.
56
+ */
57
+ declare function parseSVGStyle(svg: SVG, callback: ParseSVGStyleCallback): Promise<void>;
58
+ /**
59
+ * Synchronous version
60
+ */
61
+ declare function parseSVGStyleSync(svg: SVG, callback: ParseSVGStyleCallbackSync): void;
62
+
63
+ export { ParseSVGStyleCallback, ParseSVGStyleCallbackItem, ParseSVGStyleCallbackResult, ParseSVGStyleCallbackSync, parseSVGStyle, parseSVGStyleSync };
@@ -0,0 +1,36 @@
1
+ import { CheerioElement, WrappedCheerioElement } from '../misc/cheerio.js';
2
+ import { SVG } from './index.js';
3
+ import '@iconify/types';
4
+ import '@iconify/utils/lib/customisations/defaults';
5
+
6
+ /**
7
+ * Item in callback
8
+ */
9
+ interface ParseSVGCallbackItem {
10
+ tagName: string;
11
+ element: CheerioElement;
12
+ $element: WrappedCheerioElement;
13
+ svg: SVG;
14
+ parents: ParseSVGCallbackItem[];
15
+ testChildren: boolean;
16
+ removeNode: boolean;
17
+ }
18
+ /**
19
+ * Callback function
20
+ */
21
+ type Callback<T> = (item: ParseSVGCallbackItem) => T;
22
+ type ParseSVGCallback = Callback<void | Promise<void>>;
23
+ type ParseSVGCallbackSync = Callback<void>;
24
+ /**
25
+ * Parse SVG
26
+ *
27
+ * This function finds all elements in SVG and calls callback for each element.
28
+ * Callback can be asynchronous.
29
+ */
30
+ declare function parseSVG(svg: SVG, callback: ParseSVGCallback): Promise<void>;
31
+ /**
32
+ * Sync version
33
+ */
34
+ declare function parseSVGSync(svg: SVG, callback: ParseSVGCallbackSync): void;
35
+
36
+ export { ParseSVGCallback, ParseSVGCallbackItem, ParseSVGCallbackSync, parseSVG, parseSVGSync };