@mpxjs/api-proxy 2.10.18 → 2.10.19
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 +2 -2
- package/src/platform/api/base/rnCanIUseConfig.js +15 -0
- package/src/platform/api/camera/index.ios.js +9 -0
- package/src/platform/api/camera/index.js +7 -0
- package/src/platform/api/camera/rnCamera.js +44 -0
- package/src/platform/api/image/index.ios.js +4 -2
- package/src/platform/api/page-scroll-to/index.ios.js +1 -0
- package/src/platform/api/page-scroll-to/rnPageScrollTo.js +55 -0
- package/src/platform/api/socket/SocketTask.js +1 -1
- package/src/platform/index.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/api-proxy",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.19",
|
|
4
4
|
"description": "convert miniprogram API at each end",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"types": "@types/index.d.ts",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"optional": true
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "ca50ba6b1361f3c7790746476dd8b8e6be802ea3"
|
|
80
80
|
}
|
|
@@ -93,9 +93,16 @@ export const SUPPORTED_APIS = [
|
|
|
93
93
|
'clearStorage',
|
|
94
94
|
'clearStorageSync',
|
|
95
95
|
|
|
96
|
+
// page-scroll-to
|
|
97
|
+
'pageScrollTo',
|
|
98
|
+
|
|
96
99
|
// system
|
|
97
100
|
'getSystemInfo',
|
|
98
101
|
'getSystemInfoSync',
|
|
102
|
+
'getDeviceInfo',
|
|
103
|
+
'getWindowInfo',
|
|
104
|
+
'getLaunchOptionsSync',
|
|
105
|
+
'getEnterOptionsSync',
|
|
99
106
|
|
|
100
107
|
// setting
|
|
101
108
|
'getMenuButtonBoundingClientRect',
|
|
@@ -227,5 +234,13 @@ export const SUPPORTED_OBJECTS = {
|
|
|
227
234
|
'abort',
|
|
228
235
|
'onHeadersReceived',
|
|
229
236
|
'offHeadersReceived'
|
|
237
|
+
],
|
|
238
|
+
|
|
239
|
+
// camera
|
|
240
|
+
CameraContext: [
|
|
241
|
+
'setZoom',
|
|
242
|
+
'takePhoto',
|
|
243
|
+
'startRecord',
|
|
244
|
+
'stopRecord'
|
|
230
245
|
]
|
|
231
246
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { noop, getFocusedNavigation } from '@mpxjs/utils'
|
|
2
|
+
|
|
3
|
+
export default class CameraContext {
|
|
4
|
+
constructor () {
|
|
5
|
+
const navigation = getFocusedNavigation() || {}
|
|
6
|
+
this.camera = navigation.camera || {}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
setZoom (options = {}) {
|
|
10
|
+
const { zoom, success = noop, fail = noop, complete = noop } = options
|
|
11
|
+
try {
|
|
12
|
+
if (this.camera.setZoom) {
|
|
13
|
+
const result = { errMsg: 'setZoom:ok' }
|
|
14
|
+
success(result)
|
|
15
|
+
complete(result)
|
|
16
|
+
this.camera.setZoom(zoom)
|
|
17
|
+
} else {
|
|
18
|
+
const result = {
|
|
19
|
+
errMsg: 'setZoom:fail camera instance not found'
|
|
20
|
+
}
|
|
21
|
+
fail(result)
|
|
22
|
+
complete(result)
|
|
23
|
+
}
|
|
24
|
+
} catch (error) {
|
|
25
|
+
const result = {
|
|
26
|
+
errMsg: 'setZoom:fail ' + (error?.message || '')
|
|
27
|
+
}
|
|
28
|
+
fail(result)
|
|
29
|
+
complete(result)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
takePhoto (options) {
|
|
34
|
+
this.camera?.takePhoto(options)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
startRecord (options) {
|
|
38
|
+
this.camera?.startRecord(options)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
stopRecord (options) {
|
|
42
|
+
this.camera?.stopRecord(options)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -22,13 +22,15 @@ const getImageInfo = function (options = {}) {
|
|
|
22
22
|
failHandle(result, fail, complete)
|
|
23
23
|
return
|
|
24
24
|
}
|
|
25
|
+
|
|
25
26
|
Image.getSize(src, (width, height) => {
|
|
26
27
|
const result = {
|
|
27
28
|
errMsg: 'getImageInfo:ok',
|
|
28
29
|
width,
|
|
29
|
-
height
|
|
30
|
+
height,
|
|
31
|
+
path: src
|
|
30
32
|
}
|
|
31
|
-
defineUnsupportedProps(result, ['
|
|
33
|
+
defineUnsupportedProps(result, ['orientation', 'type'])
|
|
32
34
|
successHandle(result, success, complete)
|
|
33
35
|
}, (err) => {
|
|
34
36
|
const result = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rnPageScrollTo'
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { successHandle, failHandle, getFocusedNavigation } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 实现 React Native 下的 pageScrollTo
|
|
5
|
+
* 支持 scrollTop 和 selector 两种定位方式
|
|
6
|
+
*/
|
|
7
|
+
export function pageScrollTo (options = {}) {
|
|
8
|
+
const {
|
|
9
|
+
scrollTop,
|
|
10
|
+
duration = 300,
|
|
11
|
+
selector,
|
|
12
|
+
offsetTop = 0,
|
|
13
|
+
success,
|
|
14
|
+
fail,
|
|
15
|
+
complete
|
|
16
|
+
} = options
|
|
17
|
+
|
|
18
|
+
const navigation = getFocusedNavigation()
|
|
19
|
+
|
|
20
|
+
if (!navigation?.pageScrollTo) {
|
|
21
|
+
return failHandle({
|
|
22
|
+
errMsg: 'pageScrollTo:fail page instance not found'
|
|
23
|
+
}, fail, complete)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 验证参数
|
|
27
|
+
if (scrollTop === undefined && !selector) {
|
|
28
|
+
return failHandle({
|
|
29
|
+
errMsg: 'pageScrollTo:fail scrollTop or selector is required'
|
|
30
|
+
}, fail, complete)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
navigation.pageScrollTo({
|
|
35
|
+
scrollTop,
|
|
36
|
+
duration,
|
|
37
|
+
selector,
|
|
38
|
+
offsetTop,
|
|
39
|
+
onSuccess: () => {
|
|
40
|
+
successHandle({
|
|
41
|
+
errMsg: 'pageScrollTo:ok'
|
|
42
|
+
}, success, complete)
|
|
43
|
+
},
|
|
44
|
+
onFail: (errMsg) => {
|
|
45
|
+
failHandle({
|
|
46
|
+
errMsg: errMsg || 'pageScrollTo:fail'
|
|
47
|
+
}, fail, complete)
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
} catch (e) {
|
|
51
|
+
failHandle({
|
|
52
|
+
errMsg: `pageScrollTo:fail ${e.message}`
|
|
53
|
+
}, fail, complete)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -42,7 +42,7 @@ class SocketTask {
|
|
|
42
42
|
|
|
43
43
|
send (options = {}) {
|
|
44
44
|
const { data = '', success, fail, complete } = options
|
|
45
|
-
if (typeof data !== 'string'
|
|
45
|
+
if (typeof data !== 'string' && type(data) !== 'ArrayBuffer') {
|
|
46
46
|
const res = { errMsg: 'sendSocketMessage:fail Unsupported data type' }
|
|
47
47
|
failHandle(res, fail, complete)
|
|
48
48
|
} else if (this._socket.readyState === 1) {
|
package/src/platform/index.js
CHANGED