@mpxjs/webpack-plugin 2.8.36 → 2.8.37

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.
@@ -144,11 +144,25 @@ export function inheritEvent (type, oe, detail = {}) {
144
144
  }
145
145
 
146
146
  export function getCustomEvent (type, detail = {}, target = null) {
147
+ const targetInfo = {}
148
+ if (target) {
149
+ const targetEl = target.$el || {}
150
+ const info = {
151
+ id: targetEl.id || '',
152
+ dataset: targetEl.dataset || {},
153
+ offsetTop: targetEl.offsetTop || 0,
154
+ offsetLeft: targetEl.offsetLeft || 0
155
+ }
156
+ Object.assign(targetInfo, {
157
+ target: info,
158
+ currentTarget: info
159
+ })
160
+ }
147
161
  return {
148
162
  type,
149
163
  detail,
150
- target,
151
- timeStamp: new Date().valueOf()
164
+ timeStamp: new Date().valueOf(),
165
+ ...targetInfo
152
166
  }
153
167
  }
154
168
 
@@ -79,7 +79,7 @@
79
79
  } else {
80
80
  value = this.getValue()
81
81
  }
82
- this.$emit('change', getCustomEvent('change', { value }, this.$refs.checkboxGroup))
82
+ this.$emit('change', getCustomEvent('change', { value }, this))
83
83
  }
84
84
  }
85
85
  }
@@ -76,11 +76,11 @@
76
76
  methods: {
77
77
  submit () {
78
78
  const value = getFormValue(this.$slots.default)
79
- this.$emit('submit', getCustomEvent('submit', { value }))
79
+ this.$emit('submit', getCustomEvent('submit', { value }, this))
80
80
  },
81
81
  reset () {
82
82
  setFormValue(this.$slots.default, this.initialValue)
83
- this.$emit('reset', getCustomEvent('reset', { value: this.initialValue }))
83
+ this.$emit('reset', getCustomEvent('reset', { value: this.initialValue }, this))
84
84
  }
85
85
  }
86
86
  }
@@ -1,5 +1,5 @@
1
1
  <script>
2
- import getInnerListeners, { extendEvent } from './getInnerListeners'
2
+ import getInnerListeners, { getCustomEvent } from './getInnerListeners'
3
3
 
4
4
  export default {
5
5
  name: 'mpx-image',
@@ -22,18 +22,14 @@
22
22
  },
23
23
  beforeCreate () {
24
24
  this.image = new Image()
25
- this.image.onload = (e) => {
26
- extendEvent(e, {
27
- detail: {
28
- width: this.image.width,
29
- height: this.image.height
30
- }
31
- })
32
-
33
- this.$emit('load', e)
25
+ this.image.onload = () => {
26
+ this.$emit('load', getCustomEvent('load', {
27
+ width: this.image.width,
28
+ height: this.image.height
29
+ }, this))
34
30
  }
35
- this.image.onerror = (e) => {
36
- this.$emit('error', e)
31
+ this.image.onerror = () => {
32
+ this.$emit('error', getCustomEvent('error', {}, this))
37
33
  }
38
34
  },
39
35
  watch: {
@@ -48,9 +44,9 @@
48
44
  if (this.mode === 'widthFix' || this.mode === 'heightFix') {
49
45
  let style
50
46
  if (this.mode === 'widthFix') {
51
- style = {
52
- height: 'auto'
53
- }
47
+ style = {
48
+ height: 'auto'
49
+ }
54
50
  } else {
55
51
  style = {
56
52
  width: 'auto'
@@ -179,7 +179,7 @@
179
179
  x: this.roundFun(position.x) ? this.roundFun(position.x) : 0,
180
180
  y: this.roundFun(position.y) ? this.roundFun(position.y) : 0,
181
181
  source: this.source
182
- }))
182
+ }, this))
183
183
  }
184
184
  this.lastestX = this.roundFun(position.x)
185
185
  this.lastestY = this.roundFun(position.y)
@@ -215,7 +215,7 @@
215
215
  this.touchEvent = 'vtouchmove'
216
216
  }
217
217
  }
