@iconify/tools 2.1.0-beta.1 → 2.1.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/lib/colors/parse.d.ts +1 -1
  2. package/lib/colors/validate.d.ts +1 -1
  3. package/lib/download/git/index.cjs +0 -1
  4. package/lib/download/git/index.mjs +0 -1
  5. package/lib/download/git/reset.cjs +0 -1
  6. package/lib/download/git/reset.mjs +0 -1
  7. package/lib/download/index.cjs +0 -1
  8. package/lib/download/index.mjs +0 -1
  9. package/lib/export/directory.d.ts +0 -1
  10. package/lib/export/helpers/types-version.cjs +3 -13
  11. package/lib/export/helpers/types-version.mjs +3 -13
  12. package/lib/export/icon-package.cjs +1 -3
  13. package/lib/export/icon-package.d.ts +0 -1
  14. package/lib/export/icon-package.mjs +1 -3
  15. package/lib/export/json-package.cjs +1 -3
  16. package/lib/export/json-package.d.ts +0 -1
  17. package/lib/export/json-package.mjs +1 -3
  18. package/lib/icon-set/index.cjs +1 -1
  19. package/lib/icon-set/index.d.ts +0 -1
  20. package/lib/icon-set/index.mjs +1 -1
  21. package/lib/icon-set/match.d.ts +0 -1
  22. package/lib/icon-set/merge.cjs +4 -4
  23. package/lib/icon-set/merge.d.ts +0 -1
  24. package/lib/icon-set/merge.mjs +4 -4
  25. package/lib/icon-set/modified.d.ts +0 -1
  26. package/lib/import/directory.d.ts +0 -1
  27. package/lib/import/figma/index.d.ts +0 -1
  28. package/lib/import/figma/nodes.d.ts +0 -1
  29. package/lib/import/figma/query.d.ts +0 -1
  30. package/lib/import/figma/types/nodes.d.ts +0 -1
  31. package/lib/import/figma/types/options.d.ts +0 -1
  32. package/lib/import/figma/types/result.d.ts +0 -1
  33. package/lib/index.cjs +0 -2
  34. package/lib/index.d.ts +2 -2
  35. package/lib/index.mjs +0 -2
  36. package/lib/misc/bump-version.cjs +2 -2
  37. package/lib/misc/bump-version.mjs +2 -2
  38. package/lib/misc/cheerio.cjs +2 -0
  39. package/lib/misc/cheerio.d.ts +7 -0
  40. package/lib/misc/cheerio.mjs +1 -0
  41. package/lib/optimise/flags.cjs +8 -8
  42. package/lib/optimise/flags.d.ts +1 -1
  43. package/lib/optimise/flags.mjs +8 -8
  44. package/lib/optimise/global-style.d.ts +1 -1
  45. package/lib/optimise/scale.cjs +3 -3
  46. package/lib/optimise/scale.d.ts +2 -2
  47. package/lib/optimise/scale.mjs +3 -3
  48. package/lib/optimise/svgo.cjs +1 -1
  49. package/lib/optimise/svgo.d.ts +2 -2
  50. package/lib/optimise/svgo.mjs +1 -1
  51. package/lib/svg/analyse.d.ts +1 -1
  52. package/lib/svg/cleanup/attribs.d.ts +1 -1
  53. package/lib/svg/cleanup/bad-tags.d.ts +1 -1
  54. package/lib/svg/cleanup/inline-style.d.ts +1 -1
  55. package/lib/svg/cleanup/root-svg.d.ts +1 -1
  56. package/lib/svg/cleanup/svgo-style.cjs +1 -1
  57. package/lib/svg/cleanup/svgo-style.d.ts +1 -1
  58. package/lib/svg/cleanup/svgo-style.mjs +1 -1
  59. package/lib/svg/cleanup.d.ts +1 -1
  60. package/lib/svg/index.cjs +3 -6
  61. package/lib/svg/index.d.ts +2 -2
  62. package/lib/svg/index.mjs +3 -6
  63. package/lib/svg/parse-style.d.ts +2 -1
  64. package/lib/svg/parse.d.ts +3 -7
  65. package/package.json +5 -1
@@ -3,7 +3,7 @@ import { SVG } from '../svg/index.js';
3
3
  import { ColorAttributes } from './attribs.js';
4
4
  import { ElementsTreeItem, AnalyseSVGStructureResult, AnalyseSVGStructureOptions, ExtendedTagElement } from '../svg/analyse/types.js';
5
5
  import '../types-f0980297.js';
6
- import '@iconify/utils/lib/customisations';
6
+ import '@iconify/utils/lib/customisations/defaults';
7
7
 
