@mpxjs/api-proxy 2.10.16-beta.9 → 2.10.17-beta.1
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 +0 -27
- package/package.json +3 -11
- package/src/platform/api/ble-connection/index.ali.js +2 -67
- package/src/platform/api/ble-connection/index.js +2 -65
- package/src/platform/api/route/index.ios.js +6 -2
- package/src/platform/index.js +0 -6
- package/src/platform/api/ble-connection/index.ios.js +0 -836
- package/src/platform/api/camera/index.ios.js +0 -9
- package/src/platform/api/camera/index.js +0 -7
- package/src/platform/api/camera/rnCamera.js +0 -44
- package/src/platform/api/device/wifi/index.ios.js +0 -234
- package/src/platform/api/device/wifi/index.js +0 -22
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { noop, getFocusedNavigation } from '@mpxjs/utils'
|
|
2
|
-
|
|
3
|
-
export default class CreateCamera {
|
|
4
|
-
constructor () {
|
|
5
|
-
const navigation = getFocusedNavigation() || {}
|
|
6
|
-
this.camera = navigation.camera || {}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
setZoom (options = {}) {
|
|
10
|
-
const { zoom, success = noop, fail = noop, complete = noop } = options
|
|
11
|
-
try {
|
|
12
|
-
if (this.camera.setZoom) {
|
|
13
|
-
const result = { errMsg: 'setZoom:ok' }
|
|
14
|
-
success(result)
|
|
15
|
-
complete(result)
|
|
16
|
-
this.camera.setZoom(zoom)
|
|
17
|
-
} else {
|
|
18
|
-
const result = {
|
|
19
|
-
errMsg: 'setZoom:fail camera instance not found'
|
|
20
|
-
}
|
|
21
|
-
fail(result)
|
|
22
|
-
complete(result)
|
|
23
|
-
}
|
|
24
|
-
} catch (error) {
|
|
25
|
-
const result = {
|
|
26
|
-
errMsg: 'setZoom:fail ' + (error?.message || '')
|
|
27
|
-
}
|
|
28
|
-
fail(result)
|
|
29
|
-
complete(result)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
takePhoto (options) {
|
|
34
|
-
this.camera?.takePhoto(options)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
startRecord (options) {
|
|
38
|
-
this.camera?.startRecord(options)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
stopRecord (options) {
|
|
42
|
-
this.camera?.stopRecord(options)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { PermissionsAndroid } from 'react-native'
|
|
2
|
-
import { noop } from '@mpxjs/utils'
|
|
3
|
-
import mpx from '@mpxjs/core'
|
|
4
|
-
let startWifiReady = false
|
|
5
|
-
const wifiListListeners = []
|
|
6
|
-
|
|
7
|
-
async function requestWifiPermission () {
|
|
8
|
-
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, {
|
|
9
|
-
title: 'Location permission is required for WiFi connections',
|
|
10
|
-
message:
|
|
11
|
-
'This app needs location permission as this is required ' +
|
|
12
|
-
'to scan for wifi networks.',
|
|
13
|
-
buttonNegative: 'DENY',
|
|
14
|
-
buttonPositive: 'ALLOW'
|
|
15
|
-
})
|
|
16
|
-
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
|
|
17
|
-
return true
|
|
18
|
-
} else {
|
|
19
|
-
return false
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function startWifi (options = {}) {
|
|
24
|
-
const WifiManager = require('react-native-wifi-reborn').default
|
|
25
|
-
const { success = noop, fail = noop, complete = noop } = options
|
|
26
|
-
if (__mpx_mode__ === 'ios') {
|
|
27
|
-
const result = {
|
|
28
|
-
errMsg: 'startWifi:fail ios system not support, you need to manually go to the Settings to enable wifi'
|
|
29
|
-
}
|
|
30
|
-
fail(result)
|
|
31
|
-
complete(result)
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
startWifiReady = true
|
|
35
|
-
let wifiPermission = requestWifiPermission
|
|
36
|
-
if (mpx.config?.rnConfig?.wifiPermission) {
|
|
37
|
-
wifiPermission = mpx.config.rnConfig.wifiPermission
|
|
38
|
-
}
|
|
39
|
-
wifiPermission().then(async () => {
|
|
40
|
-
let enabled
|
|
41
|
-
try {
|
|
42
|
-
enabled = await WifiManager.isEnabled()
|
|
43
|
-
} catch (e) {
|
|
44
|
-
enabled = false
|
|
45
|
-
}
|
|
46
|
-
const result = {
|
|
47
|
-
errMsg: 'startWifi:success'
|
|
48
|
-
}
|
|
49
|
-
if (!enabled) {
|
|
50
|
-
WifiManager.setEnabled(true)
|
|
51
|
-
success(result)
|
|
52
|
-
complete(result)
|
|
53
|
-
} else {
|
|
54
|
-
success(result)
|
|
55
|
-
complete(result)
|
|
56
|
-
}
|
|
57
|
-
}).catch((err) => {
|
|
58
|
-
const result = {
|
|
59
|
-
errMsg: 'startWifi:fail ' + (typeof err === 'string' ? err : ''),
|
|
60
|
-
errCode: 12001
|
|
61
|
-
}
|
|
62
|
-
fail(result)
|
|
63
|
-
complete(result)
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function stopWifi (options = {}) {
|
|
68
|
-
const WifiManager = require('react-native-wifi-reborn').default
|
|
69
|
-
const { success = noop, fail = noop, complete = noop } = options
|
|
70
|
-
if (__mpx_mode__ === 'ios') {
|
|
71
|
-
const result = {
|
|
72
|
-
errMsg: 'startWifi:fail ios system not support, you need to manually go to the Settings to enable wifi'
|
|
73
|
-
}
|
|
74
|
-
fail(result)
|
|
75
|
-
complete(result)
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
WifiManager.setEnabled(false)
|
|
79
|
-
const result = {
|
|
80
|
-
errMsg: 'stopWifi:success'
|
|
81
|
-
}
|
|
82
|
-
success(result)
|
|
83
|
-
complete(result)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function getWifiList (options = {}) {
|
|
87
|
-
const WifiManager = require('react-native-wifi-reborn').default
|
|
88
|
-
const { success = noop, fail = noop, complete = noop } = options
|
|
89
|
-
if (__mpx_mode__ === 'ios') {
|
|
90
|
-
const result = {
|
|
91
|
-
errMsg: 'startWifi:fail ios system not support'
|
|
92
|
-
}
|
|
93
|
-
fail(result)
|
|
94
|
-
complete(result)
|
|
95
|
-
return
|
|
96
|
-
}
|
|
97
|
-
if (!startWifiReady) {
|
|
98
|
-
const result = {
|
|
99
|
-
errMsg: 'startWifi:fail not init startWifi',
|
|
100
|
-
errCode: 12000
|
|
101
|
-
}
|
|
102
|
-
fail(result)
|
|
103
|
-
complete(result)
|
|
104
|
-
return
|
|
105
|
-
}
|
|
106
|
-
WifiManager.loadWifiList().then((res) => {
|
|
107
|
-
if (wifiListListeners.length) {
|
|
108
|
-
const result = res.map(item => {
|
|
109
|
-
return {
|
|
110
|
-
SSID: item.SSID,
|
|
111
|
-
BSSID: item.BSSID,
|
|
112
|
-
frequency: item.frequency
|
|
113
|
-
}
|
|
114
|
-
})
|
|
115
|
-
wifiListListeners.forEach(callback => {
|
|
116
|
-
callback({ wifiList: result })
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
const result = {
|
|
120
|
-
errMsg: 'getWifiList:success',
|
|
121
|
-
errno: 0,
|
|
122
|
-
errCode: 0
|
|
123
|
-
}
|
|
124
|
-
success(result)
|
|
125
|
-
complete(result)
|
|
126
|
-
}).catch(() => {
|
|
127
|
-
const result = {
|
|
128
|
-
errMsg: 'getWifiList:fail'
|
|
129
|
-
}
|
|
130
|
-
fail(result)
|
|
131
|
-
complete(result)
|
|
132
|
-
})
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function onGetWifiList (callback) {
|
|
136
|
-
if (!startWifiReady && wifiListListeners.indexOf(callback) > -1) {
|
|
137
|
-
return
|
|
138
|
-
}
|
|
139
|
-
wifiListListeners.push(callback)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function offGetWifiList (callback) {
|
|
143
|
-
if (!startWifiReady) {
|
|
144
|
-
return
|
|
145
|
-
}
|
|
146
|
-
const index = wifiListListeners.indexOf(callback)
|
|
147
|
-
if (index > -1) {
|
|
148
|
-
wifiListListeners.splice(index, 1)
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function getConnectedWifi (options = {}) {
|
|
153
|
-
const WifiManager = require('react-native-wifi-reborn').default
|
|
154
|
-
const { partialInfo = false, success = noop, fail = noop, complete = noop } = options
|
|
155
|
-
|
|
156
|
-
if (!startWifiReady) {
|
|
157
|
-
const result = {
|
|
158
|
-
errMsg: 'startWifi:fail not init startWifi',
|
|
159
|
-
errCode: 12000
|
|
160
|
-
}
|
|
161
|
-
fail(result)
|
|
162
|
-
complete(result)
|
|
163
|
-
return
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (partialInfo) {
|
|
167
|
-
WifiManager.getCurrentWifiSSID().then((res) => {
|
|
168
|
-
const wifi = {
|
|
169
|
-
SSID: res,
|
|
170
|
-
BSSID: '', // iOS无法获取BSSID
|
|
171
|
-
signalStrength: 0,
|
|
172
|
-
frequency: 0
|
|
173
|
-
}
|
|
174
|
-
const result = {
|
|
175
|
-
wifi: wifi,
|
|
176
|
-
errMsg: 'getConnectedWifi:ok'
|
|
177
|
-
}
|
|
178
|
-
success(result)
|
|
179
|
-
complete(result)
|
|
180
|
-
}).catch((error) => {
|
|
181
|
-
console.log(error)
|
|
182
|
-
const result = {
|
|
183
|
-
errMsg: 'getConnectedWifi:fail'
|
|
184
|
-
}
|
|
185
|
-
fail(result)
|
|
186
|
-
complete(result)
|
|
187
|
-
})
|
|
188
|
-
} else {
|
|
189
|
-
Promise.all([
|
|
190
|
-
WifiManager.getCurrentWifiSSID().catch(() => null),
|
|
191
|
-
WifiManager.getBSSID().catch(() => ''),
|
|
192
|
-
WifiManager.getCurrentSignalStrength().catch(() => 0),
|
|
193
|
-
WifiManager.getFrequency().catch(() => 0)
|
|
194
|
-
]).then(([ssid, bssid, signalStrength, frequency]) => {
|
|
195
|
-
if (!ssid) {
|
|
196
|
-
const result = {
|
|
197
|
-
errMsg: 'getConnectedWifi:fail'
|
|
198
|
-
}
|
|
199
|
-
fail(result)
|
|
200
|
-
complete(result)
|
|
201
|
-
return
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const wifi = {
|
|
205
|
-
SSID: ssid,
|
|
206
|
-
BSSID: bssid,
|
|
207
|
-
signalStrength: signalStrength,
|
|
208
|
-
frequency: frequency
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const result = {
|
|
212
|
-
wifi: wifi,
|
|
213
|
-
errMsg: 'getConnectedWifi:ok'
|
|
214
|
-
}
|
|
215
|
-
success(result)
|
|
216
|
-
complete(result)
|
|
217
|
-
}).catch(() => {
|
|
218
|
-
const result = {
|
|
219
|
-
errMsg: 'getConnectedWifi:fail'
|
|
220
|
-
}
|
|
221
|
-
fail(result)
|
|
222
|
-
complete(result)
|
|
223
|
-
})
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export {
|
|
228
|
-
startWifi,
|
|
229
|
-
stopWifi,
|
|
230
|
-
getWifiList,
|
|
231
|
-
onGetWifiList,
|
|
232
|
-
offGetWifiList,
|
|
233
|
-
getConnectedWifi
|
|
234
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ENV_OBJ, envError } from '../../../../common/js'
|
|
2
|
-
|
|
3
|
-
const startWifi = ENV_OBJ.startWifi || envError('startWifi')
|
|
4
|
-
|
|
5
|
-
const stopWifi = ENV_OBJ.stopWifi || envError('stopWifi')
|
|
6
|
-
|
|
7
|
-
const getWifiList = ENV_OBJ.getWifiList || envError('getWifiList')
|
|
8
|
-
|
|
9
|
-
const getConnectedWifi = ENV_OBJ.getConnectedWifi || envError('getConnectedWifi')
|
|
10
|
-
|
|
11
|
-
const onGetWifiList = ENV_OBJ.onGetWifiList || envError('onGetWifiList')
|
|
12
|
-
|
|
13
|
-
const offGetWifiList = ENV_OBJ.offGetWifiList || envError('offGetWifiList')
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
startWifi,
|
|
17
|
-
stopWifi,
|
|
18
|
-
getWifiList,
|
|
19
|
-
onGetWifiList,
|
|
20
|
-
offGetWifiList,
|
|
21
|
-
getConnectedWifi
|
|
22
|
-
}
|