@dxos/network-manager 0.4.8-main.de30065 → 0.4.8-main.e23f3c5

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.
@@ -3478,7 +3478,10 @@ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-man
3478
3478
  var DATACHANNEL_LABEL = "dxos.mesh.transport";
3479
3479
  var MAX_BUFFERED_AMOUNT = 64 * 1024;
3480
3480
  var MAX_MESSAGE_SIZE = 64 * 1024;
3481
- var LibDataChannelTransport = class {
3481
+ var LibDataChannelTransport = class _LibDataChannelTransport {
3482
+ static {
3483
+ this._instanceCount = 0;
3484
+ }
3482
3485
  constructor(params) {
3483
3486
  this.params = params;
3484
3487
  this._closed = false;
@@ -3501,12 +3504,13 @@ var LibDataChannelTransport = class {
3501
3504
  };
3502
3505
  }
3503
3506
  const peer = new RTCPeerConnection(params.webrtcConfig);
3507
+ _LibDataChannelTransport._instanceCount++;
3504
3508
  peer.onicecandidateerror = (event) => {
3505
3509
  log14.error("peer.onicecandidateerror", {
3506
3510
  event
3507
3511
  }, {
3508
3512
  F: __dxlog_file15,
3509
- L: 61,
3513
+ L: 63,
3510
3514
  S: this,
3511
3515
  C: (f, a) => f(...a)
3512
3516
  });
@@ -3518,7 +3522,7 @@ var LibDataChannelTransport = class {
3518
3522
  transportConnectionState: this._connected
3519
3523
  }, {
3520
3524
  F: __dxlog_file15,
3521
- L: 65,
3525
+ L: 67,
3522
3526
  S: this,
3523
3527
  C: (f, a) => f(...a)
3524
3528
  });
@@ -3528,7 +3532,7 @@ var LibDataChannelTransport = class {
3528
3532
  event
3529
3533
  }, {
3530
3534
  F: __dxlog_file15,
3531
- L: 74,
3535
+ L: 76,
3532
3536
  S: this,
3533
3537
  C: (f, a) => f(...a)
3534
3538
  });
@@ -3552,7 +3556,7 @@ var LibDataChannelTransport = class {
3552
3556
  err
3553
3557
  }, {
3554
3558
  F: __dxlog_file15,
3555
- L: 91,
3559
+ L: 93,
3556
3560
  S: this,
3557
3561
  C: (f, a) => f(...a)
3558
3562
  });
@@ -3569,7 +3573,7 @@ var LibDataChannelTransport = class {
3569
3573
  peer
3570
3574
  }, {
3571
3575
  F: __dxlog_file15,
3572
- L: 104,
3576
+ L: 106,
3573
3577
  S: this,
3574
3578
  C: (f, a) => f(...a)
3575
3579
  });
@@ -3579,7 +3583,7 @@ var LibDataChannelTransport = class {
3579
3583
  offer
3580
3584
  }, {
3581
3585
  F: __dxlog_file15,
3582
- L: 107,
3586
+ L: 109,
3583
3587
  S: this,
3584
3588
  C: (f, a) => f(...a)
3585
3589
  });
@@ -3599,7 +3603,7 @@ var LibDataChannelTransport = class {
3599
3603
  this.handleChannel(peer.createDataChannel(DATACHANNEL_LABEL));
3600
3604
  log14.debug("created data channel", void 0, {
3601
3605
  F: __dxlog_file15,
3602
- L: 116,
3606
+ L: 118,
3603
3607
  S: this,
3604
3608
  C: (f, a) => f(...a)
3605
3609
  });
@@ -3612,7 +3616,7 @@ var LibDataChannelTransport = class {
3612
3616
  event
3613
3617
  }, {
3614
3618
  F: __dxlog_file15,
3615
- L: 122,
3619
+ L: 124,
3616
3620
  S: this,
3617
3621
  C: (f, a) => f(...a)
3618
3622
  });
