@mpxjs/api-proxy 2.9.52 → 2.9.53
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 +3 -3
- package/src/common/js/promisify.js +3 -5
- package/src/common/js/utils.js +3 -51
- package/src/install.js +2 -3
- package/src/platform/api/action-sheet/index.ali.js +2 -1
- package/src/platform/api/create-selector-query/index.ali.js +2 -1
- package/src/platform/api/request-payment/index.ali.js +2 -1
- package/src/platform/api/socket/SocketTask.js +2 -1
- package/src/platform/api/storage/index.web.js +3 -1
- package/src/platform/api/storage/rnStorage.js +2 -1
- package/src/platform/api/system/index.ali.js +6 -2
- package/src/platform/api/tab-bar/index.web.js +2 -1
- package/src/platform/api/toast/Toast.js +0 -1
- /package/src/platform/api/make-phone-call/{index.andriod.js → index.android.js} +0 -0
- /package/src/platform/api/socket/{index.andriod.js → index.android.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/api-proxy",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.53",
|
|
4
4
|
"description": "convert miniprogram API at each end",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"types": "@types/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"homepage": "https://github.com/didi/mpx#readme",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@mpxjs/utils": "^2.9.50",
|
|
41
|
-
"axios": "^1.
|
|
41
|
+
"axios": "^1.7.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@react-native-async-storage/async-storage": "^1.23.1",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"optional": true
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "505776958d34f5fea4e0b6141a0dc83ef572eb08"
|
|
68
68
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const envObj = getEnvObj()
|
|
1
|
+
import { ENV_OBJ } from './utils'
|
|
4
2
|
|
|
5
3
|
// 特别指定的不进行Promise封装的方法
|
|
6
4
|
const blackList = [
|
|
@@ -71,14 +69,14 @@ function promisify (listObj, whiteList, customBlackList) {
|
|
|
71
69
|
const obj = args[0] || {}
|
|
72
70
|
// 不需要转换 or 用户已定义回调,则不处理
|
|
73
71
|
if (!promisifyFilter(key) || obj.success || obj.fail) {
|
|
74
|
-
return listObj[key].apply(
|
|
72
|
+
return listObj[key].apply(ENV_OBJ, args)
|
|
75
73
|
} else { // 其他情况进行转换
|
|
76
74
|
if (!args[0]) args.unshift(obj)
|
|
77
75
|
let returned
|
|
78
76
|
const promise = new Promise((resolve, reject) => {
|
|
79
77
|
obj.success = resolve
|
|
80
78
|
obj.fail = reject
|
|
81
|
-
returned = listObj[key].apply(
|
|
79
|
+
returned = listObj[key].apply(ENV_OBJ, args)
|
|
82
80
|
})
|
|
83
81
|
promise.__returned = returned
|
|
84
82
|
return promise
|
package/src/common/js/utils.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { hasOwn, noop, getEnvObj } from '@mpxjs/utils'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
*
|
|
3
5
|
* @param {Object} options 原参数
|
|
@@ -12,16 +14,6 @@
|
|
|
12
14
|
* d: 4 // 增加 d
|
|
13
15
|
* })
|
|
14
16
|
*/
|
|
15
|
-
const hasOwnProperty = Object.prototype.hasOwnProperty
|
|
16
|
-
|
|
17
|
-
function type (n) {
|
|
18
|
-
return Object.prototype.toString.call(n).slice(8, -1)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function hasOwn (obj, key) {
|
|
22
|
-
return hasOwnProperty.call(obj, key)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
17
|
function changeOpts (options, updateOrRemoveOpt = {}, extraOpt = {}) {
|
|
26
18
|
let opts = {}
|
|
27
19
|
|
|
@@ -53,31 +45,6 @@ const handleSuccess = (opts, getOptions = noop, thisObj) => {
|
|
|
53
45
|
}
|
|
54
46
|
}
|
|
55
47
|
|
|
56
|
-
function getEnvObj () {
|
|
57
|
-
switch (__mpx_mode__) {
|
|
58
|
-
case 'wx':
|
|
59
|
-
return wx
|
|
60
|
-
case 'ali':
|
|
61
|
-
return my
|
|
62
|
-
case 'swan':
|
|
63
|
-
return swan
|
|
64
|
-
case 'qq':
|
|
65
|
-
return qq
|
|
66
|
-
case 'tt':
|
|
67
|
-
return tt
|
|
68
|
-
case 'jd':
|
|
69
|
-
return jd
|
|
70
|
-
case 'qa':
|
|
71
|
-
return qa
|
|
72
|
-
case 'dd':
|
|
73
|
-
return dd
|
|
74
|
-
case 'web':
|
|
75
|
-
case 'ios':
|
|
76
|
-
case 'android':
|
|
77
|
-
return {}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
48
|
function warn (msg) {
|
|
82
49
|
console.warn && console.warn(`[@mpxjs/api-proxy warn]:\n ${msg}`)
|
|
83
50
|
}
|
|
@@ -87,20 +54,10 @@ function error (msg) {
|
|
|
87
54
|
}
|
|
88
55
|
function envError (method) {
|
|
89
56
|
return () => {
|
|
90
|
-
|
|
57
|
+
throw Error(`[@mpxjs/api-proxy error]:\n ${__mpx_mode__}环境不支持${method}方法`)
|
|
91
58
|
}
|
|
92
59
|
}
|
|
93
60
|
|
|
94
|
-
function noop () {
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function makeMap (arr) {
|
|
98
|
-
return arr.reduce((obj, item) => {
|
|
99
|
-
obj[item] = true
|
|
100
|
-
return obj
|
|
101
|
-
}, {})
|
|
102
|
-
}
|
|
103
|
-
|
|
104
61
|
function defineUnsupportedProps (resObj, props) {
|
|
105
62
|
const defineProps = {}
|
|
106
63
|
props.forEach((item) => {
|
|
@@ -125,16 +82,11 @@ const ENV_OBJ = getEnvObj()
|
|
|
125
82
|
export {
|
|
126
83
|
changeOpts,
|
|
127
84
|
handleSuccess,
|
|
128
|
-
getEnvObj,
|
|
129
85
|
error,
|
|
130
86
|
envError,
|
|
131
87
|
warn,
|
|
132
|
-
noop,
|
|
133
|
-
makeMap,
|
|
134
88
|
isBrowser,
|
|
135
|
-
hasOwn,
|
|
136
89
|
throwSSRWarning,
|
|
137
90
|
ENV_OBJ,
|
|
138
|
-
type,
|
|
139
91
|
defineUnsupportedProps
|
|
140
92
|
}
|
package/src/install.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as platformApi from './platform'
|
|
2
|
-
import {
|
|
2
|
+
import { ENV_OBJ } from './common/js'
|
|
3
3
|
import promisify from './common/js/promisify'
|
|
4
4
|
|
|
5
5
|
export default function install (target, options = {}) {
|
|
@@ -9,8 +9,7 @@ export default function install (target, options = {}) {
|
|
|
9
9
|
blackList = [], // 强制不变成 promise 格式的 api
|
|
10
10
|
custom = {} // 自定义转化规则
|
|
11
11
|
} = options
|
|
12
|
-
const
|
|
13
|
-
const transedApi = Object.assign({}, envObj, platformApi)
|
|
12
|
+
const transedApi = Object.assign({}, ENV_OBJ, platformApi)
|
|
14
13
|
const promisedApi = usePromise ? promisify(transedApi, whiteList, blackList) : {}
|
|
15
14
|
Object.assign(target, transedApi, promisedApi, custom[__mpx_mode__])
|
|
16
15
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { webHandleSuccess, webHandleFail, isBrowser, throwSSRWarning } from '../../../common/js'
|
|
3
|
+
import { hasOwn } from '@mpxjs/utils'
|
|
2
4
|
|
|
3
5
|
function setStorage (options = {}) {
|
|
4
6
|
if (!isBrowser) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import AsyncStorage from '@react-native-async-storage/async-storage'
|
|
2
|
-
import {
|
|
2
|
+
import { hasOwn } from '@mpxjs/utils'
|
|
3
|
+
import { envError, webHandleSuccess, webHandleFail, defineUnsupportedProps } from '../../../common/js'
|
|
3
4
|
function setStorage (options) {
|
|
4
5
|
const { key, data, success, fail, complete } = options
|
|
5
6
|
let obj = {}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ENV_OBJ, changeOpts, envError, handleSuccess } from '../../../common/js'
|
|
1
|
+
import { ENV_OBJ, changeOpts, envError, handleSuccess, defineUnsupportedProps } from '../../../common/js'
|
|
2
2
|
|
|
3
3
|
function getSystemInfo (options = {}) {
|
|
4
4
|
const opts = changeOpts(options)
|
|
@@ -32,7 +32,11 @@ function getSystemInfoSync () {
|
|
|
32
32
|
return res
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const getDeviceInfo =
|
|
35
|
+
const getDeviceInfo = function () {
|
|
36
|
+
const res = ENV_OBJ.getDeviceBaseInfo
|
|
37
|
+
defineUnsupportedProps(res, ['deviceAbi', 'benchmarkLevel', 'cpuType'])
|
|
38
|
+
return res
|
|
39
|
+
}
|
|
36
40
|
|
|
37
41
|
const getWindowInfo = ENV_OBJ.getWindowInfo || envError('getWindowInfo')
|
|
38
42
|
|
|
File without changes
|
|
File without changes
|