UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

27 lines 1.63 kB
import type { Nodes } from 'hast'; import { type SourceComments, type Transforms } from "../../CodeHighlighter/types.mjs"; /** * Async-friendly variant of {@link ParseSource}. The build-time diff path * may wrap the synchronous highlighter with enhancers that need to run * asynchronously, so `diffHast` accepts either return shape. `comments` * is the post-transform comment map (1-indexed by line in the transformed * source) when the transform repositions lines; wrappers that drive * enhancers should prefer it over the source's own comment map so the * enhanced frame structure aligns with the patched output. */ type AsyncParseSource = (source: string, fileName: string, language?: string, comments?: SourceComments) => Nodes | Promise<Nodes>; /** * Diffs each transformed variant against `parsedSource` and returns * a `Transforms` map where every entry carries a `delta`. * * NOTE: `parsedSource` is temporarily mutated for the duration of this * call — `dataLn` properties are stripped from line spans before diffing * (so the always-sequential gutter numbering doesn't leak into the * delta) and restored in `finally`. Callers must not read from the tree * concurrently, and must not invoke `diffHast` against the same * `parsedSource` in parallel. Today's only caller (`loadSingleFile`) * runs sequentially per variant, so the constraint is satisfied; if * that ever changes, clone the source array once up front instead. */ export declare function diffHast(source: string, parsedSource: Nodes, filename: string, transforms: Transforms, parseSource: AsyncParseSource): Promise<Transforms>; export {};