import {Event} from '../event/Event' import {Awaitable, JSONState, UniversalPath} from '../util' import {ExtolloAwareNodeModule} from './types' /** * An event indicating that an NPM package has been discovered * by the framework. * * Application services can listen for this event to register * various discovery logic (e.g. automatically boot units */ export class PackageDiscovered extends Event { constructor( public packageConfig: ExtolloAwareNodeModule, public packageJson: UniversalPath, ) { super() } dehydrate(): Awaitable { return { packageConfig: this.packageConfig as JSONState, packageJson: this.packageJson.toString(), } } rehydrate(state: JSONState): Awaitable { if ( typeof state === 'object' ) { this.packageConfig = (state.packageConfig as ExtolloAwareNodeModule) this.packageJson = new UniversalPath(String(state.packageJson)) } } }