@ray-js/robot-data-stream 0.0.5-beta-1 → 0.0.5

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.
@@ -128,11 +128,11 @@ export declare class SweeperP2p extends P2pApi {
128
128
  /**
129
129
  * 注册下载有关的监听
130
130
  */
131
- private registerP2pDownloadEvent;
131
+ registerP2pDownloadEvent: () => void;
132
132
  /**
133
133
  * 移除下载有关的监听
134
134
  */
135
- private removeP2pDownloadEvent;
135
+ removeP2pDownloadEvent: () => void;
136
136
  /**
137
137
  * 单文件下载完成回调
138
138
  * @param downloadComplete
@@ -183,7 +183,7 @@ export class SweeperP2p extends P2pApi {
183
183
  if (!this.isConnecting) {
184
184
  this.reconnectP2p(() => {
185
185
  // 重连之后重新开启文件下载, 这里的成功不需要注册断开事件
186
- this.startObserverSweeperDataByP2P(this.downloadType, this.devId, this.onReceiveMapData, this.onReceivePathData);
186
+ this.startObserverSweeperDataByP2P(this.downloadType, this.devId, this.onReceiveMapData, this.onReceivePathData, this.onReceiveAIPicData, this.onReceiveAIPicHDData);
187
187
  });
188
188
  } else {
189
189
  log4js.warn('receive disconnect notice, but connectDevice is connecting');
@@ -205,8 +205,12 @@ export class SweeperP2p extends P2pApi {
205
205
  }
206
206
  this.onReceiveMapData = onReceiveMapData;
207
207
  this.onReceivePathData = onReceivePathData;
208
- this.onReceiveAIPicData = onReceiveAIPicData || (() => {});
209
- this.onReceiveAIPicHDData = onReceiveAIPicHDData || (() => {});
208
+ this.onReceiveAIPicData = onReceiveAIPicData || (() => {
209
+ // do nothing
210
+ });
211
+ this.onReceiveAIPicHDData = onReceiveAIPicHDData || (() => {
212
+ // do nothing
213
+ });
210
214
  log4js.info('startObserverSweeperDataByP2P ==>');
211
215
  this.downloadType = downloadType;
212
216
  this.setDataFilePath(devId);
package/lib/index.js CHANGED
@@ -4,6 +4,7 @@ import mitt from 'mitt';
4
4
  import log4js from '@ray-js/log4js';
5
5
  import { SweeperP2pInstance } from './api';
6
6
  import sweeperP2pInstance from './api/sweeperP2p';
7
+ import { getSystemInfoSync } from '@ray-js/ray';
7
8
  const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
8
9
  const {
9
10
  logTag,
@@ -14,10 +15,20 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
14
15
  const offSessionStatusChange = useRef(null);
15
16
  const isAppOnBackground = useRef(false);
16
17
  const timer = useRef(null);
18
+ const isIDE = getSystemInfoSync().brand === 'devtools';
17
19
  useEffect(() => {
18
20
  if (logTag) {
19
21
  log4js.setTag(logTag);
20
22
  }
23
+ if (isIDE) {
24
+ log4js.warn(`You are using the IDE environment. To perform P2P and map debugging, please ensure the 'Robot Vacuum Debugger' plugin is installed.`);
25
+ SweeperP2pInstance.onReceiveMapData = onReceiveMapData;
26
+ SweeperP2pInstance.onReceivePathData = onReceivePathData;
27
+ SweeperP2pInstance.registerP2pDownloadEvent();
28
+ return () => {
29
+ SweeperP2pInstance.removeP2pDownloadEvent();
30
+ };
31
+ }
21
32
  if (devId.startsWith('vdevo')) {
22
33
  log4js.warn('virtual device cannot use p2p');
23
34
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/robot-data-stream",
3
- "version": "0.0.5-beta-1",
3
+ "version": "0.0.5",
4
4
  "description": "扫地机P2P数据流标准化组件",
5
5
  "main": "lib/index",
6
6
  "files": [