@iconify/tools 3.0.3 → 3.0.4
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.ts +27 -0
- package/lib/colors/detect.d.ts +15 -0
- package/lib/colors/parse.d.ts +67 -0
- package/lib/colors/validate.d.ts +26 -0
- package/lib/css/parse.d.ts +6 -0
- package/lib/css/parser/error.d.ts +13 -0
- package/lib/css/parser/export.d.ts +8 -0
- package/lib/css/parser/strings.d.ts +16 -0
- package/lib/css/parser/text.d.ts +20 -0
- package/lib/css/parser/tokens.d.ts +9 -0
- package/lib/css/parser/tree.d.ts +8 -0
- package/lib/css/parser/types.d.ts +52 -0
- package/lib/download/api/cache.d.ts +20 -0
- package/lib/download/api/download.d.ts +8 -0
- package/lib/download/api/index.d.ts +8 -0
- package/lib/download/api/types.d.ts +17 -0
- package/lib/download/git/branch.d.ts +8 -0
- package/lib/download/git/hash.d.ts +8 -0
- package/lib/download/git/index.d.ts +29 -0
- package/lib/download/git/reset.d.ts +6 -0
- package/lib/download/github/hash.d.ts +8 -0
- package/lib/download/github/index.d.ts +31 -0
- package/lib/download/github/types.d.ts +11 -0
- package/lib/download/gitlab/hash.d.ts +8 -0
- package/lib/download/gitlab/index.d.ts +31 -0
- package/lib/download/gitlab/types.d.ts +15 -0
- package/lib/download/helpers/untar.d.ts +6 -0
- package/lib/download/helpers/unzip.d.ts +6 -0
- package/lib/download/index.d.ts +48 -0
- package/lib/download/npm/index.d.ts +30 -0
- package/lib/download/npm/types.d.ts +9 -0
- package/lib/download/npm/version.d.ts +16 -0
- package/lib/download/types/modified.d.ts +6 -0
- package/lib/download/types/sources.d.ts +12 -0
- package/lib/export/directory.d.ts +25 -0
- package/lib/export/helpers/custom-files.d.ts +12 -0
- package/lib/export/helpers/prepare.d.ts +19 -0
- package/lib/export/helpers/types-version.d.ts +6 -0
- package/lib/export/icon-package.d.ts +25 -0
- package/lib/export/json-package.d.ts +23 -0
- package/lib/icon-set/index.d.ts +161 -0
- package/lib/icon-set/match.d.ts +14 -0
- package/lib/icon-set/merge.d.ts +13 -0
- package/lib/icon-set/modified.d.ts +15 -0
- package/lib/icon-set/props.d.ts +13 -0
- package/lib/icon-set/tags.d.ts +22 -0
- package/lib/icon-set/types.d.ts +75 -0
- package/lib/import/directory.d.ts +51 -0
- package/lib/import/figma/index.d.ts +19 -0
- package/lib/import/figma/nodes.d.ts +17 -0
- package/lib/import/figma/query.d.ts +28 -0
- package/lib/import/figma/types/api.d.ts +53 -0
- package/lib/import/figma/types/nodes.d.ts +43 -0
- package/lib/import/figma/types/options.d.ts +58 -0
- package/lib/import/figma/types/result.d.ts +43 -0
- package/lib/index.d.ts +72 -0
- package/lib/misc/bump-version.d.ts +6 -0
- package/lib/misc/cheerio.d.ts +7 -0
- package/lib/misc/compare-dirs.d.ts +11 -0
- package/lib/misc/exec.d.ts +12 -0
- package/lib/misc/keyword.d.ts +6 -0
- package/lib/misc/scan.d.ts +33 -0
- package/lib/misc/write-json.d.ts +6 -0
- package/lib/optimise/flags.d.ts +10 -0
- package/lib/optimise/global-style.d.ts +10 -0
- package/lib/optimise/origin.d.ts +10 -0
- package/lib/optimise/scale.d.ts +10 -0
- package/lib/optimise/svgo.d.ts +36 -0
- package/lib/svg/analyse/error.d.ts +8 -0
- package/lib/svg/analyse/types.d.ts +89 -0
- package/lib/svg/analyse.d.ts +13 -0
- package/lib/svg/cleanup/attribs.d.ts +10 -0
- package/lib/svg/cleanup/bad-tags.d.ts +16 -0
- package/lib/svg/cleanup/inline-style.d.ts +10 -0
- package/lib/svg/cleanup/root-style.d.ts +16 -0
- package/lib/svg/cleanup/root-svg.d.ts +10 -0
- package/lib/svg/cleanup/svgo-style.d.ts +10 -0
- package/lib/svg/cleanup.d.ts +15 -0
- package/lib/svg/data/attributes.d.ts +77 -0
- package/lib/svg/data/tags.d.ts +95 -0
- package/lib/svg/index.d.ts +47 -0
- package/lib/svg/parse-style.d.ts +63 -0
- package/lib/svg/parse.d.ts +36 -0
- package/package.json +191 -191
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { IconSet } from '../../../icon-set/index.js';
|
|
2
|
+
import { FigmaImportParentNodeFilter, FigmaImportNodeFilter } from './nodes.js';
|
|
3
|
+
import { FigmaIconNode } from './result.js';
|
|
4
|
+
import '@iconify/types';
|
|
5
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
6
|
+
import '../../../icon-set/types.js';
|
|
7
|
+
import '../../../svg/index.js';
|
|
8
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
9
|
+
import './api.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Options for importing SVG
|
|
13
|
+
*/
|
|
14
|
+
interface FigmaImportSVGOptions {
|
|
15
|
+
includeID?: boolean;
|
|
16
|
+
simplifyStroke?: boolean;
|
|
17
|
+
useAbsoluteBounds?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Options
|
|
21
|
+
*/
|
|
22
|
+
interface FigmaImportCommonOptions {
|
|
23
|
+
token: string;
|
|
24
|
+
file: string;
|
|
25
|
+
version?: string;
|
|
26
|
+
}
|
|
27
|
+
interface FigmaIfModifiedSinceOption {
|
|
28
|
+
ifModifiedSince: string | Date | true;
|
|
29
|
+
}
|
|
30
|
+
interface FigmaFilesQueryOptions extends FigmaImportCommonOptions, Partial<FigmaIfModifiedSinceOption> {
|
|
31
|
+
ids?: string[];
|
|
32
|
+
depth?: number;
|
|
33
|
+
}
|
|
34
|
+
interface FigmaImagesQueryOptions extends FigmaImportCommonOptions {
|
|
35
|
+
svgOptions?: FigmaImportSVGOptions;
|
|
36
|
+
}
|
|
37
|
+
interface FigmaGetIconNodesOptions {
|
|
38
|
+
pages?: string[];
|
|
39
|
+
filterParentNode?: FigmaImportParentNodeFilter;
|
|
40
|
+
iconNameForNode: FigmaImportNodeFilter;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Callback to call before or after importing icon
|
|
44
|
+
*/
|
|
45
|
+
type FigmaImportedIconCallback = (node: FigmaIconNode, iconSet: IconSet) => void | Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Options for main import function
|
|
48
|
+
*/
|
|
49
|
+
interface FigmaImportOptions extends FigmaFilesQueryOptions, FigmaImagesQueryOptions, FigmaGetIconNodesOptions {
|
|
50
|
+
prefix: string;
|
|
51
|
+
cacheDir?: string;
|
|
52
|
+
cacheAPITTL?: number;
|
|
53
|
+
cacheSVGTTL?: number;
|
|
54
|
+
beforeImportingIcon?: FigmaImportedIconCallback;
|
|
55
|
+
afterImportingIcon?: FigmaImportedIconCallback;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { FigmaFilesQueryOptions, FigmaGetIconNodesOptions, FigmaIfModifiedSinceOption, FigmaImagesQueryOptions, FigmaImportOptions, FigmaImportSVGOptions };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IconSet } from '../../../icon-set/index.js';
|
|
2
|
+
import '@iconify/types';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
|
+
import '../../../icon-set/types.js';
|
|
5
|
+
import '../../../svg/index.js';
|
|
6
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Result for found icons
|
|
10
|
+
*/
|
|
11
|
+
interface FigmaIconNode {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
keyword: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
content?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Nodes count
|
|
20
|
+
*/
|
|
21
|
+
interface FigmaNodesCount {
|
|
22
|
+
nodesCount: number;
|
|
23
|
+
generatedIconsCount: number;
|
|
24
|
+
downloadedIconsCount: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Import result for icons
|
|
28
|
+
*/
|
|
29
|
+
interface FigmaNodesImportResult extends Partial<FigmaNodesCount> {
|
|
30
|
+
icons: Record<string, FigmaIconNode>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Import result
|
|
34
|
+
*/
|
|
35
|
+
interface FigmaImportResult extends FigmaNodesCount {
|
|
36
|
+
name: string;
|
|
37
|
+
version: string;
|
|
38
|
+
lastModified: string;
|
|
39
|
+
iconSet: IconSet;
|
|
40
|
+
missing: FigmaIconNode[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { FigmaIconNode, FigmaImportResult, FigmaNodesCount, FigmaNodesImportResult };
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export { SVG } from './svg/index.js';
|
|
2
|
+
export { parseSVG, parseSVGSync } from './svg/parse.js';
|
|
3
|
+
export { parseSVGStyle, parseSVGStyleSync } from './svg/parse-style.js';
|
|
4
|
+
export { analyseSVGStructure } from './svg/analyse.js';
|
|
5
|
+
export { cleanupSVG } from './svg/cleanup.js';
|
|
6
|
+
export { removeBadAttributes } from './svg/cleanup/attribs.js';
|
|
7
|
+
export { checkBadTags } from './svg/cleanup/bad-tags.js';
|
|
8
|
+
export { cleanupRootStyle } from './svg/cleanup/root-style.js';
|
|
9
|
+
export { cleanupInlineStyle } from './svg/cleanup/inline-style.js';
|
|
10
|
+
export { cleanupSVGRoot } from './svg/cleanup/root-svg.js';
|
|
11
|
+
export { convertStyleToAttrs } from './svg/cleanup/svgo-style.js';
|
|
12
|
+
export { IconSet, blankIconSet } from './icon-set/index.js';
|
|
13
|
+
export { mergeIconSets } from './icon-set/merge.js';
|
|
14
|
+
export { addTagsToIconSet } from './icon-set/tags.js';
|
|
15
|
+
export { importFromFigma } from './import/figma/index.js';
|
|
16
|
+
export { importDirectory, importDirectorySync } from './import/directory.js';
|
|
17
|
+
export { downloadGitRepo } from './download/git/index.js';
|
|
18
|
+
export { getGitRepoHash } from './download/git/hash.js';
|
|
19
|
+
export { getGitRepoBranch } from './download/git/branch.js';
|
|
20
|
+
export { resetGitRepoContents } from './download/git/reset.js';
|
|
21
|
+
export { downloadGitHubRepo } from './download/github/index.js';
|
|
22
|
+
export { getGitHubRepoHash } from './download/github/hash.js';
|
|
23
|
+
export { downloadGitLabRepo } from './download/gitlab/index.js';
|
|
24
|
+
export { getGitLabRepoHash } from './download/gitlab/hash.js';
|
|
25
|
+
export { downloadNPMPackage } from './download/npm/index.js';
|
|
26
|
+
export { getNPMVersion, getPackageVersion } from './download/npm/version.js';
|
|
27
|
+
export { downloadPackage } from './download/index.js';
|
|
28
|
+
export { downloadFile } from './download/api/download.js';
|
|
29
|
+
export { isEmptyColor, parseColors, parseColorsSync } from './colors/parse.js';
|
|
30
|
+
export { validateColors, validateColorsSync } from './colors/validate.js';
|
|
31
|
+
export { detectIconSetPalette } from './colors/detect.js';
|
|
32
|
+
export { runSVGO } from './optimise/svgo.js';
|
|
33
|
+
export { deOptimisePaths } from './optimise/flags.js';
|
|
34
|
+
export { resetSVGOrigin } from './optimise/origin.js';
|
|
35
|
+
export { scaleSVG } from './optimise/scale.js';
|
|
36
|
+
export { cleanupGlobalStyle } from './optimise/global-style.js';
|
|
37
|
+
export { exportToDirectory } from './export/directory.js';
|
|
38
|
+
export { exportIconPackage } from './export/icon-package.js';
|
|
39
|
+
export { exportJSONPackage } from './export/json-package.js';
|
|
40
|
+
export { writeJSONFile } from './misc/write-json.js';
|
|
41
|
+
export { prepareDirectoryForExport } from './export/helpers/prepare.js';
|
|
42
|
+
export { scanDirectory, scanDirectorySync } from './misc/scan.js';
|
|
43
|
+
export { compareDirectories } from './misc/compare-dirs.js';
|
|
44
|
+
export { unzip } from './download/helpers/unzip.js';
|
|
45
|
+
export { untar } from './download/helpers/untar.js';
|
|
46
|
+
export { execAsync } from './misc/exec.js';
|
|
47
|
+
export { cleanupIconKeyword } from './misc/keyword.js';
|
|
48
|
+
export { bumpVersion } from './misc/bump-version.js';
|
|
49
|
+
export { sendAPIQuery } from './download/api/index.js';
|
|
50
|
+
import '@iconify/types';
|
|
51
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
52
|
+
import './misc/cheerio.js';
|
|
53
|
+
import './css/parser/types.js';
|
|
54
|
+
import './svg/analyse/types.js';
|
|
55
|
+
import './icon-set/types.js';
|
|
56
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
57
|
+
import './download/types/modified.js';
|
|
58
|
+
import './import/figma/types/options.js';
|
|
59
|
+
import './import/figma/types/nodes.js';
|
|
60
|
+
import './import/figma/types/api.js';
|
|
61
|
+
import './import/figma/types/result.js';
|
|
62
|
+
import './download/types/sources.js';
|
|
63
|
+
import './download/github/types.js';
|
|
64
|
+
import './download/gitlab/types.js';
|
|
65
|
+
import './download/npm/types.js';
|
|
66
|
+
import './download/api/types.js';
|
|
67
|
+
import '@iconify/utils/lib/colors/types';
|
|
68
|
+
import './colors/attribs.js';
|
|
69
|
+
import 'svgo';
|
|
70
|
+
import './export/helpers/custom-files.js';
|
|
71
|
+
import 'fs';
|
|
72
|
+
import 'child_process';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface CompareDirectoriesOptions {
|
|
2
|
+
ignoreNewLine?: boolean;
|
|
3
|
+
ignoreVersions?: boolean;
|
|
4
|
+
textExtensions?: string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Compare directories. Returns true if files are identical, false if different
|
|
8
|
+
*/
|
|
9
|
+
declare function compareDirectories(dir1: string, dir2: string, options?: CompareDirectoriesOptions): Promise<boolean>;
|
|
10
|
+
|
|
11
|
+
export { CompareDirectoriesOptions, compareDirectories };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ExecOptions } from 'child_process';
|
|
2
|
+
|
|
3
|
+
interface ExecResult {
|
|
4
|
+
stdout: string;
|
|
5
|
+
stderr: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Exec as Promise
|
|
9
|
+
*/
|
|
10
|
+
declare function execAsync(cmd: string, options?: ExecOptions): Promise<ExecResult>;
|
|
11
|
+
|
|
12
|
+
export { ExecResult, execAsync };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Stats } from 'fs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Callback
|
|
5
|
+
*
|
|
6
|
+
* Extension starts with '.' (can be empty)
|
|
7
|
+
* File does not include extension
|
|
8
|
+
* Subdir ends with '/' (can be empty)
|
|
9
|
+
*
|
|
10
|
+
* Should return:
|
|
11
|
+
* - false, null or undefined to skip file
|
|
12
|
+
* - true to include file (subdir + file + extension)
|
|
13
|
+
* - string to include custom string (such as file without extension)
|
|
14
|
+
* - custom object to return custom object
|
|
15
|
+
*/
|
|
16
|
+
type ScanDirectoryCallbackFalseResult = boolean | null | undefined;
|
|
17
|
+
type ScanDirectoryCallbackStringResult = ScanDirectoryCallbackFalseResult | string;
|
|
18
|
+
type Callback<T> = (ext: string, file: string, subdir: string, path: string, stat: Stats) => T;
|
|
19
|
+
type AsyncCallback<T> = Callback<T | Promise<T>>;
|
|
20
|
+
type ScanDirectoryCallback = AsyncCallback<ScanDirectoryCallbackStringResult | unknown>;
|
|
21
|
+
type ScanDirectorySyncCallback = Callback<ScanDirectoryCallbackStringResult | unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* Find all files in directory
|
|
24
|
+
*/
|
|
25
|
+
declare function scanDirectory(path: string, callback?: AsyncCallback<ScanDirectoryCallbackStringResult>, subdirs?: boolean): Promise<string[]>;
|
|
26
|
+
declare function scanDirectory<T>(path: string, callback: AsyncCallback<T | ScanDirectoryCallbackFalseResult>, subdirs?: boolean): Promise<T[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Find all files in directory, synchronously
|
|
29
|
+
*/
|
|
30
|
+
declare function scanDirectorySync(path: string, callback?: Callback<ScanDirectoryCallbackStringResult>, subdirs?: boolean): string[];
|
|
31
|
+
declare function scanDirectorySync<T>(path: string, callback: Callback<T | ScanDirectoryCallbackFalseResult>, subdirs?: boolean): T[];
|
|
32
|
+
|
|
33
|
+
export { ScanDirectoryCallback, ScanDirectorySyncCallback, scanDirectory, scanDirectorySync };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SVG } from '../svg/index.js';
|
|
2
|
+
import '@iconify/types';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* De-optimise paths. Compressed paths are still not supported by some software.
|
|
7
|
+
*/
|
|
8
|
+
declare function deOptimisePaths(svg: SVG): Promise<void>;
|
|
9
|
+
|
|
10
|
+
export { deOptimisePaths };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PluginConfig } from 'svgo';
|
|
2
|
+
import { SVG } from '../svg/index.js';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
interface CleanupIDsOption {
|
|
7
|
+
cleanupIDs?: string | ((id: string) => string) | false;
|
|
8
|
+
}
|
|
9
|
+
interface GetSVGOPluginOptions extends CleanupIDsOption {
|
|
10
|
+
animated?: boolean;
|
|
11
|
+
keepShapes?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get list of plugins
|
|
15
|
+
*/
|
|
16
|
+
declare function getSVGOPlugins(options: GetSVGOPluginOptions): PluginConfig[];
|
|
17
|
+
/**
|
|
18
|
+
* Options
|
|
19
|
+
*/
|
|
20
|
+
interface SVGOCommonOptions {
|
|
21
|
+
multipass?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface SVGOOptionsWithPlugin extends SVGOCommonOptions {
|
|
24
|
+
plugins: PluginConfig[];
|
|
25
|
+
}
|
|
26
|
+
interface SVGOptionsWithoutPlugin extends SVGOCommonOptions, CleanupIDsOption {
|
|
27
|
+
plugins?: undefined;
|
|
28
|
+
keepShapes?: boolean;
|
|
29
|
+
}
|
|
30
|
+
type SVGOOptions = SVGOOptionsWithPlugin | SVGOptionsWithoutPlugin;
|
|
31
|
+
/**
|
|
32
|
+
* Run SVGO on icon
|
|
33
|
+
*/
|
|
34
|
+
declare function runSVGO(svg: SVG, options?: SVGOOptions): void;
|
|
35
|
+
|
|
36
|
+
export { getSVGOPlugins, runSVGO };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options
|
|
3
|
+
*/
|
|
4
|
+
interface AnalyseSVGStructureOptions {
|
|
5
|
+
fixErrors?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Extended properties for element
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Link to element
|
|
12
|
+
*/
|
|
13
|
+
interface LinkToElementWithID {
|
|
14
|
+
id: string;
|
|
15
|
+
usedAsMask: boolean;
|
|
16
|
+
usedByIndex: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* How element is used by parent elements
|
|
20
|
+
*/
|
|
21
|
+
interface ExtendedTagElementUses {
|
|
22
|
+
_usedAsMask: boolean;
|
|
23
|
+
_usedAsPaint: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Definition: mask, clip path, symbol, etc...
|
|
27
|
+
*/
|
|
28
|
+
interface ReusableElement {
|
|
29
|
+
id: string;
|
|
30
|
+
isMask: boolean;
|
|
31
|
+
index: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Element with id
|
|
35
|
+
*
|
|
36
|
+
* Similar to ReusableElement, but not necessary a definition - any element with id. Also contains list of child elements
|
|
37
|
+
*/
|
|
38
|
+
interface ElementWithID {
|
|
39
|
+
id: string;
|
|
40
|
+
isMask: boolean;
|
|
41
|
+
indexes: Set<number>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Parent and child elements. Unlike standard tree, this tree is for elements that inherit attributes from parent element
|
|
45
|
+
*/
|
|
46
|
+
interface ExtendedTagElementRelations {
|
|
47
|
+
_parentElement?: number;
|
|
48
|
+
_childElements?: number[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Extended tag
|
|
52
|
+
*/
|
|
53
|
+
interface ExtendedTagElement extends cheerio.TagElement, ExtendedTagElementUses, ExtendedTagElementRelations {
|
|
54
|
+
_index: number;
|
|
55
|
+
_id?: string;
|
|
56
|
+
_belongsTo?: ElementWithID[];
|
|
57
|
+
_reusableElement?: ReusableElement;
|
|
58
|
+
_linksTo?: LinkToElementWithID[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Additional stuff for <svg>
|
|
62
|
+
*/
|
|
63
|
+
interface ExtendedRootTagElement extends ExtendedTagElement {
|
|
64
|
+
_parsed?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Tree
|
|
68
|
+
*/
|
|
69
|
+
interface ElementsTreeItem {
|
|
70
|
+
index: number;
|
|
71
|
+
usedAsMask: boolean;
|
|
72
|
+
parent?: ElementsTreeItem;
|
|
73
|
+
children: ElementsTreeItem[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Elements map
|
|
77
|
+
*/
|
|
78
|
+
type ElementsMap = Map<number, ExtendedTagElement>;
|
|
79
|
+
/**
|
|
80
|
+
* Result
|
|
81
|
+
*/
|
|
82
|
+
interface AnalyseSVGStructureResult {
|
|
83
|
+
elements: ElementsMap;
|
|
84
|
+
ids: Record<string, number>;
|
|
85
|
+
links: LinkToElementWithID[];
|
|
86
|
+
tree: ElementsTreeItem;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { AnalyseSVGStructureOptions, AnalyseSVGStructureResult, ElementWithID, ElementsMap, ElementsTreeItem, ExtendedRootTagElement, ExtendedTagElement, ExtendedTagElementUses, LinkToElementWithID };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SVG } from './index.js';
|
|
2
|
+
import { AnalyseSVGStructureOptions, AnalyseSVGStructureResult } from './analyse/types.js';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Find all IDs, links, which elements use palette, which items aren't used
|
|
8
|
+
*
|
|
9
|
+
* Before running this function run cleanup functions to change inline style to attributes and fix attributes
|
|
10
|
+
*/
|
|
11
|
+
declare function analyseSVGStructure(svg: SVG, options?: AnalyseSVGStructureOptions): AnalyseSVGStructureResult;
|
|
12
|
+
|
|
13
|
+
export { analyseSVGStructure };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SVG } from '../index.js';
|
|
2
|
+
import '@iconify/types';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options
|
|
7
|
+
*/
|
|
8
|
+
interface CheckBadTagsOptions {
|
|
9
|
+
keepTitles?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Test for bag tags
|
|
13
|
+
*/
|
|
14
|
+
declare function checkBadTags(svg: SVG, options?: CheckBadTagsOptions): void;
|
|
15
|
+
|
|
16
|
+
export { CheckBadTagsOptions, checkBadTags };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SVG } from '../index.js';
|
|
2
|
+
import '@iconify/types';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
|
+
|
|
5
|
+
interface CleanupRootStyleResult {
|
|
6
|
+
animations?: Set<string>;
|
|
7
|
+
removedAtRules?: Set<string>;
|
|
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): CleanupRootStyleResult;
|
|
15
|
+
|
|
16
|
+
export { cleanupRootStyle };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SVG } from './index.js';
|
|
2
|
+
import { CheckBadTagsOptions } from './cleanup/bad-tags.js';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options
|
|
8
|
+
*/
|
|
9
|
+
type CleanupSVGOptions = CheckBadTagsOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Clean up SVG before parsing/optimising it
|
|
12
|
+
*/
|
|
13
|
+
declare function cleanupSVG(svg: SVG, options?: CleanupSVGOptions): void;
|
|
14
|
+
|
|
15
|
+
export { CleanupSVGOptions, cleanupSVG };
|
|
@@ -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 };
|