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

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 (107) 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/StyleAttributeConfig.js +87 -87
  8. package/lib/ux/enum/StyleSelectorType.js +6 -6
  9. package/lib/ux/enum/TemplateNodeType.js +2 -2
  10. package/lib/ux/enum/android/StyleSelectorName.js +2 -2
  11. package/lib/ux/parser/ScriptParser.js +2 -2
  12. package/lib/ux/parser/StyleParser.js +62 -62
  13. package/lib/ux/parser/TemplateValueParser.js +49 -49
  14. package/lib/ux/parser/UxParser.js +11 -11
  15. package/lib/ux/translate/android/StyleToTypescript.js +51 -51
  16. package/lib/ux/translate/android/TemplateToTypescript.js +51 -51
  17. package/lib/ux/translate/android/UxToTypescript.js +14 -14
  18. package/lib/ux/translate/android/attributeTranslate/ForTranslate.js +17 -17
  19. package/lib/ux/translate/android/attributeTranslate/IfTranslate.js +9 -9
  20. package/lib/ux/translate/vela/ScriptToTypescript.js +13 -12
  21. package/lib/ux/translate/vela/StyleToTypescript.js +10 -10
  22. package/lib/ux/translate/vela/TemplateToTypescript.js +74 -74
  23. package/lib/ux/translate/vela/TranslateCache.js +2 -2
  24. package/lib/ux/translate/vela/UxToTypescript.js +6 -6
  25. package/lib/ux/translate/vela/VelaContext.js +2 -2
  26. package/lib/ux/translate/vela/plugins/e2e.js +61 -61
  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.d.ts +10 -8
  36. package/lib/ux/translate/vela/utils/TemplateUtil.js +206 -191
  37. package/lib/ux/translate/vela/wrap/CbTranslate.js +8 -8
  38. package/lib/ux/translate/vela/wrap/CfTranslate.js +14 -14
  39. package/lib/ux/translate/vela/wrap/CiTranslate.js +11 -11
  40. package/lib/ux/utils/BabelUtil.js +35 -35
  41. package/lib/ux/utils/ElementConfigUtil.js +24 -24
  42. package/lib/ux/utils/StyleMapUtil.js +26 -16
  43. package/lib/ux/utils/StyleUtil.js +165 -165
  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 -5
  48. package/lib/xts/XtsParser.d.ts +0 -20
  49. package/lib/xts/XtsParser.js +0 -86
  50. package/lib/xts/XtsToTypescript.d.ts +0 -69
  51. package/lib/xts/XtsToTypescript.js +0 -894
  52. package/lib/xts/config/CommonAttributeList.d.ts +0 -6
  53. package/lib/xts/config/CommonAttributeList.js +0 -17
  54. package/lib/xts/config/classCount.json +0 -38
  55. package/lib/xts/config/commonAttribute.json +0 -84
  56. package/lib/xts/config/componentList.d.ts +0 -56
  57. package/lib/xts/config/componentList.js +0 -9
  58. package/lib/xts/config/predefinedComponent.json +0 -91
  59. package/lib/xts/config/render.json +0 -31
  60. package/lib/xts/data/ElementType.d.ts +0 -6
  61. package/lib/xts/data/ElementType.js +0 -5
  62. package/lib/xts/data/element/CommentElement.d.ts +0 -16
  63. package/lib/xts/data/element/CommentElement.js +0 -26
  64. package/lib/xts/data/element/ElementBase.d.ts +0 -14
  65. package/lib/xts/data/element/ElementBase.js +0 -20
  66. package/lib/xts/data/element/ForElement.d.ts +0 -58
  67. package/lib/xts/data/element/ForElement.js +0 -81
  68. package/lib/xts/data/element/IfElement.d.ts +0 -55
  69. package/lib/xts/data/element/IfElement.js +0 -87
  70. package/lib/xts/data/element/NodeElement.d.ts +0 -39
  71. package/lib/xts/data/element/NodeElement.js +0 -86
  72. package/lib/xts/enum/AttributeType.d.ts +0 -31
  73. package/lib/xts/enum/AttributeType.js +0 -53
  74. package/lib/xts/enum/Framework.d.ts +0 -98
  75. package/lib/xts/enum/Framework.js +0 -107
  76. package/lib/xts/interface/IContext.d.ts +0 -11
  77. package/lib/xts/interface/IContext.js +0 -1
  78. package/lib/xts/interface/IElement.d.ts +0 -17
  79. package/lib/xts/interface/IElement.js +0 -5
  80. package/lib/xts/interface/IExpressNode.d.ts +0 -20
  81. package/lib/xts/interface/IExpressNode.js +0 -1
  82. package/lib/xts/interface/config/ICommon.d.ts +0 -23
  83. package/lib/xts/interface/config/ICommon.js +0 -5
  84. package/lib/xts/interface/config/IRenderNode.d.ts +0 -25
  85. package/lib/xts/interface/config/IRenderNode.js +0 -1
  86. package/lib/xts/interface/validate/IAttibuteValidate.d.ts +0 -8
  87. package/lib/xts/interface/validate/IAttibuteValidate.js +0 -1
  88. package/lib/xts/interface/validate/IComponentValidate.d.ts +0 -9
  89. package/lib/xts/interface/validate/IComponentValidate.js +0 -1
  90. package/lib/xts/interface/validate/IRenderValidate.d.ts +0 -10
  91. package/lib/xts/interface/validate/IRenderValidate.js +0 -1
  92. package/lib/xts/interface/validate/ISourceFileValidate.d.ts +0 -7
  93. package/lib/xts/interface/validate/ISourceFileValidate.js +0 -1
  94. package/lib/xts/utils/AttributeUtil.d.ts +0 -73
  95. package/lib/xts/utils/AttributeUtil.js +0 -206
  96. package/lib/xts/utils/TypeUtil.d.ts +0 -60
  97. package/lib/xts/utils/TypeUtil.js +0 -97
  98. package/lib/xts/utils/TypescriptUtil.d.ts +0 -42
  99. package/lib/xts/utils/TypescriptUtil.js +0 -128
  100. package/lib/xts/validate/AttibuteValidate.d.ts +0 -18
  101. package/lib/xts/validate/AttibuteValidate.js +0 -97
  102. package/lib/xts/validate/ComponentValidate.d.ts +0 -19
  103. package/lib/xts/validate/ComponentValidate.js +0 -90
  104. package/lib/xts/validate/RenderValidate.d.ts +0 -63
  105. package/lib/xts/validate/RenderValidate.js +0 -239
  106. package/lib/xts/validate/SourceFileValidate.d.ts +0 -10
  107. package/lib/xts/validate/SourceFileValidate.js +0 -43
