@iconify/tools 2.2.5 → 3.0.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/README.md +8 -2
- package/lib/colors/detect.cjs +4 -4
- package/lib/colors/detect.d.ts +1 -1
- package/lib/colors/detect.mjs +5 -5
- package/lib/colors/parse.cjs +275 -129
- package/lib/colors/parse.d.ts +14 -5
- package/lib/colors/parse.mjs +278 -133
- package/lib/colors/validate.cjs +11 -2
- package/lib/colors/validate.d.ts +10 -2
- package/lib/colors/validate.mjs +12 -4
- package/lib/download/api/download.cjs +4 -4
- package/lib/download/api/download.mjs +4 -4
- package/lib/download/api/index.cjs +0 -1
- package/lib/download/api/index.mjs +0 -1
- package/lib/download/git/index.cjs +1 -1
- package/lib/download/git/index.mjs +1 -1
- package/lib/download/git/reset.cjs +1 -1
- package/lib/download/git/reset.mjs +1 -1
- package/lib/download/github/hash.cjs +0 -1
- package/lib/download/github/hash.mjs +0 -1
- package/lib/download/github/index.cjs +1 -1
- package/lib/download/github/index.mjs +1 -1
- package/lib/download/gitlab/hash.cjs +0 -1
- package/lib/download/gitlab/hash.mjs +0 -1
- package/lib/download/gitlab/index.cjs +1 -1
- package/lib/download/gitlab/index.mjs +1 -1
- package/lib/download/helpers/unzip.cjs +5 -1
- package/lib/download/index.cjs +1 -1
- package/lib/download/index.mjs +1 -1
- package/lib/download/npm/index.cjs +1 -1
- package/lib/download/npm/index.mjs +1 -1
- package/lib/icon-set/index.cjs +18 -0
- package/lib/icon-set/index.d.ts +7 -1
- package/lib/icon-set/index.mjs +18 -0
- package/lib/icon-set/tags.cjs +2 -2
- package/lib/icon-set/tags.d.ts +1 -1
- package/lib/icon-set/tags.mjs +2 -2
- package/lib/icon-set/types.d.ts +5 -4
- package/lib/import/directory.cjs +101 -28
- package/lib/import/directory.d.ts +12 -5
- package/lib/import/directory.mjs +103 -31
- package/lib/import/figma/index.cjs +1 -2
- package/lib/import/figma/index.mjs +1 -2
- package/lib/import/figma/query.cjs +0 -1
- package/lib/import/figma/query.mjs +0 -1
- package/lib/index.cjs +9 -1
- package/lib/index.d.ts +7 -6
- package/lib/index.mjs +8 -7
- package/lib/misc/scan.cjs +61 -8
- package/lib/misc/scan.d.ts +12 -6
- package/lib/misc/scan.mjs +62 -10
- package/lib/optimise/origin.cjs +23 -0
- package/lib/optimise/origin.d.ts +10 -0
- package/lib/optimise/origin.mjs +21 -0
- package/lib/optimise/scale.cjs +17 -15
- package/lib/optimise/scale.mjs +17 -15
- package/lib/svg/analyse.cjs +2 -2
- package/lib/svg/analyse.d.ts +1 -1
- package/lib/svg/analyse.mjs +4 -4
- package/lib/svg/cleanup/attribs.cjs +2 -2
- package/lib/svg/cleanup/attribs.d.ts +1 -1
- package/lib/svg/cleanup/attribs.mjs +3 -3
- package/lib/svg/cleanup/bad-tags.cjs +2 -2
- package/lib/svg/cleanup/bad-tags.d.ts +1 -1
- package/lib/svg/cleanup/bad-tags.mjs +3 -3
- package/lib/svg/cleanup/inline-style.cjs +2 -2
- package/lib/svg/cleanup/inline-style.d.ts +1 -1
- package/lib/svg/cleanup/inline-style.mjs +3 -3
- package/lib/svg/cleanup/root-style.cjs +1 -1
- package/lib/svg/cleanup/root-style.d.ts +1 -5
- package/lib/svg/cleanup/root-style.mjs +2 -2
- package/lib/svg/cleanup/svgo-style.cjs +2 -2
- package/lib/svg/cleanup/svgo-style.d.ts +1 -1
- package/lib/svg/cleanup/svgo-style.mjs +3 -3
- package/lib/svg/cleanup.cjs +6 -6
- package/lib/svg/cleanup.d.ts +1 -1
- package/lib/svg/cleanup.mjs +6 -6
- package/lib/svg/index.cjs +5 -1
- package/lib/svg/parse-style.cjs +149 -89
- package/lib/svg/parse-style.d.ts +6 -1
- package/lib/svg/parse-style.mjs +150 -91
- package/lib/svg/parse.cjs +56 -18
- package/lib/svg/parse.d.ts +8 -2
- package/lib/svg/parse.mjs +56 -19
- package/package.json +23 -20
package/lib/svg/parse.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
function parse(svg, callback, done) {
|
|
2
|
+
function checkNode(element, parents, done2) {
|
|
3
3
|
if (element.type !== "tag") {
|
|
4
|
-
return;
|
|
4
|
+
return done2();
|
|
5
5
|
}
|
|
6
6
|
const $element = cheerio(element);
|
|
7
7
|
const tagName = element.tagName;
|
|
@@ -14,25 +14,62 @@ async function parseSVG(svg, callback) {
|
|
|
14
14
|
testChildren: true,
|
|
15
15
|
removeNode: false
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const children = $element.children().toArray();
|
|
25
|
-
for (let i = 0; i < children.length; i++) {
|
|
26
|
-
await checkNode(children[i], newParents);
|
|
17
|
+
callback(item, () => {
|
|
18
|
+
const newParents = parents.slice(0);
|
|
19
|
+
newParents.unshift(item);
|
|
20
|
+
let queue = [];
|
|
21
|
+
if (tagName !== "style" && item.testChildren && !item.removeNode) {
|
|
22
|
+
const children = $element.children().toArray();
|
|
23
|
+
queue = children.slice(0);
|
|
27
24
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
const next = () => {
|
|
26
|
+
const queueItem = queue.shift();
|
|
27
|
+
if (!queueItem) {
|
|
28
|
+
if (item.removeNode) {
|
|
29
|
+
$element.remove();
|
|
30
|
+
}
|
|
31
|
+
return done2();
|
|
32
|
+
}
|
|
33
|
+
checkNode(queueItem, newParents, next);
|
|
34
|
+
};
|
|
35
|
+
next();
|
|
36
|
+
});
|
|
32
37
|
}
|
|
33
38
|
const cheerio = svg.$svg;
|
|
34
39
|
const $root = svg.$svg(":root");
|
|
35
|
-
|
|
40
|
+
checkNode($root.get(0), [], done);
|
|
41
|
+
}
|
|
42
|
+
function parseSVG(svg, callback) {
|
|
43
|
+
return new Promise((fulfill, reject) => {
|
|
44
|
+
parse(
|
|
45
|
+
svg,
|
|
46
|
+
(item, next) => {
|
|
47
|
+
const result = callback(item);
|
|
48
|
+
if (result instanceof Promise) {
|
|
49
|
+
result.then(next).catch(reject);
|
|
50
|
+
} else {
|
|
51
|
+
next();
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
fulfill
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function parseSVGSync(svg, callback) {
|
|
59
|
+
let isSync = true;
|
|
60
|
+
parse(
|
|
61
|
+
svg,
|
|
62
|
+
(item, next) => {
|
|
63
|
+
callback(item);
|
|
64
|
+
next();
|
|
65
|
+
},
|
|
66
|
+
() => {
|
|
67
|
+
if (!isSync) {
|
|
68
|
+
throw new Error("parseSVGSync callback was async");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
isSync = false;
|
|
36
73
|
}
|
|
37
74
|
|
|
38
|
-
export { parseSVG };
|
|
75
|
+
export { parseSVG, parseSVGSync };
|
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": "
|
|
6
|
+
"version": "3.0.0-beta.1",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"bugs": "https://github.com/iconify/tools/issues",
|
|
9
9
|
"homepage": "https://github.com/iconify/tools",
|
|
@@ -16,35 +16,33 @@
|
|
|
16
16
|
"types": "./lib/index.d.ts",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@iconify/types": "^2.0.0",
|
|
19
|
-
"@iconify/utils": "^2.1.
|
|
19
|
+
"@iconify/utils": "^2.1.5",
|
|
20
20
|
"@types/cheerio": "^0.22.31",
|
|
21
|
-
"@types/
|
|
22
|
-
"@types/tar": "^6.1.3",
|
|
21
|
+
"@types/tar": "^6.1.4",
|
|
23
22
|
"cheerio": "^1.0.0-rc.12",
|
|
24
23
|
"extract-zip": "^2.0.1",
|
|
25
|
-
"local-pkg": "^0.4.
|
|
26
|
-
"
|
|
27
|
-
"pathe": "^1.0.0",
|
|
24
|
+
"local-pkg": "^0.4.3",
|
|
25
|
+
"pathe": "^1.1.0",
|
|
28
26
|
"svgo": "^3.0.2",
|
|
29
27
|
"tar": "^6.1.13"
|
|
30
28
|
},
|
|
31
29
|
"devDependencies": {
|
|
32
|
-
"@types/jest": "^29.
|
|
33
|
-
"@types/node": "^18.11
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
35
|
-
"@typescript-eslint/parser": "^5.
|
|
30
|
+
"@types/jest": "^29.5.0",
|
|
31
|
+
"@types/node": "^18.15.11",
|
|
32
|
+
"@typescript-eslint/eslint-plugin": "^5.58.0",
|
|
33
|
+
"@typescript-eslint/parser": "^5.58.0",
|
|
36
34
|
"cross-env": "^7.0.3",
|
|
37
|
-
"eslint": "^8.
|
|
38
|
-
"eslint-config-prettier": "^8.
|
|
35
|
+
"eslint": "^8.38.0",
|
|
36
|
+
"eslint-config-prettier": "^8.8.0",
|
|
39
37
|
"eslint-plugin-jasmine": "^4.1.3",
|
|
40
38
|
"eslint-plugin-prettier": "^4.2.1",
|
|
41
|
-
"jasmine": "^4.
|
|
42
|
-
"jest": "^29.
|
|
43
|
-
"prettier": "^2.8.
|
|
44
|
-
"rimraf": "^
|
|
45
|
-
"ts-jest": "^29.0
|
|
46
|
-
"typescript": "^
|
|
47
|
-
"unbuild": "^1.
|
|
39
|
+
"jasmine": "^4.6.0",
|
|
40
|
+
"jest": "^29.5.0",
|
|
41
|
+
"prettier": "^2.8.7",
|
|
42
|
+
"rimraf": "^5.0.0",
|
|
43
|
+
"ts-jest": "^29.1.0",
|
|
44
|
+
"typescript": "^5.0.4",
|
|
45
|
+
"unbuild": "^1.2.1"
|
|
48
46
|
},
|
|
49
47
|
"exports": {
|
|
50
48
|
"./*": "./*",
|
|
@@ -423,6 +421,11 @@
|
|
|
423
421
|
"import": "./lib/optimise/global-style.mjs",
|
|
424
422
|
"types": "./lib/optimise/global-style.d.ts"
|
|
425
423
|
},
|
|
424
|
+
"./lib/optimise/origin": {
|
|
425
|
+
"require": "./lib/optimise/origin.cjs",
|
|
426
|
+
"import": "./lib/optimise/origin.mjs",
|
|
427
|
+
"types": "./lib/optimise/origin.d.ts"
|
|
428
|
+
},
|
|
426
429
|
"./lib/optimise/scale": {
|
|
427
430
|
"require": "./lib/optimise/scale.cjs",
|
|
428
431
|
"import": "./lib/optimise/scale.mjs",
|