218
- this.$emit(this.touchEvent)
218
+ this.$emit(this.touchEvent, getCustomEvent(this.touchEvent, {}, this))
219
219
  this.isFirstTouch = false
220
220
  })
221
221
  if (this.inertia) { // movable-view是否带有惯性
@@ -233,7 +233,7 @@
233
233
  x: this.roundFun(this.bs.x),
234
234
  y: this.roundFun(this.bs.y),
235
235
  scale: this.roundFun(scale)
236
- }))
236
+ }, this))
237
237
  this.lastestScale = this.roundFun(scale)
238
238
  })
239
239
  this.bs.on('zoomEnd', ({ scale }) => {
@@ -97,13 +97,13 @@
97
97
  },
98
98
  notifyChange() {
99
99
  const value = this.getValue()
100
- this.$emit('change', getCustomEvent('change', {value}))
100
+ this.$emit('change', getCustomEvent('change', { value }, this))
101
101
  },
102
- notifyPickstart(value) {
103
- this.$emit('pickstart', getCustomEvent('pickstart', {value}))
102
+ notifyPickstart() {
103
+ this.$emit('pickstart', getCustomEvent('pickstart', {}, this))
104
104
  },
105
- notifyPickend(value) {
106
- this.$emit('pickend', getCustomEvent('pickend', {value}))
105
+ notifyPickend() {
106
+ this.$emit('pickend', getCustomEvent('pickend', {}, this))
107
107
  }
108
108
  }
109
109
  }
@@ -266,11 +266,11 @@
266
266
  default:
267
267
  value = this.selectedIndex[0]
268
268
  }
269
- this.$emit('change', getCustomEvent('change', {value}))
269
+ this.$emit('change', getCustomEvent('change', {value}, this))
270
270
  },
271
271
  _cancel () {
272
272
  this.hide()
273
- this.$emit('cancel', getCustomEvent('cancel'))
273
+ this.$emit('cancel', getCustomEvent('cancel', {}, this))
274
274
  },
275
275
  _isMoving () {
276
276
  return this.wheels.some((wheel) => {
@@ -327,7 +327,7 @@
327
327
  this.$emit('columnchange', getCustomEvent('columnchange', {
328
328
  column: i,
329
329
  value: currentIndex
330
- }))
330
+ }, this))
331
331
  }
332
332
  }
333
333
  if (this.mode === 'time' || this.mode === 'date') {
@@ -113,7 +113,9 @@
113
113
  ref: 'progress',
114
114
  on: {
115
115
  transitionend: () => {
116
- this.$emit('activeend', getCustomEvent('activeend'))
116
+ this.$emit('activeend', getCustomEvent('activeend', {
117
+ curPercent: this.percent
118
+ }, this))
117
119
  }
118
120
  }
119
121
  })
@@ -84,7 +84,7 @@
84
84
  } else {
85
85
  value = this.getValue()
86
86
  }
87
- this.$emit('change', getCustomEvent('change', { value }, this.$refs.radioGroup))
87
+ this.$emit('change', getCustomEvent('change', { value }, this))
88
88
  }
89
89
  }
90
90
  }
@@ -124,7 +124,7 @@
124
124
  refresherTriggered: {
125
125
  handler (val) {
126
126
  if (!val) {
127
- this.$emit('refresherrestore')
127
+ this.$emit('refresherrestore', getCustomEvent('refresherrestore', {}, this))
128
128
  this.isLoading = false
129
129
  this.isAutoPullDown = true
130
130
  this.bs && this.bs.finishPullDown()
@@ -182,7 +182,7 @@
182
182
  scrollHeight: this.bs.scrollerHeight,
183
183
  deltaX,
184
184
  deltaY
185
- }))
185
+ }, this))
186
186
  if (this.bs.minScrollX - x < this._upperThreshold && deltaX > 0) {
187
187
  this.dispatchScrollTo('left')
188
188
  }
@@ -212,7 +212,7 @@
212
212
  this.$emit('dragstart', getCustomEvent('dragstart', {
213
213
  scrollLeft: this.bs.x ? this.bs.x * -1 : 0,
214
214
  scrollTop: this.bs.y ? this.bs.y * -1 : 0
215
- }))
215
+ }, this))
216
216
  }
