oslllo-svg-fixer 1.4.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -1
- package/README.md +2 -0
- package/package.json +11 -12
- package/scripts/debug.js +7 -0
- package/src/cli.js +8 -1
- package/src/option.js +1 -0
- package/src/processor.js +2 -1
- package/src/progress.js +1 -1
- package/src/svg.js +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,38 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## [2.1.0](https://www.github.com/oslllo/svg-fixer/compare/v2.0.1...v2.1.1) (2022-03-8)
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- add configurable trace resolution ([#72](https://github.com/oslllo/svg-fixer/pull/72))
|
|
13
|
+
|
|
14
|
+
### Updated
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
18
|
+
## [2.0.1](https://www.github.com/oslllo/svg-fixer/compare/v2.0.0...v2.0.1) (2022-01-21)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Refactor
|
|
22
|
+
|
|
23
|
+
- improve perfomance ([3b310aa](https://github.com/oslllo/svg-fixer/commit/3b310aaf3bf39f47b0bb56a722f03d40ad6a1b31))
|
|
24
|
+
|
|
25
|
+
## [2.0.0](https://www.github.com/oslllo/svg-fixer/compare/v1.4.1...v2.0.0) (2022-01-12)
|
|
26
|
+
|
|
27
|
+
This version did not break the api so upgrading from `v1.0.0` without any changes should be fine. The reason for the major version change is just in case something did break.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- Removed `Canvas & JSDOM` to fix very slow `npm install` cycles.
|
|
32
|
+
- Switched from `Canvas` to `svg2png-wasm`.
|
|
33
|
+
|
|
34
|
+
### Updated
|
|
35
|
+
|
|
36
|
+
- Updated dependencies
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## [1.4.1](https://www.github.com/oslllo/svg-fixer/compare/v1.4.0...v1.4.1) (2021-09-05)
|
|
9
40
|
|
|
10
41
|
|
|
11
42
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/oslllo-svg-fixer)
|
|
7
7
|
[](https://coveralls.io/github/oslllo/svg-fixer)
|
|
8
8
|
|
|
9
|
+
🎉 v2.0.0 Removed `Canvas & JSDOM` no more slow `npm install` cycles.
|
|
10
|
+
|
|
9
11
|
Attempts to fix your svg by turning it into a fill / single path (and making it font compatible as a bonus).
|
|
10
12
|
|
|
11
13
|
## Convert SVG Strokes To Fills
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oslllo-svg-fixer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Converts SVG Strokes To Fill.",
|
|
5
5
|
"bin": "src/cli.js",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -42,24 +42,23 @@
|
|
|
42
42
|
},
|
|
43
43
|
"homepage": "https://docs.oslllo.com/svg-fixer/master",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"fast-glob": "^3.2.
|
|
48
|
-
"oslllo-potrace": "^
|
|
49
|
-
"oslllo-svg2": "^0.
|
|
50
|
-
"oslllo-validator": "^
|
|
45
|
+
"ansi-colors": "^4.1.1",
|
|
46
|
+
"cli-progress": "^3.10.0",
|
|
47
|
+
"fast-glob": "^3.2.11",
|
|
48
|
+
"oslllo-potrace": "^2.0.0",
|
|
49
|
+
"oslllo-svg2": "^2.0.0",
|
|
50
|
+
"oslllo-validator": "^3.0.0",
|
|
51
51
|
"yargs": "^16.2.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"
|
|
55
|
-
"chai": "^4.3.4",
|
|
54
|
+
"chai": "^4.3.6",
|
|
56
55
|
"chai-as-promised": "^7.1.1",
|
|
57
56
|
"coveralls": "^3.1.1",
|
|
58
57
|
"eslint": "^7.32.0",
|
|
59
|
-
"fs-extra": "^10.0.
|
|
60
|
-
"inquirer": "^8.
|
|
58
|
+
"fs-extra": "^10.0.1",
|
|
59
|
+
"inquirer": "^8.2.0",
|
|
61
60
|
"looks-same": "^7.3.0",
|
|
62
|
-
"mocha": "^
|
|
61
|
+
"mocha": "^9.2.1",
|
|
63
62
|
"mocha-lcov-reporter": "^1.3.0",
|
|
64
63
|
"nyc": "^15.1.0",
|
|
65
64
|
"stopwatch-node": "^1.1.0"
|
package/scripts/debug.js
CHANGED
|
@@ -54,6 +54,12 @@ var questions = [
|
|
|
54
54
|
message: "Throw if destination does not exist?",
|
|
55
55
|
default: "Y",
|
|
56
56
|
},
|
|
57
|
+
{
|
|
58
|
+
type: "input",
|
|
59
|
+
name: "traceResolution",
|
|
60
|
+
message: "Enter the resolution of the trace image",
|
|
61
|
+
default: 600,
|
|
62
|
+
},
|
|
57
63
|
];
|
|
58
64
|
|
|
59
65
|
inquirer.prompt(questions).then(async (answers) => {
|
|
@@ -68,6 +74,7 @@ inquirer.prompt(questions).then(async (answers) => {
|
|
|
68
74
|
var options = {
|
|
69
75
|
showProgressBar: answers.showProgressBar,
|
|
70
76
|
throwIfDestinationDoesNotExist: answers.throwIfDestinationDoesNotExist,
|
|
77
|
+
traceResolution: answers.traceResolution,
|
|
71
78
|
};
|
|
72
79
|
var stopwatch;
|
|
73
80
|
fs.emptyDirSync(destination);
|
package/src/cli.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"use strict";
|
|
4
4
|
|
|
5
5
|
const SVGFixer = require("../");
|
|
6
|
-
const colors = require("colors");
|
|
6
|
+
const colors = require("ansi-colors");
|
|
7
7
|
var argvs = require("yargs/yargs")(process.argv.slice(2)); // eslint-disable-line no-magic-numbers
|
|
8
8
|
|
|
9
9
|
argvs
|
|
@@ -32,6 +32,12 @@ argvs
|
|
|
32
32
|
default: true,
|
|
33
33
|
type: "boolean",
|
|
34
34
|
})
|
|
35
|
+
.option("trace-resolution", {
|
|
36
|
+
alias: "tr",
|
|
37
|
+
describe: "resolution of trace image: larger == higher quality and slower processing",
|
|
38
|
+
default: 600,
|
|
39
|
+
type: "number",
|
|
40
|
+
})
|
|
35
41
|
.help();
|
|
36
42
|
|
|
37
43
|
argvs = argvs.argv;
|
|
@@ -41,6 +47,7 @@ const destination = argvs["destination"]; // eslint-disable-line dot-notation
|
|
|
41
47
|
const options = {
|
|
42
48
|
showProgressBar: argvs["show-progress"],
|
|
43
49
|
throwIfDestinationDoesNotExist: argvs["strict-destination"],
|
|
50
|
+
traceResolution: argvs["trace-resolution"],
|
|
44
51
|
};
|
|
45
52
|
|
|
46
53
|
(async () => {
|
package/src/option.js
CHANGED
package/src/processor.js
CHANGED
|
@@ -71,7 +71,8 @@ Processor.prototype = {
|
|
|
71
71
|
instance: function ({ source, destination }) {
|
|
72
72
|
return new Promise(async (resolve, reject) => {
|
|
73
73
|
try {
|
|
74
|
-
var
|
|
74
|
+
var resolution = this.fixer.options.get("traceResolution");
|
|
75
|
+
var svg = new Svg(source, resolution);
|
|
75
76
|
var fixed = await svg.process();
|
|
76
77
|
fs.writeFileSync(destination, fixed);
|
|
77
78
|
this.tick(() => resolve());
|
package/src/progress.js
CHANGED
package/src/svg.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
const Svg2 = require("oslllo-svg2");
|
|
4
4
|
const Potrace = require("oslllo-potrace");
|
|
5
5
|
|
|
6
|
-
const Svg = function (path) {
|
|
6
|
+
const Svg = function (path, traceResolution) {
|
|
7
7
|
this.filled = false;
|
|
8
8
|
this.path = path;
|
|
9
|
+
this.traceResolution = traceResolution;
|
|
9
10
|
this.png = new Object();
|
|
10
11
|
this.resized = new Object();
|
|
11
12
|
this.svg2 = Svg2(this.path);
|
|
@@ -25,13 +26,12 @@ Svg.prototype = {
|
|
|
25
26
|
return { element, svg2, dimensions };
|
|
26
27
|
},
|
|
27
28
|
getResizeDimensions() {
|
|
28
|
-
const width =
|
|
29
|
-
|
|
29
|
+
const width = this.traceResolution;
|
|
30
|
+
|
|
31
|
+
return {
|
|
30
32
|
width: width,
|
|
31
33
|
height: (width / this.original.dimensions.width) * this.original.dimensions.height,
|
|
32
34
|
};
|
|
33
|
-
|
|
34
|
-
return dimensions;
|
|
35
35
|
},
|
|
36
36
|
getOriginal: function () {
|
|
37
37
|
var element = this.element.cloneNode(true);
|
|
@@ -51,7 +51,7 @@ Svg.prototype = {
|
|
|
51
51
|
/**
|
|
52
52
|
* Ignore <path></path> "d" attribute.
|
|
53
53
|
*/
|
|
54
|
-
if (attribute.name !== "d") {
|
|
54
|
+
if (attribute && attribute.name && attribute.name !== "d") {
|
|
55
55
|
return { name: attribute.name, value: attribute.value };
|
|
56
56
|
}
|
|
57
57
|
|