@mpxjs/api-proxy 2.8.39 → 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.
- package/package.json +2 -2
- package/src/common/js/index.js +0 -1
- package/src/{mini → common/js}/promisify.js +4 -2
- package/src/common/js/utils.js +32 -1
- package/src/common/js/web.js +16 -0
- package/src/common/stylus/Preview.styl +29 -0
- package/src/index.js +3 -75
- package/src/install.js +56 -0
- package/src/{web → platform}/api/action-sheet/ActionSheet.js +2 -7
- package/src/platform/api/action-sheet/index.ali.js +28 -0
- package/src/platform/api/action-sheet/index.js +9 -0
- package/src/platform/api/add-phone-contact/index.ali.js +13 -0
- package/src/platform/api/add-phone-contact/index.js +9 -0
- package/src/platform/api/animation/index.js +9 -0
- package/src/platform/api/app/index.js +24 -0
- package/src/platform/api/audio/index.js +9 -0
- package/src/platform/api/base/index.js +12 -0
- package/src/platform/api/ble-connection/index.ali.js +17 -0
- package/src/platform/api/ble-connection/index.js +15 -0
- package/src/platform/api/canvas/index.ali.js +16 -0
- package/src/platform/api/canvas/index.js +15 -0
- package/src/platform/api/check-session/index.js +9 -0
- package/src/platform/api/clipboard-data/index.ali.js +30 -0
- package/src/platform/api/clipboard-data/index.js +12 -0
- package/src/{web → platform}/api/create-intersection-observer/IntersectionObserver.js +2 -10
- package/src/platform/api/create-intersection-observer/index.ali.js +7 -0
- package/src/platform/api/create-intersection-observer/index.js +9 -0
- package/src/{web → platform}/api/create-selector-query/SelectQuery.js +11 -3
- package/src/platform/api/create-selector-query/index.ali.js +35 -0
- package/src/platform/api/create-selector-query/index.js +9 -0
- package/src/platform/api/device/network/index.js +15 -0
- package/src/{web/api/event-channel/index.js → platform/api/event-channel/index.web.js} +13 -14
- package/src/platform/api/file/index.ali.js +35 -0
- package/src/platform/api/file/index.js +12 -0
- package/src/platform/api/get-user-info/index.ali.js +18 -0
- package/src/platform/api/get-user-info/index.js +9 -0
- package/src/platform/api/image/Preview.js +80 -0
- package/src/platform/api/image/index.ali.js +36 -0
- package/src/platform/api/image/index.js +12 -0
- package/src/platform/api/image/index.web.js +12 -0
- package/src/platform/api/login/index.ali.js +15 -0
- package/src/platform/api/login/index.js +9 -0
- package/src/platform/api/make-phone-call/index.ali.js +12 -0
- package/src/platform/api/make-phone-call/index.js +9 -0
- package/src/{web → platform}/api/modal/Modal.js +2 -7
- package/src/platform/api/modal/index.ali.js +32 -0
- package/src/platform/api/modal/index.js +9 -0
- package/src/platform/api/next-tick/index.ali.js +7 -0
- package/src/platform/api/next-tick/index.js +9 -0
- package/src/platform/api/next-tick/index.tt.js +7 -0
- package/src/platform/api/page-scroll-to/index.js +9 -0
- package/src/platform/api/pull-down/index.js +12 -0
- package/src/{web/api/pull-down/index.js → platform/api/pull-down/index.web.js} +14 -22
- package/src/platform/api/request/index.ali.js +26 -0
- package/src/platform/api/request/index.js +9 -0
- package/src/{web/api/request/index.js → platform/api/request/index.web.js} +14 -7
- package/src/platform/api/request-payment/index.ali.js +45 -0
- package/src/platform/api/request-payment/index.js +9 -0
- package/src/platform/api/route/index.js +21 -0
- package/src/{web/api/route/index.js → platform/api/route/index.web.js} +71 -78
- package/src/platform/api/scan-code/index.ali.js +17 -0
- package/src/platform/api/scan-code/index.js +9 -0
- package/src/platform/api/screen-brightness/index.ali.js +26 -0
- package/src/platform/api/screen-brightness/index.js +12 -0
- package/src/platform/api/set-navigation-bar/index.ali.js +25 -0
- package/src/platform/api/set-navigation-bar/index.js +12 -0
- package/src/{web/api/set-navigation-bar/index.js → platform/api/set-navigation-bar/index.web.js} +0 -1
- package/src/{web → platform}/api/socket/SocketTask.js +1 -1
- package/src/platform/api/socket/index.js +9 -0
- package/src/platform/api/storage/index.ali.js +59 -0
- package/src/platform/api/storage/index.js +36 -0
- package/src/{web/api/storage/index.js → platform/api/storage/index.web.js} +0 -10
- package/src/platform/api/system/index.ali.js +38 -0
- package/src/platform/api/system/index.js +12 -0
- package/src/{web/api/system/index.js → platform/api/system/index.web.js} +0 -1
- package/src/platform/api/tab-bar/index.js +18 -0
- package/src/{web/api/tab-bar/index.js → platform/api/tab-bar/index.web.js} +0 -8
- package/src/{web → platform}/api/toast/Toast.js +1 -10
- package/src/platform/api/toast/index.ali.js +39 -0
- package/src/platform/api/toast/index.js +18 -0
- package/src/platform/api/video/index.js +9 -0
- package/src/platform/api/window/index.js +12 -0
- package/src/platform/index.js +106 -0
- package/src/web/api/index.js +3 -0
- package/src/common/js/ToPromise.js +0 -25
- package/src/index.web.js +0 -27
- package/src/mini/platform/wxToAli.js +0 -667
- package/src/mini/platform/wxToQq.js +0 -20
- package/src/mini/platform/wxToTt.js +0 -9
- package/src/mini/transform.js +0 -71
- /package/src/{web/api/action-sheet/index.js → platform/api/action-sheet/index.web.js} +0 -0
- /package/src/{web → platform}/api/animation/animation.js +0 -0
- /package/src/{web/api/animation/index.js → platform/api/animation/index.web.js} +0 -0
- /package/src/{web/api/app/index.js → platform/api/app/index.web.js} +0 -0
- /package/src/{web/api/audio/index.js → platform/api/audio/index.web.js} +0 -0
- /package/src/{web → platform}/api/base/base64.js +0 -0
- /package/src/{web/api/base/index.js → platform/api/base/index.web.js} +0 -0
- /package/src/{web/api/create-intersection-observer/index.js → platform/api/create-intersection-observer/index.web.js} +0 -0
- /package/src/{web → platform}/api/create-selector-query/NodesRef.js +0 -0
- /package/src/{web/api/create-selector-query/index.js → platform/api/create-selector-query/index.web.js} +0 -0
- /package/src/{web → platform}/api/device/network/getNetworkType.js +0 -0
- /package/src/{web/api/device/network/index.js → platform/api/device/network/index.web.js} +0 -0
- /package/src/{web → platform}/api/device/network/onNetworkStatusChange.js +0 -0
- /package/src/{web/api/modal/index.js → platform/api/modal/index.web.js} +0 -0
- /package/src/{web/api/next-tick/index.js → platform/api/next-tick/index.web.js} +0 -0
- /package/src/{web/api/page-scroll-to/index.js → platform/api/page-scroll-to/index.web.js} +0 -0
- /package/src/{web → platform}/api/request/RequestTask.js +0 -0
- /package/src/{web/api/socket/index.js → platform/api/socket/index.web.js} +0 -0
- /package/src/{web/api/toast/index.js → platform/api/toast/index.web.js} +0 -0
- /package/src/{web/api/video/index.js → platform/api/video/index.web.js} +0 -0
- /package/src/{web/api/window/index.js → platform/api/window/index.web.js} +0 -0
|
@@ -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,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'
|
package/src/web/api/index.js
CHANGED
|
@@ -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
|
-
}
|