@ray-js/robot-data-stream 0.0.10-beta-23 → 0.0.10-beta-25

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.
@@ -9,9 +9,7 @@ export default class P2pApi {
9
9
  initTimeStamp: number;
10
10
  devId: string;
11
11
  traceId: string;
12
- constructor(props: {
13
- onLogger: (type: 'warn' | 'error' | 'info', data: string) => void;
14
- });
12
+ constructor();
15
13
  /**
16
14
  * 设备断开之后的重连
17
15
  */
package/lib/api/p2pApi.js CHANGED
@@ -11,12 +11,9 @@ import { trace } from '../trace';
11
11
  export default class P2pApi {
12
12
  // P2p连接状态
13
13
 
14
- constructor(props) {
14
+ constructor() {
15
15
  this.isConnected = false;
16
16
  this.isConnecting = false;
17
- if (props && props.onLogger) {
18
- this.onLogger = props === null || props === void 0 ? void 0 : props.onLogger;
19
- }
20
17
  }
21
18
 
22
19
  /**
@@ -74,9 +74,7 @@ export declare class SweeperP2p extends P2pApi {
74
74
  offTotalDownLoadProgressUpdate: () => void;
75
75
  onDefineStructuredMode: (isStructured: boolean) => void;
76
76
  mapUpdateCount: number;
77
- constructor(props: {
78
- onLogger: (type: 'warn' | 'error' | 'info', data: string) => void;
79
- });
77
+ constructor(props: any);
80
78
  private setStreamFilePath;
81
79
  private setDataFilePath;
82
80
  /**
@@ -51,9 +51,6 @@ const shouldDownloadStream = Boolean(ty.p2p.downloadStream && ty.p2p.onStreamPac
51
51
  export class SweeperP2p extends P2pApi {
52
52
  constructor(props) {
53
53
  super(props);
54
- if (props && props.onLogger) {
55
- this.onLogger = props.onLogger;
56
- }
57
54
  this.file = undefined;
58
55
  this.downloadType = 1;
59
56
  this.fileIndex = -1; // -1 表示所有文件下载完成
@@ -632,6 +629,9 @@ export class SweeperP2p extends P2pApi {
632
629
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, consistent-return
633
630
  stopObserverSweeperDataByP2P = () => {
634
631
  try {
632
+ logger('info', {
633
+ msg: `isConnected: ${this.isConnected}, devId: ${this.devId}`
634
+ }, this.onLogger);
635
635
  if (this.isConnected) {
636
636
  logger('info', {
637
637
  msg: `try disconnect device, devId: ${this.devId}`
package/lib/index.js CHANGED
@@ -2,9 +2,9 @@
2
2
  import log4js from '@ray-js/log4js';
3
3
  import { getSystemInfoSync, usePageEvent } from '@ray-js/ray';
4
4
  import { useCallback, useEffect, useRef } from 'react';
5
- import { SweeperP2p } from './api/sweeperP2p';
6
5
  import { trace } from './trace';
7
6
  import { emitter, logger } from './utils';
7
+ import { SweeperP2pInstance } from './api';
8
8
  export * from './mqtt';
9
9
  export * from './mqtt/type/requestType';
10
10
  const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
@@ -20,9 +20,6 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
20
20
  const isAppOnBackground = useRef(false);
21
21
  const timer = useRef(null);
22
22
  const isIDE = getSystemInfoSync().brand === 'devtools';
23
- const SweeperP2pInstance = new SweeperP2p({
24
- onLogger
25
- });
26
23
  const handleAppHide = useCallback(() => {
27
24
  logger('info', {
28
25
  msg: 'hooks onAppHide'
@@ -79,6 +76,7 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
79
76
  }, onLogger);
80
77
  return;
81
78
  }
79
+ SweeperP2pInstance.onLogger = onLogger;
82
80
  SweeperP2pInstance.initP2pSdk(devId).then(() => {
83
81
  connectP2p();
84
82
  trace.pointFn('p2p', {
@@ -143,11 +141,11 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
143
141
  msg: 'hooks has been started unmount'
144
142
  }, onLogger);
145
143
  isInit.current = false;
144
+ SweeperP2pInstance.stopObserverSweeperDataByP2P();
146
145
  if (offSessionStatusChange.current) {
147
146
  offSessionStatusChange.current();
148
147
  offSessionStatusChange.current = null;
149
148
  }
150
- SweeperP2pInstance.stopObserverSweeperDataByP2P();
151
149
  };
152
150
  return {
153
151
  appendDownloadStreamDuringTask: SweeperP2pInstance.appendDownloadStreamDuringTask
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/robot-data-stream",
3
- "version": "0.0.10-beta-23",
3
+ "version": "0.0.10-beta-25",
4
4
  "description": "扫地机P2P数据流标准化组件",
5
5
  "main": "lib/index",
6
6
  "files": [