@mpxjs/api-proxy 2.9.13 → 2.9.16

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 (112) hide show
  1. package/package.json +2 -2
  2. package/src/common/js/index.js +0 -1
  3. package/src/{mini → common/js}/promisify.js +5 -4
  4. package/src/common/js/utils.js +8 -11
  5. package/src/index.js +5 -75
  6. package/src/install.js +22 -0
  7. package/src/{web → platform}/api/action-sheet/ActionSheet.js +6 -6
  8. package/src/platform/api/action-sheet/index.ali.js +28 -0
  9. package/src/platform/api/action-sheet/index.js +9 -0
  10. package/src/platform/api/add-phone-contact/index.ali.js +13 -0
  11. package/src/platform/api/add-phone-contact/index.js +9 -0
  12. package/src/platform/api/animation/index.js +9 -0
  13. package/src/platform/api/app/index.js +24 -0
  14. package/src/platform/api/audio/index.js +9 -0
  15. package/src/platform/api/base/index.js +12 -0
  16. package/src/platform/api/ble-connection/index.ali.js +17 -0
  17. package/src/platform/api/ble-connection/index.js +15 -0
  18. package/src/platform/api/canvas/index.ali.js +20 -0
  19. package/src/platform/api/canvas/index.js +15 -0
  20. package/src/platform/api/check-session/index.js +9 -0
  21. package/src/platform/api/clipboard-data/index.ali.js +30 -0
  22. package/src/platform/api/clipboard-data/index.js +12 -0
  23. package/src/platform/api/create-intersection-observer/index.ali.js +7 -0
  24. package/src/platform/api/create-intersection-observer/index.js +9 -0
  25. package/src/platform/api/create-selector-query/index.ali.js +35 -0
  26. package/src/platform/api/create-selector-query/index.js +9 -0
  27. package/src/{web → platform}/api/device/network/getNetworkType.js +1 -1
  28. package/src/platform/api/device/network/index.js +15 -0
  29. package/src/platform/api/file/index.ali.js +35 -0
  30. package/src/platform/api/file/index.js +12 -0
  31. package/src/platform/api/get-user-info/index.ali.js +18 -0
  32. package/src/platform/api/get-user-info/index.js +9 -0
  33. package/src/platform/api/image/index.ali.js +36 -0
  34. package/src/platform/api/image/index.js +12 -0
  35. package/src/{web/api/preview-image/index.js → platform/api/image/index.web.js} +8 -1
  36. package/src/platform/api/lifecycle/index.ali.js +7 -0
  37. package/src/platform/api/lifecycle/index.js +9 -0
  38. package/src/platform/api/lifecycle/index.web.js +12 -0
  39. package/src/platform/api/login/index.ali.js +15 -0
  40. package/src/platform/api/login/index.js +9 -0
  41. package/src/platform/api/make-phone-call/index.ali.js +12 -0
  42. package/src/platform/api/make-phone-call/index.js +9 -0
  43. package/src/{web → platform}/api/modal/Modal.js +2 -7
  44. package/src/platform/api/modal/index.ali.js +32 -0
  45. package/src/platform/api/modal/index.js +9 -0
  46. package/src/platform/api/next-tick/index.ali.js +7 -0
  47. package/src/platform/api/next-tick/index.js +9 -0
  48. package/src/platform/api/next-tick/index.tt.js +7 -0
  49. package/src/platform/api/page-scroll-to/index.js +9 -0
  50. package/src/platform/api/pull-down/index.js +12 -0
  51. package/src/{web/api/pull-down/index.js → platform/api/pull-down/index.web.js} +14 -22
  52. package/src/platform/api/request/index.ali.js +26 -0
  53. package/src/platform/api/request/index.js +9 -0
  54. package/src/{web/api/request/index.js → platform/api/request/index.web.js} +2 -5
  55. package/src/platform/api/request-payment/index.ali.js +45 -0
  56. package/src/platform/api/request-payment/index.js +9 -0
  57. package/src/platform/api/route/index.js +21 -0
  58. package/src/{web/api/route/index.js → platform/api/route/index.web.js} +59 -80
  59. package/src/platform/api/scan-code/index.ali.js +17 -0
  60. package/src/platform/api/scan-code/index.js +9 -0
  61. package/src/platform/api/screen-brightness/index.ali.js +26 -0
  62. package/src/platform/api/screen-brightness/index.js +12 -0
  63. package/src/platform/api/set-navigation-bar/index.ali.js +25 -0
  64. package/src/platform/api/set-navigation-bar/index.js +12 -0
  65. package/src/{web/api/set-navigation-bar/index.js → platform/api/set-navigation-bar/index.web.js} +0 -1
  66. package/src/{web → platform}/api/socket/SocketTask.js +1 -1
  67. package/src/platform/api/socket/index.js +9 -0
  68. package/src/platform/api/storage/index.ali.js +59 -0
  69. package/src/platform/api/storage/index.js +36 -0
  70. package/src/{web/api/storage/index.js → platform/api/storage/index.web.js} +0 -10
  71. package/src/platform/api/system/index.ali.js +38 -0
  72. package/src/platform/api/system/index.js +12 -0
  73. package/src/{web/api/system/index.js → platform/api/system/index.web.js} +0 -1
  74. package/src/platform/api/tab-bar/index.js +18 -0
  75. package/src/{web/api/tab-bar/index.js → platform/api/tab-bar/index.web.js} +0 -8
  76. package/src/{web → platform}/api/toast/Toast.js +0 -3
  77. package/src/platform/api/toast/index.ali.js +39 -0
  78. package/src/platform/api/toast/index.js +18 -0
  79. package/src/platform/api/video/index.js +9 -0
  80. package/src/platform/api/window/index.js +12 -0
  81. package/src/platform/index.js +109 -0
  82. package/src/common/js/ToPromise.js +0 -25
  83. package/src/index.web.js +0 -24
  84. package/src/mini/platform/wxToAli.js +0 -667
  85. package/src/mini/platform/wxToQq.js +0 -20
  86. package/src/mini/platform/wxToTt.js +0 -9
  87. package/src/mini/transform.js +0 -71
  88. package/src/web/api/index.js +0 -68
  89. /package/src/{web/api/action-sheet/index.js → platform/api/action-sheet/index.web.js} +0 -0
  90. /package/src/{web → platform}/api/animation/animation.js +0 -0
  91. /package/src/{web/api/animation/index.js → platform/api/animation/index.web.js} +0 -0
  92. /package/src/{web/api/app/index.js → platform/api/app/index.web.js} +0 -0
  93. /package/src/{web/api/audio/index.js → platform/api/audio/index.web.js} +0 -0
  94. /package/src/{web → platform}/api/base/base64.js +0 -0
  95. /package/src/{web/api/base/index.js → platform/api/base/index.web.js} +0 -0
  96. /package/src/{web → platform}/api/create-intersection-observer/IntersectionObserver.js +0 -0
  97. /package/src/{web/api/create-intersection-observer/index.js → platform/api/create-intersection-observer/index.web.js} +0 -0
  98. /package/src/{web → platform}/api/create-selector-query/NodesRef.js +0 -0
  99. /package/src/{web → platform}/api/create-selector-query/SelectQuery.js +0 -0
  100. /package/src/{web/api/create-selector-query/index.js → platform/api/create-selector-query/index.web.js} +0 -0
  101. /package/src/{web/api/device/network/index.js → platform/api/device/network/index.web.js} +0 -0
  102. /package/src/{web → platform}/api/device/network/onNetworkStatusChange.js +0 -0
  103. /package/src/{web/api/event-channel/index.js → platform/api/event-channel/index.web.js} +0 -0
  104. /package/src/{web/api/preview-image → platform/api/image}/Preview.js +0 -0
  105. /package/src/{web/api/modal/index.js → platform/api/modal/index.web.js} +0 -0
  106. /package/src/{web/api/next-tick/index.js → platform/api/next-tick/index.web.js} +0 -0
  107. /package/src/{web/api/page-scroll-to/index.js → platform/api/page-scroll-to/index.web.js} +0 -0
  108. /package/src/{web → platform}/api/request/RequestTask.js +0 -0
  109. /package/src/{web/api/socket/index.js → platform/api/socket/index.web.js} +0 -0
  110. /package/src/{web/api/toast/index.js → platform/api/toast/index.web.js} +0 -0
  111. /package/src/{web/api/video/index.js → platform/api/video/index.web.js} +0 -0
  112. /package/src/{web/api/window/index.js → platform/api/window/index.web.js} +0 -0
