Skip to content

Upgrading @takumi-rs/core 1 to 2

Breaking1.8.7 → 2.19.0Breaking43Security5Platform1Deprecated2New67Changed148Fixed151Other7

Fetching 99 releases from GitHub…96 / 99
BreakingUpgrade verdict

36 breaking changes and a platform requirement change and 5 security fixes.

  • Building the Rust crate with fewer features changes what works: animated images need a format feature, and without the png feature PNG images cannot be drawn and PNG encoding is unavailable.
  • The wasm and PDF packages no longer load WOFF1 fonts, so convert them to WOFF2, TTF, or OTF.
  • Code using the GIF-specific type and error names must switch to the new animation-wide names.
  • Some list behaviours change: reversed ordered lists no longer count down, gradient bullet images fall back to the counter style, and menu/dir elements no longer start their own list numbering.
Top 5 of 44 that need code or config changes

Node.js requirement changed in 2.0.0-beta.9: >= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0 → >=18.

Breaking36
Splits takumi's Cargo features so ImageSource::Animated needs gif, png or webp, and png is only on by default via image-decoding.
ImageSource::Animatedimage-decodingpnggifwebpsvg-sizingsvgImageBuffer::encode_png
Drops WOFF1 support from @takumi-rs/wasm and takumi-pdf; @takumi-rs/core keeps WOFF1.
@takumi-rs/wasmtakumi-pdf@takumi-rs/core
Renames ImageSource::Gif to ImageSource::Animated, GifSource to AnimatedSource, and ImageError::InvalidGif to ImageError::InvalidAnimation.
ImageSource::GifImageSource::AnimatedGifSourceAnimatedSourceImageError::InvalidGifImageError::InvalidAnimation
Drops reversed handling, gradient list-style-image markers, and menu/dir list counting; <ol reversed> now counts up and only ul/ol scope counts.
olreversedlist-style-imageulmenudir
Replaces ImageCache with ResourceCache sharing one byte budget across images, SVG sources, rasters and stylesheets; default budget drops from 64 MiB to 16 MiB.
ImageCacheResourceCacheResourceCache::newRenderercacheMaxBytesRenderOptions.stylesheetArc<StyleSheet>
Drops the preact-render-to-string optional import; Preact trees traverse natively and components calling Preact hooks no longer render.
preact-render-to-string
The background shorthand no longer parses or resets background-blend-mode, and Background.blend_mode is removed.
backgroundbackground-blend-modeblend_modeBackground
Removes the ./wasm export; import from @takumi-rs/image-response instead.
@takumi-rs/image-response/wasm@takumi-rs/image-response
Makes BuiltInlineLayout layout fields private and removes several public inline-layout functions.
BuiltInlineLayout::layoutBuiltInlineLayout::custom_inline_boxesBuiltInlineLayout::measure_runsMeasuredInlineRunMeasuredInlineBoxget_parent_font_metricsresolve_inline_line_metricsresolve_inline_line_statesparley::Layout
Renames the svg feature to svg-source; svg-backend is unchanged.
svgsvg-sourcesvg-backend
Removes Renderer.encodeFrames and its EncodeFramesOptions and AnimationFrameSource types.
Renderer.encodeFramesEncodeFramesOptionsAnimationFrameSourcerenderAnimation
Renames the googleFonts family field from family to name; bare string families are unchanged.
googleFontsGoogleFontFamilyfamiliesnamefamily
Removes the text option from googleFonts because it stripped unicode-range and made glyph routing ambiguous.
googleFontstextunicode-range
Removes the createImageResponse factory; pass options straight to ImageResponse.
createImageResponseImageResponse
Renames the raster feature to raster-backend, mirroring svg-backend, and rayon no longer enables it implicitly.
rasterraster-backendsvg-backendrayon
Models image output quality per format: Jpeg/WebP carry a Quality, WebPLossless replaces lossless WebP, and write_image drops its quality argument.
ImageOutputFormat::JpegImageOutputFormat::WebPQualityWebPLosslesswrite_imagelossless
ResolvedOutlineGlyph::Plain and ResolvedOutlineGlyph::Color gain an ink field computed by outline_ink from their paths.
ResolvedOutlineGlyph::PlainResolvedOutlineGlyph::Coloroutline_ink
Shares computed style groups between boxes behind Rc, changing ComputedStyle fields and RenderContext::style to Rc<ComputedStyle>.
ComputedStyleRcRenderContext::styleRenderContextBuilder::stylebox_datainherited_data
base::resources::glyph::draw_outline replaces ErasedPen, drawing a skrifa OutlineGlyph through &mut dyn OutlinePen.
base::resources::glyph::draw_outlineErasedPenOutlineGlyphOutlinePen
Node trees nested deeper than 512 levels now fail with nodes nest deeper than 512 levels instead of crashing the process.
takumi_html::DEFAULT_MAX_DEPTHtakumi_core::layout::node::MAXIMUM_DOM_TREE_DEPTHtakumi::DEFAULT_MAX_DEPTH
SceneRequest::build replaces build_stacking_contexts; set paint_bounds: false to skip paint bounds and the text shaping they need.
SceneRequest::buildbuild_stacking_contextspaint_bounds
Applies text-overflow: ellipsis only to boxes that clip, matching Chrome, so overflow other than visible is now required.
text-overflowoverflowline-clamp
Merges custom_properties and registered_custom_properties into one custom_properties: CustomProperties field on ComputedStyle, read via get(name).
ComputedStylecustom_propertiesregistered_custom_propertiesCustomPropertiesget
Stylesheet rules now win over tw utilities because utilities sit in the last cascade layer.
tw@layer!
Rejects style values with trailing content instead of silently applying a prefix.
stylewidthvar()
Returns css from fromJsx and fromHtml, deprecating the stylesheets field.
fromJsxfromHtmlcssstylesheetsObject.keys
Stores calc() as non-zero terms, shrinking Length to 20 bytes; calc() expressions mixing more than four distinct units now fail to parse.
Lengthcalc()
Types KeyframesMap and KeyframeRule declarations with csstype Properties instead of DOM's CSSStyleDeclaration.
KeyframesMapKeyframeRuleCSSStyleDeclarationPropertiescsstype
font_families and lang options now take resolved values instead of raw strings.
font_familieslang
Replaces extractResourceUrls and fetchResources with prepareImages, which collects and fetches a node tree's remote images.
prepareImagesextractResourceUrlsfetchResourcesfetchCacheimagessourcesfetchtimeout
Changes max-width and max-height to a MaxSize value with initial None, and column-gap, row-gap and gap to a Gap value with initial Normal.
max-widthmax-heightMaxSizecolumn-gaprow-gapgapGapto_css
Replaces fetchResources and extractResourceUrls with prepareImages in @takumi-rs/helpers.
fetchResourcesextractResourceUrlsprepareImagesfetchCacheimages
Replaces googleFont and googleFontSubsets with one object-shaped googleFonts.
googleFontgoogleFontSubsetsgoogleFonts
Makes fonts and images explicit per-render resources, dropping the persistent image store and GlobalContext.
GlobalContextregisterFontloadFontloadFontSyncloadFontsfontFamiliesimagesfetchedResources
Makes the Renderer constructor parameterless and registers fonts with registerFont.
RendererregisterFont
Minimizes the public API: prelude exposes stable data structures, entry points at crate root, backends behind unstable feature, internals pub(crate).
takumi::preludeunstablepub(crate)
Security5
fromJsx escapes text inside <svg> elements to prevent markup injection, and throws on invalid XML names and unsafe style values.
fromJsxsvgstyle
Enforces allowUrl and maxBytes fetch policies on shared fetchCache hits.
fetchCacheallowUrlmaxBytes
Enforces allowUrl on every redirect hop, following redirects manually up to 5 hops and re-checking each resolved target.
fetchOkallowUrl
Caps image decode dimensions at 8192x8192 and limits GIF total-frame pixels to prevent decode-bomb OOM.
image::Limits
Decoders reject images beyond 8192x8192 and GIFs beyond a total-frame pixel budget, stopping decode-bomb OOM.
image::Limits
Platform1
These packages, plus takumi-js and @takumi-rs/image-response, now require Node 20.19 or newer.
takumi-js@takumi-rs/image-response
Deprecated2
Deprecates subsetOf and subsetRank; subsetOf now only sets the family name and subsetRank does nothing.
googleFontssubsetOfsubsetRankFontResource::unicode_range
Renames the stylesheets render option to css; the old name still works and warns once.
stylesheetscsstakumi-jstakumi-pdf