@@ -68,7 +68,7 @@ export type RegisterOpts<Props> = {
6868 /**
6969 * The component to render
7070 */
71- component : React . Component < Props > ;
71+ component : React . ComponentType < Props > ;
7272
7373 /**
7474 * Additional optional metadata for the component
@@ -118,6 +118,17 @@ export type CreateExtensionPointOptions<ComponentProps> = ExtensionPointSettings
118118 matcher ?: ( context : ExtensionRenderContext , item : Registration < ComponentProps > ) => boolean ;
119119} ;
120120
121+ /**
122+ * A registration entry that a plugin exports to register a component into an extension point.
123+ * The host app processes these at plugin load time.
124+ */
125+ export type ExtensionRegistration < Props = any > = {
126+ /** The ID of the extension point to register into */
127+ extensionPointId : string ;
128+ /** The registration options for the component */
129+ registration : RegisterOpts < Props > ;
130+ } ;
131+
121132/**
122133 * A registry to hold an extension points registered extensions, providing type safe access to the components.
123134 *
@@ -272,7 +283,7 @@ export class ExtensionPointStore<ComponentProps> {
272283 /**
273284 * Provide the components that match the given context.
274285 */
275- provide ( context : ExtensionRenderContext ) : Array < React . Component < ComponentProps > > {
286+ provide ( context : ExtensionRenderContext ) : Array < React . ComponentType < ComponentProps > > {
276287 if ( this . _settings . disabled ) {
277288 return [ ] ;
278289 }
@@ -293,7 +304,7 @@ export class ExtensionPointStore<ComponentProps> {
293304 if ( ids ) {
294305 let components = ids . map ( ( id ) => this . _extensions . get ( id ) )
295306 . filter ( ( v ) : v is Registration < ComponentProps > => ! ! v )
296- . map ( ( v ) => v . component ) ;
307+ . map ( ( v ) => v . component as React . ComponentType < ComponentProps > ) ;
297308
298309 if ( this . _settings . order ) {
299310 components = this . reorderComponents ( components , ids , this . _settings . order ) ;
@@ -308,7 +319,7 @@ export class ExtensionPointStore<ComponentProps> {
308319 // if the order is set, reorder the components
309320 let components = ids . map ( ( id ) => this . _extensions . get ( id ) )
310321 . filter ( ( v ) : v is Registration < ComponentProps > => ! ! v )
311- . map ( ( v ) => v . component ) ;
322+ . map ( ( v ) => v . component as React . ComponentType < ComponentProps > ) ;
312323
313324 // Reorder components if order is set
314325 if ( this . _settings . order ) {
@@ -318,9 +329,9 @@ export class ExtensionPointStore<ComponentProps> {
318329 return components ;
319330 }
320331
321- reorderComponents ( components : Array < React . Component < ComponentProps > > , ids : string [ ] , order : string [ ] ) : Array < React . Component < ComponentProps > > {
332+ reorderComponents ( components : Array < React . ComponentType < ComponentProps > > , ids : string [ ] , order : string [ ] ) : Array < React . ComponentType < ComponentProps > > {
322333 const idToComponentMap = new Map ( ids . map ( ( id , index ) => [ id , components [ index ] ] ) ) ;
323- return order . map ( ( id ) => idToComponentMap . get ( id ) ) . filter ( ( component ) : component is React . Component < ComponentProps > => ! ! component ) ;
334+ return order . map ( ( id ) => idToComponentMap . get ( id ) ) . filter ( ( component ) : component is React . ComponentType < ComponentProps > => ! ! component ) ;
324335 }
325336
326337 /**
0 commit comments