diff --git a/.changeset/plain-animate-name.md b/.changeset/plain-animate-name.md new file mode 100644 index 00000000..c826ff09 --- /dev/null +++ b/.changeset/plain-animate-name.md @@ -0,0 +1,5 @@ +--- +"streamdown": patch +--- + +Remove the obsolete rehypeAnimate name override; processor caching now uses function identity. diff --git a/.changeset/quiet-plugins-render.md b/.changeset/quiet-plugins-render.md index 5ada25f2..7d28c5ec 100644 --- a/.changeset/quiet-plugins-render.md +++ b/.changeset/quiet-plugins-render.md @@ -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. diff --git a/packages/streamdown/lib/animate.ts b/packages/streamdown/lib/animate.ts index 642a2566..ac80861b 100644 --- a/packages/streamdown/lib/animate.ts +++ b/packages/streamdown/lib/animate.ts @@ -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. @@ -636,7 +634,6 @@ function buildAnimatePlugin( pendingMark: null, }; - const id = instanceId++; const rehypeAnimate = () => (tree: Root) => { const charCounter = { count: 0, newIndex: 0 }; @@ -692,10 +689,6 @@ function buildAnimatePlugin( renderState.prevContentLength = 0; }; - Object.defineProperty(rehypeAnimate, "name", { - value: `rehypeAnimate$${id}`, - }); - return { name: "animate", type: "animate",