@iconify/tools 2.0.14 → 2.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/colors/attribs.cjs +30 -0
- package/lib/colors/attribs.d.ts +13 -10
- package/lib/colors/attribs.mjs +7 -13
- package/lib/colors/parse.cjs +269 -0
- package/lib/colors/parse.d.ts +15 -11
- package/lib/colors/parse.mjs +27 -31
- package/lib/colors/validate.cjs +52 -0
- package/lib/colors/validate.d.ts +11 -4
- package/lib/colors/validate.mjs +19 -6
- package/lib/css/parse.cjs +26 -0
- package/lib/css/parse.d.ts +3 -1
- package/lib/css/parse.mjs +8 -6
- package/lib/css/parser/error.cjs +25 -0
- package/lib/css/parser/error.d.ts +4 -2
- package/lib/css/parser/error.mjs +2 -4
- package/lib/css/parser/export.cjs +48 -0
- package/lib/css/parser/export.d.ts +5 -2
- package/lib/css/parser/export.mjs +4 -6
- package/lib/css/parser/strings.cjs +77 -0
- package/lib/css/parser/strings.d.ts +6 -3
- package/lib/css/parser/strings.mjs +4 -6
- package/lib/css/parser/text.cjs +135 -0
- package/lib/css/parser/text.d.ts +8 -5
- package/lib/css/parser/text.mjs +3 -8
- package/lib/css/parser/tokens.cjs +184 -0
- package/lib/css/parser/tokens.d.ts +6 -3
- package/lib/css/parser/tokens.mjs +7 -13
- package/lib/css/parser/tree.cjs +42 -0
- package/lib/css/parser/tree.d.ts +5 -2
- package/lib/css/parser/tree.mjs +2 -4
- package/lib/css/parser/types.cjs +2 -0
- package/lib/css/parser/types.d.ts +13 -11
- package/lib/css/parser/types.mjs +1 -0
- package/lib/download/api/cache.cjs +86 -0
- package/lib/download/api/cache.d.ts +8 -5
- package/lib/download/api/cache.mjs +14 -19
- package/lib/download/api/download.cjs +28 -0
- package/lib/download/api/download.d.ts +5 -2
- package/lib/download/api/download.mjs +8 -9
- package/lib/download/api/index.cjs +51 -0
- package/lib/download/api/index.d.ts +5 -2
- package/lib/download/api/index.mjs +8 -6
- package/lib/download/api/types.cjs +2 -0
- package/lib/download/api/types.d.ts +4 -2
- package/lib/download/api/types.mjs +1 -0
- package/lib/download/git/branch.cjs +22 -0
- package/lib/download/git/branch.d.ts +5 -2
- package/lib/download/git/branch.mjs +5 -5
- package/lib/download/git/hash.cjs +15 -0
- package/lib/download/git/hash.d.ts +5 -2
- package/lib/download/git/hash.mjs +5 -5
- package/lib/download/git/index.cjs +76 -0
- package/lib/download/git/index.d.ts +10 -8
- package/lib/download/git/index.mjs +41 -26
- package/lib/download/git/reset.cjs +41 -0
- package/lib/download/git/reset.d.ts +3 -1
- package/lib/download/git/reset.mjs +29 -5
- package/lib/download/github/hash.cjs +32 -0
- package/lib/download/github/hash.d.ts +5 -2
- package/lib/download/github/hash.mjs +10 -7
- package/lib/download/github/index.cjs +98 -0
- package/lib/download/github/index.d.ts +11 -9
- package/lib/download/github/index.mjs +23 -17
- package/lib/download/github/types.cjs +2 -0
- package/lib/download/github/types.d.ts +3 -1
- package/lib/download/github/types.mjs +1 -0
- package/lib/download/gitlab/hash.cjs +32 -0
- package/lib/download/gitlab/hash.d.ts +5 -2
- package/lib/download/gitlab/hash.mjs +10 -6
- package/lib/download/gitlab/index.cjs +98 -0
- package/lib/download/gitlab/index.d.ts +11 -9
- package/lib/download/gitlab/index.mjs +24 -18
- package/lib/download/gitlab/types.cjs +7 -0
- package/lib/download/gitlab/types.d.ts +4 -2
- package/lib/download/gitlab/types.mjs +3 -5
- package/lib/download/helpers/untar.cjs +14 -0
- package/lib/download/helpers/untar.d.ts +3 -1
- package/lib/download/helpers/untar.mjs +4 -5
- package/lib/download/helpers/unzip.cjs +19 -0
- package/lib/download/helpers/unzip.d.ts +3 -1
- package/lib/download/helpers/unzip.mjs +6 -7
- package/lib/download/index.cjs +64 -0
- package/lib/download/index.d.ts +18 -13
- package/lib/download/index.mjs +46 -19
- package/lib/download/npm/index.cjs +82 -0
- package/lib/download/npm/index.d.ts +10 -8
- package/lib/download/npm/index.mjs +16 -13
- package/lib/download/npm/types.cjs +2 -0
- package/lib/download/npm/types.d.ts +3 -1
- package/lib/download/npm/types.mjs +1 -0
- package/lib/download/npm/version.cjs +23 -0
- package/lib/download/npm/version.d.ts +7 -4
- package/lib/download/npm/version.mjs +8 -10
- package/lib/download/types/modified.cjs +2 -0
- package/lib/download/types/modified.d.ts +3 -1
- package/lib/download/types/modified.mjs +1 -0
- package/lib/download/types/sources.cjs +2 -0
- package/lib/download/types/sources.d.ts +4 -2
- package/lib/download/types/sources.mjs +1 -0
- package/lib/export/directory.cjs +45 -0
- package/lib/export/directory.d.ts +11 -4
- package/lib/export/directory.mjs +8 -8
- package/lib/export/helpers/custom-files.cjs +28 -0
- package/lib/export/helpers/custom-files.d.ts +4 -2
- package/lib/export/helpers/custom-files.mjs +8 -9
- package/lib/export/helpers/prepare.cjs +36 -0
- package/lib/export/helpers/prepare.d.ts +5 -3
- package/lib/export/helpers/prepare.mjs +7 -9
- package/lib/export/helpers/types-version.cjs +22 -0
- package/lib/export/helpers/types-version.d.ts +3 -1
- package/lib/export/helpers/types-version.mjs +15 -37
- package/lib/export/icon-package.cjs +59 -0
- package/lib/export/icon-package.d.ts +12 -5
- package/lib/export/icon-package.mjs +15 -16
- package/lib/export/json-package.cjs +133 -0
- package/lib/export/json-package.d.ts +12 -5
- package/lib/export/json-package.mjs +20 -21
- package/lib/icon-set/index.cjs +589 -0
- package/lib/icon-set/index.d.ts +9 -6
- package/lib/icon-set/index.mjs +40 -53
- package/lib/icon-set/match.cjs +58 -0
- package/lib/icon-set/match.d.ts +10 -3
- package/lib/icon-set/match.mjs +5 -6
- package/lib/icon-set/merge.cjs +83 -0
- package/lib/icon-set/merge.d.ts +9 -2
- package/lib/icon-set/merge.mjs +15 -10
- package/lib/icon-set/props.cjs +28 -0
- package/lib/icon-set/props.d.ts +8 -4
- package/lib/icon-set/props.mjs +7 -10
- package/lib/icon-set/types.cjs +2 -0
- package/lib/icon-set/types.d.ts +19 -17
- package/lib/icon-set/types.mjs +1 -0
- package/lib/import/directory.cjs +76 -0
- package/lib/import/directory.d.ts +11 -5
- package/lib/import/directory.mjs +36 -11
- package/lib/import/figma/index.cjs +105 -0
- package/lib/import/figma/index.d.ts +15 -5
- package/lib/import/figma/index.mjs +40 -13
- package/lib/import/figma/nodes.cjs +86 -0
- package/lib/import/figma/nodes.d.ts +13 -4
- package/lib/import/figma/nodes.mjs +3 -11
- package/lib/import/figma/query.cjs +218 -0
- package/lib/import/figma/query.d.ts +18 -9
- package/lib/import/figma/query.mjs +9 -12
- package/lib/import/figma/types/api.cjs +2 -0
- package/lib/import/figma/types/api.d.ts +8 -7
- package/lib/import/figma/types/api.mjs +1 -0
- package/lib/import/figma/types/nodes.cjs +2 -0
- package/lib/import/figma/types/nodes.d.ts +16 -9
- package/lib/import/figma/types/nodes.mjs +1 -0
- package/lib/import/figma/types/options.cjs +2 -0
- package/lib/import/figma/types/options.d.ts +17 -10
- package/lib/import/figma/types/options.mjs +1 -0
- package/lib/import/figma/types/result.cjs +2 -0
- package/lib/import/figma/types/result.d.ts +12 -5
- package/lib/import/figma/types/result.mjs +1 -0
- package/lib/index.cjs +137 -0
- package/lib/index.d.ts +65 -44
- package/lib/index.mjs +83 -94
- package/lib/misc/bump-version.cjs +17 -0
- package/lib/misc/bump-version.d.ts +3 -1
- package/lib/misc/bump-version.mjs +2 -4
- package/lib/misc/compare-dirs.cjs +75 -0
- package/lib/misc/compare-dirs.d.ts +4 -2
- package/lib/misc/compare-dirs.mjs +12 -12
- package/lib/misc/exec.cjs +25 -0
- package/lib/misc/exec.d.ts +6 -4
- package/lib/misc/exec.mjs +4 -5
- package/lib/misc/keyword.cjs +19 -0
- package/lib/misc/keyword.d.ts +3 -1
- package/lib/misc/keyword.mjs +2 -4
- package/lib/misc/scan.cjs +51 -0
- package/lib/misc/scan.d.ts +7 -6
- package/lib/misc/scan.mjs +6 -7
- package/lib/misc/write-json.cjs +11 -0
- package/lib/misc/write-json.d.ts +3 -1
- package/lib/misc/write-json.mjs +5 -6
- package/lib/optimise/flags.cjs +252 -0
- package/lib/optimise/flags.d.ts +7 -2
- package/lib/optimise/flags.mjs +18 -19
- package/lib/optimise/global-style.cjs +154 -0
- package/lib/optimise/global-style.d.ts +7 -2
- package/lib/optimise/global-style.mjs +18 -15
- package/lib/optimise/scale.cjs +26 -0
- package/lib/optimise/scale.d.ts +7 -2
- package/lib/optimise/scale.mjs +5 -5
- package/lib/optimise/svgo.cjs +83 -0
- package/lib/optimise/svgo.d.ts +10 -6
- package/lib/optimise/svgo.mjs +6 -9
- package/lib/svg/analyse/error.cjs +18 -0
- package/lib/svg/analyse/error.d.ts +5 -2
- package/lib/svg/analyse/error.mjs +2 -4
- package/lib/svg/analyse/types.cjs +2 -0
- package/lib/svg/analyse/types.d.ts +11 -11
- package/lib/svg/analyse/types.mjs +1 -0
- package/lib/svg/analyse.cjs +291 -0
- package/lib/svg/analyse.d.ts +8 -3
- package/lib/svg/analyse.mjs +15 -30
- package/lib/svg/cleanup/attribs.cjs +41 -0
- package/lib/svg/cleanup/attribs.d.ts +7 -2
- package/lib/svg/cleanup/attribs.mjs +6 -12
- package/lib/svg/cleanup/bad-tags.cjs +51 -0
- package/lib/svg/cleanup/bad-tags.d.ts +7 -2
- package/lib/svg/cleanup/bad-tags.mjs +10 -25
- package/lib/svg/cleanup/inline-style.cjs +64 -0
- package/lib/svg/cleanup/inline-style.d.ts +7 -2
- package/lib/svg/cleanup/inline-style.mjs +14 -19
- package/lib/svg/cleanup/root-svg.cjs +81 -0
- package/lib/svg/cleanup/root-svg.d.ts +7 -2
- package/lib/svg/cleanup/root-svg.mjs +7 -18
- package/lib/svg/cleanup/svgo-style.cjs +38 -0
- package/lib/svg/cleanup/svgo-style.d.ts +7 -2
- package/lib/svg/cleanup/svgo-style.mjs +16 -11
- package/lib/svg/cleanup.cjs +32 -0
- package/lib/svg/cleanup.d.ts +7 -2
- package/lib/svg/cleanup.mjs +21 -9
- package/lib/svg/data/attributes.cjs +355 -0
- package/lib/svg/data/attributes.d.ts +27 -25
- package/lib/svg/data/attributes.mjs +90 -115
- package/lib/svg/data/tags.cjs +137 -0
- package/lib/svg/data/tags.d.ts +25 -23
- package/lib/svg/data/tags.mjs +25 -49
- package/lib/svg/index.cjs +130 -0
- package/lib/svg/index.d.ts +16 -5
- package/lib/svg/index.mjs +48 -14
- package/lib/svg/parse-style.cjs +134 -0
- package/lib/svg/parse-style.d.ts +12 -8
- package/lib/svg/parse-style.mjs +11 -9
- package/lib/svg/parse.cjs +42 -0
- package/lib/svg/parse.d.ts +11 -7
- package/lib/svg/parse.mjs +2 -4
- package/package.json +99 -94
- package/lib/colors/attribs.js +0 -26
- package/lib/colors/parse.js +0 -341
- package/lib/colors/validate.js +0 -48
- package/lib/css/parse.js +0 -23
- package/lib/css/parser/error.js +0 -27
- package/lib/css/parser/export.js +0 -69
- package/lib/css/parser/strings.js +0 -93
- package/lib/css/parser/text.js +0 -171
- package/lib/css/parser/tokens.js +0 -200
- package/lib/css/parser/tree.js +0 -44
- package/lib/css/parser/types.js +0 -2
- package/lib/download/api/cache.js +0 -108
- package/lib/download/api/download.js +0 -27
- package/lib/download/api/index.js +0 -52
- package/lib/download/api/types.js +0 -2
- package/lib/download/git/branch.js +0 -22
- package/lib/download/git/hash.js +0 -14
- package/lib/download/git/index.js +0 -75
- package/lib/download/git/reset.js +0 -16
- package/lib/download/github/hash.js +0 -28
- package/lib/download/github/index.js +0 -116
- package/lib/download/github/types.js +0 -2
- package/lib/download/gitlab/hash.js +0 -27
- package/lib/download/gitlab/index.js +0 -115
- package/lib/download/gitlab/types.js +0 -7
- package/lib/download/helpers/untar.js +0 -14
- package/lib/download/helpers/unzip.js +0 -18
- package/lib/download/index.js +0 -27
- package/lib/download/npm/index.js +0 -91
- package/lib/download/npm/types.js +0 -2
- package/lib/download/npm/version.js +0 -27
- package/lib/download/types/modified.js +0 -2
- package/lib/download/types/sources.js +0 -2
- package/lib/export/directory.js +0 -52
- package/lib/export/helpers/custom-files.js +0 -32
- package/lib/export/helpers/prepare.js +0 -49
- package/lib/export/helpers/types-version.js +0 -12
- package/lib/export/icon-package.js +0 -77
- package/lib/export/json-package.js +0 -156
- package/lib/icon-set/index.js +0 -749
- package/lib/icon-set/match.js +0 -66
- package/lib/icon-set/merge.js +0 -90
- package/lib/icon-set/props.js +0 -34
- package/lib/icon-set/types.js +0 -2
- package/lib/import/directory.js +0 -59
- package/lib/import/figma/index.js +0 -90
- package/lib/import/figma/nodes.js +0 -106
- package/lib/import/figma/query.js +0 -244
- package/lib/import/figma/types/api.js +0 -12
- package/lib/import/figma/types/nodes.js +0 -2
- package/lib/import/figma/types/options.js +0 -2
- package/lib/import/figma/types/result.js +0 -2
- package/lib/index.js +0 -103
- package/lib/misc/bump-version.js +0 -19
- package/lib/misc/compare-dirs.js +0 -84
- package/lib/misc/exec.js +0 -26
- package/lib/misc/keyword.js +0 -31
- package/lib/misc/scan.js +0 -55
- package/lib/misc/write-json.js +0 -11
- package/lib/optimise/flags.js +0 -312
- package/lib/optimise/global-style.js +0 -185
- package/lib/optimise/scale.js +0 -42
- package/lib/optimise/svgo.js +0 -99
- package/lib/svg/analyse/error.js +0 -22
- package/lib/svg/analyse/types.js +0 -2
- package/lib/svg/analyse.js +0 -352
- package/lib/svg/cleanup/attribs.js +0 -51
- package/lib/svg/cleanup/bad-tags.js +0 -65
- package/lib/svg/cleanup/inline-style.js +0 -77
- package/lib/svg/cleanup/root-svg.js +0 -107
- package/lib/svg/cleanup/svgo-style.js +0 -35
- package/lib/svg/cleanup.js +0 -24
- package/lib/svg/data/attributes.js +0 -403
- package/lib/svg/data/tags.js +0 -188
- package/lib/svg/index.js +0 -134
- package/lib/svg/parse-style.js +0 -151
- package/lib/svg/parse.js +0 -49
package/lib/index.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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.cleanupGlobalStyle = 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.resetGitRepoContents = 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.analyseSVGStructure = exports.parseSVGStyle = exports.parseSVG = exports.SVG = void 0;
|
|
4
|
-
// SVG class and functions
|
|
5
|
-
var index_1 = require("./svg/index");
|
|
6
|
-
Object.defineProperty(exports, "SVG", { enumerable: true, get: function () { return index_1.SVG; } });
|
|
7
|
-
var parse_1 = require("./svg/parse");
|
|
8
|
-
Object.defineProperty(exports, "parseSVG", { enumerable: true, get: function () { return parse_1.parseSVG; } });
|
|
9
|
-
var parse_style_1 = require("./svg/parse-style");
|
|
10
|
-
Object.defineProperty(exports, "parseSVGStyle", { enumerable: true, get: function () { return parse_style_1.parseSVGStyle; } });
|
|
11
|
-
var analyse_1 = require("./svg/analyse");
|
|
12
|
-
Object.defineProperty(exports, "analyseSVGStructure", { enumerable: true, get: function () { return analyse_1.analyseSVGStructure; } });
|
|
13
|
-
// SVG cleanup
|
|
14
|
-
var cleanup_1 = require("./svg/cleanup");
|
|
15
|
-
Object.defineProperty(exports, "cleanupSVG", { enumerable: true, get: function () { return cleanup_1.cleanupSVG; } });
|
|
16
|
-
var attribs_1 = require("./svg/cleanup/attribs");
|
|
17
|
-
Object.defineProperty(exports, "removeBadAttributes", { enumerable: true, get: function () { return attribs_1.removeBadAttributes; } });
|
|
18
|
-
var bad_tags_1 = require("./svg/cleanup/bad-tags");
|
|
19
|
-
Object.defineProperty(exports, "checkBadTags", { enumerable: true, get: function () { return bad_tags_1.checkBadTags; } });
|
|
20
|
-
var inline_style_1 = require("./svg/cleanup/inline-style");
|
|
21
|
-
Object.defineProperty(exports, "cleanupInlineStyle", { enumerable: true, get: function () { return inline_style_1.cleanupInlineStyle; } });
|
|
22
|
-
var root_svg_1 = require("./svg/cleanup/root-svg");
|
|
23
|
-
Object.defineProperty(exports, "cleanupSVGRoot", { enumerable: true, get: function () { return root_svg_1.cleanupSVGRoot; } });
|
|
24
|
-
var svgo_style_1 = require("./svg/cleanup/svgo-style");
|
|
25
|
-
Object.defineProperty(exports, "convertStyleToAttrs", { enumerable: true, get: function () { return svgo_style_1.convertStyleToAttrs; } });
|
|
26
|
-
// IconSet class
|
|
27
|
-
var index_2 = require("./icon-set/index");
|
|
28
|
-
Object.defineProperty(exports, "IconSet", { enumerable: true, get: function () { return index_2.IconSet; } });
|
|
29
|
-
Object.defineProperty(exports, "blankIconSet", { enumerable: true, get: function () { return index_2.blankIconSet; } });
|
|
30
|
-
var merge_1 = require("./icon-set/merge");
|
|
31
|
-
Object.defineProperty(exports, "mergeIconSets", { enumerable: true, get: function () { return merge_1.mergeIconSets; } });
|
|
32
|
-
// Import
|
|
33
|
-
var index_3 = require("./import/figma/index");
|
|
34
|
-
Object.defineProperty(exports, "importFromFigma", { enumerable: true, get: function () { return index_3.importFromFigma; } });
|
|
35
|
-
var directory_1 = require("./import/directory");
|
|
36
|
-
Object.defineProperty(exports, "importDirectory", { enumerable: true, get: function () { return directory_1.importDirectory; } });
|
|
37
|
-
// Download (for import)
|
|
38
|
-
var index_4 = require("./download/git/index");
|
|
39
|
-
Object.defineProperty(exports, "downloadGitRepo", { enumerable: true, get: function () { return index_4.downloadGitRepo; } });
|
|
40
|
-
var hash_1 = require("./download/git/hash");
|
|
41
|
-
Object.defineProperty(exports, "getGitRepoHash", { enumerable: true, get: function () { return hash_1.getGitRepoHash; } });
|
|
42
|
-
var branch_1 = require("./download/git/branch");
|
|
43
|
-
Object.defineProperty(exports, "getGitRepoBranch", { enumerable: true, get: function () { return branch_1.getGitRepoBranch; } });
|
|
44
|
-
var reset_1 = require("./download/git/reset");
|
|
45
|
-
Object.defineProperty(exports, "resetGitRepoContents", { enumerable: true, get: function () { return reset_1.resetGitRepoContents; } });
|
|
46
|
-
var index_5 = require("./download/github/index");
|
|
47
|
-
Object.defineProperty(exports, "downloadGitHubRepo", { enumerable: true, get: function () { return index_5.downloadGitHubRepo; } });
|
|
48
|
-
var hash_2 = require("./download/github/hash");
|
|
49
|
-
Object.defineProperty(exports, "getGitHubRepoHash", { enumerable: true, get: function () { return hash_2.getGitHubRepoHash; } });
|
|
50
|
-
var index_6 = require("./download/gitlab/index");
|
|
51
|
-
Object.defineProperty(exports, "downloadGitLabRepo", { enumerable: true, get: function () { return index_6.downloadGitLabRepo; } });
|
|
52
|
-
var hash_3 = require("./download/gitlab/hash");
|
|
53
|
-
Object.defineProperty(exports, "getGitLabRepoHash", { enumerable: true, get: function () { return hash_3.getGitLabRepoHash; } });
|
|
54
|
-
var index_7 = require("./download/npm/index");
|
|
55
|
-
Object.defineProperty(exports, "downloadNPMPackage", { enumerable: true, get: function () { return index_7.downloadNPMPackage; } });
|
|
56
|
-
var version_1 = require("./download/npm/version");
|
|
57
|
-
Object.defineProperty(exports, "getNPMVersion", { enumerable: true, get: function () { return version_1.getNPMVersion; } });
|
|
58
|
-
Object.defineProperty(exports, "getPackageVersion", { enumerable: true, get: function () { return version_1.getPackageVersion; } });
|
|
59
|
-
var index_8 = require("./download/index");
|
|
60
|
-
Object.defineProperty(exports, "downloadPackage", { enumerable: true, get: function () { return index_8.downloadPackage; } });
|
|
61
|
-
// Manipulation
|
|
62
|
-
var parse_2 = require("./colors/parse");
|
|
63
|
-
Object.defineProperty(exports, "parseColors", { enumerable: true, get: function () { return parse_2.parseColors; } });
|
|
64
|
-
Object.defineProperty(exports, "isEmptyColor", { enumerable: true, get: function () { return parse_2.isEmptyColor; } });
|
|
65
|
-
var validate_1 = require("./colors/validate");
|
|
66
|
-
Object.defineProperty(exports, "validateColors", { enumerable: true, get: function () { return validate_1.validateColors; } });
|
|
67
|
-
var svgo_1 = require("./optimise/svgo");
|
|
68
|
-
Object.defineProperty(exports, "runSVGO", { enumerable: true, get: function () { return svgo_1.runSVGO; } });
|
|
69
|
-
var flags_1 = require("./optimise/flags");
|
|
70
|
-
Object.defineProperty(exports, "deOptimisePaths", { enumerable: true, get: function () { return flags_1.deOptimisePaths; } });
|
|
71
|
-
var scale_1 = require("./optimise/scale");
|
|
72
|
-
Object.defineProperty(exports, "scaleSVG", { enumerable: true, get: function () { return scale_1.scaleSVG; } });
|
|
73
|
-
var global_style_1 = require("./optimise/global-style");
|
|
74
|
-
Object.defineProperty(exports, "cleanupGlobalStyle", { enumerable: true, get: function () { return global_style_1.cleanupGlobalStyle; } });
|
|
75
|
-
// Export
|
|
76
|
-
var directory_2 = require("./export/directory");
|
|
77
|
-
Object.defineProperty(exports, "exportToDirectory", { enumerable: true, get: function () { return directory_2.exportToDirectory; } });
|
|
78
|
-
var icon_package_1 = require("./export/icon-package");
|
|
79
|
-
Object.defineProperty(exports, "exportIconPackage", { enumerable: true, get: function () { return icon_package_1.exportIconPackage; } });
|
|
80
|
-
var json_package_1 = require("./export/json-package");
|
|
81
|
-
Object.defineProperty(exports, "exportJSONPackage", { enumerable: true, get: function () { return json_package_1.exportJSONPackage; } });
|
|
82
|
-
// Misc: files, directories and archives
|
|
83
|
-
var write_json_1 = require("./misc/write-json");
|
|
84
|
-
Object.defineProperty(exports, "writeJSONFile", { enumerable: true, get: function () { return write_json_1.writeJSONFile; } });
|
|
85
|
-
var prepare_1 = require("./export/helpers/prepare");
|
|
86
|
-
Object.defineProperty(exports, "prepareDirectoryForExport", { enumerable: true, get: function () { return prepare_1.prepareDirectoryForExport; } });
|
|
87
|
-
var scan_1 = require("./misc/scan");
|
|
88
|
-
Object.defineProperty(exports, "scanDirectory", { enumerable: true, get: function () { return scan_1.scanDirectory; } });
|
|
89
|
-
var compare_dirs_1 = require("./misc/compare-dirs");
|
|
90
|
-
Object.defineProperty(exports, "compareDirectories", { enumerable: true, get: function () { return compare_dirs_1.compareDirectories; } });
|
|
91
|
-
var unzip_1 = require("./download/helpers/unzip");
|
|
92
|
-
Object.defineProperty(exports, "unzip", { enumerable: true, get: function () { return unzip_1.unzip; } });
|
|
93
|
-
var untar_1 = require("./download/helpers/untar");
|
|
94
|
-
Object.defineProperty(exports, "untar", { enumerable: true, get: function () { return untar_1.untar; } });
|
|
95
|
-
// Misc: other
|
|
96
|
-
var exec_1 = require("./misc/exec");
|
|
97
|
-
Object.defineProperty(exports, "execAsync", { enumerable: true, get: function () { return exec_1.execAsync; } });
|
|
98
|
-
var keyword_1 = require("./misc/keyword");
|
|
99
|
-
Object.defineProperty(exports, "cleanupIconKeyword", { enumerable: true, get: function () { return keyword_1.cleanupIconKeyword; } });
|
|
100
|
-
var bump_version_1 = require("./misc/bump-version");
|
|
101
|
-
Object.defineProperty(exports, "bumpVersion", { enumerable: true, get: function () { return bump_version_1.bumpVersion; } });
|
|
102
|
-
var index_9 = require("./download/api/index");
|
|
103
|
-
Object.defineProperty(exports, "sendAPIQuery", { enumerable: true, get: function () { return index_9.sendAPIQuery; } });
|
package/lib/misc/bump-version.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bumpVersion = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Bump version number
|
|
6
|
-
*/
|
|
7
|
-
function bumpVersion(version) {
|
|
8
|
-
const versionParts = version.split('.');
|
|
9
|
-
const lastPart = versionParts.pop();
|
|
10
|
-
const num = parseInt(lastPart);
|
|
11
|
-
if (isNaN(num) || num + '' !== lastPart) {
|
|
12
|
-
versionParts.push(lastPart + '.1');
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
versionParts.push(num + 1 + '');
|
|
16
|
-
}
|
|
17
|
-
return versionParts.join('.');
|
|
18
|
-
}
|
|
19
|
-
exports.bumpVersion = bumpVersion;
|
package/lib/misc/compare-dirs.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compareDirectories = void 0;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
const prepare_1 = require("../export/helpers/prepare");
|
|
6
|
-
const scan_1 = require("./scan");
|
|
7
|
-
/**
|
|
8
|
-
* Extensions that are treated as text
|
|
9
|
-
*/
|
|
10
|
-
const textFileExtensions = [
|
|
11
|
-
'json',
|
|
12
|
-
'ts',
|
|
13
|
-
'js',
|
|
14
|
-
'mjs',
|
|
15
|
-
'cjs',
|
|
16
|
-
'jsx',
|
|
17
|
-
'tsx',
|
|
18
|
-
'vue',
|
|
19
|
-
'svelte',
|
|
20
|
-
'svg',
|
|
21
|
-
'txt',
|
|
22
|
-
'md',
|
|
23
|
-
];
|
|
24
|
-
/**
|
|
25
|
-
* Compare directories. Returns true if files are identical, false if different
|
|
26
|
-
*/
|
|
27
|
-
async function compareDirectories(dir1, dir2, options) {
|
|
28
|
-
dir1 = (0, prepare_1.normalizeDir)(dir1);
|
|
29
|
-
dir2 = (0, prepare_1.normalizeDir)(dir2);
|
|
30
|
-
// Get all files
|
|
31
|
-
const files1 = await (0, scan_1.scanDirectory)(dir1);
|
|
32
|
-
const files2 = await (0, scan_1.scanDirectory)(dir2);
|
|
33
|
-
if (files1.length !== files2.length) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
// Options
|
|
37
|
-
options = options || {};
|
|
38
|
-
const ignoreNewLine = options.ignoreNewLine !== false;
|
|
39
|
-
const ignoreVersions = options.ignoreVersions !== false;
|
|
40
|
-
const textExtensions = new Set((options.textExtensions || []).concat(textFileExtensions));
|
|
41
|
-
// Check all files
|
|
42
|
-
for (let i = 0; i < files1.length; i++) {
|
|
43
|
-
const file = files1[i];
|
|
44
|
-
if (files2.indexOf(file) === -1) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
const ext = file.split('.').pop().toLowerCase();
|
|
48
|
-
const isText = textExtensions.has(ext);
|
|
49
|
-
if (!isText) {
|
|
50
|
-
// Compare binary files
|
|
51
|
-
const content1 = await fs_1.promises.readFile(dir1 + '/' + file);
|
|
52
|
-
const content2 = await fs_1.promises.readFile(dir2 + '/' + file);
|
|
53
|
-
if (Buffer.compare(content1, content2) !== 0) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
// Text files
|
|
59
|
-
let content1 = await fs_1.promises.readFile(dir1 + '/' + file, 'utf8');
|
|
60
|
-
let content2 = await fs_1.promises.readFile(dir2 + '/' + file, 'utf8');
|
|
61
|
-
if (content1 === content2) {
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if (ignoreNewLine) {
|
|
65
|
-
// Remove space before new line (\r\n -> \n), remove new line at the end
|
|
66
|
-
content1 = content1.replace(/\s+\n/g, '\n').trimRight();
|
|
67
|
-
content2 = content2.replace(/\s+\n/g, '\n').trimRight();
|
|
68
|
-
}
|
|
69
|
-
if (ignoreVersions && file.split('/').pop() === 'package.json') {
|
|
70
|
-
// Ignore versions in package.json
|
|
71
|
-
const data1 = JSON.parse(content1);
|
|
72
|
-
const data2 = JSON.parse(content2);
|
|
73
|
-
delete data1.version;
|
|
74
|
-
delete data2.version;
|
|
75
|
-
content1 = JSON.stringify(data1);
|
|
76
|
-
content2 = JSON.stringify(data2);
|
|
77
|
-
}
|
|
78
|
-
if (content1 !== content2) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
exports.compareDirectories = compareDirectories;
|
package/lib/misc/exec.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.execAsync = void 0;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
/**
|
|
6
|
-
* Exec as Promise
|
|
7
|
-
*/
|
|
8
|
-
function execAsync(cmd, options) {
|
|
9
|
-
return new Promise((fulfill, reject) => {
|
|
10
|
-
(0, child_process_1.exec)(cmd, {
|
|
11
|
-
...options,
|
|
12
|
-
encoding: 'utf8',
|
|
13
|
-
}, (error, stdout, stderr) => {
|
|
14
|
-
if (error) {
|
|
15
|
-
reject(error);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
fulfill({
|
|
19
|
-
stdout,
|
|
20
|
-
stderr,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
exports.execAsync = execAsync;
|
package/lib/misc/keyword.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cleanupIconKeyword = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Clean up keyword
|
|
6
|
-
*/
|
|
7
|
-
function cleanupIconKeyword(keyword, convertCamelCase = false) {
|
|
8
|
-
// Convert camelCase to dash-case
|
|
9
|
-
if (convertCamelCase) {
|
|
10
|
-
keyword = keyword.replace(/[A-Z]+/g, (chars) => '_' + chars.toLowerCase());
|
|
11
|
-
}
|
|
12
|
-
// Replace stuff
|
|
13
|
-
keyword = keyword
|
|
14
|
-
.toLowerCase()
|
|
15
|
-
.trim()
|
|
16
|
-
// Replace few characters with dash
|
|
17
|
-
.replace(/[_.:]/g, '-')
|
|
18
|
-
// Remove bad characters
|
|
19
|
-
.replace(/[^a-z0-9-]/g, '')
|
|
20
|
-
// Replace repeating dash
|
|
21
|
-
.replace(/[-]+/g, '-');
|
|
22
|
-
// Remove '-' at start and end
|
|
23
|
-
if (keyword.slice(0, 1) === '-') {
|
|
24
|
-
keyword = keyword.slice(1);
|
|
25
|
-
}
|
|
26
|
-
if (keyword.slice(-1) === '-') {
|
|
27
|
-
keyword = keyword.slice(0, -1);
|
|
28
|
-
}
|
|
29
|
-
return keyword;
|
|
30
|
-
}
|
|
31
|
-
exports.cleanupIconKeyword = cleanupIconKeyword;
|
package/lib/misc/scan.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.scanDirectory = void 0;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
async function scanDirectory(path, callback, subdirs = true) {
|
|
6
|
-
const results = [];
|
|
7
|
-
if (path.length && path.slice(-1) !== '/') {
|
|
8
|
-
path += '/';
|
|
9
|
-
}
|
|
10
|
-
async function scan(subdir) {
|
|
11
|
-
const files = await fs_1.promises.readdir(path + subdir);
|
|
12
|
-
for (let i = 0; i < files.length; i++) {
|
|
13
|
-
const filename = files[i];
|
|
14
|
-
if (filename.slice(0, 1) === '.') {
|
|
15
|
-
// Exclude hidden items
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
const stat = await fs_1.promises.stat(path + subdir + filename);
|
|
19
|
-
if (stat.isDirectory()) {
|
|
20
|
-
if (subdirs) {
|
|
21
|
-
await scan(subdir + filename + '/');
|
|
22
|
-
}
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
if (!stat.isFile()) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
const parts = filename.split('.');
|
|
29
|
-
const ext = parts.length > 1 ? '.' + parts.pop() : '';
|
|
30
|
-
const file = parts.join('.');
|
|
31
|
-
// Callback
|
|
32
|
-
let callbackResult;
|
|
33
|
-
if (callback) {
|
|
34
|
-
callbackResult = callback(ext, file, subdir, path, stat);
|
|
35
|
-
if (callbackResult instanceof Promise) {
|
|
36
|
-
callbackResult = await callbackResult;
|
|
37
|
-
}
|
|
38
|
-
if (callbackResult === void 0 ||
|
|
39
|
-
callbackResult === false ||
|
|
40
|
-
callbackResult === null) {
|
|
41
|
-
// Skip file
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
callbackResult = true;
|
|
47
|
-
}
|
|
48
|
-
// Add item
|
|
49
|
-
results.push(callbackResult === true ? subdir + filename : callbackResult);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
await scan('');
|
|
53
|
-
return results;
|
|
54
|
-
}
|
|
55
|
-
exports.scanDirectory = scanDirectory;
|
package/lib/misc/write-json.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.writeJSONFile = void 0;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
/**
|
|
6
|
-
* Write JSON file
|
|
7
|
-
*/
|
|
8
|
-
async function writeJSONFile(filename, data) {
|
|
9
|
-
return fs_1.promises.writeFile(filename, JSON.stringify(data, null, '\t') + '\n');
|
|
10
|
-
}
|
|
11
|
-
exports.writeJSONFile = writeJSONFile;
|
package/lib/optimise/flags.js
DELETED
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deOptimisePaths = void 0;
|
|
4
|
-
const parse_1 = require("../svg/parse");
|
|
5
|
-
/**
|
|
6
|
-
* Command constants
|
|
7
|
-
*/
|
|
8
|
-
const CLOSE_PATH = 1;
|
|
9
|
-
const MOVE_TO = 2;
|
|
10
|
-
const HORIZ_LINE_TO = 4;
|
|
11
|
-
const VERT_LINE_TO = 8;
|
|
12
|
-
const LINE_TO = 16;
|
|
13
|
-
const CURVE_TO = 32;
|
|
14
|
-
const SMOOTH_CURVE_TO = 64;
|
|
15
|
-
const QUAD_TO = 128;
|
|
16
|
-
const SMOOTH_QUAD_TO = 256;
|
|
17
|
-
const ARC = 512;
|
|
18
|
-
/**
|
|
19
|
-
* Number of arguments for each command
|
|
20
|
-
*/
|
|
21
|
-
const argCount = {
|
|
22
|
-
[MOVE_TO]: 2,
|
|
23
|
-
[LINE_TO]: 2,
|
|
24
|
-
[HORIZ_LINE_TO]: 1,
|
|
25
|
-
[VERT_LINE_TO]: 1,
|
|
26
|
-
[CLOSE_PATH]: 0,
|
|
27
|
-
[QUAD_TO]: 4,
|
|
28
|
-
[SMOOTH_QUAD_TO]: 2,
|
|
29
|
-
[CURVE_TO]: 6,
|
|
30
|
-
[SMOOTH_CURVE_TO]: 4,
|
|
31
|
-
[ARC]: 7,
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Check if character is a digit
|
|
35
|
-
*/
|
|
36
|
-
const isDigit = (num) => num >= 48 && num <= 57;
|
|
37
|
-
/**
|
|
38
|
-
* Check if character is white space
|
|
39
|
-
*/
|
|
40
|
-
const isWhiteSpace = (num) => num === 32 || num === 9 || num === 13 || num === 10;
|
|
41
|
-
/**
|
|
42
|
-
* Clean up path
|
|
43
|
-
*
|
|
44
|
-
* @param {string} path
|
|
45
|
-
* @return {string}
|
|
46
|
-
*/
|
|
47
|
-
function cleanPath(path) {
|
|
48
|
-
const commands = [];
|
|
49
|
-
const length = path.length;
|
|
50
|
-
let currentNumber = '';
|
|
51
|
-
let currentNumberHasExp = false;
|
|
52
|
-
let currentNumberHasExpDigits = false;
|
|
53
|
-
let currentNumberHasDecimal = false;
|
|
54
|
-
let canParseCommandOrComma = true;
|
|
55
|
-
let currentCommand = null;
|
|
56
|
-
let currentCommandType = null;
|
|
57
|
-
let currentArgs = [];
|
|
58
|
-
let i = 0;
|
|
59
|
-
const finishCommand = () => {
|
|
60
|
-
if (currentCommand !== null) {
|
|
61
|
-
commands.push({
|
|
62
|
-
command: currentCommand,
|
|
63
|
-
params: currentArgs.slice(0),
|
|
64
|
-
});
|
|
65
|
-
currentArgs = [];
|
|
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
|
-
}
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
const parseNumber = () => {
|
|
79
|
-
// Number ended - validate it
|
|
80
|
-
if (currentNumber !== '' && currentCommandType) {
|
|
81
|
-
let value = Number(currentNumber);
|
|
82
|
-
if (isNaN(value)) {
|
|
83
|
-
throw new Error('Invalid number "' + currentNumber + '" at ' + i);
|
|
84
|
-
}
|
|
85
|
-
// Validate arc arguments
|
|
86
|
-
if (currentCommandType === ARC) {
|
|
87
|
-
if (currentArgs.length < 2 && value <= 0) {
|
|
88
|
-
throw new Error('Expected positive number, got "' + value + '" at ' + i);
|
|
89
|
-
}
|
|
90
|
-
// eslint-disable-next-line no-constant-condition
|
|
91
|
-
while (true) {
|
|
92
|
-
// Not flag
|
|
93
|
-
if (currentArgs.length < 3 || currentArgs.length > 4) {
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
// Valid flag
|
|
97
|
-
if (currentNumber === '0' || currentNumber === '1') {
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
// Unpack flag
|
|
101
|
-
const slice = currentNumber.slice(0, 1);
|
|
102
|
-
const newNumber = currentNumber.slice(1);
|
|
103
|
-
const newValue = Number(newNumber);
|
|
104
|
-
if (slice === '0' || slice === '1') {
|
|
105
|
-
// Valid flag
|
|
106
|
-
if (isNaN(newValue)) {
|
|
107
|
-
throw new Error('Invalid number "' + currentNumber + '" at ' + i);
|
|
108
|
-
}
|
|
109
|
-
currentArgs.push(slice);
|
|
110
|
-
currentNumber = newNumber;
|
|
111
|
-
value = newValue;
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
throw new Error('Expected a flag, got "' + currentNumber + '" at ' + i);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
// Add current number to arguments list
|
|
118
|
-
currentArgs.push(currentNumber);
|
|
119
|
-
if (currentArgs.length === argCount[currentCommandType]) {
|
|
120
|
-
finishCommand();
|
|
121
|
-
}
|
|
122
|
-
currentNumber = '';
|
|
123
|
-
currentNumberHasExpDigits = false;
|
|
124
|
-
currentNumberHasExp = false;
|
|
125
|
-
currentNumberHasDecimal = false;
|
|
126
|
-
canParseCommandOrComma = true;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
for (i = 0; i < length; i++) {
|
|
130
|
-
const char = path[i];
|
|
131
|
-
const num = char.charCodeAt(0);
|
|
132
|
-
// Test for number
|
|
133
|
-
if (isDigit(num)) {
|
|
134
|
-
currentNumber += char;
|
|
135
|
-
currentNumberHasExpDigits = currentNumberHasExp;
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
// Test for exponential number
|
|
139
|
-
if (char === 'e' || char === 'E') {
|
|
140
|
-
currentNumber += char;
|
|
141
|
-
currentNumberHasExp = true;
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
// Test for number signs
|
|
145
|
-
if ((char === '-' || char === '+') &&
|
|
146
|
-
currentNumberHasExp &&
|
|
147
|
-
!currentNumberHasExpDigits) {
|
|
148
|
-
currentNumber += char;
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
// Decimal point
|
|
152
|
-
if (char === '.' && !currentNumberHasExp && !currentNumberHasDecimal) {
|
|
153
|
-
currentNumber += char;
|
|
154
|
-
currentNumberHasDecimal = true;
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
// Number ended - validate it
|
|
158
|
-
parseNumber();
|
|
159
|
-
// White space
|
|
160
|
-
if (isWhiteSpace(num)) {
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
// Only one comma per command
|
|
164
|
-
if (canParseCommandOrComma && char === ',') {
|
|
165
|
-
canParseCommandOrComma = false;
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
// New number
|
|
169
|
-
if (char === '+' || char === '-' || char === '.') {
|
|
170
|
-
currentNumber = char;
|
|
171
|
-
currentNumberHasDecimal = char === '.';
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
// Expecting new command, so argument should be empty
|
|
175
|
-
if (currentArgs.length > 0) {
|
|
176
|
-
throw new Error('Unexpected command at ' + i);
|
|
177
|
-
}
|
|
178
|
-
// Test comma, reset value
|
|
179
|
-
if (!canParseCommandOrComma) {
|
|
180
|
-
throw new Error('Command cannot follow comma at ' + i + '');
|
|
181
|
-
}
|
|
182
|
-
canParseCommandOrComma = false;
|
|
183
|
-
// Detect next command
|
|
184
|
-
currentCommand = char;
|
|
185
|
-
switch (char) {
|
|
186
|
-
case 'z':
|
|
187
|
-
case 'Z':
|
|
188
|
-
// Close path
|
|
189
|
-
commands.push({
|
|
190
|
-
command: char,
|
|
191
|
-
params: [],
|
|
192
|
-
});
|
|
193
|
-
canParseCommandOrComma = true;
|
|
194
|
-
currentCommandType = null;
|
|
195
|
-
currentCommand = null;
|
|
196
|
-
break;
|
|
197
|
-
case 'h':
|
|
198
|
-
case 'H':
|
|
199
|
-
// Horizontal move
|
|
200
|
-
currentCommandType = HORIZ_LINE_TO;
|
|
201
|
-
break;
|
|
202
|
-
case 'v':
|
|
203
|
-
case 'V':
|
|
204
|
-
// Vertical move
|
|
205
|
-
currentCommandType = VERT_LINE_TO;
|
|
206
|
-
break;
|
|
207
|
-
case 'm':
|
|
208
|
-
case 'M':
|
|
209
|
-
// Move to
|
|
210
|
-
currentCommandType = MOVE_TO;
|
|
211
|
-
break;
|
|
212
|
-
case 'l':
|
|
213
|
-
case 'L':
|
|
214
|
-
// Line to
|
|
215
|
-
currentCommandType = LINE_TO;
|
|
216
|
-
break;
|
|
217
|
-
case 'c':
|
|
218
|
-
case 'C':
|
|
219
|
-
// Curve
|
|
220
|
-
currentCommandType = CURVE_TO;
|
|
221
|
-
break;
|
|
222
|
-
case 's':
|
|
223
|
-
case 'S':
|
|
224
|
-
// Smooth curve
|
|
225
|
-
currentCommandType = SMOOTH_CURVE_TO;
|
|
226
|
-
break;
|
|
227
|
-
case 'q':
|
|
228
|
-
case 'Q':
|
|
229
|
-
// Quadratic bezier curve
|
|
230
|
-
currentCommandType = QUAD_TO;
|
|
231
|
-
break;
|
|
232
|
-
case 't':
|
|
233
|
-
case 'T':
|
|
234
|
-
// Smooth quadratic bezier curve
|
|
235
|
-
currentCommandType = SMOOTH_QUAD_TO;
|
|
236
|
-
break;
|
|
237
|
-
case 'a':
|
|
238
|
-
case 'A':
|
|
239
|
-
// Elliptic arc
|
|
240
|
-
currentCommandType = ARC;
|
|
241
|
-
break;
|
|
242
|
-
default:
|
|
243
|
-
throw new Error('Unexpected character "' + char + '" at ' + i);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
// Parse last number
|
|
247
|
-
parseNumber();
|
|
248
|
-
// Add last command
|
|
249
|
-
if (currentArgs.length) {
|
|
250
|
-
if (!currentCommandType) {
|
|
251
|
-
throw new Error('Empty path');
|
|
252
|
-
}
|
|
253
|
-
if (currentArgs.length !== argCount[currentCommandType]) {
|
|
254
|
-
throw new Error('Unexpected end of path at ' + i);
|
|
255
|
-
}
|
|
256
|
-
finishCommand();
|
|
257
|
-
}
|
|
258
|
-
// Build path
|
|
259
|
-
let output = '';
|
|
260
|
-
commands.forEach((item) => {
|
|
261
|
-
output += item.command;
|
|
262
|
-
item.params.forEach((value, index) => {
|
|
263
|
-
if (index > 0) {
|
|
264
|
-
const char = value[0];
|
|
265
|
-
// noinspection FallThroughInSwitchStatementJS
|
|
266
|
-
switch (char) {
|
|
267
|
-
case '-':
|
|
268
|
-
case '+':
|
|
269
|
-
// Number - no space
|
|
270
|
-
break;
|
|
271
|
-
case '.':
|
|
272
|
-
// Dot - no space if previous entry was command
|
|
273
|
-
if (index < 1) {
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
// No space if previous entry had dot
|
|
277
|
-
if (item.params[index - 1].indexOf('.') !== -1) {
|
|
278
|
-
break;
|
|
279
|
-
}
|
|
280
|
-
// no-fallthrough
|
|
281
|
-
default:
|
|
282
|
-
output += ' ';
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
output += value;
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
return output;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* De-optimise paths. Compressed paths are still not supported by some software.
|
|
292
|
-
*/
|
|
293
|
-
async function deOptimisePaths(svg) {
|
|
294
|
-
await (0, parse_1.parseSVG)(svg, (item) => {
|
|
295
|
-
if (item.tagName !== 'path') {
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
const d = item.element.attribs.d;
|
|
299
|
-
if (typeof d === 'string') {
|
|
300
|
-
try {
|
|
301
|
-
const optimised = cleanPath(d);
|
|
302
|
-
if (optimised !== d) {
|
|
303
|
-
item.$element.attr('d', optimised);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
catch (err) {
|
|
307
|
-
//
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
exports.deOptimisePaths = deOptimisePaths;
|