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

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.
@@ -181,7 +181,7 @@ export declare class SweeperP2p extends P2pApi {
181
181
  /**
182
182
  * 停止文件下载
183
183
  */
184
- stopObserverSweeperDataByP2P: () => Promise<false | undefined>;
184
+ stopObserverSweeperDataByP2P: () => false | undefined;
185
185
  }
186
186
  declare const sweeperP2pInstance: SweeperP2p;
187
187
  export default sweeperP2pInstance;
@@ -630,8 +630,14 @@ export class SweeperP2p extends P2pApi {
630
630
  * 停止文件下载
631
631
  */
632
632
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, consistent-return
633
- stopObserverSweeperDataByP2P = async () => {
633
+ stopObserverSweeperDataByP2P = () => {
634
634
  try {
635
+ if (this.isConnected) {
636
+ logger('info', {
637
+ msg: `try disconnect device, devId: ${this.devId}`
638
+ }, this.onLogger);
639
+ this.disconnectDevice();
640
+ }
635
641
  this.removeP2pDownloadEvent();
636
642
  // 没有必要cancelDownloadTask,只需要调用断连
637
643
  // this.cancelDownloadTask();
@@ -639,10 +645,6 @@ export class SweeperP2p extends P2pApi {
639
645
  // 先销毁断开监听
640
646
  typeof this.offSessionStatusChange === 'function' && this.offSessionStatusChange();
641
647
  // 销毁初始化时,先进行断连操作
642
-
643
- if (this.isConnected) {
644
- this.disconnectDevice();
645
- }
646
648
  } catch (e) {
647
649
  logger('error', {
648
650
  msg: 'stopObserverSweeperDataByP2P occur error ==>',
package/lib/index.js CHANGED
@@ -96,10 +96,9 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
96
96
  }, []);
97
97
  usePageEvent('onUnload', () => {
98
98
  unmount();
99
- SweeperP2pInstance.deInitP2PSDK();
100
99
  ty.offAppHide(handleAppHide);
101
100
  ty.offAppShow(handleAppShow);
102
- ty.exitMiniProgram();
101
+ SweeperP2pInstance.deInitP2PSDK();
103
102
  });
104
103
 
105
104
  /**
@@ -139,7 +138,7 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
139
138
  /**
140
139
  * p2p断开
141
140
  */
142
- const unmount = async () => {
141
+ const unmount = () => {
143
142
  logger('info', {
144
143
  msg: 'hooks has been started unmount'
145
144
  }, onLogger);
@@ -1,5 +1,3 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- const _excluded = ["msg"];
3
1
  import mitt from 'mitt';
4
2
  import { floor, join, map } from 'lodash-es';
5
3
  import log4js from '@ray-js/log4js';
@@ -50,10 +48,9 @@ export const parseJSON = str => {
50
48
  };
51
49
  export const logger = (type, params, onLogger) => {
52
50
  const {
53
- msg
54
- } = params,
55
- others = _objectWithoutProperties(params, _excluded);
56
- log4js[type](msg, others);
51
+ msg
52
+ } = params;
53
+ log4js[type](msg);
57
54
  if (onLogger) {
58
55
  onLogger(type, msg);
59
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/robot-data-stream",
3
- "version": "0.0.10-beta-21",
3
+ "version": "0.0.10-beta-23",
4
4
  "description": "扫地机P2P数据流标准化组件",
5
5
  "main": "lib/index",
6
6
  "files": [