svg-path-simplify 0.4.2 → 0.4.4

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 (61) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +7 -4
  3. package/dist/svg-path-simplify.esm.js +3593 -1279
  4. package/dist/svg-path-simplify.esm.min.js +2 -2
  5. package/dist/svg-path-simplify.js +3594 -1278
  6. package/dist/svg-path-simplify.min.js +2 -2
  7. package/dist/svg-path-simplify.pathdata.esm.js +1017 -538
  8. package/dist/svg-path-simplify.pathdata.esm.min.js +2 -2
  9. package/dist/svg-path-simplify.poly.cjs +9 -8
  10. package/docs/privacy-webapp.md +24 -0
  11. package/index.html +331 -152
  12. package/package.json +1 -1
  13. package/src/constants.js +4 -0
  14. package/src/css_parse.js +317 -0
  15. package/src/detect_input.js +76 -28
  16. package/src/index.js +8 -0
  17. package/src/pathData_simplify_cubic.js +26 -16
  18. package/src/pathData_simplify_harmonize_cpts.js +77 -1
  19. package/src/pathData_simplify_revertToquadratics.js +0 -1
  20. package/src/pathSimplify-main.js +304 -276
  21. package/src/pathSimplify-only-pathdata.js +7 -2
  22. package/src/pathSimplify-presets.js +254 -0
  23. package/src/poly-fit-curve-schneider.js +14 -7
  24. package/src/simplify_poly_RC.js +102 -0
  25. package/src/simplify_poly_RDP.js +109 -1
  26. package/src/simplify_poly_radial_distance.js +3 -3
  27. package/src/string_helpers.js +130 -4
  28. package/src/svg-getAttributes.js +4 -2
  29. package/src/svgii/convert_units.js +1 -1
  30. package/src/svgii/geometry.js +322 -5
  31. package/src/svgii/geometry_bbox_element.js +1 -1
  32. package/src/svgii/geometry_deduceRadius.js +116 -27
  33. package/src/svgii/geometry_length.js +253 -0
  34. package/src/svgii/pathData_analyze.js +18 -0
  35. package/src/svgii/pathData_convert.js +193 -89
  36. package/src/svgii/pathData_fix_directions.js +12 -14
  37. package/src/svgii/pathData_fromPoly.js +3 -3
  38. package/src/svgii/pathData_getLength.js +86 -0
  39. package/src/svgii/pathData_parse.js +2 -0
  40. package/src/svgii/pathData_parse_els.js +66 -68
  41. package/src/svgii/pathData_reorder.js +122 -16
  42. package/src/svgii/pathData_simplify_refineCorners.js +130 -35
  43. package/src/svgii/pathData_simplify_refine_round.js +420 -0
  44. package/src/svgii/pathData_split_to_groups.js +168 -0
  45. package/src/svgii/pathData_stringify.js +26 -64
  46. package/src/svgii/pathData_toPolygon.js +3 -4
  47. package/src/svgii/poly_analyze.js +61 -0
  48. package/src/svgii/poly_normalize.js +11 -2
  49. package/src/svgii/poly_to_pathdata.js +85 -24
  50. package/src/svgii/rounding.js +80 -78
  51. package/src/svgii/svg_cleanup.js +421 -619
  52. package/src/svgii/svg_cleanup_convertPathLength.js +39 -0
  53. package/src/svgii/svg_cleanup_general_svg_atts.js +97 -0
  54. package/src/svgii/svg_cleanup_normalize_transforms.js +83 -0
  55. package/src/svgii/svg_cleanup_remove_els_and_atts.js +77 -0
  56. package/src/svgii/svg_cleanup_ungroup.js +36 -0
  57. package/src/svgii/svg_el_parse_style_props.js +72 -47
  58. package/src/svgii/svg_getElementLength.js +67 -0
  59. package/src/svgii/svg_validate.js +220 -0
  60. package/tests/testSVG.js +14 -1
  61. package/src/svgii/pathData_refine_round.js +0 -222
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.4] - 2026-04-01
4
+ ### Fixed
5
+ - shape attribute retrieval in node.js
6
+ ### Added
7
+ - convert relative dash lengths relying on `pathLength` attribute
8
+ - quantized rounding allowing for half decimal steps
9
+ - improved arc segment detection and simplification
10
+ - security warnings/sanitization e.g for billion laugh exploits
11
+ - webapp: recommendations for additional optimizations
12
+
13
+ ## [0.4.3] - 2026-03-26
14
+ ### Added
15
+ - presets: apply options from existing presets (allows custom overriding)
16
+ - addititional input formats: `<symbol>` (handy for sprite editing), stringified (polygon) point arrays
17
+ - compound path splitting: creates separate `<path>` elements from overlapping sub paths
18
+ - custom element and attribute removal
19
+ - "safe" mode for path data stringification – for better legacy application support
20
+ - webapp responds to keyboard shortcuts for saving, copying and pasting
21
+ - "keepSmaller" option: takes the original input if simplification failed – useful for batch processing
22
+
23
+
3
24
  ## [0.4.2] - 2026-03-18
