import type { CoreSetup , CoreStart , Plugin } from 'src/core/public' ; import type { AdvancedSettingsSetup } from 'src/plugins/advanced_settings/public' ; import type { HomePublicPluginSetup } from 'src/plugins/home/public' ; import type { ManagementSetup , ManagementStart } from 'src/plugins/management/public' ; import type { FeaturesPluginStart } from '../../features/public' ; import { AdvancedSettingsService } from './advanced_settings' ; import { createSpacesFeatureCatalogueEntry } from './create_feature_catalogue_entry' ; import { ManagementService } from './management' ; import { initSpacesNavControl } from './nav_control' ; import { spaceSelectorApp } from './space_selector' ; import { SpacesManager } from './spaces_manager' ; import type { SpacesApi } from './types' ; import { getUiApi } from './ui_api' ; export interface PluginsSetup { advancedSettings ? : AdvancedSettingsSetup ; home ? : HomePublicPluginSetup ; management ? : ManagementSetup ; } export interface PluginsStart { features : FeaturesPluginStart ; management ? : ManagementStart ; } /**
 * Setup contract for the Spaces plugin.
 */ export type SpacesPluginSetup = ReturnType < SpacesPlugin [ 'setup' ] > ; /**
 * Start contract for the Spaces plugin.
 */ export type SpacesPluginStart = ReturnType < SpacesPlugin [ 'start' ] > ; export class SpacesPlugin implements Plugin < SpacesPluginSetup , SpacesPluginStart > { private spacesManager ! : SpacesManager ; private spacesApi ! : SpacesApi ; private managementService ? : ManagementService ; public setup ( core , plugins ) { this . spacesManager = new SpacesManager ( core . http ) ; this . spacesApi = { ui : getUiApi ( { spacesManager : this . spacesManager , getStartServices : core . getStartServices , } ) , getActiveSpace$ : ( ) => this . spacesManager . onActiveSpaceChange$ , getActiveSpace : ( ) => this . spacesManager . getActiveSpace ( ) , } ; if ( plugins . home ) { plugins . home . featureCatalogue . register ( createSpacesFeatureCatalogueEntry ( ) ) ; } if ( plugins . management ) { this . managementService = new ManagementService ( ) ; this . managementService . setup ( { management : plugins . management , getStartServices : core . getStartServices , spacesManager : this . spacesManager , } ) ; } if ( plugins . advancedSettings ) { const advancedSettingsService = new AdvancedSettingsService ( ) ; advancedSettingsService . setup ( { getActiveSpace : ( ) => this . spacesManager . getActiveSpace ( ) , componentRegistry : plugins . advancedSettings . component , } ) ; } spaceSelectorApp . create ( { getStartServices : core . getStartServices , application : core . application , spacesManager : this . spacesManager , } ) ; return { } ; } public start ( core ) { initSpacesNavControl ( this . spacesManager , core ) ; return this . spacesApi ; } public stop ( ) { if ( this . managementService ) { this . managementService . stop ( ) ; this . managementService = undefined ; } } }