chore(examples): regenerate WeChat 构建npm fixture for the new build - #13
Conversation
Refresh the checked-in examples/wechat/miniprogram_npm/@ant-design/x-markdown-mini fixture from the rebuilt package so the WeChat example opens without a manual 构建npm step and exercises the new code: shared CDN KaTeX loader (shared/loadKatexFonts.js), reflow-once flicker fix, atomic list markers, and the dropped base64 katex-font-data.js + plugins/Latex/fonts.wxss. Build output only — no library source change. Stacks on the library fix (#12); merge after it. The example dependency version bump is handled at release time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 50 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (15)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
Code Review
This pull request refactors KaTeX font loading by extracting the logic into a shared loadKatexFonts.js module, which is now utilized across both the Markdown and MiniNodeRenderer components. It also introduces a segClassOf helper to prevent visual gaps in inline code during streaming animations, adds polyfills for Array.prototype.at and String.prototype.at, and implements a blockStart function for block KaTeX tokens. Feedback on these changes highlights that onKatexFontsReady fails to execute the callback if fonts are already loaded, and that hasKatexNodes should use Array.isArray to safely handle non-array inputs and avoid potential runtime errors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| function onKatexFontsReady(cb) { | ||
| ensureKatexFonts(); | ||
| if (ready) return; | ||
| readyCallbacks.push(cb); | ||
| } |
There was a problem hiding this comment.
If ready is already true (e.g., after fonts have successfully loaded or if the API is resolved as null), calling onKatexFontsReady(cb) will return immediately without ever executing the callback cb. This means any components or features relying on this callback after the initial load will never run.
We should execute the callback immediately (using callSafe(cb)) if ready is true.
function onKatexFontsReady(cb) {
ensureKatexFonts();
if (ready) {
callSafe(cb);
return;
}
readyCallbacks.push(cb);
}| function hasKatexNodes(nodes) { | ||
| return !!nodes && nodes.some((node) => !!node && (String((node.attrs || {}).class || "").indexOf("katex") > -1 || hasKatexNodes(node.children))); | ||
| } |
There was a problem hiding this comment.
Using !!nodes is not fully safe if nodes is passed as a non-array object (e.g., {}), which would cause nodes.some to throw a TypeError. Using Array.isArray(nodes) is a safer and more robust check to prevent potential runtime crashes.
| function hasKatexNodes(nodes) { | |
| return !!nodes && nodes.some((node) => !!node && (String((node.attrs || {}).class || "").indexOf("katex") > -1 || hasKatexNodes(node.children))); | |
| } | |
| function hasKatexNodes(nodes) { | |
| return Array.isArray(nodes) && nodes.some((node) => !!node && (String((node.attrs || {}).class || "").indexOf("katex") > -1 || hasKatexNodes(node.children))); | |
| } |
| function hasKatexNodes(nodes) { | ||
| return !!nodes && nodes.some((node) => !!node && (String((node.attrs || {}).class || "").indexOf("katex") > -1 || hasKatexNodes(node.children))); | ||
| } |
There was a problem hiding this comment.
Using !!nodes is not fully safe if nodes is passed as a non-array object (e.g., {}), which would cause nodes.some to throw a TypeError. Using Array.isArray(nodes) is a safer and more robust check to prevent potential runtime crashes.
| function hasKatexNodes(nodes) { | |
| return !!nodes && nodes.some((node) => !!node && (String((node.attrs || {}).class || "").indexOf("katex") > -1 || hasKatexNodes(node.children))); | |
| } | |
| function hasKatexNodes(nodes) { | |
| return Array.isArray(nodes) && nodes.some((node) => !!node && (String((node.attrs || {}).class || "").indexOf("katex") > -1 || hasKatexNodes(node.children))); | |
| } |
🤔 This is a ...
🔗 Related Issues
Companion to #12 (Alipay real-device KaTeX fonts + streaming fixes). Stacked on #12 — merge after it.
💡 Background and Solution
Regenerates the checked-in WeChat 构建npm fixture (
examples/wechat/miniprogram_npm/@ant-design/x-markdown-mini) from the rebuilt package, so the WeChat example opens in the IDE without a manual 构建npm step and runs the new code: the shared CDN KaTeX loader (shared/loadKatexFonts.js), the reflow-once flicker fix, atomic list markers, and the removed base64katex-font-data.js+plugins/Latex/fonts.wxss.Build output only — no library source in this PR. Personal IDE config (
project.config.jsonappid,project.private.config.json) is intentionally excluded. Theexamples/*/package.jsondependency version bump is handled in the release step once the beta is published.📝 Change Log