import { AnnotationHandler, HighlightedCode, RawCode } from 'codehike/code'; import React from 'react'; import { Theme } from '@code-hike/lighter'; declare const annotations: { mark: AnnotationHandler; bg: AnnotationHandler; lineNumbers: AnnotationHandler; diff: AnnotationHandler; }; interface CodeThemeProps { codeblocks?: CodeThemeBlockProps[]; theme?: Theme; children: React.ReactNode; } interface SyntaxHighlightedCode extends HighlightedCode { title?: string; } interface CodeThemeBlockProps { /** This is the raw code. May include annotation comments. */ value: string; /** The programming language. */ lang: string; /** Metadata string (the content after the language name in a markdown codeblock). */ meta: string; title?: string; /** The highlighted code. */ highlighted?: SyntaxHighlightedCode; } declare function useCodeTheme(): { highlighted: SyntaxHighlightedCode[]; }; declare function CodeTheme(props: CodeThemeProps): React.JSX.Element; /** * Pre-highlight codeblocks INTO the shared cache without rendering them, so a * consumer (e.g. a virtualized list) can warm the samples just outside the * viewport — when they scroll in, {@link CodeTheme} finds them cached and paints * instantly. Idempotent: already-cached codeblocks are skipped. Never throws. */ declare function prewarmHighlight(codeblocks: CodeThemeBlockProps[] | undefined, theme?: Theme): Promise; interface CodeProps { codeblocks?: CodeThemeBlockProps[]; theme?: Theme; children: React.ReactNode; } declare function Code(props: CodeProps): React.JSX.Element; declare namespace Code { var LineNumber: (props: any) => React.JSX.Element | null; var Mark: (props: any) => React.JSX.Element; var MarkInline: (props: any) => React.JSX.Element; var Bg: (props: any) => React.JSX.Element; var Pre: (props: { codeblock: HighlightedCode; size?: "full"; handlers: AnnotationHandler[]; className?: string; descriptionHead?: string | React.ReactNode; descriptionContent?: string | React.ReactNode; descriptionIcon?: string; }) => React.JSX.Element; } declare function CodeLoader(): React.JSX.Element; declare function highlight(data: RawCode, theme: Theme, lang: string): HighlightedCode; declare function highlightAsync(data: RawCode, theme: Theme, lang: string): Promise; interface CodeSampleProps { name: string; description: string; codeblocks?: CodeThemeBlockProps[]; theme?: Theme; size?: "full"; lineNumbers?: boolean; descriptionHead?: string; descriptionContent?: string | React.ReactNode; descriptionIcon?: string; markdownFormat?: boolean; kind?: "secondary"; controlByMeta?: boolean; /** How the language switcher renders: a row of tabs (default) or a * dropdown to pick the language. */ languageSwitcher?: "tabs" | "dropdown"; /** Render each language as its programming-language icon (from xyd's * built-in code-language icon set, drawn via the xyd `Icon` component) * instead of the raw name. Languages without an icon keep their name. */ languageIcons?: boolean; /** Advanced override: fully control the label for a language tab/option. * Takes precedence over `languageIcons`. Falls back to the name otherwise. */ renderLanguage?: (lang: string, meta?: string) => React.ReactNode; /** Extra action(s) rendered in the code toolbar, right after the copy button * (e.g. Atlas's "run request" play icon). */ codeActions?: React.ReactNode; /** Controlled active language (a tab value = `meta || lang`). When set with * `onLangChange`, the language switcher is CONTROLLED and shared — every * CodeSample fed the same value shows the same language, and switching one * updates them all (Atlas wires this to its page-shared SDK language). */ activeLang?: string; onLangChange?: (lang: string) => void; } declare function CodeSample(props: CodeSampleProps): React.JSX.Element; interface CodeTabsProps { description: string; highlighted: SyntaxHighlightedCode[]; className?: string; controlByMeta?: boolean; } declare function withCodeTabs(PreComponent: any): (props: CodeTabsProps) => React.JSX.Element | null; interface CoderProviderProps { children: React.ReactNode; lines?: boolean; scroll?: boolean; } declare function CoderProvider({ children, lines, scroll }: CoderProviderProps): React.JSX.Element; /** Which engine the client re-highlight path uses. `codehike` is the default. */ type HighlighterName = "codehike" | "rust"; /** * A Rust highlighter function — the SAME surface as the napi/WASM * `highlight(value, lang, meta, themeJson)` binding: returns the codehike * `HighlightedCode` as a JSON string. `themeJson` is the JSON-stringified * `settings.theme.coder.syntaxHighlight` (a bundled theme name OR a resolved VS * Code theme object — both handled by the Rust engine). */ type RustHighlightFn = (value: string, lang: string, meta: string, themeJson: string) => string; interface CoderConfig { highlighter?: HighlighterName; rustHighlight?: RustHighlightFn; } /** * Configure the coder highlighter. Typically called by the docs-engine from * `settings.engine.highlighter`. Partial — only the provided keys change. */ declare function configureCoder(patch: CoderConfig): void; /** * Register the Rust (WASM) highlight function. The host calls this after it has * built + instantiated the WASM highlighter and loaded onig.wasm. Passing * `null` clears it (falls back to codehike). */ declare function setRustHighlighter(fn: RustHighlightFn | null): void; /** * The active highlighter. Resolution: explicit `configureCoder` wins, then the * `globalThis.__xydCoderHighlighter` global (so the engine can set it before the * bundle loads, without importing this package), then the `codehike` default. */ declare function getHighlighterName(): HighlighterName; /** * The registered Rust highlight function, or `null` if none. Falls back to a * `globalThis.__xydRustHighlight` global so the host can inject without importing * this package. */ declare function getRustHighlighter(): RustHighlightFn | null; /** * Whether the Rust engine should actually be used right now — the toggle is on * AND a Rust highlighter is registered. When the toggle is on but nothing is * registered yet, callers fall back to codehike (safe default), so a * misconfigured or still-loading site never breaks. */ declare function isRustHighlighterActive(): boolean; export { Code, CodeLoader, CodeSample, CodeTheme, CoderProvider, annotations, configureCoder, getHighlighterName, getRustHighlighter, highlight, highlightAsync, isRustHighlighterActive, prewarmHighlight, setRustHighlighter, useCodeTheme, withCodeTabs }; export type { CodeProps, CodeSampleProps, CodeTabsProps, CodeThemeBlockProps, CodeThemeProps, HighlighterName, RustHighlightFn };