Upgrade to v1
Walks through what's new in v1 and how to upgrade from v0.
After over half year of development, Takumi is finally ready to reach its first stable release!
This means we've locked down the public API and are committed to maintaining backward compatibility for all v1.x releases.
Install
npm i takumi-js@1What has changed?
display defaults to inline
In the early stages, Takumi defaulted display to flex to simplify common layouts.
However, to stay as close to the CSS specification as possible and ensure LLMs can produce correct components without guessing, we've changed the default to inline.
Verify your templates and explicitly add display: flex (or the flex Tailwind class) to containers where flexbox layout is intended.
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
{/* Your content here */}
</div>JavaScript / TypeScript
Unified Runtime Dectection & Fallback
For better DX, takumi-js now automatically detects the best bindings for your environment Node.js, Workers, etc.
That means you no longer need to worry about importing NAPI or WASM bindings.
emoji Option for Dynamic Emojis Loading
To improve the compability with Next.js's ImageResponse API, takumi-js now supports an emoji option that allows you to specify a custom emoji provider.
By default it's set to twemoji, if you want to source emoji glyphs from a custom font, simply set it to from-font and make sure an emoji font is included in the fonts option.
Read more in Render Emojis section.
import notoEmojiFont from "@fontsource/noto-color-emoji/files/noto-color-emoji-emoji-400-normal.woff2";
export function GET() {
return new ImageResponse(<div>It works! 😀</div>, {
emoji: "from-font",
fonts: [
{
name: "Noto Color Emoji",
data: notoEmojiFont,
},
],
});
}Lowercase Image Formats
To be more consistent with the CSS ecosystem and web standards, all image format options in @takumi-rs/core now use lowercase strings only.
const image = await renderer.render(node, {
format: "WebP"
format: "webp"
});putPersistentImage() Now Takes ImageSource
renderer.putPersistentImage() in @takumi-rs/core no longer accepts a raw Buffer as the second argument. Pass an ImageSource object instead.
const data = await readFile("foo.png");
await renderer.putPersistentImage("foo.png", data);
await renderer.putPersistentImage({ src: "foo.png", data }); Deprecated Types & Functions Removed (@takumi-rs/core)
All previously deprecated exports in @takumi-rs/core have been removed in v1. If you were relying on any deprecated APIs, update to the non-deprecated alternatives before upgrading.
Rust
RenderOptions::builder() Replaces RenderOptionsBuilder
The standalone RenderOptionsBuilder struct has been removed. Use the associated builder() method on RenderOptions instead. This switches to typed-builder, providing compile-time validation without the need for .unwrap().
let options = RenderOptionsBuilder::default().build().unwrap();
let options = RenderOptions::builder().build(); FetchTaskCollection Removed
FetchTaskCollection has been removed. Use Node::resource_urls and Style::resource_urls to retrieve the URLs of resources that need to be fetched, then provide them back to the renderer directly.
parse_svg_str Removed
The free function parse_svg_str has been removed. Use SvgSource::from_str instead.
let svg = parse_svg_str(data)?;
let svg = SvgSource::from_str(data)?; SpacePair::from_reversed_pair Removed
The SpacePair::from_reversed_pair constructor has been removed with no direct replacement. Construct SpacePair directly with the values in the correct order.
TakumiError Replaced by takumi::error::Error
The re-exported TakumiError type alias has been removed. Use takumi::error::Error directly.
use takumi::TakumiError;
use takumi::error::Error; Viewport Constructor Parameter Change
Viewport no longer implements From<(u32, u32)>. Update any tuple-based constructions to use the explicit constructor.
let viewport = (800_u32, 600_u32).into();
let viewport = Viewport::new((800, 600)); ImageSource::size() Is Now Private
ImageSource::size() has been made private. It was an internal helper and should not have been part of the public API.
detailed_css_error Feature Removed
The detailed_css_error Cargo feature has been removed. Detailed CSS error reporting is no longer gated behind a feature flag.
More in Changelog!
For a more comprehensive list of changes, please refer to the changelog in releases.
Last updated on