@@ -3630,7 +3634,7 @@ var LibDataChannelTransport = class {
3630
3634
  this._channel.onopen = () => {
3631
3635
  log14.debug("dataChannel.onopen", void 0, {
3632
3636
  F: __dxlog_file15,
3633
- L: 138,
3637
+ L: 140,
3634
3638
  S: this,
3635
3639
  C: (f, a) => f(...a)
3636
3640
  });
@@ -3651,7 +3655,7 @@ var LibDataChannelTransport = class {
3651
3655
  if (this._writeCallback !== null) {
3652
3656
  log14.error("consumer trying to write before we're ready for more data", void 0, {
3653
3657
  F: __dxlog_file15,
3654
- L: 155,
3658
+ L: 157,
3655
3659
  S: this,
3656
3660
  C: (f, a) => f(...a)
3657
3661
  });
@@ -3676,7 +3680,7 @@ var LibDataChannelTransport = class {
3676
3680
  err
3677
3681
  }, {
3678
3682
  F: __dxlog_file15,
3679
- L: 175,
3683
+ L: 177,
3680
3684
  S: this,
3681
3685
  C: (f, a) => f(...a)
3682
3686
  });
@@ -3719,7 +3723,7 @@ var LibDataChannelTransport = class {
3719
3723
  peer
3720
3724
  }, {
3721
3725
  F: __dxlog_file15,
3722
- L: 216,
3726
+ L: 218,
3723
3727
  S: this,
3724
3728
  C: (f, a) => f(...a)
3725
3729
  });
@@ -3747,7 +3751,7 @@ var LibDataChannelTransport = class {
3747
3751
  err
3748
3752
  }, {
3749
3753
  F: __dxlog_file15,
3750
- L: 227,
3754
+ L: 229,
3751
3755
  S: this,
3752
3756
  C: (f, a) => f(...a)
3753
3757
  });
@@ -3767,7 +3771,7 @@ var LibDataChannelTransport = class {
3767
3771
  err
3768
3772
  }, {
3769
3773
  F: __dxlog_file15,
3770
- L: 238,
3774
+ L: 240,
3771
3775
  S: this,
3772
3776
  C: (f, a) => f(...a)
3773
3777
  });
@@ -3786,7 +3790,7 @@ var LibDataChannelTransport = class {
3786
3790
  signal
3787
3791
  }, {
3788
3792
  F: __dxlog_file15,
3789
- L: 249,
3793
+ L: 251,
3790
3794
  S: this,
3791
3795
  C: (f, a) => f(...a)
3792
3796
  });
@@ -3795,7 +3799,7 @@ var LibDataChannelTransport = class {
3795
3799
  }).catch((err) => {
3796
3800
  log14.catch(err, void 0, {
3797
3801
  F: __dxlog_file15,
3798
- L: 254,
3802
+ L: 256,
3799
3803
  S: this,
3800
3804
  C: (f, a) => f(...a)
3801
3805
  });
@@ -3851,9 +3855,11 @@ var LibDataChannelTransport = class {
3851
3855
  rawStats: stats.raw
3852
3856
  };
3853
3857
  }
3854
- // TODO(nf): add classmethod to call node-datachannel.cleanup() when all instances have been destroyed?
3855
3858
  async destroy() {
3856
3859
  await this._close();
3860
+ if (--_LibDataChannelTransport._instanceCount === 0) {
3861
+ (await importESM("node-datachannel")).cleanup();
3862
+ }
3857
3863
  }
3858
3864
  async _disconnectStreams() {
3859
3865
  this.params.stream.unpipe?.(this._stream)?.unpipe?.(this.params.stream);
@@ -3946,4 +3952,4 @@ export {
3946
3952
  TcpTransport,
3947
3953
  createTeleportProtocolFactory
3948
3954
  };
3949
- //# sourceMappingURL=chunk-F6YEZ3WP.mjs.map
3955
+ //# sourceMappingURL=chunk-KEN4UCZF.mjs.map