RenaiApp/src/shared/types/ipc.d.ts

39 lines
779 B
TypeScript

declare const enum IpcChannel {
NHENTAI_SAVE_FAVORITES = 'NHENTAI_SAVE_FAVORITES',
NHENTAI_GET_WORK = 'NHENTAI_GET_WORK',
ENTITY_GET_WORK = 'ENTITY_GET_WORK',
}
type IpcPayload = {
id: string;
data: unknown;
};
type IpcResponse = {
id: string;
success: boolean;
data?: unknown;
// just the error message
error?: string;
};
type IpcClient = {
ask: (channel: IpcChannel, data?: unknown) => Promise<unknown>;
};
type EntityGetData = {
id: number;
};
interface IpcClientInterface {
ask(channel: IpcChannel.ENTITY_GET_WORK, data: EntityGetData): Promise<WorkSerializedInterface>;
ask(channel: IpcChannel, data?: unknown): Promise<unknown>;
}
type IpcHandler = (data?: unknown) => Promise<unknown>;
type IpcController = {
get(): IpcController;
};