@iconify/tools 2.2.4 → 2.2.6
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/index.cjs +2 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.mjs +1 -0
- 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 +16 -18
- package/lib/optimise/scale.mjs +16 -18
- package/lib/optimise/svgo.cjs +5 -0
- package/lib/optimise/svgo.mjs +5 -0
- package/package.json +20 -15
package/lib/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ const colors_validate = require('./colors/validate.cjs');
|
|
|
33
33
|
const colors_detect = require('./colors/detect.cjs');
|
|
34
34
|
const optimise_svgo = require('./optimise/svgo.cjs');
|
|
35
35
|
const optimise_flags = require('./optimise/flags.cjs');
|
|
36
|
+
const optimise_origin = require('./optimise/origin.cjs');
|
|
36
37
|
const optimise_scale = require('./optimise/scale.cjs');
|
|
37
38
|
const optimise_globalStyle = require('./optimise/global-style.cjs');
|
|
38
39
|
const export_directory = require('./export/directory.cjs');
|
|
@@ -125,6 +126,7 @@ exports.validateColors = colors_validate.validateColors;
|
|
|
125
126
|
exports.detectIconSetPalette = colors_detect.detectIconSetPalette;
|
|
126
127
|
exports.runSVGO = optimise_svgo.runSVGO;
|
|
127
128
|
exports.deOptimisePaths = optimise_flags.deOptimisePaths;
|
|
129
|
+
exports.resetSVGOrigin = optimise_origin.resetSVGOrigin;
|
|
128
130
|
exports.scaleSVG = optimise_scale.scaleSVG;
|
|
129
131
|
exports.cleanupGlobalStyle = optimise_globalStyle.cleanupGlobalStyle;
|
|
130
132
|
exports.exportToDirectory = export_directory.exportToDirectory;
|
package/lib/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export { validateColors } from './colors/validate.js';
|
|
|
31
31
|
export { detectIconSetPalette } from './colors/detect.js';
|
|
32
32
|
export { runSVGO } from './optimise/svgo.js';
|
|
33
33
|
export { deOptimisePaths } from './optimise/flags.js';
|
|
34
|
+
export { resetSVGOrigin } from './optimise/origin.js';
|
|
34
35
|
export { scaleSVG } from './optimise/scale.js';
|
|
35
36
|
export { cleanupGlobalStyle } from './optimise/global-style.js';
|
|
36
37
|
export { exportToDirectory } from './export/directory.js';
|
package/lib/index.mjs
CHANGED
|
@@ -31,6 +31,7 @@ export { validateColors } from './colors/validate.mjs';
|
|
|
31
31
|
export { detectIconSetPalette } from './colors/detect.mjs';
|
|
32
32
|
export { runSVGO } from './optimise/svgo.mjs';
|
|
33
33
|
export { deOptimisePaths } from './optimise/flags.mjs';
|
|
34
|
+
export { resetSVGOrigin } from './optimise/origin.mjs';
|
|
34
35
|
export { scaleSVG } from './optimise/scale.mjs';
|
|
35
36
|
export { cleanupGlobalStyle } from './optimise/global-style.mjs';
|
|
36
37
|
export { exportToDirectory } from './export/directory.mjs';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const optimise_svgo = require('./svgo.cjs');
|
|
4
|
+
require('svgo');
|
|
5
|
+
require('@iconify/utils/lib/svg/id');
|
|
6
|
+
|
|
7
|
+
function resetSVGOrigin(svg) {
|
|
8
|
+
const viewBox = svg.viewBox;
|
|
9
|
+
if (viewBox.left !== 0 || viewBox.top !== 0) {
|
|
10
|
+
const content = `<svg width="${viewBox.width}" height="${viewBox.height}" viewBox="0 0 ${viewBox.width} ${viewBox.height}"><g transform="translate(${0 - viewBox.left} ${0 - viewBox.top})">${svg.getBody()}</g></svg>`;
|
|
11
|
+
svg.load(content);
|
|
12
|
+
optimise_svgo.runSVGO(svg, {
|
|
13
|
+
plugins: [
|
|
14
|
+
"collapseGroups",
|
|
15
|
+
"convertTransform",
|
|
16
|
+
"convertPathData",
|
|
17
|
+
"sortAttrs"
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.resetSVGOrigin = resetSVGOrigin;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { runSVGO } from './svgo.mjs';
|
|
2
|
+
import 'svgo';
|
|
3
|
+
import '@iconify/utils/lib/svg/id';
|
|
4
|
+
|
|
5
|
+
function resetSVGOrigin(svg) {
|
|
6
|
+
const viewBox = svg.viewBox;
|
|
7
|
+
if (viewBox.left !== 0 || viewBox.top !== 0) {
|
|
8
|
+
const content = `<svg width="${viewBox.width}" height="${viewBox.height}" viewBox="0 0 ${viewBox.width} ${viewBox.height}"><g transform="translate(${0 - viewBox.left} ${0 - viewBox.top})">${svg.getBody()}</g></svg>`;
|
|
9
|
+
svg.load(content);
|
|
10
|
+
runSVGO(svg, {
|
|
11
|
+
plugins: [
|
|
12
|
+
"collapseGroups",
|
|
13
|
+
"convertTransform",
|
|
14
|
+
"convertPathData",
|
|
15
|
+
"sortAttrs"
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { resetSVGOrigin };
|
package/lib/optimise/scale.cjs
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const optimise_origin = require('./origin.cjs');
|
|
3
4
|
const optimise_svgo = require('./svgo.cjs');
|
|
4
5
|
require('svgo');
|
|
5
6
|
require('@iconify/utils/lib/svg/id');
|
|
6
7
|
|
|
7
8
|
function scaleSVG(svg, scale) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
optimise_origin.resetSVGOrigin(svg);
|
|
10
|
+
if (scale !== 1) {
|
|
11
|
+
const viewBox = svg.viewBox;
|
|
12
|
+
const width = viewBox.width * scale;
|
|
13
|
+
const height = viewBox.height * scale;
|
|
14
|
+
const content = `<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}"><g transform="scale(${scale})">${svg.getBody()}</g></svg>`;
|
|
15
|
+
svg.load(content);
|
|
16
|
+
optimise_svgo.runSVGO(svg, {
|
|
17
|
+
plugins: [
|
|
18
|
+
"collapseGroups",
|
|
19
|
+
"convertTransform",
|
|
20
|
+
"convertPathData",
|
|
21
|
+
"sortAttrs"
|
|
22
|
+
]
|
|
23
|
+
});
|
|
16
24
|
}
|
|
17
|
-
const content = `<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}"><g transform="scale(${scale})">${shiftTransform}${svg.getBody()}${shiftTransformEnd}</g></svg>`;
|
|
18
|
-
svg.load(content);
|
|
19
|
-
optimise_svgo.runSVGO(svg, {
|
|
20
|
-
plugins: [
|
|
21
|
-
"collapseGroups",
|
|
22
|
-
"convertTransform",
|
|
23
|
-
"convertPathData",
|
|
24
|
-
"sortAttrs"
|
|
25
|
-
]
|
|
26
|
-
});
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
exports.scaleSVG = scaleSVG;
|
package/lib/optimise/scale.mjs
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
+
import { resetSVGOrigin } from './origin.mjs';
|
|
1
2
|
import { runSVGO } from './svgo.mjs';
|
|
2
3
|
import 'svgo';
|
|
3
4
|
import '@iconify/utils/lib/svg/id';
|
|
4
5
|
|
|
5
6
|
function scaleSVG(svg, scale) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
resetSVGOrigin(svg);
|
|
8
|
+
if (scale !== 1) {
|
|
9
|
+
const viewBox = svg.viewBox;
|
|
10
|
+
const width = viewBox.width * scale;
|
|
11
|
+
const height = viewBox.height * scale;
|
|
12
|
+
const content = `<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}"><g transform="scale(${scale})">${svg.getBody()}</g></svg>`;
|
|
13
|
+
svg.load(content);
|
|
14
|
+
runSVGO(svg, {
|
|
15
|
+
plugins: [
|
|
16
|
+
"collapseGroups",
|
|
17
|
+
"convertTransform",
|
|
18
|
+
"convertPathData",
|
|
19
|
+
"sortAttrs"
|
|
20
|
+
]
|
|
21
|
+
});
|
|
14
22
|
}
|
|
15
|
-
const content = `<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}"><g transform="scale(${scale})">${shiftTransform}${svg.getBody()}${shiftTransformEnd}</g></svg>`;
|
|
16
|
-
svg.load(content);
|
|
17
|
-
runSVGO(svg, {
|
|
18
|
-
plugins: [
|
|
19
|
-
"collapseGroups",
|
|
20
|
-
"convertTransform",
|
|
21
|
-
"convertPathData",
|
|
22
|
-
"sortAttrs"
|
|
23
|
-
]
|
|
24
|
-
});
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
export { scaleSVG };
|
package/lib/optimise/svgo.cjs
CHANGED
|
@@ -65,6 +65,11 @@ function runSVGO(svg, options = {}) {
|
|
|
65
65
|
...options,
|
|
66
66
|
animated
|
|
67
67
|
});
|
|
68
|
+
if (code.includes("filter=") && code.includes("transform=")) {
|
|
69
|
+
plugins = plugins.filter(
|
|
70
|
+
(item) => item !== "moveElemsAttrsToGroup"
|
|
71
|
+
);
|
|
72
|
+
}
|
|
68
73
|
}
|
|
69
74
|
const pluginOptions = {
|
|
70
75
|
plugins,
|
package/lib/optimise/svgo.mjs
CHANGED
|
@@ -63,6 +63,11 @@ function runSVGO(svg, options = {}) {
|
|
|
63
63
|
...options,
|
|
64
64
|
animated
|
|
65
65
|
});
|
|
66
|
+
if (code.includes("filter=") && code.includes("transform=")) {
|
|
67
|
+
plugins = plugins.filter(
|
|
68
|
+
(item) => item !== "moveElemsAttrsToGroup"
|
|
69
|
+
);
|
|
70
|
+
}
|
|
66
71
|
}
|
|
67
72
|
const pluginOptions = {
|
|
68
73
|
plugins,
|
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": "2.2.
|
|
6
|
+
"version": "2.2.6",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"bugs": "https://github.com/iconify/tools/issues",
|
|
9
9
|
"homepage": "https://github.com/iconify/tools",
|
|
@@ -16,35 +16,35 @@
|
|
|
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.4",
|
|
20
20
|
"@types/cheerio": "^0.22.31",
|
|
21
21
|
"@types/node-fetch": "^2.6.2",
|
|
22
|
-
"@types/tar": "^6.1.
|
|
22
|
+
"@types/tar": "^6.1.4",
|
|
23
23
|
"cheerio": "^1.0.0-rc.12",
|
|
24
24
|
"extract-zip": "^2.0.1",
|
|
25
|
-
"local-pkg": "^0.4.
|
|
26
|
-
"node-fetch": "^2.6.
|
|
27
|
-
"pathe": "^1.
|
|
25
|
+
"local-pkg": "^0.4.3",
|
|
26
|
+
"node-fetch": "^2.6.9",
|
|
27
|
+
"pathe": "^1.1.0",
|
|
28
28
|
"svgo": "^3.0.2",
|
|
29
29
|
"tar": "^6.1.13"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/jest": "^29.
|
|
33
|
-
"@types/node": "^18.
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
35
|
-
"@typescript-eslint/parser": "^5.
|
|
32
|
+
"@types/jest": "^29.4.0",
|
|
33
|
+
"@types/node": "^18.14.0",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^5.52.0",
|
|
35
|
+
"@typescript-eslint/parser": "^5.52.0",
|
|
36
36
|
"cross-env": "^7.0.3",
|
|
37
|
-
"eslint": "^8.
|
|
37
|
+
"eslint": "^8.34.0",
|
|
38
38
|
"eslint-config-prettier": "^8.6.0",
|
|
39
39
|
"eslint-plugin-jasmine": "^4.1.3",
|
|
40
40
|
"eslint-plugin-prettier": "^4.2.1",
|
|
41
41
|
"jasmine": "^4.5.0",
|
|
42
|
-
"jest": "^29.3
|
|
43
|
-
"prettier": "^2.8.
|
|
42
|
+
"jest": "^29.4.3",
|
|
43
|
+
"prettier": "^2.8.4",
|
|
44
44
|
"rimraf": "^3.0.2",
|
|
45
45
|
"ts-jest": "^29.0.5",
|
|
46
|
-
"typescript": "^4.9.
|
|
47
|
-
"unbuild": "^1.1.
|
|
46
|
+
"typescript": "^4.9.5",
|
|
47
|
+
"unbuild": "^1.1.2"
|
|
48
48
|
},
|
|
49
49
|
"exports": {
|
|
50
50
|
"./*": "./*",
|
|
@@ -423,6 +423,11 @@
|
|
|
423
423
|
"import": "./lib/optimise/global-style.mjs",
|
|
424
424
|
"types": "./lib/optimise/global-style.d.ts"
|
|
425
425
|
},
|
|
426
|
+
"./lib/optimise/origin": {
|
|
427
|
+
"require": "./lib/optimise/origin.cjs",
|
|
428
|
+
"import": "./lib/optimise/origin.mjs",
|
|
429
|
+
"types": "./lib/optimise/origin.d.ts"
|
|
430
|
+
},
|
|
426
431
|
"./lib/optimise/scale": {
|
|
427
432
|
"require": "./lib/optimise/scale.cjs",
|
|
428
433
|
"import": "./lib/optimise/scale.mjs",
|