@iconify/tools 3.0.3 → 3.0.5

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.
Files changed (86) hide show
  1. package/lib/colors/attribs.d.ts +27 -0
  2. package/lib/colors/detect.d.ts +15 -0
  3. package/lib/colors/parse.d.ts +67 -0
  4. package/lib/colors/validate.d.ts +26 -0
  5. package/lib/css/parse.d.ts +6 -0
  6. package/lib/css/parser/error.d.ts +13 -0
  7. package/lib/css/parser/export.d.ts +8 -0
  8. package/lib/css/parser/strings.d.ts +16 -0
  9. package/lib/css/parser/text.d.ts +20 -0
  10. package/lib/css/parser/tokens.d.ts +9 -0
  11. package/lib/css/parser/tree.d.ts +8 -0
  12. package/lib/css/parser/types.d.ts +52 -0
  13. package/lib/download/api/cache.d.ts +20 -0
  14. package/lib/download/api/download.d.ts +8 -0
  15. package/lib/download/api/index.d.ts +8 -0
  16. package/lib/download/api/types.d.ts +17 -0
  17. package/lib/download/git/branch.d.ts +8 -0
  18. package/lib/download/git/hash.d.ts +8 -0
  19. package/lib/download/git/index.d.ts +29 -0
  20. package/lib/download/git/reset.d.ts +6 -0
  21. package/lib/download/github/hash.d.ts +8 -0
  22. package/lib/download/github/index.d.ts +31 -0
  23. package/lib/download/github/types.d.ts +11 -0
  24. package/lib/download/gitlab/hash.d.ts +8 -0
  25. package/lib/download/gitlab/index.d.ts +31 -0
  26. package/lib/download/gitlab/types.d.ts +15 -0
  27. package/lib/download/helpers/untar.d.ts +6 -0
  28. package/lib/download/helpers/unzip.d.ts +6 -0
  29. package/lib/download/index.d.ts +48 -0
  30. package/lib/download/npm/index.d.ts +30 -0
  31. package/lib/download/npm/types.d.ts +9 -0
  32. package/lib/download/npm/version.d.ts +16 -0
  33. package/lib/download/types/modified.d.ts +6 -0
  34. package/lib/download/types/sources.d.ts +12 -0
  35. package/lib/export/directory.d.ts +25 -0
  36. package/lib/export/helpers/custom-files.d.ts +12 -0
  37. package/lib/export/helpers/prepare.d.ts +19 -0
  38. package/lib/export/helpers/types-version.d.ts +6 -0
  39. package/lib/export/icon-package.d.ts +25 -0
  40. package/lib/export/json-package.d.ts +23 -0
  41. package/lib/icon-set/index.d.ts +161 -0
  42. package/lib/icon-set/match.d.ts +14 -0
  43. package/lib/icon-set/merge.d.ts +13 -0
  44. package/lib/icon-set/modified.d.ts +15 -0
  45. package/lib/icon-set/props.d.ts +13 -0
  46. package/lib/icon-set/tags.d.ts +22 -0
  47. package/lib/icon-set/types.d.ts +75 -0
  48. package/lib/import/directory.cjs +11 -2
  49. package/lib/import/directory.d.ts +51 -0
  50. package/lib/import/directory.mjs +11 -2
  51. package/lib/import/figma/index.d.ts +19 -0
  52. package/lib/import/figma/nodes.d.ts +17 -0
  53. package/lib/import/figma/query.d.ts +28 -0
  54. package/lib/import/figma/types/api.d.ts +53 -0
  55. package/lib/import/figma/types/nodes.d.ts +43 -0
  56. package/lib/import/figma/types/options.d.ts +58 -0
  57. package/lib/import/figma/types/result.d.ts +43 -0
  58. package/lib/index.d.ts +72 -0
  59. package/lib/misc/bump-version.d.ts +6 -0
  60. package/lib/misc/cheerio.d.ts +7 -0
  61. package/lib/misc/compare-dirs.d.ts +11 -0
  62. package/lib/misc/exec.d.ts +12 -0
  63. package/lib/misc/keyword.d.ts +6 -0
  64. package/lib/misc/scan.d.ts +33 -0
  65. package/lib/misc/write-json.d.ts +6 -0
  66. package/lib/optimise/flags.d.ts +10 -0
  67. package/lib/optimise/global-style.d.ts +10 -0
  68. package/lib/optimise/origin.d.ts +10 -0
  69. package/lib/optimise/scale.d.ts +10 -0
  70. package/lib/optimise/svgo.d.ts +36 -0
  71. package/lib/svg/analyse/error.d.ts +8 -0
  72. package/lib/svg/analyse/types.d.ts +89 -0
  73. package/lib/svg/analyse.d.ts +13 -0
  74. package/lib/svg/cleanup/attribs.d.ts +10 -0
  75. package/lib/svg/cleanup/bad-tags.d.ts +16 -0
  76. package/lib/svg/cleanup/inline-style.d.ts +10 -0
  77. package/lib/svg/cleanup/root-style.d.ts +16 -0
  78. package/lib/svg/cleanup/root-svg.d.ts +10 -0
  79. package/lib/svg/cleanup/svgo-style.d.ts +10 -0
  80. package/lib/svg/cleanup.d.ts +15 -0
  81. package/lib/svg/data/attributes.d.ts +77 -0
  82. package/lib/svg/data/tags.d.ts +95 -0
  83. package/lib/svg/index.d.ts +47 -0
  84. package/lib/svg/parse-style.d.ts +63 -0
  85. package/lib/svg/parse.d.ts +36 -0
  86. package/package.json +191 -191
