oslllo-svg-fixer 2.1.1 → 2.2.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +346 -0
  2. package/package.json +7 -7
  3. package/src/svg.js +11 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,346 @@
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.2.0](https://www.github.com/oslllo/svg-fixer/compare/v2.1.2...v2.2.0) (2022-10-19)
9
+
10
+
11
+ ### Features
12
+
13
+ * closes [#82](https://www.github.com/oslllo/svg-fixer/issues/82) - fix negative viewBox min-x min-y bug ([b64aa75](https://www.github.com/oslllo/svg-fixer/commit/b64aa75b4ea8d3b7a0378cc1f9ce27c92b4f606f))
14
+
15
+ ### [2.1.2](https://www.github.com/oslllo/svg-fixer/compare/v2.1.0...v2.1.2) (2022-07-16)
16
+
17
+
18
+ ### Miscellaneous Chores
19
+
20
+ * release 2.1.2 ([fd8cdaf](https://www.github.com/oslllo/svg-fixer/commit/fd8cdaf08b4645fe3fad229fefa9a97ec9124c9e))
21
+
22
+ ## 2.1.1 (2022-05-1)
23
+
24
+ ### Chore
25
+
26
+ - update dependencies
27
+ - npm audit fix
28
+
29
+
30
+ ## [2.1.0](https://www.github.com/oslllo/svg-fixer/compare/v2.0.1...v2.1.1) (2022-03-8)
31
+
32
+ ### Added
33
+
34
+ - add configurable trace resolution ([#72](https://github.com/oslllo/svg-fixer/pull/72))
35
+
36
+ ### Updated
37
+
38
+ - Updated dependencies
39
+
40
+ ## [2.0.1](https://www.github.com/oslllo/svg-fixer/compare/v2.0.0...v2.0.1) (2022-01-21)
41
+
42
+
43
+ ### Refactor
44
+
45
+ - improve perfomance ([3b310aa](https://github.com/oslllo/svg-fixer/commit/3b310aaf3bf39f47b0bb56a722f03d40ad6a1b31))
46
+
47
+ ## [2.0.0](https://www.github.com/oslllo/svg-fixer/compare/v1.4.1...v2.0.0) (2022-01-12)
48
+
49
+ 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.
50
+
51
+ ### Changed
52
+
53
+ - Removed `Canvas & JSDOM` to fix very slow `npm install` cycles.
54
+ - Switched from `Canvas` to `svg2png-wasm`.
55
+
56
+ ### Updated
57
+
58
+ - Updated dependencies
59
+
60
+
61
+ ## [1.4.1](https://www.github.com/oslllo/svg-fixer/compare/v1.4.0...v1.4.1) (2021-09-05)
62
+
63
+
64
+ ### Bug Fixes
65
+
66
+ * vulnerabilities ([99621c6](https://www.github.com/oslllo/svg-fixer/commit/99621c6258e52836f0aaaf9876fe4b4859c81ab6))
67
+
68
+ ## [1.4.0](https://www.github.com/oslllo/svg-fixer/compare/v1.3.2...v1.4.0) (2021-07-14)
69
+
70
+
71
+ ### Features
72
+
73
+ * add support for svgs with "ex", "ch", "cm", "mm", "q", "in", "pc", "pt" ([4d2c18e](https://www.github.com/oslllo/svg-fixer/commit/4d2c18ef496b9ce08cbc917e3fbb91d9f352c6ff))
74
+ * add support for svgs with fill color in path style attribute ([1aeb079](https://www.github.com/oslllo/svg-fixer/commit/1aeb0794e9693079c79981616ea00e99379c863f))
75
+ * support svgs without a set viewBox attribute ([17b876c](https://www.github.com/oslllo/svg-fixer/commit/17b876ce49ed0a047dedb098d47adcccb22ff0cf))
76
+
77
+ ### [1.3.2](https://www.github.com/oslllo/svg-fixer/compare/v1.3.1...v1.3.2) (2021-06-26)
78
+
79
+
80
+ ### Bug Fixes
81
+
82
+ * security vulnerabilities ([372730b](https://www.github.com/oslllo/svg-fixer/commit/372730bef6cf761877961796635fc406a2ecc776))
83
+
84
+ ### [1.3.1](https://www.github.com/oslllo/svg-fixer/compare/v1.3.0...v1.3.1) (2021-05-27)
85
+
86
+
87
+ ### Bug Fixes
88
+
89
+ * 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))
90
+
91
+ ## [1.3.0](https://www.github.com/oslllo/svg-fixer/compare/v1.2.1...v1.3.0) (2021-05-15)
92
+
93
+
94
+ ### Features
95
+
96
+ * 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))
97
+
98
+
99
+ ### Bug Fixes
100
+
101
+ * **eslint:** script error ([d34780e](https://www.github.com/oslllo/svg-fixer/commit/d34780e1db64d350695f5be7c4713136f9c66331))
102
+
103
+ ### [1.2.1](https://www.github.com/oslllo/svg-fixer/compare/v1.2.0...v1.2.1) (2021-05-06)
104
+
105
+
106
+ ### Bug Fixes
107
+
108
+ * drop yargs version to 16 ([7b4d9cc](https://www.github.com/oslllo/svg-fixer/commit/7b4d9ccb563027b24aefe59d394848b8937067b9))
109
+ * package breaking when process.env.NODE_ENV env variable is set ([51c6318](https://www.github.com/oslllo/svg-fixer/commit/51c6318340b97d6840ab7d2c499c77aff27b6f10))
110
+
111
+ ## [1.2.0] - 2021/4/1
112
+
113
+ ### Fixed
114
+
115
+ - Fixed bug in test.
116
+
117
+ ### Updated
118
+
119
+ - Updated dependencies.
120
+
121
+ ## [1.1.2] - 2020/12/12
122
+
123
+ ### Fixed
124
+
125
+ - Fixed vulnerability.
126
+
127
+ ### Updated
128
+
129
+ - Updated dependencies.
130
+
131
+ ## [1.1.1] - 2020/10/22
132
+
133
+ ### Fixed
134
+
135
+ - Fixed large npm package.
136
+
137
+ ## [1.1.0] - 2020/10/22
138
+
139
+ ### Fixed
140
+
141
+ - Fixed bug that allowed you to update `options` that do not exist.
142
+
143
+ ### Added
144
+
145
+ - Added `CLI` functionality.
146
+ - Added `callback` functionality to `SVGFixer.fix()`.
147
+
148
+ ### Changed
149
+
150
+ - Refactored `tests`.
151
+ - Refactored `progress bar`.
152
+
153
+ ## [1.0.2] - 2020/10/2
154
+
155
+ ### Fixed
156
+
157
+ - Fixed not being able to process SVGs with `%` dimensions.
158
+
159
+ ### Added
160
+
161
+ - SVG attribute tests.
162
+
163
+ ## [1.0.1] - 2020/9/16
164
+
165
+ ### Changed
166
+
167
+ - Remove tests from npm `package` to help reduce unpacked `package` size.
168
+
169
+ ## [1.0.0] - 2020/9/16
170
+
171
+ ⚠️ Contains breaking changes.
172
+
173
+ ### Breaking Changes
174
+
175
+ - `svgfixer.fix(source, destination, options)` ***=>*** `SVGFixer(source, destination, options).fix()`.
176
+ - It was changed from a wrapper function to a method function for `SVGFixer`.
177
+ - It still returns a `Promise`.
178
+ - `fix()` no more takes in `parameters`, those should be passed into `SVGFixer()`.
179
+ - `svgfixer.SVGFixer()` class ***=>*** `SVGFixer()`.
180
+ - The `.setOptions(options)` method has been removed, `options` should now be passed in class constructor as the 3rd `parameter`.
181
+ - The `.setSourceAndDest()` method has been removed, `source` and `destination` should now be passed in class constructor as the 1st and 2nd `parameters`.
182
+ - The `.process()` method has been removed, use `.fix()` instead.
183
+ - `SVGFixer()` does not require the [`new`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new) operator anymore.
184
+ - `fixConcurrency` has been removed, might be reimplemented on later versions.
185
+
186
+ ### Changed
187
+
188
+ - Updated dependencies.
189
+ - Refactored codebase.
190
+ - Refactored progressbar.
191
+
192
+ ## [0.6.0] - 2020/8/13
193
+
194
+ ### Security
195
+
196
+ - Updated dependencies. Fixes [Vulnerability](https://npmjs.com/advisories/1548)
197
+
198
+ ### Changed
199
+
200
+ - Updated image processor.
201
+ - Updated `CHANGELOG.md` wording and formatting.
202
+
203
+ ## [0.5.1] - 2020/7/7
204
+
205
+ ### Changed
206
+
207
+ - Updated `README.md`.
208
+
209
+ ### Added
210
+
211
+ - Documentation.
212
+
213
+ ## [0.5.0] - 2020/6/13
214
+
215
+ ### Changed
216
+
217
+ - Changed image processing engine from Sharp to Jimp. Fixes [#7](https://github.com/oslllo/svg-fixer/issues/7)
218
+ - Refactored async pools (fixConcurrency).
219
+
220
+ ### Fixed
221
+
222
+ - Fixed pathing issues on windows. Fixes [#8](https://github.com/oslllo/svg-fixer/issues/8)
223
+
224
+ ## [0.4.4] - 2020/6/8
225
+
226
+ ### Changed
227
+
228
+ - Updated dependencies. Fixes [#7](https://github.com/oslllo/svg-fixer/issues/7)
229
+
230
+ ## [0.4.3] - 2020/6/2
231
+
232
+ ### Changed
233
+
234
+ - Updated `package.json` description.
235
+
236
+ ## [0.4.2] - 2020/5/24
237
+
238
+ ### Fixed
239
+
240
+ - 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))
241
+
242
+ ## [0.4.1] - 2020/5/16
243
+
244
+ ### Security
245
+
246
+ - Fixed [Vulnerability](https://www.npmjs.com/advisories/1500)
247
+
248
+ ## [0.4.0] - 2020/5/14
249
+
250
+ ### Added
251
+
252
+ - Added new parameter `fixConcurrency` to control how many svgs to fix at a given time.
253
+ - Added new tests
254
+ - Added an perfomance increase by ~67%
255
+
256
+ |Version|completion (%)|Time (seconds)|Number of SVGs fixed|
257
+ |------|------|-----|-----|
258
+ |v0.4.0|100.00|~ 127|1315|
259
+ |v0.3.3|100.00|~ 190|1315|
260
+ |-|-|-|-|
261
+ |**VPS**|**CPU**|**RAM**|||
262
+ ||Intel(R) Xeon(R) E5-1650 v3 3.50GHz (2x) | 1548MiB|||
263
+
264
+ ### Fixed
265
+
266
+ - Fixed tests
267
+
268
+ ### Changed
269
+
270
+ - Reduceed npm package size.
271
+ - Updated `README.md`.
272
+
273
+ ## [0.3.3] - 2020/5/12
274
+
275
+ ### Added
276
+
277
+ - Added badge links to `README.md`.
278
+ - Added new tags to `package.json`.
279
+
280
+ ### Changed
281
+
282
+ - Updated `README.md` content.
283
+
284
+ ## [0.3.2] - 2020/5/10
285
+
286
+ ### Changed
287
+
288
+ - Updated README.md
289
+
290
+ ## [0.3.1] - 2020/5/9
291
+
292
+ ### Changed
293
+
294
+ - Updated `README.md`
295
+
296
+ ## [0.3.0] - 2020/5/8
297
+
298
+ ### Changed
299
+
300
+ - Refactored the whole codebase.
301
+ - Updated README.md
302
+
303
+ ### Added
304
+
305
+ - Added tests
306
+ - Added slight performance increase.
307
+
308
+ ## [0.2.0] - 2020/4/18
309
+
310
+ ### Added
311
+
312
+ - Added progress bar
313
+
314
+ ## [0.1.0] - 2020/4/17
315
+
316
+ ### Added
317
+
318
+ - Added [CHANGELOG.md](https://github.com/oslllo/svg-fixer/blob/master/CHANGELOG.md)
319
+ - Create destination folder if it does not exist.
320
+
321
+ ### Changed
322
+
323
+ - Switched from `fs` to `fs-extra`
324
+ - Changed `SvgFixer()` function name from `SvgFixer` to `svgFixer` because its a function not a class.
325
+
326
+ ### Removed
327
+
328
+ - Removed debug functions
329
+
330
+ ## [0.0.3] - 2020/4/16
331
+
332
+ ### Added
333
+
334
+ - Added package.json description
335
+
336
+ ## [0.0.2] - 2020/4/16
337
+
338
+ ### Added
339
+
340
+ - Added [README.md](https://github.com/oslllo/svg-fixer/blob/master/README.md)
341
+
342
+ ## [0.0.1] - 2020/4/16
343
+
344
+ ### Added
345
+
346
+ - Added everything, initial release.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oslllo-svg-fixer",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "Converts SVG Strokes To Fill.",
5
5
  "bin": "src/cli.js",
6
6
  "main": "src/index.js",
@@ -42,12 +42,12 @@
42
42
  },
43
43
  "homepage": "https://docs.oslllo.com/svg-fixer/master",
44
44
  "dependencies": {
45
- "ansi-colors": "^4.1.1",
46
- "cli-progress": "^3.11.0",
47
- "fast-glob": "^3.2.11",
48
- "oslllo-potrace": "^2.0.0",
49
- "oslllo-svg2": "^2.0.1",
50
- "oslllo-validator": "^3.0.0",
45
+ "ansi-colors": "^4.1.3",
46
+ "cli-progress": "^3.11.2",
47
+ "fast-glob": "^3.2.12",
48
+ "oslllo-potrace": "^2.0.1",
49
+ "oslllo-svg2": "^2.0.2",
50
+ "oslllo-validator": "^3.1.0",
51
51
  "yargs": "^16.2.0"
52
52
  },
53
53
  "devDependencies": {
package/src/svg.js CHANGED
@@ -78,7 +78,17 @@ Svg.prototype = {
78
78
  setAttributes(element, attributes) {
79
79
  attributes.forEach((attribute) => {
80
80
  if (attribute) {
81
- if (element.tagName.toLowerCase() === "path") {
81
+ if (attribute.name === "viewBox") {
82
+ const value = attribute.value.split(" ");
83
+ const x = 2;
84
+ for (var i = 0; i < x; i++) {
85
+ /**
86
+ * Set min-x & min-y to 0
87
+ */
88
+ value[i] = "0";
89
+ }
90
+ element.setAttribute(attribute.name, value.join(" "));
91
+ } else if (element.tagName.toLowerCase() === "path") {
82
92
  if (
83
93
  (attribute.name === "stroke" && this.valueIsNotBlack(attribute.value)) ||
84
94
  (attribute.name === "fill" && this.valueIsNotBlack(attribute.value))