@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 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
  [![Stability](https://img.shields.io/badge/stability-stable-green.svg)](https://github.com/emersion/stability-badges#stable)
9
9
  [![License](https://img.shields.io/github/license/jscad/OpenJSCAD.org)](https://github.com/jscad/OpenJSCAD.org/blob/master/LICENSE)
10
10
 
11
- [![Lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lernajs.io/)
11
+ [![Lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)
12
12
  [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
13
13
 
14
14
  [![Backers](https://img.shields.io/opencollective/backers/openjscad)](https://opencollective.com/openjscad)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jscad/svg-deserializer",
3
- "version": "2.5.1",
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.9.6",
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": "9768af96e5da00cd113c00ddeb0f6046707819b1"
43
+ "gitHead": "a27a6bc32c6cd313453da8b67f3fce29e008099f"
44
44
  }
@@ -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 (!coNext || !isCloseCmd(coNext.c)) {
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
- } else {
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
+ })