@@ -0,0 +1,43 @@
1
+ import { IconFigmaNode, FigmaDocument } from './api.js';
2
+ import { FigmaNodesImportResult, FigmaIconNode } from './result.js';
3
+ import '../../../icon-set/index.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
+
10
+ type FigmaImportParentNodeType = 'CANVAS' | 'FRAME' | 'GROUP' | 'SECTION';
11
+ type FigmaImportIconNodeType = IconFigmaNode['type'];
12
+ /**
13
+ * Node information passed to callback
14
+ */
15
+ interface FigmaParentNodeData {
16
+ id: string;
17
+ type: FigmaImportParentNodeType;
18
+ name: string;
19
+ }
20
+ interface FigmaImportNodeData {
21
+ id: string;
22
+ type: FigmaImportIconNodeType;
23
+ name: string;
24
+ width: number;
25
+ height: number;
26
+ parents: FigmaParentNodeData[];
27
+ }
28
+ /**
29
+ * Callback to check if node needs to be checked for icons
30
+ *
31
+ * Used to speed up processing by eleminating pages, frames and groups that do not need processing
32
+ */
33
+ type FigmaImportParentNodeFilter = (node: FigmaParentNodeData[], document: FigmaDocument) => boolean;
34
+ /**
35
+ * Check if node is an icon.
36
+ *
37
+ * Returns icon name on success, null or undefined if not should be ignored.
38
+ * Function can also return FigmaIconNode object, where it can put extra properties that can be used later
39
+ */
40
+ type FigmaIconNodeWithKeyword = Partial<FigmaIconNode> & Pick<FigmaIconNode, 'keyword'>;
41
+ type FigmaImportNodeFilter = (node: FigmaImportNodeData, nodes: FigmaNodesImportResult, document: FigmaDocument) => string | FigmaIconNodeWithKeyword | null | undefined;
42
+
43
+ export { FigmaImportIconNodeType, FigmaImportNodeData, FigmaImportNodeFilter, FigmaImportParentNodeFilter, FigmaImportParentNodeType, FigmaParentNodeData };
@@ -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,6 @@
1
+ /**
2
+ * Bump version number
3
+ */
4
+ declare function bumpVersion(version: string): string;
5
+
6
+ export { bumpVersion };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Shortcuts for Cheerio elements
3
+ */
4
+ type CheerioElement = cheerio.TagElement;
5
+ type WrappedCheerioElement = cheerio.Cheerio;
6
+
7
+ export { CheerioElement, WrappedCheerioElement };
@@ -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,6 @@
1
+ /**
2
+ * Clean up keyword
3
+ */
4
+ declare function cleanupIconKeyword(keyword: string, convertCamelCase?: boolean): string;
5
+
6
+ export { cleanupIconKeyword };
@@ -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,6 @@
1
+ /**
2
+ * Write JSON file
3
+ */
4
+ declare function writeJSONFile(filename: string, data: unknown): Promise<void>;
5
+
6
+ export { writeJSONFile };
@@ -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,10 @@
1
+ import { SVG } from '../svg/index.js';
2
+ import '@iconify/types';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
+
5
+ /**
6
+ * Expand global style
7
+ */
8
+ declare function cleanupGlobalStyle(svg: SVG): Promise<void>;
9
+
10
+ export { cleanupGlobalStyle };
@@ -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
+ * Reset origin to 0 0
7
+ */
8
+ declare function resetSVGOrigin(svg: SVG): void;
9
+
10
+ export { resetSVGOrigin };
@@ -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
+ * Scale icon
7
+ */
8
+ declare function scaleSVG(svg: SVG, scale: number): void;
9
+
10
+ export { scaleSVG };
@@ -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,8 @@
1
+ import { ExtendedTagElement } from './types.js';
2
+
3
+ /**
4
+ * Get tag for error message
5
+ */
6
+ declare function analyseTagError(element: ExtendedTagElement): string;
7
+
8
+ export { analyseTagError };
@@ -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,10 @@
1
+ import { SVG } from '../index.js';
2
+ import '@iconify/types';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
+
5
+ /**
6
+ * Remove useless attributes
7
+ */
8
+ declare function removeBadAttributes(svg: SVG): void;
9
+
10
+ export { removeBadAttributes };
@@ -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,10 @@
1
+ import { SVG } from '../index.js';
2
+ import '@iconify/types';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
+
5
+ /**
6
+ * Expand inline style
7
+ */
8
+ declare function cleanupInlineStyle(svg: SVG): void;
9
+
10
+ export { cleanupInlineStyle };
@@ -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,10 @@
1
+ import { SVG } from '../index.js';
2
+ import '@iconify/types';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
+
5
+ /**
6
+ * Clean up SVG
7
+ */
8
+ declare function cleanupSVGRoot(svg: SVG): void;
9
+
10
+ export { cleanupSVGRoot };
@@ -0,0 +1,10 @@
1
+ import { SVG } from '../index.js';
2
+ import '@iconify/types';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
+
5
+ /**
6
+ * Expand inline style
7
+ */
8
+ declare function convertStyleToAttrs(svg: SVG): void;
9
+
10
+ export { convertStyleToAttrs };
@@ -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 };