import { PluginInitializer } from './plugin' ; internal export type UnknownPluginInitializer = PluginInitializer < unknown , Record < string , unknown > > ; internal export interface CoreWindow { __kbnBundles__ : { has ( key ) : boolean ; get ( key ) : { plugin : UnknownPluginInitializer ; } | undefined ; } ; } /**
 * Reads the plugin's bundle declared in the global context.
 */ export function read ( name ) { const coreWindow = window as unknown as CoreWindow ; const exportId = `plugin/${ name }/public` ; if ( ! coreWindow . __kbnBundles__ . has ( exportId ) ) { throw new Error ( `Definition of plugin "${ name }" not found and may have failed to load.` ) ; } const pluginExport = coreWindow . __kbnBundles__ . get ( exportId ) ; if ( typeof pluginExport ?. plugin !== 'function' ) { throw new Error ( `Definition of plugin "${ name }" should be a function.` ) ; } else { return pluginExport . plugin ; } }