@mpxjs/webpack-plugin 2.9.69 → 2.9.70
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/parser.js +1 -1
- package/lib/platform/json/wx/index.js +21 -8
- package/lib/platform/style/wx/index.js +51 -54
- package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
- package/lib/platform/template/wx/component-config/index.js +1 -1
- package/lib/platform/template/wx/component-config/input.js +1 -1
- package/lib/platform/template/wx/component-config/rich-text.js +8 -0
- package/lib/platform/template/wx/component-config/swiper.js +1 -1
- package/lib/platform/template/wx/component-config/textarea.js +1 -1
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/react/processTemplate.js +3 -0
- package/lib/runtime/components/react/context.ts +4 -0
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/event.config.js +24 -24
- package/lib/runtime/components/react/dist/getInnerListeners.js +183 -166
- package/lib/runtime/components/react/dist/mpx-button.jsx +35 -42
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +35 -13
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
- package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
- package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
- package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
- package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +3 -1
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
- package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
- package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
- package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
- package/lib/runtime/components/react/dist/mpx-view.jsx +34 -46
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +105 -42
- package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -10
- package/lib/runtime/components/react/dist/utils.jsx +107 -82
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +238 -188
- package/lib/runtime/components/react/mpx-button.tsx +64 -50
- package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
- package/lib/runtime/components/react/mpx-canvas/index.tsx +46 -48
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +28 -25
- package/lib/runtime/components/react/mpx-checkbox.tsx +48 -49
- package/lib/runtime/components/react/mpx-form.tsx +25 -28
- package/lib/runtime/components/react/mpx-icon.tsx +12 -17
- package/lib/runtime/components/react/mpx-image.tsx +436 -0
- package/lib/runtime/components/react/mpx-input.tsx +77 -57
- package/lib/runtime/components/react/mpx-label.tsx +26 -27
- package/lib/runtime/components/react/mpx-movable-area.tsx +18 -23
- package/lib/runtime/components/react/mpx-movable-view.tsx +21 -25
- package/lib/runtime/components/react/mpx-navigator.tsx +2 -8
- package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
- package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +4 -1
- package/lib/runtime/components/react/mpx-picker-view.tsx +7 -1
- package/lib/runtime/components/react/mpx-radio-group.tsx +24 -27
- package/lib/runtime/components/react/mpx-radio.tsx +45 -54
- package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +121 -0
- package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
- package/lib/runtime/components/react/mpx-scroll-view.tsx +72 -71
- package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
- package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
- package/lib/runtime/components/react/mpx-switch.tsx +29 -23
- package/lib/runtime/components/react/mpx-text.tsx +14 -18
- package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
- package/lib/runtime/components/react/mpx-view.tsx +55 -65
- package/lib/runtime/components/react/mpx-web-view.tsx +108 -63
- package/lib/runtime/components/react/types/global.d.ts +3 -17
- package/lib/runtime/components/react/useAnimationHooks.ts +36 -12
- package/lib/runtime/components/react/utils.tsx +113 -82
- package/lib/runtime/components/web/getInnerListeners.js +6 -6
- package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
- package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
- package/lib/runtime/components/web/mpx-picker.vue +382 -385
- package/lib/runtime/components/web/mpx-web-view.vue +175 -161
- package/lib/runtime/optionProcessor.js +7 -38
- package/lib/runtime/utils.js +2 -0
- package/lib/style-compiler/plugins/scope-id.js +30 -2
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +77 -46
- package/lib/template-compiler/gen-node-react.js +2 -2
- package/lib/utils/pre-process-json.js +9 -5
- package/package.json +5 -4
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
- package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
- package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
- package/lib/runtime/components/web/event.js +0 -105
|
@@ -3,184 +3,198 @@
|
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
import { getCustomEvent } from './getInnerListeners'
|
|
7
|
+
import { promisify, redirectTo, navigateTo, navigateBack, reLaunch, switchTab } from '@mpxjs/api-proxy'
|
|
8
|
+
import { extend, isFunction } from '@mpxjs/utils'
|
|
9
|
+
|
|
10
|
+
const navObj = promisify({ redirectTo, navigateTo, navigateBack, reLaunch, switchTab })
|
|
11
|
+
const eventLoad = 'load'
|
|
12
|
+
const eventError = 'error'
|
|
13
|
+
const eventMessage = 'message'
|
|
14
|
+
const mpx = global.__mpx
|
|
15
|
+
export default {
|
|
16
|
+
props: {
|
|
17
|
+
src: {
|
|
18
|
+
type: String
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
computed: {
|
|
22
|
+
host () {
|
|
23
|
+
let host = this.src.split('/')
|
|
24
|
+
if (host[2]) {
|
|
25
|
+
host = host[0] + '//' + host[2]
|
|
26
|
+
} else {
|
|
27
|
+
host = ''
|
|
17
28
|
}
|
|
29
|
+
return host
|
|
18
30
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
host = ''
|
|
26
|
-
}
|
|
27
|
-
return host
|
|
28
|
-
},
|
|
29
|
-
currentUrl () {
|
|
30
|
-
if (!this.src) return ''
|
|
31
|
-
const hostValidate = this.hostValidate(this.host)
|
|
32
|
-
if (!hostValidate) {
|
|
33
|
-
console.error('访问页面域名不符合domainWhiteLists白名单配置,请确认是否正确配置该域名白名单')
|
|
34
|
-
return ''
|
|
35
|
-
}
|
|
36
|
-
let src
|
|
37
|
-
const srcQueryIndex = this.src.indexOf('?')
|
|
38
|
-
// webview与被打开页面通过_uid确定关联关系
|
|
39
|
-
if (srcQueryIndex > -1) {
|
|
40
|
-
src = `${this.src.substring(0, srcQueryIndex + 1)}mpx_webview_id=${this._uid}&${this.src.substring(srcQueryIndex + 1)}`
|
|
41
|
-
} else {
|
|
42
|
-
src = `${this.src}?mpx_webview_id=${this._uid}`
|
|
43
|
-
}
|
|
44
|
-
return src
|
|
45
|
-
},
|
|
46
|
-
loadData () {
|
|
47
|
-
return {
|
|
48
|
-
src: this.host,
|
|
49
|
-
fullUrl: this.src
|
|
50
|
-
}
|
|
31
|
+
currentUrl () {
|
|
32
|
+
if (!this.src) return ''
|
|
33
|
+
const hostValidate = this.hostValidate(this.host)
|
|
34
|
+
if (!hostValidate) {
|
|
35
|
+
console.error('访问页面域名不符合domainWhiteLists白名单配置,请确认是否正确配置该域名白名单')
|
|
36
|
+
return ''
|
|
51
37
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
errMsg: 'web-view load failed due to not in domain list'
|
|
60
|
-
}, this))
|
|
61
|
-
} else {
|
|
62
|
-
this.$nextTick(() => {
|
|
63
|
-
if (this.$refs.mpxIframe && this.mpxIframe != this.$refs.mpxIframe) {
|
|
64
|
-
this.mpxIframe = this.$refs.mpxIframe
|
|
65
|
-
this.mpxIframe.addEventListener('load', (event) => {
|
|
66
|
-
this.$emit(eventLoad, getCustomEvent(eventLoad, this.loadData, this))
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
immediate: true
|
|
38
|
+
let src
|
|
39
|
+
const srcQueryIndex = this.src.indexOf('?')
|
|
40
|
+
// webview与被打开页面通过_uid确定关联关系
|
|
41
|
+
if (srcQueryIndex > -1) {
|
|
42
|
+
src = `${this.src.substring(0, srcQueryIndex + 1)}mpx_webview_id=${this._uid}&${this.src.substring(srcQueryIndex + 1)}`
|
|
43
|
+
} else {
|
|
44
|
+
src = `${this.src}?mpx_webview_id=${this._uid}`
|
|
73
45
|
}
|
|
46
|
+
return src
|
|
74
47
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
window.addEventListener('message', this.messageCallback)
|
|
80
|
-
},
|
|
81
|
-
deactivated () {
|
|
82
|
-
if (!this.messageList.length) {
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
let data = {
|
|
86
|
-
type: 'message',
|
|
87
|
-
data: this.messageList
|
|
48
|
+
loadData () {
|
|
49
|
+
return {
|
|
50
|
+
src: this.host,
|
|
51
|
+
fullUrl: this.src
|
|
88
52
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
watch: {
|
|
56
|
+
currentUrl: {
|
|
57
|
+
handler (value) {
|
|
58
|
+
if (!value) {
|
|
59
|
+
this.$emit(eventError, getCustomEvent(eventError, extend({
|
|
60
|
+
errMsg: 'web-view load failed due to not in domain list'
|
|
61
|
+
}, this.loadData), this))
|
|
62
|
+
} else {
|
|
63
|
+
this.$nextTick(() => {
|
|
64
|
+
if (this.$refs.mpxIframe && this.mpxIframe != this.$refs.mpxIframe) {
|
|
65
|
+
this.mpxIframe = this.$refs.mpxIframe
|
|
66
|
+
this.mpxIframe.addEventListener('load', () => {
|
|
67
|
+
this.$emit(eventLoad, getCustomEvent(eventLoad, this.loadData, this))
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
immediate: true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
beforeCreate () {
|
|
77
|
+
this.messageList = []
|
|
78
|
+
},
|
|
79
|
+
mounted () {
|
|
80
|
+
window.addEventListener('message', this.messageCallback)
|
|
81
|
+
},
|
|
82
|
+
deactivated () {
|
|
83
|
+
if (!this.messageList.length) {
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
let data = {
|
|
87
|
+
type: 'message',
|
|
88
|
+
data: this.messageList
|
|
89
|
+
}
|
|
90
|
+
this.$emit(eventMessage, getCustomEvent(eventMessage, data, this))
|
|
91
|
+
},
|
|
92
|
+
destroyed () {
|
|
93
|
+
window.removeEventListener('message', this.messageCallback)
|
|
94
|
+
if (!this.messageList.length) {
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
let data = {
|
|
98
|
+
type: 'message',
|
|
99
|
+
data: this.messageList
|
|
100
|
+
}
|
|
101
|
+
this.$emit(eventMessage, getCustomEvent(eventMessage, data, this))
|
|
102
|
+
},
|
|
103
|
+
methods: {
|
|
104
|
+
messageCallback (event) {
|
|
105
|
+
const hostValidate = this.hostValidate(event.origin)
|
|
106
|
+
let data = {}
|
|
107
|
+
try {
|
|
108
|
+
const eventData = event.data
|
|
109
|
+
data = typeof eventData === 'string' ? JSON.parse(eventData) : eventData
|
|
110
|
+
} catch(e){}
|
|
111
|
+
// 判断number类型,防止undefined导致触发return逻辑
|
|
112
|
+
if (data.clientUid !== undefined && +data.clientUid !== this._uid) {
|
|
94
113
|
return
|
|
95
114
|
}
|
|
96
|
-
let
|
|
97
|
-
|
|
98
|
-
|
|
115
|
+
let value = data.payload
|
|
116
|
+
const args = data.args
|
|
117
|
+
const params = Array.isArray(args) ? args : [value]
|
|
118
|
+
if (!hostValidate) {
|
|
119
|
+
return
|
|
99
120
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
break
|
|
134
|
-
case 'reLaunch':
|
|
135
|
-
asyncCallback = navObj.reLaunch(value)
|
|
136
|
-
break
|
|
137
|
-
case 'getLocation':
|
|
138
|
-
const getLocation = mpx.config.webviewConfig.apiImplementations && mpx.config.webviewConfig.apiImplementations.getLocation
|
|
139
|
-
if (getLocation) {
|
|
140
|
-
asyncCallback = getLocation()
|
|
121
|
+
let asyncCallback = null
|
|
122
|
+
const type = data.type
|
|
123
|
+
switch (type) {
|
|
124
|
+
case 'postMessage':
|
|
125
|
+
let data = {
|
|
126
|
+
type: 'message',
|
|
127
|
+
data: params[0]?.data
|
|
128
|
+
}
|
|
129
|
+
this.$emit(eventMessage, getCustomEvent(eventMessage, data, this))
|
|
130
|
+
asyncCallback = Promise.resolve({
|
|
131
|
+
errMsg: 'invokeWebappApi:ok'
|
|
132
|
+
})
|
|
133
|
+
break
|
|
134
|
+
case 'navigateTo':
|
|
135
|
+
asyncCallback = navObj.navigateTo(...params)
|
|
136
|
+
break
|
|
137
|
+
case 'navigateBack':
|
|
138
|
+
asyncCallback = navObj.navigateBack(...params)
|
|
139
|
+
break
|
|
140
|
+
case 'redirectTo':
|
|
141
|
+
asyncCallback = navObj.redirectTo(...params)
|
|
142
|
+
break
|
|
143
|
+
case 'switchTab':
|
|
144
|
+
asyncCallback = navObj.switchTab(...params)
|
|
145
|
+
break
|
|
146
|
+
case 'reLaunch':
|
|
147
|
+
asyncCallback = navObj.reLaunch(...params)
|
|
148
|
+
break
|
|
149
|
+
default:
|
|
150
|
+
if (type) {
|
|
151
|
+
const implement = mpx.config.webviewConfig.apiImplementations && mpx.config.webviewConfig.apiImplementations[type]
|
|
152
|
+
if (isFunction(implement)) {
|
|
153
|
+
asyncCallback = Promise.resolve(implement(...params))
|
|
141
154
|
} else {
|
|
142
155
|
asyncCallback = Promise.reject({
|
|
143
|
-
errMsg:
|
|
156
|
+
errMsg: `未在apiImplementations中配置${type}方法`
|
|
144
157
|
})
|
|
145
158
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
159
|
+
}
|
|
160
|
+
break
|
|
161
|
+
}
|
|
162
|
+
asyncCallback && asyncCallback.then((res) => {
|
|
163
|
+
this.mpxIframe && this.mpxIframe.contentWindow && this.mpxIframe.contentWindow.postMessage && this.mpxIframe.contentWindow.postMessage({
|
|
164
|
+
type: type,
|
|
165
|
+
callbackId: data.callbackId,
|
|
166
|
+
result: res
|
|
167
|
+
}, event.origin)
|
|
168
|
+
}).catch((error) => {
|
|
169
|
+
this.mpxIframe && this.mpxIframe.contentWindow && this.mpxIframe.contentWindow.postMessage && this.mpxIframe.contentWindow.postMessage({
|
|
170
|
+
type: type,
|
|
171
|
+
callbackId: data.callbackId,
|
|
172
|
+
error
|
|
173
|
+
}, event.origin)
|
|
174
|
+
})
|
|
175
|
+
},
|
|
176
|
+
hostValidate (host) {
|
|
177
|
+
const hostWhitelists = mpx.config.webviewConfig && mpx.config.webviewConfig.hostWhitelists || []
|
|
178
|
+
if (hostWhitelists.length) {
|
|
179
|
+
return hostWhitelists.some((item) => {
|
|
180
|
+
return host.endsWith(item)
|
|
160
181
|
})
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const hostWhitelists = mpx.config.webviewConfig && mpx.config.webviewConfig.hostWhitelists || []
|
|
164
|
-
if (hostWhitelists.length) {
|
|
165
|
-
return hostWhitelists.some((item) => {
|
|
166
|
-
return host.endsWith(item)
|
|
167
|
-
})
|
|
168
|
-
} else {
|
|
169
|
-
return true
|
|
170
|
-
}
|
|
182
|
+
} else {
|
|
183
|
+
return true
|
|
171
184
|
}
|
|
172
185
|
}
|
|
173
186
|
}
|
|
187
|
+
}
|
|
174
188
|
</script>
|
|
175
189
|
|
|
176
190
|
<style>
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
</style>
|
|
191
|
+
.mpx-iframe {
|
|
192
|
+
width: 100%;
|
|
193
|
+
height: 100%;
|
|
194
|
+
position: absolute;
|
|
195
|
+
left: 0;
|
|
196
|
+
top: 0;
|
|
197
|
+
right: 0;
|
|
198
|
+
bottom: 0;
|
|
199
|
+
}
|
|
200
|
+
</style>
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { hasOwn, isEmptyObject } from './utils'
|
|
1
|
+
import { hasOwn, isEmptyObject, extend } from './utils'
|
|
2
2
|
import { isBrowser } from './env'
|
|
3
3
|
import transRpxStyle from './transRpxStyle'
|
|
4
4
|
import animation from './animation'
|
|
5
|
-
import { createEvent } from './components/web/event'
|
|
6
|
-
|
|
7
|
-
createEvent()
|
|
8
5
|
|
|
9
6
|
export function processComponentOption (
|
|
10
7
|
{
|
|
@@ -59,7 +56,7 @@ registered in parent context!`)
|
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
if (ctorType === 'page') {
|
|
62
|
-
option.__mpxPageConfig =
|
|
59
|
+
option.__mpxPageConfig = extend({}, global.__mpxPageConfig, pageConfig)
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
if (!hasApp) {
|
|
@@ -109,7 +106,7 @@ registered in parent context!`)
|
|
|
109
106
|
export function getComponent (component, extendOptions) {
|
|
110
107
|
component = component.__esModule ? component.default : component
|
|
111
108
|
// eslint-disable-next-line
|
|
112
|
-
if (extendOptions)
|
|
109
|
+
if (extendOptions) extend(component, extendOptions)
|
|
113
110
|
return component
|
|
114
111
|
}
|
|
115
112
|
|
|
@@ -164,10 +161,7 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
|
|
|
164
161
|
})
|
|
165
162
|
}
|
|
166
163
|
const webRouteConfig = global.__mpx.config.webConfig.routeConfig || global.__mpx.config.webRouteConfig
|
|
167
|
-
global.__mpxRouter = option.router = new VueRouter({
|
|
168
|
-
...webRouteConfig,
|
|
169
|
-
routes: routes
|
|
170
|
-
})
|
|
164
|
+
global.__mpxRouter = option.router = new VueRouter(extend({ routes }, webRouteConfig))
|
|
171
165
|
let mpxStackPath = []
|
|
172
166
|
if (isBrowser) {
|
|
173
167
|
// 解决webview被刷新导致路由栈丢失后产生错乱问题
|
|
@@ -312,25 +306,6 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
|
|
|
312
306
|
})
|
|
313
307
|
// 处理visibilitychange时触发当前活跃页面组件的onshow/onhide
|
|
314
308
|
if (isBrowser) {
|
|
315
|
-
const errorHandler = function (args, fromVue) {
|
|
316
|
-
if (global.__mpxAppCbs && global.__mpxAppCbs.error && global.__mpxAppCbs.error.length) {
|
|
317
|
-
global.__mpxAppCbs.error.forEach((cb) => {
|
|
318
|
-
cb.apply(null, args)
|
|
319
|
-
})
|
|
320
|
-
console.error(...args)
|
|
321
|
-
} else if (fromVue) {
|
|
322
|
-
throw args[0]
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
Vue.config.errorHandler = (...args) => {
|
|
326
|
-
return errorHandler(args, true)
|
|
327
|
-
}
|
|
328
|
-
window.addEventListener('error', (event) => {
|
|
329
|
-
return errorHandler([event.error, event])
|
|
330
|
-
})
|
|
331
|
-
window.addEventListener('unhandledrejection', (event) => {
|
|
332
|
-
return errorHandler([event.reason, event])
|
|
333
|
-
})
|
|
334
309
|
document.addEventListener('visibilitychange', function () {
|
|
335
310
|
const vnode = global.__mpxRouter && global.__mpxRouter.__mpxActiveVnode
|
|
336
311
|
if (vnode && vnode.componentInstance) {
|
|
@@ -365,7 +340,7 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
|
|
|
365
340
|
|
|
366
341
|
if (App.onAppInit) {
|
|
367
342
|
global.__mpxAppInit = true
|
|
368
|
-
|
|
343
|
+
extend(option, App.onAppInit() || {})
|
|
369
344
|
global.__mpxAppInit = false
|
|
370
345
|
}
|
|
371
346
|
|
|
@@ -374,14 +349,8 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
|
|
|
374
349
|
option.pinia = global.__mpxPinia
|
|
375
350
|
}
|
|
376
351
|
|
|
377
|
-
const app = new Vue({
|
|
378
|
-
|
|
379
|
-
render: (h) => h(App)
|
|
380
|
-
})
|
|
381
|
-
return {
|
|
382
|
-
app,
|
|
383
|
-
...option
|
|
384
|
-
}
|
|
352
|
+
const app = new Vue(extend(option, { render: (h) => h(App) }))
|
|
353
|
+
return extend({ app }, option)
|
|
385
354
|
}
|
|
386
355
|
|
|
387
356
|
export function processAppOption ({ firstPage, pagesMap, componentsMap, App, Vue, VueRouter, tabBarMap, el }) {
|
package/lib/runtime/utils.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const selectorParser = require('postcss-selector-parser')
|
|
2
2
|
// scope-id
|
|
3
|
-
|
|
3
|
+
function isSpaceCombinator (node) {
|
|
4
|
+
return node.type === 'combinator' && /^\s+$/.test(node.value)
|
|
5
|
+
}
|
|
4
6
|
module.exports = ({ id }) => {
|
|
5
7
|
return {
|
|
6
8
|
postcssPlugin: 'scope-id',
|
|
@@ -31,10 +33,36 @@ module.exports = ({ id }) => {
|
|
|
31
33
|
n.spaces.before = n.spaces.after = ''
|
|
32
34
|
return false
|
|
33
35
|
}
|
|
36
|
+
if (n.type === 'pseudo' && n.value === ':deep') {
|
|
37
|
+
if (n.nodes.length) {
|
|
38
|
+
let last = n
|
|
39
|
+
n.nodes[0].each((ss) => {
|
|
40
|
+
selector.insertAfter(last, ss)
|
|
41
|
+
last = ss
|
|
42
|
+
})
|
|
43
|
+
const prev = n.prev()
|
|
44
|
+
if (!prev || !isSpaceCombinator(prev)) {
|
|
45
|
+
selector.insertAfter(
|
|
46
|
+
n,
|
|
47
|
+
selectorParser.combinator({
|
|
48
|
+
value: ' '
|
|
49
|
+
})
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
n.remove()
|
|
53
|
+
} else {
|
|
54
|
+
const prev = n.prev()
|
|
55
|
+
if (prev && isSpaceCombinator(prev)) {
|
|
56
|
+
prev.remove()
|
|
57
|
+
}
|
|
58
|
+
n.remove()
|
|
59
|
+
}
|
|
60
|
+
return false
|
|
61
|
+
}
|
|
34
62
|
// /deep/ alias for >>>, since >>> doesn't work in SASS
|
|
35
63
|
if (n.type === 'tag' && n.value === '/deep/') {
|
|
36
64
|
const prev = n.prev()
|
|
37
|
-
if (prev && prev
|
|
65
|
+
if (prev && isSpaceCombinator(prev)) {
|
|
38
66
|
prev.remove()
|
|
39
67
|
}
|
|
40
68
|
n.remove()
|
|
@@ -264,7 +264,8 @@ module.exports = {
|
|
|
264
264
|
transform (code, {
|
|
265
265
|
needCollect = false,
|
|
266
266
|
renderReduce = false,
|
|
267
|
-
ignoreMap = {}
|
|
267
|
+
ignoreMap = {},
|
|
268
|
+
customBindThis
|
|
268
269
|
} = {}) {
|
|
269
270
|
const ast = babylon.parse(code, {
|
|
270
271
|
plugins: [
|
|
@@ -420,7 +421,11 @@ module.exports = {
|
|
|
420
421
|
if (isProps) {
|
|
421
422
|
propKeySet.add(name)
|
|
422
423
|
}
|
|
423
|
-
|
|
424
|
+
if (typeof customBindThis === 'function') {
|
|
425
|
+
customBindThis(path, t)
|
|
426
|
+
} else {
|
|
427
|
+
path.replaceWith(t.memberExpression(t.thisExpression(), path.node))
|
|
428
|
+
}
|
|
424
429
|
}
|
|
425
430
|
delete path.needBind
|
|
426
431
|
}
|