Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

fix: revert @muyajs/core to 0.0.39 to unblock Features/Themes preview#103

Merged
Jocs merged 1 commit into
masterfrom
worktree-atomic-swinging-starfish
May 20, 2026
Merged

fix: revert @muyajs/core to 0.0.39 to unblock Features/Themes preview#103
Jocs merged 1 commit into
masterfrom
worktree-atomic-swinging-starfish

Conversation

@Jocs

@Jocs Jocs commented May 20, 2026

Copy link
Copy Markdown
Member

Summary

  • Reverts PR chore: upgrade @muyajs/core to 0.1.0 and drop mermaid workaround #99 (the @muyajs/core 0.0.39 → 0.1.0 upgrade) because 0.1.0 breaks MarkdownToHtml.renderHtml() on first call, so the Features and Themes previews render "Error rendering content" / "Error rendering theme content" both locally and at https://marktext.me.
  • Restores the explicit mermaid dep and the rewrapMermaidSource + manual mermaid.run() workaround for the pre-existing 0.0.39 walkTokens accumulation bug.

Root cause

@muyajs/core@0.1.0 ships its mermaid integration as separate ESM chunks with a circular import between chunk-5ZQYHXKU-CWjquzqa.mjs and mermaid.core-CXkc5gBm.mjs. The consumer chunk runs var Ie = pe() at module init, but pe (the default-export of mermaid.core, lazily wrapped through the t helper) hasn't been assigned yet, so it throws TypeError: pe is not a function inside renderHtml(). The promise rejects and Feature.tsx/Theme.tsx both fall into their .catch branches.

Re-upgrade once @muyajs/core ships a release that fixes the circular chunk init.

Test plan

  • pnpm install --no-frozen-lockfile && pnpm dev — visit http://localhost:8080, confirm Features (Table/Diagram/Inline/Math/Code) and all six Themes render without Error rendering ….
  • Click through every Feature tab and every Theme — confirm mermaid SVGs render in the Diagram tab and no console errors appear.
  • pnpm build && pnpm preview — same checks on the production build at http://localhost:4173.
  • pnpm type-check passes.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 20, 2026 05:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reverts @muyajs/core from 0.1.0 back to 0.0.39 to restore working MarkdownToHtml.renderHtml() behavior, and reintroduces an explicit mermaid dependency + manual rendering path to keep Features/Themes previews rendering diagrams reliably.

Changes:

  • Downgrade @muyajs/core to ^0.0.39 and add mermaid as a direct dependency.
  • Add rewrapMermaidSource() in markdownToHtml to detect “lost language” mermaid code blocks and wrap them as <div class="mermaid">…</div>.
  • Reintroduce manual mermaid rendering in Feature.tsx and Theme.tsx.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/utils/markdownToHtml.ts Adds a workaround to rewrap mermaid sources when muya/marked loses the code language across calls.
src/components/Feature.tsx Reintroduces mermaid initialization and a mermaid.run() render pass for the Diagram feature.
src/components/Theme.tsx Reintroduces mermaid rendering for the theme preview and attempts to switch mermaid theme based on selected UI theme.
package.json Reverts @muyajs/core version and adds mermaid dependency.
pnpm-lock.yaml Updates lockfile for the dependency revert and reintroduced mermaid dependency.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/Theme.tsx
for (const code of codes) {
const preEle = code.parentNode as HTMLElement
const mermaidContainer = document.createElement('div')
mermaidContainer.innerHTML = code.innerHTML
Comment thread src/components/Theme.tsx
Comment on lines +75 to +83
const codes = muyaContainerRef.current.querySelectorAll('code.language-mermaid')
for (const code of codes) {
const preEle = code.parentNode as HTMLElement
const mermaidContainer = document.createElement('div')
mermaidContainer.innerHTML = code.innerHTML
mermaidContainer.classList.add('mermaid')
preEle.replaceWith(mermaidContainer)
}
mermaid.init({}, muyaContainerRef.current.querySelectorAll('div.mermaid'))
Comment thread src/components/Theme.tsx
Comment on lines 86 to +95
const selectTheme = (theme: ThemeItem) => {
if (/dark/i.test(theme.label)) {
mermaid.initialize({
theme: 'dark'
})
} else {
mermaid.initialize({
theme: 'default'
})
}
Comment thread pnpm-lock.yaml Outdated
Comment on lines 1210 to 1212
dompurify@3.3.0:
resolution: {integrity: sha512-r+f6MYR1gGN1eJv0TVQbhA7if/U7P87cdPl3HN5rikqaBSBxLiCb/b9O+2eG0cxz0ghyU+mU1QkbsOwERMYlWQ==}

@muyajs/core@0.1.0 ships its mermaid integration as separate ESM chunks
that have a circular import between chunk-5ZQYHXKU and mermaid.core. The
consumer chunk runs `var Ie = pe()` at module init while `pe` (the
default-export of mermaid.core, lazily wrapped through the `t` helper)
hasn't been assigned yet, so it throws `TypeError: pe is not a function`
inside MarkdownToHtml.renderHtml(). The promise rejects and both
Feature.tsx and Theme.tsx fall into their `.catch` branches, rendering
"Error rendering content" / "Error rendering theme content" on the live
site (https://marktext.me) and any local build using 0.1.0.

Revert PR #99 to restore @muyajs/core@^0.0.39, the explicit `mermaid`
dependency, and the existing `rewrapMermaidSource` + manual
`mermaid.run()` workaround for 0.0.39's walkTokens accumulation bug.
Re-upgrade once @muyajs/core ships a release that fixes the circular
chunk init.

This reverts commit aae5452.
@Jocs Jocs force-pushed the worktree-atomic-swinging-starfish branch from e01b6e3 to e400860 Compare May 20, 2026 05:13
@Jocs Jocs merged commit 060ddd4 into master May 20, 2026
0 of 4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants