@mpxjs/api-proxy 2.9.13 → 2.9.14
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 +5 -4
- package/src/common/js/utils.js +8 -11
- package/src/index.js +5 -75
- package/src/install.js +22 -0
- package/src/{web → platform}/api/action-sheet/ActionSheet.js +6 -6
- 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 +20 -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/platform/api/create-intersection-observer/index.ali.js +7 -0
- package/src/platform/api/create-intersection-observer/index.js +9 -0
- 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/{web → platform}/api/device/network/getNetworkType.js +1 -1
- package/src/platform/api/device/network/index.js +15 -0
- 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/index.ali.js +36 -0
- package/src/platform/api/image/index.js +12 -0
- package/src/{web/api/preview-image/index.js → platform/api/image/index.web.js} +8 -1
- 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} +2 -5
- 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} +59 -80
- 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 +0 -3
- 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/common/js/ToPromise.js +0 -25
- package/src/index.web.js +0 -24
- 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/index.js +0 -68
- /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 → platform}/api/create-intersection-observer/IntersectionObserver.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 → platform}/api/create-selector-query/SelectQuery.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/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/event-channel/index.js → platform/api/event-channel/index.web.js} +0 -0
- /package/src/{web/api/preview-image → platform/api/image}/Preview.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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/api-proxy",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.14",
|
|
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": "^0.21.1"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "e8ab845a544d2db0619a6a7d6c04d9d384d1a6ca"
|
|
43
43
|
}
|
package/src/common/js/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getEnvObj, noop } from './utils'
|
|
2
2
|
|
|
3
3
|
const envObj = getEnvObj()
|
|
4
4
|
|
|
@@ -29,7 +29,9 @@ const blackList = [
|
|
|
29
29
|
'getMenuButtonBoundingClientRect',
|
|
30
30
|
'reportMonitor',
|
|
31
31
|
'createOffscreenCanvas',
|
|
32
|
-
'reportEvent'
|
|
32
|
+
'reportEvent',
|
|
33
|
+
'connectSocket',
|
|
34
|
+
'base64ToArrayBuffer'
|
|
33
35
|
]
|
|
34
36
|
|
|
35
37
|
function getMapFromList (list) {
|
|
@@ -46,7 +48,6 @@ function promisify (listObj, whiteList, customBlackList) {
|
|
|
46
48
|
const result = {}
|
|
47
49
|
const whiteListMap = getMapFromList(whiteList)
|
|
48
50
|
const blackListMap = getMapFromList(blackList.concat(customBlackList))
|
|
49
|
-
const fromMap = genFromMap()
|
|
50
51
|
|
|
51
52
|
function promisifyFilter (key) {
|
|
52
53
|
if (whiteListMap && whiteListMap[key] !== undefined) {
|
|
@@ -68,7 +69,7 @@ function promisify (listObj, whiteList, customBlackList) {
|
|
|
68
69
|
|
|
69
70
|
result[key] = function (...args) {
|
|
70
71
|
if (promisifyFilter(key)) {
|
|
71
|
-
if (!args[0]
|
|
72
|
+
if (!args[0]) {
|
|
72
73
|
args.unshift({ success: noop, fail: noop })
|
|
73
74
|
}
|
|
74
75
|
const obj = args[0]
|
package/src/common/js/utils.js
CHANGED
|
@@ -29,7 +29,6 @@ function changeOpts (options, updateOrRemoveOpt = {}, extraOpt = {}) {
|
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
opts = Object.assign({}, opts, extraOpt)
|
|
32
|
-
|
|
33
32
|
return opts
|
|
34
33
|
}
|
|
35
34
|
|
|
@@ -50,15 +49,6 @@ const handleSuccess = (opts, getOptions = noop, thisObj) => {
|
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
function genFromMap () {
|
|
54
|
-
const result = {}
|
|
55
|
-
const platforms = ['wx', 'ali', 'swan', 'qq', 'tt', 'web', 'qa', 'jd', 'dd']
|
|
56
|
-
platforms.forEach((platform) => {
|
|
57
|
-
result[`__mpx_src_mode_${platform}__`] = platform
|
|
58
|
-
})
|
|
59
|
-
return result
|
|
60
|
-
}
|
|
61
|
-
|
|
62
52
|
function getEnvObj () {
|
|
63
53
|
switch (__mpx_mode__) {
|
|
64
54
|
case 'wx':
|
|
@@ -77,6 +67,8 @@ function getEnvObj () {
|
|
|
77
67
|
return qa
|
|
78
68
|
case 'dd':
|
|
79
69
|
return dd
|
|
70
|
+
case 'web':
|
|
71
|
+
return {}
|
|
80
72
|
}
|
|
81
73
|
}
|
|
82
74
|
|
|
@@ -87,6 +79,11 @@ function warn (msg) {
|
|
|
87
79
|
function error (msg) {
|
|
88
80
|
console.error && console.error(`[@mpxjs/api-proxy error]:\n ${msg}`)
|
|
89
81
|
}
|
|
82
|
+
function envError (method) {
|
|
83
|
+
return () => {
|
|
84
|
+
console.error && console.error(`[@mpxjs/api-proxy error]:\n ${__mpx_mode__}环境不支持${method}方法`)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
90
87
|
|
|
91
88
|
function noop () {
|
|
92
89
|
}
|
|
@@ -106,9 +103,9 @@ function throwSSRWarning (info) {
|
|
|
106
103
|
export {
|
|
107
104
|
changeOpts,
|
|
108
105
|
handleSuccess,
|
|
109
|
-
genFromMap,
|
|
110
106
|
getEnvObj,
|
|
111
107
|
error,
|
|
108
|
+
envError,
|
|
112
109
|
warn,
|
|
113
110
|
noop,
|
|
114
111
|
makeMap,
|
package/src/index.js
CHANGED
|
@@ -1,75 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import promisify from './
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
usePromise = false, // 是否转为 promise 格式
|
|
7
|
-
whiteList = [], // 强制变成 promise 格式的 api
|
|
8
|
-
blackList = [], // 强制不变成 promise 格式的 api
|
|
9
|
-
platform = {},
|
|
10
|
-
exclude = ['shareImageMessage'], // 强制不进行代理的api,临时fix微信分享朋友圈白屏
|
|
11
|
-
custom = {}, // 自定义转化规则
|
|
12
|
-
fallbackMap = {} // 对于不支持的API,允许配置一个映射表,接管不存在的API
|
|
13
|
-
} = options
|
|
14
|
-
|
|
15
|
-
let { from = '', to = '' } = platform
|
|
16
|
-
/* eslint-disable camelcase, no-undef */
|
|
17
|
-
if (typeof __mpx_src_mode__ !== 'undefined') {
|
|
18
|
-
if (from && from !== __mpx_src_mode__) {
|
|
19
|
-
console.warn && console.warn('the platform from field inconsistent with the current environment value\n')
|
|
20
|
-
}
|
|
21
|
-
from = `__mpx_src_mode_${__mpx_src_mode__}__`
|
|
22
|
-
} else {
|
|
23
|
-
if (!from) {
|
|
24
|
-
from = 'wx'
|
|
25
|
-
console.warn && console.warn('the platform from field is empty, wx will be used by default\n')
|
|
26
|
-
}
|
|
27
|
-
from = `__mpx_src_mode_${from}__`
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (typeof __mpx_mode__ !== 'undefined') {
|
|
31
|
-
to = __mpx_mode__
|
|
32
|
-
} else if (!to) {
|
|
33
|
-
console.warn && console.warn('the platform to field is empty, ali will be used by default\n')
|
|
34
|
-
to = 'wx'
|
|
35
|
-
}
|
|
36
|
-
/* eslint-enable */
|
|
37
|
-
|
|
38
|
-
const transedApi = transformApi({
|
|
39
|
-
exclude,
|
|
40
|
-
from,
|
|
41
|
-
to,
|
|
42
|
-
custom
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
const promisedApi = usePromise ? promisify(transedApi, whiteList, blackList) : {}
|
|
46
|
-
const allApi = Object.assign({}, transedApi, promisedApi)
|
|
47
|
-
|
|
48
|
-
Object.keys(allApi).forEach(api => {
|
|
49
|
-
try {
|
|
50
|
-
if (typeof allApi[api] !== 'function') {
|
|
51
|
-
target[api] = allApi[api]
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
target[api] = (...args) => {
|
|
56
|
-
return allApi[api].apply(target, args)
|
|
57
|
-
}
|
|
58
|
-
} catch (e) {
|
|
59
|
-
} // 支付宝不支持重写 call 方法
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
// Fallback Map option
|
|
63
|
-
Object.keys(fallbackMap)
|
|
64
|
-
.forEach(k => {
|
|
65
|
-
if (!target[k]) {
|
|
66
|
-
target[k] = fallbackMap[k]
|
|
67
|
-
}
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function getProxy (options = {}) {
|
|
72
|
-
const apiProxy = {}
|
|
73
|
-
install(apiProxy, options)
|
|
74
|
-
return apiProxy
|
|
75
|
-
}
|
|
1
|
+
import install, { getProxy } from './install'
|
|
2
|
+
import promisify from './common/js/promisify'
|
|
3
|
+
export * from './platform'
|
|
4
|
+
export { getProxy, promisify }
|
|
5
|
+
export default install
|
package/src/install.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as platformApi from './platform'
|
|
2
|
+
import { getEnvObj } from './common/js'
|
|
3
|
+
import promisify from './common/js/promisify'
|
|
4
|
+
|
|
5
|
+
export default function install (target, options = {}) {
|
|
6
|
+
const {
|
|
7
|
+
usePromise = false, // 是否转为 promise 格式
|
|
8
|
+
whiteList = [], // 强制变成 promise 格式的 api
|
|
9
|
+
blackList = [], // 强制不变成 promise 格式的 api
|
|
10
|
+
custom = {} // 自定义转化规则
|
|
11
|
+
} = options
|
|
12
|
+
const envObj = getEnvObj()
|
|
13
|
+
const transedApi = Object.assign({}, envObj, platformApi)
|
|
14
|
+
const promisedApi = usePromise ? promisify(transedApi, whiteList, blackList) : {}
|
|
15
|
+
Object.assign(target, transedApi, promisedApi, custom[__mpx_mode__])
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function getProxy (options = {}) {
|
|
19
|
+
const apiProxy = {}
|
|
20
|
+
install(apiProxy, options)
|
|
21
|
+
return apiProxy
|
|
22
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { webHandleSuccess, webHandleFail, createDom, bindTap, getRootElement } from '../../../common/js'
|
|
2
2
|
import '../../../common/stylus/ActionSheet.styl'
|
|
3
3
|
|
|
4
|
-
export default class ActionSheet
|
|
4
|
+
export default class ActionSheet {
|
|
5
5
|
constructor () {
|
|
6
|
-
super()
|
|
6
|
+
// super()
|
|
7
7
|
this.defaultOpts = {
|
|
8
8
|
itemList: [],
|
|
9
9
|
itemColor: '#000000',
|
|
@@ -45,7 +45,7 @@ export default class ActionSheet extends ToPromise {
|
|
|
45
45
|
tapIndex: index
|
|
46
46
|
}
|
|
47
47
|
webHandleSuccess(res, opts.success, opts.complete)
|
|
48
|
-
this.toPromiseResolve(res)
|
|
48
|
+
// this.toPromiseResolve(res)
|
|
49
49
|
}))
|
|
50
50
|
list.appendChild(sheet)
|
|
51
51
|
})
|
|
@@ -58,7 +58,7 @@ export default class ActionSheet extends ToPromise {
|
|
|
58
58
|
this.hide()
|
|
59
59
|
const err = { errMsg: 'showActionSheet:fail cancel' }
|
|
60
60
|
webHandleFail(err, opts.fail, opts.complete)
|
|
61
|
-
!opts.fail && this.toPromiseReject(err)
|
|
61
|
+
// !opts.fail && this.toPromiseReject(err)
|
|
62
62
|
}))
|
|
63
63
|
// make transition next frame
|
|
64
64
|
this.actionSheet.classList.add('show')
|
|
@@ -67,7 +67,7 @@ export default class ActionSheet extends ToPromise {
|
|
|
67
67
|
this.box.classList.add('show')
|
|
68
68
|
}, 17)
|
|
69
69
|
|
|
70
|
-
return this.toPromiseInitPromise()
|
|
70
|
+
// return this.toPromiseInitPromise()
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
hide () {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { changeOpts, noop } from '../../../common/js'
|
|
2
|
+
function showActionSheet (options = {}) {
|
|
3
|
+
const opts = changeOpts(options, {
|
|
4
|
+
itemList: 'items'
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const cacheSuc = opts.success || noop
|
|
8
|
+
const cacheFail = opts.fail || noop
|
|
9
|
+
|
|
10
|
+
opts.success = function (res) {
|
|
11
|
+
const sucRes = changeOpts(res, {
|
|
12
|
+
index: 'tapIndex'
|
|
13
|
+
})
|
|
14
|
+
if (sucRes.tapIndex === -1) {
|
|
15
|
+
cacheFail.call(this, {
|
|
16
|
+
errMsg: 'showActionSheet:fail cancel'
|
|
17
|
+
})
|
|
18
|
+
} else {
|
|
19
|
+
cacheSuc.call(this, sucRes)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
my.showActionSheet(opts)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
showActionSheet
|
|
28
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getEnvObj, envError } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
const ENV_OBJ = getEnvObj()
|
|
4
|
+
|
|
5
|
+
const onError = ENV_OBJ.onError || envError('onError')
|
|
6
|
+
|
|
7
|
+
const offError = ENV_OBJ.offError || envError('offError')
|
|
8
|
+
|
|
9
|
+
const onAppShow = ENV_OBJ.onAppShow || envError('onAppShow')
|
|
10
|
+
|
|
11
|
+
const offAppShow = ENV_OBJ.offAppShow || envError('offAppShow')
|
|
12
|
+
|
|
13
|
+
const onAppHide = ENV_OBJ.onAppHide || envError('onAppHide')
|
|
14
|
+
|
|
15
|
+
const offAppHide = ENV_OBJ.offAppHide || envError('offAppHide')
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
onAppShow,
|
|
19
|
+
onAppHide,
|
|
20
|
+
offAppShow,
|
|
21
|
+
offAppHide,
|
|
22
|
+
onError,
|
|
23
|
+
offError
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getEnvObj, envError } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
const ENV_OBJ = getEnvObj()
|
|
4
|
+
|
|
5
|
+
const base64ToArrayBuffer = ENV_OBJ.base64ToArrayBuffer || envError('base64ToArrayBuffer')
|
|
6
|
+
|
|
7
|
+
const arrayBufferToBase64 = ENV_OBJ.arrayBufferToBase64 || envError('arrayBufferToBase64')
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
base64ToArrayBuffer,
|
|
11
|
+
arrayBufferToBase64
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function closeBLEConnection (options = {}) {
|
|
2
|
+
my.disconnectBLEDevice(options)
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function createBLEConnection (options = {}) {
|
|
6
|
+
my.connectBLEDevice(options)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function onBLEConnectionStateChange (callback) {
|
|
10
|
+
my.onBLEConnectionStateChanged(callback)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
closeBLEConnection,
|
|
15
|
+
createBLEConnection,
|
|
16
|
+
onBLEConnectionStateChange
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getEnvObj, envError } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
const ENV_OBJ = getEnvObj()
|
|
4
|
+
|
|
5
|
+
const closeBLEConnection = ENV_OBJ.closeBLEConnection || envError('closeBLEConnection')
|
|
6
|
+
|
|
7
|
+
const createBLEConnection = ENV_OBJ.createBLEConnection || envError('createBLEConnection')
|
|
8
|
+
|
|
9
|
+
const onBLEConnectionStateChange = ENV_OBJ.onBLEConnectionStateChange || envError('onBLEConnectionStateChange')
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
closeBLEConnection,
|
|
13
|
+
createBLEConnection,
|
|
14
|
+
onBLEConnectionStateChange
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { changeOpts, envError, handleSuccess } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
function canvasToTempFilePath (options = {}) {
|
|
4
|
+
handleSuccess(options, res => {
|
|
5
|
+
return changeOpts(
|
|
6
|
+
res,
|
|
7
|
+
{ errMsg: 'canvasToTempFilePath:ok' }
|
|
8
|
+
)
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
my.canvasToTempFilePath(options)
|
|
12
|
+
}
|
|
13
|
+
const createCanvasContext = envError('createCanvasContext')
|
|
14
|
+
const canvasGetImageData = envError('canvasGetImageData')
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
createCanvasContext,
|
|
18
|
+
canvasToTempFilePath,
|
|
19
|
+
canvasGetImageData
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getEnvObj, envError } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
const ENV_OBJ = getEnvObj()
|
|
4
|
+
|
|
5
|
+
const createCanvasContext = ENV_OBJ.createCanvasContext || envError('createCanvasContext')
|
|
6
|
+
|
|
7
|
+
const canvasToTempFilePath = ENV_OBJ.canvasToTempFilePath || envError('canvasToTempFilePath')
|
|
8
|
+
|
|
9
|
+
const canvasGetImageData = ENV_OBJ.canvasGetImageData || envError('canvasGetImageData')
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
createCanvasContext,
|
|
13
|
+
canvasToTempFilePath,
|
|
14
|
+
canvasGetImageData
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { changeOpts, handleSuccess } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
function setClipboardData (options = {}) {
|
|
4
|
+
const opts = changeOpts(options, {
|
|
5
|
+
data: 'text'
|
|
6
|
+
})
|
|
7
|
+
handleSuccess(opts, res => {
|
|
8
|
+
return changeOpts(res, {
|
|
9
|
+
success: ''
|
|
10
|
+
}, {
|
|
11
|
+
errMsg: 'setClipboardData:ok'
|
|
12
|
+
})
|
|
13
|
+
})
|
|
14
|
+
my.setClipboard(opts)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getClipboardData (options = {}) {
|
|
18
|
+
const opts = changeOpts(options)
|
|
19
|
+
|
|
20
|
+
handleSuccess(opts, res => {
|
|
21
|
+
return changeOpts(res, { text: 'data' })
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
my.getClipboard(opts)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
setClipboardData,
|
|
29
|
+
getClipboardData
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getEnvObj, envError } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
const ENV_OBJ = getEnvObj()
|
|
4
|
+
|
|
5
|
+
const setClipboardData = ENV_OBJ.setClipboardData || envError('setClipboardData')
|
|
6
|
+
|
|
7
|
+
const getClipboardData = ENV_OBJ.getClipboardData || envError('getClipboardData')
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
setClipboardData,
|
|
11
|
+
getClipboardData
|
|
12
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { noop } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
function createSelectorQuery (options = {}) {
|
|
4
|
+
const selectorQuery = my.createSelectorQuery(options)
|
|
5
|
+
const proxyMethods = ['boundingClientRect', 'scrollOffset']
|
|
6
|
+
const cbs = []
|
|
7
|
+
proxyMethods.forEach((name) => {
|
|
8
|
+
const originalMethod = selectorQuery[name]
|
|
9
|
+
selectorQuery[name] = function (cb = noop) {
|
|
10
|
+
cbs.push(cb)
|
|
11
|
+
return originalMethod.call(this)
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const originalExec = selectorQuery.exec
|
|
16
|
+
selectorQuery.exec = function (originalCb = noop) {
|
|
17
|
+
const cb = function (results) {
|
|
18
|
+
results.forEach((item, index) => {
|
|
19
|
+
cbs[index] && cbs[index](item)
|
|
20
|
+
})
|
|
21
|
+
originalCb(results)
|
|
22
|
+
}
|
|
23
|
+
return originalExec.call(this, cb)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
selectorQuery.in = function () {
|
|
27
|
+
return this
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return selectorQuery
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
createSelectorQuery
|
|
35
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { webHandleSuccess, webHandleFail, isBrowser, throwSSRWarning } from '../../../../common/js'
|
|
2
2
|
|
|
3
|
-
export function getNetworkType ({ success, fail = () => {}, complete = () => {} }) {
|
|
3
|
+
export function getNetworkType ({ success, fail = () => {}, complete = () => {} } = {}) {
|
|
4
4
|
if (!isBrowser) {
|
|
5
5
|
throwSSRWarning('getNetworkType API is running in non browser environments')
|
|
6
6
|
return
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getEnvObj, envError } from '../../../../common/js'
|
|
2
|
+
|
|
3
|
+
const ENV_OBJ = getEnvObj()
|
|
4
|
+
|
|
5
|
+
const getNetworkType = ENV_OBJ.getNetworkType || envError('getNetworkType')
|
|
6
|
+
|
|
7
|
+
const onNetworkStatusChange = ENV_OBJ.onNetworkStatusChange || envError('onNetworkStatusChange')
|
|
8
|
+
|
|
9
|
+
const offNetworkStatusChange = ENV_OBJ.offNetworkStatusChange || envError('offNetworkStatusChange')
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
getNetworkType,
|
|
13
|
+
onNetworkStatusChange,
|
|
14
|
+
offNetworkStatusChange
|
|
15
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { changeOpts, handleSuccess } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
function downloadFile (options = {}) {
|
|
4
|
+
const opts = changeOpts(options)
|
|
5
|
+
|
|
6
|
+
handleSuccess(opts, res => {
|
|
7
|
+
return changeOpts(res, { apFilePath: 'tempFilePath' })
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
return my.downloadFile(opts)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function uploadFile (options = {}) {
|
|
14
|
+
const opts = changeOpts(options, { name: 'fileName' })
|
|
15
|
+
|
|
16
|
+
return my.uploadFile(opts)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function saveFile (options = {}) {
|
|
20
|
+
const opts = changeOpts(options, {
|
|
21
|
+
tempFilePath: 'apFilePath'
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
handleSuccess(opts, res => {
|
|
25
|
+
return changeOpts(res, { apFilePath: 'savedFilePath' })
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
my.saveFile(opts)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
downloadFile,
|
|
33
|
+
uploadFile,
|
|
34
|
+
saveFile
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getEnvObj, envError } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
const ENV_OBJ = getEnvObj()
|
|
4
|
+
|
|
5
|
+
const downloadFile = ENV_OBJ.downloadFile || envError('downloadFile')
|
|
6
|
+
|
|
7
|
+
const uploadFile = ENV_OBJ.uploadFile || envError('uploadFile')
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
downloadFile,
|
|
11
|
+
uploadFile
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { warn } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
const TIPS_NAME = '支付宝环境 mpx'
|
|
4
|
+
|
|
5
|
+
function getUserInfo (options = {}) {
|
|
6
|
+
if (options.withCredentials === true) {
|
|
7
|
+
warn(`支付宝不支持在 ${TIPS_NAME}.getUserInfo 使用 withCredentials 参数中获取等敏感信息`)
|
|
8
|
+
}
|
|
9
|
+
if (options.lang) {
|
|
10
|
+
warn(`支付宝不支持在 ${TIPS_NAME}.getUserInfo 中使用 lang 参数`)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
my.getOpenUserInfo(options)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
getUserInfo
|
|
18
|
+
}
|