@iconify/tools 4.0.0-dev.1 → 4.0.0
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 +14 -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 +13 -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 +1 -1
- package/lib/misc/write-json.d.cts +6 -0
- package/lib/misc/write-json.d.mts +6 -0
- package/lib/optimise/figma.cjs +5 -5
- package/lib/optimise/figma.d.cts +11 -0
- package/lib/optimise/figma.d.mts +11 -0
- package/lib/optimise/figma.mjs +5 -5
- 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/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 +26 -21
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { badAttributes, badSoftwareAttributes, badAttributePrefixes } from '../data/attributes.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { parseSVGStyle } from '../parse-style.mjs';
|
|
3
3
|
import { runSVGO } from '../../optimise/svgo.mjs';
|
|
4
4
|
import '../data/tags.mjs';
|
|
5
5
|
import '../../css/parse.mjs';
|
|
@@ -15,7 +15,7 @@ import '@iconify/utils/lib/svg/id';
|
|
|
15
15
|
|
|
16
16
|
function convertStyleToAttrs(svg) {
|
|
17
17
|
let hasStyle = false;
|
|
18
|
-
|
|
18
|
+
parseSVGStyle(svg, (item) => {
|
|
19
19
|
if (item.type !== "inline" && item.type !== "global") {
|
|
20
20
|
return item.value;
|
|
21
21
|
}
|
|
@@ -24,7 +24,7 @@ function convertStyleToAttrs(svg) {
|
|
|
24
24
|
// Attributes / properties now allowed
|
|
25
25
|
badAttributes.has(prop) || badSoftwareAttributes.has(prop) || badAttributePrefixes.has(prop.split("-").shift())
|
|
26
26
|
) {
|
|
27
|
-
return
|
|
27
|
+
return;
|
|
28
28
|
}
|
|
29
29
|
hasStyle = true;
|
|
30
30
|
return item.value;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SVG } from './index.cjs';
|
|
2
|
+
import { CheckBadTagsOptions } from './cleanup/bad-tags.cjs';
|
|
3
|
+
import 'cheerio';
|
|
4
|
+
import '@iconify/types';
|
|
5
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Options
|
|
9
|
+
*/
|
|
10
|
+
type CleanupSVGOptions = CheckBadTagsOptions;
|
|
11
|
+
/**
|
|
12
|
+
* Clean up SVG before parsing/optimising it
|
|
13
|
+
*/
|
|
14
|
+
declare function cleanupSVG(svg: SVG, options?: CleanupSVGOptions): void;
|
|
15
|
+
|
|
16
|
+
export { type CleanupSVGOptions, cleanupSVG };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SVG } from './index.mjs';
|
|
2
|
+
import { CheckBadTagsOptions } from './cleanup/bad-tags.mjs';
|
|
3
|
+
import 'cheerio';
|
|
4
|
+
import '@iconify/types';
|
|
5
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Options
|
|
9
|
+
*/
|
|
10
|
+
type CleanupSVGOptions = CheckBadTagsOptions;
|
|
11
|
+
/**
|
|
12
|
+
* Clean up SVG before parsing/optimising it
|
|
13
|
+
*/
|
|
14
|
+
declare function cleanupSVG(svg: SVG, options?: CleanupSVGOptions): void;
|
|
15
|
+
|
|
16
|
+
export { type CleanupSVGOptions, cleanupSVG };
|
package/lib/svg/cleanup.d.ts
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This list is highly opinionated. It is designed to handle icons that can be safely embedded in HTML and linked as external source.
|
|
3
|
+
* Icons cannot have anything that requires external resources, anything that renders inconsistently.
|
|
4
|
+
*/
|
|
5
|
+
/***** Attributes that are not part of tag specific stuff *****/
|
|
6
|
+
/**
|
|
7
|
+
* Attributes that icons should not mess with or that are irrelevant. They should be removed
|
|
8
|
+
*/
|
|
9
|
+
declare const badAttributes: Set<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Attributes for SVG element that should be removed
|
|
12
|
+
*/
|
|
13
|
+
declare const junkSVGAttributes: Set<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Attributes and styles often added by bad software to wrong tags, such as Adobe Illustrator and Inkscape
|
|
16
|
+
*/
|
|
17
|
+
declare const badSoftwareAttributes: Set<string>;
|
|
18
|
+
declare const badAttributePrefixes: Set<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Common attributes that can exist on any element
|
|
21
|
+
*/
|
|
22
|
+
declare const commonAttributes: Set<string>;
|
|
23
|
+
declare const stylingAttributes: Set<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Attributes that exist only on child elements of <clipPath>
|
|
26
|
+
*/
|
|
27
|
+
declare const insideClipPathAttributes: Set<string>;
|
|
28
|
+
/***** Other attributes, added to tagSpecificAttributes variable below *****/
|
|
29
|
+
/**
|
|
30
|
+
* Presentational attributes
|
|
31
|
+
*/
|
|
32
|
+
declare const fillPresentationalAttributes: Set<string>;
|
|
33
|
+
declare const strokePresentationalAttributes: Set<string>;
|
|
34
|
+
declare const urlPresentationalAttributes: Set<string>;
|
|
35
|
+
declare const visibilityPresentationalAttributes: Set<string>;
|
|
36
|
+
declare const commonColorPresentationalAttributes: Set<string>;
|
|
37
|
+
declare const otherPresentationalAttributes: Set<string>;
|
|
38
|
+
declare const presentationalAttributes: Set<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Markers
|
|
41
|
+
*
|
|
42
|
+
* Presentational attributes
|
|
43
|
+
*/
|
|
44
|
+
declare const markerAttributes: Set<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Shapes
|
|
47
|
+
*
|
|
48
|
+
* Not presentational
|
|
49
|
+
*/
|
|
50
|
+
declare const otherShapeAttributes: Set<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Animations
|
|
53
|
+
*/
|
|
54
|
+
declare const animationTimingAttributes: Set<string>;
|
|
55
|
+
declare const animationValueAttributes: Set<string>;
|
|
56
|
+
declare const otherAnimationAttributes: Set<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Gradients
|
|
59
|
+
*/
|
|
60
|
+
declare const commonGradientAttributes: Set<string>;
|
|
61
|
+
/**
|
|
62
|
+
* Filters
|
|
63
|
+
*/
|
|
64
|
+
declare const commonFeAttributes: Set<string>;
|
|
65
|
+
declare const feFuncAttributes: Set<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Tag specific attributes
|
|
68
|
+
*/
|
|
69
|
+
declare const tagSpecificAnimatedAttributes: Record<string, Set<string>>;
|
|
70
|
+
declare const tagSpecificPresentationalAttributes: Record<string, Set<string>>;
|
|
71
|
+
declare const tagSpecificNonPresentationalAttributes: Record<string, Set<string>>;
|
|
72
|
+
/**
|
|
73
|
+
* Styles to keep in tags
|
|
74
|
+
*/
|
|
75
|
+
declare const tagSpecificInlineStyles: Record<string, Set<string>>;
|
|
76
|
+
|
|
77
|
+
export { animationTimingAttributes, animationValueAttributes, badAttributePrefixes, badAttributes, badSoftwareAttributes, commonAttributes, commonColorPresentationalAttributes, commonFeAttributes, commonGradientAttributes, feFuncAttributes, fillPresentationalAttributes, insideClipPathAttributes, junkSVGAttributes, markerAttributes, otherAnimationAttributes, otherPresentationalAttributes, otherShapeAttributes, presentationalAttributes, strokePresentationalAttributes, stylingAttributes, tagSpecificAnimatedAttributes, tagSpecificInlineStyles, tagSpecificNonPresentationalAttributes, tagSpecificPresentationalAttributes, urlPresentationalAttributes, visibilityPresentationalAttributes };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This list is highly opinionated. It is designed to handle icons that can be safely embedded in HTML and linked as external source.
|
|
3
|
+
* Icons cannot have anything that requires external resources, anything that renders inconsistently.
|
|
4
|
+
*/
|
|
5
|
+
/***** Attributes that are not part of tag specific stuff *****/
|
|
6
|
+
/**
|
|
7
|
+
* Attributes that icons should not mess with or that are irrelevant. They should be removed
|
|
8
|
+
*/
|
|
9
|
+
declare const badAttributes: Set<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Attributes for SVG element that should be removed
|
|
12
|
+
*/
|
|
13
|
+
declare const junkSVGAttributes: Set<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Attributes and styles often added by bad software to wrong tags, such as Adobe Illustrator and Inkscape
|
|
16
|
+
*/
|
|
17
|
+
declare const badSoftwareAttributes: Set<string>;
|
|
18
|
+
declare const badAttributePrefixes: Set<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Common attributes that can exist on any element
|
|
21
|
+
*/
|
|
22
|
+
declare const commonAttributes: Set<string>;
|
|
23
|
+
declare const stylingAttributes: Set<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Attributes that exist only on child elements of <clipPath>
|
|
26
|
+
*/
|
|
27
|
+
declare const insideClipPathAttributes: Set<string>;
|
|
28
|
+
/***** Other attributes, added to tagSpecificAttributes variable below *****/
|
|
29
|
+
/**
|
|
30
|
+
* Presentational attributes
|
|
31
|
+
*/
|
|
32
|
+
declare const fillPresentationalAttributes: Set<string>;
|
|
33
|
+
declare const strokePresentationalAttributes: Set<string>;
|
|
34
|
+
declare const urlPresentationalAttributes: Set<string>;
|
|
35
|
+
declare const visibilityPresentationalAttributes: Set<string>;
|
|
36
|
+
declare const commonColorPresentationalAttributes: Set<string>;
|
|
37
|
+
declare const otherPresentationalAttributes: Set<string>;
|
|
38
|
+
declare const presentationalAttributes: Set<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Markers
|
|
41
|
+
*
|
|
42
|
+
* Presentational attributes
|
|
43
|
+
*/
|
|
44
|
+
declare const markerAttributes: Set<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Shapes
|
|
47
|
+
*
|
|
48
|
+
* Not presentational
|
|
49
|
+
*/
|
|
50
|
+
declare const otherShapeAttributes: Set<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Animations
|
|
53
|
+
*/
|
|
54
|
+
declare const animationTimingAttributes: Set<string>;
|
|
55
|
+
declare const animationValueAttributes: Set<string>;
|
|
56
|
+
declare const otherAnimationAttributes: Set<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Gradients
|
|
59
|
+
*/
|
|
60
|
+
declare const commonGradientAttributes: Set<string>;
|
|
61
|
+
/**
|
|
62
|
+
* Filters
|
|
63
|
+
*/
|
|
64
|
+
declare const commonFeAttributes: Set<string>;
|
|
65
|
+
declare const feFuncAttributes: Set<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Tag specific attributes
|
|
68
|
+
*/
|
|
69
|
+
declare const tagSpecificAnimatedAttributes: Record<string, Set<string>>;
|
|
70
|
+
declare const tagSpecificPresentationalAttributes: Record<string, Set<string>>;
|
|
71
|
+
declare const tagSpecificNonPresentationalAttributes: Record<string, Set<string>>;
|
|
72
|
+
/**
|
|
73
|
+
* Styles to keep in tags
|
|
74
|
+
*/
|
|
75
|
+
declare const tagSpecificInlineStyles: Record<string, Set<string>>;
|
|
76
|
+
|
|
77
|
+
export { animationTimingAttributes, animationValueAttributes, badAttributePrefixes, badAttributes, badSoftwareAttributes, commonAttributes, commonColorPresentationalAttributes, commonFeAttributes, commonGradientAttributes, feFuncAttributes, fillPresentationalAttributes, insideClipPathAttributes, junkSVGAttributes, markerAttributes, otherAnimationAttributes, otherPresentationalAttributes, otherShapeAttributes, presentationalAttributes, strokePresentationalAttributes, stylingAttributes, tagSpecificAnimatedAttributes, tagSpecificInlineStyles, tagSpecificNonPresentationalAttributes, tagSpecificPresentationalAttributes, urlPresentationalAttributes, visibilityPresentationalAttributes };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This list is highly opinionated. It is designed to handle icons that can be safely embedded in HTML and linked as external source.
|
|
3
|
+
* Icons cannot have anything that requires external resources, anything that renders inconsistently.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Bad tags
|
|
7
|
+
*
|
|
8
|
+
* Parser should throw error if one of these tags is found
|
|
9
|
+
*
|
|
10
|
+
* List includes text tags because:
|
|
11
|
+
* - it usuaully uses custom font, which makes things much more complex
|
|
12
|
+
* - it renders differently on different operating systems and browsers
|
|
13
|
+
*
|
|
14
|
+
* View tag is not allowed because it requires targeting view by id from external source, making it unusable in embedded icons.
|
|
15
|
+
*/
|
|
16
|
+
declare const badTags: Set<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Deprecated or irrelevant tags
|
|
19
|
+
*
|
|
20
|
+
* Tags that are quietly removed
|
|
21
|
+
*/
|
|
22
|
+
declare const unsupportedTags: Set<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Style
|
|
25
|
+
*/
|
|
26
|
+
declare const styleTag: Set<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Definitions: reusable elements inside
|
|
29
|
+
*/
|
|
30
|
+
declare const defsTag: Set<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Masks: colors are ignored, elements must have id
|
|
33
|
+
*/
|
|
34
|
+
declare const maskTags: Set<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Symbol
|
|
37
|
+
*/
|
|
38
|
+
declare const symbolTag: Set<string>;
|
|
39
|
+
/**
|
|
40
|
+
* SVG shapes
|
|
41
|
+
*/
|
|
42
|
+
declare const shapeTags: Set<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Use
|
|
45
|
+
*/
|
|
46
|
+
declare const useTag: Set<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Groups
|
|
49
|
+
*/
|
|
50
|
+
declare const groupTag: Set<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Marker, should be inside <defs>
|
|
53
|
+
*/
|
|
54
|
+
declare const markerTag: Set<string>;
|
|
55
|
+
/**
|
|
56
|
+
* SVG animations
|
|
57
|
+
*/
|
|
58
|
+
declare const animateTags: Set<string>;
|
|
59
|
+
declare const animateMotionChildTags: Set<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Gradients, should be inside <defs>
|
|
62
|
+
*/
|
|
63
|
+
declare const gradientTags: Set<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Gradient color, must be inside one of gradientTags
|
|
66
|
+
*/
|
|
67
|
+
declare const gradientChildTags: Set<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Pattern, should be inside <defs>
|
|
70
|
+
*/
|
|
71
|
+
declare const patternTag: Set<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Filters
|
|
74
|
+
*/
|
|
75
|
+
declare const filterTag: Set<string>;
|
|
76
|
+
declare const feLightningTags: Set<string>;
|
|
77
|
+
declare const filterChildTags: Set<string>;
|
|
78
|
+
declare const feComponentTransferChildTag: Set<string>;
|
|
79
|
+
declare const feLightningChildTags: Set<string>;
|
|
80
|
+
declare const feMergeChildTags: Set<string>;
|
|
81
|
+
/***** Combination of tags *****/
|
|
82
|
+
/**
|
|
83
|
+
* Reusable elements that use colors
|
|
84
|
+
*
|
|
85
|
+
* Most are used via color attributes like `fill`
|
|
86
|
+
* Some are used via custom attributes like `marker-start`
|
|
87
|
+
* Filter is used via `filter`
|
|
88
|
+
*/
|
|
89
|
+
declare const reusableElementsWithPalette: Set<string>;
|
|
90
|
+
/**
|
|
91
|
+
* All supported tags
|
|
92
|
+
*/
|
|
93
|
+
declare const allValidTags: Set<string>;
|
|
94
|
+
|
|
95
|
+
export { allValidTags, animateMotionChildTags, animateTags, badTags, defsTag, feComponentTransferChildTag, feLightningChildTags, feLightningTags, feMergeChildTags, filterChildTags, filterTag, gradientChildTags, gradientTags, groupTag, markerTag, maskTags, patternTag, reusableElementsWithPalette, shapeTags, styleTag, symbolTag, unsupportedTags, useTag };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This list is highly opinionated. It is designed to handle icons that can be safely embedded in HTML and linked as external source.
|
|
3
|
+
* Icons cannot have anything that requires external resources, anything that renders inconsistently.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Bad tags
|
|
7
|
+
*
|
|
8
|
+
* Parser should throw error if one of these tags is found
|
|
9
|
+
*
|
|
10
|
+
* List includes text tags because:
|
|
11
|
+
* - it usuaully uses custom font, which makes things much more complex
|
|
12
|
+
* - it renders differently on different operating systems and browsers
|
|
13
|
+
*
|
|
14
|
+
* View tag is not allowed because it requires targeting view by id from external source, making it unusable in embedded icons.
|
|
15
|
+
*/
|
|
16
|
+
declare const badTags: Set<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Deprecated or irrelevant tags
|
|
19
|
+
*
|
|
20
|
+
* Tags that are quietly removed
|
|
21
|
+
*/
|
|
22
|
+
declare const unsupportedTags: Set<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Style
|
|
25
|
+
*/
|
|
26
|
+
declare const styleTag: Set<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Definitions: reusable elements inside
|
|
29
|
+
*/
|
|
30
|
+
declare const defsTag: Set<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Masks: colors are ignored, elements must have id
|
|
33
|
+
*/
|
|
34
|
+
declare const maskTags: Set<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Symbol
|
|
37
|
+
*/
|
|
38
|
+
declare const symbolTag: Set<string>;
|
|
39
|
+
/**
|
|
40
|
+
* SVG shapes
|
|
41
|
+
*/
|
|
42
|
+
declare const shapeTags: Set<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Use
|
|
45
|
+
*/
|
|
46
|
+
declare const useTag: Set<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Groups
|
|
49
|
+
*/
|
|
50
|
+
declare const groupTag: Set<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Marker, should be inside <defs>
|
|
53
|
+
*/
|
|
54
|
+
declare const markerTag: Set<string>;
|
|
55
|
+
/**
|
|
56
|
+
* SVG animations
|
|
57
|
+
*/
|
|
58
|
+
declare const animateTags: Set<string>;
|
|
59
|
+
declare const animateMotionChildTags: Set<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Gradients, should be inside <defs>
|
|
62
|
+
*/
|
|
63
|
+
declare const gradientTags: Set<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Gradient color, must be inside one of gradientTags
|
|
66
|
+
*/
|
|
67
|
+
declare const gradientChildTags: Set<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Pattern, should be inside <defs>
|
|
70
|
+
*/
|
|
71
|
+
declare const patternTag: Set<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Filters
|
|
74
|
+
*/
|
|
75
|
+
declare const filterTag: Set<string>;
|
|
76
|
+
declare const feLightningTags: Set<string>;
|
|
77
|
+
declare const filterChildTags: Set<string>;
|
|
78
|
+
declare const feComponentTransferChildTag: Set<string>;
|
|
79
|
+
declare const feLightningChildTags: Set<string>;
|
|
80
|
+
declare const feMergeChildTags: Set<string>;
|
|
81
|
+
/***** Combination of tags *****/
|
|
82
|
+
/**
|
|
83
|
+
* Reusable elements that use colors
|
|
84
|
+
*
|
|
85
|
+
* Most are used via color attributes like `fill`
|
|
86
|
+
* Some are used via custom attributes like `marker-start`
|
|
87
|
+
* Filter is used via `filter`
|
|
88
|
+
*/
|
|
89
|
+
declare const reusableElementsWithPalette: Set<string>;
|
|
90
|
+
/**
|
|
91
|
+
* All supported tags
|
|
92
|
+
*/
|
|
93
|
+
declare const allValidTags: Set<string>;
|
|
94
|
+
|
|
95
|
+
export { allValidTags, animateMotionChildTags, animateTags, badTags, defsTag, feComponentTransferChildTag, feLightningChildTags, feLightningTags, feMergeChildTags, filterChildTags, filterTag, gradientChildTags, gradientTags, groupTag, markerTag, maskTags, patternTag, reusableElementsWithPalette, shapeTags, styleTag, symbolTag, unsupportedTags, useTag };
|
package/lib/svg/index.cjs
CHANGED
|
@@ -17,11 +17,21 @@ function _interopNamespaceCompat(e) {
|
|
|
17
17
|
|
|
18
18
|
const cheerio__namespace = /*#__PURE__*/_interopNamespaceCompat(cheerio);
|
|
19
19
|
|
|
20
|
+
var __defProp = Object.defineProperty;
|
|
21
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
22
|
+
var __publicField = (obj, key, value) => {
|
|
23
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
20
26
|
class SVG {
|
|
21
27
|
/**
|
|
22
28
|
* Constructor
|
|
23
29
|
*/
|
|
24
30
|
constructor(content) {
|
|
31
|
+
// Cheerio tree, initialized in load()
|
|
32
|
+
__publicField(this, "$svg");
|
|
33
|
+
// Dimensions, initialized in load()
|
|
34
|
+
__publicField(this, "viewBox");
|
|
25
35
|
this.load(content);
|
|
26
36
|
}
|
|
27
37
|
/**
|
|
@@ -31,7 +41,7 @@ class SVG {
|
|
|
31
41
|
if (customisations) {
|
|
32
42
|
const data = utils.iconToSVG(this.getIcon(), customisations);
|
|
33
43
|
let svgAttributes = ' xmlns="http://www.w3.org/2000/svg"';
|
|
34
|
-
if (data.body.
|
|
44
|
+
if (data.body.includes("xlink:")) {
|
|
35
45
|
svgAttributes += ' xmlns:xlink="http://www.w3.org/1999/xlink"';
|
|
36
46
|
}
|
|
37
47
|
for (const key in data.attributes) {
|
|
@@ -62,6 +72,13 @@ class SVG {
|
|
|
62
72
|
toMinifiedString(customisations) {
|
|
63
73
|
return utils.trimSVG(this.toString(customisations));
|
|
64
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Get SVG as string with whitespaces
|
|
77
|
+
*/
|
|
78
|
+
toPrettyString(customisations) {
|
|
79
|
+
const str = this.toMinifiedString(customisations);
|
|
80
|
+
return utils.prettifySVG(str) ?? str;
|
|
81
|
+
}
|
|
65
82
|
/**
|
|
66
83
|
* Get body
|
|
67
84
|
*/
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as cheerio from 'cheerio';
|
|
2
|
+
import { IconifyIcon } from '@iconify/types';
|
|
3
|
+
export { IconifyIcon } from '@iconify/types';
|
|
4
|
+
import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
export { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
|
6
|
+
|
|
7
|
+
interface ViewBox {
|
|
8
|
+
left: number;
|
|
9
|
+
top: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* SVG class, used to manipulate icon content.
|
|
16
|
+
*/
|
|
17
|
+
declare class SVG {
|
|
18
|
+
$svg: cheerio.CheerioAPI;
|
|
19
|
+
viewBox: ViewBox;
|
|
20
|
+
/**
|
|
21
|
+
* Constructor
|
|
22
|
+
*/
|
|
23
|
+
constructor(content: string);
|
|
24
|
+
/**
|
|
25
|
+
* Get SVG as string
|
|
26
|
+
*/
|
|
27
|
+
toString(customisations?: IconifyIconCustomisations): string;
|
|
28
|
+
/**
|
|
29
|
+
* Get SVG as string without whitespaces
|
|
30
|
+
*/
|
|
31
|
+
toMinifiedString(customisations?: IconifyIconCustomisations): string;
|
|
32
|
+
/**
|
|
33
|
+
* Get SVG as string with whitespaces
|
|
34
|
+
*/
|
|
35
|
+
toPrettyString(customisations?: IconifyIconCustomisations): string;
|
|
36
|
+
/**
|
|
37
|
+
* Get body
|
|
38
|
+
*/
|
|
39
|
+
getBody(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Get icon as IconifyIcon
|
|
42
|
+
*/
|
|
43
|
+
getIcon(): IconifyIcon;
|
|
44
|
+
/**
|
|
45
|
+
* Load SVG
|
|
46
|
+
*
|
|
47
|
+
* @param {string} content
|
|
48
|
+
*/
|
|
49
|
+
load(content: string): void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { SVG, type ViewBox };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as cheerio from 'cheerio';
|
|
2
|
+
import { IconifyIcon } from '@iconify/types';
|
|
3
|
+
export { IconifyIcon } from '@iconify/types';
|
|
4
|
+
import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
export { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
|
6
|
+
|
|
7
|
+
interface ViewBox {
|
|
8
|
+
left: number;
|
|
9
|
+
top: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* SVG class, used to manipulate icon content.
|
|
16
|
+
*/
|
|
17
|
+
declare class SVG {
|
|
18
|
+
$svg: cheerio.CheerioAPI;
|
|
19
|
+
viewBox: ViewBox;
|
|
20
|
+
/**
|
|
21
|
+
* Constructor
|
|
22
|
+
*/
|
|
23
|
+
constructor(content: string);
|
|
24
|
+
/**
|
|
25
|
+
* Get SVG as string
|
|
26
|
+
*/
|
|
27
|
+
toString(customisations?: IconifyIconCustomisations): string;
|
|
28
|
+
/**
|
|
29
|
+
* Get SVG as string without whitespaces
|
|
30
|
+
*/
|
|
31
|
+
toMinifiedString(customisations?: IconifyIconCustomisations): string;
|
|
32
|
+
/**
|
|
33
|
+
* Get SVG as string with whitespaces
|
|
34
|
+
*/
|
|
35
|
+
toPrettyString(customisations?: IconifyIconCustomisations): string;
|
|
36
|
+
/**
|
|
37
|
+
* Get body
|
|
38
|
+
*/
|
|
39
|
+
getBody(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Get icon as IconifyIcon
|
|
42
|
+
*/
|
|
43
|
+
getIcon(): IconifyIcon;
|
|
44
|
+
/**
|
|
45
|
+
* Load SVG
|
|
46
|
+
*
|
|
47
|
+
* @param {string} content
|
|
48
|
+
*/
|
|
49
|
+
load(content: string): void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { SVG, type ViewBox };
|
package/lib/svg/index.d.ts
CHANGED
|
@@ -29,6 +29,10 @@ declare class SVG {
|
|
|
29
29
|
* Get SVG as string without whitespaces
|
|
30
30
|
*/
|
|
31
31
|
toMinifiedString(customisations?: IconifyIconCustomisations): string;
|
|
32
|
+
/**
|
|
33
|
+
* Get SVG as string with whitespaces
|
|
34
|
+
*/
|
|
35
|
+
toPrettyString(customisations?: IconifyIconCustomisations): string;
|
|
32
36
|
/**
|
|
33
37
|
* Get body
|
|
34
38
|
*/
|
|
@@ -45,4 +49,4 @@ declare class SVG {
|
|
|
45
49
|
load(content: string): void;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
export { SVG, ViewBox };
|
|
52
|
+
export { SVG, type ViewBox };
|
package/lib/svg/index.mjs
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import * as cheerio from 'cheerio';
|
|
2
|
-
import { iconToSVG, trimSVG } from '@iconify/utils';
|
|
2
|
+
import { iconToSVG, trimSVG, prettifySVG } from '@iconify/utils';
|
|
3
3
|
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => {
|
|
7
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
|
+
return value;
|
|
9
|
+
};
|
|
4
10
|
class SVG {
|
|
5
11
|
/**
|
|
6
12
|
* Constructor
|
|
7
13
|
*/
|
|
8
14
|
constructor(content) {
|
|
15
|
+
// Cheerio tree, initialized in load()
|
|
16
|
+
__publicField(this, "$svg");
|
|
17
|
+
// Dimensions, initialized in load()
|
|
18
|
+
__publicField(this, "viewBox");
|
|
9
19
|
this.load(content);
|
|
10
20
|
}
|
|
11
21
|
/**
|
|
@@ -15,7 +25,7 @@ class SVG {
|
|
|
15
25
|
if (customisations) {
|
|
16
26
|
const data = iconToSVG(this.getIcon(), customisations);
|
|
17
27
|
let svgAttributes = ' xmlns="http://www.w3.org/2000/svg"';
|
|
18
|
-
if (data.body.
|
|
28
|
+
if (data.body.includes("xlink:")) {
|
|
19
29
|
svgAttributes += ' xmlns:xlink="http://www.w3.org/1999/xlink"';
|
|
20
30
|
}
|
|
21
31
|
for (const key in data.attributes) {
|
|
@@ -46,6 +56,13 @@ class SVG {
|
|
|
46
56
|
toMinifiedString(customisations) {
|
|
47
57
|
return trimSVG(this.toString(customisations));
|
|
48
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Get SVG as string with whitespaces
|
|
61
|
+
*/
|
|
62
|
+
toPrettyString(customisations) {
|
|
63
|
+
const str = this.toMinifiedString(customisations);
|
|
64
|
+
return prettifySVG(str) ?? str;
|
|
65
|
+
}
|
|
49
66
|
/**
|
|
50
67
|
* Get body
|
|
51
68
|
*/
|