import type { PluginLoadedMetadata, PluginUploadCommandsMetadata } from '../client/plugins'; import type { Command, ContextMenuCommand, EntryPointCommand, UsingClient } from '../commands'; import type { Awaitable } from '../common'; import type { ComponentCommands } from '../components/handler'; import type { ClientEvents } from './hooks'; export interface CustomEvents { commandsLoaded: (metadata: PluginLoadedMetadata<'commands', Command | ContextMenuCommand | EntryPointCommand>) => void; componentsLoaded: (metadata: PluginLoadedMetadata<'components', ComponentCommands>) => void; uploadCommands: (metadata: PluginUploadCommandsMetadata) => void; } export type ClientNameEvents = Extract; export type CustomEventsKeys = Extract; export interface ClientDataEvent { name: ClientNameEvents | CustomEventsKeys; once: boolean; } export type CallbackEventHandler = { [K in keyof ClientEvents]: (...data: [Awaited, UsingClient, number]) => unknown; } & { [K in keyof CustomEvents]: (...data: [...Parameters, UsingClient]) => unknown; }; export type EventContext = Parameters; export interface ClientEvent { data: ClientDataEvent; run(...args: EventContext): Awaitable; }