@jscad/svg-deserializer 2.5.1 → 2.5.3
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 +19 -0
- package/README.md +1 -1
- package/package.json +3 -3
- package/src/shapesMapGeometry.js +4 -3
- package/tests/issue.1135.test.js +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.5.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/svg-deserializer@2.5.2...@jscad/svg-deserializer@2.5.3) (2022-09-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **svg-deserializer:** corrected logic to allow path start == end point ([#1142](https://github.com/jscad/OpenJSCAD.org/issues/1142)) ([c49b540](https://github.com/jscad/OpenJSCAD.org/commit/c49b5409aee76c956fd365a43b0b49fde3d0894b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [2.5.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/svg-deserializer@2.5.1...@jscad/svg-deserializer@2.5.2) (2022-08-21)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @jscad/svg-deserializer
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [2.5.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/svg-deserializer@2.5.0...@jscad/svg-deserializer@2.5.1) (2022-07-17)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @jscad/svg-deserializer
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[](https://github.com/emersion/stability-badges#stable)
|
|
9
9
|
[](https://github.com/jscad/OpenJSCAD.org/blob/master/LICENSE)
|
|
10
10
|
|
|
11
|
-
[](https://
|
|
11
|
+
[](https://lerna.js.org/)
|
|
12
12
|
[](https://standardjs.com)
|
|
13
13
|
|
|
14
14
|
[](https://opencollective.com/openjscad)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jscad/svg-deserializer",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.3",
|
|
4
4
|
"description": "SVG Deserializer for JSCAD",
|
|
5
5
|
"homepage": "https://openjscad.xyz/",
|
|
6
6
|
"repository": "https://github.com/jscad/OpenJSCAD.org",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@jscad/array-utils": "2.1.4",
|
|
36
|
-
"@jscad/modeling": "2.
|
|
36
|
+
"@jscad/modeling": "2.10.0",
|
|
37
37
|
"saxes": "5.0.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"ava": "3.15.0",
|
|
41
41
|
"nyc": "15.1.0"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "a27a6bc32c6cd313453da8b67f3fce29e008099f"
|
|
44
44
|
}
|
package/src/shapesMapGeometry.js
CHANGED
|
@@ -428,8 +428,9 @@ const expandPath = (obj, svgUnitsPmm, svgUnitsX, svgUnitsY, svgUnitsV, svgGroups
|
|
|
428
428
|
|
|
429
429
|
if (pc !== true && paths[pathName] && paths[pathName].isClosed) {
|
|
430
430
|
let coNext = obj.commands[j + 1]
|
|
431
|
-
|
|
432
|
-
if
|
|
431
|
+
// allow self close in the last command #1135 (coNext is null or undefined)
|
|
432
|
+
// if do have a next command use pathSelfClosed to decide how to react to closing in the middle of a path
|
|
433
|
+
if (coNext && !isCloseCmd(coNext.c)) {
|
|
433
434
|
if (pathSelfClosed === 'trim') {
|
|
434
435
|
while (coNext && !isCloseCmd(coNext.c)) {
|
|
435
436
|
j++
|
|
@@ -437,7 +438,7 @@ const expandPath = (obj, svgUnitsPmm, svgUnitsX, svgUnitsY, svgUnitsV, svgGroups
|
|
|
437
438
|
}
|
|
438
439
|
} else if (pathSelfClosed === 'split') {
|
|
439
440
|
newPath()
|
|
440
|
-
}
|
|
441
|
+
}else{
|
|
441
442
|
throw new Error(`Malformed svg path at ${obj.position[0]}:${co.pos}. Path closed itself with command #${j} ${co.c}${pts.join(' ')}`)
|
|
442
443
|
}
|
|
443
444
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
|
|
3
|
+
const deserializer = require('../src/index.js')
|
|
4
|
+
|
|
5
|
+
test('deserialize issue 885 do not fail on close at the end', (t) => {
|
|
6
|
+
const svg = `<svg><g><path d="M0 0 L10 10L10 0L0 0" id="path4544" /></g></svg>`
|
|
7
|
+
|
|
8
|
+
shapes = deserializer.deserialize({ output: 'geometry', pathSelfClosed: 'error' }, svg)
|
|
9
|
+
t.is(shapes.length, 1)
|
|
10
|
+
})
|