fix(auto-icons): use @resvg/resvg-js for SVG rendering to support linearGradient#2228
fix(auto-icons): use @resvg/resvg-js for SVG rendering to support linearGradient#2228
Conversation
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
@wxt-dev/analytics
@wxt-dev/auto-icons
@wxt-dev/browser
@wxt-dev/i18n
@wxt-dev/is-background
@wxt-dev/module-react
@wxt-dev/module-solid
@wxt-dev/module-svelte
@wxt-dev/module-vue
@wxt-dev/runner
@wxt-dev/storage
@wxt-dev/unocss
@wxt-dev/webextension-polyfill
wxt
commit: |
Agent-Logs-Url: https://github.com/wxt-dev/wxt/sessions/1a956818-dd00-4908-a6f7-5279b8ae345c Co-authored-by: Timeraa <29104008+Timeraa@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2228 +/- ##
==========================================
+ Coverage 76.21% 76.43% +0.22%
==========================================
Files 115 115
Lines 3094 3094
Branches 685 685
==========================================
+ Hits 2358 2365 +7
+ Misses 653 649 -4
+ Partials 83 80 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Wanted to see how copilot agent is doing nowadays so if this PR is not up to par just close it @aklinker1. Haven't tested this at all yet |
|
@copilot can't |
|
@copilot can't sharp already render SVG files? Does it not support gradients? |
Interesting that it only listens to me huh
|
Yes,
Yes,
|
Overview
sharpcan render SVG files, but it delegates tolibrsvg(via libvips) which has known, platform-specific bugs withlinearGradientand related SVG features. Notably, sharp#1895 documents cases where SVGs usinglinearGradientcrashlibcairoon Linux with sharp's prebuilt binaries. The behavior is also inconsistent between macOS and Linux because each platform ships a different version oflibrsvg.This PR integrates
@resvg/resvg-js— a pure-Rust SVG renderer with more complete and consistent cross-platform SVG standard compliance — into theauto-iconsmodule. SVG files are now rendered to PNG via@resvg/resvg-jsfirst, and the resulting PNG buffer is then passed tosharpfor any post-processing (grayscale/overlay dev indicator, etc.). Non-SVG images continue to be handled directly bysharpas before.SVG rendering improvements:
@resvg/resvg-jsintoauto-iconsto render SVG files to PNG before resizing, addressing platform-specific limitations ofsharp'slibrsvgbackend (including crashes withlinearGradienton Linux). SVG files are detected by extension and processed withResvg, while non-SVG images are handled as before. (packages/auto-icons/src/index.ts)@resvg/resvg-jsand all necessary platform-specific binaries. (packages/auto-icons/package.json,pnpm-lock.yaml)Testing enhancements:
@resvg/resvg-js, handling of case-insensitive.svgextensions, per-size rendering, and fallback to the original logic for PNG files. Mocks were updated to simulate the new SVG rendering workflow. (packages/auto-icons/src/__test__/index.test.ts)Miscellaneous:
resvg,Resvg, andlibrsvgto the spellcheck allow-list. (cspell.yml)Manual Testing
linearGradientassrc/assets/icon.svgin a WXT project@wxt-dev/auto-iconstowxt.config.tswxt build— icons in.output/*/icons/should render with correct gradient colors instead of rendering incorrectly or crashing (as they would with sharp's librsvg backend on Linux)Related Issue