UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

24 lines (21 loc) 975 B
'use client'; import * as React from 'react'; /** * One cached pre-parsed file. Stored per-fileName: each new write replaces * any previous entry for that file. The `source` string is the cache key — * `parseControlledCode` only reuses `hast` when the controlled-code source * is byte-identical, which guarantees the cached HAST matches the input * that produced it. */ export const CodeHighlighterContext = /*#__PURE__*/React.createContext(undefined); if (process.env.NODE_ENV !== "production") CodeHighlighterContext.displayName = "CodeHighlighterContext"; export function useCodeHighlighterContext() { const context = React.useContext(CodeHighlighterContext); if (context === undefined) { throw new Error('CodeHighlighterContext is missing. `useCodeHighlighterContext` must be used within a `CodeHighlighter` component.'); } return context; } export function useCodeHighlighterContextOptional() { return React.useContext(CodeHighlighterContext); }