mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 10:56:15 -08:00
14 lines
563 B
TypeScript
14 lines
563 B
TypeScript
export type PluginFactory<Host, Result = unknown> = (this: Host, art: Host) => Result
|
|
|
|
export type PluginRegistration<Result, Registry>
|
|
= unknown extends Result ? Registry | Promise<Registry>
|
|
: Result extends Promise<unknown> ? Promise<Registry> : Registry
|
|
|
|
/** The same registry is returned immediately or after its Promise factory settles. */
|
|
export interface Plugins<Host> {
|
|
art: Host
|
|
id: number
|
|
add: <Result>(plugin: PluginFactory<Host, Result>) => PluginRegistration<Result, this>
|
|
next: (plugin: PluginFactory<Host>, result: unknown) => this
|
|
}
|