@iconify/tools 2.0.16 → 2.1.0-beta.1
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.
- package/lib/colors/parse.d.ts +1 -1
- package/lib/colors/validate.d.ts +1 -1
- package/lib/download/git/branch.cjs +2 -3
- package/lib/download/git/branch.mjs +2 -3
- package/lib/download/git/hash.cjs +1 -0
- package/lib/download/git/hash.mjs +1 -0
- package/lib/download/git/index.cjs +4 -2
- package/lib/download/git/index.mjs +4 -2
- package/lib/download/git/reset.cjs +4 -2
- package/lib/download/git/reset.mjs +4 -2
- package/lib/download/index.cjs +4 -2
- package/lib/download/index.mjs +4 -2
- package/lib/download/npm/index.cjs +1 -0
- package/lib/download/npm/index.mjs +1 -0
- package/lib/download/npm/version.cjs +1 -0
- package/lib/download/npm/version.mjs +1 -0
- package/lib/export/directory.d.ts +4 -2
- package/lib/export/icon-package.d.ts +4 -2
- package/lib/export/json-package.cjs +2 -2
- package/lib/export/json-package.d.ts +4 -2
- package/lib/export/json-package.mjs +2 -2
- package/lib/icon-set/index.cjs +100 -106
- package/lib/icon-set/index.d.ts +24 -5
- package/lib/icon-set/index.mjs +101 -107
- package/lib/icon-set/match.cjs +5 -5
- package/lib/icon-set/match.d.ts +5 -3
- package/lib/icon-set/match.mjs +2 -2
- package/lib/icon-set/merge.cjs +10 -3
- package/lib/icon-set/merge.d.ts +4 -2
- package/lib/icon-set/merge.mjs +10 -3
- package/lib/icon-set/modified.cjs +27 -0
- package/lib/icon-set/modified.d.ts +16 -0
- package/lib/icon-set/modified.mjs +23 -0
- package/lib/icon-set/props.cjs +8 -18
- package/lib/icon-set/props.d.ts +5 -6
- package/lib/icon-set/props.mjs +9 -18
- package/lib/icon-set/types.d.ts +1 -1
- package/lib/import/directory.cjs +4 -3
- package/lib/import/directory.d.ts +7 -5
- package/lib/import/directory.mjs +4 -3
- package/lib/import/figma/index.cjs +4 -3
- package/lib/import/figma/index.d.ts +4 -2
- package/lib/import/figma/index.mjs +4 -3
- package/lib/import/figma/nodes.d.ts +4 -2
- package/lib/import/figma/query.d.ts +4 -2
- package/lib/import/figma/types/nodes.d.ts +4 -2
- package/lib/import/figma/types/options.d.ts +4 -2
- package/lib/import/figma/types/result.d.ts +4 -2
- package/lib/index.cjs +5 -2
- package/lib/index.d.ts +3 -1
- package/lib/index.mjs +5 -2
- package/lib/misc/exec.cjs +7 -2
- package/lib/misc/exec.mjs +7 -2
- package/lib/optimise/flags.d.ts +1 -1
- package/lib/optimise/global-style.d.ts +1 -1
- package/lib/optimise/scale.d.ts +1 -1
- package/lib/optimise/svgo.cjs +58 -56
- package/lib/optimise/svgo.d.ts +12 -7
- package/lib/optimise/svgo.mjs +58 -55
- package/lib/svg/analyse.d.ts +1 -1
- package/lib/svg/cleanup/attribs.d.ts +1 -1
- package/lib/svg/cleanup/bad-tags.d.ts +1 -1
- package/lib/svg/cleanup/inline-style.d.ts +1 -1
- package/lib/svg/cleanup/root-svg.d.ts +1 -1
- package/lib/svg/cleanup/svgo-style.d.ts +1 -1
- package/lib/svg/cleanup.d.ts +1 -1
- package/lib/svg/index.cjs +7 -4
- package/lib/svg/index.d.ts +2 -2
- package/lib/svg/index.mjs +8 -5
- package/lib/svg/parse-style.d.ts +1 -1
- package/lib/svg/parse.d.ts +1 -1
- package/lib/types-f0980297.d.ts +258 -0
- package/package.json +6 -3
package/lib/icon-set/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defaultIconDimensions, defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
|
2
2
|
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
|
3
|
-
import {
|
|
3
|
+
import { defaultIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
|
4
4
|
import { minifyIconSet } from '@iconify/utils/lib/icon-set/minify';
|
|
5
5
|
import { convertIconSetInfo } from '@iconify/utils/lib/icon-set/convert-info';
|
|
6
|
-
import { filterProps,
|
|
6
|
+
import { filterProps, defaultCommonProps } from './props.mjs';
|
|
7
7
|
import { SVG } from '../svg/index.mjs';
|
|
8
|
+
import { mergeIconData } from '@iconify/utils';
|
|
9
|
+
import '@iconify/utils/lib/misc/objects';
|
|
8
10
|
import 'cheerio';
|
|
9
|
-
import '@iconify/utils';
|
|
10
11
|
|
|
11
|
-
const maxIteration = 6;
|
|
12
12
|
const themeKeys = ["prefixes", "suffixes"];
|
|
13
13
|
function sortThemeKeys(keys) {
|
|
14
14
|
return keys.sort((a, b) => a.length === b.length ? a.localeCompare(b) : b.length - a.length);
|
|
@@ -19,7 +19,7 @@ class IconSet {
|
|
|
19
19
|
}
|
|
20
20
|
load(data) {
|
|
21
21
|
this.prefix = data.prefix;
|
|
22
|
-
const defaultProps = filterProps(data, true);
|
|
22
|
+
const defaultProps = filterProps(data, defaultIconDimensions, true);
|
|
23
23
|
this.entries = /* @__PURE__ */ Object.create(null);
|
|
24
24
|
const entries = this.entries;
|
|
25
25
|
for (const name in data.icons) {
|
|
@@ -30,7 +30,7 @@ class IconSet {
|
|
|
30
30
|
props: filterProps({
|
|
31
31
|
...defaultProps,
|
|
32
32
|
...item
|
|
33
|
-
}, true),
|
|
33
|
+
}, defaultCommonProps, true),
|
|
34
34
|
chars: /* @__PURE__ */ new Set(),
|
|
35
35
|
categories: /* @__PURE__ */ new Set()
|
|
36
36
|
};
|
|
@@ -38,9 +38,12 @@ class IconSet {
|
|
|
38
38
|
}
|
|
39
39
|
if (data.aliases) {
|
|
40
40
|
for (const name in data.aliases) {
|
|
41
|
+
if (entries[name]) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
41
44
|
const item = data.aliases[name];
|
|
42
45
|
const parent = item.parent;
|
|
43
|
-
const props = filterProps(item, false);
|
|
46
|
+
const props = filterProps(item, defaultCommonProps, false);
|
|
44
47
|
const chars = /* @__PURE__ */ new Set();
|
|
45
48
|
if (Object.keys(props).length) {
|
|
46
49
|
const entry = {
|
|
@@ -117,6 +120,10 @@ class IconSet {
|
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
122
|
});
|
|
123
|
+
this.lastModified = data.lastModified || 0;
|
|
124
|
+
}
|
|
125
|
+
updateLastModified(value) {
|
|
126
|
+
this.lastModified = value || Math.floor(Date.now() / 1e3);
|
|
120
127
|
}
|
|
121
128
|
list(types = ["icon", "variation"]) {
|
|
122
129
|
return Object.keys(this.entries).filter((name) => {
|
|
@@ -140,60 +147,53 @@ class IconSet {
|
|
|
140
147
|
}
|
|
141
148
|
}
|
|
142
149
|
}
|
|
143
|
-
|
|
150
|
+
getTree(names) {
|
|
144
151
|
const entries = this.entries;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
152
|
+
const resolved = /* @__PURE__ */ Object.create(null);
|
|
153
|
+
function resolve(name) {
|
|
154
|
+
const item = entries[name];
|
|
155
|
+
if (!item) {
|
|
156
|
+
return resolved[name] = null;
|
|
148
157
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
case "alias":
|
|
159
|
-
return getIcon(item.parent, iteration + 1);
|
|
160
|
-
case "variation": {
|
|
161
|
-
const parent = getIcon(item.parent, iteration + 1);
|
|
162
|
-
if (!parent) {
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
for (const key in item.props) {
|
|
166
|
-
const attr = key;
|
|
167
|
-
const value = item.props[attr];
|
|
168
|
-
if (value) {
|
|
169
|
-
if (parent[attr] === void 0) {
|
|
170
|
-
parent[attr] = value;
|
|
171
|
-
} else {
|
|
172
|
-
switch (attr) {
|
|
173
|
-
case "rotate":
|
|
174
|
-
parent[attr] = (parent[attr] + value) % 4;
|
|
175
|
-
break;
|
|
176
|
-
case "hFlip":
|
|
177
|
-
case "vFlip":
|
|
178
|
-
parent[attr] = !parent[attr];
|
|
179
|
-
break;
|
|
180
|
-
default:
|
|
181
|
-
parent[attr] = value;
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return parent;
|
|
158
|
+
if (item.type === "icon") {
|
|
159
|
+
return resolved[name] = [];
|
|
160
|
+
}
|
|
161
|
+
if (resolved[name] === void 0) {
|
|
162
|
+
resolved[name] = null;
|
|
163
|
+
const parent = item.parent;
|
|
164
|
+
const value = parent && resolve(parent);
|
|
165
|
+
if (value) {
|
|
166
|
+
resolved[name] = [parent].concat(value);
|
|
188
167
|
}
|
|
189
|
-
default:
|
|
190
|
-
return null;
|
|
191
168
|
}
|
|
169
|
+
return resolved[name];
|
|
192
170
|
}
|
|
193
|
-
|
|
194
|
-
return
|
|
171
|
+
(names || Object.keys(entries)).forEach(resolve);
|
|
172
|
+
return resolved;
|
|
195
173
|
}
|
|
196
|
-
|
|
174
|
+
resolve(name, full = false) {
|
|
175
|
+
const entries = this.entries;
|
|
176
|
+
const item = entries[name];
|
|
177
|
+
const tree = item && (item.type === "icon" ? [] : this.getTree([name])[name]);
|
|
178
|
+
if (!tree) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
let result = {};
|
|
182
|
+
function parse(name2) {
|
|
183
|
+
const item2 = entries[name2];
|
|
184
|
+
if (item2.type === "alias") {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
result = mergeIconData(item2.props, result);
|
|
188
|
+
if (item2.type === "icon") {
|
|
189
|
+
result.body = item2.body;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
parse(name);
|
|
193
|
+
tree.forEach(parse);
|
|
194
|
+
return result && full ? { ...defaultIconProps, ...result } : result;
|
|
195
|
+
}
|
|
196
|
+
toString(name, customisations = {
|
|
197
197
|
width: "auto",
|
|
198
198
|
height: "auto"
|
|
199
199
|
}) {
|
|
@@ -202,8 +202,8 @@ class IconSet {
|
|
|
202
202
|
return null;
|
|
203
203
|
}
|
|
204
204
|
const result = iconToSVG(item, {
|
|
205
|
-
...
|
|
206
|
-
...
|
|
205
|
+
...defaultIconCustomisations,
|
|
206
|
+
...customisations
|
|
207
207
|
});
|
|
208
208
|
const attributes = Object.keys(result.attributes).map((key) => ` ${key}="${result.attributes[key]}"`).join("");
|
|
209
209
|
return `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"${attributes}>${result.body}</svg>`;
|
|
@@ -215,6 +215,7 @@ class IconSet {
|
|
|
215
215
|
export(validate = true) {
|
|
216
216
|
const icons = /* @__PURE__ */ Object.create(null);
|
|
217
217
|
const aliases = /* @__PURE__ */ Object.create(null);
|
|
218
|
+
const tree = validate ? this.getTree() : {};
|
|
218
219
|
const names = Object.keys(this.entries);
|
|
219
220
|
names.sort((a, b) => a.localeCompare(b));
|
|
220
221
|
names.forEach((name) => {
|
|
@@ -230,7 +231,7 @@ class IconSet {
|
|
|
230
231
|
}
|
|
231
232
|
case "alias":
|
|
232
233
|
case "variation": {
|
|
233
|
-
if (validate && !
|
|
234
|
+
if (validate && !tree[name]) {
|
|
234
235
|
break;
|
|
235
236
|
}
|
|
236
237
|
const props = item.type === "variation" ? item.props : {};
|
|
@@ -254,6 +255,9 @@ class IconSet {
|
|
|
254
255
|
if (info) {
|
|
255
256
|
result.info = info;
|
|
256
257
|
}
|
|
258
|
+
if (this.lastModified) {
|
|
259
|
+
result.lastModified = this.lastModified;
|
|
260
|
+
}
|
|
257
261
|
result.icons = icons;
|
|
258
262
|
if (Object.keys(aliases).length) {
|
|
259
263
|
result.aliases = aliases;
|
|
@@ -337,7 +341,7 @@ class IconSet {
|
|
|
337
341
|
return true;
|
|
338
342
|
}).length;
|
|
339
343
|
}
|
|
340
|
-
|
|
344
|
+
findCategory(title, add) {
|
|
341
345
|
const categoryItem = Array.from(this.categories).find((item) => item.title === title);
|
|
342
346
|
if (categoryItem) {
|
|
343
347
|
return categoryItem;
|
|
@@ -353,7 +357,7 @@ class IconSet {
|
|
|
353
357
|
return null;
|
|
354
358
|
}
|
|
355
359
|
listCategory(category) {
|
|
356
|
-
const categoryItem = typeof category === "string" ? this.
|
|
360
|
+
const categoryItem = typeof category === "string" ? this.findCategory(category, false) : category;
|
|
357
361
|
if (!categoryItem) {
|
|
358
362
|
return null;
|
|
359
363
|
}
|
|
@@ -376,51 +380,45 @@ class IconSet {
|
|
|
376
380
|
}
|
|
377
381
|
remove(name, removeDependencies = true) {
|
|
378
382
|
const entries = this.entries;
|
|
379
|
-
const names = /* @__PURE__ */ new Set();
|
|
380
383
|
if (typeof removeDependencies === "string") {
|
|
381
|
-
|
|
384
|
+
const item2 = entries[removeDependencies];
|
|
385
|
+
if (name === removeDependencies || item2?.type !== "icon") {
|
|
382
386
|
return 0;
|
|
383
387
|
}
|
|
384
|
-
names.add(removeDependencies);
|
|
385
388
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
names.add(name2);
|
|
391
|
-
if (removeDependencies === true || !iteration && typeof removeDependencies === "string") {
|
|
392
|
-
for (const key in entries) {
|
|
393
|
-
const item = entries[key];
|
|
394
|
-
switch (item.type) {
|
|
395
|
-
case "icon":
|
|
396
|
-
break;
|
|
397
|
-
case "alias":
|
|
398
|
-
case "variation":
|
|
399
|
-
if (item.parent === name2) {
|
|
400
|
-
if (removeDependencies === true) {
|
|
401
|
-
if (!del(key, iteration + 1)) {
|
|
402
|
-
return false;
|
|
403
|
-
}
|
|
404
|
-
break;
|
|
405
|
-
}
|
|
406
|
-
item.parent = removeDependencies;
|
|
407
|
-
}
|
|
408
|
-
break;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
return true;
|
|
389
|
+
const item = entries[name];
|
|
390
|
+
if (!item) {
|
|
391
|
+
return 0;
|
|
413
392
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
393
|
+
this.updateLastModified();
|
|
394
|
+
if (typeof removeDependencies === "string") {
|
|
395
|
+
for (const key in entries) {
|
|
396
|
+
const item2 = entries[key];
|
|
397
|
+
if (item2.type !== "icon" && item2.parent === name) {
|
|
398
|
+
item2.parent = removeDependencies;
|
|
399
|
+
}
|
|
417
400
|
}
|
|
418
|
-
|
|
419
|
-
|
|
401
|
+
return 0;
|
|
402
|
+
}
|
|
403
|
+
delete entries[name];
|
|
404
|
+
let count = 1;
|
|
405
|
+
function remove(parent) {
|
|
406
|
+
const list = Object.keys(entries).filter((name2) => {
|
|
407
|
+
const item2 = entries[name2];
|
|
408
|
+
return item2.type !== "icon" && item2.parent === parent;
|
|
420
409
|
});
|
|
421
|
-
|
|
410
|
+
list.forEach((name2) => {
|
|
411
|
+
if (entries[name2]) {
|
|
412
|
+
delete entries[name2];
|
|
413
|
+
count++;
|
|
414
|
+
remove(name2);
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
if (removeDependencies === true) {
|
|
419
|
+
remove(name);
|
|
422
420
|
}
|
|
423
|
-
return
|
|
421
|
+
return count;
|
|
424
422
|
}
|
|
425
423
|
rename(oldName, newName) {
|
|
426
424
|
const entries = this.entries;
|
|
@@ -447,6 +445,7 @@ class IconSet {
|
|
|
447
445
|
break;
|
|
448
446
|
}
|
|
449
447
|
}
|
|
448
|
+
this.updateLastModified();
|
|
450
449
|
return true;
|
|
451
450
|
}
|
|
452
451
|
setItem(name, item) {
|
|
@@ -459,13 +458,14 @@ class IconSet {
|
|
|
459
458
|
}
|
|
460
459
|
}
|
|
461
460
|
this.entries[name] = item;
|
|
461
|
+
this.updateLastModified();
|
|
462
462
|
return true;
|
|
463
463
|
}
|
|
464
464
|
setIcon(name, icon) {
|
|
465
465
|
return this.setItem(name, {
|
|
466
466
|
type: "icon",
|
|
467
467
|
body: icon.body,
|
|
468
|
-
props: filterProps(icon, true),
|
|
468
|
+
props: filterProps(icon, defaultCommonProps, true),
|
|
469
469
|
chars: /* @__PURE__ */ new Set(),
|
|
470
470
|
categories: /* @__PURE__ */ new Set()
|
|
471
471
|
});
|
|
@@ -486,18 +486,12 @@ class IconSet {
|
|
|
486
486
|
});
|
|
487
487
|
}
|
|
488
488
|
fromSVG(name, svg) {
|
|
489
|
-
const props = svg.viewBox;
|
|
489
|
+
const props = { ...svg.viewBox };
|
|
490
490
|
const body = svg.getBody();
|
|
491
491
|
const item = this.entries[name];
|
|
492
492
|
switch (item?.type) {
|
|
493
493
|
case "icon":
|
|
494
494
|
case "variation": {
|
|
495
|
-
for (const key in extraDefaultProps) {
|
|
496
|
-
const prop = key;
|
|
497
|
-
if (item.props[prop]) {
|
|
498
|
-
props[prop] = item.props[prop];
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
495
|
return this.setItem(name, {
|
|
502
496
|
type: "icon",
|
|
503
497
|
body,
|
|
@@ -525,7 +519,7 @@ class IconSet {
|
|
|
525
519
|
}
|
|
526
520
|
toggleCategory(iconName, category, add) {
|
|
527
521
|
const item = this.entries[iconName];
|
|
528
|
-
const categoryItem = this.
|
|
522
|
+
const categoryItem = this.findCategory(category, add);
|
|
529
523
|
if (!item || !categoryItem) {
|
|
530
524
|
return false;
|
|
531
525
|
}
|
package/lib/icon-set/match.cjs
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const defaults = require('@iconify/utils/lib/icon/defaults');
|
|
6
6
|
|
|
7
7
|
const maxIteration = 5;
|
|
8
|
-
function findMatchingIcon(iconSet, icon
|
|
9
|
-
const body = icon
|
|
8
|
+
function findMatchingIcon(iconSet, icon) {
|
|
9
|
+
const body = icon.body;
|
|
10
10
|
let hiddenMatch = null;
|
|
11
11
|
function isMatching(data) {
|
|
12
|
-
for (const key in
|
|
12
|
+
for (const key in defaults.defaultIconProps) {
|
|
13
13
|
const attr = key;
|
|
14
|
-
if (data[attr] !== icon
|
|
14
|
+
if (data[attr] !== icon[attr]) {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
17
|
}
|
package/lib/icon-set/match.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { FullIconifyIcon } from '@iconify/utils/lib/icon';
|
|
1
|
+
import { FullIconifyIcon } from '@iconify/utils/lib/icon/defaults';
|
|
2
2
|
import { IconSet } from './index.js';
|
|
3
|
-
import '
|
|
4
|
-
import '@iconify/utils/lib/customisations';
|
|
3
|
+
import '../types-f0980297.js';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
5
|
import './types.js';
|
|
6
6
|
import '../svg/index.js';
|
|
7
|
+
import '@iconify/utils/lib/customisations';
|
|
8
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Find matching icon in icon set
|
package/lib/icon-set/match.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
|
2
2
|
|
|
3
3
|
const maxIteration = 5;
|
|
4
4
|
function findMatchingIcon(iconSet, icon) {
|
|
5
5
|
const body = icon.body;
|
|
6
6
|
let hiddenMatch = null;
|
|
7
7
|
function isMatching(data) {
|
|
8
|
-
for (const key in
|
|
8
|
+
for (const key in defaultIconProps) {
|
|
9
9
|
const attr = key;
|
|
10
10
|
if (data[attr] !== icon[attr]) {
|
|
11
11
|
return false;
|
package/lib/icon-set/merge.cjs
CHANGED
|
@@ -4,15 +4,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const iconSet_index = require('./index.cjs');
|
|
6
6
|
const iconSet_match = require('./match.cjs');
|
|
7
|
-
require('
|
|
7
|
+
const iconSet_modified = require('./modified.cjs');
|
|
8
|
+
require('@iconify/utils/lib/icon/defaults');
|
|
8
9
|
require('@iconify/utils/lib/svg/build');
|
|
9
|
-
require('@iconify/utils/lib/customisations');
|
|
10
|
+
require('@iconify/utils/lib/customisations/defaults');
|
|
10
11
|
require('@iconify/utils/lib/icon-set/minify');
|
|
11
12
|
require('@iconify/utils/lib/icon-set/convert-info');
|
|
12
13
|
require('./props.cjs');
|
|
14
|
+
require('@iconify/utils/lib/misc/objects');
|
|
15
|
+
require('@iconify/utils');
|
|
13
16
|
require('../svg/index.cjs');
|
|
14
17
|
require('cheerio');
|
|
15
|
-
require('@iconify/utils');
|
|
16
18
|
|
|
17
19
|
function mergeIconSets(oldIcons, newIcons) {
|
|
18
20
|
const mergedIcons = new iconSet_index.IconSet(newIcons.export());
|
|
@@ -77,6 +79,11 @@ function mergeIconSets(oldIcons, newIcons) {
|
|
|
77
79
|
for (const name in oldEntries) {
|
|
78
80
|
add(name);
|
|
79
81
|
}
|
|
82
|
+
const lastModified1 = oldIcons.lastModified;
|
|
83
|
+
const lastModified2 = newIcons.lastModified;
|
|
84
|
+
if ((lastModified1 || lastModified2) && !iconSet_modified.hasIconDataBeenModified(oldIcons, newIcons)) {
|
|
85
|
+
mergedIcons.updateLastModified(lastModified2 ? lastModified1 ? Math.min(lastModified1, lastModified2) : lastModified2 : lastModified1);
|
|
86
|
+
}
|
|
80
87
|
return mergedIcons;
|
|
81
88
|
}
|
|
82
89
|
|
package/lib/icon-set/merge.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { IconSet } from './index.js';
|
|
2
|
-
import '
|
|
3
|
-
import '@iconify/utils/lib/customisations';
|
|
2
|
+
import '../types-f0980297.js';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
4
|
import './types.js';
|
|
5
5
|
import '../svg/index.js';
|
|
6
|
+
import '@iconify/utils/lib/customisations';
|
|
7
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Merge icon sets
|
package/lib/icon-set/merge.mjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { IconSet } from './index.mjs';
|
|
2
2
|
import { findMatchingIcon } from './match.mjs';
|
|
3
|
-
import '
|
|
3
|
+
import { hasIconDataBeenModified } from './modified.mjs';
|
|
4
|
+
import '@iconify/utils/lib/icon/defaults';
|
|
4
5
|
import '@iconify/utils/lib/svg/build';
|
|
5
|
-
import '@iconify/utils/lib/customisations';
|
|
6
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
6
7
|
import '@iconify/utils/lib/icon-set/minify';
|
|
7
8
|
import '@iconify/utils/lib/icon-set/convert-info';
|
|
8
9
|
import './props.mjs';
|
|
10
|
+
import '@iconify/utils/lib/misc/objects';
|
|
11
|
+
import '@iconify/utils';
|
|
9
12
|
import '../svg/index.mjs';
|
|
10
13
|
import 'cheerio';
|
|
11
|
-
import '@iconify/utils';
|
|
12
14
|
|
|
13
15
|
function mergeIconSets(oldIcons, newIcons) {
|
|
14
16
|
const mergedIcons = new IconSet(newIcons.export());
|
|
@@ -73,6 +75,11 @@ function mergeIconSets(oldIcons, newIcons) {
|
|
|
73
75
|
for (const name in oldEntries) {
|
|
74
76
|
add(name);
|
|
75
77
|
}
|
|
78
|
+
const lastModified1 = oldIcons.lastModified;
|
|
79
|
+
const lastModified2 = newIcons.lastModified;
|
|
80
|
+
if ((lastModified1 || lastModified2) && !hasIconDataBeenModified(oldIcons, newIcons)) {
|
|
81
|
+
mergedIcons.updateLastModified(lastModified2 ? lastModified1 ? Math.min(lastModified1, lastModified2) : lastModified2 : lastModified1);
|
|
82
|
+
}
|
|
76
83
|
return mergedIcons;
|
|
77
84
|
}
|
|
78
85
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function hasIconDataBeenModified(set1, set2) {
|
|
6
|
+
const entries1 = set1.entries;
|
|
7
|
+
const entries2 = set2.entries;
|
|
8
|
+
const keys1 = Object.keys(entries1);
|
|
9
|
+
const keys2 = Object.keys(entries2);
|
|
10
|
+
if (keys1.length !== keys2.length) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
for (let i = 0; i < keys1.length; i++) {
|
|
14
|
+
if (!entries2[keys1[i]]) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
for (let i = 0; i < keys1.length; i++) {
|
|
19
|
+
const name = keys1[i];
|
|
20
|
+
if (set1.toString(name) !== set2.toString(name)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.hasIconDataBeenModified = hasIconDataBeenModified;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IconSet } from './index.js';
|
|
2
|
+
import '../types-f0980297.js';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
|
+
import './types.js';
|
|
5
|
+
import '../svg/index.js';
|
|
6
|
+
import '@iconify/utils/lib/customisations';
|
|
7
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Check if icons in an icon set were updated.
|
|
11
|
+
*
|
|
12
|
+
* This function checks only icons, not metadata. It also ignores icon visibility.
|
|
13
|
+
*/
|
|
14
|
+
declare function hasIconDataBeenModified(set1: IconSet, set2: IconSet): boolean;
|
|
15
|
+
|
|
16
|
+
export { hasIconDataBeenModified };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function hasIconDataBeenModified(set1, set2) {
|
|
2
|
+
const entries1 = set1.entries;
|
|
3
|
+
const entries2 = set2.entries;
|
|
4
|
+
const keys1 = Object.keys(entries1);
|
|
5
|
+
const keys2 = Object.keys(entries2);
|
|
6
|
+
if (keys1.length !== keys2.length) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
for (let i = 0; i < keys1.length; i++) {
|
|
10
|
+
if (!entries2[keys1[i]]) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
for (let i = 0; i < keys1.length; i++) {
|
|
15
|
+
const name = keys1[i];
|
|
16
|
+
if (set1.toString(name) !== set2.toString(name)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { hasIconDataBeenModified };
|
package/lib/icon-set/props.cjs
CHANGED
|
@@ -2,27 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const objects = require('@iconify/utils/lib/misc/objects');
|
|
6
|
+
const utils = require('@iconify/utils');
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
+
const defaultCommonProps = Object.freeze({
|
|
9
|
+
...utils.defaultIconProps,
|
|
8
10
|
hidden: false
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
const props = Object.keys(defaultCommonProps);
|
|
15
|
-
function filterProps(data, compareDefaultValues) {
|
|
16
|
-
const result = {};
|
|
17
|
-
props.forEach((attr) => {
|
|
18
|
-
const value = data[attr];
|
|
19
|
-
if (value !== void 0 && (!compareDefaultValues || value !== defaultCommonProps[attr])) {
|
|
20
|
-
result[attr] = value;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
return result;
|
|
11
|
+
});
|
|
12
|
+
function filterProps(data, reference, compareDefaultValues) {
|
|
13
|
+
const result = objects.commonObjectProps(data, reference);
|
|
14
|
+
return compareDefaultValues ? objects.unmergeObjects(result, reference) : result;
|
|
24
15
|
}
|
|
25
16
|
|
|
26
17
|
exports.defaultCommonProps = defaultCommonProps;
|
|
27
|
-
exports.extraDefaultProps = extraDefaultProps;
|
|
28
18
|
exports.filterProps = filterProps;
|
package/lib/icon-set/props.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '
|
|
1
|
+
import { CommonIconProps } from './types.js';
|
|
2
|
+
import '../types-f0980297.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Common properties for icon and alias
|
|
6
6
|
*/
|
|
7
|
-
declare const extraDefaultProps: Required<ExtraIconProps>;
|
|
8
7
|
declare const defaultCommonProps: Required<CommonIconProps>;
|
|
9
8
|
/**
|
|
10
9
|
* Filter icon props: copies properties, removing undefined and default entries
|
|
11
10
|
*/
|
|
12
|
-
declare function filterProps(data: CommonIconProps, compareDefaultValues: boolean): CommonIconProps;
|
|
11
|
+
declare function filterProps(data: CommonIconProps, reference: CommonIconProps, compareDefaultValues: boolean): CommonIconProps;
|
|
13
12
|
|
|
14
|
-
export { defaultCommonProps,
|
|
13
|
+
export { defaultCommonProps, filterProps };
|
package/lib/icon-set/props.mjs
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { commonObjectProps, unmergeObjects } from '@iconify/utils/lib/misc/objects';
|
|
2
|
+
import { defaultIconProps } from '@iconify/utils';
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
+
const defaultCommonProps = Object.freeze({
|
|
5
|
+
...defaultIconProps,
|
|
4
6
|
hidden: false
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
const props = Object.keys(defaultCommonProps);
|
|
11
|
-
function filterProps(data, compareDefaultValues) {
|
|
12
|
-
const result = {};
|
|
13
|
-
props.forEach((attr) => {
|
|
14
|
-
const value = data[attr];
|
|
15
|
-
if (value !== void 0 && (!compareDefaultValues || value !== defaultCommonProps[attr])) {
|
|
16
|
-
result[attr] = value;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return result;
|
|
7
|
+
});
|
|
8
|
+
function filterProps(data, reference, compareDefaultValues) {
|
|
9
|
+
const result = commonObjectProps(data, reference);
|
|
10
|
+
return compareDefaultValues ? unmergeObjects(result, reference) : result;
|
|
20
11
|
}
|
|
21
12
|
|
|
22
|
-
export { defaultCommonProps,
|
|
13
|
+
export { defaultCommonProps, filterProps };
|
package/lib/icon-set/types.d.ts
CHANGED
package/lib/import/directory.cjs
CHANGED
|
@@ -8,14 +8,15 @@ const misc_keyword = require('../misc/keyword.cjs');
|
|
|
8
8
|
const misc_scan = require('../misc/scan.cjs');
|
|
9
9
|
const svg_index = require('../svg/index.cjs');
|
|
10
10
|
const svg_cleanup = require('../svg/cleanup.cjs');
|
|
11
|
-
require('@iconify/utils/lib/icon');
|
|
11
|
+
require('@iconify/utils/lib/icon/defaults');
|
|
12
12
|
require('@iconify/utils/lib/svg/build');
|
|
13
|
-
require('@iconify/utils/lib/customisations');
|
|
13
|
+
require('@iconify/utils/lib/customisations/defaults');
|
|
14
14
|
require('@iconify/utils/lib/icon-set/minify');
|
|
15
15
|
require('@iconify/utils/lib/icon-set/convert-info');
|
|
16
16
|
require('../icon-set/props.cjs');
|
|
17
|
-
require('
|
|
17
|
+
require('@iconify/utils/lib/misc/objects');
|
|
18
18
|
require('@iconify/utils');
|
|
19
|
+
require('cheerio');
|
|
19
20
|
require('../svg/cleanup/attribs.cjs');
|
|
20
21
|
require('../svg/data/attributes.cjs');
|
|
21
22
|
require('../svg/data/tags.cjs');
|