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

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 (47) hide show
  1. package/README.md +11 -11
  2. package/lib/utils/ParserUtil.js +15 -15
  3. package/lib/ux/config/ExtensionConfig.js +2 -2
  4. package/lib/ux/config/FeatureConfig.js +19 -19
  5. package/lib/ux/config/vela/StyleAttributeConfig.js +134 -88
  6. package/lib/ux/enum/StyleSelectorType.js +6 -6
  7. package/lib/ux/enum/TemplateNodeType.js +2 -2
  8. package/lib/ux/enum/android/StyleSelectorName.js +2 -2
  9. package/lib/ux/interface/IUxAst.d.ts +2 -0
  10. package/lib/ux/parser/ScriptParser.js +2 -2
  11. package/lib/ux/parser/StyleParser.js +79 -72
  12. package/lib/ux/parser/TemplateValueParser.js +49 -49
  13. package/lib/ux/parser/UxParser.js +18 -12
  14. package/lib/ux/translate/android/StyleToTypescript.js +51 -51
  15. package/lib/ux/translate/android/TemplateToTypescript.js +51 -51
  16. package/lib/ux/translate/android/UxToTypescript.js +14 -14
  17. package/lib/ux/translate/android/attributeTranslate/ForTranslate.js +17 -17
  18. package/lib/ux/translate/android/attributeTranslate/IfTranslate.js +9 -9
  19. package/lib/ux/translate/vela/ScriptToTypescript.js +10 -10
  20. package/lib/ux/translate/vela/StyleToTypescript.js +10 -10
  21. package/lib/ux/translate/vela/TemplateToTypescript.js +74 -74
  22. package/lib/ux/translate/vela/TranslateCache.js +2 -2
  23. package/lib/ux/translate/vela/UxToTypescript.js +6 -6
  24. package/lib/ux/translate/vela/VelaContext.js +2 -2
  25. package/lib/ux/translate/vela/plugins/e2e.js +63 -62
  26. package/lib/ux/translate/vela/plugins/startPage.js +1 -1
  27. package/lib/ux/translate/vela/protobuf/BinaryPlugin.js +172 -172
  28. package/lib/ux/translate/vela/protobuf/protobuf.js +235 -235
  29. package/lib/ux/translate/vela/protobuf/protobufControl.js +159 -159
  30. package/lib/ux/translate/vela/protobuf/vdom_pb.js +2374 -2374
  31. package/lib/ux/translate/vela/runtime/velaTestLibrary.js +104 -104
  32. package/lib/ux/translate/vela/utils/AttributeConfig.js +15 -15
  33. package/lib/ux/translate/vela/utils/ExtendedBoxStyle.js +38 -38
  34. package/lib/ux/translate/vela/utils/SourceMapUtil.js +30 -30
  35. package/lib/ux/translate/vela/utils/TemplateUtil.js +180 -180
  36. package/lib/ux/translate/vela/wrap/CbTranslate.js +8 -8
  37. package/lib/ux/translate/vela/wrap/CfTranslate.js +14 -14
  38. package/lib/ux/translate/vela/wrap/CiTranslate.js +11 -11
  39. package/lib/ux/utils/BabelUtil.js +35 -35
  40. package/lib/ux/utils/ElementConfigUtil.js +24 -24
  41. package/lib/ux/utils/StyleMapUtil.js +15 -15
  42. package/lib/ux/utils/StyleUtil.d.ts +1 -1
  43. package/lib/ux/utils/StyleUtil.js +192 -248
  44. package/lib/ux/utils/UxUtil.js +32 -32
  45. package/lib/ux/validate/ElementValidate.js +2 -2
  46. package/lib/ux/validate/UxFileValidate.js +2 -2
  47. package/package.json +4 -4
@@ -8,50 +8,50 @@ var parser = _interopRequireWildcard(require("@babel/parser"));
8
8
  var t = _interopRequireWildcard(require("@babel/types"));
9
9
  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); }
10
10
  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; }
11
- /**
12
- * @see:node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js的 walkIdentifiers函数
13
- * BabelUtil
11
+ /**
12
+ * @see:node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js的 walkIdentifiers函数
13
+ * BabelUtil
14
14
  */
