UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

40 lines 1.74 kB
import type { ElementContent } from 'hast'; /** * A frame's precomputed plain-text fallback together with the inclusive * 1-based source line range it covers. * * `nodes` is the `frame.data.fallback` array — usually a single text node * whose concatenated value equals the frame's rendered plain text (with a * trailing newline on every line except the final line of the source). */ export interface FrameFallback { startLine: number; endLine: number; nodes: ElementContent[]; } /** * A new frame's target line range (inclusive, 1-based). */ export interface FrameRangeBounds { startLine: number; endLine: number; } /** * Redistributes existing per-frame fallback node arrays onto a new set of * frame line ranges, shifting only the lines that cross a frame boundary. * * Enhancers never change the plain-text output of the code (they only add or * modify highlighting spans), so when a frame's line range is unchanged its * fallback is reused by reference without scanning. Only the boundary frames — * where lines move into an adjacent frame — are split, and the split walks just * the lines that need to move (counting newlines with an early exit) rather * than splitting the whole frame or re-deriving text via `toText`. * * Lines that fall in a gap between ranges (collapsed / dropped lines) have * their fallback text discarded. * * `oldFrames` must be ordered ascending and non-overlapping (gaps are allowed, * e.g. when a previous restructure already dropped lines); `ranges` must be * ordered ascending. Returns one node array per range, in range order. */ export declare function redistributeFrameFallbacks(oldFrames: FrameFallback[], ranges: FrameRangeBounds[]): ElementContent[][];