1+ import { type DashboardPlugin } from '@deephaven/plugin' ;
12import React , { createContext , useEffect , useState } from 'react' ;
23import { PluginModuleMap , loadModulePlugins } from '../plugins' ;
34
@@ -9,6 +10,9 @@ export type PluginsBootstrapProps = {
910 */
1011 pluginsUrl : string ;
1112
13+ /** The core plugins to load. */
14+ getCorePlugins ?: ( ) => Promise < DashboardPlugin [ ] > ;
15+
1216 /**
1317 * The children to render wrapped with the PluginsContext.
1418 * Note that it renders the children even if the plugins aren't loaded yet.
@@ -21,24 +25,29 @@ export type PluginsBootstrapProps = {
2125 */
2226export function PluginsBootstrap ( {
2327 pluginsUrl,
28+ getCorePlugins,
2429 children,
2530} : PluginsBootstrapProps ) : JSX . Element {
2631 const [ plugins , setPlugins ] = useState < PluginModuleMap | null > ( null ) ;
2732 useEffect (
2833 function initPlugins ( ) {
2934 let isCanceled = false ;
3035 async function loadPlugins ( ) : Promise < void > {
36+ const corePlugins = ( await getCorePlugins ?.( ) ) ?? [ ] ;
3137 const pluginModules = await loadModulePlugins ( pluginsUrl ) ;
3238 if ( ! isCanceled ) {
33- setPlugins ( pluginModules ) ;
39+ const corePluginPairs = corePlugins . map (
40+ plugin => [ plugin . name , plugin ] as const
41+ ) ;
42+ setPlugins ( new Map ( [ ...corePluginPairs , ...pluginModules ] ) ) ;
3443 }
3544 }
3645 loadPlugins ( ) ;
3746 return ( ) => {
3847 isCanceled = true ;
3948 } ;
4049 } ,
41- [ pluginsUrl ]
50+ [ pluginsUrl , getCorePlugins ]
4251 ) ;
4352
4453 return (
0 commit comments