import type {Bud, Modules} from '@roots/bud-framework' import type {ApplyPlugin, Extension} from '@roots/bud-framework/extension' import type Container from '@roots/container' export type LifecycleMethods = | 'boot' | 'buildAfter' | 'buildBefore' | 'compilerDone' | 'configAfter' | 'make' | 'register' /** * Container service for {@link Bud} extensions. * * @remarks * Extensions can be defined as a {@link Module}, which is more generic. * * They can also be defined as a {@link Plugin} which is a {@link Module} * yielding a {@link PluginInstance}. */ export interface Extensions { /** * Add an extension */ add(extension: any): Promise get(key: K): Modules[K] has(key: string): key is `${keyof Modules & string}` import( signifier: K, fatalOnError: boolean, ): Promise instantiate( extension: Extension | (new (...args: any[]) => Modules[K]), options?: Record, ): Promise isAllowed(key: string): boolean /** * Returns array of {@link PluginInstance} instances. */ make(): Promise> make(bud: Bud): Promise> options: Container<{ allowlist: Array denylist: Array discover: boolean }> remove(key: K): this repository: Modules run( extension: Modules[keyof Modules], methodName: LifecycleMethods, ): Promise runAll(methodName: LifecycleMethods): Promise> /** * Run a lifecycle method on all dependencies of a given extension or * extension signifier. */ runDependencies( extension: K | Modules[K], methodName: LifecycleMethods, ): Promise set(value: Extension): this unresolvable: Set }