@mpxjs/webpack-plugin 2.9.69 → 2.9.70-alpha.0
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/README.md +1 -1
- package/lib/config.js +14 -0
- package/lib/dependencies/AddEntryDependency.js +24 -0
- package/lib/dependencies/ResolveDependency.js +5 -0
- package/lib/index.js +38 -7
- package/lib/json-compiler/helper.js +3 -3
- package/lib/loader.js +53 -0
- package/lib/platform/template/wx/component-config/button.js +14 -2
- package/lib/platform/template/wx/component-config/image.js +4 -0
- package/lib/platform/template/wx/component-config/input.js +5 -1
- package/lib/platform/template/wx/component-config/rich-text.js +4 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
- package/lib/platform/template/wx/component-config/swiper.js +1 -1
- package/lib/platform/template/wx/component-config/switch.js +4 -0
- package/lib/platform/template/wx/component-config/text.js +4 -0
- package/lib/platform/template/wx/component-config/textarea.js +6 -1
- package/lib/platform/template/wx/component-config/view.js +4 -0
- package/lib/platform/template/wx/index.js +127 -1
- package/lib/react/processTemplate.js +3 -0
- package/lib/resolve-loader.js +4 -1
- 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 -165
- package/lib/runtime/components/react/dist/mpx-button.jsx +35 -42
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +30 -12
- 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-item.jsx +39 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +110 -97
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +32 -29
- 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-item.jsx +4 -2
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
- 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 +29 -44
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +105 -42
- package/lib/runtime/components/react/dist/pickerFaces.js +12 -6
- package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
- package/lib/runtime/components/react/dist/{pickerOverlay.jsx → pickerViewOverlay.jsx} +5 -3
- package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
- package/lib/runtime/components/react/dist/utils.jsx +20 -24
- package/lib/runtime/components/react/getInnerListeners.ts +35 -28
- package/lib/runtime/components/react/mpx-button.tsx +55 -36
- package/lib/runtime/components/react/mpx-canvas/index.tsx +2 -2
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -12
- package/lib/runtime/components/react/mpx-checkbox.tsx +28 -28
- package/lib/runtime/components/react/mpx-form.tsx +10 -8
- package/lib/runtime/components/react/mpx-icon.tsx +10 -15
- package/lib/runtime/components/react/mpx-image.tsx +396 -0
- package/lib/runtime/components/react/mpx-input.tsx +61 -33
- package/lib/runtime/components/react/mpx-label.tsx +14 -13
- package/lib/runtime/components/react/mpx-movable-area.tsx +8 -7
- package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
- 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 +11 -12
- package/lib/runtime/components/react/mpx-radio.tsx +26 -29
- package/lib/runtime/components/react/mpx-scroll-view.tsx +32 -30
- 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 +10 -8
- package/lib/runtime/components/react/mpx-text.tsx +6 -2
- package/lib/runtime/components/react/mpx-view.tsx +37 -45
- package/lib/runtime/components/react/mpx-web-view.tsx +25 -15
- package/lib/runtime/components/react/types/global.d.ts +1 -16
- package/lib/runtime/components/react/utils.tsx +24 -24
- package/lib/runtime/components/tenon/getInnerListeners.js +334 -0
- package/lib/runtime/components/tenon/tenon-button.vue +309 -0
- package/lib/runtime/components/tenon/tenon-image.vue +66 -0
- package/lib/runtime/components/tenon/tenon-input.vue +171 -0
- package/lib/runtime/components/tenon/tenon-rich-text.vue +26 -0
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +127 -0
- package/lib/runtime/components/tenon/tenon-switch.vue +96 -0
- package/lib/runtime/components/tenon/tenon-text.vue +70 -0
- package/lib/runtime/components/tenon/tenon-textarea.vue +86 -0
- package/lib/runtime/components/tenon/tenon-view.vue +93 -0
- 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 +162 -162
- package/lib/runtime/optionProcessor.js +7 -16
- package/lib/runtime/optionProcessor.tenon.js +84 -0
- package/lib/runtime/utils.js +2 -0
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/hm.js +20 -0
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +67 -40
- package/lib/template-compiler/gen-node-react.js +2 -2
- package/lib/tenon/index.js +117 -0
- package/lib/tenon/processJSON.js +352 -0
- package/lib/tenon/processScript.js +203 -0
- package/lib/tenon/processStyles.js +21 -0
- package/lib/tenon/processTemplate.js +126 -0
- package/lib/tenon/script-helper.js +223 -0
- package/lib/utils/env.js +6 -1
- package/lib/utils/get-relative-path.js +25 -0
- package/package.json +7 -3
- package/LICENSE +0 -433
- 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/dist/mpx-swiper/carouse.jsx +0 -478
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
- package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
- package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
- package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
|
@@ -3,184 +3,184 @@
|
|
|
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 } from '../../utils'
|
|
9
|
+
const navObj = promisify({ redirectTo, navigateTo, navigateBack, reLaunch, switchTab })
|
|
10
|
+
const eventLoad = 'load'
|
|
11
|
+
const eventError = 'error'
|
|
12
|
+
const eventMessage = 'message'
|
|
13
|
+
const mpx = global.__mpx
|
|
14
|
+
export default {
|
|
15
|
+
props: {
|
|
16
|
+
src: {
|
|
17
|
+
type: String
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
computed: {
|
|
21
|
+
host () {
|
|
22
|
+
let host = this.src.split('/')
|
|
23
|
+
if (host[2]) {
|
|
24
|
+
host = host[0] + '//' + host[2]
|
|
25
|
+
} else {
|
|
26
|
+
host = ''
|
|
17
27
|
}
|
|
28
|
+
return host
|
|
18
29
|
},
|
|
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
|
-
}
|
|
30
|
+
currentUrl () {
|
|
31
|
+
if (!this.src) return ''
|
|
32
|
+
const hostValidate = this.hostValidate(this.host)
|
|
33
|
+
if (!hostValidate) {
|
|
34
|
+
console.error('访问页面域名不符合domainWhiteLists白名单配置,请确认是否正确配置该域名白名单')
|
|
35
|
+
return ''
|
|
51
36
|
}
|
|
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
|
|
37
|
+
let src
|
|
38
|
+
const srcQueryIndex = this.src.indexOf('?')
|
|
39
|
+
// webview与被打开页面通过_uid确定关联关系
|
|
40
|
+
if (srcQueryIndex > -1) {
|
|
41
|
+
src = `${this.src.substring(0, srcQueryIndex + 1)}mpx_webview_id=${this._uid}&${this.src.substring(srcQueryIndex + 1)}`
|
|
42
|
+
} else {
|
|
43
|
+
src = `${this.src}?mpx_webview_id=${this._uid}`
|
|
73
44
|
}
|
|
45
|
+
return src
|
|
74
46
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
window.addEventListener('message', this.messageCallback)
|
|
80
|
-
},
|
|
81
|
-
deactivated () {
|
|
82
|
-
if (!this.messageList.length) {
|
|
83
|
-
return
|
|
47
|
+
loadData () {
|
|
48
|
+
return {
|
|
49
|
+
src: this.host,
|
|
50
|
+
fullUrl: this.src
|
|
84
51
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
watch: {
|
|
55
|
+
currentUrl: {
|
|
56
|
+
handler (value) {
|
|
57
|
+
if (!value) {
|
|
58
|
+
this.$emit(eventError, getCustomEvent(eventError, extend({
|
|
59
|
+
errMsg: 'web-view load failed due to not in domain list'
|
|
60
|
+
}, this.loadData), 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', () => {
|
|
66
|
+
this.$emit(eventLoad, getCustomEvent(eventLoad, this.loadData, this))
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
immediate: true
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
beforeCreate () {
|
|
76
|
+
this.messageList = []
|
|
77
|
+
},
|
|
78
|
+
mounted () {
|
|
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
|
|
88
|
+
}
|
|
89
|
+
this.$emit(eventMessage, getCustomEvent(eventMessage, data, this))
|
|
90
|
+
},
|
|
91
|
+
destroyed () {
|
|
92
|
+
window.removeEventListener('message', this.messageCallback)
|
|
93
|
+
if (!this.messageList.length) {
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
let data = {
|
|
97
|
+
type: 'message',
|
|
98
|
+
data: this.messageList
|
|
99
|
+
}
|
|
100
|
+
this.$emit(eventMessage, getCustomEvent(eventMessage, data, this))
|
|
101
|
+
},
|
|
102
|
+
methods: {
|
|
103
|
+
messageCallback (event) {
|
|
104
|
+
const hostValidate = this.hostValidate(event.origin)
|
|
105
|
+
const data = event.data
|
|
106
|
+
// 判断number类型,防止undefined导致触发return逻辑
|
|
107
|
+
if (data.clientUid !== undefined && +data.clientUid !== this._uid) {
|
|
108
|
+
return
|
|
88
109
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
destroyed () {
|
|
92
|
-
window.removeEventListener('message', this.messageCallback)
|
|
93
|
-
if (!this.messageList.length) {
|
|
110
|
+
let value = data.payload
|
|
111
|
+
if (!hostValidate) {
|
|
94
112
|
return
|
|
95
113
|
}
|
|
96
|
-
let
|
|
97
|
-
|
|
98
|
-
|
|
114
|
+
let asyncCallback = null
|
|
115
|
+
switch (data.type) {
|
|
116
|
+
case 'postMessage':
|
|
117
|
+
this.messageList.push(value.data || value)
|
|
118
|
+
asyncCallback = Promise.resolve({
|
|
119
|
+
errMsg: 'invokeWebappApi:ok'
|
|
120
|
+
})
|
|
121
|
+
break
|
|
122
|
+
case 'navigateTo':
|
|
123
|
+
asyncCallback = navObj.navigateTo(value)
|
|
124
|
+
break
|
|
125
|
+
case 'navigateBack':
|
|
126
|
+
asyncCallback = navObj.navigateBack(value)
|
|
127
|
+
break
|
|
128
|
+
case 'redirectTo':
|
|
129
|
+
asyncCallback = navObj.redirectTo(value)
|
|
130
|
+
break
|
|
131
|
+
case 'switchTab':
|
|
132
|
+
asyncCallback = navObj.switchTab(value)
|
|
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()
|
|
141
|
+
} else {
|
|
142
|
+
asyncCallback = Promise.reject({
|
|
143
|
+
errMsg: '未在apiImplementations中配置getLocation方法'
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
break
|
|
99
147
|
}
|
|
100
|
-
|
|
148
|
+
asyncCallback && asyncCallback.then((res) => {
|
|
149
|
+
this.mpxIframe && this.mpxIframe.contentWindow && this.mpxIframe.contentWindow.postMessage && this.mpxIframe.contentWindow.postMessage({
|
|
150
|
+
type: data.type,
|
|
151
|
+
callbackId: data.callbackId,
|
|
152
|
+
result: res
|
|
153
|
+
}, event.origin)
|
|
154
|
+
}).catch((error) => {
|
|
155
|
+
this.mpxIframe && this.mpxIframe.contentWindow && this.mpxIframe.contentWindow.postMessage && this.mpxIframe.contentWindow.postMessage({
|
|
156
|
+
type: data.type,
|
|
157
|
+
callbackId: data.callbackId,
|
|
158
|
+
error
|
|
159
|
+
}, event.origin)
|
|
160
|
+
})
|
|
101
161
|
},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (data.clientUid !== undefined && +data.clientUid !== this._uid) {
|
|
108
|
-
return
|
|
109
|
-
}
|
|
110
|
-
let value = data.payload
|
|
111
|
-
if (!hostValidate) {
|
|
112
|
-
return
|
|
113
|
-
}
|
|
114
|
-
let asyncCallback = null
|
|
115
|
-
switch (data.type) {
|
|
116
|
-
case 'postMessage':
|
|
117
|
-
this.messageList.push(value.data || value)
|
|
118
|
-
asyncCallback = Promise.resolve({
|
|
119
|
-
errMsg: 'invokeWebappApi:ok'
|
|
120
|
-
})
|
|
121
|
-
break
|
|
122
|
-
case 'navigateTo':
|
|
123
|
-
asyncCallback = navObj.navigateTo(value)
|
|
124
|
-
break
|
|
125
|
-
case 'navigateBack':
|
|
126
|
-
asyncCallback = navObj.navigateBack(value)
|
|
127
|
-
break
|
|
128
|
-
case 'redirectTo':
|
|
129
|
-
asyncCallback = navObj.redirectTo(value)
|
|
130
|
-
break
|
|
131
|
-
case 'switchTab':
|
|
132
|
-
asyncCallback = navObj.switchTab(value)
|
|
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()
|
|
141
|
-
} else {
|
|
142
|
-
asyncCallback = Promise.reject({
|
|
143
|
-
errMsg: '未在apiImplementations中配置getLocation方法'
|
|
144
|
-
})
|
|
145
|
-
}
|
|
146
|
-
break
|
|
147
|
-
}
|
|
148
|
-
asyncCallback && asyncCallback.then((res) => {
|
|
149
|
-
this.mpxIframe && this.mpxIframe.contentWindow && this.mpxIframe.contentWindow.postMessage && this.mpxIframe.contentWindow.postMessage({
|
|
150
|
-
type: data.type,
|
|
151
|
-
callbackId: data.callbackId,
|
|
152
|
-
result: res
|
|
153
|
-
}, event.origin)
|
|
154
|
-
}).catch((error) => {
|
|
155
|
-
this.mpxIframe && this.mpxIframe.contentWindow && this.mpxIframe.contentWindow.postMessage && this.mpxIframe.contentWindow.postMessage({
|
|
156
|
-
type: data.type,
|
|
157
|
-
callbackId: data.callbackId,
|
|
158
|
-
error
|
|
159
|
-
}, event.origin)
|
|
162
|
+
hostValidate (host) {
|
|
163
|
+
const hostWhitelists = mpx.config.webviewConfig && mpx.config.webviewConfig.hostWhitelists || []
|
|
164
|
+
if (hostWhitelists.length) {
|
|
165
|
+
return hostWhitelists.some((item) => {
|
|
166
|
+
return host.endsWith(item)
|
|
160
167
|
})
|
|
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
|
-
}
|
|
168
|
+
} else {
|
|
169
|
+
return true
|
|
171
170
|
}
|
|
172
171
|
}
|
|
173
172
|
}
|
|
173
|
+
}
|
|
174
174
|
</script>
|
|
175
175
|
|
|
176
176
|
<style>
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
177
|
+
.mpx-iframe {
|
|
178
|
+
width: 100%;
|
|
179
|
+
height: 100%;
|
|
180
|
+
position: absolute;
|
|
181
|
+
left: 0;
|
|
182
|
+
top: 0;
|
|
183
|
+
right: 0;
|
|
184
|
+
bottom: 0;
|
|
185
|
+
}
|
|
186
186
|
</style>
|
|
@@ -1,4 +1,4 @@
|
|
|
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'
|
|
@@ -59,7 +59,7 @@ registered in parent context!`)
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
if (ctorType === 'page') {
|
|
62
|
-
option.__mpxPageConfig =
|
|
62
|
+
option.__mpxPageConfig = extend({}, global.__mpxPageConfig, pageConfig)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
if (!hasApp) {
|
|
@@ -109,7 +109,7 @@ registered in parent context!`)
|
|
|
109
109
|
export function getComponent (component, extendOptions) {
|
|
110
110
|
component = component.__esModule ? component.default : component
|
|
111
111
|
// eslint-disable-next-line
|
|
112
|
-
if (extendOptions)
|
|
112
|
+
if (extendOptions) extend(component, extendOptions)
|
|
113
113
|
return component
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -164,10 +164,7 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
|
|
|
164
164
|
})
|
|
165
165
|
}
|
|
166
166
|
const webRouteConfig = global.__mpx.config.webConfig.routeConfig || global.__mpx.config.webRouteConfig
|
|
167
|
-
global.__mpxRouter = option.router = new VueRouter({
|
|
168
|
-
...webRouteConfig,
|
|
169
|
-
routes: routes
|
|
170
|
-
})
|
|
167
|
+
global.__mpxRouter = option.router = new VueRouter(extend({ routes }, webRouteConfig))
|
|
171
168
|
let mpxStackPath = []
|
|
172
169
|
if (isBrowser) {
|
|
173
170
|
// 解决webview被刷新导致路由栈丢失后产生错乱问题
|
|
@@ -365,7 +362,7 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
|
|
|
365
362
|
|
|
366
363
|
if (App.onAppInit) {
|
|
367
364
|
global.__mpxAppInit = true
|
|
368
|
-
|
|
365
|
+
extend(option, App.onAppInit() || {})
|
|
369
366
|
global.__mpxAppInit = false
|
|
370
367
|
}
|
|
371
368
|
|
|
@@ -374,14 +371,8 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
|
|
|
374
371
|
option.pinia = global.__mpxPinia
|
|
375
372
|
}
|
|
376
373
|
|
|
377
|
-
const app = new Vue({
|
|
378
|
-
|
|
379
|
-
render: (h) => h(App)
|
|
380
|
-
})
|
|
381
|
-
return {
|
|
382
|
-
app,
|
|
383
|
-
...option
|
|
384
|
-
}
|
|
374
|
+
const app = new Vue(extend(option, { render: (h) => h(App) }))
|
|
375
|
+
return extend({ app }, option)
|
|
385
376
|
}
|
|
386
377
|
|
|
387
378
|
export function processAppOption ({ firstPage, pagesMap, componentsMap, App, Vue, VueRouter, tabBarMap, el }) {
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// import { inBrowser } from '../utils/env'
|
|
2
|
+
|
|
3
|
+
import { hasOwn } from './utils'
|
|
4
|
+
|
|
5
|
+
export function processComponentOption (
|
|
6
|
+
{
|
|
7
|
+
option,
|
|
8
|
+
ctorType,
|
|
9
|
+
outputPath,
|
|
10
|
+
pageConfig,
|
|
11
|
+
componentsMap,
|
|
12
|
+
componentGenerics,
|
|
13
|
+
genericsInfo,
|
|
14
|
+
wxsMixin,
|
|
15
|
+
hasApp,
|
|
16
|
+
}
|
|
17
|
+
) {
|
|
18
|
+
if (ctorType === 'app') {
|
|
19
|
+
// 对于app中的组件需要全局注册
|
|
20
|
+
for (const componentName in componentsMap) {
|
|
21
|
+
if (hasOwn(componentsMap, componentName)) {
|
|
22
|
+
const component = componentsMap[componentName]
|
|
23
|
+
Vue.component(componentName, component)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
// 局部注册页面和组件中依赖的组件
|
|
28
|
+
for (const componentName in componentsMap) {
|
|
29
|
+
if (hasOwn(componentsMap, componentName)) {
|
|
30
|
+
const component = componentsMap[componentName]
|
|
31
|
+
if (!option.components) {
|
|
32
|
+
option.components = {}
|
|
33
|
+
}
|
|
34
|
+
option.components[componentName] = component
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (ctorType === 'page') {
|
|
39
|
+
(option.mixins ? option.mixins : (option.mixins = [])).push({
|
|
40
|
+
// cache page instance in tenon
|
|
41
|
+
created () {
|
|
42
|
+
global.__currentPageInstance = this
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
option.__mpxPageConfig = Object.assign({}, global.__mpxPageConfig, pageConfig)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (wxsMixin) {
|
|
50
|
+
if (option.mixins) {
|
|
51
|
+
option.mixins.push(mixin)
|
|
52
|
+
} else {
|
|
53
|
+
option.mixins = [mixin]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (outputPath) {
|
|
58
|
+
option.componentPath = '/' + outputPath
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return option
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function getComponent (component, extendOptions) {
|
|
65
|
+
component = component.__esModule ? component.default : component
|
|
66
|
+
// eslint-disable-next-line
|
|
67
|
+
if (extendOptions) Object.assign(component, extendOptions)
|
|
68
|
+
return component
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function getWxsMixin (wxsModules) {
|
|
72
|
+
if (!wxsModules) return {}
|
|
73
|
+
return {
|
|
74
|
+
created () {
|
|
75
|
+
Object.keys(wxsModules).forEach((key) => {
|
|
76
|
+
if (key in this) {
|
|
77
|
+
console.error(`[Mpx runtime error]: The wxs module key [${key}] exist in the component/page instance already, please check and rename it!`)
|
|
78
|
+
} else {
|
|
79
|
+
this[key] = wxsModules[key]
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
package/lib/runtime/utils.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = function (css, map) {
|
|
|
30
30
|
const index = queryObj.index || 0
|
|
31
31
|
const packageName = queryObj.packageRoot || mpx.currentPackageRoot || 'main'
|
|
32
32
|
|
|
33
|
-
const transRpxFn = mpx.webConfig.transRpxFn
|
|
33
|
+
const transRpxFn = mpx.webConfig && mpx.webConfig.transRpxFn
|
|
34
34
|
const testResolveRange = (include = () => true, exclude) => {
|
|
35
35
|
return matchCondition(this.resourcePath, { include, exclude })
|
|
36
36
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const postcss = require('postcss')
|
|
2
|
+
const rpxRegExp = /\b(\d+(\.\d+)?)rpx\b/
|
|
3
|
+
const rpxRegExpG = /\b(\d+(\.\d+)?)rpx\b/g
|
|
4
|
+
|
|
5
|
+
module.exports = postcss.plugin('hm', (options = {}) => root => {
|
|
6
|
+
function transHm (declaration) {
|
|
7
|
+
if (rpxRegExp.test(declaration.value)) {
|
|
8
|
+
declaration.value = declaration.value.replace(rpxRegExpG, function (match, $1) {
|
|
9
|
+
if ($1 === '0') return $1
|
|
10
|
+
return `${$1}hm`
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
root.walkRules(rule => {
|
|
16
|
+
rule.walkDecls(declaration => {
|
|
17
|
+
transHm(declaration)
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
})
|
|
@@ -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
|
}
|