@mpxjs/api-proxy 2.10.15-1 → 2.10.15-prelease.1
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 +1 -1
- package/src/common/js/promisify.js +12 -26
- package/src/common/js/utils.js +1 -3
- package/src/platform/api/action-sheet/rnActionSheet.jsx +5 -5
- package/src/platform/api/image/Preview.js +4 -3
- package/src/platform/api/modal/rnModal.jsx +2 -1
- package/src/platform/api/route/index.ios.js +1 -1
- package/src/platform/api/system/rnSystem.js +4 -9
package/package.json
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
import { ENV_OBJ } from './utils'
|
|
1
|
+
import { ENV_OBJ, warn } from './utils'
|
|
2
2
|
|
|
3
3
|
// 特别指定的不进行Promise封装的方法
|
|
4
4
|
const blackList = [
|
|
5
|
-
'clearStorage',
|
|
6
|
-
'hideToast',
|
|
7
|
-
'hideLoading',
|
|
8
5
|
'drawCanvas',
|
|
9
6
|
'canIUse',
|
|
10
|
-
'stopRecord',
|
|
11
|
-
'pauseVoice',
|
|
12
|
-
'stopVoice',
|
|
13
|
-
'pauseBackgroundAudio',
|
|
14
|
-
'stopBackgroundAudio',
|
|
15
|
-
'showNavigationBarLoading',
|
|
16
|
-
'hideNavigationBarLoading',
|
|
17
7
|
'getPerformance',
|
|
18
|
-
'hideKeyboard',
|
|
19
|
-
'stopPullDownRefresh',
|
|
20
|
-
'pageScrollTo',
|
|
21
8
|
'reportAnalytics',
|
|
22
9
|
'getMenuButtonBoundingClientRect',
|
|
23
10
|
'reportMonitor',
|
|
24
11
|
'reportEvent',
|
|
25
|
-
'connectSocket',
|
|
26
12
|
'base64ToArrayBuffer',
|
|
27
13
|
'arrayBufferToBase64',
|
|
28
14
|
'getDeviceInfo',
|
|
@@ -33,16 +19,12 @@ const blackList = [
|
|
|
33
19
|
'postMessageToReferrerPage',
|
|
34
20
|
'postMessageToReferrerMiniProgram',
|
|
35
21
|
'reportPerformance',
|
|
36
|
-
'getPerformance',
|
|
37
|
-
'preDownloadSubpackage',
|
|
38
22
|
'router',
|
|
39
23
|
'nextTick',
|
|
40
24
|
'checkIsPictureInPictureActive',
|
|
41
25
|
'worklet',
|
|
42
26
|
'revokeBufferURL',
|
|
43
|
-
'reportEvent',
|
|
44
27
|
'getExptInfoSync',
|
|
45
|
-
'reserveChannelsLive',
|
|
46
28
|
'getNFCAdapter',
|
|
47
29
|
'isVKSupport'
|
|
48
30
|
]
|
|
@@ -79,18 +61,22 @@ function promisify (listObj, whiteList, customBlackList) {
|
|
|
79
61
|
if (typeof listObj[key] !== 'function') {
|
|
80
62
|
return
|
|
81
63
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
64
|
+
if (!promisifyFilter(key)) {
|
|
65
|
+
result[key] = listObj[key].bind(ENV_OBJ)
|
|
66
|
+
} else {
|
|
67
|
+
result[key] = function (...args) {
|
|
68
|
+
const obj = args[0] || {}
|
|
69
|
+
if (obj.usePromise === false) {
|
|
70
|
+
return listObj[key].apply(ENV_OBJ, args)
|
|
71
|
+
}
|
|
89
72
|
if (!args[0]) args.unshift(obj)
|
|
90
73
|
let returned
|
|
91
74
|
const promise = new Promise((resolve, reject) => {
|
|
92
75
|
const originSuccess = obj.success
|
|
93
76
|
const originFail = obj.fail
|
|
77
|
+
if (originSuccess || originFail) {
|
|
78
|
+
warn(`The [${key}] method has been promisified, please use .then or .catch to handle the result, if you need to handle the result with options.success/fail, please set options.usePromise to false to close the promisify in this call temporarily. `)
|
|
79
|
+
}
|
|
94
80
|
obj.success = function (res) {
|
|
95
81
|
originSuccess && originSuccess.call(this, res)
|
|
96
82
|
resolve(res)
|
package/src/common/js/utils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { hasOwn, noop, getEnvObj, getFocusedNavigation, error as errorHandler, warn as warnHandler } from '@mpxjs/utils'
|
|
2
|
-
import { getCurrentInstance } from '@mpxjs/core'
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
*
|
|
@@ -90,8 +89,7 @@ function failHandle (result, fail, complete) {
|
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
function getCurrentPageId () {
|
|
93
|
-
const
|
|
94
|
-
const id = currentInstance?.proxy?.getPageId() || getFocusedNavigation()?.pageId || null
|
|
92
|
+
const id = getFocusedNavigation()?.pageId || null
|
|
95
93
|
return id
|
|
96
94
|
}
|
|
97
95
|
|
|
@@ -28,7 +28,7 @@ const styles = StyleSheet.create({
|
|
|
28
28
|
bottom: 0,
|
|
29
29
|
right: 0,
|
|
30
30
|
position: 'absolute',
|
|
31
|
-
zIndex:
|
|
31
|
+
zIndex: 10000
|
|
32
32
|
},
|
|
33
33
|
maskWrap: {
|
|
34
34
|
left: 0,
|
|
@@ -65,8 +65,8 @@ const styles = StyleSheet.create({
|
|
|
65
65
|
},
|
|
66
66
|
itemTextStyle: {
|
|
67
67
|
fontSize: 18,
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
paddingTop: 2,
|
|
69
|
+
paddingBottom: 2
|
|
70
70
|
},
|
|
71
71
|
buttonStyle: {
|
|
72
72
|
paddingTop: 10,
|
|
@@ -195,8 +195,8 @@ function ActionSheet ({ itemColor, height, success, fail, complete, alertText, i
|
|
|
195
195
|
style={{
|
|
196
196
|
color: '#000000',
|
|
197
197
|
fontSize: 18,
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
paddingTop: 2,
|
|
199
|
+
paddingBottom: 2,
|
|
200
200
|
width: '100%',
|
|
201
201
|
textAlign: 'center'
|
|
202
202
|
}}
|
|
@@ -41,7 +41,6 @@ export default class Preview {
|
|
|
41
41
|
})
|
|
42
42
|
// click to close
|
|
43
43
|
bindTap(this.preview, () => {
|
|
44
|
-
this.currentIndex = 0
|
|
45
44
|
this.preview.style.display = 'none'
|
|
46
45
|
this.preview.querySelector('.__mpx_preview_images__').remove()
|
|
47
46
|
this.preview.remove()
|
|
@@ -54,10 +53,11 @@ export default class Preview {
|
|
|
54
53
|
* @param {string[]} options.urls - 图片地址数组
|
|
55
54
|
*/
|
|
56
55
|
show (options) {
|
|
57
|
-
const supported = ['urls', 'success', 'fail', 'complete']
|
|
56
|
+
const supported = ['urls', 'success', 'fail', 'complete', 'current']
|
|
58
57
|
Object.keys(options).forEach(key => !supported.includes(key) && warn(`previewImage: 暂不支持选项 ${key} !`))
|
|
59
|
-
const { urls, success, fail, complete } = options
|
|
58
|
+
const { urls, current, success, fail, complete } = options
|
|
60
59
|
try {
|
|
60
|
+
this.currentIndex = urls.indexOf(current) > -1 ? urls.indexOf(current) : 0
|
|
61
61
|
getRootElement().appendChild(this.preview)
|
|
62
62
|
this.preview.style.display = 'block'
|
|
63
63
|
// create images with urls
|
|
@@ -65,6 +65,7 @@ export default class Preview {
|
|
|
65
65
|
this.preview.appendChild(createDom('div', { class: '__mpx_preview_images__' }, urls.map(url => createDom('div', {
|
|
66
66
|
style: `background-image: url(${url})`
|
|
67
67
|
}))))
|
|
68
|
+
this.preview.querySelector('.__mpx_preview_images__').style.transform = `translateX(-${this.currentIndex * 100}%)`
|
|
68
69
|
this.maxIndex = urls.length
|
|
69
70
|
this.updateTextTip()
|
|
70
71
|
successHandle({ errMsg: 'previewImage:ok' }, success, complete)
|
|
@@ -9,23 +9,18 @@ const getWindowInfo = function () {
|
|
|
9
9
|
const navigationInsets = navigation.insets || {}
|
|
10
10
|
const insets = Object.assign({}, initialWindowMetricsInset, navigationInsets)
|
|
11
11
|
let safeArea = {}
|
|
12
|
-
const { top = 0, left = 0 } = insets
|
|
13
|
-
let { bottom = 0, right = 0 } = initialWindowMetricsInset
|
|
14
|
-
const screenHeight = __mpx_mode__ === 'ios' ? dimensionsScreen.height : dimensionsScreen.height - bottom // 解决安卓开启屏幕内三建导航安卓把安全区计算进去后产生的影响
|
|
15
|
-
const screenWidth = __mpx_mode__ === 'ios' ? dimensionsScreen.width : dimensionsScreen.width - right
|
|
12
|
+
const { top = 0, left = 0, bottom = 0, right = 0 } = insets
|
|
16
13
|
const layout = navigation.layout || {}
|
|
14
|
+
const screenHeight = __mpx_mode__ === 'ios' ? dimensionsScreen.height : dimensionsScreen.height - layout.bottomVirtualHeight // 解决安卓开启屏幕内三建导航安卓把安全区计算进去后产生的影响
|
|
15
|
+
const screenWidth = __mpx_mode__ === 'ios' ? dimensionsScreen.width : dimensionsScreen.width - right
|
|
17
16
|
const layoutHeight = layout.height || 0
|
|
18
17
|
const layoutWidth = layout.width || 0
|
|
19
18
|
const windowHeight = layoutHeight || screenHeight
|
|
20
|
-
if (__mpx_mode__ !== 'ios') {
|
|
21
|
-
bottom = 0
|
|
22
|
-
right = 0
|
|
23
|
-
}
|
|
24
19
|
try {
|
|
25
20
|
safeArea = {
|
|
26
21
|
left,
|
|
27
22
|
right: screenWidth - right,
|
|
28
|
-
top
|
|
23
|
+
top,
|
|
29
24
|
bottom: screenHeight - bottom,
|
|
30
25
|
height: screenHeight - top - bottom,
|
|
31
26
|
width: screenWidth - left - right
|