@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,25 @@
1
+ import { IconSet } from '../icon-set/index.js';
2
+ import { ExportTargetOptions } from './helpers/prepare.js';
3
+ import '@iconify/types';
4
+ import '@iconify/utils/lib/customisations/defaults';
5
+ import '../icon-set/types.js';
6
+ import '../svg/index.js';
7
+ import '@iconify/utils/lib/icon-set/tree';
8
+
9
+ /**
10
+ * Options
11
+ */
12
+ interface ExportToDirectoryOptions extends ExportTargetOptions {
13
+ autoHeight?: boolean;
14
+ includeAliases?: boolean;
15
+ includeChars?: boolean;
16
+ log?: boolean;
17
+ }
18
+ /**
19
+ * Export icon set to directory
20
+ *
21
+ * Returns list of stored files
22
+ */
23
+ declare function exportToDirectory(iconSet: IconSet, options: ExportToDirectoryOptions): Promise<string[]>;
24
+
25
+ export { ExportToDirectoryOptions, exportToDirectory };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Options
3
+ */
4
+ interface ExportOptionsWithCustomFiles {
5
+ customFiles?: Record<string, string | Record<string, unknown> | null>;
6
+ }
7
+ /**
8
+ * Write custom files
9
+ */
10
+ declare function exportCustomFiles(dir: string, options: ExportOptionsWithCustomFiles, result?: Set<string>): Promise<void>;
11
+
12
+ export { ExportOptionsWithCustomFiles, exportCustomFiles };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Common options for all functions that export to directory
3
+ */
4
+ interface ExportTargetOptions {
5
+ target: string;
6
+ cleanup?: boolean;
7
+ }
8
+ /**
9
+ * Normalize directory
10
+ */
11
+ declare function normalizeDir(dir: string): string;
12
+ /**
13
+ * Prepare directory for export
14
+ *
15
+ * Also normalizes directory and returns normalized value
16
+ */
17
+ declare function prepareDirectoryForExport(options: ExportTargetOptions): Promise<string>;
18
+
19
+ export { ExportTargetOptions, normalizeDir, prepareDirectoryForExport };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get current version of Iconify Types package
3
+ */
4
+ declare function getTypesVersion(): Promise<string>;
5
+
6
+ export { getTypesVersion };
@@ -0,0 +1,25 @@
1
+ import { IconSet } from '../icon-set/index.js';
2
+ import { ExportTargetOptions } from './helpers/prepare.js';
3
+ import { ExportOptionsWithCustomFiles } from './helpers/custom-files.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
+ /**
11
+ * Options
12
+ */
13
+ interface ExportIconPackageOptions extends ExportTargetOptions, ExportOptionsWithCustomFiles {
14
+ package?: Record<string, unknown>;
15
+ module?: boolean;
16
+ typesContent?: string;
17
+ }
18
+ /**
19
+ * Export icon set as single icon packages
20
+ *
21
+ * Used for exporting `@iconify-icons/{prefix}` packages
22
+ */
23
+ declare function exportIconPackage(iconSet: IconSet, options: ExportIconPackageOptions): Promise<string[]>;
24
+
25
+ export { ExportIconPackageOptions, exportIconPackage };
@@ -0,0 +1,23 @@
1
+ import { IconSet } from '../icon-set/index.js';
2
+ import { ExportTargetOptions } from './helpers/prepare.js';
3
+ import { ExportOptionsWithCustomFiles } from './helpers/custom-files.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
+ /**
11
+ * Options
12
+ */
13
+ interface ExportJSONPackageOptions extends ExportTargetOptions, ExportOptionsWithCustomFiles {
14
+ package?: Record<string, unknown>;
15
+ }
16
+ /**
17
+ * Export icon set as JSON package
18
+ *
19
+ * Used for exporting `@iconify-json/{prefix}` packages
20
+ */
21
+ declare function exportJSONPackage(iconSet: IconSet, options: ExportJSONPackageOptions): Promise<string[]>;
22
+
23
+ export { ExportJSONPackageOptions, exportJSONPackage };
@@ -0,0 +1,161 @@
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.js';
4
+ import { SVG } from '../svg/index.js';
5
+ import { ParentIconsTree } from '@iconify/utils/lib/icon-set/tree';
6
+
7
+ /**
8
+ * Sort theme keys: long keys first
9
+ *
10
+ * Applies changes to parameter, but also returns it
11
+ */
12
+ declare function sortThemeKeys(keys: string[]): string[];
13
+ /**
14
+ * Export icon set
15
+ */
16
+ declare class IconSet {
17
+ /**
18
+ * Properties. You can write directly to almost any property, but avoid writing to
19
+ * 'entries' and 'categories' properties, there are functions for that.
20
+ */
21
+ prefix: string;
22
+ lastModified: number;
23
+ entries: Record<string, IconSetIconEntry>;
24
+ info: IconifyInfo | undefined;
25
+ categories: Set<IconCategory>;
26
+ prefixes: Record<string, string>;
27
+ suffixes: Record<string, string>;
28
+ /**
29
+ * Load icon set
30
+ */
31
+ constructor(data: IconifyJSON);
32
+ /**
33
+ * Load icon set
34
+ */
35
+ load(data: IconifyJSON): void;
36
+ /**
37
+ * Update last modification time
38
+ */
39
+ updateLastModified(value?: number): void;
40
+ /**
41
+ * List icons
42
+ */
43
+ list(types?: IconSetIconType[]): string[];
44
+ /**
45
+ * forEach function to loop through all entries.
46
+ * Supports asynchronous callbacks.
47
+ *
48
+ * Callback should return false to stop loop.
49
+ */
50
+ forEach(callback: IconSetAsyncForEachCallback, types?: IconSetIconType[]): Promise<void>;
51
+ /**
52
+ * Synchronous version of forEach function to loop through all entries.
53
+ *
54
+ * Callback should return false to stop loop.
55
+ */
56
+ forEachSync(callback: IconSetSyncForEachCallback, types?: IconSetIconType[]): void;
57
+ /**
58
+ * Get parent icons tree
59
+ *
60
+ * Returns parent icons list for each icon, null if failed to resolve.
61
+ * In parent icons list, first element is a direct parent, last is icon. Does not include item.
62
+ *
63
+ * Examples:
64
+ * 'alias3': ['alias2', 'alias1', 'icon']
65
+ * 'icon': []
66
+ * 'bad-icon': null
67
+ */
68
+ getTree(names?: string[]): ParentIconsTree;
69
+ /**
70
+ * Resolve icon
71
+ */
72
+ resolve(name: string, full: false): ResolvedIconifyIcon | null;
73
+ resolve(name: string): ResolvedIconifyIcon | null;
74
+ resolve(name: string, full: true): Required<ResolvedIconifyIcon> | null;
75
+ /**
76
+ * Generate HTML
77
+ */
78
+ toString(name: string, customisations?: IconifyIconCustomisations): string | null;
79
+ /**
80
+ * Get SVG instance for icon
81
+ */
82
+ toSVG(name: string): SVG | null;
83
+ /**
84
+ * Export icon set
85
+ */
86
+ export(validate?: boolean): IconifyJSON;
87
+ /**
88
+ * Get characters map
89
+ */
90
+ chars(names?: string[]): Record<string, string>;
91
+ /**
92
+ * Filter icons
93
+ */
94
+ _filter(callback: (name: string, item: IconSetIconEntry, icon?: ResolvedIconifyIcon) => boolean): string[];
95
+ /**
96
+ * Count icons
97
+ */
98
+ count(): number;
99
+ /**
100
+ * Find category by title
101
+ */
102
+ findCategory(title: string, add: boolean): IconCategory | null;
103
+ /**
104
+ * Count icons in category, remove category if empty
105
+ *
106
+ * Hidden icons and aliases do not count
107
+ */
108
+ listCategory(category: IconCategory | string): string[] | null;
109
+ /**
110
+ * Check if icon exists
111
+ */
112
+ exists(name: string): boolean;
113
+ /**
114
+ * Remove icons. Returns number of removed icons
115
+ *
116
+ * If removeDependencies is a string, it represents new parent for all aliases of removed icon. New parent cannot be alias or variation.
117
+ */
118
+ remove(name: string, removeDependencies?: boolean | string): number;
119
+ /**
120
+ * Remove icon
121
+ */
122
+ rename(oldName: string, newName: string): boolean;
123
+ /**
124
+ * Add/update item
125
+ */
126
+ setItem(name: string, item: IconSetIconEntry): boolean;
127
+ /**
128
+ * Add/update icon
129
+ */
130
+ setIcon(name: string, icon: ResolvedIconifyIcon): boolean;
131
+ /**
132
+ * Add/update alias without props
133
+ */
134
+ setAlias(name: string, parent: string): boolean;
135
+ /**
136
+ * Add/update alias with props
137
+ */
138
+ setVariation(name: string, parent: string, props: CommonIconProps): boolean;
139
+ /**
140
+ * Icon from SVG. Updates old icon if it exists
141
+ */
142
+ fromSVG(name: string, svg: SVG): boolean;
143
+ /**
144
+ * Add or remove character for icon
145
+ */
146
+ toggleCharacter(iconName: string, char: string, add: boolean): boolean;
147
+ /**
148
+ * Add or remove category for icon
149
+ */
150
+ toggleCategory(iconName: string, category: string, add: boolean): boolean;
151
+ /**
152
+ * Find icons that belong to theme
153
+ */
154
+ checkTheme(prefix: boolean): CheckThemeResult;
155
+ }
156
+ /**
157
+ * Create blank icon set
158
+ */
159
+ declare function blankIconSet(prefix: string): IconSet;
160
+
161
+ export { IconSet, blankIconSet, sortThemeKeys };
@@ -0,0 +1,14 @@
1
+ import { FullIconifyIcon } from '@iconify/utils/lib/icon/defaults';
2
+ import { IconSet } from './index.js';
3
+ import '@iconify/types';
4
+ import '@iconify/utils/lib/customisations/defaults';
5
+ import './types.js';
6
+ import '../svg/index.js';
7
+ import '@iconify/utils/lib/icon-set/tree';
8
+
9
+ /**
10
+ * Find matching icon in icon set
11
+ */
12
+ declare function findMatchingIcon(iconSet: IconSet, icon: FullIconifyIcon): string | null;
13
+
14
+ export { findMatchingIcon };
@@ -0,0 +1,13 @@
1
+ import { IconSet } from './index.js';
2
+ import '@iconify/types';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
+ import './types.js';
5
+ import '../svg/index.js';
6
+ import '@iconify/utils/lib/icon-set/tree';
7
+
8
+ /**
9
+ * Merge icon sets
10
+ */
11
+ declare function mergeIconSets(oldIcons: IconSet, newIcons: IconSet): IconSet;
12
+
13
+ export { mergeIconSets };
@@ -0,0 +1,15 @@
1
+ import { IconSet } from './index.js';
2
+ import '@iconify/types';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
+ import './types.js';
5
+ import '../svg/index.js';
6
+ import '@iconify/utils/lib/icon-set/tree';
7
+
8
+ /**
9
+ * Check if icons in an icon set were updated.
10
+ *
11
+ * This function checks only icons, not metadata. It also ignores icon visibility.
12
+ */
13
+ declare function hasIconDataBeenModified(set1: IconSet, set2: IconSet): boolean;
14
+
15
+ export { hasIconDataBeenModified };
@@ -0,0 +1,13 @@
1
+ import { CommonIconProps } from './types.js';
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,22 @@
1
+ import { IconSet } from './index.js';
2
+ import '@iconify/types';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
+ import './types.js';
5
+ import '../svg/index.js';
6
+ import '@iconify/utils/lib/icon-set/tree';
7
+
8
+ declare const paletteTags: {
9
+ monotone: string;
10
+ palette: string;
11
+ };
12
+ declare const sizeTags: {
13
+ square: string;
14
+ gridPrefix: string;
15
+ heightPrefix: string;
16
+ };
17
+ /**
18
+ * Add tags to icon set
19
+ */
20
+ declare function addTagsToIconSet(iconSet: IconSet, customTags?: string[]): string[];
21
+
22
+ 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 { CheckThemeResult, CommonIconProps, ExtraIconProps, IconCategory, IconParentData, IconSetAsyncForEachCallback, IconSetIcon, IconSetIconAlias, IconSetIconEntry, IconSetIconType, IconSetIconVariation, IconSetSyncForEachCallback, IconWithCategories, IconWithChars, IconWithPropsData, ResolvedIconifyIcon };
@@ -56,8 +56,17 @@ function importDir(iconSet, options, getKeyword, files, readFile, done) {
56
56
  svg_cleanup.cleanupSVG(svg, options);
57
57
  iconSet.fromSVG(keyword, svg);
58
58
  } catch (err) {
59
- if (options.ignoreImportErrors !== false) {
60
- throw err;
59
+ const ignore = options.ignoreImportErrors ?? false;
60
+ if (ignore === false || ignore === "warn") {
61
+ let msg = `Failed to import "${keyword}"`;
62
+ if (err instanceof Error) {
63
+ msg += `: ${err.message}`;
64
+ }
65
+ if (ignore === false) {
66
+ throw new Error(msg);
67
+ } else {
68
+ console.warn(msg);
69
+ }
61
70
  }
62
71
  }
63
72
  next();
@@ -0,0 +1,51 @@
1
+ import { IconSet } from '../icon-set/index.js';
2
+ import { CleanupSVGOptions } from '../svg/cleanup.js';
3
+ import '@iconify/types';
4
+ import '@iconify/utils/lib/customisations/defaults';
5
+ import '../icon-set/types.js';
6
+ import '../svg/index.js';
7
+ import '@iconify/utils/lib/icon-set/tree';
8
+ import '../svg/cleanup/bad-tags.js';
9
+
10
+ /**
11
+ * Entry for file
12
+ */
13
+ interface ImportDirectoryFileEntry {
14
+ path: string;
15
+ subdir: string;
16
+ file: string;
17
+ ext: string;
18
+ }
19
+ /**
20
+ * Callback to get keyword for icon based on file name
21
+ *
22
+ * Returns:
23
+ * - string for new keyword
24
+ * - undefined to skip icon
25
+ *
26
+ * Callback can be asynchronous
27
+ */
28
+ type ImportDirectoryKeywordCallbackResult = string | undefined;
29
+ type Callback<T> = (file: ImportDirectoryFileEntry, defaultKeyword: string, iconSet: IconSet) => T;
30
+ type AsyncCallback<T> = Callback<T | Promise<T>>;
31
+ type ImportDirectoryKeywordCallback = AsyncCallback<ImportDirectoryKeywordCallbackResult>;
32
+ type ImportDirectoryKeywordSyncCallback = Callback<ImportDirectoryKeywordCallbackResult>;
33
+ /**
34
+ * Options
35
+ */
36
+ interface ImportDirectoryOptions<K> extends CleanupSVGOptions {
37
+ prefix?: string;
38
+ includeSubDirs?: boolean;
39
+ keyword?: K;
40
+ ignoreImportErrors?: boolean | 'warn';
41
+ }
42
+ /**
43
+ * Import all icons from directory
44
+ */
45
+ declare function importDirectory(path: string, options?: ImportDirectoryOptions<ImportDirectoryKeywordCallback>): Promise<IconSet>;
46
+ /**
47
+ * Import all icons from directory synchronously
48
+ */
49
+ declare function importDirectorySync(path: string, options?: ImportDirectoryOptions<ImportDirectoryKeywordSyncCallback>): IconSet;
50
+
51
+ export { ImportDirectoryFileEntry, ImportDirectoryKeywordCallback, ImportDirectoryKeywordSyncCallback, importDirectory, importDirectorySync };
@@ -54,8 +54,17 @@ function importDir(iconSet, options, getKeyword, files, readFile, done) {
54
54
  cleanupSVG(svg, options);
55
55
  iconSet.fromSVG(keyword, svg);
56
56
  } catch (err) {
57
- if (options.ignoreImportErrors !== false) {
58
- throw err;
57
+ const ignore = options.ignoreImportErrors ?? false;
58
+ if (ignore === false || ignore === "warn") {
59
+ let msg = `Failed to import "${keyword}"`;
60
+ if (err instanceof Error) {
61
+ msg += `: ${err.message}`;
62
+ }
63
+ if (ignore === false) {
64
+ throw new Error(msg);
65
+ } else {
66
+ console.warn(msg);
67
+ }
59
68
  }
60
69
  }
61
70
  next();
@@ -0,0 +1,19 @@
1
+ import { DocumentNotModified } from '../../download/types/modified.js';
2
+ import { FigmaIfModifiedSinceOption, FigmaImportOptions } from './types/options.js';
3
+ import { FigmaImportResult } from './types/result.js';
4
+ import '../../icon-set/index.js';
5
+ import '@iconify/types';
6
+ import '@iconify/utils/lib/customisations/defaults';
7
+ import '../../icon-set/types.js';
8
+ import '../../svg/index.js';
9
+ import '@iconify/utils/lib/icon-set/tree';
10
+ import './types/nodes.js';
11
+ import './types/api.js';
12
+
13
+ /**
14
+ * Import icon set from Figma
15
+ */
16
+ declare function importFromFigma<T extends FigmaIfModifiedSinceOption & FigmaImportOptions>(options: T): Promise<FigmaImportResult | DocumentNotModified>;
17
+ declare function importFromFigma(options: FigmaImportOptions): Promise<FigmaImportResult>;
18
+
19
+ export { importFromFigma };
@@ -0,0 +1,17 @@
1
+ import { FigmaDocument } from './types/api.js';
2
+ import { FigmaGetIconNodesOptions } from './types/options.js';
3
+ import { FigmaNodesImportResult } from './types/result.js';
4
+ import '../../icon-set/index.js';
5
+ import '@iconify/types';
6
+ import '@iconify/utils/lib/customisations/defaults';
7
+ import '../../icon-set/types.js';
8
+ import '../../svg/index.js';
9
+ import '@iconify/utils/lib/icon-set/tree';
10
+ import './types/nodes.js';
11
+
12
+ /**
13
+ * Get node ids for icons
14
+ */
15
+ declare function getFigmaIconNodes(document: FigmaDocument, options: FigmaGetIconNodesOptions): FigmaNodesImportResult;
16
+
17
+ export { getFigmaIconNodes };
@@ -0,0 +1,28 @@
1
+ import { APICacheOptions } from '../../download/api/types.js';
2
+ import { DocumentNotModified } from '../../download/types/modified.js';
3
+ import { FigmaDocument } from './types/api.js';
4
+ import { FigmaIfModifiedSinceOption, FigmaFilesQueryOptions, FigmaImagesQueryOptions } from './types/options.js';
5
+ import { FigmaNodesImportResult } from './types/result.js';
6
+ import '../../icon-set/index.js';
7
+ import '@iconify/types';
8
+ import '@iconify/utils/lib/customisations/defaults';
9
+ import '../../icon-set/types.js';
10
+ import '../../svg/index.js';
11
+ import '@iconify/utils/lib/icon-set/tree';
12
+ import './types/nodes.js';
13
+
14
+ /**
15
+ * Get Figma files
16
+ */
17
+ declare function figmaFilesQuery<T extends FigmaIfModifiedSinceOption & FigmaFilesQueryOptions>(options: T, cache?: APICacheOptions): Promise<FigmaDocument | DocumentNotModified>;
18
+ declare function figmaFilesQuery(options: FigmaFilesQueryOptions, cache?: APICacheOptions): Promise<FigmaDocument>;
19
+ /**
20
+ * Generate all images
21
+ */
22
+ declare function figmaImagesQuery(options: FigmaImagesQueryOptions, nodes: FigmaNodesImportResult, cache?: APICacheOptions): Promise<FigmaNodesImportResult>;
23
+ /**
24
+ * Download all images
25
+ */
26
+ declare function figmaDownloadImages(nodes: FigmaNodesImportResult, cache?: APICacheOptions): Promise<FigmaNodesImportResult>;
27
+
28
+ export { figmaDownloadImages, figmaFilesQuery, figmaImagesQuery };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Basic document structure
3
+ */
4
+ interface FigmaBoundingBox {
5
+ x: number;
6
+ y: number;
7
+ width: number;
8
+ height: number;
9
+ }
10
+ interface BaseFigmaNode {
11
+ id: string;
12
+ name: string;
13
+ }
14
+ interface GenericFigmaNode extends BaseFigmaNode {
15
+ type: string;
16
+ children?: FigmaNode[];
17
+ }
18
+ interface IconFigmaNode extends BaseFigmaNode {
19
+ type: 'FRAME' | 'COMPONENT' | 'INSTANCE';
20
+ clipsContent?: boolean;
21
+ absoluteBoundingBox?: FigmaBoundingBox;
22
+ children: FigmaNode[];
23
+ }
24
+ interface FigmaDocumentNode extends BaseFigmaNode {
25
+ type: 'DOCUMENT';
26
+ children: FigmaNode[];
27
+ }
28
+ type FigmaNode = GenericFigmaNode | IconFigmaNode;
29
+ /**
30
+ * Document response from API
31
+ */
32
+ interface FigmaDocument {
33
+ document: FigmaDocumentNode;
34
+ name: string;
35
+ version: string;
36
+ lastModified: string;
37
+ thumbnailUrl: string;
38
+ role: string;
39
+ editorType: 'figma' | 'figjam';
40
+ }
41
+ interface FigmaAPIError {
42
+ status: number;
43
+ err: string;
44
+ }
45
+ /**
46
+ * Result for retrieved icons
47
+ */
48
+ interface FigmaAPIImagesResponse {
49
+ err?: string | null;
50
+ images: Record<string, string | null>;
51
+ }
52
+
53
+ export { FigmaAPIError, FigmaAPIImagesResponse, FigmaDocument, FigmaDocumentNode, FigmaNode, IconFigmaNode };