mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-12 11:01:45 +00:00
change plugin system
This commit is contained in:
38
src/types/plugins.ts
Normal file
38
src/types/plugins.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import type {
|
||||
BackendContext,
|
||||
MenuContext,
|
||||
PreloadContext,
|
||||
RendererContext,
|
||||
} from './contexts';
|
||||
|
||||
type Author = string;
|
||||
|
||||
export type PluginConfig = {
|
||||
enabled: boolean;
|
||||
} & Record<string, unknown>;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type PluginExtra = Record<string, any>;
|
||||
|
||||
type PluginLifecycle<T> =
|
||||
| ((ctx: T) => void | Promise<void>)
|
||||
| ({
|
||||
start?(ctx: T): void | Promise<void>;
|
||||
stop?(ctx: T): void | Promise<void>;
|
||||
} & PluginExtra);
|
||||
|
||||
export interface PluginDef {
|
||||
name: string;
|
||||
authors?: Author[];
|
||||
description?: string;
|
||||
config: PluginConfig;
|
||||
|
||||
menu?: (ctx: MenuContext) => Electron.MenuItemConstructorOptions[];
|
||||
restartNeeded?: boolean;
|
||||
|
||||
backend?: PluginLifecycle<BackendContext>;
|
||||
preload?: PluginLifecycle<PreloadContext>;
|
||||
renderer?: PluginLifecycle<RendererContext> & {
|
||||
stylesheet?: string;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user