@mpxjs/core 2.9.69-beta.1 → 2.9.69-beta.2
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/core",
|
|
3
|
-
"version": "2.9.69-beta.
|
|
3
|
+
"version": "2.9.69-beta.2",
|
|
4
4
|
"description": "mpx runtime core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"miniprogram",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"main": "src/index.js",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@mpxjs/utils": "^2.9.69-beta.
|
|
22
|
+
"@mpxjs/utils": "^2.9.69-beta.1",
|
|
23
23
|
"lodash": "^4.1.1",
|
|
24
24
|
"miniprogram-api-typings": "^3.10.0"
|
|
25
25
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import transferOptions from '../core/transferOptions'
|
|
2
2
|
import builtInKeysMap from './patch/builtInKeysMap'
|
|
3
|
-
import { makeMap, spreadProp,
|
|
3
|
+
import { makeMap, spreadProp, getFocusedNavigation, hasOwn, extend } from '@mpxjs/utils'
|
|
4
4
|
import { mergeLifecycle } from '../convertor/mergeLifecycle'
|
|
5
5
|
import { LIFECYCLE } from '../platform/patch/lifecycle/index'
|
|
6
6
|
import Mpx from '../index'
|
|
@@ -96,14 +96,10 @@ export default function createApp (option, config = {}) {
|
|
|
96
96
|
})
|
|
97
97
|
|
|
98
98
|
if (!global.__mpxAppLaunched) {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
initialRouteName: path.startsWith('/') ? path.slice(1) : path,
|
|
104
|
-
initialParams: queryObj
|
|
105
|
-
})
|
|
106
|
-
}
|
|
99
|
+
const { initialRouteName, initialParams } = Mpx.config.rnConfig.parseAppProps?.(props) || {}
|
|
100
|
+
initialRouteRef.current.initialRouteName = initialRouteName || initialRouteRef.current.initialRouteName
|
|
101
|
+
initialRouteRef.current.initialParams = initialParams || initialRouteRef.current.initialParams
|
|
102
|
+
|
|
107
103
|
global.__mpxAppOnLaunch = (navigation) => {
|
|
108
104
|
global.__mpxAppLaunched = true
|
|
109
105
|
const state = navigation.getState()
|
|
@@ -151,7 +147,7 @@ export default function createApp (option, config = {}) {
|
|
|
151
147
|
}
|
|
152
148
|
}
|
|
153
149
|
global.__mpxAppCbs.show.forEach((cb) => {
|
|
154
|
-
cb(options)
|
|
150
|
+
cb(options || {})
|
|
155
151
|
})
|
|
156
152
|
if (navigation && hasOwn(global.__mpxPageStatusMap, navigation.pageId)) {
|
|
157
153
|
global.__mpxPageStatusMap[navigation.pageId] = 'show'
|
|
@@ -380,6 +380,7 @@ function usePageStatus (navigation, pageId) {
|
|
|
380
380
|
}, [navigation])
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
+
const pageConfigStack = []
|
|
383
384
|
export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
384
385
|
rawOptions = mergeOptions(rawOptions, type, false)
|
|
385
386
|
const components = Object.assign({}, rawOptions.components, currentInject.getComponents())
|
|
@@ -490,7 +491,7 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
490
491
|
const { Provider, useSafeAreaInsets, GestureHandlerRootView } = global.__navigationHelper
|
|
491
492
|
const pageConfig = Object.assign({}, global.__mpxPageConfig, currentInject.pageConfig)
|
|
492
493
|
const Page = ({ navigation, route }) => {
|
|
493
|
-
const [enabled, setEnabled] = useState(
|
|
494
|
+
const [enabled, setEnabled] = useState(false)
|
|
494
495
|
const currentPageId = useMemo(() => ++pageId, [])
|
|
495
496
|
const intersectionObservers = useRef({})
|
|
496
497
|
usePageStatus(navigation, currentPageId)
|
|
@@ -505,20 +506,36 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
505
506
|
},
|
|
506
507
|
headerTintColor: pageConfig.navigationBarTextStyle || 'white'
|
|
507
508
|
})
|
|
508
|
-
|
|
509
|
-
|
|
509
|
+
|
|
510
|
+
const setStatusBar = (config) => {
|
|
511
|
+
ReactNative.StatusBar.setBarStyle(config.barStyle || 'dark-content')
|
|
510
512
|
ReactNative.StatusBar.setTranslucent(isCustom) // 控制statusbar是否占位
|
|
511
|
-
const color = isCustom ? 'transparent' :
|
|
513
|
+
const color = isCustom ? 'transparent' : config.statusBarColor
|
|
512
514
|
color && ReactNative.StatusBar.setBackgroundColor(color)
|
|
513
515
|
}
|
|
516
|
+
if (__mpx_mode__ === 'android') {
|
|
517
|
+
pageConfigStack.push(pageConfig)
|
|
518
|
+
setStatusBar(pageConfig)
|
|
519
|
+
}
|
|
520
|
+
return () => {
|
|
521
|
+
if (__mpx_mode__ === 'android') {
|
|
522
|
+
pageConfigStack.pop()
|
|
523
|
+
const config = pageConfigStack[pageConfigStack.length - 1] || {}
|
|
524
|
+
setStatusBar(config)
|
|
525
|
+
}
|
|
526
|
+
};
|
|
514
527
|
}, [])
|
|
515
528
|
|
|
516
529
|
const rootRef = useRef(null)
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
530
|
+
|
|
531
|
+
useEffect(() => {
|
|
532
|
+
const unsubscribe = navigation.addListener('transitionEnd', (e) => {
|
|
533
|
+
rootRef.current?.measureInWindow((x, y, width, height) => {
|
|
534
|
+
navigation.layout = { x, y, width, height }
|
|
535
|
+
})
|
|
536
|
+
});
|
|
537
|
+
return unsubscribe;
|
|
538
|
+
}, [navigation]);
|
|
522
539
|
|
|
523
540
|
const withKeyboardAvoidingView = (element) => {
|
|
524
541
|
if (__mpx_mode__ === 'ios') {
|
|
@@ -546,6 +563,14 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
546
563
|
|
|
547
564
|
navigation.insets = useSafeAreaInsets()
|
|
548
565
|
|
|
566
|
+
const [, setState] = useState(1)
|
|
567
|
+
|
|
568
|
+
const setStateRef = useRef(setState)
|
|
569
|
+
|
|
570
|
+
if (setStateRef.current !== setState) {
|
|
571
|
+
setStateRef.current = setState
|
|
572
|
+
}
|
|
573
|
+
|
|
549
574
|
return createElement(GestureHandlerRootView,
|
|
550
575
|
{
|
|
551
576
|
style: {
|
|
@@ -559,8 +584,7 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
|
|
|
559
584
|
flex: 1,
|
|
560
585
|
backgroundColor: pageConfig.backgroundColor || '#ffffff'
|
|
561
586
|
},
|
|
562
|
-
ref: rootRef
|
|
563
|
-
onLayout
|
|
587
|
+
ref: rootRef
|
|
564
588
|
},
|
|
565
589
|
createElement(RouteContext.Provider,
|
|
566
590
|
{
|
|
@@ -23,11 +23,13 @@ function transformProperties (properties) {
|
|
|
23
23
|
} else {
|
|
24
24
|
newFiled = Object.assign({}, rawFiled)
|
|
25
25
|
}
|
|
26
|
+
const rawObserver = rawFiled?.observer
|
|
26
27
|
newFiled.observer = function (value, oldValue) {
|
|
27
28
|
if (this.__mpxProxy) {
|
|
28
29
|
this[key] = value
|
|
29
30
|
this.__mpxProxy.propsUpdated()
|
|
30
31
|
}
|
|
32
|
+
rawObserver && rawObserver.call(this, value, oldValue)
|
|
31
33
|
}
|
|
32
34
|
newProps[key] = newFiled
|
|
33
35
|
})
|