This commit is contained in:
JellyBrick
2023-11-27 04:59:20 +09:00
parent e0a3489640
commit 11d06c50a5
26 changed files with 817 additions and 836 deletions

View File

@ -1,16 +1,17 @@
import type { BrowserWindow } from 'electron';
import type { IpcMain, IpcRenderer, WebContents, BrowserWindow } from 'electron';
import type { PluginConfig } from '@/types/plugins';
export interface BaseContext<Config extends PluginConfig> {
getConfig(): Promise<Config>;
setConfig(conf: Partial<Omit<Config, 'enabled'>>): void;
getConfig(): Promise<Config> | Config;
setConfig(conf: Partial<Omit<Config, 'enabled'>>): Promise<void> | void;
}
export interface BackendContext<Config extends PluginConfig> extends BaseContext<Config> {
ipc: {
send: (event: string, ...args: unknown[]) => void;
send: WebContents['send'];
handle: (event: string, listener: CallableFunction) => void;
on: (event: string, listener: CallableFunction) => void;
removeHandler: IpcMain['removeHandler'];
};
window: BrowserWindow;
@ -25,8 +26,9 @@ export interface PreloadContext<Config extends PluginConfig> extends BaseContext
export interface RendererContext<Config extends PluginConfig> extends BaseContext<Config> {
ipc: {
send: (event: string, ...args: unknown[]) => void;
invoke: (event: string, ...args: unknown[]) => Promise<unknown>;
send: IpcRenderer['send'];
invoke: IpcRenderer['invoke'];
on: (event: string, listener: CallableFunction) => void;
removeAllListeners: (event: string) => void;
};
}

View File

@ -34,7 +34,7 @@ export interface PluginDef<
description?: string;
config?: Config;
menu?: (ctx: MenuContext<Config>) => Promise<Electron.MenuItemConstructorOptions[]>;
menu?: (ctx: MenuContext<Config>) => Promise<Electron.MenuItemConstructorOptions[]> | Electron.MenuItemConstructorOptions[];
stylesheets?: string[];
restartNeeded?: boolean;