import type { FilePath, ModuleID, ModuleResolver } from '@boost/common'; export type Source = FilePath | ModuleID; export type SourceOptions = boolean | object; export type SourceWithOptions = [Source, SourceOptions]; export type Callback = (value: T) => Promise | void; // Easier for consumers to type // eslint-disable-next-line @typescript-eslint/no-explicit-any export interface Pluggable { /** Unique name of the plugin. Typically the npm package name. */ readonly name: ModuleID; /** Priority in which to order the plugin. */ priority?: number; /** Life cycle called when the plugin is unregistered. */ shutdown?: Callback; /** Life cycle called when the plugin is registered. */ startup?: Callback; } export type Setting = Record; export type Factory = ( options: Partial, ) => Promise | T; export interface RegisterOptions { /** Override the priority of the plugin. */ priority?: number; /** Custom tool instance to pass to life cycles. */ tool?: T; } export interface Registration extends RegisterOptions { /** Unique name of the plugin. */ name: ModuleID; /** Plugin instance or object. */ plugin: T; } export interface RegistryOptions { /** Callback fired after a plugin's `shutdown` life cycle is executed. */ afterShutdown?: Callback; /** Callback fired after a plugin's `startup` life cycle is executed. */ afterStartup?: Callback; /** Callback fired before a plugin's `shutdown` life cycle is executed. */ beforeShutdown?: Callback; /** Callback fired before a plugin's `startup` life cycle is executed. */ beforeStartup?: Callback; /** Custom module resolver. */ resolver?: ModuleResolver; /** Validate the shape of the plugin being registered. */ validate: Callback; }