@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.
- package/README.md +11 -11
- package/lib/index.d.ts +1 -4
- package/lib/index.js +0 -27
- package/lib/utils/ParserUtil.js +15 -15
- package/lib/ux/config/ExtensionConfig.js +2 -2
- package/lib/ux/config/FeatureConfig.js +19 -19
- package/lib/ux/config/vela/ElementConfig.js +8 -0
- package/lib/ux/config/vela/StyleAttributeConfig.js +87 -87
- package/lib/ux/enum/StyleSelectorType.js +6 -6
- package/lib/ux/enum/TemplateNodeType.js +2 -2
- package/lib/ux/enum/android/StyleSelectorName.js +2 -2
- package/lib/ux/parser/ScriptParser.js +2 -2
- package/lib/ux/parser/StyleParser.js +62 -62
- package/lib/ux/parser/TemplateValueParser.js +49 -49
- package/lib/ux/parser/UxParser.js +11 -11
- package/lib/ux/translate/android/StyleToTypescript.js +51 -51
- package/lib/ux/translate/android/TemplateToTypescript.js +51 -51
- package/lib/ux/translate/android/UxToTypescript.js +14 -14
- package/lib/ux/translate/android/attributeTranslate/ForTranslate.js +17 -17
- package/lib/ux/translate/android/attributeTranslate/IfTranslate.js +9 -9
- package/lib/ux/translate/vela/ScriptToTypescript.js +13 -12
- package/lib/ux/translate/vela/StyleToTypescript.js +10 -10
- package/lib/ux/translate/vela/TemplateToTypescript.js +74 -74
- package/lib/ux/translate/vela/TranslateCache.js +2 -2
- package/lib/ux/translate/vela/UxToTypescript.js +6 -6
- package/lib/ux/translate/vela/VelaContext.js +2 -2
- package/lib/ux/translate/vela/plugins/e2e.js +61 -61
- package/lib/ux/translate/vela/protobuf/BinaryPlugin.js +172 -172
- package/lib/ux/translate/vela/protobuf/protobuf.js +235 -235
- package/lib/ux/translate/vela/protobuf/protobufControl.js +159 -159
- package/lib/ux/translate/vela/protobuf/vdom_pb.js +2374 -2374
- package/lib/ux/translate/vela/runtime/velaTestLibrary.js +104 -104
- package/lib/ux/translate/vela/utils/AttributeConfig.js +15 -15
- package/lib/ux/translate/vela/utils/ExtendedBoxStyle.js +38 -38
- package/lib/ux/translate/vela/utils/SourceMapUtil.d.ts +4 -0
- package/lib/ux/translate/vela/utils/SourceMapUtil.js +36 -30
- package/lib/ux/translate/vela/utils/TemplateUtil.d.ts +10 -8
- package/lib/ux/translate/vela/utils/TemplateUtil.js +206 -191
- package/lib/ux/translate/vela/wrap/CbTranslate.js +8 -8
- package/lib/ux/translate/vela/wrap/CfTranslate.js +14 -14
- package/lib/ux/translate/vela/wrap/CiTranslate.js +11 -11
- package/lib/ux/utils/BabelUtil.js +35 -35
- package/lib/ux/utils/ElementConfigUtil.js +24 -24
- package/lib/ux/utils/StyleMapUtil.js +26 -16
- package/lib/ux/utils/StyleUtil.js +165 -165
- package/lib/ux/utils/UxUtil.js +32 -32
- package/lib/ux/validate/ElementValidate.js +2 -2
- package/lib/ux/validate/UxFileValidate.js +2 -2
- package/package.json +4 -5
- package/lib/xts/XtsParser.d.ts +0 -20
- package/lib/xts/XtsParser.js +0 -86
- package/lib/xts/XtsToTypescript.d.ts +0 -69
- package/lib/xts/XtsToTypescript.js +0 -894
- package/lib/xts/config/CommonAttributeList.d.ts +0 -6
- package/lib/xts/config/CommonAttributeList.js +0 -17
- package/lib/xts/config/classCount.json +0 -38
- package/lib/xts/config/commonAttribute.json +0 -84
- package/lib/xts/config/componentList.d.ts +0 -56
- package/lib/xts/config/componentList.js +0 -9
- package/lib/xts/config/predefinedComponent.json +0 -91
- package/lib/xts/config/render.json +0 -31
- package/lib/xts/data/ElementType.d.ts +0 -6
- package/lib/xts/data/ElementType.js +0 -5
- package/lib/xts/data/element/CommentElement.d.ts +0 -16
- package/lib/xts/data/element/CommentElement.js +0 -26
- package/lib/xts/data/element/ElementBase.d.ts +0 -14
- package/lib/xts/data/element/ElementBase.js +0 -20
- package/lib/xts/data/element/ForElement.d.ts +0 -58
- package/lib/xts/data/element/ForElement.js +0 -81
- package/lib/xts/data/element/IfElement.d.ts +0 -55
- package/lib/xts/data/element/IfElement.js +0 -87
- package/lib/xts/data/element/NodeElement.d.ts +0 -39
- package/lib/xts/data/element/NodeElement.js +0 -86
- package/lib/xts/enum/AttributeType.d.ts +0 -31
- package/lib/xts/enum/AttributeType.js +0 -53
- package/lib/xts/enum/Framework.d.ts +0 -98
- package/lib/xts/enum/Framework.js +0 -107
- package/lib/xts/interface/IContext.d.ts +0 -11
- package/lib/xts/interface/IContext.js +0 -1
- package/lib/xts/interface/IElement.d.ts +0 -17
- package/lib/xts/interface/IElement.js +0 -5
- package/lib/xts/interface/IExpressNode.d.ts +0 -20
- package/lib/xts/interface/IExpressNode.js +0 -1
- package/lib/xts/interface/config/ICommon.d.ts +0 -23
- package/lib/xts/interface/config/ICommon.js +0 -5
- package/lib/xts/interface/config/IRenderNode.d.ts +0 -25
- package/lib/xts/interface/config/IRenderNode.js +0 -1
- package/lib/xts/interface/validate/IAttibuteValidate.d.ts +0 -8
- package/lib/xts/interface/validate/IAttibuteValidate.js +0 -1
- package/lib/xts/interface/validate/IComponentValidate.d.ts +0 -9
- package/lib/xts/interface/validate/IComponentValidate.js +0 -1
- package/lib/xts/interface/validate/IRenderValidate.d.ts +0 -10
- package/lib/xts/interface/validate/IRenderValidate.js +0 -1
- package/lib/xts/interface/validate/ISourceFileValidate.d.ts +0 -7
- package/lib/xts/interface/validate/ISourceFileValidate.js +0 -1
- package/lib/xts/utils/AttributeUtil.d.ts +0 -73
- package/lib/xts/utils/AttributeUtil.js +0 -206
- package/lib/xts/utils/TypeUtil.d.ts +0 -60
- package/lib/xts/utils/TypeUtil.js +0 -97
- package/lib/xts/utils/TypescriptUtil.d.ts +0 -42
- package/lib/xts/utils/TypescriptUtil.js +0 -128
- package/lib/xts/validate/AttibuteValidate.d.ts +0 -18
- package/lib/xts/validate/AttibuteValidate.js +0 -97
- package/lib/xts/validate/ComponentValidate.d.ts +0 -19
- package/lib/xts/validate/ComponentValidate.js +0 -90
- package/lib/xts/validate/RenderValidate.d.ts +0 -63
- package/lib/xts/validate/RenderValidate.js +0 -239
- package/lib/xts/validate/SourceFileValidate.d.ts +0 -10
- package/lib/xts/validate/SourceFileValidate.js +0 -43
|
@@ -11,8 +11,8 @@ var _TemplateUtil = _interopRequireDefault(require("../../vela/utils/TemplateUti
|
|
|
11
11
|
var _CfTranslate = _interopRequireDefault(require("../../vela/wrap/CfTranslate"));
|
|
12
12
|
var _AndroidContext = _interopRequireDefault(require("../AndroidContext"));
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
/**
|
|
15
|
-
* ForTranslate
|
|
14
|
+
/**
|
|
15
|
+
* ForTranslate
|
|
16
16
|
*/
|
|
17
17
|
class ForTranslate {
|
|
18
18
|
KEY = 'for';
|
|
@@ -25,21 +25,21 @@ class ForTranslate {
|
|
|
25
25
|
return Boolean(_TemplateUtil.default.getAttribute(node, this.KEY));
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
* 转换 for 节点
|
|
30
|
-
* 1. 只有 list,生成
|
|
31
|
-
* ```
|
|
32
|
-
* { repeat:function }
|
|
33
|
-
* ```
|
|
34
|
-
* 2. 有index、 item中的任意一项,生成
|
|
35
|
-
* ```json
|
|
36
|
-
* repeat: {
|
|
37
|
-
* exp: function,
|
|
38
|
-
* key: index,
|
|
39
|
-
* value: item
|
|
40
|
-
* }
|
|
41
|
-
* ```
|
|
42
|
-
* @param node
|
|
28
|
+
/**
|
|
29
|
+
* 转换 for 节点
|
|
30
|
+
* 1. 只有 list,生成
|
|
31
|
+
* ```
|
|
32
|
+
* { repeat:function }
|
|
33
|
+
* ```
|
|
34
|
+
* 2. 有index、 item中的任意一项,生成
|
|
35
|
+
* ```json
|
|
36
|
+
* repeat: {
|
|
37
|
+
* exp: function,
|
|
38
|
+
* key: index,
|
|
39
|
+
* value: item
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
* @param node
|
|
43
43
|
*/
|
|
44
44
|
async translate(node) {
|
|
45
45
|
const {
|
|
@@ -9,8 +9,8 @@ var _ElementConfigUtil = _interopRequireDefault(require("../../../utils/ElementC
|
|
|
9
9
|
var _TemplateUtil = _interopRequireDefault(require("../../vela/utils/TemplateUtil"));
|
|
10
10
|
var _AndroidContext = _interopRequireDefault(require("../AndroidContext"));
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
/**
|
|
13
|
-
* IfTranslate
|
|
12
|
+
/**
|
|
13
|
+
* IfTranslate
|
|
14
14
|
*/
|
|
15
15
|
class IfTranslate {
|
|
16
16
|
KEY_LIST = ['if', 'elif', 'else'];
|
|
@@ -23,13 +23,13 @@ class IfTranslate {
|
|
|
23
23
|
return this.KEY_LIST.some(item => _TemplateUtil.default.getAttribute(node, item));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* 1. 获取条件列表,节点的条件 = 前置条件取反 && 当前节点自身条件
|
|
30
|
-
* 2. 返回 {show:Function}
|
|
31
|
-
* @param node
|
|
32
|
-
* @param identifiers
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
*
|
|
29
|
+
* 1. 获取条件列表,节点的条件 = 前置条件取反 && 当前节点自身条件
|
|
30
|
+
* 2. 返回 {show:Function}
|
|
31
|
+
* @param node
|
|
32
|
+
* @param identifiers
|
|
33
33
|
*/
|
|
34
34
|
async translate(node, identifiers) {
|
|
35
35
|
const conditions = this.templateUtil.getIfCoditionList(node);
|
|
@@ -15,8 +15,8 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
15
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
16
|
const BabelPreset = require('@babel/preset-env');
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* ScriptToTypescript
|
|
18
|
+
/**
|
|
19
|
+
* ScriptToTypescript
|
|
20
20
|
*/
|
|
21
21
|
class ScriptToTypescript {
|
|
22
22
|
_systemFeatures = (() => new Set())();
|
|
@@ -45,10 +45,10 @@ class ScriptToTypescript {
|
|
|
45
45
|
mapList: []
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
/**
|
|
49
|
-
* babel自定义插件实现替换
|
|
50
|
-
* @param sourceCode
|
|
51
|
-
* @returns
|
|
48
|
+
/**
|
|
49
|
+
* babel自定义插件实现替换
|
|
50
|
+
* @param sourceCode
|
|
51
|
+
* @returns
|
|
52
52
|
*/
|
|
53
53
|
babelScript(sourceTree) {
|
|
54
54
|
const sourceCode = sourceTree.content ? sourceTree.content : `""`;
|
|
@@ -132,8 +132,8 @@ class ScriptToTypescript {
|
|
|
132
132
|
return '';
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
/**
|
|
136
|
-
* 缓存并检查 feature
|
|
135
|
+
/**
|
|
136
|
+
* 缓存并检查 feature
|
|
137
137
|
*/
|
|
138
138
|
cacheAndCheckFeature() {
|
|
139
139
|
const {
|
|
@@ -160,8 +160,8 @@ class ScriptToTypescript {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
/**
|
|
164
|
-
* 检查代码
|
|
163
|
+
/**
|
|
164
|
+
* 检查代码
|
|
165
165
|
*/
|
|
166
166
|
async checkCode(sourceTree) {
|
|
167
167
|
const code = sourceTree.content;
|
|
@@ -182,8 +182,9 @@ class ScriptToTypescript {
|
|
|
182
182
|
},
|
|
183
183
|
rules: {
|
|
184
184
|
'*': 'off',
|
|
185
|
-
|
|
186
|
-
'no-
|
|
185
|
+
'no-undef': 'error',
|
|
186
|
+
'no-unused-vars': 'warn',
|
|
187
|
+
'max-lines-per-function': ['warn', 500]
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
}).lintText(code);
|
|
@@ -9,8 +9,8 @@ var _StyleSelectorType = require("../../enum/StyleSelectorType");
|
|
|
9
9
|
var _StyleUtil = _interopRequireDefault(require("../../utils/StyleUtil"));
|
|
10
10
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
/**
|
|
13
|
-
* StyleToTypescript
|
|
12
|
+
/**
|
|
13
|
+
* StyleToTypescript
|
|
14
14
|
*/
|
|
15
15
|
class StyleToTypescript {
|
|
16
16
|
constructor(options, compilerOption) {
|
|
@@ -125,10 +125,10 @@ class StyleToTypescript {
|
|
|
125
125
|
});
|
|
126
126
|
return targetNodeList;
|
|
127
127
|
}
|
|
128
|
-
/**
|
|
129
|
-
* 选择器类型报错,添加thorwLog
|
|
130
|
-
* @param type
|
|
131
|
-
* @param name
|
|
128
|
+
/**
|
|
129
|
+
* 选择器类型报错,添加thorwLog
|
|
130
|
+
* @param type
|
|
131
|
+
* @param name
|
|
132
132
|
*/
|
|
133
133
|
addThorwLog(type, name, position, info) {
|
|
134
134
|
const {
|
|
@@ -266,10 +266,10 @@ class StyleToTypescript {
|
|
|
266
266
|
}]);
|
|
267
267
|
return targetNodes;
|
|
268
268
|
}
|
|
269
|
-
/**
|
|
270
|
-
* vela快应用:按照运行时要求,只补全第一个MediaQuery节点缺少的媒体类型
|
|
271
|
-
* @param sourceNodes
|
|
272
|
-
* @returns
|
|
269
|
+
/**
|
|
270
|
+
* vela快应用:按照运行时要求,只补全第一个MediaQuery节点缺少的媒体类型
|
|
271
|
+
* @param sourceNodes
|
|
272
|
+
* @returns
|
|
273
273
|
*/
|
|
274
274
|
translateMediaPrelude(sourceNodes) {
|
|
275
275
|
const firstMediaQuery = sourceNodes[0];
|
|
@@ -17,8 +17,8 @@ var _CiTranslate = _interopRequireDefault(require("./wrap/CiTranslate"));
|
|
|
17
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
18
|
const STATIC_NAME = 'static';
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* TemplateToTypescript
|
|
20
|
+
/**
|
|
21
|
+
* TemplateToTypescript
|
|
22
22
|
*/
|
|
23
23
|
class TemplateToTypescript {
|
|
24
24
|
project = (() => new _tsMorph.Project({
|
|
@@ -29,9 +29,9 @@ class TemplateToTypescript {
|
|
|
29
29
|
}))();
|
|
30
30
|
_mapList = [];
|
|
31
31
|
elementConfigUtil = (() => new _ElementConfigUtil.default(_ElementConfig.default))();
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* @param importList 组件列表
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param importList 组件列表
|
|
35
35
|
*/
|
|
36
36
|
constructor(options, compilerOption, importList) {
|
|
37
37
|
this.options = options;
|
|
@@ -40,13 +40,13 @@ class TemplateToTypescript {
|
|
|
40
40
|
this.templateUtil = new _TemplateUtil.default(_VelaContext.default, options, compilerOption, this.elementConfigUtil);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @param sourceTree
|
|
46
|
-
* @param offsetList
|
|
47
|
-
* @returns
|
|
48
|
-
*
|
|
49
|
-
* @see [解析流程](../doc/ux解析流程.md)
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param sourceTree
|
|
46
|
+
* @param offsetList
|
|
47
|
+
* @returns
|
|
48
|
+
*
|
|
49
|
+
* @see [解析流程](../doc/ux解析流程.md)
|
|
50
50
|
*/
|
|
51
51
|
async translate(sourceTree,
|
|
52
52
|
// eslint-disable-next-line
|
|
@@ -74,10 +74,10 @@ class TemplateToTypescript {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
/**
|
|
78
|
-
* 生成节点表达式
|
|
79
|
-
* @param node
|
|
80
|
-
* @returns
|
|
77
|
+
/**
|
|
78
|
+
* 生成节点表达式
|
|
79
|
+
* @param node
|
|
80
|
+
* @returns
|
|
81
81
|
*/
|
|
82
82
|
async createNodeExpression(node, identifiers) {
|
|
83
83
|
// 1. 获取所有属性,并提取数据
|
|
@@ -88,21 +88,21 @@ class TemplateToTypescript {
|
|
|
88
88
|
return await this.createElementWrap(node, elementExpression, infomation, identifiers);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
/**
|
|
92
|
-
* 预处理属性
|
|
93
|
-
* 1. 特定元素和特定属性处理
|
|
94
|
-
* a. 允许设置文字的元素:如果子元素无节点元素, “文本子元素”做为 value 属性. 例如 `<Text>这里全是文字,没有带 tag 的节点</Text>`
|
|
95
|
-
* b. 特定元素的特定属性:如果是静态路径,加上 require
|
|
96
|
-
* 2. 去除特殊属性
|
|
97
|
-
* 3. 添加特殊属性
|
|
98
|
-
* a. 添加static: 存在static属性 && 存在动态属性
|
|
99
|
-
* 4. 属性拆分为属性名和修饰符, 并提取修饰符
|
|
100
|
-
a. static 修饰符:如果元素存在 static 属性,则排除全部属性的 static 修饰符
|
|
101
|
-
b. 特殊属性不生成修饰符:[if elif else]--修饰符生成到 ci 中; for-修饰符生成到 cf 中
|
|
102
|
-
c. 其它情况:生成对象 {[属性名]:{修饰符名:true}}
|
|
103
|
-
* 5. 事件、逻辑属性强制设置为动态属性
|
|
104
|
-
* @param node
|
|
105
|
-
* @returns
|
|
91
|
+
/**
|
|
92
|
+
* 预处理属性
|
|
93
|
+
* 1. 特定元素和特定属性处理
|
|
94
|
+
* a. 允许设置文字的元素:如果子元素无节点元素, “文本子元素”做为 value 属性. 例如 `<Text>这里全是文字,没有带 tag 的节点</Text>`
|
|
95
|
+
* b. 特定元素的特定属性:如果是静态路径,加上 require
|
|
96
|
+
* 2. 去除特殊属性
|
|
97
|
+
* 3. 添加特殊属性
|
|
98
|
+
* a. 添加static: 存在static属性 && 存在动态属性
|
|
99
|
+
* 4. 属性拆分为属性名和修饰符, 并提取修饰符
|
|
100
|
+
a. static 修饰符:如果元素存在 static 属性,则排除全部属性的 static 修饰符
|
|
101
|
+
b. 特殊属性不生成修饰符:[if elif else]--修饰符生成到 ci 中; for-修饰符生成到 cf 中
|
|
102
|
+
c. 其它情况:生成对象 {[属性名]:{修饰符名:true}}
|
|
103
|
+
* 5. 事件、逻辑属性强制设置为动态属性
|
|
104
|
+
* @param node
|
|
105
|
+
* @returns
|
|
106
106
|
*/
|
|
107
107
|
preprocessingProperties(node, extractionInformation) {
|
|
108
108
|
const {
|
|
@@ -203,17 +203,17 @@ class TemplateToTypescript {
|
|
|
203
203
|
return result;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
/**
|
|
207
|
-
* 创建元素表达式
|
|
208
|
-
*
|
|
209
|
-
* 此方法只创建节点本身的函数
|
|
210
|
-
*
|
|
211
|
-
* 示例:aiot.__ce__("div", {}, [children])
|
|
212
|
-
*
|
|
213
|
-
* 1. 如果是#text 节点,做为<span>文字内容</span> 返回
|
|
214
|
-
* 2. 其它按普通元素处理
|
|
215
|
-
* @param node
|
|
216
|
-
* @returns
|
|
206
|
+
/**
|
|
207
|
+
* 创建元素表达式
|
|
208
|
+
*
|
|
209
|
+
* 此方法只创建节点本身的函数
|
|
210
|
+
*
|
|
211
|
+
* 示例:aiot.__ce__("div", {}, [children])
|
|
212
|
+
*
|
|
213
|
+
* 1. 如果是#text 节点,做为<span>文字内容</span> 返回
|
|
214
|
+
* 2. 其它按普通元素处理
|
|
215
|
+
* @param node
|
|
216
|
+
* @returns
|
|
217
217
|
*/
|
|
218
218
|
async createElementExpression(node, extractionInformation, identifiers) {
|
|
219
219
|
const {
|
|
@@ -304,13 +304,13 @@ class TemplateToTypescript {
|
|
|
304
304
|
return result;
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
/**
|
|
308
|
-
* 从节点中提取标识符列表
|
|
309
|
-
*
|
|
310
|
-
* 例如从 <div for="(item, index) in data"/> 提取 item ,index
|
|
311
|
-
*
|
|
312
|
-
* 目前只有一种情况:for
|
|
313
|
-
* @param element
|
|
307
|
+
/**
|
|
308
|
+
* 从节点中提取标识符列表
|
|
309
|
+
*
|
|
310
|
+
* 例如从 <div for="(item, index) in data"/> 提取 item ,index
|
|
311
|
+
*
|
|
312
|
+
* 目前只有一种情况:for
|
|
313
|
+
* @param element
|
|
314
314
|
*/
|
|
315
315
|
getIdentifiersFromNode(node) {
|
|
316
316
|
const result = [];
|
|
@@ -334,13 +334,13 @@ class TemplateToTypescript {
|
|
|
334
334
|
return result;
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
-
/**
|
|
338
|
-
* 获取函数调用表达式的名称
|
|
339
|
-
* 1. 无:block**
|
|
340
|
-
* 1. ✓cc: 自定义组件
|
|
341
|
-
* 1. ✓cdc: (is/remotewidget) + component
|
|
342
|
-
* 1. ✓ ce: 一般情况
|
|
343
|
-
* @returns
|
|
337
|
+
/**
|
|
338
|
+
* 获取函数调用表达式的名称
|
|
339
|
+
* 1. 无:block**
|
|
340
|
+
* 1. ✓cc: 自定义组件
|
|
341
|
+
* 1. ✓cdc: (is/remotewidget) + component
|
|
342
|
+
* 1. ✓ ce: 一般情况
|
|
343
|
+
* @returns
|
|
344
344
|
*/
|
|
345
345
|
getCallExpressionName(node) {
|
|
346
346
|
const {
|
|
@@ -360,10 +360,10 @@ class TemplateToTypescript {
|
|
|
360
360
|
return result ? `__${result}__` : '';
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
-
/**
|
|
364
|
-
* 是否是自定义组件
|
|
365
|
-
* @param componentName 组件名称
|
|
366
|
-
* @returns
|
|
363
|
+
/**
|
|
364
|
+
* 是否是自定义组件
|
|
365
|
+
* @param componentName 组件名称
|
|
366
|
+
* @returns
|
|
367
367
|
*/
|
|
368
368
|
isCustomeComponent(componentName) {
|
|
369
369
|
const {
|
|
@@ -372,13 +372,13 @@ class TemplateToTypescript {
|
|
|
372
372
|
return importList?.map(item => item.toLowerCase()).includes(componentName.toLowerCase());
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
-
/**
|
|
376
|
-
* 生成包裹元素
|
|
377
|
-
* 1. 文字:无包裹内容
|
|
378
|
-
* 2. 通过block-cb, for-cf, if-ci 检查是否有包裹层
|
|
379
|
-
* @param node
|
|
380
|
-
* @param elementExpression
|
|
381
|
-
* @returns
|
|
375
|
+
/**
|
|
376
|
+
* 生成包裹元素
|
|
377
|
+
* 1. 文字:无包裹内容
|
|
378
|
+
* 2. 通过block-cb, for-cf, if-ci 检查是否有包裹层
|
|
379
|
+
* @param node
|
|
380
|
+
* @param elementExpression
|
|
381
|
+
* @returns
|
|
382
382
|
*/
|
|
383
383
|
async createElementWrap(node, elementExpression, infomation, identifiers) {
|
|
384
384
|
// 1
|
|
@@ -396,13 +396,13 @@ class TemplateToTypescript {
|
|
|
396
396
|
return result;
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
-
/**
|
|
400
|
-
* 提取节点属性信息
|
|
401
|
-
*
|
|
402
|
-
* 1. 根据属性提示属性信息
|
|
403
|
-
* 2. 对于文本类元素,是否有动态属性,还需要检查文本内容。 例如:<text>{{aa}}</text> 也应判定为有动态值
|
|
404
|
-
* @param node
|
|
405
|
-
* @returns
|
|
399
|
+
/**
|
|
400
|
+
* 提取节点属性信息
|
|
401
|
+
*
|
|
402
|
+
* 1. 根据属性提示属性信息
|
|
403
|
+
* 2. 对于文本类元素,是否有动态属性,还需要检查文本内容。 例如:<text>{{aa}}</text> 也应判定为有动态值
|
|
404
|
+
* @param node
|
|
405
|
+
* @returns
|
|
406
406
|
*/
|
|
407
407
|
extractionAttributeInfomation(node) {
|
|
408
408
|
const {
|
|
@@ -11,8 +11,8 @@ var _SourceMapUtil = _interopRequireDefault(require("./utils/SourceMapUtil"));
|
|
|
11
11
|
var _UxUtil = _interopRequireDefault(require("../../utils/UxUtil"));
|
|
12
12
|
var _ParserUtil = _interopRequireDefault(require("../../../utils/ParserUtil"));
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
/**
|
|
15
|
-
* UxToTypescript
|
|
14
|
+
/**
|
|
15
|
+
* UxToTypescript
|
|
16
16
|
*/
|
|
17
17
|
class UxToTypescript {
|
|
18
18
|
constructor(options, integratedFunction, compilerOption, context) {
|
|
@@ -54,10 +54,10 @@ class UxToTypescript {
|
|
|
54
54
|
sourceMap: newGenerator
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
59
|
-
* @param importList
|
|
60
|
-
* @returns
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @param importList
|
|
60
|
+
* @returns
|
|
61
61
|
*/
|
|
62
62
|
importToTypescript(importList) {
|
|
63
63
|
return _UxUtil.default.importToTypescript(importList, this.compilerOption);
|
|
@@ -12,11 +12,11 @@ var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
-
/**
|
|
16
|
-
* 用于添加应用自动化测试代码
|
|
17
|
-
* 分为两种情况
|
|
18
|
-
* 1. app文件
|
|
19
|
-
* 2. page 文件
|
|
15
|
+
/**
|
|
16
|
+
* 用于添加应用自动化测试代码
|
|
17
|
+
* 分为两种情况
|
|
18
|
+
* 1. app文件
|
|
19
|
+
* 2. page 文件
|
|
20
20
|
*/
|
|
21
21
|
function e2e() {
|
|
22
22
|
return {
|
|
@@ -40,12 +40,12 @@ function e2e() {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
/**
|
|
44
|
-
* 添加 app 的测试代码
|
|
45
|
-
*
|
|
46
|
-
* 引入测试框架文件
|
|
47
|
-
* @param path
|
|
48
|
-
* @param opts
|
|
43
|
+
/**
|
|
44
|
+
* 添加 app 的测试代码
|
|
45
|
+
*
|
|
46
|
+
* 引入测试框架文件
|
|
47
|
+
* @param path
|
|
48
|
+
* @param opts
|
|
49
49
|
*/
|
|
50
50
|
function addAppTestCode(path) {
|
|
51
51
|
const runtimePath = _path.default.join(__dirname, '../runtime/velaTestLibrary.js');
|
|
@@ -55,40 +55,40 @@ function addAppTestCode(path) {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
/**
|
|
59
|
-
* 添加页面的测试代码
|
|
60
|
-
* 1. 如果测试文件存在,则
|
|
61
|
-
* a. import 测试文件
|
|
62
|
-
* b. 设置测试函数: 如果 onTestStart 方法已存在,则在其内部添加测试代码;否则,添加 onTestStart方法
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* 2. 如果启用自动路由,且当前页面是首页
|
|
66
|
-
* a. 从routerList 中过滤出有测试文件的路由
|
|
67
|
-
* b. 在末尾添加 $generateAutoRunTest
|
|
68
|
-
* c. 在onShow 方法中调用 $generateAutoRunTest
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* @description 示例
|
|
72
|
-
*
|
|
73
|
-
* 源码 `src/home/myHome.ux`
|
|
74
|
-
* ```
|
|
75
|
-
*
|
|
76
|
-
* export default {}
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
* 产物
|
|
80
|
-
* ```
|
|
81
|
-
* import fnTestCase from 'test/home/myHome.js'
|
|
82
|
-
*
|
|
83
|
-
* export default {
|
|
84
|
-
* onTestStart: (){
|
|
85
|
-
* // code
|
|
86
|
-
* }
|
|
87
|
-
* }
|
|
88
|
-
* ```
|
|
89
|
-
*
|
|
90
|
-
* @param path
|
|
91
|
-
* @param opts
|
|
58
|
+
/**
|
|
59
|
+
* 添加页面的测试代码
|
|
60
|
+
* 1. 如果测试文件存在,则
|
|
61
|
+
* a. import 测试文件
|
|
62
|
+
* b. 设置测试函数: 如果 onTestStart 方法已存在,则在其内部添加测试代码;否则,添加 onTestStart方法
|
|
63
|
+
*
|
|
64
|
+
*
|
|
65
|
+
* 2. 如果启用自动路由,且当前页面是首页
|
|
66
|
+
* a. 从routerList 中过滤出有测试文件的路由
|
|
67
|
+
* b. 在末尾添加 $generateAutoRunTest
|
|
68
|
+
* c. 在onShow 方法中调用 $generateAutoRunTest
|
|
69
|
+
*
|
|
70
|
+
*
|
|
71
|
+
* @description 示例
|
|
72
|
+
*
|
|
73
|
+
* 源码 `src/home/myHome.ux`
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* export default {}
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* 产物
|
|
80
|
+
* ```
|
|
81
|
+
* import fnTestCase from 'test/home/myHome.js'
|
|
82
|
+
*
|
|
83
|
+
* export default {
|
|
84
|
+
* onTestStart: (){
|
|
85
|
+
* // code
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @param path
|
|
91
|
+
* @param opts
|
|
92
92
|
*/
|
|
93
93
|
function addPageTestCode(path, opts) {
|
|
94
94
|
const e2eConfig = getE2eConfig(opts);
|
|
@@ -132,13 +132,13 @@ function addPageTestCode(path, opts) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
/**
|
|
136
|
-
* 插入函数
|
|
137
|
-
*
|
|
138
|
-
* 如果已存在,把函数体插入到指定函数末尾;不存在,则添加
|
|
139
|
-
*
|
|
140
|
-
* @param name 函数名
|
|
141
|
-
* @param body 函数体
|
|
135
|
+
/**
|
|
136
|
+
* 插入函数
|
|
137
|
+
*
|
|
138
|
+
* 如果已存在,把函数体插入到指定函数末尾;不存在,则添加
|
|
139
|
+
*
|
|
140
|
+
* @param name 函数名
|
|
141
|
+
* @param body 函数体
|
|
142
142
|
*/
|
|
143
143
|
function insertFun(name, body, properties) {
|
|
144
144
|
const fun = properties.find(p => p.type === 'ObjectMethod' && p.key.name === name);
|
|
@@ -223,12 +223,12 @@ function getE2eConfig(opts) {
|
|
|
223
223
|
return result;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
/**
|
|
227
|
-
* 获取源文件对应的测试文件地址
|
|
228
|
-
* @param sourceFile 源文件
|
|
229
|
-
* @param opts
|
|
230
|
-
* @param e2eConfig
|
|
231
|
-
* @returns
|
|
226
|
+
/**
|
|
227
|
+
* 获取源文件对应的测试文件地址
|
|
228
|
+
* @param sourceFile 源文件
|
|
229
|
+
* @param opts
|
|
230
|
+
* @param e2eConfig
|
|
231
|
+
* @returns
|
|
232
232
|
*/
|
|
233
233
|
function getTestFilePath(sourceFile, opts, e2eConfig) {
|
|
234
234
|
const {
|
|
@@ -242,9 +242,9 @@ function getTestFilePath(sourceFile, opts, e2eConfig) {
|
|
|
242
242
|
return _path.default.join(e2eConfig.testDir, parsed.dir, `${parsed.name}.js`);
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
/**
|
|
246
|
-
* 获取测试函数的函数体
|
|
247
|
-
* @returns
|
|
245
|
+
/**
|
|
246
|
+
* 获取测试函数的函数体
|
|
247
|
+
* @returns
|
|
248
248
|
*/
|
|
249
249
|
function generateTestFn() {
|
|
250
250
|
const fn = `function(){
|