import type { InjectionKey } from 'vue'
import type { Emitter } from '/@/utils/mitt'
import { createContext, useContext } from '/@/hooks/core/useContext'

export interface VContextProps {
  rootEmitter: Emitter
}

const key: InjectionKey<VContextProps> = Symbol()

export function createVContext(context: VContextProps) {
  return createContext<VContextProps>(context, key, { readonly: false, native: true })
}

export function useVContext() {
  return useContext<VContextProps>(key)
}
