@iconify/tools 2.0.10 → 2.0.11
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/icon-set/index.js +3 -21
- package/lib/icon-set/index.mjs +5 -21
- package/lib/icon-set/merge.js +0 -1
- package/lib/icon-set/merge.mjs +1 -2
- package/lib/icon-set/types.d.ts +3 -1
- package/lib/optimise/flags.js +9 -0
- package/lib/optimise/flags.mjs +8 -0
- package/package.json +2 -2
package/lib/icon-set/index.js
CHANGED
|
@@ -71,7 +71,6 @@ class IconSet {
|
|
|
71
71
|
parent,
|
|
72
72
|
props,
|
|
73
73
|
chars,
|
|
74
|
-
categories: new Set(),
|
|
75
74
|
};
|
|
76
75
|
entries[name] = entry;
|
|
77
76
|
}
|
|
@@ -111,7 +110,6 @@ class IconSet {
|
|
|
111
110
|
const icon = entries[iconName];
|
|
112
111
|
switch (icon === null || icon === void 0 ? void 0 : icon.type) {
|
|
113
112
|
case 'icon':
|
|
114
|
-
case 'variation':
|
|
115
113
|
icon.categories.add(item);
|
|
116
114
|
}
|
|
117
115
|
});
|
|
@@ -461,8 +459,8 @@ class IconSet {
|
|
|
461
459
|
return null;
|
|
462
460
|
}
|
|
463
461
|
// Find icons
|
|
464
|
-
const icons = this._filter((_key, item
|
|
465
|
-
if (item.type
|
|
462
|
+
const icons = this._filter((_key, item) => {
|
|
463
|
+
if (item.type !== 'icon' || item.props.hidden) {
|
|
466
464
|
return false;
|
|
467
465
|
}
|
|
468
466
|
return item.categories.has(categoryItem);
|
|
@@ -620,26 +618,11 @@ class IconSet {
|
|
|
620
618
|
* Add/update alias with props
|
|
621
619
|
*/
|
|
622
620
|
setVariation(name, parent, props) {
|
|
623
|
-
// Copy categories
|
|
624
|
-
let categories;
|
|
625
|
-
while (!categories) {
|
|
626
|
-
const parentItem = this.entries[parent];
|
|
627
|
-
if (!parentItem) {
|
|
628
|
-
return false;
|
|
629
|
-
}
|
|
630
|
-
if (parentItem.type === 'alias') {
|
|
631
|
-
parent = parentItem.parent;
|
|
632
|
-
}
|
|
633
|
-
else {
|
|
634
|
-
categories = new Set(parentItem.categories);
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
621
|
return this.setItem(name, {
|
|
638
622
|
type: 'variation',
|
|
639
623
|
parent,
|
|
640
624
|
props,
|
|
641
625
|
chars: new Set(),
|
|
642
|
-
categories,
|
|
643
626
|
});
|
|
644
627
|
}
|
|
645
628
|
/**
|
|
@@ -665,7 +648,7 @@ class IconSet {
|
|
|
665
648
|
body,
|
|
666
649
|
props,
|
|
667
650
|
chars: item.chars,
|
|
668
|
-
categories: item.categories,
|
|
651
|
+
categories: item.type === 'icon' ? item.categories : new Set(),
|
|
669
652
|
});
|
|
670
653
|
}
|
|
671
654
|
}
|
|
@@ -700,7 +683,6 @@ class IconSet {
|
|
|
700
683
|
}
|
|
701
684
|
switch (item.type) {
|
|
702
685
|
case 'icon':
|
|
703
|
-
case 'variation':
|
|
704
686
|
if (item.categories.has(categoryItem) !== add) {
|
|
705
687
|
categoryItem.count += add ? 1 : -1;
|
|
706
688
|
item.categories[add ? 'add' : 'delete'](categoryItem);
|
package/lib/icon-set/index.mjs
CHANGED
|
@@ -46,8 +46,7 @@ var IconSet = class {
|
|
|
46
46
|
type: "variation",
|
|
47
47
|
parent,
|
|
48
48
|
props,
|
|
49
|
-
chars
|
|
50
|
-
categories: new Set()
|
|
49
|
+
chars
|
|
51
50
|
};
|
|
52
51
|
entries[name] = entry;
|
|
53
52
|
} else {
|
|
@@ -82,7 +81,6 @@ var IconSet = class {
|
|
|
82
81
|
const icon = entries[iconName];
|
|
83
82
|
switch (icon == null ? void 0 : icon.type) {
|
|
84
83
|
case "icon":
|
|
85
|
-
case "variation":
|
|
86
84
|
icon.categories.add(item);
|
|
87
85
|
}
|
|
88
86
|
});
|
|
@@ -363,8 +361,8 @@ var IconSet = class {
|
|
|
363
361
|
if (!categoryItem) {
|
|
364
362
|
return null;
|
|
365
363
|
}
|
|
366
|
-
const icons = this._filter((_key, item
|
|
367
|
-
if (item.type
|
|
364
|
+
const icons = this._filter((_key, item) => {
|
|
365
|
+
if (item.type !== "icon" || item.props.hidden) {
|
|
368
366
|
return false;
|
|
369
367
|
}
|
|
370
368
|
return item.categories.has(categoryItem);
|
|
@@ -488,24 +486,11 @@ var IconSet = class {
|
|
|
488
486
|
});
|
|
489
487
|
}
|
|
490
488
|
setVariation(name, parent, props) {
|
|
491
|
-
let categories;
|
|
492
|
-
while (!categories) {
|
|
493
|
-
const parentItem = this.entries[parent];
|
|
494
|
-
if (!parentItem) {
|
|
495
|
-
return false;
|
|
496
|
-
}
|
|
497
|
-
if (parentItem.type === "alias") {
|
|
498
|
-
parent = parentItem.parent;
|
|
499
|
-
} else {
|
|
500
|
-
categories = new Set(parentItem.categories);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
489
|
return this.setItem(name, {
|
|
504
490
|
type: "variation",
|
|
505
491
|
parent,
|
|
506
492
|
props,
|
|
507
|
-
chars: new Set()
|
|
508
|
-
categories
|
|
493
|
+
chars: new Set()
|
|
509
494
|
});
|
|
510
495
|
}
|
|
511
496
|
fromSVG(name, svg) {
|
|
@@ -526,7 +511,7 @@ var IconSet = class {
|
|
|
526
511
|
body,
|
|
527
512
|
props,
|
|
528
513
|
chars: item.chars,
|
|
529
|
-
categories: item.categories
|
|
514
|
+
categories: item.type === "icon" ? item.categories : new Set()
|
|
530
515
|
});
|
|
531
516
|
}
|
|
532
517
|
}
|
|
@@ -554,7 +539,6 @@ var IconSet = class {
|
|
|
554
539
|
}
|
|
555
540
|
switch (item.type) {
|
|
556
541
|
case "icon":
|
|
557
|
-
case "variation":
|
|
558
542
|
if (item.categories.has(categoryItem) !== add) {
|
|
559
543
|
categoryItem.count += add ? 1 : -1;
|
|
560
544
|
item.categories[add ? "add" : "delete"](categoryItem);
|
package/lib/icon-set/merge.js
CHANGED
package/lib/icon-set/merge.mjs
CHANGED
package/lib/icon-set/types.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export interface IconWithChars {
|
|
|
25
25
|
}
|
|
26
26
|
export interface IconWithPropsData extends IconWithChars {
|
|
27
27
|
props: CommonIconProps;
|
|
28
|
+
}
|
|
29
|
+
export interface IconWithCategories {
|
|
28
30
|
categories: Set<IconCategory>;
|
|
29
31
|
}
|
|
30
32
|
export interface IconParentData {
|
|
@@ -33,7 +35,7 @@ export interface IconParentData {
|
|
|
33
35
|
/**
|
|
34
36
|
* Icon types
|
|
35
37
|
*/
|
|
36
|
-
export interface IconSetIcon extends IconWithPropsData {
|
|
38
|
+
export interface IconSetIcon extends IconWithPropsData, IconWithCategories {
|
|
37
39
|
type: 'icon';
|
|
38
40
|
body: string;
|
|
39
41
|
}
|
package/lib/optimise/flags.js
CHANGED
|
@@ -64,6 +64,15 @@ function cleanPath(path) {
|
|
|
64
64
|
});
|
|
65
65
|
currentArgs = [];
|
|
66
66
|
canParseCommandOrComma = true;
|
|
67
|
+
// Change command for lines after moving
|
|
68
|
+
switch (currentCommand) {
|
|
69
|
+
case 'M':
|
|
70
|
+
currentCommand = 'L';
|
|
71
|
+
break;
|
|
72
|
+
case 'm':
|
|
73
|
+
currentCommand = 'l';
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
67
76
|
}
|
|
68
77
|
};
|
|
69
78
|
const parseNumber = () => {
|
package/lib/optimise/flags.mjs
CHANGED
|
@@ -44,6 +44,14 @@ function cleanPath(path) {
|
|
|
44
44
|
});
|
|
45
45
|
currentArgs = [];
|
|
46
46
|
canParseCommandOrComma = true;
|
|
47
|
+
switch (currentCommand) {
|
|
48
|
+
case "M":
|
|
49
|
+
currentCommand = "L";
|
|
50
|
+
break;
|
|
51
|
+
case "m":
|
|
52
|
+
currentCommand = "l";
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
47
55
|
}
|
|
48
56
|
};
|
|
49
57
|
const parseNumber = () => {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@iconify/tools",
|
|
3
3
|
"description": "Collection of functions for cleaning up and parsing SVG for Iconify project",
|
|
4
4
|
"author": "Vjacheslav Trushkin",
|
|
5
|
-
"version": "2.0.
|
|
5
|
+
"version": "2.0.11",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bugs": "https://github.com/iconify/tools/issues",
|
|
8
8
|
"homepage": "https://github.com/iconify/tools",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"test": "npm run test:jest && npm run test:jasmine"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@iconify/utils": "^1.0.
|
|
25
|
+
"@iconify/utils": "^1.0.23",
|
|
26
26
|
"@types/cheerio": "^0.22.30",
|
|
27
27
|
"@types/node-fetch": "^2.5.12",
|
|
28
28
|
"@types/svgo": "^2.6.0",
|