@aiot-toolkit/parser 2.0.5-beta.9 → 2.0.5-widget-provider-beta.2

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 (109) hide show
  1. package/README.md +11 -11
  2. package/lib/index.d.ts +1 -4
  3. package/lib/index.js +0 -27
  4. package/lib/utils/ParserUtil.js +15 -15
  5. package/lib/ux/config/ExtensionConfig.js +2 -2
  6. package/lib/ux/config/FeatureConfig.js +19 -19
  7. package/lib/ux/config/vela/ElementConfig.js +8 -0
  8. package/lib/ux/config/vela/StyleAttributeConfig.js +87 -87
  9. package/lib/ux/enum/StyleSelectorType.js +6 -6
  10. package/lib/ux/enum/TemplateNodeType.js +2 -2
  11. package/lib/ux/enum/android/StyleSelectorName.js +2 -2
  12. package/lib/ux/parser/ScriptParser.js +2 -2
  13. package/lib/ux/parser/StyleParser.js +62 -62
  14. package/lib/ux/parser/TemplateValueParser.js +49 -49
  15. package/lib/ux/parser/UxParser.js +11 -11
  16. package/lib/ux/translate/android/StyleToTypescript.js +51 -51
  17. package/lib/ux/translate/android/TemplateToTypescript.js +51 -51
  18. package/lib/ux/translate/android/UxToTypescript.js +14 -14
  19. package/lib/ux/translate/android/attributeTranslate/ForTranslate.js +17 -17
  20. package/lib/ux/translate/android/attributeTranslate/IfTranslate.js +9 -9
  21. package/lib/ux/translate/vela/ScriptToTypescript.js +13 -12
  22. package/lib/ux/translate/vela/StyleToTypescript.js +10 -10
  23. package/lib/ux/translate/vela/TemplateToTypescript.js +74 -74
  24. package/lib/ux/translate/vela/TranslateCache.js +2 -2
  25. package/lib/ux/translate/vela/UxToTypescript.js +6 -6
  26. package/lib/ux/translate/vela/VelaContext.js +2 -2
  27. package/lib/ux/translate/vela/plugins/e2e.js +61 -61
  28. package/lib/ux/translate/vela/protobuf/BinaryPlugin.js +172 -172
  29. package/lib/ux/translate/vela/protobuf/protobuf.js +235 -235
  30. package/lib/ux/translate/vela/protobuf/protobufControl.js +159 -159
  31. package/lib/ux/translate/vela/protobuf/vdom_pb.js +2374 -2374
  32. package/lib/ux/translate/vela/runtime/velaTestLibrary.js +104 -104
  33. package/lib/ux/translate/vela/utils/AttributeConfig.js +15 -15
  34. package/lib/ux/translate/vela/utils/ExtendedBoxStyle.js +38 -38
  35. package/lib/ux/translate/vela/utils/SourceMapUtil.d.ts +4 -0
  36. package/lib/ux/translate/vela/utils/SourceMapUtil.js +36 -30
  37. package/lib/ux/translate/vela/utils/TemplateUtil.d.ts +10 -8
  38. package/lib/ux/translate/vela/utils/TemplateUtil.js +206 -191
  39. package/lib/ux/translate/vela/wrap/CbTranslate.js +8 -8
  40. package/lib/ux/translate/vela/wrap/CfTranslate.js +14 -14
  41. package/lib/ux/translate/vela/wrap/CiTranslate.js +11 -11
  42. package/lib/ux/utils/BabelUtil.js +35 -35
  43. package/lib/ux/utils/ElementConfigUtil.js +24 -24
  44. package/lib/ux/utils/StyleMapUtil.js +26 -16
  45. package/lib/ux/utils/StyleUtil.js +165 -165
  46. package/lib/ux/utils/UxUtil.js +32 -32
  47. package/lib/ux/validate/ElementValidate.js +2 -2
  48. package/lib/ux/validate/UxFileValidate.js +2 -2
  49. package/package.json +4 -5
  50. package/lib/xts/XtsParser.d.ts +0 -20
  51. package/lib/xts/XtsParser.js +0 -86
  52. package/lib/xts/XtsToTypescript.d.ts +0 -69
  53. package/lib/xts/XtsToTypescript.js +0 -894
  54. package/lib/xts/config/CommonAttributeList.d.ts +0 -6
  55. package/lib/xts/config/CommonAttributeList.js +0 -17
  56. package/lib/xts/config/classCount.json +0 -38
  57. package/lib/xts/config/commonAttribute.json +0 -84
  58. package/lib/xts/config/componentList.d.ts +0 -56
  59. package/lib/xts/config/componentList.js +0 -9
  60. package/lib/xts/config/predefinedComponent.json +0 -91
  61. package/lib/xts/config/render.json +0 -31
  62. package/lib/xts/data/ElementType.d.ts +0 -6
  63. package/lib/xts/data/ElementType.js +0 -5
  64. package/lib/xts/data/element/CommentElement.d.ts +0 -16
  65. package/lib/xts/data/element/CommentElement.js +0 -26
  66. package/lib/xts/data/element/ElementBase.d.ts +0 -14
  67. package/lib/xts/data/element/ElementBase.js +0 -20
  68. package/lib/xts/data/element/ForElement.d.ts +0 -58
  69. package/lib/xts/data/element/ForElement.js +0 -81
  70. package/lib/xts/data/element/IfElement.d.ts +0 -55
  71. package/lib/xts/data/element/IfElement.js +0 -87
  72. package/lib/xts/data/element/NodeElement.d.ts +0 -39
  73. package/lib/xts/data/element/NodeElement.js +0 -86
  74. package/lib/xts/enum/AttributeType.d.ts +0 -31
  75. package/lib/xts/enum/AttributeType.js +0 -53
  76. package/lib/xts/enum/Framework.d.ts +0 -98
  77. package/lib/xts/enum/Framework.js +0 -107
  78. package/lib/xts/interface/IContext.d.ts +0 -11
  79. package/lib/xts/interface/IContext.js +0 -1
  80. package/lib/xts/interface/IElement.d.ts +0 -17
  81. package/lib/xts/interface/IElement.js +0 -5
  82. package/lib/xts/interface/IExpressNode.d.ts +0 -20
  83. package/lib/xts/interface/IExpressNode.js +0 -1
  84. package/lib/xts/interface/config/ICommon.d.ts +0 -23
  85. package/lib/xts/interface/config/ICommon.js +0 -5
  86. package/lib/xts/interface/config/IRenderNode.d.ts +0 -25
  87. package/lib/xts/interface/config/IRenderNode.js +0 -1
  88. package/lib/xts/interface/validate/IAttibuteValidate.d.ts +0 -8
  89. package/lib/xts/interface/validate/IAttibuteValidate.js +0 -1
  90. package/lib/xts/interface/validate/IComponentValidate.d.ts +0 -9
  91. package/lib/xts/interface/validate/IComponentValidate.js +0 -1
  92. package/lib/xts/interface/validate/IRenderValidate.d.ts +0 -10
  93. package/lib/xts/interface/validate/IRenderValidate.js +0 -1
  94. package/lib/xts/interface/validate/ISourceFileValidate.d.ts +0 -7
  95. package/lib/xts/interface/validate/ISourceFileValidate.js +0 -1
  96. package/lib/xts/utils/AttributeUtil.d.ts +0 -73
  97. package/lib/xts/utils/AttributeUtil.js +0 -206
  98. package/lib/xts/utils/TypeUtil.d.ts +0 -60
  99. package/lib/xts/utils/TypeUtil.js +0 -97
  100. package/lib/xts/utils/TypescriptUtil.d.ts +0 -42
  101. package/lib/xts/utils/TypescriptUtil.js +0 -128
  102. package/lib/xts/validate/AttibuteValidate.d.ts +0 -18
  103. package/lib/xts/validate/AttibuteValidate.js +0 -97
  104. package/lib/xts/validate/ComponentValidate.d.ts +0 -19
  105. package/lib/xts/validate/ComponentValidate.js +0 -90
  106. package/lib/xts/validate/RenderValidate.d.ts +0 -63
  107. package/lib/xts/validate/RenderValidate.js +0 -239
  108. package/lib/xts/validate/SourceFileValidate.d.ts +0 -10
  109. package/lib/xts/validate/SourceFileValidate.js +0 -43
