@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,104 +1,104 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (C) 2017, hapjs.org. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* assert文档:http://chaijs.com/api/assert/
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const chai = require('vela-chai')
|
|
10
|
-
const quickAppText = require('vela-quickapp-test')
|
|
11
|
-
|
|
12
|
-
// 注入全局
|
|
13
|
-
global.assert = chai.assert
|
|
14
|
-
|
|
15
|
-
for (let key in quickAppText) {
|
|
16
|
-
global[key] = quickAppText[key]
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 标准化(去除px单位、合并或者展开、尺寸标准化)
|
|
21
|
-
*/
|
|
22
|
-
global.normalize = function (map) {
|
|
23
|
-
map = map || {}
|
|
24
|
-
|
|
25
|
-
Object.keys(map).forEach(function (key) {
|
|
26
|
-
// 去除px单位
|
|
27
|
-
map[key] && map[key].replace && (map[key] = map[key].replace(/px/g, ''))
|
|
28
|
-
let val = map[key]
|
|
29
|
-
|
|
30
|
-
// 合并或者展开
|
|
31
|
-
if (['margin', 'padding', 'borderWidth', 'borderColor'].indexOf(key) > -1 && /\s+/.test(val)) {
|
|
32
|
-
const valList = val.replace(/,\s+/g, ',').split(/\s+/)
|
|
33
|
-
const valHash = valList.reduce((sum, v) => {
|
|
34
|
-
sum[v] = true
|
|
35
|
-
return sum
|
|
36
|
-
}, {})
|
|
37
|
-
|
|
38
|
-
if (Object.keys(valHash).length === 1) {
|
|
39
|
-
// 合并
|
|
40
|
-
map[key] = valList[0]
|
|
41
|
-
} else {
|
|
42
|
-
// 完全展开
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// 750标准尺寸
|
|
47
|
-
val = map[key]
|
|
48
|
-
if (/^\d*\.?\d*$/.test(val) && !isNaN(parseFloat(val))) {
|
|
49
|
-
map[key] = +val
|
|
50
|
-
// 标准尺寸
|
|
51
|
-
map[key + 'Std'] = Math.round((map[key] * global.Env.designWidth) / global.Env.deviceWidth)
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
return map
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 获取宽高以及相对距离
|
|
59
|
-
* @desc 相当于 node.getBoundingRect()
|
|
60
|
-
* @param ref
|
|
61
|
-
* @return {*|{content}|{}}
|
|
62
|
-
*/
|
|
63
|
-
global.nodeRect = function (ref) {
|
|
64
|
-
// Node节点转换
|
|
65
|
-
ref = ref.ref || ref
|
|
66
|
-
|
|
67
|
-
return global.model.getBoundingRect({ ref: ref }) || {}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 获取设置的节点属性
|
|
72
|
-
* @param ref
|
|
73
|
-
* @return {*|{}}
|
|
74
|
-
*/
|
|
75
|
-
global.nodeAttr = function (ref) {
|
|
76
|
-
// Node节点转换
|
|
77
|
-
ref = ref.ref || ref
|
|
78
|
-
|
|
79
|
-
return global.model.getComputedAttr({ ref: ref }) || {}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* 获取设置的节点样式
|
|
84
|
-
* @param ref
|
|
85
|
-
* @return {*|{content}|CSSStyleDeclaration|CssStyle|{}}
|
|
86
|
-
*/
|
|
87
|
-
global.nodeStyle = function (ref) {
|
|
88
|
-
// Node节点转换
|
|
89
|
-
ref = ref.ref || ref
|
|
90
|
-
|
|
91
|
-
return global.model.getComputedStyle({ ref: ref }) || {}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* 获取节点信息
|
|
96
|
-
* @param ref
|
|
97
|
-
* @return {*|{content}|{}}
|
|
98
|
-
*/
|
|
99
|
-
global.nodeInfo = function (ref) {
|
|
100
|
-
// Node节点转换
|
|
101
|
-
ref = ref.ref || ref
|
|
102
|
-
|
|
103
|
-
return global.model.getComponent({ ref: ref }) || {}
|
|
104
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2017, hapjs.org. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* assert文档:http://chaijs.com/api/assert/
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const chai = require('vela-chai')
|
|
10
|
+
const quickAppText = require('vela-quickapp-test')
|
|
11
|
+
|
|
12
|
+
// 注入全局
|
|
13
|
+
global.assert = chai.assert
|
|
14
|
+
|
|
15
|
+
for (let key in quickAppText) {
|
|
16
|
+
global[key] = quickAppText[key]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 标准化(去除px单位、合并或者展开、尺寸标准化)
|
|
21
|
+
*/
|
|
22
|
+
global.normalize = function (map) {
|
|
23
|
+
map = map || {}
|
|
24
|
+
|
|
25
|
+
Object.keys(map).forEach(function (key) {
|
|
26
|
+
// 去除px单位
|
|
27
|
+
map[key] && map[key].replace && (map[key] = map[key].replace(/px/g, ''))
|
|
28
|
+
let val = map[key]
|
|
29
|
+
|
|
30
|
+
// 合并或者展开
|
|
31
|
+
if (['margin', 'padding', 'borderWidth', 'borderColor'].indexOf(key) > -1 && /\s+/.test(val)) {
|
|
32
|
+
const valList = val.replace(/,\s+/g, ',').split(/\s+/)
|
|
33
|
+
const valHash = valList.reduce((sum, v) => {
|
|
34
|
+
sum[v] = true
|
|
35
|
+
return sum
|
|
36
|
+
}, {})
|
|
37
|
+
|
|
38
|
+
if (Object.keys(valHash).length === 1) {
|
|
39
|
+
// 合并
|
|
40
|
+
map[key] = valList[0]
|
|
41
|
+
} else {
|
|
42
|
+
// 完全展开
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 750标准尺寸
|
|
47
|
+
val = map[key]
|
|
48
|
+
if (/^\d*\.?\d*$/.test(val) && !isNaN(parseFloat(val))) {
|
|
49
|
+
map[key] = +val
|
|
50
|
+
// 标准尺寸
|
|
51
|
+
map[key + 'Std'] = Math.round((map[key] * global.Env.designWidth) / global.Env.deviceWidth)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
return map
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 获取宽高以及相对距离
|
|
59
|
+
* @desc 相当于 node.getBoundingRect()
|
|
60
|
+
* @param ref
|
|
61
|
+
* @return {*|{content}|{}}
|
|
62
|
+
*/
|
|
63
|
+
global.nodeRect = function (ref) {
|
|
64
|
+
// Node节点转换
|
|
65
|
+
ref = ref.ref || ref
|
|
66
|
+
|
|
67
|
+
return global.model.getBoundingRect({ ref: ref }) || {}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 获取设置的节点属性
|
|
72
|
+
* @param ref
|
|
73
|
+
* @return {*|{}}
|
|
74
|
+
*/
|
|
75
|
+
global.nodeAttr = function (ref) {
|
|
76
|
+
// Node节点转换
|
|
77
|
+
ref = ref.ref || ref
|
|
78
|
+
|
|
79
|
+
return global.model.getComputedAttr({ ref: ref }) || {}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 获取设置的节点样式
|
|
84
|
+
* @param ref
|
|
85
|
+
* @return {*|{content}|CSSStyleDeclaration|CssStyle|{}}
|
|
86
|
+
*/
|
|
87
|
+
global.nodeStyle = function (ref) {
|
|
88
|
+
// Node节点转换
|
|
89
|
+
ref = ref.ref || ref
|
|
90
|
+
|
|
91
|
+
return global.model.getComputedStyle({ ref: ref }) || {}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 获取节点信息
|
|
96
|
+
* @param ref
|
|
97
|
+
* @return {*|{content}|{}}
|
|
98
|
+
*/
|
|
99
|
+
global.nodeInfo = function (ref) {
|
|
100
|
+
// Node节点转换
|
|
101
|
+
ref = ref.ref || ref
|
|
102
|
+
|
|
103
|
+
return global.model.getComponent({ ref: ref }) || {}
|
|
104
|
+
}
|
|
@@ -100,11 +100,11 @@ const ATTRIBUTE_CONFIG = {
|
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
-
/**
|
|
104
|
-
* 转换动态值的默认方法
|
|
105
|
-
* @param value
|
|
106
|
-
* @param disabledWrap 是否禁用函数包裹。因为普通属性不用函数无法动态响应,而 for 的 list 属性设置函数又报错;所以这里临时加一个参数,在生成__list__的地方手动设置为 true
|
|
107
|
-
* @returns
|
|
103
|
+
/**
|
|
104
|
+
* 转换动态值的默认方法
|
|
105
|
+
* @param value
|
|
106
|
+
* @param disabledWrap 是否禁用函数包裹。因为普通属性不用函数无法动态响应,而 for 的 list 属性设置函数又报错;所以这里临时加一个参数,在生成__list__的地方手动设置为 true
|
|
107
|
+
* @returns
|
|
108
108
|
*/
|
|
109
109
|
const defaultAttributeTranslate = function (value) {
|
|
110
110
|
let disabledWrap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -114,16 +114,16 @@ const defaultAttributeTranslate = function (value) {
|
|
|
114
114
|
return `function() { return ${value} }`;
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
/**
|
|
118
|
-
* 转换事件属性的值
|
|
119
|
-
*
|
|
120
|
-
* 1. 普通函数不转换: function(){}
|
|
121
|
-
* 2. 函数名:_vm_.a 转换为 _vm_.a(event)
|
|
122
|
-
* 3. 函数调用:_vm_.a(x, y) 转换为 _vm_.a(x, y, event)
|
|
123
|
-
* 4. 箭头函数不转换: ()=>{}
|
|
124
|
-
*
|
|
125
|
-
* @param value
|
|
126
|
-
* @returns
|
|
117
|
+
/**
|
|
118
|
+
* 转换事件属性的值
|
|
119
|
+
*
|
|
120
|
+
* 1. 普通函数不转换: function(){}
|
|
121
|
+
* 2. 函数名:_vm_.a 转换为 _vm_.a(event)
|
|
122
|
+
* 3. 函数调用:_vm_.a(x, y) 转换为 _vm_.a(x, y, event)
|
|
123
|
+
* 4. 箭头函数不转换: ()=>{}
|
|
124
|
+
*
|
|
125
|
+
* @param value
|
|
126
|
+
* @returns
|
|
127
127
|
*/
|
|
128
128
|
exports.defaultAttributeTranslate = defaultAttributeTranslate;
|
|
129
129
|
const eventAttributeTranslate = (options, value, attribute) => {
|
|
@@ -12,12 +12,12 @@ const borderWidthList = ['thin', 'medium', 'thick'];
|
|
|
12
12
|
const borderStyleList = ['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'];
|
|
13
13
|
const timingFunctions = ['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'cubic-bezier', 'step-start', 'step-end', 'jump-start', 'jump-end', 'jump-none', 'jump-both', 'start', 'end'];
|
|
14
14
|
const REGEXP_PROPERTY_NAME = /^[a-zA-Z-]+[a-zA-Z0-9-]*/;
|
|
15
|
-
/**
|
|
16
|
-
* ExtendedBoxStyle
|
|
15
|
+
/**
|
|
16
|
+
* ExtendedBoxStyle
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* ExtendedBoxStyle
|
|
19
|
+
/**
|
|
20
|
+
* ExtendedBoxStyle
|
|
21
21
|
*/
|
|
22
22
|
class ExtendedBoxStyle {
|
|
23
23
|
static extendBoxStyle(sourceNode) {
|
|
@@ -47,14 +47,14 @@ class ExtendedBoxStyle {
|
|
|
47
47
|
}
|
|
48
48
|
return targetList;
|
|
49
49
|
}
|
|
50
|
-
/**
|
|
51
|
-
* 扩展border样式
|
|
52
|
-
* 扩展border的前提是border的格式符合CSS标准
|
|
53
|
-
* 1. 展开border节点为borderWidth、borderStyle、borderColor
|
|
54
|
-
* 2. 扩展borderWidth、borderColor属性
|
|
55
|
-
* 3. 将border[Left、Right、Top、Bottom]由第1步生成的结果赋值给targetList
|
|
56
|
-
* @param sourceNode
|
|
57
|
-
* @param targetList
|
|
50
|
+
/**
|
|
51
|
+
* 扩展border样式
|
|
52
|
+
* 扩展border的前提是border的格式符合CSS标准
|
|
53
|
+
* 1. 展开border节点为borderWidth、borderStyle、borderColor
|
|
54
|
+
* 2. 扩展borderWidth、borderColor属性
|
|
55
|
+
* 3. 将border[Left、Right、Top、Bottom]由第1步生成的结果赋值给targetList
|
|
56
|
+
* @param sourceNode
|
|
57
|
+
* @param targetList
|
|
58
58
|
*/
|
|
59
59
|
static extendBorderStyle(sourceNode, targetList) {
|
|
60
60
|
const {
|
|
@@ -106,15 +106,15 @@ class ExtendedBoxStyle {
|
|
|
106
106
|
break;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
/**
|
|
110
|
-
* 扩展元素与位置
|
|
111
|
-
* margin->0:'marginTop', 1:'marginRight', 2:'marginBottom', 3:'marginLeft'
|
|
112
|
-
* 解析时,只有valueList.length > 1才会返回列表
|
|
113
|
-
* 1. 节点值为数组且长度大于1时,待扩展值顺序为数组值的顺序
|
|
114
|
-
* 2. 若待扩展元素无对应数组值,则取对称位置的数组值index-2
|
|
115
|
-
* 3. 节点值为非数组,则取对应节点值即可
|
|
116
|
-
* @param sourceNode
|
|
117
|
-
* @param targetList
|
|
109
|
+
/**
|
|
110
|
+
* 扩展元素与位置
|
|
111
|
+
* margin->0:'marginTop', 1:'marginRight', 2:'marginBottom', 3:'marginLeft'
|
|
112
|
+
* 解析时,只有valueList.length > 1才会返回列表
|
|
113
|
+
* 1. 节点值为数组且长度大于1时,待扩展值顺序为数组值的顺序
|
|
114
|
+
* 2. 若待扩展元素无对应数组值,则取对称位置的数组值index-2
|
|
115
|
+
* 3. 节点值为非数组,则取对应节点值即可
|
|
116
|
+
* @param sourceNode
|
|
117
|
+
* @param targetList
|
|
118
118
|
*/
|
|
119
119
|
static extendPosition(sourceNode, targetList) {
|
|
120
120
|
const {
|
|
@@ -140,19 +140,19 @@ class ExtendedBoxStyle {
|
|
|
140
140
|
targetList[namePos] = value;
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
/**
|
|
144
|
-
* 按照大写字符拆分字符串
|
|
145
|
-
* bordeWidth -> border,width
|
|
146
|
-
* @param str
|
|
147
|
-
* @returns
|
|
143
|
+
/**
|
|
144
|
+
* 按照大写字符拆分字符串
|
|
145
|
+
* bordeWidth -> border,width
|
|
146
|
+
* @param str
|
|
147
|
+
* @returns
|
|
148
148
|
*/
|
|
149
149
|
static splitByUppercase(str) {
|
|
150
150
|
return str.split(/(?=[A-Z])/);
|
|
151
151
|
}
|
|
152
|
-
/**
|
|
153
|
-
* 展开border的每个值
|
|
154
|
-
* @param sourceNode
|
|
155
|
-
* @param extendedBorder
|
|
152
|
+
/**
|
|
153
|
+
* 展开border的每个值
|
|
154
|
+
* @param sourceNode
|
|
155
|
+
* @param extendedBorder
|
|
156
156
|
*/
|
|
157
157
|
static extendValueTypeNode(sourceNode, extendedBorder, name) {
|
|
158
158
|
// border borderLeft ---> borderWidth borderLeftWidth
|
|
@@ -168,18 +168,18 @@ class ExtendedBoxStyle {
|
|
|
168
168
|
extendedBorder[color] = value;
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
/**
|
|
172
|
-
* 判断border节点值是否有borderWidth
|
|
173
|
-
* @param nodeValue
|
|
174
|
-
* @returns
|
|
171
|
+
/**
|
|
172
|
+
* 判断border节点值是否有borderWidth
|
|
173
|
+
* @param nodeValue
|
|
174
|
+
* @returns
|
|
175
175
|
*/
|
|
176
176
|
static isBorderWidth(nodeValue) {
|
|
177
177
|
return unitList.indexOf(nodeValue.unit) > -1 || borderWidthList.indexOf(nodeValue.value) > -1;
|
|
178
178
|
}
|
|
179
|
-
/**
|
|
180
|
-
* 第一个时间为 transitionDuration
|
|
181
|
-
* @param sourceNode
|
|
182
|
-
* @param targetList
|
|
179
|
+
/**
|
|
180
|
+
* 第一个时间为 transitionDuration
|
|
181
|
+
* @param sourceNode
|
|
182
|
+
* @param targetList
|
|
183
183
|
*/
|
|
184
184
|
static extendTransition(sourceNode, targetList) {
|
|
185
185
|
// 默认值
|
|
@@ -5,16 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _sourceMap = require("source-map");
|
|
8
|
-
/**
|
|
9
|
-
* SourceMapUtil
|
|
8
|
+
/**
|
|
9
|
+
* SourceMapUtil
|
|
10
10
|
*/
|
|
11
11
|
class SourceMapUtil {
|
|
12
|
-
/**
|
|
13
|
-
* 更新source map
|
|
14
|
-
* @param sourceMapStr 更新前的source map字符串
|
|
15
|
-
* @param offsetInfo 目标代码合并时用到的偏移量
|
|
16
|
-
* @param options
|
|
17
|
-
* @returns 返回更新了map的generator对象
|
|
12
|
+
/**
|
|
13
|
+
* 更新source map
|
|
14
|
+
* @param sourceMapStr 更新前的source map字符串
|
|
15
|
+
* @param offsetInfo 目标代码合并时用到的偏移量
|
|
16
|
+
* @param options
|
|
17
|
+
* @returns 返回更新了map的generator对象
|
|
18
18
|
*/
|
|
19
19
|
static async updateSourceMap(sourceMapStr, offsetInfo, options) {
|
|
20
20
|
if (!sourceMapStr) {
|
|
@@ -30,10 +30,10 @@ class SourceMapUtil {
|
|
|
30
30
|
tempGenerator.setSourceContent(consumer.sources[0], options.content);
|
|
31
31
|
return tempGenerator;
|
|
32
32
|
}
|
|
33
|
-
/**
|
|
34
|
-
* 基于sourceMap字符串创建一个consumer对象、一个mappings为空的tempGenerator对象
|
|
35
|
-
* @param sourceMap
|
|
36
|
-
* @returns
|
|
33
|
+
/**
|
|
34
|
+
* 基于sourceMap字符串创建一个consumer对象、一个mappings为空的tempGenerator对象
|
|
35
|
+
* @param sourceMap
|
|
36
|
+
* @returns
|
|
37
37
|
*/
|
|
38
38
|
static async createConsumerAndGenerator(sourceMap) {
|
|
39
39
|
const consumer = await new _sourceMap.SourceMapConsumer(sourceMap);
|
|
@@ -44,10 +44,10 @@ class SourceMapUtil {
|
|
|
44
44
|
tempGenerator
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
/**
|
|
48
|
-
* 创建一个mappings为空的tempGenerator对象
|
|
49
|
-
* @param sourceMap
|
|
50
|
-
* @returns
|
|
47
|
+
/**
|
|
48
|
+
* 创建一个mappings为空的tempGenerator对象
|
|
49
|
+
* @param sourceMap
|
|
50
|
+
* @returns
|
|
51
51
|
*/
|
|
52
52
|
static async createTempGenerator(sourceMap) {
|
|
53
53
|
const tempSourceMap = JSON.parse(sourceMap);
|
|
@@ -55,11 +55,11 @@ class SourceMapUtil {
|
|
|
55
55
|
const tempConsumer = await new _sourceMap.SourceMapConsumer(tempSourceMap);
|
|
56
56
|
return _sourceMap.SourceMapGenerator.fromSourceMap(tempConsumer);
|
|
57
57
|
}
|
|
58
|
-
/**
|
|
59
|
-
* 更新tempGenerator的mappings
|
|
60
|
-
* @param consumer 更新前mappings存储在该对象中
|
|
61
|
-
* @param tempGenerator 待更新mappings的对象
|
|
62
|
-
* @param updateInfo 传递更新过程中使用的偏移量
|
|
58
|
+
/**
|
|
59
|
+
* 更新tempGenerator的mappings
|
|
60
|
+
* @param consumer 更新前mappings存储在该对象中
|
|
61
|
+
* @param tempGenerator 待更新mappings的对象
|
|
62
|
+
* @param updateInfo 传递更新过程中使用的偏移量
|
|
63
63
|
*/
|
|
64
64
|
static updateMappings(consumer, tempGenerator, updateInfo) {
|
|
65
65
|
consumer.eachMapping(mapping => {
|
|
@@ -81,11 +81,11 @@ class SourceMapUtil {
|
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
-
/**
|
|
85
|
-
* 从babel后的代码中切割出源码和source map
|
|
86
|
-
* @param appScriptTree
|
|
87
|
-
* @param project
|
|
88
|
-
* @returns
|
|
84
|
+
/**
|
|
85
|
+
* 从babel后的代码中切割出源码和source map
|
|
86
|
+
* @param appScriptTree
|
|
87
|
+
* @param project
|
|
88
|
+
* @returns
|
|
89
89
|
*/
|
|
90
90
|
static splitSourceMap(appScriptTree) {
|
|
91
91
|
// 取出script中的source map
|
|
@@ -102,10 +102,10 @@ class SourceMapUtil {
|
|
|
102
102
|
scriptSourceMap: result[1] ? Buffer.from(result[1], 'base64').toString() : ''
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
/**
|
|
106
|
-
* 计算addStatments中字符串所占行数
|
|
107
|
-
* @param str
|
|
108
|
-
* @returns
|
|
105
|
+
/**
|
|
106
|
+
* 计算addStatments中字符串所占行数
|
|
107
|
+
* @param str
|
|
108
|
+
* @returns
|
|
109
109
|
*/
|
|
110
110
|
static countStatementLines(originStr) {
|
|
111
111
|
if (!originStr) {
|
|
@@ -245,14 +245,16 @@ declare class TemplateUtil {
|
|
|
245
245
|
} | undefined;
|
|
246
246
|
/**
|
|
247
247
|
* 元素的属性转换为资源路径
|
|
248
|
-
* 1.
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
* 3
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
248
|
+
* 1. 不转换
|
|
249
|
+
* 1.1 属性本身无需转换
|
|
250
|
+
* 1.2 值不满足预设的条件: 不转换
|
|
251
|
+
* 1.3 绝对路径:不转换
|
|
252
|
+
* 2. 动态值:
|
|
253
|
+
* 2.1 第一段是静态值: 第一段转换为相对 src 的绝对路径, 示例:../a/b{{x}} --> /a/b{{x}} + 添加 warn
|
|
254
|
+
* 2.2 其它:不转换
|
|
255
|
+
* 3. 静态值:
|
|
256
|
+
* 3.1. 如果文件在src中,转换为相对src的路径, 示例:project/src/assets/a/b.png 转换为 /assets/a/b.png
|
|
257
|
+
* 3.2. 否则修改为 require()
|
|
256
258
|
*/
|
|
257
259
|
convertResourcePath(nodeName: string, attrs: IAttributeNode[]): void;
|
|
258
260
|
/**
|