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

583 Commits

Author SHA1 Message Date
Bogdan Chadkin
422fa142f2 Reuse plugin types for config 2022-11-11 12:50:33 +03:00
Bogdan Chadkin
e2e65cfc1e Move plugin types into d.ts 2022-11-11 12:19:38 +03:00
Bogdan Chadkin
6295c60fbf Rename cleanupIDs to cleanupIds for consistency with prefixIds 2022-10-23 11:54:48 +03:00
Bogdan Chadkin
bc07c483c3 Remove prefix param from cleanupIDs plugin 2022-10-23 11:40:48 +03:00
Bogdan Chadkin
f5d1dd06cc Loosly cover with types convertPathData 2022-10-16 14:53:04 +03:00
Bogdan Chadkin
dd9cad1cf9 Add sortAttrs to default preset 2022-10-09 17:29:11 +03:00
Bogdan Chadkin
e6bd703b0a Remove unused active and type fields from plugins 2022-10-08 23:39:58 +03:00
Bogdan Chadkin
12272958db Upgrade csso and csstree 2022-10-08 14:57:57 +03:00
Bogdan Chadkin
075ab164f6 Store builtin plugins as an array 2022-10-02 22:58:02 +03:00
Bogdan Chadkin
954faf3c87 Remove default plugin.params support 2022-10-02 19:43:06 +03:00
Bogdan Chadkin
516c6e1fc1 Drop createContentItem from public api and JSAPI node wrappers 2022-10-02 12:00:44 +03:00
Raphael Boidol
2ea65860f0 Remove stable package in favor of native stable sort (#1681) 2022-10-01 21:21:09 +03:00
Liam Mitchell
1b88baa123 More helpful preset warnings (#1645)
* More helpful preset warnings

* Optimise
2022-02-07 12:22:14 +03:00
Bogdan Chadkin
da1d761b53 Refactor removeDimensions and removeXMLNS (#1640)
Migrated both to visitor api and tsdoc
2022-01-22 00:12:52 +03:00
Bogdan Chadkin
238d3bf600 Refactor convertStyleToAttrs (#1635)
Did not rewrite much, just migrated to tsdoc and visitor plugin api.
This plugin will be obsolete eventually.
2022-01-20 10:55:01 +03:00
Bogdan Chadkin
aaf1cfa5e7 Refactor removeNonInheritableGroupAttrs and moveGroupAttrsToElems (#1636)
Batched in one PR. Pretty simple changes. Just migrated to api and
added more safety checks for types.
2022-01-19 20:42:13 +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
Rogier Slag
04abd6fc59 Correct typo in comment in removeDimensions plugin (#1633) 2021-12-28 16:15:55 +03:00
Bogdan Chadkin
dfc5b982c9 Rename master branch to main 2021-12-25 15:09:34 +03:00
Bogdan Chadkin
79d4babcaf Replace closestByName utility with visitSkip (#1613)
The last usage of closestByName utility based on node.parentNode
is removed here. One step closer to clean ast in v3.
2021-12-07 11:05:15 +03:00
Bogdan Chadkin
72b972261d Refactor inlineStyles (#1601)
This is a big one

- got rid from another closestByName usage
- delegated removing empty defs elements to removeEmptyContainers plugin
- got rid from all css-tools usages (most inlineStyles code was there
  for some reason)
- combined a few loops
- fixed useMqs option (I would remove it in v3 for simplicity as it
  seems nobody use it)
2021-10-30 01:31:52 +03:00
Devon Govett
2d6deeaf21 Remove xmlns:xlink in removeXMLNS plugin (#1508)
xmlns:xlink is also not required in SVGs embedded in HTML
2021-10-15 12:16:08 +03:00
Bogdan Chadkin
4377ea38c4 Refactor removeEmptyAttrs (#1594)
- migrated to visitor plugin api
- covered with tsdoc
2021-10-07 14:07:06 +03:00
Ilya Skriblovsky
6235264cf3 Fix prefixIds plugin to properly handle url()s in style="..." (#1592)
`prefixIds` plugin currently breaks url()-links inside `style` attributes:

```javascript
optimize(
  `<g style="fill:url(#brush-id);stroke:url(#pen-id)"/>`,
  { plugins: ['prefixIds'] }
).data
```
will generate `<g style=""/>`. Seems like `prefixIds` assumes that attribute's whole value might be `url()`, but this is not the case for the `style` attribute.

This fix solves the issue by preserving all attribute's content other than #id inside url(). It also adds some more tests for the `prefixIds` plugin.
2021-09-30 14:40:40 +03:00
Bogdan Chadkin
543346ca97 Refactor moveElemsAttrsToGroup (#1574)
- migrated to visitor plugin api
- covered with tsdoc
- added more test cases
- restructured and simplified code
2021-09-23 21:52:46 +03:00
Bogdan Chadkin
9ebff13725 Refactor mergeStyles (#1575)
- covered with tsdoc
- replace another closestByName usage with visitSkip symbol to skip
  subtree instead of skipping element by ancestor

Better review with hidden whitespaces as most code just got bigger indent.
2021-09-23 21:48:54 +03:00
Samuel Vaillant
8af10de8d4 fix(plugin): removeAttrs: warn without attrs (#1582) 2021-09-23 21:48:14 +03:00
Bogdan Chadkin
e3c6873243 Refactor collapseGroups (#1572)
- migrated to visitor plugin api
- covered with tsdoc

Part of the code is still complicated. Will come to it eventually.
2021-09-16 01:51:08 +03:00
Bogdan Chadkin
a0bf4f7ebf Add missing filter primitives to collections (#1571)
Ref https://github.com/svg/svgo/issues/1045#issuecomment-510208768

This should prevent feDropShadow from removing.
2021-09-14 18:03:50 +03:00
Bogdan Chadkin
edbd433753 Refactor removeEmptyContainers (#1570)
- migrated to visitor plugin api
- covered with tsdoc
2021-09-14 18:03:29 +03:00
Bogdan Chadkin
1c551a87c0 Refactor sortAttrs plugin (#1564)
- covered with tsdoc
- migrated to visitor plugin api
- slightly simplified (hope so) logic by avoiding loop over order array
  in every compare function call
- rewrote tests
2021-09-13 16:16:56 +03:00
Bogdan Chadkin
3d22a5b23d Refactor prefixIds (#1561)
Ref https://github.com/svg/svgo/issues/1499

- migrated to visitor plugin api
- covered with tsdoc
- made the plugin idempotent as requested a few times
  Now even manually running svgo a few times will not duplicate
  prefix in ids and classes
- run each plugin test twice to see which plugin need to run many times
  ideally idempotent plugins will allow to get rid of multipass option in v3
2021-09-13 16:16:38 +03:00
Bogdan Chadkin
6eb4524aef Refactor removeUnusedNS plugin (#1559)
- covered with types
- migrated to visitor plugin api
- dropped traverse utility which is replaced by visitor
2021-09-10 20:30:34 +03:00
Bogdan Chadkin
f587aae1c2 Refactor removeEditorsNSData (#1557)
- covered with types
- migrated to visitor plugin api
- got rid from parseName utility in favour of simple string operations
2021-09-10 19:34:27 +03:00
Bogdan Chadkin
298820b8d9 Refactor cleanupIDs (#1556)
I still did get how id generation works but data flow is clear now at
least.

- covered with types
- migrated to visitor plugin api
- got rid of traverse api
2021-09-05 17:35:37 +03:00
Bogdan Chadkin
107922405a Refactor minifyStyles plugin (#1552)
- migrated to visitor plugin api
- covered with types
- get rid from "traverse" usage

Splitted the work to collecting and modifying when root exit.
2021-09-05 17:35:11 +03:00
Bogdan Chadkin
93143f32c1 Refactor removeUselessStrokeAndFill (#1549)
The logic is a little messy. Will be better when we drop node 12 support
and use optional chaining.

- migrated to visitor plugin api
- covered with types
- get rid from patching params as plugin state
- replaced many node.computedAttr() with style manager
- enabled and fixed removeNone param test (was merged as muted back in 2017)
- added ability to return null and not run visitor in plugins
2021-09-05 17:34:13 +03:00
Bogdan Chadkin
fab4b255c7 Add xmlns:xlink in reusePaths plugin (#1555)
Ref https://github.com/svg/svgo/issues/1200
2021-09-03 20:57:01 +03:00
Bogdan Chadkin
1e5236d813 Refactor reusePaths plugin (#1551)
- migrated to visitor plugin api; combination of enter and exit helped
  to fit into single traverse
- got rid from the only node.clone() usage in the project so no need to
  reimplement it
- the logic is a bit simplified
2021-09-01 15:47:04 +03:00
Bogdan Chadkin
680e143daf Add transform-origin to presentation attributes
Ref https://github.com/svg/svgo/issues/1475
2021-08-27 23:39:51 +03:00
Bogdan Chadkin
bc95263885 Refactor removeUnknownsAndDefaults (#1548)
- got rid from two computeAttr usages
- got rid from node.parentNode usages
- avoided mutating global _collections objects
- refactored with visitor api
- covered with types
- skip whole foreignObject subtree not only its children
2021-08-27 23:02:28 +03:00
Bogdan Chadkin
5ad2d4a5f6 Refactor removeOffCanvasPaths plugin (#1545)
- refactored with visitor plugin api
- covered with types
- replaced parentNode traverse with visitSkip symbol
- replaced regex path parser with parsePathData
- get rid from global state which lead test case to invalid state
2021-08-27 17:15:18 +03:00
Bogdan Chadkin
ac8edbaf41 Fix applying transform to arc with zero radius
Ref https://github.com/svg/svgo/issues/1500
2021-08-27 01:03:11 +03:00
Bogdan Chadkin
1b02799e18 Cover convertTransform plugin with types (#1542)
In this diff covered convertTransform pluginn with types
and got rid from global state which made data flow more complex and
error prone.
2021-08-25 20:52:31 +03:00
Bogdan Chadkin
cce036f285 Refactor convertColors (#1543)
- refactored with visitor plugin api
- covered with types
2021-08-25 20:52:21 +03:00
Bogdan Chadkin
a228020329 Refactor defs plugins (#1544)
Refactored and covered with types following plugins

- removeUselessDefs
- sortDefsChildren
2021-08-25 20:52:07 +03:00
Bogdan Chadkin
0ead871eed Cover with types numeric values plugins (#1541)
- cleanupNumericValues
- cleanupListOfValues
2021-08-24 14:57:09 +03:00
Bogdan Chadkin
4082eca762 Refactor cleanupEnableBackground with visitor plugin api (#1540)
Slightly restructured plugin to do less work in case no filters used.
2021-08-24 14:20:23 +03:00
Bogdan Chadkin
a2331a5dee removeViewBox and convertShapeToPath types and visitor (#1537)
- added types to convertShapeToPath
- refactored removeViewBox with visitor plugin api and got rid from one
  closestByName usage
2021-08-24 13:41:26 +03:00
Bogdan Chadkin
74c383153e Cover mergePaths plugin with types (#1539)
- covered mergePaths plugin
- covered big path logic
2021-08-24 13:41:16 +03:00