@@ -0,0 +1,17 @@
1
+ import { changeOpts, handleSuccess } from '../../../common/js'
2
+
3
+ function scanCode (options = {}) {
4
+ const opts = changeOpts(options, {
5
+ onlyFromCamera: 'hideAlbum'
6
+ })
7
+
8
+ handleSuccess(opts, res => {
9
+ return changeOpts(res, { code: 'result' })
10
+ })
11
+
12
+ my.scan(opts)
13
+ }
14
+
15
+ export {
16
+ scanCode
17
+ }
@@ -0,0 +1,9 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const scanCode = ENV_OBJ.scanCode || envError('scanCode')
6
+
7
+ export {
8
+ scanCode
9
+ }
@@ -0,0 +1,26 @@
1
+ import { changeOpts, handleSuccess } from '../../../common/js'
2
+
3
+ function setScreenBrightness (options = {}) {
4
+ const opts = changeOpts(options, {
5
+ value: 'brightness'
6
+ })
7
+ handleSuccess(opts, res => {
8
+ return changeOpts(res, {}, { errMsg: 'setScreenBrightness:ok' })
9
+ })
10
+ my.setScreenBrightness(opts)
11
+ }
12
+
13
+ function getScreenBrightness (options = {}) {
14
+ const opts = changeOpts(options)
15
+
16
+ handleSuccess(opts, res => {
17
+ return changeOpts(res, { brightness: 'value' }, { errMsg: 'getScreenBrightness:ok' })
18
+ })
19
+
20
+ my.getScreenBrightness(opts)
21
+ }
22
+
23
+ export {
24
+ setScreenBrightness,
25
+ getScreenBrightness
26
+ }
@@ -0,0 +1,12 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const setScreenBrightness = ENV_OBJ.setScreenBrightness || envError('setScreenBrightness')
6
+
7
+ const getScreenBrightness = ENV_OBJ.getScreenBrightness || envError('getScreenBrightness')
8
+
9
+ export {
10
+ setScreenBrightness,
11
+ getScreenBrightness
12
+ }
@@ -0,0 +1,25 @@
1
+ import { changeOpts, handleSuccess } from '../../../common/js'
2
+
3
+ function setNavigationBarTitle (options = {}) {
4
+ handleSuccess(options, res => {
5
+ return changeOpts(res, {}, { errMsg: 'setScreenBrightness:ok' })
6
+ })
7
+ if (my.canIUse('setNavigationBarTitle')) {
8
+ my.setNavigationBarTitle(options)
9
+ return
10
+ }
11
+ my.setNavigationBar(options)
12
+ }
13
+
14
+ function setNavigationBarColor (options = {}) {
15
+ if (my.canIUse('setNavigationBarColor')) {
16
+ my.setNavigationBarColor(options)
17
+ return
18
+ }
19
+ my.setNavigationBar(options)
20
+ }
21
+
22
+ export {
23
+ setNavigationBarTitle,
24
+ setNavigationBarColor
25
+ }
@@ -0,0 +1,12 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const setNavigationBarTitle = ENV_OBJ.setNavigationBarTitle || envError('setNavigationBarTitle')
6
+
7
+ const setNavigationBarColor = ENV_OBJ.setNavigationBarColor || envError('setNavigationBarColor')
8
+
9
+ export {
10
+ setNavigationBarTitle,
11
+ setNavigationBarColor
12
+ }
@@ -6,7 +6,6 @@ function setNavigationBarTitle (options = {}) {
6
6
  return
7
7
  }
