@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
33 lines • 1.79 kB
text/typescript
/**
* Light, client-reachable facade over the grammar engine in `./parseSource`.
*
* Importing this module must NOT pull `createStarryNight` (the regex engine:
* vscode-textmate + oniguruma) or any grammar JSON into the bundle — the engine
* is reached only through the dynamic `import()` in {@link ensureGrammars}. That
* keeps `CodeHighlighter` (which drives lazy, per-language grammar loading from
* the client chunk) free of the engine until a block actually needs to
* highlight, mirroring the `./useCode/transformEngineCache` split.
*/
/**
* Synchronously reports whether every given scope's grammar is already
* registered. Reads the shared singleton without importing the engine, so it is
* safe on the render path (e.g. a `useState` initializer) to decide whether a
* block can highlight immediately or must wait — avoiding a cold flash.
*/
export declare function areGrammarsRegistered(scopes: string[]): boolean;
/**
* Ensures the grammars for the given scopes (and their dependencies) are
* registered, loading the engine and the per-scope grammar chunks on demand. A
* synchronous no-op when the scopes are already registered (warm — e.g. a prior
* block, the speculative preload, or an eager `CodeProvider` primed them), so it
* is cheap to call on render or as a speculative preload. Fails open: a failed
* load leaves the affected scope as plain text.
*/
export declare function ensureGrammars(scopes: string[]): Promise<void>;
/**
* Registers ALL grammars via the single barrel chunk (~146 KB gzip). Backs the
* `preloadGrammars: 'all'` provider opt-in — for layouts that will render code
* in many languages and prefer one upfront fetch over per-language chunks. Fails
* open.
*/
export declare function preloadAllGrammars(): Promise<void>;