@mpxjs/api-proxy 2.9.6 → 2.9.11-test.0

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 (110) 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 +4 -2
  4. package/src/common/js/utils.js +32 -1
  5. package/src/common/js/web.js +25 -15
  6. package/src/index.js +4 -75
  7. package/src/install.js +62 -0
  8. package/src/{web → platform}/api/action-sheet/ActionSheet.js +6 -6
  9. package/src/platform/api/action-sheet/index.ali.js +28 -0
  10. package/src/platform/api/action-sheet/index.js +9 -0
  11. package/src/platform/api/add-phone-contact/index.ali.js +13 -0
  12. package/src/platform/api/add-phone-contact/index.js +9 -0
  13. package/src/platform/api/animation/index.js +9 -0
  14. package/src/platform/api/app/index.js +24 -0
  15. package/src/platform/api/audio/index.js +9 -0
  16. package/src/platform/api/base/index.js +12 -0
  17. package/src/platform/api/ble-connection/index.ali.js +17 -0
  18. package/src/platform/api/ble-connection/index.js +15 -0
  19. package/src/platform/api/canvas/index.ali.js +16 -0
  20. package/src/platform/api/canvas/index.js +15 -0
  21. package/src/platform/api/check-session/index.js +9 -0
  22. package/src/platform/api/clipboard-data/index.ali.js +30 -0
  23. package/src/platform/api/clipboard-data/index.js +12 -0
  24. package/src/platform/api/create-intersection-observer/index.ali.js +7 -0
  25. package/src/platform/api/create-intersection-observer/index.js +9 -0
  26. package/src/platform/api/create-selector-query/index.ali.js +35 -0
  27. package/src/platform/api/create-selector-query/index.js +9 -0
  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/platform/api/login/index.ali.js +15 -0
  36. package/src/platform/api/login/index.js +9 -0
  37. package/src/platform/api/make-phone-call/index.ali.js +12 -0
  38. package/src/platform/api/make-phone-call/index.js +9 -0
  39. package/src/{web → platform}/api/modal/Modal.js +2 -7
  40. package/src/platform/api/modal/index.ali.js +32 -0
  41. package/src/platform/api/modal/index.js +9 -0
  42. package/src/platform/api/next-tick/index.ali.js +7 -0
  43. package/src/platform/api/next-tick/index.js +9 -0
  44. package/src/platform/api/next-tick/index.tt.js +7 -0
  45. package/src/platform/api/page-scroll-to/index.js +9 -0
  46. package/src/platform/api/pull-down/index.js +12 -0
  47. package/src/{web/api/pull-down/index.js → platform/api/pull-down/index.web.js} +14 -22
  48. package/src/platform/api/request/index.ali.js +26 -0
  49. package/src/platform/api/request/index.js +9 -0
  50. package/src/{web/api/request/index.js → platform/api/request/index.web.js} +2 -5
  51. package/src/platform/api/request-payment/index.ali.js +45 -0
  52. package/src/platform/api/request-payment/index.js +9 -0
  53. package/src/platform/api/route/index.js +21 -0
  54. package/src/{web/api/route/index.js → platform/api/route/index.web.js} +59 -80
  55. package/src/platform/api/scan-code/index.ali.js +17 -0
  56. package/src/platform/api/scan-code/index.js +9 -0
  57. package/src/platform/api/screen-brightness/index.ali.js +26 -0
  58. package/src/platform/api/screen-brightness/index.js +12 -0
  59. package/src/platform/api/set-navigation-bar/index.ali.js +25 -0
  60. package/src/platform/api/set-navigation-bar/index.js +12 -0
  61. package/src/{web/api/set-navigation-bar/index.js → platform/api/set-navigation-bar/index.web.js} +0 -1
  62. package/src/{web → platform}/api/socket/SocketTask.js +1 -1
  63. package/src/platform/api/socket/index.js +9 -0
  64. package/src/platform/api/storage/index.ali.js +59 -0
  65. package/src/platform/api/storage/index.js +36 -0
  66. package/src/{web/api/storage/index.js → platform/api/storage/index.web.js} +0 -10
  67. package/src/platform/api/system/index.ali.js +38 -0
  68. package/src/platform/api/system/index.js +12 -0
  69. package/src/{web/api/system/index.js → platform/api/system/index.web.js} +0 -1
  70. package/src/platform/api/tab-bar/index.js +18 -0
  71. package/src/{web/api/tab-bar/index.js → platform/api/tab-bar/index.web.js} +0 -8
  72. package/src/{web → platform}/api/toast/Toast.js +1 -3
  73. package/src/platform/api/toast/index.ali.js +39 -0
  74. package/src/platform/api/toast/index.js +18 -0
  75. package/src/platform/api/video/index.js +9 -0
  76. package/src/platform/api/window/index.js +12 -0
  77. package/src/platform/index.js +106 -0
  78. package/src/common/js/ToPromise.js +0 -25
  79. package/src/index.web.js +0 -24
  80. package/src/mini/platform/wxToAli.js +0 -667
  81. package/src/mini/platform/wxToQq.js +0 -20
  82. package/src/mini/platform/wxToTt.js +0 -9
  83. package/src/mini/transform.js +0 -71
  84. package/src/web/api/index.js +0 -68
  85. /package/src/{web/api/action-sheet/index.js → platform/api/action-sheet/index.web.js} +0 -0
  86. /package/src/{web → platform}/api/animation/animation.js +0 -0
  87. /package/src/{web/api/animation/index.js → platform/api/animation/index.web.js} +0 -0
  88. /package/src/{web/api/app/index.js → platform/api/app/index.web.js} +0 -0
  89. /package/src/{web/api/audio/index.js → platform/api/audio/index.web.js} +0 -0
  90. /package/src/{web → platform}/api/base/base64.js +0 -0
  91. /package/src/{web/api/base/index.js → platform/api/base/index.web.js} +0 -0
  92. /package/src/{web → platform}/api/create-intersection-observer/IntersectionObserver.js +0 -0
  93. /package/src/{web/api/create-intersection-observer/index.js → platform/api/create-intersection-observer/index.web.js} +0 -0
  94. /package/src/{web → platform}/api/create-selector-query/NodesRef.js +0 -0
  95. /package/src/{web → platform}/api/create-selector-query/SelectQuery.js +0 -0
  96. /package/src/{web/api/create-selector-query/index.js → platform/api/create-selector-query/index.web.js} +0 -0
  97. /package/src/{web → platform}/api/device/network/getNetworkType.js +0 -0
  98. /package/src/{web/api/device/network/index.js → platform/api/device/network/index.web.js} +0 -0
  99. /package/src/{web → platform}/api/device/network/onNetworkStatusChange.js +0 -0
  100. /package/src/{web/api/event-channel/index.js → platform/api/event-channel/index.web.js} +0 -0
  101. /package/src/{web/api/preview-image → platform/api/image}/Preview.js +0 -0
  102. /package/src/{web/api/preview-image/index.js → platform/api/image/index.web.js} +0 -0
  103. /package/src/{web/api/modal/index.js → platform/api/modal/index.web.js} +0 -0
  104. /package/src/{web/api/next-tick/index.js → platform/api/next-tick/index.web.js} +0 -0
  105. /package/src/{web/api/page-scroll-to/index.js → platform/api/page-scroll-to/index.web.js} +0 -0
  106. /package/src/{web → platform}/api/request/RequestTask.js +0 -0
  107. /package/src/{web/api/socket/index.js → platform/api/socket/index.web.js} +0 -0
  108. /package/src/{web/api/toast/index.js → platform/api/toast/index.web.js} +0 -0
  109. /package/src/{web/api/video/index.js → platform/api/video/index.web.js} +0 -0
  110. /package/src/{web/api/window/index.js → platform/api/window/index.web.js} +0 -0
