@mpxjs/api-proxy 2.9.27 → 2.9.38

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 (66) hide show
  1. package/package.json +2 -2
  2. package/src/common/js/utils.js +16 -1
  3. package/src/platform/api/action-sheet/index.ali.js +3 -2
  4. package/src/platform/api/action-sheet/index.js +1 -3
  5. package/src/platform/api/add-phone-contact/index.ali.js +2 -2
  6. package/src/platform/api/add-phone-contact/index.js +1 -3
  7. package/src/platform/api/animation/index.js +1 -3
  8. package/src/platform/api/app/index.js +1 -3
  9. package/src/platform/api/audio/index.js +1 -3
  10. package/src/platform/api/base/index.js +1 -3
  11. package/src/platform/api/base/index.web.js +1 -1
  12. package/src/platform/api/ble-connection/index.ali.js +5 -3
  13. package/src/platform/api/ble-connection/index.js +1 -3
  14. package/src/platform/api/canvas/index.ali.js +2 -4
  15. package/src/platform/api/canvas/index.js +1 -6
  16. package/src/platform/api/check-session/index.js +1 -3
  17. package/src/platform/api/clipboard-data/index.ali.js +3 -3
  18. package/src/platform/api/clipboard-data/index.js +1 -3
  19. package/src/platform/api/create-intersection-observer/IntersectionObserver.js +7 -4
  20. package/src/platform/api/create-intersection-observer/index.ali.js +3 -1
  21. package/src/platform/api/create-intersection-observer/index.js +1 -3
  22. package/src/platform/api/create-selector-query/SelectQuery.js +2 -1
  23. package/src/platform/api/create-selector-query/index.ali.js +2 -2
  24. package/src/platform/api/create-selector-query/index.js +1 -3
  25. package/src/platform/api/device/network/index.js +1 -3
  26. package/src/platform/api/device/network/onNetworkStatusChange.js +1 -1
  27. package/src/platform/api/file/index.ali.js +4 -4
  28. package/src/platform/api/file/index.js +1 -3
  29. package/src/platform/api/get-user-info/index.ali.js +2 -2
  30. package/src/platform/api/get-user-info/index.js +1 -3
  31. package/src/platform/api/image/index.ali.js +3 -3
  32. package/src/platform/api/image/index.js +1 -3
  33. package/src/platform/api/lifecycle/index.ali.js +3 -1
  34. package/src/platform/api/lifecycle/index.js +1 -3
  35. package/src/platform/api/login/index.ali.js +2 -2
  36. package/src/platform/api/login/index.js +1 -3
  37. package/src/platform/api/make-phone-call/index.ali.js +2 -2
  38. package/src/platform/api/make-phone-call/index.js +1 -3
  39. package/src/platform/api/modal/index.ali.js +3 -3
  40. package/src/platform/api/modal/index.js +1 -3
  41. package/src/platform/api/next-tick/index.js +1 -3
  42. package/src/platform/api/page-scroll-to/index.js +1 -3
  43. package/src/platform/api/pull-down/index.js +1 -3
  44. package/src/platform/api/request/index.ali.js +4 -4
  45. package/src/platform/api/request/index.js +1 -3
  46. package/src/platform/api/request-payment/index.ali.js +2 -2
  47. package/src/platform/api/request-payment/index.js +1 -3
  48. package/src/platform/api/route/index.js +1 -3
  49. package/src/platform/api/scan-code/index.ali.js +2 -2
  50. package/src/platform/api/scan-code/index.js +1 -3
  51. package/src/platform/api/screen-brightness/index.ali.js +3 -3
  52. package/src/platform/api/screen-brightness/index.js +1 -3
  53. package/src/platform/api/set-navigation-bar/index.ali.js +7 -9
  54. package/src/platform/api/set-navigation-bar/index.js +1 -3
  55. package/src/platform/api/socket/index.js +1 -3
  56. package/src/platform/api/storage/index.ali.js +12 -10
  57. package/src/platform/api/storage/index.js +1 -3
  58. package/src/platform/api/system/index.ali.js +5 -5
  59. package/src/platform/api/system/index.js +1 -3
  60. package/src/platform/api/tab-bar/index.js +1 -3
  61. package/src/platform/api/toast/index.ali.js +5 -5
  62. package/src/platform/api/toast/index.js +1 -3
  63. package/src/platform/api/video/index.js +1 -3
  64. package/src/platform/api/window/index.js +1 -3
  65. package/src/platform/api/window/index.web.js +1 -1
  66. package/src/platform/index.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/api-proxy",