@@ -1,6 +0,0 @@
1
- import { IAttributeExpression } from '../interface/config/ICommon';
2
- /**
3
- * 将属性配置文件转为目标格式
4
- */
5
- declare let CommonAttributeList: IAttributeExpression[];
6
- export default CommonAttributeList;
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _commonAttribute = _interopRequireDefault(require("./commonAttribute.json"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- /**
10
- * 将属性配置文件转为目标格式
11
- */
12
- let CommonAttributeList = [];
13
- const attibuteGroups = _commonAttribute.default.attributeGroups;
14
- attibuteGroups.map(item => {
15
- CommonAttributeList.push(...item.chilidren);
16
- });
17
- var _default = exports.default = CommonAttributeList;
@@ -1,38 +0,0 @@
1
- [
2
- {
3
- "name": "aspect.xts",
4
- "rule": [
5
- {
6
- "classDecorator": "parentClass",
7
- "value": "@parentClass(ViewAspect)",
8
- "keyword": "vaspect",
9
- "min": 1,
10
- "max": 1
11
- }
12
- ]
13
- },
14
- {
15
- "name": "app.xts",
16
- "rule": [
17
- {
18
- "classDecorator": "parentClass",
19
- "value": "@parentClass(App)",
20
- "keyword": "app",
21
- "min": 1,
22
- "max": 1
23
- }
24
- ]
25
- },
26
- {
27
- "name": ".*",
28
- "rule": [
29
- {
30
- "classDecorator": "parentClass",
31
- "value": "@parentClass(Component)",
32
- "keyword": "component",
33
- "min": 0,
34
- "max": 1
35
- }
36
- ]
37
- }
38
- ]
@@ -1,84 +0,0 @@
1
- {
2
- "name": "List Of Common Properties",
3
- "title": "通用属性清单",
4
- "desc": "目前属性可以分为目前属性可以分为:尺寸边距设置、位置设置 、Flex 布局、边框设置、背景设置、透明度设置、图形变换、文本样式设置、组件标识、显示控制、禁用控制、样式、transform操作",
5
- "attributeGroups": [
6
- {
7
- "groupName": "sizeSettings",
8
- "title": "尺寸边距设置",
9
- "chilidren": [
10
- {
11
- "name": "width",
12
- "type": [
13
- {
14
- "subType": "string",
15
- "subTypeDesc": "<length>:具体长度 | <percentage>:百分比"
16
- }
17
- ],
18
- "desc": "设置组件自身的宽度,缺省时使用元素自身内容需要的宽度。若子组件的宽大于父组件的宽,则会画出父组件的范围。"
19
- },
20
- {
21
- "name": "height",
22
- "desc": "设置组件自身的高度,缺省时使用元素自身内容需要的高度。若子组件的高大于父组件的高,则会画出父组件的范围。"
23
- },
24
- {
25
- "name": "padding",
26
- "type": [
27
- {
28
- "subType": "object",
29
- "chilidren": [
30
- {
31
- "name": "top",
32
- "type": "number",
33
- "desc": "<length>"
34
- },
35
- {
36
- "name": "right",
37
- "type": "number",
38
- "desc": "<length>"
39
- },
40
- {
41
- "name": "bottom",
42
- "type": "number",
43
- "desc": "<length>"
44
- },
45
- {
46
- "name": "left",
47
- "type": "number",
48
- "desc": "<length>"
49
- }
50
- ],
51
- "subTypeDesc": ""
52
- },
53
- {
54
- "subType": "number",
55
- "subTypeDesc": "<length>:百分比"
56
- }
57
- ],
58
- "defaultValue": "0",
59
- "desc": "设置内边距属性。"
60
- },
61
- {
62
- "name": "maxWidth",
63
- "type": [
64
- {
65
- "subType": "string",
66
- "subTypeDesc": "none"
67
- },
68
- {
69
- "subType": "number",
70
- "subTypeDesc": "<length> | <percentage>"
71
- }
72
- ],
73
- "defaultValue": "none",
74
- "desc": "指定元素的最大宽度。该属性不能为负值,默认值 none 表示不做限制,下同"
75
- }
76
- ]
77
- },
78
- {
79
- "groupName": "positionSettings",
80
- "title": "位置设置",
81
- "chilidren": []
82
- }
83
- ]
84
- }
@@ -1,56 +0,0 @@
1
- declare const _default: ({
2
- name: string;
3
- title: string;
4
- desc: string;
5
- attributeGroups: never[];
6
- eventGroups: {
7
- name: string;
8
- title: string;
9
- desc: string;
10
- }[];
11
- type?: undefined;
12
- methodGrops?: undefined;
13
- } | {
14
- name: string;
15
- title: string;
16
- desc: string;
17
- type: {
18
- subType: string;
19
- }[];
20
- attributeGroups: {
21
- name: string;
22
- }[];
23
- eventGroups: {
24
- name: string;
25
- title: string;
26
- desc: string;
27
- }[];
28
- methodGrops: {
29
- name: string;
30
- type: {
31
- subType: string;
32
- children: {
33
- name: string;
34
- type: string;
35
- }[];
36
- }[];
37
- defaultValue: boolean;
38
- desc: string;
39
- }[];
40
- } | {
41
- name: string;
42
- type: {
43
- subType: string;
44
- }[];
45
- attributeGroups: {
46
- name: string;
47
- type: {
48
- subType: string;
49
- }[];
50
- }[];
51
- title?: undefined;
52
- desc?: undefined;
53
- eventGroups?: undefined;
54
- methodGrops?: undefined;
55
- })[];
56
- export default _default;
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _predefinedComponent = _interopRequireDefault(require("./predefinedComponent.json"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- var _default = exports.default = _predefinedComponent.default.componentGroups;
@@ -1,91 +0,0 @@
1
- {
2
- "name": "Common componentList",
3
- "title": "通用组件",
4
- "desc": "无论是 预定义组件(通用组件) 或者 自定义组件(业务组件) 都具备组件本质所包含的三个性质扩展性、通用性、健壮性。",
5
- "componentGroups": [
6
- {
7
- "name": "Row",
8
- "title": "Row组件",
9
- "desc": "沿水平方向布局容器。",
10
- "attributeGroups": [],
11
- "eventGroups": [
12
- {
13
- "name": "",
14
- "title": "事件",
15
- "desc": "通用事件"
16
- }
17
- ]
18
- },
19
- {
20
- "name": "Column",
21
- "title": "Column组件",
22
- "desc": "沿垂直方向布局的容器。",
23
- "attributeGroups": [],
24
- "eventGroups": [
25
- {
26
- "name": "",
27
- "title": "事件",
28
- "desc": "通用事件"
29
- }
30
- ]
31
- },
32
- {
33
- "name": "Button",
34
- "title": "Button组件",
35
- "desc": "按钮组件。",
36
- "type": [
37
- {
38
- "subType": "string"
39
- }
40
- ],
41
- "attributeGroups": [
42
- {
43
- "name": "disabled"
44
- }
45
- ],
46
- "eventGroups": [
47
- {
48
- "name": "",
49
- "title": "事件",
50
- "desc": "通用事件"
51
- }
52
- ],
53
- "methodGrops": [
54
- {
55
- "name": "focus",
56
- "type": [
57
- {
58
- "subType": "object",
59
- "children": [
60
- {
61
- "name": "focus",
62
- "type": "boolean"
63
- }
64
- ]
65
- }
66
- ],
67
- "defaultValue": true,
68
- "desc": "使组件获得或者失去焦点,可触发 focus 伪类(focus 伪类样式还未支持)"
69
- }
70
- ]
71
- },
72
- {
73
- "name": "Text",
74
- "type": [
75
- {
76
- "subType": "string"
77
- }
78
- ],
79
- "attributeGroups": [
80
- {
81
- "name": "fontSize",
82
- "type": [
83
- {
84
- "subType": "string"
85
- }
86
- ]
87
- }
88
- ]
89
- }
90
- ]
91
- }
@@ -1,31 +0,0 @@
1
- [
2
- {
3
- "name": "this.",
4
- "rule": [
5
- {
6
- "decorator": "@Renderer"
7
- }
8
- ]
9
- },
10
- {
11
- "name": "ForEach",
12
- "rule": [
13
- {
14
- "paramIndex": 0,
15
- "type": "PropertyAccessExpression",
16
- "desc": "必须是数组,允许设置为空数组,空数组场景下将不会创建子组件。"
17
- },
18
- {
19
- "paramIndex": 1,
20
- "type": "ArrowFunction",
21
- "desc": "生成子组件的lambda函数,为数组中的每一个数据项创建一个或多个子组件,单个子组件或子组件列表必须包括在大括号“{...}”中。"
22
- },
23
- {
24
- "paramIndex": 2,
25
- "type": "ArrowFunction",
26
- "isRequired": false,
27
- "desc": "匿名函数,用于给数组中的每一个数据项生成唯一且固定的键值。"
28
- }
29
- ]
30
- }
31
- ]
@@ -1,6 +0,0 @@
1
- import CommentElement from './element/CommentElement';
2
- import ForElement from './element/ForElement';
3
- import IfElement from './element/IfElement';
4
- import NodeElement from './element/NodeElement';
5
- type RenderElement = NodeElement | IfElement | ForElement | CommentElement;
6
- export { RenderElement };
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,16 +0,0 @@
1
- import { Node, ts } from 'ts-morph';
2
- import IContext from '../../interface/IContext';
3
- import { RenderElement } from '../ElementType';
4
- import ElementBase from './ElementBase';
5
- /**
6
- * CommentElement
7
- */
8
- declare class CommentElement extends ElementBase {
9
- node: Node<ts.Node>;
10
- static collect(context: IContext, nodeList: Node<ts.Node>[], startIndex: number): {
11
- element: RenderElement;
12
- offset: number;
13
- };
14
- static match(node: Node<ts.Node>): boolean;
15
- }
16
- export default CommentElement;
@@ -1,26 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _tsMorph = require("ts-morph");
8
- var _ElementBase = _interopRequireDefault(require("./ElementBase"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- /**
11
- * CommentElement
12
- */
13
- class CommentElement extends _ElementBase.default {
14
- static collect(context, nodeList, startIndex) {
15
- const element = new CommentElement();
16
- element.node = nodeList[startIndex];
17
- return {
18
- element,
19
- offset: 1
20
- };
21
- }
22
- static match(node) {
23
- return node instanceof _tsMorph.CommentStatement;
24
- }
25
- }
26
- var _default = exports.default = CommentElement;
@@ -1,14 +0,0 @@
1
- import { Node, ts } from 'ts-morph';
2
- import IContext from '../../interface/IContext';
3
- import { RenderElement } from '../ElementType';
4
- /**
5
- * ElementBase
6
- */
7
- declare abstract class ElementBase {
8
- static collect(context: IContext, nodeList: Node<ts.Node>[], startIndex: number, collectChildren: (nodeList: Node<ts.Node>[]) => RenderElement[]): {
9
- element: RenderElement;
10
- offset: number;
11
- };
12
- static match(node: Node<ts.Node>): boolean;
13
- }
14
- export default ElementBase;
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /* eslint-disable */
8
-
9
- /**
10
- * ElementBase
11
- */
12
- class ElementBase {
13
- static collect(context, nodeList, startIndex, collectChildren) {
14
- throw new Error('Subclasses must implement staticFunction `collect`.');
15
- }
16
- static match(node) {
17
- throw new Error('Subclasses must implement staticFunction `match`.');
18
- }
19
- }
20
- var _default = exports.default = ElementBase;
@@ -1,58 +0,0 @@
1
- import { ArrowFunction, Identifier, Node, ts } from 'ts-morph';
2
- import IContext from '../../interface/IContext';
3
- import { RenderElement } from '../ElementType';
4
- import ElementBase from './ElementBase';
5
- /**
6
- * ForElement
7
- * @description 示例源码
8
- * ```js
9
- * ForEach(
10
- * arr, // 循环对象
11
- * (item, index)=>{}, // 渲染函数
12
- * (item, index)=>{} // key 函数
13
- * )
14
- * ```
15
- */
16
- declare class ForElement extends ElementBase {
17
- /**
18
- * 采集对象
19
- */
20
- target: Identifier;
21
- /**
22
- * 生成 key 的函数
23
- */
24
- keyFunction?: ArrowFunction;
25
- /**
26
- * 渲染参数列表
27
- */
28
- renderArguments?: Node<ts.Node>[];
29
- /**
30
- * 渲染元素列表
31
- */
32
- renderElementList?: RenderElement[];
33
- /**
34
- * 采集 for 元素
35
- *
36
- * @description 源码如下,采集为1个 forElement
37
- * ```js
38
- * ForEach(arr, (item, index)=>{}, (item, index)=>item.key)
39
- * ```
40
- *
41
- * ### 采集步骤
42
- * 1. 第1个参数作为循环目标: target
43
- * 2. 第2个参数作为 render函数,基参数为 renderArguments、其函数体子元素为 renderElementList
44
- * 3. 第3个参数作为生成 key 的函数 keyFunction
45
- *
46
- * @param context
47
- * @param nodeList
48
- * @param startIndex
49
- * @param collectChildren
50
- * @returns
51
- */
52
- static collect(context: IContext, nodeList: Node<ts.Node>[], startIndex: number, collectChildren: (nodeList: Node<ts.Node>[]) => RenderElement[]): {
53
- element: RenderElement;
54
- offset: number;
55
- };
56
- static match(node: Node<ts.Node>): boolean;
57
- }
58
- export default ForElement;
@@ -1,81 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _TypescriptUtil = _interopRequireDefault(require("../../utils/TypescriptUtil"));
8
- var _RenderValidate = _interopRequireDefault(require("../../validate/RenderValidate"));
9
- var _ElementBase = _interopRequireDefault(require("./ElementBase"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- /**
12
- * ForElement
13
- * @description 示例源码
14
- * ```js
15
- * ForEach(
16
- * arr, // 循环对象
17
- * (item, index)=>{}, // 渲染函数
18
- * (item, index)=>{} // key 函数
19
- * )
20
- * ```
21
- */
22
- class ForElement extends _ElementBase.default {
23
- /**
24
- * 采集对象
25
- */
26
-
27
- /**
28
- * 生成 key 的函数
29
- */
30
-
31
- /**
32
- * 渲染参数列表
33
- */
34
-
35
- /**
36
- * 渲染元素列表
37
- */
38
-
39
- /**
40
- * 采集 for 元素
41
- *
42
- * @description 源码如下,采集为1个 forElement
43
- * ```js
44
- * ForEach(arr, (item, index)=>{}, (item, index)=>item.key)
45
- * ```
46
- *
47
- * ### 采集步骤
48
- * 1. 第1个参数作为循环目标: target
49
- * 2. 第2个参数作为 render函数,基参数为 renderArguments、其函数体子元素为 renderElementList
50
- * 3. 第3个参数作为生成 key 的函数 keyFunction
51
- *
52
- * @param context
53
- * @param nodeList
54
- * @param startIndex
55
- * @param collectChildren
56
- * @returns
57
- */
58
- static collect(context, nodeList, startIndex, collectChildren) {
59
- const callFunction = nodeList[startIndex].getExpression();
60
- const argumentList = callFunction.getArguments();
61
- // ForEach参数检查
62
- new _RenderValidate.default().validateForEach(context, nodeList[startIndex], argumentList);
63
- const element = new ForElement();
64
- element.target = argumentList[0];
65
- const renderFunction = argumentList[1];
66
- element.renderArguments = renderFunction.getParameters();
67
- element.keyFunction = argumentList[2];
68
- const children = _TypescriptUtil.default.getBlockChildren(renderFunction.getBody());
69
- if (children && children.length) {
70
- element.renderElementList = collectChildren(children);
71
- }
72
- return {
73
- element,
74
- offset: 1
75
- };
76
- }
77
- static match(node) {
78
- return new _RenderValidate.default().checkNodeIsForEach(node);
79
- }
80
- }
81
- var _default = exports.default = ForElement;
@@ -1,55 +0,0 @@
1
- import { Expression, Node, ts } from 'ts-morph';
2
- import IContext from '../../interface/IContext';
3
- import { RenderElement } from '../ElementType';
4
- import ElementBase from './ElementBase';
5
- /**
6
- * 表示 if else 的元素
7
- *
8
- * @description 示例源码
9
- * ```js
10
- * if(x){} // 1个 if
11
- * else if(){} // 任意个 else if
12
- * else {} // 1 或 n 个 else
13
- * ```
14
- */
15
- declare class IfElement extends ElementBase {
16
- /**
17
- * 元素列表
18
- */
19
- elements: RenderElement[];
20
- /**
21
- * 后续的 if else/else 元素
22
- */
23
- elseElement?: IfElement;
24
- /**
25
- * 条件表达式
26
- */
27
- expression?: Expression;
28
- constructor();
29
- get isElse(): boolean;
30
- static match(node: Node<ts.Node>): boolean;
31
- static collect(context: IContext, nodeList: Node<ts.Node>[], startIndex: number, collectChildren: (nodeList: Node<ts.Node>[]) => RenderElement[]): {
32
- element: IfElement;
33
- offset: number;
34
- };
35
- /**
36
- * if else转换为 ifElement
37
- *
38
- * @description 源码如下,转换为**1**个 IfElement
39
- * ```js
40
- * if(x){ Row1() }
41
- * else if(y) { Row2() }
42
- * else { Row3() }
43
- * ```
44
- *
45
- * 转换过程为:
46
- * 1. 检查元素是否为 else
47
- * 2. 如果是 else, 则获取 else 中的元素--Row3()
48
- * 3. 否则,获取: a. if 的条件表达式、b. if 自身的元素--Row1()、c. 递归获取后续的 else 或 if else
49
- * @param statement
50
- * @param collectChildren
51
- * @returns
52
- */
53
- private static ifStatementToIfElement;
54
- }
55
- export default IfElement;