8
8
  /**
9
9
  * Result
@@ -1,7 +1,7 @@
1
1
  import { SVG } from '../svg/index.js';
2
2
  import { ParseColorsOptions, FindColorsResult } from './parse.js';
3
3
  import '../types-f0980297.js';
4
- import '@iconify/utils/lib/customisations';
4
+ import '@iconify/utils/lib/customisations/defaults';
5
5
  import '@iconify/utils/lib/colors/types';
6
6
  import './attribs.js';
7
7
  import '../svg/analyse/types.js';
@@ -33,7 +33,6 @@ require('stream');
33
33
  require('extract-zip');
34
34
  require('tar');
35
35
  require('@iconify/utils/lib/colors');
36
- require('local-pkg');
37
36
 
38
37
  async function downloadGitRepo(options) {
39
38
  const { remote, branch } = options;
@@ -29,7 +29,6 @@ import 'stream';
29
29
  import 'extract-zip';
30
30
  import 'tar';
31
31
  import '@iconify/utils/lib/colors';
32
- import 'local-pkg';
33
32
 
34
33
  async function downloadGitRepo(options) {
35
34
  const { remote, branch } = options;
@@ -23,7 +23,6 @@ require('../api/download.cjs');
23
23
  require('extract-zip');
24
24
  require('tar');
25
25
  require('@iconify/utils/lib/colors');
26
- require('local-pkg');
27
26
  require('../../svg/parse.cjs');
28
27
  require('@iconify/utils/lib/misc/objects');
29
28
  require('path');
@@ -19,7 +19,6 @@ import '../api/download.mjs';
19
19
  import 'extract-zip';
20
20
  import 'tar';
21
21
  import '@iconify/utils/lib/colors';
22
- import 'local-pkg';
23
22
  import '../../svg/parse.mjs';
24
23
  import '@iconify/utils/lib/misc/objects';
25
24
  import 'path';
@@ -42,7 +42,6 @@ require('../icon-set/props.cjs');
42
42
  require('@iconify/utils/lib/misc/objects');
43
43
  require('tar');
44
44
  require('@iconify/utils/lib/colors');
45
- require('local-pkg');
46
45
  require('./helpers/untar.cjs');
47
46
  require('./npm/version.cjs');
48
47
  require('./gitlab/hash.cjs');
@@ -38,7 +38,6 @@ import '../icon-set/props.mjs';
38
38
  import '@iconify/utils/lib/misc/objects';
39
39
  import 'tar';
40
40
  import '@iconify/utils/lib/colors';
41
- import 'local-pkg';
42
41
  import './helpers/untar.mjs';
43
42
  import './npm/version.mjs';
44
43
  import './gitlab/hash.mjs';
@@ -4,7 +4,6 @@ import '../types-f0980297.js';
4
4
  import '@iconify/utils/lib/customisations/defaults';
5
5
  import '../icon-set/types.js';
6
6
  import '../svg/index.js';
7
- import '@iconify/utils/lib/customisations';
8
7
  import '@iconify/utils/lib/icon-set/tree';
9
8
 
10
9
  /**
@@ -2,21 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const localPkg = require('local-pkg');
6
- const fs = require('fs');
5
+ require('local-pkg');
6
+ require('fs');
7
7
 
8
- let cache;
9
- async function getVersion() {
10
- const packageName = "@iconify/types/package.json";
11
- const filename = localPkg.resolveModule(packageName);
12
- if (!filename) {
13
- throw new Error(`Cannot resolve ${packageName}`);
14
- }
15
- const content = JSON.parse(await fs.promises.readFile(filename, "utf8"));
16
- return cache = content.version;
17
- }
18
8
  async function getTypesVersion() {
19
- return cache || await getVersion();
9
+ throw new Error(`getTypesVersion() is deprecated, use wildcard to make packages work with all versions`);
20
10
  }
21
11
 
22
12
  exports.getTypesVersion = getTypesVersion;
@@ -1,18 +1,8 @@
1
- import { resolveModule } from 'local-pkg';
2
- import { promises } from 'fs';
1
+ import 'local-pkg';
2
+ import 'fs';
3
3
 
4
- let cache;
5
- async function getVersion() {
6
- const packageName = "@iconify/types/package.json";
7
- const filename = resolveModule(packageName);
8
- if (!filename) {
9
- throw new Error(`Cannot resolve ${packageName}`);
10
- }
11
- const content = JSON.parse(await promises.readFile(filename, "utf8"));
12
- return cache = content.version;
13
- }
14
4
  async function getTypesVersion() {
15
- return cache || await getVersion();
5
+ throw new Error(`getTypesVersion() is deprecated, use wildcard to make packages work with all versions`);
16
6
  }
17
7
 
18
8
  export { getTypesVersion };
@@ -5,10 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const fs = require('fs');
6
6
  const export_helpers_prepare = require('./helpers/prepare.cjs');
7
7
  const misc_writeJson = require('../misc/write-json.cjs');
8
- const export_helpers_typesVersion = require('./helpers/types-version.cjs');
9
8
  const export_helpers_customFiles = require('./helpers/custom-files.cjs');
10
9
  require('pathe');
11
- require('local-pkg');
12
10
 
13
11
  const defaultTypesContent = `import type { IconifyIcon } from '@iconify/types';
14
12
  declare const data: IconifyIcon;
@@ -48,7 +46,7 @@ async function exportIconPackage(iconSet, options) {
48
46
  iconSetInfo: info,
49
47
  ...customPackageProps,
50
48
  dependencies: dependencies || {
51
- "@iconify/types": "^" + await export_helpers_typesVersion.getTypesVersion()
49
+ "@iconify/types": "*"
52
50
  }
53
51
  };
54
52
  await misc_writeJson.writeJSONFile(dir + "/package.json", packageJSON);
@@ -5,7 +5,6 @@ import '../types-f0980297.js';
5
5
  import '@iconify/utils/lib/customisations/defaults';
6
6
  import '../icon-set/types.js';
7
7
  import '../svg/index.js';
8
- import '@iconify/utils/lib/customisations';
9
8
  import '@iconify/utils/lib/icon-set/tree';
10
9
 
11
10
  /**
@@ -1,10 +1,8 @@
1
1
  import { promises } from 'fs';
2
2
  import { prepareDirectoryForExport } from './helpers/prepare.mjs';
3
3
  import { writeJSONFile } from '../misc/write-json.mjs';
4
- import { getTypesVersion } from './helpers/types-version.mjs';
5
4
  import { exportCustomFiles } from './helpers/custom-files.mjs';
6
5
  import 'pathe';
7
- import 'local-pkg';
8
6
 
9
7
  const defaultTypesContent = `import type { IconifyIcon } from '@iconify/types';
10
8
  declare const data: IconifyIcon;
@@ -44,7 +42,7 @@ async function exportIconPackage(iconSet, options) {
44
42
  iconSetInfo: info,
45
43
  ...customPackageProps,
46
44
  dependencies: dependencies || {
47
- "@iconify/types": "^" + await getTypesVersion()
45
+ "@iconify/types": "*"
48
46
  }
49
47
  };
50
48
  await writeJSONFile(dir + "/package.json", packageJSON);
@@ -6,10 +6,8 @@ const fs = require('fs');
6
6
  const defaults = require('@iconify/utils/lib/icon/defaults');
7
7
  const export_helpers_prepare = require('./helpers/prepare.cjs');
8
8
  const misc_writeJson = require('../misc/write-json.cjs');
9
- const export_helpers_typesVersion = require('./helpers/types-version.cjs');
10
9
  const export_helpers_customFiles = require('./helpers/custom-files.cjs');
11
10
  require('pathe');
12
- require('local-pkg');
13
11
 
14
12
  const exportTypes = {
15
13
  icons: "IconifyJSON",
@@ -76,7 +74,7 @@ async function exportJSONPackage(iconSet, options) {
76
74
  exports: packageJSONExports,
77
75
  iconSet: packageJSONIconSet,
78
76
  dependencies: dependencies || {
79
- "@iconify/types": "^" + await export_helpers_typesVersion.getTypesVersion()
77
+ "@iconify/types": "*"
80
78
  }
81
79
  };
82
80
  const dtsContent = [];
@@ -5,7 +5,6 @@ import '../types-f0980297.js';
5
5
  import '@iconify/utils/lib/customisations/defaults';
6
6
  import '../icon-set/types.js';
7
7
  import '../svg/index.js';
8
- import '@iconify/utils/lib/customisations';
9
8
  import '@iconify/utils/lib/icon-set/tree';
10
9
 
11
10
  /**
@@ -2,10 +2,8 @@ import { promises } from 'fs';
2
2
  import { defaultIconDimensions } from '@iconify/utils/lib/icon/defaults';
3
3
  import { prepareDirectoryForExport } from './helpers/prepare.mjs';
4
4
  import { writeJSONFile } from '../misc/write-json.mjs';
5
- import { getTypesVersion } from './helpers/types-version.mjs';
6
5
  import { exportCustomFiles } from './helpers/custom-files.mjs';
7
6
  import 'pathe';
8
- import 'local-pkg';
9
7
 
10
8
  const exportTypes = {
11
9
  icons: "IconifyJSON",
@@ -72,7 +70,7 @@ async function exportJSONPackage(iconSet, options) {
72
70
  exports: packageJSONExports,
73
71
  iconSet: packageJSONIconSet,
74
72
  dependencies: dependencies || {
75
- "@iconify/types": "^" + await getTypesVersion()
73
+ "@iconify/types": "*"
76
74
  }
77
75
  };
78
76
  const dtsContent = [];
@@ -219,7 +219,7 @@ class IconSet {
219
219
  export(validate = true) {
220
220
  const icons = /* @__PURE__ */ Object.create(null);