15
15
  class BabelUtil {
16
- /**
17
- * 是否是对象的标识符
18
- *
19
- * 例如: a = {}
20
- * @param node
21
- * @returns
16
+ /**
17
+ * 是否是对象的标识符
18
+ *
19
+ * 例如: a = {}
20
+ * @param node
21
+ * @returns
22
22
  */
23
23
  static isObjectIdentifier(node) {
24
24
  return node && (node.type === 'ObjectProperty' || node.type === 'ObjectMethod') && !node.computed;
25
25
  }
26
26
 
27
- /**
28
- * 是否是对象键的标识符
29
- *
30
- * 例如: {x: **} 中的 x
31
- * @param node
32
- * @param parent
33
- * @returns
27
+ /**
28
+ * 是否是对象键的标识符
29
+ *
30
+ * 例如: {x: **} 中的 x
31
+ * @param node
32
+ * @param parent
33
+ * @returns
34
34
  */
35
35
  static isObjectKeyIdentifier(node, parent) {
36
36
  return this.isObjectIdentifier(parent) && parent.key === node;
37
37
  }
38
38
 
39
- /**
40
- * 生成 babel的函数体
41
- * @param code
42
- * @returns
39
+ /**
40
+ * 生成 babel的函数体
41
+ * @param code
42
+ * @returns
43
43
  */
44
44
  static generateFunctionBody(code) {
45
45
  const func = `function() {${code}}`;
46
46
  return parser.parseExpression(func).body;
47
47
  }
48
48
 
49
- /**
50
- * 插入或更新函数到对象
51
- *
52
- * @param functionName 函数名. 如果存在此函数,则把body插入到最后;否则,添加函数
53
- * @param body 新增的函数体
54
- * @param path 对象路径(babel的路径)
49
+ /**
50
+ * 插入或更新函数到对象
51
+ *
52
+ * @param functionName 函数名. 如果存在此函数,则把body插入到最后;否则,添加函数
53
+ * @param body 新增的函数体
54
+ * @param path 对象路径(babel的路径)
55
55
  */
56
56
  static insertOrUpdateFunctionToObject(functionName, body, path) {
57
57
  if (path.node.declaration.type === 'ObjectExpression') {
@@ -68,15 +68,15 @@ class BabelUtil {
68
68
  }
69
69
  }
70
70
 
71
- /**
72
- * 插入import, 如果 `importName` 存在,则不执行操作
73
- *
74
- * @example
75
- * import router from '@system/router'
76
- *
77
- * @param importName import的名称, 例如:router
78
- * @param importPath import的路径, 例如:@system/router
79
- * @param param babel节点, 只有 `Program` 类型时才执行
71
+ /**
72
+ * 插入import, 如果 `importName` 存在,则不执行操作
73
+ *
74
+ * @example
75
+ * import router from '@system/router'
76
+ *
77
+ * @param importName import的名称, 例如:router
78
+ * @param importPath import的路径, 例如:@system/router
79
+ * @param param babel节点, 只有 `Program` 类型时才执行
80
80
  */
81
81
  static insertImportToProgram(importName, importPath, param) {
82
82
  if (param.type === 'Program') {
@@ -8,8 +8,8 @@ var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
8
  var _TemplateUtil = _interopRequireDefault(require("../translate/vela/utils/TemplateUtil"));
9
9
  var _QuickAppDocHelp = require("@aiot-toolkit/shared-utils/lib/utils/QuickAppDocHelp");
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- /**
12
- * ElementConfigUtil
11
+ /**
12
+ * ElementConfigUtil
13
13
  */
14
14
  class ElementConfigUtil {
15
15
  constructor(config) {
@@ -27,15 +27,15 @@ class ElementConfigUtil {
27
27
  return false;
28
28
  };
29
29
 
30
- /**
31
- *
32
- * 对非自定义组件检查元素合法性
33
- * 1. 是否有配置
34
- * 2. 检查属性值是否合法
35
- * 3. 检查是否缺少必填属性
36
- * @param tagName 元素名称 <com id="a"> 中的 com
37
- * @param importList
38
- * @returns
30
+ /**
31
+ *
32
+ * 对非自定义组件检查元素合法性
33
+ * 1. 是否有配置
34
+ * 2. 检查属性值是否合法
35
+ * 3. 检查是否缺少必填属性
36
+ * @param tagName 元素名称 <com id="a"> 中的 com
37
+ * @param importList
38
+ * @returns
39
39
  */
40
40
  validateElement = (options, tag, attributes, importList) => {
41
41
  const tagName = tag.name;
@@ -92,19 +92,19 @@ class ElementConfigUtil {
92
92
  return true;
93
93
  };
94
94
 
95
- /**
96
- * 检查属性
97
- * 1. 是否忽略: data-* 忽略
98
- * 2. 如果是事件
99
- * a. 检查是否在 元素 events 或 commonEvents 中
100
- * b. 检查是否有值
101
- * 3. 不是事件
102
- * a. 检查是否在attributes配置中
103
- * b. 是否有 enum,如果有,则检查值是否在配置中(不检查动态值)
104
- * c. 是否有 validate,如果有,则执行并返回结果
105
- * @param tagName 元素标签名
106
- * @param attributeName 属性名
107
- * @param attributeValue 属性值
95
+ /**
96
+ * 检查属性
97
+ * 1. 是否忽略: data-* 忽略
98
+ * 2. 如果是事件
99
+ * a. 检查是否在 元素 events 或 commonEvents 中
100
+ * b. 检查是否有值
101
+ * 3. 不是事件
102
+ * a. 检查是否在attributes配置中
103
+ * b. 是否有 enum,如果有,则检查值是否在配置中(不检查动态值)
104
+ * c. 是否有 validate,如果有,则执行并返回结果
105
+ * @param tagName 元素标签名
106
+ * @param attributeName 属性名
107
+ * @param attributeValue 属性值
108
108
  */
109
109
  validateAttribute = (options, tagName, attribute) => {
110
110
  const elementConfig = this.getElementConfig(tagName);
@@ -13,21 +13,21 @@ class StyleMapUtil {
13
13
  this.lineOffset = lineOffset;
14
14
  this.options = options;
15
15
  }
16
- /**
17
- * 1. 根据生成结果位置找转换前的行列值
18
- * 2. 根据样式代码总体偏移量,计算出当前节点行在ux中的行
19
- * 2.1 查看map信息,原始行总是从第三行开始计算,-2是去掉生成map信息时多余的偏移量
20
- * 2.2 再加上样式代码总体偏移量,就可以计算出实际所在行数
21
- * 3. 返回节点原始位置信息
22
- * 3.1 原始位置的startLine即为上一步计算了偏移量的行信息
23
- * 3.2 原始位置的startColumn为查找到的节点列信息(目前看结果不存在列偏移)
24
- * 3.3 原始位置的endLine为startLine+生成结果中所占据行数的值
25
- * 3.4 原始位置的endColumn根据map结果,发现存在1个位置的差异,所以-1
26
- * 3.5 source存储来源的文件
27
- * @param location 生成结果中节点的位置信息
28
- * @param consumer 经过解析器获取的map信息生成的consumer对象
29
- * @param offset 当前样式代码在ux文件中的偏移量
30
- * @returns
16
+ /**
17
+ * 1. 根据生成结果位置找转换前的行列值
18
+ * 2. 根据样式代码总体偏移量,计算出当前节点行在ux中的行
19
+ * 2.1 查看map信息,原始行总是从第三行开始计算,-2是去掉生成map信息时多余的偏移量
20
+ * 2.2 再加上样式代码总体偏移量,就可以计算出实际所在行数
21
+ * 3. 返回节点原始位置信息
22
+ * 3.1 原始位置的startLine即为上一步计算了偏移量的行信息
23
+ * 3.2 原始位置的startColumn为查找到的节点列信息(目前看结果不存在列偏移)
24
+ * 3.3 原始位置的endLine为startLine+生成结果中所占据行数的值
25
+ * 3.4 原始位置的endColumn根据map结果,发现存在1个位置的差异,所以-1
26
+ * 3.5 source存储来源的文件
27
+ * @param location 生成结果中节点的位置信息
28
+ * @param consumer 经过解析器获取的map信息生成的consumer对象
29
+ * @param offset 当前样式代码在ux文件中的偏移量
30
+ * @returns
31
31
  */
32
32
  transfromLocToPosition(location) {
33
33
  const {
@@ -107,7 +107,7 @@ declare class StyleUtil {
107
107
  * @param trace 是否需要追溯到上一次sourcemap, default: false
108
108
  * @returns
109
109
  */
110
- static collectSyntaxError(errors: Array<any>, instance: StyleMapUtil, trace?: boolean, startLineOffset?: number): IStyleError[];
110
+ static collectSyntaxError(errors: Array<any>): IStyleError[];
111
111
  /**
112
112
  * 相同选择器时融合样式
113
113
  * 1. 遍历待融合列表,如果元素长度为3,判断选择器列表是否在存储列表中存在