@joker.front/core 1.2.137 → 1.2.138

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.
Files changed (36) hide show
  1. package/README.md +3 -1
  2. package/dist/bundle.es.js +3 -8
  3. package/dist/bundle.js +3 -8
  4. package/package.json +1 -1
  5. package/types/components/component.d.ts +0 -13
  6. package/types/components/container.d.ts +0 -15
  7. package/types/components/template.d.ts +0 -7
  8. package/types/docs/build/docs.d.ts +0 -1
  9. package/types/docs/build/markdown-it-demo.d.ts +0 -3
  10. package/types/docs/build/utils.d.ts +0 -3
  11. package/types/docs/common/loading.d.ts +0 -2
  12. package/types/docs/main.d.ts +0 -1
  13. package/types/eventBus.d.ts +0 -15
  14. package/types/filter.d.ts +0 -13
  15. package/types/src/component.d.ts +0 -216
  16. package/types/src/event-bus.d.ts +0 -15
  17. package/types/src/filter.d.ts +0 -13
  18. package/types/src/hmr.d.ts +0 -15
  19. package/types/src/index.d.ts +0 -10
  20. package/types/src/observer/dep.d.ts +0 -46
  21. package/types/src/observer/index.d.ts +0 -46
  22. package/types/src/observer/watcher.d.ts +0 -46
  23. package/types/src/parser/command/code.d.ts +0 -6
  24. package/types/src/parser/command/condition.d.ts +0 -22
  25. package/types/src/parser/command/for.d.ts +0 -23
  26. package/types/src/parser/command/section.d.ts +0 -8
  27. package/types/src/parser/comment.d.ts +0 -6
  28. package/types/src/parser/component.d.ts +0 -23
  29. package/types/src/parser/element.d.ts +0 -9
  30. package/types/src/parser/index.d.ts +0 -77
  31. package/types/src/parser/parser.d.ts +0 -82
  32. package/types/src/parser/render.d.ts +0 -86
  33. package/types/src/parser/text.d.ts +0 -6
  34. package/types/src/parser/vnode.d.ts +0 -182
  35. package/types/src/props.d.ts +0 -9
  36. package/types/src/utils/DI.d.ts +0 -15
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Joker
2
2
 
3
+ Joker 是一个框架平台,旨在为所有开发场景提供支持。其中,Joker.front 是 Joker 平台下的前端开发框架,它提供标准化的前端开发标准,使用面向对象、组件化的编程模型,帮助你高效地开发用户界面。无论是简单还是复杂的界面,Joker.front 都可以轻松应对。
4
+
3
5
  ## 什么是 Joker?
4
6
 
5
7
  Joker 是一个框架平台,旨在为所有开发场景提供支持。其中,Joker.front 是 Joker 平台下的前端开发框架,它提供标准化的前端开发标准,使用面向对象、组件化的编程模型,帮助你高效地开发用户界面。无论是简单还是复杂的界面,Joker.front 都可以轻松应对。
@@ -61,4 +63,4 @@ npm run dev
61
63
 
62
64
  ## 文档
63
65
 
64
- [官网](www.jokers.pub)
66
+ [官网](http://www.jokers.pub)
package/dist/bundle.es.js CHANGED
@@ -1562,6 +1562,7 @@ var Render;
1562
1562
  }
1563
1563
  }
