mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
plugin system poc
This commit is contained in:
1
src/plugins/utils/common/index.ts
Normal file
1
src/plugins/utils/common/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './types';
|
||||
29
src/plugins/utils/common/types.ts
Normal file
29
src/plugins/utils/common/types.ts
Normal 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;
|
||||
@ -1,3 +1,4 @@
|
||||
export * from './css';
|
||||
export * from './fs';
|
||||
export * from './plugin';
|
||||
export * from './types';
|
||||
|
||||
7
src/plugins/utils/main/types.ts
Normal file
7
src/plugins/utils/main/types.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import type { Config, MainPlugin, MenuPlugin, PreloadPlugin } from '../common';
|
||||
|
||||
export const defineMainPlugin = <ConfigType extends Config>(plugin: MainPlugin<ConfigType>) => plugin;
|
||||
|
||||
export const definePreloadPlugin = <ConfigType extends Config>(plugin: PreloadPlugin<ConfigType>) => plugin;
|
||||
|
||||
export const defineMenuPlugin = <ConfigType extends Config>(plugin: MenuPlugin<ConfigType>) => plugin;
|
||||
3
src/plugins/utils/renderer/types.ts
Normal file
3
src/plugins/utils/renderer/types.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import type { Config, RendererPlugin } from '../common';
|
||||
|
||||
export const defineRendererPlugin = <ConfigType extends Config>(plugin: RendererPlugin<ConfigType>) => plugin;
|
||||
Reference in New Issue
Block a user