@mpxjs/api-proxy 2.8.28-beta.11 → 2.8.40-test

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 (111) hide show
  1. package/package.json +3 -3
  2. package/src/common/js/index.js +0 -1
  3. package/src/{mini → common/js}/promisify.js +4 -2
  4. package/src/common/js/utils.js +32 -1
  5. package/src/common/js/web.js +16 -0
  6. package/src/common/stylus/Preview.styl +29 -0
  7. package/src/index.js +3 -77
  8. package/src/install.js +56 -0
  9. package/src/{web → platform}/api/action-sheet/ActionSheet.js +2 -7
  10. package/src/platform/api/action-sheet/index.ali.js +28 -0
  11. package/src/platform/api/action-sheet/index.js +9 -0
  12. package/src/platform/api/add-phone-contact/index.ali.js +13 -0
  13. package/src/platform/api/add-phone-contact/index.js +9 -0
  14. package/src/platform/api/animation/index.js +9 -0
  15. package/src/platform/api/app/index.js +24 -0
  16. package/src/platform/api/audio/index.js +9 -0
  17. package/src/platform/api/base/index.js +12 -0
  18. package/src/platform/api/ble-connection/index.ali.js +17 -0
  19. package/src/platform/api/ble-connection/index.js +15 -0
  20. package/src/platform/api/canvas/index.ali.js +16 -0
  21. package/src/platform/api/canvas/index.js +15 -0
  22. package/src/platform/api/check-session/index.js +9 -0
  23. package/src/platform/api/clipboard-data/index.ali.js +30 -0
  24. package/src/platform/api/clipboard-data/index.js +12 -0
  25. package/src/{web → platform}/api/create-intersection-observer/IntersectionObserver.js +2 -10
  26. package/src/platform/api/create-intersection-observer/index.ali.js +7 -0
  27. package/src/platform/api/create-intersection-observer/index.js +9 -0
  28. package/src/{web → platform}/api/create-selector-query/SelectQuery.js +11 -3
  29. package/src/platform/api/create-selector-query/index.ali.js +35 -0
  30. package/src/platform/api/create-selector-query/index.js +9 -0
  31. package/src/platform/api/device/network/index.js +15 -0
  32. package/src/{web/api/event-channel/index.js → platform/api/event-channel/index.web.js} +13 -14
  33. package/src/platform/api/file/index.ali.js +35 -0
  34. package/src/platform/api/file/index.js +12 -0
  35. package/src/platform/api/get-user-info/index.ali.js +18 -0
  36. package/src/platform/api/get-user-info/index.js +9 -0
  37. package/src/platform/api/image/Preview.js +80 -0
  38. package/src/platform/api/image/index.ali.js +36 -0
  39. package/src/platform/api/image/index.js +12 -0
  40. package/src/platform/api/image/index.web.js +12 -0
  41. package/src/platform/api/login/index.ali.js +15 -0
  42. package/src/platform/api/login/index.js +9 -0
  43. package/src/platform/api/make-phone-call/index.ali.js +12 -0
  44. package/src/platform/api/make-phone-call/index.js +9 -0
  45. package/src/{web → platform}/api/modal/Modal.js +2 -7
  46. package/src/platform/api/modal/index.ali.js +32 -0
  47. package/src/platform/api/modal/index.js +9 -0
  48. package/src/platform/api/next-tick/index.ali.js +7 -0
  49. package/src/platform/api/next-tick/index.js +9 -0
  50. package/src/platform/api/next-tick/index.tt.js +7 -0
  51. package/src/platform/api/page-scroll-to/index.js +9 -0
  52. package/src/platform/api/pull-down/index.js +12 -0
  53. package/src/{web/api/pull-down/index.js → platform/api/pull-down/index.web.js} +14 -22
  54. package/src/platform/api/request/index.ali.js +26 -0
  55. package/src/platform/api/request/index.js +9 -0
  56. package/src/{web/api/request/index.js → platform/api/request/index.web.js} +14 -7
  57. package/src/platform/api/request-payment/index.ali.js +45 -0
  58. package/src/platform/api/request-payment/index.js +9 -0
  59. package/src/platform/api/route/index.js +21 -0
  60. package/src/{web/api/route/index.js → platform/api/route/index.web.js} +71 -78
  61. package/src/platform/api/scan-code/index.ali.js +17 -0
  62. package/src/platform/api/scan-code/index.js +9 -0
  63. package/src/platform/api/screen-brightness/index.ali.js +26 -0
  64. package/src/platform/api/screen-brightness/index.js +12 -0
  65. package/src/platform/api/set-navigation-bar/index.ali.js +25 -0
  66. package/src/platform/api/set-navigation-bar/index.js +12 -0
  67. package/src/{web/api/set-navigation-bar/index.js → platform/api/set-navigation-bar/index.web.js} +0 -1
  68. package/src/{web → platform}/api/socket/SocketTask.js +1 -1
  69. package/src/platform/api/socket/index.js +9 -0
  70. package/src/platform/api/storage/index.ali.js +59 -0
  71. package/src/platform/api/storage/index.js +36 -0
  72. package/src/{web/api/storage/index.js → platform/api/storage/index.web.js} +0 -10
  73. package/src/platform/api/system/index.ali.js +38 -0
  74. package/src/platform/api/system/index.js +12 -0
  75. package/src/{web/api/system/index.js → platform/api/system/index.web.js} +0 -1
  76. package/src/platform/api/tab-bar/index.js +18 -0
  77. package/src/{web/api/tab-bar/index.js → platform/api/tab-bar/index.web.js} +0 -8
  78. package/src/{web → platform}/api/toast/Toast.js +1 -10
  79. package/src/platform/api/toast/index.ali.js +39 -0
  80. package/src/platform/api/toast/index.js +18 -0
  81. package/src/platform/api/video/index.js +9 -0
  82. package/src/platform/api/window/index.js +12 -0
  83. package/src/platform/index.js +106 -0
  84. package/src/web/api/index.js +3 -0
  85. package/src/common/js/ToPromise.js +0 -25
  86. package/src/index.web.js +0 -27
  87. package/src/mini/platform/wxToAli.js +0 -676
  88. package/src/mini/platform/wxToQq.js +0 -20
  89. package/src/mini/platform/wxToTt.js +0 -9
  90. package/src/mini/transform.js +0 -71
  91. /package/src/{web/api/action-sheet/index.js → platform/api/action-sheet/index.web.js} +0 -0
  92. /package/src/{web → platform}/api/animation/animation.js +0 -0
  93. /package/src/{web/api/animation/index.js → platform/api/animation/index.web.js} +0 -0
  94. /package/src/{web/api/app/index.js → platform/api/app/index.web.js} +0 -0
  95. /package/src/{web/api/audio/index.js → platform/api/audio/index.web.js} +0 -0
  96. /package/src/{web → platform}/api/base/base64.js +0 -0
  97. /package/src/{web/api/base/index.js → platform/api/base/index.web.js} +0 -0
  98. /package/src/{web/api/create-intersection-observer/index.js → platform/api/create-intersection-observer/index.web.js} +0 -0
  99. /package/src/{web → platform}/api/create-selector-query/NodesRef.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 → platform}/api/device/network/getNetworkType.js +0 -0
  102. /package/src/{web/api/device/network/index.js → platform/api/device/network/index.web.js} +0 -0
  103. /package/src/{web → platform}/api/device/network/onNetworkStatusChange.js +0 -0
  104. /package/src/{web/api/modal/index.js → platform/api/modal/index.web.js} +0 -0
  105. /package/src/{web/api/next-tick/index.js → platform/api/next-tick/index.web.js} +0 -0
  106. /package/src/{web/api/page-scroll-to/index.js → platform/api/page-scroll-to/index.web.js} +0 -0
  107. /package/src/{web → platform}/api/request/RequestTask.js +0 -0
  108. /package/src/{web/api/socket/index.js → platform/api/socket/index.web.js} +0 -0
  109. /package/src/{web/api/toast/index.js → platform/api/toast/index.web.js} +0 -0
  110. /package/src/{web/api/video/index.js → platform/api/video/index.web.js} +0 -0
  111. /package/src/{web/api/window/index.js → platform/api/window/index.web.js} +0 -0
