fix(rspress-plugin-mermaid): fix render id handling - #36
Merged
Conversation
Co-Authored-By: Swifty <usr161043261@outlook.com>
mermaid v10 serializes render() calls through its internal execution queue, so the module-level queue in the plugin is unnecessary. Co-Authored-By: Swifty <usr161043261@outlook.com>
Co-Authored-By: Swifty <usr161043261@outlook.com>
Contributor
Author
|
The latest commit 19830f4 fixes the rs fmt --check failure. The wrapped import in packages/rspress-plugin-mermaid/src/index.ts has been collapsed back to a single line. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Serialize mermaid renders through a module-level queue because mermaid v10render()is not reentrant: concurrent renders share temporary DOM elements keyed by the render id and corrupt each other's outputuseId()value before using it as the mermaid render id; only:was stripped previously, while other React versions emit characters that must not leak into SVG ids andurl(#...)marker references (e.g.«»in React 19.0-19.1)import.meta.dirnameinstead of__dirnameso the plugin works in ESMMermaidRendererPropsin the component to keep the published component self-contained, and addrspress-plugin-mermaidas a devDependency for type checkingTest plan
pnpm testpassespnpm exec rstest run --config rstest.e2e.config.ts packages/rspress-plugin-mermaid/index.spec.ts: 5 tests pass (SVG rendering, labels, concurrent diagrams, dark mode toggle, invalid diagram fallback)