@alilc/lowcode-editor-core
Version:
Core Api for Ali lowCode engine
59 lines (58 loc) • 3.14 kB
TypeScript
import { StrictEventEmitter } from 'strict-event-emitter-types';
import { EventEmitter } from 'events';
import { EventBus, IEventBus } from './event-bus';
import { IPublicModelEditor, EditorConfig, PluginClassSet, IPublicTypeEditorValueKey, IPublicTypeEditorGetResult, HookConfig, GlobalEvent } from '@alilc/lowcode-types';
import { IPublicTypeAssetsJson } from '@alilc/lowcode-utils';
export declare interface Editor extends StrictEventEmitter<EventEmitter, GlobalEvent.EventConfig> {
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
once(event: string | symbol, listener: (...args: any[]) => void): this;
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
off(event: string | symbol, listener: (...args: any[]) => void): this;
removeAllListeners(event?: string | symbol): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(event: string | symbol): Function[];
rawListeners(event: string | symbol): Function[];
listenerCount(type: string | symbol): number;
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
eventNames(): Array<string | symbol>;
}
export interface IEditor extends IPublicModelEditor {
config?: EditorConfig;
components?: PluginClassSet;
eventBus: IEventBus;
init(config?: EditorConfig, components?: PluginClassSet): Promise<any>;
}
export declare class Editor extends EventEmitter implements IEditor {
readonly viewName: string;
readonly workspaceMode: boolean;
/**
* Ioc Container
*/
private context;
get locale(): any;
config?: EditorConfig;
eventBus: EventBus;
components?: PluginClassSet;
private hooks;
private waits;
constructor(viewName?: string, workspaceMode?: boolean);
get<T = undefined, KeyOrType = any>(keyOrType: KeyOrType): IPublicTypeEditorGetResult<T, KeyOrType> | undefined;
has(keyOrType: IPublicTypeEditorValueKey): boolean;
set(key: IPublicTypeEditorValueKey, data: any): void | Promise<void>;
setAssets(assets: IPublicTypeAssetsJson): Promise<void>;
onceGot<T = undefined, KeyOrType extends IPublicTypeEditorValueKey = any>(keyOrType: KeyOrType): Promise<IPublicTypeEditorGetResult<T, KeyOrType>>;
onGot<T = undefined, KeyOrType extends IPublicTypeEditorValueKey = any>(keyOrType: KeyOrType, fn: (data: IPublicTypeEditorGetResult<T, KeyOrType>) => void): () => void;
onChange<T = undefined, KeyOrType extends IPublicTypeEditorValueKey = any>(keyOrType: KeyOrType, fn: (data: IPublicTypeEditorGetResult<T, KeyOrType>) => void): () => void;
register(data: any, key?: IPublicTypeEditorValueKey): void;
init(config?: EditorConfig, components?: PluginClassSet): Promise<any>;
destroy(): void;
initHooks: (hooks: HookConfig[]) => HookConfig[];
registerHooks: (hooks: HookConfig[]) => void;
unregisterHooks: () => void;
private notifyGot;
private setWait;
private delWait;
}
export declare const commonEvent: EventBus;