@iconify/tools 4.0.0-dev.1 → 4.0.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/attribs.d.cts +27 -0
- package/lib/colors/attribs.d.mts +27 -0
- package/lib/colors/attribs.d.ts +1 -1
- package/lib/colors/detect.cjs +2 -2
- package/lib/colors/detect.d.cts +16 -0
- package/lib/colors/detect.d.mts +16 -0
- package/lib/colors/detect.mjs +3 -3
- package/lib/colors/parse.cjs +132 -276
- package/lib/colors/parse.d.cts +60 -0
- package/lib/colors/parse.d.mts +60 -0
- package/lib/colors/parse.d.ts +7 -15
- package/lib/colors/parse.mjs +136 -279
- package/lib/colors/validate.cjs +2 -11
- package/lib/colors/validate.d.cts +20 -0
- package/lib/colors/validate.d.mts +20 -0
- package/lib/colors/validate.d.ts +4 -11
- package/lib/colors/validate.mjs +4 -12
- package/lib/css/parse.d.cts +6 -0
- package/lib/css/parse.d.mts +6 -0
- package/lib/css/parser/error.d.cts +13 -0
- package/lib/css/parser/error.d.mts +13 -0
- package/lib/css/parser/error.d.ts +1 -1
- package/lib/css/parser/export.d.cts +8 -0
- package/lib/css/parser/export.d.mts +8 -0
- package/lib/css/parser/strings.d.cts +16 -0
- package/lib/css/parser/strings.d.mts +16 -0
- package/lib/css/parser/text.d.cts +20 -0
- package/lib/css/parser/text.d.mts +20 -0
- package/lib/css/parser/tokens.d.cts +9 -0
- package/lib/css/parser/tokens.d.mts +9 -0
- package/lib/css/parser/tree.d.cts +8 -0
- package/lib/css/parser/tree.d.mts +8 -0
- package/lib/css/parser/types.d.cts +52 -0
- package/lib/css/parser/types.d.mts +52 -0
- package/lib/css/parser/types.d.ts +1 -1
- package/lib/download/api/cache.d.cts +20 -0
- package/lib/download/api/cache.d.mts +20 -0
- package/lib/download/api/config.cjs +11 -0
- package/lib/download/api/config.d.cts +18 -0
- package/lib/download/api/config.d.mts +18 -0
- package/lib/download/api/config.d.ts +18 -0
- package/lib/download/api/config.mjs +8 -0
- package/lib/download/api/download.cjs +15 -7
- package/lib/download/api/download.d.cts +8 -0
- package/lib/download/api/download.d.mts +8 -0
- package/lib/download/api/download.mjs +11 -7
- package/lib/download/api/index.cjs +23 -7
- package/lib/download/api/index.d.cts +8 -0
- package/lib/download/api/index.d.mts +8 -0
- package/lib/download/api/index.mjs +19 -7
- package/lib/download/api/queue.cjs +104 -0
- package/lib/download/api/queue.d.cts +32 -0
- package/lib/download/api/queue.d.mts +32 -0
- package/lib/download/api/queue.d.ts +32 -0
- package/lib/download/api/queue.mjs +101 -0
- package/lib/download/api/types.d.cts +17 -0
- package/lib/download/api/types.d.mts +17 -0
- package/lib/download/api/types.d.ts +1 -1
- package/lib/download/git/branch.d.cts +8 -0
- package/lib/download/git/branch.d.mts +8 -0
- package/lib/download/git/hash.d.cts +8 -0
- package/lib/download/git/hash.d.mts +8 -0
- package/lib/download/git/index.cjs +2 -4
- package/lib/download/git/index.d.cts +29 -0
- package/lib/download/git/index.d.mts +29 -0
- package/lib/download/git/index.d.ts +1 -1
- package/lib/download/git/index.mjs +2 -4
- package/lib/download/git/reset.cjs +2 -4
- package/lib/download/git/reset.d.cts +6 -0
- package/lib/download/git/reset.d.mts +6 -0
- package/lib/download/git/reset.mjs +2 -4
- package/lib/download/github/hash.cjs +2 -0
- package/lib/download/github/hash.d.cts +8 -0
- package/lib/download/github/hash.d.mts +8 -0
- package/lib/download/github/hash.mjs +2 -0
- package/lib/download/github/index.cjs +2 -2
- package/lib/download/github/index.d.cts +31 -0
- package/lib/download/github/index.d.mts +31 -0
- package/lib/download/github/index.d.ts +1 -1
- package/lib/download/github/index.mjs +2 -2
- package/lib/download/github/types.d.cts +11 -0
- package/lib/download/github/types.d.mts +11 -0
- package/lib/download/github/types.d.ts +1 -1
- package/lib/download/gitlab/hash.cjs +2 -0
- package/lib/download/gitlab/hash.d.cts +8 -0
- package/lib/download/gitlab/hash.d.mts +8 -0
- package/lib/download/gitlab/hash.mjs +2 -0
- package/lib/download/gitlab/index.cjs +2 -2
- package/lib/download/gitlab/index.d.cts +31 -0
- package/lib/download/gitlab/index.d.mts +31 -0
- package/lib/download/gitlab/index.d.ts +1 -1
- package/lib/download/gitlab/index.mjs +2 -2
- package/lib/download/gitlab/types.d.cts +15 -0
- package/lib/download/gitlab/types.d.mts +15 -0
- package/lib/download/gitlab/types.d.ts +1 -1
- package/lib/download/helpers/untar.d.cts +6 -0
- package/lib/download/helpers/untar.d.mts +6 -0
- package/lib/download/helpers/unzip.d.cts +6 -0
- package/lib/download/helpers/unzip.d.mts +6 -0
- package/lib/download/index.cjs +2 -2
- package/lib/download/index.d.cts +48 -0
- package/lib/download/index.d.mts +48 -0
- package/lib/download/index.d.ts +1 -1
- package/lib/download/index.mjs +2 -2
- package/lib/download/npm/index.cjs +2 -2
- package/lib/download/npm/index.d.cts +30 -0
- package/lib/download/npm/index.d.mts +30 -0
- package/lib/download/npm/index.d.ts +1 -1
- package/lib/download/npm/index.mjs +2 -2
- package/lib/download/npm/types.d.cts +9 -0
- package/lib/download/npm/types.d.mts +9 -0
- package/lib/download/npm/types.d.ts +1 -1
- package/lib/download/npm/version.d.cts +16 -0
- package/lib/download/npm/version.d.mts +16 -0
- package/lib/download/npm/version.d.ts +1 -1
- package/lib/download/types/modified.d.cts +6 -0
- package/lib/download/types/modified.d.mts +6 -0
- package/lib/download/types/modified.d.ts +1 -1
- package/lib/download/types/sources.d.cts +12 -0
- package/lib/download/types/sources.d.mts +12 -0
- package/lib/download/types/sources.d.ts +1 -1
- package/lib/export/directory.d.cts +26 -0
- package/lib/export/directory.d.mts +26 -0
- package/lib/export/directory.d.ts +1 -1
- package/lib/export/helpers/custom-files.d.cts +12 -0
- package/lib/export/helpers/custom-files.d.mts +12 -0
- package/lib/export/helpers/custom-files.d.ts +1 -1
- package/lib/export/helpers/prepare.d.cts +19 -0
- package/lib/export/helpers/prepare.d.mts +19 -0
- package/lib/export/helpers/prepare.d.ts +1 -1
- package/lib/export/helpers/types-version.d.cts +6 -0
- package/lib/export/helpers/types-version.d.mts +6 -0
- package/lib/export/icon-package.d.cts +26 -0
- package/lib/export/icon-package.d.mts +26 -0
- package/lib/export/icon-package.d.ts +2 -2
- package/lib/export/json-package.cjs +1 -0
- package/lib/export/json-package.d.cts +25 -0
- package/lib/export/json-package.d.mts +25 -0
- package/lib/export/json-package.d.ts +2 -1
- package/lib/export/json-package.mjs +1 -0
- package/lib/icon-set/index.cjs +25 -4
- package/lib/icon-set/index.d.cts +162 -0
- package/lib/icon-set/index.d.mts +162 -0
- package/lib/icon-set/index.mjs +25 -4
- package/lib/icon-set/match.d.cts +15 -0
- package/lib/icon-set/match.d.mts +15 -0
- package/lib/icon-set/merge.d.cts +14 -0
- package/lib/icon-set/merge.d.mts +14 -0
- package/lib/icon-set/modified.d.cts +16 -0
- package/lib/icon-set/modified.d.mts +16 -0
- package/lib/icon-set/props.d.cts +13 -0
- package/lib/icon-set/props.d.mts +13 -0
- package/lib/icon-set/tags.d.cts +23 -0
- package/lib/icon-set/tags.d.mts +23 -0
- package/lib/icon-set/types.d.cts +75 -0
- package/lib/icon-set/types.d.mts +75 -0
- package/lib/icon-set/types.d.ts +1 -1
- package/lib/import/directory.d.cts +52 -0
- package/lib/import/directory.d.mts +52 -0
- package/lib/import/directory.d.ts +1 -1
- package/lib/import/figma/index.cjs +3 -0
- package/lib/import/figma/index.d.cts +20 -0
- package/lib/import/figma/index.d.mts +20 -0
- package/lib/import/figma/index.mjs +3 -0
- package/lib/import/figma/nodes.cjs +1 -1
- package/lib/import/figma/nodes.d.cts +18 -0
- package/lib/import/figma/nodes.d.mts +18 -0
- package/lib/import/figma/nodes.mjs +1 -1
- package/lib/import/figma/query.cjs +104 -76
- package/lib/import/figma/query.d.cts +42 -0
- package/lib/import/figma/query.d.mts +42 -0
- package/lib/import/figma/query.d.ts +15 -2
- package/lib/import/figma/query.mjs +106 -78
- package/lib/import/figma/types/api.d.cts +53 -0
- package/lib/import/figma/types/api.d.mts +53 -0
- package/lib/import/figma/types/api.d.ts +1 -1
- package/lib/import/figma/types/nodes.d.cts +44 -0
- package/lib/import/figma/types/nodes.d.mts +44 -0
- package/lib/import/figma/types/nodes.d.ts +1 -1
- package/lib/import/figma/types/options.d.cts +59 -0
- package/lib/import/figma/types/options.d.mts +59 -0
- package/lib/import/figma/types/options.d.ts +1 -1
- package/lib/import/figma/types/result.d.cts +44 -0
- package/lib/import/figma/types/result.d.mts +44 -0
- package/lib/import/figma/types/result.d.ts +1 -1
- package/lib/index.cjs +15 -13
- package/lib/index.d.cts +78 -0
- package/lib/index.d.mts +78 -0
- package/lib/index.d.ts +8 -5
- package/lib/index.mjs +14 -12
- package/lib/misc/bump-version.d.cts +6 -0
- package/lib/misc/bump-version.d.mts +6 -0
- package/lib/misc/cheerio.d.cts +9 -0
- package/lib/misc/cheerio.d.mts +9 -0
- package/lib/misc/cheerio.d.ts +1 -1
- package/lib/misc/compare-dirs.cjs +3 -3
- package/lib/misc/compare-dirs.d.cts +11 -0
- package/lib/misc/compare-dirs.d.mts +11 -0
- package/lib/misc/compare-dirs.d.ts +1 -1
- package/lib/misc/compare-dirs.mjs +3 -3
- package/lib/misc/exec.d.cts +12 -0
- package/lib/misc/exec.d.mts +12 -0
- package/lib/misc/exec.d.ts +1 -1
- package/lib/misc/keyword.d.cts +6 -0
- package/lib/misc/keyword.d.mts +6 -0
- package/lib/misc/scan.d.cts +33 -0
- package/lib/misc/scan.d.mts +33 -0
- package/lib/misc/scan.d.ts +3 -3
- package/lib/misc/write-json.d.cts +6 -0
- package/lib/misc/write-json.d.mts +6 -0
- package/lib/optimise/figma.cjs +55 -33
- package/lib/optimise/figma.d.cts +13 -0
- package/lib/optimise/figma.d.mts +13 -0
- package/lib/optimise/figma.d.ts +3 -1
- package/lib/optimise/figma.mjs +55 -33
- package/lib/optimise/flags.cjs +3 -3
- package/lib/optimise/flags.d.cts +11 -0
- package/lib/optimise/flags.d.mts +11 -0
- package/lib/optimise/flags.d.ts +1 -1
- package/lib/optimise/flags.mjs +3 -3
- package/lib/optimise/global-style.cjs +7 -7
- package/lib/optimise/global-style.d.cts +11 -0
- package/lib/optimise/global-style.d.mts +11 -0
- package/lib/optimise/global-style.d.ts +1 -1
- package/lib/optimise/global-style.mjs +7 -7
- package/lib/optimise/mask.cjs +1 -1
- package/lib/optimise/mask.d.cts +24 -0
- package/lib/optimise/mask.d.mts +24 -0
- package/lib/optimise/mask.mjs +2 -2
- package/lib/optimise/origin.d.cts +11 -0
- package/lib/optimise/origin.d.mts +11 -0
- package/lib/optimise/scale.d.cts +11 -0
- package/lib/optimise/scale.d.mts +11 -0
- package/lib/optimise/svgo.cjs +1 -1
- package/lib/optimise/svgo.d.cts +37 -0
- package/lib/optimise/svgo.d.mts +37 -0
- package/lib/optimise/svgo.mjs +1 -1
- package/lib/optimise/unwrap.cjs +31 -0
- package/lib/optimise/unwrap.d.cts +11 -0
- package/lib/optimise/unwrap.d.mts +11 -0
- package/lib/optimise/unwrap.d.ts +11 -0
- package/lib/optimise/unwrap.mjs +29 -0
- package/lib/svg/analyse/error.d.cts +10 -0
- package/lib/svg/analyse/error.d.mts +10 -0
- package/lib/svg/analyse/error.d.ts +1 -0
- package/lib/svg/analyse/types.d.cts +92 -0
- package/lib/svg/analyse/types.d.mts +92 -0
- package/lib/svg/analyse/types.d.ts +4 -3
- package/lib/svg/analyse.cjs +2 -2
- package/lib/svg/analyse.d.cts +15 -0
- package/lib/svg/analyse.d.mts +15 -0
- package/lib/svg/analyse.d.ts +1 -0
- package/lib/svg/analyse.mjs +4 -4
- package/lib/svg/cleanup/attribs.cjs +1 -1
- package/lib/svg/cleanup/attribs.d.cts +11 -0
- package/lib/svg/cleanup/attribs.d.mts +11 -0
- package/lib/svg/cleanup/attribs.mjs +2 -2
- package/lib/svg/cleanup/bad-tags.cjs +1 -1
- package/lib/svg/cleanup/bad-tags.d.cts +17 -0
- package/lib/svg/cleanup/bad-tags.d.mts +17 -0
- package/lib/svg/cleanup/bad-tags.d.ts +1 -1
- package/lib/svg/cleanup/bad-tags.mjs +2 -2
- package/lib/svg/cleanup/inline-style.cjs +1 -1
- package/lib/svg/cleanup/inline-style.d.cts +11 -0
- package/lib/svg/cleanup/inline-style.d.mts +11 -0
- package/lib/svg/cleanup/inline-style.mjs +2 -2
- package/lib/svg/cleanup/root-style.cjs +1 -1
- package/lib/svg/cleanup/root-style.d.cts +17 -0
- package/lib/svg/cleanup/root-style.d.mts +17 -0
- package/lib/svg/cleanup/root-style.mjs +2 -2
- package/lib/svg/cleanup/root-svg.cjs +3 -3
- package/lib/svg/cleanup/root-svg.d.cts +11 -0
- package/lib/svg/cleanup/root-svg.d.mts +11 -0
- package/lib/svg/cleanup/root-svg.mjs +3 -3
- package/lib/svg/cleanup/svgo-style.cjs +2 -2
- package/lib/svg/cleanup/svgo-style.d.cts +11 -0
- package/lib/svg/cleanup/svgo-style.d.mts +11 -0
- package/lib/svg/cleanup/svgo-style.mjs +3 -3
- package/lib/svg/cleanup.d.cts +16 -0
- package/lib/svg/cleanup.d.mts +16 -0
- package/lib/svg/cleanup.d.ts +1 -1
- package/lib/svg/data/attributes.d.cts +77 -0
- package/lib/svg/data/attributes.d.mts +77 -0
- package/lib/svg/data/tags.d.cts +95 -0
- package/lib/svg/data/tags.d.mts +95 -0
- package/lib/svg/index.cjs +18 -1
- package/lib/svg/index.d.cts +52 -0
- package/lib/svg/index.d.mts +52 -0
- package/lib/svg/index.d.ts +5 -1
- package/lib/svg/index.mjs +19 -2
- package/lib/svg/parse-style.cjs +178 -235
- package/lib/svg/parse-style.d.cts +58 -0
- package/lib/svg/parse-style.d.mts +58 -0
- package/lib/svg/parse-style.d.ts +3 -9
- package/lib/svg/parse-style.mjs +180 -236
- package/lib/svg/parse.cjs +27 -59
- package/lib/svg/parse.d.cts +30 -0
- package/lib/svg/parse.d.mts +30 -0
- package/lib/svg/parse.d.ts +3 -10
- package/lib/svg/parse.mjs +28 -59
- package/package.json +34 -24
package/lib/optimise/figma.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const svg_data_tags = require('../svg/data/tags.cjs');
|
|
4
|
+
const optimise_unwrap = require('./unwrap.cjs');
|
|
4
5
|
|
|
5
6
|
function isTinyNumber(value, limit) {
|
|
6
7
|
const num = parseInt(value);
|
|
@@ -24,8 +25,8 @@ function checkClipPathNode(clipNode, expectedWidth, expectedHeight) {
|
|
|
24
25
|
...childNode.attribs
|
|
25
26
|
};
|
|
26
27
|
delete attribs["fill"];
|
|
27
|
-
const fill =
|
|
28
|
-
if (fill !== "white" && fill !== "#fff" && fill !== "#ffffff") {
|
|
28
|
+
const fill = childNode.attribs["fill"]?.toLowerCase();
|
|
29
|
+
if (fill !== "white" && fill !== "#fff" && fill !== "#ffffff" && fill !== void 0) {
|
|
29
30
|
console.warn(
|
|
30
31
|
"Unxepected fill on clip path:",
|
|
31
32
|
childNode.attribs["fill"]
|
|
@@ -42,6 +43,24 @@ function checkClipPathNode(clipNode, expectedWidth, expectedHeight) {
|
|
|
42
43
|
}
|
|
43
44
|
delete attribs["width"];
|
|
44
45
|
delete attribs["height"];
|
|
46
|
+
for (const attr in childNode.attribs) {
|
|
47
|
+
const value = childNode.attribs[attr];
|
|
48
|
+
switch (attr) {
|
|
49
|
+
case "rx":
|
|
50
|
+
case "ry":
|
|
51
|
+
case "x":
|
|
52
|
+
case "y":
|
|
53
|
+
if (value === "0") {
|
|
54
|
+
delete attribs[attr];
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
case "transform":
|
|
58
|
+
if (value === "") {
|
|
59
|
+
delete attribs[attr];
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
45
64
|
break;
|
|
46
65
|
}
|
|
47
66
|
default:
|
|
@@ -74,11 +93,28 @@ function checkClipPathNode(clipNode, expectedWidth, expectedHeight) {
|
|
|
74
93
|
}
|
|
75
94
|
const urlStart = "url(#";
|
|
76
95
|
const urlEnd = ")";
|
|
77
|
-
function
|
|
78
|
-
|
|
96
|
+
function remove(svg) {
|
|
97
|
+
optimise_unwrap.unwrapEmptyGroup(svg);
|
|
98
|
+
let content = svg.toString();
|
|
99
|
+
const backup = content;
|
|
100
|
+
const clipPathBlocks = content.match(
|
|
101
|
+
/<clipPath[^>]*>[\s\S]+?<\/clipPath>/g
|
|
102
|
+
);
|
|
103
|
+
if (clipPathBlocks?.length === 2 && clipPathBlocks[0] === clipPathBlocks[1]) {
|
|
104
|
+
const split = clipPathBlocks[0];
|
|
105
|
+
const lines = content.split(split);
|
|
106
|
+
content = lines.shift() + split + lines.join("");
|
|
107
|
+
}
|
|
108
|
+
content = content.replaceAll('class="frame-clip-def frame-clip"', "");
|
|
109
|
+
if (content.includes("<defs>")) {
|
|
110
|
+
content = content.replace(/<\/?defs>/g, "");
|
|
111
|
+
}
|
|
112
|
+
if (content !== backup) {
|
|
113
|
+
svg.load(content);
|
|
114
|
+
}
|
|
115
|
+
const cheerio = svg.$svg;
|
|
79
116
|
const $root = svg.$svg(":root");
|
|
80
117
|
const children = $root.children();
|
|
81
|
-
const backup = svg.toString();
|
|
82
118
|
const shapesToClip = [];
|
|
83
119
|
let clipID;
|
|
84
120
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -112,7 +148,7 @@ function removeFigmaClipPathFromSVG(svg) {
|
|
|
112
148
|
svg.viewBox.width,
|
|
113
149
|
svg.viewBox.height
|
|
114
150
|
);
|
|
115
|
-
|
|
151
|
+
cheerio(node).remove();
|
|
116
152
|
return result;
|
|
117
153
|
};
|
|
118
154
|
const findClipPath = () => {
|
|
@@ -120,29 +156,6 @@ function removeFigmaClipPathFromSVG(svg) {
|
|
|
120
156
|
const node = children[i];
|
|
121
157
|
if (node.type === "tag") {
|
|
122
158
|
const tagName = node.tagName;
|
|
123
|
-
if (svg_data_tags.defsTag.has(tagName)) {
|
|
124
|
-
const defsChildren = node.children;
|
|
125
|
-
for (let j = 0; j < defsChildren.length; j++) {
|
|
126
|
-
const childNode = defsChildren[j];
|
|
127
|
-
if (childNode.type === "tag" && childNode.tagName === "clipPath") {
|
|
128
|
-
const result = checkClipPath(childNode);
|
|
129
|
-
if (result !== void 0) {
|
|
130
|
-
const validChildren = node.children.filter(
|
|
131
|
-
(test) => {
|
|
132
|
-
if (test.type === "text") {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
);
|
|
138
|
-
if (!validChildren.length) {
|
|
139
|
-
cheerio2(node).remove();
|
|
140
|
-
}
|
|
141
|
-
return result;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
159
|
if (tagName === "clipPath") {
|
|
147
160
|
const result = checkClipPath(node);
|
|
148
161
|
if (result !== void 0) {
|
|
@@ -154,22 +167,31 @@ function removeFigmaClipPathFromSVG(svg) {
|
|
|
154
167
|
};
|
|
155
168
|
const clipPath = findClipPath();
|
|
156
169
|
if (!clipPath) {
|
|
157
|
-
svg.load(backup);
|
|
158
170
|
return false;
|
|
159
171
|
}
|
|
160
172
|
const attribs = clipPath.attribs;
|
|
161
173
|
for (let i = 0; i < shapesToClip.length; i++) {
|
|
162
174
|
const node = shapesToClip[i];
|
|
163
|
-
|
|
175
|
+
cheerio(node).removeAttr("clip-path");
|
|
164
176
|
for (const attr in attribs) {
|
|
165
177
|
if (node.attribs[attr] !== void 0) {
|
|
166
|
-
svg.load(backup);
|
|
167
178
|
return false;
|
|
168
179
|
}
|
|
169
|
-
|
|
180
|
+
cheerio(node).attr(attr, attribs[attr]);
|
|
170
181
|
}
|
|
171
182
|
}
|
|
172
183
|
return true;
|
|
173
184
|
}
|
|
185
|
+
function removeFigmaClipPathFromSVG(svg) {
|
|
186
|
+
const backup = svg.toString();
|
|
187
|
+
try {
|
|
188
|
+
if (remove(svg)) {
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
} catch {
|
|
192
|
+
}
|
|
193
|
+
svg.load(backup);
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
174
196
|
|
|
175
197
|
exports.removeFigmaClipPathFromSVG = removeFigmaClipPathFromSVG;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SVG } from '../svg/index.cjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Removes clip path from SVG, which Figma and Penpot add to icons that might have overflowing elements
|
|
8
|
+
*
|
|
9
|
+
* Function was originally designed for Figma only, but later added support for Penpot
|
|
10
|
+
*/
|
|
11
|
+
declare function removeFigmaClipPathFromSVG(svg: SVG): boolean;
|
|
12
|
+
|
|
13
|
+
export { removeFigmaClipPathFromSVG };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SVG } from '../svg/index.mjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Removes clip path from SVG, which Figma and Penpot add to icons that might have overflowing elements
|
|
8
|
+
*
|
|
9
|
+
* Function was originally designed for Figma only, but later added support for Penpot
|
|
10
|
+
*/
|
|
11
|
+
declare function removeFigmaClipPathFromSVG(svg: SVG): boolean;
|
|
12
|
+
|
|
13
|
+
export { removeFigmaClipPathFromSVG };
|
package/lib/optimise/figma.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ import '@iconify/types';
|
|
|
4
4
|
import '@iconify/utils/lib/customisations/defaults';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Removes clip path from SVG, which Figma
|
|
7
|
+
* Removes clip path from SVG, which Figma and Penpot add to icons that might have overflowing elements
|
|
8
|
+
*
|
|
9
|
+
* Function was originally designed for Figma only, but later added support for Penpot
|
|
8
10
|
*/
|
|
9
11
|
declare function removeFigmaClipPathFromSVG(svg: SVG): boolean;
|
|
10
12
|
|
package/lib/optimise/figma.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defsTag, maskTags, symbolTag } from '../svg/data/tags.mjs';
|
|
2
|
+
import { unwrapEmptyGroup } from './unwrap.mjs';
|
|
2
3
|
|
|
3
4
|
function isTinyNumber(value, limit) {
|
|
4
5
|
const num = parseInt(value);
|
|
@@ -22,8 +23,8 @@ function checkClipPathNode(clipNode, expectedWidth, expectedHeight) {
|
|
|
22
23
|
...childNode.attribs
|
|
23
24
|
};
|
|
24
25
|
delete attribs["fill"];
|
|
25
|
-
const fill =
|
|
26
|
-
if (fill !== "white" && fill !== "#fff" && fill !== "#ffffff") {
|
|
26
|
+
const fill = childNode.attribs["fill"]?.toLowerCase();
|
|
27
|
+
if (fill !== "white" && fill !== "#fff" && fill !== "#ffffff" && fill !== void 0) {
|
|
27
28
|
console.warn(
|
|
28
29
|
"Unxepected fill on clip path:",
|
|
29
30
|
childNode.attribs["fill"]
|
|
@@ -40,6 +41,24 @@ function checkClipPathNode(clipNode, expectedWidth, expectedHeight) {
|
|
|
40
41
|
}
|
|
41
42
|
delete attribs["width"];
|
|
42
43
|
delete attribs["height"];
|
|
44
|
+
for (const attr in childNode.attribs) {
|
|
45
|
+
const value = childNode.attribs[attr];
|
|
46
|
+
switch (attr) {
|
|
47
|
+
case "rx":
|
|
48
|
+
case "ry":
|
|
49
|
+
case "x":
|
|
50
|
+
case "y":
|
|
51
|
+
if (value === "0") {
|
|
52
|
+
delete attribs[attr];
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
case "transform":
|
|
56
|
+
if (value === "") {
|
|
57
|
+
delete attribs[attr];
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
43
62
|
break;
|
|
44
63
|
}
|
|
45
64
|
default:
|
|
@@ -72,11 +91,28 @@ function checkClipPathNode(clipNode, expectedWidth, expectedHeight) {
|
|
|
72
91
|
}
|
|
73
92
|
const urlStart = "url(#";
|
|
74
93
|
const urlEnd = ")";
|
|
75
|
-
function
|
|
76
|
-
|
|
94
|
+
function remove(svg) {
|
|
95
|
+
unwrapEmptyGroup(svg);
|
|
96
|
+
let content = svg.toString();
|
|
97
|
+
const backup = content;
|
|
98
|
+
const clipPathBlocks = content.match(
|
|
99
|
+
/<clipPath[^>]*>[\s\S]+?<\/clipPath>/g
|
|
100
|
+
);
|
|
101
|
+
if (clipPathBlocks?.length === 2 && clipPathBlocks[0] === clipPathBlocks[1]) {
|
|
102
|
+
const split = clipPathBlocks[0];
|
|
103
|
+
const lines = content.split(split);
|
|
104
|
+
content = lines.shift() + split + lines.join("");
|
|
105
|
+
}
|
|
106
|
+
content = content.replaceAll('class="frame-clip-def frame-clip"', "");
|
|
107
|
+
if (content.includes("<defs>")) {
|
|
108
|
+
content = content.replace(/<\/?defs>/g, "");
|
|
109
|
+
}
|
|
110
|
+
if (content !== backup) {
|
|
111
|
+
svg.load(content);
|
|
112
|
+
}
|
|
113
|
+
const cheerio = svg.$svg;
|
|
77
114
|
const $root = svg.$svg(":root");
|
|
78
115
|
const children = $root.children();
|
|
79
|
-
const backup = svg.toString();
|
|
80
116
|
const shapesToClip = [];
|
|
81
117
|
let clipID;
|
|
82
118
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -110,7 +146,7 @@ function removeFigmaClipPathFromSVG(svg) {
|
|
|
110
146
|
svg.viewBox.width,
|
|
111
147
|
svg.viewBox.height
|
|
112
148
|
);
|
|
113
|
-
|
|
149
|
+
cheerio(node).remove();
|
|
114
150
|
return result;
|
|
115
151
|
};
|
|
116
152
|
const findClipPath = () => {
|
|
@@ -118,29 +154,6 @@ function removeFigmaClipPathFromSVG(svg) {
|
|
|
118
154
|
const node = children[i];
|
|
119
155
|
if (node.type === "tag") {
|
|
120
156
|
const tagName = node.tagName;
|
|
121
|
-
if (defsTag.has(tagName)) {
|
|
122
|
-
const defsChildren = node.children;
|
|
123
|
-
for (let j = 0; j < defsChildren.length; j++) {
|
|
124
|
-
const childNode = defsChildren[j];
|
|
125
|
-
if (childNode.type === "tag" && childNode.tagName === "clipPath") {
|
|
126
|
-
const result = checkClipPath(childNode);
|
|
127
|
-
if (result !== void 0) {
|
|
128
|
-
const validChildren = node.children.filter(
|
|
129
|
-
(test) => {
|
|
130
|
-
if (test.type === "text") {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
);
|
|
136
|
-
if (!validChildren.length) {
|
|
137
|
-
cheerio2(node).remove();
|
|
138
|
-
}
|
|
139
|
-
return result;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
157
|
if (tagName === "clipPath") {
|
|
145
158
|
const result = checkClipPath(node);
|
|
146
159
|
if (result !== void 0) {
|
|
@@ -152,22 +165,31 @@ function removeFigmaClipPathFromSVG(svg) {
|
|
|
152
165
|
};
|
|
153
166
|
const clipPath = findClipPath();
|
|
154
167
|
if (!clipPath) {
|
|
155
|
-
svg.load(backup);
|
|
156
168
|
return false;
|
|
157
169
|
}
|
|
158
170
|
const attribs = clipPath.attribs;
|
|
159
171
|
for (let i = 0; i < shapesToClip.length; i++) {
|
|
160
172
|
const node = shapesToClip[i];
|
|
161
|
-
|
|
173
|
+
cheerio(node).removeAttr("clip-path");
|
|
162
174
|
for (const attr in attribs) {
|
|
163
175
|
if (node.attribs[attr] !== void 0) {
|
|
164
|
-
svg.load(backup);
|
|
165
176
|
return false;
|
|
166
177
|
}
|
|
167
|
-
|
|
178
|
+
cheerio(node).attr(attr, attribs[attr]);
|
|
168
179
|
}
|
|
169
180
|
}
|
|
170
181
|
return true;
|
|
171
182
|
}
|
|
183
|
+
function removeFigmaClipPathFromSVG(svg) {
|
|
184
|
+
const backup = svg.toString();
|
|
185
|
+
try {
|
|
186
|
+
if (remove(svg)) {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
} catch {
|
|
190
|
+
}
|
|
191
|
+
svg.load(backup);
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
172
194
|
|
|
173
195
|
export { removeFigmaClipPathFromSVG };
|
package/lib/optimise/flags.cjs
CHANGED
|
@@ -223,7 +223,7 @@ function cleanPath(path) {
|
|
|
223
223
|
if (index < 1) {
|
|
224
224
|
break;
|
|
225
225
|
}
|
|
226
|
-
if (item.params[index - 1].
|
|
226
|
+
if (item.params[index - 1].includes(".")) {
|
|
227
227
|
break;
|
|
228
228
|
}
|
|
229
229
|
default:
|
|
@@ -235,8 +235,8 @@ function cleanPath(path) {
|
|
|
235
235
|
});
|
|
236
236
|
return output;
|
|
237
237
|
}
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
function deOptimisePaths(svg) {
|
|
239
|
+
svg_parse.parseSVG(svg, (item) => {
|
|
240
240
|
if (item.tagName !== "path") {
|
|
241
241
|
return;
|
|
242
242
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SVG } from '../svg/index.cjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* De-optimise paths. Compressed paths are still not supported by some software.
|
|
8
|
+
*/
|
|
9
|
+
declare function deOptimisePaths(svg: SVG): void;
|
|
10
|
+
|
|
11
|
+
export { deOptimisePaths };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SVG } from '../svg/index.mjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* De-optimise paths. Compressed paths are still not supported by some software.
|
|
8
|
+
*/
|
|
9
|
+
declare function deOptimisePaths(svg: SVG): void;
|
|
10
|
+
|
|
11
|
+
export { deOptimisePaths };
|
package/lib/optimise/flags.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ import '@iconify/utils/lib/customisations/defaults';
|
|
|
6
6
|
/**
|
|
7
7
|
* De-optimise paths. Compressed paths are still not supported by some software.
|
|
8
8
|
*/
|
|
9
|
-
declare function deOptimisePaths(svg: SVG):
|
|
9
|
+
declare function deOptimisePaths(svg: SVG): void;
|
|
10
10
|
|
|
11
11
|
export { deOptimisePaths };
|
package/lib/optimise/flags.mjs
CHANGED
|
@@ -221,7 +221,7 @@ function cleanPath(path) {
|
|
|
221
221
|
if (index < 1) {
|
|
222
222
|
break;
|
|
223
223
|
}
|
|
224
|
-
if (item.params[index - 1].
|
|
224
|
+
if (item.params[index - 1].includes(".")) {
|
|
225
225
|
break;
|
|
226
226
|
}
|
|
227
227
|
default:
|
|
@@ -233,8 +233,8 @@ function cleanPath(path) {
|
|
|
233
233
|
});
|
|
234
234
|
return output;
|
|
235
235
|
}
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
function deOptimisePaths(svg) {
|
|
237
|
+
parseSVG(svg, (item) => {
|
|
238
238
|
if (item.tagName !== "path") {
|
|
239
239
|
return;
|
|
240
240
|
}
|
|
@@ -15,11 +15,11 @@ function getClassList(value) {
|
|
|
15
15
|
return value?.split(/\s+/);
|
|
16
16
|
}
|
|
17
17
|
const tempDataAttrbiute = "data-gstyle-temp";
|
|
18
|
-
|
|
18
|
+
function cleanupGlobalStyle(svg) {
|
|
19
19
|
const backup = svg.toString();
|
|
20
20
|
let containsTempAttr = false;
|
|
21
21
|
const animatedClasses = /* @__PURE__ */ new Set();
|
|
22
|
-
|
|
22
|
+
svg_parse.parseSVG(svg, (item) => {
|
|
23
23
|
if (!svg_data_tags.animateTags.has(item.tagName)) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
@@ -41,7 +41,7 @@ async function cleanupGlobalStyle(svg) {
|
|
|
41
41
|
});
|
|
42
42
|
const removeClasses = /* @__PURE__ */ new Set();
|
|
43
43
|
try {
|
|
44
|
-
|
|
44
|
+
svg_parseStyle.parseSVGStyle(svg, (styleItem) => {
|
|
45
45
|
const returnValue = styleItem.value;
|
|
46
46
|
if (styleItem.type !== "global") {
|
|
47
47
|
return returnValue;
|
|
@@ -93,7 +93,7 @@ async 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
|
}
|
|
@@ -101,7 +101,7 @@ async function cleanupGlobalStyle(svg) {
|
|
|
101
101
|
}
|
|
102
102
|
return false;
|
|
103
103
|
};
|
|
104
|
-
|
|
104
|
+
svg_parse.parseSVG(svg, (svgItem) => {
|
|
105
105
|
const tagName = svgItem.tagName;
|
|
106
106
|
const $element = svgItem.$element;
|
|
107
107
|
if (!isMatch(tagName, $element)) {
|
|
@@ -130,7 +130,7 @@ async function cleanupGlobalStyle(svg) {
|
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
});
|
|
133
|
-
|
|
133
|
+
svg_parse.parseSVG(svg, (svgItem) => {
|
|
134
134
|
const $element = svgItem.$element;
|
|
135
135
|
const classList = getClassList($element.attr("class"));
|
|
136
136
|
if (!classList) {
|
|
@@ -146,7 +146,7 @@ async function cleanupGlobalStyle(svg) {
|
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
148
|
if (containsTempAttr) {
|
|
149
|
-
|
|
149
|
+
svg_parse.parseSVG(svg, (item) => {
|
|
150
150
|
item.$element.removeAttr(tempDataAttrbiute);
|
|
151
151
|
});
|
|
152
152
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SVG } from '../svg/index.cjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Expand global style
|
|
8
|
+
*/
|
|
9
|
+
declare function cleanupGlobalStyle(svg: SVG): void;
|
|
10
|
+
|
|
11
|
+
export { cleanupGlobalStyle };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SVG } from '../svg/index.mjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Expand global style
|
|
8
|
+
*/
|
|
9
|
+
declare function cleanupGlobalStyle(svg: SVG): void;
|
|
10
|
+
|
|
11
|
+
export { cleanupGlobalStyle };
|
|
@@ -13,11 +13,11 @@ function getClassList(value) {
|
|
|
13
13
|
return value?.split(/\s+/);
|
|
14
14
|
}
|
|
15
15
|
const tempDataAttrbiute = "data-gstyle-temp";
|
|
16
|
-
|
|
16
|
+
function cleanupGlobalStyle(svg) {
|
|
17
17
|
const backup = svg.toString();
|
|
18
18
|
let containsTempAttr = false;
|
|
19
19
|
const animatedClasses = /* @__PURE__ */ new Set();
|
|
20
|
-
|
|
20
|
+
parseSVG(svg, (item) => {
|
|
21
21
|
if (!animateTags.has(item.tagName)) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
@@ -39,7 +39,7 @@ async function cleanupGlobalStyle(svg) {
|
|
|
39
39
|
});
|
|
40
40
|
const removeClasses = /* @__PURE__ */ new Set();
|
|
41
41
|
try {
|
|
42
|
-
|
|
42
|
+
parseSVGStyle(svg, (styleItem) => {
|
|
43
43
|
const returnValue = styleItem.value;
|
|
44
44
|
if (styleItem.type !== "global") {
|
|
45
45
|
return returnValue;
|
|
@@ -91,7 +91,7 @@ async 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
|
}
|
|
@@ -99,7 +99,7 @@ async function cleanupGlobalStyle(svg) {
|
|
|
99
99
|
}
|
|
100
100
|
return false;
|
|
101
101
|
};
|
|
102
|
-
|
|
102
|
+
parseSVG(svg, (svgItem) => {
|
|
103
103
|
const tagName = svgItem.tagName;
|
|
104
104
|
const $element = svgItem.$element;
|
|
105
105
|
if (!isMatch(tagName, $element)) {
|
|
@@ -128,7 +128,7 @@ async function cleanupGlobalStyle(svg) {
|
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
130
|
});
|
|
131
|
-
|
|
131
|
+
parseSVG(svg, (svgItem) => {
|
|
132
132
|
const $element = svgItem.$element;
|
|
133
133
|
const classList = getClassList($element.attr("class"));
|
|
134
134
|
if (!classList) {
|
|
@@ -144,7 +144,7 @@ async function cleanupGlobalStyle(svg) {
|
|
|
144
144
|
}
|
|
145
145
|
});
|
|
146
146
|
if (containsTempAttr) {
|
|
147
|
-
|
|
147
|
+
parseSVG(svg, (item) => {
|
|
148
148
|
item.$element.removeAttr(tempDataAttrbiute);
|
|
149
149
|
});
|
|
150
150
|
}
|
package/lib/optimise/mask.cjs
CHANGED
|
@@ -46,7 +46,7 @@ function convertSVGToMask(svg, options = {}) {
|
|
|
46
46
|
let failed = false;
|
|
47
47
|
let hasCustomValue = false;
|
|
48
48
|
const backup = svg.toString();
|
|
49
|
-
colors_parse.
|
|
49
|
+
colors_parse.parseColors(svg, {
|
|
50
50
|
callback: (attr, colorStr, color) => {
|
|
51
51
|
if (!color || colors_parse.isEmptyColor(color)) {
|
|
52
52
|
return colorStr;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Color } from '@iconify/utils/lib/colors/types';
|
|
2
|
+
import { SVG } from '../svg/index.cjs';
|
|
3
|
+
import 'cheerio';
|
|
4
|
+
import '@iconify/types';
|
|
5
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
6
|
+
|
|
7
|
+
type ColorCallback = (value: string, color: Color | null) => boolean;
|
|
8
|
+
type ColorCheck = string | string[] | ColorCallback;
|
|
9
|
+
interface SVGToMaskOptions {
|
|
10
|
+
color?: string;
|
|
11
|
+
solid?: ColorCheck;
|
|
12
|
+
transparent?: ColorCheck;
|
|
13
|
+
custom?: (value: string, color: Color | null) => string | number | undefined;
|
|
14
|
+
force?: boolean;
|
|
15
|
+
id?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Converts SVG to mask
|
|
19
|
+
*
|
|
20
|
+
* Fixes badly designed icons, which use white shape where icon supposed to be transparent
|
|
21
|
+
*/
|
|
22
|
+
declare function convertSVGToMask(svg: SVG, options?: SVGToMaskOptions): boolean;
|
|
23
|
+
|
|
24
|
+
export { convertSVGToMask };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Color } from '@iconify/utils/lib/colors/types';
|
|
2
|
+
import { SVG } from '../svg/index.mjs';
|
|
3
|
+
import 'cheerio';
|
|
4
|
+
import '@iconify/types';
|
|
5
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
6
|
+
|
|
7
|
+
type ColorCallback = (value: string, color: Color | null) => boolean;
|
|
8
|
+
type ColorCheck = string | string[] | ColorCallback;
|
|
9
|
+
interface SVGToMaskOptions {
|
|
10
|
+
color?: string;
|
|
11
|
+
solid?: ColorCheck;
|
|
12
|
+
transparent?: ColorCheck;
|
|
13
|
+
custom?: (value: string, color: Color | null) => string | number | undefined;
|
|
14
|
+
force?: boolean;
|
|
15
|
+
id?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Converts SVG to mask
|
|
19
|
+
*
|
|
20
|
+
* Fixes badly designed icons, which use white shape where icon supposed to be transparent
|
|
21
|
+
*/
|
|
22
|
+
declare function convertSVGToMask(svg: SVG, options?: SVGToMaskOptions): boolean;
|
|
23
|
+
|
|
24
|
+
export { convertSVGToMask };
|
package/lib/optimise/mask.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseColors, isEmptyColor } from '../colors/parse.mjs';
|
|
2
2
|
import { parseSVGContent, splitSVGDefs, iconToHTML } from '@iconify/utils';
|
|
3
3
|
import '@iconify/utils/lib/colors';
|
|
4
4
|
import '../svg/data/tags.mjs';
|
|
@@ -44,7 +44,7 @@ function convertSVGToMask(svg, options = {}) {
|
|
|
44
44
|
let failed = false;
|
|
45
45
|
let hasCustomValue = false;
|
|
46
46
|
const backup = svg.toString();
|
|
47
|
-
|
|
47
|
+
parseColors(svg, {
|
|
48
48
|
callback: (attr, colorStr, color) => {
|
|
49
49
|
if (!color || isEmptyColor(color)) {
|
|
50
50
|
return colorStr;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SVG } from '../svg/index.cjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reset origin to 0 0
|
|
8
|
+
*/
|
|
9
|
+
declare function resetSVGOrigin(svg: SVG): void;
|
|
10
|
+
|
|
11
|
+
export { resetSVGOrigin };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SVG } from '../svg/index.mjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reset origin to 0 0
|
|
8
|
+
*/
|
|
9
|
+
declare function resetSVGOrigin(svg: SVG): void;
|
|
10
|
+
|
|
11
|
+
export { resetSVGOrigin };
|