8
8
  const { title, success, complete } = options
9
-
10
9
  if (document.title !== title) {
11
10
  document.title = title
12
11
  }
@@ -56,7 +56,7 @@ class SocketTask {
56
56
  }
57
57
  }
58
58
 
59
- close (options) {
59
+ close (options = {}) {
60
60
  const { code = 1000, reason = '', success, fail, complete } = options
61
61
  this._closeData = {
62
62
  code,
@@ -0,0 +1,9 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const connectSocket = ENV_OBJ.connectSocket || envError('connectSocket')
6
+
7
+ export {
8
+ connectSocket
9
+ }
@@ -0,0 +1,59 @@
1
+ function setStorage (options) {
2
+ my.setStorage(options)
3
+ }
4
+
5
+ function setStorageSync (key, data) {
6
+ my.setStorageSync({
7
+ key,
8
+ data
9
+ })
10
+ }
11
+
12
+ function getStorage (options) {
13
+ my.getStorage(options)
14
+ }
15
+
16
+ function getStorageSync (key) {
17
+ return my.getStorageSync({
18
+ key
19
+ }).data
20
+ }
21
+
22
+ function getStorageInfo (options) {
23
+ return my.getStorageInfo(options)
24
+ }
25
+
26
+ function getStorageInfoSync () {
27
+ return my.getStorageInfoSync()
28
+ }
29
+
30
+ function removeStorage (options) {
31
+ return my.removeStorage(options)
32
+ }
33
+
34
+ function removeStorageSync (key) {
35
+ my.removeStorageSync({
36
+ key
37
+ })
38
+ }
39
+
40
+ function clearStorage (options) {
41
+ my.clearStorage(options)
42
+ }
43
+
44
+ function clearStorageSync (options) {
45
+ my.clearStorageSync(options)
46
+ }
47
+
48
+ export {
49
+ setStorage,
50
+ setStorageSync,
51
+ getStorage,
52
+ getStorageSync,
53
+ getStorageInfo,
54
+ getStorageInfoSync,
55
+ removeStorage,
56
+ removeStorageSync,
57
+ clearStorage,
58
+ clearStorageSync
59
+ }
@@ -0,0 +1,36 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const setStorage = ENV_OBJ.setStorage || envError('setStorage')
6
+
7
+ const setStorageSync = ENV_OBJ.setStorageSync || envError('setStorageSync')
8
+
9
+ const getStorage = ENV_OBJ.getStorage || envError('getStorage')
10
+
11
+ const getStorageSync = ENV_OBJ.getStorageSync || envError('getStorageSync')
12
+
13
+ const getStorageInfo = ENV_OBJ.getStorageInfo || envError('getStorageInfo')
14
+
15
+ const getStorageInfoSync = ENV_OBJ.getStorageInfoSync || envError('getStorageInfoSync')
16
+
17
+ const removeStorage = ENV_OBJ.removeStorage || envError('removeStorage')
18
+
19
+ const removeStorageSync = ENV_OBJ.removeStorageSync || envError('removeStorageSync')
20
+
21
+ const clearStorage = ENV_OBJ.clearStorage || envError('clearStorage')
22
+
23
+ const clearStorageSync = ENV_OBJ.clearStorageSync || envError('clearStorageSync')
24
+
25
+ export {
26
+ setStorage,
27
+ setStorageSync,
28
+ getStorage,
29
+ getStorageSync,
30
+ getStorageInfo,
31
+ getStorageInfoSync,
32
+ removeStorage,
33
+ removeStorageSync,
34
+ clearStorage,
35
+ clearStorageSync
36
+ }
@@ -12,11 +12,9 @@ function setStorage (options = {}) {
12
12
 
13
13
  const res = { errMsg: 'setStorage:ok' }
14
14
  webHandleSuccess(res, success, complete)
15
- return Promise.resolve(res)
16
15
  } catch (err) {
17
16
  const res = { errMsg: `setStorage:fail ${err}` }
18
17
  webHandleFail(res, fail, complete)
19
- return Promise.reject(res)
20
18
  }
21
19
  }
22
20
 
@@ -46,11 +44,9 @@ function getStorage (options = {}) {
46
44
  if (result) {
47
45
  const res = { errMsg: 'getStorage:ok', data: data }
48
46
  webHandleSuccess(res, success, complete)
49
- return Promise.resolve(res)
50
47
  } else {
51
48
  const res = { errMsg: 'getStorage:fail', data: null }
52
49
  webHandleFail(res, fail, complete)
53
- return Promise.reject(res)
54
50
  }
55
51
  }
56
52
 
@@ -91,11 +87,9 @@ function getStorageInfo (options = {}) {
91
87
 
92
88
  const res = Object.assign({}, { errMsg: 'getStorageInfo:ok' }, info)
93
89
  webHandleSuccess(res, success, complete)
94
- return Promise.resolve(res)
95
90
  } catch (err) {
96
91
  const res = { errMsg: `getStorageInfo:fail ${err}` }
97
92
  webHandleFail(res, fail, complete)
98
- return Promise.reject(res)
99
93
  }
100
94
  }
101
95
 
@@ -123,11 +117,9 @@ function removeStorage (options = { key: '' }) {
123
117
 
124
118
  const res = { errMsg: 'removeStorage:ok' }
125
119
  webHandleSuccess(res, success, complete)
126
- return Promise.resolve(res)
127
120
  } catch (err) {
128
121
  const res = { errMsg: `removeStorage:fail ${err}` }
129
122
  webHandleFail(res, fail, complete)
130
- return Promise.reject(res)
131
123
  }
132
124
  }