217
217
  if (this.refresherEnabled) {
218
218
  this.isAutoPullDown = false
@@ -223,13 +223,13 @@
223
223
  this.$emit('dragging', getCustomEvent('dragging', {
224
224
  scrollLeft: this.bs.x ? this.bs.x * -1 : 0,
225
225
  scrollTop: this.bs.y ? this.bs.y * -1 : 0
226
- }))
226
+ }, this))
227
227
  }
228
228
  if (this.refresherEnabled) {
229
229
  if (this.bs.y > 0 && this.bs.y < this.refresherThreshold && this.bs.movingDirectionY !== 1) {
230
230
  this.isAutoPullDown = false
231
231
  this.isLoading = false
232
- this.$emit('refresherpulling')
232
+ this.$emit('refresherpulling', getCustomEvent('refresherpulling', {}, this))
233
233
  }
234
234
  }
235
235
  })
@@ -238,7 +238,7 @@
238
238
  this.$emit('dragend', getCustomEvent('dragend', {
239
239
  scrollLeft: this.bs.x ? this.bs.x * -1 : 0,
240
240
  scrollTop: this.bs.y ? this.bs.y * -1 : 0
241
- }))
241
+ }, this))
242
242
  }
243
243
  })
244
244
  if (this.refresherEnabled) {
@@ -248,12 +248,12 @@
248
248
  this.isLoading = true
249
249
  if (this.bs.y < this.refresherThreshold) {
250
250
  this.isAutoPullDown = true
251
- this.$emit('refresherabort')
251
+ this.$emit('refresherabort', getCustomEvent('refresherabort', {}, this))
252
252
  }
253
253
  }
254
254
  })
255
255
  this.bs.on('pullingDown', () => {
256
- this.$emit('refresherrefresh')
256
+ this.$emit('refresherrefresh', getCustomEvent('refresherrefresh', {}, this))
257
257
  })
258
258
  }
259
259
  }
@@ -312,7 +312,7 @@
312
312
  dispatchScrollTo: throttle(function (direction) {
313
313
  let eventName = 'scrolltoupper'
314
314
  if (direction === 'bottom' || direction === 'right') eventName = 'scrolltolower'
315
- this.$emit(eventName, getCustomEvent(eventName, { direction }))
315
+ this.$emit(eventName, getCustomEvent(eventName, { direction }, this))
316
316
  }, 200, {
317
317
  leading: true,
318
318
  trailing: false
@@ -156,12 +156,12 @@
156
156
  let eventName = 'changing'
157
157
  let moveStartX = event.targetTouches[0] && event.targetTouches[0].pageX
158
158
  this.setLineValue(moveStartX)
159
- this.$emit(eventName, getCustomEvent(eventName, { value: this.sliderValue }, this.$refs.slider))
159
+ this.$emit(eventName, getCustomEvent(eventName, { value: this.sliderValue }, this))
160
160
  }
161
161
  },
162
162
  sliderTouchEnd (event) {
163
163
  let eventName = 'change'
164
- this.$emit(eventName, getCustomEvent(eventName, { value: this.sliderValue }, this.$refs.slider))
164
+ this.$emit(eventName, getCustomEvent(eventName, { value: this.sliderValue }, this))
165
165
  this.isDrag = false
166
166
  },
167
167
  sliderClick (event) {
@@ -170,7 +170,7 @@
170
170
  }
171
171
  this.setLineValue(event.pageX)
172
172
  let eventName = 'change'
173
- this.$emit(eventName, getCustomEvent(eventName, { value: this.sliderValue }, this.$refs.slider))
173
+ this.$emit(eventName, getCustomEvent(eventName, { value: this.sliderValue }, this))
174
174
  },
175
175
  setLineValue (moveStartX) {
176
176
  moveStartX = moveStartX - this.startX
@@ -200,7 +200,7 @@
200
200
  } else {
201
201
  value = this.getValue()
202
202
  }
