@mpxjs/api-proxy 2.10.4-beta.3 → 2.10.4-beta.4

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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/api-proxy",
3
- "version": "2.10.4-beta.3",
3
+ "version": "2.10.4-beta.4",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -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
  }
@@ -38,8 +38,11 @@ const getImageInfo = function (options = {}) {
38
38
  })
39
39
  }
40
40
 
41
+ const chooseMedia = envError('chooseMedia')
42
+
41
43
  export {
42
44
  previewImage,
43
45
  compressImage,
44
- getImageInfo
46
+ getImageInfo,
47
+ chooseMedia
45
48
  }
@@ -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
  }
@@ -60,8 +60,11 @@ const getImageInfo = function (options = {}) {
60
60
  }
61
61
  }
62
62
 
63
+ const chooseMedia = envError('chooseMedia')
64
+
63
65
  export {
64
66
  previewImage,
65
67
  compressImage,
66
- getImageInfo
68
+ getImageInfo,
69
+ chooseMedia
67
70
  }
@@ -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
  }
@@ -33,12 +33,46 @@ function getSystemInfoSync () {
33
33
  }
34
34
 
35
35
  const getDeviceInfo = function () {
36
- const res = ENV_OBJ.getDeviceBaseInfo
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 = ENV_OBJ.getWindowInfo || envError('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
 
@@ -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