@mpxjs/core 2.10.14-beta.1 → 2.10.14-beta.14

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/@types/index.d.ts CHANGED
@@ -381,6 +381,13 @@ export interface RnConfig {
381
381
  * @param packages 分包名数组
382
382
  */
383
383
  downloadChunkAsync?: (packages: Array<string>) => void;
384
+
385
+ /**
386
+ * bundle 中是否关闭 android 键盘避让功能,如果关闭需要将该配置设置为 false,使用 mpx 内置的键盘避让逻辑
387
+ * @platform android
388
+ * @default true
389
+ */
390
+ enableNativeKeyboardAvoiding?: boolean
384
391
  }
385
392
 
386
393
  interface MpxConfig {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/core",
3
- "version": "2.10.14-beta.1",
3
+ "version": "2.10.14-beta.14",
4
4
  "description": "mpx runtime core",
5
5
  "keywords": [
6
6
  "miniprogram",
@@ -10,7 +10,7 @@ import { createElement, memo, useRef, useEffect } from 'react'
10
10
  import * as ReactNative from 'react-native'
11
11
  import { initAppProvides } from './export/inject'
12
12
  import { NavigationContainer, createNativeStackNavigator, SafeAreaProvider, GestureHandlerRootView } from './env/navigationHelper'
13
- import createMpxNav from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/nav'
13
+ import MpxNav from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/nav'
14
14
  import { NavSharedProvider } from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-nav-container'
15
15
 
16
16
  const appHooksMap = makeMap(mergeLifecycle(LIFECYCLE).app)
@@ -34,15 +34,6 @@ function filterOptions (options, appData) {
34
34
  return newOptions
35
35
  }
36
36
 
37
- let CachedMpxNav = null
38
-
39
- function getMpxNav() {
40
- // Mpx toplevel 执行时获取不到
41
- return (CachedMpxNav ??= createMpxNav({
42
- Mpx
43
- }))
44
- }
45
-
46
37
  export default function createApp (options) {
47
38
  const appData = {}
48
39
  // app选项目前不需要进行转换
@@ -76,7 +67,7 @@ export default function createApp (options) {
76
67
  flex: 1
77
68
  }
78
69
  },
79
- createElement(getMpxNav(), {
70
+ createElement(MpxNav, {
80
71
  pageConfig: pageConfig,
81
72
  navigation
82
73
  }),
@@ -118,7 +109,7 @@ export default function createApp (options) {
118
109
  }
119
110
  }
120
111
  const appState = reactive({ state: '' })
121
- // TODO hideReason 暂未完全模拟
112
+ // TODO reason 目前支持模拟 0/3
122
113
  // 0用户退出小程序
123
114
  // 1进入其他小程序
124
115
  // 2打开原生功能页
@@ -146,12 +137,10 @@ export default function createApp (options) {
146
137
  global.__mpxAppCbs.show.forEach((cb) => {
147
138
  cb(options)
148
139
  })
149
- } else if (value === 'hide') {
150
- const reason = appState.hideReason ?? 3
151
- delete appState.hideReason
152
- global.__mpxAppCbs.hide.forEach((cb) => {
140
+ } else if (value === 'hide' || value === 'exit') {
141
+ global.__mpxAppCbs.hide.forEach((cb) => {
153
142
  cb({
154
- reason
143
+ reason: value === 'exit' ? 0 : 3
155
144
  })
156
145
  })
157
146
  }
@@ -164,7 +153,6 @@ export default function createApp (options) {
164
153
  global.__mpxPageStatusMap[navigation.pageId] = 'show'
165
154
  }
166
155
  } else if (currentState === 'inactive' || currentState === 'background') {
167
- appState.hideReason = 3
168
156
  appState.state = 'hide'
169
157
  if (navigation && hasOwn(global.__mpxPageStatusMap, navigation.pageId)) {
170
158
  global.__mpxPageStatusMap[navigation.pageId] = 'hide'
@@ -234,8 +222,7 @@ export default function createApp (options) {
234
222
  }
235
223
  })
236
224
  return () => {
237
- appState.hideReason = 0
238
- appState.state = 'hide'
225
+ appState.state = 'exit'
239
226
  changeSubscription && changeSubscription.remove()
240
227
  resizeSubScription && resizeSubScription.remove()
241
228
  }
@@ -1,7 +1,7 @@
1
1
  import { createNativeStackNavigator } from '@react-navigation/native-stack'
2
2
  import { NavigationContainer, StackActions } from '@react-navigation/native'
3
3
  import PortalHost from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-portal/portal-host'
4
- import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context'
4
+ import { SafeAreaProvider, useSafeAreaInsets, initialWindowMetrics } from 'react-native-safe-area-context'
5
5
  import { GestureHandlerRootView } from 'react-native-gesture-handler'
6
6
 
7
7
  export {
@@ -11,5 +11,6 @@ export {
11
11
  GestureHandlerRootView,
12
12
  PortalHost,
13
13
  SafeAreaProvider,
14
- useSafeAreaInsets
14
+ useSafeAreaInsets,
15
+ initialWindowMetrics
15
16
  }
@@ -15,7 +15,7 @@ import {
15
15
  KeyboardAvoidContext,
16
16
  RouteContext
17
17
  } from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/context'
18
- import { PortalHost, useSafeAreaInsets } from '../env/navigationHelper'
18
+ import { PortalHost, useSafeAreaInsets, initialWindowMetrics } from '../env/navigationHelper'
19
19
  import { useInnerHeaderHeight } from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/nav'
20
20
 
21
21
  const ProviderContext = createContext(null)
@@ -481,7 +481,17 @@ function getLayoutData (headerHeight) {
481
481
  // 在横屏状态下 screen.height = window.height + bottomVirtualHeight
482
482
  // 在正常状态 screen.height = window.height + bottomVirtualHeight + statusBarHeight
483
483
  const isLandscape = screenDimensions.height < screenDimensions.width
484
- const bottomVirtualHeight = isLandscape ? screenDimensions.height - windowDimensions.height : ((screenDimensions.height - windowDimensions.height - ReactNative.StatusBar.currentHeight) || 0)
484
+ // const bottomVirtualHeight = isLandscape ? screenDimensions.height - windowDimensions.height : ((screenDimensions.height - windowDimensions.height - ReactNative.StatusBar.currentHeight) || 0)
485
+ let bottomVirtualHeight = 0
486
+ // 红米手机&魅族16T手机的screen.height = windowHeight + bottomVirtualHeight 导致计算出来的底部虚拟偏少。此部分端引擎同学进行修改中
487
+ // mpx临时兼容 bottomVirtualHeight取 initialWindowMetrics.inset.bottom 和 反算出来的bottomVirtualHeight的更大的值
488
+ if (ReactNative.Platform.OS === 'android') {
489
+ if (isLandscape) {
490
+ bottomVirtualHeight = screenDimensions.height - windowDimensions.height
491
+ } else {
492
+ bottomVirtualHeight = Math.max(screenDimensions.height - windowDimensions.height - ReactNative.StatusBar.currentHeight, initialWindowMetrics?.insets?.bottom || 0, 0)
493
+ }
494
+ }
485
495
  return {
486
496
  left: 0,
487
497
  top: headerHeight,