203
- this.$emit('change', getCustomEvent('change', { value: value }, this.$refs.slider))
203
+ this.$emit('change', getCustomEvent('change', { value: value }, this))
204
204
  }
205
205
  }
206
206
  }
@@ -145,7 +145,7 @@
145
145
  current: this.currentIndex,
146
146
  currentItemId: this.itemIds[this.currentIndex] || '',
147
147
  source: this.changeSource
148
- }))
148
+ }, this))
149
149
  })
150
150
 
151
151
  this.bs.on('scrollEnd', () => {
@@ -153,13 +153,13 @@
153
153
  current: this.currentIndex,
154
154
  currentItemId: this.itemIds[this.currentIndex] || '',
155
155
  source: this.changeSource
156
- }))
156
+ }, this))
157
157
  })
158
158
  this.bs.on('scroll', throttle(({ x, y }) => {
159
159
  this.$emit('transition', getCustomEvent('transition', {
160
160
  dx: this.lastX - x,
161
161
  dy: this.lastY - y
162
- }))
162
+ }, this))
163
163
  }, 30, {
164
164
  leading: true,
165
165
  trailing: false
@@ -80,7 +80,7 @@
80
80
  } else {
81
81
  value = this.getValue()
82
82
  }
83
- this.$emit('change', getCustomEvent('change', { value }, this.$refs.switch))
83
+ this.$emit('change', getCustomEvent('change', { value }, this))
84
84
  }
85
85
  }
86
86
  }
@@ -14,7 +14,7 @@
14
14
  </template>
15
15
 
16
16
  <script>
17
- import { inheritEvent, extendEvent } from './getInnerListeners'
17
+ import { inheritEvent } from './getInnerListeners'
18
18
 
19
19
  export default {
20
20
  name: 'mpx-video',
@@ -169,75 +169,61 @@
169
169
  const videoNode = this.$refs['_mpx_video_ref']
170
170
 
171
171
  videoNode.addEventListener('play', (e) => {
172
- extendEvent(e, { detail: {} })
173
- this.$emit('play', e)
172
+ this.$emit('play', inheritEvent('play', e, {}))
174
173
  })
175
174
 
176
175
  videoNode.addEventListener('pause', (e) => {
177
- extendEvent(e, { detail: {} })
178
- this.$emit('pause', e)
176
+ this.$emit('pause', inheritEvent('pause', e, {}))
179
177
  })
180
178
 
181
179
  videoNode.addEventListener('ended', (e) => {
182
- extendEvent(e, { detail: {} })
183
- this.$emit('ended', e)
180
+ this.$emit('ended', inheritEvent('ended', e, {}))
184
181
  })
185
182
 
186
183
  videoNode.addEventListener('timeupdate', (e) => {
187
184
  const eNode = e.target
188
- extendEvent(e, { detail: { currentTime: eNode.currentTime, duration: eNode.duration } })
189
- this.$emit('timeupdate', e)
185
+ this.$emit('timeupdate', inheritEvent('timeupdate', e, { currentTime: eNode.currentTime, duration: eNode.duration }))
190
186
  })
191
187
 
192
188
  videoNode.addEventListener('error', (e) => {
193
- extendEvent(e, { detail: {} })
194
- this.$emit('error', e)
189
+ this.$emit('error', inheritEvent('error', e, {}))
195
190
  })
196
191
 
197
192
  videoNode.addEventListener('waiting', (e) => {
198
- extendEvent(e, { detail: {} })
199
- this.$emit('waiting', e)
193
+ this.$emit('waiting', inheritEvent('waiting', e, {}))
200
194
  })
201
195
 
202
196
  videoNode.addEventListener('loadedmetadata', (e) => {
203
197
  const eNode = e.target
204
- extendEvent(e, { detail: { width: eNode.videoWidth, height: eNode.videoHeight, duration: eNode.duration } })
205
- this.$emit('loadedmetadata', e)
198
+ this.$emit('loadedmetadata', inheritEvent('loadedmetadata', e, { width: eNode.videoWidth, height: eNode.videoHeight, duration: eNode.duration }))
206
199
  })
207
200
 
208
201
  videoNode.addEventListener('progress', (e) => {
209
202
  const eNode = e.target
210
203
  const buffered = (eNode?.buffered?.end(0)) / (eNode?.duration)
211
- extendEvent(e, { detail: { buffered: buffered * 100 } })
212
- this.$emit('progress', e)
204
+ this.$emit('progress', inheritEvent('progress', e, { buffered: buffered * 100 }))
213
205
  })
214
206
 
215
207
  videoNode.addEventListener('seeked', (e) => {
216
208
  const eNode = e.target
217
- const ne = inheritEvent('seekcomplete', e, { position: eNode.currentTime })
218
- this.$emit('seekcomplete', ne)
209
+ this.$emit('seekcomplete', inheritEvent('seekcomplete', e, { position: eNode.currentTime }))
219
210
  })
220
211
 
221
212
  videoNode.addEventListener('fullscreenchange', (e) => {
222
213
  // TODO direction
223
- extendEvent(e, { detail: { fullScreen: false } })
224
214
  if (document.isFullScreen) {
225
- e.detail.fullScreen = true
226
- this.$emit('fullscreenchange', e)
215
+ this.$emit('fullscreenchange', inheritEvent('fullscreenchange', e, { fullScreen: true }))
227
216
  } else {
228
- e.detail.fullScreen = false
229
- this.$emit('fullscreenchange', e)
217
+ this.$emit('fullscreenchange', inheritEvent('fullscreenchange', e, { fullScreen: false }))
230
218
  }
231
219
  })
232
220
 
233
221
  videoNode.addEventListener('enterpictureinpicture', (e) => {
234
- extendEvent(e, { detail: {} })
235
- this.$emit('enterpictureinpicture', e)
222
+ this.$emit('enterpictureinpicture', inheritEvent('enterpictureinpicture', e, {}))
236
223
  })
237
224
 
238
225
  videoNode.addEventListener('leavepictureinpicture', (e) => {
239
- extendEvent(e, { detail: {} })
240
- this.$emit('leavepictureinpicture', e)
226
+ this.$emit('leavepictureinpicture', inheritEvent('leavepictureinpicture', e, {}))
241
227
  })
242
228
  }
