@mpxjs/webpack-plugin 2.8.56 → 2.8.59
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/index.js
CHANGED
|
@@ -173,12 +173,6 @@ class MpxWebpackPlugin {
|
|
|
173
173
|
options.retryRequireAsync = options.retryRequireAsync || false
|
|
174
174
|
options.enableAliRequireAsync = options.enableAliRequireAsync || false
|
|
175
175
|
options.optimizeSize = options.optimizeSize || false
|
|
176
|
-
let proxyComponentEventsRules = []
|
|
177
|
-
const proxyComponentEventsRulesRaw = options.proxyComponentEventsRules
|
|
178
|
-
if (proxyComponentEventsRulesRaw) {
|
|
179
|
-
proxyComponentEventsRules = Array.isArray(proxyComponentEventsRulesRaw) ? proxyComponentEventsRulesRaw : [proxyComponentEventsRulesRaw]
|
|
180
|
-
}
|
|
181
|
-
options.proxyComponentEventsRules = proxyComponentEventsRules
|
|
182
176
|
this.options = options
|
|
183
177
|
// Hack for buildDependencies
|
|
184
178
|
const rawResolveBuildDependencies = FileSystemInfo.prototype.resolveBuildDependencies
|
|
@@ -646,7 +640,6 @@ class MpxWebpackPlugin {
|
|
|
646
640
|
enableRequireAsync: this.options.mode === 'wx' || (this.options.mode === 'ali' && this.options.enableAliRequireAsync),
|
|
647
641
|
partialCompile: this.options.partialCompile,
|
|
648
642
|
asyncSubpackageRules: this.options.asyncSubpackageRules,
|
|
649
|
-
proxyComponentEventsRules: this.options.proxyComponentEventsRules,
|
|
650
643
|
pathHash: (resourcePath) => {
|
|
651
644
|
if (this.options.pathHashMode === 'relative' && this.options.projectRoot) {
|
|
652
645
|
return hash(path.relative(this.options.projectRoot, resourcePath))
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<video
|
|
3
3
|
ref="_mpx_video_ref"
|
|
4
|
-
|
|
5
|
-
:src="src"
|
|
6
|
-
:controls="showControlsTool"
|
|
7
|
-
:autoplay="autoplay"
|
|
8
|
-
:loop="loop"
|
|
9
|
-
:muted="mutedCopy"
|
|
10
|
-
:poster="poster"
|
|
4
|
+
class="video-js"
|
|
11
5
|
v-bind="playsinlineAttr"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<script>
|
|
6
|
+
></video>
|
|
7
|
+
</template>
|
|
8
|
+
<script>
|
|
17
9
|
import { inheritEvent } from './getInnerListeners'
|
|
10
|
+
import videojs from 'video.js'
|
|
11
|
+
import 'video.js/dist/video-js.min.css'
|
|
18
12
|
|
|
19
13
|
export default {
|
|
20
14
|
name: 'mpx-video',
|
|
@@ -54,7 +48,7 @@
|
|
|
54
48
|
type: Boolean,
|
|
55
49
|
default: false
|
|
56
50
|
},
|
|
57
|
-
initialTime: {
|
|
51
|
+
initialTime: {
|
|
58
52
|
type: Number,
|
|
59
53
|
default: 0
|
|
60
54
|
},
|
|
@@ -63,6 +57,10 @@
|
|
|
63
57
|
type: Boolean,
|
|
64
58
|
default: true
|
|
65
59
|
},
|
|
60
|
+
showBottomProgress: { // done
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: true
|
|
63
|
+
},
|
|
66
64
|
showFullscreenBtn: { // done
|
|
67
65
|
type: Boolean,
|
|
68
66
|
default: true
|
|
@@ -125,135 +123,166 @@
|
|
|
125
123
|
default: false
|
|
126
124
|
},
|
|
127
125
|
playsinline: {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
},
|
|
132
|
-
computed: {
|
|
133
|
-
playsinlineAttr () {
|
|
134
|
-
if (!this.playsinline) return {}
|
|
135
|
-
return {
|
|
136
|
-
'webkit-playsinline': true,
|
|
137
|
-
'playsinline': true,
|
|
138
|
-
'x5-playsinline': true
|
|
139
|
-
}
|
|
140
|
-
}
|
|
126
|
+
type: Boolean,
|
|
127
|
+
default: true
|
|
128
|
+
}
|
|
141
129
|
},
|
|
142
130
|
data () {
|
|
143
131
|
return {
|
|
144
|
-
showControlsTool: this.controls,
|
|
145
|
-
mutedCopy: this.muted,
|
|
146
|
-
classList: ''
|
|
147
132
|
}
|
|
148
133
|
},
|
|
134
|
+
computed: {
|
|
135
|
+
playsinlineAttr () {
|
|
136
|
+
if (!this.playsinline) return {}
|
|
137
|
+
return {
|
|
138
|
+
'webkit-playsinline': true,
|
|
139
|
+
'playsinline': true,
|
|
140
|
+
'x5-playsinline': true,
|
|
141
|
+
'x5-video-orientation': 'landscape|portrait'
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
149
145
|
watch: {
|
|
150
|
-
muted (val) {
|
|
151
|
-
this.
|
|
146
|
+
muted: function (val) {
|
|
147
|
+
this._player?.muted(val)
|
|
148
|
+
},
|
|
149
|
+
controls: function (show) {
|
|
150
|
+
this.$emit('controlstoggle', inheritEvent('controlstoggle', {}, { show }))
|
|
152
151
|
}
|
|
153
152
|
},
|
|
154
153
|
mounted () {
|
|
154
|
+
const videoNode = this.$refs['_mpx_video_ref']
|
|
155
|
+
this._player = videojs(videoNode, {
|
|
156
|
+
controls: true,
|
|
157
|
+
sources:[
|
|
158
|
+
{
|
|
159
|
+
src: this.src
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
autoplay: this.autoplay,
|
|
163
|
+
loop: this.loop,
|
|
164
|
+
/**
|
|
165
|
+
log 若 controls 属性值为 false 则设置 poster 无效
|
|
166
|
+
*/
|
|
167
|
+
poster: this.controls ? this.poster : ''
|
|
168
|
+
}, function () {
|
|
169
|
+
})
|
|
170
|
+
this.initPlayer()
|
|
155
171
|
this.initStyle()
|
|
156
172
|
this.initEvent()
|
|
157
173
|
},
|
|
158
174
|
methods: {
|
|
159
|
-
|
|
160
|
-
|
|
175
|
+
initPlayer () {
|
|
176
|
+
this._player.muted(this.muted)
|
|
161
177
|
if (this.initialTime) {
|
|
162
|
-
|
|
178
|
+
this._player.currentTime(this.initialTime)
|
|
163
179
|
}
|
|
164
|
-
if (this.autoplay) { // log 解决autoplay无法自动播放问题
|
|
165
|
-
this.mutedCopy = true
|
|
166
|
-
}
|
|
167
|
-
if (!this.showProgress) this.classList += ' mpx-no-show_progress'
|
|
168
|
-
if (!this.showFullscreenBtn) this.classList += ' mpx-no-show_fullscreen_btn'
|
|
169
|
-
if (!this.showPlayBtn) this.classList += ' mpx-no-show_play_btn'
|
|
170
|
-
if (!this.showCenterPlayBtn) this.classList += ' mpx-no-show_center_play_btn'
|
|
171
|
-
if (!this.showMuteBtn) this.classList += ' mpx-no-show_mute_btn'
|
|
172
180
|
},
|
|
173
|
-
|
|
174
|
-
|
|
181
|
+
initStyle () {
|
|
182
|
+
if (!this.controls) this._player.el_.classList.add('mpx-no-show_controls')
|
|
183
|
+
|
|
184
|
+
if (!this.showBottomProgress) this._player.el_.classList.add('mpx-no-show_progress')
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
showProgress若不设置,宽度大于240时才会显示
|
|
188
|
+
*/
|
|
189
|
+
if (!this.showProgress || (this._player.el_.offsetWidth < 240 && this.showProgress)) this._player.el_.classList.add('mpx-no-show_progress')
|
|
175
190
|
|
|
176
|
-
|
|
191
|
+
if (!this.showFullscreenBtn) this._player.el_.classList.add('mpx-no-show_fullscreen_btn')
|
|
192
|
+
|
|
193
|
+
if (!this.showPlayBtn) this._player.el_.classList.add('mpx-no-show_play_btn')
|
|
194
|
+
|
|
195
|
+
if (!this.showCenterPlayBtn) this._player.el_.classList.add('mpx-no-show_center_play_btn')
|
|
196
|
+
|
|
197
|
+
if (!this.showMuteBtn) this._player.el_.classList.add('mpx-no-show_mute_btn')
|
|
198
|
+
},
|
|
199
|
+
initEvent () {
|
|
200
|
+
this._player.on('play', (e) => {
|
|
177
201
|
this.$emit('play', inheritEvent('play', e, {}))
|
|
178
202
|
})
|
|
179
203
|
|
|
180
|
-
|
|
204
|
+
this._player.on('pause', (e) => {
|
|
181
205
|
this.$emit('pause', inheritEvent('pause', e, {}))
|
|
182
206
|
})
|
|
183
207
|
|
|
184
|
-
|
|
208
|
+
this._player.on('ended', (e) => {
|
|
185
209
|
this.$emit('ended', inheritEvent('ended', e, {}))
|
|
186
210
|
})
|
|
187
211
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
this.$emit('timeupdate', inheritEvent('timeupdate', e, { currentTime: eNode.currentTime, duration: eNode.duration }))
|
|
212
|
+
this._player.on('timeupdate', (e) => {
|
|
213
|
+
this.$emit('timeupdate', inheritEvent('timeupdate', e, {}))
|
|
191
214
|
})
|
|
192
215
|
|
|
193
|
-
|
|
216
|
+
this._player.on('error', (e) => {
|
|
194
217
|
this.$emit('error', inheritEvent('error', e, {}))
|
|
195
218
|
})
|
|
196
219
|
|
|
197
|
-
|
|
220
|
+
this._player.on('waiting', (e) => {
|
|
198
221
|
this.$emit('waiting', inheritEvent('waiting', e, {}))
|
|
199
222
|
})
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const eNode = e.target
|
|
203
|
-
this.$emit('loadedmetadata', inheritEvent('loadedmetadata', e, { width: eNode.videoWidth, height: eNode.videoHeight, duration: eNode.duration }))
|
|
223
|
+
this._player.on('loadedmetadata', (e) => {
|
|
224
|
+
this.$emit('loadedmetadata', inheritEvent('loadedmetadata', e, {}))
|
|
204
225
|
})
|
|
205
226
|
|
|
206
|
-
|
|
227
|
+
this._player.on('progress', (e) => {
|
|
207
228
|
const eNode = e.target
|
|
208
229
|
const buffered = (eNode?.buffered?.end(0)) / (eNode?.duration)
|
|
209
230
|
this.$emit('progress', inheritEvent('progress', e, { buffered: buffered * 100 }))
|
|
210
231
|
})
|
|
211
232
|
|
|
212
|
-
|
|
233
|
+
this._player.on('seeked', (e) => {
|
|
213
234
|
const eNode = e.target
|
|
214
|
-
this.$emit('seekcomplete', inheritEvent('seekcomplete', e, { position: eNode.currentTime
|
|
235
|
+
this.$emit('seekcomplete', inheritEvent('seekcomplete', e, { position: eNode.currentTime }))
|
|
215
236
|
})
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
this.$emit('fullscreenchange', inheritEvent('fullscreenchange', e, { fullScreen: false }))
|
|
237
|
+
this._player.on('fullscreenchange', (e) => {
|
|
238
|
+
if (!this._player.paused()) {
|
|
239
|
+
// hack: 解决退出全屏自动暂停
|
|
240
|
+
setTimeout(() => {
|
|
241
|
+
this._player.play()
|
|
242
|
+
}, 500)
|
|
223
243
|
}
|
|
244
|
+
this.$emit('fullscreenchange', inheritEvent('fullscreenchange', e, { fullScreen: this._player.isFullscreen() }))
|
|
224
245
|
})
|
|
225
246
|
|
|
226
|
-
|
|
247
|
+
this._player.on('enterpictureinpicture', (e) => {
|
|
227
248
|
this.$emit('enterpictureinpicture', inheritEvent('enterpictureinpicture', e, {}))
|
|
228
249
|
})
|
|
229
250
|
|
|
230
|
-
|
|
251
|
+
this._player.on('leavepictureinpicture', (e) => {
|
|
231
252
|
this.$emit('leavepictureinpicture', inheritEvent('leavepictureinpicture', e, {}))
|
|
232
253
|
})
|
|
254
|
+
|
|
233
255
|
}
|
|
234
256
|
}
|
|
235
257
|
}
|
|
236
|
-
</script>
|
|
258
|
+
</script>
|
|
259
|
+
|
|
260
|
+
<style lang="stylus">
|
|
261
|
+
|
|
262
|
+
.vjs-chapters-button
|
|
263
|
+
display: none !important
|
|
264
|
+
|
|
265
|
+
.mpx-no-show_controls
|
|
266
|
+
.vjs-control-bar
|
|
267
|
+
display none !important
|
|
237
268
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
&::-webkit-media-controls-timeline
|
|
242
|
-
display none !important
|
|
269
|
+
.mpx-no-show_progress
|
|
270
|
+
.vjs-progress-control
|
|
271
|
+
display none !important
|
|
243
272
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
273
|
+
.mpx-no-show_fullscreen_btn
|
|
274
|
+
.vjs-fullscreen-control
|
|
275
|
+
display none !important
|
|
247
276
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
277
|
+
.mpx-no-show_play_btn
|
|
278
|
+
.vjs-play-control
|
|
279
|
+
display none !important
|
|
251
280
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
281
|
+
.mpx-no-show_center_play_btn
|
|
282
|
+
.vjs-big-play-button
|
|
283
|
+
display none !important
|
|
255
284
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
</style>
|
|
285
|
+
.mpx-no-show_mute_btn
|
|
286
|
+
.vjs-mute-control
|
|
287
|
+
display none !important
|
|
288
|
+
</style>
|
|
@@ -96,6 +96,16 @@ function checkDelAndGetPath (path) {
|
|
|
96
96
|
} else {
|
|
97
97
|
delPath = current.parentPath
|
|
98
98
|
}
|
|
99
|
+
} else if (t.isLogicalExpression(current.container)) { // case: a || ''
|
|
100
|
+
const key = current.key === 'left' ? 'right' : 'left'
|
|
101
|
+
if (t.isLiteral(current.parent[key])) {
|
|
102
|
+
delPath = current.parentPath
|
|
103
|
+
} else {
|
|
104
|
+
canDel = false
|
|
105
|
+
break
|
|
106
|
+
}
|
|
107
|
+
} else if (current.key === 'expression' && t.isExpressionStatement(current.parentPath)) { // dealRemove删除节点时需要
|
|
108
|
+
delPath = current.parentPath
|
|
99
109
|
} else {
|
|
100
110
|
break
|
|
101
111
|
}
|
|
@@ -152,10 +162,6 @@ function checkPrefix (keys, key) {
|
|
|
152
162
|
}
|
|
153
163
|
|
|
154
164
|
function dealRemove (path, replace) {
|
|
155
|
-
while (path.key === 'expression' && t.isExpressionStatement(path.parentPath)) {
|
|
156
|
-
path = path.parentPath
|
|
157
|
-
}
|
|
158
|
-
|
|
159
165
|
try {
|
|
160
166
|
if (replace) {
|
|
161
167
|
path.replaceWith(t.stringLiteral(''))
|
|
@@ -163,9 +169,7 @@ function dealRemove (path, replace) {
|
|
|
163
169
|
t.validate(path, path.key, null)
|
|
164
170
|
path.remove()
|
|
165
171
|
}
|
|
166
|
-
} catch (e) {
|
|
167
|
-
console.error(e)
|
|
168
|
-
}
|
|
172
|
+
} catch (e) {}
|
|
169
173
|
}
|
|
170
174
|
|
|
171
175
|
module.exports = {
|
|
@@ -202,9 +206,23 @@ module.exports = {
|
|
|
202
206
|
Identifier (path) {
|
|
203
207
|
if (
|
|
204
208
|
checkBindThis(path) &&
|
|
205
|
-
!path.scope.hasBinding(path.node.name) &&
|
|
206
209
|
!ignoreMap[path.node.name]
|
|
207
210
|
) {
|
|
211
|
+
const scopeBinding = path.scope.hasBinding(path.node.name)
|
|
212
|
+
// 删除局部作用域的变量
|
|
213
|
+
if (scopeBinding) {
|
|
214
|
+
if (renderReduce) {
|
|
215
|
+
const { delPath, canDel, ignore, replace } = checkDelAndGetPath(path)
|
|
216
|
+
if (canDel && !ignore) {
|
|
217
|
+
delPath.delInfo = {
|
|
218
|
+
isLocal: true,
|
|
219
|
+
canDel,
|
|
220
|
+
replace
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return
|
|
225
|
+
}
|
|
208
226
|
const { last, keyPath } = calPropName(path)
|
|
209
227
|
path.needBind = true
|
|
210
228
|
if (needCollect) {
|
|
@@ -272,10 +290,14 @@ module.exports = {
|
|
|
272
290
|
enter (path) {
|
|
273
291
|
// 删除重复变量
|
|
274
292
|
if (path.delInfo) {
|
|
275
|
-
const { keyPath, canDel, replace } = path.delInfo
|
|
293
|
+
const { keyPath, canDel, isLocal, replace } = path.delInfo
|
|
276
294
|
delete path.delInfo
|
|
277
295
|
|
|
278
296
|
if (canDel) {
|
|
297
|
+
if (isLocal) { // 局部作用域里的变量,可直接删除
|
|
298
|
+
dealRemove(path, replace)
|
|
299
|
+
return
|
|
300
|
+
}
|
|
279
301
|
const data = bindingsMap.get(currentBlock)
|
|
280
302
|
const { bindings, pBindings } = data
|
|
281
303
|
const allBindings = Object.assign({}, pBindings, bindings)
|
|
@@ -3,6 +3,7 @@ const he = require('he')
|
|
|
3
3
|
const config = require('../config')
|
|
4
4
|
const { MPX_ROOT_VIEW, MPX_APP_MODULE_ID } = require('../utils/const')
|
|
5
5
|
const normalize = require('../utils/normalize')
|
|
6
|
+
const { normalizeCondition } = require('../utils/match-condition')
|
|
6
7
|
const isValidIdentifierStr = require('../utils/is-valid-identifier-str')
|
|
7
8
|
const isEmptyObject = require('../utils/is-empty-object')
|
|
8
9
|
const getRulesRunner = require('../platform/index')
|
|
@@ -1750,68 +1751,105 @@ function processBuiltInComponents (el, meta) {
|
|
|
1750
1751
|
}
|
|
1751
1752
|
}
|
|
1752
1753
|
|
|
1753
|
-
function
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1754
|
+
function processAliAddComponentRootView (el, options) {
|
|
1755
|
+
const processAttrsConditions = [
|
|
1756
|
+
{ condition: /^(on|catch)Tap$/, action: 'clone' },
|
|
1757
|
+
{ condition: /^(on|catch)TouchStart$/, action: 'clone' },
|
|
1758
|
+
{ condition: /^(on|catch)TouchMove$/, action: 'clone' },
|
|
1759
|
+
{ condition: /^(on|catch)TouchEnd$/, action: 'clone' },
|
|
1760
|
+
{ condition: /^(on|catch)TouchCancel$/, action: 'clone' },
|
|
1761
|
+
{ condition: /^(on|catch)LongTap$/, action: 'clone' },
|
|
1762
|
+
{ condition: /^data-/, action: 'clone' },
|
|
1763
|
+
{ condition: /^id$/, action: 'clone' },
|
|
1764
|
+
{ condition: /^style$/, action: 'move' },
|
|
1765
|
+
{ condition: /^slot$/, action: 'move' }
|
|
1766
|
+
]
|
|
1767
|
+
const processAppendAttrsRules = [
|
|
1768
|
+
{ name: 'class', value: `${MPX_ROOT_VIEW} host-${options.moduleId}` }
|
|
1769
|
+
]
|
|
1770
|
+
const newElAttrs = []
|
|
1771
|
+
const allAttrs = cloneAttrsList(el.attrsList)
|
|
1772
|
+
|
|
1773
|
+
function processClone (attr) {
|
|
1774
|
+
newElAttrs.push(attr)
|
|
1766
1775
|
}
|
|
1767
|
-
}
|
|
1768
1776
|
|
|
1769
|
-
function
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
const sep = name === 'style' ? ';' : ' '
|
|
1774
|
-
value = value ? `{{${typeName}||''}}${sep}${value}` : `{{${typeName}||''}}`
|
|
1775
|
-
return [name, value]
|
|
1776
|
-
}
|
|
1777
|
+
function processMove (attr) {
|
|
1778
|
+
getAndRemoveAttr(el, attr.name)
|
|
1779
|
+
newElAttrs.push(attr)
|
|
1780
|
+
}
|
|
1777
1781
|
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
const
|
|
1781
|
-
const
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1782
|
+
function processAppendRules (el) {
|
|
1783
|
+
processAppendAttrsRules.forEach((rule) => {
|
|
1784
|
+
const getNeedAppendAttrValue = el.attrsMap[rule.name]
|
|
1785
|
+
const value = getNeedAppendAttrValue ? getNeedAppendAttrValue + ' ' + rule.value : rule.value
|
|
1786
|
+
newElAttrs.push({
|
|
1787
|
+
name: rule.name,
|
|
1788
|
+
value
|
|
1785
1789
|
})
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1790
|
+
})
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
processAttrsConditions.forEach(item => {
|
|
1794
|
+
const matcher = normalizeCondition(item.condition)
|
|
1795
|
+
allAttrs.forEach((attr) => {
|
|
1796
|
+
if (matcher(attr.name)) {
|
|
1797
|
+
if (item.action === 'clone') {
|
|
1798
|
+
processClone(attr)
|
|
1799
|
+
} else if (item.action === 'move') {
|
|
1800
|
+
processMove(attr)
|
|
1801
|
+
}
|
|
1791
1802
|
}
|
|
1792
1803
|
})
|
|
1804
|
+
})
|
|
1805
|
+
|
|
1806
|
+
processAppendRules(el)
|
|
1807
|
+
const componentWrapView = createASTElement('view', newElAttrs)
|
|
1808
|
+
moveBaseDirective(componentWrapView, el)
|
|
1809
|
+
if (el.is && el.components) {
|
|
1810
|
+
el = postProcessComponentIs(el)
|
|
1793
1811
|
}
|
|
1812
|
+
|
|
1813
|
+
replaceNode(el, componentWrapView, true)
|
|
1814
|
+
addChild(componentWrapView, el)
|
|
1815
|
+
return componentWrapView
|
|
1794
1816
|
}
|
|
1795
1817
|
|
|
1796
1818
|
// 有virtualHost情况wx组件注入virtualHost。无virtualHost阿里组件注入root-view。其他跳过。
|
|
1797
1819
|
function getVirtualHostRoot (options, meta) {
|
|
1798
|
-
if (srcMode === 'wx'
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1820
|
+
if (srcMode === 'wx') {
|
|
1821
|
+
if (options.isComponent) {
|
|
1822
|
+
if ((mode === 'wx') && options.hasVirtualHost) {
|
|
1823
|
+
// wx组件注入virtualHost配置
|
|
1824
|
+
!meta.options && (meta.options = {})
|
|
1825
|
+
meta.options.virtualHost = true
|
|
1826
|
+
}
|
|
1827
|
+
if ((mode === 'web') && !options.hasVirtualHost) {
|
|
1828
|
+
// ali组件根节点实体化
|
|
1829
|
+
const rootView = createASTElement('view', [
|
|
1830
|
+
{
|
|
1831
|
+
name: 'class',
|
|
1832
|
+
value: `${MPX_ROOT_VIEW} host-${options.moduleId}`
|
|
1833
|
+
},
|
|
1834
|
+
{
|
|
1835
|
+
name: 'v-on',
|
|
1836
|
+
value: '$listeners'
|
|
1837
|
+
}
|
|
1838
|
+
])
|
|
1839
|
+
rootView.hasEvent = true
|
|
1840
|
+
processElement(rootView, rootView, options, meta)
|
|
1841
|
+
return rootView
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
if (options.isPage) {
|
|
1845
|
+
if (mode === 'web') {
|
|
1846
|
+
return createASTElement('div', [
|
|
1847
|
+
{
|
|
1848
|
+
name: 'class',
|
|
1849
|
+
value: 'page'
|
|
1850
|
+
}
|
|
1851
|
+
])
|
|
1852
|
+
}
|
|
1815
1853
|
}
|
|
1816
1854
|
}
|
|
1817
1855
|
return getTempNode()
|
|
@@ -1991,16 +2029,6 @@ function processMpxTagName (el) {
|
|
|
1991
2029
|
}
|
|
1992
2030
|
|
|
1993
2031
|
function processElement (el, root, options, meta) {
|
|
1994
|
-
const transAli = mode === 'ali' && srcMode === 'wx'
|
|
1995
|
-
const transWeb = mode === 'web' && srcMode === 'wx'
|
|
1996
|
-
if (transAli) {
|
|
1997
|
-
processRootViewStyleClassHack(el, options, root)
|
|
1998
|
-
processRootViewEventHack(el, options, root)
|
|
1999
|
-
}
|
|
2000
|
-
if (transWeb) {
|
|
2001
|
-
processRootViewEventHack(el, options, root)
|
|
2002
|
-
}
|
|
2003
|
-
|
|
2004
2032
|
processAtMode(el)
|
|
2005
2033
|
// 如果已经标记了这个元素要被清除,直接return跳过后续处理步骤
|
|
2006
2034
|
if (el._atModeStatus === 'mismatch') {
|
|
@@ -2020,6 +2048,8 @@ function processElement (el, root, options, meta) {
|
|
|
2020
2048
|
|
|
2021
2049
|
processInjectWxs(el, meta)
|
|
2022
2050
|
|
|
2051
|
+
const transAli = mode === 'ali' && srcMode === 'wx'
|
|
2052
|
+
|
|
2023
2053
|
if (mode === 'web') {
|
|
2024
2054
|
// 收集内建组件
|
|
2025
2055
|
processBuiltInComponents(el, meta)
|
|
@@ -2071,7 +2101,11 @@ function closeElement (el, meta, options) {
|
|
|
2071
2101
|
postProcessWxs(el, meta)
|
|
2072
2102
|
|
|
2073
2103
|
if (!pass) {
|
|
2074
|
-
|
|
2104
|
+
if (isComponentNode(el, options) && !options.hasVirtualHost && mode === 'ali') {
|
|
2105
|
+
el = processAliAddComponentRootView(el, options)
|
|
2106
|
+
} else {
|
|
2107
|
+
el = postProcessComponentIs(el)
|
|
2108
|
+
}
|
|
2075
2109
|
}
|
|
2076
2110
|
postProcessFor(el)
|
|
2077
2111
|
postProcessIf(el)
|
|
@@ -19,6 +19,7 @@ module.exports = function (raw) {
|
|
|
19
19
|
const localSrcMode = queryObj.mode
|
|
20
20
|
const packageName = queryObj.packageRoot || mpx.currentPackageRoot || 'main'
|
|
21
21
|
const componentsMap = mpx.componentsMap[packageName]
|
|
22
|
+
const pagesMap = mpx.pagesMap
|
|
22
23
|
const wxsContentMap = mpx.wxsContentMap
|
|
23
24
|
const renderOptimizeRules = mpx.renderOptimizeRules
|
|
24
25
|
const usingComponents = queryObj.usingComponents || []
|
|
@@ -40,14 +41,6 @@ module.exports = function (raw) {
|
|
|
40
41
|
)
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
let proxyComponentEvents = null
|
|
44
|
-
for (const item of mpx.proxyComponentEventsRules) {
|
|
45
|
-
if (matchCondition(resourcePath, item)) {
|
|
46
|
-
const eventsRaw = item.events
|
|
47
|
-
proxyComponentEvents = Array.isArray(eventsRaw) ? eventsRaw : [eventsRaw]
|
|
48
|
-
break
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
44
|
const { root: ast, meta } = compiler.parse(raw, {
|
|
52
45
|
warn,
|
|
53
46
|
error,
|
|
@@ -56,6 +49,7 @@ module.exports = function (raw) {
|
|
|
56
49
|
hasComment,
|
|
57
50
|
isNative,
|
|
58
51
|
isComponent: !!componentsMap[resourcePath],
|
|
52
|
+
isPage: !!pagesMap[resourcePath],
|
|
59
53
|
mode,
|
|
60
54
|
env,
|
|
61
55
|
srcMode: localSrcMode || globalSrcMode,
|
|
@@ -70,8 +64,7 @@ module.exports = function (raw) {
|
|
|
70
64
|
checkUsingComponents: matchCondition(resourcePath, mpx.checkUsingComponentsRules),
|
|
71
65
|
globalComponents: Object.keys(mpx.usingComponents),
|
|
72
66
|
forceProxyEvent: matchCondition(resourcePath, mpx.forceProxyEventRules),
|
|
73
|
-
hasVirtualHost: matchCondition(resourcePath, mpx.autoVirtualHostRules)
|
|
74
|
-
proxyComponentEvents
|
|
67
|
+
hasVirtualHost: matchCondition(resourcePath, mpx.autoVirtualHostRules)
|
|
75
68
|
})
|
|
76
69
|
|
|
77
70
|
if (meta.wxsContentMap) {
|
|
@@ -23,7 +23,6 @@ module.exports = function (template, {
|
|
|
23
23
|
decodeHTMLText,
|
|
24
24
|
externalClasses,
|
|
25
25
|
checkUsingComponents,
|
|
26
|
-
proxyComponentEventsRules,
|
|
27
26
|
autoVirtualHostRules
|
|
28
27
|
} = mpx
|
|
29
28
|
const { resourcePath } = parseRequest(loaderContext.resource)
|
|
@@ -58,15 +57,6 @@ module.exports = function (template, {
|
|
|
58
57
|
if (template.content) {
|
|
59
58
|
const templateSrcMode = template.mode || srcMode
|
|
60
59
|
|
|
61
|
-
let proxyComponentEvents = null
|
|
62
|
-
for (const item of proxyComponentEventsRules) {
|
|
63
|
-
if (matchCondition(resourcePath, item)) {
|
|
64
|
-
const eventsRaw = item.events
|
|
65
|
-
proxyComponentEvents = Array.isArray(eventsRaw) ? eventsRaw : [eventsRaw]
|
|
66
|
-
break
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
60
|
const { root, meta } = templateCompiler.parse(template.content, {
|
|
71
61
|
warn: (msg) => {
|
|
72
62
|
loaderContext.emitWarning(
|
|
@@ -82,6 +72,7 @@ module.exports = function (template, {
|
|
|
82
72
|
hasComment,
|
|
83
73
|
isNative,
|
|
84
74
|
isComponent: ctorType === 'component',
|
|
75
|
+
isPage: ctorType === 'page',
|
|
85
76
|
mode,
|
|
86
77
|
srcMode: templateSrcMode,
|
|
87
78
|
defs,
|
|
@@ -97,7 +88,6 @@ module.exports = function (template, {
|
|
|
97
88
|
globalComponents: [],
|
|
98
89
|
// web模式下实现抽象组件
|
|
99
90
|
componentGenerics,
|
|
100
|
-
proxyComponentEvents,
|
|
101
91
|
hasVirtualHost: matchCondition(resourcePath, autoVirtualHostRules)
|
|
102
92
|
})
|
|
103
93
|
if (meta.wxsModuleMap) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.59",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
"postcss-modules-values": "^4.0.0",
|
|
55
55
|
"postcss-selector-parser": "^6.0.8",
|
|
56
56
|
"postcss-value-parser": "^4.0.2",
|
|
57
|
-
"source-list-map": "^2.0.0"
|
|
57
|
+
"source-list-map": "^2.0.0",
|
|
58
|
+
"video.js": "^8.6.0"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
60
61
|
"webpack": "^5.48.0"
|
|
@@ -81,5 +82,5 @@
|
|
|
81
82
|
"engines": {
|
|
82
83
|
"node": ">=14.14.0"
|
|
83
84
|
},
|
|
84
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "4e014ea355bb2d659c6fd6a3040b6b88245da9e5"
|
|
85
86
|
}
|