Browse Source

KERNEL-827 reactor: 申明方式改变

es6
iapyang 5 years ago
parent
commit
235832fe3b
  1. 42
      typescript/core/ob.ts
  2. 166
      typescript/core/widget.ts
  3. 11
      typescript/index.ts

42
typescript/core/ob.ts

@ -1,39 +1,45 @@
export declare class _OB {
protected props: Props | (<T>(config: T) => Props & T);
export interface OBConstructor {
new(config: any): _OB;
(config: any): _OB;
readonly prototype: _OB;
}
export interface _OB {
props: Props | (<T>(config: T) => Props & T);
protected options: Props;
options: Props;
private events?: {
events?: {
[eventName: string]: Function[];
};
public init: Function | null;
init: Function | null;
public destroyed: Function | null;
destroyed: Function | null;
protected _defaultConfig: (..._args: any[]) => { [key: string]: any } | {};
_defaultConfig: (..._args: any[]) => { [key: string]: any } | {};
protected _init: () => void;
_init: () => void;
private _initListeners: () => void;
_initListeners: () => void;
private _getEvents: () => { [eventName: string]: Function[] };
_getEvents: () => { [eventName: string]: Function[] };
public on: (eventName: string, fn: Function) => void;
on: (eventName: string, fn: Function) => void;
public once: (eventName: string, fn: Function) => void;
once: (eventName: string, fn: Function) => void;
public un: (eName: string, fn: Function) => void;
un: (eName: string, fn: Function) => void;
protected _initRef: () => void;
_initRef: () => void;
protected _purgeRef: () => void;
_purgeRef: () => void;
public purgeListeners: () => void;
purgeListeners: () => void;
public fireEvent: (eName: string, ...args: any[]) => boolean;
fireEvent: (eName: string, ...args: any[]) => boolean;
public destroy: () => void;
destroy: () => void;
}
interface Props {

166
typescript/core/widget.ts

@ -1,159 +1,169 @@
import { _OB } from "./ob";
export interface WidgetConstructor {
new(config: any): _Widget;
(config: any): _Widget;
readonly prototype: _Widget;
/**
*
* @param engine
*/
registerRenderEngine: (engine: RenderEngine) => void;
}
export declare class _Widget extends _OB {
export interface _Widget extends _OB {
/**
* loading的锁
*/
protected __asking: boolean;
__asking: boolean;
/**
*
*/
protected __async: boolean;
__async: boolean;
/**
* widget类标识符
*/
public widgetName: string | null;
widgetName: string | null;
/**
*
*/
private _isRoot: boolean;
_isRoot: boolean;
/**
*
*/
private _parent: _Widget | null;
_parent: _Widget | null;
// TODO: 完成jquery文件夹后把这块改了
/**
* dom的类jQuery对象
*/
public element: any;
element: any;
/**
*
*/
public _children: {
_children: {
[key: string]: _Widget;
};
/**
*
*/
private _isMounted: boolean;
_isMounted: boolean;
/**
* enable
*/
private _manualSetEnable: boolean;
_manualSetEnable: boolean;
/**
* valid
*/
private _manualSetValid: boolean;
_manualSetValid: boolean;
/**
*
*/
public _renderEngine: RenderEngine;
_renderEngine: RenderEngine;
private _store: () => any;
_store: () => any;
private model: any;
model: any;
// 生命周期函数
/**
*
*/
public beforeInit: Function | null;
beforeInit: Function | null;
/**
*
*/
public beforeCreate: Function | null;
beforeCreate: Function | null;
/**
*
*/
public created: Function | null;
created: Function | null;
/**
*
*/
public render: Function | null;
render: Function | null;
/**
*
*/
public beforeMount: Function | null;
beforeMount: Function | null;
/**
*
*/
public mounted: Function | null;
mounted: Function | null;
/**
*
*/
public shouldUpdate: Function | null;
shouldUpdate: Function | null;
/**
*
*/
public update: Function;
update: Function;
/**
*
*/
public beforeDestroy: Function | null;
beforeDestroy: Function | null;
/**
*
*/
public destroyed: Function | null;
destroyed: Function | null;
/**
* render函数
*/
private _initRender: () => void;
_initRender: () => void;
/**
* render函数
*/
private _render: () => void;
_render: () => void;
/**
*
*/
private _initRoot: () => void;
_initRoot: () => void;
/**
*
*/
private _initElementWidth: () => void;
_initElementWidth: () => void;
/**
*
*/
private _initElementHeight: () => void;
_initElementHeight: () => void;
/**
*
*/
private _initVisual: () => void;
_initVisual: () => void;
/**
*
*/
private _initEffects: () => void;
_initEffects: () => void;
/**
* mounted锁
*/
private _initState: () => void;
_initState: () => void;
/**
* dom
*/
private _initElement: () => void;
_initElement: () => void;
/**
*
*/
private _setParent: () => void;
_setParent: () => void;
/**
* @param force
@ -161,218 +171,212 @@ export declare class _Widget extends _OB {
* @param lifeHook
* @param predicate widget的回调
*/
public _mount: (force?: boolean, deep?: boolean, lifeHook?: boolean, predicate?: Function) => boolean;
_mount: (force?: boolean, deep?: boolean, lifeHook?: boolean, predicate?: Function) => boolean;
/**
*
*/
private _mountChildren: Function | null;
_mountChildren: Function | null;
/**
*
*/
public isMounted: () => boolean;
isMounted: () => boolean;
/**
*
*/
public setWidth: (w: number) => void;
setWidth: (w: number) => void;
/**
*
*/
public setHeight: (h: number) => void;
setHeight: (h: number) => void;
/**
*
*/
private _setEnable: (enable: boolean) => void;
_setEnable: (enable: boolean) => void;
/**
*
*/
private _setValid: (valid: boolean) => void;
_setValid: (valid: boolean) => void;
/**
*
*/
private _setVisible: (visible: boolean) => void;
_setVisible: (visible: boolean) => void;
/**
*
*/
public setEnable: (enable: boolean) => void;
setEnable: (enable: boolean) => void;
/**
*
*/
public setVisible: (visible: boolean) => void;
setVisible: (visible: boolean) => void;
/**
*
*/
public setValid: (valid: boolean) => void;
setValid: (valid: boolean) => void;
/**
*
* @param args arguments参数
*/
public doBehavior: (...args: any[]) => void;
doBehavior: (...args: any[]) => void;
/**
*
*/
public getWidth: () => number;
getWidth: () => number;
/**
*
*/
public getHeight: () => number;
getHeight: () => number;
/**
*
*/
public isValid: () => boolean;
isValid: () => boolean;
/**
*
*/
public addWidget: (_name: any, _widget: _Widget) => _Widget;
addWidget: (_name: any, _widget: _Widget) => _Widget;
/**
* wigetname获取子元素实例
*/
public getWidgetByName: (_name: string) => _Widget;
getWidgetByName: (_name: string) => _Widget;
/**
*
* @param nameOrWidget widgetName或widget实例
*/
public removeWidget: (nameOrWidget: string | _Widget) => void;
removeWidget: (nameOrWidget: string | _Widget) => void;
/**
*
*/
public hasWidget: (name: string) => boolean;
hasWidget: (name: string) => boolean;
/**
* widgetName
*/
public getName: () => string;
getName: () => string;
/**
* tag
* @param tag html tag
*/
public setTag: (tag: string) => void;
setTag: (tag: string) => void;
/**
* tag
*/
public getTag: () => string;
getTag: () => string;
/**
*
* @param key
* @param value
*/
public attr: (key: string | { [key: string]: any }, value: any) => any;
attr: (key: string | { [key: string]: any }, value: any) => any;
/**
* text
*/
public getText: () => string;
getText: () => string;
/**
* text
*/
public setText: () => void;
setText: () => void;
/**
*
*/
public getValue: () => any;
getValue: () => any;
/**
*
*/
public setValue: (...args: any[]) => void;
setValue: (...args: any[]) => void;
/**
* enable
*/
public isEnabled: () => boolean;
isEnabled: () => boolean;
/**
*
*/
public isVisible: () => boolean;
isVisible: () => boolean;
/**
* disable元素
*/
public disable: ()=> void;
disable: ()=> void;
/**
* enable元素
*/
public enable: () => void;
enable: () => void;
/**
* widget合法
*/
public valid: () => void;
valid: () => void;
/**
* 使
*/
public invalid: () => void;
invalid: () => void;
/**
* 使
*/
public invisible: () => void;
invisible: () => void;
/**
*
*/
public visible: () => void;
visible: () => void;
/**
*
*/
private __d: () => void;
__d: () => void;
/**
*
*/
private _unMount: () => void;
_unMount: () => void;
/**
* hang元素
*/
public isolate: () => void;
isolate: () => void;
/**
*
*/
public empty: () => void;
empty: () => void;
/**
* destory方法
*/
protected _destroy: () => void;
_destroy: () => void;
/**
* destory元素
*/
public destroy: () => void;
/**
*
* @param engine
*/
static registerRenderEngine: (engine: RenderEngine) => void;
destroy: () => void;
}
interface RenderEngine {

11
typescript/index.ts

@ -1,10 +1,9 @@
import { _i18n } from "./core/i18n";
import { _OB } from "./core/ob";
import { OBConstructor } from "./core/ob";
import { _func } from "./core/func";
import { _Widget } from "./core/widget";
import { WidgetConstructor } from "./core/widget";
export interface BI extends _func {
i18n: _i18n;
OB: _OB;
Widget: _Widget;
export interface _BI extends _func, _i18n {
OB: OBConstructor;
Widget: WidgetConstructor;
}
Loading…
Cancel
Save