import type { InjectionKey } from 'vue' ; import { inject , provide } from 'vue' ; import type { AppContext , MDXComponents , UserApp } from '../../shared' ; import { useAppConfig } from './appConfig' ; export const mdxComponentsKey = Symbol ( '[iles-mdx-components]' ) ; export function useMDXComponents ( ) { return inject ( mdxComponentsKey ) ; } export function provideMDXComponents ( mdxComponents ) { const overrideElements = useAppConfig ( ) ?. overrideElements ; if ( overrideElements ) { for ( const key in mdxComponents ) { if ( key === key . toLowerCase ( ) && ! overrideElements . includes ( key ) ) console . warn ( `Provided an MDX shortcode for '${ key }', but it's being optimized. You must specify '${ key }' in mdxComponents in app.ts` ) ; } } provide ( mdxComponentsKey , mdxComponents ) ; } export async function installMDXComponents ( context , { mdxComponents } ) { const components = mdxComponents ? typeof mdxComponents === 'function' ? await mdxComponents ( context ) : mdxComponents : { } ; context . app . provide ( mdxComponentsKey , components ) ; }