1
0
mirror of https://github.com/svg/svgo.git synced 2026-01-27 07:02:06 +03:00

122 Commits

Author SHA1 Message Date
Seth Falco
26d059f3d7 fix: invoke mapNodesToParents lazily (#2132) 2025-05-11 15:38:41 +01:00
Seth Falco
747cc722d9 chore: revamp how we export types (#2118) 2025-05-04 17:39:44 +01:00
Seth Falco
49954bc0d9 chores: various clean ups regardin ESM and TypeScript (#2117) 2025-05-03 09:42:29 +01:00
Seth Falco
a8a53dbd90 chore: apply more eslint rules (#2116) 2025-05-02 10:00:37 +01:00
Seth Falco
8c593fab06 chore: bulk update all jsdoc and jsdoctypes (#2114) 2025-05-01 22:16:52 +01:00
Seth Falco
4573d0178e chore: migrate plugin types to plugin (#2111) 2025-04-30 02:16:53 +01:00
Seth Falco
dba60b3580 chore: migrate from ts-ignore to ts-expect-error (#2103) 2025-04-12 19:41:49 +01:00
Seth Falco
9c8768f64d ci: add spellcheck (#2101) 2025-04-12 16:47:32 +01:00
Seth Falco
8d6385bd9a fix(convertPathData): preserve vertex for markers only path (#1967) 2024-03-02 01:24:43 +00:00
Seth Falco
174e952573 chore: use math.hypot (#1936) 2024-01-17 22:15:35 +00:00
Kendell R
6afc7bdb52 fix(convertPathData): fix q control point behavior when item is removed (#1927) 2024-01-06 14:07:25 +00:00
Jon Dufresne
2442f74239 chore: convert project to us ECMAScript modules (preserving CJS compatibility) (#1905) 2024-01-03 16:17:37 +00:00
Kendell R
8644cf36e8 feat(convertPathData): convert c to q (#1892) 2024-01-01 20:47:21 +00:00
Seth Falco
2661dacc24 fix(convertTransform): fix scale and rotate on skew + refactors (#1916) 2023-12-31 00:59:18 +00:00
Seth Falco
433dcefd64 refactor(convertPaths): clean up plugin (#1913) 2023-12-28 17:51:19 +00:00
Kendell R
f238d6a213 feat(convertPathData): allow converting q to t in more cases (#1889) 2023-12-27 23:41:09 +00:00
Kendell R
562152a729 feat(convertPathData): use the sagitta of arcs to round and convert to lines when applicable (#1873) 2023-12-27 12:53:01 +00:00
mozzie
90406f7967 refactor(mergePaths): improve performance on large files (#1764) 2023-12-26 00:53:44 +00:00
Seth Falco
a3da8b3a76 refactor: use set in _collections (#1899) 2023-12-24 01:54:17 +00:00
Kendell R
a7859eb177 fix(convertPathData): fix some weird behavior (#1867) 2023-12-24 01:47:29 +00:00
Seth Falco
22533f1ffe chore: update prettier and eslint (#1885) 2023-12-15 13:10:21 +00:00
Jon Dufresne
d6ff70baf9 chore: fix several typos (#1868) 2023-12-03 18:02:22 +00:00
Kendell R
8dd7a3b2fc fix(convertPathData): handle setting prev properly to fix path joining and #1855 (#1856) 2023-11-29 00:39:08 +00:00
Kendell R
86d5040382 fix(convertPathData): account for error in z conversions (#1842) 2023-11-28 02:01:20 +00:00
Kendell R
14bdacc2df feat(convertPathData): replace with z and remove z when optimal (#1822) 2023-11-12 13:52:01 +00:00
Marvin Hagemeister
c641da2734 Speed up strongRound by avoiding string casting (#1716)
I'm currently profiling my build pipeline and noticed that the
`strongRound` function showed up a couple of times, followed immediately
with a bit of GC cleanup shortly after. We can speed up that function by
avoiding the string casting caused by `Number.prototype.toFixed()`.

In my project's build pipeline with lots of svg icons this saves about
1.4s in total.

<img width="792" alt="js-tools-strongRound"
src="https://user-images.githubusercontent.com/1062408/204393563-666be3e0-e0ee-4608-9b7d-9ea8352bd36b.png">
2022-11-30 11:53:39 +03:00
Bogdan Chadkin
e2e65cfc1e Move plugin types into d.ts 2022-11-11 12:19:38 +03:00
Bogdan Chadkin
f5d1dd06cc Loosly cover with types convertPathData 2022-10-16 14:53:04 +03:00
Bogdan Chadkin
e6bd703b0a Remove unused active and type fields from plugins 2022-10-08 23:39:58 +03:00
Bogdan Chadkin
954faf3c87 Remove default plugin.params support 2022-10-02 19:43:06 +03:00
Bogdan Chadkin
068db0e894 Refactor applyTransforms (#1637)
- applyTransforms is prepared to be a separate plugin, in v3 I will
  remove it from convertPathData
- migrated to tsdoc
- removed optimisation with stroke-width inside id (still not idea how
  it worked)
- added deoptimisation when id is on element to fix redefining in `<use>`

Note: review with hidden whitespaces
2022-01-19 20:41:10 +03:00
Bogdan Chadkin
539237ce87 Normalize path data structure (#1538)
Use modern path data structure in all plugins.
Will be easier to cover with types.
2021-08-24 00:01:18 +03:00
Bogdan Chadkin
07f8d606e0 Implement preset-default plugin (#1513)
I saw complaints about `extendDefaultPlugins` api

- it cannot be used when svgo is installed globally
- it requires svgo to be installed when using svgo-loader or svgo-jsx
- it prevents using serializable config formats like json

In this diff I introduced the new plugin which is a bundle of all
default plugins.

```js
module.exports = {
  plugins: [
    'preset_default',
    // or
    {
      name: 'preset_default',
      floatPrecision: 4,
      overrides: {
        convertPathData: {
          applyTransforms: false
        }
      }
    }
  ]
}
```
2021-08-13 19:07:08 +03:00
Bogdan Chadkin
2c0c361074 Collect stylesheet once per plugin (#1456)
computeStyle(node) in isolation is quite slow utility because it
collects style elements across whole document, parses and sort them.

In this diff I splitted it into `collectStylesheet(root)` and
`computeStyle(stylesheet, node)` which are easy integrate with new
visitor plugin api.
2021-08-12 03:08:39 +03:00
Bogdan Chadkin
3d79f57a10 Convert convertPathData to visitor 2021-03-29 11:01:13 +03:00
Bogdan Chadkin
316a002299 Remove hasAttr and hasAttrLocal usages (#1447)
In most cases simple check for null is enough.
2021-03-22 01:24:59 +03:00
Bogdan Chadkin
61657433e1 Refactor apply transforms
- handle each command separately
- handle both relative and absolute commands
- moved into _applyTransforms.js to convert eventually into plugin
- apply transforms before converting into relative

These changes makes code independent and easy to work with.
2021-03-15 21:24:23 +03:00
Bogdan Chadkin
a04b27a1df Refactor convertToRelative
Slight code simplification. Each command is processed exclusively
without assumtions. Removed moveto and closepath common coords
reference, handle in applyTransform instead. Rely on new path data
naming.
2021-03-15 13:41:12 +03:00
Bogdan Chadkin
ba7e9bdc0d Fix collapsing repeated with marker-mid in style rule 2021-03-06 01:36:18 +03:00
Bogdan Chadkin
c21fef54e1 Remove useless path commands considering static styles 2021-03-05 18:08:02 +03:00
Bogdan Chadkin
7901588a9f Fix path optimisation with stroke-linecap round
Ref https://github.com/svg/svgo/issues/890
2021-02-28 15:22:27 +03:00
XhmikosR
1310210d4e Use https when possible and fix an inactive domain (#1374) 2021-02-25 13:48:18 +03:00
Bogdan Chadkin
9263d9ab90 Fix svg spec urls in plugins 2021-02-24 11:18:48 +03:00
一丝
8d7cfa02c7 After ‘arcto’ path command(a or A) flags, spaces are no longer removed by default (#1353)
Co-authored-by: 壹丝 <jie.lijie@alibaba-inc.com>
2021-02-20 18:58:42 +03:00
jlherren
dfe649fa8d Fix collapsing of repeated commands in convertPathData plugin
This fixes #1166
2019-11-05 19:22:43 +03:00
GreLI
8671c4c3df Fix incorrect prev arc segment angle calculation.
Close #1109
2019-07-14 12:07:59 +03:00
GreLI
258fecfa6b Remove spaces after ‘arcto’ path command flags 2019-07-13 16:18:08 +03:00
GreLI
5800635226 Fix converting to large arcs from nearly straight lines curves
Fix #842
2018-09-16 17:12:06 +03:00
GreLI
831f95fccc Fix empty path segments removing with stroke-linecap
Fix #1017
2018-09-16 15:36:41 +03:00
Mikuláš Sychra
e928c1f050 Update convertPathData.js (#906)
Added parameter forceAbsolutePath to get absolute SVG path (even when the relative path is shorter).
2018-09-15 14:40:34 +03:00