@mpxjs/core 2.9.42 → 2.9.46
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 +4 -4
- package/src/dynamic/dynamicRenderMixin.empty.js +17 -0
- package/src/platform/builtInMixins/index.js +5 -9
- package/src/platform/builtInMixins/proxyEventMixin.js +6 -0
- package/src/platform/createApp.ios.js +9 -2
- package/src/platform/patch/react/getDefaultOptions.ios.js +22 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/core",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.46",
|
|
4
4
|
"description": "mpx runtime core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"miniprogram",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@mpxjs/store": "^2.9.0",
|
|
30
30
|
"@react-navigation/native": "^6.1.17",
|
|
31
31
|
"@react-navigation/native-stack": "^6.9.26",
|
|
32
|
-
"react": "
|
|
33
|
-
"react-native": "
|
|
32
|
+
"react": "*",
|
|
33
|
+
"react-native": "*",
|
|
34
34
|
"vue": "^2.7.10",
|
|
35
35
|
"vue-demi": "^0.14.6",
|
|
36
36
|
"vue-i18n": "^8.27.2",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"url": "https://github.com/didi/mpx/issues"
|
|
82
82
|
},
|
|
83
83
|
"sideEffects": false,
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "310d4b0986313835bb30f027983c2bc1b64814c6"
|
|
85
85
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function dynamicRefsMixin () {
|
|
2
|
+
return {}
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function dynamicSlotMixin () {
|
|
6
|
+
return {}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function dynamicRenderHelperMixin () {
|
|
10
|
+
return {}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
dynamicRefsMixin,
|
|
15
|
+
dynamicSlotMixin,
|
|
16
|
+
dynamicRenderHelperMixin
|
|
17
|
+
}
|
|
@@ -10,7 +10,7 @@ import pageScrollMixin from './pageScrollMixin'
|
|
|
10
10
|
import componentGenericsMixin from './componentGenericsMixin'
|
|
11
11
|
import getTabBarMixin from './getTabBarMixin'
|
|
12
12
|
import pageRouteMixin from './pageRouteMixin'
|
|
13
|
-
import { dynamicRefsMixin, dynamicRenderHelperMixin, dynamicSlotMixin } from '../../dynamic/dynamicRenderMixin'
|
|
13
|
+
import { dynamicRefsMixin, dynamicRenderHelperMixin, dynamicSlotMixin } from '../../dynamic/dynamicRenderMixin.empty'
|
|
14
14
|
import styleHelperMixin from './styleHelperMixin'
|
|
15
15
|
import directiveHelperMixin from './directiveHelperMixin'
|
|
16
16
|
import { isReact } from '@mpxjs/utils'
|
|
@@ -50,15 +50,11 @@ export default function getBuiltInMixins (options, type) {
|
|
|
50
50
|
bulitInMixins = bulitInMixins.concat([
|
|
51
51
|
renderHelperMixin(),
|
|
52
52
|
showMixin(type),
|
|
53
|
-
i18nMixin()
|
|
53
|
+
i18nMixin(),
|
|
54
|
+
dynamicRenderHelperMixin(),
|
|
55
|
+
dynamicSlotMixin(),
|
|
56
|
+
dynamicRefsMixin()
|
|
54
57
|
])
|
|
55
|
-
if (__mpx_dynamic_runtime__) {
|
|
56
|
-
bulitInMixins = bulitInMixins.concat([
|
|
57
|
-
dynamicRenderHelperMixin(),
|
|
58
|
-
dynamicSlotMixin(),
|
|
59
|
-
dynamicRefsMixin()
|
|
60
|
-
])
|
|
61
|
-
}
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
60
|
return bulitInMixins.filter(item => item)
|
|
@@ -18,6 +18,8 @@ export default function proxyEventMixin () {
|
|
|
18
18
|
}
|
|
19
19
|
const location = this.__mpxProxy.options.mpxFileResource
|
|
20
20
|
const type = $event.type
|
|
21
|
+
// thanos 平台特殊事件标识
|
|
22
|
+
const emitMode = $event.detail && $event.detail.mpxEmit
|
|
21
23
|
if (!type) {
|
|
22
24
|
error('Event object must have [type] property!', location)
|
|
23
25
|
return
|
|
@@ -44,6 +46,10 @@ export default function proxyEventMixin () {
|
|
|
44
46
|
let returnedValue
|
|
45
47
|
curEventConfig.forEach((item) => {
|
|
46
48
|
const callbackName = item[0]
|
|
49
|
+
if (emitMode) {
|
|
50
|
+
// thanos 平台特殊事件标识处理
|
|
51
|
+
$event = $event.detail.data
|
|
52
|
+
}
|
|
47
53
|
if (callbackName) {
|
|
48
54
|
const params = item.length > 1
|
|
49
55
|
? item.slice(1).map(item => {
|
|
@@ -49,7 +49,6 @@ export default function createApp (option, config = {}) {
|
|
|
49
49
|
component: item
|
|
50
50
|
})
|
|
51
51
|
})
|
|
52
|
-
global.__navigationRef = navigationRef
|
|
53
52
|
global.__mpxOptionsMap = global.__mpxOptionsMap || {}
|
|
54
53
|
const onStateChange = () => {
|
|
55
54
|
if (global.__navigationHelper.lastSuccessCallback) {
|
|
@@ -81,7 +80,6 @@ export default function createApp (option, config = {}) {
|
|
|
81
80
|
referrerInfo: {}
|
|
82
81
|
}
|
|
83
82
|
global.__mpxEnterOptions = options
|
|
84
|
-
// todo relaunch时会重复执行,需check
|
|
85
83
|
defaultOptions.onLaunch && defaultOptions.onLaunch.call(instance, options)
|
|
86
84
|
}, [])
|
|
87
85
|
return createElement(NavigationContainer,
|
|
@@ -101,4 +99,13 @@ export default function createApp (option, config = {}) {
|
|
|
101
99
|
global.getApp = function () {
|
|
102
100
|
return appData
|
|
103
101
|
}
|
|
102
|
+
global.getCurrentPages = function () {
|
|
103
|
+
const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
|
|
104
|
+
if (navigation) {
|
|
105
|
+
return navigation.getState().routes.map((route) => {
|
|
106
|
+
return global.__mpxPagesMap[route.key] && global.__mpxPagesMap[route.key][0]
|
|
107
|
+
}).filter(item => item)
|
|
108
|
+
}
|
|
109
|
+
return []
|
|
110
|
+
}
|
|
104
111
|
}
|
|
@@ -3,7 +3,7 @@ import * as ReactNative from 'react-native'
|
|
|
3
3
|
import { ReactiveEffect } from '../../../observer/effect'
|
|
4
4
|
import { hasOwn, isFunction, noop, isObject, error, getByPath, collectDataset } from '@mpxjs/utils'
|
|
5
5
|
import MpxProxy from '../../../core/proxy'
|
|
6
|
-
import { BEFOREUPDATE, UPDATED } from '../../../core/innerLifecycle'
|
|
6
|
+
import { BEFOREUPDATE, UPDATED, ONLOAD } from '../../../core/innerLifecycle'
|
|
7
7
|
import mergeOptions from '../../../core/mergeOptions'
|
|
8
8
|
import { queueJob } from '../../../observer/scheduler'
|
|
9
9
|
|
|
@@ -43,7 +43,7 @@ function createEffect (proxy, components, props) {
|
|
|
43
43
|
}, () => queueJob(update), proxy.scope)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
function createInstance ({ propsRef,
|
|
46
|
+
function createInstance ({ propsRef, type, rawOptions, currentInject, validProps, components }) {
|
|
47
47
|
const instance = Object.create({
|
|
48
48
|
setData (data, callback) {
|
|
49
49
|
return this.__mpxProxy.forceUpdate(data, { sync: true }, callback)
|
|
@@ -61,7 +61,7 @@ function createInstance ({ propsRef, ref, type, rawOptions, currentInject, valid
|
|
|
61
61
|
return propsData
|
|
62
62
|
},
|
|
63
63
|
__getSlot (name) {
|
|
64
|
-
const { children } = propsRef.current
|
|
64
|
+
const { children } = propsRef.current
|
|
65
65
|
if (children) {
|
|
66
66
|
const result = []
|
|
67
67
|
if (Array.isArray(children)) {
|
|
@@ -164,8 +164,20 @@ function createInstance ({ propsRef, ref, type, rawOptions, currentInject, valid
|
|
|
164
164
|
}
|
|
165
165
|
})
|
|
166
166
|
|
|
167
|
+
const props = propsRef.current
|
|
168
|
+
|
|
169
|
+
if (type === 'page') {
|
|
170
|
+
instance.route = props.route.name
|
|
171
|
+
global.__mpxPagesMap[props.route.key] = [instance, props.navigation]
|
|
172
|
+
}
|
|
173
|
+
|
|
167
174
|
const proxy = instance.__mpxProxy = new MpxProxy(rawOptions, instance)
|
|
168
175
|
proxy.created()
|
|
176
|
+
|
|
177
|
+
if (type === 'page') {
|
|
178
|
+
proxy.callHook(ONLOAD, [props.route.params])
|
|
179
|
+
}
|
|
180
|
+
|
|
169
181
|
Object.assign(proxy, {
|
|
170
182
|
onStoreChange: null,
|
|
171
183
|
// eslint-disable-next-line symbol-description
|
|
@@ -205,7 +217,7 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
205
217
|
let isFirst = false
|
|
206
218
|
if (!instanceRef.current) {
|
|
207
219
|
isFirst = true
|
|
208
|
-
instanceRef.current = createInstance({ propsRef,
|
|
220
|
+
instanceRef.current = createInstance({ propsRef, type, rawOptions, currentInject, validProps, components })
|
|
209
221
|
}
|
|
210
222
|
const instance = instanceRef.current
|
|
211
223
|
// reset instance
|
|
@@ -238,6 +250,9 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
238
250
|
proxy.mounted()
|
|
239
251
|
return () => {
|
|
240
252
|
proxy.unmounted()
|
|
253
|
+
if (type === 'page') {
|
|
254
|
+
delete global.__mpxPagesMap[props.route.key]
|
|
255
|
+
}
|
|
241
256
|
}
|
|
242
257
|
}, [])
|
|
243
258
|
|
|
@@ -249,7 +264,7 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
249
264
|
if (type === 'page') {
|
|
250
265
|
const { Provider } = global.__navigationHelper
|
|
251
266
|
const pageConfig = Object.assign({}, global.__mpxPageConfig, currentInject.pageConfig)
|
|
252
|
-
const Page = ({ navigation }) => {
|
|
267
|
+
const Page = ({ navigation, route }) => {
|
|
253
268
|
useLayoutEffect(() => {
|
|
254
269
|
navigation.setOptions({
|
|
255
270
|
headerTitle: pageConfig.navigationBarTitleText || '',
|
|
@@ -259,6 +274,7 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
259
274
|
headerTintColor: pageConfig.navigationBarTextStyle || 'white'
|
|
260
275
|
})
|
|
261
276
|
}, [])
|
|
277
|
+
|
|
262
278
|
return createElement(Provider,
|
|
263
279
|
null,
|
|
264
280
|
createElement(ReactNative.View,
|
|
@@ -268,7 +284,7 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
268
284
|
backgroundColor: pageConfig.backgroundColor || '#ffffff'
|
|
269
285
|
}
|
|
270
286
|
},
|
|
271
|
-
createElement(defaultOptions)
|
|
287
|
+
createElement(defaultOptions, { navigation, route, pageConfig })
|
|
272
288
|
)
|
|
273
289
|
)
|
|
274
290
|
}
|