@mpxjs/api-proxy 2.9.66 → 2.9.67

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.
Files changed (28) hide show
  1. package/package.json +3 -11
  2. package/src/platform/api/request/index.web.js +8 -5
  3. package/src/platform/api/route/index.ios.js +1 -16
  4. package/src/platform/api/system/rnSystem.js +4 -45
  5. package/src/platform/api/system/rnWindowInfo.js +42 -0
  6. package/src/platform/index.js +2 -2
  7. package/src/platform/api/action-sheet/index.android.js +0 -1
  8. package/src/platform/api/animation/index.android.js +0 -1
  9. package/src/platform/api/app/index.android.js +0 -1
  10. package/src/platform/api/base/index.android.js +0 -1
  11. package/src/platform/api/clipboard-data/index.android.js +0 -1
  12. package/src/platform/api/create-selector-query/index.android.js +0 -1
  13. package/src/platform/api/device/network/index.android.js +0 -1
  14. package/src/platform/api/keyboard/index.android.js +0 -1
  15. package/src/platform/api/location/index.android.js +0 -1
  16. package/src/platform/api/make-phone-call/index.android.js +0 -1
  17. package/src/platform/api/modal/index.android.js +0 -1
  18. package/src/platform/api/next-tick/index.android.js +0 -1
  19. package/src/platform/api/request/index.android.js +0 -1
  20. package/src/platform/api/route/index.android.js +0 -1
  21. package/src/platform/api/screen-brightness/index.android.js +0 -1
  22. package/src/platform/api/set-navigation-bar/index.android.js +0 -1
  23. package/src/platform/api/socket/index.android.js +0 -1
  24. package/src/platform/api/storage/index.android.js +0 -1
  25. package/src/platform/api/system/index.android.js +0 -1
  26. package/src/platform/api/toast/index.android.js +0 -1
  27. package/src/platform/api/vibrate/index.android.js +0 -1
  28. package/src/platform/api/window/index.android.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/api-proxy",
3
- "version": "2.9.66",
3
+ "version": "2.9.67",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -37,15 +37,13 @@
37
37
  },
38
38
  "homepage": "https://github.com/didi/mpx#readme",
39
39
  "dependencies": {
40
- "@mpxjs/utils": "^2.9.65",
40
+ "@mpxjs/utils": "^2.9.67",
41
41
  "axios": "^1.7.3"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@ant-design/react-native": "^5.1.3",
45
45
  "@react-native-async-storage/async-storage": "^1.23.1",
46
46
  "@react-native-community/netinfo": "^11.2.1",
47
- "expo-brightness": "~11.8.0",
48
- "expo-clipboard": "~6.0.3",
49
47
  "react-native-device-info": "^10.13.2",
50
48
  "react-native-get-location": "^4.0.1",
51
49
  "react-native-haptic-feedback": "^2.3.3",
@@ -55,9 +53,6 @@
55
53
  "@react-native-async-storage/async-storage": {
56
54
  "optional": true
57
55
  },
58
- "expo-clipboard": {
59
- "optional": true
60
- },
61
56
  "@react-native-community/netinfo": {
62
57
  "optional": true
63
58
  },
@@ -73,12 +68,9 @@
73
68
  "@ant-design/react-native": {
74
69
  "optional": true
75
70
  },
76
- "expo-brightness": {
77
- "optional": true
78
- },
79
71
  "react-native-haptic-feedback": {
80
72
  "optional": true
81
73
  }
82
74
  },
83
- "gitHead": "ff9eb06a3be28538870823cebf813ed56f39bbd7"
75
+ "gitHead": "b23d3850c16543c5998811b8d1d8e6ee7988c0f8"
84
76
  }
@@ -1,6 +1,7 @@
1
1
  import axios from 'axios'
