@iconify/tools 4.0.0-beta.5 → 4.0.0-beta.8
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/detect.cjs +1 -1
- package/lib/colors/detect.mjs +1 -1
- package/lib/colors/parse.cjs +2 -2
- package/lib/colors/parse.mjs +2 -2
- package/lib/download/git/index.cjs +1 -1
- package/lib/download/git/index.mjs +1 -1
- package/lib/icon-set/index.cjs +3 -4
- package/lib/icon-set/index.mjs +3 -4
- package/lib/import/figma/nodes.cjs +1 -1
- package/lib/import/figma/nodes.mjs +1 -1
- package/lib/misc/compare-dirs.cjs +3 -3
- package/lib/misc/compare-dirs.mjs +3 -3
- package/lib/optimise/flags.cjs +1 -1
- package/lib/optimise/flags.mjs +1 -1
- package/lib/optimise/global-style.cjs +1 -1
- package/lib/optimise/global-style.mjs +1 -1
- package/lib/optimise/svgo.cjs +2 -2
- package/lib/optimise/svgo.mjs +2 -2
- package/lib/svg/analyse.cjs +1 -1
- package/lib/svg/analyse.mjs +1 -1
- package/lib/svg/cleanup/svgo-style.cjs +1 -1
- package/lib/svg/cleanup/svgo-style.mjs +1 -1
- package/lib/svg/index.cjs +1 -1
- package/lib/svg/index.mjs +1 -1
- package/package.json +2 -2
package/lib/colors/detect.cjs
CHANGED
package/lib/colors/detect.mjs
CHANGED
package/lib/colors/parse.cjs
CHANGED
|
@@ -128,7 +128,7 @@ function parseColors(svg, options = {}) {
|
|
|
128
128
|
svg_parseStyle.parseSVGStyle(svg, (item) => {
|
|
129
129
|
const prop = item.prop;
|
|
130
130
|
const value = item.value;
|
|
131
|
-
if (propsToCheck.
|
|
131
|
+
if (!propsToCheck.includes(prop)) {
|
|
132
132
|
return value;
|
|
133
133
|
}
|
|
134
134
|
const attr = prop;
|
|
@@ -213,7 +213,7 @@ function parseColors(svg, options = {}) {
|
|
|
213
213
|
}
|
|
214
214
|
if (svg_data_tags.animateTags.has(tagName)) {
|
|
215
215
|
const attr = attribs.attributeName;
|
|
216
|
-
if (propsToCheck.
|
|
216
|
+
if (propsToCheck.includes(attr)) {
|
|
217
217
|
for (let i = 0; i < animatePropsToCheck.length; i++) {
|
|
218
218
|
const elementProp = animatePropsToCheck[i];
|
|
219
219
|
const fullValue = attribs[elementProp];
|
package/lib/colors/parse.mjs
CHANGED
|
@@ -126,7 +126,7 @@ function parseColors(svg, options = {}) {
|
|
|
126
126
|
parseSVGStyle(svg, (item) => {
|
|
127
127
|
const prop = item.prop;
|
|
128
128
|
const value = item.value;
|
|
129
|
-
if (propsToCheck.
|
|
129
|
+
if (!propsToCheck.includes(prop)) {
|
|
130
130
|
return value;
|
|
131
131
|
}
|
|
132
132
|
const attr = prop;
|
|
@@ -211,7 +211,7 @@ function parseColors(svg, options = {}) {
|
|
|
211
211
|
}
|
|
212
212
|
if (animateTags.has(tagName)) {
|
|
213
213
|
const attr = attribs.attributeName;
|
|
214
|
-
if (propsToCheck.
|
|
214
|
+
if (propsToCheck.includes(attr)) {
|
|
215
215
|
for (let i = 0; i < animatePropsToCheck.length; i++) {
|
|
216
216
|
const elementProp = animatePropsToCheck[i];
|
|
217
217
|
const fullValue = attribs[elementProp];
|
|
@@ -31,7 +31,7 @@ require('tar');
|
|
|
31
31
|
|
|
32
32
|
async function downloadGitRepo(options) {
|
|
33
33
|
const { remote, branch } = options;
|
|
34
|
-
const hasHashInTarget = options.target.
|
|
34
|
+
const hasHashInTarget = options.target.includes("{hash}");
|
|
35
35
|
const ifModifiedSince = options.ifModifiedSince;
|
|
36
36
|
if (ifModifiedSince || hasHashInTarget) {
|
|
37
37
|
const result = await misc_exec.execAsync(
|
|
@@ -29,7 +29,7 @@ import 'tar';
|
|
|
29
29
|
|
|
30
30
|
async function downloadGitRepo(options) {
|
|
31
31
|
const { remote, branch } = options;
|
|
32
|
-
const hasHashInTarget = options.target.
|
|
32
|
+
const hasHashInTarget = options.target.includes("{hash}");
|
|
33
33
|
const ifModifiedSince = options.ifModifiedSince;
|
|
34
34
|
if (ifModifiedSince || hasHashInTarget) {
|
|
35
35
|
const result = await execAsync(
|
package/lib/icon-set/index.cjs
CHANGED
|
@@ -145,10 +145,9 @@ class IconSet {
|
|
|
145
145
|
* List icons
|
|
146
146
|
*/
|
|
147
147
|
list(types = ["icon", "variation"]) {
|
|
148
|
-
return Object.keys(this.entries).filter(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
148
|
+
return Object.keys(this.entries).filter(
|
|
149
|
+
(name) => types.includes(this.entries[name].type)
|
|
150
|
+
);
|
|
152
151
|
}
|
|
153
152
|
/**
|
|
154
153
|
* forEach function to loop through all entries.
|
package/lib/icon-set/index.mjs
CHANGED
|
@@ -143,10 +143,9 @@ class IconSet {
|
|
|
143
143
|
* List icons
|
|
144
144
|
*/
|
|
145
145
|
list(types = ["icon", "variation"]) {
|
|
146
|
-
return Object.keys(this.entries).filter(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
});
|
|
146
|
+
return Object.keys(this.entries).filter(
|
|
147
|
+
(name) => types.includes(this.entries[name].type)
|
|
148
|
+
);
|
|
150
149
|
}
|
|
151
150
|
/**
|
|
152
151
|
* forEach function to loop through all entries.
|
|
@@ -64,7 +64,7 @@ function getFigmaIconNodes(document, options) {
|
|
|
64
64
|
const newParents = parents.concat([parentItem]);
|
|
65
65
|
if (!parents.length && options.pages) {
|
|
66
66
|
const allowedPages = options.pages;
|
|
67
|
-
if (allowedPages.
|
|
67
|
+
if (!allowedPages.includes(node.id) && !allowedPages.includes(node.name.trim())) {
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
70
|
} else {
|
|
@@ -62,7 +62,7 @@ function getFigmaIconNodes(document, options) {
|
|
|
62
62
|
const newParents = parents.concat([parentItem]);
|
|
63
63
|
if (!parents.length && options.pages) {
|
|
64
64
|
const allowedPages = options.pages;
|
|
65
|
-
if (allowedPages.
|
|
65
|
+
if (!allowedPages.includes(node.id) && !allowedPages.includes(node.name.trim())) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
} else {
|
|
@@ -35,7 +35,7 @@ async function compareDirectories(dir1, dir2, options) {
|
|
|
35
35
|
);
|
|
36
36
|
for (let i = 0; i < files1.length; i++) {
|
|
37
37
|
const file = files1[i];
|
|
38
|
-
if (files2.
|
|
38
|
+
if (!files2.includes(file)) {
|
|
39
39
|
return false;
|
|
40
40
|
}
|
|
41
41
|
const ext = file.split(".").pop().toLowerCase();
|
|
@@ -54,8 +54,8 @@ async function compareDirectories(dir1, dir2, options) {
|
|
|
54
54
|
continue;
|
|
55
55
|
}
|
|
56
56
|
if (ignoreNewLine) {
|
|
57
|
-
content1 = content1.replace(/\s+\n/g, "\n").
|
|
58
|
-
content2 = content2.replace(/\s+\n/g, "\n").
|
|
57
|
+
content1 = content1.replace(/\s+\n/g, "\n").trimEnd();
|
|
58
|
+
content2 = content2.replace(/\s+\n/g, "\n").trimEnd();
|
|
59
59
|
}
|
|
60
60
|
if (ignoreVersions && file.split("/").pop() === "package.json") {
|
|
61
61
|
const data1 = JSON.parse(content1);
|
|
@@ -33,7 +33,7 @@ async function compareDirectories(dir1, dir2, options) {
|
|
|
33
33
|
);
|
|
34
34
|
for (let i = 0; i < files1.length; i++) {
|
|
35
35
|
const file = files1[i];
|
|
36
|
-
if (files2.
|
|
36
|
+
if (!files2.includes(file)) {
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
39
|
const ext = file.split(".").pop().toLowerCase();
|
|
@@ -52,8 +52,8 @@ async function compareDirectories(dir1, dir2, options) {
|
|
|
52
52
|
continue;
|
|
53
53
|
}
|
|
54
54
|
if (ignoreNewLine) {
|
|
55
|
-
content1 = content1.replace(/\s+\n/g, "\n").
|
|
56
|
-
content2 = content2.replace(/\s+\n/g, "\n").
|
|
55
|
+
content1 = content1.replace(/\s+\n/g, "\n").trimEnd();
|
|
56
|
+
content2 = content2.replace(/\s+\n/g, "\n").trimEnd();
|
|
57
57
|
}
|
|
58
58
|
if (ignoreVersions && file.split("/").pop() === "package.json") {
|
|
59
59
|
const data1 = JSON.parse(content1);
|
package/lib/optimise/flags.cjs
CHANGED
package/lib/optimise/flags.mjs
CHANGED
|
@@ -93,7 +93,7 @@ function cleanupGlobalStyle(svg) {
|
|
|
93
93
|
break;
|
|
94
94
|
case "class": {
|
|
95
95
|
const className = $element.attr("class");
|
|
96
|
-
if (className && getClassList(className).
|
|
96
|
+
if (className && getClassList(className).includes(value)) {
|
|
97
97
|
return true;
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -91,7 +91,7 @@ function cleanupGlobalStyle(svg) {
|
|
|
91
91
|
break;
|
|
92
92
|
case "class": {
|
|
93
93
|
const className = $element.attr("class");
|
|
94
|
-
if (className && getClassList(className).
|
|
94
|
+
if (className && getClassList(className).includes(value)) {
|
|
95
95
|
return true;
|
|
96
96
|
}
|
|
97
97
|
}
|
package/lib/optimise/svgo.cjs
CHANGED
|
@@ -30,7 +30,7 @@ function getSVGOPlugins(options) {
|
|
|
30
30
|
...options.animated ? [] : ["removeUselessStrokeAndFill"],
|
|
31
31
|
// Plugins that modify shapes or are bugged when using animations
|
|
32
32
|
...options.animated || options.keepShapes ? [] : [
|
|
33
|
-
|
|
33
|
+
"removeHiddenElems",
|
|
34
34
|
"convertShapeToPath",
|
|
35
35
|
"convertEllipseToCircle",
|
|
36
36
|
{
|
|
@@ -60,7 +60,7 @@ function runSVGO(svg, options = {}) {
|
|
|
60
60
|
if (options.plugins) {
|
|
61
61
|
plugins = options.plugins;
|
|
62
62
|
} else {
|
|
63
|
-
const animated = code.
|
|
63
|
+
const animated = code.includes("<animate") || code.includes("<set");
|
|
64
64
|
plugins = getSVGOPlugins({
|
|
65
65
|
...options,
|
|
66
66
|
animated
|
package/lib/optimise/svgo.mjs
CHANGED
|
@@ -28,7 +28,7 @@ function getSVGOPlugins(options) {
|
|
|
28
28
|
...options.animated ? [] : ["removeUselessStrokeAndFill"],
|
|
29
29
|
// Plugins that modify shapes or are bugged when using animations
|
|
30
30
|
...options.animated || options.keepShapes ? [] : [
|
|
31
|
-
|
|
31
|
+
"removeHiddenElems",
|
|
32
32
|
"convertShapeToPath",
|
|
33
33
|
"convertEllipseToCircle",
|
|
34
34
|
{
|
|
@@ -58,7 +58,7 @@ function runSVGO(svg, options = {}) {
|
|
|
58
58
|
if (options.plugins) {
|
|
59
59
|
plugins = options.plugins;
|
|
60
60
|
} else {
|
|
61
|
-
const animated = code.
|
|
61
|
+
const animated = code.includes("<animate") || code.includes("<set");
|
|
62
62
|
plugins = getSVGOPlugins({
|
|
63
63
|
...options,
|
|
64
64
|
animated
|
package/lib/svg/analyse.cjs
CHANGED
|
@@ -263,7 +263,7 @@ function analyseSVGStructure(svg, options = {}) {
|
|
|
263
263
|
usedItems = usedItems.slice(0);
|
|
264
264
|
usedItems.push(element._index);
|
|
265
265
|
element._childElements?.forEach((childIndex) => {
|
|
266
|
-
if (usedItems.
|
|
266
|
+
if (usedItems.includes(childIndex)) {
|
|
267
267
|
throw new Error("Recursion");
|
|
268
268
|
}
|
|
269
269
|
const childItem = {
|
package/lib/svg/analyse.mjs
CHANGED
|
@@ -261,7 +261,7 @@ function analyseSVGStructure(svg, options = {}) {
|
|
|
261
261
|
usedItems = usedItems.slice(0);
|
|
262
262
|
usedItems.push(element._index);
|
|
263
263
|
element._childElements?.forEach((childIndex) => {
|
|
264
|
-
if (usedItems.
|
|
264
|
+
if (usedItems.includes(childIndex)) {
|
|
265
265
|
throw new Error("Recursion");
|
|
266
266
|
}
|
|
267
267
|
const childItem = {
|
|
@@ -26,7 +26,7 @@ function convertStyleToAttrs(svg) {
|
|
|
26
26
|
// Attributes / properties now allowed
|
|
27
27
|
svg_data_attributes.badAttributes.has(prop) || svg_data_attributes.badSoftwareAttributes.has(prop) || svg_data_attributes.badAttributePrefixes.has(prop.split("-").shift())
|
|
28
28
|
) {
|
|
29
|
-
return
|
|
29
|
+
return;
|
|
30
30
|
}
|
|
31
31
|
hasStyle = true;
|
|
32
32
|
return item.value;
|
|
@@ -24,7 +24,7 @@ function convertStyleToAttrs(svg) {
|
|
|
24
24
|
// Attributes / properties now allowed
|
|
25
25
|
badAttributes.has(prop) || badSoftwareAttributes.has(prop) || badAttributePrefixes.has(prop.split("-").shift())
|
|
26
26
|
) {
|
|
27
|
-
return
|
|
27
|
+
return;
|
|
28
28
|
}
|
|
29
29
|
hasStyle = true;
|
|
30
30
|
return item.value;
|
package/lib/svg/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ class SVG {
|
|
|
31
31
|
if (customisations) {
|
|
32
32
|
const data = utils.iconToSVG(this.getIcon(), customisations);
|
|
33
33
|
let svgAttributes = ' xmlns="http://www.w3.org/2000/svg"';
|
|
34
|
-
if (data.body.
|
|
34
|
+
if (data.body.includes("xlink:")) {
|
|
35
35
|
svgAttributes += ' xmlns:xlink="http://www.w3.org/1999/xlink"';
|
|
36
36
|
}
|
|
37
37
|
for (const key in data.attributes) {
|
package/lib/svg/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ class SVG {
|
|
|
15
15
|
if (customisations) {
|
|
16
16
|
const data = iconToSVG(this.getIcon(), customisations);
|
|
17
17
|
let svgAttributes = ' xmlns="http://www.w3.org/2000/svg"';
|
|
18
|
-
if (data.body.
|
|
18
|
+
if (data.body.includes("xlink:")) {
|
|
19
19
|
svgAttributes += ' xmlns:xlink="http://www.w3.org/1999/xlink"';
|
|
20
20
|
}
|
|
21
21
|
for (const key in data.attributes) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Collection of functions for cleaning up and parsing SVG for Iconify project",
|
|
5
5
|
"author": "Vjacheslav Trushkin",
|
|
6
|
-
"version": "4.0.0-beta.
|
|
6
|
+
"version": "4.0.0-beta.8",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"tag": "next"
|
|
9
9
|
},
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"extract-zip": "^2.0.1",
|
|
27
27
|
"local-pkg": "^0.4.3",
|
|
28
28
|
"pathe": "^1.1.1",
|
|
29
|
-
"svgo": "
|
|
29
|
+
"svgo": "3.0.5",
|
|
30
30
|
"tar": "^6.2.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|