3
- "version": "2.9.27",
3
+ "version": "2.9.38",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -39,5 +39,5 @@
39
39
  "dependencies": {
40
40
  "axios": "^1.6.7"
41
41
  },
42
- "gitHead": "3939aaaa7d9be0c86e51da16080a6cd8d7863a1a"
42
+ "gitHead": "5e2740e2091edda91eda9ffe775989c7fd9838df"
43
43
  }
@@ -95,11 +95,24 @@ function makeMap (arr) {
95
95
  }, {})
96
96
  }
97
97
 
98
+ function parseDataset (dataset) {
99
+ const parsed = {}
100
+ for (const key in dataset) {
101
+ if (hasOwn(dataset, key)) {
102
+ parsed[key] = JSON.parse(dataset[key])
103
+ }
104
+ }
105
+ return parsed
106
+ }
107
+
98
108
  const isBrowser = typeof window !== 'undefined'
99
109
 
100
110
  function throwSSRWarning (info) {
101
111
  console.error(`[Mpx runtime error]: Dangerous API! ${info}, It may cause some problems, please use this method with caution`)
102
112
  }
113
+
114
+ const ENV_OBJ = getEnvObj()
115
+
103
116
  export {
104
117
  changeOpts,
105
118
  handleSuccess,
@@ -111,5 +124,7 @@ export {
111
124
  makeMap,
112
125
  isBrowser,
113
126
  hasOwn,
114
- throwSSRWarning
127
+ throwSSRWarning,
128
+ ENV_OBJ,
129
+ parseDataset
115
130
  }
@@ -1,4 +1,5 @@
1
- import { changeOpts, noop } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, noop } from '../../../common/js'
2
+
2
3
  function showActionSheet (options = {}) {
3
4
  const opts = changeOpts(options, {
4
5
  itemList: 'items'
@@ -20,7 +21,7 @@ function showActionSheet (options = {}) {
20
21
  }
21
22
  }
22
23
 
23
- my.showActionSheet(opts)
24
+ return ENV_OBJ.showActionSheet(opts)
24
25
  }
25
26
 
26
27
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const showActionSheet = ENV_OBJ.showActionSheet || envError('showActionSheet')
6
4
 
@@ -1,11 +1,11 @@
1
- import { changeOpts } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts } from '../../../common/js'
2
2
 
3
3
  function addPhoneContact (options = {}) {
4
4
  const opts = changeOpts(options, {
5
5
  weChatNumber: 'alipayAccount'
6
6
  })
7
7
 
8
- my.addPhoneContact(opts)
8
+ return ENV_OBJ.addPhoneContact(opts)
9
9
  }
10
10
 
11
11
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const addPhoneContact = ENV_OBJ.addPhoneContact || envError('addPhoneContact')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const createAnimation = ENV_OBJ.createAnimation || envError('createAnimation')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const onError = ENV_OBJ.onError || envError('onError')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const createInnerAudioContext = ENV_OBJ.createInnerAudioContext || envError('createInnerAudioContext')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const base64ToArrayBuffer = ENV_OBJ.base64ToArrayBuffer || envError('base64ToArrayBuffer')
6
4
 
@@ -1,7 +1,7 @@
1
1
  import { fromByteArray, toByteArray } from './base64'
2
2
 
3
3
  function base64ToArrayBuffer (base64) {
4
- return toByteArray(base64)
4
+ return toByteArray(base64)?.buffer
5
5
  }
6
6
 
