@dcloudio/uni-template-compiler 2.0.1-34720220422002 → 2.0.1-34920220607003
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/lib/app/parser/component-parser.js +3 -2
- package/lib/app/parser/tag-parser.js +8 -1
- package/lib/app/util.js +5 -1
- package/lib/index.js +14 -5
- package/lib/module.js +0 -3
- package/lib/module.uniad.js +16 -0
- package/lib/util.js +5 -2
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const {
|
|
2
|
-
ID
|
|
2
|
+
ID,
|
|
3
|
+
elements
|
|
3
4
|
} = require('../util')
|
|
4
5
|
|
|
5
6
|
const {
|
|
@@ -9,7 +10,7 @@ const {
|
|
|
9
10
|
// 仅限 view 层
|
|
10
11
|
module.exports = function parseComponent (el) {
|
|
11
12
|
// 需要把自定义组件的 attrs, props 全干掉
|
|
12
|
-
if (el.tag && isComponent(el.tag)) {
|
|
13
|
+
if (el.tag && !elements.includes(el.tag) && isComponent(el.tag)) {
|
|
13
14
|
// 仅保留 id、ID、data
|
|
14
15
|
el.attrs && (el.attrs = el.attrs.filter(attr => {
|
|
15
16
|
const name = attr.name
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
const {
|
|
2
|
-
hasOwn
|
|
2
|
+
hasOwn,
|
|
3
|
+
elements
|
|
3
4
|
} = require('../util')
|
|
4
5
|
|
|
5
6
|
const tags = require('@dcloudio/uni-cli-shared/lib/tags')
|
|
6
7
|
|
|
7
8
|
// 仅限 view 层
|
|
8
9
|
module.exports = function parseTag (el) {
|
|
10
|
+
const tag = el.tag
|
|
11
|
+
const element = elements.find(element => tag === element || 'uni-' + tag === element)
|
|
12
|
+
if (element) {
|
|
13
|
+
el.tag = element
|
|
14
|
+
return
|
|
15
|
+
}
|
|
9
16
|
if (el.tag.indexOf('v-uni-') !== 0 && hasOwn(tags, el.tag)) {
|
|
10
17
|
el.tag = 'v-uni-' + el.tag
|
|
11
18
|
}
|
package/lib/app/util.js
CHANGED
|
@@ -20,6 +20,9 @@ const V_FOR = 'f'
|
|
|
20
20
|
const V_IF = 'i'
|
|
21
21
|
const V_ELSE_IF = 'e'
|
|
22
22
|
|
|
23
|
+
// web components
|
|
24
|
+
const elements = ['uni-view']
|
|
25
|
+
|
|
23
26
|
function isVar (str) {
|
|
24
27
|
if (!str) {
|
|
25
28
|
return false
|
|
@@ -273,6 +276,7 @@ module.exports = {
|
|
|
273
276
|
GET_DATA,
|
|
274
277
|
SET_MP_CLASS,
|
|
275
278
|
GET_CHANGE_DATA,
|
|
279
|
+
elements,
|
|
276
280
|
isVar,
|
|
277
281
|
hasOwn,
|
|
278
282
|
addAttr,
|
|
@@ -288,4 +292,4 @@ module.exports = {
|
|
|
288
292
|
getBindingAttr,
|
|
289
293
|
getAndRemoveAttr,
|
|
290
294
|
traverseNode
|
|
291
|
-
}
|
|
295
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -15,7 +15,8 @@ const generateScript = require('./script/generate')
|
|
|
15
15
|
const traverseTemplate = require('./template/traverse')
|
|
16
16
|
const generateTemplate = require('./template/generate')
|
|
17
17
|
|
|
18
|
-
const compilerModule = require('./module')
|
|
18
|
+
const compilerModule = require('./module')
|
|
19
|
+
const compilerModuleUniad = require('./module.uniad')
|
|
19
20
|
|
|
20
21
|
const compilerAlipayModule = require('./module-alipay')
|
|
21
22
|
const compilerToutiaoModule = require('./module-toutiao')
|
|
@@ -37,7 +38,11 @@ const isWin = /^win/.test(process.platform)
|
|
|
37
38
|
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
|
|
38
39
|
|
|
39
40
|
module.exports = {
|
|
40
|
-
compile (source, options = {}) {
|
|
41
|
+
compile (source, options = {}) {
|
|
42
|
+
if (Array.isArray(options.modules)) {
|
|
43
|
+
options.modules.push(compilerModuleUniad)
|
|
44
|
+
}
|
|
45
|
+
|
|
41
46
|
if ( // 启用摇树优化后,需要过滤内置组件
|
|
42
47
|
!options.autoComponentResourcePath ||
|
|
43
48
|
options.autoComponentResourcePath.indexOf('@dcloudio/uni-h5/src') === -1
|
|
@@ -46,7 +51,8 @@ module.exports = {
|
|
|
46
51
|
}
|
|
47
52
|
if (!options.modules) {
|
|
48
53
|
options.modules = []
|
|
49
|
-
}
|
|
54
|
+
}
|
|
55
|
+
|
|
50
56
|
// transformAssetUrls
|
|
51
57
|
options.modules.push(require('./asset-url'))
|
|
52
58
|
options.modules.push(require('./bool-attr'))
|
|
@@ -90,7 +96,7 @@ module.exports = {
|
|
|
90
96
|
return compileTemplate(source, options, compile)
|
|
91
97
|
}
|
|
92
98
|
|
|
93
|
-
options.modules.push(compilerModule)
|
|
99
|
+
options.modules.push(compilerModule)
|
|
94
100
|
|
|
95
101
|
if (options.mp.platform === 'mp-alipay') {
|
|
96
102
|
options.modules.push(compilerAlipayModule)
|
|
@@ -118,7 +124,10 @@ module.exports = {
|
|
|
118
124
|
options.mp.filterModules = Object.keys(options.filterModules || {})
|
|
119
125
|
|
|
120
126
|
// (可用的原生微信小程序组件,global+scoped)
|
|
121
|
-
options.mp.wxComponents = options.wxComponents || Object.create(null)
|
|
127
|
+
options.mp.wxComponents = options.wxComponents || Object.create(null)
|
|
128
|
+
Object.assign(options.mp.wxComponents, {
|
|
129
|
+
'uniad-plugin': 'plugin://uni-ad/ad'
|
|
130
|
+
})
|
|
122
131
|
|
|
123
132
|
const state = {
|
|
124
133
|
ast: {},
|
package/lib/module.js
CHANGED
|
@@ -15,9 +15,6 @@ module.exports = {
|
|
|
15
15
|
preTransformNode (el, {
|
|
16
16
|
warn
|
|
17
17
|
}) {
|
|
18
|
-
if (process.env.UNI_PLATFORM === 'app-plus' && el.tag === 'ad') {
|
|
19
|
-
warn('app-vue平台, <ad> 组件暂不支持非 V3 编译, 详见: https://ask.dcloud.net.cn/article/36599')
|
|
20
|
-
}
|
|
21
18
|
if (el.tag === 'slot' && !el.attrsMap.name) {
|
|
22
19
|
el.attrsList.push({
|
|
23
20
|
name: 'SLOT_DEFAULT',
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const AD_COMPONENTS = ['uniad', 'ad-rewarded-video', 'ad-fullscreen-video', 'ad-interstitial']
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
preTransformNode (el, {
|
|
5
|
+
warn
|
|
6
|
+
}) {
|
|
7
|
+
if (process.env.UNI_PLATFORM === 'mp-weixin') {
|
|
8
|
+
if (el.tag === 'ad' && (el.attrsMap.adpid || el.attrsMap[':adpid'])) {
|
|
9
|
+
el.tag = 'uniad'
|
|
10
|
+
}
|
|
11
|
+
if (AD_COMPONENTS.indexOf(el.tag) > -1) {
|
|
12
|
+
process.env.USE_UNI_AD = true
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
package/lib/util.js
CHANGED
|
@@ -4,7 +4,8 @@ const babelGenerate = require('@babel/generator').default
|
|
|
4
4
|
const uniI18n = require('@dcloudio/uni-cli-i18n')
|
|
5
5
|
|
|
6
6
|
const {
|
|
7
|
-
METHOD_RENDER_LIST
|
|
7
|
+
METHOD_RENDER_LIST,
|
|
8
|
+
METHOD_RESOLVE_SCOPED_SLOTS
|
|
8
9
|
} = require('./constants')
|
|
9
10
|
|
|
10
11
|
function cached (fn) {
|
|
@@ -48,6 +49,8 @@ function traverseKey (ast, state) {
|
|
|
48
49
|
CallExpression (path) {
|
|
49
50
|
if (path.node.callee.name === METHOD_RENDER_LIST) {
|
|
50
51
|
path.stop()
|
|
52
|
+
} else if (path.node.callee.name === METHOD_RESOLVE_SCOPED_SLOTS) {
|
|
53
|
+
path.skip()
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
})
|
|
@@ -207,7 +210,7 @@ function isComponent (tagName) {
|
|
|
207
210
|
return false
|
|
208
211
|
}
|
|
209
212
|
}
|
|
210
|
-
return !hasOwn(tags, getTagName(tagName.replace(
|
|
213
|
+
return !hasOwn(tags, getTagName(tagName.replace(/^v-uni-/, '')))
|
|
211
214
|
}
|
|
212
215
|
|
|
213
216
|
function makeMap (str, expectsLowerCase) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-template-compiler",
|
|
3
|
-
"version": "2.0.1-
|
|
3
|
+
"version": "2.0.1-34920220607003",
|
|
4
4
|
"description": "uni-template-compiler",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"@babel/types": "^7.3.3",
|
|
23
23
|
"vue-template-compiler": "^2.6.10"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "ab4199a51b6a576ce347f419e2b013ec3a60c15a"
|
|
26
26
|
}
|