@mpxjs/webpack-plugin 2.9.35 → 2.9.36
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/runtime/components/web/event.js +13 -5
- package/lib/runtime/components/web/getInnerListeners.js +1 -1
- package/lib/runtime/components/web/mpx-icon.vue +26 -25
- package/lib/runtime/components/web/mpx-web-view.vue +13 -1
- package/lib/runtime/optionProcessor.js +26 -1
- package/lib/web/processMainScript.js +1 -3
- package/lib/web/processScript.js +2 -2
- package/lib/web/script-helper.js +7 -1
- package/package.json +2 -2
|
@@ -89,9 +89,17 @@ function MpxEvent (layer) {
|
|
|
89
89
|
this.addListener()
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
export function createEvent () {
|
|
93
|
+
if (isBrowser && !global.__mpxCreatedEvent) {
|
|
94
|
+
global.__mpxCreatedEvent = true
|
|
95
|
+
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
|
96
|
+
// eslint-disable-next-line no-new
|
|
97
|
+
new MpxEvent(document.body)
|
|
98
|
+
} else {
|
|
99
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
100
|
+
// eslint-disable-next-line no-new
|
|
101
|
+
new MpxEvent(document.body)
|
|
102
|
+
}, false)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
97
105
|
}
|
|
@@ -8,8 +8,8 @@ function processModel (listeners, context) {
|
|
|
8
8
|
if (modelEvent) {
|
|
9
9
|
// 对于modelEvent,内部获得时间后向外部转发,触发外部listener的同时转发为mpxModel事件
|
|
10
10
|
listeners[modelEvent] = function (e) {
|
|
11
|
-
context.$emit(modelEvent, e)
|
|
12
11
|
context.$emit('mpxModel', e)
|
|
12
|
+
context.$emit(modelEvent, e)
|
|
13
13
|
}
|
|
14
14
|
// 内部listener不需要mpxModel
|
|
15
15
|
delete listeners.mpxModel
|
|
@@ -2,16 +2,31 @@
|
|
|
2
2
|
import getInnerListeners from './getInnerListeners'
|
|
3
3
|
import { processSize } from '../../utils'
|
|
4
4
|
|
|
5
|
-
let defaultColor
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
let defaultColor
|
|
6
|
+
if (global.__style === 'v2') {
|
|
7
|
+
defaultColor = {
|
|
8
|
+
success: '#07c160',
|
|
9
|
+
'success_no_circle': '#07c160',
|
|
10
|
+
info: '#10AEFF',
|
|
11
|
+
warn: '#F76260',
|
|
12
|
+
waiting: '#10AEFF',
|
|
13
|
+
cancel: '#F43530',
|
|
14
|
+
download: '#13bf69',
|
|
15
|
+
search: '#7d7979',
|
|
16
|
+
clear: '#B2B2B2'
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
defaultColor = {
|
|
20
|
+
success: '#09BB07',
|
|
21
|
+
'success_no_circle': '#09BB07',
|
|
22
|
+
info: '#10AEFF',
|
|
23
|
+
warn: '#F76260',
|
|
24
|
+
waiting: '#10AEFF',
|
|
25
|
+
cancel: '#F43530',
|
|
26
|
+
download: '#09BB07',
|
|
27
|
+
search: '#B2B2B2',
|
|
28
|
+
clear: '#B2B2B2'
|
|
29
|
+
}
|
|
15
30
|
}
|
|
16
31
|
|
|
17
32
|
export default {
|
|
@@ -52,17 +67,6 @@
|
|
|
52
67
|
width: sizeStr,
|
|
53
68
|
height: sizeStr
|
|
54
69
|
}
|
|
55
|
-
defaultColor = {
|
|
56
|
-
success: '#07c160',
|
|
57
|
-
'success_no_circle': '#07c160',
|
|
58
|
-
info: '#10AEFF',
|
|
59
|
-
warn: '#F76260',
|
|
60
|
-
waiting: '#10AEFF',
|
|
61
|
-
cancel: '#F43530',
|
|
62
|
-
download: '#13bf69',
|
|
63
|
-
search: '#7d7979',
|
|
64
|
-
clear: '#B2B2B2'
|
|
65
|
-
}
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
const data = {
|
|
@@ -118,11 +122,8 @@
|
|
|
118
122
|
&.mpx-icon-waiting-v2,
|
|
119
123
|
&.mpx-icon-search-v2,
|
|
120
124
|
&.mpx-icon-clear-v2,
|
|
121
|
-
&.mpx-icon-success_no_circle-v2
|
|
122
|
-
&.mpx-icon-download-v2
|
|
125
|
+
&.mpx-icon-success_no_circle-v2
|
|
123
126
|
display: inline-block
|
|
124
|
-
width: 64px
|
|
125
|
-
height: 64px
|
|
126
127
|
mask-position: 50% 50%
|
|
127
128
|
-webkit-mask-position: 50% 50%
|
|
128
129
|
-webkit-mask-repeat: no-repeat
|
|
@@ -33,7 +33,15 @@
|
|
|
33
33
|
console.error('访问页面域名不符合domainWhiteLists白名单配置,请确认是否正确配置该域名白名单')
|
|
34
34
|
return ''
|
|
35
35
|
}
|
|
36
|
-
|
|
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
|
|
37
45
|
},
|
|
38
46
|
loadData () {
|
|
39
47
|
return {
|
|
@@ -95,6 +103,10 @@
|
|
|
95
103
|
messageCallback (event) {
|
|
96
104
|
const hostValidate = this.hostValidate(event.origin)
|
|
97
105
|
const data = event.data
|
|
106
|
+
// 判断number类型,防止undefined导致触发return逻辑
|
|
107
|
+
if (data.clientUid !== undefined && +data.clientUid !== this._uid) {
|
|
108
|
+
return
|
|
109
|
+
}
|
|
98
110
|
let value = data.payload
|
|
99
111
|
if (!hostValidate) {
|
|
100
112
|
return
|
|
@@ -2,6 +2,9 @@ import { hasOwn, isEmptyObject } 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()
|
|
5
8
|
|
|
6
9
|
export function processComponentOption (
|
|
7
10
|
{
|
|
@@ -138,7 +141,18 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
|
|
|
138
141
|
...webRouteConfig,
|
|
139
142
|
routes: routes
|
|
140
143
|
})
|
|
141
|
-
|
|
144
|
+
let mpxStackPath = []
|
|
145
|
+
if (isBrowser) {
|
|
146
|
+
// 解决webview被刷新导致路由栈丢失后产生错乱问题
|
|
147
|
+
const sessionStorage = window.sessionStorage
|
|
148
|
+
try {
|
|
149
|
+
if (sessionStorage) {
|
|
150
|
+
mpxStackPath = JSON.parse(sessionStorage.getItem('_mpx_stack_path_'))
|
|
151
|
+
}
|
|
152
|
+
} catch (e) {
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
global.__mpxRouter.stack = mpxStackPath
|
|
142
156
|
global.__mpxRouter.lastStack = null
|
|
143
157
|
global.__mpxRouter.needCache = null
|
|
144
158
|
global.__mpxRouter.needRemove = []
|
|
@@ -252,6 +266,17 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
|
|
|
252
266
|
global.__mpxRouter.needCache = insertItem
|
|
253
267
|
}
|
|
254
268
|
}
|
|
269
|
+
if (isBrowser) {
|
|
270
|
+
const sessionStorage = window.sessionStorage
|
|
271
|
+
if (sessionStorage) {
|
|
272
|
+
const stackStorage = global.__mpxRouter.stack.slice(0, global.__mpxRouter.stack.length - 1).map((item) => {
|
|
273
|
+
return {
|
|
274
|
+
path: item.path
|
|
275
|
+
}
|
|
276
|
+
})
|
|
277
|
+
sessionStorage.setItem('_mpx_stack_path_', JSON.stringify(stackStorage))
|
|
278
|
+
}
|
|
279
|
+
}
|
|
255
280
|
next()
|
|
256
281
|
})
|
|
257
282
|
// 处理visibilitychange时触发当前活跃页面组件的onshow/onhide
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const addQuery = require('../utils/add-query')
|
|
3
3
|
const normalize = require('../utils/normalize')
|
|
4
4
|
const optionProcessorPath = normalize.lib('runtime/optionProcessor')
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
const {
|
|
7
7
|
buildComponentsMap,
|
|
8
8
|
buildPagesMap,
|
|
@@ -66,8 +66,6 @@ module.exports = function (script, {
|
|
|
66
66
|
globalTabBar
|
|
67
67
|
})
|
|
68
68
|
|
|
69
|
-
output += `\n require(${stringifyRequest(loaderContext, eventPath)})\n`
|
|
70
|
-
|
|
71
69
|
output += `\n var App = require(${stringifyRequest(loaderContext, addQuery(resource, { isApp: true }))}).default\n`
|
|
72
70
|
|
|
73
71
|
output += `
|
package/lib/web/processScript.js
CHANGED
|
@@ -18,7 +18,7 @@ module.exports = function (script, {
|
|
|
18
18
|
wxsModuleMap,
|
|
19
19
|
localComponentsMap
|
|
20
20
|
}, callback) {
|
|
21
|
-
const { projectRoot, appInfo } = loaderContext.getMpx()
|
|
21
|
+
const { projectRoot, appInfo, webConfig } = loaderContext.getMpx()
|
|
22
22
|
|
|
23
23
|
const stringifyRequest = r => loaderUtils.stringifyRequest(loaderContext, r)
|
|
24
24
|
|
|
@@ -73,7 +73,7 @@ module.exports = function (script, {
|
|
|
73
73
|
})
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
content += buildGlobalParams({ moduleId, scriptSrcMode, loaderContext, isProduction })
|
|
76
|
+
content += buildGlobalParams({ moduleId, scriptSrcMode, loaderContext, isProduction, webConfig, hasApp })
|
|
77
77
|
content += getRequireScript({ ctorType, script, loaderContext })
|
|
78
78
|
content += `
|
|
79
79
|
export default processComponentOption({
|
package/lib/web/script-helper.js
CHANGED
|
@@ -144,7 +144,8 @@ function buildGlobalParams ({
|
|
|
144
144
|
jsonConfig,
|
|
145
145
|
webConfig,
|
|
146
146
|
isMain,
|
|
147
|
-
globalTabBar
|
|
147
|
+
globalTabBar,
|
|
148
|
+
hasApp
|
|
148
149
|
}) {
|
|
149
150
|
let content = ''
|
|
150
151
|
if (isMain) {
|
|
@@ -175,6 +176,11 @@ function buildGlobalParams ({
|
|
|
175
176
|
if (globalTabBar) {
|
|
176
177
|
content += globalTabBar
|
|
177
178
|
}
|
|
179
|
+
} else if (!hasApp) {
|
|
180
|
+
content += `
|
|
181
|
+
global.__mpxGenericsMap = global.__mpxGenericsMap || {}
|
|
182
|
+
global.__mpxOptionsMap = global.__mpxOptionsMap || {}
|
|
183
|
+
global.__mpxTransRpxFn = ${webConfig.transRpxFn} \n`
|
|
178
184
|
}
|
|
179
185
|
content += ` global.currentModuleId = ${JSON.stringify(moduleId)}\n`
|
|
180
186
|
content += ` global.currentSrcMode = ${JSON.stringify(scriptSrcMode)}\n`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.36",
|
|
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": "
|
|
85
|
+
"gitHead": "23c1e87cde0eafbb4a6526d83551eb5e12740ba8"
|
|
86
86
|
}
|