feat(webui): render Mermaid diagrams with Pele (#6302)
* feat(webui): render Mermaid diagrams with Pele * fix(webui): reserve diagram replacement capacity * fix(webui): prebundle lazy diagram worker dependencies * fix(webui): account diagram capacity by encoded size * fix(webui): use shared hover hints for diagram actions * docs(webui): focus diagram guide on usage
This commit is contained in:
1 parent
0f3b47bc3a
commit
f57018aa7f
40 files changed
+2335
-1458
No files matched your search
@@ -32,7 +32,7 @@ function startupSkeleton(): Plugin {
|
||||
|
||||
const GZIP_MIN_BYTES = 4 * 1024;
|
||||
const GZIP_ASSET_PATTERN = /\.(?:css|html|js|json|mjs|svg)$/i;
|
||||
const LAZY_FEATURE_CHUNK_PREFIXES = ["markdown-vendor-", "syntax-highlight-", "katex-"];
|
||||
const LAZY_FEATURE_CHUNK_PREFIXES = ["markdown-vendor-", "markdown-diagrams-", "MermaidBlock-", "syntax-highlight-", "katex-"];
|
||||
|
||||
export function entryLazyFeatureImports(imports: string[]): string[] {
|
||||
return imports.filter((fileName) =>
|
||||
@@ -108,8 +108,7 @@ export function webuiManualChunk(id: string): string | undefined {
|
||||
if (id.includes("node_modules/refractor/lang/")) {
|
||||
return;
|
||||
}
|
||||
// Streamdown lazy-loads diagrams and highlighted code. Keep those modules
|
||||
// outside the core markdown chunk so ordinary replies do not download them.
|
||||
// Streamdown retains a lazy viewer shell, not the native Mermaid engine.
|
||||
if (id.includes("node_modules/streamdown/dist/mermaid-")) return "markdown-diagrams";
|
||||
if (id.includes("node_modules/streamdown/dist/highlighted-body-")) return "markdown-code";
|
||||
// Refractor reaches this HAST helper through hastscript. Keeping it with
|
||||
@@ -158,8 +157,14 @@ export default defineConfig(({ mode }) => {
|
||||
// Pre-bundle Dialog up front, including lazy settings/sheets. Excluding
|
||||
// it splits its layer/focus state from optimized Popover and DropdownMenu,
|
||||
// so nested overlays can dismiss the wrong layer in development.
|
||||
include: ["@radix-ui/react-dialog"],
|
||||
include: [
|
||||
"@radix-ui/react-dialog",
|
||||
// Vite's HTML scan does not follow the lazy Worker entry. Discovering
|
||||
// these imports on first render would reload the page and lose UI state.
|
||||
"pele/lazy", "saxes", "css-tree/parser", "css-tree/walker", "css-tree/generator",
|
||||
],
|
||||
},
|
||||
worker: { format: "es" },
|
||||
build: {
|
||||
outDir: path.resolve(__dirname, "../nanobot/web/dist"),
|
||||
emptyOutDir: true,
|
||||
|
||||
Reference in new issue
Block a user