@mpxjs/api-proxy 2.10.16-beta.10 → 2.10.16-beta.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/api-proxy",
3
- "version": "2.10.16-beta.10",
3
+ "version": "2.10.16-beta.11",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -199,12 +199,12 @@ function startBluetoothDevicesDiscovery (options = {}) {
199
199
  }
200
200
  DiscoverPeripheralSubscription = BleManager.onDiscoverPeripheral((device) => {
201
201
  const advertising = device.advertising || {}
202
- const advertisData = advertising.manufacturerData?.data || null
202
+ const advertisData = (advertising.manufacturerData && Object.values(advertising.manufacturerData)[0]?.data) || null
203
203
  const deviceInfo = {
204
204
  deviceId: device.id,
205
205
  name: device.name || advertising.localName || '未知设备',
206
206
  RSSI: device.rssi || 0,
207
- advertisData: advertisData ? base64ToArrayBuffer(advertisData) : advertisData, // todo需要转换
207
+ advertisData: advertisData ? base64ToArrayBuffer(advertisData) : advertisData,
208
208
  advertisServiceUUIDs: advertising.serviceUUIDs || [],
209
209
  localName: advertising.localName || '',
210
210
  serviceData: advertising.serviceData || {},
@@ -213,6 +213,9 @@ function startBluetoothDevicesDiscovery (options = {}) {
213
213
  if (allowDuplicatesKey === false) {
214
214
  const existingDeviceIndex = getDevices.findIndex(existingDevice => existingDevice.deviceId === deviceInfo.deviceId)
215
215
  if (existingDeviceIndex > -1) {
216
+ if (device.name) {
217
+ getDevices.splice(existingDeviceIndex, 1, deviceInfo)
218
+ }
216
219
  return
217
220
  }
218
221
  }
@@ -21,7 +21,6 @@ async function requestWifiPermission () {
21
21
  }
22
22
 
23
23
  function startWifi (options = {}) {
24
- const WifiManager = require('react-native-wifi-reborn').default
25
24
  const { success = noop, fail = noop, complete = noop } = options
26
25
  if (__mpx_mode__ === 'ios') {
27
26
  const result = {
@@ -31,6 +30,7 @@ function startWifi (options = {}) {
31
30
  complete(result)
32
31
  return
33
32
  }
33
+ const WifiManager = require('react-native-wifi-reborn').default
34
34
  let wifiPermission = requestWifiPermission
35
35
  if (mpx.config?.rnConfig?.wifiPermission) {
36
36
  wifiPermission = mpx.config.rnConfig.wifiPermission
@@ -71,13 +71,14 @@ function stopWifi (options = {}) {
71
71
  const { success = noop, fail = noop, complete = noop } = options
72
72
  if (__mpx_mode__ === 'ios') {
73
73
  const result = {
74
- errMsg: 'startWifi:fail ios system not support, you need to manually go to the Settings to enable wifi'
74
+ errMsg: 'stopWifi:fail ios system not support, you need to manually go to the Settings to enable wifi'
75
75
  }
76
76
  fail(result)
77
77
  complete(result)
78
78
  return
79
79
  }
80
80
  startWifiReady = false
81
+ wifiListListeners.length = 0
81
82
  const result = {
82
83
  errMsg: 'stopWifi:success'
83
84
  }
@@ -86,11 +87,10 @@ function stopWifi (options = {}) {
86
87
  }
87
88
 
88
89
  function getWifiList (options = {}) {
89
- const WifiManager = require('react-native-wifi-reborn').default
90
90
  const { success = noop, fail = noop, complete = noop } = options
91
91
  if (__mpx_mode__ === 'ios') {
92
92
  const result = {
93
- errMsg: 'startWifi:fail ios system not support'
93
+ errMsg: 'getWifiList:fail ios system not support'
94
94
  }
95
95
  fail(result)
96
96
  complete(result)
@@ -98,13 +98,14 @@ function getWifiList (options = {}) {
98
98
  }
99
99
  if (!startWifiReady) {
100
100
  const result = {
101
- errMsg: 'startWifi:fail not init startWifi',
101
+ errMsg: 'getWifiList:fail not init startWifi',
102
102
  errCode: 12000
103
103
  }
104
104
  fail(result)
105
105
  complete(result)
106
106
  return
107
107
  }
108
+ const WifiManager = require('react-native-wifi-reborn').default
108
109
  WifiManager.reScanAndLoadWifiList().then((res) => {
109
110
  const wifiList = res.map(item => {
110
111
  return {
@@ -153,19 +154,18 @@ function offGetWifiList (callback) {
153
154
  }
154
155
 
155
156
  function getConnectedWifi (options = {}) {
156
- const WifiManager = require('react-native-wifi-reborn').default
157
157
  const { partialInfo = false, success = noop, fail = noop, complete = noop } = options
158
158
 
159
159
  if (!startWifiReady) {
160
160
  const result = {
161
- errMsg: 'startWifi:fail not init startWifi',
161
+ errMsg: 'getConnectedWifi:fail not init startWifi',
162
162
  errCode: 12000
163
163
  }
164
164
  fail(result)
165
165
  complete(result)
166
166
  return
167
167
  }
168
-
168
+ const WifiManager = require('react-native-wifi-reborn').default
169
169
  if (partialInfo) {
170
170
  WifiManager.getCurrentWifiSSID().then((res) => {
171
171
  const wifi = {