@mpxjs/api-proxy 2.9.69-beta.1 → 2.9.69-beta.5
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 +1 -0
- package/package.json +1 -1
- package/src/platform/api/action-sheet/rnActionSheet.jsx +11 -1
- package/src/platform/api/create-intersection-observer/rnIntersectionObserver.js +4 -5
- package/src/platform/api/modal/rnModal.jsx +1 -1
- package/src/platform/api/route/index.ios.js +36 -10
- package/src/platform/api/system/index.web.js +1 -1
- package/src/platform/api/system/rnSystem.js +3 -9
- package/src/platform/api/toast/rnToast.jsx +2 -2
package/@types/index.d.ts
CHANGED
|
@@ -98,6 +98,7 @@ export const clearStorage: WechatMiniprogram.Wx['clearStorage']
|
|
|
98
98
|
export const clearStorageSync: WechatMiniprogram.Wx['clearStorageSync']
|
|
99
99
|
export const getSystemInfo: WechatMiniprogram.Wx['getSystemInfo']
|
|
100
100
|
export const getSystemInfoSync: WechatMiniprogram.Wx['getSystemInfoSync']
|
|
101
|
+
export const getWindowInfo: WechatMiniprogram.Wx['getWindowInfo']
|
|
101
102
|
export const setTabBarItem: WechatMiniprogram.Wx['setTabBarItem']
|
|
102
103
|
export const setTabBarStyle: WechatMiniprogram.Wx['setTabBarStyle']
|
|
103
104
|
export const showTabBar: WechatMiniprogram.Wx['showTabBar']
|
package/package.json
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { View, Text, StyleSheet } from 'react-native'
|
|
2
2
|
import { successHandle, failHandle } from '../../../common/js'
|
|
3
|
-
import
|
|
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
|
|
13
|
+
if (itemList.length > 6) {
|
|
14
|
+
const result = {
|
|
15
|
+
errMsg: 'showActionSheet:fail parameter error: itemList should not be large than 6'
|
|
16
|
+
}
|
|
17
|
+
failHandle(result, fail, complete)
|
|
18
|
+
return
|
|
19
|
+
}
|
|
12
20
|
const windowInfo = getWindowInfo()
|
|
13
21
|
const bottom = windowInfo.screenHeight - windowInfo.safeArea.bottom
|
|
14
22
|
let actionSheetKey = null
|
|
@@ -77,6 +85,8 @@ function showActionSheet (options = {}) {
|
|
|
77
85
|
const remove = function () {
|
|
78
86
|
if (actionSheetKey) {
|
|
79
87
|
slideOut()
|
|
88
|
+
Portal.remove(actionSheetKey)
|
|
89
|
+
actionSheetKey = null
|
|
80
90
|
setTimeout(() => {
|
|
81
91
|
Portal.remove(actionSheetKey)
|
|
82
92
|
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
|
|
103
|
-
left: this.margins.left,
|
|
104
|
-
right: navigationLayout.width
|
|
105
|
-
bottom: navigationLayout.y + navigationLayout.height
|
|
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
|
|
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 {
|
|
@@ -33,10 +33,27 @@ function resolvePath (relative, base) {
|
|
|
33
33
|
}
|
|
34
34
|
return stack.join('/')
|
|
35
35
|
}
|
|
36
|
+
function isLock(navigationHelper, type, options) {
|
|
37
|
+
if (navigationHelper.lastSuccessCallback && navigationHelper.lastFailCallback) {
|
|
38
|
+
const res = { errMsg: `${type}:fail the previous routing event didn't complete` }
|
|
39
|
+
failHandle(res, options.fail, options.complete)
|
|
40
|
+
return true
|
|
41
|
+
}
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
if (navigationHelper.lastFailCallback) {
|
|
44
|
+
navigationHelper.lastFailCallback('timeout')
|
|
45
|
+
navigationHelper.lastFailCallback = null
|
|
46
|
+
}
|
|
47
|
+
}, 350)
|
|
48
|
+
return false
|
|
49
|
+
}
|
|
36
50
|
|
|
37
|
-
function navigateTo (options = {}) {
|
|
38
|
-
const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
|
|
51
|
+
function navigateTo (options = {}) {
|
|
39
52
|
const navigationHelper = global.__navigationHelper
|
|
53
|
+
if (isLock(navigationHelper, 'navigateTo', options)) {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
|
|
40
57
|
if (navigation && navigationHelper) {
|
|
41
58
|
const { path, queryObj } = parseUrl(options.url)
|
|
42
59
|
const basePath = getBasePath(navigation)
|
|
@@ -56,6 +73,9 @@ function navigateTo (options = {}) {
|
|
|
56
73
|
function redirectTo (options = {}) {
|
|
57
74
|
const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
|
|
58
75
|
const navigationHelper = global.__navigationHelper
|
|
76
|
+
if (isLock(navigationHelper, 'redirectTo', options)) {
|
|
77
|
+
return
|
|
78
|
+
}
|
|
59
79
|
if (navigation && navigationHelper) {
|
|
60
80
|
const { path, queryObj } = parseUrl(options.url)
|
|
61
81
|
const basePath = getBasePath(navigation)
|
|
@@ -75,9 +95,20 @@ function redirectTo (options = {}) {
|
|
|
75
95
|
function navigateBack (options = {}) {
|
|
76
96
|
const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
|
|
77
97
|
const navigationHelper = global.__navigationHelper
|
|
98
|
+
if (isLock(navigationHelper, 'navigateBack', options)) {
|
|
99
|
+
return
|
|
100
|
+
}
|
|
78
101
|
if (navigation && navigationHelper) {
|
|
79
102
|
const delta = options.delta || 1
|
|
80
103
|
const routeLength = navigation.getState().routes.length
|
|
104
|
+
navigationHelper.lastSuccessCallback = () => {
|
|
105
|
+
const res = { errMsg: 'navigateBack:ok' }
|
|
106
|
+
successHandle(res, options.success, options.complete)
|
|
107
|
+
}
|
|
108
|
+
navigationHelper.lastFailCallback = (msg) => {
|
|
109
|
+
const res = { errMsg: `navigateBack:fail ${msg}` }
|
|
110
|
+
failHandle(res, options.fail, options.complete)
|
|
111
|
+
}
|
|
81
112
|
if (delta >= routeLength && global.__mpx?.config.rnConfig.onAppBack?.(delta - routeLength + 1)) {
|
|
82
113
|
nextTick(() => {
|
|
83
114
|
const res = { errMsg: 'navigateBack:ok' }
|
|
@@ -85,14 +116,6 @@ function navigateBack (options = {}) {
|
|
|
85
116
|
})
|
|
86
117
|
} else {
|
|
87
118
|
navigation.pop(delta)
|
|
88
|
-
navigationHelper.lastSuccessCallback = () => {
|
|
89
|
-
const res = { errMsg: 'navigateBack:ok' }
|
|
90
|
-
successHandle(res, options.success, options.complete)
|
|
91
|
-
}
|
|
92
|
-
navigationHelper.lastFailCallback = (msg) => {
|
|
93
|
-
const res = { errMsg: `navigateBack:fail ${msg}` }
|
|
94
|
-
failHandle(res, options.fail, options.complete)
|
|
95
|
-
}
|
|
96
119
|
}
|
|
97
120
|
}
|
|
98
121
|
}
|
|
@@ -100,6 +123,9 @@ function navigateBack (options = {}) {
|
|
|
100
123
|
function reLaunch (options = {}) {
|
|
101
124
|
const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
|
|
102
125
|
const navigationHelper = global.__navigationHelper
|
|
126
|
+
if (isLock(navigationHelper, 'reLaunch', options)) {
|
|
127
|
+
return
|
|
128
|
+
}
|
|
103
129
|
if (navigation && navigationHelper) {
|
|
104
130
|
const { path, queryObj } = parseUrl(options.url)
|
|
105
131
|
const basePath = getBasePath(navigation)
|
|
@@ -139,7 +139,7 @@ const getLaunchOptionsSync = function () {
|
|
|
139
139
|
throwSSRWarning('getLaunchOptionsSync API is running in non browser environments')
|
|
140
140
|
return
|
|
141
141
|
}
|
|
142
|
-
return global.
|
|
142
|
+
return global.__mpxLaunchOptions || {}
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
export {
|
|
@@ -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 || {}
|
|
@@ -41,18 +42,11 @@ const getWindowInfo = function () {
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
const getLaunchOptionsSync = function () {
|
|
44
|
-
|
|
45
|
-
const { path, scene, query } = options
|
|
46
|
-
return {
|
|
47
|
-
path,
|
|
48
|
-
scene,
|
|
49
|
-
query
|
|
50
|
-
}
|
|
45
|
+
return global.__mpxLaunchOptions || {}
|
|
51
46
|
}
|
|
52
47
|
|
|
53
48
|
const getEnterOptionsSync = function () {
|
|
54
|
-
|
|
55
|
-
return result
|
|
49
|
+
return global.__mpxEnterOptions || {}
|
|
56
50
|
}
|
|
57
51
|
|
|
58
52
|
export {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { View, Text, Image, StyleSheet, ActivityIndicator, Dimensions } from 'react-native'
|
|
2
2
|
import { successHandle, failHandle } from '../../../common/js'
|
|
3
|
-
import
|
|
3
|
+
import Portal from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-portal'
|
|
4
4
|
|
|
5
5
|
let toastKey
|
|
6
6
|
let isLoadingShow
|
|
7
7
|
const dimensionsScreen = Dimensions.get('screen')
|
|
8
8
|
const screenHeight = dimensionsScreen.height
|
|
9
|
-
const contentTop = parseInt(screenHeight * 0.
|
|
9
|
+
const contentTop = parseInt(screenHeight * 0.4)
|
|
10
10
|
let tId // show duration 计时id
|
|
11
11
|
const styles = StyleSheet.create({
|
|
12
12
|
toastContent: {
|