@@ -1,71 +0,0 @@
1
- import { error, getEnvObj, genFromMap, makeMap } from '../common/js'
2
- import getWxToAliApi from './platform/wxToAli'
3
- import getWxToQqApi from './platform/wxToQq'
4
- import getWxToTtApi from './platform/wxToTt'
5
-
6
- const fromMap = genFromMap()
7
-
8
- function joinName (from = '', to = '') {
9
- return `${fromMap[from]}_${to}`
10
- }
11
-
12
- function transformApi (options) {
13
- const envObj = getEnvObj()
14
- const from = options.from
15
- const to = options.to
16
- const fromTo = joinName(from, to)
17
- const wxToAliApi = getWxToAliApi()
18
- const wxToQqApi = getWxToQqApi()
19
- const wxToTtApi = getWxToTtApi()
20
- const platformMap = {
21
- wx_ali: wxToAliApi,
22
- wx_qq: wxToQqApi,
23
- wx_tt: wxToTtApi
24
- }
25
- const needProxy = Object.create(null)
26
- const excludeMap = makeMap(options.exclude)
27
- const platformApi = platformMap[fromTo] || {}
28
- Object.keys(envObj).concat(Object.keys(platformApi)).forEach((key) => {
29
- if (!excludeMap[key]) {
30
- needProxy[key] = envObj[key] || platformApi[key]
31
- }
32
- })
33
- const result = Object.create(null)
34
- Object.keys(needProxy).forEach(api => {
35
- // 非函数不做转换
36
- if (typeof needProxy[api] !== 'function') {
37
- result[api] = needProxy[api]
38
- return
39
- }
40
-
41
- result[api] = (...args) => {
42
- let from = options.from
43
- const to = options.to
44
- if (args.length > 0) {
45
- from = args.pop()
46
- if (typeof from !== 'string' || !fromMap[from]) {
47
- args.push(from)
48
- from = options.from
49
- }
50
- }
51
-
52
- const fromTo = joinName(from, to)
53
- if (options.custom[fromTo] && options.custom[fromTo][api]) {
54
- return options.custom[fromTo][api].apply(this, args)
55
- } else if (
56
- platformMap[fromTo] &&
57
- platformMap[fromTo][api]
58
- ) {
59
- return platformMap[fromTo][api].apply(this, args)
60
- } else if (envObj[api]) {
61
- return envObj[api].apply(this, args)
62
- } else {
63
- error(`当前环境不存在 ${api} 方法`)
64
- }
65
- }
66
- })
67
-
68
- return result
69
- }
70
-
71
- export default transformApi
@@ -1,68 +0,0 @@
1
- // base64ToArrayBuffer, arrayBufferToBase64
2
- export * from './base'
3
-
4
- // createSelectorQuery
5
- export * from './create-selector-query'
6
-
7
- // showActionSheet
8
- export * from './action-sheet'
9
-
10
- // showToast, hideToast, showLoading, hideLoading
11
- export * from './toast'
12
-
13
- // previewImage
14
- export * from './preview-image'
15
-
16
- // showModal
17
- export * from './modal'
18
-
19
- // setStorage, setStorageSync, getStorage, getStorageSync
20
- // getStorageInfo, getStorageInfoSync, removeStorage, removeStorageSync
21
- // clearStorage, clearStorageSync
22
- export * from './storage'
23
-
24
- // getSystemInfo, getSystemInfoSync
25
- export * from './system'
26
-
27
- // getNetworkType, onNetworkStatusChange, offNetworkStatusChange
28
- export * from './device/network'
29
-
30
- // request
31
- export * from './request'
32
-
33
- // redirectTo, navigateTo, navigateBack, reLaunch, switchTab
34
- export * from './route'
35
-
36
- // connectSocket, sendSocketMessage, closeSocket
37
- // onSocketOpen, onSocketError, onSocketMessage, onSocketClose
38
- export * from './socket'
39
-
40
- // setNavigationBarTitle setNavigationBarColor
41
- export * from './set-navigation-bar'
42
-
43
- // nextTick
44
- export * from './next-tick'
45
-
46
- // onWindowResize offWindowResize
47
- export * from './window'
48
-
49
- // stopPullDownRefresh startPullDownRefresh
50
- export * from './pull-down'
51
-
52
- // createInnerAudioContext
53
- export * from './audio'
54
-
55
- // createVideoContext
56
- export * from './video'
57
-
58
- export * from './page-scroll-to'
59
-
60
- export * from './tab-bar'
61
-
62
- export * from './app'
63
-
64
- // createAnimation
65
- export * from './animation'
66
-
67
- // createIntersectionObserver
68
- export * from './create-intersection-observer'
File without changes