@iconify/tools 2.0.7 → 2.0.11
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/parse.d.ts +10 -1
- package/lib/colors/parse.js +10 -3
- package/lib/colors/parse.mjs +7 -3
- package/lib/colors/validate.js +5 -2
- package/lib/colors/validate.mjs +3 -1
- package/lib/download/github/index.d.ts +1 -1
- package/lib/download/gitlab/hash.d.ts +5 -0
- package/lib/download/gitlab/hash.js +27 -0
- package/lib/download/gitlab/hash.mjs +24 -0
- package/lib/download/gitlab/index.d.ts +29 -0
- package/lib/download/gitlab/index.js +115 -0
- package/lib/download/gitlab/index.mjs +88 -0
- package/lib/download/gitlab/types.d.ts +13 -0
- package/lib/download/gitlab/types.js +7 -0
- package/lib/download/gitlab/types.mjs +5 -0
- package/lib/download/index.d.ts +33 -10
- package/lib/download/index.js +7 -6
- package/lib/download/index.mjs +9 -6
- package/lib/download/types/sources.d.ts +1 -1
- package/lib/icon-set/index.js +4 -21
- package/lib/icon-set/index.mjs +6 -21
- package/lib/icon-set/merge.js +0 -1
- package/lib/icon-set/merge.mjs +1 -2
- package/lib/icon-set/types.d.ts +3 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +11 -7
- package/lib/index.mjs +4 -0
- package/lib/optimise/flags.js +9 -0
- package/lib/optimise/flags.mjs +8 -0
- package/lib/optimise/svgo.js +1 -1
- package/lib/optimise/svgo.mjs +0 -1
- package/lib/svg/cleanup/root-svg.js +1 -1
- package/lib/svg/cleanup/root-svg.mjs +1 -1
- package/package.json +18 -2
package/lib/colors/parse.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Color } from '@iconify/utils/lib/colors/types';
|
|
2
2
|
import type { SVG } from '../svg';
|
|
3
|
+
import { ParseSVGCallbackItem } from '../svg/parse';
|
|
3
4
|
import { ColorAttributes } from './attribs';
|
|
4
5
|
/**
|
|
5
6
|
* Result
|
|
@@ -23,9 +24,17 @@ declare type ParseColorsCallback = (attr: ColorAttributes, colorString: string,
|
|
|
23
24
|
/**
|
|
24
25
|
* Options
|
|
25
26
|
*/
|
|
27
|
+
export declare type ParseColorOptionsDefaultColorCallback = (prop: string, item: ExtendedParseSVGCallbackItem) => Color;
|
|
26
28
|
export interface ParseColorsOptions {
|
|
27
29
|
callback?: ParseColorsCallback;
|
|
28
|
-
defaultColor?: Color | string;
|
|
30
|
+
defaultColor?: Color | string | ParseColorOptionsDefaultColorCallback;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Extend properties for item
|
|
34
|
+
*/
|
|
35
|
+
declare type ItemColors = Partial<Record<ColorAttributes, Color | string>>;
|
|
36
|
+
export interface ExtendedParseSVGCallbackItem extends ParseSVGCallbackItem {
|
|
37
|
+
colors?: ItemColors;
|
|
29
38
|
}
|
|
30
39
|
/**
|
|
31
40
|
* Find colors in icon
|
package/lib/colors/parse.js
CHANGED
|
@@ -95,6 +95,10 @@ async function parseColors(svg, options = {}) {
|
|
|
95
95
|
// Resolve color
|
|
96
96
|
const parsedColor = (0, colors_1.stringToColor)(value);
|
|
97
97
|
const defaultValue = parsedColor || value;
|
|
98
|
+
// Ignore url()
|
|
99
|
+
if ((parsedColor === null || parsedColor === void 0 ? void 0 : parsedColor.type) === 'function' && parsedColor.func === 'url') {
|
|
100
|
+
return value;
|
|
101
|
+
}
|
|
98
102
|
// Check if callback exists
|
|
99
103
|
if (!options.callback) {
|
|
100
104
|
addColorToItem(prop, defaultValue, item);
|
|
@@ -246,10 +250,13 @@ async function parseColors(svg, options = {}) {
|
|
|
246
250
|
if (color === attribs_1.defaultBlackColor) {
|
|
247
251
|
// Default black color: change it
|
|
248
252
|
if (defaultColor) {
|
|
253
|
+
const defaultColorValue = typeof defaultColor === 'function'
|
|
254
|
+
? defaultColor(prop, item)
|
|
255
|
+
: defaultColor;
|
|
249
256
|
// Add color to results and change attribute
|
|
250
|
-
findColor(
|
|
251
|
-
$element.attr(prop, (0, colors_1.colorToString)(
|
|
252
|
-
itemColors[prop] =
|
|
257
|
+
findColor(defaultColorValue, true);
|
|
258
|
+
$element.attr(prop, (0, colors_1.colorToString)(defaultColorValue));
|
|
259
|
+
itemColors[prop] = defaultColorValue;
|
|
253
260
|
}
|
|
254
261
|
else {
|
|
255
262
|
result.hasUnsetColor = true;
|
package/lib/colors/parse.mjs
CHANGED
|
@@ -77,6 +77,9 @@ async function parseColors(svg, options = {}) {
|
|
|
77
77
|
}
|
|
78
78
|
const parsedColor = stringToColor(value);
|
|
79
79
|
const defaultValue = parsedColor || value;
|
|
80
|
+
if ((parsedColor == null ? void 0 : parsedColor.type) === "function" && parsedColor.func === "url") {
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
80
83
|
if (!options.callback) {
|
|
81
84
|
addColorToItem(prop, defaultValue, item);
|
|
82
85
|
return value;
|
|
@@ -198,9 +201,10 @@ async function parseColors(svg, options = {}) {
|
|
|
198
201
|
const color = getElementColor(prop, item);
|
|
199
202
|
if (color === defaultBlackColor) {
|
|
200
203
|
if (defaultColor) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
+
const defaultColorValue = typeof defaultColor === "function" ? defaultColor(prop, item) : defaultColor;
|
|
205
|
+
findColor(defaultColorValue, true);
|
|
206
|
+
$element.attr(prop, colorToString(defaultColorValue));
|
|
207
|
+
itemColors[prop] = defaultColorValue;
|
|
204
208
|
} else {
|
|
205
209
|
result.hasUnsetColor = true;
|
|
206
210
|
}
|
package/lib/colors/validate.js
CHANGED
|
@@ -35,9 +35,12 @@ async function validateColors(svg, expectMonotone, options) {
|
|
|
35
35
|
throw new Error('Unexpected color: ' + (0, colors_1.colorToString)(color));
|
|
36
36
|
}
|
|
37
37
|
return;
|
|
38
|
-
// Do not allow other colors
|
|
39
38
|
default:
|
|
40
|
-
|
|
39
|
+
// Allow url()
|
|
40
|
+
if (color.type !== 'function' || color.func !== 'url') {
|
|
41
|
+
// Do not allow other colors
|
|
42
|
+
throw new Error('Unexpected color: ' + (0, colors_1.colorToString)(color));
|
|
43
|
+
}
|
|
41
44
|
}
|
|
42
45
|
});
|
|
43
46
|
return palette;
|
package/lib/colors/validate.mjs
CHANGED
|
@@ -23,7 +23,9 @@ async function validateColors(svg, expectMonotone, options) {
|
|
|
23
23
|
}
|
|
24
24
|
return;
|
|
25
25
|
default:
|
|
26
|
-
|
|
26
|
+
if (color.type !== "function" || color.func !== "url") {
|
|
27
|
+
throw new Error("Unexpected color: " + colorToString(color));
|
|
28
|
+
}
|
|
27
29
|
}
|
|
28
30
|
});
|
|
29
31
|
return palette;
|
|
@@ -6,7 +6,7 @@ interface IfModifiedSinceOption {
|
|
|
6
6
|
ifModifiedSince: string | DownloadGitHubRepoResult;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* Options for
|
|
9
|
+
* Options for downloadGitHubRepo()
|
|
10
10
|
*/
|
|
11
11
|
export interface DownloadGitHubRepoOptions extends ExportTargetOptions, GitHubAPIOptions, Partial<IfModifiedSinceOption> {
|
|
12
12
|
cleanupOldFiles?: boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGitLabRepoHash = void 0;
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
/**
|
|
7
|
+
* Get latest hash from GitHub using API
|
|
8
|
+
*/
|
|
9
|
+
async function getGitLabRepoHash(options) {
|
|
10
|
+
const uri = `${options.uri || types_1.defaultGitLabBaseURI}/${options.project}/repository/branches/${options.branch}/`;
|
|
11
|
+
const data = await (0, api_1.sendAPIQuery)({
|
|
12
|
+
uri,
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: 'token ' + options.token,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
if (typeof data !== 'string') {
|
|
18
|
+
throw new Error(`Error downloading data from GitLab API: ${data}`);
|
|
19
|
+
}
|
|
20
|
+
const content = JSON.parse(data);
|
|
21
|
+
const item = (content instanceof Array ? content : [content]).find((item) => item.name === options.branch && typeof item.commit.id === 'string');
|
|
22
|
+
if (!item) {
|
|
23
|
+
throw new Error('Error parsing GitLab API response');
|
|
24
|
+
}
|
|
25
|
+
return item.commit.id;
|
|
26
|
+
}
|
|
27
|
+
exports.getGitLabRepoHash = getGitLabRepoHash;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/download/gitlab/hash.ts
|
|
2
|
+
import { sendAPIQuery } from "../api/index.mjs";
|
|
3
|
+
import { defaultGitLabBaseURI } from "./types.mjs";
|
|
4
|
+
async function getGitLabRepoHash(options) {
|
|
5
|
+
const uri = `${options.uri || defaultGitLabBaseURI}/${options.project}/repository/branches/${options.branch}/`;
|
|
6
|
+
const data = await sendAPIQuery({
|
|
7
|
+
uri,
|
|
8
|
+
headers: {
|
|
9
|
+
Authorization: "token " + options.token
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
if (typeof data !== "string") {
|
|
13
|
+
throw new Error(`Error downloading data from GitLab API: ${data}`);
|
|
14
|
+
}
|
|
15
|
+
const content = JSON.parse(data);
|
|
16
|
+
const item = (content instanceof Array ? content : [content]).find((item2) => item2.name === options.branch && typeof item2.commit.id === "string");
|
|
17
|
+
if (!item) {
|
|
18
|
+
throw new Error("Error parsing GitLab API response");
|
|
19
|
+
}
|
|
20
|
+
return item.commit.id;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
getGitLabRepoHash
|
|
24
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ExportTargetOptions } from '../../export/helpers/prepare';
|
|
2
|
+
import type { DocumentNotModified } from '../types/modified';
|
|
3
|
+
import { GitLabAPIOptions } from './types';
|
|
4
|
+
import type { DownloadSourceMixin } from '../types/sources';
|
|
5
|
+
interface IfModifiedSinceOption {
|
|
6
|
+
ifModifiedSince: string | DownloadGitLabRepoResult;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Options for downloadGitLabRepo()
|
|
10
|
+
*/
|
|
11
|
+
export interface DownloadGitLabRepoOptions extends ExportTargetOptions, GitLabAPIOptions, Partial<IfModifiedSinceOption> {
|
|
12
|
+
cleanupOldFiles?: boolean;
|
|
13
|
+
cleanupOldDirectories?: boolean;
|
|
14
|
+
log?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Result
|
|
18
|
+
*/
|
|
19
|
+
export interface DownloadGitLabRepoResult extends DownloadSourceMixin<'gitlab'> {
|
|
20
|
+
rootDir: string;
|
|
21
|
+
contentsDir: string;
|
|
22
|
+
hash: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Download GitLab repo using API
|
|
26
|
+
*/
|
|
27
|
+
export declare function downloadGitLabRepo<T extends IfModifiedSinceOption & DownloadGitLabRepoOptions>(options: T): Promise<DownloadGitLabRepoResult | DocumentNotModified>;
|
|
28
|
+
export declare function downloadGitLabRepo(options: DownloadGitLabRepoOptions): Promise<DownloadGitLabRepoResult>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.downloadGitLabRepo = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const prepare_1 = require("../../export/helpers/prepare");
|
|
6
|
+
const hash_1 = require("./hash");
|
|
7
|
+
const types_1 = require("./types");
|
|
8
|
+
const download_1 = require("../api/download");
|
|
9
|
+
const unzip_1 = require("../helpers/unzip");
|
|
10
|
+
/**
|
|
11
|
+
* Find matching directories
|
|
12
|
+
*/
|
|
13
|
+
async function findMatchingDirs(rootDir, hash) {
|
|
14
|
+
const matches = [];
|
|
15
|
+
const files = await fs_1.promises.readdir(rootDir);
|
|
16
|
+
for (let i = 0; i < files.length; i++) {
|
|
17
|
+
const file = files[i];
|
|
18
|
+
const lastChunk = file.split('-').pop();
|
|
19
|
+
if (lastChunk.length < 4 ||
|
|
20
|
+
lastChunk !== hash.slice(0, lastChunk.length)) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const stat = await fs_1.promises.stat(rootDir + '/' + file);
|
|
24
|
+
if (stat.isDirectory()) {
|
|
25
|
+
matches.push(file);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return matches;
|
|
29
|
+
}
|
|
30
|
+
async function downloadGitLabRepo(options) {
|
|
31
|
+
// Check for last commit
|
|
32
|
+
const hash = await (0, hash_1.getGitLabRepoHash)(options);
|
|
33
|
+
const ifModifiedSince = options.ifModifiedSince;
|
|
34
|
+
if (ifModifiedSince) {
|
|
35
|
+
const expectedHash = typeof ifModifiedSince === 'string'
|
|
36
|
+
? ifModifiedSince
|
|
37
|
+
: ifModifiedSince.downloadType === 'gitlab'
|
|
38
|
+
? ifModifiedSince.hash
|
|
39
|
+
: null;
|
|
40
|
+
if (hash === expectedHash) {
|
|
41
|
+
return 'not_modified';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Replace hash in target
|
|
45
|
+
options.target = options.target.replace('{hash}', hash);
|
|
46
|
+
// Prepare target directory
|
|
47
|
+
const rootDir = (options.target = await (0, prepare_1.prepareDirectoryForExport)(options));
|
|
48
|
+
// Archive name
|
|
49
|
+
const archiveTarget = rootDir + '/' + hash + '.zip';
|
|
50
|
+
// Check if archive exists
|
|
51
|
+
let exists = false;
|
|
52
|
+
try {
|
|
53
|
+
const stat = await fs_1.promises.stat(archiveTarget);
|
|
54
|
+
exists = stat.isFile();
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
//
|
|
58
|
+
}
|
|
59
|
+
// Download file
|
|
60
|
+
if (!exists) {
|
|
61
|
+
const uri = `${options.uri || types_1.defaultGitLabBaseURI}/${options.project}/repository/archive.zip?sha=${hash}`;
|
|
62
|
+
await (0, download_1.downloadFile)({
|
|
63
|
+
uri,
|
|
64
|
+
headers: {
|
|
65
|
+
Authorization: 'token ' + options.token,
|
|
66
|
+
},
|
|
67
|
+
}, archiveTarget);
|
|
68
|
+
}
|
|
69
|
+
// Clean up old directories
|
|
70
|
+
const files = await fs_1.promises.readdir(rootDir);
|
|
71
|
+
const hashSearch = '-' + hash;
|
|
72
|
+
for (let i = 0; i < files.length; i++) {
|
|
73
|
+
const file = files[i];
|
|
74
|
+
if (file === hash + '.zip') {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const filename = rootDir + '/' + files[i];
|
|
78
|
+
const stat = await fs_1.promises.lstat(filename);
|
|
79
|
+
const isDir = stat.isDirectory();
|
|
80
|
+
if (
|
|
81
|
+
// Remove symbolic links
|
|
82
|
+
stat.isSymbolicLink() ||
|
|
83
|
+
// Remove if directory matches hash to avoid errors extracting zip
|
|
84
|
+
(isDir && filename.slice(0 - hashSearch.length) === hashSearch) ||
|
|
85
|
+
// Remove if directory and cleanupOldDirectories is not disabled
|
|
86
|
+
(isDir && options.cleanupOldDirectories !== false) ||
|
|
87
|
+
// Remove if file and cleanupOldFiles is enabled
|
|
88
|
+
(!isDir && options.cleanupOldFiles)) {
|
|
89
|
+
try {
|
|
90
|
+
await fs_1.promises.rm(filename, {
|
|
91
|
+
force: true,
|
|
92
|
+
recursive: true,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
//
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Unpack it
|
|
101
|
+
await (0, unzip_1.unzip)(archiveTarget, rootDir);
|
|
102
|
+
// Get actual dir
|
|
103
|
+
const matchingDirs = await findMatchingDirs(rootDir, hash);
|
|
104
|
+
if (matchingDirs.length !== 1) {
|
|
105
|
+
throw new Error(`Error unpacking ${hash}.zip`);
|
|
106
|
+
}
|
|
107
|
+
const contentsDir = rootDir + '/' + matchingDirs[0];
|
|
108
|
+
return {
|
|
109
|
+
downloadType: 'gitlab',
|
|
110
|
+
rootDir,
|
|
111
|
+
contentsDir,
|
|
112
|
+
hash,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
exports.downloadGitLabRepo = downloadGitLabRepo;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// src/download/gitlab/index.ts
|
|
2
|
+
import { promises as fs } from "fs";
|
|
3
|
+
import {
|
|
4
|
+
prepareDirectoryForExport
|
|
5
|
+
} from "../../export/helpers/prepare.mjs";
|
|
6
|
+
import { getGitLabRepoHash } from "./hash.mjs";
|
|
7
|
+
import { defaultGitLabBaseURI } from "./types.mjs";
|
|
8
|
+
import { downloadFile } from "../api/download.mjs";
|
|
9
|
+
import { unzip } from "../helpers/unzip.mjs";
|
|
10
|
+
async function findMatchingDirs(rootDir, hash) {
|
|
11
|
+
const matches = [];
|
|
12
|
+
const files = await fs.readdir(rootDir);
|
|
13
|
+
for (let i = 0; i < files.length; i++) {
|
|
14
|
+
const file = files[i];
|
|
15
|
+
const lastChunk = file.split("-").pop();
|
|
16
|
+
if (lastChunk.length < 4 || lastChunk !== hash.slice(0, lastChunk.length)) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const stat = await fs.stat(rootDir + "/" + file);
|
|
20
|
+
if (stat.isDirectory()) {
|
|
21
|
+
matches.push(file);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return matches;
|
|
25
|
+
}
|
|
26
|
+
async function downloadGitLabRepo(options) {
|
|
27
|
+
const hash = await getGitLabRepoHash(options);
|
|
28
|
+
const ifModifiedSince = options.ifModifiedSince;
|
|
29
|
+
if (ifModifiedSince) {
|
|
30
|
+
const expectedHash = typeof ifModifiedSince === "string" ? ifModifiedSince : ifModifiedSince.downloadType === "gitlab" ? ifModifiedSince.hash : null;
|
|
31
|
+
if (hash === expectedHash) {
|
|
32
|
+
return "not_modified";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
options.target = options.target.replace("{hash}", hash);
|
|
36
|
+
const rootDir = options.target = await prepareDirectoryForExport(options);
|
|
37
|
+
const archiveTarget = rootDir + "/" + hash + ".zip";
|
|
38
|
+
let exists = false;
|
|
39
|
+
try {
|
|
40
|
+
const stat = await fs.stat(archiveTarget);
|
|
41
|
+
exists = stat.isFile();
|
|
42
|
+
} catch (err) {
|
|
43
|
+
}
|
|
44
|
+
if (!exists) {
|
|
45
|
+
const uri = `${options.uri || defaultGitLabBaseURI}/${options.project}/repository/archive.zip?sha=${hash}`;
|
|
46
|
+
await downloadFile({
|
|
47
|
+
uri,
|
|
48
|
+
headers: {
|
|
49
|
+
Authorization: "token " + options.token
|
|
50
|
+
}
|
|
51
|
+
}, archiveTarget);
|
|
52
|
+
}
|
|
53
|
+
const files = await fs.readdir(rootDir);
|
|
54
|
+
const hashSearch = "-" + hash;
|
|
55
|
+
for (let i = 0; i < files.length; i++) {
|
|
56
|
+
const file = files[i];
|
|
57
|
+
if (file === hash + ".zip") {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const filename = rootDir + "/" + files[i];
|
|
61
|
+
const stat = await fs.lstat(filename);
|
|
62
|
+
const isDir = stat.isDirectory();
|
|
63
|
+
if (stat.isSymbolicLink() || isDir && filename.slice(0 - hashSearch.length) === hashSearch || isDir && options.cleanupOldDirectories !== false || !isDir && options.cleanupOldFiles) {
|
|
64
|
+
try {
|
|
65
|
+
await fs.rm(filename, {
|
|
66
|
+
force: true,
|
|
67
|
+
recursive: true
|
|
68
|
+
});
|
|
69
|
+
} catch (err) {
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
await unzip(archiveTarget, rootDir);
|
|
74
|
+
const matchingDirs = await findMatchingDirs(rootDir, hash);
|
|
75
|
+
if (matchingDirs.length !== 1) {
|
|
76
|
+
throw new Error(`Error unpacking ${hash}.zip`);
|
|
77
|
+
}
|
|
78
|
+
const contentsDir = rootDir + "/" + matchingDirs[0];
|
|
79
|
+
return {
|
|
80
|
+
downloadType: "gitlab",
|
|
81
|
+
rootDir,
|
|
82
|
+
contentsDir,
|
|
83
|
+
hash
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
downloadGitLabRepo
|
|
88
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API options
|
|
3
|
+
*/
|
|
4
|
+
export interface GitLabAPIOptions {
|
|
5
|
+
uri?: string;
|
|
6
|
+
token: string;
|
|
7
|
+
project: string;
|
|
8
|
+
branch: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Default base URI for GitLab API
|
|
12
|
+
*/
|
|
13
|
+
export declare const defaultGitLabBaseURI = "https://gitlab.com/api/v4/projects";
|
package/lib/download/index.d.ts
CHANGED
|
@@ -3,18 +3,41 @@ import { DownloadGitRepoOptions, DownloadGitRepoResult } from './git';
|
|
|
3
3
|
import { DownloadNPMPackageOptions, DownloadNPMPackageResult } from './npm';
|
|
4
4
|
import type { DocumentNotModified } from './types/modified';
|
|
5
5
|
import type { DownloadSourceMixin, DownloadSourceType } from './types/sources';
|
|
6
|
+
import { DownloadGitLabRepoOptions, DownloadGitLabRepoResult } from './gitlab';
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Options and result combinations
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
interface DownloadGitRepo {
|
|
11
|
+
options: DownloadGitRepoOptions & DownloadSourceMixin<'git'>;
|
|
12
|
+
result: DownloadGitRepoResult;
|
|
13
|
+
}
|
|
14
|
+
interface DownloadGitHubRepo {
|
|
15
|
+
options: DownloadGitHubRepoOptions & DownloadSourceMixin<'github'>;
|
|
16
|
+
result: DownloadGitHubRepoResult;
|
|
17
|
+
}
|
|
18
|
+
interface DownloadGitLabRepo {
|
|
19
|
+
options: DownloadGitLabRepoOptions & DownloadSourceMixin<'gitlab'>;
|
|
20
|
+
result: DownloadGitLabRepoResult;
|
|
21
|
+
}
|
|
22
|
+
interface DownloadNPMPackage {
|
|
23
|
+
options: DownloadNPMPackageOptions & DownloadSourceMixin<'npm'>;
|
|
24
|
+
result: DownloadNPMPackageResult;
|
|
25
|
+
}
|
|
13
26
|
/**
|
|
14
|
-
*
|
|
27
|
+
* Combinations based on type
|
|
15
28
|
*/
|
|
16
|
-
export declare type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
29
|
+
export declare type DownloadParamsMixin<T extends DownloadSourceType> = T extends 'git' ? DownloadGitRepo : T extends 'github' ? DownloadGitHubRepo : T extends 'gitlab' ? DownloadGitLabRepo : T extends 'npm' ? DownloadNPMPackage : never;
|
|
30
|
+
/**
|
|
31
|
+
* Combinations
|
|
32
|
+
*/
|
|
33
|
+
export declare type DownloadParams = DownloadGitRepo | DownloadGitHubRepo | DownloadGitLabRepo | DownloadNPMPackage;
|
|
34
|
+
/**
|
|
35
|
+
* Pick options or result from combinations
|
|
36
|
+
*/
|
|
37
|
+
declare type DownloadOptions<T extends DownloadSourceType> = DownloadParamsMixin<T>['options'];
|
|
38
|
+
declare type DownloadResult<T extends DownloadSourceType> = Promise<DocumentNotModified | DownloadParamsMixin<T>['result']>;
|
|
39
|
+
export declare function downloadPackage<T extends 'git'>(options: DownloadOptions<T>): DownloadResult<T>;
|
|
40
|
+
export declare function downloadPackage<T extends 'github'>(options: DownloadOptions<T>): DownloadResult<T>;
|
|
41
|
+
export declare function downloadPackage<T extends 'gitlab'>(options: DownloadOptions<T>): DownloadResult<T>;
|
|
42
|
+
export declare function downloadPackage<T extends 'npm'>(options: DownloadOptions<T>): DownloadResult<T>;
|
|
20
43
|
export {};
|
package/lib/download/index.js
CHANGED
|
@@ -4,23 +4,24 @@ exports.downloadPackage = void 0;
|
|
|
4
4
|
const github_1 = require("./github");
|
|
5
5
|
const git_1 = require("./git");
|
|
6
6
|
const npm_1 = require("./npm");
|
|
7
|
+
const gitlab_1 = require("./gitlab");
|
|
7
8
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
9
|
function assertNever(v) {
|
|
9
10
|
//
|
|
10
11
|
}
|
|
11
12
|
function downloadPackage(options) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
case 'git': {
|
|
13
|
+
switch (options.downloadType) {
|
|
14
|
+
case 'git':
|
|
15
15
|
return (0, git_1.downloadGitRepo)(options);
|
|
16
|
-
}
|
|
17
16
|
case 'github':
|
|
18
17
|
return (0, github_1.downloadGitHubRepo)(options);
|
|
18
|
+
case 'gitlab':
|
|
19
|
+
return (0, gitlab_1.downloadGitLabRepo)(options);
|
|
19
20
|
case 'npm':
|
|
20
21
|
return (0, npm_1.downloadNPMPackage)(options);
|
|
21
22
|
default:
|
|
22
|
-
assertNever(
|
|
23
|
-
throw new Error(`Invalid download type: ${
|
|
23
|
+
assertNever(options);
|
|
24
|
+
throw new Error(`Invalid download type: ${options.downloadType}`);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
exports.downloadPackage = downloadPackage;
|
package/lib/download/index.mjs
CHANGED
|
@@ -8,21 +8,24 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
downloadNPMPackage
|
|
10
10
|
} from "./npm/index.mjs";
|
|
11
|
+
import {
|
|
12
|
+
downloadGitLabRepo
|
|
13
|
+
} from "./gitlab/index.mjs";
|
|
11
14
|
function assertNever(v) {
|
|
12
15
|
}
|
|
13
16
|
function downloadPackage(options) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
case "git": {
|
|
17
|
+
switch (options.downloadType) {
|
|
18
|
+
case "git":
|
|
17
19
|
return downloadGitRepo(options);
|
|
18
|
-
}
|
|
19
20
|
case "github":
|
|
20
21
|
return downloadGitHubRepo(options);
|
|
22
|
+
case "gitlab":
|
|
23
|
+
return downloadGitLabRepo(options);
|
|
21
24
|
case "npm":
|
|
22
25
|
return downloadNPMPackage(options);
|
|
23
26
|
default:
|
|
24
|
-
assertNever(
|
|
25
|
-
throw new Error(`Invalid download type: ${
|
|
27
|
+
assertNever(options);
|
|
28
|
+
throw new Error(`Invalid download type: ${options.downloadType}`);
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
export {
|
package/lib/icon-set/index.js
CHANGED
|
@@ -71,7 +71,6 @@ class IconSet {
|
|
|
71
71
|
parent,
|
|
72
72
|
props,
|
|
73
73
|
chars,
|
|
74
|
-
categories: new Set(),
|
|
75
74
|
};
|
|
76
75
|
entries[name] = entry;
|
|
77
76
|
}
|
|
@@ -111,7 +110,6 @@ class IconSet {
|
|
|
111
110
|
const icon = entries[iconName];
|
|
112
111
|
switch (icon === null || icon === void 0 ? void 0 : icon.type) {
|
|
113
112
|
case 'icon':
|
|
114
|
-
case 'variation':
|
|
115
113
|
icon.categories.add(item);
|
|
116
114
|
}
|
|
117
115
|
});
|
|
@@ -342,6 +340,7 @@ class IconSet {
|
|
|
342
340
|
.forEach((item) => {
|
|
343
341
|
const names = this.listCategory(item);
|
|
344
342
|
if (names) {
|
|
343
|
+
names.sort((a, b) => a.localeCompare(b));
|
|
345
344
|
categories[item.title] = names;
|
|
346
345
|
}
|
|
347
346
|
});
|
|
@@ -460,8 +459,8 @@ class IconSet {
|
|
|
460
459
|
return null;
|
|
461
460
|
}
|
|
462
461
|
// Find icons
|
|
463
|
-
const icons = this._filter((_key, item
|
|
464
|
-
if (item.type
|
|
462
|
+
const icons = this._filter((_key, item) => {
|
|
463
|
+
if (item.type !== 'icon' || item.props.hidden) {
|
|
465
464
|
return false;
|
|
466
465
|
}
|
|
467
466
|
return item.categories.has(categoryItem);
|
|
@@ -619,26 +618,11 @@ class IconSet {
|
|
|
619
618
|
* Add/update alias with props
|
|
620
619
|
*/
|
|
621
620
|
setVariation(name, parent, props) {
|
|
622
|
-
// Copy categories
|
|
623
|
-
let categories;
|
|
624
|
-
while (!categories) {
|
|
625
|
-
const parentItem = this.entries[parent];
|
|
626
|
-
if (!parentItem) {
|
|
627
|
-
return false;
|
|
628
|
-
}
|
|
629
|
-
if (parentItem.type === 'alias') {
|
|
630
|
-
parent = parentItem.parent;
|
|
631
|
-
}
|
|
632
|
-
else {
|
|
633
|
-
categories = new Set(parentItem.categories);
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
621
|
return this.setItem(name, {
|
|
637
622
|
type: 'variation',
|
|
638
623
|
parent,
|
|
639
624
|
props,
|
|
640
625
|
chars: new Set(),
|
|
641
|
-
categories,
|
|
642
626
|
});
|
|
643
627
|
}
|
|
644
628
|
/**
|
|
@@ -664,7 +648,7 @@ class IconSet {
|
|
|
664
648
|
body,
|
|
665
649
|
props,
|
|
666
650
|
chars: item.chars,
|
|
667
|
-
categories: item.categories,
|
|
651
|
+
categories: item.type === 'icon' ? item.categories : new Set(),
|
|
668
652
|
});
|
|
669
653
|
}
|
|
670
654
|
}
|
|
@@ -699,7 +683,6 @@ class IconSet {
|
|
|
699
683
|
}
|
|
700
684
|
switch (item.type) {
|
|
701
685
|
case 'icon':
|
|
702
|
-
case 'variation':
|
|
703
686
|
if (item.categories.has(categoryItem) !== add) {
|
|
704
687
|
categoryItem.count += add ? 1 : -1;
|
|
705
688
|
item.categories[add ? 'add' : 'delete'](categoryItem);
|
package/lib/icon-set/index.mjs
CHANGED
|
@@ -46,8 +46,7 @@ var IconSet = class {
|
|
|
46
46
|
type: "variation",
|
|
47
47
|
parent,
|
|
48
48
|
props,
|
|
49
|
-
chars
|
|
50
|
-
categories: new Set()
|
|
49
|
+
chars
|
|
51
50
|
};
|
|
52
51
|
entries[name] = entry;
|
|
53
52
|
} else {
|
|
@@ -82,7 +81,6 @@ var IconSet = class {
|
|
|
82
81
|
const icon = entries[iconName];
|
|
83
82
|
switch (icon == null ? void 0 : icon.type) {
|
|
84
83
|
case "icon":
|
|
85
|
-
case "variation":
|
|
86
84
|
icon.categories.add(item);
|
|
87
85
|
}
|
|
88
86
|
});
|
|
@@ -271,6 +269,7 @@ var IconSet = class {
|
|
|
271
269
|
Array.from(this.categories).sort((a, b) => a.title.localeCompare(b.title)).forEach((item) => {
|
|
272
270
|
const names2 = this.listCategory(item);
|
|
273
271
|
if (names2) {
|
|
272
|
+
names2.sort((a, b) => a.localeCompare(b));
|
|
274
273
|
categories[item.title] = names2;
|
|
275
274
|
}
|
|
276
275
|
});
|
|
@@ -362,8 +361,8 @@ var IconSet = class {
|
|
|
362
361
|
if (!categoryItem) {
|
|
363
362
|
return null;
|
|
364
363
|
}
|
|
365
|
-
const icons = this._filter((_key, item
|
|
366
|
-
if (item.type
|
|
364
|
+
const icons = this._filter((_key, item) => {
|
|
365
|
+
if (item.type !== "icon" || item.props.hidden) {
|
|
367
366
|
return false;
|
|
368
367
|
}
|
|
369
368
|
return item.categories.has(categoryItem);
|
|
@@ -487,24 +486,11 @@ var IconSet = class {
|
|
|
487
486
|
});
|
|
488
487
|
}
|
|
489
488
|
setVariation(name, parent, props) {
|
|
490
|
-
let categories;
|
|
491
|
-
while (!categories) {
|
|
492
|
-
const parentItem = this.entries[parent];
|
|
493
|
-
if (!parentItem) {
|
|
494
|
-
return false;
|
|
495
|
-
}
|
|
496
|
-
if (parentItem.type === "alias") {
|
|
497
|
-
parent = parentItem.parent;
|
|
498
|
-
} else {
|
|
499
|
-
categories = new Set(parentItem.categories);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
489
|
return this.setItem(name, {
|
|
503
490
|
type: "variation",
|
|
504
491
|
parent,
|
|
505
492
|
props,
|
|
506
|
-
chars: new Set()
|
|
507
|
-
categories
|
|
493
|
+
chars: new Set()
|
|
508
494
|
});
|
|
509
495
|
}
|
|
510
496
|
fromSVG(name, svg) {
|
|
@@ -525,7 +511,7 @@ var IconSet = class {
|
|
|
525
511
|
body,
|
|
526
512
|
props,
|
|
527
513
|
chars: item.chars,
|
|
528
|
-
categories: item.categories
|
|
514
|
+
categories: item.type === "icon" ? item.categories : new Set()
|
|
529
515
|
});
|
|
530
516
|
}
|
|
531
517
|
}
|
|
@@ -553,7 +539,6 @@ var IconSet = class {
|
|
|
553
539
|
}
|
|
554
540
|
switch (item.type) {
|
|
555
541
|
case "icon":
|
|
556
|
-
case "variation":
|
|
557
542
|
if (item.categories.has(categoryItem) !== add) {
|
|
558
543
|
categoryItem.count += add ? 1 : -1;
|
|
559
544
|
item.categories[add ? "add" : "delete"](categoryItem);
|
package/lib/icon-set/merge.js
CHANGED
package/lib/icon-set/merge.mjs
CHANGED
package/lib/icon-set/types.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export interface IconWithChars {
|
|
|
25
25
|
}
|
|
26
26
|
export interface IconWithPropsData extends IconWithChars {
|
|
27
27
|
props: CommonIconProps;
|
|
28
|
+
}
|
|
29
|
+
export interface IconWithCategories {
|
|
28
30
|
categories: Set<IconCategory>;
|
|
29
31
|
}
|
|
30
32
|
export interface IconParentData {
|
|
@@ -33,7 +35,7 @@ export interface IconParentData {
|
|
|
33
35
|
/**
|
|
34
36
|
* Icon types
|
|
35
37
|
*/
|
|
36
|
-
export interface IconSetIcon extends IconWithPropsData {
|
|
38
|
+
export interface IconSetIcon extends IconWithPropsData, IconWithCategories {
|
|
37
39
|
type: 'icon';
|
|
38
40
|
body: string;
|
|
39
41
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export { getGitRepoHash } from './download/git/hash';
|
|
|
16
16
|
export { getGitRepoBranch } from './download/git/branch';
|
|
17
17
|
export { downloadGitHubRepo } from './download/github/index';
|
|
18
18
|
export { getGitHubRepoHash } from './download/github/hash';
|
|
19
|
+
export { downloadGitLabRepo } from './download/gitlab/index';
|
|
20
|
+
export { getGitLabRepoHash } from './download/gitlab/hash';
|
|
19
21
|
export { downloadNPMPackage } from './download/npm/index';
|
|
20
22
|
export { getNPMVersion, getPackageVersion } from './download/npm/version';
|
|
21
23
|
export { downloadPackage } from './download/index';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendAPIQuery = exports.bumpVersion = exports.cleanupIconKeyword = exports.execAsync = exports.untar = exports.unzip = exports.compareDirectories = exports.scanDirectory = exports.prepareDirectoryForExport = exports.writeJSONFile = exports.exportJSONPackage = exports.exportIconPackage = exports.exportToDirectory = exports.scaleSVG = exports.deOptimisePaths = exports.runSVGO = exports.validateColors = exports.isEmptyColor = exports.parseColors = exports.downloadPackage = exports.getPackageVersion = exports.getNPMVersion = exports.downloadNPMPackage = exports.getGitHubRepoHash = exports.downloadGitHubRepo = exports.getGitRepoBranch = exports.getGitRepoHash = exports.downloadGitRepo = exports.importDirectory = exports.importFromFigma = exports.mergeIconSets = exports.blankIconSet = exports.IconSet = exports.convertStyleToAttrs = exports.cleanupSVGRoot = exports.cleanupInlineStyle = exports.checkBadTags = exports.removeBadAttributes = exports.cleanupSVG = exports.parseSVGStyle = exports.parseSVG = exports.SVG = void 0;
|
|
3
|
+
exports.sendAPIQuery = exports.bumpVersion = exports.cleanupIconKeyword = exports.execAsync = exports.untar = exports.unzip = exports.compareDirectories = exports.scanDirectory = exports.prepareDirectoryForExport = exports.writeJSONFile = exports.exportJSONPackage = exports.exportIconPackage = exports.exportToDirectory = exports.scaleSVG = exports.deOptimisePaths = exports.runSVGO = exports.validateColors = exports.isEmptyColor = exports.parseColors = exports.downloadPackage = exports.getPackageVersion = exports.getNPMVersion = exports.downloadNPMPackage = exports.getGitLabRepoHash = exports.downloadGitLabRepo = exports.getGitHubRepoHash = exports.downloadGitHubRepo = exports.getGitRepoBranch = exports.getGitRepoHash = exports.downloadGitRepo = exports.importDirectory = exports.importFromFigma = exports.mergeIconSets = exports.blankIconSet = exports.IconSet = exports.convertStyleToAttrs = exports.cleanupSVGRoot = exports.cleanupInlineStyle = exports.checkBadTags = exports.removeBadAttributes = exports.cleanupSVG = exports.parseSVGStyle = exports.parseSVG = exports.SVG = void 0;
|
|
4
4
|
// SVG class and functions
|
|
5
5
|
var index_1 = require("./svg/index");
|
|
6
6
|
Object.defineProperty(exports, "SVG", { enumerable: true, get: function () { return index_1.SVG; } });
|
|
@@ -43,13 +43,17 @@ var index_5 = require("./download/github/index");
|
|
|
43
43
|
Object.defineProperty(exports, "downloadGitHubRepo", { enumerable: true, get: function () { return index_5.downloadGitHubRepo; } });
|
|
44
44
|
var hash_2 = require("./download/github/hash");
|
|
45
45
|
Object.defineProperty(exports, "getGitHubRepoHash", { enumerable: true, get: function () { return hash_2.getGitHubRepoHash; } });
|
|
46
|
-
var index_6 = require("./download/
|
|
47
|
-
Object.defineProperty(exports, "
|
|
46
|
+
var index_6 = require("./download/gitlab/index");
|
|
47
|
+
Object.defineProperty(exports, "downloadGitLabRepo", { enumerable: true, get: function () { return index_6.downloadGitLabRepo; } });
|
|
48
|
+
var hash_3 = require("./download/gitlab/hash");
|
|
49
|
+
Object.defineProperty(exports, "getGitLabRepoHash", { enumerable: true, get: function () { return hash_3.getGitLabRepoHash; } });
|
|
50
|
+
var index_7 = require("./download/npm/index");
|
|
51
|
+
Object.defineProperty(exports, "downloadNPMPackage", { enumerable: true, get: function () { return index_7.downloadNPMPackage; } });
|
|
48
52
|
var version_1 = require("./download/npm/version");
|
|
49
53
|
Object.defineProperty(exports, "getNPMVersion", { enumerable: true, get: function () { return version_1.getNPMVersion; } });
|
|
50
54
|
Object.defineProperty(exports, "getPackageVersion", { enumerable: true, get: function () { return version_1.getPackageVersion; } });
|
|
51
|
-
var
|
|
52
|
-
Object.defineProperty(exports, "downloadPackage", { enumerable: true, get: function () { return
|
|
55
|
+
var index_8 = require("./download/index");
|
|
56
|
+
Object.defineProperty(exports, "downloadPackage", { enumerable: true, get: function () { return index_8.downloadPackage; } });
|
|
53
57
|
// Manipulation
|
|
54
58
|
var parse_2 = require("./colors/parse");
|
|
55
59
|
Object.defineProperty(exports, "parseColors", { enumerable: true, get: function () { return parse_2.parseColors; } });
|
|
@@ -89,5 +93,5 @@ var keyword_1 = require("./misc/keyword");
|
|
|
89
93
|
Object.defineProperty(exports, "cleanupIconKeyword", { enumerable: true, get: function () { return keyword_1.cleanupIconKeyword; } });
|
|
90
94
|
var bump_version_1 = require("./misc/bump-version");
|
|
91
95
|
Object.defineProperty(exports, "bumpVersion", { enumerable: true, get: function () { return bump_version_1.bumpVersion; } });
|
|
92
|
-
var
|
|
93
|
-
Object.defineProperty(exports, "sendAPIQuery", { enumerable: true, get: function () { return
|
|
96
|
+
var index_9 = require("./download/api/index");
|
|
97
|
+
Object.defineProperty(exports, "sendAPIQuery", { enumerable: true, get: function () { return index_9.sendAPIQuery; } });
|
package/lib/index.mjs
CHANGED
|
@@ -17,6 +17,8 @@ import { getGitRepoHash } from "./download/git/hash.mjs";
|
|
|
17
17
|
import { getGitRepoBranch } from "./download/git/branch.mjs";
|
|
18
18
|
import { downloadGitHubRepo } from "./download/github/index.mjs";
|
|
19
19
|
import { getGitHubRepoHash } from "./download/github/hash.mjs";
|
|
20
|
+
import { downloadGitLabRepo } from "./download/gitlab/index.mjs";
|
|
21
|
+
import { getGitLabRepoHash } from "./download/gitlab/hash.mjs";
|
|
20
22
|
import { downloadNPMPackage } from "./download/npm/index.mjs";
|
|
21
23
|
import { getNPMVersion, getPackageVersion } from "./download/npm/version.mjs";
|
|
22
24
|
import { downloadPackage } from "./download/index.mjs";
|
|
@@ -52,6 +54,7 @@ export {
|
|
|
52
54
|
convertStyleToAttrs,
|
|
53
55
|
deOptimisePaths,
|
|
54
56
|
downloadGitHubRepo,
|
|
57
|
+
downloadGitLabRepo,
|
|
55
58
|
downloadGitRepo,
|
|
56
59
|
downloadNPMPackage,
|
|
57
60
|
downloadPackage,
|
|
@@ -60,6 +63,7 @@ export {
|
|
|
60
63
|
exportJSONPackage,
|
|
61
64
|
exportToDirectory,
|
|
62
65
|
getGitHubRepoHash,
|
|
66
|
+
getGitLabRepoHash,
|
|
63
67
|
getGitRepoBranch,
|
|
64
68
|
getGitRepoHash,
|
|
65
69
|
getNPMVersion,
|
package/lib/optimise/flags.js
CHANGED
|
@@ -64,6 +64,15 @@ function cleanPath(path) {
|
|
|
64
64
|
});
|
|
65
65
|
currentArgs = [];
|
|
66
66
|
canParseCommandOrComma = true;
|
|
67
|
+
// Change command for lines after moving
|
|
68
|
+
switch (currentCommand) {
|
|
69
|
+
case 'M':
|
|
70
|
+
currentCommand = 'L';
|
|
71
|
+
break;
|
|
72
|
+
case 'm':
|
|
73
|
+
currentCommand = 'l';
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
67
76
|
}
|
|
68
77
|
};
|
|
69
78
|
const parseNumber = () => {
|
package/lib/optimise/flags.mjs
CHANGED
|
@@ -44,6 +44,14 @@ function cleanPath(path) {
|
|
|
44
44
|
});
|
|
45
45
|
currentArgs = [];
|
|
46
46
|
canParseCommandOrComma = true;
|
|
47
|
+
switch (currentCommand) {
|
|
48
|
+
case "M":
|
|
49
|
+
currentCommand = "L";
|
|
50
|
+
break;
|
|
51
|
+
case "m":
|
|
52
|
+
currentCommand = "l";
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
47
55
|
}
|
|
48
56
|
};
|
|
49
57
|
const parseNumber = () => {
|
package/lib/optimise/svgo.js
CHANGED
package/lib/optimise/svgo.mjs
CHANGED
|
@@ -77,7 +77,7 @@ async function cleanupSVGRoot(svg) {
|
|
|
77
77
|
$root.removeAttr(attr);
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
|
-
console.
|
|
80
|
+
console.warn(`Removing unexpected attribute on SVG: ${attr}`);
|
|
81
81
|
$root.removeAttr(attr);
|
|
82
82
|
});
|
|
83
83
|
if (Object.keys(moveToChildren).length) {
|
|
@@ -60,7 +60,7 @@ async function cleanupSVGRoot(svg) {
|
|
|
60
60
|
$root.removeAttr(attr);
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
console.
|
|
63
|
+
console.warn(`Removing unexpected attribute on SVG: ${attr}`);
|
|
64
64
|
$root.removeAttr(attr);
|
|
65
65
|
});
|
|
66
66
|
if (Object.keys(moveToChildren).length) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@iconify/tools",
|
|
3
3
|
"description": "Collection of functions for cleaning up and parsing SVG for Iconify project",
|
|
4
4
|
"author": "Vjacheslav Trushkin",
|
|
5
|
-
"version": "2.0.
|
|
5
|
+
"version": "2.0.11",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bugs": "https://github.com/iconify/tools/issues",
|
|
8
8
|
"homepage": "https://github.com/iconify/tools",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"test": "npm run test:jest && npm run test:jasmine"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@iconify/utils": "^1.0.
|
|
25
|
+
"@iconify/utils": "^1.0.23",
|
|
26
26
|
"@types/cheerio": "^0.22.30",
|
|
27
27
|
"@types/node-fetch": "^2.5.12",
|
|
28
28
|
"@types/svgo": "^2.6.0",
|
|
@@ -136,6 +136,22 @@
|
|
|
136
136
|
"require": "./lib/download/github/types.js",
|
|
137
137
|
"import": "./lib/download/github/types.mjs"
|
|
138
138
|
},
|
|
139
|
+
"./lib/download/gitlab/hash": {
|
|
140
|
+
"require": "./lib/download/gitlab/hash.js",
|
|
141
|
+
"import": "./lib/download/gitlab/hash.mjs"
|
|
142
|
+
},
|
|
143
|
+
"./lib/download/gitlab": {
|
|
144
|
+
"require": "./lib/download/gitlab/index.js",
|
|
145
|
+
"import": "./lib/download/gitlab/index.mjs"
|
|
146
|
+
},
|
|
147
|
+
"./lib/download/gitlab/index": {
|
|
148
|
+
"require": "./lib/download/gitlab/index.js",
|
|
149
|
+
"import": "./lib/download/gitlab/index.mjs"
|
|
150
|
+
},
|
|
151
|
+
"./lib/download/gitlab/types": {
|
|
152
|
+
"require": "./lib/download/gitlab/types.js",
|
|
153
|
+
"import": "./lib/download/gitlab/types.mjs"
|
|
154
|
+
},
|
|
139
155
|
"./lib/download/helpers/untar": {
|
|
140
156
|
"require": "./lib/download/helpers/untar.js",
|
|
141
157
|
"import": "./lib/download/helpers/untar.mjs"
|