UNPKG

1.92 kBTypeScriptView Raw
1import { Config } from './commands/args';
2import { BabelRC } from './utils/babel-config';
3export declare type SetConfig = (config: Config) => Config;
4export declare type ModifyBundlerConfig<C = any> = (config: C, dev: boolean, args: Config) => C;
5export declare type ModifyBabelRC = (babelrc: BabelRC, args: Config) => BabelRC;
6export declare type onCreateApp = <A>(app: A) => void;
7export declare type OnServerListening = <S>(server: S) => void;
8export declare type OnPreBuild = (args: Config) => void;
9export declare type OnPostBuild = (args: Config) => void;
10export declare type OnPreRender = () => void;
11export declare type OnPostRender = () => void;
12export interface PluginFactory {
13 setConfig?: SetConfig;
14 modifyBundlerConfig?: ModifyBundlerConfig;
15 modifyBabelRc?: ModifyBabelRC;
16 onCreateApp?: onCreateApp;
17 onServerListening?: OnServerListening;
18 onPreBuild?: OnPreBuild;
19 onPostBuild?: OnPostBuild;
20 onPreRender?: OnPreRender;
21 onPostRender?: OnPostRender;
22}
23export declare class Plugin<C = any> implements PluginFactory {
24 static runPluginsMethod(plugins: Plugin[] | undefined): (method: keyof Plugin, ...args: any[]) => void;
25 static propsOfPlugins(plugins: Plugin[]): (prop: keyof Plugin) => any[];
26 static reduceFromPlugins<C>(plugins: Plugin[] | undefined): (method: keyof Plugin, initial: C, ...args: any[]) => C;
27 readonly setConfig?: SetConfig;
28 readonly modifyBundlerConfig?: ModifyBundlerConfig<C>;
29 readonly modifyBabelRc?: ModifyBabelRC;
30 readonly onCreateApp?: onCreateApp;
31 readonly onServerListening?: OnServerListening;
32 readonly onPreBuild?: OnPreBuild;
33 readonly onPostBuild?: OnPostBuild;
34 readonly onPreRender?: OnPreRender;
35 readonly onPostRender?: OnPostRender;
36 constructor(p: PluginFactory);
37}
38export declare function createPlugin<C = any>(factory: PluginFactory): Plugin<C>;