@mega-yfue/eufy-sdk 0.6.0-beta.16 → 0.6.0-beta.18

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/dist/index.js CHANGED
@@ -8858,6 +8858,19 @@ function encodeSceneClean(sceneId) {
8858
8858
  const { method: method2, param } = ModeCtrlParamMethod.SCENE;
8859
8859
  return encodeModeCtrlParam(method2, param, (p) => p.int(SCENE_CLEAN_ID, sceneId));
8860
8860
  }
8861
+ var MAP_WATCH_FIELD = {
8862
+ /** The time the write is sent, in microseconds since the epoch. */
8863
+ TIME_US: 1,
8864
+ /** `1` on the write that asks for the map. */
8865
+ WATCHING: 2
8866
+ };
8867
+ function encodeMapWatch(nowMs, watching) {
8868
+ return rawDp((w) => {
8869
+ w.int(MAP_WATCH_FIELD.TIME_US, Math.floor(nowMs) * 1e3);
8870
+ if (watching)
8871
+ w.int(MAP_WATCH_FIELD.WATCHING, 1);
8872
+ });
8873
+ }
8861
8874
  function encodeAutoClean() {
8862
8875
  const { method: method2, param } = ModeCtrlParamMethod.AUTO;
8863
8876
  return encodeModeCtrlParam(method2, param, (p) => p.int(AUTO_CLEAN_TIMES, 1));
@@ -10727,6 +10740,20 @@ var VACUUM_CLEAN_MEMBERS = {
10727
10740
  * WATCHED: run on a T2351, it started the named scene.
10728
10741
  */
10729
10742
  startScene: method(({ sink }) => (sceneId) => sink.dispatch(aiotDp(VACUUM_DP.MODE_CTRL, encodeSceneClean(sceneId))), "Run a saved cleaning scene by its id (ModeCtrlRequest method 24 over DP 152).", isAiotVacuum),
10743
+ /**
10744
+ * Ask the robot to push its whole map — plane, room outline, room list and restricted zones — on the
10745
+ * map stream, as the vendor app does when its map view opens: two DP 153 writes, the time and then the
10746
+ * time with field 2 set (see {@link encodeMapWatch}).
10747
+ *
10748
+ * A docked robot sends no map of its own accord, so this is how its room ids and names become
10749
+ * readable without a clean. The map arrives on the stream like any other, not as this call's result.
10750
+ *
10751
+ * WATCHED: sent to a docked robot, it pushed its whole map within a second.
10752
+ */
10753
+ requestMap: method(({ sink }) => async () => {
10754
+ await sink.dispatch(aiotDp(VACUUM_DP.WORK_STATUS, encodeMapWatch(Date.now(), false)));
10755
+ await sink.dispatch(aiotDp(VACUUM_DP.WORK_STATUS, encodeMapWatch(Date.now(), true)));
10756
+ }, "Ask the robot to push its whole map on the map stream (two map-watch writes over DP 153).", isAiotVacuum),
10730
10757
  /**
10731
10758
  * State the cleaning settings a run uses — `CleanParamRequest.clean_param` over DP 154.
10732
10759
  *
@@ -18943,8 +18970,9 @@ var AccessUnitAssembler = class {
18943
18970
  this.onDropped?.({ carried: open2.carried, chunks: open2.chunks.length, count: this.droppedUnits });
18944
18971
  }
18945
18972
  };
18973
+ var SPLIT_UNIT_STAMP_SPREAD_MS = 100;
18946
18974
  function sameUnit(open2, next) {
18947
- return next.timestamp === open2.timestamp && next.sequence === open2.sequence;
18975
+ return next.sequence === open2.sequence && next.timestamp - open2.timestamp >>> 0 <= SPLIT_UNIT_STAMP_SPREAD_MS;
18948
18976
  }
18949
18977
  function beginsAccessUnit(body) {
18950
18978
  if (body.length < 4 || body[0] !== 0 || body[1] !== 0)
@@ -19495,6 +19523,7 @@ var LiveStream = class extends EventEmitter3 {
19495
19523
  }
19496
19524
  return void 0;
19497
19525
  }
19526
+ /** Emit one accepted media frame; an audio frame with no bytes past its header emits nothing. */
19498
19527
  onFrame(f) {
19499
19528
  const accepted = this.acceptsMedia(f);
19500
19529
  if (f.commandId === CMD_VIDEO_FRAME2 && !this.tracedFirstVideoCommand) {
@@ -19626,11 +19655,11 @@ var LiveStream = class extends EventEmitter3 {
19626
19655
  * The payload of an audio frame. On a stream with an ECIES decoder, a sealed frame ({@link isSealedAudio}) is
19627
19656
  * opened under the media key of the latest keyframe, and answers `undefined` when it does not open or arrives
19628
19657
  * before any keyframe gave a media key, since its bytes are ciphertext. Every other frame is the bytes after
19629
- * its header.
19658
+ * its header, empty for a frame that carries only its header.
19630
19659
  */
19631
19660
  audioPayload(frame) {
19632
19661
  if (!this.decoder || !isSealedAudio(frame)) {
19633
- return frame.length > AUDIO_HEADER_LEN ? frame.subarray(AUDIO_HEADER_LEN) : frame;
19662
+ return frame.subarray(AUDIO_HEADER_LEN);
19634
19663
  }
19635
19664
  const mediaKey = this.decoder.currentMediaKey;
19636
19665
  return mediaKey ? openSealedAudio(frame, mediaKey) : void 0;