import { Engine } from '../index';
import { AssetPackage, CPage } from '@chamn/model';
import { Emitter } from 'mitt';
import { Workbench } from '../component/Workbench';
import { CustomI18n } from '../i18n';
export type PluginObj<C, E = any> = {
    name: string;
    init: (ctx: CPluginCtx<C>) => Promise<void>;
    destroy: (ctx: CPluginCtx<C>) => Promise<void>;
    /** 用于暴露给外部重载插件 */
    reload?: (ctx: CPluginCtx<C>) => Promise<void>;
    /** 插件暴露给外部可以调用的方法 */
    export: (ctx: CPluginCtx<C>) => E;
    meta: {
        engine: {
            version: string;
        };
    };
};
export type CPlugin<C = Record<string, any>, E = any> = PluginObj<C, E> | ((ctx: CPluginCtx<C>) => PluginObj<C, E>);
type PluginManagerOptions = {
    getWorkbench: () => Workbench;
    emitter: Emitter<any>;
    pageModel: CPage;
    i18n: CustomI18n;
    assets: AssetPackage[];
    engine: Engine;
};
export type CPluginCtx<C = any> = {
    globalEmitter: Emitter<any>;
    /** 当前插件外部传入的配置 **/
    config: C;
    pluginManager: PluginManager;
    pluginReadyOk: () => void;
} & PluginManagerOptions;
export type PluginInstance<C = any, E = any> = {
    ctx: CPluginCtx<C>;
    export: E;
    source: PluginObj<C, E>;
    ready: boolean;
};
export type CustomPluginHook<P extends PluginInstance<any, any> = any> = (pluginInstance: P) => P;
export declare class PluginManager {
    plugins: Map<string, PluginInstance>;
    emitter: Emitter<any>;
    getWorkbench: () => Workbench;
    pageModel: CPage;
    i18n: CustomI18n;
    assets: AssetPackage[];
    engine: Engine;
    customPluginHooks: Record<string, CustomPluginHook[]>;
    constructor({ getWorkbench, emitter, pageModel, i18n, assets, engine }: PluginManagerOptions);
    /** 自定义插件, 可以修改插件的配置 */
    customPlugin: <P extends PluginInstance<any, any>>(pluginName: string, customPluginHook: CustomPluginHook<P>) => void;
    createPluginCtx: () => CPluginCtx<any>;
    add(plugin: CPlugin): Promise<void>;
    get<P extends PluginInstance<any, any>>(pluginName: string): Promise<P | undefined>;
    remove(name: string): Promise<void>;
    onPluginReadyOk(pluginName: string, cb?: (pluginHandle: PluginInstance) => void): Promise<PluginInstance<any, any>> | undefined;
}
export {};
