@streamdown/code@2.0.0

Vanilagy/mediabunny@streamdown/code@2.0.0Sep 30, 2026by github-actions[bot]

Upgrading?

AI Summary

This is a major version bump for the code highlighting library, upgrading to Shiki v4 and enforcing Node.js 20+. It introduces performance optimizations for streaming code blocks by only tokenizing new lines and introduces a bounded Least Recently Used (LRU) cache to manage memory usage.

Key Highlights

  • Upgrade to Shiki v4
  • Node.js 20 or newer is now required
  • Incremental tokenization during streaming
  • Bounded LRU cache for finished code blocks

Breaking Changes

  • Node.js 20 or newer is now required when using @streamdown/code

New Features

  • Tokenize only new lines of a code block while streaming
  • Least-recently-used cache (LRU) for finished code blocks
  • Cache size limits based on tokens, lines, and characters

Full Release Notes

### Major Changes

- db6fefc: Upgrade Shiki to v4. Node.js 20 or newer is now required when using `@streamdown/code`.

### Patch Changes

- 0ea9e64: Tokenize only the new lines of a code block while it streams instead of re-tokenizing the whole block on every update.
- 4ec5639: Bound the code highlight cache. Results of streaming code blocks are no longer cached (each is superseded by the next update), and finished code blocks are kept in a least-recently-used cache bounded by their size (tokens, lines and characters) and by a limit of 5,000 results. Lookups compare the full code, so blocks that differ only in the middle no longer share tokens. A code block also ignores highlight results for code it has already moved past.

Related Repositories