@mpxjs/api-proxy 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/api-proxy",
3
- "version": "2.9.69-beta.1",
3
+ "version": "2.9.69-beta.2",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -1,12 +1,13 @@
1
1
  import { View, Text, StyleSheet } from 'react-native'
2
2
  import { successHandle, failHandle } from '../../../common/js'
3
- import { Portal } from '@ant-design/react-native'
3
+ import Portal from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-portal'
4
4
  import { getWindowInfo } from '../system/rnSystem'
5
5
  import Animated, {
6
6
  useSharedValue,
7
7
  useAnimatedStyle,
8
8
  withTiming
9
9
  } from 'react-native-reanimated'
10
+
10
11
  function showActionSheet (options = {}) {
11
12
  const { alertText, itemList = [], itemColor = '#000000', success, fail, complete } = options
12
13
  const windowInfo = getWindowInfo()
@@ -77,6 +78,8 @@ function showActionSheet (options = {}) {
77
78
  const remove = function () {
78
79
  if (actionSheetKey) {
79
80
  slideOut()
81
+ Portal.remove(actionSheetKey)
82
+ actionSheetKey = null
80
83
  setTimeout(() => {
81
84
  Portal.remove(actionSheetKey)
82
85
  actionSheetKey = null
@@ -2,7 +2,6 @@ import { isArray, isObject, isString, noop } from '@mpxjs/utils'
2
2
  import throttle from 'lodash/throttle'
3
3
  import { Dimensions } from 'react-native'
4
4
  import { getFocusedNavigation } from '../../../common/js'
5
-
6
5
  const WindowRefStr = 'window'
7
6
  const IgnoreTarget = 'ignore'
8
7
  const DefaultMargin = { top: 0, bottom: 0, left: 0, right: 0 }
@@ -99,10 +98,10 @@ class RNIntersectionObserver {
99
98
  }
100
99
 
101
100
  const windowRect = {
102
- top: navigationLayout.y + this.margins.top,
103
- left: this.margins.left,
104
- right: navigationLayout.width - this.margins.right,
105
- bottom: navigationLayout.y + navigationLayout.height - this.margins.bottom
101
+ top: navigationLayout.y - this.margins.top,
102
+ left: 0 - this.margins.left,
103
+ right: navigationLayout.width + this.margins.right,
104
+ bottom: navigationLayout.y + navigationLayout.height + this.margins.bottom
106
105
  }
107
106
 
108
107
  this.windowRect = windowRect
@@ -1,6 +1,6 @@
1
1
  import { View, Dimensions, Text, StyleSheet, TouchableOpacity, ScrollView, TextInput } from 'react-native'
2
2
  import { successHandle, failHandle } from '../../../common/js'
3
- import { Portal } from '@ant-design/react-native'
3
+ import Portal from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-portal'
4
4
  const { width, height } = Dimensions.get('window')
5
5
  const showModal = function (options = {}) {
6
6
  const {
@@ -34,7 +34,12 @@ function resolvePath (relative, base) {
34
34
  return stack.join('/')
35
35
  }
36
36
 
37
+ let toPending = false
37
38
  function navigateTo (options = {}) {
39
+ if (toPending) {
40
+ return
41
+ }
42
+ toPending = true
38
43
  const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
39
44
  const navigationHelper = global.__navigationHelper
40
45
  if (navigation && navigationHelper) {
@@ -50,10 +55,17 @@ function navigateTo (options = {}) {
50
55
  const res = { errMsg: `navigateTo:fail ${msg}` }
51
56
  failHandle(res, options.fail, options.complete)
52
57
  }
58
+ navigationHelper.transitionEndCallback = () => {
59
+ toPending = false
60
+ }
53
61
  }
54
62
  }
55
-
63
+ let redirectPending = false
56
64
  function redirectTo (options = {}) {
65
+ if (redirectPending) {
66
+ return
67
+ }
68
+ redirectPending = true
57
69
  const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
58
70
  const navigationHelper = global.__navigationHelper
59
71
  if (navigation && navigationHelper) {
@@ -69,10 +81,17 @@ function redirectTo (options = {}) {
69
81
  const res = { errMsg: `redirectTo:fail ${msg}` }
70
82
  failHandle(res, options.fail, options.complete)
71
83
  }
84
+ navigationHelper.transitionEndCallback = () => {
85
+ redirectPending = false
86
+ }
72
87
  }
73
88
  }
74
-
89
+ let backPending = false
75
90
  function navigateBack (options = {}) {
91
+ if (backPending) {
92
+ return
93
+ }
94
+ backPending = true
76
95
  const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
77
96
  const navigationHelper = global.__navigationHelper
78
97
  if (navigation && navigationHelper) {
@@ -80,6 +99,7 @@ function navigateBack (options = {}) {
80
99
  const routeLength = navigation.getState().routes.length
81
100
  if (delta >= routeLength && global.__mpx?.config.rnConfig.onAppBack?.(delta - routeLength + 1)) {
82
101
  nextTick(() => {
102
+ backPending = false
83
103
  const res = { errMsg: 'navigateBack:ok' }
84
104
  successHandle(res, options.success, options.complete)
85
105
  })
@@ -94,10 +114,17 @@ function navigateBack (options = {}) {
94
114
  failHandle(res, options.fail, options.complete)
95
115
  }
96
116
  }
117
+ navigationHelper.transitionEndCallback = () => {
118
+ backPending = false
119
+ }
97
120
  }
98
121
  }
99
-
122
+ let reLaunchPending = false
100
123
  function reLaunch (options = {}) {
124
+ if (reLaunchPending) {
125
+ return
126
+ }
127
+ reLaunchPending = true
101
128
  const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
102
129
  const navigationHelper = global.__navigationHelper
103
130
  if (navigation && navigationHelper) {
@@ -121,6 +148,9 @@ function reLaunch (options = {}) {
121
148
  const res = { errMsg: `redirectTo:fail ${msg}` }
122
149
  failHandle(res, options.fail, options.complete)
123
150
  }
151
+ navigationHelper.transitionEndCallback = () => {
152
+ reLaunchPending = false
153
+ }
124
154
  }
125
155
  }
126
156
 
@@ -10,6 +10,7 @@ const getWindowInfo = function () {
10
10
  const insets = Object.assign(initialWindowMetricsInset, navigationInsets)
11
11
  let safeArea = {}
12
12
  const { top = 0, bottom = 0, left = 0, right = 0 } = insets
13
+
13
14
  const screenHeight = __mpx_mode__ === 'ios' ? dimensionsScreen.height : dimensionsScreen.height - bottom // 解决安卓开启屏幕内三建导航安卓把安全区计算进去后产生的影响
14
15
  const screenWidth = __mpx_mode__ === 'ios' ? dimensionsScreen.width : dimensionsScreen.width - right
15
16
  const layout = navigation.layout || {}
@@ -1,6 +1,6 @@
1
1
  import { View, Text, Image, StyleSheet, ActivityIndicator, Dimensions } from 'react-native'
2
2
  import { successHandle, failHandle } from '../../../common/js'
3
- import { Portal } from '@ant-design/react-native'
3
+ import Portal from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-portal'
4
4
 
5
5
  let toastKey
6
6
  let isLoadingShow