@@ -1,159 +1,159 @@
1
- const vdom_pb = require('./vdom_pb')
2
- const Path = require('path')
3
- const fs = require('fs')
4
- const AIOT = require('./protobuf')
5
-
6
- /**
7
- *
8
- * @param {[[[number, string]], {[key:string]:string|number}][]} style
9
- */
10
- function translateStyle(style, aiot) {
11
- const exportCell = aiot.expCell
12
-
13
- style.forEach((item) => {
14
- const hasProperty = item.length === 3
15
- let property
16
- let selectorList = item[0]
17
- let styleValue = item[1]
18
- if (hasProperty) {
19
- property = item[0]
20
- selectorList = item[1]
21
- styleValue = item[2]
22
- }
23
-
24
- const cssCell = exportCell.addCssarr()
25
-
26
- // 如果有 property,写入
27
- if (hasProperty && property) {
28
- Object.keys(property).forEach((key) => {
29
- const value = property[key]
30
- const propertyArr = cssCell.addPropertyarr()
31
- // 设置属性名
32
- const propertyKey = new vdom_pb.StyleKey()
33
- propertyKey.setValue(key)
34
- propertyArr.setKey(propertyKey)
35
-
36
- // 设置属性值
37
- switch (typeof value) {
38
- case 'string':
39
- propertyArr.setStringvl(value)
40
- break
41
- case 'number':
42
- if (Number.isInteger(value)) {
43
- propertyArr.setInt32vl(value)
44
- } else {
45
- propertyArr.setDoublevl(value)
46
- }
47
- break
48
- }
49
- })
50
- }
51
-
52
- // 写入选择器
53
- selectorList.forEach((selectorItem) => {
54
- const selector = cssCell.addSelectorarr()
55
- selector.setId(selectorItem[0])
56
- selector.setName(selectorItem[1])
57
- })
58
-
59
- // 写入属性值
60
- Object.keys(styleValue).forEach((key) => {
61
- const value = styleValue[key]
62
-
63
- const styleVl = cssCell.addStylearr()
64
-
65
- // 设置css属性名称
66
- const pk = new vdom_pb.StyleKey()
67
- pk.setValue(key)
68
- styleVl.setKey(pk)
69
-
70
- const valueType = typeof value
71
- // 设置css值
72
- switch (valueType) {
73
- case 'string':
74
- styleVl.setStringvl(value)
75
- break
76
- case 'number':
77
- if (Number.isInteger(value)) {
78
- styleVl.setInt32vl(value)
79
- } else {
80
- styleVl.setDoublevl(value)
81
- }
82
- break
83
- case 'object':
84
- styleVl.setStylevlarr(aiot.parseObj(value))
85
- break
86
- default:
87
- console.warn(`CssValue Of ${valueType} NotProcessed`)
88
- }
89
- })
90
- })
91
- return exportCell
92
- }
93
-
94
- function translateTemplate(template, aiot) {
95
- const vm = {}
96
- if (template) {
97
- // eslint-disable-next-line no-eval
98
- eval(`(${template})`)(vm)
99
- }
100
- }
101
-
102
- function createItem(entryName, style, template) {
103
- // 创建aiot对象
104
- let aiot = new AIOT()
105
- aiot.init(entryName || 'entry')
106
- // 写入template
107
- translateTemplate(template, aiot)
108
- // 写入style
109
- translateStyle(style, aiot)
110
-
111
- return aiot
112
- }
113
-
114
- /**
115
- *
116
- * @param {*} template
117
- */
118
- function extractFunctions(template) {
119
- // 创建aiot对象
120
- let aiot = new AIOT()
121
- aiot.init('temp')
122
-
123
- // 写入template
124
- translateTemplate(template, aiot)
125
-
126
- return aiot
127
- }
128
-
129
- /**
130
- * 创建bin文件
131
- * @param {string} fileName
132
- * @param {string[]} styleList
133
- * @param {string[]} templateList
134
- */
135
- function createBin(fileName, tagList, styleList, templateList) {
136
- const dataList = styleList.map((item, index) => {
137
- return createItem(tagList[index], JSON.parse(item), templateList[index])
138
- })
139
-
140
- // 写入数据
141
- let indexExport = new vdom_pb.ExportArr()
142
- indexExport.clearValuearrList()
143
- dataList.forEach((item) => {
144
- indexExport.addValuearr(item.expCell)
145
- })
146
-
147
- // 如果文件夹不存在,则创建
148
- const folder = Path.dirname(fileName)
149
- if (!fs.existsSync(folder)) {
150
- fs.mkdirSync(folder, { recursive: true })
151
- }
152
- // 写入文件
153
- let outbuff = indexExport.serializeBinary()
154
- fs.writeFileSync(fileName, outbuff)
155
- }
156
- module.exports = {
157
- extractFunctions,
158
- createBin
159
- }
1
+ const vdom_pb = require('./vdom_pb')
2
+ const Path = require('path')
3
+ const fs = require('fs')
4
+ const AIOT = require('./protobuf')
5
+
6
+ /**
7
+ *
8
+ * @param {[[[number, string]], {[key:string]:string|number}][]} style
9
+ */
10
+ function translateStyle(style, aiot) {
11
+ const exportCell = aiot.expCell
12
+
13
+ style.forEach((item) => {
14
+ const hasProperty = item.length === 3
15
+ let property
16
+ let selectorList = item[0]
17
+ let styleValue = item[1]
18
+ if (hasProperty) {
19
+ property = item[0]
20
+ selectorList = item[1]
21
+ styleValue = item[2]
22
+ }
23
+
24
+ const cssCell = exportCell.addCssarr()
25
+
26
+ // 如果有 property,写入
27
+ if (hasProperty && property) {
28
+ Object.keys(property).forEach((key) => {
29
+ const value = property[key]
30
+ const propertyArr = cssCell.addPropertyarr()
31
+ // 设置属性名
32
+ const propertyKey = new vdom_pb.StyleKey()
33
+ propertyKey.setValue(key)
34
+ propertyArr.setKey(propertyKey)
35
+
36
+ // 设置属性值
37
+ switch (typeof value) {
38
+ case 'string':
39
+ propertyArr.setStringvl(value)
40
+ break
41
+ case 'number':
42
+ if (Number.isInteger(value)) {
43
+ propertyArr.setInt32vl(value)
44
+ } else {
45
+ propertyArr.setDoublevl(value)
46
+ }
47
+ break
48
+ }
49
+ })
50
+ }
51
+
52
+ // 写入选择器
53
+ selectorList.forEach((selectorItem) => {
54
+ const selector = cssCell.addSelectorarr()
55
+ selector.setId(selectorItem[0])
56
+ selector.setName(selectorItem[1])
57
+ })
58
+
59
+ // 写入属性值
60
+ Object.keys(styleValue).forEach((key) => {
61
+ const value = styleValue[key]
62
+
63
+ const styleVl = cssCell.addStylearr()
64
+
65
+ // 设置css属性名称
66
+ const pk = new vdom_pb.StyleKey()
67
+ pk.setValue(key)
68
+ styleVl.setKey(pk)
69
+
70
+ const valueType = typeof value
71
+ // 设置css值
72
+ switch (valueType) {
73
+ case 'string':
74
+ styleVl.setStringvl(value)
75
+ break
76
+ case 'number':
77
+ if (Number.isInteger(value)) {
78
+ styleVl.setInt32vl(value)
79
+ } else {
80
+ styleVl.setDoublevl(value)
81
+ }
82
+ break
83
+ case 'object':
84
+ styleVl.setStylevlarr(aiot.parseObj(value))
85
+ break
86
+ default:
87
+ console.warn(`CssValue Of ${valueType} NotProcessed`)
88
+ }
89
+ })
90
+ })
91
+ return exportCell
92
+ }
93
+
94
+ function translateTemplate(template, aiot) {
95
+ const vm = {}
96
+ if (template) {
97
+ // eslint-disable-next-line no-eval
98
+ eval(`(${template})`)(vm)
99
+ }
100
+ }
101
+
102
+ function createItem(entryName, style, template) {
103
+ // 创建aiot对象
104
+ let aiot = new AIOT()
105
+ aiot.init(entryName || 'entry')
106
+ // 写入template
107
+ translateTemplate(template, aiot)
108
+ // 写入style
109
+ translateStyle(style, aiot)
110
+
111
+ return aiot
112
+ }
113
+
114
+ /**
115
+ *
116
+ * @param {*} template
117
+ */
118
+ function extractFunctions(template) {
119
+ // 创建aiot对象
120
+ let aiot = new AIOT()
121
+ aiot.init('temp')
122
+
123
+ // 写入template
124
+ translateTemplate(template, aiot)
125
+
126
+ return aiot
127
+ }
128
+
129
+ /**
130
+ * 创建bin文件
131
+ * @param {string} fileName
132
+ * @param {string[]} styleList
133
+ * @param {string[]} templateList
134
+ */
135
+ function createBin(fileName, tagList, styleList, templateList) {
136
+ const dataList = styleList.map((item, index) => {
137
+ return createItem(tagList[index], JSON.parse(item), templateList[index])
138
+ })
139
+
140
+ // 写入数据
141
+ let indexExport = new vdom_pb.ExportArr()
142
+ indexExport.clearValuearrList()
143
+ dataList.forEach((item) => {
144
+ indexExport.addValuearr(item.expCell)
145
+ })
146
+
147
+ // 如果文件夹不存在,则创建
148
+ const folder = Path.dirname(fileName)
149
+ if (!fs.existsSync(folder)) {
150
+ fs.mkdirSync(folder, { recursive: true })
151
+ }
152
+ // 写入文件
153
+ let outbuff = indexExport.serializeBinary()
154
+ fs.writeFileSync(fileName, outbuff)
155
+ }
156
+ module.exports = {
157
+ extractFunctions,
158
+ createBin
159
+ }