@iconify/tools 2.2.0-beta.4 → 2.2.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/parse.cjs +1 -0
- package/lib/colors/parse.mjs +1 -0
- package/lib/download/git/index.cjs +1 -0
- package/lib/download/git/index.mjs +1 -0
- package/lib/download/github/index.cjs +7 -1
- package/lib/download/github/index.mjs +7 -1
- package/lib/download/gitlab/index.cjs +7 -1
- package/lib/download/gitlab/index.mjs +7 -1
- package/lib/export/icon-package.cjs +1 -0
- package/lib/export/icon-package.mjs +1 -0
- package/lib/export/json-package.cjs +1 -0
- package/lib/export/json-package.mjs +1 -0
- package/lib/icon-set/index.cjs +90 -0
- package/lib/icon-set/index.mjs +90 -0
- package/lib/import/figma/index.cjs +5 -0
- package/lib/import/figma/index.mjs +5 -0
- package/lib/optimise/svgo.cjs +6 -1
- package/lib/optimise/svgo.mjs +6 -1
- package/lib/svg/cleanup/root-style.cjs +5 -1
- package/lib/svg/cleanup/root-style.mjs +5 -1
- package/lib/svg/cleanup/root-svg.cjs +6 -1
- package/lib/svg/cleanup/root-svg.mjs +6 -1
- package/lib/svg/cleanup/svgo-style.cjs +4 -1
- package/lib/svg/cleanup/svgo-style.mjs +4 -1
- package/lib/svg/data/attributes.cjs +17 -0
- package/lib/svg/data/attributes.mjs +17 -0
- package/lib/svg/data/tags.cjs +6 -0
- package/lib/svg/data/tags.mjs +6 -0
- package/lib/svg/index.cjs +20 -0
- package/lib/svg/index.mjs +20 -0
- package/license.txt +0 -0
- package/package.json +531 -533
package/lib/optimise/svgo.cjs
CHANGED
|
@@ -26,7 +26,9 @@ function getSVGOPlugins(options) {
|
|
|
26
26
|
"collapseGroups",
|
|
27
27
|
"sortDefsChildren",
|
|
28
28
|
"sortAttrs",
|
|
29
|
+
// Plugins that are bugged when using animations
|
|
29
30
|
...options.animated ? [] : ["removeUselessStrokeAndFill"],
|
|
31
|
+
// Plugins that modify shapes or are bugged when using animations
|
|
30
32
|
...options.animated || options.keepShapes ? [] : [
|
|
31
33
|
"removeHiddenElems",
|
|
32
34
|
"convertShapeToPath",
|
|
@@ -43,9 +45,12 @@ function getSVGOPlugins(options) {
|
|
|
43
45
|
noSpaceAfterFlags: true
|
|
44
46
|
}
|
|
45
47
|
},
|
|
48
|
+
// 'removeOffCanvasPaths', // bugged for some icons
|
|
46
49
|
"reusePaths"
|
|
47
50
|
],
|
|
48
|
-
|
|
51
|
+
// Clean up IDs, first run
|
|
52
|
+
// Sometimes bugs out on animated icons. Do not use with animations!
|
|
53
|
+
...!options.animated && options.cleanupIDs !== false ? ["cleanupIds"] : []
|
|
49
54
|
];
|
|
50
55
|
}
|
|
51
56
|
function runSVGO(svg, options = {}) {
|
package/lib/optimise/svgo.mjs
CHANGED
|
@@ -24,7 +24,9 @@ function getSVGOPlugins(options) {
|
|
|
24
24
|
"collapseGroups",
|
|
25
25
|
"sortDefsChildren",
|
|
26
26
|
"sortAttrs",
|
|
27
|
+
// Plugins that are bugged when using animations
|
|
27
28
|
...options.animated ? [] : ["removeUselessStrokeAndFill"],
|
|
29
|
+
// Plugins that modify shapes or are bugged when using animations
|
|
28
30
|
...options.animated || options.keepShapes ? [] : [
|
|
29
31
|
"removeHiddenElems",
|
|
30
32
|
"convertShapeToPath",
|
|
@@ -41,9 +43,12 @@ function getSVGOPlugins(options) {
|
|
|
41
43
|
noSpaceAfterFlags: true
|
|
42
44
|
}
|
|
43
45
|
},
|
|
46
|
+
// 'removeOffCanvasPaths', // bugged for some icons
|
|
44
47
|
"reusePaths"
|
|
45
48
|
],
|
|
46
|
-
|
|
49
|
+
// Clean up IDs, first run
|
|
50
|
+
// Sometimes bugs out on animated icons. Do not use with animations!
|
|
51
|
+
...!options.animated && options.cleanupIDs !== false ? ["cleanupIds"] : []
|
|
47
52
|
];
|
|
48
53
|
}
|
|
49
54
|
function runSVGO(svg, options = {}) {
|
|
@@ -12,7 +12,11 @@ require('../parse.cjs');
|
|
|
12
12
|
|
|
13
13
|
function cleanupRootStyle(svg) {
|
|
14
14
|
return svg_parseStyle.parseSVGStyle(svg, (item) => {
|
|
15
|
-
if (
|
|
15
|
+
if (
|
|
16
|
+
// If global style
|
|
17
|
+
item.type === "global" && // If selector tokens contain at-rule
|
|
18
|
+
item.selectorTokens.find((token) => token.type === "at-rule")
|
|
19
|
+
) {
|
|
16
20
|
return;
|
|
17
21
|
}
|
|
18
22
|
return item.value;
|
|
@@ -10,7 +10,11 @@ import '../parse.mjs';
|
|
|
10
10
|
|
|
11
11
|
function cleanupRootStyle(svg) {
|
|
12
12
|
return parseSVGStyle(svg, (item) => {
|
|
13
|
-
if (
|
|
13
|
+
if (
|
|
14
|
+
// If global style
|
|
15
|
+
item.type === "global" && // If selector tokens contain at-rule
|
|
16
|
+
item.selectorTokens.find((token) => token.type === "at-rule")
|
|
17
|
+
) {
|
|
14
18
|
return;
|
|
15
19
|
}
|
|
16
20
|
return item.value;
|
|
@@ -48,7 +48,12 @@ function cleanupSVGRoot(svg) {
|
|
|
48
48
|
}
|
|
49
49
|
throw new Error(`Unexpected attribute "${attr}" on <${tagName}>`);
|
|
50
50
|
}
|
|
51
|
-
if (
|
|
51
|
+
if (
|
|
52
|
+
// Events
|
|
53
|
+
attr.slice(0, 2) === "on" || // aria-stuff
|
|
54
|
+
attr.slice(0, 5) === "aria-" || // Junk
|
|
55
|
+
attr.slice(0, 6) === "xmlns:"
|
|
56
|
+
) {
|
|
52
57
|
$root.removeAttr(attr);
|
|
53
58
|
return;
|
|
54
59
|
}
|
|
@@ -46,7 +46,12 @@ function cleanupSVGRoot(svg) {
|
|
|
46
46
|
}
|
|
47
47
|
throw new Error(`Unexpected attribute "${attr}" on <${tagName}>`);
|
|
48
48
|
}
|
|
49
|
-
if (
|
|
49
|
+
if (
|
|
50
|
+
// Events
|
|
51
|
+
attr.slice(0, 2) === "on" || // aria-stuff
|
|
52
|
+
attr.slice(0, 5) === "aria-" || // Junk
|
|
53
|
+
attr.slice(0, 6) === "xmlns:"
|
|
54
|
+
) {
|
|
50
55
|
$root.removeAttr(attr);
|
|
51
56
|
return;
|
|
52
57
|
}
|
|
@@ -19,7 +19,10 @@ async function convertStyleToAttrs(svg) {
|
|
|
19
19
|
let hasStyle = false;
|
|
20
20
|
await svg_parseStyle.parseSVGStyle(svg, (item) => {
|
|
21
21
|
const prop = item.prop;
|
|
22
|
-
if (
|
|
22
|
+
if (
|
|
23
|
+
// Attributes / properties now allowed
|
|
24
|
+
svg_data_attributes.badAttributes.has(prop) || svg_data_attributes.badSoftwareAttributes.has(prop) || svg_data_attributes.badAttributePrefixes.has(prop.split("-").shift())
|
|
25
|
+
) {
|
|
23
26
|
return void 0;
|
|
24
27
|
}
|
|
25
28
|
hasStyle = true;
|
|
@@ -17,7 +17,10 @@ async function convertStyleToAttrs(svg) {
|
|
|
17
17
|
let hasStyle = false;
|
|
18
18
|
await parseSVGStyle(svg, (item) => {
|
|
19
19
|
const prop = item.prop;
|
|
20
|
-
if (
|
|
20
|
+
if (
|
|
21
|
+
// Attributes / properties now allowed
|
|
22
|
+
badAttributes.has(prop) || badSoftwareAttributes.has(prop) || badAttributePrefixes.has(prop.split("-").shift())
|
|
23
|
+
) {
|
|
21
24
|
return void 0;
|
|
22
25
|
}
|
|
23
26
|
hasStyle = true;
|
|
@@ -29,6 +29,7 @@ const badSoftwareAttributes = /* @__PURE__ */ new Set([
|
|
|
29
29
|
"overflow",
|
|
30
30
|
"marker",
|
|
31
31
|
"white-space",
|
|
32
|
+
// Font stuff
|
|
32
33
|
"direction"
|
|
33
34
|
]);
|
|
34
35
|
const badAttributePrefixes = /* @__PURE__ */ new Set([
|
|
@@ -37,6 +38,7 @@ const badAttributePrefixes = /* @__PURE__ */ new Set([
|
|
|
37
38
|
"block",
|
|
38
39
|
"data",
|
|
39
40
|
"aria",
|
|
41
|
+
// Font stuff
|
|
40
42
|
"text",
|
|
41
43
|
"font",
|
|
42
44
|
"letter",
|
|
@@ -44,6 +46,7 @@ const badAttributePrefixes = /* @__PURE__ */ new Set([
|
|
|
44
46
|
"word",
|
|
45
47
|
"line",
|
|
46
48
|
"writing",
|
|
49
|
+
// Prefix for browser specific stuff
|
|
47
50
|
""
|
|
48
51
|
]);
|
|
49
52
|
const commonAttributes = /* @__PURE__ */ new Set(["id"]);
|
|
@@ -155,12 +158,15 @@ const tagSpecificAnimatedAttributes = {
|
|
|
155
158
|
rect: /* @__PURE__ */ new Set(["x", "y", "width", "height", "rx", "ry"])
|
|
156
159
|
};
|
|
157
160
|
const tagSpecificPresentationalAttributes = {
|
|
161
|
+
// SVG
|
|
158
162
|
svg: /* @__PURE__ */ new Set(["width", "height", ...presentationalAttributes]),
|
|
163
|
+
// Defnitions, containers and masks
|
|
159
164
|
clipPath: /* @__PURE__ */ new Set([...presentationalAttributes]),
|
|
160
165
|
defs: /* @__PURE__ */ new Set([]),
|
|
161
166
|
g: /* @__PURE__ */ new Set([...presentationalAttributes]),
|
|
162
167
|
mask: /* @__PURE__ */ new Set(["x", "y", "width", "height", ...presentationalAttributes]),
|
|
163
168
|
symbol: /* @__PURE__ */ new Set(["x", "y", "width", "height", ...presentationalAttributes]),
|
|
169
|
+
// Use
|
|
164
170
|
use: /* @__PURE__ */ new Set([
|
|
165
171
|
"x",
|
|
166
172
|
"y",
|
|
@@ -170,7 +176,9 @@ const tagSpecificPresentationalAttributes = {
|
|
|
170
176
|
"refY",
|
|
171
177
|
...presentationalAttributes
|
|
172
178
|
]),
|
|
179
|
+
// Marker
|
|
173
180
|
marker: /* @__PURE__ */ new Set([...presentationalAttributes]),
|
|
181
|
+
// Gradients
|
|
174
182
|
linearGradient: /* @__PURE__ */ new Set([
|
|
175
183
|
"x1",
|
|
176
184
|
"x2",
|
|
@@ -188,6 +196,7 @@ const tagSpecificPresentationalAttributes = {
|
|
|
188
196
|
...presentationalAttributes
|
|
189
197
|
]),
|
|
190
198
|
stop: /* @__PURE__ */ new Set(["offset", "stop-color", "stop-opacity"]),
|
|
199
|
+
// Filters
|
|
191
200
|
feFlood: /* @__PURE__ */ new Set(["flood-color", "flood-opacity"]),
|
|
192
201
|
feDropShadow: /* @__PURE__ */ new Set(["flood-color", "flood-opacity"])
|
|
193
202
|
};
|
|
@@ -205,10 +214,13 @@ svg_data_tags.filterChildTags.forEach((tag) => {
|
|
|
205
214
|
]);
|
|
206
215
|
});
|
|
207
216
|
const tagSpecificNonPresentationalAttributes = {
|
|
217
|
+
// SVG
|
|
208
218
|
svg: /* @__PURE__ */ new Set(["xmlns", "viewBox", "preserveAspectRatio"]),
|
|
219
|
+
// Defnitions, containers and masks
|
|
209
220
|
clipPath: /* @__PURE__ */ new Set(["clipPathUnits"]),
|
|
210
221
|
mask: /* @__PURE__ */ new Set(["maskContentUnits", "maskUnits"]),
|
|
211
222
|
symbol: /* @__PURE__ */ new Set(["viewBox", "preserveAspectRatio"]),
|
|
223
|
+
// Shapes
|
|
212
224
|
circle: /* @__PURE__ */ new Set([...otherShapeAttributes]),
|
|
213
225
|
ellipse: /* @__PURE__ */ new Set([...otherShapeAttributes]),
|
|
214
226
|
line: /* @__PURE__ */ new Set([...otherShapeAttributes]),
|
|
@@ -216,7 +228,9 @@ const tagSpecificNonPresentationalAttributes = {
|
|
|
216
228
|
polygon: /* @__PURE__ */ new Set([...otherShapeAttributes]),
|
|
217
229
|
polyline: /* @__PURE__ */ new Set([...otherShapeAttributes]),
|
|
218
230
|
rect: /* @__PURE__ */ new Set([...otherShapeAttributes]),
|
|
231
|
+
// Use
|
|
219
232
|
use: /* @__PURE__ */ new Set(["href"]),
|
|
233
|
+
// Marker
|
|
220
234
|
marker: /* @__PURE__ */ new Set([
|
|
221
235
|
"markerHeight",
|
|
222
236
|
"markerUnits",
|
|
@@ -227,6 +241,7 @@ const tagSpecificNonPresentationalAttributes = {
|
|
|
227
241
|
"refY",
|
|
228
242
|
"viewBox"
|
|
229
243
|
]),
|
|
244
|
+
// Animations
|
|
230
245
|
animate: /* @__PURE__ */ new Set([
|
|
231
246
|
...animationTimingAttributes,
|
|
232
247
|
...animationValueAttributes,
|
|
@@ -256,8 +271,10 @@ const tagSpecificNonPresentationalAttributes = {
|
|
|
256
271
|
...otherAnimationAttributes
|
|
257
272
|
]),
|
|
258
273
|
mpath: /* @__PURE__ */ new Set(["href"]),
|
|
274
|
+
// Gradients
|
|
259
275
|
linearGradient: /* @__PURE__ */ new Set([...commonGradientAttributes]),
|
|
260
276
|
radialGradient: /* @__PURE__ */ new Set([...commonGradientAttributes]),
|
|
277
|
+
// Filters
|
|
261
278
|
feSpotLight: /* @__PURE__ */ new Set([
|
|
262
279
|
"x",
|
|
263
280
|
"y",
|
|
@@ -27,6 +27,7 @@ const badSoftwareAttributes = /* @__PURE__ */ new Set([
|
|
|
27
27
|
"overflow",
|
|
28
28
|
"marker",
|
|
29
29
|
"white-space",
|
|
30
|
+
// Font stuff
|
|
30
31
|
"direction"
|
|
31
32
|
]);
|
|
32
33
|
const badAttributePrefixes = /* @__PURE__ */ new Set([
|
|
@@ -35,6 +36,7 @@ const badAttributePrefixes = /* @__PURE__ */ new Set([
|
|
|
35
36
|
"block",
|
|
36
37
|
"data",
|
|
37
38
|
"aria",
|
|
39
|
+
// Font stuff
|
|
38
40
|
"text",
|
|
39
41
|
"font",
|
|
40
42
|
"letter",
|
|
@@ -42,6 +44,7 @@ const badAttributePrefixes = /* @__PURE__ */ new Set([
|
|
|
42
44
|
"word",
|
|
43
45
|
"line",
|
|
44
46
|
"writing",
|
|
47
|
+
// Prefix for browser specific stuff
|
|
45
48
|
""
|
|
46
49
|
]);
|
|
47
50
|
const commonAttributes = /* @__PURE__ */ new Set(["id"]);
|
|
@@ -153,12 +156,15 @@ const tagSpecificAnimatedAttributes = {
|
|
|
153
156
|
rect: /* @__PURE__ */ new Set(["x", "y", "width", "height", "rx", "ry"])
|
|
154
157
|
};
|
|
155
158
|
const tagSpecificPresentationalAttributes = {
|
|
159
|
+
// SVG
|
|
156
160
|
svg: /* @__PURE__ */ new Set(["width", "height", ...presentationalAttributes]),
|
|
161
|
+
// Defnitions, containers and masks
|
|
157
162
|
clipPath: /* @__PURE__ */ new Set([...presentationalAttributes]),
|
|
158
163
|
defs: /* @__PURE__ */ new Set([]),
|
|
159
164
|
g: /* @__PURE__ */ new Set([...presentationalAttributes]),
|
|
160
165
|
mask: /* @__PURE__ */ new Set(["x", "y", "width", "height", ...presentationalAttributes]),
|
|
161
166
|
symbol: /* @__PURE__ */ new Set(["x", "y", "width", "height", ...presentationalAttributes]),
|
|
167
|
+
// Use
|
|
162
168
|
use: /* @__PURE__ */ new Set([
|
|
163
169
|
"x",
|
|
164
170
|
"y",
|
|
@@ -168,7 +174,9 @@ const tagSpecificPresentationalAttributes = {
|
|
|
168
174
|
"refY",
|
|
169
175
|
...presentationalAttributes
|
|
170
176
|
]),
|
|
177
|
+
// Marker
|
|
171
178
|
marker: /* @__PURE__ */ new Set([...presentationalAttributes]),
|
|
179
|
+
// Gradients
|
|
172
180
|
linearGradient: /* @__PURE__ */ new Set([
|
|
173
181
|
"x1",
|
|
174
182
|
"x2",
|
|
@@ -186,6 +194,7 @@ const tagSpecificPresentationalAttributes = {
|
|
|
186
194
|
...presentationalAttributes
|
|
187
195
|
]),
|
|
188
196
|
stop: /* @__PURE__ */ new Set(["offset", "stop-color", "stop-opacity"]),
|
|
197
|
+
// Filters
|
|
189
198
|
feFlood: /* @__PURE__ */ new Set(["flood-color", "flood-opacity"]),
|
|
190
199
|
feDropShadow: /* @__PURE__ */ new Set(["flood-color", "flood-opacity"])
|
|
191
200
|
};
|
|
@@ -203,10 +212,13 @@ filterChildTags.forEach((tag) => {
|
|
|
203
212
|
]);
|
|
204
213
|
});
|
|
205
214
|
const tagSpecificNonPresentationalAttributes = {
|
|
215
|
+
// SVG
|
|
206
216
|
svg: /* @__PURE__ */ new Set(["xmlns", "viewBox", "preserveAspectRatio"]),
|
|
217
|
+
// Defnitions, containers and masks
|
|
207
218
|
clipPath: /* @__PURE__ */ new Set(["clipPathUnits"]),
|
|
208
219
|
mask: /* @__PURE__ */ new Set(["maskContentUnits", "maskUnits"]),
|
|
209
220
|
symbol: /* @__PURE__ */ new Set(["viewBox", "preserveAspectRatio"]),
|
|
221
|
+
// Shapes
|
|
210
222
|
circle: /* @__PURE__ */ new Set([...otherShapeAttributes]),
|
|
211
223
|
ellipse: /* @__PURE__ */ new Set([...otherShapeAttributes]),
|
|
212
224
|
line: /* @__PURE__ */ new Set([...otherShapeAttributes]),
|
|
@@ -214,7 +226,9 @@ const tagSpecificNonPresentationalAttributes = {
|
|
|
214
226
|
polygon: /* @__PURE__ */ new Set([...otherShapeAttributes]),
|
|
215
227
|
polyline: /* @__PURE__ */ new Set([...otherShapeAttributes]),
|
|
216
228
|
rect: /* @__PURE__ */ new Set([...otherShapeAttributes]),
|
|
229
|
+
// Use
|
|
217
230
|
use: /* @__PURE__ */ new Set(["href"]),
|
|
231
|
+
// Marker
|
|
218
232
|
marker: /* @__PURE__ */ new Set([
|
|
219
233
|
"markerHeight",
|
|
220
234
|
"markerUnits",
|
|
@@ -225,6 +239,7 @@ const tagSpecificNonPresentationalAttributes = {
|
|
|
225
239
|
"refY",
|
|
226
240
|
"viewBox"
|
|
227
241
|
]),
|
|
242
|
+
// Animations
|
|
228
243
|
animate: /* @__PURE__ */ new Set([
|
|
229
244
|
...animationTimingAttributes,
|
|
230
245
|
...animationValueAttributes,
|
|
@@ -254,8 +269,10 @@ const tagSpecificNonPresentationalAttributes = {
|
|
|
254
269
|
...otherAnimationAttributes
|
|
255
270
|
]),
|
|
256
271
|
mpath: /* @__PURE__ */ new Set(["href"]),
|
|
272
|
+
// Gradients
|
|
257
273
|
linearGradient: /* @__PURE__ */ new Set([...commonGradientAttributes]),
|
|
258
274
|
radialGradient: /* @__PURE__ */ new Set([...commonGradientAttributes]),
|
|
275
|
+
// Filters
|
|
259
276
|
feSpotLight: /* @__PURE__ */ new Set([
|
|
260
277
|
"x",
|
|
261
278
|
"y",
|
package/lib/svg/data/tags.cjs
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const badTags = /* @__PURE__ */ new Set([
|
|
4
|
+
// Nasty stuff or external resource
|
|
4
5
|
"foreignObject",
|
|
5
6
|
"script",
|
|
6
7
|
"image",
|
|
7
8
|
"feImage",
|
|
9
|
+
// Deprecated
|
|
8
10
|
"animateColor",
|
|
9
11
|
"altGlyph",
|
|
12
|
+
// Text
|
|
10
13
|
"text",
|
|
11
14
|
"tspan",
|
|
12
15
|
"switch",
|
|
13
16
|
"textPath",
|
|
17
|
+
// Font
|
|
14
18
|
"font",
|
|
15
19
|
"font-face",
|
|
16
20
|
"glyph",
|
|
17
21
|
"missing-glyph",
|
|
18
22
|
"hkern",
|
|
19
23
|
"vhern",
|
|
24
|
+
// View
|
|
20
25
|
"view",
|
|
26
|
+
// Link
|
|
21
27
|
"a"
|
|
22
28
|
]);
|
|
23
29
|
const unsupportedTags = /* @__PURE__ */ new Set(["metadata", "desc", "title"]);
|
package/lib/svg/data/tags.mjs
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
const badTags = /* @__PURE__ */ new Set([
|
|
2
|
+
// Nasty stuff or external resource
|
|
2
3
|
"foreignObject",
|
|
3
4
|
"script",
|
|
4
5
|
"image",
|
|
5
6
|
"feImage",
|
|
7
|
+
// Deprecated
|
|
6
8
|
"animateColor",
|
|
7
9
|
"altGlyph",
|
|
10
|
+
// Text
|
|
8
11
|
"text",
|
|
9
12
|
"tspan",
|
|
10
13
|
"switch",
|
|
11
14
|
"textPath",
|
|
15
|
+
// Font
|
|
12
16
|
"font",
|
|
13
17
|
"font-face",
|
|
14
18
|
"glyph",
|
|
15
19
|
"missing-glyph",
|
|
16
20
|
"hkern",
|
|
17
21
|
"vhern",
|
|
22
|
+
// View
|
|
18
23
|
"view",
|
|
24
|
+
// Link
|
|
19
25
|
"a"
|
|
20
26
|
]);
|
|
21
27
|
const unsupportedTags = /* @__PURE__ */ new Set(["metadata", "desc", "title"]);
|
package/lib/svg/index.cjs
CHANGED
|
@@ -4,9 +4,15 @@ const cheerio = require('cheerio');
|
|
|
4
4
|
const utils = require('@iconify/utils');
|
|
5
5
|
|
|
6
6
|
class SVG {
|
|
7
|
+
/**
|
|
8
|
+
* Constructor
|
|
9
|
+
*/
|
|
7
10
|
constructor(content) {
|
|
8
11
|
this.load(content);
|
|
9
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Get SVG as string
|
|
15
|
+
*/
|
|
10
16
|
toString(customisations) {
|
|
11
17
|
if (customisations) {
|
|
12
18
|
const data = utils.iconToSVG(this.getIcon(), customisations);
|
|
@@ -36,9 +42,15 @@ class SVG {
|
|
|
36
42
|
}
|
|
37
43
|
return this.$svg.html();
|
|
38
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Get SVG as string without whitespaces
|
|
47
|
+
*/
|
|
39
48
|
toMinifiedString(customisations) {
|
|
40
49
|
return utils.trimSVG(this.toString(customisations));
|
|
41
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Get body
|
|
53
|
+
*/
|
|
42
54
|
getBody() {
|
|
43
55
|
const $root = this.$svg(":root");
|
|
44
56
|
const attribs = $root.get(0).attribs;
|
|
@@ -54,6 +66,9 @@ class SVG {
|
|
|
54
66
|
}
|
|
55
67
|
return utils.trimSVG(this.$svg("svg").html());
|
|
56
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Get icon as IconifyIcon
|
|
71
|
+
*/
|
|
57
72
|
getIcon() {
|
|
58
73
|
const props = this.viewBox;
|
|
59
74
|
const body = this.getBody();
|
|
@@ -62,6 +77,11 @@ class SVG {
|
|
|
62
77
|
body
|
|
63
78
|
};
|
|
64
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Load SVG
|
|
82
|
+
*
|
|
83
|
+
* @param {string} content
|
|
84
|
+
*/
|
|
65
85
|
load(content) {
|
|
66
86
|
function remove(str1, str2, append) {
|
|
67
87
|
let start = 0;
|
package/lib/svg/index.mjs
CHANGED
|
@@ -2,9 +2,15 @@ import cheerio from 'cheerio';
|
|
|
2
2
|
import { iconToSVG, trimSVG } from '@iconify/utils';
|
|
3
3
|
|
|
4
4
|
class SVG {
|
|
5
|
+
/**
|
|
6
|
+
* Constructor
|
|
7
|
+
*/
|
|
5
8
|
constructor(content) {
|
|
6
9
|
this.load(content);
|
|
7
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Get SVG as string
|
|
13
|
+
*/
|
|
8
14
|
toString(customisations) {
|
|
9
15
|
if (customisations) {
|
|
10
16
|
const data = iconToSVG(this.getIcon(), customisations);
|
|
@@ -34,9 +40,15 @@ class SVG {
|
|
|
34
40
|
}
|
|
35
41
|
return this.$svg.html();
|
|
36
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Get SVG as string without whitespaces
|
|
45
|
+
*/
|
|
37
46
|
toMinifiedString(customisations) {
|
|
38
47
|
return trimSVG(this.toString(customisations));
|
|
39
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Get body
|
|
51
|
+
*/
|
|
40
52
|
getBody() {
|
|
41
53
|
const $root = this.$svg(":root");
|
|
42
54
|
const attribs = $root.get(0).attribs;
|
|
@@ -52,6 +64,9 @@ class SVG {
|
|
|
52
64
|
}
|
|
53
65
|
return trimSVG(this.$svg("svg").html());
|
|
54
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Get icon as IconifyIcon
|
|
69
|
+
*/
|
|
55
70
|
getIcon() {
|
|
56
71
|
const props = this.viewBox;
|
|
57
72
|
const body = this.getBody();
|
|
@@ -60,6 +75,11 @@ class SVG {
|
|
|
60
75
|
body
|
|
61
76
|
};
|
|
62
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Load SVG
|
|
80
|
+
*
|
|
81
|
+
* @param {string} content
|
|
82
|
+
*/
|
|
63
83
|
load(content) {
|
|
64
84
|
function remove(str1, str2, append) {
|
|
65
85
|
let start = 0;
|
package/license.txt
CHANGED
|
File without changes
|