@aiot-toolkit/parser 2.0.5-beta.8 → 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.
- 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/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.js +30 -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 +176 -174
- 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 +6 -6
- 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
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
const Path = require('path')
|
|
2
|
-
const { createBin } = require('./protobufControl')
|
|
3
|
-
|
|
4
|
-
const contentType = {
|
|
5
|
-
style: 'style',
|
|
6
|
-
template: 'template',
|
|
7
|
-
tagName: 'tagName'
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const ext = '.bin'
|
|
11
|
-
|
|
12
|
-
class BinaryPlugin {
|
|
13
|
-
/**
|
|
14
|
-
* 所有要创建二进制文件的数据
|
|
15
|
-
*
|
|
16
|
-
* @type {{[binFileName:string]:{
|
|
17
|
-
* sourceFileName:string,
|
|
18
|
-
* tagName?:string,
|
|
19
|
-
* style?:string
|
|
20
|
-
* template?:string
|
|
21
|
-
* }[]}}
|
|
22
|
-
*/
|
|
23
|
-
static binaryData = {}
|
|
24
|
-
|
|
25
|
-
static config = {}
|
|
26
|
-
|
|
27
|
-
static createBinFiles() {
|
|
28
|
-
const keys = Object.keys(BinaryPlugin.binaryData)
|
|
29
|
-
if (keys.length > 0) {
|
|
30
|
-
keys.forEach((binPath) => {
|
|
31
|
-
// 写入文件
|
|
32
|
-
// 1. 获取style template内容
|
|
33
|
-
// 2. 获取bin文件名= build目录 + 文件名相对src的路径
|
|
34
|
-
// 3. 创建buffer数据
|
|
35
|
-
// 4. 写入文件
|
|
36
|
-
const data = BinaryPlugin.binaryData[binPath]
|
|
37
|
-
const styleList = []
|
|
38
|
-
const templateList = []
|
|
39
|
-
const tagList = []
|
|
40
|
-
|
|
41
|
-
data.forEach((item) => {
|
|
42
|
-
tagList.push(item.tagName || '')
|
|
43
|
-
styleList.push(item.style || '[]')
|
|
44
|
-
templateList.push(item.template || '')
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
const ext = Path.extname(binPath)
|
|
48
|
-
|
|
49
|
-
// 如果不是hml文件,生成style.bin
|
|
50
|
-
if (ext !== '.hml') {
|
|
51
|
-
const cssBinPath = BinaryPlugin.getBinPath(binPath, 'style')
|
|
52
|
-
createBin(
|
|
53
|
-
cssBinPath,
|
|
54
|
-
new Array(tagList.length).fill(''),
|
|
55
|
-
styleList,
|
|
56
|
-
new Array(templateList.length).fill('')
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// 如果不是css类型的文件,生成template.bin
|
|
61
|
-
if (!['.css', '.less', '.scss', '.sass'].includes(ext)) {
|
|
62
|
-
const templateBinPath = BinaryPlugin.getBinPath(binPath, 'template')
|
|
63
|
-
createBin(templateBinPath, tagList, new Array(styleList.length).fill('[]'), templateList)
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
static reset() {
|
|
70
|
-
BinaryPlugin.binaryData = {}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
*
|
|
75
|
-
* @private
|
|
76
|
-
* @param {string} binPath
|
|
77
|
-
* @param {'style'|'template'} type
|
|
78
|
-
*/
|
|
79
|
-
static getBinPath(binPath, type) {
|
|
80
|
-
const srcPath = Path.join(this.config.projectPath, this.config.source)
|
|
81
|
-
const relativePath = Path.relative(srcPath, binPath)
|
|
82
|
-
const parse = Path.parse(relativePath)
|
|
83
|
-
|
|
84
|
-
const result = Path.join(
|
|
85
|
-
this.config.outputProjectPath,
|
|
86
|
-
this.config.output,
|
|
87
|
-
Path.dirname(relativePath),
|
|
88
|
-
`${parse.name}.${type}${ext}`
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
return result
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
*
|
|
96
|
-
* @private
|
|
97
|
-
* @param {string} binFileName 要生成的bin文件路径
|
|
98
|
-
* @param {string} sourceFileName 源码文件路径
|
|
99
|
-
* @param {string} type 添加内容的类型, 参考contentType
|
|
100
|
-
* @param {string} content
|
|
101
|
-
*
|
|
102
|
-
* @returns {{index:number, name:string}}
|
|
103
|
-
*/
|
|
104
|
-
static addContent(binFileName, sourceFileName, type, content, pagePath = '') {
|
|
105
|
-
const binaryData = BinaryPlugin.binaryData
|
|
106
|
-
// 1. 如果没有对应的bin数据,则创建
|
|
107
|
-
|
|
108
|
-
if (!binaryData[binFileName]) {
|
|
109
|
-
binaryData[binFileName] = []
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const array = binaryData[binFileName]
|
|
113
|
-
let item
|
|
114
|
-
// 2. 通过sourceFileName寻找是否已存在对应的数据,如果存在,记录位置并直接使用;不存在,则新建
|
|
115
|
-
const index = array.findIndex((item) => item.sourceFileName === sourceFileName)
|
|
116
|
-
if (index >= 0) {
|
|
117
|
-
item = array[index]
|
|
118
|
-
item[type] = content
|
|
119
|
-
} else {
|
|
120
|
-
item = {
|
|
121
|
-
sourceFileName,
|
|
122
|
-
[type]: content
|
|
123
|
-
}
|
|
124
|
-
array.push(item)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const binPath = BinaryPlugin.getBinPath(binFileName, type)
|
|
128
|
-
let relativePath = Path.relative(
|
|
129
|
-
Path.resolve(this.config.outputProjectPath, this.config.output),
|
|
130
|
-
binPath
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
relativePath = relativePath.replace(/\\/g, '/')
|
|
134
|
-
|
|
135
|
-
return {
|
|
136
|
-
index: index >= 0 ? index : array.length - 1,
|
|
137
|
-
name: relativePath
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
static addTagName(binFileName, sourceFileName, content, pagePath = '') {
|
|
142
|
-
return BinaryPlugin.addContent(
|
|
143
|
-
binFileName,
|
|
144
|
-
sourceFileName,
|
|
145
|
-
contentType.tagName,
|
|
146
|
-
content,
|
|
147
|
-
pagePath
|
|
148
|
-
)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
static addTemplate(binFileName, sourceFileName, content, pagePath = '') {
|
|
152
|
-
return BinaryPlugin.addContent(
|
|
153
|
-
binFileName,
|
|
154
|
-
sourceFileName,
|
|
155
|
-
contentType.template,
|
|
156
|
-
content,
|
|
157
|
-
pagePath
|
|
158
|
-
)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
static addStyle(binFileName, sourceFileName, content, pagePath = '') {
|
|
162
|
-
return BinaryPlugin.addContent(
|
|
163
|
-
binFileName,
|
|
164
|
-
sourceFileName,
|
|
165
|
-
contentType.style,
|
|
166
|
-
content,
|
|
167
|
-
pagePath
|
|
168
|
-
)
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
module.exports = BinaryPlugin
|
|
1
|
+
const Path = require('path')
|
|
2
|
+
const { createBin } = require('./protobufControl')
|
|
3
|
+
|
|
4
|
+
const contentType = {
|
|
5
|
+
style: 'style',
|
|
6
|
+
template: 'template',
|
|
7
|
+
tagName: 'tagName'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const ext = '.bin'
|
|
11
|
+
|
|
12
|
+
class BinaryPlugin {
|
|
13
|
+
/**
|
|
14
|
+
* 所有要创建二进制文件的数据
|
|
15
|
+
*
|
|
16
|
+
* @type {{[binFileName:string]:{
|
|
17
|
+
* sourceFileName:string,
|
|
18
|
+
* tagName?:string,
|
|
19
|
+
* style?:string
|
|
20
|
+
* template?:string
|
|
21
|
+
* }[]}}
|
|
22
|
+
*/
|
|
23
|
+
static binaryData = {}
|
|
24
|
+
|
|
25
|
+
static config = {}
|
|
26
|
+
|
|
27
|
+
static createBinFiles() {
|
|
28
|
+
const keys = Object.keys(BinaryPlugin.binaryData)
|
|
29
|
+
if (keys.length > 0) {
|
|
30
|
+
keys.forEach((binPath) => {
|
|
31
|
+
// 写入文件
|
|
32
|
+
// 1. 获取style template内容
|
|
33
|
+
// 2. 获取bin文件名= build目录 + 文件名相对src的路径
|
|
34
|
+
// 3. 创建buffer数据
|
|
35
|
+
// 4. 写入文件
|
|
36
|
+
const data = BinaryPlugin.binaryData[binPath]
|
|
37
|
+
const styleList = []
|
|
38
|
+
const templateList = []
|
|
39
|
+
const tagList = []
|
|
40
|
+
|
|
41
|
+
data.forEach((item) => {
|
|
42
|
+
tagList.push(item.tagName || '')
|
|
43
|
+
styleList.push(item.style || '[]')
|
|
44
|
+
templateList.push(item.template || '')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const ext = Path.extname(binPath)
|
|
48
|
+
|
|
49
|
+
// 如果不是hml文件,生成style.bin
|
|
50
|
+
if (ext !== '.hml') {
|
|
51
|
+
const cssBinPath = BinaryPlugin.getBinPath(binPath, 'style')
|
|
52
|
+
createBin(
|
|
53
|
+
cssBinPath,
|
|
54
|
+
new Array(tagList.length).fill(''),
|
|
55
|
+
styleList,
|
|
56
|
+
new Array(templateList.length).fill('')
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 如果不是css类型的文件,生成template.bin
|
|
61
|
+
if (!['.css', '.less', '.scss', '.sass'].includes(ext)) {
|
|
62
|
+
const templateBinPath = BinaryPlugin.getBinPath(binPath, 'template')
|
|
63
|
+
createBin(templateBinPath, tagList, new Array(styleList.length).fill('[]'), templateList)
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static reset() {
|
|
70
|
+
BinaryPlugin.binaryData = {}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @private
|
|
76
|
+
* @param {string} binPath
|
|
77
|
+
* @param {'style'|'template'} type
|
|
78
|
+
*/
|
|
79
|
+
static getBinPath(binPath, type) {
|
|
80
|
+
const srcPath = Path.join(this.config.projectPath, this.config.source)
|
|
81
|
+
const relativePath = Path.relative(srcPath, binPath)
|
|
82
|
+
const parse = Path.parse(relativePath)
|
|
83
|
+
|
|
84
|
+
const result = Path.join(
|
|
85
|
+
this.config.outputProjectPath,
|
|
86
|
+
this.config.output,
|
|
87
|
+
Path.dirname(relativePath),
|
|
88
|
+
`${parse.name}.${type}${ext}`
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
return result
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @private
|
|
97
|
+
* @param {string} binFileName 要生成的bin文件路径
|
|
98
|
+
* @param {string} sourceFileName 源码文件路径
|
|
99
|
+
* @param {string} type 添加内容的类型, 参考contentType
|
|
100
|
+
* @param {string} content
|
|
101
|
+
*
|
|
102
|
+
* @returns {{index:number, name:string}}
|
|
103
|
+
*/
|
|
104
|
+
static addContent(binFileName, sourceFileName, type, content, pagePath = '') {
|
|
105
|
+
const binaryData = BinaryPlugin.binaryData
|
|
106
|
+
// 1. 如果没有对应的bin数据,则创建
|
|
107
|
+
|
|
108
|
+
if (!binaryData[binFileName]) {
|
|
109
|
+
binaryData[binFileName] = []
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const array = binaryData[binFileName]
|
|
113
|
+
let item
|
|
114
|
+
// 2. 通过sourceFileName寻找是否已存在对应的数据,如果存在,记录位置并直接使用;不存在,则新建
|
|
115
|
+
const index = array.findIndex((item) => item.sourceFileName === sourceFileName)
|
|
116
|
+
if (index >= 0) {
|
|
117
|
+
item = array[index]
|
|
118
|
+
item[type] = content
|
|
119
|
+
} else {
|
|
120
|
+
item = {
|
|
121
|
+
sourceFileName,
|
|
122
|
+
[type]: content
|
|
123
|
+
}
|
|
124
|
+
array.push(item)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const binPath = BinaryPlugin.getBinPath(binFileName, type)
|
|
128
|
+
let relativePath = Path.relative(
|
|
129
|
+
Path.resolve(this.config.outputProjectPath, this.config.output),
|
|
130
|
+
binPath
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
relativePath = relativePath.replace(/\\/g, '/')
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
index: index >= 0 ? index : array.length - 1,
|
|
137
|
+
name: relativePath
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
static addTagName(binFileName, sourceFileName, content, pagePath = '') {
|
|
142
|
+
return BinaryPlugin.addContent(
|
|
143
|
+
binFileName,
|
|
144
|
+
sourceFileName,
|
|
145
|
+
contentType.tagName,
|
|
146
|
+
content,
|
|
147
|
+
pagePath
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static addTemplate(binFileName, sourceFileName, content, pagePath = '') {
|
|
152
|
+
return BinaryPlugin.addContent(
|
|
153
|
+
binFileName,
|
|
154
|
+
sourceFileName,
|
|
155
|
+
contentType.template,
|
|
156
|
+
content,
|
|
157
|
+
pagePath
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
static addStyle(binFileName, sourceFileName, content, pagePath = '') {
|
|
162
|
+
return BinaryPlugin.addContent(
|
|
163
|
+
binFileName,
|
|
164
|
+
sourceFileName,
|
|
165
|
+
contentType.style,
|
|
166
|
+
content,
|
|
167
|
+
pagePath
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
module.exports = BinaryPlugin
|