UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

49 lines 2.52 kB
import type { HastRoot, Transforms } from "../../CodeHighlighter/types.mjs"; /** * Recursively walks a jsondiffpatch delta looking for any inserted hast * element with `className === 'collapse'`. Used to mark a manifest entry * as layout-affecting (phase 1, coordinated barrier so peers stay in * lockstep) so the runtime doesn't have to decompress the embedded hast * payload on every selection change to classify the swap. * * Walks every nested value rather than interpreting jsondiffpatch's * opcodes (`[value]` for insert, `[oldValue, 0, 0]` for delete, `_t: 'a'` * + `_N` keys for array ops). The collapse placeholder is only ever * produced by `compactCollapseInTreeInPlace` on the *transform* side of * the diff, so any hast element with className 'collapse' anywhere in * the delta tree is necessarily part of an insertion or in-place rewrite. */ export declare function deltaContainsCollapse(delta: unknown): boolean; /** * Splits a `Transforms` map (as produced by `diffHast`, which always * carries deltas for entries that change the source — rename-only * entries pass through with no delta) into the variant-level `manifest` * (no `delta`) and the `embedded` map that should ride inside * `source.data.transforms`. * * Entries with a meaningful delta land in both the manifest (with * `hasDelta: true`) and the embedded map. Rename-only entries (no * delta but a renamed `fileName`) land only in the manifest with * `hasDelta` omitted or `false`; consumers use this flag to hide the * transform toggle while still applying the rename when the user has * the matching transform preference selected. Entries with neither a * delta nor a rename are dropped from both. * * Returns `undefined` when no entry survived — callers should treat that * as "no transforms to record". * * This is the single source of truth for the manifest / embedded split; * both `computeHastDeltas` (per-file diffs) and the variant-level embed * step in `loadIsomorphicCodeVariant` go through it so the wire shape * stays consistent. */ export declare function splitTransformsForEmbed(transforms: Transforms): { manifest: Transforms; embedded: Transforms; } | undefined; /** * Embeds `embedded` transforms inside `root.data.transforms` so they ride * along inside the (possibly later compressed) hast payload and stay out * of the variant-level wire shape that ends up in HTML / module graph. */ export declare function embedTransformsInRoot(root: HastRoot, embedded: Transforms): void;