@iconify/tools 2.1.0 → 2.1.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.
Files changed (114) hide show
  1. package/lib/colors/detect.cjs +68 -0
  2. package/lib/colors/detect.d.ts +15 -0
  3. package/lib/colors/detect.mjs +64 -0
  4. package/lib/colors/parse.cjs +31 -7
  5. package/lib/colors/parse.d.ts +1 -1
  6. package/lib/colors/parse.mjs +31 -7
  7. package/lib/colors/validate.cjs +9 -3
  8. package/lib/colors/validate.d.ts +1 -1
  9. package/lib/colors/validate.mjs +9 -3
  10. package/lib/css/parser/error.cjs +1 -1
  11. package/lib/css/parser/error.mjs +1 -1
  12. package/lib/css/parser/strings.cjs +10 -2
  13. package/lib/css/parser/strings.mjs +10 -2
  14. package/lib/css/parser/tokens.cjs +133 -109
  15. package/lib/css/parser/tokens.mjs +133 -109
  16. package/lib/download/api/cache.cjs +28 -21
  17. package/lib/download/api/cache.mjs +28 -21
  18. package/lib/download/git/branch.cjs +1 -1
  19. package/lib/download/git/branch.mjs +1 -1
  20. package/lib/download/git/hash.cjs +1 -1
  21. package/lib/download/git/hash.mjs +1 -1
  22. package/lib/download/git/index.cjs +7 -4
  23. package/lib/download/git/index.mjs +7 -4
  24. package/lib/download/git/reset.cjs +1 -2
  25. package/lib/download/git/reset.mjs +1 -2
  26. package/lib/download/github/index.cjs +10 -7
  27. package/lib/download/github/index.mjs +10 -7
  28. package/lib/download/gitlab/hash.cjs +3 -1
  29. package/lib/download/gitlab/hash.mjs +3 -1
  30. package/lib/download/gitlab/index.cjs +9 -6
  31. package/lib/download/gitlab/index.mjs +9 -6
  32. package/lib/download/index.cjs +4 -3
  33. package/lib/download/index.mjs +4 -3
  34. package/lib/download/npm/index.cjs +12 -8
  35. package/lib/download/npm/index.mjs +12 -8
  36. package/lib/download/npm/version.cjs +4 -2
  37. package/lib/download/npm/version.mjs +4 -2
  38. package/lib/export/directory.d.ts +1 -1
  39. package/lib/export/helpers/types-version.cjs +3 -1
  40. package/lib/export/helpers/types-version.mjs +3 -1
  41. package/lib/export/icon-package.d.ts +1 -1
  42. package/lib/export/json-package.cjs +13 -3
  43. package/lib/export/json-package.d.ts +1 -1
  44. package/lib/export/json-package.mjs +13 -3
  45. package/lib/icon-set/index.cjs +20 -8
  46. package/lib/icon-set/index.d.ts +1 -1
  47. package/lib/icon-set/index.mjs +20 -8
  48. package/lib/icon-set/match.d.ts +1 -1
  49. package/lib/icon-set/merge.d.ts +1 -1
  50. package/lib/icon-set/modified.d.ts +1 -1
  51. package/lib/icon-set/props.d.ts +1 -1
  52. package/lib/icon-set/tags.cjs +97 -0
  53. package/lib/icon-set/tags.d.ts +22 -0
  54. package/lib/icon-set/tags.mjs +91 -0
  55. package/lib/icon-set/types.d.ts +1 -1
  56. package/lib/import/directory.cjs +4 -1
  57. package/lib/import/directory.d.ts +1 -1
  58. package/lib/import/directory.mjs +4 -1
  59. package/lib/import/figma/index.cjs +5 -2
  60. package/lib/import/figma/index.d.ts +1 -1
  61. package/lib/import/figma/index.mjs +5 -2
  62. package/lib/import/figma/nodes.cjs +6 -2
  63. package/lib/import/figma/nodes.d.ts +2 -2
  64. package/lib/import/figma/nodes.mjs +6 -2
  65. package/lib/import/figma/query.cjs +29 -15
  66. package/lib/import/figma/query.d.ts +1 -1
  67. package/lib/import/figma/query.mjs +29 -15
  68. package/lib/import/figma/types/nodes.d.ts +1 -1
  69. package/lib/import/figma/types/options.d.ts +1 -1
  70. package/lib/import/figma/types/result.d.ts +1 -1
  71. package/lib/index.cjs +6 -3
  72. package/lib/index.d.ts +3 -1
  73. package/lib/index.mjs +4 -3
  74. package/lib/misc/compare-dirs.cjs +3 -1
  75. package/lib/misc/compare-dirs.mjs +3 -1
  76. package/lib/misc/exec.cjs +7 -8
  77. package/lib/misc/exec.mjs +7 -8
  78. package/lib/misc/keyword.cjs +4 -1
  79. package/lib/misc/keyword.mjs +4 -1
  80. package/lib/misc/scan.cjs +3 -1
  81. package/lib/misc/scan.mjs +3 -1
  82. package/lib/optimise/flags.cjs +9 -3
  83. package/lib/optimise/flags.d.ts +1 -1
  84. package/lib/optimise/flags.mjs +9 -3
  85. package/lib/optimise/global-style.cjs +10 -3
  86. package/lib/optimise/global-style.d.ts +1 -1
  87. package/lib/optimise/global-style.mjs +10 -3
  88. package/lib/optimise/scale.d.ts +1 -1
  89. package/lib/optimise/svgo.d.ts +1 -1
  90. package/lib/svg/analyse.cjs +20 -6
  91. package/lib/svg/analyse.d.ts +1 -1
  92. package/lib/svg/analyse.mjs +20 -6
  93. package/lib/svg/cleanup/attribs.d.ts +1 -1
  94. package/lib/svg/cleanup/bad-tags.cjs +7 -2
  95. package/lib/svg/cleanup/bad-tags.d.ts +1 -1
  96. package/lib/svg/cleanup/bad-tags.mjs +7 -2
  97. package/lib/svg/cleanup/inline-style.cjs +12 -4
  98. package/lib/svg/cleanup/inline-style.d.ts +1 -1
  99. package/lib/svg/cleanup/inline-style.mjs +12 -4
  100. package/lib/svg/cleanup/root-style.d.ts +1 -1
  101. package/lib/svg/cleanup/root-svg.d.ts +1 -1
  102. package/lib/svg/cleanup/svgo-style.d.ts +1 -1
  103. package/lib/svg/cleanup.d.ts +1 -1
  104. package/lib/svg/data/attributes.cjs +0 -1
  105. package/lib/svg/data/attributes.mjs +0 -1
  106. package/lib/svg/index.cjs +12 -3
  107. package/lib/svg/index.d.ts +2 -2
  108. package/lib/svg/index.mjs +12 -3
  109. package/lib/svg/parse-style.cjs +13 -8
  110. package/lib/svg/parse-style.d.ts +1 -1
  111. package/lib/svg/parse-style.mjs +13 -8
  112. package/lib/svg/parse.d.ts +1 -1
  113. package/package.json +23 -8
  114. package/lib/types-6360d61e.d.ts +0 -261
