@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
20 lines • 1.1 kB
text/typescript
import type { HastRoot } from "../../CodeHighlighter/types.mjs";
import type { FrameRange } from "./calculateFrameRanges.mjs";
/**
* Restructures the HAST frame tree based on computed frame ranges.
*
* This function flattens all existing frame children into a single ordered array,
* then redistributes them into new frames based on the provided frame ranges.
* It's a flat iteration (not a deep recursive traversal) since the HAST structure
* is always Root → Frame(s) → Line(s).
*
* Per-frame `data.fallback` text is kept in sync: it is redistributed onto the
* new frames by shifting only the lines that cross a frame boundary (see
* `redistributeFrameFallbacks`), so enhancers that re-chunk frames don't
* invalidate the precomputed fallback.
*
* @param root - The HAST root node to restructure (mutated in place)
* @param frameRanges - Ordered array of frame ranges
* @param regionIndentLevels - Map of highlighted region index to indent level
*/
export declare function restructureFrames(root: HastRoot, frameRanges: FrameRange[], regionIndentLevels: Map<number, number>): void;