oslllo-svg-fixer 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oslllo-svg-fixer",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "Converts SVG Strokes To Fill.",
5
5
  "bin": "src/cli.js",
6
6
  "main": "src/index.js",
@@ -43,23 +43,22 @@
43
43
  "homepage": "https://docs.oslllo.com/svg-fixer/master",
44
44
  "dependencies": {
45
45
  "ansi-colors": "^4.1.1",
46
- "cli-progress": "^3.10.0",
47
- "fast-glob": "^3.2.10",
46
+ "cli-progress": "^3.11.0",
47
+ "fast-glob": "^3.2.11",
48
48
  "oslllo-potrace": "^2.0.0",
49
- "oslllo-svg2": "^1.0.0",
49
+ "oslllo-svg2": "^2.0.1",
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",
60
- "inquirer": "^8.2.0",
58
+ "fs-extra": "^10.1.0",
59
+ "inquirer": "^8.2.4",
61
60
  "looks-same": "^7.3.0",
62
- "mocha": "^9.1.3",
61
+ "mocha": "^9.2.2",
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
@@ -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);
package/CHANGELOG.md DELETED
@@ -1,305 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [2.0.0](https://www.github.com/oslllo/svg-fixer/compare/v1.4.1...v2.0.0) (2022-01-12)
9
-
10
-
11
- ### Bug Fixes
12
-
13
- * **security:** audit fix ([6047ad8](https://www.github.com/oslllo/svg-fixer/commit/6047ad88645d9f4cb251ca9bac04f278c902aa85))
14
-
15
-
16
- ### Miscellaneous Chores
17
-
18
- * release 2.0.0 ([7abe789](https://www.github.com/oslllo/svg-fixer/commit/7abe789afc9ba6ff04c4f32a284561cf497f0c48))
19
-
20
- ### [1.4.1](https://www.github.com/oslllo/svg-fixer/compare/v1.4.0...v1.4.1) (2021-09-05)
21
-
22
-
23
- ### Bug Fixes
24
-
25
- * vulnerabilities ([99621c6](https://www.github.com/oslllo/svg-fixer/commit/99621c6258e52836f0aaaf9876fe4b4859c81ab6))
26
-
27
- ## [1.4.0](https://www.github.com/oslllo/svg-fixer/compare/v1.3.2...v1.4.0) (2021-07-14)
28
-
29
-
30
- ### Features
31
-
32
- * add support for svgs with "ex", "ch", "cm", "mm", "q", "in", "pc", "pt" ([4d2c18e](https://www.github.com/oslllo/svg-fixer/commit/4d2c18ef496b9ce08cbc917e3fbb91d9f352c6ff))
33
- * add support for svgs with fill color in path style attribute ([1aeb079](https://www.github.com/oslllo/svg-fixer/commit/1aeb0794e9693079c79981616ea00e99379c863f))
34
- * support svgs without a set viewBox attribute ([17b876c](https://www.github.com/oslllo/svg-fixer/commit/17b876ce49ed0a047dedb098d47adcccb22ff0cf))
35
-
36
- ### [1.3.2](https://www.github.com/oslllo/svg-fixer/compare/v1.3.1...v1.3.2) (2021-06-26)
37
-
38
-
39
- ### Bug Fixes
40
-
41
- * security vulnerabilities ([372730b](https://www.github.com/oslllo/svg-fixer/commit/372730bef6cf761877961796635fc406a2ecc776))
42
-
43
- ### [1.3.1](https://www.github.com/oslllo/svg-fixer/compare/v1.3.0...v1.3.1) (2021-05-27)
44
-
45
-
46
- ### Bug Fixes
47
-
48
- * output svg being smaller than viewBox ([#48](https://www.github.com/oslllo/svg-fixer/issues/48)) ([f658614](https://www.github.com/oslllo/svg-fixer/commit/f65861448802b9b7c6cd6c889207b5f1a7c66592))
49
-
50
- ## [1.3.0](https://www.github.com/oslllo/svg-fixer/compare/v1.2.1...v1.3.0) (2021-05-15)
51
-
52
-
53
- ### Features
54
-
55
- * add support for svgs with light colored fill ([#45](https://www.github.com/oslllo/svg-fixer/issues/45)) ([47aa95d](https://www.github.com/oslllo/svg-fixer/commit/47aa95da9e7054b84f3b2d36528784c5dbe6663d))
56
-
57
-
58
- ### Bug Fixes
59
-
60
- * **eslint:** script error ([d34780e](https://www.github.com/oslllo/svg-fixer/commit/d34780e1db64d350695f5be7c4713136f9c66331))
61
-
62
- ### [1.2.1](https://www.github.com/oslllo/svg-fixer/compare/v1.2.0...v1.2.1) (2021-05-06)
63
-
64
-
65
- ### Bug Fixes
66
-
67
- * drop yargs version to 16 ([7b4d9cc](https://www.github.com/oslllo/svg-fixer/commit/7b4d9ccb563027b24aefe59d394848b8937067b9))
68
- * package breaking when process.env.NODE_ENV env variable is set ([51c6318](https://www.github.com/oslllo/svg-fixer/commit/51c6318340b97d6840ab7d2c499c77aff27b6f10))
69
-
70
- ## [1.2.0] - 2021/4/1
71
-
72
- ### Fixed
73
-
74
- - Fixed bug in test.
75
-
76
- ### Updated
77
-
78
- - Updated dependencies.
79
-
80
- ## [1.1.2] - 2020/12/12
81
-
82
- ### Fixed
83
-
84
- - Fixed vulnerability.
85
-
86
- ### Updated
87
-
88
- - Updated dependencies.
89
-
90
- ## [1.1.1] - 2020/10/22
91
-
92
- ### Fixed
93
-
94
- - Fixed large npm package.
95
-
96
- ## [1.1.0] - 2020/10/22
97
-
98
- ### Fixed
99
-
100
- - Fixed bug that allowed you to update `options` that do not exist.
101
-
102
- ### Added
103
-
104
- - Added `CLI` functionality.
105
- - Added `callback` functionality to `SVGFixer.fix()`.
106
-
107
- ### Changed
108
-
109
- - Refactored `tests`.
110
- - Refactored `progress bar`.
111
-
112
- ## [1.0.2] - 2020/10/2
113
-
114
- ### Fixed
115
-
116
- - Fixed not being able to process SVGs with `%` dimensions.
117
-
118
- ### Added
119
-
120
- - SVG attribute tests.
121
-
122
- ## [1.0.1] - 2020/9/16
123
-
124
- ### Changed
125
-
126
- - Remove tests from npm `package` to help reduce unpacked `package` size.
127
-
128
- ## [1.0.0] - 2020/9/16
129
-
130
- ⚠️ Contains breaking changes.
131
-
132
- ### Breaking Changes
133
-
134
- - `svgfixer.fix(source, destination, options)` ***=>*** `SVGFixer(source, destination, options).fix()`.
135
- - It was changed from a wrapper function to a method function for `SVGFixer`.
136
- - It still returns a `Promise`.
137
- - `fix()` no more takes in `parameters`, those should be passed into `SVGFixer()`.
138
- - `svgfixer.SVGFixer()` class ***=>*** `SVGFixer()`.
139
- - The `.setOptions(options)` method has been removed, `options` should now be passed in class constructor as the 3rd `parameter`.
140
- - The `.setSourceAndDest()` method has been removed, `source` and `destination` should now be passed in class constructor as the 1st and 2nd `parameters`.
141
- - The `.process()` method has been removed, use `.fix()` instead.
142
- - `SVGFixer()` does not require the [`new`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new) operator anymore.
143
- - `fixConcurrency` has been removed, might be reimplemented on later versions.
144
-
145
- ### Changed
146
-
147
- - Updated dependencies.
148
- - Refactored codebase.
149
- - Refactored progressbar.
150
-
151
- ## [0.6.0] - 2020/8/13
152
-
153
- ### Security
154
-
155
- - Updated dependencies. Fixes [Vulnerability](https://npmjs.com/advisories/1548)
156
-
157
- ### Changed
158
-
159
- - Updated image processor.
160
- - Updated `CHANGELOG.md` wording and formatting.
161
-
162
- ## [0.5.1] - 2020/7/7
163
-
164
- ### Changed
165
-
166
- - Updated `README.md`.
167
-
168
- ### Added
169
-
170
- - Documentation.
171
-
172
- ## [0.5.0] - 2020/6/13
173
-
174
- ### Changed
175
-
176
- - Changed image processing engine from Sharp to Jimp. Fixes [#7](https://github.com/oslllo/svg-fixer/issues/7)
177
- - Refactored async pools (fixConcurrency).
178
-
179
- ### Fixed
180
-
181
- - Fixed pathing issues on windows. Fixes [#8](https://github.com/oslllo/svg-fixer/issues/8)
182
-
183
- ## [0.4.4] - 2020/6/8
184
-
185
- ### Changed
186
-
187
- - Updated dependencies. Fixes [#7](https://github.com/oslllo/svg-fixer/issues/7)
188
-
189
- ## [0.4.3] - 2020/6/2
190
-
191
- ### Changed
192
-
193
- - Updated `package.json` description.
194
-
195
- ## [0.4.2] - 2020/5/24
196
-
197
- ### Fixed
198
-
199
- - Fixed incorrect svg data when source svg has 'px', 'rem' or 'em' on height and width attributes as a unit of measurement. See ([#5](https://github.com/oslllo/svg-fixer/issues/5))
200
-
201
- ## [0.4.1] - 2020/5/16
202
-
203
- ### Security
204
-
205
- - Fixed [Vulnerability](https://www.npmjs.com/advisories/1500)
206
-
207
- ## [0.4.0] - 2020/5/14
208
-
209
- ### Added
210
-
211
- - Added new parameter `fixConcurrency` to control how many svgs to fix at a given time.
212
- - Added new tests
213
- - Added an perfomance increase by ~67%
214
-
215
- |Version|completion (%)|Time (seconds)|Number of SVGs fixed|
216
- |------|------|-----|-----|
217
- |v0.4.0|100.00|~ 127|1315|
218
- |v0.3.3|100.00|~ 190|1315|
219
- |-|-|-|-|
220
- |**VPS**|**CPU**|**RAM**|||
221
- ||Intel(R) Xeon(R) E5-1650 v3 3.50GHz (2x) | 1548MiB|||
222
-
223
- ### Fixed
224
-
225
- - Fixed tests
226
-
227
- ### Changed
228
-
229
- - Reduceed npm package size.
230
- - Updated `README.md`.
231
-
232
- ## [0.3.3] - 2020/5/12
233
-
234
- ### Added
235
-
236
- - Added badge links to `README.md`.
237
- - Added new tags to `package.json`.
238
-
239
- ### Changed
240
-
241
- - Updated `README.md` content.
242
-
243
- ## [0.3.2] - 2020/5/10
244
-
245
- ### Changed
246
-
247
- - Updated README.md
248
-
249
- ## [0.3.1] - 2020/5/9
250
-
251
- ### Changed
252
-
253
- - Updated `README.md`
254
-
255
- ## [0.3.0] - 2020/5/8
256
-
257
- ### Changed
258
-
259
- - Refactored the whole codebase.
260
- - Updated README.md
261
-
262
- ### Added
263
-
264
- - Added tests
265
- - Added slight performance increase.
266
-
267
- ## [0.2.0] - 2020/4/18
268
-
269
- ### Added
270
-
271
- - Added progress bar
272
-
273
- ## [0.1.0] - 2020/4/17
274
-
275
- ### Added
276
-
277
- - Added [CHANGELOG.md](https://github.com/oslllo/svg-fixer/blob/master/CHANGELOG.md)
278
- - Create destination folder if it does not exist.
279
-
280
- ### Changed
281
-
282
- - Switched from `fs` to `fs-extra`
283
- - Changed `SvgFixer()` function name from `SvgFixer` to `svgFixer` because its a function not a class.
284
-
285
- ### Removed
286
-
287
- - Removed debug functions
288
-
289
- ## [0.0.3] - 2020/4/16
290
-
291
- ### Added
292
-
293
- - Added package.json description
294
-
295
- ## [0.0.2] - 2020/4/16
296
-
297
- ### Added
298
-
299
- - Added [README.md](https://github.com/oslllo/svg-fixer/blob/master/README.md)
300
-
301
- ## [0.0.1] - 2020/4/16
302
-
303
- ### Added
304
-
305
- - Added everything, initial release.