UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

43 lines 1.93 kB
import * as React from 'react'; import type { FallbackNode } from "../pipeline/hastUtils/fallbackFormat.mjs"; type HighlightAt = 'hydration' | 'idle' | 'visible'; interface TypeCodeProps { /** JSON-serialized HAST tree (root > pre > code > children). */ hastJson?: string; /** DEFLATE-compressed, base64-encoded HAST tree. */ hastCompressed?: string; /** When to replace the fallback with the fully-highlighted version. */ highlightAt: HighlightAt; /** * Links-only fallback (code children with highlighting spans stripped), * in compact `FallbackNode[]` format. * Serves two purposes: * 1. Rendered as the initial display until the full highlight is ready. * 2. Its text content is used as a DEFLATE dictionary for decompression * when `hastCompressed` was compressed with that same text dictionary. */ fallback?: FallbackNode[]; /** Props for the `<code>` element wrapper (className, etc.). */ codeProps?: Record<string, unknown>; } /** * Renders a links-only fallback on the server and replaces it with the * fully syntax-highlighted version on the client at the configured time. * * When `fallback` is provided, it is converted to HAST and rendered for the * initial display. Its text content is derived (via `fallbackToText`) to serve * as the DEFLATE dictionary for decompressing `hastCompressed`. * * - `'hydration'`: parse immediately on mount. * - `'idle'`: defer to `requestIdleCallback` regardless of visibility. * - `'visible'`: wait until the element enters the viewport (IntersectionObserver), * then defer to `requestIdleCallback` to avoid blocking scroll or paint. */ export declare function TypeCode({ hastJson, hastCompressed, highlightAt, fallback, codeProps }: TypeCodeProps): React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement> | React.DetailedReactHTMLElement<Record<string, unknown>, HTMLElement>; export {};