@iconify/tools 4.0.0-dev.1 → 4.0.1
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 +15 -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 +14 -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 +3 -3
- package/lib/misc/write-json.d.cts +6 -0
- package/lib/misc/write-json.d.mts +6 -0
- package/lib/optimise/figma.cjs +55 -33
- package/lib/optimise/figma.d.cts +13 -0
- package/lib/optimise/figma.d.mts +13 -0
- package/lib/optimise/figma.d.ts +3 -1
- package/lib/optimise/figma.mjs +55 -33
- 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/optimise/unwrap.cjs +31 -0
- package/lib/optimise/unwrap.d.cts +11 -0
- package/lib/optimise/unwrap.d.mts +11 -0
- package/lib/optimise/unwrap.d.ts +11 -0
- package/lib/optimise/unwrap.mjs +29 -0
- 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 +34 -24
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { IconifyInfo, IconifyJSON } from '@iconify/types';
|
|
2
|
+
import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
|
3
|
+
import { IconSetIconEntry, IconCategory, IconSetIconType, IconSetAsyncForEachCallback, IconSetSyncForEachCallback, ResolvedIconifyIcon, CommonIconProps, CheckThemeResult } from './types.mjs';
|
|
4
|
+
import { SVG } from '../svg/index.mjs';
|
|
5
|
+
import { ParentIconsTree } from '@iconify/utils/lib/icon-set/tree';
|
|
6
|
+
import 'cheerio';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Sort theme keys: long keys first
|
|
10
|
+
*
|
|
11
|
+
* Applies changes to parameter, but also returns it
|
|
12
|
+
*/
|
|
13
|
+
declare function sortThemeKeys(keys: string[]): string[];
|
|
14
|
+
/**
|
|
15
|
+
* Export icon set
|
|
16
|
+
*/
|
|
17
|
+
declare class IconSet {
|
|
18
|
+
/**
|
|
19
|
+
* Properties. You can write directly to almost any property, but avoid writing to
|
|
20
|
+
* 'entries' and 'categories' properties, there are functions for that.
|
|
21
|
+
*/
|
|
22
|
+
prefix: string;
|
|
23
|
+
lastModified: number;
|
|
24
|
+
entries: Record<string, IconSetIconEntry>;
|
|
25
|
+
info: IconifyInfo | undefined;
|
|
26
|
+
categories: Set<IconCategory>;
|
|
27
|
+
prefixes: Record<string, string>;
|
|
28
|
+
suffixes: Record<string, string>;
|
|
29
|
+
/**
|
|
30
|
+
* Load icon set
|
|
31
|
+
*/
|
|
32
|
+
constructor(data: IconifyJSON);
|
|
33
|
+
/**
|
|
34
|
+
* Load icon set
|
|
35
|
+
*/
|
|
36
|
+
load(data: IconifyJSON): void;
|
|
37
|
+
/**
|
|
38
|
+
* Update last modification time
|
|
39
|
+
*/
|
|
40
|
+
updateLastModified(value?: number): void;
|
|
41
|
+
/**
|
|
42
|
+
* List icons
|
|
43
|
+
*/
|
|
44
|
+
list(types?: IconSetIconType[]): string[];
|
|
45
|
+
/**
|
|
46
|
+
* forEach function to loop through all entries.
|
|
47
|
+
* Supports asynchronous callbacks.
|
|
48
|
+
*
|
|
49
|
+
* Callback should return false to stop loop.
|
|
50
|
+
*/
|
|
51
|
+
forEach(callback: IconSetAsyncForEachCallback, types?: IconSetIconType[]): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Synchronous version of forEach function to loop through all entries.
|
|
54
|
+
*
|
|
55
|
+
* Callback should return false to stop loop.
|
|
56
|
+
*/
|
|
57
|
+
forEachSync(callback: IconSetSyncForEachCallback, types?: IconSetIconType[]): void;
|
|
58
|
+
/**
|
|
59
|
+
* Get parent icons tree
|
|
60
|
+
*
|
|
61
|
+
* Returns parent icons list for each icon, null if failed to resolve.
|
|
62
|
+
* In parent icons list, first element is a direct parent, last is icon. Does not include item.
|
|
63
|
+
*
|
|
64
|
+
* Examples:
|
|
65
|
+
* 'alias3': ['alias2', 'alias1', 'icon']
|
|
66
|
+
* 'icon': []
|
|
67
|
+
* 'bad-icon': null
|
|
68
|
+
*/
|
|
69
|
+
getTree(names?: string[]): ParentIconsTree;
|
|
70
|
+
/**
|
|
71
|
+
* Resolve icon
|
|
72
|
+
*/
|
|
73
|
+
resolve(name: string, full: false): ResolvedIconifyIcon | null;
|
|
74
|
+
resolve(name: string): ResolvedIconifyIcon | null;
|
|
75
|
+
resolve(name: string, full: true): Required<ResolvedIconifyIcon> | null;
|
|
76
|
+
/**
|
|
77
|
+
* Generate HTML
|
|
78
|
+
*/
|
|
79
|
+
toString(name: string, customisations?: IconifyIconCustomisations): string | null;
|
|
80
|
+
/**
|
|
81
|
+
* Get SVG instance for icon
|
|
82
|
+
*/
|
|
83
|
+
toSVG(name: string): SVG | null;
|
|
84
|
+
/**
|
|
85
|
+
* Export icon set
|
|
86
|
+
*/
|
|
87
|
+
export(validate?: boolean): IconifyJSON;
|
|
88
|
+
/**
|
|
89
|
+
* Get characters map
|
|
90
|
+
*/
|
|
91
|
+
chars(names?: string[]): Record<string, string>;
|
|
92
|
+
/**
|
|
93
|
+
* Filter icons
|
|
94
|
+
*/
|
|
95
|
+
_filter(callback: (name: string, item: IconSetIconEntry, icon?: ResolvedIconifyIcon) => boolean): string[];
|
|
96
|
+
/**
|
|
97
|
+
* Count icons
|
|
98
|
+
*/
|
|
99
|
+
count(): number;
|
|
100
|
+
/**
|
|
101
|
+
* Find category by title
|
|
102
|
+
*/
|
|
103
|
+
findCategory(title: string, add: boolean): IconCategory | null;
|
|
104
|
+
/**
|
|
105
|
+
* Count icons in category, remove category if empty
|
|
106
|
+
*
|
|
107
|
+
* Hidden icons and aliases do not count
|
|
108
|
+
*/
|
|
109
|
+
listCategory(category: IconCategory | string): string[] | null;
|
|
110
|
+
/**
|
|
111
|
+
* Check if icon exists
|
|
112
|
+
*/
|
|
113
|
+
exists(name: string): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Remove icons. Returns number of removed icons
|
|
116
|
+
*
|
|
117
|
+
* If removeDependencies is a string, it represents new parent for all aliases of removed icon. New parent cannot be alias or variation.
|
|
118
|
+
*/
|
|
119
|
+
remove(name: string, removeDependencies?: boolean | string): number;
|
|
120
|
+
/**
|
|
121
|
+
* Rename icon
|
|
122
|
+
*/
|
|
123
|
+
rename(oldName: string, newName: string): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Add/update item
|
|
126
|
+
*/
|
|
127
|
+
setItem(name: string, item: IconSetIconEntry): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Add/update icon
|
|
130
|
+
*/
|
|
131
|
+
setIcon(name: string, icon: ResolvedIconifyIcon): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Add/update alias without props
|
|
134
|
+
*/
|
|
135
|
+
setAlias(name: string, parent: string): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Add/update alias with props
|
|
138
|
+
*/
|
|
139
|
+
setVariation(name: string, parent: string, props: CommonIconProps): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Icon from SVG. Updates old icon if it exists
|
|
142
|
+
*/
|
|
143
|
+
fromSVG(name: string, svg: SVG): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Add or remove character for icon
|
|
146
|
+
*/
|
|
147
|
+
toggleCharacter(iconName: string, char: string, add: boolean): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Add or remove category for icon
|
|
150
|
+
*/
|
|
151
|
+
toggleCategory(iconName: string, category: string, add: boolean): boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Find icons that belong to theme
|
|
154
|
+
*/
|
|
155
|
+
checkTheme(prefix: boolean): CheckThemeResult;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Create blank icon set
|
|
159
|
+
*/
|
|
160
|
+
declare function blankIconSet(prefix: string): IconSet;
|
|
161
|
+
|
|
162
|
+
export { IconSet, blankIconSet, sortThemeKeys };
|
package/lib/icon-set/index.mjs
CHANGED
|
@@ -8,6 +8,12 @@ import { mergeIconData } from '@iconify/utils';
|
|
|
8
8
|
import '@iconify/utils/lib/misc/objects';
|
|
9
9
|
import 'cheerio';
|
|
10
10
|
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __publicField = (obj, key, value) => {
|
|
14
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
11
17
|
const themeKeys = ["prefixes", "suffixes"];
|
|
12
18
|
function sortThemeKeys(keys) {
|
|
13
19
|
return keys.sort(
|
|
@@ -19,6 +25,22 @@ class IconSet {
|
|
|
19
25
|
* Load icon set
|
|
20
26
|
*/
|
|
21
27
|
constructor(data) {
|
|
28
|
+
/**
|
|
29
|
+
* Properties. You can write directly to almost any property, but avoid writing to
|
|
30
|
+
* 'entries' and 'categories' properties, there are functions for that.
|
|
31
|
+
*/
|
|
32
|
+
// Icon set prefix
|
|
33
|
+
__publicField(this, "prefix");
|
|
34
|
+
// Last modification time
|
|
35
|
+
__publicField(this, "lastModified");
|
|
36
|
+
// All icons
|
|
37
|
+
__publicField(this, "entries");
|
|
38
|
+
// Information block
|
|
39
|
+
__publicField(this, "info");
|
|
40
|
+
// Categories, using custom type. Use functions to update data
|
|
41
|
+
__publicField(this, "categories");
|
|
42
|
+
__publicField(this, "prefixes");
|
|
43
|
+
__publicField(this, "suffixes");
|
|
22
44
|
this.load(data);
|
|
23
45
|
}
|
|
24
46
|
/**
|
|
@@ -143,10 +165,9 @@ class IconSet {
|
|
|
143
165
|
* List icons
|
|
144
166
|
*/
|
|
145
167
|
list(types = ["icon", "variation"]) {
|
|
146
|
-
return Object.keys(this.entries).filter(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
});
|
|
168
|
+
return Object.keys(this.entries).filter(
|
|
169
|
+
(name) => types.includes(this.entries[name].type)
|
|
170
|
+
);
|
|
150
171
|
}
|
|
151
172
|
/**
|
|
152
173
|
* forEach function to loop through all entries.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FullIconifyIcon } from '@iconify/utils/lib/icon/defaults';
|
|
2
|
+
import { IconSet } from './index.cjs';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
import './types.cjs';
|
|
6
|
+
import '../svg/index.cjs';
|
|
7
|
+
import 'cheerio';
|
|
8
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Find matching icon in icon set
|
|
12
|
+
*/
|
|
13
|
+
declare function findMatchingIcon(iconSet: IconSet, icon: FullIconifyIcon): string | null;
|
|
14
|
+
|
|
15
|
+
export { findMatchingIcon };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FullIconifyIcon } from '@iconify/utils/lib/icon/defaults';
|
|
2
|
+
import { IconSet } from './index.mjs';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
import './types.mjs';
|
|
6
|
+
import '../svg/index.mjs';
|
|
7
|
+
import 'cheerio';
|
|
8
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Find matching icon in icon set
|
|
12
|
+
*/
|
|
13
|
+
declare function findMatchingIcon(iconSet: IconSet, icon: FullIconifyIcon): string | null;
|
|
14
|
+
|
|
15
|
+
export { findMatchingIcon };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IconSet } from './index.cjs';
|
|
2
|
+
import '@iconify/types';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
|
+
import './types.cjs';
|
|
5
|
+
import '../svg/index.cjs';
|
|
6
|
+
import 'cheerio';
|
|
7
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Merge icon sets
|
|
11
|
+
*/
|
|
12
|
+
declare function mergeIconSets(oldIcons: IconSet, newIcons: IconSet): IconSet;
|
|
13
|
+
|
|
14
|
+
export { mergeIconSets };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IconSet } from './index.mjs';
|
|
2
|
+
import '@iconify/types';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
|
+
import './types.mjs';
|
|
5
|
+
import '../svg/index.mjs';
|
|
6
|
+
import 'cheerio';
|
|
7
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Merge icon sets
|
|
11
|
+
*/
|
|
12
|
+
declare function mergeIconSets(oldIcons: IconSet, newIcons: IconSet): IconSet;
|
|
13
|
+
|
|
14
|
+
export { mergeIconSets };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IconSet } from './index.cjs';
|
|
2
|
+
import '@iconify/types';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
|
+
import './types.cjs';
|
|
5
|
+
import '../svg/index.cjs';
|
|
6
|
+
import 'cheerio';
|
|
7
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Check if icons in an icon set were updated.
|
|
11
|
+
*
|
|
12
|
+
* This function checks only icons, not metadata. It also ignores icon visibility.
|
|
13
|
+
*/
|
|
14
|
+
declare function hasIconDataBeenModified(set1: IconSet, set2: IconSet): boolean;
|
|
15
|
+
|
|
16
|
+
export { hasIconDataBeenModified };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IconSet } from './index.mjs';
|
|
2
|
+
import '@iconify/types';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
|
+
import './types.mjs';
|
|
5
|
+
import '../svg/index.mjs';
|
|
6
|
+
import 'cheerio';
|
|
7
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Check if icons in an icon set were updated.
|
|
11
|
+
*
|
|
12
|
+
* This function checks only icons, not metadata. It also ignores icon visibility.
|
|
13
|
+
*/
|
|
14
|
+
declare function hasIconDataBeenModified(set1: IconSet, set2: IconSet): boolean;
|
|
15
|
+
|
|
16
|
+
export { hasIconDataBeenModified };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommonIconProps } from './types.cjs';
|
|
2
|
+
import '@iconify/types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Common properties for icon and alias
|
|
6
|
+
*/
|
|
7
|
+
declare const defaultCommonProps: Required<CommonIconProps>;
|
|
8
|
+
/**
|
|
9
|
+
* Filter icon props: copies properties, removing undefined and default entries
|
|
10
|
+
*/
|
|
11
|
+
declare function filterProps(data: CommonIconProps, reference: CommonIconProps, compareDefaultValues: boolean): CommonIconProps;
|
|
12
|
+
|
|
13
|
+
export { defaultCommonProps, filterProps };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommonIconProps } from './types.mjs';
|
|
2
|
+
import '@iconify/types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Common properties for icon and alias
|
|
6
|
+
*/
|
|
7
|
+
declare const defaultCommonProps: Required<CommonIconProps>;
|
|
8
|
+
/**
|
|
9
|
+
* Filter icon props: copies properties, removing undefined and default entries
|
|
10
|
+
*/
|
|
11
|
+
declare function filterProps(data: CommonIconProps, reference: CommonIconProps, compareDefaultValues: boolean): CommonIconProps;
|
|
12
|
+
|
|
13
|
+
export { defaultCommonProps, filterProps };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IconSet } from './index.cjs';
|
|
2
|
+
import '@iconify/types';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
|
+
import './types.cjs';
|
|
5
|
+
import '../svg/index.cjs';
|
|
6
|
+
import 'cheerio';
|
|
7
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
8
|
+
|
|
9
|
+
declare const paletteTags: {
|
|
10
|
+
monotone: string;
|
|
11
|
+
palette: string;
|
|
12
|
+
};
|
|
13
|
+
declare const sizeTags: {
|
|
14
|
+
square: string;
|
|
15
|
+
gridPrefix: string;
|
|
16
|
+
heightPrefix: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Add tags to icon set
|
|
20
|
+
*/
|
|
21
|
+
declare function addTagsToIconSet(iconSet: IconSet, customTags?: string[]): string[];
|
|
22
|
+
|
|
23
|
+
export { addTagsToIconSet, paletteTags, sizeTags };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IconSet } from './index.mjs';
|
|
2
|
+
import '@iconify/types';
|
|
3
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
4
|
+
import './types.mjs';
|
|
5
|
+
import '../svg/index.mjs';
|
|
6
|
+
import 'cheerio';
|
|
7
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
8
|
+
|
|
9
|
+
declare const paletteTags: {
|
|
10
|
+
monotone: string;
|
|
11
|
+
palette: string;
|
|
12
|
+
};
|
|
13
|
+
declare const sizeTags: {
|
|
14
|
+
square: string;
|
|
15
|
+
gridPrefix: string;
|
|
16
|
+
heightPrefix: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Add tags to icon set
|
|
20
|
+
*/
|
|
21
|
+
declare function addTagsToIconSet(iconSet: IconSet, customTags?: string[]): string[];
|
|
22
|
+
|
|
23
|
+
export { addTagsToIconSet, paletteTags, sizeTags };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ExtendedIconifyIcon, ExtendedIconifyAlias, IconifyOptional, IconifyIcon } from '@iconify/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Category item
|
|
5
|
+
*/
|
|
6
|
+
interface IconCategory {
|
|
7
|
+
title: string;
|
|
8
|
+
count: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get common properties: IconifyOptional + APIIconAttributes
|
|
12
|
+
*/
|
|
13
|
+
type CommonProps<A, B> = {
|
|
14
|
+
[K in keyof A & keyof B]?: A[K] extends B[K] ? A[K] : never;
|
|
15
|
+
};
|
|
16
|
+
type CommonIconProps = CommonProps<ExtendedIconifyIcon, ExtendedIconifyAlias>;
|
|
17
|
+
/**
|
|
18
|
+
* Exclude IconifyOptional from CommonIconProps
|
|
19
|
+
*/
|
|
20
|
+
type ExtraIconProps = Omit<CommonIconProps, keyof IconifyOptional>;
|
|
21
|
+
/**
|
|
22
|
+
* Partials
|
|
23
|
+
*/
|
|
24
|
+
interface IconWithChars {
|
|
25
|
+
chars: Set<string>;
|
|
26
|
+
}
|
|
27
|
+
interface IconWithPropsData extends IconWithChars {
|
|
28
|
+
props: CommonIconProps;
|
|
29
|
+
}
|
|
30
|
+
interface IconWithCategories {
|
|
31
|
+
categories: Set<IconCategory>;
|
|
32
|
+
}
|
|
33
|
+
interface IconParentData {
|
|
34
|
+
parent: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Icon types
|
|
38
|
+
*/
|
|
39
|
+
interface IconSetIcon extends IconWithPropsData, IconWithCategories {
|
|
40
|
+
type: 'icon';
|
|
41
|
+
body: string;
|
|
42
|
+
}
|
|
43
|
+
interface IconSetIconAlias extends IconWithChars, IconParentData {
|
|
44
|
+
type: 'alias';
|
|
45
|
+
}
|
|
46
|
+
interface IconSetIconVariation extends IconWithPropsData, IconParentData {
|
|
47
|
+
type: 'variation';
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* All icon types
|
|
51
|
+
*/
|
|
52
|
+
type IconSetIconEntry = IconSetIcon | IconSetIconAlias | IconSetIconVariation;
|
|
53
|
+
type IconSetIconType = IconSetIconEntry['type'];
|
|
54
|
+
/**
|
|
55
|
+
* Full icon with extra stuff
|
|
56
|
+
*/
|
|
57
|
+
interface ResolvedIconifyIcon extends IconifyIcon, ExtraIconProps {
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Result for checking theme: list of names for each theme
|
|
61
|
+
*/
|
|
62
|
+
interface CheckThemeResult {
|
|
63
|
+
valid: Record<string, string[]>;
|
|
64
|
+
invalid: string[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Callback for forEach functions
|
|
68
|
+
*
|
|
69
|
+
* Return false to stop loop
|
|
70
|
+
*/
|
|
71
|
+
type IconSetForEachCallbackResult = void | false;
|
|
72
|
+
type IconSetAsyncForEachCallback = (name: string, type: IconSetIconEntry['type']) => Promise<IconSetForEachCallbackResult> | IconSetForEachCallbackResult;
|
|
73
|
+
type IconSetSyncForEachCallback = (name: string, type: IconSetIconEntry['type']) => IconSetForEachCallbackResult;
|
|
74
|
+
|
|
75
|
+
export type { CheckThemeResult, CommonIconProps, ExtraIconProps, IconCategory, IconParentData, IconSetAsyncForEachCallback, IconSetIcon, IconSetIconAlias, IconSetIconEntry, IconSetIconType, IconSetIconVariation, IconSetSyncForEachCallback, IconWithCategories, IconWithChars, IconWithPropsData, ResolvedIconifyIcon };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ExtendedIconifyIcon, ExtendedIconifyAlias, IconifyOptional, IconifyIcon } from '@iconify/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Category item
|
|
5
|
+
*/
|
|
6
|
+
interface IconCategory {
|
|
7
|
+
title: string;
|
|
8
|
+
count: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get common properties: IconifyOptional + APIIconAttributes
|
|
12
|
+
*/
|
|
13
|
+
type CommonProps<A, B> = {
|
|
14
|
+
[K in keyof A & keyof B]?: A[K] extends B[K] ? A[K] : never;
|
|
15
|
+
};
|
|
16
|
+
type CommonIconProps = CommonProps<ExtendedIconifyIcon, ExtendedIconifyAlias>;
|
|
17
|
+
/**
|
|
18
|
+
* Exclude IconifyOptional from CommonIconProps
|
|
19
|
+
*/
|
|
20
|
+
type ExtraIconProps = Omit<CommonIconProps, keyof IconifyOptional>;
|
|
21
|
+
/**
|
|
22
|
+
* Partials
|
|
23
|
+
*/
|
|
24
|
+
interface IconWithChars {
|
|
25
|
+
chars: Set<string>;
|
|
26
|
+
}
|
|
27
|
+
interface IconWithPropsData extends IconWithChars {
|
|
28
|
+
props: CommonIconProps;
|
|
29
|
+
}
|
|
30
|
+
interface IconWithCategories {
|
|
31
|
+
categories: Set<IconCategory>;
|
|
32
|
+
}
|
|
33
|
+
interface IconParentData {
|
|
34
|
+
parent: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Icon types
|
|
38
|
+
*/
|
|
39
|
+
interface IconSetIcon extends IconWithPropsData, IconWithCategories {
|
|
40
|
+
type: 'icon';
|
|
41
|
+
body: string;
|
|
42
|
+
}
|
|
43
|
+
interface IconSetIconAlias extends IconWithChars, IconParentData {
|
|
44
|
+
type: 'alias';
|
|
45
|
+
}
|
|
46
|
+
interface IconSetIconVariation extends IconWithPropsData, IconParentData {
|
|
47
|
+
type: 'variation';
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* All icon types
|
|
51
|
+
*/
|
|
52
|
+
type IconSetIconEntry = IconSetIcon | IconSetIconAlias | IconSetIconVariation;
|
|
53
|
+
type IconSetIconType = IconSetIconEntry['type'];
|
|
54
|
+
/**
|
|
55
|
+
* Full icon with extra stuff
|
|
56
|
+
*/
|
|
57
|
+
interface ResolvedIconifyIcon extends IconifyIcon, ExtraIconProps {
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Result for checking theme: list of names for each theme
|
|
61
|
+
*/
|
|
62
|
+
interface CheckThemeResult {
|
|
63
|
+
valid: Record<string, string[]>;
|
|
64
|
+
invalid: string[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Callback for forEach functions
|
|
68
|
+
*
|
|
69
|
+
* Return false to stop loop
|
|
70
|
+
*/
|
|
71
|
+
type IconSetForEachCallbackResult = void | false;
|
|
72
|
+
type IconSetAsyncForEachCallback = (name: string, type: IconSetIconEntry['type']) => Promise<IconSetForEachCallbackResult> | IconSetForEachCallbackResult;
|
|
73
|
+
type IconSetSyncForEachCallback = (name: string, type: IconSetIconEntry['type']) => IconSetForEachCallbackResult;
|
|
74
|
+
|
|
75
|
+
export type { CheckThemeResult, CommonIconProps, ExtraIconProps, IconCategory, IconParentData, IconSetAsyncForEachCallback, IconSetIcon, IconSetIconAlias, IconSetIconEntry, IconSetIconType, IconSetIconVariation, IconSetSyncForEachCallback, IconWithCategories, IconWithChars, IconWithPropsData, ResolvedIconifyIcon };
|
package/lib/icon-set/types.d.ts
CHANGED
|
@@ -72,4 +72,4 @@ type IconSetForEachCallbackResult = void | false;
|
|
|
72
72
|
type IconSetAsyncForEachCallback = (name: string, type: IconSetIconEntry['type']) => Promise<IconSetForEachCallbackResult> | IconSetForEachCallbackResult;
|
|
73
73
|
type IconSetSyncForEachCallback = (name: string, type: IconSetIconEntry['type']) => IconSetForEachCallbackResult;
|
|
74
74
|
|
|
75
|
-
export { CheckThemeResult, CommonIconProps, ExtraIconProps, IconCategory, IconParentData, IconSetAsyncForEachCallback, IconSetIcon, IconSetIconAlias, IconSetIconEntry, IconSetIconType, IconSetIconVariation, IconSetSyncForEachCallback, IconWithCategories, IconWithChars, IconWithPropsData, ResolvedIconifyIcon };
|
|
75
|
+
export type { CheckThemeResult, CommonIconProps, ExtraIconProps, IconCategory, IconParentData, IconSetAsyncForEachCallback, IconSetIcon, IconSetIconAlias, IconSetIconEntry, IconSetIconType, IconSetIconVariation, IconSetSyncForEachCallback, IconWithCategories, IconWithChars, IconWithPropsData, ResolvedIconifyIcon };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { IconSet } from '../icon-set/index.cjs';
|
|
2
|
+
import { CleanupSVGOptions } from '../svg/cleanup.cjs';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
import '../icon-set/types.cjs';
|
|
6
|
+
import '../svg/index.cjs';
|
|
7
|
+
import 'cheerio';
|
|
8
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
9
|
+
import '../svg/cleanup/bad-tags.cjs';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Entry for file
|
|
13
|
+
*/
|
|
14
|
+
interface ImportDirectoryFileEntry {
|
|
15
|
+
path: string;
|
|
16
|
+
subdir: string;
|
|
17
|
+
file: string;
|
|
18
|
+
ext: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Callback to get keyword for icon based on file name
|
|
22
|
+
*
|
|
23
|
+
* Returns:
|
|
24
|
+
* - string for new keyword
|
|
25
|
+
* - undefined to skip icon
|
|
26
|
+
*
|
|
27
|
+
* Callback can be asynchronous
|
|
28
|
+
*/
|
|
29
|
+
type ImportDirectoryKeywordCallbackResult = string | undefined;
|
|
30
|
+
type Callback<T> = (file: ImportDirectoryFileEntry, defaultKeyword: string, iconSet: IconSet) => T;
|
|
31
|
+
type AsyncCallback<T> = Callback<T | Promise<T>>;
|
|
32
|
+
type ImportDirectoryKeywordCallback = AsyncCallback<ImportDirectoryKeywordCallbackResult>;
|
|
33
|
+
type ImportDirectoryKeywordSyncCallback = Callback<ImportDirectoryKeywordCallbackResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Options
|
|
36
|
+
*/
|
|
37
|
+
interface ImportDirectoryOptions<K> extends CleanupSVGOptions {
|
|
38
|
+
prefix?: string;
|
|
39
|
+
includeSubDirs?: boolean;
|
|
40
|
+
keyword?: K;
|
|
41
|
+
ignoreImportErrors?: boolean | 'warn';
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Import all icons from directory
|
|
45
|
+
*/
|
|
46
|
+
declare function importDirectory(path: string, options?: ImportDirectoryOptions<ImportDirectoryKeywordCallback>): Promise<IconSet>;
|
|
47
|
+
/**
|
|
48
|
+
* Import all icons from directory synchronously
|
|
49
|
+
*/
|
|
50
|
+
declare function importDirectorySync(path: string, options?: ImportDirectoryOptions<ImportDirectoryKeywordSyncCallback>): IconSet;
|
|
51
|
+
|
|
52
|
+
export { type ImportDirectoryFileEntry, type ImportDirectoryKeywordCallback, type ImportDirectoryKeywordSyncCallback, importDirectory, importDirectorySync };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { IconSet } from '../icon-set/index.mjs';
|
|
2
|
+
import { CleanupSVGOptions } from '../svg/cleanup.mjs';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
5
|
+
import '../icon-set/types.mjs';
|
|
6
|
+
import '../svg/index.mjs';
|
|
7
|
+
import 'cheerio';
|
|
8
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
9
|
+
import '../svg/cleanup/bad-tags.mjs';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Entry for file
|
|
13
|
+
*/
|
|
14
|
+
interface ImportDirectoryFileEntry {
|
|
15
|
+
path: string;
|
|
16
|
+
subdir: string;
|
|
17
|
+
file: string;
|
|
18
|
+
ext: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Callback to get keyword for icon based on file name
|
|
22
|
+
*
|
|
23
|
+
* Returns:
|
|
24
|
+
* - string for new keyword
|
|
25
|
+
* - undefined to skip icon
|
|
26
|
+
*
|
|
27
|
+
* Callback can be asynchronous
|
|
28
|
+
*/
|
|
29
|
+
type ImportDirectoryKeywordCallbackResult = string | undefined;
|
|
30
|
+
type Callback<T> = (file: ImportDirectoryFileEntry, defaultKeyword: string, iconSet: IconSet) => T;
|
|
31
|
+
type AsyncCallback<T> = Callback<T | Promise<T>>;
|
|
32
|
+
type ImportDirectoryKeywordCallback = AsyncCallback<ImportDirectoryKeywordCallbackResult>;
|
|
33
|
+
type ImportDirectoryKeywordSyncCallback = Callback<ImportDirectoryKeywordCallbackResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Options
|
|
36
|
+
*/
|
|
37
|
+
interface ImportDirectoryOptions<K> extends CleanupSVGOptions {
|
|
38
|
+
prefix?: string;
|
|
39
|
+
includeSubDirs?: boolean;
|
|
40
|
+
keyword?: K;
|
|
41
|
+
ignoreImportErrors?: boolean | 'warn';
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Import all icons from directory
|
|
45
|
+
*/
|
|
46
|
+
declare function importDirectory(path: string, options?: ImportDirectoryOptions<ImportDirectoryKeywordCallback>): Promise<IconSet>;
|
|
47
|
+
/**
|
|
48
|
+
* Import all icons from directory synchronously
|
|
49
|
+
*/
|
|
50
|
+
declare function importDirectorySync(path: string, options?: ImportDirectoryOptions<ImportDirectoryKeywordSyncCallback>): IconSet;
|
|
51
|
+
|
|
52
|
+
export { type ImportDirectoryFileEntry, type ImportDirectoryKeywordCallback, type ImportDirectoryKeywordSyncCallback, importDirectory, importDirectorySync };
|
|
@@ -49,4 +49,4 @@ declare function importDirectory(path: string, options?: ImportDirectoryOptions<
|
|
|
49
49
|
*/
|
|
50
50
|
declare function importDirectorySync(path: string, options?: ImportDirectoryOptions<ImportDirectoryKeywordSyncCallback>): IconSet;
|
|
51
51
|
|
|
52
|
-
export { ImportDirectoryFileEntry, ImportDirectoryKeywordCallback, ImportDirectoryKeywordSyncCallback, importDirectory, importDirectorySync };
|
|
52
|
+
export { type ImportDirectoryFileEntry, type ImportDirectoryKeywordCallback, type ImportDirectoryKeywordSyncCallback, importDirectory, importDirectorySync };
|
|
@@ -34,10 +34,13 @@ require('../../optimise/svgo.cjs');
|
|
|
34
34
|
require('svgo');
|
|
35
35
|
require('@iconify/utils/lib/svg/id');
|
|
36
36
|
require('../../download/api/index.cjs');
|
|
37
|
+
require('axios');
|
|
37
38
|
require('../../download/api/cache.cjs');
|
|
38
39
|
require('fs');
|
|
39
40
|
require('crypto');
|
|
40
41
|
require('../../misc/scan.cjs');
|
|
42
|
+
require('../../download/api/config.cjs');
|
|
43
|
+
require('../../download/api/queue.cjs');
|
|
41
44
|
|
|
42
45
|
async function importFromFigma(options) {
|
|
43
46
|
const cacheOptions = options.cacheDir ? {
|