make PluginConfig and dependent types public

This commit is contained in:
Ryan Vazquez
2020-10-26 15:02:19 -04:00
parent 0eac8f037d
commit fe741950a0
2 changed files with 34 additions and 38 deletions
+2 -38
View File
@@ -14,54 +14,18 @@
* limitations under the License.
*/
import { ComponentType } from 'react';
import {
PluginConfig,
PluginOutput,
RoutePath,
RouteOptions,
FeatureFlagName,
BackstagePlugin,
} from './types';
import { validateBrowserCompat, validateFlagName } from '../app/FeatureFlags';
import { RouteRef } from '../routing';
import { AnyApiFactory } from '../apis';
export type PluginConfig = {
id: string;
apis?: Iterable<AnyApiFactory>;
register?(hooks: PluginHooks): void;
};
export type PluginHooks = {
router: RouterHooks;
featureFlags: FeatureFlagsHooks;
};
export type RouterHooks = {
addRoute(
target: RouteRef,
Component: ComponentType<any>,
options?: RouteOptions,
): void;
/**
* @deprecated See the `addRoute` method
*/
registerRoute(
path: RoutePath,
Component: ComponentType<any>,
options?: RouteOptions,
): void;
};
export type FeatureFlagsHooks = {
register(name: FeatureFlagName): void;
};
export class PluginImpl {
private storedOutput?: PluginOutput[];
constructor(private readonly config: PluginConfig) {}
constructor(private readonly config: PluginConfig) { }
getId(): string {
return this.config.id;
+32
View File
@@ -73,3 +73,35 @@ export type BackstagePlugin = {
output(): PluginOutput[];
getApis(): Iterable<AnyApiFactory>;
};
export type PluginConfig = {
id: string;
apis?: Iterable<AnyApiFactory>;
register?(hooks: PluginHooks): void;
};
export type PluginHooks = {
router: RouterHooks;
featureFlags: FeatureFlagsHooks;
};
export type RouterHooks = {
addRoute(
target: RouteRef,
Component: ComponentType<any>,
options?: RouteOptions,
): void;
/**
* @deprecated See the `addRoute` method
*/
registerRoute(
path: RoutePath,
Component: ComponentType<any>,
options?: RouteOptions,
): void;
};
export type FeatureFlagsHooks = {
register(name: FeatureFlagName): void;
};