7
7
  function arrayBufferToBase64 (arrayBuffer) {
@@ -1,13 +1,15 @@
1
+ import { ENV_OBJ } from '../../../common/js'
2
+
1
3
  function closeBLEConnection (options = {}) {
2
- my.disconnectBLEDevice(options)
4
+ return ENV_OBJ.disconnectBLEDevice(options)
3
5
  }
4
6
 
5
7
  function createBLEConnection (options = {}) {
6
- my.connectBLEDevice(options)
8
+ return ENV_OBJ.connectBLEDevice(options)
7
9
  }
8
10
 
9
11
  function onBLEConnectionStateChange (callback) {
10
- my.onBLEConnectionStateChanged(callback)
12
+ return ENV_OBJ.onBLEConnectionStateChanged(callback)
11
13
  }
12
14
 
13
15
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const closeBLEConnection = ENV_OBJ.closeBLEConnection || envError('closeBLEConnection')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, envError, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, envError, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function canvasToTempFilePath (options = {}) {
4
4
  handleSuccess(options, res => {
@@ -8,13 +8,11 @@ function canvasToTempFilePath (options = {}) {
8
8
  )
9
9
  })
10
10
 
11
- my.canvasToTempFilePath(options)
11
+ return ENV_OBJ.canvasToTempFilePath(options)
12
12
  }
13
- const createCanvasContext = envError('createCanvasContext')
14
13
  const canvasGetImageData = envError('canvasGetImageData')
15
14
 
16
15
  export {
17
- createCanvasContext,
18
16
  canvasToTempFilePath,
19
17
  canvasGetImageData
20
18
  }
@@ -1,15 +1,10 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
4
-
5
- const createCanvasContext = ENV_OBJ.createCanvasContext || envError('createCanvasContext')
1
+ import { ENV_OBJ, envError } from '../../../common/js'
6
2
 
7
3
  const canvasToTempFilePath = ENV_OBJ.canvasToTempFilePath || envError('canvasToTempFilePath')
8
4
 
9
5
  const canvasGetImageData = ENV_OBJ.canvasGetImageData || envError('canvasGetImageData')
10
6
 
11
7
  export {
12
- createCanvasContext,
13
8
  canvasToTempFilePath,
14
9
  canvasGetImageData
15
10
  }
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const checkSession = ENV_OBJ.checkSession || envError('checkSession')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function setClipboardData (options = {}) {
4
4
  const opts = changeOpts(options, {
@@ -11,7 +11,7 @@ function setClipboardData (options = {}) {
11
11
  errMsg: 'setClipboardData:ok'
12
12
  })
13
13
  })
14
- my.setClipboard(opts)
14
+ return ENV_OBJ.setClipboard(opts)
15
15
  }
16
16
 
17
17
  function getClipboardData (options = {}) {
@@ -21,7 +21,7 @@ function getClipboardData (options = {}) {
21
21
  return changeOpts(res, { text: 'data' })
22
22
  })
23
23
 
24
- my.getClipboard(opts)
24
+ return ENV_OBJ.getClipboard(opts)
25
25
  }
26
26
 
27
27
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const setClipboardData = ENV_OBJ.setClipboardData || envError('setClipboardData')
6
4
 
@@ -1,4 +1,5 @@
1
1
  import { nextTick } from '../next-tick'
2
+ import { parseDataset } from '../../../common/js'
2
3
 
3
4
  let isInit = true
4
5
 
