import { CommonDirectives , DependencyVueRouterDirectives } from './directives/index' ; import { CommonComponents , DependencyVueRouterComponents , DependencyComponentsReferences } from './components/index' ; import { Vue as VueConstructor } from 'vue-property-decorator' ; import each from 'lodash/each' ; import extend from 'lodash/extend' ; import { assert } from './util' ; import { DirectiveOptions } from 'vue/types/options' ; export const installFn = function ( Vue , useRouter ? ) { const registryDirective = function ( value , name ) : void { Vue . directive ( name , value ) ; } ; each ( CommonDirectives , registryDirective ) ; if ( useRouter ) { each ( DependencyVueRouterDirectives , registryDirective ) ; } each ( CommonComponents , function ( value , name ) { Vue . component ( name , value ) ; } ) ; if ( useRouter ) { each ( DependencyVueRouterComponents as { [ s ] : DirectiveOptions ; } , function ( value , name ) { let denpendency ; if ( name in DependencyComponentsReferences ) { denpendency = ( DependencyComponentsReferences as Record < string , any > ) [ name ] ; let dependencyComponent ; for ( let item of denpendency ) { dependencyComponent = Vue . component ( item ) ; if ( dependencyComponent ) { break ; } } assert ( ! ! dependencyComponent , 'please call method Vue.use(VueRouter) before Vue.use(VueAccessControl)' ) ; value = extend ( value , { extends : dependencyComponent , } ) ; } Vue . component ( name , value ) ; } ) ; } } ;