@mpxjs/core 2.8.18 → 2.8.20
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/package.json +2 -2
- package/src/core/mergeOptions.js +2 -2
- package/src/core/proxy.js +2 -1
- package/src/platform/patch/ali/getDefaultOptions.js +8 -2
- package/src/platform/patch/builtInKeysMap.js +4 -4
- package/src/platform/patch/web/getDefaultOptions.js +11 -7
- package/src/platform/patch/wx/getDefaultOptions.js +8 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/core",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.20",
|
|
4
4
|
"description": "mpx runtime core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"miniprogram",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"url": "https://github.com/didi/mpx/issues"
|
|
48
48
|
},
|
|
49
49
|
"sideEffects": false,
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "c330d3938cc0c37843761df8b1f2deb9b6c618fc"
|
|
51
51
|
}
|
package/src/core/mergeOptions.js
CHANGED
|
@@ -47,7 +47,7 @@ export default function mergeOptions (options = {}, type, needConvert) {
|
|
|
47
47
|
|
|
48
48
|
export function getMixin (mixin = {}) {
|
|
49
49
|
// 用于ts反向推导mixin类型
|
|
50
|
-
return mixin
|
|
50
|
+
return mixin
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function extractMixins (mergeOptions, options, needConvert) {
|
|
@@ -214,7 +214,7 @@ function mergeMixins (parent, child) {
|
|
|
214
214
|
mergeHooks(parent, child, key)
|
|
215
215
|
} else if (/^(data|dataFn)$/.test(key)) {
|
|
216
216
|
mergeDataFn(parent, child, key)
|
|
217
|
-
} else if (/^(computed|properties|props|methods|proto|options|relations)$/.test(key)) {
|
|
217
|
+
} else if (/^(computed|properties|props|methods|proto|options|relations|initData)$/.test(key)) {
|
|
218
218
|
mergeShallowObj(parent, child, key)
|
|
219
219
|
} else if (/^(watch|observers|pageLifetimes|events)$/.test(key)) {
|
|
220
220
|
mergeToArray(parent, child, key)
|
package/src/core/proxy.js
CHANGED
|
@@ -121,11 +121,12 @@ export default class MpxProxy {
|
|
|
121
121
|
this.currentRenderTask = null
|
|
122
122
|
}
|
|
123
123
|
this.initApi()
|
|
124
|
-
this.callHook(BEFORECREATE)
|
|
125
124
|
}
|
|
126
125
|
|
|
127
126
|
created () {
|
|
128
127
|
if (__mpx_mode__ !== 'web') {
|
|
128
|
+
// web中BEFORECREATE钩子通过vue的beforeCreate钩子单独驱动
|
|
129
|
+
this.callHook(BEFORECREATE)
|
|
129
130
|
setCurrentInstance(this)
|
|
130
131
|
this.initProps()
|
|
131
132
|
this.initSetup()
|
|
@@ -74,8 +74,14 @@ function filterOptions (options, type) {
|
|
|
74
74
|
if (builtInKeysMap[key]) {
|
|
75
75
|
return
|
|
76
76
|
}
|
|
77
|
-
if (key === '
|
|
78
|
-
|
|
77
|
+
if (key === 'data' || key === 'initData') {
|
|
78
|
+
if (!hasOwn(newOptions, 'data')) {
|
|
79
|
+
newOptions.data = Object.assign({}, options.initData, options.data)
|
|
80
|
+
}
|
|
81
|
+
} else if (key === 'properties' || key === 'props') {
|
|
82
|
+
if (!hasOwn(newOptions, 'props')) {
|
|
83
|
+
newOptions.props = Object.assign({}, options.props, options.properties)
|
|
84
|
+
}
|
|
79
85
|
} else if (key === 'methods' && type === 'page') {
|
|
80
86
|
Object.assign(newOptions, options[key])
|
|
81
87
|
} else {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { INNER_LIFECYCLES } from '../../core/innerLifecycle'
|
|
2
2
|
import { makeMap } from '@mpxjs/utils'
|
|
3
3
|
|
|
4
|
-
let
|
|
4
|
+
let builtInKeys
|
|
5
5
|
|
|
6
6
|
if (__mpx_mode__ === 'web') {
|
|
7
|
-
|
|
7
|
+
builtInKeys = [
|
|
8
8
|
'proto',
|
|
9
9
|
'mixins',
|
|
10
10
|
'mpxCustomKeysForBlend',
|
|
@@ -15,7 +15,7 @@ if (__mpx_mode__ === 'web') {
|
|
|
15
15
|
'__pageCtor__'
|
|
16
16
|
]
|
|
17
17
|
} else {
|
|
18
|
-
|
|
18
|
+
builtInKeys = [
|
|
19
19
|
'setup',
|
|
20
20
|
'dataFn',
|
|
21
21
|
'proto',
|
|
@@ -31,4 +31,4 @@ if (__mpx_mode__ === 'web') {
|
|
|
31
31
|
]
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export default makeMap(
|
|
34
|
+
export default makeMap(builtInKeys.concat(INNER_LIFECYCLES))
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import builtInKeysMap from '../builtInKeysMap'
|
|
2
2
|
import mergeOptions from '../../../core/mergeOptions'
|
|
3
|
-
import { diffAndCloneA } from '@mpxjs/utils'
|
|
3
|
+
import { diffAndCloneA, hasOwn } from '@mpxjs/utils'
|
|
4
4
|
import { getCurrentInstance as getCurrentVueInstance } from '../../export/index'
|
|
5
5
|
import MpxProxy, { setCurrentInstance, unsetCurrentInstance } from '../../../core/proxy'
|
|
6
|
-
import { BEFOREUPDATE, UPDATED, BEFOREUNMOUNT, UNMOUNTED } from '../../../core/innerLifecycle'
|
|
6
|
+
import { BEFORECREATE, BEFOREUPDATE, UPDATED, BEFOREUNMOUNT, UNMOUNTED } from '../../../core/innerLifecycle'
|
|
7
7
|
|
|
8
8
|
function filterOptions (options) {
|
|
9
9
|
const newOptions = {}
|
|
@@ -12,11 +12,13 @@ function filterOptions (options) {
|
|
|
12
12
|
return
|
|
13
13
|
}
|
|
14
14
|
if (key === 'data' || key === 'dataFn') {
|
|
15
|
-
newOptions
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
if (!hasOwn(newOptions, 'data')) {
|
|
16
|
+
newOptions.data = function mergeFn () {
|
|
17
|
+
return Object.assign(
|
|
18
|
+
diffAndCloneA(options.data || {}).clone,
|
|
19
|
+
options.dataFn && options.dataFn.call(this)
|
|
20
|
+
)
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
} else {
|
|
22
24
|
newOptions[key] = options[key]
|
|
@@ -28,8 +30,10 @@ function filterOptions (options) {
|
|
|
28
30
|
function initProxy (context, rawOptions) {
|
|
29
31
|
if (!context.__mpxProxy) {
|
|
30
32
|
context.__mpxProxy = new MpxProxy(rawOptions, context)
|
|
33
|
+
context.__mpxProxy.callHook(BEFORECREATE)
|
|
31
34
|
} else if (context.__mpxProxy.isUnmounted()) {
|
|
32
35
|
context.__mpxProxy = new MpxProxy(rawOptions, context, true)
|
|
36
|
+
context.__mpxProxy.callHook(BEFORECREATE)
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
|
|
@@ -112,8 +112,14 @@ export function filterOptions (options) {
|
|
|
112
112
|
if (builtInKeysMap[key]) {
|
|
113
113
|
return
|
|
114
114
|
}
|
|
115
|
-
if (key === '
|
|
116
|
-
|
|
115
|
+
if (key === 'data' || key === 'initData') {
|
|
116
|
+
if (!hasOwn(newOptions, 'data')) {
|
|
117
|
+
newOptions.data = Object.assign({}, options.initData, options.data)
|
|
118
|
+
}
|
|
119
|
+
} else if (key === 'properties' || key === 'props') {
|
|
120
|
+
if (!hasOwn(newOptions, 'properties')) {
|
|
121
|
+
newOptions.properties = transformProperties(Object.assign({}, options.props, options.properties))
|
|
122
|
+
}
|
|
117
123
|
} else if (key === 'methods' && options.__pageCtor__) {
|
|
118
124
|
// 构造器为Page时抽取所有methods方法到顶层
|
|
119
125
|
Object.assign(newOptions, options[key])
|