133
125
 
@@ -151,11 +143,9 @@ function clearStorage (options = {}) {
151
143
 
152
144
  const res = { errMsg: 'clearStorage:ok' }
153
145
  webHandleSuccess(res, success, complete)
154
- return Promise.resolve(res)
155
146
  } catch (err) {
156
147
  const res = { errMsg: `clearStorage:fail ${err}` }
157
148
  webHandleFail(res, fail, complete)
158
- return Promise.reject(res)
159
149
  }
160
150
  }
161
151
 
@@ -0,0 +1,38 @@
1
+ import { changeOpts, handleSuccess } from '../../../common/js'
2
+
3
+ function getSystemInfo (options = {}) {
4
+ const opts = changeOpts(options)
5
+
6
+ handleSuccess(opts, res => {
7
+ res.system = `${res.platform} ${res.system}`
8
+ res.SDKVersion = my.SDKVersion
9
+
10
+ // 支付宝 windowHeight 可能为 0
11
+ if (!res.windowHeight) {
12
+ res.windowHeight = Math.floor(res.screenHeight * res.windowWidth / res.screenWidth) - 50
13
+ }
14
+
15
+ return res
16
+ })
17
+
18
+ my.getSystemInfo(opts)
19
+ }
20
+
21
+ function getSystemInfoSync () {
22
+ const res = my.getSystemInfoSync() || {}
23
+
24
+ res.system = `${res.platform} ${res.system}`
25
+ res.SDKVersion = my.SDKVersion
26
+
27
+ // 支付宝 windowHeight 可能为 0
28
+ if (!res.windowHeight) {
29
+ res.windowHeight = Math.floor(res.screenHeight * res.windowWidth / res.screenWidth) - 50
30
+ }
31
+
32
+ return res
33
+ }
34
+
35
+ export {
36
+ getSystemInfo,
37
+ getSystemInfoSync
38
+ }
@@ -0,0 +1,12 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const getSystemInfo = ENV_OBJ.getSystemInfo || envError('getSystemInfo')
6
+
7
+ const getSystemInfoSync = ENV_OBJ.getSystemInfoSync || envError('getSystemInfoSync')
8
+
9
+ export {
10
+ getSystemInfo,
11
+ getSystemInfoSync
12
+ }
@@ -77,7 +77,6 @@ function getSystemInfo (options = {}) {
77
77
  const info = getSystemInfoSync()
78
78
  const res = Object.assign({ errMsg: 'getSystemInfo:ok' }, info)
79
79
  webHandleSuccess(res, options.success, options.complete)
80
- return Promise.resolve(res)
81
80
  }
