import React from 'react'; import { type CSSObject } from 'restyle'; import type { Languages } from '../../utils/get-language.ts'; import { type SourceTextHydrationMetadata } from '../../analysis/query/source-text-metadata.ts'; import type { Token } from '../../utils/get-tokens.ts'; import { getThemeColors } from '../../utils/get-theme.ts'; import type { ConfigurationOptions } from '../Config/types.ts'; import { type PathLike } from '../../utils/path.ts'; import { type QuickInfoEntry, type QuickInfoPopoverProps } from './QuickInfoProvider.tsx'; import { type SlotComponentOrProps } from '../../utils/slot-components.ts'; type ThemeColors = Awaited>; interface QuickInfoRequestSource { filePath: string; sourceMetadata: SourceTextHydrationMetadata; valueSignature?: string; } export declare function shouldSkipInlineSourceMetadataLookup({ resolvedPath, language, supportsSourceFormattingInCurrentContext, shouldUseInlineSourceMetadataFastPath, isFormattingExplicit, shouldFormat, }: { resolvedPath: string | undefined; language: Languages | undefined; supportsSourceFormattingInCurrentContext: boolean; shouldUseInlineSourceMetadataFastPath: boolean; isFormattingExplicit: boolean; shouldFormat: boolean; }): boolean; export type AnnotationRenderer = React.ComponentType & { children?: React.ReactNode; }>; export type AnnotationRenderers = Record; export interface TokensTokenProps extends Omit, 'children'> { children: React.ReactNode; css?: CSSObject; quickInfoId?: string; highlightColor?: string; } export interface TokensErrorProps extends Omit, 'children'> { children: React.ReactNode; css?: CSSObject; } export type TokensPopoverProps = QuickInfoPopoverProps; export interface TokensComponentOverrides { Token: SlotComponentOrProps; Error: SlotComponentOrProps; Popover: SlotComponentOrProps; } export interface TokensComponents { Token: React.ComponentType; Error: React.ComponentType; Popover: React.ComponentType; } export interface TokensProps { /** Code string to highlight and render as tokens. */ children?: string | Promise; /** Name or path of the tokens to render. This will read the local file system contents from the `baseDirectory` joined with the `path` prop instead of creating a virtual file. Pass `null` to explicitly disable context inheritance. */ path?: PathLike | null; /** The base directory to use when analyzing the source code. This will read the local file system contents from the `baseDirectory` joined with the `path` prop instead of creating a virtual file. */ baseDirectory?: PathLike; /** Language to use for syntax highlighting. */ language?: Languages; /** Whether to allow errors to be displayed. */ allowErrors?: boolean | string; /** Whether to show errors. */ showErrors?: boolean; /** Whether or not to analyze the source code for type errors and provide quick information on hover. */ shouldAnalyze?: boolean; /** Whether or not to format the source code using `prettier` if installed. */ shouldFormat?: boolean; /** Override the default token, diagnostic, and quick info popover renderers. */ components?: Partial; /** Optional theme configuration to drive highlighting explicitly. */ theme?: ConfigurationOptions['theme']; /** Custom render function for each line of tokens. */ renderLine?: (line: { children: React.ReactNode; index: number; isLast: boolean; }) => React.ReactNode; /** * Map of annotation tag names to render functions. When provided, comments * matching the annotation signature will be removed from the rendered output * and replaced with the corresponding annotation components. */ annotations?: AnnotationRenderers; } /** Renders syntax highlighted tokens for the `CodeBlock` component. */ export declare function Tokens(props: TokensProps): React.JSX.Element | Promise; interface RenderTokenOptions { token: Token; tokenIndex: number; lineIndex: number; quickInfoRequestPosition?: number; baseTokenClassName?: string; quickInfoRequestSource?: QuickInfoRequestSource; registerQuickInfoEntry?: (entry: QuickInfoEntry) => void; theme: ThemeColors; components: TokensComponents; } declare function renderToken({ token, tokenIndex, lineIndex, quickInfoRequestPosition, baseTokenClassName, quickInfoRequestSource, registerQuickInfoEntry, theme, components, }: RenderTokenOptions): React.ReactNode; export declare const __TEST_ONLY__: { renderToken: typeof renderToken; }; export {};