@@ -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 {
@@ -1,14 +1,7 @@
1
- import { webHandleSuccess } from '../../../common/js'
1
+ import { webHandleSuccess, createDom } from '../../../common/js'
2
2
  import '../../../common/stylus/Toast.styl'
3
3
  import '../../../common/stylus/Loading.styl'
4
4
 
5
- function createDom (tag, attrs = {}, children = []) {
6
- const dom = document.createElement(tag)
7
- Object.keys(attrs).forEach(k => dom.setAttribute(k, attrs[k]))
8
- children.length && children.forEach(child => dom.appendChild(child))
9
- return dom
10
- }
11
-
12
5
  export default class Toast {
13
6
  constructor () {
14
7
  this.defaultOpts = {
@@ -84,7 +77,6 @@ export default class Toast {
84
77
 
85
78
  const errMsg = type === 'loading' ? 'showLoading:ok' : 'showToast:ok'
86
79
  webHandleSuccess({ errMsg }, opts.success, opts.complete)
87
- return Promise.resolve({ errMsg })
88
80
  }
89
81
 
90
82
  hide (options = {}, type) {
@@ -100,6 +92,5 @@ export default class Toast {
100
92
  }
101
93
 
102
94
  this.hideTimer = setTimeout(() => { this.toast.classList.remove('show') }, duration)
103
- return Promise.resolve({ errMsg })
104
95
  }
105
96
  }
@@ -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,106 @@
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'
@@ -10,6 +10,9 @@ export * from './action-sheet'
10
10
  // showToast, hideToast, showLoading, hideLoading
11
11
  export * from './toast'
12
12
 
13
+ // previewImage
14
+ export * from './preview-image'
15
+
13
16
  // showModal
14
17
  export * from './modal'
15
18
 
@@ -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,27 +0,0 @@
1
- import * as allApi from './web/api'
2
- import { EventChannel } from './web/api/event-channel'
3
- import { genFromMap } from './common/js'
4
-
5
- export default function install (target) {
6
- const fromMap = genFromMap()
7
-
8
- global.EventChannel = new EventChannel()
9
-
10
- Object.keys(allApi).forEach(api => {
11
- target[api] = function (...args) {
12
- if (args.length > 0) {
13
- const from = args.pop()
14
- if (typeof from !== 'string' || !fromMap[from]) {
15
- args.push(from)
16
- }
17
- }
18
-
19
- return allApi[api].apply(target, args)
20
- }
21
- })
22
- }
23
- export function getProxy () {
24
- const apiProxy = {}
25
- install(apiProxy)
26
- return apiProxy
27
- }