@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
31 lines • 2.05 kB
text/typescript
import type { BaseContentLoadingProps, Code, Fallbacks } from "./types.mjs";
import { type SourceLineCounts } from "../useCode/sourceLineCounts.mjs";
/** Per-variant → per-file line metadata threaded for the fallback. */
export type LineCountsByVariant = Record<string, Record<string, SourceLineCounts>>;
export declare function codeToFallbackProps(variant: string, code?: Code, _fileName?: string, _needsAllFiles?: boolean, needsAllVariants?: boolean, allFallbackHasts?: Record<string, Fallbacks>, allLineCounts?: LineCountsByVariant): BaseContentLoadingProps;
/**
* Read a variant's per-file fallbacks straight off its `VariantCode` `fallback`
* fields (main + extra files), returning a `Fallbacks` map keyed by file name.
*
* The fallback crosses the server→client boundary exactly once: either on the
* `VariantCode` (no `ContentLoading`) or — after `stripFallbackHastsFromCode`
* moves it — on the `ContentLoading` props. This reads the former location, so
* the client can resolve the DEFLATE dictionary for `hastCompressed` without a
* hoist when there's no `ContentLoading`. Returns `undefined` when the variant
* carries no fallback (a string variant, a live-HAST source, or one whose
* fallbacks were stripped for a `ContentLoading` component) — in which case the
* hoisted copy is used instead.
*/
export declare function deriveFallbacksFromCode(code: Code | undefined, variantName: string): Fallbacks | undefined;
/**
* Strip `fallback` entries from a `Code` object and return the
* stripped Code alongside the extracted fallbacks grouped by variant → fileName.
*
* Used on the server to separate the fallback data from the Code
* so Code is sent to CodeHighlighterClient without fallbacks, and
* the data is passed to ContentLoading as source/extraSource props.
*/
export declare function stripFallbackHastsFromCode(code: Code | undefined, variantName: string, fallbackUsesExtraFiles?: boolean, fallbackUsesAllVariants?: boolean): {
strippedCode: Code;
allFallbackHasts: Record<string, Fallbacks>;
};