import { chatViewPlugins, messageEventPlugins, messageViewPlugins } from './video'
import type VideoSendInfo from "@/plugins/video/mode/VideoSendInfo";

const VimPlugin = {
  homePlugins: [],
  chatViewPlugins: () => {
    return [...chatViewPlugins()]
  },
  //消息展示插件
  messageViewPlugins: () => {
    return [...messageViewPlugins()]
  },
  //消息调用插件
  messageEventPlugins: () => {
    return [...messageEventPlugins()]
  },
  // 渲染消息展示插件
  renderMessage(type: string) {
    const plugin = VimPlugin.messageViewPlugins().find((p) => p.messageType === type)
    if (plugin) {
      return plugin.renderMessage()
    }
    return null
  },
  //收到消息的处理函数
  messageListener: (sendInfo: VideoSendInfo<any>) => {
    const plugin = VimPlugin.messageEventPlugins().find((p) => p.code === sendInfo.code)
    if (plugin) {
      plugin.listener(sendInfo)
    }
  }
}
export default VimPlugin
