oslllo-svg-fixer 2.0.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 CHANGED
@@ -5,7 +5,17 @@ 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
- ### [2.0.1](https://www.github.com/oslllo/svg-fixer/compare/v2.0.0...v2.0.1) (2022-01-21)
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)
9
19
 
10
20
 
11
21
  ### Refactor
@@ -14,7 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
24
 
15
25
  ## [2.0.0](https://www.github.com/oslllo/svg-fixer/compare/v1.4.1...v2.0.0) (2022-01-12)
16
26
 
17
- This version did not break the api so upgrading from `< v0.3.1` without any changes should be fine. The reason for the major version change is just in case something did break.
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.
18
28
 
19
29
  ### Changed
20
30
 
@@ -26,7 +36,7 @@ This version did not break the api so upgrading from `< v0.3.1` without any chan
26
36
  - Updated dependencies
27
37
 
28
38
 
29
- ### [1.4.1](https://www.github.com/oslllo/svg-fixer/compare/v1.4.0...v1.4.1) (2021-09-05)
39
+ ## [1.4.1](https://www.github.com/oslllo/svg-fixer/compare/v1.4.0...v1.4.1) (2021-09-05)
30
40
 
31
41
 
32
42
  ### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oslllo-svg-fixer",
3
- "version": "2.0.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",
@@ -44,24 +44,23 @@
44
44
  "dependencies": {
45
45
  "ansi-colors": "^4.1.1",
46
46
  "cli-progress": "^3.10.0",
47
- "fast-glob": "^3.2.10",
47
+ "fast-glob": "^3.2.11",
48
48
  "oslllo-potrace": "^2.0.0",
49
49
  "oslllo-svg2": "^2.0.0",
50
50
  "oslllo-validator": "^3.0.0",
51
51
  "yargs": "^16.2.0"
52
52
  },
53
53
  "devDependencies": {
54
- "capture-console": "^1.0.1",
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.0",
58
+ "fs-extra": "^10.0.1",
60
59
  "inquirer": "^8.2.0",
61
60
  "looks-same": "^7.3.0",
62
- "mocha": "^9.1.3",
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"
66
65
  }
67
- }
66
+ }
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
@@ -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
@@ -7,6 +7,7 @@ const Option = function (options) {
7
7
  this.data = {
8
8
  showProgressBar: false,
9
9
  throwIfDestinationDoesNotExist: true,
10
+ traceResolution: 600,
10
11
  };
11
12
  if (!is.object(options)) {
12
13
  throw error.invalidParameterError("options", "object", options);
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 svg = new Svg(source);
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/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 = 600;
29
- const dimensions = {
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);