Files
Exiled-Exchange-2/ipc/types.ts
2022-12-28 12:52:59 +02:00

144 lines
2.9 KiB
TypeScript

export interface HostConfig {
shortcuts: ShortcutAction[]
restoreClipboard: boolean
clientLog: string | null
gameConfig: string | null
stashScroll: boolean
overlayKey: string
disableUpdateDownload: boolean
logLevel: string
windowTitle: string
}
export interface ShortcutAction {
shortcut: string
keepModKeys?: true
action: {
type: 'copy-item'
focusOverlay?: boolean
target: string
} | {
type: 'trigger-event'
target: string
} | {
type: 'stash-search'
text: string
} | {
type: 'toggle-overlay'
} | {
type: 'paste-in-chat'
text: string
send: boolean
} | {
type: 'test-only'
}
}
export type IpcEvent =
// events that have meaning only in Overlay mode:
IpcOverlayAttached |
IpcFocusChange |
IpcVisibility |
IpcFocusGame |
IpcHideExclusiveWidget |
IpcTrackArea |
// events used by any type of Client:
IpcSaveConfig |
IpcUpdateInfo |
IpcStashSearch |
IpcGameLog |
IpcClientIsActive |
IpcLogEntry |
IpcHostConfig |
IpcWidgetAction |
IpcItemText |
IpcConfigChanged
export type IpcEventPayload<Name extends IpcEvent['name'], T extends IpcEvent = IpcEvent> =
T extends { name: Name, payload: infer P } ? P : never
type IpcOverlayAttached =
Event<'MAIN->OVERLAY::overlay-attached'>
type IpcFocusChange =
Event<'MAIN->OVERLAY::focus-change', {
game: boolean
overlay: boolean
usingHotkey: boolean
}>
type IpcVisibility =
Event<'MAIN->OVERLAY::visibility', {
isVisible: boolean
}>
type IpcFocusGame =
Event<'OVERLAY->MAIN::focus-game'>
type IpcHideExclusiveWidget =
Event<'MAIN->OVERLAY::hide-exclusive-widget'>
type IpcTrackArea =
Event<'OVERLAY->MAIN::track-area', {
holdKey: string
closeThreshold: number
from: { x: number, y: number }
area: { x: number, y: number, width: number, height: number }
}>
type IpcHostConfig =
Event<'CLIENT->MAIN::update-host-config', HostConfig>
type IpcClientIsActive =
Event<'CLIENT->MAIN::used-recently'>
type IpcSaveConfig =
Event<'CLIENT->MAIN::save-config', {
contents: string
isTemporary: boolean
}>
type IpcConfigChanged =
Event<'MAIN->CLIENT::config-changed', {
contents: string
}>
type IpcLogEntry =
Event<'MAIN->CLIENT::log-entry', {
message: string
}>
type IpcWidgetAction =
Event<'MAIN->CLIENT::widget-action', {
target: string
}>
type IpcItemText =
Event<'MAIN->CLIENT::item-text', {
target: string
clipboard: string
position: { x: number, y: number }
focusOverlay: boolean
}>
type IpcStashSearch =
Event<'CLIENT->MAIN::stash-search', {
text: string
}>
type IpcGameLog =
Event<'MAIN->CLIENT::game-log', {
lines: string[]
}>
export type IpcUpdateInfo =
Event<'MAIN->CLIENT::update-available', {
auto: boolean
version: string
}>
interface Event<TName extends string, TPayload = undefined> {
name: TName
payload: TPayload
}