UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

24 lines (19 loc) 1.01 kB
'use client'; import * as React from 'react'; // Type definitions for the heavy functions we're moving to context // Lazy accessors for the heaviest functions. Each returns the function via a // dynamic import (deduped per page by `PreloadProvider`), so the function's // module - and its heavy transitive deps (e.g. jsondiffpatch) - stays out of // the initial client bundle. The accessor's *presence* (always defined when a // CodeProvider is mounted) is the synchronously-known "is provisioned" signal // that gates loading, replacing the previous "is the resolved fn present" check. /** * Context interface for code processing functions. * Provides heavy functions via context that can't be serialized across the server-client boundary. */ export const CodeContext = /*#__PURE__*/React.createContext({}); if (process.env.NODE_ENV !== "production") CodeContext.displayName = "CodeContext"; export const useCodeContext = () => { const context = React.useContext(CodeContext); return context; };