@iconify/tools 2.1.0-beta.5 → 2.1.0-beta.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/import/directory.cjs +3 -2
- package/lib/import/directory.mjs +3 -2
- package/lib/import/figma/index.cjs +3 -2
- package/lib/import/figma/index.mjs +3 -2
- package/lib/index.cjs +2 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.mjs +1 -0
- package/lib/svg/cleanup/root-style.cjs +24 -0
- package/lib/svg/cleanup/root-style.d.ts +16 -0
- package/lib/svg/cleanup/root-style.mjs +20 -0
- package/lib/svg/cleanup/root-svg.cjs +2 -2
- package/lib/svg/cleanup/root-svg.d.ts +1 -1
- package/lib/svg/cleanup/root-svg.mjs +2 -2
- package/lib/svg/cleanup.cjs +3 -1
- package/lib/svg/cleanup.mjs +3 -1
- package/lib/svg/parse-style.cjs +1 -1
- package/lib/svg/parse-style.mjs +1 -1
- package/package.json +5 -1
package/lib/import/directory.cjs
CHANGED
|
@@ -27,11 +27,12 @@ require('../css/parser/tokens.cjs');
|
|
|
27
27
|
require('../css/parser/error.cjs');
|
|
28
28
|
require('../css/parser/strings.cjs');
|
|
29
29
|
require('../css/parser/text.cjs');
|
|
30
|
-
require('../svg/cleanup/root-
|
|
31
|
-
require('../svg/cleanup/svgo-style.cjs');
|
|
30
|
+
require('../svg/cleanup/root-style.cjs');
|
|
32
31
|
require('../svg/parse-style.cjs');
|
|
33
32
|
require('../css/parser/export.cjs');
|
|
34
33
|
require('../css/parser/tree.cjs');
|
|
34
|
+
require('../svg/cleanup/root-svg.cjs');
|
|
35
|
+
require('../svg/cleanup/svgo-style.cjs');
|
|
35
36
|
require('../optimise/svgo.cjs');
|
|
36
37
|
require('svgo');
|
|
37
38
|
|
package/lib/import/directory.mjs
CHANGED
|
@@ -23,11 +23,12 @@ import '../css/parser/tokens.mjs';
|
|
|
23
23
|
import '../css/parser/error.mjs';
|
|
24
24
|
import '../css/parser/strings.mjs';
|
|
25
25
|
import '../css/parser/text.mjs';
|
|
26
|
-
import '../svg/cleanup/root-
|
|
27
|
-
import '../svg/cleanup/svgo-style.mjs';
|
|
26
|
+
import '../svg/cleanup/root-style.mjs';
|
|
28
27
|
import '../svg/parse-style.mjs';
|
|
29
28
|
import '../css/parser/export.mjs';
|
|
30
29
|
import '../css/parser/tree.mjs';
|
|
30
|
+
import '../svg/cleanup/root-svg.mjs';
|
|
31
|
+
import '../svg/cleanup/svgo-style.mjs';
|
|
31
32
|
import '../optimise/svgo.mjs';
|
|
32
33
|
import 'svgo';
|
|
33
34
|
|
|
@@ -26,11 +26,12 @@ require('../../css/parser/tokens.cjs');
|
|
|
26
26
|
require('../../css/parser/error.cjs');
|
|
27
27
|
require('../../css/parser/strings.cjs');
|
|
28
28
|
require('../../css/parser/text.cjs');
|
|
29
|
-
require('../../svg/cleanup/root-
|
|
30
|
-
require('../../svg/cleanup/svgo-style.cjs');
|
|
29
|
+
require('../../svg/cleanup/root-style.cjs');
|
|
31
30
|
require('../../svg/parse-style.cjs');
|
|
32
31
|
require('../../css/parser/export.cjs');
|
|
33
32
|
require('../../css/parser/tree.cjs');
|
|
33
|
+
require('../../svg/cleanup/root-svg.cjs');
|
|
34
|
+
require('../../svg/cleanup/svgo-style.cjs');
|
|
34
35
|
require('../../optimise/svgo.cjs');
|
|
35
36
|
require('svgo');
|
|
36
37
|
require('../../download/api/index.cjs');
|
|
@@ -22,11 +22,12 @@ import '../../css/parser/tokens.mjs';
|
|
|
22
22
|
import '../../css/parser/error.mjs';
|
|
23
23
|
import '../../css/parser/strings.mjs';
|
|
24
24
|
import '../../css/parser/text.mjs';
|
|
25
|
-
import '../../svg/cleanup/root-
|
|
26
|
-
import '../../svg/cleanup/svgo-style.mjs';
|
|
25
|
+
import '../../svg/cleanup/root-style.mjs';
|
|
27
26
|
import '../../svg/parse-style.mjs';
|
|
28
27
|
import '../../css/parser/export.mjs';
|
|
29
28
|
import '../../css/parser/tree.mjs';
|
|
29
|
+
import '../../svg/cleanup/root-svg.mjs';
|
|
30
|
+
import '../../svg/cleanup/svgo-style.mjs';
|
|
30
31
|
import '../../optimise/svgo.mjs';
|
|
31
32
|
import 'svgo';
|
|
32
33
|
import '../../download/api/index.mjs';
|
package/lib/index.cjs
CHANGED
|
@@ -9,6 +9,7 @@ const svg_analyse = require('./svg/analyse.cjs');
|
|
|
9
9
|
const svg_cleanup = require('./svg/cleanup.cjs');
|
|
10
10
|
const svg_cleanup_attribs = require('./svg/cleanup/attribs.cjs');
|
|
11
11
|
const svg_cleanup_badTags = require('./svg/cleanup/bad-tags.cjs');
|
|
12
|
+
const svg_cleanup_rootStyle = require('./svg/cleanup/root-style.cjs');
|
|
12
13
|
const svg_cleanup_inlineStyle = require('./svg/cleanup/inline-style.cjs');
|
|
13
14
|
const svg_cleanup_rootSvg = require('./svg/cleanup/root-svg.cjs');
|
|
14
15
|
const svg_cleanup_svgoStyle = require('./svg/cleanup/svgo-style.cjs');
|
|
@@ -95,6 +96,7 @@ exports.analyseSVGStructure = svg_analyse.analyseSVGStructure;
|
|
|
95
96
|
exports.cleanupSVG = svg_cleanup.cleanupSVG;
|
|
96
97
|
exports.removeBadAttributes = svg_cleanup_attribs.removeBadAttributes;
|
|
97
98
|
exports.checkBadTags = svg_cleanup_badTags.checkBadTags;
|
|
99
|
+
exports.cleanupRootStyle = svg_cleanup_rootStyle.cleanupRootStyle;
|
|
98
100
|
exports.cleanupInlineStyle = svg_cleanup_inlineStyle.cleanupInlineStyle;
|
|
99
101
|
exports.cleanupSVGRoot = svg_cleanup_rootSvg.cleanupSVGRoot;
|
|
100
102
|
exports.convertStyleToAttrs = svg_cleanup_svgoStyle.convertStyleToAttrs;
|
package/lib/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { analyseSVGStructure } from './svg/analyse.js';
|
|
|
5
5
|
export { cleanupSVG } from './svg/cleanup.js';
|
|
6
6
|
export { removeBadAttributes } from './svg/cleanup/attribs.js';
|
|
7
7
|
export { checkBadTags } from './svg/cleanup/bad-tags.js';
|
|
8
|
+
export { cleanupRootStyle } from './svg/cleanup/root-style.js';
|
|
8
9
|
export { cleanupInlineStyle } from './svg/cleanup/inline-style.js';
|
|
9
10
|
export { cleanupSVGRoot } from './svg/cleanup/root-svg.js';
|
|
10
11
|
export { convertStyleToAttrs } from './svg/cleanup/svgo-style.js';
|
package/lib/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ export { analyseSVGStructure } from './svg/analyse.mjs';
|
|
|
5
5
|
export { cleanupSVG } from './svg/cleanup.mjs';
|
|
6
6
|
export { removeBadAttributes } from './svg/cleanup/attribs.mjs';
|
|
7
7
|
export { checkBadTags } from './svg/cleanup/bad-tags.mjs';
|
|
8
|
+
export { cleanupRootStyle } from './svg/cleanup/root-style.mjs';
|
|
8
9
|
export { cleanupInlineStyle } from './svg/cleanup/inline-style.mjs';
|
|
9
10
|
export { cleanupSVGRoot } from './svg/cleanup/root-svg.mjs';
|
|
10
11
|
export { convertStyleToAttrs } from './svg/cleanup/svgo-style.mjs';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const svg_parseStyle = require('../parse-style.cjs');
|
|
6
|
+
require('../../css/parse.cjs');
|
|
7
|
+
require('../../css/parser/tokens.cjs');
|
|
8
|
+
require('../../css/parser/error.cjs');
|
|
9
|
+
require('../../css/parser/strings.cjs');
|
|
10
|
+
require('../../css/parser/text.cjs');
|
|
11
|
+
require('../../css/parser/export.cjs');
|
|
12
|
+
require('../../css/parser/tree.cjs');
|
|
13
|
+
require('../parse.cjs');
|
|
14
|
+
|
|
15
|
+
function cleanupRootStyle(svg) {
|
|
16
|
+
return svg_parseStyle.parseSVGStyle(svg, (item) => {
|
|
17
|
+
if (item.type === "global" && item.selectorTokens.find((token) => token.type === "at-rule")) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
return item.value;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.cleanupRootStyle = cleanupRootStyle;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SVG } from '../index.js';
|
|
2
|
+
import { parseSVGStyle } from '../parse-style.js';
|
|
3
|
+
import '../../types-f0980297.js';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
import '../../css/parser/types.js';
|
|
6
|
+
import '../parse.js';
|
|
7
|
+
import '../../misc/cheerio.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Clean up root style
|
|
11
|
+
*
|
|
12
|
+
* This function removes all at-rule tokens, such as `@font-face`, `@media`
|
|
13
|
+
*/
|
|
14
|
+
declare function cleanupRootStyle(svg: SVG): ReturnType<typeof parseSVGStyle>;
|
|
15
|
+
|
|
16
|
+
export { cleanupRootStyle };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parseSVGStyle } from '../parse-style.mjs';
|
|
2
|
+
import '../../css/parse.mjs';
|
|
3
|
+
import '../../css/parser/tokens.mjs';
|
|
4
|
+
import '../../css/parser/error.mjs';
|
|
5
|
+
import '../../css/parser/strings.mjs';
|
|
6
|
+
import '../../css/parser/text.mjs';
|
|
7
|
+
import '../../css/parser/export.mjs';
|
|
8
|
+
import '../../css/parser/tree.mjs';
|
|
9
|
+
import '../parse.mjs';
|
|
10
|
+
|
|
11
|
+
function cleanupRootStyle(svg) {
|
|
12
|
+
return parseSVGStyle(svg, (item) => {
|
|
13
|
+
if (item.type === "global" && item.selectorTokens.find((token) => token.type === "at-rule")) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return item.value;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { cleanupRootStyle };
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const svg_data_attributes = require('../data/attributes.cjs');
|
|
6
6
|
const svg_data_tags = require('../data/tags.cjs');
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
function cleanupSVGRoot(svg) {
|
|
9
9
|
const cheerio = svg.$svg;
|
|
10
10
|
const $root = svg.$svg(":root");
|
|
11
11
|
const root = $root.get(0);
|
|
@@ -26,7 +26,7 @@ async function cleanupSVGRoot(svg) {
|
|
|
26
26
|
case "height":
|
|
27
27
|
if (value.slice(-2) === "px") {
|
|
28
28
|
const num = value.replace("px", "");
|
|
29
|
-
if (parseFloat(num)
|
|
29
|
+
if (parseFloat(num).toString() === num) {
|
|
30
30
|
$root.attr(attr, num);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { commonAttributes, badAttributes, junkSVGAttributes, badSoftwareAttributes, badAttributePrefixes, tagSpecificNonPresentationalAttributes, tagSpecificPresentationalAttributes, stylingAttributes } from '../data/attributes.mjs';
|
|
2
2
|
import { reusableElementsWithPalette, maskTags } from '../data/tags.mjs';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
function cleanupSVGRoot(svg) {
|
|
5
5
|
const cheerio = svg.$svg;
|
|
6
6
|
const $root = svg.$svg(":root");
|
|
7
7
|
const root = $root.get(0);
|
|
@@ -22,7 +22,7 @@ async function cleanupSVGRoot(svg) {
|
|
|
22
22
|
case "height":
|
|
23
23
|
if (value.slice(-2) === "px") {
|
|
24
24
|
const num = value.replace("px", "");
|
|
25
|
-
if (parseFloat(num)
|
|
25
|
+
if (parseFloat(num).toString() === num) {
|
|
26
26
|
$root.attr(attr, num);
|
|
27
27
|
}
|
|
28
28
|
}
|
package/lib/svg/cleanup.cjs
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const svg_cleanup_attribs = require('./cleanup/attribs.cjs');
|
|
6
6
|
const svg_cleanup_badTags = require('./cleanup/bad-tags.cjs');
|
|
7
7
|
const svg_cleanup_inlineStyle = require('./cleanup/inline-style.cjs');
|
|
8
|
+
const svg_cleanup_rootStyle = require('./cleanup/root-style.cjs');
|
|
8
9
|
const svg_cleanup_rootSvg = require('./cleanup/root-svg.cjs');
|
|
9
10
|
const svg_cleanup_svgoStyle = require('./cleanup/svgo-style.cjs');
|
|
10
11
|
require('./data/attributes.cjs');
|
|
@@ -24,9 +25,10 @@ require('svgo');
|
|
|
24
25
|
async function cleanupSVG(svg) {
|
|
25
26
|
await svg_cleanup_inlineStyle.cleanupInlineStyle(svg);
|
|
26
27
|
await svg_cleanup_svgoStyle.convertStyleToAttrs(svg);
|
|
27
|
-
|
|
28
|
+
svg_cleanup_rootSvg.cleanupSVGRoot(svg);
|
|
28
29
|
await svg_cleanup_badTags.checkBadTags(svg);
|
|
29
30
|
await svg_cleanup_attribs.removeBadAttributes(svg);
|
|
31
|
+
await svg_cleanup_rootStyle.cleanupRootStyle(svg);
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
exports.cleanupSVG = cleanupSVG;
|
package/lib/svg/cleanup.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { removeBadAttributes } from './cleanup/attribs.mjs';
|
|
2
2
|
import { checkBadTags } from './cleanup/bad-tags.mjs';
|
|
3
3
|
import { cleanupInlineStyle } from './cleanup/inline-style.mjs';
|
|
4
|
+
import { cleanupRootStyle } from './cleanup/root-style.mjs';
|
|
4
5
|
import { cleanupSVGRoot } from './cleanup/root-svg.mjs';
|
|
5
6
|
import { convertStyleToAttrs } from './cleanup/svgo-style.mjs';
|
|
6
7
|
import './data/attributes.mjs';
|
|
@@ -20,9 +21,10 @@ import 'svgo';
|
|
|
20
21
|
async function cleanupSVG(svg) {
|
|
21
22
|
await cleanupInlineStyle(svg);
|
|
22
23
|
await convertStyleToAttrs(svg);
|
|
23
|
-
|
|
24
|
+
cleanupSVGRoot(svg);
|
|
24
25
|
await checkBadTags(svg);
|
|
25
26
|
await removeBadAttributes(svg);
|
|
27
|
+
await cleanupRootStyle(svg);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export { cleanupSVG };
|
package/lib/svg/parse-style.cjs
CHANGED
|
@@ -16,7 +16,7 @@ async function parseSVGStyle(svg, callback) {
|
|
|
16
16
|
const tagName = item.tagName;
|
|
17
17
|
const $element = item.$element;
|
|
18
18
|
if (tagName === "style") {
|
|
19
|
-
const content = $element.
|
|
19
|
+
const content = $element.text();
|
|
20
20
|
if (typeof content !== "string") {
|
|
21
21
|
$element.remove();
|
|
22
22
|
return;
|
package/lib/svg/parse-style.mjs
CHANGED
|
@@ -12,7 +12,7 @@ async function parseSVGStyle(svg, callback) {
|
|
|
12
12
|
const tagName = item.tagName;
|
|
13
13
|
const $element = item.$element;
|
|
14
14
|
if (tagName === "style") {
|
|
15
|
-
const content = $element.
|
|
15
|
+
const content = $element.text();
|
|
16
16
|
if (typeof content !== "string") {
|
|
17
17
|
$element.remove();
|
|
18
18
|
return;
|
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.1.0-beta.
|
|
6
|
+
"version": "2.1.0-beta.6",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"bugs": "https://github.com/iconify/tools/issues",
|
|
9
9
|
"homepage": "https://github.com/iconify/tools",
|
|
@@ -368,6 +368,10 @@
|
|
|
368
368
|
"require": "./lib/svg/cleanup/inline-style.cjs",
|
|
369
369
|
"import": "./lib/svg/cleanup/inline-style.mjs"
|
|
370
370
|
},
|
|
371
|
+
"./lib/svg/cleanup/root-style": {
|
|
372
|
+
"require": "./lib/svg/cleanup/root-style.cjs",
|
|
373
|
+
"import": "./lib/svg/cleanup/root-style.mjs"
|
|
374
|
+
},
|
|
371
375
|
"./lib/svg/cleanup/root-svg": {
|
|
372
376
|
"require": "./lib/svg/cleanup/root-svg.cjs",
|
|
373
377
|
"import": "./lib/svg/cleanup/root-svg.mjs"
|