2
2
  import { successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
3
3
  import RequestTask from './RequestTask'
4
+ import { serialize, buildUrl } from '@mpxjs/utils'
4
5
 
5
6
  function request (options = { url: '' }) {
6
7
  const CancelToken = axios.CancelToken
@@ -8,6 +9,7 @@ function request (options = { url: '' }) {
8
9
  const requestTask = new RequestTask(source.cancel)
9
10
 
10
11
  let {
12
+ url,
11
13
  data = {},
12
14
  method = 'GET',
13
15
  dataType = 'json',
@@ -18,8 +20,11 @@ function request (options = { url: '' }) {
18
20
  fail = null,
19
21
  complete = null
20
22
  } = options
21
-
22
23
  method = method.toUpperCase()
24
+ if (method === 'GET') {
25
+ url = buildUrl(url, data)
26
+ data = {}
27
+ }
23
28
 
24
29
  if (
25
30
  method === 'POST' &&
@@ -27,9 +32,7 @@ function request (options = { url: '' }) {
27
32
  (header['Content-Type'] === 'application/x-www-form-urlencoded' ||
28
33
  header['content-type'] === 'application/x-www-form-urlencoded')
29
34
  ) {
30
- data = Object.keys(data).reduce((pre, curKey) => {
31
- return `${pre}&${encodeURIComponent(curKey)}=${encodeURIComponent(data[curKey])}`
32
- }, '').slice(1)
35
+ data = serialize(data)
33
36
  }
34
37
 
35
38
  /**
@@ -58,7 +61,7 @@ function request (options = { url: '' }) {
58
61
  */
59
62
  const rOptions = Object.assign(options, {
60
63
  method,
61
- url: options.url,
64
+ url,
62
65
  data,
63
66
  headers: header,
64
67
  responseType,
@@ -1,20 +1,5 @@
1
1
  import { successHandle, failHandle } from '../../../common/js'
2
- import { parseQuery } from '@mpxjs/utils'
3
-
4
- function parseUrl (url) {
5
- let path = url
6
- let query = ''
7
- const queryIndex = url.indexOf('?')
8
- if (queryIndex >= 0) {
9
- path = url.slice(0, queryIndex)
10
- query = url.slice(queryIndex)
11
- }
12
- const queryObj = parseQuery(query || '?')
13
- return {
14
- path,
15
- queryObj
16
- }
17
- }
2
+ import { parseUrlQuery as parseUrl } from '@mpxjs/utils'
18
3
 
19
4
  function getBasePath (navigation) {
20
5
  if (navigation) {
@@ -1,48 +1,7 @@
1
1
  import DeviceInfo from 'react-native-device-info'
2
- import { Platform, PixelRatio, Dimensions, StatusBar } from 'react-native'
3
- import { initialWindowMetrics } from 'react-native-safe-area-context'
4
- import { successHandle, failHandle, defineUnsupportedProps, getFocusedNavigation } from '../../../common/js'
5
-
6
- const getWindowInfo = function () {
7
- const dimensionsScreen = Dimensions.get('screen')
8
- const navigation = getFocusedNavigation()
9
- const insets = {
10
- ...initialWindowMetrics?.insets,
11
- ...navigation?.insets
12
- }
13
- let safeArea = {}
14
- let { top = 0, bottom = 0, left = 0, right = 0 } = insets
15
- if (Platform.OS === 'android') {
16
- top = StatusBar.currentHeight || 0
17
- }
18
- const screenHeight = dimensionsScreen.height
19
- const screenWidth = dimensionsScreen.width
20
- const layout = navigation?.layout || {}
21
- const layoutHeight = layout.height || 0
22
- const layoutWidth = layout.width || 0
23
- const windowHeight = layoutHeight || screenHeight
24
- try {
25
- safeArea = {
26
- left,
27
- right: screenWidth - right,
28
- top,
29
- bottom: screenHeight - bottom,
30
- height: screenHeight - top - bottom,
31
- width: screenWidth - left - right
32
- }
33
- } catch (error) {
34
- }
35
- const result = {
36
- pixelRatio: PixelRatio.get(),
37
- windowWidth: layoutWidth || screenWidth,
38
- windowHeight, // 取不到layout的时候有个兜底
39
- screenWidth: screenWidth,
40
- screenHeight: screenHeight,
41
- screenTop: screenHeight - windowHeight,
42
- safeArea
43
- }
44
- return result
45
- }
2
+ import { PixelRatio } from 'react-native'
3
+ import { successHandle, failHandle, defineUnsupportedProps } from '../../../common/js'
4
+ import { getWindowInfo } from './rnWindowInfo'
46
5
 
47
6
  const getSystemInfoSync = function () {
48
7
  const windowInfo = getWindowInfo()
@@ -101,7 +60,7 @@ const getSystemInfo = function (options = {}) {
101
60
 
102
61
  const getDeviceInfo = function () {
103
62
  const deviceInfo = {}
104
- if (Platform.OS === 'android') {
63
+ if (__mpx_mode__ === 'android') {
105
64
  const deviceAbi = DeviceInfo.supported64BitAbisSync() || []
106
65
  deviceInfo.deviceAbi = deviceAbi[0] || null
107
66
  }
@@ -0,0 +1,42 @@
1
+ import { PixelRatio, Dimensions } from 'react-native'
2
+ import { initialWindowMetrics } from 'react-native-safe-area-context'
3
+ import { getFocusedNavigation } from '../../../common/js'
4
+
5
+ const getWindowInfo = function () {
6
+ const dimensionsScreen = Dimensions.get('screen')
7
+ const navigation = getFocusedNavigation()
8
+ const insets = Object.assign(initialWindowMetrics?.insets, navigation?.insets)
9
+ let safeArea = {}
10
+ const { top = 0, bottom = 0, left = 0, right = 0 } = insets
11
+ const screenHeight = dimensionsScreen.height
12
+ const screenWidth = dimensionsScreen.width
13
+ const layout = navigation?.layout || {}
14
+ const layoutHeight = layout.height || 0
15
+ const layoutWidth = layout.width || 0
16
+ const windowHeight = layoutHeight || screenHeight
17
+ try {
18
+ safeArea = {
19
+ left,
20
+ right: screenWidth - right,
21
+ top,
22
+ bottom: screenHeight - bottom,
23
+ height: screenHeight - top - bottom,
24
+ width: screenWidth - left - right
25
+ }
26
+ } catch (error) {
27
+ }
28
+ const result = {
29
+ pixelRatio: PixelRatio.get(),
30
+ windowWidth: layoutWidth || screenWidth,
31
+ windowHeight, // 取不到layout的时候有个兜底
32
+ screenWidth: screenWidth,
33
+ screenHeight: screenHeight,
34
+ screenTop: screenHeight - windowHeight,
35
+ safeArea
36
+ }
37
+ return result
38
+ }
39
+
40
+ export {
41
+ getWindowInfo
42
+ }
@@ -26,7 +26,7 @@ export * from './api/canvas'
26
26
  export * from './api/check-session'
27
27
 
28
28
  // setClipboardData, getClipboardData
29
- export * from './api/clipboard-data'
29
+ // export * from './api/clipboard-data'
30
30
 
31
31
  // createIntersectionObserver
32
32
  export * from './api/create-intersection-observer'
@@ -77,7 +77,7 @@ export * from './api/route'
77
77
  export * from './api/scan-code'
78
78
 
79
79
  // setScreenBrightness, getScreenBrightness
80
- export * from './api/screen-brightness'
80
+ // export * from './api/screen-brightness'
81
81
 
82
82
  // setNavigationBarTitle, setNavigationBarColor
83
83
  export * from './api/set-navigation-bar'
@@ -1 +0,0 @@
1
- export * from './rnActionSheet'
@@ -1 +0,0 @@
1
- export * from './index.ios'
@@ -1 +0,0 @@
1
- export * from './index.web'
@@ -1 +0,0 @@
1
- export * from './index.web'
@@ -1 +0,0 @@
1
- export * from './rnClipboard'
@@ -1 +0,0 @@
1
- export * from './index.ios'
@@ -1 +0,0 @@
1
- export * from './rnNetwork'
@@ -1 +0,0 @@
1
- export * from './index'
@@ -1 +0,0 @@
1
- export * from './index.ios'
@@ -1 +0,0 @@
1
- export * from './rnMakePhone'
@@ -1 +0,0 @@
1
- export * from './rnModal'
@@ -1 +0,0 @@
1
- export * from './index.ali'
@@ -1 +0,0 @@
1
- export * from './index.web'
@@ -1 +0,0 @@
1
- export * from './index.ios'
@@ -1 +0,0 @@
1
- export * from './rnScreenBrightness'
@@ -1 +0,0 @@
1
- export * from './index.ios'
@@ -1 +0,0 @@
1
- export * from './index.web'
@@ -1 +0,0 @@
1
- export * from './rnStorage'
@@ -1 +0,0 @@
1
- export * from './rnSystem'
@@ -1 +0,0 @@
1
- export * from './rnToast'
@@ -1 +0,0 @@
1
- export * from './index.ios'
@@ -1 +0,0 @@
1
- export * from './rnWindow'