@ray-js/robot-data-stream 0.0.10-beta-25 → 0.0.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.
@@ -73,8 +73,7 @@ export declare class SweeperP2p extends P2pApi {
73
73
  offDownLoadProgressUpdate: () => void;
74
74
  offTotalDownLoadProgressUpdate: () => void;
75
75
  onDefineStructuredMode: (isStructured: boolean) => void;
76
- mapUpdateCount: number;
77
- constructor(props: any);
76
+ constructor();
78
77
  private setStreamFilePath;
79
78
  private setDataFilePath;
80
79
  /**
@@ -153,16 +152,6 @@ export declare class SweeperP2p extends P2pApi {
153
152
  * @param downloadComplete
154
153
  */
155
154
  private p2pStreamPacketReceiveCallback;
156
- /**
157
- * 单文件下载完成回调
158
- * @param data
159
- */
160
- private fileDownloadProgressCallback;
161
- /**
162
- * 多文件下载进度监听
163
- * @param data
164
- */
165
- private fileTotalDownloadProgressCallback;
166
155
  /**
167
156
  * 从指定的文件路径获取文件
168
157
  * @param fileName
@@ -4,7 +4,7 @@ import "core-js/modules/esnext.iterator.map.js";
4
4
  /* eslint-disable no-shadow */
5
5
  import P2pApi from './p2pApi';
6
6
  import Base64 from 'base64-js';
7
- import { padStart, join, map } from 'lodash-es';
7
+ import { padStart, join, map, once } from 'lodash-es';
8
8
  import { logger } from '../utils';
9
9
  import { trace } from '../trace';
10
10
  /**
@@ -49,8 +49,8 @@ const FILE_NAME_MAP = {
49
49
  // 走p2p流传输(新) or 读取bin文件(旧)
50
50
  const shouldDownloadStream = Boolean(ty.p2p.downloadStream && ty.p2p.onStreamPacketReceive);
51
51
  export class SweeperP2p extends P2pApi {
52
- constructor(props) {
53
- super(props);
52
+ constructor() {
53
+ super();
54
54
  this.file = undefined;
55
55
  this.downloadType = 1;
56
56
  this.fileIndex = -1; // -1 表示所有文件下载完成
@@ -61,7 +61,6 @@ export class SweeperP2p extends P2pApi {
61
61
  this.cacheData = {};
62
62
  this.exitFiles = [];
63
63
  this.firstPackageTime = Date.now();
64
- this.mapUpdateCount = 0;
65
64
  this.packetTotalMap = new Map([['map.bin', -1], ['map_structured.bin', -1], ['cleanPath.bin', -1], ['ai.bin', -1], ['aiHD_XXXX_YYYY.bin', -1], ['map.bin.stream', -1], ['map_structured.bin.stream', -1], ['cleanPath.bin.stream', -1], ['ai.bin.stream', -1], ['aiHD_XXXX_YYYY.bin.stream', -1]]);
66
65
  this.packetSerialNumberCacheMap = new Map([['map.bin', -1], ['map_structured.bin', -1], ['cleanPath.bin', -1], ['ai.bin', -1], ['aiHD_XXXX_YYYY.bin', -1], ['map.bin.stream', -1], ['map_structured.bin.stream', -1], ['cleanPath.bin.stream', -1], ['ai.bin.stream', -1], ['aiHD_XXXX_YYYY.bin.stream', -1]]);
67
66
  this.packetDataCacheMap = new Map([['map.bin', new Map()], ['map_structured.bin', new Map()], ['cleanPath.bin', new Map()], ['ai.bin', new Map()], ['aiHD_XXXX_YYYY.bin', new Map()], ['map.bin.stream', new Map()], ['map_structured.bin.stream', new Map()], ['cleanPath.bin.stream', new Map()], ['ai.bin.stream', new Map()], ['aiHD_XXXX_YYYY.bin.stream', new Map()]]);
@@ -386,12 +385,11 @@ export class SweeperP2p extends P2pApi {
386
385
  }
387
386
  }
388
387
  };
389
- initStructuredMode = v => {
390
- if (this.mapUpdateCount > 1) return;
388
+ initStructuredMode = (() => once(isStructured => {
391
389
  if (this.onDefineStructuredMode) {
392
- this.onDefineStructuredMode(v);
390
+ this.onDefineStructuredMode(isStructured);
393
391
  }
394
- };
392
+ }))();
395
393
 
396
394
  /**
397
395
  * p2p数据流回调
@@ -471,7 +469,6 @@ export class SweeperP2p extends P2pApi {
471
469
  if (this.cacheData[type] !== hexValue) {
472
470
  if (type === 0 || type === 6) {
473
471
  this.onReceiveMapData(hexValue);
474
- this.mapUpdateCount += 1;
475
472
  }
476
473
  if (type === 1) {
477
474
  this.onReceivePathData(hexValue);
@@ -488,22 +485,6 @@ export class SweeperP2p extends P2pApi {
488
485
  }
489
486
  };
490
487
 
491
- /**
492
- * 单文件下载完成回调
493
- * @param data
494
- */
495
- fileDownloadProgressCallback = () => {
496
- // console.log('fileDownloadProgressCallback', data);
497
- };
498
-
499
- /**
500
- * 多文件下载进度监听
501
- * @param data
502
- */
503
- fileTotalDownloadProgressCallback = () => {
504
- // console.log('fileTotalDownloadProgressCallback', data );
505
- };
506
-
507
488
  /**
508
489
  * 从指定的文件路径获取文件
509
490
  * @param fileName
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/robot-data-stream",
3
- "version": "0.0.10-beta-25",
3
+ "version": "0.0.11",
4
4
  "description": "扫地机P2P数据流标准化组件",
5
5
  "main": "lib/index",
6
6
  "files": [