@@ -1,4 +1,4 @@
1
- import { a as IconifyInfo, b as IconifyJSON } from '../types-6360d61e.js';
1
+ import { IconifyInfo, IconifyJSON } from '@iconify/types';
2
2
  import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
3
3
  import { IconSetIconEntry, IconCategory, IconSetIconType, IconSetAsyncForEachCallback, ResolvedIconifyIcon, CommonIconProps, CheckThemeResult } from './types.js';
4
4
  import { SVG } from '../svg/index.js';
@@ -10,7 +10,9 @@ import 'cheerio';
10
10
 
11
11
  const themeKeys = ["prefixes", "suffixes"];
12
12
  function sortThemeKeys(keys) {
13
- return keys.sort((a, b) => a.length === b.length ? a.localeCompare(b) : b.length - a.length);
13
+ return keys.sort(
14
+ (a, b) => a.length === b.length ? a.localeCompare(b) : b.length - a.length
15
+ );
14
16
  }
15
17
  class IconSet {
16
18
  constructor(data) {
@@ -26,10 +28,14 @@ class IconSet {
26
28
  const entry = {
27
29
  type: "icon",
28
30
  body: item.body,
29
- props: filterProps({
30
- ...defaultProps,
31
- ...item
32
- }, defaultCommonProps, true),
31
+ props: filterProps(
32
+ {
33
+ ...defaultProps,
34
+ ...item
35
+ },
36
+ defaultCommonProps,
37
+ true
38
+ ),
33
39
  chars: /* @__PURE__ */ new Set(),
34
40
  categories: /* @__PURE__ */ new Set()
35
41
  };
@@ -201,7 +207,9 @@ class IconSet {
201
207
  return null;
202
208
  }
203
209
  const result = iconToSVG(item, customisations);
204
- const attributes = Object.keys(result.attributes).map((key) => ` ${key}="${result.attributes[key]}"`).join("");
210
+ const attributes = Object.keys(result.attributes).map(
211
+ (key) => ` ${key}="${result.attributes[key]}"`
212
+ ).join("");
205
213
  return `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"${attributes}>${result.body}</svg>`;
206
214
  }
207
215
  toSVG(name) {
@@ -258,7 +266,9 @@ class IconSet {
258
266
  if (Object.keys(aliases).length) {
259
267
  result.aliases = aliases;
260
268
  }
261
- const chars = this.chars(Object.keys(icons).concat(Object.keys(aliases)));
269
+ const chars = this.chars(
270
+ Object.keys(icons).concat(Object.keys(aliases))
271
+ );
262
272
  if (Object.keys(chars).length) {
263
273
  result.chars = chars;
264
274
  }
@@ -338,7 +348,9 @@ class IconSet {
338
348
  }).length;
339
349
  }
340
350
  findCategory(title, add) {
341
- const categoryItem = Array.from(this.categories).find((item) => item.title === title);
351
+ const categoryItem = Array.from(this.categories).find(
352
+ (item) => item.title === title
353
+ );
342
354
  if (categoryItem) {
343
355
  return categoryItem;
344
356
  }
@@ -1,6 +1,6 @@
1
1
  import { FullIconifyIcon } from '@iconify/utils/lib/icon/defaults';
2
2
  import { IconSet } from './index.js';
3
- import '../types-6360d61e.js';
3
+ import '@iconify/types';
4
4
  import '@iconify/utils/lib/customisations/defaults';
5
5
  import './types.js';
6
6
  import '../svg/index.js';
@@ -1,5 +1,5 @@
1
1
  import { IconSet } from './index.js';
2
- import '../types-6360d61e.js';
2
+ import '@iconify/types';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import './types.js';
5
5
  import '../svg/index.js';
@@ -1,5 +1,5 @@
1
1
  import { IconSet } from './index.js';
2
- import '../types-6360d61e.js';
2
+ import '@iconify/types';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import './types.js';
5
5
  import '../svg/index.js';
@@ -1,5 +1,5 @@
1
1
  import { CommonIconProps } from './types.js';
2
- import '../types-6360d61e.js';
2
+ import '@iconify/types';
3
3
 
4
4
  /**
5
5
  * Common properties for icon and alias
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const defaults = require('@iconify/utils/lib/icon/defaults');
6
+ const colors_detect = require('../colors/detect.cjs');
7
+ require('../colors/parse.cjs');
8
+ require('@iconify/utils/lib/colors');
9
+ require('../svg/data/tags.cjs');
10
+ require('../svg/parse-style.cjs');
11
+ require('../css/parse.cjs');
12
+ require('../css/parser/tokens.cjs');
13
+ require('../css/parser/error.cjs');
14
+ require('../css/parser/strings.cjs');
15
+ require('../css/parser/text.cjs');
16
+ require('../css/parser/export.cjs');
17
+ require('../css/parser/tree.cjs');
18
+ require('../svg/parse.cjs');
19
+ require('../colors/attribs.cjs');
20
+ require('../svg/data/attributes.cjs');
21
+ require('../svg/analyse.cjs');
22
+ require('../svg/analyse/error.cjs');
23
+
24
+ const paletteTags = {
25
+ monotone: "Monotone",
26
+ palette: "Has Colors"
27
+ };
28
+ const sizeTags = {
29
+ square: "Square",
30
+ gridPrefix: "Grid: ",
31
+ heightPrefix: "Height: "
32
+ };
33
+ async function addTagsToIconSet(iconSet, customTags) {
34
+ const info = iconSet.info;
35
+ const tags = [];
36
+ const iconNames = Object.keys(iconSet.entries).filter((key) => {
37
+ const item = iconSet.entries[key];
38
+ if (item.type !== "icon") {
39
+ return false;
40
+ }
41
+ if (item.props.hidden) {
42
+ return false;
43
+ }
44
+ return true;
45
+ });
46
+ if (iconNames.length) {
47
+ let hasPalette = info?.palette;
48
+ if (hasPalette === void 0) {
49
+ hasPalette = await colors_detect.detectIconSetPalette(iconSet);
50
+ }
51
+ if (hasPalette === true) {
52
+ tags.push(paletteTags.palette);
53
+ }
54
+ if (hasPalette === false) {
55
+ tags.push(paletteTags.monotone);
56
+ }
57
+ let isSquare = true;
58
+ let height;
59
+ for (let i = 0; i < iconNames.length; i++) {
60
+ const icon = iconSet.entries[iconNames[i]];
61
+ if (icon.type !== "icon") {
62
+ continue;
63
+ }
64
+ const iconProps = icon.props;
65
+ const iconWidth = iconProps.width || defaults.defaultIconDimensions.width;
66
+ const iconHeight = iconProps.height || defaults.defaultIconDimensions.height;
67
+ if (isSquare && iconWidth !== iconHeight) {
68
+ isSquare = false;
69
+ }
70
+ if (height === void 0) {
71
+ height = iconHeight;
72
+ } else if (height && iconHeight !== height) {
73
+ height = null;
74
+ }
75
+ if (!height && !isSquare) {
76
+ break;
77
+ }
78
+ }
79
+ if (height && Math.round(height) === height) {
80
+ tags.push(
81
+ (isSquare ? sizeTags.gridPrefix : sizeTags.heightPrefix) + height.toString()
82
+ );
83
+ }
84
+ if (isSquare) {
85
+ tags.push(sizeTags.square);
86
+ }
87
+ }
88
+ const result = tags.concat(customTags || []);
89
+ if (info) {
90
+ info.tags = result;
91
+ }
92
+ return result;
93
+ }
94
+
95
+ exports.addTagsToIconSet = addTagsToIconSet;
96
+ exports.paletteTags = paletteTags;
97
+ exports.sizeTags = sizeTags;
@@ -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[]): Promise<string[]>;
21
+
22
+ export { addTagsToIconSet, paletteTags, sizeTags };
@@ -0,0 +1,91 @@
1
+ import { defaultIconDimensions } from '@iconify/utils/lib/icon/defaults';
2
+ import { detectIconSetPalette } from '../colors/detect.mjs';
3
+ import '../colors/parse.mjs';
4
+ import '@iconify/utils/lib/colors';
5
+ import '../svg/data/tags.mjs';
6
+ import '../svg/parse-style.mjs';
7
+ import '../css/parse.mjs';
8
+ import '../css/parser/tokens.mjs';
9
+ import '../css/parser/error.mjs';
10
+ import '../css/parser/strings.mjs';
11
+ import '../css/parser/text.mjs';
12
+ import '../css/parser/export.mjs';
13
+ import '../css/parser/tree.mjs';
14
+ import '../svg/parse.mjs';
15
+ import '../colors/attribs.mjs';
16
+ import '../svg/data/attributes.mjs';
17
+ import '../svg/analyse.mjs';
18
+ import '../svg/analyse/error.mjs';
19
+
20
+ const paletteTags = {
21
+ monotone: "Monotone",
22
+ palette: "Has Colors"
23
+ };
24
+ const sizeTags = {
25
+ square: "Square",
26
+ gridPrefix: "Grid: ",
27
+ heightPrefix: "Height: "
28
+ };
29
+ async function addTagsToIconSet(iconSet, customTags) {
30
+ const info = iconSet.info;
31
+ const tags = [];
32
+ const iconNames = Object.keys(iconSet.entries).filter((key) => {
33
+ const item = iconSet.entries[key];
34
+ if (item.type !== "icon") {
35
+ return false;
36
+ }
37
+ if (item.props.hidden) {
38
+ return false;
39
+ }
40
+ return true;
41
+ });
42
+ if (iconNames.length) {
43
+ let hasPalette = info?.palette;
44
+ if (hasPalette === void 0) {
45
+ hasPalette = await detectIconSetPalette(iconSet);
46
+ }
47
+ if (hasPalette === true) {
48
+ tags.push(paletteTags.palette);
49
+ }
50
+ if (hasPalette === false) {
51
+ tags.push(paletteTags.monotone);
52
+ }
53
+ let isSquare = true;
54
+ let height;
55
+ for (let i = 0; i < iconNames.length; i++) {
56
+ const icon = iconSet.entries[iconNames[i]];
57
+ if (icon.type !== "icon") {
58
+ continue;
59
+ }
60
+ const iconProps = icon.props;
61
+ const iconWidth = iconProps.width || defaultIconDimensions.width;
62
+ const iconHeight = iconProps.height || defaultIconDimensions.height;
63
+ if (isSquare && iconWidth !== iconHeight) {
64
+ isSquare = false;
65
+ }
66
+ if (height === void 0) {
67
+ height = iconHeight;
68
+ } else if (height && iconHeight !== height) {
69
+ height = null;
70
+ }
71
+ if (!height && !isSquare) {
72
+ break;
73
+ }
74
+ }
75
+ if (height && Math.round(height) === height) {
76
+ tags.push(
77
+ (isSquare ? sizeTags.gridPrefix : sizeTags.heightPrefix) + height.toString()
78
+ );
79
+ }
80
+ if (isSquare) {
81
+ tags.push(sizeTags.square);
82
+ }
83
+ }
84
+ const result = tags.concat(customTags || []);
85
+ if (info) {
86
+ info.tags = result;
87
+ }
88
+ return result;
89
+ }
90
+
91
+ export { addTagsToIconSet, paletteTags, sizeTags };
@@ -1,4 +1,4 @@
1
- import { E as ExtendedIconifyIcon, c as ExtendedIconifyAlias, d as IconifyOptional, I as IconifyIcon } from '../types-6360d61e.js';
1
+ import { ExtendedIconifyIcon, ExtendedIconifyAlias, IconifyOptional, IconifyIcon } from '@iconify/types';
2
2
 
3
3
  /**
4
4
  * Category item
@@ -61,7 +61,10 @@ async function importDirectory(path, options = {}) {
61
61
  continue;
62
62
  }
63
63
  try {
64
- const content = await fs.promises.readFile(file.path + file.subdir + file.file + file.ext, "utf8");
64
+ const content = await fs.promises.readFile(
65
+ file.path + file.subdir + file.file + file.ext,
66
+ "utf8"
67
+ );
65
68
  const svg = new svg_index.SVG(content);
66
69
  await svg_cleanup.cleanupSVG(svg);
67
70
  iconSet.fromSVG(keyword, svg);
@@ -1,5 +1,5 @@
1
1
  import { IconSet } from '../icon-set/index.js';
2
- import '../types-6360d61e.js';
2
+ import '@iconify/types';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import '../icon-set/types.js';
5
5
  import '../svg/index.js';
@@ -57,7 +57,10 @@ async function importDirectory(path, options = {}) {
57
57
  continue;
58
58
  }
59
59
  try {
60
- const content = await promises.readFile(file.path + file.subdir + file.file + file.ext, "utf8");
60
+ const content = await promises.readFile(
61
+ file.path + file.subdir + file.file + file.ext,
62
+ "utf8"
63
+ );
61
64
  const svg = new SVG(content);
62
65
  await cleanupSVG(svg);
63
66
  iconSet.fromSVG(keyword, svg);
@@ -50,12 +50,15 @@ async function importFromFigma(options) {
50
50
  ttl: options.cacheSVGTTL || 60 * 60 * 24 * 30,
51
51
  dir: options.cacheDir
52
52
  } : void 0;
53
- const document = await import_figma_query.figmaFilesQuery(options, cacheOptions);
53
+ const document = await import_figma_query.figmaFilesQuery(
54
+ options,
55
+ cacheOptions
56
+ );
54
57
  if (document === "not_modified") {
55
58
  return document;
56
59
  }
57
60
  options.version = document.version;
58
- const nodes = await import_figma_nodes.getFigmaIconNodes(document, options);
61
+ const nodes = import_figma_nodes.getFigmaIconNodes(document, options);
59
62
  await import_figma_query.figmaImagesQuery(options, nodes, cacheOptions);
60
63
  await import_figma_query.figmaDownloadImages(nodes, cacheSVGOptions);
61
64
  const iconSet = iconSet_index.blankIconSet(options.prefix);
@@ -2,7 +2,7 @@ import { DocumentNotModified } from '../../download/types/modified.js';
2
2
  import { FigmaIfModifiedSinceOption, FigmaImportOptions } from './types/options.js';
3
3
  import { FigmaImportResult } from './types/result.js';
4
4
  import '../../icon-set/index.js';
5
- import '../../types-6360d61e.js';
5
+ import '@iconify/types';
6
6
  import '@iconify/utils/lib/customisations/defaults';
7
7
  import '../../icon-set/types.js';
8
8
  import '../../svg/index.js';
@@ -46,12 +46,15 @@ async function importFromFigma(options) {
46
46
  ttl: options.cacheSVGTTL || 60 * 60 * 24 * 30,
47
47
  dir: options.cacheDir
48
48
  } : void 0;
49
- const document = await figmaFilesQuery(options, cacheOptions);
49
+ const document = await figmaFilesQuery(
50
+ options,
51
+ cacheOptions
52
+ );
50
53
  if (document === "not_modified") {
51
54
  return document;
52
55
  }
53
56
  options.version = document.version;
54
- const nodes = await getFigmaIconNodes(document, options);
57
+ const nodes = getFigmaIconNodes(document, options);
55
58
  await figmaImagesQuery(options, nodes, cacheOptions);
56
59
  await figmaDownloadImages(nodes, cacheSVGOptions);
57
60
  const iconSet = blankIconSet(options.prefix);
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- async function getFigmaIconNodes(document, options) {
5
+ function getFigmaIconNodes(document, options) {
6
6
  const nodes = {
7
7
  icons: /* @__PURE__ */ Object.create(null)
8
8
  };
@@ -23,7 +23,11 @@ async function getFigmaIconNodes(document, options) {
23
23
  height: box.height,
24
24
  parents
25
25
  };
26
- const keyword = options.iconNameForNode(item, nodes, document);
26
+ const keyword = options.iconNameForNode(
27
+ item,
28
+ nodes,
29
+ document
30
+ );
27
31
  if (typeof keyword === "string") {
28
32
  found++;
29
33
  nodes.icons[node.id] = {
@@ -2,7 +2,7 @@ import { FigmaDocument } from './types/api.js';
2
2
  import { FigmaGetIconNodesOptions } from './types/options.js';
3
3
  import { FigmaNodesImportResult } from './types/result.js';
4
4
  import '../../icon-set/index.js';
5
- import '../../types-6360d61e.js';
5
+ import '@iconify/types';
6
6
  import '@iconify/utils/lib/customisations/defaults';
7
7
  import '../../icon-set/types.js';
8
8
  import '../../svg/index.js';
@@ -12,6 +12,6 @@ import './types/nodes.js';
12
12
  /**
13
13
  * Get node ids for icons
14
14
  */
15
- declare function getFigmaIconNodes(document: FigmaDocument, options: FigmaGetIconNodesOptions): Promise<FigmaNodesImportResult>;
15
+ declare function getFigmaIconNodes(document: FigmaDocument, options: FigmaGetIconNodesOptions): FigmaNodesImportResult;
16
16
 
17
17
  export { getFigmaIconNodes };
@@ -1,4 +1,4 @@
1
- async function getFigmaIconNodes(document, options) {
1
+ function getFigmaIconNodes(document, options) {
2
2
  const nodes = {
3
3
  icons: /* @__PURE__ */ Object.create(null)
4
4
  };
@@ -19,7 +19,11 @@ async function getFigmaIconNodes(document, options) {
19
19
  height: box.height,
20
20
  parents
21
21
  };
22
- const keyword = options.iconNameForNode(item, nodes, document);
22
+ const keyword = options.iconNameForNode(
23
+ item,
24
+ nodes,
25
+ document
26
+ );
23
27
  if (typeof keyword === "string") {
24
28
  found++;
25
29
  nodes.icons[node.id] = {
@@ -30,7 +30,7 @@ async function figmaFilesQuery(options, cache) {
30
30
  params.set("version", options.version);
31
31
  }
32
32
  if (options.depth) {
33
- params.set("depth", options.depth + "");
33
+ params.set("depth", options.depth.toString());
34
34
  }
35
35
  const queryParams = {
36
36
  uri: "https://api.figma.com/v1/files/" + options.file,
@@ -97,11 +97,15 @@ async function figmaFilesQuery(options, cache) {
97
97
  }
98
98
  if (typeof parsedData.status === "number") {
99
99
  const figmaError = parsedData;
100
- throw new Error(`Error retrieving document from API: ${figmaError.err}`);
100
+ throw new Error(
101
+ `Error retrieving document from API: ${figmaError.err}`
102
+ );
101
103
  }
102
104
  const document = parsedData;
103
105
  if (document.editorType !== "figma") {
104
- throw new Error(`Error retrieving document from API: document is for ${document.editorType}`);
106
+ throw new Error(
107
+ `Error retrieving document from API: document is for ${document.editorType}`
108
+ );
105
109
  }
106
110
  if (identicalDates(options.ifModifiedSince, document.lastModified)) {
107
111
  return "not_modified";
@@ -133,13 +137,16 @@ async function figmaImagesQuery(options, nodes, cache) {
133
137
  if (svgOptions.useAbsoluteBounds) {
134
138
  params.set("use_absolute_bounds", "true");
135
139
  }
136
- const data = await download_api_index.sendAPIQuery({
137
- uri,
138
- params,
139
- headers: {
140
- "X-FIGMA-TOKEN": options.token
141
- }
142
- }, cache);
140
+ const data = await download_api_index.sendAPIQuery(
141
+ {
142
+ uri,
143
+ params,
144
+ headers: {
145
+ "X-FIGMA-TOKEN": options.token
146
+ }
147
+ },
148
+ cache
149
+ );
143
150
  if (typeof data === "number") {
144
151
  lastError = data;
145
152
  return;
@@ -175,7 +182,9 @@ async function figmaImagesQuery(options, nodes, cache) {
175
182
  }
176
183
  if (!found) {
177
184
  if (lastError) {
178
- throw new Error(`Error retrieving image data from API${lastError ? ": " + lastError : ""}`);
185
+ throw new Error(
186
+ `Error retrieving image data from API${lastError ? ": " + lastError.toString() : ""}`
187
+ );
179
188
  } else {
180
189
  throw new Error("No valid icon layers were found");
181
190
  }
@@ -194,9 +203,12 @@ async function figmaDownloadImages(nodes, cache) {
194
203
  if (!item.url) {
195
204
  continue;
196
205
  }
197
- const result = await download_api_index.sendAPIQuery({
198
- uri: item.url
199
- }, cache);
206
+ const result = await download_api_index.sendAPIQuery(
207
+ {
208
+ uri: item.url
209
+ },
210
+ cache
211
+ );
200
212
  if (typeof result === "number") {
201
213
  lastError = result;
202
214
  continue;
@@ -207,7 +219,9 @@ async function figmaDownloadImages(nodes, cache) {
207
219
  }
208
220
  }
209
221
  if (!count) {
210
- throw new Error(`Error retrieving images${lastError ? ": " + lastError : ""}`);
222
+ throw new Error(
223
+ `Error retrieving images${lastError ? ": " + lastError.toString() : ""}`
224
+ );
211
225
  }
212
226
  nodes.downloadedIconsCount = count;
213
227
  return nodes;
@@ -4,7 +4,7 @@ import { FigmaDocument } from './types/api.js';
4
4
  import { FigmaIfModifiedSinceOption, FigmaFilesQueryOptions, FigmaImagesQueryOptions } from './types/options.js';
5
5
  import { FigmaNodesImportResult } from './types/result.js';
6
6
  import '../../icon-set/index.js';
7
- import '../../types-6360d61e.js';
7
+ import '@iconify/types';
8
8
  import '@iconify/utils/lib/customisations/defaults';
9
9
  import '../../icon-set/types.js';
10
10
  import '../../svg/index.js';
@@ -26,7 +26,7 @@ async function figmaFilesQuery(options, cache) {
26
26
  params.set("version", options.version);
27
27
  }
28
28
  if (options.depth) {
29
- params.set("depth", options.depth + "");
29
+ params.set("depth", options.depth.toString());
30
30
  }
31
31
  const queryParams = {
32
32
  uri: "https://api.figma.com/v1/files/" + options.file,
@@ -93,11 +93,15 @@ async function figmaFilesQuery(options, cache) {
93
93
  }
94
94
  if (typeof parsedData.status === "number") {
95
95
  const figmaError = parsedData;
96
- throw new Error(`Error retrieving document from API: ${figmaError.err}`);
96
+ throw new Error(
97
+ `Error retrieving document from API: ${figmaError.err}`
98
+ );
97
99
  }
98
100
  const document = parsedData;
99
101
  if (document.editorType !== "figma") {
100
- throw new Error(`Error retrieving document from API: document is for ${document.editorType}`);
102
+ throw new Error(
103
+ `Error retrieving document from API: document is for ${document.editorType}`
104
+ );
101
105
  }
102
106
  if (identicalDates(options.ifModifiedSince, document.lastModified)) {
103
107
  return "not_modified";
@@ -129,13 +133,16 @@ async function figmaImagesQuery(options, nodes, cache) {
129
133
  if (svgOptions.useAbsoluteBounds) {
130
134
  params.set("use_absolute_bounds", "true");
131
135
  }
132
- const data = await sendAPIQuery({
133
- uri,
134
- params,
135
- headers: {
136
- "X-FIGMA-TOKEN": options.token
137
- }
138
- }, cache);
136
+ const data = await sendAPIQuery(
137
+ {
138
+ uri,
139
+ params,
140
+ headers: {
141
+ "X-FIGMA-TOKEN": options.token
142
+ }
143
+ },
144
+ cache
145
+ );
139
146
  if (typeof data === "number") {
140
147
  lastError = data;
141
148
  return;
@@ -171,7 +178,9 @@ async function figmaImagesQuery(options, nodes, cache) {
171
178
  }
172
179
  if (!found) {
173
180
  if (lastError) {
174
- throw new Error(`Error retrieving image data from API${lastError ? ": " + lastError : ""}`);
181
+ throw new Error(
182
+ `Error retrieving image data from API${lastError ? ": " + lastError.toString() : ""}`
183
+ );
175
184
  } else {
176
185
  throw new Error("No valid icon layers were found");
177
186
  }
@@ -190,9 +199,12 @@ async function figmaDownloadImages(nodes, cache) {
190
199
  if (!item.url) {
191
200
  continue;
192
201
  }
193
- const result = await sendAPIQuery({
194
- uri: item.url
195
- }, cache);
202
+ const result = await sendAPIQuery(
203
+ {
204
+ uri: item.url
205
+ },
206
+ cache
207
+ );
196
208
  if (typeof result === "number") {
197
209
  lastError = result;
198
210
  continue;
@@ -203,7 +215,9 @@ async function figmaDownloadImages(nodes, cache) {
203
215
  }
204
216
  }
205
217
  if (!count) {
206
- throw new Error(`Error retrieving images${lastError ? ": " + lastError : ""}`);
218
+ throw new Error(
219
+ `Error retrieving images${lastError ? ": " + lastError.toString() : ""}`
220
+ );
207
221
  }
208
222
  nodes.downloadedIconsCount = count;
209
223
  return nodes;
@@ -1,7 +1,7 @@
1
1
  import { IconFigmaNode, FigmaDocument } from './api.js';
2
2
  import { FigmaNodesImportResult, FigmaIconNode } from './result.js';
3
3
  import '../../../icon-set/index.js';
4
- import '../../../types-6360d61e.js';
4
+ import '@iconify/types';
5
5
  import '@iconify/utils/lib/customisations/defaults';
6
6
  import '../../../icon-set/types.js';
7
7
  import '../../../svg/index.js';
@@ -1,7 +1,7 @@
1
1
  import { IconSet } from '../../../icon-set/index.js';
2
2
  import { FigmaImportParentNodeFilter, FigmaImportNodeFilter } from './nodes.js';
3
3
  import { FigmaIconNode } from './result.js';
4
- import '../../../types-6360d61e.js';
4
+ import '@iconify/types';
5
5
  import '@iconify/utils/lib/customisations/defaults';
6
6
  import '../../../icon-set/types.js';
7
7
  import '../../../svg/index.js';