82
81
 
83
82
  export {
@@ -0,0 +1,18 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const setTabBarItem = ENV_OBJ.setTabBarItem || envError('setTabBarItem')
6
+
7
+ const setTabBarStyle = ENV_OBJ.setTabBarStyle || envError('setTabBarStyle')
8
+
9
+ const showTabBar = ENV_OBJ.showTabBar || envError('showTabBar')
10
+
11
+ const hideTabBar = ENV_OBJ.hideTabBar || envError('hideTabBar')
12
+
13
+ export {
14
+ setTabBarItem,
15
+ setTabBarStyle,
16
+ showTabBar,
17
+ hideTabBar
18
+ }
@@ -21,10 +21,8 @@ function setTabBarStyle (options = {}) {
21
21
 
22
22
  if (resolved) {
23
23
  webHandleSuccess(resolved, options.success, options.complete)
24
- return Promise.resolve(resolved)
25
24
  }
26
25
  webHandleFail(rejected, options.fail, options.complete)
27
- return Promise.reject(rejected)
28
26
  }
29
27
 
30
28
  function setTabBarItem (options = {}) {
@@ -52,10 +50,8 @@ function setTabBarItem (options = {}) {
52
50
 
53
51
  if (resolved) {
54
52
  webHandleSuccess(resolved, options.success, options.complete)
55
- return Promise.resolve(resolved)
56
53
  }
57
54
  webHandleFail(rejected, options.fail, options.complete)
58
- return Promise.reject(rejected)
59
55
  }
60
56
 
61
57
  function showTabBar (options = {}) {
@@ -70,10 +66,8 @@ function showTabBar (options = {}) {
70
66
 
71
67
  if (resolved) {
72
68
  webHandleSuccess(resolved, options.success, options.complete)
73
- return Promise.resolve(resolved)
74
69
  }
75
70
  webHandleFail(rejected, options.fail, options.complete)
76
- return Promise.reject(rejected)
77
71
  }
78
72
 
79
73
  function hideTabBar (options = {}) {
@@ -88,10 +82,8 @@ function hideTabBar (options = {}) {
88
82
 
89
83
  if (resolved) {
90
84
  webHandleSuccess(resolved, options.success, options.complete)
91
- return Promise.resolve(resolved)
92
85
  }
93
86
  webHandleFail(rejected, options.fail, options.complete)
94
- return Promise.reject(rejected)
95
87
  }
96
88
 
97
89
  export {
@@ -76,7 +76,6 @@ export default class Toast {
76
76
 
77
77
  const errMsg = type === 'loading' ? 'showLoading:ok' : 'showToast:ok'
78
78
  webHandleSuccess({ errMsg }, opts.success, opts.complete)
79
- return Promise.resolve({ errMsg })
80
79
  }
81
80
 
82
81
  hide (options = {}, type) {
@@ -90,11 +89,9 @@ export default class Toast {
90
89
  clearTimeout(this.hideTimer)
91
90
  this.hideTimer = null
92
91
  }
93
-
94
92
  this.hideTimer = setTimeout(() => {
95
93
  this.toast.classList.remove('show')
96
94
  this.toast.remove() // hide 则卸载
97
95
  }, duration)
98
- return Promise.resolve({ errMsg })
99
96
  }
100
97
  }
@@ -0,0 +1,39 @@
1
+ import { changeOpts, warn } from '../../../common/js'
2
+
3
+ const TIPS_NAME = '支付宝环境 mpx'
4
+
5
+ function showToast (options = {}) {
6
+ const opts = changeOpts(options, {
7
+ title: 'content',
8
+ icon: 'type'
9
+ })
10
+ my.showToast(opts)
11
+ }
12
+
13
+ function hideToast (options = {}) {
14
+ if (options.success || options.fail || options.complete) {
15
+ warn(`${TIPS_NAME}.hideToast 不支持 success/fail/complete 参数`)
16
+ }
17
+ my.hideToast(options)
18
+ }
19
+
20
+ function showLoading (options = {}) {
21
+ const opts = changeOpts(options, {
22
+ title: 'content'
23
+ })
24
+ my.showLoading(opts)
25
+ }
26
+
27
+ function hideLoading (options = {}) {
28
+ if (options.success || options.fail || options.complete) {
29
+ warn(`${TIPS_NAME}.hideLoading 不支持 success/fail/complete 参数`)
30
+ }
31
+ my.hideLoading(options)
32
+ }
33
+
34
+ export {
35
+ showToast,
36
+ hideToast,
37
+ showLoading,
38
+ hideLoading
39
+ }
@@ -0,0 +1,18 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const showToast = ENV_OBJ.showToast || envError('showToast')
6
+
7
+ const hideToast = ENV_OBJ.hideToast || envError('hideToast')
8
+
9
+ const showLoading = ENV_OBJ.showLoading || envError('showLoading')
10
+
11
+ const hideLoading = ENV_OBJ.hideLoading || envError('hideLoading')
12
+
13
+ export {
14
+ showToast,
15
+ hideToast,
16
+ showLoading,
17
+ hideLoading
18
+ }
@@ -0,0 +1,9 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const createVideoContext = ENV_OBJ.createVideoContext || envError('createVideoContext')
6
+
7
+ export {
8
+ createVideoContext
9
+ }
@@ -0,0 +1,12 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const onWindowResize = ENV_OBJ.onWindowResize || envError('onWindowResize')
6
+
7
+ const offWindowResize = ENV_OBJ.offWindowResize || envError('offWindowResize')
8
+
9
+ export {
10
+ onWindowResize,
11
+ offWindowResize
12
+ }
@@ -0,0 +1,109 @@
1
+ // showActionSheet
2
+ export * from './api/action-sheet'
3
+
4
+ // addPhoneContact
5
+ export * from './api/add-phone-contact'
6
+
7
+ // createAnimation
8
+ export * from './api/animation'
9
+
10
+ // onAppShow, onAppHide, offAppShow, offAppHide, onError, offError
11
+ export * from './api/app'
12
+
13
+ // createInnerAudioContext
14
+ export * from './api/audio'
15
+
16
+ // base64ToArrayBuffer, arrayBufferToBase64
17
+ export * from './api/base'
18
+
19
+ // closeBLEConnection, createBLEConnection, onBLEConnectionStateChange
20
+ export * from './api/ble-connection'
21
+
22
+ // createCanvasContext, canvasToTempFilePath, canvasGetImageData
23
+ export * from './api/canvas'
24
+
25
+ // checkSession
26
+ export * from './api/check-session'
27
+
28
+ // setClipboardData, getClipboardData
29
+ export * from './api/clipboard-data'
30
+
31
+ // createIntersectionObserver
32
+ export * from './api/create-intersection-observer'
33
+
34
+ // createSelectorQuery
35
+ export * from './api/create-selector-query'
36
+
37
+ // getNetworkType, onNetworkStatusChange, offNetworkStatusChange
38
+ export * from './api/device/network'
39
+
40
+ // downloadFile, uploadFile
41
+ export * from './api/file'
42
+
43
+ // getUserInfo
44
+ export * from './api/get-user-info'
45
+
46
+ // previewImage, compressImage
47
+ export * from './api/image'
48
+
49
+ // login
50
+ export * from './api/login'
51
+
52
+ // makePhoneCall
53
+ export * from './api/make-phone-call'
54
+
55
+ // showModal
56
+ export * from './api/modal'
57
+
58
+ // nextTick
59
+ export * from './api/next-tick'
60
+
61
+ // pageScrollTo
62
+ export * from './api/page-scroll-to'
63
+
64
+ // stopPullDownRefresh
65
+ export * from './api/pull-down'
66
+
67
+ // request
68
+ export * from './api/request'
69
+
70
+ // requestPayment
71
+ export * from './api/request-payment'
72
+
73
+ // redirectTo, navigateTo, navigateBack, reLaunch, switchTab
74
+ export * from './api/route'
75
+
76
+ // scanCode
77
+ export * from './api/scan-code'
78
+
79
+ // setScreenBrightness, getScreenBrightness
80
+ export * from './api/screen-brightness'
81
+
82
+ // setNavigationBarTitle, setNavigationBarColor
83
+ export * from './api/set-navigation-bar'
84
+
85
+ // connectSocket
86
+ export * from './api/socket'
87
+
88
+ // setStorage, setStorageSync, getStorage, getStorageSync
89
+ // getStorageInfo, getStorageInfoSync, removeStorage, removeStorageSync
90
+ // clearStorage, clearStorageSync
91
+ export * from './api/storage'
92
+
93
+ // getSystemInfo, getSystemInfoSync
94
+ export * from './api/system'
95
+
96
+ // setTabBarItem, setTabBarStyle, showTabBar, hideTabBar
97
+ export * from './api/tab-bar'
98
+
99
+ // showToast, hideToast, showLoading, hideLoading
100
+ export * from './api/toast'
101
+
102
+ // createVideoContext
103
+ export * from './api/video'
104
+
105
+ // onWindowResize, offWindowResize
106
+ export * from './api/window'
107
+
108
+ // getEnterOptionsSync
109
+ export * from './api/lifecycle'
@@ -1,25 +0,0 @@
1
- class ToPromise {
2
- constructor () {
3
- this._resolve = null
4
- this._reject = null
5
- }
6
-
7
- toPromiseInitPromise () {
8
- return new Promise((resolve, reject) => {
9
- this._resolve = resolve
10
- this._reject = reject
11
- })
12
- }
13
-
14
- toPromiseResolve (res) {
15
- this._resolve(res)
16
- }
17
-
18
- toPromiseReject (err) {
19
- this._reject(err)
20
- }
21
- }
22
-
23
- export {
24
- ToPromise
25
- }
package/src/index.web.js DELETED
@@ -1,24 +0,0 @@
1
- import * as allApi from './web/api'
2
- import { genFromMap } from './common/js'
3
-
4
- export default function install (target) {
5
- const fromMap = genFromMap()
6
-
7
- Object.keys(allApi).forEach(api => {
8
- target[api] = function (...args) {
9
- if (args.length > 0) {
10
- const from = args.pop()
11
- if (typeof from !== 'string' || !fromMap[from]) {
12
- args.push(from)
13
- }
14
- }
15
-
16
- return allApi[api].apply(target, args)
17
- }
18
- })
19
- }
20
- export function getProxy () {
21
- const apiProxy = {}
22
- install(apiProxy)
23
- return apiProxy
24
- }