@kumix/ui 0.3.9 → 0.3.10

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.
Files changed (77) hide show
  1. package/README.md +15 -14
  2. package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
  3. package/dist/components/motion/animated-sidebar.js.map +1 -1
  4. package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
  5. package/dist/components/motion/availability-scheduler/day-row.d.ts.map +1 -1
  6. package/dist/components/motion/availability-scheduler/day-row.js +15 -7
  7. package/dist/components/motion/availability-scheduler/day-row.js.map +1 -1
  8. package/dist/components/motion/availability-scheduler/index.js +1 -1
  9. package/dist/components/motion/button/index.d.ts +2 -1
  10. package/dist/components/motion/button/index.js +2 -1
  11. package/dist/components/motion/button/metallic.d.ts +10 -0
  12. package/dist/components/motion/button/metallic.d.ts.map +1 -0
  13. package/dist/components/motion/button/metallic.js +71 -0
  14. package/dist/components/motion/button/metallic.js.map +1 -0
  15. package/dist/components/motion/expandable-control.d.ts +28 -0
  16. package/dist/components/motion/expandable-control.d.ts.map +1 -0
  17. package/dist/components/motion/expandable-control.js +149 -0
  18. package/dist/components/motion/expandable-control.js.map +1 -0
  19. package/dist/components/motion/expanding-arrow-button.d.ts +12 -0
  20. package/dist/components/motion/expanding-arrow-button.d.ts.map +1 -0
  21. package/dist/components/motion/expanding-arrow-button.js +142 -0
  22. package/dist/components/motion/expanding-arrow-button.js.map +1 -0
  23. package/dist/components/motion/file-tree.d.ts +42 -0
  24. package/dist/components/motion/file-tree.d.ts.map +1 -0
  25. package/dist/components/motion/file-tree.js +272 -0
  26. package/dist/components/motion/file-tree.js.map +1 -0
  27. package/dist/components/reui/alert.d.ts +1 -1
  28. package/dist/components/reui/badge.d.ts +1 -1
  29. package/dist/components/reui/code-block/code-block-highlight.d.ts +216 -0
  30. package/dist/components/reui/code-block/code-block-highlight.d.ts.map +1 -0
  31. package/dist/components/reui/code-block/code-block-highlight.js +792 -0
  32. package/dist/components/reui/code-block/code-block-highlight.js.map +1 -0
  33. package/dist/components/reui/code-block/code-block.d.ts +197 -0
  34. package/dist/components/reui/code-block/code-block.d.ts.map +1 -0
  35. package/dist/components/reui/code-block/code-block.js +1150 -0
  36. package/dist/components/reui/code-block/code-block.js.map +1 -0
  37. package/dist/components/reui/frame.d.ts +1 -1
  38. package/dist/components/reui/gantt/gantt-bar.js +42 -12
  39. package/dist/components/reui/gantt/gantt-bar.js.map +1 -1
  40. package/dist/components/reui/gantt/gantt-dnd.d.ts.map +1 -1
  41. package/dist/components/reui/gantt/gantt-dnd.js +22 -7
  42. package/dist/components/reui/gantt/gantt-dnd.js.map +1 -1
  43. package/dist/components/reui/gantt/gantt-i18n.d.ts +8 -0
  44. package/dist/components/reui/gantt/gantt-i18n.d.ts.map +1 -1
  45. package/dist/components/reui/gantt/gantt-i18n.js +6 -1
  46. package/dist/components/reui/gantt/gantt-i18n.js.map +1 -1
  47. package/dist/components/reui/gantt/gantt-lib.d.ts +59 -2
  48. package/dist/components/reui/gantt/gantt-lib.d.ts.map +1 -1
  49. package/dist/components/reui/gantt/gantt-lib.js +67 -2
  50. package/dist/components/reui/gantt/gantt-lib.js.map +1 -1
  51. package/dist/components/reui/gantt/gantt-recurrence.js +3 -3
  52. package/dist/components/reui/gantt/gantt-recurrence.js.map +1 -1
  53. package/dist/components/reui/gantt/gantt-types.d.ts +32 -1
  54. package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -1
  55. package/dist/components/reui/gantt/gantt-view.d.ts.map +1 -1
  56. package/dist/components/reui/gantt/gantt-view.js +324 -35
  57. package/dist/components/reui/gantt/gantt-view.js.map +1 -1
  58. package/dist/components/reui/gantt/gantt.d.ts +71 -2
  59. package/dist/components/reui/gantt/gantt.d.ts.map +1 -1
  60. package/dist/components/reui/gantt/gantt.js +8 -0
  61. package/dist/components/reui/gantt/gantt.js.map +1 -1
  62. package/dist/components/ui/attachment.d.ts +1 -1
  63. package/dist/components/ui/badge.d.ts +1 -1
  64. package/dist/components/ui/bubble.d.ts +1 -1
  65. package/dist/components/ui/button-group.d.ts +1 -1
  66. package/dist/components/ui/button.d.ts +1 -1
  67. package/dist/components/ui/field.d.ts +1 -1
  68. package/dist/components/ui/item.d.ts +2 -2
  69. package/dist/components/ui/marker.d.ts +1 -1
  70. package/dist/components/ui/sidebar.d.ts +1 -1
  71. package/dist/components/ui/tabs.d.ts +1 -1
  72. package/dist/components/ui/toggle.d.ts +1 -1
  73. package/dist/{copy-menu-1FKoMc9o.js → copy-menu-C5GaT4Z-.js} +67 -2
  74. package/dist/copy-menu-C5GaT4Z-.js.map +1 -0
  75. package/dist/types-smkWN_7x.d.ts.map +1 -1
  76. package/package.json +5 -11
  77. package/dist/copy-menu-1FKoMc9o.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-block-highlight.js","names":[],"sources":["../../../../src/components/reui/code-block/code-block-highlight.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport type { ShikiTransformer } from \"shiki\";\n\n/**\n * One themed slice of a line. `color`/`colorDark` emit as `--cb-c`/`--cb-cd`\n * custom properties, so one rule pair on the `<pre>` theme-switches the whole\n * block. An uncoloured token keeps both undefined and renders as a bare text\n * node with no wrapper.\n */\nexport type CodeBlockToken = {\n content: string;\n color?: string;\n colorDark?: string;\n fontStyle?: CodeBlockFontStyle;\n word?: boolean;\n};\n\nexport type CodeBlockFontStyle = \"italic\" | \"bold\" | \"underline\";\n\nexport type CodeBlockDiffKind = \"add\" | \"remove\";\n\nexport type CodeBlockLevel = \"error\" | \"warning\" | \"info\";\n\n/**\n * Per-line presentation state, resolved once at highlight time.\n *\n * Two sources merge here: the props on the root, and the classes a shiki\n * transformer put on the line, so `@shikijs/transformers` notation such as\n * `[!code ++]` reaches the same place without the renderer knowing shiki\n * exists. Props win on conflict, because notation lives in the source string,\n * which a consumer often does not control.\n */\nexport type CodeBlockLineState = {\n highlighted?: boolean;\n diff?: CodeBlockDiffKind;\n focused?: boolean;\n level?: CodeBlockLevel;\n};\n\n/**\n * A rendered line. `number` is the DISPLAYED number (offset by `startLine`);\n * line specs address source lines, so changing `startLine` never invalidates\n * them. Instances are reused across passes when unchanged, which is what lets\n * the row be a plain `React.memo` and a streamed chunk cost one re-render.\n */\nexport type CodeBlockLine = {\n tokens: CodeBlockToken[];\n number: number;\n text: string;\n state?: CodeBlockLineState;\n /**\n * Replaces the counter-driven gutter number for this row - a unified patch\n * shows \"old new\" pairs, a hunk header shows dots. Rendered verbatim.\n */\n gutter?: string;\n};\n\n/** Source lines, as `[2, 3, 4]` or as a range string such as `\"2-4,7\"`. */\nexport type CodeBlockLineSpec = number[] | string;\n\nexport type CodeBlockDiffSpec = {\n added?: CodeBlockLineSpec;\n removed?: CodeBlockLineSpec;\n};\n\nexport type CodeBlockLevelSpec = Partial<Record<CodeBlockLevel, CodeBlockLineSpec>>;\n\n/** A word to mark, optionally restricted to some source lines. */\nexport type CodeBlockWordSpec = string | { word: string; lines?: CodeBlockLineSpec };\n\nexport type CodeBlockThemes = { light: string; dark: string };\n\n/**\n * shiki's own transformer type, imported type-only so it erases at compile\n * time and costs the bundle nothing. The previous structural stand-in\n * (`Record<string, unknown>`) rejected every real `ShikiTransformer`: an\n * interface without an index signature is not assignable to it.\n */\nexport type CodeBlockTransformer = ShikiTransformer;\n\nexport type CodeBlockHighlightOptions = {\n language?: string;\n themes?: CodeBlockThemes;\n transformers?: CodeBlockTransformer[];\n startLine?: number;\n /**\n * Distinguishes same-signature blocks in the line-reuse cache. Without it,\n * two identically-configured streams evict each other's previous document.\n * The root passes its own instance id.\n */\n instanceKey?: string;\n highlightedLines?: CodeBlockLineSpec;\n highlightedWords?: CodeBlockWordSpec[];\n focusedLines?: CodeBlockLineSpec;\n diff?: CodeBlockDiffSpec;\n lineLevels?: CodeBlockLevelSpec;\n};\n\n/** What a `CodeBlockLineActions` render prop receives. */\nexport type CodeBlockLineActionContext = {\n line: number;\n text: string;\n state?: CodeBlockLineState;\n};\n\nexport type CodeBlockLineActionsRender = (context: CodeBlockLineActionContext) => ReactNode;\n\n/* -------------------------------------------------------------------------- */\n/* Languages */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A STATIC map, never ``import(`shiki/langs/${lang}.mjs`)``: a template import\n * makes bundlers bundle all ~200 grammars. Written out, each entry is its own\n * lazy chunk. To add a language, add a line: that is the intended extension\n * point of this file.\n */\nexport const codeBlockLanguages: Record<string, () => Promise<unknown>> = {\n bash: () => import(\"shiki/langs/bash.mjs\"),\n c: () => import(\"shiki/langs/c.mjs\"),\n cpp: () => import(\"shiki/langs/cpp.mjs\"),\n csharp: () => import(\"shiki/langs/csharp.mjs\"),\n css: () => import(\"shiki/langs/css.mjs\"),\n diff: () => import(\"shiki/langs/diff.mjs\"),\n docker: () => import(\"shiki/langs/docker.mjs\"),\n go: () => import(\"shiki/langs/go.mjs\"),\n graphql: () => import(\"shiki/langs/graphql.mjs\"),\n html: () => import(\"shiki/langs/html.mjs\"),\n java: () => import(\"shiki/langs/java.mjs\"),\n javascript: () => import(\"shiki/langs/javascript.mjs\"),\n json: () => import(\"shiki/langs/json.mjs\"),\n jsx: () => import(\"shiki/langs/jsx.mjs\"),\n kotlin: () => import(\"shiki/langs/kotlin.mjs\"),\n markdown: () => import(\"shiki/langs/markdown.mjs\"),\n php: () => import(\"shiki/langs/php.mjs\"),\n python: () => import(\"shiki/langs/python.mjs\"),\n ruby: () => import(\"shiki/langs/ruby.mjs\"),\n rust: () => import(\"shiki/langs/rust.mjs\"),\n scss: () => import(\"shiki/langs/scss.mjs\"),\n shell: () => import(\"shiki/langs/shellscript.mjs\"),\n sql: () => import(\"shiki/langs/sql.mjs\"),\n swift: () => import(\"shiki/langs/swift.mjs\"),\n toml: () => import(\"shiki/langs/toml.mjs\"),\n tsx: () => import(\"shiki/langs/tsx.mjs\"),\n typescript: () => import(\"shiki/langs/typescript.mjs\"),\n vue: () => import(\"shiki/langs/vue.mjs\"),\n yaml: () => import(\"shiki/langs/yaml.mjs\"),\n};\n\n/** Spellings a consumer is likely to pass, mapped onto the map above. */\nconst LANGUAGE_ALIASES: Record<string, string> = {\n \"c++\": \"cpp\",\n \"c#\": \"csharp\",\n cs: \"csharp\",\n dockerfile: \"docker\",\n htm: \"html\",\n js: \"javascript\",\n jsonc: \"json\",\n md: \"markdown\",\n mdx: \"markdown\",\n py: \"python\",\n rb: \"ruby\",\n rs: \"rust\",\n sh: \"shell\",\n shellscript: \"shell\",\n ts: \"typescript\",\n yml: \"yaml\",\n zsh: \"shell\",\n};\n\nexport const codeBlockThemes: Record<string, () => Promise<unknown>> = {\n \"github-light\": () => import(\"shiki/themes/github-light.mjs\"),\n \"github-dark\": () => import(\"shiki/themes/github-dark.mjs\"),\n /**\n * Design-token theming: every token colour becomes a `var(--code-token-*)`\n * reference, so the palette lives in the consumer's stylesheet and follows\n * their themes. Pass as BOTH sides. Variables consumed (prefix `--code-`):\n * foreground, token-constant, token-string, token-comment, token-keyword,\n * token-parameter, token-function, token-string-expression,\n * token-punctuation, token-link.\n */\n \"css-variables\": async () => {\n const { createCssVariablesTheme } = await import(\"shiki/core\");\n return createCssVariablesTheme({\n name: \"css-variables\",\n variablePrefix: \"--code-\",\n fontStyle: true,\n });\n },\n};\n\nexport const DEFAULT_CODE_BLOCK_THEMES: CodeBlockThemes = {\n light: \"github-light\",\n dark: \"github-dark\",\n};\n\n/** Resolves an alias and reports whether the grammar is actually available. */\nexport function resolveCodeBlockLanguage(language?: string): string | undefined {\n if (!language) return undefined;\n const normalized = language.trim().toLowerCase();\n const resolved = LANGUAGE_ALIASES[normalized] ?? normalized;\n return resolved in codeBlockLanguages ? resolved : undefined;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Pure helpers */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Turns `[2, 3]` or `\"2-4,7\"` into a set of source line numbers.\n *\n * Deliberately total: a reversed range, a negative bound or outright garbage\n * yields an empty set rather than throwing. These values often come from user\n * content or from a model, and a code viewer that crashes on a bad range is\n * worse than one that shows no highlight.\n */\nexport function parseLineSpec(spec?: CodeBlockLineSpec): Set<number> {\n const out = new Set<number>();\n if (!spec) return out;\n\n if (Array.isArray(spec)) {\n for (const value of spec) {\n if (Number.isInteger(value) && value > 0) out.add(value);\n }\n return out;\n }\n\n for (const part of spec.split(\",\")) {\n const trimmed = part.trim();\n if (!trimmed) continue;\n\n const range = trimmed.match(/^(\\d+)\\s*-\\s*(\\d+)$/);\n if (range) {\n const start = Number(range[1]);\n const end = Number(range[2]);\n if (start > 0 && end >= start) {\n for (let line = start; line <= end; line += 1) out.add(line);\n }\n continue;\n }\n\n if (/^\\d+$/.test(trimmed)) {\n const single = Number(trimmed);\n if (single > 0) out.add(single);\n }\n }\n\n return out;\n}\n\n/** Normalises line endings so every downstream offset is LF-based. */\nexport function normalizeCode(code: string): string {\n return code.replace(/\\r\\n?/g, \"\\n\");\n}\n\n/**\n * Character ranges for `highlightedWords`, as shiki `decorations`.\n *\n * shiki rejects overlapping decorations, so a later match that would overlap an\n * earlier one is dropped rather than passed through to throw.\n */\nexport function buildWordDecorations(\n code: string,\n words?: CodeBlockWordSpec[],\n): { start: number; end: number; properties: { class: string } }[] {\n if (!words?.length) return [];\n\n const lineStarts: number[] = [0];\n for (let index = 0; index < code.length; index += 1) {\n if (code[index] === \"\\n\") lineStarts.push(index + 1);\n }\n\n const lineAt = (offset: number) => {\n let low = 0;\n let high = lineStarts.length - 1;\n while (low < high) {\n const mid = Math.ceil((low + high) / 2);\n if (lineStarts[mid] <= offset) low = mid;\n else high = mid - 1;\n }\n return low + 1;\n };\n\n const taken: { start: number; end: number }[] = [];\n const out: { start: number; end: number; properties: { class: string } }[] = [];\n\n for (const entry of words) {\n const word = typeof entry === \"string\" ? entry : entry.word;\n if (!word) continue;\n const limit = typeof entry === \"string\" ? undefined : parseLineSpec(entry.lines);\n\n let from = code.indexOf(word);\n while (from !== -1) {\n const to = from + word.length;\n const withinLimit = !limit || limit.size === 0 || limit.has(lineAt(from));\n const overlaps = taken.some((r) => from < r.end && to > r.start);\n\n if (withinLimit && !overlaps) {\n taken.push({ start: from, end: to });\n out.push({ start: from, end: to, properties: { class: \"cb-word\" } });\n }\n from = code.indexOf(word, from + word.length);\n }\n }\n\n return out.sort((a, b) => a.start - b.start);\n}\n\n/**\n * Strips `[!code ...]` notation from a copy payload: the transformer already\n * drops it from RENDERED output, but the raw `code` string would paste the\n * comment into someone's editor.\n */\nexport function stripNotationComments(code: string): string {\n return code\n .split(\"\\n\")\n .map((line) =>\n line.replace(/\\s*(?:\\/\\/|#|--|;|%|<!--|\\/\\*)\\s*\\[!code[^\\]]*\\]\\s*(?:-->|\\*\\/)?\\s*$/, \"\"),\n )\n .join(\"\\n\");\n}\n\n/**\n * Plain, unhighlighted lines. One token per line, no colour.\n *\n * This is both the `highlight={false}` renderer and the first paint of a\n * streaming block, so the tail of a stream is readable before its grammar pass\n * lands and no frame is ever blank.\n */\nexport function toPlainLines(code: string, startLine = 1): CodeBlockLine[] {\n return normalizeCode(code)\n .split(\"\\n\")\n .map((text, index) => ({\n tokens: text ? [{ content: text }] : [],\n number: startLine + index,\n text,\n }));\n}\n\n/**\n * Pulls `code` and `language` out of the props react-markdown gives a `pre`:\n * the glue every AI chat app writes by hand, shipped here instead. Tolerant by\n * construction, because a still-streaming fence has no closing delimiter and\n * often no language yet, and must render as plain text rather than throw.\n */\nexport function markdownCodeProps(props: { children?: ReactNode; className?: string }): {\n code: string;\n language?: string;\n} {\n let language: string | undefined;\n let code = \"\";\n\n const readClassName = (value: unknown) => {\n if (typeof value !== \"string\") return;\n const match = value.match(/(?:^|\\s)language-([\\w+#-]+)/);\n if (match && !language) language = match[1];\n };\n\n const walk = (node: unknown): void => {\n if (node === null || node === undefined || node === false) return;\n if (typeof node === \"string\") {\n code += node;\n return;\n }\n if (typeof node === \"number\") {\n code += String(node);\n return;\n }\n if (Array.isArray(node)) {\n for (const child of node) walk(child);\n return;\n }\n if (typeof node === \"object\" && \"props\" in (node as object)) {\n const nodeProps = (node as { props?: Record<string, unknown> }).props;\n if (!nodeProps) return;\n readClassName(nodeProps.className);\n walk(nodeProps.children);\n }\n };\n\n readClassName(props.className);\n walk(props.children);\n\n return { code: code.replace(/\\n$/, \"\"), language };\n}\n\n/** One segment of a markdown string: prose, or a fenced code block. */\nexport type CodeBlockMarkdownPart = {\n type: \"text\" | \"code\";\n content: string;\n language?: string;\n /** True for a fence whose closing delimiter has not arrived yet. */\n open: boolean;\n};\n\n/**\n * Splits markdown into prose and fenced code, for transcripts that render a\n * raw assistant message without a markdown dependency. The unterminated\n * trailing fence is the point: mid-stream it comes back as a code part flagged\n * `open`, instead of being dropped or read as prose.\n */\nexport function markdownFences(markdown: string): CodeBlockMarkdownPart[] {\n const parts: CodeBlockMarkdownPart[] = [];\n const lines = markdown.split(\"\\n\");\n\n let inFence = false;\n let opener = \"\";\n let language: string | undefined;\n let buffer: string[] = [];\n\n const flushText = () => {\n const text = buffer.join(\"\\n\").trim();\n if (text) parts.push({ type: \"text\", content: text, open: false });\n buffer = [];\n };\n\n const flushCode = (open: boolean) => {\n parts.push({\n type: \"code\",\n content: buffer.join(\"\\n\"),\n language,\n open,\n });\n buffer = [];\n language = undefined;\n };\n\n for (const line of lines) {\n /* CommonMark fences: three or more backticks OR tildes. The closer must\n repeat the opener's character at least as many times, or a \\`\\`\\`\\`\n fence containing \\`\\`\\` examples would close three lines early. */\n const fence = line.match(/^\\s*(`{3,}|~{3,})([\\w+#-]*)\\s*$/);\n\n if (fence && !inFence) {\n flushText();\n inFence = true;\n opener = fence[1];\n language = fence[2] || undefined;\n continue;\n }\n\n if (\n fence &&\n inFence &&\n fence[1][0] === opener[0] &&\n fence[1].length >= opener.length &&\n !fence[2]\n ) {\n flushCode(false);\n inFence = false;\n continue;\n }\n\n buffer.push(line);\n }\n\n /* A fence still open at the end of the string is the streaming case: the\n closing delimiter has not arrived. Reporting it as code with `open` set is\n what lets a transcript render the partial block instead of dropping it. */\n if (inFence) flushCode(true);\n else flushText();\n\n return parts;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Engine */\n/* -------------------------------------------------------------------------- */\n\ntype HighlighterLike = {\n codeToHast: (code: string, options: Record<string, unknown>) => unknown;\n getLoadedLanguages: () => string[];\n loadLanguage: (lang: unknown) => Promise<void>;\n loadTheme: (theme: unknown) => Promise<void>;\n};\n\nlet highlighterPromise: Promise<HighlighterLike> | null = null;\nconst loadedLanguages = new Set<string>();\nconst loadedThemes = new Set<string>();\n\n/**\n * One highlighter per page, on the JavaScript regex engine: oniguruma needs\n * WebAssembly, which forces `'wasm-unsafe-eval'` into every consumer's CSP.\n * `forgiving` keeps an inexpressible grammar pattern from taking the block\n * down.\n */\nasync function loadHighlighter() {\n if (!highlighterPromise) {\n highlighterPromise = (async () => {\n const [{ createHighlighterCore }, { createJavaScriptRegexEngine }] = await Promise.all([\n import(\"shiki/core\"),\n import(\"shiki/engine/javascript\"),\n ]);\n\n return (await createHighlighterCore({\n themes: [],\n langs: [],\n engine: createJavaScriptRegexEngine({ forgiving: true }),\n })) as unknown as HighlighterLike;\n })();\n }\n\n return highlighterPromise;\n}\n\n/**\n * Themes register per name, on demand, exactly like languages.\n *\n * Baking the FIRST caller's pair into the singleton looks correct until a page\n * holds two blocks with different `themes` props: the second silently renders\n * in the first one's colours, because the singleton never learns about the\n * request. Loading by name makes every block's prop actually mean something.\n */\nconst warnedThemes = new Set<string>();\n\nasync function ensureTheme(\n highlighter: HighlighterLike,\n name: string,\n side: \"light\" | \"dark\" = \"light\",\n) {\n /* Falls back to the MATCHING side (an unknown dark theme used to fall back\n to github-light, silently rendering light colours in dark mode). */\n const resolved = name in codeBlockThemes ? name : DEFAULT_CODE_BLOCK_THEMES[side];\n if (resolved !== name && process.env.NODE_ENV !== \"production\" && !warnedThemes.has(name)) {\n warnedThemes.add(name);\n console.warn(\n `[code-block] Unknown theme \"${name}\" - falling back to \"${resolved}\". ` +\n \"Register it in codeBlockThemes to use it.\",\n );\n }\n if (loadedThemes.has(resolved)) return resolved;\n await highlighter.loadTheme(await codeBlockThemes[resolved]());\n loadedThemes.add(resolved);\n return resolved;\n}\n\nasync function ensureLanguage(highlighter: HighlighterLike, language: string) {\n if (loadedLanguages.has(language)) return;\n const loader = codeBlockLanguages[language];\n if (!loader) return;\n await highlighter.loadLanguage(await loader());\n loadedLanguages.add(language);\n}\n\n/* -------------------------------------------------------------------------- */\n/* hast to normalised lines */\n/* -------------------------------------------------------------------------- */\n\ntype HastNode = {\n type: string;\n tagName?: string;\n value?: string;\n properties?: Record<string, unknown>;\n children?: HastNode[];\n};\n\nconst FONT_STYLE_BY_DECLARATION: Record<string, CodeBlockFontStyle> = {\n \"font-style:italic\": \"italic\",\n \"font-weight:bold\": \"bold\",\n \"text-decoration:underline\": \"underline\",\n};\n\n/** Splits shiki's inline `style` string into the fields a token carries. */\nfunction readTokenStyle(style: unknown): Omit<CodeBlockToken, \"content\"> {\n if (typeof style !== \"string\") return {};\n\n const out: Omit<CodeBlockToken, \"content\"> = {};\n for (const declaration of style.split(\";\")) {\n const trimmed = declaration.trim();\n if (!trimmed) continue;\n\n const separator = trimmed.indexOf(\":\");\n if (separator === -1) continue;\n\n const property = trimmed.slice(0, separator).trim();\n const value = trimmed.slice(separator + 1).trim();\n\n if (property === \"color\") out.color = value;\n else if (property === \"--shiki-dark\") out.colorDark = value;\n else {\n const fontStyle = FONT_STYLE_BY_DECLARATION[`${property}:${value}`];\n if (fontStyle) out.fontStyle = fontStyle;\n }\n }\n return out;\n}\n\n/**\n * shiki emits raw `class` (string or array), not hast's `className`; reading\n * only `className` finds nothing, which looks like a transformer that never\n * ran.\n */\nfunction classListOf(node: HastNode): string[] {\n const value = node.properties?.class ?? node.properties?.className;\n if (Array.isArray(value)) return value.map(String);\n if (typeof value === \"string\") return value.split(/\\s+/).filter(Boolean);\n return [];\n}\n\n/** Maps the classes shiki transformers put on a line onto line state. */\nfunction stateFromClasses(classes: string[]): CodeBlockLineState | undefined {\n const state: CodeBlockLineState = {};\n if (classes.includes(\"highlighted\")) state.highlighted = true;\n if (classes.includes(\"focused\")) state.focused = true;\n if (classes.includes(\"diff\")) {\n if (classes.includes(\"add\")) state.diff = \"add\";\n else if (classes.includes(\"remove\")) state.diff = \"remove\";\n }\n for (const level of [\"error\", \"warning\", \"info\"] as const) {\n if (classes.includes(level)) state.level = level;\n }\n return Object.keys(state).length ? state : undefined;\n}\n\nfunction collectTokens(node: HastNode, out: CodeBlockToken[], inWord: boolean): void {\n for (const child of node.children ?? []) {\n if (child.type === \"text\") {\n if (!child.value) continue;\n out.push(inWord ? { content: child.value, word: true } : { content: child.value });\n continue;\n }\n if (child.type !== \"element\") continue;\n\n const classes = classListOf(child);\n const childInWord = inWord || classes.includes(\"cb-word\");\n const style = readTokenStyle(child.properties?.style);\n const hasStyle = Boolean(style.color || style.colorDark || style.fontStyle);\n\n /* A styled leaf is a token; a wrapper (a decoration span) is descended into\n so its own children keep their individual colours. */\n const onlyText = (child.children ?? []).every((grandChild) => grandChild.type === \"text\");\n\n if (hasStyle && onlyText) {\n const content = (child.children ?? []).map((c) => c.value ?? \"\").join(\"\");\n if (!content) continue;\n out.push({\n content,\n ...style,\n ...(childInWord ? { word: true } : {}),\n });\n continue;\n }\n\n collectTokens(child, out, childInWord);\n }\n}\n\nfunction findCodeElement(root: HastNode): HastNode | undefined {\n if (root.type === \"element\" && root.tagName === \"code\") return root;\n for (const child of root.children ?? []) {\n const found = findCodeElement(child);\n if (found) return found;\n }\n return undefined;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Identity reuse */\n/* -------------------------------------------------------------------------- */\n\nconst MAX_TRACKED_DOCUMENTS = 24;\n\n/**\n * Previous result per option signature, so a growing stream can reuse lines.\n * Keyed WITH the caller's instanceKey: without it, two same-configured blocks\n * evicted each other's entry on every interleaved pass. Bounded above because\n * module state outlives requests on the server.\n */\nconst previousDocuments = new Map<string, CodeBlockLine[]>();\n\nfunction sameLine(a: CodeBlockLine, b: CodeBlockLine): boolean {\n if (a.number !== b.number || a.text !== b.text) return false;\n if (a.tokens.length !== b.tokens.length) return false;\n if (JSON.stringify(a.state ?? null) !== JSON.stringify(b.state ?? null)) {\n return false;\n }\n for (let index = 0; index < a.tokens.length; index += 1) {\n const left = a.tokens[index];\n const right = b.tokens[index];\n if (\n left.content !== right.content ||\n left.color !== right.color ||\n left.colorDark !== right.colorDark ||\n left.fontStyle !== right.fontStyle ||\n left.word !== right.word\n ) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Swaps freshly built lines for the previous pass's objects where nothing\n * changed. This is why streaming is cheap: the row is a reference-equality\n * `memo`, so without this, appending one token to a 400 line file re-renders\n * 400 subtrees per chunk.\n */\nfunction reuseUnchangedLines(key: string, next: CodeBlockLine[]): CodeBlockLine[] {\n const previous = previousDocuments.get(key);\n\n if (previous) {\n for (let index = 0; index < next.length; index += 1) {\n const before = previous[index];\n if (before && sameLine(before, next[index])) next[index] = before;\n }\n }\n\n previousDocuments.set(key, next);\n if (previousDocuments.size > MAX_TRACKED_DOCUMENTS) {\n const oldest = previousDocuments.keys().next().value;\n if (oldest !== undefined) previousDocuments.delete(oldest);\n }\n\n return next;\n}\n\n/* -------------------------------------------------------------------------- */\n/* highlightCode */\n/* -------------------------------------------------------------------------- */\n\nfunction applyPropState(lines: CodeBlockLine[], options: CodeBlockHighlightOptions): void {\n const highlighted = parseLineSpec(options.highlightedLines);\n const focused = parseLineSpec(options.focusedLines);\n const added = parseLineSpec(options.diff?.added);\n const removed = parseLineSpec(options.diff?.removed);\n const levels = {\n error: parseLineSpec(options.lineLevels?.error),\n warning: parseLineSpec(options.lineLevels?.warning),\n info: parseLineSpec(options.lineLevels?.info),\n };\n\n lines.forEach((line, index) => {\n const source = index + 1;\n const state: CodeBlockLineState = { ...line.state };\n\n if (highlighted.has(source)) state.highlighted = true;\n if (focused.has(source)) state.focused = true;\n if (added.has(source)) state.diff = \"add\";\n else if (removed.has(source)) state.diff = \"remove\";\n for (const level of [\"error\", \"warning\", \"info\"] as const) {\n if (levels[level].has(source)) state.level = level;\n }\n\n line.state = Object.keys(state).length ? state : undefined;\n });\n}\n\n/**\n * Highlights `code` into the renderer's line shape. Built on `codeToHast` so\n * consumer transformers run and their line classes land in `line.state`,\n * making prop state and `[!code ++]` notation one feature, not two code\n * paths. Safe in a server component: the result is plain JSON.\n */\nexport async function highlightCode(\n code: string,\n options: CodeBlockHighlightOptions = {},\n): Promise<CodeBlockLine[]> {\n const source = normalizeCode(code);\n const startLine = options.startLine ?? 1;\n const language = resolveCodeBlockLanguage(options.language);\n\n if (!language) return toPlainLines(source, startLine);\n\n const themes = options.themes ?? DEFAULT_CODE_BLOCK_THEMES;\n const signature = JSON.stringify([\n options.instanceKey ?? null,\n language,\n themes,\n startLine,\n options.highlightedLines ?? null,\n options.highlightedWords ?? null,\n options.focusedLines ?? null,\n options.diff ?? null,\n options.lineLevels ?? null,\n (options.transformers ?? []).length,\n ]);\n\n let root: HastNode;\n try {\n const highlighter = await loadHighlighter();\n const [light, dark] = await Promise.all([\n ensureTheme(highlighter, themes.light),\n ensureTheme(highlighter, themes.dark),\n ]);\n await ensureLanguage(highlighter, language);\n\n root = highlighter.codeToHast(source, {\n lang: language,\n themes: { light, dark },\n defaultColor: \"light\",\n cssVariablePrefix: \"--shiki-\",\n decorations: buildWordDecorations(source, options.highlightedWords),\n ...(options.transformers?.length ? { transformers: options.transformers } : {}),\n }) as HastNode;\n } catch {\n /* A missing grammar, an unloadable theme or a transformer throwing must not\n take the surface down. Plain text is always readable. */\n return toPlainLines(source, startLine);\n }\n\n const codeElement = findCodeElement(root);\n if (!codeElement) return toPlainLines(source, startLine);\n\n const lines: CodeBlockLine[] = [];\n for (const child of codeElement.children ?? []) {\n if (child.type !== \"element\") continue;\n const tokens: CodeBlockToken[] = [];\n collectTokens(child, tokens, false);\n lines.push({\n tokens,\n number: startLine + lines.length,\n text: tokens.map((token) => token.content).join(\"\"),\n state: stateFromClasses(classListOf(child)),\n });\n }\n\n if (!lines.length) return toPlainLines(source, startLine);\n\n applyPropState(lines, options);\n return reuseUnchangedLines(signature, lines);\n}\n\n/** Test seam: drops the singleton and every cached document. */\nexport function resetCodeBlockHighlighter(): void {\n highlighterPromise = null;\n loadedLanguages.clear();\n loadedThemes.clear();\n previousDocuments.clear();\n}\n\n/* -------------------------------------------------------------------------- */\n/* ANSI */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The 16 SGR slots as CSS variables with readable defaults per theme, so a\n * consumer retints terminal output next to their other design tokens\n * (`--code-ansi-red`, `--code-ansi-bright-blue`, ...). 256-colour and\n * truecolor sequences bypass the palette and emit their literal colour.\n */\nconst ANSI_SLOTS = [\n \"black\",\n \"red\",\n \"green\",\n \"yellow\",\n \"blue\",\n \"magenta\",\n \"cyan\",\n \"white\",\n \"bright-black\",\n \"bright-red\",\n \"bright-green\",\n \"bright-yellow\",\n \"bright-blue\",\n \"bright-magenta\",\n \"bright-cyan\",\n \"bright-white\",\n] as const;\n\nconst ANSI_LIGHT = [\n \"#3f3f46\",\n \"#dc2626\",\n \"#16a34a\",\n \"#a16207\",\n \"#2563eb\",\n \"#9333ea\",\n \"#0891b2\",\n \"#71717a\",\n \"#52525b\",\n \"#ef4444\",\n \"#22c55e\",\n \"#ca8a04\",\n \"#3b82f6\",\n \"#a855f7\",\n \"#06b6d4\",\n \"#a1a1aa\",\n];\nconst ANSI_DARK = [\n \"#a1a1aa\",\n \"#f87171\",\n \"#4ade80\",\n \"#facc15\",\n \"#60a5fa\",\n \"#c084fc\",\n \"#22d3ee\",\n \"#e4e4e7\",\n \"#71717a\",\n \"#fca5a5\",\n \"#86efac\",\n \"#fde047\",\n \"#93c5fd\",\n \"#d8b4fe\",\n \"#67e8f9\",\n \"#fafafa\",\n];\n\nconst ansiVar = (slot: number, fallback: string) =>\n `var(--code-ansi-${ANSI_SLOTS[slot]}, ${fallback})`;\n\n/** xterm 256-colour index to hex, computed rather than tabled. */\nfunction ansi256(index: number): string {\n if (index < 16) return ANSI_DARK[index];\n if (index >= 232) {\n const v = 8 + (index - 232) * 10;\n const h = v.toString(16).padStart(2, \"0\");\n return `#${h}${h}${h}`;\n }\n const cube = [0, 95, 135, 175, 215, 255];\n const n = index - 16;\n const to = (v: number) => cube[v].toString(16).padStart(2, \"0\");\n return `#${to(Math.floor(n / 36))}${to(Math.floor(n / 6) % 6)}${to(n % 6)}`;\n}\n\n// biome-ignore lint/suspicious/noControlCharactersInRegex: <>\nconst SGR_RE = /\\x1b\\[([0-9;]*)m/g;\n/* Everything except SGR (the trailing `m`), which the tokenizer consumes -\n this regex once matched SGR too and silently stripped every colour. */\nconst OTHER_ESCAPES_RE =\n // biome-ignore lint/suspicious/noControlCharactersInRegex: <>\n /\\x1b(?:\\[(?![0-9;]*m)[0-9;?]*[A-Za-z]|\\][^\\x07]*(?:\\x07|\\x1b\\\\)|[()][0-9A-B])/g;\n\ntype AnsiStyle = {\n color?: string;\n colorDark?: string;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n};\n\n/**\n * Terminal output with SGR colour codes, as renderable lines: feed the result\n * to the `lines` prop. Covers what agent stdout actually uses - 30-37 / 90-97\n * foregrounds, 38;5;n and 38;2;r;g;b, bold, italic, underline and resets.\n * Backgrounds and cursor movements are STRIPPED rather than rendered: a code\n * surface has its own background, and a partial screen-drawing stream is\n * better read as text than half-drawn.\n */\nexport function ansiToLines(text: string, startLine = 1): CodeBlockLine[] {\n const clean = normalizeCode(text).replace(OTHER_ESCAPES_RE, \"\");\n\n return clean.split(\"\\n\").map((raw, index) => {\n const tokens: CodeBlockToken[] = [];\n const style: AnsiStyle = {};\n let plain = \"\";\n let last = 0;\n\n const flush = (content: string) => {\n if (!content) return;\n const fontStyle = style.bold\n ? (\"bold\" as const)\n : style.italic\n ? (\"italic\" as const)\n : style.underline\n ? (\"underline\" as const)\n : undefined;\n tokens.push({\n content,\n color: style.color,\n colorDark: style.colorDark,\n fontStyle,\n });\n };\n\n SGR_RE.lastIndex = 0;\n let match: RegExpExecArray | null;\n // biome-ignore lint/suspicious/noAssignInExpressions: <>\n while ((match = SGR_RE.exec(raw))) {\n flush(raw.slice(last, match.index));\n plain += raw.slice(last, match.index);\n last = match.index + match[0].length;\n\n const params = (match[1] || \"0\").split(\";\").map(Number);\n for (let i = 0; i < params.length; i += 1) {\n const code = params[i];\n if (code === 0) {\n delete style.color;\n delete style.colorDark;\n style.bold = style.italic = style.underline = false;\n } else if (code === 1) style.bold = true;\n else if (code === 3) style.italic = true;\n else if (code === 4) style.underline = true;\n else if (code === 22) style.bold = false;\n else if (code === 23) style.italic = false;\n else if (code === 24) style.underline = false;\n else if (code === 39) {\n delete style.color;\n delete style.colorDark;\n } else if (code >= 30 && code <= 37) {\n style.color = ansiVar(code - 30, ANSI_LIGHT[code - 30]);\n style.colorDark = ansiVar(code - 30, ANSI_DARK[code - 30]);\n } else if (code >= 90 && code <= 97) {\n style.color = ansiVar(code - 82, ANSI_LIGHT[code - 82]);\n style.colorDark = ansiVar(code - 82, ANSI_DARK[code - 82]);\n } else if (code === 38 && params[i + 1] === 5) {\n const hex = ansi256(params[i + 2] ?? 0);\n style.color = style.colorDark = hex;\n i += 2;\n } else if (code === 38 && params[i + 1] === 2) {\n const [r, g, b] = [params[i + 2] ?? 0, params[i + 3] ?? 0, params[i + 4] ?? 0];\n const hex = `#${[r, g, b].map((v) => v.toString(16).padStart(2, \"0\")).join(\"\")}`;\n style.color = style.colorDark = hex;\n i += 4;\n } else if (code === 48 && (params[i + 1] === 5 || params[i + 1] === 2)) {\n i += params[i + 1] === 5 ? 2 : 4;\n }\n /* 40-47 / 100-107 backgrounds: consumed by falling through. */\n }\n }\n flush(raw.slice(last));\n plain += raw.slice(last);\n\n return { number: startLine + index, text: plain, tokens };\n });\n}\n\n/* -------------------------------------------------------------------------- */\n/* Unified diff */\n/* -------------------------------------------------------------------------- */\n\nexport type CodeBlockPatchFile = {\n /** New-side path, or the old one for a deletion. */\n file: string;\n /** Unified view: context, removed and added lines with dual gutter labels. */\n lines: CodeBlockLine[];\n added: number;\n removed: number;\n hunks: { header: string; at: number }[];\n};\n\n/**\n * A `git diff` / unified patch, as renderable per-file line sets: feed each\n * file's `lines` to the `lines` prop and the diff tints, `+`/`-` glyphs and\n * dual old/new gutter numbers all come from the parse - no `diff` prop\n * arithmetic against a hand-concatenated string. Tokens are plain; patches\n * read by tint, not grammar.\n */\nexport function parseUnifiedDiff(patch: string): CodeBlockPatchFile[] {\n const files: CodeBlockPatchFile[] = [];\n let current: CodeBlockPatchFile | null = null;\n let oldNumber = 0;\n let newNumber = 0;\n let width = 4;\n\n const push = (text: string, state: CodeBlockLineState | undefined, gutter: string) => {\n if (!current) return;\n current.lines.push({\n number: current.lines.length + 1,\n text,\n tokens: [{ content: text }],\n state,\n gutter,\n });\n };\n const pad = (value: number | null) => (value === null ? \"\" : String(value)).padStart(width);\n\n for (const raw of normalizeCode(patch).split(\"\\n\")) {\n const fileHeader = raw.match(/^diff --git a\\/(.+) b\\/(.+)$/);\n const plusHeader = raw.match(/^\\+\\+\\+ (?:b\\/)?(.+)$/);\n if (fileHeader || plusHeader) {\n const name = fileHeader ? fileHeader[2] : plusHeader![1];\n if (name !== \"/dev/null\" && (!current || current.file !== name)) {\n current = { file: name, lines: [], added: 0, removed: 0, hunks: [] };\n files.push(current);\n }\n continue;\n }\n if (\n /^(---|index |old mode|new mode|new file|deleted file|similarity|rename |Binary )/.test(raw)\n ) {\n continue;\n }\n\n const hunk = raw.match(/^@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@(.*)$/);\n if (hunk && current) {\n oldNumber = Number(hunk[1]);\n newNumber = Number(hunk[3]);\n width = Math.max(\n String(oldNumber + Number(hunk[2] ?? 0)).length,\n String(newNumber + Number(hunk[4] ?? 0)).length,\n 2,\n );\n current.hunks.push({ header: raw, at: current.lines.length + 1 });\n push(\n hunk[5].trim() || raw,\n { level: \"info\" },\n `${\"·\".padStart(width)} ${\"·\".padStart(width)}`,\n );\n continue;\n }\n if (!current || (!raw && files.length === 0)) continue;\n\n if (raw.startsWith(\"+\")) {\n push(raw.slice(1), { diff: \"add\" }, `${pad(null)} ${pad(newNumber)}`);\n newNumber += 1;\n current.added += 1;\n } else if (raw.startsWith(\"-\")) {\n push(raw.slice(1), { diff: \"remove\" }, `${pad(oldNumber)} ${pad(null)}`);\n oldNumber += 1;\n current.removed += 1;\n } else if (raw.startsWith(\" \") || raw === \"\") {\n if (current.lines.length === 0 && raw === \"\") continue;\n push(raw.slice(1), undefined, `${pad(oldNumber)} ${pad(newNumber)}`);\n oldNumber += 1;\n newNumber += 1;\n }\n }\n\n return files;\n}\n"],"mappings":";;;;;;;;AAuHA,MAAa,qBAA6D;CACxE,YAAY,OAAO;CACnB,SAAS,OAAO;CAChB,WAAW,OAAO;CAClB,cAAc,OAAO;CACrB,WAAW,OAAO;CAClB,YAAY,OAAO;CACnB,cAAc,OAAO;CACrB,UAAU,OAAO;CACjB,eAAe,OAAO;CACtB,YAAY,OAAO;CACnB,YAAY,OAAO;CACnB,kBAAkB,OAAO;CACzB,YAAY,OAAO;CACnB,WAAW,OAAO;CAClB,cAAc,OAAO;CACrB,gBAAgB,OAAO;CACvB,WAAW,OAAO;CAClB,cAAc,OAAO;CACrB,YAAY,OAAO;CACnB,YAAY,OAAO;CACnB,YAAY,OAAO;CACnB,aAAa,OAAO;CACpB,WAAW,OAAO;CAClB,aAAa,OAAO;CACpB,YAAY,OAAO;CACnB,WAAW,OAAO;CAClB,kBAAkB,OAAO;CACzB,WAAW,OAAO;CAClB,YAAY,OAAO;AACrB;;AAGA,MAAM,mBAA2C;CAC/C,OAAO;CACP,MAAM;CACN,IAAI;CACJ,YAAY;CACZ,KAAK;CACL,IAAI;CACJ,OAAO;CACP,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,aAAa;CACb,IAAI;CACJ,KAAK;CACL,KAAK;AACP;AAEA,MAAa,kBAA0D;CACrE,sBAAsB,OAAO;CAC7B,qBAAqB,OAAO;;;;;;;;;CAS5B,iBAAi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AG,GAAG;GACvB,KAAK,IAAI,MAAM,CAAC,GAAG,EAAE,MAAM,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,GAAG,IAAI,SAAS,GAAG;GACpE,aAAa;GACb,QAAQ,SAAS;EACnB,OAAO,IAAI,IAAI,WAAW,GAAG,GAAG;GAC9B,KAAK,IAAI,MAAM,CAAC,GAAG,EAAE,MAAM,SAAS,GAAG,GAAG,IAAI,SAAS,EAAE,GAAG,IAAI,IAAI,GAAG;GACvE,aAAa;GACb,QAAQ,WAAW;EACrB,OAAO,IAAI,IAAI,WAAW,GAAG,KAAK,QAAQ,IAAI;GAC5C,IAAI,QAAQ,MAAM,WAAW,KAAK,QAAQ,IAAI;GAC9C,KAAK,IAAI,MAAM,CAAC,GAAG,KAAA,GAAW,GAAG,IAAI,SAAS,EAAE,GAAG,IAAI,SAAS,GAAG;GACnE,aAAa;GACb,aAAa;EACf;CACF;CAEA,OAAO;AACT"}
