@iconify/tools 1.3.17 → 2.0.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/.editorconfig +13 -0
  2. package/.eslintignore +2 -0
  3. package/lib/colors/attribs.d.ts +16 -0
  4. package/lib/colors/attribs.js +26 -0
  5. package/lib/colors/attribs.mjs +28 -0
  6. package/lib/colors/parse.d.ts +37 -0
  7. package/lib/colors/parse.js +261 -0
  8. package/lib/colors/parse.mjs +212 -0
  9. package/lib/css/parse.d.ts +4 -0
  10. package/lib/css/parse.js +23 -0
  11. package/lib/css/parse.mjs +20 -0
  12. package/lib/css/parser/error.d.ts +11 -0
  13. package/lib/css/parser/error.js +27 -0
  14. package/lib/css/parser/error.mjs +23 -0
  15. package/lib/css/parser/export.d.ts +5 -0
  16. package/lib/css/parser/export.js +69 -0
  17. package/lib/css/parser/export.mjs +46 -0
  18. package/lib/css/parser/strings.d.ts +13 -0
  19. package/lib/css/parser/strings.js +93 -0
  20. package/lib/css/parser/strings.mjs +74 -0
  21. package/lib/css/parser/text.d.ts +17 -0
  22. package/lib/css/parser/text.js +174 -0
  23. package/lib/css/parser/text.mjs +133 -0
  24. package/lib/css/parser/tokens.d.ts +6 -0
  25. package/lib/css/parser/tokens.js +200 -0
  26. package/lib/css/parser/tokens.mjs +186 -0
  27. package/lib/css/parser/tree.d.ts +5 -0
  28. package/lib/css/parser/tree.js +44 -0
  29. package/lib/css/parser/tree.mjs +40 -0
  30. package/lib/css/parser/types.d.ts +51 -0
  31. package/lib/css/parser/types.js +2 -0
  32. package/lib/css/parser/types.mjs +0 -0
  33. package/lib/icon-set/index.d.ts +134 -0
  34. package/lib/icon-set/index.js +776 -0
  35. package/lib/icon-set/index.mjs +617 -0
  36. package/lib/icon-set/match.d.ts +6 -0
  37. package/lib/icon-set/match.js +66 -0
  38. package/lib/icon-set/match.mjs +55 -0
  39. package/lib/icon-set/merge.d.ts +5 -0
  40. package/lib/icon-set/merge.js +91 -0
  41. package/lib/icon-set/merge.mjs +75 -0
  42. package/lib/icon-set/props.d.ts +10 -0
  43. package/lib/icon-set/props.js +33 -0
  44. package/lib/icon-set/props.mjs +25 -0
  45. package/lib/icon-set/types.d.ts +68 -0
  46. package/lib/icon-set/types.js +2 -0
  47. package/lib/icon-set/types.mjs +0 -0
  48. package/lib/import/directory.d.ts +35 -0
  49. package/lib/import/directory.js +59 -0
  50. package/lib/import/directory.mjs +47 -0
  51. package/lib/misc/keyword.d.ts +4 -0
  52. package/lib/misc/keyword.js +31 -0
  53. package/lib/misc/keyword.mjs +17 -0
  54. package/lib/misc/scan.d.ts +24 -0
  55. package/lib/misc/scan.js +48 -0
  56. package/lib/misc/scan.mjs +43 -0
  57. package/lib/optimise/flags.d.ts +5 -0
  58. package/lib/optimise/flags.js +303 -0
  59. package/lib/optimise/flags.mjs +241 -0
  60. package/lib/optimise/scale.d.ts +5 -0
  61. package/lib/optimise/scale.js +42 -0
  62. package/lib/optimise/scale.mjs +22 -0
  63. package/lib/optimise/svgo.d.ts +27 -0
  64. package/lib/optimise/svgo.js +88 -0
  65. package/lib/optimise/svgo.mjs +75 -0
  66. package/lib/svg/cleanup/attribs.d.ts +5 -0
  67. package/lib/svg/cleanup/attribs.js +43 -0
  68. package/lib/svg/cleanup/attribs.mjs +36 -0
  69. package/lib/svg/cleanup/bad-tags.d.ts +5 -0
  70. package/lib/svg/cleanup/bad-tags.js +69 -0
  71. package/lib/svg/cleanup/bad-tags.mjs +68 -0
  72. package/lib/svg/cleanup/inline-style.d.ts +5 -0
  73. package/lib/svg/cleanup/inline-style.js +77 -0
  74. package/lib/svg/cleanup/inline-style.mjs +65 -0
  75. package/lib/svg/cleanup/root-svg.d.ts +5 -0
  76. package/lib/svg/cleanup/root-svg.js +106 -0
  77. package/lib/svg/cleanup/root-svg.mjs +88 -0
  78. package/lib/svg/cleanup/svgo-style.d.ts +5 -0
  79. package/lib/svg/cleanup/svgo-style.js +35 -0
  80. package/lib/svg/cleanup/svgo-style.mjs +29 -0
  81. package/lib/svg/cleanup.d.ts +5 -0
  82. package/lib/svg/cleanup.js +24 -0
  83. package/lib/svg/cleanup.mjs +16 -0
  84. package/lib/svg/data/attributes.d.ts +71 -0
  85. package/lib/svg/data/attributes.js +403 -0
  86. package/lib/svg/data/attributes.mjs +352 -0
  87. package/lib/svg/data/tags.d.ts +89 -0
  88. package/lib/svg/data/tags.js +185 -0
  89. package/lib/svg/data/tags.mjs +136 -0
  90. package/lib/svg/index.d.ts +33 -0
  91. package/lib/svg/index.js +122 -0
  92. package/lib/svg/index.mjs +85 -0
  93. package/lib/svg/parse-style.d.ts +40 -0
  94. package/lib/svg/parse-style.js +131 -0
  95. package/lib/svg/parse-style.mjs +109 -0
  96. package/lib/svg/parse.d.ts +30 -0
  97. package/lib/svg/parse.js +49 -0
  98. package/lib/svg/parse.mjs +40 -0
  99. package/package.json +167 -13
  100. package/README.md +0 -576
  101. package/license.txt +0 -21
  102. package/sample/parse.js +0 -74
  103. package/sample/source/icon-close.svg +0 -15
  104. package/sample/source/icon-confirm.svg +0 -14
  105. package/sample/source/icon-search.svg +0 -16
  106. package/src/collection.js +0 -641
  107. package/src/colors/change_palette.js +0 -227
  108. package/src/colors/get_palette.js +0 -143
  109. package/src/colors/opacify.js +0 -195
  110. package/src/export/component.js +0 -482
  111. package/src/export/dir.js +0 -109
  112. package/src/export/json.js +0 -329
  113. package/src/export/phantomjs.js +0 -76
  114. package/src/export/phantomjs_script.js +0 -125
  115. package/src/export/png.js +0 -193
  116. package/src/export/svg.js +0 -55
  117. package/src/export/templates/component.md +0 -79
  118. package/src/export/templates/info.md +0 -3
  119. package/src/export/templates/sample-react-1.md +0 -21
  120. package/src/export/templates/sample-react-2.md +0 -15
  121. package/src/export/templates/sample-react.md +0 -11
  122. package/src/export/templates/sample-svelte.md +0 -11
  123. package/src/export/templates/sample-svelte1.md +0 -22
  124. package/src/export/templates/sample-svelte2.md +0 -13
  125. package/src/export/templates/sample-vue-0.md +0 -30
  126. package/src/export/templates/sample-vue-1.md +0 -25
  127. package/src/export/templates/sample-vue-2.md +0 -27
  128. package/src/export/templates/sample-vue.md +0 -28
  129. package/src/helpers.js +0 -43
  130. package/src/import/dir.js +0 -234
  131. package/src/import/font.js +0 -402
  132. package/src/import/json.js +0 -200
  133. package/src/import/svg.js +0 -60
  134. package/src/import/web_icons.js +0 -248
  135. package/src/modules.js +0 -50
  136. package/src/optimize/crop.js +0 -554
  137. package/src/optimize/crop_script.js +0 -525
  138. package/src/optimize/flags.js +0 -430
  139. package/src/optimize/scale.js +0 -72
  140. package/src/optimize/svgo.js +0 -161
  141. package/src/optimize/tags.js +0 -522
  142. package/src/shapes/convert.js +0 -264
  143. package/src/shapes/index.js +0 -135
  144. package/src/shapes/length.js +0 -707
  145. package/src/shapes/length_script.js +0 -105
  146. package/src/shapes/options.js +0 -60
  147. package/src/svg.js +0 -162
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTokens = void 0;
4
+ const error_1 = require("./error");
5
+ const strings_1 = require("./strings");
6
+ const text_1 = require("./text");
7
+ /**
8
+ * Find all tokens in css, sort by index
9
+ */
10
+ function findTokens(code, tokens) {
11
+ const list = [];
12
+ const lc = code.toLowerCase();
13
+ tokens.forEach((token) => {
14
+ let index = 0;
15
+ // eslint-disable-next-line no-constant-condition
16
+ while (true) {
17
+ index = lc.indexOf(token, index);
18
+ if (index === -1) {
19
+ return;
20
+ }
21
+ list.push({
22
+ token: token,
23
+ index: index,
24
+ });
25
+ index++;
26
+ }
27
+ });
28
+ list.sort((a, b) => a.index - b.index);
29
+ return list;
30
+ }
31
+ /**
32
+ * Get tokens
33
+ */
34
+ function getTokens(css) {
35
+ const items = [];
36
+ let textQueue = [];
37
+ let start = 0;
38
+ let depth = 0;
39
+ try {
40
+ const checkRule = (text) => {
41
+ var _a;
42
+ if (!textQueue.length) {
43
+ return;
44
+ }
45
+ const item = (0, text_1.textTokensToRule)(textQueue);
46
+ if (item) {
47
+ items.push(item);
48
+ return;
49
+ }
50
+ const value = (0, text_1.mergeTextTokens)(textQueue) + text;
51
+ if (!value.length) {
52
+ return;
53
+ }
54
+ throw (0, error_1.styleParseError)('Invalid css rule', css, (_a = textQueue[0]) === null || _a === void 0 ? void 0 : _a.index);
55
+ };
56
+ findTokens(css, ['"', "'", '/*', '{', '}', ';', 'url(', '\\']).forEach((token) => {
57
+ if (token.index < start) {
58
+ return;
59
+ }
60
+ switch (token.token) {
61
+ case '/*': {
62
+ // Skip to end of comment
63
+ textQueue.push({
64
+ type: 'chunk',
65
+ text: css.slice(start, token.index),
66
+ index: start,
67
+ });
68
+ start = token.index;
69
+ const end = css.indexOf('*/', start + 2);
70
+ if (end === -1) {
71
+ // Invalid string
72
+ throw (0, error_1.styleParseError)('Missing comment closing statement', css, start);
73
+ }
74
+ start = end + 2;
75
+ break;
76
+ }
77
+ case '\\':
78
+ // Escaped character, skip next character
79
+ textQueue.push({
80
+ type: 'chunk',
81
+ text: css.slice(start, token.index + 2),
82
+ index: start,
83
+ });
84
+ start = token.index + 2;
85
+ break;
86
+ case 'url(': {
87
+ textQueue.push({
88
+ type: 'chunk',
89
+ text: css.slice(start, token.index),
90
+ index: start,
91
+ });
92
+ start = token.index;
93
+ // Skip to end of URL
94
+ const end = (0, strings_1.findEndOfURL)(css, start);
95
+ if (typeof end !== 'number') {
96
+ throw end;
97
+ }
98
+ textQueue.push({
99
+ type: 'url',
100
+ text: css.slice(start, end),
101
+ index: start,
102
+ });
103
+ start = end;
104
+ break;
105
+ }
106
+ case '"':
107
+ case "'": {
108
+ textQueue.push({
109
+ type: 'chunk',
110
+ text: css.slice(start, token.index),
111
+ index: start,
112
+ });
113
+ start = token.index;
114
+ // Skip to end of quoted string
115
+ const end = (0, strings_1.findEndOfQuotedString)(css, token.token, start);
116
+ if (end === null) {
117
+ throw (0, error_1.styleParseError)('Missing closing ' + token.token, css, start);
118
+ }
119
+ textQueue.push({
120
+ type: 'quoted-string',
121
+ text: css.slice(start, end),
122
+ index: start,
123
+ });
124
+ start = end;
125
+ break;
126
+ }
127
+ case ';': {
128
+ textQueue.push({
129
+ type: 'chunk',
130
+ text: css.slice(start, token.index),
131
+ index: start,
132
+ });
133
+ checkRule(token.token);
134
+ start = token.index + 1;
135
+ textQueue = [];
136
+ break;
137
+ }
138
+ case '{': {
139
+ // Get selector
140
+ textQueue.push({
141
+ type: 'chunk',
142
+ text: css.slice(start, token.index),
143
+ index: start,
144
+ });
145
+ const item = (0, text_1.textTokensToSelector)(textQueue);
146
+ if (!item) {
147
+ throw (0, error_1.styleParseError)('Invalid css rule', css, start);
148
+ }
149
+ items.push(item);
150
+ start = token.index + 1;
151
+ textQueue = [];
152
+ depth++;
153
+ break;
154
+ }
155
+ case '}': {
156
+ // End of block
157
+ textQueue.push({
158
+ type: 'chunk',
159
+ text: css.slice(start, token.index),
160
+ index: start,
161
+ });
162
+ checkRule('');
163
+ items.push({
164
+ type: 'close',
165
+ index: token.index,
166
+ });
167
+ if (!depth) {
168
+ throw (0, error_1.styleParseError)('Unexpected }', css, token.index);
169
+ }
170
+ depth--;
171
+ start = token.index + 1;
172
+ textQueue = [];
173
+ break;
174
+ }
175
+ default:
176
+ throw new Error(`Forgot to parse token: ${token.token}`);
177
+ }
178
+ });
179
+ if (depth) {
180
+ return (0, error_1.styleParseError)('Missing }', css);
181
+ }
182
+ // Add remaining code
183
+ textQueue.push({
184
+ type: 'chunk',
185
+ text: css.slice(start),
186
+ index: start,
187
+ });
188
+ checkRule('');
189
+ }
190
+ catch (err) {
191
+ // Return error if it is StyleParseError object, re-throw if it is something else
192
+ if (typeof err === 'object' &&
193
+ err.type === 'style-parse-error') {
194
+ return err;
195
+ }
196
+ throw err;
197
+ }
198
+ return items;
199
+ }
200
+ exports.getTokens = getTokens;
@@ -0,0 +1,186 @@
1
+ // src/css/parser/tokens.ts
2
+ import { styleParseError } from "./error.mjs";
3
+ import { findEndOfQuotedString, findEndOfURL } from "./strings.mjs";
4
+ import {
5
+ mergeTextTokens,
6
+ textTokensToRule,
7
+ textTokensToSelector
8
+ } from "./text.mjs";
9
+ function findTokens(code, tokens) {
10
+ const list = [];
11
+ const lc = code.toLowerCase();
12
+ tokens.forEach((token) => {
13
+ let index = 0;
14
+ while (true) {
15
+ index = lc.indexOf(token, index);
16
+ if (index === -1) {
17
+ return;
18
+ }
19
+ list.push({
20
+ token,
21
+ index
22
+ });
23
+ index++;
24
+ }
25
+ });
26
+ list.sort((a, b) => a.index - b.index);
27
+ return list;
28
+ }
29
+ function getTokens(css) {
30
+ const items = [];
31
+ let textQueue = [];
32
+ let start = 0;
33
+ let depth = 0;
34
+ try {
35
+ const checkRule = (text) => {
36
+ var _a;
37
+ if (!textQueue.length) {
38
+ return;
39
+ }
40
+ const item = textTokensToRule(textQueue);
41
+ if (item) {
42
+ items.push(item);
43
+ return;
44
+ }
45
+ const value = mergeTextTokens(textQueue) + text;
46
+ if (!value.length) {
47
+ return;
48
+ }
49
+ throw styleParseError("Invalid css rule", css, (_a = textQueue[0]) == null ? void 0 : _a.index);
50
+ };
51
+ findTokens(css, ['"', "'", "/*", "{", "}", ";", "url(", "\\"]).forEach((token) => {
52
+ if (token.index < start) {
53
+ return;
54
+ }
55
+ switch (token.token) {
56
+ case "/*": {
57
+ textQueue.push({
58
+ type: "chunk",
59
+ text: css.slice(start, token.index),
60
+ index: start
61
+ });
62
+ start = token.index;
63
+ const end = css.indexOf("*/", start + 2);
64
+ if (end === -1) {
65
+ throw styleParseError("Missing comment closing statement", css, start);
66
+ }
67
+ start = end + 2;
68
+ break;
69
+ }
70
+ case "\\":
71
+ textQueue.push({
72
+ type: "chunk",
73
+ text: css.slice(start, token.index + 2),
74
+ index: start
75
+ });
76
+ start = token.index + 2;
77
+ break;
78
+ case "url(": {
79
+ textQueue.push({
80
+ type: "chunk",
81
+ text: css.slice(start, token.index),
82
+ index: start
83
+ });
84
+ start = token.index;
85
+ const end = findEndOfURL(css, start);
86
+ if (typeof end !== "number") {
87
+ throw end;
88
+ }
89
+ textQueue.push({
90
+ type: "url",
91
+ text: css.slice(start, end),
92
+ index: start
93
+ });
94
+ start = end;
95
+ break;
96
+ }
97
+ case '"':
98
+ case "'": {
99
+ textQueue.push({
100
+ type: "chunk",
101
+ text: css.slice(start, token.index),
102
+ index: start
103
+ });
104
+ start = token.index;
105
+ const end = findEndOfQuotedString(css, token.token, start);
106
+ if (end === null) {
107
+ throw styleParseError("Missing closing " + token.token, css, start);
108
+ }
109
+ textQueue.push({
110
+ type: "quoted-string",
111
+ text: css.slice(start, end),
112
+ index: start
113
+ });
114
+ start = end;
115
+ break;
116
+ }
117
+ case ";": {
118
+ textQueue.push({
119
+ type: "chunk",
120
+ text: css.slice(start, token.index),
121
+ index: start
122
+ });
123
+ checkRule(token.token);
124
+ start = token.index + 1;
125
+ textQueue = [];
126
+ break;
127
+ }
128
+ case "{": {
129
+ textQueue.push({
130
+ type: "chunk",
131
+ text: css.slice(start, token.index),
132
+ index: start
133
+ });
134
+ const item = textTokensToSelector(textQueue);
135
+ if (!item) {
136
+ throw styleParseError("Invalid css rule", css, start);
137
+ }
138
+ items.push(item);
139
+ start = token.index + 1;
140
+ textQueue = [];
141
+ depth++;
142
+ break;
143
+ }
144
+ case "}": {
145
+ textQueue.push({
146
+ type: "chunk",
147
+ text: css.slice(start, token.index),
148
+ index: start
149
+ });
150
+ checkRule("");
151
+ items.push({
152
+ type: "close",
153
+ index: token.index
154
+ });
155
+ if (!depth) {
156
+ throw styleParseError("Unexpected }", css, token.index);
157
+ }
158
+ depth--;
159
+ start = token.index + 1;
160
+ textQueue = [];
161
+ break;
162
+ }
163
+ default:
164
+ throw new Error(`Forgot to parse token: ${token.token}`);
165
+ }
166
+ });
167
+ if (depth) {
168
+ return styleParseError("Missing }", css);
169
+ }
170
+ textQueue.push({
171
+ type: "chunk",
172
+ text: css.slice(start),
173
+ index: start
174
+ });
175
+ checkRule("");
176
+ } catch (err) {
177
+ if (typeof err === "object" && err.type === "style-parse-error") {
178
+ return err;
179
+ }
180
+ throw err;
181
+ }
182
+ return items;
183
+ }
184
+ export {
185
+ getTokens
186
+ };
@@ -0,0 +1,5 @@
1
+ import type { CSSToken, CSSTreeToken } from './types';
2
+ /**
3
+ * Convert tokens list to tree
4
+ */
5
+ export declare function tokensTree(tokens: CSSToken[]): CSSTreeToken[];
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tokensTree = void 0;
4
+ /**
5
+ * Convert tokens list to tree
6
+ */
7
+ function tokensTree(tokens) {
8
+ const result = [];
9
+ let index = 0;
10
+ function parse(target) {
11
+ while (index < tokens.length) {
12
+ const token = tokens[index];
13
+ index++;
14
+ switch (token.type) {
15
+ case 'close':
16
+ return;
17
+ case 'selector':
18
+ case 'at-rule': {
19
+ const newItem = {
20
+ ...token,
21
+ children: [],
22
+ };
23
+ target.push(newItem);
24
+ parse(newItem.children);
25
+ // Remove token without children
26
+ if (!newItem.children.length) {
27
+ const index = target.indexOf(newItem);
28
+ if (index !== -1) {
29
+ target.splice(index, 1);
30
+ }
31
+ }
32
+ break;
33
+ }
34
+ default:
35
+ target.push(token);
36
+ }
37
+ }
38
+ }
39
+ while (index < tokens.length) {
40
+ parse(result);
41
+ }
42
+ return result;
43
+ }
44
+ exports.tokensTree = tokensTree;
@@ -0,0 +1,40 @@
1
+ // src/css/parser/tree.ts
2
+ function tokensTree(tokens) {
3
+ const result = [];
4
+ let index = 0;
5
+ function parse(target) {
6
+ while (index < tokens.length) {
7
+ const token = tokens[index];
8
+ index++;
9
+ switch (token.type) {
10
+ case "close":
11
+ return;
12
+ case "selector":
13
+ case "at-rule": {
14
+ const newItem = {
15
+ ...token,
16
+ children: []
17
+ };
18
+ target.push(newItem);
19
+ parse(newItem.children);
20
+ if (!newItem.children.length) {
21
+ const index2 = target.indexOf(newItem);
22
+ if (index2 !== -1) {
23
+ target.splice(index2, 1);
24
+ }
25
+ }
26
+ break;
27
+ }
28
+ default:
29
+ target.push(token);
30
+ }
31
+ }
32
+ }
33
+ while (index < tokens.length) {
34
+ parse(result);
35
+ }
36
+ return result;
37
+ }
38
+ export {
39
+ tokensTree
40
+ };
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Text tokens, to be split combined into correct tokens later
3
+ */
4
+ export interface TextToken {
5
+ type: 'chunk' | 'url' | 'quoted-string';
6
+ index: number;
7
+ text: string;
8
+ }
9
+ /**
10
+ * Values
11
+ */
12
+ export declare type CSSATValue = string | string[];
13
+ /**
14
+ * Tokens
15
+ */
16
+ export interface CSSRuleToken {
17
+ type: 'rule';
18
+ index: number;
19
+ prop: string;
20
+ value: string;
21
+ important?: boolean;
22
+ }
23
+ export interface CSSSelectorToken {
24
+ type: 'selector';
25
+ index: number;
26
+ code: string;
27
+ selectors: string[];
28
+ }
29
+ export interface CSSAtRuleToken {
30
+ type: 'at-rule';
31
+ index: number;
32
+ code: string;
33
+ atRule: string;
34
+ atValues: CSSATValue[];
35
+ }
36
+ export interface CSSCloseToken {
37
+ type: 'close';
38
+ index: number;
39
+ }
40
+ export declare type CSSTokenWithSelector = CSSSelectorToken | CSSAtRuleToken;
41
+ export declare type CSSToken = CSSRuleToken | CSSSelectorToken | CSSAtRuleToken | CSSCloseToken;
42
+ /**
43
+ * Tree tokens
44
+ */
45
+ export interface CSSSelectorTreeToken extends CSSSelectorToken {
46
+ children: CSSTreeToken[];
47
+ }
48
+ export interface CSSAtRuleTreeToken extends CSSAtRuleToken {
49
+ children: CSSTreeToken[];
50
+ }
51
+ export declare type CSSTreeToken = CSSRuleToken | CSSSelectorTreeToken | CSSAtRuleTreeToken;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
File without changes
@@ -0,0 +1,134 @@
1
+ import type { IconifyJSON, IconifyInfo } from '@iconify/types';
2
+ import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations';
3
+ import type { CheckThemeResult, CommonIconProps, IconCategory, IconSetAsyncForEachCallback, IconSetIconEntry, IconSetIconType, ResolvedIconifyIcon } from './types';
4
+ import { SVG } from '../svg';
5
+ /**
6
+ * Sort theme keys: long keys first
7
+ *
8
+ * Applies changes to parameter, but also returns it
9
+ */
10
+ export declare function sortThemeKeys(keys: string[]): string[];
11
+ /**
12
+ * Export icon set
13
+ */
14
+ export declare class IconSet {
15
+ /**
16
+ * Properties. You can write directly to almost any property, but avoid writing to
17
+ * 'entries' and 'categories' properties, there are functions for that.
18
+ */
19
+ prefix: string;
20
+ entries: Record<string, IconSetIconEntry>;
21
+ info: IconifyInfo | undefined;
22
+ categories: Set<IconCategory>;
23
+ prefixes: Record<string, string>;
24
+ suffixes: Record<string, string>;
25
+ /**
26
+ * Load icon set
27
+ */
28
+ constructor(data: IconifyJSON);
29
+ /**
30
+ * Load icon set
31
+ */
32
+ load(data: IconifyJSON): void;
33
+ /**
34
+ * List icons
35
+ */
36
+ list(types?: IconSetIconType[]): string[];
37
+ /**
38
+ * forEach function to loop through all entries.
39
+ * Supports asynchronous callbacks.
40
+ *
41
+ * Callback should return false to stop loop.
42
+ */
43
+ forEach(callback: IconSetAsyncForEachCallback, types?: IconSetIconType[]): Promise<void>;
44
+ /**
45
+ * Resolve icon
46
+ */
47
+ resolve(name: string, full: false): ResolvedIconifyIcon | null;
48
+ resolve(name: string): ResolvedIconifyIcon | null;
49
+ resolve(name: string, full: true): Required<ResolvedIconifyIcon> | null;
50
+ /**
51
+ * Generate HTML
52
+ */
53
+ toString(name: string, custommisations?: IconifyIconCustomisations): string | null;
54
+ /**
55
+ * Get SVG instance for icon
56
+ */
57
+ toSVG(name: string): SVG | null;
58
+ /**
59
+ * Export icon set
60
+ */
61
+ export(validate?: boolean): IconifyJSON;
62
+ /**
63
+ * Get characters map
64
+ */
65
+ chars(names?: string[]): Record<string, string>;
66
+ /**
67
+ * Filter icons
68
+ */
69
+ _filter(callback: (name: string, item: IconSetIconEntry, icon?: ResolvedIconifyIcon) => boolean): string[];
70
+ /**
71
+ * Count icons
72
+ */
73
+ count(): number;
74
+ /**
75
+ * Find category by title
76
+ */
77
+ _findCategory(title: string, add: boolean): IconCategory | null;
78
+ /**
79
+ * Count icons in category, remove category if empty
80
+ *
81
+ * Hidden icons and aliases do not count
82
+ */
83
+ listCategory(category: IconCategory | string): string[] | null;
84
+ /**
85
+ * Check if icon exists
86
+ */
87
+ exists(name: string): boolean;
88
+ /**
89
+ * Remove icons. Returns number of removed icons
90
+ *
91
+ * If removeDependencies is a string, it represents new parent for all aliases of removed icon.
92
+ */
93
+ remove(name: string, removeDependencies?: boolean | string): number;
94
+ /**
95
+ * Remove icon
96
+ */
97
+ rename(oldName: string, newName: string): boolean;
98
+ /**
99
+ * Add/update item
100
+ */
101
+ setItem(name: string, item: IconSetIconEntry): boolean;
102
+ /**
103
+ * Add/update icon
104
+ */
105
+ setIcon(name: string, icon: ResolvedIconifyIcon): boolean;
106
+ /**
107
+ * Add/update alias without props
108
+ */
109
+ setAlias(name: string, parent: string): boolean;
110
+ /**
111
+ * Add/update alias with props
112
+ */
113
+ setVariation(name: string, parent: string, props: CommonIconProps): boolean;
114
+ /**
115
+ * Icon from SVG. Updates old icon if it exists
116
+ */
117
+ fromSVG(name: string, svg: SVG): boolean;
118
+ /**
119
+ * Add or remove character for icon
120
+ */
121
+ toggleCharacter(iconName: string, char: string, add: boolean): boolean;
122
+ /**
123
+ * Add or remove category for icon
124
+ */
125
+ toggleCategory(iconName: string, category: string, add: boolean): boolean;
126
+ /**
127
+ * Find icons that belong to theme
128
+ */
129
+ checkTheme(prefix: boolean): CheckThemeResult;
130
+ }
131
+ /**
132
+ * Create blank icon set
133
+ */
134
+ export declare function blankIconSet(prefix: string): IconSet;