243
229
  }
@@ -3,7 +3,7 @@
3
3
  </template>
4
4
 
5
5
  <script>
6
- import getInnerListeners, { getCustomEvent } from './getInnerListeners'
6
+ import { getCustomEvent } from './getInnerListeners'
7
7
  import { redirectTo, navigateTo, navigateBack, reLaunch, switchTab} from '@mpxjs/api-proxy/src/web/api/index'
8
8
 
9
9
  const eventLoad = 'load'
@@ -43,17 +43,15 @@
43
43
  return domain
44
44
  }
45
45
  },
46
- created () {
46
+ mounted () {
47
47
  setTimeout(() => {
48
48
  if (!this.Loaded) {
49
49
  const loadData = {
50
50
  src: this.src
51
51
  }
52
- this.$emit(eventError, getCustomEvent(eventError, loadData))
52
+ this.$emit(eventError, getCustomEvent(eventError, loadData, this))
53
53
  }
54
54
  }, 1000)
55
- },
56
- mounted () {
57
55
  this.mpxIframe = this.$refs.mpxIframe
58
56
  this.mpxIframe.addEventListener('load', (event) => {
59
57
  event.currentTarget.contentWindow.postMessage(this.mainDomain, '*')
@@ -94,7 +92,7 @@
94
92
  const loadData = {
95
93
  src: this.src
96
94
  }
97
- this.$emit(eventLoad, getCustomEvent(eventLoad, loadData))
95
+ this.$emit(eventLoad, getCustomEvent(eventLoad, loadData, this))
98
96
  }
99
97
  })
100
98
  },
@@ -110,7 +108,7 @@
110
108
  type: 'message',
111
109
  data: this.messageList
112
110
  }
113
- this.$emit(eventMessage, getCustomEvent(eventMessage, data))
111
+ this.$emit(eventMessage, getCustomEvent(eventMessage, data, this))
114
112
  },
