import SocketIOClient from "socket.io-client"; import { DefaultComputed, DefaultData, DefaultMethods, DefaultProps, PropsDefinition, } from "vue/types/options"; import { Vue } from "vue/types/vue"; import { PluginFunction, PluginObject } from "vue"; import { Store } from "vuex"; interface socketHandler { (this: T, ...args: any[]): void } interface Sockets { [key: string]: socketHandler } declare module 'vue/types/vue' { interface Vue { $socket: SocketIOClient.Socket, sockets: { subscribe(eventName: string, handler: socketHandler): void, unsubscribe(eventName: string): void, } } } declare module '@vue/runtime-core' { interface ComponentCustomProperties { $socket: SocketIOClient.Socket, } } declare module 'vue/types/options' { interface ComponentOptions< V extends Vue, Data=DefaultData, Methods=DefaultMethods, Computed=DefaultComputed, PropsDef=PropsDefinition, Props=DefaultProps> { sockets?: Sockets } } export interface VueSocketOptions { debug?: boolean; connection: string | SocketIOClient.Socket, vuex?: { store?: Store, actionPrefix?: string, mutationPrefix?: string, options?: { useConnectionNamespace?: boolean } }, // type declarations for optional options options?:{ path?: string; } } export default class VueSocketIO implements PluginObject { constructor (options: VueSocketOptions); install: PluginFunction }