221
221
  const aliases = /* @__PURE__ */ Object.create(null);
222
- const tree = validate ? this.getTree() : {};
222
+ const tree = validate ? this.getTree() : /* @__PURE__ */ Object.create(null);
223
223
  const names = Object.keys(this.entries);
224
224
  names.sort((a, b) => a.localeCompare(b));
225
225
  names.forEach((name) => {
@@ -3,7 +3,6 @@ import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/def
3
3
  import { IconSetIconEntry, IconCategory, IconSetIconType, IconSetAsyncForEachCallback, ResolvedIconifyIcon, CommonIconProps, CheckThemeResult } from './types.js';
4
4
  import { SVG } from '../svg/index.js';
5
5
  import { ParentIconsTree } from '@iconify/utils/lib/icon-set/tree';
6
- import '@iconify/utils/lib/customisations';
7
6
 
8
7
  /**
9
8
  * Sort theme keys: long keys first
@@ -215,7 +215,7 @@ class IconSet {
215
215
  export(validate = true) {
216
216
  const icons = /* @__PURE__ */ Object.create(null);
217
217
  const aliases = /* @__PURE__ */ Object.create(null);
218
- const tree = validate ? this.getTree() : {};
218
+ const tree = validate ? this.getTree() : /* @__PURE__ */ Object.create(null);
219
219
  const names = Object.keys(this.entries);
220
220
  names.sort((a, b) => a.localeCompare(b));
221
221
  names.forEach((name) => {
@@ -4,7 +4,6 @@ import '../types-f0980297.js';
4
4
  import '@iconify/utils/lib/customisations/defaults';
5
5
  import './types.js';
6
6
  import '../svg/index.js';
7
- import '@iconify/utils/lib/customisations';
8
7
  import '@iconify/utils/lib/icon-set/tree';
9
8
 
10
9
  /**
@@ -79,10 +79,10 @@ function mergeIconSets(oldIcons, newIcons) {
79
79
  for (const name in oldEntries) {
80
80
  add(name);
81
81
  }
82
- const lastModified1 = oldIcons.lastModified;
83
- const lastModified2 = newIcons.lastModified;
84
- if ((lastModified1 || lastModified2) && !iconSet_modified.hasIconDataBeenModified(oldIcons, newIcons)) {
85
- mergedIcons.updateLastModified(lastModified2 ? lastModified1 ? Math.min(lastModified1, lastModified2) : lastModified2 : lastModified1);
82
+ if (oldIcons.lastModified && !iconSet_modified.hasIconDataBeenModified(oldIcons, mergedIcons)) {
83
+ mergedIcons.updateLastModified(oldIcons.lastModified);
84
+ } else if (newIcons.lastModified && !iconSet_modified.hasIconDataBeenModified(newIcons, mergedIcons)) {
85
+ mergedIcons.updateLastModified(newIcons.lastModified);
86
86
  }
87
87
  return mergedIcons;
88
88
  }
@@ -3,7 +3,6 @@ import '../types-f0980297.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import './types.js';
5
5
  import '../svg/index.js';
6
- import '@iconify/utils/lib/customisations';
7
6
  import '@iconify/utils/lib/icon-set/tree';
8
7
 
9
8
  /**
@@ -75,10 +75,10 @@ function mergeIconSets(oldIcons, newIcons) {
75
75
  for (const name in oldEntries) {
76
76
  add(name);
77
77
  }
78
- const lastModified1 = oldIcons.lastModified;
79
- const lastModified2 = newIcons.lastModified;
80
- if ((lastModified1 || lastModified2) && !hasIconDataBeenModified(oldIcons, newIcons)) {
81
- mergedIcons.updateLastModified(lastModified2 ? lastModified1 ? Math.min(lastModified1, lastModified2) : lastModified2 : lastModified1);
78
+ if (oldIcons.lastModified && !hasIconDataBeenModified(oldIcons, mergedIcons)) {
79
+ mergedIcons.updateLastModified(oldIcons.lastModified);
80
+ } else if (newIcons.lastModified && !hasIconDataBeenModified(newIcons, mergedIcons)) {
81
+ mergedIcons.updateLastModified(newIcons.lastModified);
82
82
  }
83
83
  return mergedIcons;
84
84
  }
@@ -3,7 +3,6 @@ import '../types-f0980297.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import './types.js';
5
5
  import '../svg/index.js';
6
- import '@iconify/utils/lib/customisations';
7
6
  import '@iconify/utils/lib/icon-set/tree';
8
7
 
9
8
  /**
@@ -3,7 +3,6 @@ import '../types-f0980297.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import '../icon-set/types.js';
5
5
  import '../svg/index.js';
6
- import '@iconify/utils/lib/customisations';
7
6
  import '@iconify/utils/lib/icon-set/tree';
8
7
 
9
8
  /**
@@ -6,7 +6,6 @@ import '../../types-f0980297.js';
6
6
  import '@iconify/utils/lib/customisations/defaults';
7
7
  import '../../icon-set/types.js';
8
8
  import '../../svg/index.js';
9
- import '@iconify/utils/lib/customisations';
10
9
  import '@iconify/utils/lib/icon-set/tree';
11
10
  import './types/nodes.js';
12
11
  import './types/api.js';
@@ -6,7 +6,6 @@ import '../../types-f0980297.js';
6
6
  import '@iconify/utils/lib/customisations/defaults';
7
7
  import '../../icon-set/types.js';
8
8
  import '../../svg/index.js';
9
- import '@iconify/utils/lib/customisations';
10
9
  import '@iconify/utils/lib/icon-set/tree';
11
10
  import './types/nodes.js';
12
11
 
@@ -8,7 +8,6 @@ import '../../types-f0980297.js';
8
8
  import '@iconify/utils/lib/customisations/defaults';
9
9
  import '../../icon-set/types.js';
10
10
  import '../../svg/index.js';
11
- import '@iconify/utils/lib/customisations';
12
11
  import '@iconify/utils/lib/icon-set/tree';
13
12
  import './types/nodes.js';
14
13
 
@@ -5,7 +5,6 @@ import '../../../types-f0980297.js';
5
5
  import '@iconify/utils/lib/customisations/defaults';
6
6
  import '../../../icon-set/types.js';
7
7
  import '../../../svg/index.js';
8
- import '@iconify/utils/lib/customisations';
9
8
  import '@iconify/utils/lib/icon-set/tree';
10
9
 
11
10
  declare type FigmaImportParentNodeType = 'CANVAS' | 'FRAME' | 'GROUP';
@@ -5,7 +5,6 @@ import '../../../types-f0980297.js';
5
5
  import '@iconify/utils/lib/customisations/defaults';
6
6
  import '../../../icon-set/types.js';
7
7
  import '../../../svg/index.js';
8
- import '@iconify/utils/lib/customisations';
9
8
  import '@iconify/utils/lib/icon-set/tree';
10
9
  import './api.js';
11
10
 
@@ -3,7 +3,6 @@ import '../../../types-f0980297.js';
3
3
  import '@iconify/utils/lib/customisations/defaults';
4
4
  import '../../../icon-set/types.js';
5
5
  import '../../../svg/index.js';
6
- import '@iconify/utils/lib/customisations';
7
6
  import '@iconify/utils/lib/icon-set/tree';
8
7
 
9
8
  /**
package/lib/index.cjs CHANGED
@@ -83,10 +83,8 @@ require('stream');
83
83
  require('extract-zip');
84
84
  require('tar');
85
85
  require('@iconify/utils/lib/colors');
86
- require('local-pkg');
87
86
  require('./download/gitlab/types.cjs');
88
87
  require('./colors/attribs.cjs');
89
- require('./export/helpers/types-version.cjs');
90
88
  require('./export/helpers/custom-files.cjs');
91
89
 
92
90
 
package/lib/index.d.ts CHANGED
@@ -44,10 +44,10 @@ export { cleanupIconKeyword } from './misc/keyword.js';
44
44
  export { bumpVersion } from './misc/bump-version.js';
45
45
  export { sendAPIQuery } from './download/api/index.js';
46
46
  import './types-f0980297.js';
47
- import '@iconify/utils/lib/customisations';
47
+ import '@iconify/utils/lib/customisations/defaults';
48
+ import './misc/cheerio.js';
48
49
  import './css/parser/types.js';
49
50
  import './svg/analyse/types.js';
50
- import '@iconify/utils/lib/customisations/defaults';
51
51
  import './icon-set/types.js';
52
52
  import '@iconify/utils/lib/icon-set/tree';
53
53
  import './download/types/modified.js';
package/lib/index.mjs CHANGED
@@ -79,8 +79,6 @@ import 'stream';
79
79
  import 'extract-zip';
80
80
  import 'tar';
81
81
  import '@iconify/utils/lib/colors';
82
- import 'local-pkg';
83
82
  import './download/gitlab/types.mjs';
84
83
  import './colors/attribs.mjs';
85
- import './export/helpers/types-version.mjs';
86
84
  import './export/helpers/custom-files.mjs';
@@ -6,10 +6,10 @@ function bumpVersion(version) {
6
6
  const versionParts = version.split(".");
7
7
  const lastPart = versionParts.pop();
8
8
  const num = parseInt(lastPart);
9
- if (isNaN(num) || num + "" !== lastPart) {
9
+ if (isNaN(num) || num.toString() !== lastPart) {
10
10
  versionParts.push(lastPart + ".1");
11
11
  } else {
12
- versionParts.push(num + 1 + "");
12
+ versionParts.push((num + 1).toString());
13
13
  }
14
14
  return versionParts.join(".");
15
15
  }
@@ -2,10 +2,10 @@ function bumpVersion(version) {
2
2
  const versionParts = version.split(".");
3
3
  const lastPart = versionParts.pop();
4
4
  const num = parseInt(lastPart);
5
- if (isNaN(num) || num + "" !== lastPart) {
5
+ if (isNaN(num) || num.toString() !== lastPart) {
6
6
  versionParts.push(lastPart + ".1");
7
7
  } else {
8
- versionParts.push(num + 1 + "");
8
+ versionParts.push((num + 1).toString());
9
9
  }
10
10
  return versionParts.join(".");
11
11
  }
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Shortcuts for Cheerio elements
3
+ */
4
+ declare type CheerioElement = cheerio.TagElement;
5
+ declare type WrappedCheerioElement = cheerio.Cheerio;
6
+
7
+ export { CheerioElement, WrappedCheerioElement };
@@ -0,0 +1 @@
1
+
@@ -62,11 +62,11 @@ function cleanPath(path) {
62
62
  if (currentNumber !== "" && currentCommandType) {
63
63
  let value = Number(currentNumber);
64
64
  if (isNaN(value)) {
65
- throw new Error('Invalid number "' + currentNumber + '" at ' + i);
65
+ throw new Error(`Invalid number "${currentNumber}" at ${i}`);
66
66
  }
67
67
  if (currentCommandType === ARC) {
68
68
  if (currentArgs.length < 2 && value <= 0) {
69
- throw new Error('Expected positive number, got "' + value + '" at ' + i);
69
+ throw new Error(`Expected positive number, got "${value}" at ${i}`);
70
70
  }
71
71
  while (true) {
72
72
  if (currentArgs.length < 3 || currentArgs.length > 4) {
@@ -80,14 +80,14 @@ function cleanPath(path) {
80
80
  const newValue = Number(newNumber);
81
81
  if (slice === "0" || slice === "1") {
82
82
  if (isNaN(newValue)) {
83
- throw new Error('Invalid number "' + currentNumber + '" at ' + i);
83
+ throw new Error(`Invalid number "${currentNumber}" at ${i}`);
84
84
  }
85
85
  currentArgs.push(slice);
86
86
  currentNumber = newNumber;
87
87
  value = newValue;
88
88
  continue;
89
89
  }
90
- throw new Error('Expected a flag, got "' + currentNumber + '" at ' + i);
90
+ throw new Error(`Expected a flag, got "${currentNumber}" at ${i}`);
91
91
  }
92
92
  }
93
93
  currentArgs.push(currentNumber);
@@ -137,10 +137,10 @@ function cleanPath(path) {
137
137
  continue;
138
138
  }
139
139
  if (currentArgs.length > 0) {
140
- throw new Error("Unexpected command at " + i);
140
+ throw new Error(`Unexpected command at ${i}`);
141
141
  }
142
142
  if (!canParseCommandOrComma) {
143
- throw new Error("Command cannot follow comma at " + i);
143
+ throw new Error(`Command cannot follow comma at ${i}`);
144
144
  }
145
145
  canParseCommandOrComma = false;
146
146
  currentCommand = char;
@@ -192,7 +192,7 @@ function cleanPath(path) {
192
192
  currentCommandType = ARC;
193
193
  break;
194
194
  default:
195
- throw new Error('Unexpected character "' + char + '" at ' + i);
195
+ throw new Error(`Unexpected character "${char}" at ${i}`);
196
196
  }
197
197
  }
198
198
  parseNumber();
@@ -201,7 +201,7 @@ function cleanPath(path) {
201
201
  throw new Error("Empty path");
202
202
  }
203
203
  if (currentArgs.length !== argCount[currentCommandType]) {
204
- throw new Error("Unexpected end of path at " + i);
204
+ throw new Error(`Unexpected end of path at ${i}`);
205
205
  }
206
206
  finishCommand();
207
207
  }
@@ -1,6 +1,6 @@
1
1
  import { SVG } from '../svg/index.js';
2
2
  import '../types-f0980297.js';
3
- import '@iconify/utils/lib/customisations';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
6
6
  * De-optimise paths. Compressed paths are still not supported by some software.
@@ -58,11 +58,11 @@ function cleanPath(path) {
58
58
  if (currentNumber !== "" && currentCommandType) {
59
59
  let value = Number(currentNumber);
60
60
  if (isNaN(value)) {
61
- throw new Error('Invalid number "' + currentNumber + '" at ' + i);
61
+ throw new Error(`Invalid number "${currentNumber}" at ${i}`);
62
62
  }
63
63
  if (currentCommandType === ARC) {
64
64
  if (currentArgs.length < 2 && value <= 0) {
65
- throw new Error('Expected positive number, got "' + value + '" at ' + i);
65
+ throw new Error(`Expected positive number, got "${value}" at ${i}`);
66
66
  }
67
67
  while (true) {
68
68
  if (currentArgs.length < 3 || currentArgs.length > 4) {
@@ -76,14 +76,14 @@ function cleanPath(path) {
76
76
  const newValue = Number(newNumber);
77
77
  if (slice === "0" || slice === "1") {
78
78
  if (isNaN(newValue)) {
79
- throw new Error('Invalid number "' + currentNumber + '" at ' + i);
79
+ throw new Error(`Invalid number "${currentNumber}" at ${i}`);
80
80
  }
81
81
  currentArgs.push(slice);
82
82
  currentNumber = newNumber;
83
83
  value = newValue;
84
84
  continue;
85
85
  }
86
- throw new Error('Expected a flag, got "' + currentNumber + '" at ' + i);
86
+ throw new Error(`Expected a flag, got "${currentNumber}" at ${i}`);
87
87
  }
88
88
  }
89
89
  currentArgs.push(currentNumber);
@@ -133,10 +133,10 @@ function cleanPath(path) {
133
133
  continue;
134
134
  }
135
135
  if (currentArgs.length > 0) {
136
- throw new Error("Unexpected command at " + i);
136
+ throw new Error(`Unexpected command at ${i}`);
137
137
  }
138
138
  if (!canParseCommandOrComma) {
139
- throw new Error("Command cannot follow comma at " + i);
139
+ throw new Error(`Command cannot follow comma at ${i}`);
140
140
  }
141
141
  canParseCommandOrComma = false;
142
142
  currentCommand = char;
@@ -188,7 +188,7 @@ function cleanPath(path) {
188
188
  currentCommandType = ARC;
189
189
  break;
190
190
  default:
191
- throw new Error('Unexpected character "' + char + '" at ' + i);
191
+ throw new Error(`Unexpected character "${char}" at ${i}`);
192
192
  }
193
193
  }
194
194
  parseNumber();
@@ -197,7 +197,7 @@ function cleanPath(path) {
197
197
  throw new Error("Empty path");
198
198
  }
199
199
  if (currentArgs.length !== argCount[currentCommandType]) {
200
- throw new Error("Unexpected end of path at " + i);
200
+ throw new Error(`Unexpected end of path at ${i}`);
201
201
  }
202
202
  finishCommand();
203
203
  }
@@ -1,6 +1,6 @@
1
1
  import { SVG } from '../svg/index.js';
2
2
  import '../types-f0980297.js';
3
- import '@iconify/utils/lib/customisations';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
6
6
  * Expand global style
@@ -5,15 +5,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const optimise_svgo = require('./svgo.cjs');
6
6
  require('svgo');
7
7
 
8
- async function scaleSVG(svg, scale) {
8
+ function scaleSVG(svg, scale) {
9
9
  const viewBox = svg.viewBox;
10
10
  const width = viewBox.width * scale;
11
11
  const height = viewBox.height * scale;
12
12
  const left = viewBox.left * scale;
13
13
  const top = viewBox.top * scale;
14
- const content = '<svg width="' + width + '" height="' + height + '" viewBox="' + left + " " + top + " " + width + " " + height + '"><g transform="scale(' + scale + ')">' + svg.getBody() + "</g></svg>";
14
+ const content = `<svg width="${width}" height="${height}" viewBox="${left} ${top} ${width} ${height}"><g transform="scale(${scale})">${svg.getBody()}</g></svg>`;
15
15
  svg.load(content);
16
- await optimise_svgo.runSVGO(svg, {
16
+ optimise_svgo.runSVGO(svg, {
17
17
  plugins: [
18
18
  "collapseGroups",
19
19
  "convertTransform",
@@ -1,10 +1,10 @@
1
1
  import { SVG } from '../svg/index.js';
2
2
  import '../types-f0980297.js';
3
- import '@iconify/utils/lib/customisations';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
6
6
  * Scale icon
7
7
  */
8
- declare function scaleSVG(svg: SVG, scale: number): Promise<void>;
8
+ declare function scaleSVG(svg: SVG, scale: number): void;
9
9
 
10
10
  export { scaleSVG };
@@ -1,15 +1,15 @@
1
1
  import { runSVGO } from './svgo.mjs';
2
2
  import 'svgo';
3
3
 
4
- async function scaleSVG(svg, scale) {
4
+ function scaleSVG(svg, scale) {
5
5
  const viewBox = svg.viewBox;
6
6
  const width = viewBox.width * scale;
7
7
  const height = viewBox.height * scale;
8
8
  const left = viewBox.left * scale;
9
9
  const top = viewBox.top * scale;
10
- const content = '<svg width="' + width + '" height="' + height + '" viewBox="' + left + " " + top + " " + width + " " + height + '"><g transform="scale(' + scale + ')">' + svg.getBody() + "</g></svg>";
10
+ const content = `<svg width="${width}" height="${height}" viewBox="${left} ${top} ${width} ${height}"><g transform="scale(${scale})">${svg.getBody()}</g></svg>`;
11
11
  svg.load(content);
12
- await runSVGO(svg, {
12
+ runSVGO(svg, {
13
13
  plugins: [
14
14
  "collapseGroups",
15
15
  "convertTransform",
@@ -56,7 +56,7 @@ function getSVGOPlugins(options) {
56
56
  ] : []
57
57
  ];
58
58
  }
59
- async function runSVGO(svg, options = {}) {
59
+ function runSVGO(svg, options = {}) {
60
60
  const code = svg.toString();
61
61
  const multipass = options.multipass !== false;
62
62
  let plugins;
@@ -1,7 +1,7 @@
1
1
  import { Plugin } from 'svgo';
2
2
  import { SVG } from '../svg/index.js';
3
3
  import '../types-f0980297.js';
4
- import '@iconify/utils/lib/customisations';
4
+ import '@iconify/utils/lib/customisations/defaults';
5
5
 
6
6
  interface CleanupIDsOption {
7
7
  cleanupIDs?: string | false;
@@ -31,6 +31,6 @@ declare type SVGOOptions = SVGOOptionsWithPlugin | SVGOptionsWithoutPlugin;
31
31
  /**
32
32
  * Run SVGO on icon
33
33
  */
34
- declare function runSVGO(svg: SVG, options?: SVGOOptions): Promise<void>;
34
+ declare function runSVGO(svg: SVG, options?: SVGOOptions): void;
35
35
 
36
36
  export { getSVGOPlugins, runSVGO };
@@ -52,7 +52,7 @@ function getSVGOPlugins(options) {
52
52
  ] : []
53
53
  ];
54
54
  }
55
- async function runSVGO(svg, options = {}) {
55
+ function runSVGO(svg, options = {}) {
56
56
  const code = svg.toString();
57
57
  const multipass = options.multipass !== false;
58
58
  let plugins;
@@ -1,7 +1,7 @@
1
1
  import { SVG } from './index.js';
2
2
  import { AnalyseSVGStructureOptions, AnalyseSVGStructureResult } from './analyse/types.js';
3
3
  import '../types-f0980297.js';
4
- import '@iconify/utils/lib/customisations';
4
+ import '@iconify/utils/lib/customisations/defaults';
5
5
 
6
6
  /**
7
7
  * Find all IDs, links, which elements use palette, which items aren't used
@@ -1,6 +1,6 @@
1
1
  import { SVG } from '../index.js';
2
2
  import '../../types-f0980297.js';
3
- import '@iconify/utils/lib/customisations';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
6
6
  * Remove useless attributes
@@ -1,6 +1,6 @@
1
1
  import { SVG } from '../index.js';
2
2
  import '../../types-f0980297.js';
3
- import '@iconify/utils/lib/customisations';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
6
6
  * Test for bag tags
@@ -1,6 +1,6 @@
1
1
  import { SVG } from '../index.js';
2
2
  import '../../types-f0980297.js';
3
- import '@iconify/utils/lib/customisations';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
6
6
  * Expand inline style
@@ -1,6 +1,6 @@
1
1
  import { SVG } from '../index.js';
2
2
  import '../../types-f0980297.js';
3
- import '@iconify/utils/lib/customisations';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
6
6
  * Clean up SVG
@@ -29,7 +29,7 @@ async function convertStyleToAttrs(svg) {
29
29
  if (!hasStyle) {
30
30
  return;
31
31
  }
32
- await optimise_svgo.runSVGO(svg, {
32
+ optimise_svgo.runSVGO(svg, {
33
33
  plugins: ["convertStyleToAttrs", "inlineStyles"],
34
34
  multipass: true
35
35
  });
@@ -1,6 +1,6 @@
1
1
  import { SVG } from '../index.js';
2
2
  import '../../types-f0980297.js';
3
- import '@iconify/utils/lib/customisations';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
6
6
  * Expand inline style
@@ -25,7 +25,7 @@ async function convertStyleToAttrs(svg) {
25
25
  if (!hasStyle) {
26
26
  return;
27
27
  }
28
- await runSVGO(svg, {
28
+ runSVGO(svg, {
29
29
  plugins: ["convertStyleToAttrs", "inlineStyles"],
30
30
  multipass: true
31
31
  });
@@ -1,6 +1,6 @@
1
1
  import { SVG } from './index.js';
2
2
  import '../types-f0980297.js';
3
- import '@iconify/utils/lib/customisations';
3
+ import '@iconify/utils/lib/customisations/defaults';
4
4
 
5
5
  /**
6
6
  * Clean up SVG before parsing/optimising it
package/lib/svg/index.cjs CHANGED
@@ -31,21 +31,18 @@ class SVG {
31
31
  const value = data.attributes[key];
32
32
  svgAttributes += " " + key + '="' + value + '"';
33
33
  }
34
- if (customisations.inline) {
35
- svgAttributes += ' style="vertical-align: -0.125em;"';
36
- }
37
34
  return "<svg" + svgAttributes + ">" + data.body + "</svg>";
38
35
  }
39
36
  const $root = this.$svg(":root");
40
37
  const box = this.viewBox;
41
38
  if ($root.attr("viewBox") === void 0) {
42
- $root.attr("viewBox", box.left + " " + box.top + " " + box.width + " " + box.height);
39
+ $root.attr("viewBox", `${box.left} ${box.top} ${box.width} ${box.height}`);
43
40
  }
44
41
  if ($root.attr("width") === void 0) {
45
- $root.attr("width", box.width + "");
42
+ $root.attr("width", box.width.toString());
46
43
  }
47
44
  if ($root.attr("height") === void 0) {
48
- $root.attr("height", box.height + "");
45
+ $root.attr("height", box.height.toString());
49
46
  }
50
47
  return this.$svg.html();
51
48
  }
@@ -1,7 +1,7 @@
1
1
  import { I as IconifyIcon } from '../types-f0980297.js';
2
2
  export { I as IconifyIcon } from '../types-f0980297.js';
3
- import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations';
4
- export { IconifyIconCustomisations } from '@iconify/utils/lib/customisations';
3
+ import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
4
+ export { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
5
5
 
6
6
  interface ViewBox {
7
7
  left: number;
package/lib/svg/index.mjs CHANGED
@@ -23,21 +23,18 @@ class SVG {
23
23
  const value = data.attributes[key];
24
24
  svgAttributes += " " + key + '="' + value + '"';
25
25
  }
26
- if (customisations.inline) {
27
- svgAttributes += ' style="vertical-align: -0.125em;"';
28
- }
29
26
  return "<svg" + svgAttributes + ">" + data.body + "</svg>";
30
27
  }
31
28
  const $root = this.$svg(":root");
32
29
  const box = this.viewBox;
33
30
  if ($root.attr("viewBox") === void 0) {
34
- $root.attr("viewBox", box.left + " " + box.top + " " + box.width + " " + box.height);
31
+ $root.attr("viewBox", `${box.left} ${box.top} ${box.width} ${box.height}`);
35
32
  }
36
33
  if ($root.attr("width") === void 0) {
37
- $root.attr("width", box.width + "");
34
+ $root.attr("width", box.width.toString());
38
35
  }
39
36
  if ($root.attr("height") === void 0) {
40
- $root.attr("height", box.height + "");
37
+ $root.attr("height", box.height.toString());
41
38
  }
42
39
  return this.$svg.html();
43
40
  }
@@ -2,7 +2,8 @@ import { SVG } from './index.js';
2
2
  import { CSSRuleToken, CSSToken } from '../css/parser/types.js';
3
3
  import { ParseSVGCallbackItem } from './parse.js';
4
4
  import '../types-f0980297.js';
5
- import '@iconify/utils/lib/customisations';
5
+ import '@iconify/utils/lib/customisations/defaults';
6
+ import '../misc/cheerio.js';
6
7
 
7
8
  /**
8
9
  * Item in callback
@@ -1,12 +1,8 @@
1
+ import { CheerioElement, WrappedCheerioElement } from '../misc/cheerio.js';
1
2
  import { SVG } from './index.js';
2
3
  import '../types-f0980297.js';
3
- import '@iconify/utils/lib/customisations';
4
+ import '@iconify/utils/lib/customisations/defaults';
4
5
 
5
- /**
6
- * Shortcuts for Cheerio elements
7
- */
8
- declare type CheerioElement = cheerio.TagElement;
9
- declare type WrappedCheerioElement = cheerio.Cheerio;
10
6
  /**
11
7
  * Item in callback
12
8
  */
@@ -31,4 +27,4 @@ declare type ParseSVGCallback = (item: ParseSVGCallbackItem) => void | Promise<v
31
27
  */
32
28
  declare function parseSVG(svg: SVG, callback: ParseSVGCallback): Promise<void>;
33
29
 
34
- export { CheerioElement, ParseSVGCallback, ParseSVGCallbackItem, WrappedCheerioElement, parseSVG };
30
+ export { ParseSVGCallback, ParseSVGCallbackItem, parseSVG };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "description": "Collection of functions for cleaning up and parsing SVG for Iconify project",
5
5
  "author": "Vjacheslav Trushkin",
6
- "version": "2.1.0-beta.1",
6
+ "version": "2.1.0-beta.4",
7
7
  "license": "MIT",
8
8
  "bugs": "https://github.com/iconify/tools/issues",
9
9
  "homepage": "https://github.com/iconify/tools",
@@ -300,6 +300,10 @@
300
300
  "require": "./lib/misc/bump-version.cjs",
301
301
  "import": "./lib/misc/bump-version.mjs"
302
302
  },
303
+ "./lib/misc/cheerio": {
304
+ "require": "./lib/misc/cheerio.cjs",
305
+ "import": "./lib/misc/cheerio.mjs"
306
+ },
303
307
  "./lib/misc/compare-dirs": {
304
308
  "require": "./lib/misc/compare-dirs.cjs",
305
309
  "import": "./lib/misc/compare-dirs.mjs"