@mpxjs/api-proxy 2.9.70-alpha.0 → 2.9.70
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/@types/index.d.ts +13 -0
- package/LICENSE +433 -0
- package/package.json +4 -3
- package/src/common/js/index.js +0 -1
- package/src/common/js/promisify.js +11 -3
- package/src/common/js/utils.js +1 -11
- package/src/platform/api/action-sheet/rnActionSheet.jsx +67 -81
- package/src/platform/api/app/index.web.js +26 -11
- package/src/platform/api/create-intersection-observer/rnIntersectionObserver.js +2 -2
- package/src/platform/api/image/index.ali.js +4 -1
- package/src/platform/api/image/index.ios.js +45 -0
- package/src/platform/api/image/index.js +4 -1
- package/src/platform/api/image/index.web.js +46 -2
- package/src/platform/api/modal/rnModal.jsx +7 -8
- package/src/platform/api/request/index.web.js +2 -3
- package/src/platform/api/set-navigation-bar/index.ali.js +6 -1
- package/src/platform/api/set-navigation-bar/index.ios.js +6 -3
- package/src/platform/api/set-navigation-bar/index.js +4 -1
- package/src/platform/api/set-navigation-bar/index.web.js +5 -2
- package/src/platform/api/setting/index.js +19 -0
- package/src/platform/api/system/index.ios.js +84 -1
- package/src/platform/api/system/rnSystem.js +35 -72
- package/src/platform/api/toast/rnToast.jsx +23 -16
- package/src/platform/index.js +4 -1
- package/src/common/js/ToPromise.js +0 -25
- package/src/common/stylus/Modal.tenon.styl +0 -42
- package/src/common/stylus/Toast.tenon.styl +0 -56
- package/src/index.tenon.js +0 -27
- package/src/platform/api/animation/animation.tenon.js +0 -225
- package/src/platform/api/animation/index.tenon.js +0 -89
- package/src/platform/api/event-channel/index.tenon.js +0 -52
- package/src/platform/api/modal/index.tenon.js +0 -12
- package/src/platform/api/modal/tenonModal.js +0 -154
- package/src/platform/api/next-tick/index.tenon.js +0 -11
- package/src/platform/api/request/index.tenon.js +0 -85
- package/src/platform/api/request/tenonUtil.js +0 -0
- package/src/platform/api/route/index.tenon.js +0 -121
- package/src/platform/api/set-navigation-bar/index.tenon.js +0 -17
- package/src/platform/api/socket/SocketTask.tenon.js +0 -105
- package/src/platform/api/socket/index.tenon.js +0 -48
- package/src/platform/api/storage/index.tenon.js +0 -144
- package/src/platform/api/system/index.tenon.js +0 -52
- package/src/platform/api/system/rnWindowInfo.js +0 -42
- package/src/platform/api/toast/Toast.tenon.js +0 -101
- package/src/platform/api/toast/index.tenon.js +0 -36
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { successHandle, failHandle, warn } from '../../../common/js'
|
|
2
|
-
import { hasOwn } from '@mpxjs/utils'
|
|
3
|
-
const { Storage } = __GLOBAL__
|
|
4
|
-
|
|
5
|
-
function setStorage (options = {}) {
|
|
6
|
-
const { key, data, success, fail, complete } = options
|
|
7
|
-
|
|
8
|
-
try {
|
|
9
|
-
setStorageSync(key, data)
|
|
10
|
-
|
|
11
|
-
const res = { errMsg: 'setStorage:ok' }
|
|
12
|
-
successHandle(res, success, complete)
|
|
13
|
-
return Promise.resolve(res)
|
|
14
|
-
} catch (err) {
|
|
15
|
-
const res = { errMsg: `setStorage:fail ${err}` }
|
|
16
|
-
failHandle(res, fail, complete)
|
|
17
|
-
return Promise.reject(res)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function setStorageSync (key = '', data) {
|
|
22
|
-
let obj = {}
|
|
23
|
-
|
|
24
|
-
if (typeof data === 'symbol') {
|
|
25
|
-
obj = { data: '' }
|
|
26
|
-
} else {
|
|
27
|
-
obj = { data }
|
|
28
|
-
}
|
|
29
|
-
Storage.set(key, JSON.stringify(obj))
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getStorage (options = {}) {
|
|
33
|
-
const { key, success, fail, complete } = options
|
|
34
|
-
const { result, data } = getItem(key)
|
|
35
|
-
|
|
36
|
-
if (result) {
|
|
37
|
-
const res = { errMsg: 'getStorage:ok', data: data }
|
|
38
|
-
successHandle(res, success, complete)
|
|
39
|
-
return Promise.resolve(res)
|
|
40
|
-
} else {
|
|
41
|
-
const res = { errMsg: 'getStorage:fail', data: null }
|
|
42
|
-
failHandle(res, fail, complete)
|
|
43
|
-
return Promise.reject(res)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function getStorageSync (key) {
|
|
48
|
-
const res = getItem(key)
|
|
49
|
-
if (res.result) return res.data
|
|
50
|
-
|
|
51
|
-
return ''
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function getItem (key) {
|
|
55
|
-
let item
|
|
56
|
-
try {
|
|
57
|
-
item = JSON.parse(Storage.get(key))
|
|
58
|
-
} catch (e) {}
|
|
59
|
-
|
|
60
|
-
if (item && typeof item === 'object' && hasOwn(item, 'data')) {
|
|
61
|
-
return { result: true, data: item.data }
|
|
62
|
-
} else {
|
|
63
|
-
return { result: false }
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function getStorageInfo (options = {}) {
|
|
68
|
-
const { success, fail, complete } = options
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
const info = getStorageInfoSync()
|
|
72
|
-
|
|
73
|
-
const res = Object.assign({}, { errMsg: 'getStorageInfo:ok' }, info)
|
|
74
|
-
successHandle(res, success, complete)
|
|
75
|
-
return Promise.resolve(res)
|
|
76
|
-
} catch (err) {
|
|
77
|
-
const res = { errMsg: `getStorageInfo:fail ${err}` }
|
|
78
|
-
failHandle(res, fail, complete)
|
|
79
|
-
return Promise.reject(res)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function getStorageInfoSync () {
|
|
84
|
-
return {
|
|
85
|
-
keys: Object.keys(Storage),
|
|
86
|
-
limitSize: null,
|
|
87
|
-
currentSize: null
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function removeStorage (options = { key: '' }) {
|
|
92
|
-
const { key, success, fail, complete } = options
|
|
93
|
-
|
|
94
|
-
try {
|
|
95
|
-
removeStorageSync(key)
|
|
96
|
-
|
|
97
|
-
const res = { errMsg: 'removeStorage:ok' }
|
|
98
|
-
successHandle(res, success, complete)
|
|
99
|
-
return Promise.resolve(res)
|
|
100
|
-
} catch (err) {
|
|
101
|
-
const res = { errMsg: `removeStorage:fail ${err}` }
|
|
102
|
-
failHandle(res, fail, complete)
|
|
103
|
-
return Promise.reject(res)
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function removeStorageSync (key) {
|
|
108
|
-
Storage.remove(key)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function clearStorage (options = {}) {
|
|
112
|
-
warn('不支持clearStorageSync')
|
|
113
|
-
// const { success, fail, complete } = options
|
|
114
|
-
|
|
115
|
-
// try {
|
|
116
|
-
// clearStorageSync()
|
|
117
|
-
|
|
118
|
-
// const res = { errMsg: 'clearStorage:ok' }
|
|
119
|
-
// successHandle(res, success, complete)
|
|
120
|
-
// return Promise.resolve(res)
|
|
121
|
-
// } catch (err) {
|
|
122
|
-
// const res = { errMsg: `clearStorage:fail ${err}` }
|
|
123
|
-
// failHandle(res, fail, complete)
|
|
124
|
-
// return Promise.reject(res)
|
|
125
|
-
// }
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function clearStorageSync () {
|
|
129
|
-
// Storage.clear()
|
|
130
|
-
warn('不支持clearStorageSync')
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export {
|
|
134
|
-
setStorage,
|
|
135
|
-
setStorageSync,
|
|
136
|
-
getStorage,
|
|
137
|
-
getStorageSync,
|
|
138
|
-
getStorageInfo,
|
|
139
|
-
getStorageInfoSync,
|
|
140
|
-
removeStorage,
|
|
141
|
-
removeStorageSync,
|
|
142
|
-
clearStorage,
|
|
143
|
-
clearStorageSync
|
|
144
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { successHandle } from '../../../common/js'
|
|
2
|
-
const { Hummer } = __GLOBAL__
|
|
3
|
-
|
|
4
|
-
function getSystemInfoSync () {
|
|
5
|
-
const {
|
|
6
|
-
platform,
|
|
7
|
-
osVersion,
|
|
8
|
-
deviceWidth,
|
|
9
|
-
deviceHeight,
|
|
10
|
-
availableWidth,
|
|
11
|
-
availableHeight,
|
|
12
|
-
safeAreaBottom
|
|
13
|
-
} = Hummer.env || {}
|
|
14
|
-
return {
|
|
15
|
-
brand: platform,
|
|
16
|
-
model: platform,
|
|
17
|
-
pixelRatio: null,
|
|
18
|
-
screenWidth: deviceWidth,
|
|
19
|
-
screenHeight: deviceHeight,
|
|
20
|
-
windowWidth: availableWidth,
|
|
21
|
-
windowHeight: availableHeight,
|
|
22
|
-
statusBarHeight: null,
|
|
23
|
-
language: null,
|
|
24
|
-
version: null,
|
|
25
|
-
system: platform + osVersion,
|
|
26
|
-
platform: platform,
|
|
27
|
-
fontSizeSetting: null,
|
|
28
|
-
SDKVersion: null,
|
|
29
|
-
benchmarkLevel: null,
|
|
30
|
-
albumAuthorized: null,
|
|
31
|
-
cameraAuthorized: null,
|
|
32
|
-
locationAuthorized: null,
|
|
33
|
-
microphoneAuthorized: null,
|
|
34
|
-
notificationAlertAuthorized: null,
|
|
35
|
-
notificationAuthorized: null,
|
|
36
|
-
notificationBadgeAuthorized: null,
|
|
37
|
-
notificationSoundAuthorized: null,
|
|
38
|
-
bluetoothEnabled: null,
|
|
39
|
-
locationEnabled: null,
|
|
40
|
-
wifiEnabled: null,
|
|
41
|
-
safeArea: safeAreaBottom
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function getSystemInfo (options = {}) {
|
|
46
|
-
const info = getSystemInfoSync()
|
|
47
|
-
const res = Object.assign({ errMsg: 'getSystemInfo:ok' }, info)
|
|
48
|
-
successHandle(res, options.success, options.complete)
|
|
49
|
-
return Promise.resolve(res)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export { getSystemInfo, getSystemInfoSync }
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { PixelRatio, Dimensions } from 'react-native'
|
|
2
|
-
import { initialWindowMetrics } from 'react-native-safe-area-context'
|
|
3
|
-
import { getFocusedNavigation } from '../../../common/js'
|
|
4
|
-
|
|
5
|
-
const getWindowInfo = function () {
|
|
6
|
-
const dimensionsScreen = Dimensions.get('screen')
|
|
7
|
-
const navigation = getFocusedNavigation()
|
|
8
|
-
const insets = Object.assign(initialWindowMetrics?.insets, navigation?.insets)
|
|
9
|
-
let safeArea = {}
|
|
10
|
-
const { top = 0, bottom = 0, left = 0, right = 0 } = insets
|
|
11
|
-
const screenHeight = dimensionsScreen.height
|
|
12
|
-
const screenWidth = dimensionsScreen.width
|
|
13
|
-
const layout = navigation?.layout || {}
|
|
14
|
-
const layoutHeight = layout.height || 0
|
|
15
|
-
const layoutWidth = layout.width || 0
|
|
16
|
-
const windowHeight = layoutHeight || screenHeight
|
|
17
|
-
try {
|
|
18
|
-
safeArea = {
|
|
19
|
-
left,
|
|
20
|
-
right: screenWidth - right,
|
|
21
|
-
top,
|
|
22
|
-
bottom: screenHeight - bottom,
|
|
23
|
-
height: screenHeight - top - bottom,
|
|
24
|
-
width: screenWidth - left - right
|
|
25
|
-
}
|
|
26
|
-
} catch (error) {
|
|
27
|
-
}
|
|
28
|
-
const result = {
|
|
29
|
-
pixelRatio: PixelRatio.get(),
|
|
30
|
-
windowWidth: layoutWidth || screenWidth,
|
|
31
|
-
windowHeight, // 取不到layout的时候有个兜底
|
|
32
|
-
screenWidth: screenWidth,
|
|
33
|
-
screenHeight: screenHeight,
|
|
34
|
-
screenTop: screenHeight - windowHeight,
|
|
35
|
-
safeArea
|
|
36
|
-
}
|
|
37
|
-
return result
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export {
|
|
41
|
-
getWindowInfo
|
|
42
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { successHandle } from '../../../common/js'
|
|
2
|
-
import '../../../common/stylus/Toast.styl'
|
|
3
|
-
|
|
4
|
-
import { getClassStyle } from '@hummer/tenon-vue'
|
|
5
|
-
|
|
6
|
-
function createDom (Element, attrs = {}, children = []) {
|
|
7
|
-
const dom = new Element()
|
|
8
|
-
Object.keys(attrs).forEach(k => Reflect.set(dom, k, attrs[k]))
|
|
9
|
-
children.length && children.forEach(child => dom.appendChild(child))
|
|
10
|
-
return dom
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default class Toast {
|
|
14
|
-
constructor () {
|
|
15
|
-
this.defaultOpts = {
|
|
16
|
-
title: '',
|
|
17
|
-
icon: 'success',
|
|
18
|
-
image: '',
|
|
19
|
-
duration: 1500,
|
|
20
|
-
mask: false,
|
|
21
|
-
success: () => {},
|
|
22
|
-
fail: () => {},
|
|
23
|
-
complete: () => {}
|
|
24
|
-
}
|
|
25
|
-
this.dialog = null
|
|
26
|
-
this.hideTimer = null
|
|
27
|
-
this.type = null
|
|
28
|
-
|
|
29
|
-
// create & combine toast
|
|
30
|
-
this.toast = createDom(View, { style: getClassStyle(null, '__mpx_toast__') }, [
|
|
31
|
-
// todo 暂不支持 mask隐藏
|
|
32
|
-
// this.mask = createDom(View, { style: getClassStyle(null, '__mpx_mask__') }),
|
|
33
|
-
this.content = createDom(View, { style: getClassStyle(null, '__mpx_toast_box__') }, [
|
|
34
|
-
this.icon = createDom(View, { style: getClassStyle(null, '__mpx_toast_icon__') }),
|
|
35
|
-
this.title = createDom(Text, { style: getClassStyle(null, '__mpx_toast_title__') })
|
|
36
|
-
])
|
|
37
|
-
])
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
show (options, type) {
|
|
41
|
-
if (this.hideTimer) {
|
|
42
|
-
clearTimeout(this.hideTimer)
|
|
43
|
-
this.hideTimer = null
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const opts = Object.assign({}, this.defaultOpts, options)
|
|
47
|
-
|
|
48
|
-
this.type = type
|
|
49
|
-
|
|
50
|
-
// if (opts.mask) {
|
|
51
|
-
// this.mask.class += 'show'
|
|
52
|
-
// } else {
|
|
53
|
-
// this.mask.classList.remove('show')
|
|
54
|
-
// }
|
|
55
|
-
|
|
56
|
-
// const defaultIconClass = '__mpx_toast_icon__'
|
|
57
|
-
|
|
58
|
-
const iconClass = opts.image
|
|
59
|
-
? '' // image
|
|
60
|
-
: opts.icon === 'none'
|
|
61
|
-
? '__hide_icon' // none
|
|
62
|
-
: opts.icon === 'error'
|
|
63
|
-
? '__error_icon'
|
|
64
|
-
: '__success_icon' // default
|
|
65
|
-
|
|
66
|
-
// 在Hummer环境,Object.assign 有一些问题,需要重新进行一次赋值
|
|
67
|
-
this.icon.style = Object.assign(this.icon.style, getClassStyle(null, `${iconClass}`))
|
|
68
|
-
|
|
69
|
-
opts.image && (this.icon.style = Object.assign(this.icon.style, { backgroundImage: opts.image }))
|
|
70
|
-
|
|
71
|
-
this.title.text = opts.title || ''
|
|
72
|
-
|
|
73
|
-
this.dialog = new Dialog()
|
|
74
|
-
this.dialog.cancelable = false
|
|
75
|
-
opts.icon === 'loading'
|
|
76
|
-
? this.dialog.loading(opts.title || 'loading...') // 空字符串也被过滤
|
|
77
|
-
: this.dialog.custom(this.toast)
|
|
78
|
-
|
|
79
|
-
opts.duration >= 0 && this.hide({ duration: opts.duration }, type)
|
|
80
|
-
|
|
81
|
-
const errMsg = type === 'loading' ? 'showLoading:ok' : 'showToast:ok'
|
|
82
|
-
successHandle({ errMsg }, opts.success, opts.complete)
|
|
83
|
-
return Promise.resolve({ errMsg })
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
hide (options = {}, type) {
|
|
87
|
-
if (this.type !== type) return
|
|
88
|
-
|
|
89
|
-
const duration = options.duration || 0
|
|
90
|
-
const errMsg = type === 'loading' ? 'hideLoading:ok' : 'hideToast:ok'
|
|
91
|
-
successHandle({ errMsg }, options.success, options.complete)
|
|
92
|
-
|
|
93
|
-
if (this.hideTimer) {
|
|
94
|
-
clearTimeout(this.hideTimer)
|
|
95
|
-
this.hideTimer = null
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
this.hideTimer = setTimeout(() => { this.dialog.dismiss() }, duration)
|
|
99
|
-
return Promise.resolve({ errMsg })
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import Toast from './Toast'
|
|
2
|
-
|
|
3
|
-
let toast = null
|
|
4
|
-
|
|
5
|
-
function showToast (options = { title: '' }) {
|
|
6
|
-
if (!toast) { toast = new Toast() }
|
|
7
|
-
return toast.show(options, 'toast')
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function hideToast (options = {}) {
|
|
11
|
-
if (!toast) { return }
|
|
12
|
-
return toast.hide(Object.assign({ duration: 0 }, options), 'toast')
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function showLoading (options = { title: '' }) {
|
|
16
|
-
if (!toast) { toast = new Toast() }
|
|
17
|
-
return toast.show(Object.assign({
|
|
18
|
-
icon: 'loading',
|
|
19
|
-
duration: -1
|
|
20
|
-
}, options), 'loading')
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function hideLoading (options = {}) {
|
|
24
|
-
if (!toast) { return }
|
|
25
|
-
return toast.hide(Object.assign({
|
|
26
|
-
icon: 'loading',
|
|
27
|
-
duration: 0
|
|
28
|
-
}, options), 'loading')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
showToast,
|
|
33
|
-
hideToast,
|
|
34
|
-
showLoading,
|
|
35
|
-
hideLoading
|
|
36
|
-
}
|