@mpxjs/webpack-plugin 2.8.40-test → 2.8.40-test.2
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/dependencies/DynamicEntryDependency.js +10 -16
- package/lib/index.js +87 -60
- package/lib/json-compiler/helper.js +8 -5
- package/lib/json-compiler/index.js +2 -2
- package/lib/loader.js +28 -27
- package/lib/parser.js +0 -1
- package/lib/platform/index.js +15 -4
- package/lib/platform/json/wx/index.js +3 -5
- package/lib/platform/run-rules.js +1 -2
- package/lib/platform/template/normalize-component-rules.js +41 -42
- package/lib/platform/template/wx/component-config/component.js +1 -2
- package/lib/platform/template/wx/component-config/fix-component-name.js +21 -0
- package/lib/platform/template/wx/component-config/index.js +4 -4
- package/lib/platform/template/wx/index.js +21 -16
- package/lib/runtime/base.styl +9 -1
- package/lib/runtime/components/web/getInnerListeners.js +1 -2
- package/lib/runtime/components/web/mpx-image.vue +13 -10
- package/lib/runtime/components/web/mpx-movable-view.vue +1 -1
- package/lib/runtime/components/web/mpx-picker-view-column.vue +10 -2
- package/lib/runtime/components/web/mpx-picker.vue +9 -1
- package/lib/runtime/components/web/mpx-swiper.vue +2 -2
- package/lib/runtime/optionProcessor.js +321 -264
- package/lib/runtime/stringify.wxs +44 -8
- package/lib/style-compiler/index.js +1 -2
- package/lib/template-compiler/compiler.js +74 -56
- package/lib/utils/check-core-version-match.js +18 -14
- package/lib/web/processJSON.js +4 -3
- package/lib/web/processMainScript.js +84 -0
- package/lib/web/processScript.js +21 -204
- package/lib/web/processTemplate.js +4 -1
- package/lib/web/script-helper.js +202 -0
- package/package.json +5 -4
- package/lib/platform/template/wx/component-config/fix-html-tag.js +0 -17
- package/lib/style-compiler/plugins/trim.js +0 -15
|
@@ -33,13 +33,13 @@ const switchComponent = require('./switch')
|
|
|
33
33
|
const template = require('./template')
|
|
34
34
|
const text = require('./text')
|
|
35
35
|
const textarea = require('./textarea')
|
|
36
|
-
const
|
|
36
|
+
const unsupported = require('./unsupported')
|
|
37
37
|
const video = require('./video')
|
|
38
38
|
const view = require('./view')
|
|
39
39
|
const webView = require('./web-view')
|
|
40
40
|
const wxs = require('./wxs')
|
|
41
41
|
const component = require('./component')
|
|
42
|
-
const
|
|
42
|
+
const fixComponentName = require('./fix-component-name')
|
|
43
43
|
|
|
44
44
|
module.exports = function getComponentConfigs ({ warn, error }) {
|
|
45
45
|
/**
|
|
@@ -80,8 +80,8 @@ module.exports = function getComponentConfigs ({ warn, error }) {
|
|
|
80
80
|
|
|
81
81
|
// 转换规则只需以微信为基准配置微信和支付宝的差异部分,比如微信和支付宝都支持但是写法不一致,或者微信支持而支付宝不支持的部分(抛出错误或警告)
|
|
82
82
|
return [
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
...unsupported({ print }),
|
|
84
|
+
fixComponentName({ print }),
|
|
85
85
|
ad({ print }),
|
|
86
86
|
view({ print }),
|
|
87
87
|
scrollView({ print }),
|
|
@@ -3,9 +3,7 @@ const JSON5 = require('json5')
|
|
|
3
3
|
const getComponentConfigs = require('./component-config')
|
|
4
4
|
const normalizeComponentRules = require('../normalize-component-rules')
|
|
5
5
|
const isValidIdentifierStr = require('../../../utils/is-valid-identifier-str')
|
|
6
|
-
const
|
|
7
|
-
const parseMustache = templateCompiler.parseMustache
|
|
8
|
-
const stringifyWithResolveComputed = templateCompiler.stringifyWithResolveComputed
|
|
6
|
+
const { parseMustacheWithContext, stringifyWithResolveComputed } = require('../../../template-compiler/compiler')
|
|
9
7
|
const normalize = require('../../../utils/normalize')
|
|
10
8
|
|
|
11
9
|
module.exports = function getSpec ({ warn, error }) {
|
|
@@ -17,10 +15,10 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
17
15
|
postProps: [
|
|
18
16
|
{
|
|
19
17
|
web ({ name, value }) {
|
|
20
|
-
const parsed =
|
|
18
|
+
const parsed = parseMustacheWithContext(value)
|
|
21
19
|
if (parsed.hasBinding) {
|
|
22
20
|
return {
|
|
23
|
-
name: name === 'animation' ? 'v-'
|
|
21
|
+
name: name === 'animation' ? 'v-animation' : ':' + name,
|
|
24
22
|
value: parsed.result
|
|
25
23
|
}
|
|
26
24
|
}
|
|
@@ -34,7 +32,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
34
32
|
test: 'wx:for',
|
|
35
33
|
swan (obj, data) {
|
|
36
34
|
const attrsMap = data.el.attrsMap
|
|
37
|
-
const parsed =
|
|
35
|
+
const parsed = parseMustacheWithContext(obj.value)
|
|
38
36
|
let listName = parsed.result
|
|
39
37
|
const el = data.el
|
|
40
38
|
|
|
@@ -48,7 +46,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
if (keyName) {
|
|
51
|
-
const parsed =
|
|
49
|
+
const parsed = parseMustacheWithContext(keyName)
|
|
52
50
|
if (parsed.hasBinding) {
|
|
53
51
|
// keyStr = ` trackBy ${parsed.result.slice(1, -1)}`
|
|
54
52
|
} else if (keyName === '*this') {
|
|
@@ -78,7 +76,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
78
76
|
}
|
|
79
77
|
},
|
|
80
78
|
web ({ value }, { el }) {
|
|
81
|
-
const parsed =
|
|
79
|
+
const parsed = parseMustacheWithContext(value)
|
|
82
80
|
const attrsMap = el.attrsMap
|
|
83
81
|
const itemName = attrsMap['wx:for-item'] || 'item'
|
|
84
82
|
const indexName = attrsMap['wx:for-index'] || 'index'
|
|
@@ -190,9 +188,8 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
190
188
|
}
|
|
191
189
|
const styleBinding = []
|
|
192
190
|
el.isStyleParsed = true
|
|
193
|
-
// 不过滤的话每一个属性都要 parse
|
|
194
191
|
el.attrsList.filter(item => this.test.test(item.name)).forEach((item) => {
|
|
195
|
-
const parsed =
|
|
192
|
+
const parsed = parseMustacheWithContext(item.value)
|
|
196
193
|
styleBinding.push(parsed.result)
|
|
197
194
|
})
|
|
198
195
|
return {
|
|
@@ -203,12 +200,20 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
203
200
|
},
|
|
204
201
|
{
|
|
205
202
|
// 样式类名绑定
|
|
206
|
-
test: /^wx:
|
|
207
|
-
web ({ value }) {
|
|
208
|
-
|
|
203
|
+
test: /^(class|wx:class)$/,
|
|
204
|
+
web ({ value }, { el }) {
|
|
205
|
+
if (el.isClassParsed) {
|
|
206
|
+
return false
|
|
207
|
+
}
|
|
208
|
+
const classBinding = []
|
|
209
|
+
el.isClassParsed = true
|
|
210
|
+
el.attrsList.filter(item => this.test.test(item.name)).forEach((item) => {
|
|
211
|
+
const parsed = parseMustacheWithContext(item.value)
|
|
212
|
+
classBinding.push(parsed.result)
|
|
213
|
+
})
|
|
209
214
|
return {
|
|
210
215
|
name: ':class',
|
|
211
|
-
value:
|
|
216
|
+
value: `[${classBinding}]`
|
|
212
217
|
}
|
|
213
218
|
}
|
|
214
219
|
},
|
|
@@ -259,7 +264,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
259
264
|
},
|
|
260
265
|
web ({ name, value }) {
|
|
261
266
|
let dir = this.test.exec(name)[1]
|
|
262
|
-
const parsed =
|
|
267
|
+
const parsed = parseMustacheWithContext(value)
|
|
263
268
|
if (dir === 'elif') {
|
|
264
269
|
dir = 'else-if'
|
|
265
270
|
}
|
|
@@ -359,7 +364,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
359
364
|
}
|
|
360
365
|
},
|
|
361
366
|
web ({ name, value }, { eventRules, el, usingComponents }) {
|
|
362
|
-
if (
|
|
367
|
+
if (parseMustacheWithContext(value).hasBinding) {
|
|
363
368
|
error('Web environment does not support mustache binding in event props!')
|
|
364
369
|
return
|
|
365
370
|
}
|
package/lib/runtime/base.styl
CHANGED
|
@@ -48,9 +48,17 @@ span {
|
|
|
48
48
|
white-space: pre-line;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
html, body,
|
|
51
|
+
html, body, #app {
|
|
52
|
+
display: block;
|
|
53
|
+
width: 100%;
|
|
54
|
+
height: 100%;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
page {
|
|
58
|
+
display: block;
|
|
52
59
|
width: 100%;
|
|
53
60
|
height: 100%;
|
|
61
|
+
background-color: #fff;
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
.pull-down-loading {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { isEmptyObject } from '../../utils'
|
|
2
2
|
import { isBrowser } from '../../env'
|
|
3
3
|
|
|
4
|
-
const isTouchDevice = isBrowser ? document && ('ontouchstart' in document.documentElement) : true
|
|
5
|
-
|
|
6
4
|
function processModel (listeners, context) {
|
|
7
5
|
// 该函数只有wx:model的情况下才调用,而且默认e.detail.value有值
|
|
8
6
|
// 该函数必须在产生merge前执行
|
|
@@ -49,6 +47,7 @@ function mergeListeners (listeners, otherListeners, options = {}) {
|
|
|
49
47
|
function processTap (listeners, context) {
|
|
50
48
|
const listenerMap = {}
|
|
51
49
|
const tapEvents = ['tap', 'longpress', 'longtap']
|
|
50
|
+
const isTouchDevice = isBrowser ? document && ('ontouchstart' in document.documentElement) : true
|
|
52
51
|
tapEvents.forEach((eventName) => {
|
|
53
52
|
if (listeners[eventName]) {
|
|
54
53
|
listenerMap[eventName] = true
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import getInnerListeners, { getCustomEvent } from './getInnerListeners'
|
|
3
|
+
import { isBrowser } from '../../env'
|
|
3
4
|
|
|
4
5
|
export default {
|
|
5
6
|
name: 'mpx-image',
|
|
@@ -21,21 +22,23 @@
|
|
|
21
22
|
}
|
|
22
23
|
},
|
|
23
24
|
beforeCreate () {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this
|
|
25
|
+
if (isBrowser) {
|
|
26
|
+
this.image = new Image()
|
|
27
|
+
this.image.onload = () => {
|
|
28
|
+
this.$emit('load', getCustomEvent('load', {
|
|
29
|
+
width: this.image.width,
|
|
30
|
+
height: this.image.height
|
|
31
|
+
}, this))
|
|
32
|
+
}
|
|
33
|
+
this.image.onerror = () => {
|
|
34
|
+
this.$emit('error', getCustomEvent('error', {}, this))
|
|
35
|
+
}
|
|
33
36
|
}
|
|
34
37
|
},
|
|
35
38
|
watch: {
|
|
36
39
|
src: {
|
|
37
40
|
handler (src) {
|
|
38
|
-
if (src) this.image.src = src
|
|
41
|
+
if (src && this.image) this.image.src = src
|
|
39
42
|
},
|
|
40
43
|
immediate: true
|
|
41
44
|
}
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
this.refresh()
|
|
179
179
|
})
|
|
180
180
|
const elementToObserve = document.querySelector('.mpx-movable-scroll-content')
|
|
181
|
-
this.resizeObserver.observe(elementToObserve)
|
|
181
|
+
elementToObserve && this.resizeObserver.observe(elementToObserve)
|
|
182
182
|
}
|
|
183
183
|
},
|
|
184
184
|
refresh () {
|
|
@@ -15,7 +15,13 @@
|
|
|
15
15
|
export default {
|
|
16
16
|
name: 'mpx-picker-view-column',
|
|
17
17
|
props: {
|
|
18
|
-
value: Array
|
|
18
|
+
value: Array,
|
|
19
|
+
scrollOptions: {
|
|
20
|
+
type: Object,
|
|
21
|
+
default: () => {
|
|
22
|
+
return {}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
19
25
|
},
|
|
20
26
|
data() {
|
|
21
27
|
return {
|
|
@@ -64,7 +70,9 @@
|
|
|
64
70
|
rotate: -5,
|
|
65
71
|
wheelWrapperClass: 'wheel-scroll'
|
|
66
72
|
},
|
|
67
|
-
probeType: 3
|
|
73
|
+
probeType: 3,
|
|
74
|
+
bindToWrapper: true,
|
|
75
|
+
...this.scrollOptions
|
|
68
76
|
})
|
|
69
77
|
this.wheels[0].on('scrollStart', function () {
|
|
70
78
|
if (this.pickerView) {
|
|
@@ -138,6 +138,12 @@
|
|
|
138
138
|
fields: {
|
|
139
139
|
type: String,
|
|
140
140
|
default: 'day'
|
|
141
|
+
},
|
|
142
|
+
scrollOptions: {
|
|
143
|
+
type: Object,
|
|
144
|
+
default: () => {
|
|
145
|
+
return {}
|
|
146
|
+
}
|
|
141
147
|
}
|
|
142
148
|
},
|
|
143
149
|
data () {
|
|
@@ -311,7 +317,9 @@
|
|
|
311
317
|
wheelWrapperClass: 'wheel-scroll',
|
|
312
318
|
wheelItemClass: 'wheel-item'
|
|
313
319
|
},
|
|
314
|
-
probeType: 3
|
|
320
|
+
probeType: 3,
|
|
321
|
+
bindToWrapper: true,
|
|
322
|
+
...this.scrollOptions
|
|
315
323
|
})
|
|
316
324
|
if (this.mode === 'time' || this.mode === 'date') {
|
|
317
325
|
this.wheels[i].on('scrollStart', function (i) {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
default: () => {
|
|
48
48
|
return {}
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|
|
51
51
|
},
|
|
52
52
|
data () {
|
|
53
53
|
return {
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
this.bs.scroller.hooks.on('beforeRefresh', () => {
|
|
213
213
|
this.initLayerComputed()
|
|
214
214
|
})
|
|
215
|
-
this.bs.on('
|
|
215
|
+
this.bs.on('slidePageChanged', (page) => {
|
|
216
216
|
this.currentIndex = this.vertical ? page.pageY : page.pageX
|
|
217
217
|
this.$emit('change', getCustomEvent('change', {
|
|
218
218
|
current: this.currentIndex,
|