mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-06-02 13:41:01 +00:00
fix: 增加 editor 的 on/off 等方法提示, 移除 events 以及相应 types 依赖
This commit is contained in:
parent
8fd797d487
commit
20b697b99f
@ -20,7 +20,6 @@
|
|||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"enzyme": "^3.11.0",
|
"enzyme": "^3.11.0",
|
||||||
"enzyme-adapter-react-16": "^1.15.5",
|
"enzyme-adapter-react-16": "^1.15.5",
|
||||||
"event": "^1.0.0",
|
|
||||||
"react": "^16",
|
"react": "^16",
|
||||||
"react-dom": "^16.7.0",
|
"react-dom": "^16.7.0",
|
||||||
"zen-logger": "^1.1.0"
|
"zen-logger": "^1.1.0"
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export function set(obj: any, path: any, val: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function delay(ms) {
|
export function delay(ms) {
|
||||||
return new Promise(resove => setTimeout(resove, ms));
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function delayObxTick() {
|
export function delayObxTick() {
|
||||||
|
|||||||
@ -16,6 +16,25 @@ import * as utils from './utils';
|
|||||||
EventEmitter.defaultMaxListeners = 100;
|
EventEmitter.defaultMaxListeners = 100;
|
||||||
const NOT_FOUND = Symbol.for('not_found');
|
const NOT_FOUND = Symbol.for('not_found');
|
||||||
|
|
||||||
|
export declare interface Editor {
|
||||||
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
on(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[];
|
||||||
|
emit(event: string | symbol, ...args: any[]): boolean;
|
||||||
|
listenerCount(type: string | symbol): number;
|
||||||
|
// Added in Node 6...
|
||||||
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||||
|
eventNames(): Array<string | symbol>;
|
||||||
|
}
|
||||||
|
|
||||||
export class Editor extends EventEmitter implements IEditor {
|
export class Editor extends EventEmitter implements IEditor {
|
||||||
/**
|
/**
|
||||||
* Ioc Container
|
* Ioc Container
|
||||||
@ -32,7 +51,10 @@ export class Editor extends EventEmitter implements IEditor {
|
|||||||
|
|
||||||
private hooks: HookConfig[] = [];
|
private hooks: HookConfig[] = [];
|
||||||
|
|
||||||
get<T = undefined, KeyOrType = any>(keyOrType: KeyOrType, opt?: GetOptions): GetReturnType<T, KeyOrType> | undefined {
|
get<T = undefined, KeyOrType = any>(
|
||||||
|
keyOrType: KeyOrType,
|
||||||
|
opt?: GetOptions,
|
||||||
|
): GetReturnType<T, KeyOrType> | undefined {
|
||||||
const x = this.context.get<T, KeyOrType>(keyOrType, opt);
|
const x = this.context.get<T, KeyOrType>(keyOrType, opt);
|
||||||
if (x === NOT_FOUND) {
|
if (x === NOT_FOUND) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@ -53,7 +75,9 @@ export class Editor extends EventEmitter implements IEditor {
|
|||||||
this.notifyGot(key);
|
this.notifyGot(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
onceGot<T = undefined, KeyOrType extends KeyType = any>(keyOrType: KeyOrType): Promise<GetReturnType<T, KeyOrType>> {
|
onceGot<T = undefined, KeyOrType extends KeyType = any>(
|
||||||
|
keyOrType: KeyOrType,
|
||||||
|
): Promise<GetReturnType<T, KeyOrType>> {
|
||||||
const x = this.context.get<T, KeyOrType>(keyOrType);
|
const x = this.context.get<T, KeyOrType>(keyOrType);
|
||||||
if (x !== NOT_FOUND) {
|
if (x !== NOT_FOUND) {
|
||||||
return Promise.resolve(x);
|
return Promise.resolve(x);
|
||||||
@ -153,11 +177,11 @@ export class Editor extends EventEmitter implements IEditor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private waits = new Map<
|
private waits = new Map<
|
||||||
KeyType,
|
KeyType,
|
||||||
Array<{
|
Array<{
|
||||||
once?: boolean;
|
once?: boolean;
|
||||||
resolve:(data: any) => void;
|
resolve: (data: any) => void;
|
||||||
}>
|
}>
|
||||||
>();
|
>();
|
||||||
|
|
||||||
private notifyGot(key: KeyType) {
|
private notifyGot(key: KeyType) {
|
||||||
|
|||||||
@ -29,7 +29,6 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ali/lowcode-editor-setters": "^1.0.22",
|
"@ali/lowcode-editor-setters": "^1.0.22",
|
||||||
"@alib/build-scripts": "^0.1.18",
|
"@alib/build-scripts": "^0.1.18",
|
||||||
"@types/events": "^3.0.0",
|
|
||||||
"@types/react": "^16.8.3",
|
"@types/react": "^16.8.3",
|
||||||
"@types/react-dom": "^16.8.2",
|
"@types/react-dom": "^16.8.2",
|
||||||
"build-plugin-fusion": "^0.1.0",
|
"build-plugin-fusion": "^0.1.0",
|
||||||
|
|||||||
@ -25,7 +25,6 @@
|
|||||||
"@ali/ve-less-variables": "^2.0.0",
|
"@ali/ve-less-variables": "^2.0.0",
|
||||||
"@alifd/next": "^1.20.12",
|
"@alifd/next": "^1.20.12",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"events": "^3.2.0",
|
|
||||||
"react": "^16.8.1",
|
"react": "^16.8.1",
|
||||||
"react-dom": "^16.8.1"
|
"react-dom": "^16.8.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -46,7 +46,6 @@
|
|||||||
"@ali/lowcode-test-mate": "^1.0.1",
|
"@ali/lowcode-test-mate": "^1.0.1",
|
||||||
"@alib/build-scripts": "^0.1.18",
|
"@alib/build-scripts": "^0.1.18",
|
||||||
"@types/domready": "^1.0.0",
|
"@types/domready": "^1.0.0",
|
||||||
"@types/events": "^3.0.0",
|
|
||||||
"@types/react": "^16.8.3",
|
"@types/react": "^16.8.3",
|
||||||
"@types/react-dom": "^16.8.2",
|
"@types/react-dom": "^16.8.2",
|
||||||
"build-plugin-fusion": "0.1.17-beta.0",
|
"build-plugin-fusion": "0.1.17-beta.0",
|
||||||
|
|||||||
@ -39,7 +39,6 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@alib/build-scripts": "^0.1.18",
|
"@alib/build-scripts": "^0.1.18",
|
||||||
"@types/events": "^3.0.0",
|
|
||||||
"@types/react": "^16.8.3",
|
"@types/react": "^16.8.3",
|
||||||
"@types/react-dom": "^16.8.2",
|
"@types/react-dom": "^16.8.2",
|
||||||
"@types/streamsaver": "^2.0.0",
|
"@types/streamsaver": "^2.0.0",
|
||||||
|
|||||||
@ -19,7 +19,6 @@
|
|||||||
"@ali/lowcode-datasource-engine": "^1.0.22",
|
"@ali/lowcode-datasource-engine": "^1.0.22",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"events": "^3.0.0",
|
|
||||||
"fetch-jsonp": "^1.1.3",
|
"fetch-jsonp": "^1.1.3",
|
||||||
"intl-messageformat": "^9.3.1",
|
"intl-messageformat": "^9.3.1",
|
||||||
"jsonuri": "^2.1.2",
|
"jsonuri": "^2.1.2",
|
||||||
|
|||||||
@ -42,7 +42,6 @@
|
|||||||
"@ali/lowcode-test-mate": "^1.0.1",
|
"@ali/lowcode-test-mate": "^1.0.1",
|
||||||
"@alib/build-scripts": "^0.1.18",
|
"@alib/build-scripts": "^0.1.18",
|
||||||
"@types/domready": "^1.0.0",
|
"@types/domready": "^1.0.0",
|
||||||
"@types/events": "^3.0.0",
|
|
||||||
"@types/react": "^16.8.3",
|
"@types/react": "^16.8.3",
|
||||||
"@types/react-dom": "^16.8.2",
|
"@types/react-dom": "^16.8.2",
|
||||||
"build-plugin-fusion": "0.1.17-beta.0",
|
"build-plugin-fusion": "0.1.17-beta.0",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user