@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
40 lines • 2.02 kB
text/typescript
import * as React from 'react';
import type { LoadCodeMeta, LoadSource, LoadVariantMeta, SourceEnhancers } from "../CodeHighlighter/types.mjs";
interface CodeProviderLazyProps {
/** Child components that will have access to the code handling context */
children: React.ReactNode;
/** Function to load code metadata from a URL */
loadCodeMeta?: LoadCodeMeta;
/** Function to load specific variant metadata */
loadVariantMeta?: LoadVariantMeta;
/** Function to load raw source code and dependencies */
loadSource?: LoadSource;
sourceEnhancers?: SourceEnhancers;
/**
* Warm grammars at the provider level instead of waiting for each block to
* load its own on demand. Pass a list of language names (`'tsx'`, `'css'`) or
* scope names (`'source.tsx'`) to preload exactly those (one chunk each), or
* `'all'` to fetch the single ~146 KB grammar barrel up front. Useful for
* a layout that knows it will render code in a fixed set of languages, or one
* with many languages where a single fetch beats many per-language chunks.
* Omit it (the default) to keep grammars fully lazy and per-language.
*/
preloadGrammars?: 'all' | string[];
}
/**
* Lazy counterpart to `CodeProvider`: the same context, but the heavy functions
* (the variant/fallback loaders and the transform-delta computer that pulls
* `jsondiffpatch`) are loaded via dynamic `import()` on demand instead of bundled.
* Use this as the general default to keep them out of the initial bundle.
*
* It renders its own `PreloadProvider`, so the heavy-chunk fetches dedupe across
* every code block in its subtree - and `CodeHighlighter`'s first-render
* speculative preload shares the same promise the eventual consumer resolves -
* with no extra wiring. (Cross-page network fetches of an identical chunk are
* deduped by the browser module cache regardless.)
*/
export declare function CodeProviderLazy({
children,
...rest
}: CodeProviderLazyProps): import("react/jsx-runtime").JSX.Element;
export {};