plugin system poc

This commit is contained in:
JellyBrick
2023-11-09 12:43:41 +09:00
parent 06dc0e80f0
commit b6e7e75ae8
5 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1 @@
export * from './types';

View File

@ -0,0 +1,29 @@
import type { BrowserWindow } from 'electron';
export interface Config {
enabled: boolean;
}
export interface Plugin<ConfigType extends Config> {
name: string;
description: string;
config: ConfigType;
}
export interface RendererPlugin<ConfigType extends Config> extends Plugin<ConfigType> {
onEnable: (config: ConfigType) => void;
}
export interface MainPlugin<ConfigType extends Config> extends Plugin<ConfigType> {
onEnable: (window: BrowserWindow, config: ConfigType) => string;
}
export interface PreloadPlugin<ConfigType extends Config> extends Plugin<ConfigType> {
onEnable: (config: ConfigType) => void;
}
export interface MenuPlugin<ConfigType extends Config> extends Plugin<ConfigType> {
onEnable: (config: ConfigType) => void;
}
export const defineConfig = <ConfigType extends Config>(config: ConfigType) => config;