import { UnregisterCallback } from 'history' ; import { InternalApplicationSetup , InternalApplicationStart , AppNavLinkStatus , AppMountParameters , } from '../application' ; import type { HttpSetup , HttpStart } from '../http' ; import type { CoreContext } from '../core_system' ; import type { NotificationsSetup , NotificationsStart } from '../notifications' ; import type { IUiSettingsClient } from '../ui_settings' ; import type { InjectedMetadataSetup } from '../injected_metadata' ; import { renderApp as renderErrorApp , setupUrlOverflowDetection } from './errors' ; import { renderApp as renderStatusApp } from './status' ; interface SetupDeps { application : InternalApplicationSetup ; http : HttpSetup ; injectedMetadata : InjectedMetadataSetup ; notifications : NotificationsSetup ; } interface StartDeps { application : InternalApplicationStart ; http : HttpStart ; notifications : NotificationsStart ; uiSettings : IUiSettingsClient ; } export class CoreApp { private stopHistoryListening ? : UnregisterCallback ; constructor ( private readonly coreContext ) { } public setup ( { http , application , injectedMetadata , notifications } ) { application . register ( this . coreContext . coreId , { id : 'error' , title : 'App Error' , navLinkStatus : AppNavLinkStatus . hidden , mount ( params ) { return renderErrorApp ( params , { basePath : http . basePath } ) ; } , } ) ; if ( injectedMetadata . getAnonymousStatusPage ( ) ) { http . anonymousPaths . register ( '/status' ) ; } application . register ( this . coreContext . coreId , { id : 'status' , title : 'Server Status' , appRoute : '/status' , chromeless : true , navLinkStatus : AppNavLinkStatus . hidden , mount ( params ) { return renderStatusApp ( params , { http , notifications } ) ; } , } ) ; } public start ( { application , http , notifications , uiSettings } ) { if ( ! application . history ) { return ; } this . stopHistoryListening = setupUrlOverflowDetection ( { basePath : http . basePath , history : application . history , toasts : notifications . toasts , uiSettings , } ) ; } public stop ( ) { if ( this . stopHistoryListening ) { this . stopHistoryListening ( ) ; this . stopHistoryListening = undefined ; } } }