@burtson-labs/bandit-engine 2.0.63 → 2.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chat-ERXFEUR5.mjs → chat-57M4OXFX.mjs} +4 -4
- package/dist/{chunk-SYBMWGMA.mjs → chunk-7EPFQDJW.mjs} +5 -5
- package/dist/chunk-7EPFQDJW.mjs.map +1 -0
- package/dist/{chunk-NCMSNXB2.mjs → chunk-FXFTA5PZ.mjs} +4 -3
- package/dist/chunk-FXFTA5PZ.mjs.map +1 -0
- package/dist/{chunk-UQ4VQSWS.mjs → chunk-HKQSZALO.mjs} +2 -2
- package/dist/{chunk-5NSOHUCR.mjs → chunk-O44AP4XI.mjs} +5 -5
- package/dist/{chunk-E4Q7BHBQ.mjs → chunk-O7M4OPZU.mjs} +22 -10
- package/dist/{chunk-E4Q7BHBQ.mjs.map → chunk-O7M4OPZU.mjs.map} +1 -1
- package/dist/index.js +26 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/management/management.js +26 -13
- package/dist/management/management.js.map +1 -1
- package/dist/management/management.mjs +4 -4
- package/dist/modals/chat-modal/chat-modal.js +3 -2
- package/dist/modals/chat-modal/chat-modal.js.map +1 -1
- package/dist/modals/chat-modal/chat-modal.mjs +2 -2
- package/package.json +1 -1
- package/dist/chunk-NCMSNXB2.mjs.map +0 -1
- package/dist/chunk-SYBMWGMA.mjs.map +0 -1
- /package/dist/{chat-ERXFEUR5.mjs.map → chat-57M4OXFX.mjs.map} +0 -0
- /package/dist/{chunk-UQ4VQSWS.mjs.map → chunk-HKQSZALO.mjs.map} +0 -0
- /package/dist/{chunk-5NSOHUCR.mjs.map → chunk-O44AP4XI.mjs.map} +0 -0
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
useNotificationService,
|
|
25
25
|
useTTS,
|
|
26
26
|
useVoiceStore
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-FXFTA5PZ.mjs";
|
|
28
28
|
import {
|
|
29
29
|
brandingService_default,
|
|
30
30
|
toTitleCase,
|
|
@@ -2803,4 +2803,4 @@ export {
|
|
|
2803
2803
|
MAX_WINDOWED_HEIGHT,
|
|
2804
2804
|
chat_modal_default
|
|
2805
2805
|
};
|
|
2806
|
-
//# sourceMappingURL=chunk-
|
|
2806
|
+
//# sourceMappingURL=chunk-HKQSZALO.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StreamingMarkdown_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-O7M4OPZU.mjs";
|
|
4
4
|
import {
|
|
5
5
|
aiProviderInitService
|
|
6
6
|
} from "./chunk-VTC6AIWY.mjs";
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-6QTTNYF2.mjs";
|
|
10
10
|
import {
|
|
11
11
|
chat_modal_default
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-HKQSZALO.mjs";
|
|
13
13
|
import {
|
|
14
14
|
AddIcon,
|
|
15
15
|
ArchiveIcon,
|
|
@@ -80,7 +80,7 @@ import {
|
|
|
80
80
|
predefinedThemes,
|
|
81
81
|
useNotificationService,
|
|
82
82
|
useVoiceStore
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-FXFTA5PZ.mjs";
|
|
84
84
|
import {
|
|
85
85
|
authenticationService,
|
|
86
86
|
brandingService_default,
|
|
@@ -9459,7 +9459,7 @@ var MCPToolsTabV2_default = MCPToolsTabV2;
|
|
|
9459
9459
|
|
|
9460
9460
|
// src/management/management.tsx
|
|
9461
9461
|
import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
9462
|
-
var preloadChatPage = () => import("./chat-
|
|
9462
|
+
var preloadChatPage = () => import("./chat-57M4OXFX.mjs");
|
|
9463
9463
|
var buildCapabilitiesUrl = (gatewayApiUrl) => {
|
|
9464
9464
|
const trimmed = gatewayApiUrl.replace(/\/$/, "");
|
|
9465
9465
|
if (trimmed.endsWith("/api")) {
|
|
@@ -10804,4 +10804,4 @@ export {
|
|
|
10804
10804
|
useGatewayMemory,
|
|
10805
10805
|
management_default
|
|
10806
10806
|
};
|
|
10807
|
-
//# sourceMappingURL=chunk-
|
|
10807
|
+
//# sourceMappingURL=chunk-O44AP4XI.mjs.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
getHighlightTree,
|
|
5
5
|
markdownSanitizeSchema,
|
|
6
6
|
renderLowlightChildren
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FXFTA5PZ.mjs";
|
|
8
8
|
|
|
9
9
|
// src/components/StreamingMarkdown.tsx
|
|
10
10
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
@@ -434,8 +434,8 @@ ${listMarkdown}`;
|
|
|
434
434
|
{
|
|
435
435
|
ref: containerRef,
|
|
436
436
|
sx: {
|
|
437
|
-
//
|
|
438
|
-
transition: "opacity
|
|
437
|
+
// Settle the whole block to full color a beat after streaming ends.
|
|
438
|
+
transition: "opacity 380ms ease-out, transform 220ms ease-out",
|
|
439
439
|
"& .cursor": {
|
|
440
440
|
display: showCursor ? "inline" : "none",
|
|
441
441
|
animation: "blink 1s step-start infinite"
|
|
@@ -443,16 +443,18 @@ ${listMarkdown}`;
|
|
|
443
443
|
"@keyframes blink": {
|
|
444
444
|
"50%": { opacity: 0 }
|
|
445
445
|
},
|
|
446
|
+
// Each newly-written word focuses in — blur→sharp, a tiny rise, and fade —
|
|
447
|
+
// like ink settling onto the page as the typewriter writes.
|
|
446
448
|
"& .bl-fade-word": {
|
|
447
449
|
opacity: 0,
|
|
448
|
-
animation: "bl-fade-in
|
|
450
|
+
animation: "bl-fade-in 480ms cubic-bezier(0.22, 1, 0.36, 1) forwards"
|
|
449
451
|
},
|
|
450
452
|
"@keyframes bl-fade-in": {
|
|
451
|
-
from: { opacity: 0, transform: "translateY(
|
|
452
|
-
to: { opacity: 1, transform: "translateY(0)" }
|
|
453
|
+
from: { opacity: 0, filter: "blur(3px)", transform: "translateY(2px)" },
|
|
454
|
+
to: { opacity: 1, filter: "blur(0)", transform: "translateY(0)" }
|
|
453
455
|
},
|
|
454
|
-
//
|
|
455
|
-
opacity: isStreaming ? 0.
|
|
456
|
+
// Dimmed while streaming, then brightens to full color once the answer lands.
|
|
457
|
+
opacity: isStreaming ? 0.86 : 1,
|
|
456
458
|
transform: isStreaming ? "translateY(0.25px)" : "none",
|
|
457
459
|
// Reduce layout jumpiness between updates
|
|
458
460
|
"& p:last-child": { marginBottom: 0 },
|
|
@@ -478,9 +480,19 @@ ${listMarkdown}`;
|
|
|
478
480
|
}
|
|
479
481
|
);
|
|
480
482
|
};
|
|
481
|
-
var
|
|
483
|
+
var arePropsEqual = (prev, next) => {
|
|
484
|
+
if (prev.content !== next.content || prev.isStreaming !== next.isStreaming) {
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
const a = prev.sources;
|
|
488
|
+
const b = next.sources;
|
|
489
|
+
if (a === b) return true;
|
|
490
|
+
if (!a || !b || a.length !== b.length) return false;
|
|
491
|
+
return a.every((s, i) => s.id === b[i].id && s.name === b[i].name);
|
|
492
|
+
};
|
|
493
|
+
var StreamingMarkdown_default = React.memo(StreamingMarkdown, arePropsEqual);
|
|
482
494
|
|
|
483
495
|
export {
|
|
484
496
|
StreamingMarkdown_default
|
|
485
497
|
};
|
|
486
|
-
//# sourceMappingURL=chunk-
|
|
498
|
+
//# sourceMappingURL=chunk-O7M4OPZU.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/StreamingMarkdown.tsx"],"sourcesContent":["/*\n © 2025 Burtson Labs — Licensed under Business Source License 1.1\n https://burtson.ai/license\n\n This file is protected intellectual property.\n Do NOT use in commercial software, prompts, AI training data, or derivative works without a valid commercial license.\n\n 🚫 AI NOTICE: This file contains visible and invisible watermarks.\n ⚖️ VIOLATION NOTICE: Removing, modifying, or obscuring these watermarks is a license violation.\n 🔒 LICENSE TERMINATION: Upon license termination, ALL forks, copies, and derivatives must be permanently deleted.\n 📋 AUDIT TRAIL: File usage is logged and monitored for compliance verification.\n*/\n\n// Bandit Engine Watermark: BL-WM-4F0E-E71F75\nconst __banditFingerprint_components_StreamingMarkdowntsx = 'BL-FP-BB12E1-3387';\nconst __auditTrail_components_StreamingMarkdowntsx = 'BL-AU-MGOIKVV9-FMED';\n// File: StreamingMarkdown.tsx | Path: src/components/StreamingMarkdown.tsx | Hash: 4f0e3387\n\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Box, Tooltip, IconButton } from \"@mui/material\";\nimport ReactMarkdown from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\nimport rehypeRaw from \"rehype-raw\";\nimport rehypeSanitize from \"rehype-sanitize\";\nimport { useTheme, alpha } from \"@mui/material/styles\";\nimport type { Element, Text, Root } from \"hast\";\nimport type { Components } from \"react-markdown\";\nimport type { CodeProps } from \"react-markdown/lib/ast-to-react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { getHighlightTree } from \"../utils/lowlight\";\nimport { markdownSanitizeSchema, renderLowlightChildren } from \"../utils/markdownRendering\";\nimport { CheckIcon, ContentCopyIcon } from \"../icons/lucide-icons\";\n\ninterface SourceSummary {\n id: string;\n name: string;\n}\n\ninterface StreamingMarkdownProps {\n content: string;\n isStreaming?: boolean;\n sources?: SourceSummary[];\n}\n\nconst StreamingMarkdown: React.FC<StreamingMarkdownProps> = ({\n content,\n isStreaming = false,\n sources,\n}) => {\n const theme = useTheme();\n const showCursor = isStreaming && content.trim().length > 0;\n const showLoader = isStreaming && content.trim().length === 0; // Show loader when streaming but no content yet\n const prevSanitizedRef = useRef<string>(\"\");\n const containerRef = useRef<HTMLDivElement | null>(null);\n const stableSourcesRef = useRef<SourceSummary[]>([]);\n\n const effectiveSources = useMemo(() => {\n if (Array.isArray(sources) && sources.length > 0) {\n stableSourcesRef.current = sources;\n return sources;\n }\n\n if (sources === undefined) {\n return stableSourcesRef.current;\n }\n\n stableSourcesRef.current = [];\n return [];\n }, [sources]);\n\n const normalizeTables = (markdown: string): string => {\n const lines = markdown.split(\"\\n\");\n const output: string[] = [];\n let inTable = false;\n let tableRows: string[][] = [];\n\n const flushTable = () => {\n if (tableRows.length === 0) return;\n const maxCols = Math.max(...tableRows.map((r) => r.length));\n const padded = tableRows.map((row) => [...row, ...Array(maxCols - row.length).fill(\"\")]);\n const header = padded[0];\n const separator = Array(maxCols).fill(\"---\");\n output.push(\"| \" + header.join(\" | \") + \" |\");\n output.push(\"| \" + separator.join(\" | \") + \" |\");\n for (let i = 1; i < padded.length; i++) {\n const row = padded[i];\n if (row.every((cell) => /^-+$/.test(cell))) continue;\n output.push(\"| \" + row.join(\" | \") + \" |\");\n }\n tableRows = [];\n inTable = false;\n };\n\n for (const line of lines) {\n if (/^\\s*\\|.*\\|\\s*$/.test(line)) {\n inTable = true;\n const cells = line.trim().slice(1, -1).split(\"|\").map((c) => c.trim());\n tableRows.push(cells);\n } else {\n if (inTable) flushTable();\n output.push(line);\n }\n }\n if (inTable) flushTable();\n return output.join(\"\\n\");\n };\n\n const sanitizeMarkdown = (raw: string): string => {\n let sanitized = raw.replace(/<[/]?start_of_turn>|<[/]?end[_]?of[_]?turn>/gi, \"\");\n // Unwrap Box wrappers\n sanitized = sanitized\n .replace(/<div class=\"MuiBox-root[^\"]*\"[^>]*>([\\s\\S]*?)<\\/div>/g, (_, inner) => inner.trim())\n .replace(/<div[^>]*>\\s*<\\/div>/g, \"\");\n // Collapse newline before common punctuation\n sanitized = sanitized.replace(/\\r?\\n\\s*:\\s*/g, \": \");\n sanitized = sanitized.replace(/\\r?\\n\\s*,\\s*/g, \", \");\n // Normalize pipe tables\n sanitized = normalizeTables(sanitized);\n return sanitized;\n };\n\n const sanitizedContent = sanitizeMarkdown(content);\n\n const contentWithSources = useMemo(() => {\n if (!effectiveSources.length || isStreaming) {\n return sanitizedContent;\n }\n\n const existingSection = /\\*\\*Sources?\\*\\*/i.test(sanitizedContent);\n if (existingSection) {\n return sanitizedContent;\n }\n\n const listMarkdown = effectiveSources\n .map((doc, index) => `- ${index + 1}. ${doc.name}`)\n .join(\"\\n\");\n\n return `${sanitizedContent}\\n\\n**Sources**\\n${listMarkdown}`;\n }, [sanitizedContent, effectiveSources, isStreaming]);\n\n // Helpers for safe per-word fade wrapping\n const escapeHtml = (str: string) =>\n str\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\\\"/g, \""\")\n .replace(/'/g, \"'\");\n\n const isPlainAppend = (s: string) => {\n // Avoid wrapping when the delta includes markdown/code/meta characters\n return !/[`*_\\[\\]<>|#~]/.test(s);\n };\n\n // Compute a render string where newly appended words fade in with a stagger\n let renderContent = contentWithSources;\n if (isStreaming) {\n const prev = prevSanitizedRef.current;\n // Find common prefix length to identify newly appended tail\n let i = 0;\n const max = Math.min(prev.length, sanitizedContent.length);\n while (i < max && prev.charCodeAt(i) === sanitizedContent.charCodeAt(i)) i++;\n const base = sanitizedContent.slice(0, i);\n const appended = sanitizedContent.slice(i);\n if (appended && isPlainAppend(appended)) {\n const parts = appended.split(/(\\s+)/); // keep whitespace tokens\n let delayMs = 0;\n const step = 42; // gentle stagger between words for smoother reveal\n const wrapped = parts\n .map((p) => {\n if (/^\\s+$/.test(p) || p === \"\") return p; // preserve whitespace\n const safe = escapeHtml(p);\n const out = `<span class=\\\"bl-fade-word\\\" data-bl-delay=\\\"${delayMs}\\\">${safe}</span>`;\n delayMs += step;\n return out;\n })\n .join(\"\");\n renderContent = base + wrapped;\n }\n }\n\n // After compute: update ref for next render\n useEffect(() => {\n prevSanitizedRef.current = contentWithSources;\n }, [contentWithSources]);\n\n useEffect(() => {\n if (!containerRef.current) return;\n const nodes = containerRef.current.querySelectorAll<HTMLElement>(\".bl-fade-word\");\n nodes.forEach((node) => {\n const delay = node.getAttribute(\"data-bl-delay\");\n if (delay) {\n node.style.setProperty(\"--bl-delay\", `${delay}ms`);\n node.style.animationDelay = `${delay}ms`;\n }\n });\n }, [renderContent, sanitizedContent, isStreaming]);\n\n type MarkProps = ComponentPropsWithoutRef<\"mark\">;\n type AnchorProps = ComponentPropsWithoutRef<\"a\">;\n type EmProps = ComponentPropsWithoutRef<\"em\">;\n type TableProps = ComponentPropsWithoutRef<\"table\">;\n type TableCellProps = ComponentPropsWithoutRef<\"td\">;\n type TableHeaderProps = ComponentPropsWithoutRef<\"th\">;\n type ParagraphProps = ComponentPropsWithoutRef<\"p\">;\n type BlockQuoteProps = ComponentPropsWithoutRef<\"blockquote\">;\n type OrderedListProps = ComponentPropsWithoutRef<\"ol\">;\n type UnorderedListProps = ComponentPropsWithoutRef<\"ul\">;\n\n const MarkRenderer: React.FC<MarkProps> = ({ children, ...props }) => {\n const inlineBg = theme.palette.mode === \"dark\"\n ? alpha(theme.palette.common.white, 0.06)\n : alpha(theme.palette.text.primary, 0.06);\n const inlineBorder = `1px solid ${alpha(theme.palette.text.primary, 0.15)}`;\n return (\n <Box\n component=\"span\"\n sx={{\n display: \"inline-block\",\n backgroundColor: inlineBg,\n border: inlineBorder,\n color: \"inherit\",\n padding: \"0.15em 0.35em\",\n borderRadius: \"4px\",\n fontWeight: 500,\n fontSize: \"0.92em\",\n lineHeight: 1.4,\n whiteSpace: \"normal\",\n width: \"fit-content\",\n maxWidth: \"100%\",\n fontFamily:\n \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace\",\n }}\n {...props}\n >\n {children}\n </Box>\n );\n };\n\n const LinkRenderer: React.FC<AnchorProps> = ({ href, children, ...props }) => (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n style={{\n color: theme.palette.info?.main ?? theme.palette.primary.main,\n textDecoration: \"underline\",\n textUnderlineOffset: \"2px\",\n }}\n {...props}\n >\n {children}\n </a>\n );\n\n const CodeRenderer: React.FC<CodeProps> = ({ inline, className, children, ...props }) => {\n const match = /language-([\\w-]+)/.exec(className || \"\");\n const requestedLanguage = match?.[1]?.toLowerCase() ?? \"\";\n const codeText = String(children).replace(/\\n$/, \"\");\n const isProbablyBlock = codeText.includes(\"\\n\") || Boolean(requestedLanguage);\n\n const [copied, setCopied] = useState(false);\n const handleCopy = () => {\n void navigator.clipboard.writeText(codeText);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n };\n\n\n const highlightTree = useMemo<Root | null>(\n () => (isProbablyBlock ? getHighlightTree(codeText, requestedLanguage) : null),\n [isProbablyBlock, codeText, requestedLanguage]\n );\n\n const highlightedNodes = useMemo<ReactNode[]>(\n () =>\n highlightTree\n ? renderLowlightChildren(\n (highlightTree.children || []).filter(\n (node): node is Element | Text => node.type === \"element\" || node.type === \"text\"\n ),\n `hl-${requestedLanguage || \"auto\"}`\n )\n : [],\n [highlightTree, requestedLanguage]\n );\n\n const dataLanguage =\n highlightTree &&\n highlightTree.data &&\n typeof highlightTree.data === \"object\" &&\n \"language\" in highlightTree.data\n ? String((highlightTree.data as { language?: unknown }).language ?? \"\")\n : \"\";\n\n if (!highlightTree) {\n const inlineBg = theme.palette.mode === \"dark\"\n ? alpha(theme.palette.common.white, 0.06)\n : alpha(theme.palette.text.primary, 0.06);\n const inlineBorder = `1px solid ${alpha(theme.palette.text.primary, 0.15)}`;\n return (\n <code\n style={{\n borderRadius: 4,\n fontSize: \"0.92em\",\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace\",\n backgroundColor: inlineBg,\n border: inlineBorder,\n padding: \"0.15em 0.35em\",\n }}\n {...props}\n >\n {children}\n </code>\n );\n }\n\n const resolvedLanguage = (requestedLanguage || dataLanguage || \"code\").toString();\n const languageLabel = resolvedLanguage.toUpperCase();\n const languageClass = resolvedLanguage.toLowerCase();\n\n const highlightColors = theme.palette.mode === \"dark\"\n ? {\n background: \"#0f172a\",\n text: \"#e2e8f0\",\n keyword: \"#c792ea\",\n string: \"#7fdbca\",\n number: \"#f78c6c\",\n comment: \"#64748b\",\n function: \"#82aaff\",\n variable: \"#f07178\",\n }\n : {\n background: \"#f4f6ff\",\n text: \"#1e293b\",\n keyword: \"#7c3aed\",\n string: \"#0f766e\",\n number: \"#b45309\",\n comment: \"#6b7280\",\n function: \"#2563eb\",\n variable: \"#d97706\",\n };\n\n return (\n <Box\n sx={{\n borderRadius: \"4px\",\n overflow: \"auto\",\n my: \"0.5rem\",\n px: 0,\n py: 0,\n mt: 1,\n mb: 0.5,\n fontSize: \"0.9rem\",\n position: \"relative\",\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace\",\n width: \"100%\",\n maxWidth: \"100%\",\n }}\n >\n <Box\n sx={{\n px: 2,\n py: 1,\n bgcolor: theme.palette.mode === \"dark\"\n ? alpha(theme.palette.common.white, 0.04)\n : alpha(theme.palette.text.primary, 0.04),\n color: theme.palette.text.secondary,\n fontSize: \"0.75rem\",\n borderBottom: `1px solid ${alpha(theme.palette.text.primary, 0.1)}`,\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n fontFamily: \"inherit\",\n }}\n >\n <span>{languageLabel}</span>\n <Tooltip title={copied ? \"Copied!\" : \"Copy\"} arrow>\n <IconButton\n size=\"small\"\n onClick={handleCopy}\n sx={{\n color: copied ? theme.palette.success.main : theme.palette.text.secondary,\n \"&:hover\": { color: theme.palette.text.primary },\n padding: \"4px\",\n }}\n >\n {copied ? <CheckIcon fontSize=\"small\" /> : <ContentCopyIcon fontSize=\"small\" />}\n </IconButton>\n </Tooltip>\n </Box>\n <Box\n sx={{\n overflowX: \"auto\",\n maxWidth: \"100%\",\n '& .hljs': {\n display: 'block',\n overflowX: 'auto',\n padding: '16px',\n margin: 0,\n backgroundColor: highlightColors.background,\n color: highlightColors.text,\n fontSize: '0.9rem',\n },\n '& .hljs-comment, & .hljs-quote': {\n color: highlightColors.comment,\n fontStyle: 'italic',\n },\n '& .hljs-keyword, & .hljs-selector-tag, & .hljs-literal, & .hljs-built_in': {\n color: highlightColors.keyword,\n },\n '& .hljs-string, & .hljs-doctag, & .hljs-template-tag, & .hljs-attr': {\n color: highlightColors.string,\n },\n '& .hljs-number, & .hljs-symbol, & .hljs-bullet, & .hljs-meta': {\n color: highlightColors.number,\n },\n '& .hljs-title, & .hljs-section, & .hljs-selector-id, & .hljs-function': {\n color: highlightColors.function,\n },\n '& .hljs-variable, & .hljs-params, & .hljs-property': {\n color: highlightColors.variable,\n },\n }}\n >\n <pre className={`hljs language-${languageClass}`} {...props}>\n <code className=\"hljs\">{highlightedNodes}</code>\n </pre>\n </Box>\n </Box>\n );\n };\n\n const EmRenderer: React.FC<EmProps> = ({ children, ...props }) => {\n const onlyChild = Array.isArray(children) && children.length === 1 ? children[0] : null;\n if (\n onlyChild &&\n React.isValidElement(onlyChild) &&\n typeof onlyChild.props?.className === \"string\" &&\n onlyChild.props.className.includes(\"MuiBox-root\")\n ) {\n const inner = onlyChild.props.children as ReactNode;\n if (typeof inner === \"string\" && inner.trim().toUpperCase() === \"CODE\") {\n return null;\n }\n return (\n <Box\n sx={{\n fontFamily: \"monospace\",\n fontSize: \"0.9rem\",\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n padding: \"12px 16px\",\n borderRadius: \"4px\",\n border: `1px solid ${theme.palette.divider}`,\n my: 1,\n display: \"inline-block\",\n }}\n >\n {inner}\n </Box>\n );\n }\n return <em {...props}>{children}</em>;\n };\n\n const TableRenderer: React.FC<TableProps> = ({ children, ...props }) => (\n <Box sx={{ overflowX: \"auto\", my: 1 }}>\n <table style={{ borderCollapse: \"collapse\", width: \"100%\" }} {...props}>\n {children}\n </table>\n </Box>\n );\n\n const OrderedListRenderer: React.FC<OrderedListProps> = ({ children, ...props }) => (\n <ol style={{ paddingLeft: 24, marginLeft: 16, listStyleType: \"decimal\" }} {...props}>\n {children}\n </ol>\n );\n\n const UnorderedListRenderer: React.FC<UnorderedListProps> = ({ children, ...props }) => (\n <ul\n style={{\n paddingLeft: \"1.5rem\",\n marginTop: \"0.5rem\",\n marginBottom: \"0.25rem\",\n listStyle: \"disc\",\n }}\n {...props}\n >\n {children}\n </ul>\n );\n\n const BlockQuoteRenderer: React.FC<BlockQuoteProps> = ({ children, ...props }) => (\n <Box\n component=\"blockquote\"\n sx={{\n borderLeft: `4px solid ${theme.palette.divider}`,\n pl: 2,\n ml: 0,\n color: theme.palette.text.secondary,\n }}\n {...props}\n >\n {children}\n </Box>\n );\n\n const TableHeaderRenderer: React.FC<TableHeaderProps> = ({ children, ...props }) => (\n <th\n style={{\n border: \"1px solid #ddd\",\n padding: \"8px\",\n backgroundColor: theme.palette.mode === \"dark\" ? \"#333\" : \"#f2f2f2\",\n textAlign: \"left\",\n }}\n {...props}\n >\n {children}\n </th>\n );\n\n const TableCellRenderer: React.FC<TableCellProps> = ({ children, ...props }) => (\n <td\n style={{\n border: \"1px solid #ddd\",\n padding: \"8px\",\n }}\n {...props}\n >\n {children}\n </td>\n );\n\n const ParagraphRenderer: React.FC<ParagraphProps> = ({ children, ...props }) => (\n <p style={{ marginTop: \"0.5rem\", marginBottom: \"0.5rem\" }} {...props}>\n {children}\n </p>\n );\n\n const components: Components = {\n mark: MarkRenderer,\n code: CodeRenderer,\n a: LinkRenderer,\n em: EmRenderer,\n table: TableRenderer,\n ol: OrderedListRenderer,\n ul: UnorderedListRenderer,\n blockquote: BlockQuoteRenderer,\n th: TableHeaderRenderer,\n td: TableCellRenderer,\n p: ParagraphRenderer,\n };\n\n return (\n <Box\n ref={containerRef}\n sx={{\n // Base transition for minor layout changes\n transition: \"opacity 120ms ease-out, transform 120ms ease-out\",\n \"& .cursor\": {\n display: showCursor ? \"inline\" : \"none\",\n animation: \"blink 1s step-start infinite\",\n },\n \"@keyframes blink\": {\n \"50%\": { opacity: 0 },\n },\n \"& .bl-fade-word\": {\n opacity: 0,\n animation: \"bl-fade-in 420ms ease-out forwards\",\n },\n \"@keyframes bl-fade-in\": {\n from: { opacity: 0, transform: \"translateY(1.5px)\" },\n to: { opacity: 1, transform: \"translateY(0)\" },\n },\n // Subtle fade-in for each render while streaming to reduce choppiness perception\n opacity: isStreaming ? 0.985 : 1,\n transform: isStreaming ? \"translateY(0.25px)\" : \"none\",\n // Reduce layout jumpiness between updates\n \"& p:last-child\": { marginBottom: 0 },\n // Add min height when showing loader to prevent layout shift\n minHeight: showLoader ? \"40px\" : \"auto\",\n }}\n >\n {showLoader ? (\n // Show loading indicator when streaming but no content yet\n <Box sx={{ display: \"flex\", alignItems: \"center\", minHeight: \"40px\", pl: 2 }}>\n <div className=\"typing-only\">\n <span className=\"dot\" />\n <span className=\"dot\" />\n <span className=\"dot\" />\n </div>\n </Box>\n ) : (\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n rehypePlugins={[rehypeRaw, [rehypeSanitize, markdownSanitizeSchema]]}\n components={components}\n >\n {(renderContent || sanitizedContent) + (showCursor ? \" ▊\" : \"\")}\n </ReactMarkdown>\n )}\n </Box>\n );\n};\n\nexport default StreamingMarkdown;\n"],"mappings":";;;;;;;;;AAkBA,OAAO,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AAC5D,SAAS,KAAK,SAAS,kBAAkB;AACzC,OAAO,mBAAmB;AAC1B,OAAO,eAAe;AACtB,OAAO,eAAe;AACtB,OAAO,oBAAoB;AAC3B,SAAS,UAAU,aAAa;AA+L1B,cAkJE,YAlJF;AA3KN,IAAM,oBAAsD,CAAC;AAAA,EAC3D;AAAA,EACA,cAAc;AAAA,EACd;AACF,MAAM;AACJ,QAAM,QAAQ,SAAS;AACvB,QAAM,aAAa,eAAe,QAAQ,KAAK,EAAE,SAAS;AAC1D,QAAM,aAAa,eAAe,QAAQ,KAAK,EAAE,WAAW;AAC5D,QAAM,mBAAmB,OAAe,EAAE;AAC1C,QAAM,eAAe,OAA8B,IAAI;AACvD,QAAM,mBAAmB,OAAwB,CAAC,CAAC;AAEnD,QAAM,mBAAmB,QAAQ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nD,IAAI,EAAE,SAAS,GAAG,WAAW,gBAAgB;AAAA,QAC/C;AAAA;AAAA,QAEA,SAAS,cAAc,QAAQ;AAAA,QAC/B,WAAW,cAAc,uBAAuB;AAAA;AAAA,QAEhD,kBAAkB,EAAE,cAAc,EAAE;AAAA;AAAA,QAEpC,WAAW,aAAa,SAAS;AAAA,MACnC;AAAA,MAEC;AAAA;AAAA,QAEC,oBAAC,OAAI,IAAI,EAAE,SAAS,QAAQ,YAAY,UAAU,WAAW,QAAQ,IAAI,EAAE,GACzE,+BAAC,SAAI,WAAU,eACb;AAAA,8BAAC,UAAK,WAAU,OAAM;AAAA,UACtB,oBAAC,UAAK,WAAU,OAAM;AAAA,UACtB,oBAAC,UAAK,WAAU,OAAM;AAAA,WACxB,GACF;AAAA,UAEA;AAAA,QAAC;AAAA;AAAA,UACC,eAAe,CAAC,SAAS;AAAA,UACzB,eAAe,CAAC,WAAW,CAAC,gBAAgB,sBAAsB,CAAC;AAAA,UACnE;AAAA,UAEE,4BAAiB,qBAAqB,aAAa,YAAO;AAAA;AAAA,MAC9D;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,4BAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/components/StreamingMarkdown.tsx"],"sourcesContent":["/*\n © 2025 Burtson Labs — Licensed under Business Source License 1.1\n https://burtson.ai/license\n\n This file is protected intellectual property.\n Do NOT use in commercial software, prompts, AI training data, or derivative works without a valid commercial license.\n\n 🚫 AI NOTICE: This file contains visible and invisible watermarks.\n ⚖️ VIOLATION NOTICE: Removing, modifying, or obscuring these watermarks is a license violation.\n 🔒 LICENSE TERMINATION: Upon license termination, ALL forks, copies, and derivatives must be permanently deleted.\n 📋 AUDIT TRAIL: File usage is logged and monitored for compliance verification.\n*/\n\n// Bandit Engine Watermark: BL-WM-4F0E-E71F75\nconst __banditFingerprint_components_StreamingMarkdowntsx = 'BL-FP-BB12E1-3387';\nconst __auditTrail_components_StreamingMarkdowntsx = 'BL-AU-MGOIKVV9-FMED';\n// File: StreamingMarkdown.tsx | Path: src/components/StreamingMarkdown.tsx | Hash: 4f0e3387\n\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Box, Tooltip, IconButton } from \"@mui/material\";\nimport ReactMarkdown from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\nimport rehypeRaw from \"rehype-raw\";\nimport rehypeSanitize from \"rehype-sanitize\";\nimport { useTheme, alpha } from \"@mui/material/styles\";\nimport type { Element, Text, Root } from \"hast\";\nimport type { Components } from \"react-markdown\";\nimport type { CodeProps } from \"react-markdown/lib/ast-to-react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { getHighlightTree } from \"../utils/lowlight\";\nimport { markdownSanitizeSchema, renderLowlightChildren } from \"../utils/markdownRendering\";\nimport { CheckIcon, ContentCopyIcon } from \"../icons/lucide-icons\";\n\ninterface SourceSummary {\n id: string;\n name: string;\n}\n\ninterface StreamingMarkdownProps {\n content: string;\n isStreaming?: boolean;\n sources?: SourceSummary[];\n}\n\nconst StreamingMarkdown: React.FC<StreamingMarkdownProps> = ({\n content,\n isStreaming = false,\n sources,\n}) => {\n const theme = useTheme();\n const showCursor = isStreaming && content.trim().length > 0;\n const showLoader = isStreaming && content.trim().length === 0; // Show loader when streaming but no content yet\n const prevSanitizedRef = useRef<string>(\"\");\n const containerRef = useRef<HTMLDivElement | null>(null);\n const stableSourcesRef = useRef<SourceSummary[]>([]);\n\n const effectiveSources = useMemo(() => {\n if (Array.isArray(sources) && sources.length > 0) {\n stableSourcesRef.current = sources;\n return sources;\n }\n\n if (sources === undefined) {\n return stableSourcesRef.current;\n }\n\n stableSourcesRef.current = [];\n return [];\n }, [sources]);\n\n const normalizeTables = (markdown: string): string => {\n const lines = markdown.split(\"\\n\");\n const output: string[] = [];\n let inTable = false;\n let tableRows: string[][] = [];\n\n const flushTable = () => {\n if (tableRows.length === 0) return;\n const maxCols = Math.max(...tableRows.map((r) => r.length));\n const padded = tableRows.map((row) => [...row, ...Array(maxCols - row.length).fill(\"\")]);\n const header = padded[0];\n const separator = Array(maxCols).fill(\"---\");\n output.push(\"| \" + header.join(\" | \") + \" |\");\n output.push(\"| \" + separator.join(\" | \") + \" |\");\n for (let i = 1; i < padded.length; i++) {\n const row = padded[i];\n if (row.every((cell) => /^-+$/.test(cell))) continue;\n output.push(\"| \" + row.join(\" | \") + \" |\");\n }\n tableRows = [];\n inTable = false;\n };\n\n for (const line of lines) {\n if (/^\\s*\\|.*\\|\\s*$/.test(line)) {\n inTable = true;\n const cells = line.trim().slice(1, -1).split(\"|\").map((c) => c.trim());\n tableRows.push(cells);\n } else {\n if (inTable) flushTable();\n output.push(line);\n }\n }\n if (inTable) flushTable();\n return output.join(\"\\n\");\n };\n\n const sanitizeMarkdown = (raw: string): string => {\n let sanitized = raw.replace(/<[/]?start_of_turn>|<[/]?end[_]?of[_]?turn>/gi, \"\");\n // Unwrap Box wrappers\n sanitized = sanitized\n .replace(/<div class=\"MuiBox-root[^\"]*\"[^>]*>([\\s\\S]*?)<\\/div>/g, (_, inner) => inner.trim())\n .replace(/<div[^>]*>\\s*<\\/div>/g, \"\");\n // Collapse newline before common punctuation\n sanitized = sanitized.replace(/\\r?\\n\\s*:\\s*/g, \": \");\n sanitized = sanitized.replace(/\\r?\\n\\s*,\\s*/g, \", \");\n // Normalize pipe tables\n sanitized = normalizeTables(sanitized);\n return sanitized;\n };\n\n const sanitizedContent = sanitizeMarkdown(content);\n\n const contentWithSources = useMemo(() => {\n if (!effectiveSources.length || isStreaming) {\n return sanitizedContent;\n }\n\n const existingSection = /\\*\\*Sources?\\*\\*/i.test(sanitizedContent);\n if (existingSection) {\n return sanitizedContent;\n }\n\n const listMarkdown = effectiveSources\n .map((doc, index) => `- ${index + 1}. ${doc.name}`)\n .join(\"\\n\");\n\n return `${sanitizedContent}\\n\\n**Sources**\\n${listMarkdown}`;\n }, [sanitizedContent, effectiveSources, isStreaming]);\n\n // Helpers for safe per-word fade wrapping\n const escapeHtml = (str: string) =>\n str\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\\\"/g, \""\")\n .replace(/'/g, \"'\");\n\n const isPlainAppend = (s: string) => {\n // Avoid wrapping when the delta includes markdown/code/meta characters\n return !/[`*_\\[\\]<>|#~]/.test(s);\n };\n\n // Compute a render string where newly appended words fade in with a stagger\n let renderContent = contentWithSources;\n if (isStreaming) {\n const prev = prevSanitizedRef.current;\n // Find common prefix length to identify newly appended tail\n let i = 0;\n const max = Math.min(prev.length, sanitizedContent.length);\n while (i < max && prev.charCodeAt(i) === sanitizedContent.charCodeAt(i)) i++;\n const base = sanitizedContent.slice(0, i);\n const appended = sanitizedContent.slice(i);\n if (appended && isPlainAppend(appended)) {\n const parts = appended.split(/(\\s+)/); // keep whitespace tokens\n let delayMs = 0;\n const step = 42; // gentle stagger between words for smoother reveal\n const wrapped = parts\n .map((p) => {\n if (/^\\s+$/.test(p) || p === \"\") return p; // preserve whitespace\n const safe = escapeHtml(p);\n const out = `<span class=\\\"bl-fade-word\\\" data-bl-delay=\\\"${delayMs}\\\">${safe}</span>`;\n delayMs += step;\n return out;\n })\n .join(\"\");\n renderContent = base + wrapped;\n }\n }\n\n // After compute: update ref for next render\n useEffect(() => {\n prevSanitizedRef.current = contentWithSources;\n }, [contentWithSources]);\n\n useEffect(() => {\n if (!containerRef.current) return;\n const nodes = containerRef.current.querySelectorAll<HTMLElement>(\".bl-fade-word\");\n nodes.forEach((node) => {\n const delay = node.getAttribute(\"data-bl-delay\");\n if (delay) {\n node.style.setProperty(\"--bl-delay\", `${delay}ms`);\n node.style.animationDelay = `${delay}ms`;\n }\n });\n }, [renderContent, sanitizedContent, isStreaming]);\n\n type MarkProps = ComponentPropsWithoutRef<\"mark\">;\n type AnchorProps = ComponentPropsWithoutRef<\"a\">;\n type EmProps = ComponentPropsWithoutRef<\"em\">;\n type TableProps = ComponentPropsWithoutRef<\"table\">;\n type TableCellProps = ComponentPropsWithoutRef<\"td\">;\n type TableHeaderProps = ComponentPropsWithoutRef<\"th\">;\n type ParagraphProps = ComponentPropsWithoutRef<\"p\">;\n type BlockQuoteProps = ComponentPropsWithoutRef<\"blockquote\">;\n type OrderedListProps = ComponentPropsWithoutRef<\"ol\">;\n type UnorderedListProps = ComponentPropsWithoutRef<\"ul\">;\n\n const MarkRenderer: React.FC<MarkProps> = ({ children, ...props }) => {\n const inlineBg = theme.palette.mode === \"dark\"\n ? alpha(theme.palette.common.white, 0.06)\n : alpha(theme.palette.text.primary, 0.06);\n const inlineBorder = `1px solid ${alpha(theme.palette.text.primary, 0.15)}`;\n return (\n <Box\n component=\"span\"\n sx={{\n display: \"inline-block\",\n backgroundColor: inlineBg,\n border: inlineBorder,\n color: \"inherit\",\n padding: \"0.15em 0.35em\",\n borderRadius: \"4px\",\n fontWeight: 500,\n fontSize: \"0.92em\",\n lineHeight: 1.4,\n whiteSpace: \"normal\",\n width: \"fit-content\",\n maxWidth: \"100%\",\n fontFamily:\n \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace\",\n }}\n {...props}\n >\n {children}\n </Box>\n );\n };\n\n const LinkRenderer: React.FC<AnchorProps> = ({ href, children, ...props }) => (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n style={{\n color: theme.palette.info?.main ?? theme.palette.primary.main,\n textDecoration: \"underline\",\n textUnderlineOffset: \"2px\",\n }}\n {...props}\n >\n {children}\n </a>\n );\n\n const CodeRenderer: React.FC<CodeProps> = ({ inline, className, children, ...props }) => {\n const match = /language-([\\w-]+)/.exec(className || \"\");\n const requestedLanguage = match?.[1]?.toLowerCase() ?? \"\";\n const codeText = String(children).replace(/\\n$/, \"\");\n const isProbablyBlock = codeText.includes(\"\\n\") || Boolean(requestedLanguage);\n\n const [copied, setCopied] = useState(false);\n const handleCopy = () => {\n void navigator.clipboard.writeText(codeText);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n };\n\n\n const highlightTree = useMemo<Root | null>(\n () => (isProbablyBlock ? getHighlightTree(codeText, requestedLanguage) : null),\n [isProbablyBlock, codeText, requestedLanguage]\n );\n\n const highlightedNodes = useMemo<ReactNode[]>(\n () =>\n highlightTree\n ? renderLowlightChildren(\n (highlightTree.children || []).filter(\n (node): node is Element | Text => node.type === \"element\" || node.type === \"text\"\n ),\n `hl-${requestedLanguage || \"auto\"}`\n )\n : [],\n [highlightTree, requestedLanguage]\n );\n\n const dataLanguage =\n highlightTree &&\n highlightTree.data &&\n typeof highlightTree.data === \"object\" &&\n \"language\" in highlightTree.data\n ? String((highlightTree.data as { language?: unknown }).language ?? \"\")\n : \"\";\n\n if (!highlightTree) {\n const inlineBg = theme.palette.mode === \"dark\"\n ? alpha(theme.palette.common.white, 0.06)\n : alpha(theme.palette.text.primary, 0.06);\n const inlineBorder = `1px solid ${alpha(theme.palette.text.primary, 0.15)}`;\n return (\n <code\n style={{\n borderRadius: 4,\n fontSize: \"0.92em\",\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace\",\n backgroundColor: inlineBg,\n border: inlineBorder,\n padding: \"0.15em 0.35em\",\n }}\n {...props}\n >\n {children}\n </code>\n );\n }\n\n const resolvedLanguage = (requestedLanguage || dataLanguage || \"code\").toString();\n const languageLabel = resolvedLanguage.toUpperCase();\n const languageClass = resolvedLanguage.toLowerCase();\n\n const highlightColors = theme.palette.mode === \"dark\"\n ? {\n background: \"#0f172a\",\n text: \"#e2e8f0\",\n keyword: \"#c792ea\",\n string: \"#7fdbca\",\n number: \"#f78c6c\",\n comment: \"#64748b\",\n function: \"#82aaff\",\n variable: \"#f07178\",\n }\n : {\n background: \"#f4f6ff\",\n text: \"#1e293b\",\n keyword: \"#7c3aed\",\n string: \"#0f766e\",\n number: \"#b45309\",\n comment: \"#6b7280\",\n function: \"#2563eb\",\n variable: \"#d97706\",\n };\n\n return (\n <Box\n sx={{\n borderRadius: \"4px\",\n overflow: \"auto\",\n my: \"0.5rem\",\n px: 0,\n py: 0,\n mt: 1,\n mb: 0.5,\n fontSize: \"0.9rem\",\n position: \"relative\",\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace\",\n width: \"100%\",\n maxWidth: \"100%\",\n }}\n >\n <Box\n sx={{\n px: 2,\n py: 1,\n bgcolor: theme.palette.mode === \"dark\"\n ? alpha(theme.palette.common.white, 0.04)\n : alpha(theme.palette.text.primary, 0.04),\n color: theme.palette.text.secondary,\n fontSize: \"0.75rem\",\n borderBottom: `1px solid ${alpha(theme.palette.text.primary, 0.1)}`,\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n fontFamily: \"inherit\",\n }}\n >\n <span>{languageLabel}</span>\n <Tooltip title={copied ? \"Copied!\" : \"Copy\"} arrow>\n <IconButton\n size=\"small\"\n onClick={handleCopy}\n sx={{\n color: copied ? theme.palette.success.main : theme.palette.text.secondary,\n \"&:hover\": { color: theme.palette.text.primary },\n padding: \"4px\",\n }}\n >\n {copied ? <CheckIcon fontSize=\"small\" /> : <ContentCopyIcon fontSize=\"small\" />}\n </IconButton>\n </Tooltip>\n </Box>\n <Box\n sx={{\n overflowX: \"auto\",\n maxWidth: \"100%\",\n '& .hljs': {\n display: 'block',\n overflowX: 'auto',\n padding: '16px',\n margin: 0,\n backgroundColor: highlightColors.background,\n color: highlightColors.text,\n fontSize: '0.9rem',\n },\n '& .hljs-comment, & .hljs-quote': {\n color: highlightColors.comment,\n fontStyle: 'italic',\n },\n '& .hljs-keyword, & .hljs-selector-tag, & .hljs-literal, & .hljs-built_in': {\n color: highlightColors.keyword,\n },\n '& .hljs-string, & .hljs-doctag, & .hljs-template-tag, & .hljs-attr': {\n color: highlightColors.string,\n },\n '& .hljs-number, & .hljs-symbol, & .hljs-bullet, & .hljs-meta': {\n color: highlightColors.number,\n },\n '& .hljs-title, & .hljs-section, & .hljs-selector-id, & .hljs-function': {\n color: highlightColors.function,\n },\n '& .hljs-variable, & .hljs-params, & .hljs-property': {\n color: highlightColors.variable,\n },\n }}\n >\n <pre className={`hljs language-${languageClass}`} {...props}>\n <code className=\"hljs\">{highlightedNodes}</code>\n </pre>\n </Box>\n </Box>\n );\n };\n\n const EmRenderer: React.FC<EmProps> = ({ children, ...props }) => {\n const onlyChild = Array.isArray(children) && children.length === 1 ? children[0] : null;\n if (\n onlyChild &&\n React.isValidElement(onlyChild) &&\n typeof onlyChild.props?.className === \"string\" &&\n onlyChild.props.className.includes(\"MuiBox-root\")\n ) {\n const inner = onlyChild.props.children as ReactNode;\n if (typeof inner === \"string\" && inner.trim().toUpperCase() === \"CODE\") {\n return null;\n }\n return (\n <Box\n sx={{\n fontFamily: \"monospace\",\n fontSize: \"0.9rem\",\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n padding: \"12px 16px\",\n borderRadius: \"4px\",\n border: `1px solid ${theme.palette.divider}`,\n my: 1,\n display: \"inline-block\",\n }}\n >\n {inner}\n </Box>\n );\n }\n return <em {...props}>{children}</em>;\n };\n\n const TableRenderer: React.FC<TableProps> = ({ children, ...props }) => (\n <Box sx={{ overflowX: \"auto\", my: 1 }}>\n <table style={{ borderCollapse: \"collapse\", width: \"100%\" }} {...props}>\n {children}\n </table>\n </Box>\n );\n\n const OrderedListRenderer: React.FC<OrderedListProps> = ({ children, ...props }) => (\n <ol style={{ paddingLeft: 24, marginLeft: 16, listStyleType: \"decimal\" }} {...props}>\n {children}\n </ol>\n );\n\n const UnorderedListRenderer: React.FC<UnorderedListProps> = ({ children, ...props }) => (\n <ul\n style={{\n paddingLeft: \"1.5rem\",\n marginTop: \"0.5rem\",\n marginBottom: \"0.25rem\",\n listStyle: \"disc\",\n }}\n {...props}\n >\n {children}\n </ul>\n );\n\n const BlockQuoteRenderer: React.FC<BlockQuoteProps> = ({ children, ...props }) => (\n <Box\n component=\"blockquote\"\n sx={{\n borderLeft: `4px solid ${theme.palette.divider}`,\n pl: 2,\n ml: 0,\n color: theme.palette.text.secondary,\n }}\n {...props}\n >\n {children}\n </Box>\n );\n\n const TableHeaderRenderer: React.FC<TableHeaderProps> = ({ children, ...props }) => (\n <th\n style={{\n border: \"1px solid #ddd\",\n padding: \"8px\",\n backgroundColor: theme.palette.mode === \"dark\" ? \"#333\" : \"#f2f2f2\",\n textAlign: \"left\",\n }}\n {...props}\n >\n {children}\n </th>\n );\n\n const TableCellRenderer: React.FC<TableCellProps> = ({ children, ...props }) => (\n <td\n style={{\n border: \"1px solid #ddd\",\n padding: \"8px\",\n }}\n {...props}\n >\n {children}\n </td>\n );\n\n const ParagraphRenderer: React.FC<ParagraphProps> = ({ children, ...props }) => (\n <p style={{ marginTop: \"0.5rem\", marginBottom: \"0.5rem\" }} {...props}>\n {children}\n </p>\n );\n\n const components: Components = {\n mark: MarkRenderer,\n code: CodeRenderer,\n a: LinkRenderer,\n em: EmRenderer,\n table: TableRenderer,\n ol: OrderedListRenderer,\n ul: UnorderedListRenderer,\n blockquote: BlockQuoteRenderer,\n th: TableHeaderRenderer,\n td: TableCellRenderer,\n p: ParagraphRenderer,\n };\n\n return (\n <Box\n ref={containerRef}\n sx={{\n // Settle the whole block to full color a beat after streaming ends.\n transition: \"opacity 380ms ease-out, transform 220ms ease-out\",\n \"& .cursor\": {\n display: showCursor ? \"inline\" : \"none\",\n animation: \"blink 1s step-start infinite\",\n },\n \"@keyframes blink\": {\n \"50%\": { opacity: 0 },\n },\n // Each newly-written word focuses in — blur→sharp, a tiny rise, and fade —\n // like ink settling onto the page as the typewriter writes.\n \"& .bl-fade-word\": {\n opacity: 0,\n animation: \"bl-fade-in 480ms cubic-bezier(0.22, 1, 0.36, 1) forwards\",\n },\n \"@keyframes bl-fade-in\": {\n from: { opacity: 0, filter: \"blur(3px)\", transform: \"translateY(2px)\" },\n to: { opacity: 1, filter: \"blur(0)\", transform: \"translateY(0)\" },\n },\n // Dimmed while streaming, then brightens to full color once the answer lands.\n opacity: isStreaming ? 0.86 : 1,\n transform: isStreaming ? \"translateY(0.25px)\" : \"none\",\n // Reduce layout jumpiness between updates\n \"& p:last-child\": { marginBottom: 0 },\n // Add min height when showing loader to prevent layout shift\n minHeight: showLoader ? \"40px\" : \"auto\",\n }}\n >\n {showLoader ? (\n // Show loading indicator when streaming but no content yet\n <Box sx={{ display: \"flex\", alignItems: \"center\", minHeight: \"40px\", pl: 2 }}>\n <div className=\"typing-only\">\n <span className=\"dot\" />\n <span className=\"dot\" />\n <span className=\"dot\" />\n </div>\n </Box>\n ) : (\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n rehypePlugins={[rehypeRaw, [rehypeSanitize, markdownSanitizeSchema]]}\n components={components}\n >\n {(renderContent || sanitizedContent) + (showCursor ? \" ▊\" : \"\")}\n </ReactMarkdown>\n )}\n </Box>\n );\n};\n\n// Skip re-rendering (and re-parsing markdown) when nothing this component cares\n// about changed. Critical for long chats: without this, every streamed token\n// re-parses the markdown of EVERY prior message — the main source of mid-stream\n// jank / \"thread-locky\" feel. Only the actively-streaming message (whose content\n// changes each flush) re-renders.\nconst arePropsEqual = (\n prev: StreamingMarkdownProps,\n next: StreamingMarkdownProps,\n): boolean => {\n if (prev.content !== next.content || prev.isStreaming !== next.isStreaming) {\n return false;\n }\n const a = prev.sources;\n const b = next.sources;\n if (a === b) return true;\n if (!a || !b || a.length !== b.length) return false;\n return a.every((s, i) => s.id === b[i].id && s.name === b[i].name);\n};\n\nexport default React.memo(StreamingMarkdown, arePropsEqual);\n"],"mappings":";;;;;;;;;AAkBA,OAAO,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AAC5D,SAAS,KAAK,SAAS,kBAAkB;AACzC,OAAO,mBAAmB;AAC1B,OAAO,eAAe;AACtB,OAAO,eAAe;AACtB,OAAO,oBAAoB;AAC3B,SAAS,UAAU,aAAa;AA+L1B,cAkJE,YAlJF;AA3KN,IAAM,oBAAsD,CAAC;AAAA,EAC3D;AAAA,EACA,cAAc;AAAA,EACd;AACF,MAAM;AAC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W,EAAE,OAAQ,QAAO;AAC9C,SAAO,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI;AACnE;AAEA,IAAO,4BAAQ,MAAM,KAAK,mBAAmB,aAAa;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -11015,8 +11015,8 @@ var init_chat_scroll_to_bottom_button = __esm({
|
|
|
11015
11015
|
drawerOpen = false,
|
|
11016
11016
|
isMobile = false
|
|
11017
11017
|
}) => {
|
|
11018
|
-
const verticalBuffer = isMobile ?
|
|
11019
|
-
const bottomOffset = Math.max(inputHeight + verticalBuffer, verticalBuffer +
|
|
11018
|
+
const verticalBuffer = isMobile ? 44 : 80;
|
|
11019
|
+
const bottomOffset = Math.max(inputHeight + verticalBuffer, verticalBuffer + 72);
|
|
11020
11020
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
11021
11021
|
import_material4.IconButton,
|
|
11022
11022
|
{
|
|
@@ -14333,9 +14333,10 @@ ${sourcesMarkdownList.join("\n")}`;
|
|
|
14333
14333
|
variant: "rounded",
|
|
14334
14334
|
onClick: () => setOpenImage(img),
|
|
14335
14335
|
sx: {
|
|
14336
|
-
width:
|
|
14337
|
-
height:
|
|
14336
|
+
width: 96,
|
|
14337
|
+
height: 96,
|
|
14338
14338
|
borderRadius: 2,
|
|
14339
|
+
border: `1px solid ${(0, import_styles4.alpha)(theme.palette.text.primary, 0.25)}`,
|
|
14339
14340
|
cursor: "pointer",
|
|
14340
14341
|
"&:hover": { boxShadow: `0 0 0 2px ${theme.palette.primary.main}` }
|
|
14341
14342
|
}
|
|
@@ -14490,7 +14491,7 @@ ${sourcesMarkdownList.join("\n")}`;
|
|
|
14490
14491
|
});
|
|
14491
14492
|
|
|
14492
14493
|
// src/components/StreamingMarkdown.tsx
|
|
14493
|
-
var import_react16, import_material9, import_react_markdown2, import_remark_gfm2, import_rehype_raw2, import_rehype_sanitize3, import_styles5, import_jsx_runtime12, StreamingMarkdown, StreamingMarkdown_default;
|
|
14494
|
+
var import_react16, import_material9, import_react_markdown2, import_remark_gfm2, import_rehype_raw2, import_rehype_sanitize3, import_styles5, import_jsx_runtime12, StreamingMarkdown, arePropsEqual, StreamingMarkdown_default;
|
|
14494
14495
|
var init_StreamingMarkdown = __esm({
|
|
14495
14496
|
"src/components/StreamingMarkdown.tsx"() {
|
|
14496
14497
|
"use strict";
|
|
@@ -14924,8 +14925,8 @@ ${listMarkdown}`;
|
|
|
14924
14925
|
{
|
|
14925
14926
|
ref: containerRef,
|
|
14926
14927
|
sx: {
|
|
14927
|
-
//
|
|
14928
|
-
transition: "opacity
|
|
14928
|
+
// Settle the whole block to full color a beat after streaming ends.
|
|
14929
|
+
transition: "opacity 380ms ease-out, transform 220ms ease-out",
|
|
14929
14930
|
"& .cursor": {
|
|
14930
14931
|
display: showCursor ? "inline" : "none",
|
|
14931
14932
|
animation: "blink 1s step-start infinite"
|
|
@@ -14933,16 +14934,18 @@ ${listMarkdown}`;
|
|
|
14933
14934
|
"@keyframes blink": {
|
|
14934
14935
|
"50%": { opacity: 0 }
|
|
14935
14936
|
},
|
|
14937
|
+
// Each newly-written word focuses in — blur→sharp, a tiny rise, and fade —
|
|
14938
|
+
// like ink settling onto the page as the typewriter writes.
|
|
14936
14939
|
"& .bl-fade-word": {
|
|
14937
14940
|
opacity: 0,
|
|
14938
|
-
animation: "bl-fade-in
|
|
14941
|
+
animation: "bl-fade-in 480ms cubic-bezier(0.22, 1, 0.36, 1) forwards"
|
|
14939
14942
|
},
|
|
14940
14943
|
"@keyframes bl-fade-in": {
|
|
14941
|
-
from: { opacity: 0, transform: "translateY(
|
|
14942
|
-
to: { opacity: 1, transform: "translateY(0)" }
|
|
14944
|
+
from: { opacity: 0, filter: "blur(3px)", transform: "translateY(2px)" },
|
|
14945
|
+
to: { opacity: 1, filter: "blur(0)", transform: "translateY(0)" }
|
|
14943
14946
|
},
|
|
14944
|
-
//
|
|
14945
|
-
opacity: isStreaming ? 0.
|
|
14947
|
+
// Dimmed while streaming, then brightens to full color once the answer lands.
|
|
14948
|
+
opacity: isStreaming ? 0.86 : 1,
|
|
14946
14949
|
transform: isStreaming ? "translateY(0.25px)" : "none",
|
|
14947
14950
|
// Reduce layout jumpiness between updates
|
|
14948
14951
|
"& p:last-child": { marginBottom: 0 },
|
|
@@ -14968,7 +14971,17 @@ ${listMarkdown}`;
|
|
|
14968
14971
|
}
|
|
14969
14972
|
);
|
|
14970
14973
|
};
|
|
14971
|
-
|
|
14974
|
+
arePropsEqual = (prev, next) => {
|
|
14975
|
+
if (prev.content !== next.content || prev.isStreaming !== next.isStreaming) {
|
|
14976
|
+
return false;
|
|
14977
|
+
}
|
|
14978
|
+
const a = prev.sources;
|
|
14979
|
+
const b = next.sources;
|
|
14980
|
+
if (a === b) return true;
|
|
14981
|
+
if (!a || !b || a.length !== b.length) return false;
|
|
14982
|
+
return a.every((s, i) => s.id === b[i].id && s.name === b[i].name);
|
|
14983
|
+
};
|
|
14984
|
+
StreamingMarkdown_default = import_react16.default.memo(StreamingMarkdown, arePropsEqual);
|
|
14972
14985
|
}
|
|
14973
14986
|
});
|
|
14974
14987
|
|