import type { Bud } from '@roots/bud-framework'; import type { MultiStats, Stats } from '@roots/bud-framework/config'; import { BudError } from '@roots/bud-support/errors'; import logger from '@roots/bud-support/logger'; import Container from '@roots/container'; interface Contract { /** * Bud instance */ app: Bud; /** * Boot callback */ boot?(app: Bud): Promise; /** * Bootstrap callback */ bootstrap?(app: Bud): Promise; /** * After build callback */ buildAfter?(app: Bud): Promise; /** * Before build callback */ buildBefore?(app: Bud): Promise; /** * Handle errors */ catch(error: BudError | string): never; /** * Before compiler callback */ compilerBefore?(app: Bud): Promise; /** * Compiler done callback */ compilerDone?(bud: Bud, stats: MultiStats & Stats): Promise; /** * After config callback */ configAfter?(app: Bud): Promise; /** * Before config callback */ configBefore?(app: Bud): Promise; /** * Return the bud instance */ done(): Bud; /** * Scoped logger */ logger: typeof logger; /** * Register callback */ register?(app: Bud): Promise; /** * Server after callback */ serverAfter?(app: Bud): Promise; /** * Server before callback */ serverBefore?(app: Bud): Promise; } /** * Service * * @remarks * The Service interface provides access to the Bud parent container. * * A Service interfaces with the Framework through a series of callbacks at different points in the build. */ declare abstract class Base implements Contract { _app: () => Bud; /** * Class constructor */ constructor(_app: () => Bud); /** * {@link Contract.app} * @readonly */ get app(): Bud; /** * {@link Contract.boot} */ boot?(app: Bud): Promise; /** * {@link Contract.bootstrap} */ bootstrap?(app: Bud): Promise; /** * {@link Contract.buildAfter} */ buildAfter?(app: Bud): Promise; /** * {@link Contract.buildBefore} */ buildBefore?(app: Bud): Promise; /** * {@link Contract.catch} */ catch(error: BudError | string): never; /** * {@link Contract.compilerBefore} */ compilerBefore?(app: Bud): Promise; /** * {@link Contract.compilerDone} */ compilerDone?(bud: Bud, stats: MultiStats & Stats): Promise; /** * {@link Contract.configAfter} */ configAfter?(app: Bud): Promise; /** * {@link Contract.done} */ done(): Bud; /** * {@link Contract.logger} */ get logger(): typeof logger; /** * {@link Contract.register} */ register?(bud: Bud): Promise; /** * {@link Contract.serverAfter} */ serverAfter?(app: Bud): Promise; /** * {@link Contract.serverBefore} */ serverBefore?(app: Bud): Promise; } /** * Service * * @remarks * The Service interface provides access to the {@link Bud} container. * * A Service interfaces with the Framework through a series of callbacks at different points in the build. */ declare abstract class BaseContainer extends Container implements Contract { _app: () => Bud; /** * Class constructor */ constructor(_app: () => Bud); /** * {@link Contract.app} * @readonly */ get app(): Bud; /** * {@link Contract.boot} */ boot?(app: Bud): Promise; /** * {@link Contract.bootstrap} */ bootstrap?(app: Bud): Promise; /** * {@link Contract.buildAfter} */ buildAfter?(app: Bud): Promise; /** * {@link Contract.buildBefore} */ buildBefore?(app: Bud): Promise; /** * {@link Contract.catch} */ catch(error: BudError | string): never; /** * {@link Contract.compilerBefore} */ compilerBefore?(app: Bud): Promise; /** * {@link Contract.compilerDone} */ compilerDone?(bud: Bud, stats: MultiStats & Stats): Promise; /** * {@link Contract.configAfter} */ configAfter?(app: Bud): Promise; /** * {@link Contract.done} */ done(): Bud; /** * {@link Contract.logger} */ get logger(): typeof logger; /** * {@link Contract.register} */ register?(bud: Bud): Promise; /** * {@link Contract.serverAfter} */ serverAfter?(app: Bud): Promise; /** * {@link Contract.serverBefore} */ serverBefore?(app: Bud): Promise; } export { Base, Base as Service, Base as default, BaseContainer, BaseContainer as ServiceContainer, type Contract, };