@joker.front/core 1.2.136
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -0
- package/dist/bundle.es.js +3589 -0
- package/dist/bundle.js +3643 -0
- package/package.json +50 -0
- package/types/component.d.ts +216 -0
- package/types/components/component.d.ts +13 -0
- package/types/components/container.d.ts +15 -0
- package/types/components/template.d.ts +7 -0
- package/types/docs/build/docs.d.ts +1 -0
- package/types/docs/build/markdown-it-demo.d.ts +3 -0
- package/types/docs/build/utils.d.ts +3 -0
- package/types/docs/common/loading.d.ts +2 -0
- package/types/docs/main.d.ts +1 -0
- package/types/event-bus.d.ts +15 -0
- package/types/eventBus.d.ts +15 -0
- package/types/filter.d.ts +13 -0
- package/types/global.d.ts +13 -0
- package/types/hmr.d.ts +15 -0
- package/types/index.d.ts +10 -0
- package/types/observer/dep.d.ts +46 -0
- package/types/observer/index.d.ts +46 -0
- package/types/observer/watcher.d.ts +46 -0
- package/types/parser/command/code.d.ts +6 -0
- package/types/parser/command/condition.d.ts +22 -0
- package/types/parser/command/for.d.ts +23 -0
- package/types/parser/command/section.d.ts +8 -0
- package/types/parser/comment.d.ts +6 -0
- package/types/parser/component.d.ts +23 -0
- package/types/parser/element.d.ts +9 -0
- package/types/parser/index.d.ts +77 -0
- package/types/parser/parser.d.ts +82 -0
- package/types/parser/render.d.ts +86 -0
- package/types/parser/text.d.ts +6 -0
- package/types/parser/vnode.d.ts +180 -0
- package/types/props.d.ts +9 -0
- package/types/src/component.d.ts +216 -0
- package/types/src/event-bus.d.ts +15 -0
- package/types/src/filter.d.ts +13 -0
- package/types/src/hmr.d.ts +15 -0
- package/types/src/index.d.ts +10 -0
- package/types/src/observer/dep.d.ts +46 -0
- package/types/src/observer/index.d.ts +46 -0
- package/types/src/observer/watcher.d.ts +46 -0
- package/types/src/parser/command/code.d.ts +6 -0
- package/types/src/parser/command/condition.d.ts +22 -0
- package/types/src/parser/command/for.d.ts +23 -0
- package/types/src/parser/command/section.d.ts +8 -0
- package/types/src/parser/comment.d.ts +6 -0
- package/types/src/parser/component.d.ts +23 -0
- package/types/src/parser/element.d.ts +9 -0
- package/types/src/parser/index.d.ts +77 -0
- package/types/src/parser/parser.d.ts +82 -0
- package/types/src/parser/render.d.ts +86 -0
- package/types/src/parser/text.d.ts +6 -0
- package/types/src/parser/vnode.d.ts +182 -0
- package/types/src/props.d.ts +9 -0
- package/types/src/utils/DI.d.ts +15 -0
- package/types/utils/DI.d.ts +15 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Component, ComponentConstructor, TemplateType } from "./component";
|
|
2
|
+
/**
|
|
3
|
+
* 热更新助手(热更新使用)(构建时会按需剔除)
|
|
4
|
+
*/
|
|
5
|
+
export declare let __JOKER_HMR_RUNTIME: {
|
|
6
|
+
recordRender: (id: string, template: {
|
|
7
|
+
render: TemplateType;
|
|
8
|
+
}) => void;
|
|
9
|
+
recordComponent: (id: string, component: {
|
|
10
|
+
component: ComponentConstructor;
|
|
11
|
+
}) => void;
|
|
12
|
+
record: (id: string, component: Component) => void;
|
|
13
|
+
reload: (id: string, component: ComponentConstructor) => void;
|
|
14
|
+
rerender: (id: string, template: TemplateType) => void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { AST, RENDER_HANDLER, createCodeFunction, createCommand, createComment, createElement, createFuntionBody, createText, createComponent } from "@joker.front/ast";
|
|
2
|
+
export * from "./component";
|
|
3
|
+
export * from "./parser/vnode";
|
|
4
|
+
export { ParserTemplate, NodeChangeType } from "./parser/index";
|
|
5
|
+
export * from "./observer/watcher";
|
|
6
|
+
export * from "./observer/index";
|
|
7
|
+
export * from "./utils/DI";
|
|
8
|
+
export * from "./hmr";
|
|
9
|
+
export * from "./event-bus";
|
|
10
|
+
export { registerGlobalFilter } from "./filter";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Watcher } from "./watcher";
|
|
2
|
+
/**
|
|
3
|
+
* 作为观察者和对象代理中间的关系桥
|
|
4
|
+
* 数据变更时:Ob->dep->watcher
|
|
5
|
+
* 设置依赖时:watcher->dep
|
|
6
|
+
*/
|
|
7
|
+
export declare class Dep {
|
|
8
|
+
/**
|
|
9
|
+
* 关系id,尽在production模式下生效
|
|
10
|
+
*/
|
|
11
|
+
id: string;
|
|
12
|
+
/**
|
|
13
|
+
* 当前目标的监听者
|
|
14
|
+
*
|
|
15
|
+
* 在更改值之前,设置该静态值,使其在值变更时收集相应的依赖关系
|
|
16
|
+
* 设置完毕后清除该值
|
|
17
|
+
*
|
|
18
|
+
* 之所以采用静态值,不采用方法的原因:
|
|
19
|
+
* 可能存在多值变更,或者读取
|
|
20
|
+
*/
|
|
21
|
+
static target?: Watcher<any>;
|
|
22
|
+
watchers: Map<string | symbol, Watcher<any>[]>;
|
|
23
|
+
/**
|
|
24
|
+
* 设置依赖
|
|
25
|
+
* @param key
|
|
26
|
+
*/
|
|
27
|
+
depend(key: string | symbol): void;
|
|
28
|
+
/**
|
|
29
|
+
* 添加观察者
|
|
30
|
+
* @param key
|
|
31
|
+
* @param watcher
|
|
32
|
+
*/
|
|
33
|
+
addWatcher(key: string | symbol, watcher: Watcher<any>): void;
|
|
34
|
+
/**
|
|
35
|
+
* 删除观察者
|
|
36
|
+
* @param key
|
|
37
|
+
* @param watcher
|
|
38
|
+
*/
|
|
39
|
+
removeWatcher(key: string | symbol, watcher: Watcher<any>): void;
|
|
40
|
+
/**
|
|
41
|
+
* 通知key下面的观察者
|
|
42
|
+
* @param key
|
|
43
|
+
*/
|
|
44
|
+
notify(key: string | symbol): void;
|
|
45
|
+
}
|
|
46
|
+
export declare function notifyGroupDeps(list: Map<Dep, Array<string | symbol>>): void;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 存放劫持对象的Dep的Key
|
|
3
|
+
*/
|
|
4
|
+
export declare const OBJECTPROXY_DEPID: unique symbol;
|
|
5
|
+
/**
|
|
6
|
+
* 数据劫持
|
|
7
|
+
* @param data 数据
|
|
8
|
+
* @param clone 是否clone
|
|
9
|
+
* @returns 返回可观察对象
|
|
10
|
+
*/
|
|
11
|
+
export declare function observer<T extends Object>(data: T, clone?: boolean): T;
|
|
12
|
+
/**
|
|
13
|
+
* 定义可劫持观察的属性
|
|
14
|
+
*
|
|
15
|
+
* 该方法会污染value深层,如想纯净数据,自行clone
|
|
16
|
+
* @param target
|
|
17
|
+
* @param key
|
|
18
|
+
* @param value
|
|
19
|
+
*/
|
|
20
|
+
export declare function defineObserverProperty(target: any, key: string | symbol, value: any): void;
|
|
21
|
+
/**
|
|
22
|
+
* 浅劫持监听,不污染数据源,只对根值监听,不对属性监听
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export declare class ShallowObserver<T> {
|
|
26
|
+
private data;
|
|
27
|
+
private dep;
|
|
28
|
+
constructor(data: T);
|
|
29
|
+
/**
|
|
30
|
+
* 是否有变更
|
|
31
|
+
*/
|
|
32
|
+
isChanged: boolean;
|
|
33
|
+
get value(): T;
|
|
34
|
+
set value(newVal: T);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 组合回复,针对大量值变更,又不想频繁更新DOM,
|
|
38
|
+
* 可通过该方法实现一个作用域内的统一组合回复
|
|
39
|
+
* @param func 处理方法
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
export declare function combinedReply(func: Function): void;
|
|
43
|
+
/**
|
|
44
|
+
* 判断一个值是否是已被数据代理劫持
|
|
45
|
+
*/
|
|
46
|
+
export declare function isObserverData(data: any): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Dep } from "./dep";
|
|
2
|
+
/**
|
|
3
|
+
* 观察者
|
|
4
|
+
*
|
|
5
|
+
* 负责观察对象,并收集依赖关系,并在值变更时做出回调响应
|
|
6
|
+
*/
|
|
7
|
+
export declare class Watcher<T extends object = any> {
|
|
8
|
+
private ob;
|
|
9
|
+
private updateCallBack;
|
|
10
|
+
private forceCallBack?;
|
|
11
|
+
private getter;
|
|
12
|
+
value: any;
|
|
13
|
+
isDestroy: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 运行时的关系收集
|
|
16
|
+
*
|
|
17
|
+
* 主要作用是:运行时做基本的重复过滤,并收集当前“有效的”Dep关系
|
|
18
|
+
* 一个Dep 肯定对应一个对象, 对象的key不会出现重复
|
|
19
|
+
*/
|
|
20
|
+
private runRelations;
|
|
21
|
+
/**
|
|
22
|
+
* 实际关系
|
|
23
|
+
*/
|
|
24
|
+
relations: Map<Dep, Array<string | symbol>>;
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param ob 数据源
|
|
28
|
+
* @param expOrFn 表达式(string|Function)
|
|
29
|
+
* @param updateCallBack update回调
|
|
30
|
+
* @param forceCallBack 是否强制回调, 有些值未变更时也会强制回调
|
|
31
|
+
*/
|
|
32
|
+
constructor(ob: T | (() => T), updateCallBack: Function, expOrFn?: string | ((obj: T) => any | void) | Function, forceCallBack?: boolean | undefined);
|
|
33
|
+
getValue(): any;
|
|
34
|
+
/**
|
|
35
|
+
* 添加Dep关系
|
|
36
|
+
* @param dep
|
|
37
|
+
* @param key
|
|
38
|
+
*/
|
|
39
|
+
addDep(dep: Dep, key: string | symbol): void;
|
|
40
|
+
/**
|
|
41
|
+
* 更新值,并对其进行响应
|
|
42
|
+
*/
|
|
43
|
+
update(): void;
|
|
44
|
+
destroy(): void;
|
|
45
|
+
private clearnDeps;
|
|
46
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AST } from "@joker.front/ast";
|
|
2
|
+
import { IParser } from "../parser";
|
|
3
|
+
import { VNode } from "../vnode";
|
|
4
|
+
export declare class ParserCondition extends IParser<AST.IfCommand, VNode.Condition> {
|
|
5
|
+
parser(): void;
|
|
6
|
+
/**
|
|
7
|
+
* 渲染子集
|
|
8
|
+
*
|
|
9
|
+
* @return 返回当前渲染是否有显示变更
|
|
10
|
+
*/
|
|
11
|
+
private renderConditionChildren;
|
|
12
|
+
/**
|
|
13
|
+
* 获取同级前面的判断条件结果,如果有一个true则返回true,
|
|
14
|
+
* 否则认为上面所有条件判断都为false
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
private getPrevIfResult;
|
|
18
|
+
/**
|
|
19
|
+
* 重载所有的判断(从上到下)
|
|
20
|
+
*/
|
|
21
|
+
private reloadAllCondition;
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AST } from "@joker.front/ast";
|
|
2
|
+
import { IParser } from "../parser";
|
|
3
|
+
import { VNode } from "../vnode";
|
|
4
|
+
export declare class ParserList extends IParser<AST.ForCommand, VNode.List> {
|
|
5
|
+
parser(): void;
|
|
6
|
+
private renderChildrens;
|
|
7
|
+
private renderConditionChildrens;
|
|
8
|
+
private renderInOrOfChildrens;
|
|
9
|
+
/**
|
|
10
|
+
* 渲染循环项
|
|
11
|
+
* @param ob
|
|
12
|
+
* @param index
|
|
13
|
+
*/
|
|
14
|
+
private renderItem;
|
|
15
|
+
/**
|
|
16
|
+
* 销毁历史遗留多余的节点
|
|
17
|
+
* @param index
|
|
18
|
+
*/
|
|
19
|
+
private destroyOldChildrens;
|
|
20
|
+
}
|
|
21
|
+
export declare class ParserListeItem extends IParser<AST.ForCommand, VNode.ListItem> {
|
|
22
|
+
parser(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AST } from "@joker.front/ast";
|
|
2
|
+
import { IParser } from "../parser";
|
|
3
|
+
import { VNode } from "../vnode";
|
|
4
|
+
export declare const DEFAULT_SECTION_TAG = "default";
|
|
5
|
+
export declare class ParserRenderSection extends IParser<AST.PropertyOrFunctionCommand, VNode.RenderSection> {
|
|
6
|
+
parser(): void;
|
|
7
|
+
private transformParam;
|
|
8
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AST, IComponent } from "@joker.front/ast";
|
|
2
|
+
import { IParser } from "./parser";
|
|
3
|
+
import { Component } from "../component";
|
|
4
|
+
import { VNode } from "./vnode";
|
|
5
|
+
export declare function checkIsComponent(tagName: string, ob: Component): boolean;
|
|
6
|
+
export declare class ParserComponent extends IParser<(AST.Element | AST.Component) & {
|
|
7
|
+
node?: VNode.Component<IComponent>;
|
|
8
|
+
}, VNode.Component<IComponent>> {
|
|
9
|
+
parser(): void;
|
|
10
|
+
/**
|
|
11
|
+
* 是否允许重载
|
|
12
|
+
* 直接指向内存的组件,无法重新实例化
|
|
13
|
+
*/
|
|
14
|
+
get canReload(): boolean;
|
|
15
|
+
/** 用于重载 */
|
|
16
|
+
reload(): void;
|
|
17
|
+
private initPropData;
|
|
18
|
+
private initEvent;
|
|
19
|
+
private renderChildren;
|
|
20
|
+
private getSections;
|
|
21
|
+
protected beforeDestroy(keepalive?: boolean): void;
|
|
22
|
+
private transformPropValue;
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AST } from "@joker.front/ast";
|
|
2
|
+
import { IParser } from "./parser";
|
|
3
|
+
import { VNode } from "./vnode";
|
|
4
|
+
export declare class ParserElement extends IParser<AST.Element, VNode.Element> {
|
|
5
|
+
parser(): void;
|
|
6
|
+
private initAttributes;
|
|
7
|
+
private initEvents;
|
|
8
|
+
private transformAttrVal;
|
|
9
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { AST } from "@joker.front/ast";
|
|
2
|
+
import { Component } from "../component";
|
|
3
|
+
import { Render } from "./render";
|
|
4
|
+
import { VNode } from "./vnode";
|
|
5
|
+
export type NodeChangeType = "append" | "remove" | "update" | "after-enter" | "after-leave";
|
|
6
|
+
export type ObType = Component & Record<string, any>;
|
|
7
|
+
export declare class ParserTemplate {
|
|
8
|
+
asts: AST.Node[];
|
|
9
|
+
ob: ObType;
|
|
10
|
+
/** VNode 根 */
|
|
11
|
+
root: VNode.Root;
|
|
12
|
+
/** VNode ref索引集 */
|
|
13
|
+
refs: Record<string, Array<VNode.Node>>;
|
|
14
|
+
sleeped: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* node变更观察者
|
|
17
|
+
*/
|
|
18
|
+
nodeWatcherEvents: Record<string, Array<(node: VNode.Node, type: NodeChangeType, propertyKey?: string) => void>>;
|
|
19
|
+
/** VNode 渲染处理程序 (依赖注入) */
|
|
20
|
+
render: Render.IRender;
|
|
21
|
+
constructor(asts: AST.Node[], ob: ObType, parent?: VNode.Node);
|
|
22
|
+
parser(): void;
|
|
23
|
+
/**
|
|
24
|
+
* VNode挂载
|
|
25
|
+
* @param root
|
|
26
|
+
*/
|
|
27
|
+
mount(root: any): void;
|
|
28
|
+
/**
|
|
29
|
+
* 编译AST子集
|
|
30
|
+
* @param asts
|
|
31
|
+
* @param parent
|
|
32
|
+
*/
|
|
33
|
+
parserNodes(asts: AST.Node[], parent: VNode.Node, ob?: Component & Record<string, any>): void;
|
|
34
|
+
/**
|
|
35
|
+
* 添加ref
|
|
36
|
+
* @param refName ref值
|
|
37
|
+
* @param node VNode节点
|
|
38
|
+
*/
|
|
39
|
+
addRef(refKey: string, node: VNode.Node): void;
|
|
40
|
+
/**
|
|
41
|
+
* 移除Node所在ref
|
|
42
|
+
* @param node VNode节点
|
|
43
|
+
*/
|
|
44
|
+
removeRef(node: VNode.Node): void;
|
|
45
|
+
/**
|
|
46
|
+
* 添加节点变更观察者
|
|
47
|
+
* @param ref
|
|
48
|
+
* @param callBack
|
|
49
|
+
*/
|
|
50
|
+
addNodeWatcher(ref: string, callBack: (node: VNode.Node, type: NodeChangeType) => void): void;
|
|
51
|
+
/**
|
|
52
|
+
* 移除节点变更观察者
|
|
53
|
+
* @param ref
|
|
54
|
+
* @param callBack
|
|
55
|
+
*/
|
|
56
|
+
removeNodeWatcher(ref: string, callBack: Function): void;
|
|
57
|
+
/**
|
|
58
|
+
* 响应节点变更,通知观察者
|
|
59
|
+
* @param ref
|
|
60
|
+
* @param node
|
|
61
|
+
* @param nodeChangeType
|
|
62
|
+
*/
|
|
63
|
+
notifyNodeWatcher(ref: string, node: VNode.Node, nodeChangeType: NodeChangeType, propertyKey?: string): void;
|
|
64
|
+
sleep(node?: VNode.Node): void;
|
|
65
|
+
private weakup;
|
|
66
|
+
/**
|
|
67
|
+
* 销毁
|
|
68
|
+
*/
|
|
69
|
+
destroy(keepalive?: boolean): void;
|
|
70
|
+
reParser(asts: AST.Node[], keepalive?: boolean): void;
|
|
71
|
+
nodeTransition(node: VNode.Node | undefined, mode: "enter" | "leave", name?: string, callBack?: Function, type?: "transition" | "animation"): boolean;
|
|
72
|
+
}
|
|
73
|
+
export declare function getFirstElement(node: VNode.Node): VNode.Element | undefined;
|
|
74
|
+
export declare function getNodeSupportTransition(node: VNode.Node): {
|
|
75
|
+
name: any;
|
|
76
|
+
type: any;
|
|
77
|
+
} | undefined;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { AST } from "@joker.front/ast";
|
|
2
|
+
import { ObType, ParserTemplate, NodeChangeType } from ".";
|
|
3
|
+
import { Watcher } from "../observer/watcher";
|
|
4
|
+
import { VNode } from "./vnode";
|
|
5
|
+
export declare const FILTERTAG = "Filter";
|
|
6
|
+
export declare abstract class IParser<T extends AST.Node, N extends VNode.Node> {
|
|
7
|
+
/** ast集合 */
|
|
8
|
+
protected ast: T;
|
|
9
|
+
/** 数据源 会在component上进行属性新增 */
|
|
10
|
+
ob: ObType;
|
|
11
|
+
/** 父节点 */
|
|
12
|
+
protected parent: VNode.Node;
|
|
13
|
+
/** 外部处理(ParserTemplate) */
|
|
14
|
+
protected ext: ParserTemplate;
|
|
15
|
+
/** 当前转换节点ref标记 */
|
|
16
|
+
ref: string;
|
|
17
|
+
/** 当前AST解析 所产生的观察者 */
|
|
18
|
+
private watchers;
|
|
19
|
+
node?: N;
|
|
20
|
+
constructor(
|
|
21
|
+
/** ast集合 */
|
|
22
|
+
ast: T,
|
|
23
|
+
/** 数据源 会在component上进行属性新增 */
|
|
24
|
+
ob: ObType,
|
|
25
|
+
/** 父节点 */
|
|
26
|
+
parent: VNode.Node,
|
|
27
|
+
/** 外部处理(ParserTemplate) */
|
|
28
|
+
ext: ParserTemplate);
|
|
29
|
+
/**
|
|
30
|
+
* 上游主入口方法(初始化执行)
|
|
31
|
+
*/
|
|
32
|
+
abstract parser(): void;
|
|
33
|
+
protected beforeDestroy(keepalive?: boolean): void | boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 销毁流程
|
|
36
|
+
*/
|
|
37
|
+
destroy(keepalive?: boolean): void;
|
|
38
|
+
private destroyOtherData;
|
|
39
|
+
/**
|
|
40
|
+
* 销毁所有子集VNode
|
|
41
|
+
*/
|
|
42
|
+
protected destroyChildrens(keepalive?: boolean): void;
|
|
43
|
+
/**
|
|
44
|
+
* 销毁所有子集VNode的watcher,为了防止延迟卸载时,无效通知广播
|
|
45
|
+
*/
|
|
46
|
+
protected destroyChildrensWatcher(nodeItem?: VNode.Node): void;
|
|
47
|
+
/**
|
|
48
|
+
* 插入自身节点
|
|
49
|
+
*/
|
|
50
|
+
protected appendNode(): void;
|
|
51
|
+
protected afterParser(): void;
|
|
52
|
+
/**
|
|
53
|
+
* 通知节点观察者
|
|
54
|
+
* @param type 通知类型
|
|
55
|
+
*/
|
|
56
|
+
protected notifyNodeWatcher(type: NodeChangeType, propertyKey?: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* 运行表达式方法,并返回运行后的值(不带观察者)
|
|
59
|
+
* @param express 表达式 string|function
|
|
60
|
+
* @param ob 数据源
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
protected runExpress(express: string, ob: any): any;
|
|
64
|
+
/**
|
|
65
|
+
* 运行表达式方法,并返回运行后的值(带观察者)
|
|
66
|
+
* @param express 表达式 string|function
|
|
67
|
+
* @param ob 数据源
|
|
68
|
+
* @param updateCallBack 更新回调
|
|
69
|
+
* @param forceCallBack 是否强制回调
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
protected runExpressWithWatcher(express: string | Function, ob: any, updateCallBack: (newVal: any, oldVal: any) => void, forceCallBack?: boolean): any;
|
|
73
|
+
/**
|
|
74
|
+
* 添加观察者
|
|
75
|
+
* @param watcher
|
|
76
|
+
*/
|
|
77
|
+
protected addWatch(watcher: Watcher<any>): void;
|
|
78
|
+
/**
|
|
79
|
+
* 清空所有观察者
|
|
80
|
+
*/
|
|
81
|
+
protected clearWatchers(): void;
|
|
82
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { VNode } from "./vnode";
|
|
2
|
+
import { IComponent } from "@joker.front/ast";
|
|
3
|
+
type TransitionType = "transition" | "animation";
|
|
4
|
+
export declare namespace Render {
|
|
5
|
+
/**
|
|
6
|
+
* 注入TagId
|
|
7
|
+
*/
|
|
8
|
+
const IRENDERIOCTAGID: unique symbol;
|
|
9
|
+
/**
|
|
10
|
+
* 备注:在渲染时执行appendNode,最终执行一次mount挂载
|
|
11
|
+
* 不会出现根目录append的场景,因为指令group会优先占位
|
|
12
|
+
*
|
|
13
|
+
* append 和 remove方法不会存在 parent的参数,因为一次挂载后
|
|
14
|
+
* 会存在关系,根据关系直接执行
|
|
15
|
+
* 上游调用也无需关心parent,特别是在watch周期内
|
|
16
|
+
*/
|
|
17
|
+
interface IRender {
|
|
18
|
+
/**
|
|
19
|
+
* 挂载
|
|
20
|
+
* @param root 挂载根
|
|
21
|
+
* 不限制root类型,为后面做多端兼容
|
|
22
|
+
*/
|
|
23
|
+
mount(root: any): void;
|
|
24
|
+
/**
|
|
25
|
+
* 添加节点
|
|
26
|
+
* @param node NodeInfo
|
|
27
|
+
*/
|
|
28
|
+
appendNode(node: VNode.Node): void;
|
|
29
|
+
/**
|
|
30
|
+
* 更新节点
|
|
31
|
+
* @param node NodeInfo
|
|
32
|
+
* @param propertyKey 更新属性名称
|
|
33
|
+
*/
|
|
34
|
+
updateNode(node: VNode.Node, propertyKey?: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* 删除节点
|
|
37
|
+
* @param {VNode.Node} node
|
|
38
|
+
* @param {VNode.Node} parent 如果为空则带表root跟节点下集
|
|
39
|
+
* @param {boolean} reserveOutPut 是否需要保留out产物
|
|
40
|
+
*/
|
|
41
|
+
removeNode(node: VNode.Node, reserveOutPut?: boolean): void;
|
|
42
|
+
/**
|
|
43
|
+
* 销毁,卸载DOM并释放变量
|
|
44
|
+
*/
|
|
45
|
+
destroy(): void;
|
|
46
|
+
/**
|
|
47
|
+
* element节点transition enter
|
|
48
|
+
*/
|
|
49
|
+
elementToEnter(node: VNode.Element, name: string, type?: TransitionType, callBack?: Function): void;
|
|
50
|
+
/**
|
|
51
|
+
* element节点transition leave
|
|
52
|
+
*/
|
|
53
|
+
elementToLeave(node: VNode.Element, name: string, type?: TransitionType, callBack?: Function): void;
|
|
54
|
+
/**
|
|
55
|
+
* 触发组件事件
|
|
56
|
+
* @param node
|
|
57
|
+
* @param eventName
|
|
58
|
+
* @returns false 则代表通知广播
|
|
59
|
+
*/
|
|
60
|
+
triggerEvent(node: VNode.Component, eventName: string, e: VNode.Event): void | false;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 默认Render,采用H5-DOM模式进行输出
|
|
64
|
+
*/
|
|
65
|
+
class DomRender implements IRender {
|
|
66
|
+
elements: DocumentFragment;
|
|
67
|
+
constructor();
|
|
68
|
+
mount(root: Element | VNode.Component): void;
|
|
69
|
+
appendNode(node: VNode.Node): void;
|
|
70
|
+
updateNode(node: VNode.Node, propertyKey?: string | undefined): void;
|
|
71
|
+
removeNode(node: VNode.Node, reserveOutPut?: boolean): void;
|
|
72
|
+
destroy(): void;
|
|
73
|
+
elementToEnter(node: VNode.Element, name: string, type?: TransitionType, callBack?: Function): void;
|
|
74
|
+
elementToLeave(node: VNode.Element, name: string, type?: TransitionType, callBack?: Function): void;
|
|
75
|
+
triggerEvent(node: VNode.Component<IComponent & Record<string, any>>, _eventName: string, _e: VNode.Event): void | false;
|
|
76
|
+
private transitionFrame;
|
|
77
|
+
private renderNode;
|
|
78
|
+
private initElementEvents;
|
|
79
|
+
private parserHtml;
|
|
80
|
+
private isCommandGroup;
|
|
81
|
+
private appendNodeChildren;
|
|
82
|
+
private setAttribute;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export declare function getTransitionClassName(transition: string, mode: "enter" | "leave", type: "from" | "active" | "to"): string;
|
|
86
|
+
export {};
|