@dcloudio/uni-template-compiler 2.0.2-alpha-4080720251125002 → 2.0.2-alpha-5000020260203001
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/auto-components.js +3 -1
- package/lib/mp.js +1 -179
- package/lib/native-tags.js +187 -0
- package/lib/script/traverse/data/class.js +3 -2
- package/lib/script/traverse/data/style.js +1 -1
- package/lib/template/generate.js +1 -1
- package/package.json +2 -2
package/lib/auto-components.js
CHANGED
|
@@ -105,7 +105,9 @@ function compileTemplate (source, options, compile) {
|
|
|
105
105
|
|
|
106
106
|
const compilerModule = {
|
|
107
107
|
preTransformNode (el, options) {
|
|
108
|
-
|
|
108
|
+
const supportedPlatforms = ['mp-weixin', 'mp-jd']
|
|
109
|
+
const unsupportedPlatforms = ['mp-xhs', 'mp-kuaishou'] // 小红书和快手无原生 match-media 组件,使用 uni-match-media 组件会报错 uni.createMediaQueryObserver is not a function
|
|
110
|
+
if (el.tag === 'match-media' && ![...supportedPlatforms, ...unsupportedPlatforms].includes(process.env.UNI_PLATFORM)) {
|
|
109
111
|
el.tag = 'uni-match-media'
|
|
110
112
|
}
|
|
111
113
|
if (process.env.UNI_PLATFORM === 'quickapp-native') {
|
package/lib/mp.js
CHANGED
|
@@ -1,186 +1,8 @@
|
|
|
1
1
|
const uniI18n = require('@dcloudio/uni-cli-i18n')
|
|
2
|
-
const {
|
|
3
|
-
|
|
2
|
+
const { tags } = require('./native-tags')
|
|
4
3
|
const EVENTS = {
|
|
5
4
|
click: 'tap'
|
|
6
5
|
}
|
|
7
|
-
// UNI_INPUT_DIR 在 test 环境下不存在
|
|
8
|
-
const manifestJson = process.env.UNI_INPUT_DIR ? getManifestJson() : {}
|
|
9
|
-
const nativeTags = (manifestJson[process.env.UNI_PLATFORM] || {}).nativeTags || []
|
|
10
|
-
const tags = {
|
|
11
|
-
// 小程序平台通用组件
|
|
12
|
-
base: [
|
|
13
|
-
'slot',
|
|
14
|
-
'block',
|
|
15
|
-
'component',
|
|
16
|
-
'template',
|
|
17
|
-
|
|
18
|
-
'ad',
|
|
19
|
-
'audio',
|
|
20
|
-
'button',
|
|
21
|
-
'camera',
|
|
22
|
-
'canvas',
|
|
23
|
-
'checkbox',
|
|
24
|
-
'checkbox-group',
|
|
25
|
-
'cover-image',
|
|
26
|
-
'cover-view',
|
|
27
|
-
'form',
|
|
28
|
-
'functional-page-navigator',
|
|
29
|
-
'icon',
|
|
30
|
-
'image',
|
|
31
|
-
'input',
|
|
32
|
-
'label',
|
|
33
|
-
'live-player',
|
|
34
|
-
'live-pusher',
|
|
35
|
-
'map',
|
|
36
|
-
'movable-area',
|
|
37
|
-
'movable-view',
|
|
38
|
-
'navigator',
|
|
39
|
-
'official-account',
|
|
40
|
-
'open-data',
|
|
41
|
-
'picker',
|
|
42
|
-
'picker-view',
|
|
43
|
-
'picker-view-column',
|
|
44
|
-
'progress',
|
|
45
|
-
'radio',
|
|
46
|
-
'radio-group',
|
|
47
|
-
'rich-text',
|
|
48
|
-
'scroll-view',
|
|
49
|
-
'slider',
|
|
50
|
-
'swiper',
|
|
51
|
-
'swiper-item',
|
|
52
|
-
'switch',
|
|
53
|
-
'text',
|
|
54
|
-
'textarea',
|
|
55
|
-
'video',
|
|
56
|
-
'view',
|
|
57
|
-
'web-view',
|
|
58
|
-
'editor'
|
|
59
|
-
],
|
|
60
|
-
'mp-baidu': [
|
|
61
|
-
'animation-video',
|
|
62
|
-
'animation-view',
|
|
63
|
-
'ar-camera',
|
|
64
|
-
'rtc-room',
|
|
65
|
-
'rtc-room-item',
|
|
66
|
-
'tabs',
|
|
67
|
-
'tab-item',
|
|
68
|
-
'follow-swan',
|
|
69
|
-
'login',
|
|
70
|
-
'inline-payment-panel',
|
|
71
|
-
'talos-linear-gradient',
|
|
72
|
-
'talos-rc-view',
|
|
73
|
-
'talos-nested-scroll-view',
|
|
74
|
-
'talos-nested-scroll-top-container',
|
|
75
|
-
'talos-nested-scroll-bottom-container',
|
|
76
|
-
'talos-waterfall-view',
|
|
77
|
-
'talos-waterfall-item',
|
|
78
|
-
'talos-waterfall-header',
|
|
79
|
-
'talos-waterfall-footer',
|
|
80
|
-
'talos-pull-refresh',
|
|
81
|
-
'talos-control-container',
|
|
82
|
-
'talos-na-refresh-control',
|
|
83
|
-
'talos-modal',
|
|
84
|
-
'talos-svg',
|
|
85
|
-
...nativeTags
|
|
86
|
-
],
|
|
87
|
-
'mp-weixin': [
|
|
88
|
-
'page-container',
|
|
89
|
-
'page-meta',
|
|
90
|
-
'navigation-bar',
|
|
91
|
-
'match-media',
|
|
92
|
-
'share-element',
|
|
93
|
-
'channel-live',
|
|
94
|
-
'channel-video',
|
|
95
|
-
'voip-room',
|
|
96
|
-
'root-portal',
|
|
97
|
-
'subscribe',
|
|
98
|
-
// 手势组件
|
|
99
|
-
'tap-gesture-handler',
|
|
100
|
-
'double-tap-gesture-handler',
|
|
101
|
-
'scale-gesture-handler',
|
|
102
|
-
'force-press-gesture-handler',
|
|
103
|
-
'pan-gesture-handler',
|
|
104
|
-
'vertical-drag-gesture-handler',
|
|
105
|
-
'horizontal-drag-gesture-handler',
|
|
106
|
-
'long-press-gesture-handler',
|
|
107
|
-
// 其他
|
|
108
|
-
'draggable-sheet',
|
|
109
|
-
'grid-builder',
|
|
110
|
-
'grid-view',
|
|
111
|
-
'list-view',
|
|
112
|
-
'list-builder',
|
|
113
|
-
'nested-scroll-body',
|
|
114
|
-
'nested-scroll-header',
|
|
115
|
-
'open-container',
|
|
116
|
-
'share-element',
|
|
117
|
-
'snapshot',
|
|
118
|
-
// 'span', // todo: 临时移除 span 的支持,后续判断 skyline 环境进行区分 ask 190418
|
|
119
|
-
'sticky-header',
|
|
120
|
-
'sticky-section',
|
|
121
|
-
'store-product',
|
|
122
|
-
'store-home',
|
|
123
|
-
'store-gift',
|
|
124
|
-
'store-coupon',
|
|
125
|
-
'open-data-list',
|
|
126
|
-
'open-data-item',
|
|
127
|
-
'selection',
|
|
128
|
-
...nativeTags
|
|
129
|
-
],
|
|
130
|
-
// 支付宝小程序平台独有组件
|
|
131
|
-
'mp-alipay': [
|
|
132
|
-
'lifestyle',
|
|
133
|
-
'life-follow',
|
|
134
|
-
'contact-button',
|
|
135
|
-
'spread',
|
|
136
|
-
'error-view',
|
|
137
|
-
'poster',
|
|
138
|
-
'cashier',
|
|
139
|
-
'ix-grid',
|
|
140
|
-
'ix-native-grid',
|
|
141
|
-
'ix-native-list',
|
|
142
|
-
'mkt',
|
|
143
|
-
'page-container',
|
|
144
|
-
'page-meta',
|
|
145
|
-
'root-portal',
|
|
146
|
-
'share-element',
|
|
147
|
-
'lottie',
|
|
148
|
-
'join-group-chat',
|
|
149
|
-
'subscribe-message',
|
|
150
|
-
'mpass-component',
|
|
151
|
-
...nativeTags
|
|
152
|
-
],
|
|
153
|
-
// 抖音小程序平台独有组件
|
|
154
|
-
'mp-toutiao': [
|
|
155
|
-
'draw-ad',
|
|
156
|
-
'aweme-data',
|
|
157
|
-
'consume-card',
|
|
158
|
-
'pay-button',
|
|
159
|
-
'rate-button',
|
|
160
|
-
'member-button',
|
|
161
|
-
'confirm-receipt-button',
|
|
162
|
-
'live-preview',
|
|
163
|
-
'aweme-live-book',
|
|
164
|
-
'aweme-user-card',
|
|
165
|
-
'rtc-room',
|
|
166
|
-
'clue-order-form',
|
|
167
|
-
'shop-follow-card',
|
|
168
|
-
...nativeTags
|
|
169
|
-
],
|
|
170
|
-
'mp-kuaishou': [
|
|
171
|
-
'follow-service',
|
|
172
|
-
'payment-list',
|
|
173
|
-
'playlet',
|
|
174
|
-
'address',
|
|
175
|
-
'page-meta',
|
|
176
|
-
'navigation-bar',
|
|
177
|
-
...nativeTags
|
|
178
|
-
],
|
|
179
|
-
'mp-xhs': ['post-note-button', 'group-chat-card', ...nativeTags],
|
|
180
|
-
'mp-jd': ['root-portal', 'page-container', ...nativeTags],
|
|
181
|
-
'mp-qq': [...nativeTags],
|
|
182
|
-
'mp-harmony': [...nativeTags]
|
|
183
|
-
}
|
|
184
6
|
|
|
185
7
|
const baseCompiler = {
|
|
186
8
|
ref: 'data-ref',
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
const { getManifestJson } = require('@dcloudio/uni-cli-shared/lib/manifest')
|
|
2
|
+
|
|
3
|
+
// UNI_INPUT_DIR 在 test 环境下不存在
|
|
4
|
+
const manifestJson = process.env.UNI_INPUT_DIR ? getManifestJson() : {}
|
|
5
|
+
const nativeTags = (manifestJson[process.env.UNI_PLATFORM] || {}).nativeTags || []
|
|
6
|
+
const tags = {
|
|
7
|
+
// 小程序平台通用组件
|
|
8
|
+
base: [
|
|
9
|
+
'slot',
|
|
10
|
+
'block',
|
|
11
|
+
'component',
|
|
12
|
+
'template',
|
|
13
|
+
|
|
14
|
+
'ad',
|
|
15
|
+
'audio',
|
|
16
|
+
'button',
|
|
17
|
+
'camera',
|
|
18
|
+
'canvas',
|
|
19
|
+
'checkbox',
|
|
20
|
+
'checkbox-group',
|
|
21
|
+
'cover-image',
|
|
22
|
+
'cover-view',
|
|
23
|
+
'form',
|
|
24
|
+
'functional-page-navigator',
|
|
25
|
+
'icon',
|
|
26
|
+
'image',
|
|
27
|
+
'input',
|
|
28
|
+
'label',
|
|
29
|
+
'live-player',
|
|
30
|
+
'live-pusher',
|
|
31
|
+
'map',
|
|
32
|
+
'movable-area',
|
|
33
|
+
'movable-view',
|
|
34
|
+
'navigator',
|
|
35
|
+
'official-account',
|
|
36
|
+
'open-data',
|
|
37
|
+
'picker',
|
|
38
|
+
'picker-view',
|
|
39
|
+
'picker-view-column',
|
|
40
|
+
'progress',
|
|
41
|
+
'radio',
|
|
42
|
+
'radio-group',
|
|
43
|
+
'rich-text',
|
|
44
|
+
'scroll-view',
|
|
45
|
+
'slider',
|
|
46
|
+
'swiper',
|
|
47
|
+
'swiper-item',
|
|
48
|
+
'switch',
|
|
49
|
+
'text',
|
|
50
|
+
'textarea',
|
|
51
|
+
'video',
|
|
52
|
+
'view',
|
|
53
|
+
'web-view',
|
|
54
|
+
'editor'
|
|
55
|
+
],
|
|
56
|
+
'mp-baidu': [
|
|
57
|
+
'animation-video',
|
|
58
|
+
'animation-view',
|
|
59
|
+
'ar-camera',
|
|
60
|
+
'rtc-room',
|
|
61
|
+
'rtc-room-item',
|
|
62
|
+
'tabs',
|
|
63
|
+
'tab-item',
|
|
64
|
+
'follow-swan',
|
|
65
|
+
'login',
|
|
66
|
+
'inline-payment-panel',
|
|
67
|
+
'talos-linear-gradient',
|
|
68
|
+
'talos-rc-view',
|
|
69
|
+
'talos-nested-scroll-view',
|
|
70
|
+
'talos-nested-scroll-top-container',
|
|
71
|
+
'talos-nested-scroll-bottom-container',
|
|
72
|
+
'talos-waterfall-view',
|
|
73
|
+
'talos-waterfall-item',
|
|
74
|
+
'talos-waterfall-header',
|
|
75
|
+
'talos-waterfall-footer',
|
|
76
|
+
'talos-pull-refresh',
|
|
77
|
+
'talos-control-container',
|
|
78
|
+
'talos-na-refresh-control',
|
|
79
|
+
'talos-modal',
|
|
80
|
+
'talos-svg',
|
|
81
|
+
...nativeTags
|
|
82
|
+
],
|
|
83
|
+
'mp-weixin': [
|
|
84
|
+
'channel-live',
|
|
85
|
+
'channel-video',
|
|
86
|
+
'double-tap-gesture-handler',
|
|
87
|
+
'draggable-sheet',
|
|
88
|
+
'editor-portal',
|
|
89
|
+
'force-press-gesture-handler',
|
|
90
|
+
'grid-builder',
|
|
91
|
+
'grid-view',
|
|
92
|
+
'horizontal-drag-gesture-handler',
|
|
93
|
+
'keyboard-accessory',
|
|
94
|
+
'list-builder',
|
|
95
|
+
'list-view',
|
|
96
|
+
'long-press-gesture-handler',
|
|
97
|
+
'match-media',
|
|
98
|
+
'navigation-bar',
|
|
99
|
+
'nested-scroll-body',
|
|
100
|
+
'nested-scroll-header',
|
|
101
|
+
'official-account-publish',
|
|
102
|
+
'open-container',
|
|
103
|
+
'open-data-list',
|
|
104
|
+
'open-data-item',
|
|
105
|
+
'page-container',
|
|
106
|
+
'page-meta',
|
|
107
|
+
'pan-gesture-handler',
|
|
108
|
+
'root-portal',
|
|
109
|
+
'scale-gesture-handler',
|
|
110
|
+
'selection',
|
|
111
|
+
'share-element',
|
|
112
|
+
'snapshot',
|
|
113
|
+
'sticky-header',
|
|
114
|
+
'sticky-section',
|
|
115
|
+
'store-coupon',
|
|
116
|
+
'store-gift',
|
|
117
|
+
'store-home',
|
|
118
|
+
'store-product',
|
|
119
|
+
'subscribe',
|
|
120
|
+
'tap-gesture-handler',
|
|
121
|
+
'vertical-drag-gesture-handler',
|
|
122
|
+
'voip-room',
|
|
123
|
+
|
|
124
|
+
// 'span', // todo: 临时移除 span 的支持,后续判断 skyline 环境进行区分 ask 190418
|
|
125
|
+
...nativeTags
|
|
126
|
+
],
|
|
127
|
+
// 支付宝小程序平台独有组件
|
|
128
|
+
'mp-alipay': [
|
|
129
|
+
'lifestyle',
|
|
130
|
+
'life-follow',
|
|
131
|
+
'contact-button',
|
|
132
|
+
'spread',
|
|
133
|
+
'error-view',
|
|
134
|
+
'poster',
|
|
135
|
+
'cashier',
|
|
136
|
+
'ix-grid',
|
|
137
|
+
'ix-native-grid',
|
|
138
|
+
'ix-native-list',
|
|
139
|
+
'mkt',
|
|
140
|
+
'page-container',
|
|
141
|
+
'page-meta',
|
|
142
|
+
'root-portal',
|
|
143
|
+
'share-element',
|
|
144
|
+
'lottie',
|
|
145
|
+
'join-group-chat',
|
|
146
|
+
'subscribe-message',
|
|
147
|
+
'mpass-component',
|
|
148
|
+
'ad-feeds',
|
|
149
|
+
...nativeTags
|
|
150
|
+
],
|
|
151
|
+
// 抖音小程序平台独有组件
|
|
152
|
+
'mp-toutiao': [
|
|
153
|
+
'draw-ad',
|
|
154
|
+
'aweme-data',
|
|
155
|
+
'consume-card',
|
|
156
|
+
'pay-button',
|
|
157
|
+
'rate-button',
|
|
158
|
+
'member-button',
|
|
159
|
+
'confirm-receipt-button',
|
|
160
|
+
'live-preview',
|
|
161
|
+
'aweme-live-book',
|
|
162
|
+
'aweme-user-card',
|
|
163
|
+
'rtc-room',
|
|
164
|
+
'clue-order-form',
|
|
165
|
+
'shop-follow-card',
|
|
166
|
+
'mask',
|
|
167
|
+
'video-player',
|
|
168
|
+
...nativeTags
|
|
169
|
+
],
|
|
170
|
+
'mp-kuaishou': [
|
|
171
|
+
'follow-service',
|
|
172
|
+
'payment-list',
|
|
173
|
+
'playlet',
|
|
174
|
+
'address',
|
|
175
|
+
'page-meta',
|
|
176
|
+
'navigation-bar',
|
|
177
|
+
...nativeTags
|
|
178
|
+
],
|
|
179
|
+
'mp-xhs': ['post-note-button', 'group-chat-card', 'video-player', ...nativeTags],
|
|
180
|
+
'mp-jd': ['root-portal', 'page-container', 'match-media', ...nativeTags],
|
|
181
|
+
'mp-qq': [...nativeTags],
|
|
182
|
+
'mp-harmony': [...nativeTags]
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
module.exports = {
|
|
186
|
+
tags
|
|
187
|
+
}
|
|
@@ -11,6 +11,8 @@ const {
|
|
|
11
11
|
isVForElement
|
|
12
12
|
} = require('../../../util')
|
|
13
13
|
|
|
14
|
+
const transPlatform = ['mp-toutiao', 'mp-alipay', 'mp-lark']
|
|
15
|
+
|
|
14
16
|
function processClassArrayExpressionElements (classArrayExpression) {
|
|
15
17
|
let binaryExpression
|
|
16
18
|
|
|
@@ -45,7 +47,6 @@ function processStaticClass (classArrayExpression, staticClassPath, state) {
|
|
|
45
47
|
staticClassPath.remove()
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
const transPlatform = ['mp-toutiao', 'mp-alipay', 'mp-lark']
|
|
49
50
|
if (transPlatform.includes(state.options.platform.name)) {
|
|
50
51
|
// classArrayExpression => binaryExpression
|
|
51
52
|
return processClassArrayExpressionElements(classArrayExpression)
|
|
@@ -126,7 +127,7 @@ module.exports = function processClass (paths, path, state) {
|
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
if (mergeVirtualHostAttributes && isRootElement(path.parentPath) && !isVForElement(path.parentPath)) {
|
|
129
|
-
const virtualHostClass = t.identifier(VIRTUAL_HOST_CLASS)
|
|
130
|
+
const virtualHostClass = transPlatform.includes(state.options.platform.name) ? t.logicalExpression('||', t.identifier(VIRTUAL_HOST_CLASS), t.stringLiteral('')) : t.identifier(VIRTUAL_HOST_CLASS)
|
|
130
131
|
if (classArrayExpression) {
|
|
131
132
|
classArrayExpression.elements.push(virtualHostClass)
|
|
132
133
|
} else {
|
|
@@ -86,7 +86,7 @@ function processStyleObjectExpression (styleValuePath) {
|
|
|
86
86
|
'+',
|
|
87
87
|
t.binaryExpression(
|
|
88
88
|
'+',
|
|
89
|
-
t.stringLiteral(hyphenate(key.name || key.value) + ':'),
|
|
89
|
+
propertyPath.node.computed ? t.binaryExpression('+', t.parenthesizedExpression(key), t.stringLiteral(':')) : t.stringLiteral(hyphenate(key.name || key.value) + ':'),
|
|
90
90
|
t.parenthesizedExpression(propertyPath.node.value)
|
|
91
91
|
),
|
|
92
92
|
t.stringLiteral(';')
|
package/lib/template/generate.js
CHANGED
|
@@ -44,7 +44,7 @@ function processElement (ast, state, isRoot) {
|
|
|
44
44
|
if (platform.isComponent(ast.type)) {
|
|
45
45
|
if (platformName === 'mp-alipay') {
|
|
46
46
|
ast.attr.onVueInit = INTERNAL_EVENT_LINK
|
|
47
|
-
} else if (platformName !== 'mp-baidu') {
|
|
47
|
+
} else if (platformName !== 'mp-baidu' && platformName !== 'mp-harmony') {
|
|
48
48
|
ast.attr['bind:' + INTERNAL_EVENT_LINK] = INTERNAL_EVENT_LINK
|
|
49
49
|
}
|
|
50
50
|
// TODO 过滤小程序原生组件
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-template-compiler",
|
|
3
|
-
"version": "2.0.2-alpha-
|
|
3
|
+
"version": "2.0.2-alpha-5000020260203001",
|
|
4
4
|
"description": "uni-template-compiler",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"@babel/types": "^7.3.3",
|
|
24
24
|
"vue-template-compiler": "^2.6.10"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "87ec9e5606a61868b10428184badb099ac9bffd6"
|
|
27
27
|
}
|