@@ -27,14 +28,16 @@ class WebIntersectionObserver {
27
28
  if (!isInit || (isInit && (entry.intersectionRatio !== initialRatio && (this._minThreshold <= entry.intersectionRatio)))) {
28
29
  Object.defineProperties(entry, {
29
30
  id: {
30
- value: entry.target.getAttribute('id') || '',
31
- writable: false,
31
+ get () {
32
+ return entry.target.id || ''
33
+ },
32
34
  enumerable: true,
33
35
  configurable: true
34
36
  },
35
37
  dataset: {
36
- value: entry.target.dataset || {},
37
- writable: false,
38
+ get () {
39
+ return parseDataset(entry.target.dataset)
40
+ },
38
41
  enumerable: true,
39
42
  configurable: true
40
43
  },
@@ -1,5 +1,7 @@
1
+ import { ENV_OBJ } from '../../../common/js'
2
+
1
3
  function createIntersectionObserver (component, options = {}) {
2
- return my.createIntersectionObserver(options)
4
+ return ENV_OBJ.createIntersectionObserver(options)
3
5
  }
4
6
 
5
7
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const createIntersectionObserver = ENV_OBJ.createIntersectionObserver || envError('createIntersectionObserver')
6
4
 
@@ -1,4 +1,5 @@
1
1
  import NodesRef from './NodesRef'
2
+ import { parseDataset } from '../../../common/js'
2
3
 
3
4
  class SelectQuery {
4
5
  constructor () {
@@ -82,7 +83,7 @@ class SelectQuery {
82
83
  const res = {}
83
84
  const isViewport = selector === 'html'
84
85
  if (id) res.id = el.id
85
- if (dataset) res.dataset = Object.assign({}, el.dataset)
86
+ if (dataset) res.dataset = parseDataset(el.dataset)
86
87
  if (rect) {
87
88
  if (isViewport) {
88
89
  res.left = 0
@@ -1,7 +1,7 @@
1
- import { noop } from '../../../common/js'
1
+ import { ENV_OBJ, noop } from '../../../common/js'
2
2
 
3
3
  function createSelectorQuery (options = {}) {
4
- const selectorQuery = my.createSelectorQuery(options)
4
+ const selectorQuery = ENV_OBJ.createSelectorQuery(options)
5
5
  const proxyMethods = ['boundingClientRect', 'scrollOffset']
6
6
  const cbs = []
7
7
  proxyMethods.forEach((name) => {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const createSelectorQuery = ENV_OBJ.createSelectorQuery || envError('createSelectorQuery')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../../common/js'
4
2
 
5
3
  const getNetworkType = ENV_OBJ.getNetworkType || envError('getNetworkType')
6
4
 
@@ -1,4 +1,4 @@
1
- import { isBrowser, throwSSRWarning } from '../../../../common/js/utils'
1
+ import { isBrowser, throwSSRWarning } from '../../../../common/js'
2
2
  const fnMap = new Map()
3
3
 
4
4
  const oldObserveList = new Set()
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function downloadFile (options = {}) {
4
4
  const opts = changeOpts(options)
@@ -7,13 +7,13 @@ function downloadFile (options = {}) {
7
7
  return changeOpts(res, { apFilePath: 'tempFilePath' })
8
8
  })
9
9
 
10
- return my.downloadFile(opts)
10
+ return ENV_OBJ.downloadFile(opts)
11
11
  }
12
12
 
13
13
  function uploadFile (options = {}) {
14
14
  const opts = changeOpts(options, { name: 'fileName' })
15
15
 
16
- return my.uploadFile(opts)
16
+ return ENV_OBJ.uploadFile(opts)
17
17
  }
18
18
 
19
19
  function saveFile (options = {}) {
@@ -25,7 +25,7 @@ function saveFile (options = {}) {
25
25
  return changeOpts(res, { apFilePath: 'savedFilePath' })
26
26
  })
27
27
 
28
- my.saveFile(opts)
28
+ return ENV_OBJ.saveFile(opts)
29
29
  }
30
30
 
31
31
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const downloadFile = ENV_OBJ.downloadFile || envError('downloadFile')
6
4
 
@@ -1,4 +1,4 @@
1
- import { warn } from '../../../common/js'
1
+ import { ENV_OBJ, warn } from '../../../common/js'
2
2
 
3
3
  const TIPS_NAME = '支付宝环境 mpx'
4
4
 
@@ -10,7 +10,7 @@ function getUserInfo (options = {}) {
10
10
  warn(`支付宝不支持在 ${TIPS_NAME}.getUserInfo 中使用 lang 参数`)
11
11
  }
12
12
 
13
- my.getOpenUserInfo(options)
13
+ return ENV_OBJ.getOpenUserInfo(options)
14
14
  }
15
15
 
16
16
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const getUserInfo = ENV_OBJ.getUserInfo || envError('getUserInfo')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function previewImage (options = {}) {
4
4
  const opts = changeOpts(options)
@@ -8,7 +8,7 @@ function previewImage (options = {}) {
8
8
  opts.current = idx !== -1 ? idx : 0
9
9
  }
10
10
 
11
- my.previewImage(opts)
11
+ return ENV_OBJ.previewImage(opts)
12
12
  }
13
13
 
14
14
  function compressImage (options = {}) {
@@ -27,7 +27,7 @@ function compressImage (options = {}) {
27
27
  )
28
28
  })
29
29
 
30
- my.compressImage(opts)
30
+ return ENV_OBJ.compressImage(opts)
31
31
  }
32
32
 
33
33
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const previewImage = ENV_OBJ.previewImage || envError('previewImage')
6
4
 
@@ -1,5 +1,7 @@
1
+ import { ENV_OBJ } from '../../../common/js'
2
+
1
3
  function getEnterOptionsSync () {
2
- return my.getEnterOptionsSync()
4
+ return ENV_OBJ.getEnterOptionsSync()
3
5
  }
4
6
 
5
7
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const getEnterOptionsSync = ENV_OBJ.getEnterOptionsSync || envError('getEnterOptionsSync')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function login (options = {}) {
4
4
  const opts = changeOpts(options)
@@ -7,7 +7,7 @@ function login (options = {}) {
7
7
  return changeOpts(res, { authCode: 'code' }, { errMsg: 'login:ok' })
8
8
  })
9
9
 
10
- my.getAuthCode(opts)
10
+ return ENV_OBJ.getAuthCode(opts)
11
11
  }
12
12
 
13
13
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const login = ENV_OBJ.login || envError('login')
6
4
 
@@ -1,10 +1,10 @@
1
- import { changeOpts } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts } from '../../../common/js'
2
2
 
3
3
  function makePhoneCall (options = {}) {
4
4
  const opts = changeOpts(options, {
5
5
  phoneNumber: 'number'
6
6
  })
7
- my.makePhoneCall(opts)
7
+ return ENV_OBJ.makePhoneCall(opts)
8
8
  }
9
9
 
10
10
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const makePhoneCall = ENV_OBJ.makePhoneCall || envError('makePhoneCall')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function showModal (options = {}) {
4
4
  let opts
@@ -13,7 +13,7 @@ function showModal (options = {}) {
13
13
  return changeOpts(res, undefined, { cancel: !res.confirm })
14
14
  })
15
15
 
16
- my.confirm(opts)
16
+ return ENV_OBJ.confirm(opts)
17
17
  } else {
18
18
  opts = changeOpts(options, {
19
19
  confirmText: 'buttonText'
@@ -23,7 +23,7 @@ function showModal (options = {}) {
23
23
  return changeOpts(res, undefined, { cancel: false, confirm: true })
24
24
  })
25
25
 
26
- my.alert(opts)
26
+ return ENV_OBJ.alert(opts)
27
27
  }
28
28
  }
29
29
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const showModal = ENV_OBJ.showModal || envError('showModal')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const nextTick = ENV_OBJ.nextTick || envError('nextTick')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const pageScrollTo = ENV_OBJ.pageScrollTo || envError('pageScrollTo')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const stopPullDownRefresh = ENV_OBJ.stopPullDownRefresh || envError('stopPullDownRefresh')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function request (options = {}) {
4
4
  const opts = changeOpts(options, {
@@ -14,10 +14,10 @@ function request (options = {}) {
14
14
 
15
15
  // request 在 1.11.0 以上版本才支持
16
16
  // httpRequest 即将被废弃,钉钉端仍需要使用
17
- if (my.canIUse('request')) {
18
- return my.request(opts)
17
+ if (ENV_OBJ.canIUse('request')) {
18
+ return ENV_OBJ.request(opts)
19
19
  } else {
20
- return my.httpRequest(opts)
20
+ return ENV_OBJ.httpRequest(opts)
21
21
  }
22
22
  }
23
23
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const request = ENV_OBJ.request || envError('request')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, error, noop } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, error, noop } from '../../../common/js'
2
2
 
3
3
  const TIPS_NAME = '支付宝环境 mpx'
4
4
 
@@ -37,7 +37,7 @@ function requestPayment (options = {}) {
37
37
  }
38
38
  }
39
39
 
40
- my.tradePay(opts)
40
+ return ENV_OBJ.tradePay(opts)
41
41
  }
42
42
 
43
43
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const requestPayment = ENV_OBJ.requestPayment || envError('requestPayment')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const redirectTo = ENV_OBJ.redirectTo || envError('redirectTo')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function scanCode (options = {}) {
4
4
  const opts = changeOpts(options, {
@@ -9,7 +9,7 @@ function scanCode (options = {}) {
9
9
  return changeOpts(res, { code: 'result' })
10
10
  })
11
11
 
12
- my.scan(opts)
12
+ return ENV_OBJ.scan(opts)
13
13
  }
14
14
 
15
15
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const scanCode = ENV_OBJ.scanCode || envError('scanCode')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function setScreenBrightness (options = {}) {
4
4
  const opts = changeOpts(options, {
@@ -7,7 +7,7 @@ function setScreenBrightness (options = {}) {
7
7
  handleSuccess(opts, res => {
8
8
  return changeOpts(res, {}, { errMsg: 'setScreenBrightness:ok' })
9
9
  })
10
- my.setScreenBrightness(opts)
10
+ return ENV_OBJ.setScreenBrightness(opts)
11
11
  }
12
12
 
13
13
  function getScreenBrightness (options = {}) {
@@ -17,7 +17,7 @@ function getScreenBrightness (options = {}) {
17
17
  return changeOpts(res, { brightness: 'value' }, { errMsg: 'getScreenBrightness:ok' })
18
18
  })
19
19
 
20
- my.getScreenBrightness(opts)
20
+ return ENV_OBJ.getScreenBrightness(opts)
21
21
  }
22
22
 
23
23
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const setScreenBrightness = ENV_OBJ.setScreenBrightness || envError('setScreenBrightness')
6
4
 
@@ -1,22 +1,20 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function setNavigationBarTitle (options = {}) {
4
4
  handleSuccess(options, res => {
5
5
  return changeOpts(res, {}, { errMsg: 'setScreenBrightness:ok' })
6
6
  })
7
- if (my.canIUse('setNavigationBarTitle')) {
8
- my.setNavigationBarTitle(options)
9
- return
7
+ if (ENV_OBJ.canIUse('setNavigationBarTitle')) {
8
+ return ENV_OBJ.setNavigationBarTitle(options)
10
9
  }
11
- my.setNavigationBar(options)
10
+ return ENV_OBJ.setNavigationBar(options)
12
11
  }
13
12
 
14
13
  function setNavigationBarColor (options = {}) {
15
- if (my.canIUse('setNavigationBarColor')) {
16
- my.setNavigationBarColor(options)
17
- return
14
+ if (ENV_OBJ.canIUse('setNavigationBarColor')) {
15
+ return ENV_OBJ.setNavigationBarColor(options)
18
16
  }
19
- my.setNavigationBar(options)
17
+ return ENV_OBJ.setNavigationBar(options)
20
18
  }
21
19
 
22
20
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const setNavigationBarTitle = ENV_OBJ.setNavigationBarTitle || envError('setNavigationBarTitle')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const connectSocket = ENV_OBJ.connectSocket || envError('connectSocket')
6
4
 
@@ -1,48 +1,50 @@
1
+ import { ENV_OBJ } from '../../../common/js'
2
+
1
3
  function setStorage (options) {
2
- my.setStorage(options)
4
+ return ENV_OBJ.setStorage(options)
3
5
  }
4
6
 
5
7
  function setStorageSync (key, data) {
6
- my.setStorageSync({
8
+ return ENV_OBJ.setStorageSync({
7
9
  key,
8
10
  data
9
11
  })
10
12
  }
11
13
 
12
14
  function getStorage (options) {
13
- my.getStorage(options)
15
+ return ENV_OBJ.getStorage(options)
14
16
  }
15
17
 
16
18
  function getStorageSync (key) {
17
- return my.getStorageSync({
19
+ return ENV_OBJ.getStorageSync({
18
20
  key
19
21
  }).data
20
22
  }
21
23
 
22
24
  function getStorageInfo (options) {
23
- return my.getStorageInfo(options)
25
+ return ENV_OBJ.getStorageInfo(options)
24
26
  }
25
27
 
26
28
  function getStorageInfoSync () {
27
- return my.getStorageInfoSync()
29
+ return ENV_OBJ.getStorageInfoSync()
28
30
  }
29
31
 
30
32
  function removeStorage (options) {
31
- return my.removeStorage(options)
33
+ return ENV_OBJ.removeStorage(options)
32
34
  }
33
35
 
34
36
  function removeStorageSync (key) {
35
- my.removeStorageSync({
37
+ return ENV_OBJ.removeStorageSync({
36
38
  key
37
39
  })
38
40
  }
39
41
 
40
42
  function clearStorage (options) {
41
- my.clearStorage(options)
43
+ return ENV_OBJ.clearStorage(options)
42
44
  }
43
45
 
44
46
  function clearStorageSync (options) {
45
- my.clearStorageSync(options)
47
+ return ENV_OBJ.clearStorageSync(options)
46
48
  }
47
49
 
48
50
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const setStorage = ENV_OBJ.setStorage || envError('setStorage')
6
4
 
@@ -1,11 +1,11 @@
1
- import { changeOpts, handleSuccess } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
2
2
 
3
3
  function getSystemInfo (options = {}) {
4
4
  const opts = changeOpts(options)
5
5
 
6
6
  handleSuccess(opts, res => {
7
7
  res.system = `${res.platform} ${res.system}`
8
- res.SDKVersion = my.SDKVersion
8
+ res.SDKVersion = ENV_OBJ.SDKVersion
9
9
 
10
10
  // 支付宝 windowHeight 可能为 0
11
11
  if (!res.windowHeight) {
@@ -15,14 +15,14 @@ function getSystemInfo (options = {}) {
15
15
  return res
16
16
  })
17
17
 
18
- my.getSystemInfo(opts)
18
+ return ENV_OBJ.getSystemInfo(opts)
19
19
  }
20
20
 
21
21
  function getSystemInfoSync () {
22
- const res = my.getSystemInfoSync() || {}
22
+ const res = ENV_OBJ.getSystemInfoSync() || {}
23
23
 
24
24
  res.system = `${res.platform} ${res.system}`
25
- res.SDKVersion = my.SDKVersion
25
+ res.SDKVersion = ENV_OBJ.SDKVersion
26
26
 
27
27
  // 支付宝 windowHeight 可能为 0
28
28
  if (!res.windowHeight) {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const getSystemInfo = ENV_OBJ.getSystemInfo || envError('getSystemInfo')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const setTabBarItem = ENV_OBJ.setTabBarItem || envError('setTabBarItem')
6
4
 
@@ -1,4 +1,4 @@
1
- import { changeOpts, warn } from '../../../common/js'
1
+ import { ENV_OBJ, changeOpts, warn } from '../../../common/js'
2
2
 
3
3
  const TIPS_NAME = '支付宝环境 mpx'
4
4
 
@@ -7,28 +7,28 @@ function showToast (options = {}) {
7
7
  title: 'content',
8
8
  icon: 'type'
9
9
  })
10
- my.showToast(opts)
10
+ return ENV_OBJ.showToast(opts)
11
11
  }
12
12
 
13
13
  function hideToast (options = {}) {
14
14
  if (options.success || options.fail || options.complete) {
15
15
  warn(`${TIPS_NAME}.hideToast 不支持 success/fail/complete 参数`)
16
16
  }
17
- my.hideToast(options)
17
+ return ENV_OBJ.hideToast(options)
18
18
  }
19
19
 
20
20
  function showLoading (options = {}) {
21
21
  const opts = changeOpts(options, {
22
22
  title: 'content'
23
23
  })
24
- my.showLoading(opts)
24
+ return ENV_OBJ.showLoading(opts)
25
25
  }
26
26
 
27
27
  function hideLoading (options = {}) {
28
28
  if (options.success || options.fail || options.complete) {
29
29
  warn(`${TIPS_NAME}.hideLoading 不支持 success/fail/complete 参数`)
30
30
  }
31
- my.hideLoading(options)
31
+ return ENV_OBJ.hideLoading(options)
32
32
  }
33
33
 
34
34
  export {
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const showToast = ENV_OBJ.showToast || envError('showToast')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const createVideoContext = ENV_OBJ.createVideoContext || envError('createVideoContext')
6
4
 
@@ -1,6 +1,4 @@
1
- import { getEnvObj, envError } from '../../../common/js'
2
-
3
- const ENV_OBJ = getEnvObj()
1
+ import { ENV_OBJ, envError } from '../../../common/js'
4
2
 
5
3
  const onWindowResize = ENV_OBJ.onWindowResize || envError('onWindowResize')
6
4
 
@@ -1,4 +1,4 @@
1
- import { isBrowser } from '../../../common/js/utils'
1
+ import { isBrowser } from '../../../common/js'
2
2
 
3
3
  const callbacks = []
4
4
 
@@ -19,7 +19,7 @@ export * from './api/base'
19
19
  // closeBLEConnection, createBLEConnection, onBLEConnectionStateChange
20
20
  export * from './api/ble-connection'
21
21
 
22
- // createCanvasContext, canvasToTempFilePath, canvasGetImageData
22
+ // canvasToTempFilePath, canvasGetImageData
23
23
  export * from './api/canvas'
24
24
 
25
25
  // checkSession