1564
1564
  else if (attrName === "style" && isObject(attrVal)) {
1565
+ el.removeAttribute("style");
1565
1566
  for (let name in attrVal) {
1566
1567
  let isEmptyValue = false;
1567
1568
  if (attrVal[name] === undefined || attrVal[name] === false) {
@@ -1571,14 +1572,8 @@ var Render;
1571
1572
  if (isEmptyStr(val)) {
1572
1573
  isEmptyValue = true;
1573
1574
  }
1574
- //空移除属性
1575
- if (isEmptyValue) {
1576
- el.style.removeProperty(name);
1577
- //@ts-ignore
1578
- el.style[name] = "";
1579
- continue;
1580
- }
1581
- else {
1575
+ //非空
1576
+ if (!isEmptyValue) {
1582
1577
  //@ts-ignore
1583
1578
  el.style[name] = val;
1584
1579
  }
package/dist/bundle.js CHANGED
@@ -1563,6 +1563,7 @@ var Render;
1563
1563
  }
1564
1564
  }
1565
1565
  else if (attrName === "style" && isObject(attrVal)) {
1566
+ el.removeAttribute("style");
1566
1567
  for (let name in attrVal) {
1567
1568
  let isEmptyValue = false;
1568
1569
  if (attrVal[name] === undefined || attrVal[name] === false) {
@@ -1572,14 +1573,8 @@ var Render;
1572
1573
  if (isEmptyStr(val)) {
1573
1574
  isEmptyValue = true;
1574
1575
  }
1575
- //空移除属性
1576
- if (isEmptyValue) {
1577
- el.style.removeProperty(name);
1578
- //@ts-ignore
1579
- el.style[name] = "";
1580
- continue;
1581
- }
1582
- else {
1576
+ //非空
1577
+ if (!isEmptyValue) {
1583
1578
  //@ts-ignore
1584
1579
  el.style[name] = val;
1585
1580
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joker.front/core",
3
- "version": "1.2.137",
3
+ "version": "1.2.138",
4
4
  "description": "",
5
5
  "main": "./dist/bundle.js",
6
6
  "module": "./dist/bundle.es.js",
@@ -1,13 +0,0 @@
1
- import { Component } from "../component";
2
- export declare class ComponentContainer extends Component {
3
- template: never[];
4
- propsType: {
5
- name: StringConstructor;
6
- data: ObjectConstructor;
7
- };
8
- private cache;
9
- mounted(): void;
10
- loadComponent(componentName: string): Promise<void>;
11
- beforeDestory(): void;
12
- removeCache(componentName?: string): void;
13
- }
@@ -1,15 +0,0 @@
1
- import { Component } from "../index";
2
- /**
3
- * 动态组件容器
4
- */
5
- export declare class ComponentContainer extends Component<{
6
- name: string;
7
- data: object;
8
- }> {
9
- template: never[];
10
- private cache;
11
- mounted(): void;
12
- loadComponent(componentName?: string): Promise<void>;
13
- beforeDestory(): void;
14
- removeCache(componentName?: string): void;
15
- }
@@ -1,7 +0,0 @@
1
- import { Component } from "../component";
2
- /**
3
- * 虚拟模板容器,用于进行归组,作为组件配置属性
4
- */
5
- export declare class Template extends Component {
6
- template: () => import("@joker.front/ast").AST.Command[];
7
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import MarkdownIt from "markdown-it";
2
- export declare let demoPlugin: MarkdownIt.PluginSimple;
3
- export declare let divPlugin: MarkdownIt.PluginSimple;
@@ -1,3 +0,0 @@
1
- export declare const isWindows: boolean;
2
- export declare function normalizePath(strPath: string): string;
3
- export declare function slash(p: string): string;
@@ -1,2 +0,0 @@
1
- export declare function showLoading(): void;
2
- export declare function hideLoading(): void;
@@ -1 +0,0 @@
1
- import "@joker.front/ui/index.css";
@@ -1,15 +0,0 @@
1
- export type EventCallBackItem = {
2
- callBack: EventCallBackType;
3
- once?: Boolean;
4
- };
5
- export type EventCallBackType = (e: {
6
- stopPropagation: Function;
7
- callTimes: Number;
8
- }, params?: any) => boolean | void;
9
- export declare class EventBus<T extends string> {
10
- private eventDatas;
11
- on(eventName: T, callBack: EventCallBackType): void;
12
- once(eventName: T, callBack: EventCallBackType): void;
13
- off(eventName: T, callBack?: EventCallBackType): void;
14
- trigger(eventName: T, param?: any): false | undefined;
15
- }
package/types/filter.d.ts DELETED
@@ -1,13 +0,0 @@
1
- export type GlobalFilter = (...args: any[]) => string | void | undefined;
2
- export declare const globalFilters: Record<string, GlobalFilter>;
3
- /**
4
- * 注册全局组件
5
- * @param components 组件
6
- */
7
- export declare function registerGlobalFilter(filters: Record<string, GlobalFilter>): void;
8
- /**
9
- * 根据注册key获取组件
10
- * @param name 组件名称
11
- * @returns 组件
12
- */
13
- export declare function getGlobalFilter(key: string): GlobalFilter | undefined;
@@ -1,216 +0,0 @@
1
- import { AST, IComponent, RENDER_HANDLER } from "@joker.front/ast";
2
- import { NodeChangeType, ParserTemplate } from "./parser";
3
- import { VNode } from "./parser/vnode";
4
- import { PropType } from "./props";
5
- declare const PROPS_DATA_KEY: unique symbol;
6
- declare const PROPS_DATA_PROXY: unique symbol;
7
- declare const PRIVATE_WATCHERS: unique symbol;
8
- declare const EVENT_DATA_KEY: unique symbol;
9
- declare const PARSER_TEMPLATE_TARGET: unique symbol;
10
- export type TemplateType = Array<AST.Node> | ((h: typeof RENDER_HANDLER) => Array<AST.Node>);
11
- export declare const SCOPE_ID: unique symbol;
12
- export declare const JOKER_COMPONENT_TAG: unique symbol;
13
- export type ComponentConstructor = typeof Component<any>;
14
- export type ImportComponentConstructor = () => Promise<{
15
- default: ComponentConstructor;
16
- }>;
17
- export type SectionType = {
18
- asts: AST.Node[];
19
- ob?: Component & Record<string, any>;
20
- parser?: ParserTemplate;
21
- params?: string[];
22
- };
23
- type DefaultKeyVal = Record<string | symbol, any>;
24
- /**
25
- * Joker组件
26
- */
27
- export declare class Component<T extends DefaultKeyVal = {}> implements IComponent {
28
- $sections: Record<string, SectionType>;
29
- readonly isKeepAlive?: boolean | undefined;
30
- static [JOKER_COMPONENT_TAG]: boolean;
31
- /**
32
- * scopeId 配合css:Scoped
33
- */
34
- [SCOPE_ID]?: string;
35
- /**
36
- * 可观察数据(具备劫持观察能力)
37
- */
38
- model: DefaultKeyVal;
39
- /**
40
- * 渲染模板
41
- */
42
- template?: TemplateType;
43
- /**
44
- * 挂载根
45
- */
46
- $root: any;
47
- /**
48
- * 是否已睡眠
49
- */
50
- isSleeped: boolean;
51
- /**
52
- * 可用的声明组件
53
- */
54
- components: Record<string, ComponentConstructor | ImportComponentConstructor>;
55
- /**
56
- * props辅助约束
57
- * @example { name:"默认值",age:Number }
58
- * 可以配置默认值,也可以配置为约束,类型参考PropType
59
- */
60
- propsOption?: Partial<Record<keyof T, PropType | any>>;
61
- private [PROPS_DATA_KEY];
62
- private [PARSER_TEMPLATE_TARGET]?;
63
- private [PROPS_DATA_PROXY]?;
64
- private [PRIVATE_WATCHERS];
65
- private [EVENT_DATA_KEY];
66
- /**
67
- * @param propData prop参数
68
- * @param sections 渲染部分区域
69
- * @param isKeepAlive 是否要保持存活,启用时再destroy时只会销毁UI部分,不会销毁数据,直到使用destroy(true)才会销毁
70
- */
71
- constructor(propData?: T, $sections?: Record<string, SectionType>, isKeepAlive?: boolean | undefined);
72
- /**
73
- * 主动声明接受的参数
74
- * @returns
75
- */
76
- get props(): Readonly<Partial<T>>;
77
- /**
78
- * 挂载
79
- * @param root
80
- */
81
- $mount(root: any | VNode.Component<IComponent>): this;
82
- /**
83
- * 节点动画,仅支持 element及组件节点
84
- */
85
- $nodeTransition(nodeOrRef: string | VNode.Node, mode: "enter" | "leave", name?: string, callBack?: Function, type?: "transition" | "animation"): void;
86
- /**
87
- * 销毁
88
- */
89
- $destroy(force?: boolean): void;
90
- /**
91
- * VNode ref索引集
92
- */
93
- get $refs(): Readonly<Record<string, Array<VNode.Node>>>;
94
- /**
95
- * 根据ref获取单个VNode
96
- */
97
- $getRef<T extends VNode.Node>(ref: string): T | undefined;
98
- /**
99
- * 获取相同ref的VNode集合
100
- */
101
- $getRefs<T extends VNode.Node>(ref: string): Array<T> | undefined;
102
- /**
103
- * 单向同步prop值,并监听变更后重新同步
104
- * @param propKey 需要观察同步的props key
105
- * @param modelKey 要赋值的model key,不传案prop key 进行赋值
106
- * @param convertVal 值转换方法
107
- */
108
- $syncProp(propKey: keyof T): void;
109
- $syncProp(propKey: keyof T, modelKey: string): void;
110
- $syncProp(propKey: keyof T, convertVal: (val: any) => any): void;
111
- $syncProp(propKey: keyof T, modelKey: string, convertVal: (val: any) => any): void;
112
- /**
113
- * 根节点(虚拟DOM)
114
- */
115
- get $rootVNode(): Readonly<VNode.Root> | undefined;
116
- /**
117
- * 添加节点变更监听
118
- * @param ref ref标记
119
- * @param callBack
120
- * @returns 销毁方法
121
- */
122
- $watchNode(ref: string, callBack: (node: VNode.Node, type: NodeChangeType, property?: string) => void): (() => void) | undefined;
123
- /**
124
- * 观察值变更
125
- * @param express
126
- * @param callBack
127
- * @returns 销毁watcher
128
- */
129
- $watch(express: () => any, callBack: (nv?: any, ov?: any) => void): () => void;
130
- /**
131
- * 事件注册
132
- * @param eventName
133
- * @param callBack
134
- */
135
- $on(eventName: string, callBack: VNode.EventCallBack): void;
136
- /**
137
- * 事件卸载
138
- * @param eventName
139
- * @param callBack
140
- */
141
- $off(eventName: string, callBack?: VNode.EventCallBack): void;
142
- /**
143
- * 触发事件
144
- * @param eventName 事件名称
145
- * @param param 参数
146
- * @param targetEvent event
147
- */
148
- $trigger(eventName: string, param?: any, targetEvent?: VNode.Event): void;
149
- /**
150
- * 主动渲染(仅渲染,一般适用于模板区域的热更新使用/或动态装载等复杂场景)
151
- * @param newTemplate 可指定新的模板,否则按照原模板
152
- * @param keepalive 渲染新模板时,是否要保留之前的存活组件(高级用法)
153
- * @returns
154
- */
155
- $render(newTemplate?: TemplateType, keepalive?: boolean): void;
156
- /**
157
- * 生命周期函数(完成初始化)
158
- */
159
- protected created(): void;
160
- /**
161
- * 生命周期函数(完成挂载)
162
- */
163
- protected mounted(): void;
164
- /**
165
- * 生命周期函数(销毁前)
166
- */
167
- protected beforeDestroy(): void;
168
- /**
169
- * 睡眠时,在启用keepalive属性时才会触发该周期
170
- */
171
- protected sleeped(): void;
172
- /**
173
- * 唤醒时,在启用keepalive属性时才会触发该周期
174
- */
175
- protected wakeup(): void;
176
- /**
177
- * 生命周期函数(销毁后)
178
- */
179
- protected destroyed(): void;
180
- }
181
- /**
182
- * 注册全局组件
183
- * @param componentsOrName 组件名/列表
184
- * @param component 组件
185
- */
186
- export declare function registerGlobalComponent(componentsOrName: Record<string, ComponentConstructor> | string, component?: ComponentConstructor): void;
187
- /**
188
- * 根据注册key获取组件
189
- * @param name 组件名称
190
- * @returns 组件
191
- */
192
- export declare function getGlobalComponent(key: string): ComponentConstructor | undefined;
193
- /**
194
- * 动态组件容器
195
- */
196
- export declare class ComponentContainer extends Component<{
197
- [key: string]: any;
198
- name: string;
199
- "transition-name": string;
200
- }> {
201
- template: never[];
202
- private cache;
203
- mounted(): void;
204
- private propsVaule;
205
- created(): void;
206
- loadComponent(componentName?: string): Promise<void>;
207
- beforeDestroy(): void;
208
- removeCache(componentName?: string): void;
209
- }
210
- /**
211
- * 虚拟模板容器,用于进行归组,作为组件配置属性
212
- */
213
- export declare class Template extends Component {
214
- template: () => AST.Command[];
215
- }
216
- export {};
@@ -1,15 +0,0 @@
1
- export type EventCallBackItem = {
2
- callBack: EventCallBackType;
3
- once?: Boolean;
4
- };
5
- export type EventCallBackType = (e: {
6
- stopPropagation: Function;
7
- callTimes: Number;
8
- }, params?: any) => boolean | void;
9
- export declare class EventBus<T extends string> {
10
- private eventDatas;
11
- on(eventName: T, callBack: EventCallBackType): void;
12
- once(eventName: T, callBack: EventCallBackType): void;
13
- off(eventName: T, callBack?: EventCallBackType): void;
14
- trigger(eventName: T, param?: any): false | undefined;
15
- }
@@ -1,13 +0,0 @@
1
- export type GlobalFilter = (...args: any[]) => string | void | undefined;
2
- export declare const globalFilters: Record<string, GlobalFilter>;
3
- /**
4
- * 注册全局组件
5
- * @param components 组件
6
- */
7
- export declare function registerGlobalFilter(filters: Record<string, GlobalFilter>): void;
8
- /**
9
- * 根据注册key获取组件
10
- * @param name 组件名称
11
- * @returns 组件
12
- */
13
- export declare function getGlobalFilter(key: string): GlobalFilter | undefined;
@@ -1,15 +0,0 @@
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
- };
@@ -1,10 +0,0 @@
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";
@@ -1,46 +0,0 @@
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;
@@ -1,46 +0,0 @@
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;
@@ -1,46 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- import { AST } from "@joker.front/ast";
2
- import { IParser } from "../parser";
3
- import { VNode } from "../vnode";
4
- export declare class ParserCode extends IParser<AST.PropertyOrFunctionCommand, VNode.Text | VNode.Html> {
5
- parser(): void;
6
- }
@@ -1,22 +0,0 @@
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
- }
@@ -1,23 +0,0 @@
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
- }
@@ -1,8 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- import { AST } from "@joker.front/ast";
2
- import { IParser } from "./parser";
3
- import { VNode } from "./vnode";
4
- export declare class ParserComment extends IParser<AST.Comment, VNode.Comment> {
5
- parser(): void;
6
- }
@@ -1,23 +0,0 @@
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
- }
@@ -1,9 +0,0 @@
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
- }
@@ -1,77 +0,0 @@
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;
@@ -1,82 +0,0 @@
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
- }
@@ -1,86 +0,0 @@
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 {};
@@ -1,6 +0,0 @@
1
- import { AST } from "@joker.front/ast";
2
- import { IParser } from "./parser";
3
- import { VNode } from "./vnode";
4
- export declare class ParserText extends IParser<AST.Text, VNode.Text> {
5
- parser(): void;
6
- }
@@ -1,182 +0,0 @@
1
- import { AST, IComponent } from "@joker.front/ast";
2
- import { Component as ComponentClass } from "../component";
3
- import { ObType } from ".";
4
- import { SectionType } from "../component";
5
- import { IParser } from "./parser";
6
- /**
7
- * 虚拟DOM
8
- *
9
- * 该控件分类区别于AST,分类是按照实际输出类型作为划分
10
- */
11
- export declare namespace VNode {
12
- const PARSERKEY: unique symbol;
13
- /**
14
- * VNode 基类
15
- */
16
- class Node {
17
- parent?: Node | undefined;
18
- /**
19
- * 是否是静态节点,非动态节点。例如:element、text、comment等
20
- */
21
- static?: boolean;
22
- output?: any;
23
- [PARSERKEY]?: IParser<AST.Node, VNode.Node>;
24
- childrens?: Node[];
25
- /**
26
- * 当前节点是否睡眠
27
- */
28
- sleep: boolean;
29
- constructor(parent?: Node | undefined);
30
- /**
31
- * 上一个节点
32
- */
33
- get prev(): Node | undefined;
34
- /**
35
- * 下一个节点
36
- */
37
- get next(): Node | undefined;
38
- /**
39
- * 匹配第一个符合要求的祖先元素
40
- * @param match
41
- * @param breakWhenVRoot 是否过滤到当前视图根时中断
42
- * @returns
43
- */
44
- closest<T extends VNode.Node = VNode.Node>(filter: (node: VNode.Node) => boolean | void, breakWhenVRoot?: boolean): T | undefined;
45
- /**
46
- * 返回所有匹配的子元素
47
- * @param filter 返回true则记录,返回false则跳过该元素的子集
48
- * @returns
49
- */
50
- find(filter: (node: VNode.Node) => boolean | void, childrens?: Array<VNode.Node>, _out?: Array<VNode.Node>): Array<VNode.Node>;
51
- /**
52
- * 是否包含
53
- * @param filter 返回true则记录,返回false则跳过该元素的子集
54
- * @returns
55
- */
56
- contains(filter: (node: VNode.Node) => boolean | void, childrens?: Array<VNode.Node>): boolean;
57
- }
58
- /**
59
- * 根节点
60
- */
61
- class Root<T extends IComponent = IComponent & Record<string, any>> extends Node {
62
- childrens: Node[];
63
- component: T;
64
- constructor();
65
- }
66
- /**
67
- * 文本类型节点
68
- */
69
- class Text extends Node {
70
- text: string;
71
- static: boolean;
72
- constructor(text: string, parent: Node);
73
- }
74
- /**
75
- * Html节点
76
- */
77
- class Html extends Node {
78
- html: string;
79
- static: boolean;
80
- constructor(html: string, parent: Node);
81
- }
82
- /**
83
- * 注释节点
84
- */
85
- class Comment extends Node {
86
- text: string;
87
- static: boolean;
88
- constructor(text: string, parent: Node);
89
- }
90
- /**
91
- * Element节点
92
- */
93
- class Element extends Node {
94
- tagName: string;
95
- static: boolean;
96
- attributes: Record<string, any>;
97
- transitionTimer?: number;
98
- childrens: Node[];
99
- events: Array<[string, {
100
- modifiers?: string[];
101
- callBack: EventCallBack;
102
- }]>;
103
- /**
104
- * 协助事件存储,用于存储辅助事件,例如outside等事件
105
- */
106
- _assistEventCache?: Array<[string, (e: any) => void]>;
107
- constructor(tagName: string, parent: Node);
108
- }
109
- type Event<T = undefined> = {
110
- /**
111
- * 事件名称
112
- */
113
- eventName: string;
114
- /**
115
- * 原生event,对应运行平台
116
- */
117
- event?: any;
118
- /** 触发事件目标元素 */
119
- target?: Node;
120
- /** 阻止默认事件 */
121
- preventDefault(): void;
122
- /** 阻止事件传播 */
123
- stopPropagation(): void;
124
- /** 参数 */
125
- data: T;
126
- };
127
- type EventCallBack<T = any> = (e: Event<T>) => void;
128
- /**
129
- * 组件节点
130
- */
131
- class Component<T extends IComponent = IComponent & Record<string, any>> extends Node {
132
- name?: string;
133
- transitionTimer?: number;
134
- component: T;
135
- events: Array<[string, {
136
- modifiers?: string[];
137
- callBack: EventCallBack;
138
- }]>;
139
- propValues: Record<string, any>;
140
- keepalive?: boolean;
141
- /**
142
- * 当前组件第一个element vnode
143
- */
144
- get firstElement(): Element | undefined;
145
- private findElement;
146
- }
147
- /**
148
- * 条件节点
149
- */
150
- class Condition extends Node {
151
- cmdName: AST.IfCommand["kind"];
152
- result: boolean;
153
- childrens: Node[];
154
- isShow: boolean;
155
- constructor(cmdName: AST.IfCommand["kind"], parent: Node);
156
- }
157
- /**
158
- * 列表节点,内部包含多组列表项
159
- */
160
- class List extends Node {
161
- childrens: ListItem[];
162
- }
163
- /**
164
- * 循环列表项
165
- */
166
- class ListItem extends Node {
167
- ob: ObType;
168
- childrens: Node[];
169
- constructor(ob: ObType, parent: VNode.Node);
170
- }
171
- /**
172
- * 插槽节点
173
- */
174
- class RenderSection extends Node {
175
- id: string;
176
- params: any[];
177
- section?: SectionType;
178
- childrens: Node[];
179
- ob?: ComponentClass & Record<string, any>;
180
- constructor(idOrSection: string | SectionType, parent: Node);
181
- }
182
- }
@@ -1,9 +0,0 @@
1
- export type PropValueType = String | ArrayConstructor | Number | Object | Function | Boolean;
2
- export type PropTypeFullModel = {
3
- type?: PropValueType | Array<PropValueType>;
4
- required?: Boolean;
5
- default?: any;
6
- validate?: (val: any) => Boolean;
7
- };
8
- export type PropType = PropValueType | Array<PropValueType> | PropTypeFullModel;
9
- export declare function getPropValue(propsData: Readonly<Record<string | symbol, any>>, key: string | symbol, propsType?: Record<string | symbol, any>): any;
@@ -1,15 +0,0 @@
1
- type Constructor<T = any> = new (...args: any[]) => T;
2
- /**
3
- * IOC依赖注入容器
4
- *
5
- * IOC依赖注入适用场景:
6
- * 内部已规划的API、Interface,需要在外部对其进行逻辑注入的场景
7
- * 区分于plugin,plugin是根据整体声明周期做的切面注入
8
- */
9
- export declare namespace IContainer {
10
- function bind<T>(tagId: symbol | string): {
11
- to: (target: Constructor<T>) => void;
12
- };
13
- function get<T>(tagId: symbol | string, ...params: any[]): T | undefined;
14
- }
15
- export {};