@iconify/tools 4.0.0-beta.9 → 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.d.cts +16 -0
- package/lib/colors/detect.d.mts +16 -0
- package/lib/colors/parse.d.cts +60 -0
- package/lib/colors/parse.d.mts +60 -0
- package/lib/colors/parse.d.ts +1 -1
- package/lib/colors/validate.d.cts +20 -0
- package/lib/colors/validate.d.mts +20 -0
- 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.d.cts +18 -0
- package/lib/download/api/config.d.mts +18 -0
- package/lib/download/api/download.d.cts +8 -0
- package/lib/download/api/download.d.mts +8 -0
- package/lib/download/api/index.d.cts +8 -0
- package/lib/download/api/index.d.mts +8 -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 +1 -1
- 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.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/reset.d.cts +6 -0
- package/lib/download/git/reset.d.mts +6 -0
- package/lib/download/github/hash.d.cts +8 -0
- package/lib/download/github/hash.d.mts +8 -0
- 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/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.d.cts +8 -0
- package/lib/download/gitlab/hash.d.mts +8 -0
- 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/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.d.cts +48 -0
- package/lib/download/index.d.mts +48 -0
- package/lib/download/index.d.ts +1 -1
- 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/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 +1 -3
- 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 +1 -1
- package/lib/icon-set/index.cjs +22 -0
- package/lib/icon-set/index.d.cts +162 -0
- package/lib/icon-set/index.d.mts +162 -0
- package/lib/icon-set/index.mjs +22 -0
- 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.d.cts +20 -0
- package/lib/import/figma/index.d.mts +20 -0
- package/lib/import/figma/nodes.d.cts +18 -0
- package/lib/import/figma/nodes.d.mts +18 -0
- 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 +1 -1
- 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 +7 -5
- package/lib/index.d.cts +78 -0
- package/lib/index.d.mts +78 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.mjs +6 -5
- 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.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/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.d.cts +11 -0
- package/lib/optimise/figma.d.mts +11 -0
- package/lib/optimise/flags.d.cts +11 -0
- package/lib/optimise/flags.d.mts +11 -0
- package/lib/optimise/global-style.d.cts +11 -0
- package/lib/optimise/global-style.d.mts +11 -0
- package/lib/optimise/mask.d.cts +24 -0
- package/lib/optimise/mask.d.mts +24 -0
- 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.d.cts +37 -0
- package/lib/optimise/svgo.d.mts +37 -0
- package/lib/svg/analyse/error.d.cts +10 -0
- package/lib/svg/analyse/error.d.mts +10 -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 +1 -1
- package/lib/svg/analyse.d.cts +15 -0
- package/lib/svg/analyse.d.mts +15 -0
- package/lib/svg/cleanup/attribs.d.cts +11 -0
- package/lib/svg/cleanup/attribs.d.mts +11 -0
- 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/inline-style.d.cts +11 -0
- package/lib/svg/cleanup/inline-style.d.mts +11 -0
- 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-svg.d.cts +11 -0
- package/lib/svg/cleanup/root-svg.d.mts +11 -0
- package/lib/svg/cleanup/svgo-style.d.cts +11 -0
- package/lib/svg/cleanup/svgo-style.d.mts +11 -0
- 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 +17 -0
- 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 +18 -1
- 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 +1 -1
- package/lib/svg/parse.d.cts +30 -0
- package/lib/svg/parse.d.mts +30 -0
- package/lib/svg/parse.d.ts +1 -1
- package/package.json +14 -17
|
@@ -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 };
|
|
@@ -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 };
|
|
@@ -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 };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PluginConfig } from 'svgo';
|
|
2
|
+
import { SVG } from '../svg/index.cjs';
|
|
3
|
+
import 'cheerio';
|
|
4
|
+
import '@iconify/types';
|
|
5
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
6
|
+
|
|
7
|
+
interface CleanupIDsOption {
|
|
8
|
+
cleanupIDs?: string | ((id: string) => string) | false;
|
|
9
|
+
}
|
|
10
|
+
interface GetSVGOPluginOptions extends CleanupIDsOption {
|
|
11
|
+
animated?: boolean;
|
|
12
|
+
keepShapes?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get list of plugins
|
|
16
|
+
*/
|
|
17
|
+
declare function getSVGOPlugins(options: GetSVGOPluginOptions): PluginConfig[];
|
|
18
|
+
/**
|
|
19
|
+
* Options
|
|
20
|
+
*/
|
|
21
|
+
interface SVGOCommonOptions {
|
|
22
|
+
multipass?: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface SVGOOptionsWithPlugin extends SVGOCommonOptions {
|
|
25
|
+
plugins: PluginConfig[];
|
|
26
|
+
}
|
|
27
|
+
interface SVGOptionsWithoutPlugin extends SVGOCommonOptions, CleanupIDsOption {
|
|
28
|
+
plugins?: undefined;
|
|
29
|
+
keepShapes?: boolean;
|
|
30
|
+
}
|
|
31
|
+
type SVGOOptions = SVGOOptionsWithPlugin | SVGOptionsWithoutPlugin;
|
|
32
|
+
/**
|
|
33
|
+
* Run SVGO on icon
|
|
34
|
+
*/
|
|
35
|
+
declare function runSVGO(svg: SVG, options?: SVGOOptions): void;
|
|
36
|
+
|
|
37
|
+
export { getSVGOPlugins, runSVGO };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PluginConfig } from 'svgo';
|
|
2
|
+
import { SVG } from '../svg/index.mjs';
|
|
3
|
+
import 'cheerio';
|
|
4
|
+
import '@iconify/types';
|
|
5
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
6
|
+
|
|
7
|
+
interface CleanupIDsOption {
|
|
8
|
+
cleanupIDs?: string | ((id: string) => string) | false;
|
|
9
|
+
}
|
|
10
|
+
interface GetSVGOPluginOptions extends CleanupIDsOption {
|
|
11
|
+
animated?: boolean;
|
|
12
|
+
keepShapes?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get list of plugins
|
|
16
|
+
*/
|
|
17
|
+
declare function getSVGOPlugins(options: GetSVGOPluginOptions): PluginConfig[];
|
|
18
|
+
/**
|
|
19
|
+
* Options
|
|
20
|
+
*/
|
|
21
|
+
interface SVGOCommonOptions {
|
|
22
|
+
multipass?: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface SVGOOptionsWithPlugin extends SVGOCommonOptions {
|
|
25
|
+
plugins: PluginConfig[];
|
|
26
|
+
}
|
|
27
|
+
interface SVGOptionsWithoutPlugin extends SVGOCommonOptions, CleanupIDsOption {
|
|
28
|
+
plugins?: undefined;
|
|
29
|
+
keepShapes?: boolean;
|
|
30
|
+
}
|
|
31
|
+
type SVGOOptions = SVGOOptionsWithPlugin | SVGOptionsWithoutPlugin;
|
|
32
|
+
/**
|
|
33
|
+
* Run SVGO on icon
|
|
34
|
+
*/
|
|
35
|
+
declare function runSVGO(svg: SVG, options?: SVGOOptions): void;
|
|
36
|
+
|
|
37
|
+
export { getSVGOPlugins, runSVGO };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { CheerioElement } from '../../misc/cheerio.cjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Options
|
|
6
|
+
*/
|
|
7
|
+
interface AnalyseSVGStructureOptions {
|
|
8
|
+
fixErrors?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Extended properties for element
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Link to element
|
|
15
|
+
*/
|
|
16
|
+
interface LinkToElementWithID {
|
|
17
|
+
id: string;
|
|
18
|
+
usedAsMask: boolean;
|
|
19
|
+
usedByIndex: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* How element is used by parent elements
|
|
23
|
+
*/
|
|
24
|
+
interface ExtendedTagElementUses {
|
|
25
|
+
_usedAsMask: boolean;
|
|
26
|
+
_usedAsPaint: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Definition: mask, clip path, symbol, etc...
|
|
30
|
+
*/
|
|
31
|
+
interface ReusableElement {
|
|
32
|
+
id: string;
|
|
33
|
+
isMask: boolean;
|
|
34
|
+
index: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Element with id
|
|
38
|
+
*
|
|
39
|
+
* Similar to ReusableElement, but not necessary a definition - any element with id. Also contains list of child elements
|
|
40
|
+
*/
|
|
41
|
+
interface ElementWithID {
|
|
42
|
+
id: string;
|
|
43
|
+
isMask: boolean;
|
|
44
|
+
indexes: Set<number>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Parent and child elements. Unlike standard tree, this tree is for elements that inherit attributes from parent element
|
|
48
|
+
*/
|
|
49
|
+
interface ExtendedTagElementRelations {
|
|
50
|
+
_parentElement?: number;
|
|
51
|
+
_childElements?: number[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Extended tag
|
|
55
|
+
*/
|
|
56
|
+
interface ExtendedTagElement extends CheerioElement, ExtendedTagElementUses, ExtendedTagElementRelations {
|
|
57
|
+
_index: number;
|
|
58
|
+
_id?: string;
|
|
59
|
+
_belongsTo?: ElementWithID[];
|
|
60
|
+
_reusableElement?: ReusableElement;
|
|
61
|
+
_linksTo?: LinkToElementWithID[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Additional stuff for <svg>
|
|
65
|
+
*/
|
|
66
|
+
interface ExtendedRootTagElement extends ExtendedTagElement {
|
|
67
|
+
_parsed?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Tree
|
|
71
|
+
*/
|
|
72
|
+
interface ElementsTreeItem {
|
|
73
|
+
index: number;
|
|
74
|
+
usedAsMask: boolean;
|
|
75
|
+
parent?: ElementsTreeItem;
|
|
76
|
+
children: ElementsTreeItem[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Elements map
|
|
80
|
+
*/
|
|
81
|
+
type ElementsMap = Map<number, ExtendedTagElement>;
|
|
82
|
+
/**
|
|
83
|
+
* Result
|
|
84
|
+
*/
|
|
85
|
+
interface AnalyseSVGStructureResult {
|
|
86
|
+
elements: ElementsMap;
|
|
87
|
+
ids: Record<string, number>;
|
|
88
|
+
links: LinkToElementWithID[];
|
|
89
|
+
tree: ElementsTreeItem;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type { AnalyseSVGStructureOptions, AnalyseSVGStructureResult, ElementWithID, ElementsMap, ElementsTreeItem, ExtendedRootTagElement, ExtendedTagElement, ExtendedTagElementUses, LinkToElementWithID };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { CheerioElement } from '../../misc/cheerio.mjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Options
|
|
6
|
+
*/
|
|
7
|
+
interface AnalyseSVGStructureOptions {
|
|
8
|
+
fixErrors?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Extended properties for element
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Link to element
|
|
15
|
+
*/
|
|
16
|
+
interface LinkToElementWithID {
|
|
17
|
+
id: string;
|
|
18
|
+
usedAsMask: boolean;
|
|
19
|
+
usedByIndex: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* How element is used by parent elements
|
|
23
|
+
*/
|
|
24
|
+
interface ExtendedTagElementUses {
|
|
25
|
+
_usedAsMask: boolean;
|
|
26
|
+
_usedAsPaint: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Definition: mask, clip path, symbol, etc...
|
|
30
|
+
*/
|
|
31
|
+
interface ReusableElement {
|
|
32
|
+
id: string;
|
|
33
|
+
isMask: boolean;
|
|
34
|
+
index: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Element with id
|
|
38
|
+
*
|
|
39
|
+
* Similar to ReusableElement, but not necessary a definition - any element with id. Also contains list of child elements
|
|
40
|
+
*/
|
|
41
|
+
interface ElementWithID {
|
|
42
|
+
id: string;
|
|
43
|
+
isMask: boolean;
|
|
44
|
+
indexes: Set<number>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Parent and child elements. Unlike standard tree, this tree is for elements that inherit attributes from parent element
|
|
48
|
+
*/
|
|
49
|
+
interface ExtendedTagElementRelations {
|
|
50
|
+
_parentElement?: number;
|
|
51
|
+
_childElements?: number[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Extended tag
|
|
55
|
+
*/
|
|
56
|
+
interface ExtendedTagElement extends CheerioElement, ExtendedTagElementUses, ExtendedTagElementRelations {
|
|
57
|
+
_index: number;
|
|
58
|
+
_id?: string;
|
|
59
|
+
_belongsTo?: ElementWithID[];
|
|
60
|
+
_reusableElement?: ReusableElement;
|
|
61
|
+
_linksTo?: LinkToElementWithID[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Additional stuff for <svg>
|
|
65
|
+
*/
|
|
66
|
+
interface ExtendedRootTagElement extends ExtendedTagElement {
|
|
67
|
+
_parsed?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Tree
|
|
71
|
+
*/
|
|
72
|
+
interface ElementsTreeItem {
|
|
73
|
+
index: number;
|
|
74
|
+
usedAsMask: boolean;
|
|
75
|
+
parent?: ElementsTreeItem;
|
|
76
|
+
children: ElementsTreeItem[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Elements map
|
|
80
|
+
*/
|
|
81
|
+
type ElementsMap = Map<number, ExtendedTagElement>;
|
|
82
|
+
/**
|
|
83
|
+
* Result
|
|
84
|
+
*/
|
|
85
|
+
interface AnalyseSVGStructureResult {
|
|
86
|
+
elements: ElementsMap;
|
|
87
|
+
ids: Record<string, number>;
|
|
88
|
+
links: LinkToElementWithID[];
|
|
89
|
+
tree: ElementsTreeItem;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type { AnalyseSVGStructureOptions, AnalyseSVGStructureResult, ElementWithID, ElementsMap, ElementsTreeItem, ExtendedRootTagElement, ExtendedTagElement, ExtendedTagElementUses, LinkToElementWithID };
|
|
@@ -89,4 +89,4 @@ interface AnalyseSVGStructureResult {
|
|
|
89
89
|
tree: ElementsTreeItem;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
export { AnalyseSVGStructureOptions, AnalyseSVGStructureResult, ElementWithID, ElementsMap, ElementsTreeItem, ExtendedRootTagElement, ExtendedTagElement, ExtendedTagElementUses, LinkToElementWithID };
|
|
92
|
+
export type { AnalyseSVGStructureOptions, AnalyseSVGStructureResult, ElementWithID, ElementsMap, ElementsTreeItem, ExtendedRootTagElement, ExtendedTagElement, ExtendedTagElementUses, LinkToElementWithID };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SVG } from './index.cjs';
|
|
2
|
+
import { AnalyseSVGStructureOptions, AnalyseSVGStructureResult } from './analyse/types.cjs';
|
|
3
|
+
import 'cheerio';
|
|
4
|
+
import '@iconify/types';
|
|
5
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
6
|
+
import '../misc/cheerio.cjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Find all IDs, links, which elements use palette, which items aren't used
|
|
10
|
+
*
|
|
11
|
+
* Before running this function run cleanup functions to change inline style to attributes and fix attributes
|
|
12
|
+
*/
|
|
13
|
+
declare function analyseSVGStructure(svg: SVG, options?: AnalyseSVGStructureOptions): AnalyseSVGStructureResult;
|
|
14
|
+
|
|
15
|
+
export { analyseSVGStructure };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SVG } from './index.mjs';
|
|
2
|
+
import { AnalyseSVGStructureOptions, AnalyseSVGStructureResult } from './analyse/types.mjs';
|
|
3
|
+
import 'cheerio';
|
|
4
|
+
import '@iconify/types';
|
|
5
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
6
|
+
import '../misc/cheerio.mjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Find all IDs, links, which elements use palette, which items aren't used
|
|
10
|
+
*
|
|
11
|
+
* Before running this function run cleanup functions to change inline style to attributes and fix attributes
|
|
12
|
+
*/
|
|
13
|
+
declare function analyseSVGStructure(svg: SVG, options?: AnalyseSVGStructureOptions): AnalyseSVGStructureResult;
|
|
14
|
+
|
|
15
|
+
export { analyseSVGStructure };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SVG } from '../index.cjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Remove useless attributes
|
|
8
|
+
*/
|
|
9
|
+
declare function removeBadAttributes(svg: SVG): void;
|
|
10
|
+
|
|
11
|
+
export { removeBadAttributes };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SVG } from '../index.mjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Remove useless attributes
|
|
8
|
+
*/
|
|
9
|
+
declare function removeBadAttributes(svg: SVG): void;
|
|
10
|
+
|
|
11
|
+
export { removeBadAttributes };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SVG } from '../index.cjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options
|
|
8
|
+
*/
|
|
9
|
+
interface CheckBadTagsOptions {
|
|
10
|
+
keepTitles?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Test for bag tags
|
|
14
|
+
*/
|
|
15
|
+
declare function checkBadTags(svg: SVG, options?: CheckBadTagsOptions): void;
|
|
16
|
+
|
|
17
|
+
export { type CheckBadTagsOptions, checkBadTags };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SVG } from '../index.mjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options
|
|
8
|
+
*/
|
|
9
|
+
interface CheckBadTagsOptions {
|
|
10
|
+
keepTitles?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Test for bag tags
|
|
14
|
+
*/
|
|
15
|
+
declare function checkBadTags(svg: SVG, options?: CheckBadTagsOptions): void;
|
|
16
|
+
|
|
17
|
+
export { type CheckBadTagsOptions, checkBadTags };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SVG } from '../index.cjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Expand inline style
|
|
8
|
+
*/
|
|
9
|
+
declare function cleanupInlineStyle(svg: SVG): void;
|
|
10
|
+
|
|
11
|
+
export { cleanupInlineStyle };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SVG } from '../index.mjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Expand inline style
|
|
8
|
+
*/
|
|
9
|
+
declare function cleanupInlineStyle(svg: SVG): void;
|
|
10
|
+
|
|
11
|
+
export { cleanupInlineStyle };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SVG } from '../index.cjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
interface CleanupRootStyleResult {
|
|
7
|
+
animations?: Set<string>;
|
|
8
|
+
removedAtRules?: Set<string>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Clean up root style
|
|
12
|
+
*
|
|
13
|
+
* This function removes all at-rule tokens, such as `@font-face`, `@media`
|
|
14
|
+
*/
|
|
15
|
+
declare function cleanupRootStyle(svg: SVG): CleanupRootStyleResult;
|
|
16
|
+
|
|
17
|
+
export { cleanupRootStyle };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SVG } from '../index.mjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
interface CleanupRootStyleResult {
|
|
7
|
+
animations?: Set<string>;
|
|
8
|
+
removedAtRules?: Set<string>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Clean up root style
|
|
12
|
+
*
|
|
13
|
+
* This function removes all at-rule tokens, such as `@font-face`, `@media`
|
|
14
|
+
*/
|
|
15
|
+
declare function cleanupRootStyle(svg: SVG): CleanupRootStyleResult;
|
|
16
|
+
|
|
17
|
+
export { cleanupRootStyle };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SVG } from '../index.cjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Expand inline style
|
|
8
|
+
*/
|
|
9
|
+
declare function convertStyleToAttrs(svg: SVG): void;
|
|
10
|
+
|
|
11
|
+
export { convertStyleToAttrs };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SVG } from '../index.mjs';
|
|
2
|
+
import 'cheerio';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Expand inline style
|
|
8
|
+
*/
|
|
9
|
+
declare function convertStyleToAttrs(svg: SVG): void;
|
|
10
|
+
|
|
11
|
+
export { convertStyleToAttrs };
|
|
@@ -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