import { join } from 'path' ; import { PackageInfo } from '@kbn/config' ; import { fromRoot } from '@kbn/utils' ; import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm' ; import UiSharedDepsSrc from '@kbn/ui-shared-deps-src' ; import { IRouter } from '../../http' ; import { UiPlugins } from '../../plugins' ; import { FileHashCache } from './file_hash_cache' ; import { registerRouteForBundle } from './bundles_route' ; param { Object } options property property property return export function registerBundleRoutes ( { router , serverBasePath , uiPlugins , packageInfo , } ) { const { dist : isDist , buildNum } = packageInfo ; const fileHashCache = new FileHashCache ( ) ; registerRouteForBundle ( router , { publicPath : `${ serverBasePath }/${ buildNum }/bundles/kbn-ui-shared-deps-npm/` , routePath : `/${ buildNum }/bundles/kbn-ui-shared-deps-npm/` , bundlesPath : UiSharedDepsNpm . distDir , fileHashCache , isDist , } ) ; registerRouteForBundle ( router , { publicPath : `${ serverBasePath }/${ buildNum }/bundles/kbn-ui-shared-deps-src/` , routePath : `/${ buildNum }/bundles/kbn-ui-shared-deps-src/` , bundlesPath : UiSharedDepsSrc . distDir , fileHashCache , isDist , } ) ; registerRouteForBundle ( router , { publicPath : `${ serverBasePath }/${ buildNum }/bundles/core/` , routePath : `/${ buildNum }/bundles/core/` , bundlesPath : fromRoot ( join ( 'src' , 'core' , 'target' , 'public' ) ) , fileHashCache , isDist , } ) ; [ ... uiPlugins . internal . entries ( ) ] . forEach ( ( [ id , { publicTargetDir , version } ] ) => { registerRouteForBundle ( router , { publicPath : `${ serverBasePath }/${ buildNum }/bundles/plugin/${ id }/${ version }/` , routePath : `/${ buildNum }/bundles/plugin/${ id }/${ version }/` , bundlesPath : publicTargetDir , fileHashCache , isDist , } ) ; } ) ; }