@iconify/tools 4.0.0-dev.1 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +15 -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 +14 -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 +3 -3
- package/lib/misc/write-json.d.cts +6 -0
- package/lib/misc/write-json.d.mts +6 -0
- package/lib/optimise/figma.cjs +55 -33
- package/lib/optimise/figma.d.cts +13 -0
- package/lib/optimise/figma.d.mts +13 -0
- package/lib/optimise/figma.d.ts +3 -1
- package/lib/optimise/figma.mjs +55 -33
- 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/optimise/unwrap.cjs +31 -0
- package/lib/optimise/unwrap.d.cts +11 -0
- package/lib/optimise/unwrap.d.mts +11 -0
- package/lib/optimise/unwrap.d.ts +11 -0
- package/lib/optimise/unwrap.mjs +29 -0
- 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 +34 -24
package/lib/colors/validate.cjs
CHANGED
|
@@ -17,7 +17,8 @@ require('../svg/data/attributes.cjs');
|
|
|
17
17
|
require('../svg/analyse.cjs');
|
|
18
18
|
require('../svg/analyse/error.cjs');
|
|
19
19
|
|
|
20
|
-
function
|
|
20
|
+
function validateColors(svg, expectMonotone, options) {
|
|
21
|
+
const palette = colors_parse.parseColors(svg, options);
|
|
21
22
|
palette.colors.forEach((color) => {
|
|
22
23
|
if (typeof color === "string") {
|
|
23
24
|
throw new Error("Unexpected color: " + color);
|
|
@@ -49,17 +50,7 @@ function checkPalette(palette, expectMonotone) {
|
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
});
|
|
52
|
-
}
|
|
53
|
-
async function validateColors(svg, expectMonotone, options) {
|
|
54
|
-
const palette = await colors_parse.parseColors(svg, options);
|
|
55
|
-
checkPalette(palette, expectMonotone);
|
|
56
|
-
return palette;
|
|
57
|
-
}
|
|
58
|
-
function validateColorsSync(svg, expectMonotone, options) {
|
|
59
|
-
const palette = colors_parse.parseColorsSync(svg, options);
|
|
60
|
-
checkPalette(palette, expectMonotone);
|
|
61
53
|
return palette;
|
|
62
54
|
}
|
|
63
55
|
|
|
64
56
|
exports.validateColors = validateColors;
|
|
65
|
-
exports.validateColorsSync = validateColorsSync;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SVG } from '../svg/index.cjs';
|
|
2
|
+
import { ParseColorsOptions, FindColorsResult } from './parse.cjs';
|
|
3
|
+
import 'cheerio';
|
|
4
|
+
import '@iconify/types';
|
|
5
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
6
|
+
import '@iconify/utils/lib/colors/types';
|
|
7
|
+
import './attribs.cjs';
|
|
8
|
+
import '../svg/analyse/types.cjs';
|
|
9
|
+
import '../misc/cheerio.cjs';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Validate colors in icon
|
|
13
|
+
*
|
|
14
|
+
* If icon is monotone,
|
|
15
|
+
*
|
|
16
|
+
* Throws exception on error
|
|
17
|
+
*/
|
|
18
|
+
declare function validateColors(svg: SVG, expectMonotone: boolean, options?: ParseColorsOptions): FindColorsResult;
|
|
19
|
+
|
|
20
|
+
export { validateColors };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SVG } from '../svg/index.mjs';
|
|
2
|
+
import { ParseColorsOptions, FindColorsResult } from './parse.mjs';
|
|
3
|
+
import 'cheerio';
|
|
4
|
+
import '@iconify/types';
|
|
5
|
+
import '@iconify/utils/lib/customisations/defaults';
|
|
6
|
+
import '@iconify/utils/lib/colors/types';
|
|
7
|
+
import './attribs.mjs';
|
|
8
|
+
import '../svg/analyse/types.mjs';
|
|
9
|
+
import '../misc/cheerio.mjs';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Validate colors in icon
|
|
13
|
+
*
|
|
14
|
+
* If icon is monotone,
|
|
15
|
+
*
|
|
16
|
+
* Throws exception on error
|
|
17
|
+
*/
|
|
18
|
+
declare function validateColors(svg: SVG, expectMonotone: boolean, options?: ParseColorsOptions): FindColorsResult;
|
|
19
|
+
|
|
20
|
+
export { validateColors };
|
package/lib/colors/validate.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { SVG } from '../svg/index.js';
|
|
2
|
-
import { ParseColorsOptions, FindColorsResult
|
|
2
|
+
import { ParseColorsOptions, FindColorsResult } from './parse.js';
|
|
3
3
|
import 'cheerio';
|
|
4
4
|
import '@iconify/types';
|
|
5
5
|
import '@iconify/utils/lib/customisations/defaults';
|
|
6
6
|
import '@iconify/utils/lib/colors/types';
|
|
7
7
|
import './attribs.js';
|
|
8
8
|
import '../svg/analyse/types.js';
|
|
9
|
+
import '../misc/cheerio.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Validate colors in icon
|
|
@@ -14,14 +15,6 @@ import '../svg/analyse/types.js';
|
|
|
14
15
|
*
|
|
15
16
|
* Throws exception on error
|
|
16
17
|
*/
|
|
17
|
-
declare function validateColors(svg: SVG, expectMonotone: boolean, options?: ParseColorsOptions):
|
|
18
|
-
/**
|
|
19
|
-
* Validate colors in icon, synchronous version
|
|
20
|
-
*
|
|
21
|
-
* If icon is monotone,
|
|
22
|
-
*
|
|
23
|
-
* Throws exception on error
|
|
24
|
-
*/
|
|
25
|
-
declare function validateColorsSync(svg: SVG, expectMonotone: boolean, options?: ParseColorsSyncOptions): FindColorsResult;
|
|
18
|
+
declare function validateColors(svg: SVG, expectMonotone: boolean, options?: ParseColorsOptions): FindColorsResult;
|
|
26
19
|
|
|
27
|
-
export { validateColors
|
|
20
|
+
export { validateColors };
|
package/lib/colors/validate.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { colorToString } from '@iconify/utils/lib/colors';
|
|
2
|
-
import { parseColors
|
|
2
|
+
import { parseColors } from './parse.mjs';
|
|
3
3
|
import '../svg/data/tags.mjs';
|
|
4
4
|
import '../svg/parse-style.mjs';
|
|
5
5
|
import '../css/parse.mjs';
|
|
@@ -15,7 +15,8 @@ import '../svg/data/attributes.mjs';
|
|
|
15
15
|
import '../svg/analyse.mjs';
|
|
16
16
|
import '../svg/analyse/error.mjs';
|
|
17
17
|
|
|
18
|
-
function
|
|
18
|
+
function validateColors(svg, expectMonotone, options) {
|
|
19
|
+
const palette = parseColors(svg, options);
|
|
19
20
|
palette.colors.forEach((color) => {
|
|
20
21
|
if (typeof color === "string") {
|
|
21
22
|
throw new Error("Unexpected color: " + color);
|
|
@@ -47,16 +48,7 @@ function checkPalette(palette, expectMonotone) {
|
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
});
|
|
50
|
-
}
|
|
51
|
-
async function validateColors(svg, expectMonotone, options) {
|
|
52
|
-
const palette = await parseColors(svg, options);
|
|
53
|
-
checkPalette(palette, expectMonotone);
|
|
54
|
-
return palette;
|
|
55
|
-
}
|
|
56
|
-
function validateColorsSync(svg, expectMonotone, options) {
|
|
57
|
-
const palette = parseColorsSync(svg, options);
|
|
58
|
-
checkPalette(palette, expectMonotone);
|
|
59
51
|
return palette;
|
|
60
52
|
}
|
|
61
53
|
|
|
62
|
-
export { validateColors
|
|
54
|
+
export { validateColors };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface StyleParseError {
|
|
2
|
+
type: 'style-parse-error';
|
|
3
|
+
message: string;
|
|
4
|
+
code: string;
|
|
5
|
+
index?: number;
|
|
6
|
+
fullMessage: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Create error message
|
|
10
|
+
*/
|
|
11
|
+
declare function styleParseError(message: string, code: string, index?: number): StyleParseError;
|
|
12
|
+
|
|
13
|
+
export { type StyleParseError, styleParseError };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface StyleParseError {
|
|
2
|
+
type: 'style-parse-error';
|
|
3
|
+
message: string;
|
|
4
|
+
code: string;
|
|
5
|
+
index?: number;
|
|
6
|
+
fullMessage: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Create error message
|
|
10
|
+
*/
|
|
11
|
+
declare function styleParseError(message: string, code: string, index?: number): StyleParseError;
|
|
12
|
+
|
|
13
|
+
export { type StyleParseError, styleParseError };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StyleParseError } from './error.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Find end of quoted string
|
|
5
|
+
*
|
|
6
|
+
* Returns index of character after quote
|
|
7
|
+
*/
|
|
8
|
+
declare function findEndOfQuotedString(code: string, quote: string, start: number): number | null;
|
|
9
|
+
/**
|
|
10
|
+
* Find end of url
|
|
11
|
+
*
|
|
12
|
+
* Returns index of character after end of URL
|
|
13
|
+
*/
|
|
14
|
+
declare function findEndOfURL(code: string, start: number): number | StyleParseError;
|
|
15
|
+
|
|
16
|
+
export { findEndOfQuotedString, findEndOfURL };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StyleParseError } from './error.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Find end of quoted string
|
|
5
|
+
*
|
|
6
|
+
* Returns index of character after quote
|
|
7
|
+
*/
|
|
8
|
+
declare function findEndOfQuotedString(code: string, quote: string, start: number): number | null;
|
|
9
|
+
/**
|
|
10
|
+
* Find end of url
|
|
11
|
+
*
|
|
12
|
+
* Returns index of character after end of URL
|
|
13
|
+
*/
|
|
14
|
+
declare function findEndOfURL(code: string, start: number): number | StyleParseError;
|
|
15
|
+
|
|
16
|
+
export { findEndOfQuotedString, findEndOfURL };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TextToken, CSSRuleToken, CSSTokenWithSelector } from './types.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Merge text tokens to string
|
|
5
|
+
*/
|
|
6
|
+
declare function mergeTextTokens(tokens: TextToken[]): string;
|
|
7
|
+
/**
|
|
8
|
+
* Get list of selectors from list of words
|
|
9
|
+
*/
|
|
10
|
+
declare function getSelectors(tokens: TextToken[]): string[];
|
|
11
|
+
/**
|
|
12
|
+
* Convert text token to rule
|
|
13
|
+
*/
|
|
14
|
+
declare function textTokensToRule(tokens: TextToken[]): CSSRuleToken | null;
|
|
15
|
+
/**
|
|
16
|
+
* Create at-rule or selector token from text tokens
|
|
17
|
+
*/
|
|
18
|
+
declare function textTokensToSelector(tokens: TextToken[]): CSSTokenWithSelector | null;
|
|
19
|
+
|
|
20
|
+
export { getSelectors, mergeTextTokens, textTokensToRule, textTokensToSelector };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TextToken, CSSRuleToken, CSSTokenWithSelector } from './types.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Merge text tokens to string
|
|
5
|
+
*/
|
|
6
|
+
declare function mergeTextTokens(tokens: TextToken[]): string;
|
|
7
|
+
/**
|
|
8
|
+
* Get list of selectors from list of words
|
|
9
|
+
*/
|
|
10
|
+
declare function getSelectors(tokens: TextToken[]): string[];
|
|
11
|
+
/**
|
|
12
|
+
* Convert text token to rule
|
|
13
|
+
*/
|
|
14
|
+
declare function textTokensToRule(tokens: TextToken[]): CSSRuleToken | null;
|
|
15
|
+
/**
|
|
16
|
+
* Create at-rule or selector token from text tokens
|
|
17
|
+
*/
|
|
18
|
+
declare function textTokensToSelector(tokens: TextToken[]): CSSTokenWithSelector | null;
|
|
19
|
+
|
|
20
|
+
export { getSelectors, mergeTextTokens, textTokensToRule, textTokensToSelector };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text tokens, to be split combined into correct tokens later
|
|
3
|
+
*/
|
|
4
|
+
interface TextToken {
|
|
5
|
+
type: 'chunk' | 'url' | 'quoted-string';
|
|
6
|
+
index: number;
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Values
|
|
11
|
+
*/
|
|
12
|
+
type CSSATValue = string | string[];
|
|
13
|
+
/**
|
|
14
|
+
* Tokens
|
|
15
|
+
*/
|
|
16
|
+
interface CSSRuleToken {
|
|
17
|
+
type: 'rule';
|
|
18
|
+
index: number;
|
|
19
|
+
prop: string;
|
|
20
|
+
value: string;
|
|
21
|
+
important?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface CSSSelectorToken {
|
|
24
|
+
type: 'selector';
|
|
25
|
+
index: number;
|
|
26
|
+
code: string;
|
|
27
|
+
selectors: string[];
|
|
28
|
+
}
|
|
29
|
+
interface CSSAtRuleToken {
|
|
30
|
+
type: 'at-rule';
|
|
31
|
+
index: number;
|
|
32
|
+
rule: string;
|
|
33
|
+
value: string;
|
|
34
|
+
}
|
|
35
|
+
interface CSSCloseToken {
|
|
36
|
+
type: 'close';
|
|
37
|
+
index: number;
|
|
38
|
+
}
|
|
39
|
+
type CSSTokenWithSelector = CSSSelectorToken | CSSAtRuleToken;
|
|
40
|
+
type CSSToken = CSSRuleToken | CSSSelectorToken | CSSAtRuleToken | CSSCloseToken;
|
|
41
|
+
/**
|
|
42
|
+
* Tree tokens
|
|
43
|
+
*/
|
|
44
|
+
interface CSSSelectorTreeToken extends CSSSelectorToken {
|
|
45
|
+
children: CSSTreeToken[];
|
|
46
|
+
}
|
|
47
|
+
interface CSSAtRuleTreeToken extends CSSAtRuleToken {
|
|
48
|
+
children: CSSTreeToken[];
|
|
49
|
+
}
|
|
50
|
+
type CSSTreeToken = CSSRuleToken | CSSSelectorTreeToken | CSSAtRuleTreeToken;
|
|
51
|
+
|
|
52
|
+
export type { CSSATValue, CSSAtRuleToken, CSSAtRuleTreeToken, CSSCloseToken, CSSRuleToken, CSSSelectorToken, CSSSelectorTreeToken, CSSToken, CSSTokenWithSelector, CSSTreeToken, TextToken };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text tokens, to be split combined into correct tokens later
|
|
3
|
+
*/
|
|
4
|
+
interface TextToken {
|
|
5
|
+
type: 'chunk' | 'url' | 'quoted-string';
|
|
6
|
+
index: number;
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Values
|
|
11
|
+
*/
|
|
12
|
+
type CSSATValue = string | string[];
|
|
13
|
+
/**
|
|
14
|
+
* Tokens
|
|
15
|
+
*/
|
|
16
|
+
interface CSSRuleToken {
|
|
17
|
+
type: 'rule';
|
|
18
|
+
index: number;
|
|
19
|
+
prop: string;
|
|
20
|
+
value: string;
|
|
21
|
+
important?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface CSSSelectorToken {
|
|
24
|
+
type: 'selector';
|
|
25
|
+
index: number;
|
|
26
|
+
code: string;
|
|
27
|
+
selectors: string[];
|
|
28
|
+
}
|
|
29
|
+
interface CSSAtRuleToken {
|
|
30
|
+
type: 'at-rule';
|
|
31
|
+
index: number;
|
|
32
|
+
rule: string;
|
|
33
|
+
value: string;
|
|
34
|
+
}
|
|
35
|
+
interface CSSCloseToken {
|
|
36
|
+
type: 'close';
|
|
37
|
+
index: number;
|
|
38
|
+
}
|
|
39
|
+
type CSSTokenWithSelector = CSSSelectorToken | CSSAtRuleToken;
|
|
40
|
+
type CSSToken = CSSRuleToken | CSSSelectorToken | CSSAtRuleToken | CSSCloseToken;
|
|
41
|
+
/**
|
|
42
|
+
* Tree tokens
|
|
43
|
+
*/
|
|
44
|
+
interface CSSSelectorTreeToken extends CSSSelectorToken {
|
|
45
|
+
children: CSSTreeToken[];
|
|
46
|
+
}
|
|
47
|
+
interface CSSAtRuleTreeToken extends CSSAtRuleToken {
|
|
48
|
+
children: CSSTreeToken[];
|
|
49
|
+
}
|
|
50
|
+
type CSSTreeToken = CSSRuleToken | CSSSelectorTreeToken | CSSAtRuleTreeToken;
|
|
51
|
+
|
|
52
|
+
export type { CSSATValue, CSSAtRuleToken, CSSAtRuleTreeToken, CSSCloseToken, CSSRuleToken, CSSSelectorToken, CSSSelectorTreeToken, CSSToken, CSSTokenWithSelector, CSSTreeToken, TextToken };
|
|
@@ -49,4 +49,4 @@ interface CSSAtRuleTreeToken extends CSSAtRuleToken {
|
|
|
49
49
|
}
|
|
50
50
|
type CSSTreeToken = CSSRuleToken | CSSSelectorTreeToken | CSSAtRuleTreeToken;
|
|
51
51
|
|
|
52
|
-
export { CSSATValue, CSSAtRuleToken, CSSAtRuleTreeToken, CSSCloseToken, CSSRuleToken, CSSSelectorToken, CSSSelectorTreeToken, CSSToken, CSSTokenWithSelector, CSSTreeToken, TextToken };
|
|
52
|
+
export type { CSSATValue, CSSAtRuleToken, CSSAtRuleTreeToken, CSSCloseToken, CSSRuleToken, CSSSelectorToken, CSSSelectorTreeToken, CSSToken, CSSTokenWithSelector, CSSTreeToken, TextToken };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { APIQueryParams, APICacheOptions } from './types.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unique key
|
|
5
|
+
*/
|
|
6
|
+
declare function apiCacheKey(query: APIQueryParams): string;
|
|
7
|
+
/**
|
|
8
|
+
* Store cache
|
|
9
|
+
*/
|
|
10
|
+
declare function storeAPICache(options: APICacheOptions, key: string, data: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Get item from cache
|
|
13
|
+
*/
|
|
14
|
+
declare function getAPICache(dir: string, key: string): Promise<string | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Clear cache
|
|
17
|
+
*/
|
|
18
|
+
declare function clearAPICache(dir: string): Promise<void>;
|
|
19
|
+
|
|
20
|
+
export { apiCacheKey, clearAPICache, getAPICache, storeAPICache };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { APIQueryParams, APICacheOptions } from './types.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unique key
|
|
5
|
+
*/
|
|
6
|
+
declare function apiCacheKey(query: APIQueryParams): string;
|
|
7
|
+
/**
|
|
8
|
+
* Store cache
|
|
9
|
+
*/
|
|
10
|
+
declare function storeAPICache(options: APICacheOptions, key: string, data: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Get item from cache
|
|
13
|
+
*/
|
|
14
|
+
declare function getAPICache(dir: string, key: string): Promise<string | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Clear cache
|
|
17
|
+
*/
|
|
18
|
+
declare function clearAPICache(dir: string): Promise<void>;
|
|
19
|
+
|
|
20
|
+
export { apiCacheKey, clearAPICache, getAPICache, storeAPICache };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { APIQueryParams } from './types.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Axios config, customisable
|
|
6
|
+
*/
|
|
7
|
+
declare const axiosConfig: Omit<AxiosRequestConfig, 'headers' | 'responseType' | 'url' | 'method' | 'data'>;
|
|
8
|
+
interface AxiosCallbacks {
|
|
9
|
+
onStart?: (url: string, params: APIQueryParams) => void;
|
|
10
|
+
onSuccess?: (url: string, params: APIQueryParams) => void;
|
|
11
|
+
onError?: (url: string, params: APIQueryParams, errorCode?: number) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Customisable callbacks, used for logging
|
|
15
|
+
*/
|
|
16
|
+
declare const fetchCallbacks: AxiosCallbacks;
|
|
17
|
+
|
|
18
|
+
export { axiosConfig, fetchCallbacks };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { APIQueryParams } from './types.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Axios config, customisable
|
|
6
|
+
*/
|
|
7
|
+
declare const axiosConfig: Omit<AxiosRequestConfig, 'headers' | 'responseType' | 'url' | 'method' | 'data'>;
|
|
8
|
+
interface AxiosCallbacks {
|
|
9
|
+
onStart?: (url: string, params: APIQueryParams) => void;
|
|
10
|
+
onSuccess?: (url: string, params: APIQueryParams) => void;
|
|
11
|
+
onError?: (url: string, params: APIQueryParams, errorCode?: number) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Customisable callbacks, used for logging
|
|
15
|
+
*/
|
|
16
|
+
declare const fetchCallbacks: AxiosCallbacks;
|
|
17
|
+
|
|
18
|
+
export { axiosConfig, fetchCallbacks };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { APIQueryParams } from './types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Axios config, customisable
|
|
6
|
+
*/
|
|
7
|
+
declare const axiosConfig: Omit<AxiosRequestConfig, 'headers' | 'responseType' | 'url' | 'method' | 'data'>;
|
|
8
|
+
interface AxiosCallbacks {
|
|
9
|
+
onStart?: (url: string, params: APIQueryParams) => void;
|
|
10
|
+
onSuccess?: (url: string, params: APIQueryParams) => void;
|
|
11
|
+
onError?: (url: string, params: APIQueryParams, errorCode?: number) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Customisable callbacks, used for logging
|
|
15
|
+
*/
|
|
16
|
+
declare const fetchCallbacks: AxiosCallbacks;
|
|
17
|
+
|
|
18
|
+
export { axiosConfig, fetchCallbacks };
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const stream = require('stream');
|
|
3
|
+
const axios = require('axios');
|
|
5
4
|
const promises = require('fs/promises');
|
|
5
|
+
const download_api_config = require('./config.cjs');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
8
|
+
|
|
9
|
+
const axios__default = /*#__PURE__*/_interopDefaultCompat(axios);
|
|
6
10
|
|
|
7
|
-
util.promisify(stream.pipeline);
|
|
8
11
|
async function downloadFile(query, target) {
|
|
9
12
|
const params = query.params ? query.params.toString() : "";
|
|
10
13
|
const url = query.uri + (params ? "?" + params : "");
|
|
11
14
|
const headers = query.headers;
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
download_api_config.fetchCallbacks.onStart?.(url, query);
|
|
16
|
+
const response = await axios__default.get(url, {
|
|
17
|
+
...download_api_config.axiosConfig,
|
|
18
|
+
headers,
|
|
19
|
+
responseType: "arraybuffer"
|
|
14
20
|
});
|
|
15
|
-
if (
|
|
21
|
+
if (response.status !== 200) {
|
|
22
|
+
download_api_config.fetchCallbacks.onError?.(url, query, response.status);
|
|
16
23
|
throw new Error(`Error downloading ${url}: ${response.status}`);
|
|
17
24
|
}
|
|
18
|
-
const data =
|
|
25
|
+
const data = response.data;
|
|
26
|
+
download_api_config.fetchCallbacks.onSuccess?.(url, query);
|
|
19
27
|
await promises.writeFile(target, Buffer.from(data));
|
|
20
28
|
}
|
|
21
29
|
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { pipeline } from 'stream';
|
|
1
|
+
import axios from 'axios';
|
|
3
2
|
import { writeFile } from 'fs/promises';
|
|
3
|
+
import { fetchCallbacks, axiosConfig } from './config.mjs';
|
|
4
4
|
|
|
5
|
-
promisify(pipeline);
|
|
6
5
|
async function downloadFile(query, target) {
|
|
7
6
|
const params = query.params ? query.params.toString() : "";
|
|
8
7
|
const url = query.uri + (params ? "?" + params : "");
|
|
9
8
|
const headers = query.headers;
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
fetchCallbacks.onStart?.(url, query);
|
|
10
|
+
const response = await axios.get(url, {
|
|
11
|
+
...axiosConfig,
|
|
12
|
+
headers,
|
|
13
|
+
responseType: "arraybuffer"
|
|
12
14
|
});
|
|
13
|
-
if (
|
|
15
|
+
if (response.status !== 200) {
|
|
16
|
+
fetchCallbacks.onError?.(url, query, response.status);
|
|
14
17
|
throw new Error(`Error downloading ${url}: ${response.status}`);
|
|
15
18
|
}
|
|
16
|
-
const data =
|
|
19
|
+
const data = response.data;
|
|
20
|
+
fetchCallbacks.onSuccess?.(url, query);
|
|
17
21
|
await writeFile(target, Buffer.from(data));
|
|
18
22
|
}
|
|
19
23
|
|