@iconify/tools 2.0.14 → 2.0.15
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.cjs +30 -0
- package/lib/colors/attribs.d.ts +13 -10
- package/lib/colors/attribs.mjs +7 -13
- package/lib/colors/parse.cjs +269 -0
- package/lib/colors/parse.d.ts +15 -11
- package/lib/colors/parse.mjs +27 -31
- package/lib/colors/validate.cjs +52 -0
- package/lib/colors/validate.d.ts +11 -4
- package/lib/colors/validate.mjs +19 -6
- package/lib/css/parse.cjs +26 -0
- package/lib/css/parse.d.ts +3 -1
- package/lib/css/parse.mjs +8 -6
- package/lib/css/parser/error.cjs +25 -0
- package/lib/css/parser/error.d.ts +4 -2
- package/lib/css/parser/error.mjs +2 -4
- package/lib/css/parser/export.cjs +48 -0
- package/lib/css/parser/export.d.ts +5 -2
- package/lib/css/parser/export.mjs +4 -6
- package/lib/css/parser/strings.cjs +77 -0
- package/lib/css/parser/strings.d.ts +6 -3
- package/lib/css/parser/strings.mjs +4 -6
- package/lib/css/parser/text.cjs +135 -0
- package/lib/css/parser/text.d.ts +8 -5
- package/lib/css/parser/text.mjs +3 -8
- package/lib/css/parser/tokens.cjs +184 -0
- package/lib/css/parser/tokens.d.ts +6 -3
- package/lib/css/parser/tokens.mjs +7 -13
- package/lib/css/parser/tree.cjs +42 -0
- package/lib/css/parser/tree.d.ts +5 -2
- package/lib/css/parser/tree.mjs +2 -4
- package/lib/css/parser/types.cjs +2 -0
- package/lib/css/parser/types.d.ts +13 -11
- package/lib/css/parser/types.mjs +1 -0
- package/lib/download/api/cache.cjs +86 -0
- package/lib/download/api/cache.d.ts +8 -5
- package/lib/download/api/cache.mjs +14 -19
- package/lib/download/api/download.cjs +28 -0
- package/lib/download/api/download.d.ts +5 -2
- package/lib/download/api/download.mjs +8 -9
- package/lib/download/api/index.cjs +51 -0
- package/lib/download/api/index.d.ts +5 -2
- package/lib/download/api/index.mjs +8 -6
- package/lib/download/api/types.cjs +2 -0
- package/lib/download/api/types.d.ts +4 -2
- package/lib/download/api/types.mjs +1 -0
- package/lib/download/git/branch.cjs +22 -0
- package/lib/download/git/branch.d.ts +5 -2
- package/lib/download/git/branch.mjs +5 -5
- package/lib/download/git/hash.cjs +15 -0
- package/lib/download/git/hash.d.ts +5 -2
- package/lib/download/git/hash.mjs +5 -5
- package/lib/download/git/index.cjs +76 -0
- package/lib/download/git/index.d.ts +10 -8
- package/lib/download/git/index.mjs +41 -26
- package/lib/download/git/reset.cjs +41 -0
- package/lib/download/git/reset.d.ts +3 -1
- package/lib/download/git/reset.mjs +29 -5
- package/lib/download/github/hash.cjs +32 -0
- package/lib/download/github/hash.d.ts +5 -2
- package/lib/download/github/hash.mjs +10 -7
- package/lib/download/github/index.cjs +98 -0
- package/lib/download/github/index.d.ts +11 -9
- package/lib/download/github/index.mjs +23 -17
- package/lib/download/github/types.cjs +2 -0
- package/lib/download/github/types.d.ts +3 -1
- package/lib/download/github/types.mjs +1 -0
- package/lib/download/gitlab/hash.cjs +32 -0
- package/lib/download/gitlab/hash.d.ts +5 -2
- package/lib/download/gitlab/hash.mjs +10 -6
- package/lib/download/gitlab/index.cjs +98 -0
- package/lib/download/gitlab/index.d.ts +11 -9
- package/lib/download/gitlab/index.mjs +24 -18
- package/lib/download/gitlab/types.cjs +7 -0
- package/lib/download/gitlab/types.d.ts +4 -2
- package/lib/download/gitlab/types.mjs +3 -5
- package/lib/download/helpers/untar.cjs +14 -0
- package/lib/download/helpers/untar.d.ts +3 -1
- package/lib/download/helpers/untar.mjs +4 -5
- package/lib/download/helpers/unzip.cjs +19 -0
- package/lib/download/helpers/unzip.d.ts +3 -1
- package/lib/download/helpers/unzip.mjs +6 -7
- package/lib/download/index.cjs +64 -0
- package/lib/download/index.d.ts +18 -13
- package/lib/download/index.mjs +46 -19
- package/lib/download/npm/index.cjs +82 -0
- package/lib/download/npm/index.d.ts +10 -8
- package/lib/download/npm/index.mjs +16 -13
- package/lib/download/npm/types.cjs +2 -0
- package/lib/download/npm/types.d.ts +3 -1
- package/lib/download/npm/types.mjs +1 -0
- package/lib/download/npm/version.cjs +23 -0
- package/lib/download/npm/version.d.ts +7 -4
- package/lib/download/npm/version.mjs +8 -10
- package/lib/download/types/modified.cjs +2 -0
- package/lib/download/types/modified.d.ts +3 -1
- package/lib/download/types/modified.mjs +1 -0
- package/lib/download/types/sources.cjs +2 -0
- package/lib/download/types/sources.d.ts +4 -2
- package/lib/download/types/sources.mjs +1 -0
- package/lib/export/directory.cjs +45 -0
- package/lib/export/directory.d.ts +11 -4
- package/lib/export/directory.mjs +8 -8
- package/lib/export/helpers/custom-files.cjs +28 -0
- package/lib/export/helpers/custom-files.d.ts +4 -2
- package/lib/export/helpers/custom-files.mjs +8 -9
- package/lib/export/helpers/prepare.cjs +36 -0
- package/lib/export/helpers/prepare.d.ts +5 -3
- package/lib/export/helpers/prepare.mjs +7 -9
- package/lib/export/helpers/types-version.cjs +22 -0
- package/lib/export/helpers/types-version.d.ts +3 -1
- package/lib/export/helpers/types-version.mjs +15 -37
- package/lib/export/icon-package.cjs +59 -0
- package/lib/export/icon-package.d.ts +12 -5
- package/lib/export/icon-package.mjs +15 -16
- package/lib/export/json-package.cjs +133 -0
- package/lib/export/json-package.d.ts +12 -5
- package/lib/export/json-package.mjs +20 -21
- package/lib/icon-set/index.cjs +589 -0
- package/lib/icon-set/index.d.ts +9 -6
- package/lib/icon-set/index.mjs +40 -53
- package/lib/icon-set/match.cjs +58 -0
- package/lib/icon-set/match.d.ts +10 -3
- package/lib/icon-set/match.mjs +5 -6
- package/lib/icon-set/merge.cjs +83 -0
- package/lib/icon-set/merge.d.ts +9 -2
- package/lib/icon-set/merge.mjs +15 -10
- package/lib/icon-set/props.cjs +28 -0
- package/lib/icon-set/props.d.ts +8 -4
- package/lib/icon-set/props.mjs +7 -10
- package/lib/icon-set/types.cjs +2 -0
- package/lib/icon-set/types.d.ts +19 -17
- package/lib/icon-set/types.mjs +1 -0
- package/lib/import/directory.cjs +76 -0
- package/lib/import/directory.d.ts +11 -5
- package/lib/import/directory.mjs +36 -11
- package/lib/import/figma/index.cjs +105 -0
- package/lib/import/figma/index.d.ts +15 -5
- package/lib/import/figma/index.mjs +40 -13
- package/lib/import/figma/nodes.cjs +86 -0
- package/lib/import/figma/nodes.d.ts +13 -4
- package/lib/import/figma/nodes.mjs +3 -11
- package/lib/import/figma/query.cjs +218 -0
- package/lib/import/figma/query.d.ts +18 -9
- package/lib/import/figma/query.mjs +9 -12
- package/lib/import/figma/types/api.cjs +2 -0
- package/lib/import/figma/types/api.d.ts +8 -7
- package/lib/import/figma/types/api.mjs +1 -0
- package/lib/import/figma/types/nodes.cjs +2 -0
- package/lib/import/figma/types/nodes.d.ts +16 -9
- package/lib/import/figma/types/nodes.mjs +1 -0
- package/lib/import/figma/types/options.cjs +2 -0
- package/lib/import/figma/types/options.d.ts +17 -10
- package/lib/import/figma/types/options.mjs +1 -0
- package/lib/import/figma/types/result.cjs +2 -0
- package/lib/import/figma/types/result.d.ts +12 -5
- package/lib/import/figma/types/result.mjs +1 -0
- package/lib/index.cjs +137 -0
- package/lib/index.d.ts +65 -44
- package/lib/index.mjs +83 -94
- package/lib/misc/bump-version.cjs +17 -0
- package/lib/misc/bump-version.d.ts +3 -1
- package/lib/misc/bump-version.mjs +2 -4
- package/lib/misc/compare-dirs.cjs +75 -0
- package/lib/misc/compare-dirs.d.ts +4 -2
- package/lib/misc/compare-dirs.mjs +12 -12
- package/lib/misc/exec.cjs +25 -0
- package/lib/misc/exec.d.ts +6 -4
- package/lib/misc/exec.mjs +4 -5
- package/lib/misc/keyword.cjs +19 -0
- package/lib/misc/keyword.d.ts +3 -1
- package/lib/misc/keyword.mjs +2 -4
- package/lib/misc/scan.cjs +51 -0
- package/lib/misc/scan.d.ts +7 -6
- package/lib/misc/scan.mjs +6 -7
- package/lib/misc/write-json.cjs +11 -0
- package/lib/misc/write-json.d.ts +3 -1
- package/lib/misc/write-json.mjs +5 -6
- package/lib/optimise/flags.cjs +252 -0
- package/lib/optimise/flags.d.ts +7 -2
- package/lib/optimise/flags.mjs +18 -19
- package/lib/optimise/global-style.cjs +154 -0
- package/lib/optimise/global-style.d.ts +7 -2
- package/lib/optimise/global-style.mjs +18 -15
- package/lib/optimise/scale.cjs +26 -0
- package/lib/optimise/scale.d.ts +7 -2
- package/lib/optimise/scale.mjs +5 -5
- package/lib/optimise/svgo.cjs +83 -0
- package/lib/optimise/svgo.d.ts +10 -6
- package/lib/optimise/svgo.mjs +6 -9
- package/lib/svg/analyse/error.cjs +18 -0
- package/lib/svg/analyse/error.d.ts +5 -2
- package/lib/svg/analyse/error.mjs +2 -4
- package/lib/svg/analyse/types.cjs +2 -0
- package/lib/svg/analyse/types.d.ts +11 -11
- package/lib/svg/analyse/types.mjs +1 -0
- package/lib/svg/analyse.cjs +291 -0
- package/lib/svg/analyse.d.ts +8 -3
- package/lib/svg/analyse.mjs +15 -30
- package/lib/svg/cleanup/attribs.cjs +41 -0
- package/lib/svg/cleanup/attribs.d.ts +7 -2
- package/lib/svg/cleanup/attribs.mjs +6 -12
- package/lib/svg/cleanup/bad-tags.cjs +51 -0
- package/lib/svg/cleanup/bad-tags.d.ts +7 -2
- package/lib/svg/cleanup/bad-tags.mjs +10 -25
- package/lib/svg/cleanup/inline-style.cjs +64 -0
- package/lib/svg/cleanup/inline-style.d.ts +7 -2
- package/lib/svg/cleanup/inline-style.mjs +14 -19
- package/lib/svg/cleanup/root-svg.cjs +81 -0
- package/lib/svg/cleanup/root-svg.d.ts +7 -2
- package/lib/svg/cleanup/root-svg.mjs +7 -18
- package/lib/svg/cleanup/svgo-style.cjs +38 -0
- package/lib/svg/cleanup/svgo-style.d.ts +7 -2
- package/lib/svg/cleanup/svgo-style.mjs +16 -11
- package/lib/svg/cleanup.cjs +32 -0
- package/lib/svg/cleanup.d.ts +7 -2
- package/lib/svg/cleanup.mjs +21 -9
- package/lib/svg/data/attributes.cjs +355 -0
- package/lib/svg/data/attributes.d.ts +27 -25
- package/lib/svg/data/attributes.mjs +90 -115
- package/lib/svg/data/tags.cjs +137 -0
- package/lib/svg/data/tags.d.ts +25 -23
- package/lib/svg/data/tags.mjs +25 -49
- package/lib/svg/index.cjs +130 -0
- package/lib/svg/index.d.ts +16 -5
- package/lib/svg/index.mjs +48 -14
- package/lib/svg/parse-style.cjs +134 -0
- package/lib/svg/parse-style.d.ts +12 -8
- package/lib/svg/parse-style.mjs +11 -9
- package/lib/svg/parse.cjs +42 -0
- package/lib/svg/parse.d.ts +11 -7
- package/lib/svg/parse.mjs +2 -4
- package/package.json +99 -94
- package/lib/colors/attribs.js +0 -26
- package/lib/colors/parse.js +0 -341
- package/lib/colors/validate.js +0 -48
- package/lib/css/parse.js +0 -23
- package/lib/css/parser/error.js +0 -27
- package/lib/css/parser/export.js +0 -69
- package/lib/css/parser/strings.js +0 -93
- package/lib/css/parser/text.js +0 -171
- package/lib/css/parser/tokens.js +0 -200
- package/lib/css/parser/tree.js +0 -44
- package/lib/css/parser/types.js +0 -2
- package/lib/download/api/cache.js +0 -108
- package/lib/download/api/download.js +0 -27
- package/lib/download/api/index.js +0 -52
- package/lib/download/api/types.js +0 -2
- package/lib/download/git/branch.js +0 -22
- package/lib/download/git/hash.js +0 -14
- package/lib/download/git/index.js +0 -75
- package/lib/download/git/reset.js +0 -16
- package/lib/download/github/hash.js +0 -28
- package/lib/download/github/index.js +0 -116
- package/lib/download/github/types.js +0 -2
- package/lib/download/gitlab/hash.js +0 -27
- package/lib/download/gitlab/index.js +0 -115
- package/lib/download/gitlab/types.js +0 -7
- package/lib/download/helpers/untar.js +0 -14
- package/lib/download/helpers/unzip.js +0 -18
- package/lib/download/index.js +0 -27
- package/lib/download/npm/index.js +0 -91
- package/lib/download/npm/types.js +0 -2
- package/lib/download/npm/version.js +0 -27
- package/lib/download/types/modified.js +0 -2
- package/lib/download/types/sources.js +0 -2
- package/lib/export/directory.js +0 -52
- package/lib/export/helpers/custom-files.js +0 -32
- package/lib/export/helpers/prepare.js +0 -49
- package/lib/export/helpers/types-version.js +0 -12
- package/lib/export/icon-package.js +0 -77
- package/lib/export/json-package.js +0 -156
- package/lib/icon-set/index.js +0 -749
- package/lib/icon-set/match.js +0 -66
- package/lib/icon-set/merge.js +0 -90
- package/lib/icon-set/props.js +0 -34
- package/lib/icon-set/types.js +0 -2
- package/lib/import/directory.js +0 -59
- package/lib/import/figma/index.js +0 -90
- package/lib/import/figma/nodes.js +0 -106
- package/lib/import/figma/query.js +0 -244
- package/lib/import/figma/types/api.js +0 -12
- package/lib/import/figma/types/nodes.js +0 -2
- package/lib/import/figma/types/options.js +0 -2
- package/lib/import/figma/types/result.js +0 -2
- package/lib/index.js +0 -103
- package/lib/misc/bump-version.js +0 -19
- package/lib/misc/compare-dirs.js +0 -84
- package/lib/misc/exec.js +0 -26
- package/lib/misc/keyword.js +0 -31
- package/lib/misc/scan.js +0 -55
- package/lib/misc/write-json.js +0 -11
- package/lib/optimise/flags.js +0 -312
- package/lib/optimise/global-style.js +0 -185
- package/lib/optimise/scale.js +0 -42
- package/lib/optimise/svgo.js +0 -99
- package/lib/svg/analyse/error.js +0 -22
- package/lib/svg/analyse/types.js +0 -2
- package/lib/svg/analyse.js +0 -352
- package/lib/svg/cleanup/attribs.js +0 -51
- package/lib/svg/cleanup/bad-tags.js +0 -65
- package/lib/svg/cleanup/inline-style.js +0 -77
- package/lib/svg/cleanup/root-svg.js +0 -107
- package/lib/svg/cleanup/svgo-style.js +0 -35
- package/lib/svg/cleanup.js +0 -24
- package/lib/svg/data/attributes.js +0 -403
- package/lib/svg/data/tags.js +0 -188
- package/lib/svg/index.js +0 -134
- package/lib/svg/parse-style.js +0 -151
- package/lib/svg/parse.js +0 -49
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const iconSet_index = require('../icon-set/index.cjs');
|
|
7
|
+
const misc_keyword = require('../misc/keyword.cjs');
|
|
8
|
+
const misc_scan = require('../misc/scan.cjs');
|
|
9
|
+
const svg_index = require('../svg/index.cjs');
|
|
10
|
+
const svg_cleanup = require('../svg/cleanup.cjs');
|
|
11
|
+
require('@iconify/utils/lib/icon');
|
|
12
|
+
require('@iconify/utils/lib/svg/build');
|
|
13
|
+
require('@iconify/utils/lib/customisations');
|
|
14
|
+
require('@iconify/utils/lib/icon-set/minify');
|
|
15
|
+
require('@iconify/utils/lib/icon-set/convert-info');
|
|
16
|
+
require('../icon-set/props.cjs');
|
|
17
|
+
require('cheerio');
|
|
18
|
+
require('@iconify/utils');
|
|
19
|
+
require('../svg/cleanup/attribs.cjs');
|
|
20
|
+
require('../svg/data/attributes.cjs');
|
|
21
|
+
require('../svg/data/tags.cjs');
|
|
22
|
+
require('../svg/parse.cjs');
|
|
23
|
+
require('../svg/cleanup/bad-tags.cjs');
|
|
24
|
+
require('../svg/cleanup/inline-style.cjs');
|
|
25
|
+
require('../css/parse.cjs');
|
|
26
|
+
require('../css/parser/tokens.cjs');
|
|
27
|
+
require('../css/parser/error.cjs');
|
|
28
|
+
require('../css/parser/strings.cjs');
|
|
29
|
+
require('../css/parser/text.cjs');
|
|
30
|
+
require('../svg/cleanup/root-svg.cjs');
|
|
31
|
+
require('../svg/cleanup/svgo-style.cjs');
|
|
32
|
+
require('../svg/parse-style.cjs');
|
|
33
|
+
require('../css/parser/export.cjs');
|
|
34
|
+
require('../css/parser/tree.cjs');
|
|
35
|
+
require('../optimise/svgo.cjs');
|
|
36
|
+
require('svgo');
|
|
37
|
+
|
|
38
|
+
async function importDirectory(path, options = {}) {
|
|
39
|
+
const files = await misc_scan.scanDirectory(path, (ext, file, subdir, path2) => {
|
|
40
|
+
if (ext.toLowerCase() === ".svg") {
|
|
41
|
+
const result = {
|
|
42
|
+
file,
|
|
43
|
+
ext,
|
|
44
|
+
subdir,
|
|
45
|
+
path: path2
|
|
46
|
+
};
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
});
|
|
51
|
+
const iconSet = iconSet_index.blankIconSet(options.prefix || "");
|
|
52
|
+
for (let i = 0; i < files.length; i++) {
|
|
53
|
+
const file = files[i];
|
|
54
|
+
const defaultKeyword = misc_keyword.cleanupIconKeyword(file.file);
|
|
55
|
+
let keyword = options.keyword ? options.keyword(file, defaultKeyword, iconSet) : defaultKeyword;
|
|
56
|
+
if (keyword instanceof Promise) {
|
|
57
|
+
keyword = await keyword;
|
|
58
|
+
}
|
|
59
|
+
if (typeof keyword !== "string" || !keyword.length) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const content = await fs.promises.readFile(file.path + file.subdir + file.file + file.ext, "utf8");
|
|
64
|
+
const svg = new svg_index.SVG(content);
|
|
65
|
+
await svg_cleanup.cleanupSVG(svg);
|
|
66
|
+
iconSet.fromSVG(keyword, svg);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
if (options.ignoreImportErrors !== false) {
|
|
69
|
+
throw err;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return iconSet;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
exports.importDirectory = importDirectory;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { IconSet } from '../icon-set';
|
|
1
|
+
import { IconSet } from '../icon-set/index.js';
|
|
2
|
+
import '@iconify/types';
|
|
3
|
+
import '@iconify/utils/lib/customisations';
|
|
4
|
+
import '../icon-set/types.js';
|
|
5
|
+
import '../svg/index.js';
|
|
6
|
+
|
|
2
7
|
/**
|
|
3
8
|
* Entry for file
|
|
4
9
|
*/
|
|
5
|
-
|
|
10
|
+
interface ImportDirectpryFileEntry {
|
|
6
11
|
path: string;
|
|
7
12
|
subdir: string;
|
|
8
13
|
file: string;
|
|
@@ -18,7 +23,7 @@ export interface ImportDirectpryFileEntry {
|
|
|
18
23
|
* Callback can be asynchronous
|
|
19
24
|
*/
|
|
20
25
|
declare type ImportDirectoryKeywordCallbackResult = string | undefined;
|
|
21
|
-
|
|
26
|
+
declare type ImportDirectoryKeywordCallback = (file: ImportDirectpryFileEntry, defaultKeyword: string, iconSet: IconSet) => ImportDirectoryKeywordCallbackResult | Promise<ImportDirectoryKeywordCallbackResult>;
|
|
22
27
|
/**
|
|
23
28
|
* Options
|
|
24
29
|
*/
|
|
@@ -31,5 +36,6 @@ interface ImportDirectoryOptions {
|
|
|
31
36
|
/**
|
|
32
37
|
* Import all icons from directory
|
|
33
38
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
declare function importDirectory(path: string, options?: ImportDirectoryOptions): Promise<IconSet>;
|
|
40
|
+
|
|
41
|
+
export { ImportDirectoryKeywordCallback, ImportDirectpryFileEntry, importDirectory };
|
package/lib/import/directory.mjs
CHANGED
|
@@ -1,10 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
1
|
+
import { promises } from 'fs';
|
|
2
|
+
import { blankIconSet } from '../icon-set/index.mjs';
|
|
3
|
+
import { cleanupIconKeyword } from '../misc/keyword.mjs';
|
|
4
|
+
import { scanDirectory } from '../misc/scan.mjs';
|
|
5
|
+
import { SVG } from '../svg/index.mjs';
|
|
6
|
+
import { cleanupSVG } from '../svg/cleanup.mjs';
|
|
7
|
+
import '@iconify/utils/lib/icon';
|
|
8
|
+
import '@iconify/utils/lib/svg/build';
|
|
9
|
+
import '@iconify/utils/lib/customisations';
|
|
10
|
+
import '@iconify/utils/lib/icon-set/minify';
|
|
11
|
+
import '@iconify/utils/lib/icon-set/convert-info';
|
|
12
|
+
import '../icon-set/props.mjs';
|
|
13
|
+
import 'cheerio';
|
|
14
|
+
import '@iconify/utils';
|
|
15
|
+
import '../svg/cleanup/attribs.mjs';
|
|
16
|
+
import '../svg/data/attributes.mjs';
|
|
17
|
+
import '../svg/data/tags.mjs';
|
|
18
|
+
import '../svg/parse.mjs';
|
|
19
|
+
import '../svg/cleanup/bad-tags.mjs';
|
|
20
|
+
import '../svg/cleanup/inline-style.mjs';
|
|
21
|
+
import '../css/parse.mjs';
|
|
22
|
+
import '../css/parser/tokens.mjs';
|
|
23
|
+
import '../css/parser/error.mjs';
|
|
24
|
+
import '../css/parser/strings.mjs';
|
|
25
|
+
import '../css/parser/text.mjs';
|
|
26
|
+
import '../svg/cleanup/root-svg.mjs';
|
|
27
|
+
import '../svg/cleanup/svgo-style.mjs';
|
|
28
|
+
import '../svg/parse-style.mjs';
|
|
29
|
+
import '../css/parser/export.mjs';
|
|
30
|
+
import '../css/parser/tree.mjs';
|
|
31
|
+
import '../optimise/svgo.mjs';
|
|
32
|
+
import 'svgo';
|
|
33
|
+
|
|
8
34
|
async function importDirectory(path, options = {}) {
|
|
9
35
|
const files = await scanDirectory(path, (ext, file, subdir, path2) => {
|
|
10
36
|
if (ext.toLowerCase() === ".svg") {
|
|
@@ -30,7 +56,7 @@ async function importDirectory(path, options = {}) {
|
|
|
30
56
|
continue;
|
|
31
57
|
}
|
|
32
58
|
try {
|
|
33
|
-
const content = await
|
|
59
|
+
const content = await promises.readFile(file.path + file.subdir + file.file + file.ext, "utf8");
|
|
34
60
|
const svg = new SVG(content);
|
|
35
61
|
await cleanupSVG(svg);
|
|
36
62
|
iconSet.fromSVG(keyword, svg);
|
|
@@ -42,6 +68,5 @@ async function importDirectory(path, options = {}) {
|
|
|
42
68
|
}
|
|
43
69
|
return iconSet;
|
|
44
70
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
71
|
+
|
|
72
|
+
export { importDirectory };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const iconSet_index = require('../../icon-set/index.cjs');
|
|
6
|
+
const svg_index = require('../../svg/index.cjs');
|
|
7
|
+
const svg_cleanup = require('../../svg/cleanup.cjs');
|
|
8
|
+
const import_figma_nodes = require('./nodes.cjs');
|
|
9
|
+
const import_figma_query = require('./query.cjs');
|
|
10
|
+
require('@iconify/utils/lib/icon');
|
|
11
|
+
require('@iconify/utils/lib/svg/build');
|
|
12
|
+
require('@iconify/utils/lib/customisations');
|
|
13
|
+
require('@iconify/utils/lib/icon-set/minify');
|
|
14
|
+
require('@iconify/utils/lib/icon-set/convert-info');
|
|
15
|
+
require('../../icon-set/props.cjs');
|
|
16
|
+
require('cheerio');
|
|
17
|
+
require('@iconify/utils');
|
|
18
|
+
require('../../svg/cleanup/attribs.cjs');
|
|
19
|
+
require('../../svg/data/attributes.cjs');
|
|
20
|
+
require('../../svg/data/tags.cjs');
|
|
21
|
+
require('../../svg/parse.cjs');
|
|
22
|
+
require('../../svg/cleanup/bad-tags.cjs');
|
|
23
|
+
require('../../svg/cleanup/inline-style.cjs');
|
|
24
|
+
require('../../css/parse.cjs');
|
|
25
|
+
require('../../css/parser/tokens.cjs');
|
|
26
|
+
require('../../css/parser/error.cjs');
|
|
27
|
+
require('../../css/parser/strings.cjs');
|
|
28
|
+
require('../../css/parser/text.cjs');
|
|
29
|
+
require('../../svg/cleanup/root-svg.cjs');
|
|
30
|
+
require('../../svg/cleanup/svgo-style.cjs');
|
|
31
|
+
require('../../svg/parse-style.cjs');
|
|
32
|
+
require('../../css/parser/export.cjs');
|
|
33
|
+
require('../../css/parser/tree.cjs');
|
|
34
|
+
require('../../optimise/svgo.cjs');
|
|
35
|
+
require('svgo');
|
|
36
|
+
require('../../download/api/index.cjs');
|
|
37
|
+
require('node-fetch');
|
|
38
|
+
require('../../download/api/cache.cjs');
|
|
39
|
+
require('fs');
|
|
40
|
+
require('crypto');
|
|
41
|
+
require('../../misc/scan.cjs');
|
|
42
|
+
|
|
43
|
+
async function importFromFigma(options) {
|
|
44
|
+
const cacheOptions = options.cacheDir ? {
|
|
45
|
+
ttl: options.cacheAPITTL || 60 * 60 * 24,
|
|
46
|
+
dir: options.cacheDir
|
|
47
|
+
} : void 0;
|
|
48
|
+
const cacheSVGOptions = options.cacheDir ? {
|
|
49
|
+
ttl: options.cacheSVGTTL || 60 * 60 * 24 * 30,
|
|
50
|
+
dir: options.cacheDir
|
|
51
|
+
} : void 0;
|
|
52
|
+
const document = await import_figma_query.figmaFilesQuery(options, cacheOptions);
|
|
53
|
+
if (document === "not_modified") {
|
|
54
|
+
return document;
|
|
55
|
+
}
|
|
56
|
+
options.version = document.version;
|
|
57
|
+
const nodes = await import_figma_nodes.getFigmaIconNodes(document, options);
|
|
58
|
+
await import_figma_query.figmaImagesQuery(options, nodes, cacheOptions);
|
|
59
|
+
await import_figma_query.figmaDownloadImages(nodes, cacheSVGOptions);
|
|
60
|
+
const iconSet = iconSet_index.blankIconSet(options.prefix);
|
|
61
|
+
const icons = nodes.icons;
|
|
62
|
+
const missing = [];
|
|
63
|
+
const iconIDs = Object.keys(icons);
|
|
64
|
+
for (let i = 0; i < iconIDs.length; i++) {
|
|
65
|
+
const id = iconIDs[i];
|
|
66
|
+
const item = icons[id];
|
|
67
|
+
if (typeof item.content !== "string") {
|
|
68
|
+
missing.push(item);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (options.beforeImportingIcon) {
|
|
72
|
+
const callbackResult = options.beforeImportingIcon(item, iconSet);
|
|
73
|
+
if (callbackResult instanceof Promise) {
|
|
74
|
+
await callbackResult;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const svg = new svg_index.SVG(item.content);
|
|
79
|
+
await svg_cleanup.cleanupSVG(svg);
|
|
80
|
+
iconSet.fromSVG(item.keyword, svg);
|
|
81
|
+
} catch (err) {
|
|
82
|
+
missing.push(item);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (options.afterImportingIcon) {
|
|
86
|
+
const callbackResult = options.afterImportingIcon(item, iconSet);
|
|
87
|
+
if (callbackResult instanceof Promise) {
|
|
88
|
+
await callbackResult;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const result = {
|
|
93
|
+
name: document.name,
|
|
94
|
+
version: document.version,
|
|
95
|
+
lastModified: document.lastModified,
|
|
96
|
+
nodesCount: nodes.nodesCount,
|
|
97
|
+
generatedIconsCount: nodes.generatedIconsCount,
|
|
98
|
+
downloadedIconsCount: nodes.downloadedIconsCount,
|
|
99
|
+
iconSet,
|
|
100
|
+
missing
|
|
101
|
+
};
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
exports.importFromFigma = importFromFigma;
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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';
|
|
7
|
+
import '../../icon-set/types.js';
|
|
8
|
+
import '../../svg/index.js';
|
|
9
|
+
import './types/nodes.js';
|
|
10
|
+
import './types/api.js';
|
|
11
|
+
|
|
4
12
|
/**
|
|
5
13
|
* Import icon set from Figma
|
|
6
14
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
15
|
+
declare function importFromFigma<T extends FigmaIfModifiedSinceOption & FigmaImportOptions>(options: T): Promise<FigmaImportResult | DocumentNotModified>;
|
|
16
|
+
declare function importFromFigma(options: FigmaImportOptions): Promise<FigmaImportResult>;
|
|
17
|
+
|
|
18
|
+
export { importFromFigma };
|
|
@@ -1,13 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { blankIconSet } from '../../icon-set/index.mjs';
|
|
2
|
+
import { SVG } from '../../svg/index.mjs';
|
|
3
|
+
import { cleanupSVG } from '../../svg/cleanup.mjs';
|
|
4
|
+
import { getFigmaIconNodes } from './nodes.mjs';
|
|
5
|
+
import { figmaFilesQuery, figmaImagesQuery, figmaDownloadImages } from './query.mjs';
|
|
6
|
+
import '@iconify/utils/lib/icon';
|
|
7
|
+
import '@iconify/utils/lib/svg/build';
|
|
8
|
+
import '@iconify/utils/lib/customisations';
|
|
9
|
+
import '@iconify/utils/lib/icon-set/minify';
|
|
10
|
+
import '@iconify/utils/lib/icon-set/convert-info';
|
|
11
|
+
import '../../icon-set/props.mjs';
|
|
12
|
+
import 'cheerio';
|
|
13
|
+
import '@iconify/utils';
|
|
14
|
+
import '../../svg/cleanup/attribs.mjs';
|
|
15
|
+
import '../../svg/data/attributes.mjs';
|
|
16
|
+
import '../../svg/data/tags.mjs';
|
|
17
|
+
import '../../svg/parse.mjs';
|
|
18
|
+
import '../../svg/cleanup/bad-tags.mjs';
|
|
19
|
+
import '../../svg/cleanup/inline-style.mjs';
|
|
20
|
+
import '../../css/parse.mjs';
|
|
21
|
+
import '../../css/parser/tokens.mjs';
|
|
22
|
+
import '../../css/parser/error.mjs';
|
|
23
|
+
import '../../css/parser/strings.mjs';
|
|
24
|
+
import '../../css/parser/text.mjs';
|
|
25
|
+
import '../../svg/cleanup/root-svg.mjs';
|
|
26
|
+
import '../../svg/cleanup/svgo-style.mjs';
|
|
27
|
+
import '../../svg/parse-style.mjs';
|
|
28
|
+
import '../../css/parser/export.mjs';
|
|
29
|
+
import '../../css/parser/tree.mjs';
|
|
30
|
+
import '../../optimise/svgo.mjs';
|
|
31
|
+
import 'svgo';
|
|
32
|
+
import '../../download/api/index.mjs';
|
|
33
|
+
import 'node-fetch';
|
|
34
|
+
import '../../download/api/cache.mjs';
|
|
35
|
+
import 'fs';
|
|
36
|
+
import 'crypto';
|
|
37
|
+
import '../../misc/scan.mjs';
|
|
38
|
+
|
|
11
39
|
async function importFromFigma(options) {
|
|
12
40
|
const cacheOptions = options.cacheDir ? {
|
|
13
41
|
ttl: options.cacheAPITTL || 60 * 60 * 24,
|
|
@@ -69,6 +97,5 @@ async function importFromFigma(options) {
|
|
|
69
97
|
};
|
|
70
98
|
return result;
|
|
71
99
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
100
|
+
|
|
101
|
+
export { importFromFigma };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
async function getFigmaIconNodes(document, options) {
|
|
6
|
+
const nodes = {
|
|
7
|
+
icons: /* @__PURE__ */ Object.create(null)
|
|
8
|
+
};
|
|
9
|
+
let found = 0;
|
|
10
|
+
const check = (node, parents) => {
|
|
11
|
+
const iconNodeType = node.type;
|
|
12
|
+
switch (iconNodeType) {
|
|
13
|
+
case "COMPONENT":
|
|
14
|
+
case "INSTANCE":
|
|
15
|
+
case "FRAME": {
|
|
16
|
+
const iconNode = node;
|
|
17
|
+
if (iconNode.absoluteBoundingBox) {
|
|
18
|
+
const box = iconNode.absoluteBoundingBox;
|
|
19
|
+
const item = {
|
|
20
|
+
...node,
|
|
21
|
+
type: iconNodeType,
|
|
22
|
+
width: box.width,
|
|
23
|
+
height: box.height,
|
|
24
|
+
parents
|
|
25
|
+
};
|
|
26
|
+
const keyword = options.iconNameForNode(item, nodes, document);
|
|
27
|
+
if (typeof keyword === "string") {
|
|
28
|
+
found++;
|
|
29
|
+
nodes.icons[node.id] = {
|
|
30
|
+
id: node.id,
|
|
31
|
+
name: node.name,
|
|
32
|
+
keyword
|
|
33
|
+
};
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (keyword && typeof keyword === "object" && typeof keyword.keyword === "string") {
|
|
37
|
+
found++;
|
|
38
|
+
nodes.icons[node.id] = {
|
|
39
|
+
...keyword,
|
|
40
|
+
id: node.id,
|
|
41
|
+
name: node.name
|
|
42
|
+
};
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (!node.children) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const parentNodeType = node.type;
|
|
53
|
+
switch (parentNodeType) {
|
|
54
|
+
case "CANVAS":
|
|
55
|
+
case "FRAME":
|
|
56
|
+
case "GROUP": {
|
|
57
|
+
const parentItem = {
|
|
58
|
+
...node,
|
|
59
|
+
type: parentNodeType
|
|
60
|
+
};
|
|
61
|
+
const newParents = parents.concat([parentItem]);
|
|
62
|
+
if (!parents.length && options.pages) {
|
|
63
|
+
const allowedPages = options.pages;
|
|
64
|
+
if (allowedPages.indexOf(node.id) === -1 && allowedPages.indexOf(node.name.trim()) === -1) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
if (options.filterParentNode && !options.filterParentNode(newParents, document)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
node.children.forEach((childNode) => {
|
|
73
|
+
check(childNode, newParents);
|
|
74
|
+
});
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
document.document.children.forEach((node) => {
|
|
80
|
+
check(node, []);
|
|
81
|
+
});
|
|
82
|
+
nodes.nodesCount = found;
|
|
83
|
+
return nodes;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
exports.getFigmaIconNodes = getFigmaIconNodes;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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';
|
|
7
|
+
import '../../icon-set/types.js';
|
|
8
|
+
import '../../svg/index.js';
|
|
9
|
+
import './types/nodes.js';
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
12
|
* Get node ids for icons
|
|
6
13
|
*/
|
|
7
|
-
|
|
14
|
+
declare function getFigmaIconNodes(document: FigmaDocument, options: FigmaGetIconNodesOptions): Promise<FigmaNodesImportResult>;
|
|
15
|
+
|
|
16
|
+
export { getFigmaIconNodes };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
// src/import/figma/nodes.ts
|
|
2
|
-
function assertNever(v) {
|
|
3
|
-
}
|
|
4
1
|
async function getFigmaIconNodes(document, options) {
|
|
5
2
|
const nodes = {
|
|
6
|
-
icons: Object.create(null)
|
|
3
|
+
icons: /* @__PURE__ */ Object.create(null)
|
|
7
4
|
};
|
|
8
5
|
let found = 0;
|
|
9
6
|
const check = (node, parents) => {
|
|
@@ -44,8 +41,6 @@ async function getFigmaIconNodes(document, options) {
|
|
|
44
41
|
}
|
|
45
42
|
break;
|
|
46
43
|
}
|
|
47
|
-
default:
|
|
48
|
-
assertNever(iconNodeType);
|
|
49
44
|
}
|
|
50
45
|
if (!node.children) {
|
|
51
46
|
return;
|
|
@@ -75,8 +70,6 @@ async function getFigmaIconNodes(document, options) {
|
|
|
75
70
|
});
|
|
76
71
|
break;
|
|
77
72
|
}
|
|
78
|
-
default:
|
|
79
|
-
assertNever(parentNodeType);
|
|
80
73
|
}
|
|
81
74
|
};
|
|
82
75
|
document.document.children.forEach((node) => {
|
|
@@ -85,6 +78,5 @@ async function getFigmaIconNodes(document, options) {
|
|
|
85
78
|
nodes.nodesCount = found;
|
|
86
79
|
return nodes;
|
|
87
80
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
};
|
|
81
|
+
|
|
82
|
+
export { getFigmaIconNodes };
|