115
113
  destroyed () {
116
114
  if (!this.isPostMessage) {
@@ -120,7 +118,7 @@
120
118
  type: 'message',
121
119
  data: this.messageList
122
120
  }
123
- this.$emit(eventMessage, getCustomEvent(eventMessage, data))
121
+ this.$emit(eventMessage, getCustomEvent(eventMessage, data, this))
124
122
  }
125
123
  }
126
124
  </script>
@@ -2,15 +2,15 @@
2
2
  MIT License http://www.opensource.org/licenses/mit-license.php
3
3
  Author Tobias Koppers @sokra
4
4
  */
5
- module.exports = (cssWithMappingToString) => {
5
+ module.exports = function (cssWithMappingToString) {
6
6
  const list = []
7
7
 
8
8
  // return the list of modules as css string
9
9
  list.toString = function toString () {
10
- return this.map((item) => {
11
- let content = ''
10
+ return this.map(function (item) {
11
+ var content = ''
12
12
 
13
- const needLayer = typeof item[5] !== 'undefined'
13
+ var needLayer = typeof item[5] !== 'undefined'
14
14
 
15
15
  if (item[4]) {
16
16
  content += `@supports (${item[4]}) {`
@@ -48,11 +48,11 @@ module.exports = (cssWithMappingToString) => {
48
48
  modules = [[null, modules, undefined]]
49
49
  }
50
50
 
51
- const alreadyImportedModules = {}
51
+ var alreadyImportedModules = {}
52
52
 
53
53
  if (dedupe) {
54
54
  for (let k = 0; k < this.length; k++) {
55
- const id = this[k][0]
55
+ var id = this[k][0]
56
56
 
57
57
  if (id != null) {
58
58
  alreadyImportedModules[id] = true
@@ -60,8 +60,8 @@ module.exports = (cssWithMappingToString) => {
60
60
  }
61
61
  }
62
62
 
63
- for (let k = 0; k < modules.length; k++) {
64
- const item = [].concat(modules[k])
63
+ for (var k = 0; k < modules.length; k++) {
64
+ var item = [].concat(modules[k])
65
65
 
66
66
  if (dedupe && alreadyImportedModules[item[0]]) {
67
67
  continue
@@ -1 +1,3 @@
1
- module.exports = (i) => i[1]
1
+ module.exports = function (i) {
2
+ return i[1]
3
+ }
@@ -1,6 +1,6 @@
1
- module.exports = (item) => {
2
- const content = item[1]
3
- const cssMapping = item[3]
1
+ module.exports = function (item) {
2
+ var content = item[1]
3
+ var cssMapping = item[3]
4
4
 
5
5
  if (!cssMapping) {
6
6
  return content
@@ -8,13 +8,13 @@ module.exports = (item) => {
8
8
 
9
9
  if (typeof btoa === 'function') {
10
10
  // eslint-disable-next-line no-undef
11
- const base64 = btoa(
11
+ var base64 = btoa(
12
12
  unescape(encodeURIComponent(JSON.stringify(cssMapping)))
13
13
  )
14
- const data = `sourceMappingURL=data:application/json;charset=utf-8;base64,${base64}`
15
- const sourceMapping = `/*# ${data} */`
14
+ var data = `sourceMappingURL=data:application/json;charset=utf-8;base64,${base64}`
15
+ var sourceMapping = `/*# ${data} */`
16
16
 
17
- const sourceURLs = cssMapping.sources.map(
17
+ var sourceURLs = cssMapping.sources.map(
18
18
  (source) => `/*# sourceURL=${cssMapping.sourceRoot || ''}${source} */`
19
19
  )
20
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.8.36",
3
+ "version": "2.8.37",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -82,5 +82,5 @@
82
82
  "engines": {
83
83
  "node": ">=14.14.0"
84
84
  },
85
- "gitHead": "f7d1fc9bf1aaf7aff6fe9f2a11288dc5e12f78d6"
85
+ "gitHead": "87ec3c789ed2a427e73b839a9d3548fb6e42d922"
86
86
  }