@mpxjs/api-proxy 2.10.4-beta.1 → 2.10.4-beta.11
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 +5 -0
- package/package.json +1 -1
- package/src/platform/api/animation/index.ios.js +1 -1
- package/src/platform/api/create-intersection-observer/rnIntersectionObserver.js +9 -4
- package/src/platform/api/image/index.ali.js +6 -3
- package/src/platform/api/image/index.ios.js +4 -1
- package/src/platform/api/image/index.js +4 -1
- package/src/platform/api/image/index.web.js +4 -1
- package/src/platform/api/location/index.ali.js +15 -3
- package/src/platform/api/location/index.ios.js +13 -1
- package/src/platform/api/location/index.js +13 -1
- package/src/platform/api/location/index.web.js +13 -1
- package/src/platform/api/set-navigation-bar/index.ios.js +6 -6
- package/src/platform/api/system/index.ali.js +36 -2
- package/src/platform/api/system/rnSystem.js +1 -2
- package/src/platform/api/toast/rnToast.jsx +3 -7
- package/src/platform/index.js +2 -2
- /package/src/platform/api/animation/{animation.react.js → animation.ios.js} +0 -0
package/@types/index.d.ts
CHANGED
|
@@ -121,12 +121,17 @@ export const enableAlertBeforeUnload: WechatMiniprogram.Wx['enableAlertBeforeUnl
|
|
|
121
121
|
export const disableAlertBeforeUnload: WechatMiniprogram.Wx['disableAlertBeforeUnload']
|
|
122
122
|
export const getMenuButtonBoundingClientRect: WechatMiniprogram.Wx['getMenuButtonBoundingClientRect']
|
|
123
123
|
export const getImageInfo: WechatMiniprogram.Wx['getImageInfo']
|
|
124
|
+
export const chooseMedia: WechatMiniprogram.Wx['chooseMedia']
|
|
124
125
|
export const vibrateShort: WechatMiniprogram.Wx['vibrateShort']
|
|
125
126
|
export const vibrateLong: WechatMiniprogram.Wx['vibrateLong']
|
|
126
127
|
export const getExtConfig: WechatMiniprogram.Wx['getExtConfig']
|
|
127
128
|
export const getExtConfigSync: WechatMiniprogram.Wx['getExtConfigSync']
|
|
128
129
|
export const openLocation: WechatMiniprogram.Wx['openLocation']
|
|
129
130
|
export const chooseLocation: WechatMiniprogram.Wx['chooseLocation']
|
|
131
|
+
export const onLocationChange: WechatMiniprogram.Wx['onLocationChange']
|
|
132
|
+
export const offLocationChange: WechatMiniprogram.Wx['offLocationChange']
|
|
133
|
+
export const startLocationUpdate: WechatMiniprogram.Wx['startLocationUpdate']
|
|
134
|
+
export const stopLocationUpdate: WechatMiniprogram.Wx['stopLocationUpdate']
|
|
130
135
|
|
|
131
136
|
declare const install: (...args: any) => any
|
|
132
137
|
|
package/package.json
CHANGED
|
@@ -95,21 +95,25 @@ class RNIntersectionObserver {
|
|
|
95
95
|
const navigationLayout = navigation.layout || {
|
|
96
96
|
x: 0,
|
|
97
97
|
y: 0,
|
|
98
|
+
top: 0,
|
|
99
|
+
left: 0,
|
|
98
100
|
width: screen.width,
|
|
99
101
|
height: screen.height
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
const windowRect = {
|
|
103
|
-
top: navigationLayout.
|
|
105
|
+
top: navigationLayout.top - this.margins.top,
|
|
104
106
|
left: 0 - this.margins.left,
|
|
105
107
|
right: navigationLayout.width + this.margins.right,
|
|
106
|
-
bottom: navigationLayout.
|
|
108
|
+
bottom: navigationLayout.top + navigationLayout.height + this.margins.bottom
|
|
107
109
|
}
|
|
108
110
|
this.windowRect = windowRect
|
|
109
111
|
return this.windowRect
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
_getReferenceRect (targetRef) {
|
|
115
|
+
const navigation = getFocusedNavigation() || {}
|
|
116
|
+
const layout = navigation.layout || {}
|
|
113
117
|
const targetRefs = isArray(targetRef) ? targetRef : [targetRef]
|
|
114
118
|
const targetPromiseQueue = []
|
|
115
119
|
targetRefs.forEach((targetRefItem) => {
|
|
@@ -127,11 +131,12 @@ class RNIntersectionObserver {
|
|
|
127
131
|
targetPromiseQueue.push(new Promise((resolve) => {
|
|
128
132
|
target.measureInWindow(
|
|
129
133
|
(x, y, width, height) => {
|
|
134
|
+
// 安卓measureInWindow的参考值在android下为statubar的左下角,因此top需要调整一下
|
|
130
135
|
const boundingClientRect = {
|
|
131
136
|
left: x,
|
|
132
|
-
top: y,
|
|
137
|
+
top: y + layout.statusBarHeight || 0,
|
|
133
138
|
right: x + width,
|
|
134
|
-
bottom: y + height,
|
|
139
|
+
bottom: y + height + layout.statusBarHeight || 0,
|
|
135
140
|
width: width,
|
|
136
141
|
height: height
|
|
137
142
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
|
|
1
|
+
import { ENV_OBJ, changeOpts, handleSuccess, envError } from '../../../common/js'
|
|
2
2
|
|
|
3
3
|
function previewImage (options = {}) {
|
|
4
4
|
const opts = changeOpts(options)
|
|
@@ -30,10 +30,13 @@ function compressImage (options = {}) {
|
|
|
30
30
|
return ENV_OBJ.compressImage(opts)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const getImageInfo = ENV_OBJ.getImageInfo
|
|
33
|
+
const getImageInfo = ENV_OBJ.getImageInfo || envError('getImageInfo')
|
|
34
|
+
|
|
35
|
+
const chooseMedia = envError('chooseMedia')
|
|
34
36
|
|
|
35
37
|
export {
|
|
36
38
|
previewImage,
|
|
37
39
|
compressImage,
|
|
38
|
-
getImageInfo
|
|
40
|
+
getImageInfo,
|
|
41
|
+
chooseMedia
|
|
39
42
|
}
|
|
@@ -6,8 +6,11 @@ const compressImage = ENV_OBJ.compressImage || envError('compressImage')
|
|
|
6
6
|
|
|
7
7
|
const getImageInfo = ENV_OBJ.getImageInfo || envError('getImageInfo')
|
|
8
8
|
|
|
9
|
+
const chooseMedia = ENV_OBJ.chooseMedia || envError('chooseMedia')
|
|
10
|
+
|
|
9
11
|
export {
|
|
10
12
|
previewImage,
|
|
11
13
|
compressImage,
|
|
12
|
-
getImageInfo
|
|
14
|
+
getImageInfo,
|
|
15
|
+
chooseMedia
|
|
13
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ENV_OBJ, changeOpts, handleSuccess, defineUnsupportedProps } from '../../../common/js'
|
|
1
|
+
import { ENV_OBJ, changeOpts, handleSuccess, defineUnsupportedProps, envError } from '../../../common/js'
|
|
2
2
|
|
|
3
3
|
function getLocation (options = {}) {
|
|
4
4
|
const opts = Object.assign(options, {
|
|
@@ -22,10 +22,22 @@ function openLocation (options = {}) {
|
|
|
22
22
|
return ENV_OBJ.openLocation(opts)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const chooseLocation = ENV_OBJ.chooseLocation
|
|
25
|
+
const chooseLocation = ENV_OBJ.chooseLocation || envError('chooseLocation')
|
|
26
|
+
|
|
27
|
+
const onLocationChange = envError('onLocationChange')
|
|
28
|
+
|
|
29
|
+
const offLocationChange = envError('offLocationChange')
|
|
30
|
+
|
|
31
|
+
const startLocationUpdate = envError('startLocationUpdate')
|
|
32
|
+
|
|
33
|
+
const stopLocationUpdate = envError('stopLocationUpdate')
|
|
26
34
|
|
|
27
35
|
export {
|
|
28
36
|
getLocation,
|
|
29
37
|
openLocation,
|
|
30
|
-
chooseLocation
|
|
38
|
+
chooseLocation,
|
|
39
|
+
onLocationChange,
|
|
40
|
+
offLocationChange,
|
|
41
|
+
startLocationUpdate,
|
|
42
|
+
stopLocationUpdate
|
|
31
43
|
}
|
|
@@ -24,8 +24,20 @@ const openLocation = envError('openLocation')
|
|
|
24
24
|
|
|
25
25
|
const chooseLocation = envError('chooseLocation')
|
|
26
26
|
|
|
27
|
+
const onLocationChange = envError('onLocationChange')
|
|
28
|
+
|
|
29
|
+
const offLocationChange = envError('offLocationChange')
|
|
30
|
+
|
|
31
|
+
const startLocationUpdate = envError('startLocationUpdate')
|
|
32
|
+
|
|
33
|
+
const stopLocationUpdate = envError('stopLocationUpdate')
|
|
34
|
+
|
|
27
35
|
export {
|
|
28
36
|
getLocation,
|
|
29
37
|
openLocation,
|
|
30
|
-
chooseLocation
|
|
38
|
+
chooseLocation,
|
|
39
|
+
onLocationChange,
|
|
40
|
+
offLocationChange,
|
|
41
|
+
startLocationUpdate,
|
|
42
|
+
stopLocationUpdate
|
|
31
43
|
}
|
|
@@ -6,8 +6,20 @@ const openLocation = ENV_OBJ.openLocation || envError('openLocation')
|
|
|
6
6
|
|
|
7
7
|
const chooseLocation = ENV_OBJ.chooseLocation || envError('chooseLocation')
|
|
8
8
|
|
|
9
|
+
const onLocationChange = ENV_OBJ.onLocationChange || envError('onLocationChange')
|
|
10
|
+
|
|
11
|
+
const offLocationChange = ENV_OBJ.offLocationChange || envError('offLocationChange')
|
|
12
|
+
|
|
13
|
+
const startLocationUpdate = ENV_OBJ.startLocationUpdate || envError('startLocationUpdate')
|
|
14
|
+
|
|
15
|
+
const stopLocationUpdate = ENV_OBJ.stopLocationUpdate || envError('stopLocationUpdate')
|
|
16
|
+
|
|
9
17
|
export {
|
|
10
18
|
getLocation,
|
|
11
19
|
openLocation,
|
|
12
|
-
chooseLocation
|
|
20
|
+
chooseLocation,
|
|
21
|
+
onLocationChange,
|
|
22
|
+
offLocationChange,
|
|
23
|
+
startLocationUpdate,
|
|
24
|
+
stopLocationUpdate
|
|
13
25
|
}
|
|
@@ -29,8 +29,20 @@ const openLocation = envError('openLocation')
|
|
|
29
29
|
|
|
30
30
|
const chooseLocation = envError('chooseLocation')
|
|
31
31
|
|
|
32
|
+
const onLocationChange = envError('onLocationChange')
|
|
33
|
+
|
|
34
|
+
const offLocationChange = envError('offLocationChange')
|
|
35
|
+
|
|
36
|
+
const startLocationUpdate = envError('startLocationUpdate')
|
|
37
|
+
|
|
38
|
+
const stopLocationUpdate = envError('stopLocationUpdate')
|
|
39
|
+
|
|
32
40
|
export {
|
|
33
41
|
getLocation,
|
|
34
42
|
openLocation,
|
|
35
|
-
chooseLocation
|
|
43
|
+
chooseLocation,
|
|
44
|
+
onLocationChange,
|
|
45
|
+
offLocationChange,
|
|
46
|
+
startLocationUpdate,
|
|
47
|
+
stopLocationUpdate
|
|
36
48
|
}
|
|
@@ -7,7 +7,9 @@ function setNavigationBarTitle (options = {}) {
|
|
|
7
7
|
failHandle({ errMsg: 'setNavigationBarTitle:fail' }, fail, complete)
|
|
8
8
|
} else {
|
|
9
9
|
nextTick(() => {
|
|
10
|
-
navigation.
|
|
10
|
+
navigation.setPageConfig({
|
|
11
|
+
navigationBarTitleText: title.trim()
|
|
12
|
+
})
|
|
11
13
|
successHandle({ errMsg: 'setNavigationBarTitle:ok' }, success, complete)
|
|
12
14
|
})
|
|
13
15
|
}
|
|
@@ -20,11 +22,9 @@ function setNavigationBarColor (options = {}) {
|
|
|
20
22
|
failHandle({ errMsg: 'setNavigationBarColor:fail' }, fail, complete)
|
|
21
23
|
} else {
|
|
22
24
|
nextTick(() => {
|
|
23
|
-
navigation.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
headerTintColor: frontColor
|
|
25
|
+
navigation.setPageConfig({
|
|
26
|
+
navigationBarBackgroundColor: backgroundColor,
|
|
27
|
+
navigationBarTextStyle: frontColor
|
|
28
28
|
})
|
|
29
29
|
successHandle({ errMsg: 'setNavigationBarColor:ok' }, success, complete)
|
|
30
30
|
})
|
|
@@ -33,12 +33,46 @@ function getSystemInfoSync () {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const getDeviceInfo = function () {
|
|
36
|
-
|
|
36
|
+
let res
|
|
37
|
+
if (ENV_OBJ.canIUse('getDeviceBaseInfo')) {
|
|
38
|
+
res = ENV_OBJ.getDeviceBaseInfo()
|
|
39
|
+
} else {
|
|
40
|
+
const systemInfo = getSystemInfoSync()
|
|
41
|
+
res = {
|
|
42
|
+
abi: systemInfo.abi || null,
|
|
43
|
+
benchmarkLevel: systemInfo.benchmarkLevel || null,
|
|
44
|
+
brand: systemInfo.brand,
|
|
45
|
+
model: systemInfo.model,
|
|
46
|
+
system: systemInfo.system,
|
|
47
|
+
platform: systemInfo.platform,
|
|
48
|
+
memorySize: systemInfo.memorySize || null
|
|
49
|
+
}
|
|
50
|
+
}
|
|
37
51
|
defineUnsupportedProps(res, ['deviceAbi', 'benchmarkLevel', 'cpuType'])
|
|
38
52
|
return res
|
|
39
53
|
}
|
|
40
54
|
|
|
41
|
-
const getWindowInfo =
|
|
55
|
+
const getWindowInfo = function () {
|
|
56
|
+
let res
|
|
57
|
+
if (ENV_OBJ.canIUse('getWindowInfo')) {
|
|
58
|
+
res = ENV_OBJ.getWindowInfo()
|
|
59
|
+
} else {
|
|
60
|
+
const systemInfo = getSystemInfoSync()
|
|
61
|
+
res = {
|
|
62
|
+
pixelRatio: systemInfo.pixelRatio,
|
|
63
|
+
screenWidth: systemInfo.screenWidth,
|
|
64
|
+
screenHeight: systemInfo.screenHeight,
|
|
65
|
+
windowWidth: systemInfo.windowWidth,
|
|
66
|
+
windowHeight: systemInfo.windowHeight,
|
|
67
|
+
statusBarHeight: systemInfo.statusBarHeight,
|
|
68
|
+
safeArea: systemInfo.safeArea || null,
|
|
69
|
+
screenTop: systemInfo.screenTop || null
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return res
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// const getWindowInfo = ENV_OBJ.getWindowInfo || envError('getWindowInfo')
|
|
42
76
|
|
|
43
77
|
const getLaunchOptionsSync = ENV_OBJ.getLaunchOptionsSync || envError('getLaunchOptionsSync')
|
|
44
78
|
|
|
@@ -7,10 +7,9 @@ const getWindowInfo = function () {
|
|
|
7
7
|
const navigation = getFocusedNavigation() || {}
|
|
8
8
|
const initialWindowMetricsInset = initialWindowMetrics?.insets || {}
|
|
9
9
|
const navigationInsets = navigation.insets || {}
|
|
10
|
-
const insets = Object.assign(initialWindowMetricsInset, navigationInsets)
|
|
10
|
+
const insets = Object.assign({}, initialWindowMetricsInset, navigationInsets)
|
|
11
11
|
let safeArea = {}
|
|
12
12
|
const { top = 0, bottom = 0, left = 0, right = 0 } = insets
|
|
13
|
-
|
|
14
13
|
const screenHeight = __mpx_mode__ === 'ios' ? dimensionsScreen.height : dimensionsScreen.height - bottom // 解决安卓开启屏幕内三建导航安卓把安全区计算进去后产生的影响
|
|
15
14
|
const screenWidth = __mpx_mode__ === 'ios' ? dimensionsScreen.width : dimensionsScreen.width - right
|
|
16
15
|
const layout = navigation.layout || {}
|
|
@@ -32,8 +32,7 @@ const styles = StyleSheet.create({
|
|
|
32
32
|
alignItems: 'center'
|
|
33
33
|
},
|
|
34
34
|
toastHasIcon: {
|
|
35
|
-
|
|
36
|
-
width: 120
|
|
35
|
+
width: 140
|
|
37
36
|
},
|
|
38
37
|
toastImg: {
|
|
39
38
|
width: 40,
|
|
@@ -46,8 +45,6 @@ const styles = StyleSheet.create({
|
|
|
46
45
|
color: '#ffffff',
|
|
47
46
|
fontSize: 12,
|
|
48
47
|
lineHeight: 18,
|
|
49
|
-
height: 18,
|
|
50
|
-
overflow: 'hidden',
|
|
51
48
|
marginTop: 10
|
|
52
49
|
}
|
|
53
50
|
})
|
|
@@ -80,7 +77,7 @@ function showToast (options = {}) {
|
|
|
80
77
|
ToastView = <View style={[styles.toastWrap, { pointerEvents }]}>
|
|
81
78
|
<View style={[styles.toastContent, styles.toastHasIcon]}>
|
|
82
79
|
<Image style={ styles.toastImg } source={{ uri: image || iconImg[icon] }}></Image>
|
|
83
|
-
{ title ? <Text style={styles.toastText}>{title}</Text> : null }
|
|
80
|
+
{ title ? <Text numberOfLines={2} style={styles.toastText}>{title}</Text> : null }
|
|
84
81
|
</View>
|
|
85
82
|
</View>
|
|
86
83
|
} else if (icon === 'loading') {
|
|
@@ -91,7 +88,7 @@ function showToast (options = {}) {
|
|
|
91
88
|
size='small'
|
|
92
89
|
color='#eee'
|
|
93
90
|
/>
|
|
94
|
-
{ title ? <Text style={styles.toastText}>{title}</Text> : null }
|
|
91
|
+
{ title ? <Text numberOfLines={2} style={styles.toastText}>{title}</Text> : null }
|
|
95
92
|
</View>
|
|
96
93
|
</View>
|
|
97
94
|
} else {
|
|
@@ -102,7 +99,6 @@ function showToast (options = {}) {
|
|
|
102
99
|
...styles.toastText,
|
|
103
100
|
...(icon === 'none'
|
|
104
101
|
? {
|
|
105
|
-
height: 'auto',
|
|
106
102
|
marginTop: 0
|
|
107
103
|
}
|
|
108
104
|
: {})
|
package/src/platform/index.js
CHANGED
|
@@ -43,7 +43,7 @@ export * from './api/file'
|
|
|
43
43
|
// getUserInfo
|
|
44
44
|
export * from './api/get-user-info'
|
|
45
45
|
|
|
46
|
-
// previewImage, compressImage, getImageInfo
|
|
46
|
+
// previewImage, compressImage, getImageInfo, chooseMedia
|
|
47
47
|
export * from './api/image'
|
|
48
48
|
|
|
49
49
|
// login
|
|
@@ -105,7 +105,7 @@ export * from './api/video'
|
|
|
105
105
|
// onWindowResize, offWindowResize
|
|
106
106
|
export * from './api/window'
|
|
107
107
|
|
|
108
|
-
// getLocation, openLocation, chooseLocation
|
|
108
|
+
// getLocation, openLocation, chooseLocation, onLocationChange, offLocationChange, startLocationUpdate, stopLocationUpdate
|
|
109
109
|
export * from './api/location'
|
|
110
110
|
|
|
111
111
|
// getExtConfig, getExtConfigSync
|
|
File without changes
|