UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

30 lines (29 loc) 1.22 kB
import { CSSProperties } from 'react'; import type { BuiltinTheme, CodeToHastOptions, ThemedToken } from 'shiki'; import { SWRResponse } from 'swr'; declare const MD5_LENGTH_THRESHOLD = 10000; type ColorReplacements = { [themeName: string]: { [color: string]: string; }; }; type StreamingHighlightResult = { colorReplacements?: Record<string, string>; lines: ThemedToken[][]; preStyle?: CSSProperties; }; type UseHighlightResponse = SWRResponse<string, Error> & { colorReplacements?: ColorReplacements; streaming?: StreamingHighlightResult; }; type ICodeToHtml = (code: string, options: CodeToHastOptions) => Promise<string>; declare const loadShiki: () => Promise<ICodeToHtml | null>; declare const shikiPromise: Promise<ICodeToHtml | null>; declare const escapeHtml: (str: string) => string; export declare const useHighlight: (text: string, { language, enableTransformer, theme: builtinTheme, streaming, }: { enableTransformer?: boolean | undefined; language: string; streaming?: boolean | undefined; theme?: import("shiki/dist/themes.mjs").BundledTheme | undefined; }) => UseHighlightResponse; export { escapeHtml, loadShiki, MD5_LENGTH_THRESHOLD, shikiPromise };