4
25
  ### Fixed
5
26
  - attribute retrieval and conversion in node
package/README.md CHANGED
@@ -294,7 +294,7 @@ let pathDataOpt = simplifyPathData(pathDataString);
294
294
  ### Web app
295
295
  You can easily test this library via the [**webapp**](https://herrstrietzel.github.io/svg-path-simplify/) or by checking the demo folder.
296
296
 
297
- ![web app](./demo/img/screenshot.png)
297
+ ![svg-path-simplify web app](./demo/img/svg-path-simplify-webapp.png)
298
298
 
299
299
  #### Features
300
300
  * test all provided simplification option - export settings as JS object
@@ -311,6 +311,9 @@ You can easily test this library via the [**webapp**](https://herrstrietzel.gith
311
311
  * [simple setup esm](./demo/simple-esm.html)
312
312
  * [codepen](https://codepen.io/herrstrietzel/pen/PwzxpoE)
313
313
 
314
+ ### Webapp examples
315
+ * [font/glyph simplification](https://herrstrietzel.github.io/svg-path-simplify/?samples=fira_alegreya_opensans)
316
+
314
317
 
315
318
 
316
319
  ## Limitations
@@ -333,9 +336,8 @@ SVGs > 1 MB are most of the time not salvagable. At least if they contain 10K+ o
333
336
 
334
337
  ## Changelog, Updates and rollback
335
338
  ### Changelog
336
- * 0.3.0 webapp adds support for multi file batch optimizations, web worker support, drawing direction fix option (for fill rules)
337
- * 0.2.0 added features for polygon curve fitting
338
- * 0.1.0 fixed node support for complete svg files
339
+ See [changelog.md](https://github.com/herrstrietzel/svg-path-simplify/blob/main/CHANGELOG.md)
340
+
339
341
 
340
342
  ### Rollback
341
343
  If you encounter any issues with the recent versions you can rollback to a previous version.
@@ -368,4 +370,5 @@ You can also post in the [discussions](https://github.com/herrstrietzel/svg-path
368
370
  * obviously, [Dmitry Baranovskiy](https://github.com/dmitrybaranovskiy) – a lot of these helper functions originate either from Raphaël or snap.svg – or are at least heavily inspired by some helpers from these libraries
369
371
  * [Andrea Giammarchi a.k.a WebReflection](https://github.com/WebReflection) for [linkedom](https://github.com/WebReflection/linkedom) which helped to make this lib run also in node or a web worker
370
372
  * [Photopea](https://github.com/photopea) for the fast [UZIP](https://github.com/photopea/UZIP.js) which is deployed in the webapp for batch file downloads.
373
+ * [mdpjs](https://github.com/UmemotoCtrl/mdpjs) for the great JS markdown parser (used in the web app)
371
374