import { INvModule } from '../types' ; import { injected , rootInjector , providersFormater , TProviders } from '@indiv/di' ; export type TNvModuleOptions = { imports ? : Function [ ] ; declarations ? : Function [ ] ; providers ? : TProviders ; exports ? : Function [ ] ; bootstrap ? : Function ; } ; NvModule NvModule export param { TNvModuleOptions } options returns { ( _constructor : Function ) => void } export function NvModule ( options ) { return function ( _constructor ) : void { injected ( _constructor ) ; rootInjector . setProvider ( _constructor , _constructor ) ; ( _constructor as any ) . nvType = 'nvModule' ; const vm = _constructor . prototype ; vm . $declarationMap = new Map ( ) ; if ( ! vm . $providers ) vm . $providers = [ ] ; if ( options . imports ) vm . $imports = options . imports ; if ( options . declarations ) vm . $declarations = options . declarations ; if ( options . providers ) vm . $providers = providersFormater ( [ ... vm . $providers , ... options . providers ] ) ; if ( options . exports ) { vm . $exports = options . exports ; vm . $exportsList = [ ] ; } if ( options . bootstrap ) vm . $bootstrap = options . bootstrap ; } ; }