Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/plain-animate-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"streamdown": patch
---

Remove the obsolete rehypeAnimate name override; processor caching now uses function identity.
2 changes: 1 addition & 1 deletion .changeset/quiet-plugins-render.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"streamdown": patch
---

Distinguish remark and rehype plugins by function identity when caching processors, so same-name plugins with different closures do not reuse each other's behavior.
Distinguish remark and rehype plugins by function identity when caching processors, so same-name plugins with different closures do not reuse each other's behavior. Apps that create plugin functions during render now get a new processor on each render. This is slower for that pattern but does not grow memory; create plugins once (module scope or `useMemo`) to keep cache hits.
7 changes: 0 additions & 7 deletions packages/streamdown/lib/animate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,6 @@ const processTextNode = (
return index + nodes.length;
};

let instanceId = 0;

/**
* Create an animate rehype plugin. The optional `timeline` is an internal
* Streamdown wiring detail — not part of the public `animated` prop surface.
Expand Down Expand Up @@ -636,7 +634,6 @@ function buildAnimatePlugin(
pendingMark: null,
};

const id = instanceId++;
const rehypeAnimate = () => (tree: Root) => {
const charCounter = { count: 0, newIndex: 0 };

Expand Down Expand Up @@ -692,10 +689,6 @@ function buildAnimatePlugin(
renderState.prevContentLength = 0;
};

Object.defineProperty(rehypeAnimate, "name", {
value: `rehypeAnimate$${id}`,
});

return {
name: "animate",
type: "animate",
Expand Down
Loading