@mega-yfue/eufy-sdk 0.5.0-beta.71 → 0.5.0-beta.72

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
@@ -24553,6 +24553,10 @@ var RtcSession = class extends EventEmitter11 {
24553
24553
  * `connect()` still waiting for the signalling auth is rejected and its timer stopped.
24554
24554
  */
24555
24555
  close() {
24556
+ this.shutdown();
24557
+ }
24558
+ /** {@link RtcSession.close}, with the failure that ended the session handed to `close` when one did. */
24559
+ shutdown(err) {
24556
24560
  if (this.closed)
24557
24561
  return;
24558
24562
  this.closed = true;
@@ -24565,7 +24569,7 @@ var RtcSession = class extends EventEmitter11 {
24565
24569
  this.signaling.close();
24566
24570
  this.peer.close();
24567
24571
  this.settleAuth(new Error("RTC session closed while waiting for signalling auth"));
24568
- this.announceClose();
24572
+ this.announceClose(err);
24569
24573
  }
24570
24574
  /**
24571
24575
  * Trickle one local candidate, or the empty end-of-candidates. The native peer can report one after the
@@ -24577,11 +24581,11 @@ var RtcSession = class extends EventEmitter11 {
24577
24581
  return;
24578
24582
  this.signaling.sendInfoCandidate(candidate);
24579
24583
  }
24580
- announceClose() {
24584
+ announceClose(err) {
24581
24585
  if (this.closeAnnounced)
24582
24586
  return;
24583
24587
  this.closeAnnounced = true;
24584
- this.emit("close");
24588
+ this.emit("close", err);
24585
24589
  }
24586
24590
  waitForAuth() {
24587
24591
  if (this.authOk)
@@ -24641,7 +24645,14 @@ var RtcSession = class extends EventEmitter11 {
24641
24645
  const status = payload.status;
24642
24646
  if (status === 100 && payload.turn) {
24643
24647
  this.turn = payload.turn;
24644
- await this.peer.init(payload.turn);
24648
+ try {
24649
+ await this.peer.init(payload.turn);
24650
+ } catch (e) {
24651
+ const err = e instanceof Error ? e : new Error(String(e));
24652
+ this.emit("error", err);
24653
+ this.shutdown(err);
24654
+ return;
24655
+ }
24645
24656
  return;
24646
24657
  }
24647
24658
  if (status === 200) {
@@ -24977,9 +24988,9 @@ var RtcCommandRouter = class {
24977
24988
  }
24978
24989
  /**
24979
24990
  * One bounded bring-up: the session is up when its command channel opens, and it fails, with the
24980
- * session closed and every listener gone, when `connect()` throws, the session closes first, or
24981
- * {@link CONNECT_TIMEOUT_MS} passes. A single promise, so an early failure cannot leave a second one
24982
- * rejecting unheard.
24991
+ * session closed and every listener gone, when `connect()` throws, the session closes first (rejecting
24992
+ * with the failure that closed it, when it carries one), or {@link CONNECT_TIMEOUT_MS} passes. A single
24993
+ * promise, so an early failure cannot leave a second one rejecting unheard.
24983
24994
  */
24984
24995
  bringUp(sn, session) {
24985
24996
  return new Promise((resolve, reject) => {
@@ -25003,7 +25014,7 @@ var RtcCommandRouter = class {
25003
25014
  }
25004
25015
  };
25005
25016
  const onConnected = () => finish();
25006
- const onClose = () => finish(new Error(`rtc: ${sn} session closed before the command channel opened`));
25017
+ const onClose = (err) => finish(err ?? new Error(`rtc: ${sn} session closed before the command channel opened`));
25007
25018
  const timer = setTimeout(() => finish(new Error(`rtc: ${sn} did not come up within ${CONNECT_TIMEOUT_MS2}ms`)), CONNECT_TIMEOUT_MS2);
25008
25019
  session.once("connected", onConnected);
25009
25020
  session.once("close", onClose);