@iconify/tools 4.0.0-dev.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/colors/attribs.d.cts +27 -0
- package/lib/colors/attribs.d.mts +27 -0
- package/lib/colors/attribs.d.ts +1 -1
- package/lib/colors/detect.cjs +2 -2
- package/lib/colors/detect.d.cts +16 -0
- package/lib/colors/detect.d.mts +16 -0
- package/lib/colors/detect.mjs +3 -3
- package/lib/colors/parse.cjs +132 -276
- package/lib/colors/parse.d.cts +60 -0
- package/lib/colors/parse.d.mts +60 -0
- package/lib/colors/parse.d.ts +7 -15
- package/lib/colors/parse.mjs +136 -279
- package/lib/colors/validate.cjs +2 -11
- package/lib/colors/validate.d.cts +20 -0
- package/lib/colors/validate.d.mts +20 -0
- package/lib/colors/validate.d.ts +4 -11
- package/lib/colors/validate.mjs +4 -12
- package/lib/css/parse.d.cts +6 -0
- package/lib/css/parse.d.mts +6 -0
- package/lib/css/parser/error.d.cts +13 -0
- package/lib/css/parser/error.d.mts +13 -0
- package/lib/css/parser/error.d.ts +1 -1
- package/lib/css/parser/export.d.cts +8 -0
- package/lib/css/parser/export.d.mts +8 -0
- package/lib/css/parser/strings.d.cts +16 -0
- package/lib/css/parser/strings.d.mts +16 -0
- package/lib/css/parser/text.d.cts +20 -0
- package/lib/css/parser/text.d.mts +20 -0
- package/lib/css/parser/tokens.d.cts +9 -0
- package/lib/css/parser/tokens.d.mts +9 -0
- package/lib/css/parser/tree.d.cts +8 -0
- package/lib/css/parser/tree.d.mts +8 -0
- package/lib/css/parser/types.d.cts +52 -0
- package/lib/css/parser/types.d.mts +52 -0
- package/lib/css/parser/types.d.ts +1 -1
- package/lib/download/api/cache.d.cts +20 -0
- package/lib/download/api/cache.d.mts +20 -0
- package/lib/download/api/config.cjs +11 -0
- package/lib/download/api/config.d.cts +18 -0
- package/lib/download/api/config.d.mts +18 -0
- package/lib/download/api/config.d.ts +18 -0
- package/lib/download/api/config.mjs +8 -0
- package/lib/download/api/download.cjs +15 -7
- package/lib/download/api/download.d.cts +8 -0
- package/lib/download/api/download.d.mts +8 -0
- package/lib/download/api/download.mjs +11 -7
- package/lib/download/api/index.cjs +23 -7
- package/lib/download/api/index.d.cts +8 -0
- package/lib/download/api/index.d.mts +8 -0
- package/lib/download/api/index.mjs +19 -7
- package/lib/download/api/queue.cjs +104 -0
- package/lib/download/api/queue.d.cts +32 -0
- package/lib/download/api/queue.d.mts +32 -0
- package/lib/download/api/queue.d.ts +32 -0
- package/lib/download/api/queue.mjs +101 -0
- package/lib/download/api/types.d.cts +17 -0
- package/lib/download/api/types.d.mts +17 -0
- package/lib/download/api/types.d.ts +1 -1
- package/lib/download/git/branch.d.cts +8 -0
- package/lib/download/git/branch.d.mts +8 -0
- package/lib/download/git/hash.d.cts +8 -0
- package/lib/download/git/hash.d.mts +8 -0
- package/lib/download/git/index.cjs +2 -4
- package/lib/download/git/index.d.cts +29 -0
- package/lib/download/git/index.d.mts +29 -0
- package/lib/download/git/index.d.ts +1 -1
- package/lib/download/git/index.mjs +2 -4
- package/lib/download/git/reset.cjs +2 -4
- package/lib/download/git/reset.d.cts +6 -0
- package/lib/download/git/reset.d.mts +6 -0
- package/lib/download/git/reset.mjs +2 -4
- package/lib/download/github/hash.cjs +2 -0
- package/lib/download/github/hash.d.cts +8 -0
- package/lib/download/github/hash.d.mts +8 -0
- package/lib/download/github/hash.mjs +2 -0
- package/lib/download/github/index.cjs +2 -2
- package/lib/download/github/index.d.cts +31 -0
- package/lib/download/github/index.d.mts +31 -0
- package/lib/download/github/index.d.ts +1 -1
- package/lib/download/github/index.mjs +2 -2
- package/lib/download/github/types.d.cts +11 -0
- package/lib/download/github/types.d.mts +11 -0
- package/lib/download/github/types.d.ts +1 -1
- package/lib/download/gitlab/hash.cjs +2 -0
- package/lib/download/gitlab/hash.d.cts +8 -0
- package/lib/download/gitlab/hash.d.mts +8 -0
- package/lib/download/gitlab/hash.mjs +2 -0
- package/lib/download/gitlab/index.cjs +2 -2
- package/lib/download/gitlab/index.d.cts +31 -0
- package/lib/download/gitlab/index.d.mts +31 -0
- package/lib/download/gitlab/index.d.ts +1 -1
- package/lib/download/gitlab/index.mjs +2 -2
- package/lib/download/gitlab/types.d.cts +15 -0
- package/lib/download/gitlab/types.d.mts +15 -0
- package/lib/download/gitlab/types.d.ts +1 -1
- package/lib/download/helpers/untar.d.cts +6 -0
- package/lib/download/helpers/untar.d.mts +6 -0
- package/lib/download/helpers/unzip.d.cts +6 -0
- package/lib/download/helpers/unzip.d.mts +6 -0
- package/lib/download/index.cjs +2 -2
- package/lib/download/index.d.cts +48 -0
- package/lib/download/index.d.mts +48 -0
- package/lib/download/index.d.ts +1 -1
- package/lib/download/index.mjs +2 -2
- package/lib/download/npm/index.cjs +2 -2
- package/lib/download/npm/index.d.cts +30 -0
- package/lib/download/npm/index.d.mts +30 -0
- package/lib/download/npm/index.d.ts +1 -1
- package/lib/download/npm/index.mjs +2 -2
- package/lib/download/npm/types.d.cts +9 -0
- package/lib/download/npm/types.d.mts +9 -0
- package/lib/download/npm/types.d.ts +1 -1
- package/lib/download/npm/version.d.cts +16 -0
- package/lib/download/npm/version.d.mts +16 -0
- package/lib/download/npm/version.d.ts +1 -1
- package/lib/download/types/modified.d.cts +6 -0
- package/lib/download/types/modified.d.mts +6 -0
- package/lib/download/types/modified.d.ts +1 -1
- package/lib/download/types/sources.d.cts +12 -0
- package/lib/download/types/sources.d.mts +12 -0
- package/lib/download/types/sources.d.ts +1 -1
- package/lib/export/directory.d.cts +26 -0
- package/lib/export/directory.d.mts +26 -0
- package/lib/export/directory.d.ts +1 -1
- package/lib/export/helpers/custom-files.d.cts +12 -0
- package/lib/export/helpers/custom-files.d.mts +12 -0
- package/lib/export/helpers/custom-files.d.ts +1 -1
- package/lib/export/helpers/prepare.d.cts +19 -0
- package/lib/export/helpers/prepare.d.mts +19 -0
- package/lib/export/helpers/prepare.d.ts +1 -1
- package/lib/export/helpers/types-version.d.cts +6 -0
- package/lib/export/helpers/types-version.d.mts +6 -0
- package/lib/export/icon-package.d.cts +26 -0
- package/lib/export/icon-package.d.mts +26 -0
- package/lib/export/icon-package.d.ts +2 -2
- package/lib/export/json-package.cjs +1 -0
- package/lib/export/json-package.d.cts +25 -0
- package/lib/export/json-package.d.mts +25 -0
- package/lib/export/json-package.d.ts +2 -1
- package/lib/export/json-package.mjs +1 -0
- package/lib/icon-set/index.cjs +25 -4
- package/lib/icon-set/index.d.cts +162 -0
- package/lib/icon-set/index.d.mts +162 -0
- package/lib/icon-set/index.mjs +25 -4
- package/lib/icon-set/match.d.cts +15 -0
- package/lib/icon-set/match.d.mts +15 -0
- package/lib/icon-set/merge.d.cts +14 -0
- package/lib/icon-set/merge.d.mts +14 -0
- package/lib/icon-set/modified.d.cts +16 -0
- package/lib/icon-set/modified.d.mts +16 -0
- package/lib/icon-set/props.d.cts +13 -0
- package/lib/icon-set/props.d.mts +13 -0
- package/lib/icon-set/tags.d.cts +23 -0
- package/lib/icon-set/tags.d.mts +23 -0
- package/lib/icon-set/types.d.cts +75 -0
- package/lib/icon-set/types.d.mts +75 -0
- package/lib/icon-set/types.d.ts +1 -1
- package/lib/import/directory.d.cts +52 -0
- package/lib/import/directory.d.mts +52 -0
- package/lib/import/directory.d.ts +1 -1
- package/lib/import/figma/index.cjs +3 -0
- package/lib/import/figma/index.d.cts +20 -0
- package/lib/import/figma/index.d.mts +20 -0
- package/lib/import/figma/index.mjs +3 -0
- package/lib/import/figma/nodes.cjs +1 -1
- package/lib/import/figma/nodes.d.cts +18 -0
- package/lib/import/figma/nodes.d.mts +18 -0
- package/lib/import/figma/nodes.mjs +1 -1
- package/lib/import/figma/query.cjs +104 -76
- package/lib/import/figma/query.d.cts +42 -0
- package/lib/import/figma/query.d.mts +42 -0
- package/lib/import/figma/query.d.ts +15 -2
- package/lib/import/figma/query.mjs +106 -78
- package/lib/import/figma/types/api.d.cts +53 -0
- package/lib/import/figma/types/api.d.mts +53 -0
- package/lib/import/figma/types/api.d.ts +1 -1
- package/lib/import/figma/types/nodes.d.cts +44 -0
- package/lib/import/figma/types/nodes.d.mts +44 -0
- package/lib/import/figma/types/nodes.d.ts +1 -1
- package/lib/import/figma/types/options.d.cts +59 -0
- package/lib/import/figma/types/options.d.mts +59 -0
- package/lib/import/figma/types/options.d.ts +1 -1
- package/lib/import/figma/types/result.d.cts +44 -0
- package/lib/import/figma/types/result.d.mts +44 -0
- package/lib/import/figma/types/result.d.ts +1 -1
- package/lib/index.cjs +14 -13
- package/lib/index.d.cts +78 -0
- package/lib/index.d.mts +78 -0
- package/lib/index.d.ts +8 -5
- package/lib/index.mjs +13 -12
- package/lib/misc/bump-version.d.cts +6 -0
- package/lib/misc/bump-version.d.mts +6 -0
- package/lib/misc/cheerio.d.cts +9 -0
- package/lib/misc/cheerio.d.mts +9 -0
- package/lib/misc/cheerio.d.ts +1 -1
- package/lib/misc/compare-dirs.cjs +3 -3
- package/lib/misc/compare-dirs.d.cts +11 -0
- package/lib/misc/compare-dirs.d.mts +11 -0
- package/lib/misc/compare-dirs.d.ts +1 -1
- package/lib/misc/compare-dirs.mjs +3 -3
- package/lib/misc/exec.d.cts +12 -0
- package/lib/misc/exec.d.mts +12 -0
- package/lib/misc/exec.d.ts +1 -1
- package/lib/misc/keyword.d.cts +6 -0
- package/lib/misc/keyword.d.mts +6 -0
- package/lib/misc/scan.d.cts +33 -0
- package/lib/misc/scan.d.mts +33 -0
- package/lib/misc/scan.d.ts +1 -1
- package/lib/misc/write-json.d.cts +6 -0
- package/lib/misc/write-json.d.mts +6 -0
- package/lib/optimise/figma.cjs +5 -5
- package/lib/optimise/figma.d.cts +11 -0
- package/lib/optimise/figma.d.mts +11 -0
- package/lib/optimise/figma.mjs +5 -5
- package/lib/optimise/flags.cjs +3 -3
- package/lib/optimise/flags.d.cts +11 -0
- package/lib/optimise/flags.d.mts +11 -0
- package/lib/optimise/flags.d.ts +1 -1
- package/lib/optimise/flags.mjs +3 -3
- package/lib/optimise/global-style.cjs +7 -7
- package/lib/optimise/global-style.d.cts +11 -0
- package/lib/optimise/global-style.d.mts +11 -0
- package/lib/optimise/global-style.d.ts +1 -1
- package/lib/optimise/global-style.mjs +7 -7
- package/lib/optimise/mask.cjs +1 -1
- package/lib/optimise/mask.d.cts +24 -0
- package/lib/optimise/mask.d.mts +24 -0
- package/lib/optimise/mask.mjs +2 -2
- package/lib/optimise/origin.d.cts +11 -0
- package/lib/optimise/origin.d.mts +11 -0
- package/lib/optimise/scale.d.cts +11 -0
- package/lib/optimise/scale.d.mts +11 -0
- package/lib/optimise/svgo.cjs +1 -1
- package/lib/optimise/svgo.d.cts +37 -0
- package/lib/optimise/svgo.d.mts +37 -0
- package/lib/optimise/svgo.mjs +1 -1
- package/lib/svg/analyse/error.d.cts +10 -0
- package/lib/svg/analyse/error.d.mts +10 -0
- package/lib/svg/analyse/error.d.ts +1 -0
- package/lib/svg/analyse/types.d.cts +92 -0
- package/lib/svg/analyse/types.d.mts +92 -0
- package/lib/svg/analyse/types.d.ts +4 -3
- package/lib/svg/analyse.cjs +2 -2
- package/lib/svg/analyse.d.cts +15 -0
- package/lib/svg/analyse.d.mts +15 -0
- package/lib/svg/analyse.d.ts +1 -0
- package/lib/svg/analyse.mjs +4 -4
- package/lib/svg/cleanup/attribs.cjs +1 -1
- package/lib/svg/cleanup/attribs.d.cts +11 -0
- package/lib/svg/cleanup/attribs.d.mts +11 -0
- package/lib/svg/cleanup/attribs.mjs +2 -2
- package/lib/svg/cleanup/bad-tags.cjs +1 -1
- package/lib/svg/cleanup/bad-tags.d.cts +17 -0
- package/lib/svg/cleanup/bad-tags.d.mts +17 -0
- package/lib/svg/cleanup/bad-tags.d.ts +1 -1
- package/lib/svg/cleanup/bad-tags.mjs +2 -2
- package/lib/svg/cleanup/inline-style.cjs +1 -1
- package/lib/svg/cleanup/inline-style.d.cts +11 -0
- package/lib/svg/cleanup/inline-style.d.mts +11 -0
- package/lib/svg/cleanup/inline-style.mjs +2 -2
- package/lib/svg/cleanup/root-style.cjs +1 -1
- package/lib/svg/cleanup/root-style.d.cts +17 -0
- package/lib/svg/cleanup/root-style.d.mts +17 -0
- package/lib/svg/cleanup/root-style.mjs +2 -2
- package/lib/svg/cleanup/root-svg.cjs +3 -3
- package/lib/svg/cleanup/root-svg.d.cts +11 -0
- package/lib/svg/cleanup/root-svg.d.mts +11 -0
- package/lib/svg/cleanup/root-svg.mjs +3 -3
- package/lib/svg/cleanup/svgo-style.cjs +2 -2
- package/lib/svg/cleanup/svgo-style.d.cts +11 -0
- package/lib/svg/cleanup/svgo-style.d.mts +11 -0
- package/lib/svg/cleanup/svgo-style.mjs +3 -3
- package/lib/svg/cleanup.d.cts +16 -0
- package/lib/svg/cleanup.d.mts +16 -0
- package/lib/svg/cleanup.d.ts +1 -1
- package/lib/svg/data/attributes.d.cts +77 -0
- package/lib/svg/data/attributes.d.mts +77 -0
- package/lib/svg/data/tags.d.cts +95 -0
- package/lib/svg/data/tags.d.mts +95 -0
- package/lib/svg/index.cjs +18 -1
- package/lib/svg/index.d.cts +52 -0
- package/lib/svg/index.d.mts +52 -0
- package/lib/svg/index.d.ts +5 -1
- package/lib/svg/index.mjs +19 -2
- package/lib/svg/parse-style.cjs +178 -235
- package/lib/svg/parse-style.d.cts +58 -0
- package/lib/svg/parse-style.d.mts +58 -0
- package/lib/svg/parse-style.d.ts +3 -9
- package/lib/svg/parse-style.mjs +180 -236
- package/lib/svg/parse.cjs +27 -59
- package/lib/svg/parse.d.cts +30 -0
- package/lib/svg/parse.d.mts +30 -0
- package/lib/svg/parse.d.ts +3 -10
- package/lib/svg/parse.mjs +28 -59
- package/package.json +26 -21
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DocumentNotModified } from '../../download/types/modified.cjs';
|
|
2
|
+
import { FigmaIfModifiedSinceOption, FigmaImportOptions } from './types/options.cjs';
|
|
3
|
+
import { FigmaImportResult } from './types/result.cjs';
|
|
4
|
+
import '../../icon-set/index.cjs';
|
|
5
|
+
import '@iconify/types';
|
|
6
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
7
|
+
import '../../icon-set/types.cjs';
|
|
8
|
+
import '../../svg/index.cjs';
|
|
9
|
+
import 'cheerio';
|
|
10
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
11
|
+
import './types/nodes.cjs';
|
|
12
|
+
import './types/api.cjs';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Import icon set from Figma
|
|
16
|
+
*/
|
|
17
|
+
declare function importFromFigma<T extends FigmaIfModifiedSinceOption & FigmaImportOptions>(options: T): Promise<FigmaImportResult | DocumentNotModified>;
|
|
18
|
+
declare function importFromFigma(options: FigmaImportOptions): Promise<FigmaImportResult>;
|
|
19
|
+
|
|
20
|
+
export { importFromFigma };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DocumentNotModified } from '../../download/types/modified.mjs';
|
|
2
|
+
import { FigmaIfModifiedSinceOption, FigmaImportOptions } from './types/options.mjs';
|
|
3
|
+
import { FigmaImportResult } from './types/result.mjs';
|
|
4
|
+
import '../../icon-set/index.mjs';
|
|
5
|
+
import '@iconify/types';
|
|
6
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
7
|
+
import '../../icon-set/types.mjs';
|
|
8
|
+
import '../../svg/index.mjs';
|
|
9
|
+
import 'cheerio';
|
|
10
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
11
|
+
import './types/nodes.mjs';
|
|
12
|
+
import './types/api.mjs';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Import icon set from Figma
|
|
16
|
+
*/
|
|
17
|
+
declare function importFromFigma<T extends FigmaIfModifiedSinceOption & FigmaImportOptions>(options: T): Promise<FigmaImportResult | DocumentNotModified>;
|
|
18
|
+
declare function importFromFigma(options: FigmaImportOptions): Promise<FigmaImportResult>;
|
|
19
|
+
|
|
20
|
+
export { importFromFigma };
|
|
@@ -32,10 +32,13 @@ import '../../optimise/svgo.mjs';
|
|
|
32
32
|
import 'svgo';
|
|
33
33
|
import '@iconify/utils/lib/svg/id';
|
|
34
34
|
import '../../download/api/index.mjs';
|
|
35
|
+
import 'axios';
|
|
35
36
|
import '../../download/api/cache.mjs';
|
|
36
37
|
import 'fs';
|
|
37
38
|
import 'crypto';
|
|
38
39
|
import '../../misc/scan.mjs';
|
|
40
|
+
import '../../download/api/config.mjs';
|
|
41
|
+
import '../../download/api/queue.mjs';
|
|
39
42
|
|
|
40
43
|
async function importFromFigma(options) {
|
|
41
44
|
const cacheOptions = options.cacheDir ? {
|
|
@@ -64,7 +64,7 @@ function getFigmaIconNodes(document, options) {
|
|
|
64
64
|
const newParents = parents.concat([parentItem]);
|
|
65
65
|
if (!parents.length && options.pages) {
|
|
66
66
|
const allowedPages = options.pages;
|
|
67
|
-
if (allowedPages.
|
|
67
|
+
if (!allowedPages.includes(node.id) && !allowedPages.includes(node.name.trim())) {
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
70
|
} else {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FigmaDocument } from './types/api.cjs';
|
|
2
|
+
import { FigmaGetIconNodesOptions } from './types/options.cjs';
|
|
3
|
+
import { FigmaNodesImportResult } from './types/result.cjs';
|
|
4
|
+
import '../../icon-set/index.cjs';
|
|
5
|
+
import '@iconify/types';
|
|
6
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
7
|
+
import '../../icon-set/types.cjs';
|
|
8
|
+
import '../../svg/index.cjs';
|
|
9
|
+
import 'cheerio';
|
|
10
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
11
|
+
import './types/nodes.cjs';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get node ids for icons
|
|
15
|
+
*/
|
|
16
|
+
declare function getFigmaIconNodes(document: FigmaDocument, options: FigmaGetIconNodesOptions): FigmaNodesImportResult;
|
|
17
|
+
|
|
18
|
+
export { getFigmaIconNodes };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FigmaDocument } from './types/api.mjs';
|
|
2
|
+
import { FigmaGetIconNodesOptions } from './types/options.mjs';
|
|
3
|
+
import { FigmaNodesImportResult } from './types/result.mjs';
|
|
4
|
+
import '../../icon-set/index.mjs';
|
|
5
|
+
import '@iconify/types';
|
|
6
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
7
|
+
import '../../icon-set/types.mjs';
|
|
8
|
+
import '../../svg/index.mjs';
|
|
9
|
+
import 'cheerio';
|
|
10
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
11
|
+
import './types/nodes.mjs';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get node ids for icons
|
|
15
|
+
*/
|
|
16
|
+
declare function getFigmaIconNodes(document: FigmaDocument, options: FigmaGetIconNodesOptions): FigmaNodesImportResult;
|
|
17
|
+
|
|
18
|
+
export { getFigmaIconNodes };
|
|
@@ -62,7 +62,7 @@ function getFigmaIconNodes(document, options) {
|
|
|
62
62
|
const newParents = parents.concat([parentItem]);
|
|
63
63
|
if (!parents.length && options.pages) {
|
|
64
64
|
const allowedPages = options.pages;
|
|
65
|
-
if (allowedPages.
|
|
65
|
+
if (!allowedPages.includes(node.id) && !allowedPages.includes(node.name.trim())) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
} else {
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const download_api_index = require('../../download/api/index.cjs');
|
|
4
4
|
const download_api_cache = require('../../download/api/cache.cjs');
|
|
5
|
+
const download_api_queue = require('../../download/api/queue.cjs');
|
|
6
|
+
require('axios');
|
|
7
|
+
require('../../download/api/config.cjs');
|
|
5
8
|
require('fs');
|
|
6
9
|
require('crypto');
|
|
7
10
|
require('../../misc/scan.cjs');
|
|
@@ -113,78 +116,92 @@ async function figmaImagesQuery(options, nodes, cache) {
|
|
|
113
116
|
const uri = "https://api.figma.com/v1/images/" + options.file;
|
|
114
117
|
const maxLength = 2048 - uri.length;
|
|
115
118
|
const svgOptions = options.svgOptions || {};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
119
|
+
const query = (ids2) => {
|
|
120
|
+
return new Promise((resolve, reject) => {
|
|
121
|
+
const params = new URLSearchParams({
|
|
122
|
+
ids: ids2.join(","),
|
|
123
|
+
format: "svg"
|
|
124
|
+
});
|
|
125
|
+
if (options.version) {
|
|
126
|
+
params.set("version", options.version);
|
|
127
|
+
}
|
|
128
|
+
if (svgOptions.includeID) {
|
|
129
|
+
params.set("svg_include_id", "true");
|
|
130
|
+
}
|
|
131
|
+
if (svgOptions.simplifyStroke) {
|
|
132
|
+
params.set("svg_simplify_stroke", "true");
|
|
133
|
+
}
|
|
134
|
+
if (svgOptions.useAbsoluteBounds) {
|
|
135
|
+
params.set("use_absolute_bounds", "true");
|
|
136
|
+
}
|
|
137
|
+
download_api_index.sendAPIQuery(
|
|
138
|
+
{
|
|
139
|
+
uri,
|
|
140
|
+
params,
|
|
141
|
+
headers: {
|
|
142
|
+
"X-FIGMA-TOKEN": options.token
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
cache
|
|
146
|
+
).then((data) => {
|
|
147
|
+
if (typeof data === "number") {
|
|
148
|
+
reject(data);
|
|
149
|
+
return;
|
|
143
150
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
try {
|
|
152
|
-
const parsedData = JSON.parse(data);
|
|
153
|
-
const images = parsedData.images;
|
|
154
|
-
for (const id in images) {
|
|
155
|
-
const node = nodes.icons[id];
|
|
156
|
-
const target = images[id];
|
|
157
|
-
if (node && target) {
|
|
158
|
-
node.url = target;
|
|
159
|
-
found++;
|
|
151
|
+
let parsedData;
|
|
152
|
+
try {
|
|
153
|
+
parsedData = JSON.parse(data);
|
|
154
|
+
} catch {
|
|
155
|
+
reject("Bad API response");
|
|
156
|
+
return;
|
|
160
157
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
158
|
+
resolve(parsedData);
|
|
159
|
+
}).catch(reject);
|
|
160
|
+
});
|
|
165
161
|
};
|
|
162
|
+
let ids = [];
|
|
163
|
+
let idsLength = 0;
|
|
166
164
|
const allKeys = Object.keys(nodes.icons);
|
|
165
|
+
const queue = [];
|
|
167
166
|
for (let i = 0; i < allKeys.length; i++) {
|
|
168
167
|
const id = allKeys[i];
|
|
169
168
|
ids.push(id);
|
|
170
169
|
idsLength += id.length + 1;
|
|
171
170
|
if (idsLength >= maxLength) {
|
|
172
|
-
|
|
171
|
+
queue.push(ids.slice(0));
|
|
173
172
|
ids = [];
|
|
174
173
|
idsLength = 0;
|
|
175
174
|
}
|
|
176
175
|
}
|
|
177
176
|
if (idsLength) {
|
|
178
|
-
|
|
177
|
+
queue.push(ids.slice(0));
|
|
179
178
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
179
|
+
const queryParams = {
|
|
180
|
+
// Params
|
|
181
|
+
total: queue.length,
|
|
182
|
+
callback: (index) => query(queue[index]),
|
|
183
|
+
// Payload to identify failed items in onfail callback
|
|
184
|
+
function: "figmaImagesQuery",
|
|
185
|
+
payload: queue
|
|
186
|
+
};
|
|
187
|
+
const results = await download_api_queue.runConcurrentQueries(queryParams);
|
|
188
|
+
let found = 0;
|
|
189
|
+
results.forEach((data) => {
|
|
190
|
+
if (!data) {
|
|
191
|
+
return;
|
|
187
192
|
}
|
|
193
|
+
const images = data.images;
|
|
194
|
+
for (const id in images) {
|
|
195
|
+
const node = nodes.icons[id];
|
|
196
|
+
const target = images[id];
|
|
197
|
+
if (node && target) {
|
|
198
|
+
node.url = target;
|
|
199
|
+
found++;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
if (!found) {
|
|
204
|
+
throw new Error("No valid icon layers were found");
|
|
188
205
|
}
|
|
189
206
|
nodes.generatedIconsCount = found;
|
|
190
207
|
return nodes;
|
|
@@ -193,32 +210,43 @@ async function figmaDownloadImages(nodes, cache) {
|
|
|
193
210
|
const icons = nodes.icons;
|
|
194
211
|
const ids = Object.keys(icons);
|
|
195
212
|
let count = 0;
|
|
196
|
-
|
|
213
|
+
const filtered = [];
|
|
197
214
|
for (let i = 0; i < ids.length; i++) {
|
|
198
215
|
const id = ids[i];
|
|
199
216
|
const item = icons[id];
|
|
200
|
-
if (
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
const result = await download_api_index.sendAPIQuery(
|
|
204
|
-
{
|
|
205
|
-
uri: item.url
|
|
206
|
-
},
|
|
207
|
-
cache
|
|
208
|
-
);
|
|
209
|
-
if (typeof result === "number") {
|
|
210
|
-
lastError = result;
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
if (typeof result === "string") {
|
|
214
|
-
count++;
|
|
215
|
-
item.content = result;
|
|
217
|
+
if (item.url) {
|
|
218
|
+
filtered.push(item);
|
|
216
219
|
}
|
|
217
220
|
}
|
|
221
|
+
const params = {
|
|
222
|
+
// Params
|
|
223
|
+
total: filtered.length,
|
|
224
|
+
callback: (index) => {
|
|
225
|
+
return new Promise((resolve, reject) => {
|
|
226
|
+
const item = filtered[index];
|
|
227
|
+
download_api_index.sendAPIQuery(
|
|
228
|
+
{
|
|
229
|
+
uri: item.url
|
|
230
|
+
},
|
|
231
|
+
cache
|
|
232
|
+
).then((data) => {
|
|
233
|
+
if (typeof data === "string") {
|
|
234
|
+
count++;
|
|
235
|
+
item.content = data;
|
|
236
|
+
resolve(void 0);
|
|
237
|
+
} else {
|
|
238
|
+
reject(data);
|
|
239
|
+
}
|
|
240
|
+
}).catch(reject);
|
|
241
|
+
});
|
|
242
|
+
},
|
|
243
|
+
// Payload to identify failed items in onfail callback
|
|
244
|
+
function: "figmaDownloadImages",
|
|
245
|
+
payload: filtered
|
|
246
|
+
};
|
|
247
|
+
await download_api_queue.runConcurrentQueries(params);
|
|
218
248
|
if (!count) {
|
|
219
|
-
throw new Error(
|
|
220
|
-
`Error retrieving images${lastError ? ": " + lastError.toString() : ""}`
|
|
221
|
-
);
|
|
249
|
+
throw new Error("Error retrieving images");
|
|
222
250
|
}
|
|
223
251
|
nodes.downloadedIconsCount = count;
|
|
224
252
|
return nodes;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { APICacheOptions } from '../../download/api/types.cjs';
|
|
2
|
+
import { DocumentNotModified } from '../../download/types/modified.cjs';
|
|
3
|
+
import { FigmaDocument } from './types/api.cjs';
|
|
4
|
+
import { FigmaIfModifiedSinceOption, FigmaFilesQueryOptions, FigmaImagesQueryOptions } from './types/options.cjs';
|
|
5
|
+
import { FigmaNodesImportResult, FigmaIconNode } from './types/result.cjs';
|
|
6
|
+
import '../../icon-set/index.cjs';
|
|
7
|
+
import '@iconify/types';
|
|
8
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
9
|
+
import '../../icon-set/types.cjs';
|
|
10
|
+
import '../../svg/index.cjs';
|
|
11
|
+
import 'cheerio';
|
|
12
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
13
|
+
import './types/nodes.cjs';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Extra parameters added to runConcurrentQueries()
|
|
17
|
+
*
|
|
18
|
+
* Can be used to identify failed items in onfail callback
|
|
19
|
+
*/
|
|
20
|
+
interface FigmaIconNodeWithURL extends FigmaIconNode {
|
|
21
|
+
url: string;
|
|
22
|
+
}
|
|
23
|
+
type FigmaConcurrentQueriesParamsFunction = 'figmaImagesQuery' | 'figmaDownloadImages';
|
|
24
|
+
interface FigmaConcurrentQueriesParams<T extends FigmaConcurrentQueriesParamsFunction> {
|
|
25
|
+
function: T;
|
|
26
|
+
payload: T extends 'figmaImagesQuery' ? string[][] : FigmaIconNodeWithURL[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get Figma files
|
|
30
|
+
*/
|
|
31
|
+
declare function figmaFilesQuery<T extends FigmaIfModifiedSinceOption & FigmaFilesQueryOptions>(options: T, cache?: APICacheOptions): Promise<FigmaDocument | DocumentNotModified>;
|
|
32
|
+
declare function figmaFilesQuery(options: FigmaFilesQueryOptions, cache?: APICacheOptions): Promise<FigmaDocument>;
|
|
33
|
+
/**
|
|
34
|
+
* Generate all images
|
|
35
|
+
*/
|
|
36
|
+
declare function figmaImagesQuery(options: FigmaImagesQueryOptions, nodes: FigmaNodesImportResult, cache?: APICacheOptions): Promise<FigmaNodesImportResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Download all images
|
|
39
|
+
*/
|
|
40
|
+
declare function figmaDownloadImages(nodes: FigmaNodesImportResult, cache?: APICacheOptions): Promise<FigmaNodesImportResult>;
|
|
41
|
+
|
|
42
|
+
export { type FigmaConcurrentQueriesParams, type FigmaConcurrentQueriesParamsFunction, figmaDownloadImages, figmaFilesQuery, figmaImagesQuery };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { APICacheOptions } from '../../download/api/types.mjs';
|
|
2
|
+
import { DocumentNotModified } from '../../download/types/modified.mjs';
|
|
3
|
+
import { FigmaDocument } from './types/api.mjs';
|
|
4
|
+
import { FigmaIfModifiedSinceOption, FigmaFilesQueryOptions, FigmaImagesQueryOptions } from './types/options.mjs';
|
|
5
|
+
import { FigmaNodesImportResult, FigmaIconNode } from './types/result.mjs';
|
|
6
|
+
import '../../icon-set/index.mjs';
|
|
7
|
+
import '@iconify/types';
|
|
8
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
9
|
+
import '../../icon-set/types.mjs';
|
|
10
|
+
import '../../svg/index.mjs';
|
|
11
|
+
import 'cheerio';
|
|
12
|
+
import '@iconify/utils/lib/icon-set/tree';
|
|
13
|
+
import './types/nodes.mjs';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Extra parameters added to runConcurrentQueries()
|
|
17
|
+
*
|
|
18
|
+
* Can be used to identify failed items in onfail callback
|
|
19
|
+
*/
|
|
20
|
+
interface FigmaIconNodeWithURL extends FigmaIconNode {
|
|
21
|
+
url: string;
|
|
22
|
+
}
|
|
23
|
+
type FigmaConcurrentQueriesParamsFunction = 'figmaImagesQuery' | 'figmaDownloadImages';
|
|
24
|
+
interface FigmaConcurrentQueriesParams<T extends FigmaConcurrentQueriesParamsFunction> {
|
|
25
|
+
function: T;
|
|
26
|
+
payload: T extends 'figmaImagesQuery' ? string[][] : FigmaIconNodeWithURL[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get Figma files
|
|
30
|
+
*/
|
|
31
|
+
declare function figmaFilesQuery<T extends FigmaIfModifiedSinceOption & FigmaFilesQueryOptions>(options: T, cache?: APICacheOptions): Promise<FigmaDocument | DocumentNotModified>;
|
|
32
|
+
declare function figmaFilesQuery(options: FigmaFilesQueryOptions, cache?: APICacheOptions): Promise<FigmaDocument>;
|
|
33
|
+
/**
|
|
34
|
+
* Generate all images
|
|
35
|
+
*/
|
|
36
|
+
declare function figmaImagesQuery(options: FigmaImagesQueryOptions, nodes: FigmaNodesImportResult, cache?: APICacheOptions): Promise<FigmaNodesImportResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Download all images
|
|
39
|
+
*/
|
|
40
|
+
declare function figmaDownloadImages(nodes: FigmaNodesImportResult, cache?: APICacheOptions): Promise<FigmaNodesImportResult>;
|
|
41
|
+
|
|
42
|
+
export { type FigmaConcurrentQueriesParams, type FigmaConcurrentQueriesParamsFunction, figmaDownloadImages, figmaFilesQuery, figmaImagesQuery };
|
|
@@ -2,7 +2,7 @@ import { APICacheOptions } from '../../download/api/types.js';
|
|
|
2
2
|
import { DocumentNotModified } from '../../download/types/modified.js';
|
|
3
3
|
import { FigmaDocument } from './types/api.js';
|
|
4
4
|
import { FigmaIfModifiedSinceOption, FigmaFilesQueryOptions, FigmaImagesQueryOptions } from './types/options.js';
|
|
5
|
-
import { FigmaNodesImportResult } from './types/result.js';
|
|
5
|
+
import { FigmaNodesImportResult, FigmaIconNode } from './types/result.js';
|
|
6
6
|
import '../../icon-set/index.js';
|
|
7
7
|
import '@iconify/types';
|
|
8
8
|
import '@iconify/utils/lib/customisations/defaults';
|
|
@@ -12,6 +12,19 @@ import 'cheerio';
|
|
|
12
12
|
import '@iconify/utils/lib/icon-set/tree';
|
|
13
13
|
import './types/nodes.js';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Extra parameters added to runConcurrentQueries()
|
|
17
|
+
*
|
|
18
|
+
* Can be used to identify failed items in onfail callback
|
|
19
|
+
*/
|
|
20
|
+
interface FigmaIconNodeWithURL extends FigmaIconNode {
|
|
21
|
+
url: string;
|
|
22
|
+
}
|
|
23
|
+
type FigmaConcurrentQueriesParamsFunction = 'figmaImagesQuery' | 'figmaDownloadImages';
|
|
24
|
+
interface FigmaConcurrentQueriesParams<T extends FigmaConcurrentQueriesParamsFunction> {
|
|
25
|
+
function: T;
|
|
26
|
+
payload: T extends 'figmaImagesQuery' ? string[][] : FigmaIconNodeWithURL[];
|
|
27
|
+
}
|
|
15
28
|
/**
|
|
16
29
|
* Get Figma files
|
|
17
30
|
*/
|
|
@@ -26,4 +39,4 @@ declare function figmaImagesQuery(options: FigmaImagesQueryOptions, nodes: Figma
|
|
|
26
39
|
*/
|
|
27
40
|
declare function figmaDownloadImages(nodes: FigmaNodesImportResult, cache?: APICacheOptions): Promise<FigmaNodesImportResult>;
|
|
28
41
|
|
|
29
|
-
export { figmaDownloadImages, figmaFilesQuery, figmaImagesQuery };
|
|
42
|
+
export { type FigmaConcurrentQueriesParams, type FigmaConcurrentQueriesParamsFunction, figmaDownloadImages, figmaFilesQuery, figmaImagesQuery };
|