mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 11:51:47 +00:00
feat: createBackend, createPreload, createRenderer
Introduced the mentioned helper methods in order to help split big plugins into manageable chunks.
This commit is contained in:
@ -9,6 +9,8 @@ import type {
|
||||
PluginConfig,
|
||||
PluginLifecycleExtra,
|
||||
PluginLifecycleSimple,
|
||||
PluginLifecycle,
|
||||
RendererPluginLifecycle,
|
||||
} from '@/types/plugins';
|
||||
|
||||
export const createPlugin = <
|
||||
@ -29,6 +31,37 @@ export const createPlugin = <
|
||||
},
|
||||
) => def;
|
||||
|
||||
export const createBackend = <
|
||||
BackendProperties,
|
||||
Config extends PluginConfig = PluginConfig,
|
||||
>(
|
||||
back: {
|
||||
[Key in keyof BackendProperties]: BackendProperties[Key];
|
||||
} & PluginLifecycle<Config, BackendContext<Config>, BackendProperties>,
|
||||
) => back;
|
||||
|
||||
export const createPreload = <
|
||||
PreloadProperties,
|
||||
Config extends PluginConfig = PluginConfig,
|
||||
>(
|
||||
preload: {
|
||||
[Key in keyof PreloadProperties]: PreloadProperties[Key];
|
||||
} & PluginLifecycle<Config, PreloadContext<Config>, PreloadProperties>,
|
||||
) => preload;
|
||||
|
||||
export const createRenderer = <
|
||||
RendererProperties,
|
||||
Config extends PluginConfig = PluginConfig,
|
||||
>(
|
||||
renderer: {
|
||||
[Key in keyof RendererProperties]: RendererProperties[Key];
|
||||
} & RendererPluginLifecycle<
|
||||
Config,
|
||||
RendererContext<Config>,
|
||||
RendererProperties
|
||||
>,
|
||||
) => renderer;
|
||||
|
||||
type Options<Config extends PluginConfig> =
|
||||
| { ctx: 'backend'; context: BackendContext<Config> }
|
||||
| { ctx: 'preload'; context: PreloadContext<Config> }
|
||||
|
||||
Reference in New Issue
Block a user