@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
23 lines • 1.5 kB
text/typescript
import type { Code, CodeHighlighterBaseProps } from "./types.mjs";
type HighlightAfter = CodeHighlighterBaseProps<{}>['highlightAfter'];
/**
* Resolve the staging `fallbackCritical` field at a server→client (or client-load)
* boundary, returning a clone of `code` ready to cross to the client:
*
* - **Promote** — under `highlightAt: 'init'` (and not `collapseToEmpty`), each
* variant whose `fallbackCritical` *and* plain `fallback` are both present has the
* sparse `fallbackCritical` diff spliced over its `fallback` (`promoteCriticalFallback`)
* — the visible frames become highlighted, the rest stay plain — so the first paint is
* highlighted with no client-side decompression. The promoted `fallback` stays a valid
* DEFLATE dictionary because the spliced frames have byte-identical text. With
* `collapseToEmpty`, the correct critical fallback is all-plain (no frame is visible),
* which already equals `fallback` — so promotion is skipped.
* - **Strip** — `fallbackCritical` is always deleted (even when not promoting, and
* even for non-`init` modes), so it never crosses to the `Content`/`ContentLoading`
* components or bloats the serialized payload.
*
* Returns `code` unchanged (same reference) when no variant carries `fallbackCritical`,
* and clones only the variants that do.
*/
export declare function resolveFallbackCritical(code: Code | undefined, highlightAfter: HighlightAfter, collapseToEmpty: boolean): Code | undefined;
export {};