@@ -0,0 +1,197 @@
1
+ import { CodeBlockDiffSpec, CodeBlockHighlightOptions, CodeBlockLevelSpec, CodeBlockLine, CodeBlockLineActionsRender, CodeBlockLineSpec, CodeBlockLineState, CodeBlockPatchFile, CodeBlockThemes, CodeBlockToken, CodeBlockTransformer, CodeBlockWordSpec, ansiToLines, markdownCodeProps, markdownFences, parseUnifiedDiff } from "./code-block-highlight.js";
2
+ import { Button } from "../../ui/button.js";
3
+ import { ComponentProps, ReactNode } from "react";
4
+ //#region src/components/reui/code-block/code-block.d.ts
5
+ /**
6
+ * Two contexts: the document changes on every streamed chunk, the config does
7
+ * not. Splitting them keeps a stream from re-rendering the chrome per chunk.
8
+ */
9
+ type CodeBlockConfigValue = {
10
+ language?: string;
11
+ resolvedLanguage?: string;
12
+ showLineNumbers: boolean;
13
+ wrap: boolean;
14
+ setWrap: (wrap: boolean) => void;
15
+ wrapControlled: boolean;
16
+ expanded: boolean;
17
+ setExpanded: (expanded: boolean) => void;
18
+ collapsible: boolean;
19
+ streaming: boolean;
20
+ contentId: string;
21
+ };
22
+ /**
23
+ * `CodeBlockLineActions` renders nothing itself: it registers its render prop
24
+ * here and the ACTIVE ROW renders it, so actions stay aligned when soft wrap
25
+ * gives lines different heights.
26
+ */
27
+ type CodeBlockLineActionsSide = "end" | "gutter";
28
+ declare function useCodeBlockConfig(part: string): CodeBlockConfigValue & {
29
+ code: string;
30
+ };
31
+ type CodeBlockFoldRegion = {
32
+ /** Source line that owns the toggle and stays visible when folded. */
33
+ start: number;
34
+ /** Last source line the region swallows. */
35
+ end: number;
36
+ };
37
+ type CodeBlockProps = {
38
+ code?: string;
39
+ language?: string;
40
+ lines?: CodeBlockLine[];
41
+ themes?: CodeBlockThemes;
42
+ highlight?: boolean;
43
+ showLineNumbers?: boolean;
44
+ startLine?: number;
45
+ wrap?: boolean;
46
+ defaultWrap?: boolean;
47
+ onWrapChange?: (wrap: boolean) => void;
48
+ maxLines?: number;
49
+ variant?: "default" | "ghost";
50
+ label?: string;
51
+ highlightedLines?: CodeBlockLineSpec;
52
+ highlightedWords?: CodeBlockWordSpec[];
53
+ focusedLines?: CodeBlockLineSpec;
54
+ diff?: CodeBlockDiffSpec;
55
+ lineLevels?: CodeBlockLevelSpec;
56
+ transformers?: CodeBlockTransformer[];
57
+ streaming?: boolean;
58
+ selectable?: boolean;
59
+ selectedLines?: number[];
60
+ defaultSelectedLines?: number[];
61
+ onSelectedLinesChange?: (lines: number[]) => void;
62
+ /** Screen-reader text announced when a stream finishes, for localisation. */
63
+ completeAnnouncement?: string;
64
+ /** Collapsed state under `maxLines`, controlled. */
65
+ expanded?: boolean;
66
+ defaultExpanded?: boolean;
67
+ onExpandedChange?: (expanded: boolean) => void;
68
+ /** Detects fold regions from indentation and renders a toggle per region. */
69
+ foldable?: boolean;
70
+ /**
71
+ * Replaces the indentation heuristic with your own regions (source-numbered,
72
+ * like every line spec) - grammar folding, JSON blocks, patch hunks.
73
+ * Implies nothing about `foldable`; pass both.
74
+ */
75
+ foldRegions?: CodeBlockFoldRegion[];
76
+ /** Folded regions by start line, 1-based within `code`. Controlled. */
77
+ folded?: number[];
78
+ /** Folded regions by their start line, uncontrolled. */
79
+ defaultFolded?: number[];
80
+ onFoldedChange?: (folded: number[]) => void;
81
+ children?: ReactNode;
82
+ } & Omit<ComponentProps<"div">, "children" | "onSelect">;
83
+ /**
84
+ * The root. `<CodeBlock code={code} language="tsx" />` is a complete block;
85
+ * passing `lines` from a server component skips the client highlighter and
86
+ * shiki entirely. Children are CHROME ONLY: the root renders the code surface
87
+ * itself, so child order never matters and a wrapper cannot break scrolling.
88
+ */
89
+ declare function CodeBlock({ code, language, lines: linesProp, themes, highlight, showLineNumbers, startLine, wrap: wrapProp, defaultWrap, onWrapChange, maxLines, variant, label, highlightedLines, highlightedWords, focusedLines, diff, lineLevels, transformers, streaming, selectable, selectedLines, defaultSelectedLines, onSelectedLinesChange, completeAnnouncement, expanded: expandedProp, defaultExpanded, onExpandedChange, foldable, foldRegions: foldRegionsProp, folded, defaultFolded, onFoldedChange, className, children, ...props }: CodeBlockProps): import("react").JSX.Element;
90
+ /**
91
+ * The code surface as a composable part: inside your own ScrollArea the block
92
+ * stops scrolling internally and the ancestor owns both axes (`maxLines`'
93
+ * height cap no longer applies). Omitted, the root renders the same surface
94
+ * itself, exactly as before.
95
+ */
96
+ declare function CodeBlockContent({ className }: {
97
+ className?: string;
98
+ }): import("react").JSX.Element;
99
+ /**
100
+ * Opt-in header. Absent, the block renders no chrome, so it nests in a Card or
101
+ * Frame without a doubled bar. Presence flips `data-has-header` on the root,
102
+ * detected from the element type rather than a `:has()` selector.
103
+ */
104
+ declare function CodeBlockHeader({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
105
+ declare function CodeBlockTitle({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
106
+ /**
107
+ * The resolved language as a label, no props needed. It shows what the
108
+ * highlighter actually resolved, so an unsupported grammar becomes visible
109
+ * instead of silently rendering plain.
110
+ */
111
+ declare function CodeBlockLanguage({ className, children, ...props }: ComponentProps<"span">): import("react").JSX.Element | null;
112
+ type CodeBlockCopyButtonProps = {
113
+ value?: string;
114
+ timeout?: number;
115
+ onCopy?: (value: string) => void;
116
+ onCopyError?: (error: unknown) => void;
117
+ /** Accessible names, for localisation. */
118
+ labels?: {
119
+ copy?: string;
120
+ copied?: string;
121
+ };
122
+ /** `pinned` floats over the surface; `inline` sits in a header. */
123
+ position?: "auto" | "pinned" | "inline";
124
+ alwaysVisible?: boolean;
125
+ } & Omit<ComponentProps<typeof Button>, "value" | "onCopy">;
126
+ /**
127
+ * Copy button. Inline inside a header, pinned over the surface anywhere else.
128
+ * Pinning is absolute against the root, not `position: sticky`: sticky still
129
+ * slides away under HORIZONTAL scroll, and code scrolls sideways constantly.
130
+ * Notation comments are stripped from the payload, matching what is rendered.
131
+ */
132
+ declare function CodeBlockCopyButton({ value, timeout, onCopy, onCopyError, labels, position, alwaysVisible, className, variant, size, children, ...props }: CodeBlockCopyButtonProps): import("react").JSX.Element;
133
+ declare function CodeBlockWrapToggle({ className, children, variant, size, onClick, ...props }: ComponentProps<typeof Button>): import("react").JSX.Element;
134
+ /**
135
+ * Expands a block collapsed by `maxLines`.
136
+ *
137
+ * Renders nothing when the content is shorter than the cut, so a consumer can
138
+ * always compose it without guarding on line count themselves.
139
+ */
140
+ declare function CodeBlockExpandButton({ className, children, variant, size, onClick, ...props }: ComponentProps<typeof Button>): import("react").JSX.Element | null;
141
+ type CodeBlockLineActionsProps = {
142
+ children: CodeBlockLineActionsRender;
143
+ /**
144
+ * `end` floats the group over the end of the active row. `gutter` puts it in
145
+ * the channel beside the line number, which is where a "add this line"
146
+ * affordance belongs. A fold toggle owns that channel when both are on, so a
147
+ * gutter action on a fold-start row falls back to `end`.
148
+ */
149
+ side?: CodeBlockLineActionsSide;
150
+ };
151
+ type CodeBlockDownloadButtonProps = {
152
+ /** Text to save. Defaults to the block's code with notation stripped. */
153
+ value?: string;
154
+ /** Defaults to `code.<ext>` from the block's language. */
155
+ filename?: string;
156
+ onDownload?: (filename: string) => void;
157
+ /** `pinned` floats over the surface; `inline` sits in a header. */
158
+ position?: "auto" | "pinned" | "inline";
159
+ alwaysVisible?: boolean;
160
+ /** Accessible name, for localisation. */
161
+ label?: string;
162
+ } & Omit<ComponentProps<typeof Button>, "value">;
163
+ /**
164
+ * Saves the block's code as a file - the sibling the copy button was missing
165
+ * for builder-style output, where the result IS a file and disk is the next
166
+ * step. Same placement contract as the copy button.
167
+ */
168
+ declare function CodeBlockDownloadButton({ value, filename, onDownload, position, alwaysVisible, label, className, variant, size, children, ...props }: CodeBlockDownloadButtonProps): import("react").JSX.Element;
169
+ declare function CodeBlockLineActions({ children, side }: CodeBlockLineActionsProps): null;
170
+ /**
171
+ * Live folding for anything composed inside the block - a "fold all" control,
172
+ * a region count. Mirrors `useCodeBlockSelection`; region and start numbers
173
+ * are source-based like every line spec.
174
+ */
175
+ declare function useCodeBlockFolding(): {
176
+ foldable: boolean;
177
+ regions: CodeBlockFoldRegion[];
178
+ foldedStarts: number[];
179
+ toggleFold: (start: number) => void;
180
+ foldAll: () => void;
181
+ unfoldAll: () => void;
182
+ };
183
+ /**
184
+ * Live selection for anything composed inside the block - a line action, a
185
+ * header control. Returns the selected lines as a sorted array plus the same
186
+ * toggle the rows use, so an "add selection to chat" affordance can act on the
187
+ * whole range instead of only the hovered line.
188
+ */
189
+ declare function useCodeBlockSelection(): {
190
+ selectable: boolean;
191
+ selectedLines: number[];
192
+ toggleLine: (line: number, extend: boolean) => void;
193
+ clearSelection: () => void;
194
+ };
195
+ //#endregion
196
+ export { CodeBlock, CodeBlockContent, CodeBlockCopyButton, CodeBlockCopyButtonProps, type CodeBlockDiffSpec, CodeBlockDownloadButton, CodeBlockDownloadButtonProps, CodeBlockExpandButton, CodeBlockFoldRegion, CodeBlockHeader, type CodeBlockHighlightOptions, CodeBlockLanguage, type CodeBlockLevelSpec, type CodeBlockLine, CodeBlockLineActions, CodeBlockLineActionsProps, type CodeBlockLineActionsRender, CodeBlockLineActionsSide, type CodeBlockLineSpec, type CodeBlockLineState, type CodeBlockPatchFile, CodeBlockProps, type CodeBlockThemes, CodeBlockTitle, type CodeBlockToken, type CodeBlockTransformer, type CodeBlockWordSpec, CodeBlockWrapToggle, ansiToLines, markdownCodeProps, markdownFences, parseUnifiedDiff, useCodeBlockConfig, useCodeBlockFolding, useCodeBlockSelection };
197
+ //# sourceMappingURL=code-block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-block.d.ts","names":[],"sources":["../../../../src/components/reui/code-block/code-block.tsx"],"mappings":";;;;;;;;KAwDK;EACH;EACA;EACA;EACA;EACA,UAAU;EACV;EACA;EACA,cAAc;EACd;EACA;EACA;;;;;;;KAqCU;iBAsBH,mBAAmB,eAAe;EAAyB;;KAqMxD;;EAEV;;EAEA;;KAsVU;EACV;EACA;EACA,QAAQ;EACR,SAAS;EACT;EACA;EACA;EACA;EACA;EACA,gBAAgB;EAChB;EACA;EACA;EACA,mBAAmB;EACnB,mBAAmB;EACnB,eAAe;EACf,OAAO;EACP,aAAa;EACb,eAAe;EACf;EACA;EACA;EACA;EACA,yBAAyB;;EAEzB;;EAEA;EACA;EACA,oBAAoB;;EAEpB;;;;;;EAMA,cAAc;;EAEd;;EAEA;EACA,kBAAkB;EAClB,WAAW;IACT,KAAK;;;;;;;iBAQA,YACP,MACA,UACA,OAAO,WACP,QACA,WACA,iBACA,WACA,MAAM,UACN,aACA,cACA,UACA,SACA,OACA,kBACA,kBACA,cACA,MACA,YACA,cACA,WACA,YACA,eACA,sBACA,uBACA,sBACA,UAAU,cACV,iBACA,kBACA,UACA,aAAa,iBACb,QACA,eACA,gBACA,WACA,aACG,SACF,iCAAc,IAAA;;;;;;;iBA0cR,mBAAmB;EAAe;oBAAoB,IAAA;;;;;;iBAiatD,kBAAkB,cAAc,SAAS,wCAAqB,IAAA;iBAe9D,iBAAiB,cAAc,SAAS,wCAAqB,IAAA;;;;;;iBAe7D,oBAAoB,WAAW,aAAa,SAAS,yCAAsB,I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