diff --git a/packages/core/src/api/plugin/Plugin.tsx b/packages/core/src/api/plugin/Plugin.tsx index efaabd0ff1..aa1ff417b7 100644 --- a/packages/core/src/api/plugin/Plugin.tsx +++ b/packages/core/src/api/plugin/Plugin.tsx @@ -15,7 +15,12 @@ */ import { ComponentType } from 'react'; -import { PluginOutput, RoutePath, RouteOptions } from './types'; +import { + PluginOutput, + RoutePath, + RouteOptions, + FeatureFlagName, +} from './types'; import { Widget } from '../widgetView/types'; export type PluginConfig = { @@ -26,6 +31,7 @@ export type PluginConfig = { export type PluginHooks = { router: RouterHooks; widgets: WidgetHooks; + featureFlags: FeatureFlagsHooks; }; export type RouterHooks = { @@ -46,6 +52,10 @@ export type WidgetHooks = { add(widget: Widget): void; }; +export type FeatureFlagsHooks = { + registerFeatureFlag(name: FeatureFlagName): void; +}; + export const registerSymbol = Symbol('plugin-register'); export const outputSymbol = Symbol('plugin-output'); @@ -78,6 +88,11 @@ export default class Plugin { outputs.push({ type: 'widget', widget }); }, }, + featureFlags: { + registerFeatureFlag(name) { + outputs.push({ type: 'feature-flag', name }); + }, + }, }); this.storedOutput = outputs; diff --git a/packages/core/src/api/plugin/types.ts b/packages/core/src/api/plugin/types.ts index 47c121fae8..b006e06d9a 100644 --- a/packages/core/src/api/plugin/types.ts +++ b/packages/core/src/api/plugin/types.ts @@ -43,4 +43,15 @@ export type WidgetOutput = { widget: Widget; }; -export type PluginOutput = RouteOutput | RedirectRouteOutput | WidgetOutput; +export type FeatureFlagName = string; + +export type FeatureFlagOutput = { + type: 'feature-flag'; + name: FeatureFlagName; +}; + +export type PluginOutput = + | RouteOutput + | RedirectRouteOutput + | WidgetOutput + | FeatureFlagOutput;