import { CoreSetup , Plugin , AppMountParameters , DEFAULT_APP_CATEGORIES , } from '../../../src/core/public' ; import { ExampleDefinition } from './types' ; export interface DeveloperExamplesSetup { register : ( def : ExampleDefinition ) => void ; } export class DeveloperExamplesPlugin implements Plugin < DeveloperExamplesSetup , void > { private examplesRegistry : ExampleDefinition [ ] = [ ] ; public setup ( core ) { const examples = this . examplesRegistry ; core . application . register ( { id : 'developerExamples' , title : 'Developer examples' , order : - 2000 , category : DEFAULT_APP_CATEGORIES . opensearchDashboards , async mount ( params ) { const { renderApp } = await import ( './app' ) ; const [ coreStart ] = await core . getStartServices ( ) ; return renderApp ( { examples , navigateToApp : ( appId ) => coreStart . application . navigateToApp ( appId ) , getUrlForApp : ( appId ) => coreStart . application . getUrlForApp ( appId ) , } , params . element ) ; } , } ) ; const api = { register : ( def ) => { this . examplesRegistry . push ( def ) ; } , } ; return api ; } public start ( ) { } public stop ( ) { } }