@dxos/network-manager 0.2.4-main.c33ce2c → 0.2.4-main.e68de56

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.
@@ -2617,6 +2617,7 @@ var SimplePeerTransport = class {
2617
2617
  constructor(params) {
2618
2618
  this.params = params;
2619
2619
  this._closed = false;
2620
+ this._piped = false;
2620
2621
  this.closed = new Event8();
2621
2622
  this.connected = new Event8();
2622
2623
  this.errors = new ErrorStream4();
@@ -2625,13 +2626,13 @@ var SimplePeerTransport = class {
2625
2626
  id: this._instanceId
2626
2627
  }), {
2627
2628
  F: __dxlog_file12,
2628
- L: 40,
2629
+ L: 41,
2629
2630
  S: this,
2630
2631
  C: (f, a) => f(...a)
2631
2632
  });
2632
2633
  log11("created connection", params, {
2633
2634
  F: __dxlog_file12,
2634
- L: 41,
2635
+ L: 42,
2635
2636
  S: this,
2636
2637
  C: (f, a) => f(...a)
2637
2638
  });
@@ -2644,7 +2645,7 @@ var SimplePeerTransport = class {
2644
2645
  this._peer.on("signal", async (data) => {
2645
2646
  log11("signal", data, {
2646
2647
  F: __dxlog_file12,
2647
- L: 50,
2648
+ L: 51,
2648
2649
  S: this,
2649
2650
  C: (f, a) => f(...a)
2650
2651
  });
@@ -2657,22 +2658,22 @@ var SimplePeerTransport = class {
2657
2658
  this._peer.on("connect", () => {
2658
2659
  log11("connected", void 0, {
2659
2660
  F: __dxlog_file12,
2660
- L: 55,
2661
+ L: 56,
2661
2662
  S: this,
2662
2663
  C: (f, a) => f(...a)
2663
2664
  });
2664
2665
  this.params.stream.pipe(this._peer).pipe(this.params.stream);
2666
+ this._piped = true;
2665
2667
  this.connected.emit();
2666
2668
  });
2667
2669
  this._peer.on("close", async () => {
2668
2670
  log11("closed", void 0, {
2669
2671
  F: __dxlog_file12,
2670
- L: 61,
2672
+ L: 63,
2671
2673
  S: this,
2672
2674
  C: (f, a) => f(...a)
2673
2675
  });
2674
- await this._disconnectStreams();
2675
- this.closed.emit();
2676
+ await this.destroy();
2676
2677
  });
2677
2678
  this._peer.on("error", async (err) => {
2678
2679
  if (typeof RTCError !== "undefined" && err instanceof RTCError) {
@@ -2684,7 +2685,7 @@ var SimplePeerTransport = class {
2684
2685
  } else if ("code" in err) {
2685
2686
  log11.info("simple-peer error", err, {
2686
2687
  F: __dxlog_file12,
2687
- L: 77,
2688
+ L: 78,
2688
2689
  S: this,
2689
2690
  C: (f, a) => f(...a)
2690
2691
  });
@@ -2712,7 +2713,7 @@ var SimplePeerTransport = class {
2712
2713
  } else {
2713
2714
  log11.info("unknown peer connection error", err, {
2714
2715
  F: __dxlog_file12,
2715
- L: 101,
2716
+ L: 102,
2716
2717
  S: this,
2717
2718
  C: (f, a) => f(...a)
2718
2719
  });
@@ -2726,7 +2727,7 @@ var SimplePeerTransport = class {
2726
2727
  stats
2727
2728
  }, {
2728
2729
  F: __dxlog_file12,
2729
- L: 109,
2730
+ L: 110,
2730
2731
  S: this,
2731
2732
  C: (f, a) => f(...a)
2732
2733
  });
@@ -2735,7 +2736,7 @@ var SimplePeerTransport = class {
2735
2736
  } catch (err2) {
2736
2737
  log11.catch(err2, void 0, {
2737
2738
  F: __dxlog_file12,
2738
- L: 116,
2739
+ L: 117,
2739
2740
  S: this,
2740
2741
  C: (f, a) => f(...a)
2741
2742
  });
@@ -2746,7 +2747,7 @@ var SimplePeerTransport = class {
2746
2747
  id: this._instanceId
2747
2748
  }), {
2748
2749
  F: __dxlog_file12,
2749
- L: 121,
2750
+ L: 122,
2750
2751
  S: this,
2751
2752
  C: (f, a) => f(...a)
2752
2753
  });
@@ -2754,17 +2755,20 @@ var SimplePeerTransport = class {
2754
2755
  async destroy() {
2755
2756
  log11("closing...", void 0, {
2756
2757
  F: __dxlog_file12,
2757
- L: 125,
2758
+ L: 126,
2758
2759
  S: this,
2759
2760
  C: (f, a) => f(...a)
2760
2761
  });
2762
+ if (this._closed) {
2763
+ return;
2764
+ }
2761
2765
  this._closed = true;
2762
- await this._disconnectStreams();
2766
+ this._disconnectStreams();
2763
2767
  this._peer.destroy();
2764
2768
  this.closed.emit();
2765
2769
  log11("closed", void 0, {
2766
2770
  F: __dxlog_file12,
2767
- L: 130,
2771
+ L: 134,
2768
2772
  S: this,
2769
2773
  C: (f, a) => f(...a)
2770
2774
  });
@@ -2776,8 +2780,10 @@ var SimplePeerTransport = class {
2776
2780
  invariant11(signal.payload.data, "Signal message must contain signal data.");
2777
2781
  this._peer.signal(signal.payload.data);
2778
2782
  }
2779
- async _disconnectStreams() {
2780
- this.params.stream.unpipe?.(this._peer)?.unpipe?.(this.params.stream);
2783
+ _disconnectStreams() {
2784
+ if (this._piped) {
2785
+ this.params.stream.unpipe?.(this._peer)?.unpipe?.(this.params.stream);
2786
+ }
2781
2787
  }
2782
2788
  };
2783
2789
  var createSimplePeerTransportFactory = (webrtcConfig) => ({
@@ -3508,4 +3514,4 @@ export {
3508
3514
  TcpTransport,
3509
3515
  createTeleportProtocolFactory
3510
3516
  };
3511
- //# sourceMappingURL=chunk-3KLH55NB.mjs.map
3517
+ //# sourceMappingURL=chunk-TRMX3E42.mjs.map