@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
23 lines • 1.13 kB
text/typescript
/**
* On first render, start loading the grammar chunks a block is about to need for
* client-side highlighting, so they are in flight before `useCode` mounts and
* the parse runs. Mirrors {@link useSpeculativeCodePreload} /
* {@link useSpeculativeUseCodePreload}: detection is cheap and synchronous
* (`detectGrammarScopes` reads only metadata), the load runs in a mount effect
* (so it never blocks first paint), and `ensureGrammars` dedupes with the
* eventual consumer (`useGrammarsReady`) and is a no-op when warm.
*
* The signal is deliberately accurate so a block needs only its own languages: a
* fully-precomputed read-only block (which renders its highlighted HAST and
* never calls `parseSource`) sets `enabled = false` and loads no grammar at all,
* and a `tsx`+`css` block loads only those two grammars instead of all ten.
*/
export declare function useSpeculativeGrammarPreload({
scopes,
enabled
}: {
/** Grammar scopes the block needs (should be memoized by the caller). */
scopes: string[];
/** Whether the block will highlight client-side (or live-edit). */
enabled: boolean;
}): void;