@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
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const axios = require('axios');
|
|
3
4
|
const download_api_cache = require('./cache.cjs');
|
|
5
|
+
const download_api_config = require('./config.cjs');
|
|
4
6
|
require('fs');
|
|
5
7
|
require('crypto');
|
|
6
8
|
require('../../misc/scan.cjs');
|
|
7
9
|
|
|
10
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
11
|
+
|
|
12
|
+
const axios__default = /*#__PURE__*/_interopDefaultCompat(axios);
|
|
13
|
+
|
|
8
14
|
async function sendAPIQuery(query, cache) {
|
|
9
15
|
const cacheKey = cache ? download_api_cache.apiCacheKey(query) : "";
|
|
10
16
|
if (cache) {
|
|
@@ -26,18 +32,28 @@ async function sendAPIQuery(query, cache) {
|
|
|
26
32
|
async function sendQuery(query) {
|
|
27
33
|
const params = query.params ? query.params.toString() : "";
|
|
28
34
|
const url = query.uri + (params ? "?" + params : "");
|
|
29
|
-
console.log("Fetch:", url);
|
|
30
35
|
const headers = query.headers;
|
|
36
|
+
download_api_config.fetchCallbacks.onStart?.(url, query);
|
|
37
|
+
function fail(value) {
|
|
38
|
+
download_api_config.fetchCallbacks.onError?.(url, query, value);
|
|
39
|
+
return value ?? 404;
|
|
40
|
+
}
|
|
31
41
|
try {
|
|
32
|
-
const response = await
|
|
33
|
-
|
|
42
|
+
const response = await axios__default.get(url, {
|
|
43
|
+
...download_api_config.axiosConfig,
|
|
44
|
+
headers,
|
|
45
|
+
responseType: "text"
|
|
34
46
|
});
|
|
35
|
-
if (response.status
|
|
36
|
-
return response.status;
|
|
47
|
+
if (response.status !== 200) {
|
|
48
|
+
return fail(response.status);
|
|
49
|
+
}
|
|
50
|
+
if (typeof response.data !== "string") {
|
|
51
|
+
return fail();
|
|
37
52
|
}
|
|
38
|
-
|
|
53
|
+
download_api_config.fetchCallbacks.onSuccess?.(url, query);
|
|
54
|
+
return response.data;
|
|
39
55
|
} catch (err) {
|
|
40
|
-
return
|
|
56
|
+
return fail();
|
|
41
57
|
}
|
|
42
58
|
}
|
|
43
59
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
1
2
|
import { apiCacheKey, getAPICache, storeAPICache } from './cache.mjs';
|
|
3
|
+
import { fetchCallbacks, axiosConfig } from './config.mjs';
|
|
2
4
|
import 'fs';
|
|
3
5
|
import 'crypto';
|
|
4
6
|
import '../../misc/scan.mjs';
|
|
@@ -24,18 +26,28 @@ async function sendAPIQuery(query, cache) {
|
|
|
24
26
|
async function sendQuery(query) {
|
|
25
27
|
const params = query.params ? query.params.toString() : "";
|
|
26
28
|
const url = query.uri + (params ? "?" + params : "");
|
|
27
|
-
console.log("Fetch:", url);
|
|
28
29
|
const headers = query.headers;
|
|
30
|
+
fetchCallbacks.onStart?.(url, query);
|
|
31
|
+
function fail(value) {
|
|
32
|
+
fetchCallbacks.onError?.(url, query, value);
|
|
33
|
+
return value ?? 404;
|
|
34
|
+
}
|
|
29
35
|
try {
|
|
30
|
-
const response = await
|
|
31
|
-
|
|
36
|
+
const response = await axios.get(url, {
|
|
37
|
+
...axiosConfig,
|
|
38
|
+
headers,
|
|
39
|
+
responseType: "text"
|
|
32
40
|
});
|
|
33
|
-
if (response.status
|
|
34
|
-
return response.status;
|
|
41
|
+
if (response.status !== 200) {
|
|
42
|
+
return fail(response.status);
|
|
43
|
+
}
|
|
44
|
+
if (typeof response.data !== "string") {
|
|
45
|
+
return fail();
|
|
35
46
|
}
|
|
36
|
-
|
|
47
|
+
fetchCallbacks.onSuccess?.(url, query);
|
|
48
|
+
return response.data;
|
|
37
49
|
} catch (err) {
|
|
38
|
-
return
|
|
50
|
+
return fail();
|
|
39
51
|
}
|
|
40
52
|
}
|
|
41
53
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const defaultQueueParams = {
|
|
4
|
+
limit: 5,
|
|
5
|
+
retries: 3
|
|
6
|
+
};
|
|
7
|
+
function runConcurrentQueries(params) {
|
|
8
|
+
const allParams = {
|
|
9
|
+
...defaultQueueParams,
|
|
10
|
+
...params
|
|
11
|
+
};
|
|
12
|
+
const paramsWithCount = allParams;
|
|
13
|
+
const paramsWithPromises = allParams;
|
|
14
|
+
const isCallback = typeof paramsWithCount.total === "number";
|
|
15
|
+
const count = isCallback ? paramsWithCount.total : paramsWithPromises.promises.length;
|
|
16
|
+
const limit = Math.max(1, Math.min(allParams.limit || 1, count));
|
|
17
|
+
const retries = Math.max(1, allParams.retries || 1);
|
|
18
|
+
const results = Array(count).fill(void 0);
|
|
19
|
+
let nextIndex = 0;
|
|
20
|
+
const resolving = /* @__PURE__ */ new Set();
|
|
21
|
+
let rejected = false;
|
|
22
|
+
let resolved = false;
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
function resolvedItem() {
|
|
25
|
+
if (rejected || resolved) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (!resolving.size && nextIndex > count) {
|
|
29
|
+
resolved = true;
|
|
30
|
+
resolve(results);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (resolving.size < limit && nextIndex <= count) {
|
|
34
|
+
startNext();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function fail(index, err) {
|
|
38
|
+
function done(failed) {
|
|
39
|
+
resolving.delete(index);
|
|
40
|
+
if (failed) {
|
|
41
|
+
rejected = true;
|
|
42
|
+
reject(err);
|
|
43
|
+
} else {
|
|
44
|
+
resolvedItem();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (allParams.onError) {
|
|
48
|
+
let retry;
|
|
49
|
+
try {
|
|
50
|
+
retry = allParams.onError(index, err, params);
|
|
51
|
+
} catch (err2) {
|
|
52
|
+
err = err2;
|
|
53
|
+
done(true);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (retry instanceof Promise) {
|
|
57
|
+
retry.then(() => {
|
|
58
|
+
done(false);
|
|
59
|
+
}).catch((err2) => {
|
|
60
|
+
err = err2;
|
|
61
|
+
done(true);
|
|
62
|
+
});
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
done(false);
|
|
66
|
+
} else {
|
|
67
|
+
done(true);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function run(index, retry) {
|
|
71
|
+
resolving.add(index);
|
|
72
|
+
const p = isCallback ? paramsWithCount.callback(index) : paramsWithPromises.promises[index];
|
|
73
|
+
allParams.onStart?.(index, params);
|
|
74
|
+
p.then((value) => {
|
|
75
|
+
resolving.delete(index);
|
|
76
|
+
results[index] = value;
|
|
77
|
+
allParams.onSuccess?.(index, params, value);
|
|
78
|
+
resolvedItem();
|
|
79
|
+
}).catch((err) => {
|
|
80
|
+
if (retry < retries) {
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
run(index, retry + 1);
|
|
83
|
+
});
|
|
84
|
+
} else if (!rejected) {
|
|
85
|
+
fail(index, err);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function startNext() {
|
|
90
|
+
const index = nextIndex++;
|
|
91
|
+
if (index >= count) {
|
|
92
|
+
resolvedItem();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
run(index, 0);
|
|
96
|
+
}
|
|
97
|
+
for (let i = 0; i < limit; i++) {
|
|
98
|
+
startNext();
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
exports.defaultQueueParams = defaultQueueParams;
|
|
104
|
+
exports.runConcurrentQueries = runConcurrentQueries;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default parameters
|
|
3
|
+
*/
|
|
4
|
+
declare const defaultQueueParams: ConcurrentQueriesCommonParams<unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* Callback to get query
|
|
7
|
+
*/
|
|
8
|
+
type GetConcurrentQueryCallback<T> = (index: number) => Promise<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Parameters
|
|
11
|
+
*/
|
|
12
|
+
interface ConcurrentQueriesCommonParams<T> {
|
|
13
|
+
limit?: number;
|
|
14
|
+
retries?: number;
|
|
15
|
+
onError?: (index: number, error: unknown, params: ConcurrentQueriesParams<T>) => void | Promise<void>;
|
|
16
|
+
onSuccess?: (index: number, params: ConcurrentQueriesParams<T>, result: T) => void;
|
|
17
|
+
onStart?: (index: number, params: ConcurrentQueriesParams<T>) => void;
|
|
18
|
+
}
|
|
19
|
+
interface ConcurrentQueriesParamsWithCount<T> extends ConcurrentQueriesCommonParams<T> {
|
|
20
|
+
total: number;
|
|
21
|
+
callback: (index: number) => Promise<T>;
|
|
22
|
+
}
|
|
23
|
+
interface ConcurrentQueriesParamsWithPromises<T> extends ConcurrentQueriesCommonParams<T> {
|
|
24
|
+
promises: Promise<T>[];
|
|
25
|
+
}
|
|
26
|
+
type ConcurrentQueriesParams<T> = ConcurrentQueriesParamsWithCount<T> | ConcurrentQueriesParamsWithPromises<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Runs concurrent async operations
|
|
29
|
+
*/
|
|
30
|
+
declare function runConcurrentQueries<T>(params: ConcurrentQueriesParams<T>): Promise<T[]>;
|
|
31
|
+
|
|
32
|
+
export { type ConcurrentQueriesCommonParams, type ConcurrentQueriesParams, type ConcurrentQueriesParamsWithCount, type ConcurrentQueriesParamsWithPromises, type GetConcurrentQueryCallback, defaultQueueParams, runConcurrentQueries };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default parameters
|
|
3
|
+
*/
|
|
4
|
+
declare const defaultQueueParams: ConcurrentQueriesCommonParams<unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* Callback to get query
|
|
7
|
+
*/
|
|
8
|
+
type GetConcurrentQueryCallback<T> = (index: number) => Promise<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Parameters
|
|
11
|
+
*/
|
|
12
|
+
interface ConcurrentQueriesCommonParams<T> {
|
|
13
|
+
limit?: number;
|
|
14
|
+
retries?: number;
|
|
15
|
+
onError?: (index: number, error: unknown, params: ConcurrentQueriesParams<T>) => void | Promise<void>;
|
|
16
|
+
onSuccess?: (index: number, params: ConcurrentQueriesParams<T>, result: T) => void;
|
|
17
|
+
onStart?: (index: number, params: ConcurrentQueriesParams<T>) => void;
|
|
18
|
+
}
|
|
19
|
+
interface ConcurrentQueriesParamsWithCount<T> extends ConcurrentQueriesCommonParams<T> {
|
|
20
|
+
total: number;
|
|
21
|
+
callback: (index: number) => Promise<T>;
|
|
22
|
+
}
|
|
23
|
+
interface ConcurrentQueriesParamsWithPromises<T> extends ConcurrentQueriesCommonParams<T> {
|
|
24
|
+
promises: Promise<T>[];
|
|
25
|
+
}
|
|
26
|
+
type ConcurrentQueriesParams<T> = ConcurrentQueriesParamsWithCount<T> | ConcurrentQueriesParamsWithPromises<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Runs concurrent async operations
|
|
29
|
+
*/
|
|
30
|
+
declare function runConcurrentQueries<T>(params: ConcurrentQueriesParams<T>): Promise<T[]>;
|
|
31
|
+
|
|
32
|
+
export { type ConcurrentQueriesCommonParams, type ConcurrentQueriesParams, type ConcurrentQueriesParamsWithCount, type ConcurrentQueriesParamsWithPromises, type GetConcurrentQueryCallback, defaultQueueParams, runConcurrentQueries };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default parameters
|
|
3
|
+
*/
|
|
4
|
+
declare const defaultQueueParams: ConcurrentQueriesCommonParams<unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* Callback to get query
|
|
7
|
+
*/
|
|
8
|
+
type GetConcurrentQueryCallback<T> = (index: number) => Promise<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Parameters
|
|
11
|
+
*/
|
|
12
|
+
interface ConcurrentQueriesCommonParams<T> {
|
|
13
|
+
limit?: number;
|
|
14
|
+
retries?: number;
|
|
15
|
+
onError?: (index: number, error: unknown, params: ConcurrentQueriesParams<T>) => void | Promise<void>;
|
|
16
|
+
onSuccess?: (index: number, params: ConcurrentQueriesParams<T>, result: T) => void;
|
|
17
|
+
onStart?: (index: number, params: ConcurrentQueriesParams<T>) => void;
|
|
18
|
+
}
|
|
19
|
+
interface ConcurrentQueriesParamsWithCount<T> extends ConcurrentQueriesCommonParams<T> {
|
|
20
|
+
total: number;
|
|
21
|
+
callback: (index: number) => Promise<T>;
|
|
22
|
+
}
|
|
23
|
+
interface ConcurrentQueriesParamsWithPromises<T> extends ConcurrentQueriesCommonParams<T> {
|
|
24
|
+
promises: Promise<T>[];
|
|
25
|
+
}
|
|
26
|
+
type ConcurrentQueriesParams<T> = ConcurrentQueriesParamsWithCount<T> | ConcurrentQueriesParamsWithPromises<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Runs concurrent async operations
|
|
29
|
+
*/
|
|
30
|
+
declare function runConcurrentQueries<T>(params: ConcurrentQueriesParams<T>): Promise<T[]>;
|
|
31
|
+
|
|
32
|
+
export { type ConcurrentQueriesCommonParams, type ConcurrentQueriesParams, type ConcurrentQueriesParamsWithCount, type ConcurrentQueriesParamsWithPromises, type GetConcurrentQueryCallback, defaultQueueParams, runConcurrentQueries };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const defaultQueueParams = {
|
|
2
|
+
limit: 5,
|
|
3
|
+
retries: 3
|
|
4
|
+
};
|
|
5
|
+
function runConcurrentQueries(params) {
|
|
6
|
+
const allParams = {
|
|
7
|
+
...defaultQueueParams,
|
|
8
|
+
...params
|
|
9
|
+
};
|
|
10
|
+
const paramsWithCount = allParams;
|
|
11
|
+
const paramsWithPromises = allParams;
|
|
12
|
+
const isCallback = typeof paramsWithCount.total === "number";
|
|
13
|
+
const count = isCallback ? paramsWithCount.total : paramsWithPromises.promises.length;
|
|
14
|
+
const limit = Math.max(1, Math.min(allParams.limit || 1, count));
|
|
15
|
+
const retries = Math.max(1, allParams.retries || 1);
|
|
16
|
+
const results = Array(count).fill(void 0);
|
|
17
|
+
let nextIndex = 0;
|
|
18
|
+
const resolving = /* @__PURE__ */ new Set();
|
|
19
|
+
let rejected = false;
|
|
20
|
+
let resolved = false;
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
function resolvedItem() {
|
|
23
|
+
if (rejected || resolved) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (!resolving.size && nextIndex > count) {
|
|
27
|
+
resolved = true;
|
|
28
|
+
resolve(results);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (resolving.size < limit && nextIndex <= count) {
|
|
32
|
+
startNext();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function fail(index, err) {
|
|
36
|
+
function done(failed) {
|
|
37
|
+
resolving.delete(index);
|
|
38
|
+
if (failed) {
|
|
39
|
+
rejected = true;
|
|
40
|
+
reject(err);
|
|
41
|
+
} else {
|
|
42
|
+
resolvedItem();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (allParams.onError) {
|
|
46
|
+
let retry;
|
|
47
|
+
try {
|
|
48
|
+
retry = allParams.onError(index, err, params);
|
|
49
|
+
} catch (err2) {
|
|
50
|
+
err = err2;
|
|
51
|
+
done(true);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (retry instanceof Promise) {
|
|
55
|
+
retry.then(() => {
|
|
56
|
+
done(false);
|
|
57
|
+
}).catch((err2) => {
|
|
58
|
+
err = err2;
|
|
59
|
+
done(true);
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
done(false);
|
|
64
|
+
} else {
|
|
65
|
+
done(true);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function run(index, retry) {
|
|
69
|
+
resolving.add(index);
|
|
70
|
+
const p = isCallback ? paramsWithCount.callback(index) : paramsWithPromises.promises[index];
|
|
71
|
+
allParams.onStart?.(index, params);
|
|
72
|
+
p.then((value) => {
|
|
73
|
+
resolving.delete(index);
|
|
74
|
+
results[index] = value;
|
|
75
|
+
allParams.onSuccess?.(index, params, value);
|
|
76
|
+
resolvedItem();
|
|
77
|
+
}).catch((err) => {
|
|
78
|
+
if (retry < retries) {
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
run(index, retry + 1);
|
|
81
|
+
});
|
|
82
|
+
} else if (!rejected) {
|
|
83
|
+
fail(index, err);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function startNext() {
|
|
88
|
+
const index = nextIndex++;
|
|
89
|
+
if (index >= count) {
|
|
90
|
+
resolvedItem();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
run(index, 0);
|
|
94
|
+
}
|
|
95
|
+
for (let i = 0; i < limit; i++) {
|
|
96
|
+
startNext();
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { defaultQueueParams, runConcurrentQueries };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Cache
|
|
3
|
+
*/
|
|
4
|
+
interface APICacheOptions {
|
|
5
|
+
dir: string;
|
|
6
|
+
ttl: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Params
|
|
10
|
+
*/
|
|
11
|
+
interface APIQueryParams {
|
|
12
|
+
uri: string;
|
|
13
|
+
params?: URLSearchParams;
|
|
14
|
+
headers?: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { APICacheOptions, APIQueryParams };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Cache
|
|
3
|
+
*/
|
|
4
|
+
interface APICacheOptions {
|
|
5
|
+
dir: string;
|
|
6
|
+
ttl: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Params
|
|
10
|
+
*/
|
|
11
|
+
interface APIQueryParams {
|
|
12
|
+
uri: string;
|
|
13
|
+
params?: URLSearchParams;
|
|
14
|
+
headers?: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { APICacheOptions, APIQueryParams };
|
|
@@ -23,17 +23,15 @@ require('@iconify/utils/lib/icon-set/convert-info');
|
|
|
23
23
|
require('../../icon-set/props.cjs');
|
|
24
24
|
require('@iconify/utils/lib/misc/objects');
|
|
25
25
|
require('@iconify/utils/lib/colors');
|
|
26
|
+
require('axios');
|
|
26
27
|
require('crypto');
|
|
27
|
-
require('../api/download.cjs');
|
|
28
|
-
require('util');
|
|
29
|
-
require('stream');
|
|
30
28
|
require('fs/promises');
|
|
31
29
|
require('extract-zip');
|
|
32
30
|
require('tar');
|
|
33
31
|
|
|
34
32
|
async function downloadGitRepo(options) {
|
|
35
33
|
const { remote, branch } = options;
|
|
36
|
-
const hasHashInTarget = options.target.
|
|
34
|
+
const hasHashInTarget = options.target.includes("{hash}");
|
|
37
35
|
const ifModifiedSince = options.ifModifiedSince;
|
|
38
36
|
if (ifModifiedSince || hasHashInTarget) {
|
|
39
37
|
const result = await misc_exec.execAsync(
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ExportTargetOptions } from '../../export/helpers/prepare.cjs';
|
|
2
|
+
import { DocumentNotModified } from '../types/modified.cjs';
|
|
3
|
+
import { DownloadSourceMixin } from '../types/sources.cjs';
|
|
4
|
+
|
|
5
|
+
interface IfModifiedSinceOption {
|
|
6
|
+
ifModifiedSince: string | true | DownloadGitRepoResult;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Options for downloadGitRepo()
|
|
10
|
+
*/
|
|
11
|
+
interface DownloadGitRepoOptions extends ExportTargetOptions, Partial<IfModifiedSinceOption> {
|
|
12
|
+
remote: string;
|
|
13
|
+
branch: string;
|
|
14
|
+
log?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Result
|
|
18
|
+
*/
|
|
19
|
+
interface DownloadGitRepoResult extends DownloadSourceMixin<'git'> {
|
|
20
|
+
contentsDir: string;
|
|
21
|
+
hash: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Download Git repo
|
|
25
|
+
*/
|
|
26
|
+
declare function downloadGitRepo<T extends IfModifiedSinceOption & DownloadGitRepoOptions>(options: T): Promise<DownloadGitRepoResult | DocumentNotModified>;
|
|
27
|
+
declare function downloadGitRepo(options: DownloadGitRepoOptions): Promise<DownloadGitRepoResult>;
|
|
28
|
+
|
|
29
|
+
export { type DownloadGitRepoOptions, type DownloadGitRepoResult, downloadGitRepo };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ExportTargetOptions } from '../../export/helpers/prepare.mjs';
|
|
2
|
+
import { DocumentNotModified } from '../types/modified.mjs';
|
|
3
|
+
import { DownloadSourceMixin } from '../types/sources.mjs';
|
|
4
|
+
|
|
5
|
+
interface IfModifiedSinceOption {
|
|
6
|
+
ifModifiedSince: string | true | DownloadGitRepoResult;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Options for downloadGitRepo()
|
|
10
|
+
*/
|
|
11
|
+
interface DownloadGitRepoOptions extends ExportTargetOptions, Partial<IfModifiedSinceOption> {
|
|
12
|
+
remote: string;
|
|
13
|
+
branch: string;
|
|
14
|
+
log?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Result
|
|
18
|
+
*/
|
|
19
|
+
interface DownloadGitRepoResult extends DownloadSourceMixin<'git'> {
|
|
20
|
+
contentsDir: string;
|
|
21
|
+
hash: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Download Git repo
|
|
25
|
+
*/
|
|
26
|
+
declare function downloadGitRepo<T extends IfModifiedSinceOption & DownloadGitRepoOptions>(options: T): Promise<DownloadGitRepoResult | DocumentNotModified>;
|
|
27
|
+
declare function downloadGitRepo(options: DownloadGitRepoOptions): Promise<DownloadGitRepoResult>;
|
|
28
|
+
|
|
29
|
+
export { type DownloadGitRepoOptions, type DownloadGitRepoResult, downloadGitRepo };
|
|
@@ -26,4 +26,4 @@ interface DownloadGitRepoResult extends DownloadSourceMixin<'git'> {
|
|
|
26
26
|
declare function downloadGitRepo<T extends IfModifiedSinceOption & DownloadGitRepoOptions>(options: T): Promise<DownloadGitRepoResult | DocumentNotModified>;
|
|
27
27
|
declare function downloadGitRepo(options: DownloadGitRepoOptions): Promise<DownloadGitRepoResult>;
|
|
28
28
|
|
|
29
|
-
export { DownloadGitRepoOptions, DownloadGitRepoResult, downloadGitRepo };
|
|
29
|
+
export { type DownloadGitRepoOptions, type DownloadGitRepoResult, downloadGitRepo };
|
|
@@ -21,17 +21,15 @@ import '@iconify/utils/lib/icon-set/convert-info';
|
|
|
21
21
|
import '../../icon-set/props.mjs';
|
|
22
22
|
import '@iconify/utils/lib/misc/objects';
|
|
23
23
|
import '@iconify/utils/lib/colors';
|
|
24
|
+
import 'axios';
|
|
24
25
|
import 'crypto';
|
|
25
|
-
import '../api/download.mjs';
|
|
26
|
-
import 'util';
|
|
27
|
-
import 'stream';
|
|
28
26
|
import 'fs/promises';
|
|
29
27
|
import 'extract-zip';
|
|
30
28
|
import 'tar';
|
|
31
29
|
|
|
32
30
|
async function downloadGitRepo(options) {
|
|
33
31
|
const { remote, branch } = options;
|
|
34
|
-
const hasHashInTarget = options.target.
|
|
32
|
+
const hasHashInTarget = options.target.includes("{hash}");
|
|
35
33
|
const ifModifiedSince = options.ifModifiedSince;
|
|
36
34
|
if (ifModifiedSince || hasHashInTarget) {
|
|
37
35
|
const result = await execAsync(
|
|
@@ -13,19 +13,17 @@ require('@iconify/utils/lib/icon-set/minify');
|
|
|
13
13
|
require('@iconify/utils/lib/icon-set/convert-info');
|
|
14
14
|
require('../../icon-set/props.cjs');
|
|
15
15
|
require('@iconify/utils/lib/colors');
|
|
16
|
+
require('axios');
|
|
16
17
|
require('fs');
|
|
17
18
|
require('crypto');
|
|
18
19
|
require('pathe');
|
|
19
20
|
const misc_exec = require('../../misc/exec.cjs');
|
|
20
|
-
require('
|
|
21
|
+
require('fs/promises');
|
|
21
22
|
require('extract-zip');
|
|
22
23
|
require('tar');
|
|
23
24
|
require('../../svg/parse.cjs');
|
|
24
25
|
require('@iconify/utils/lib/misc/objects');
|
|
25
26
|
require('child_process');
|
|
26
|
-
require('util');
|
|
27
|
-
require('stream');
|
|
28
|
-
require('fs/promises');
|
|
29
27
|
|
|
30
28
|
async function resetGitRepoContents(target) {
|
|
31
29
|
await misc_exec.execAsync("git add -A", {
|
|
@@ -11,19 +11,17 @@ import '@iconify/utils/lib/icon-set/minify';
|
|
|
11
11
|
import '@iconify/utils/lib/icon-set/convert-info';
|
|
12
12
|
import '../../icon-set/props.mjs';
|
|
13
13
|
import '@iconify/utils/lib/colors';
|
|
14
|
+
import 'axios';
|
|
14
15
|
import 'fs';
|
|
15
16
|
import 'crypto';
|
|
16
17
|
import 'pathe';
|
|
17
18
|
import { execAsync } from '../../misc/exec.mjs';
|
|
18
|
-
import '
|
|
19
|
+
import 'fs/promises';
|
|
19
20
|
import 'extract-zip';
|
|
20
21
|
import 'tar';
|
|
21
22
|
import '../../svg/parse.mjs';
|
|
22
23
|
import '@iconify/utils/lib/misc/objects';
|
|
23
24
|
import 'child_process';
|
|
24
|
-
import 'util';
|
|
25
|
-
import 'stream';
|
|
26
|
-
import 'fs/promises';
|
|
27
25
|
|
|
28
26
|
async function resetGitRepoContents(target) {
|
|
29
27
|
await execAsync("git add -A", {
|