fix(vec2svg): deduplicate raster image resources - #884
Open
syrkis wants to merge 2 commits into
Open
Conversation
Author
|
Tinymist integration is available in Myriad-Dreamin/tinymist#2686. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #883
Summary
Deduplicate repeated PNG, JPEG, GIF, and WebP resources in
reflexo-vec2svg.Raster images are now emitted once in SVG definitions and placements reference the shared resource with
<use>. Resourceidentity is based on the image format and encoded bytes, while placement-specific sizing, transforms, alt text, and
image-renderingremain on each placement.Vector images retain the existing inline rendering path. Resource definitions remain scoped to each independently usable
SVG document.
Motivation
Previously, every placement embedded its own Base64 payload. Documents that reused large raster images could therefore
produce very large SVG output.
For the 100-placement regression case, the embedded payload count decreases from 100 to 1.
Compatibility
Both
hrefandxlink:hrefare emitted for image references. The generated SVG remains self-contained, and independentlyexported documents do not share definitions.
Testing
Added coverage for:
Validated with:
cargo fmt --all --checkcargo test -p reflexo-vec2svgcargo clippy -p reflexo-vec2svg --all-targets --all-features -- -D warningscargo build -p reflexo-vec2svgIncremental rendering
The browser-side SVG resource patcher now retains image definitions introduced by incremental updates.
This covers the case where a watched raster file changes and receives a new stable resource ID. The updated
<use>reference now resolves to the newly installed definition without refreshing the document.Validated with:
rollout.webp → rollout_2.webp → rollout.webp;