@dxos/network-manager 0.6.14-staging.54a8bab → 0.6.14-staging.8758a12

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.
Files changed (26) hide show
  1. package/dist/lib/browser/{chunk-UEVA7BFW.mjs → chunk-MAR4A5JK.mjs} +69 -50
  2. package/dist/lib/browser/{chunk-UEVA7BFW.mjs.map → chunk-MAR4A5JK.mjs.map} +3 -3
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/testing/index.mjs +1 -1
  6. package/dist/lib/node/{chunk-LK5D44SA.cjs → chunk-J5PWZKEH.cjs} +72 -53
  7. package/dist/lib/node/{chunk-LK5D44SA.cjs.map → chunk-J5PWZKEH.cjs.map} +3 -3
  8. package/dist/lib/node/index.cjs +23 -23
  9. package/dist/lib/node/index.cjs.map +1 -1
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/testing/index.cjs +14 -14
  12. package/dist/lib/node-esm/{chunk-Y5TD36KR.mjs → chunk-XHE7MQ7U.mjs} +69 -50
  13. package/dist/lib/node-esm/{chunk-Y5TD36KR.mjs.map → chunk-XHE7MQ7U.mjs.map} +3 -3
  14. package/dist/lib/node-esm/index.mjs +1 -1
  15. package/dist/lib/node-esm/meta.json +1 -1
  16. package/dist/lib/node-esm/testing/index.mjs +1 -1
  17. package/dist/types/src/transport/webrtc/rtc-peer-connection.d.ts +4 -0
  18. package/dist/types/src/transport/webrtc/rtc-peer-connection.d.ts.map +1 -1
  19. package/dist/types/src/transport/webrtc/rtc-transport-channel.d.ts.map +1 -1
  20. package/dist/types/src/transport/webrtc/rtc-transport-factory.d.ts.map +1 -1
  21. package/dist/types/src/transport/webrtc/rtc-transport-service.d.ts.map +1 -1
  22. package/package.json +18 -18
  23. package/src/transport/webrtc/rtc-peer-connection.ts +20 -6
  24. package/src/transport/webrtc/rtc-transport-channel.ts +7 -1
  25. package/src/transport/webrtc/rtc-transport-factory.ts +1 -0
  26. package/src/transport/webrtc/rtc-transport-service.ts +4 -2
@@ -3108,7 +3108,17 @@ var RtcTransportChannel = class extends Resource {
3108
3108
  }
3109
3109
  }).catch((err) => {
3110
3110
  if (this.isOpen) {
3111
- this.errors.raise(new ConnectivityError2(`Failed to create a channel: ${err?.message ?? "unknown reason."}`));
3111
+ const error = err instanceof Error ? err : new ConnectivityError2(`Failed to create a channel: ${JSON.stringify(err?.message)}`);
3112
+ this.errors.raise(error);
3113
+ } else {
3114
+ log12.verbose("connection establishment failed after transport was closed", {
3115
+ err
3116
+ }, {
3117
+ F: __dxlog_file13,
3118
+ L: 76,
3119
+ S: this,
3120
+ C: (f, a) => f(...a)
3121
+ });
3112
3122
  }
3113
3123
  }).finally(() => {
3114
3124
  this._isChannelCreationInProgress = false;
@@ -3123,7 +3133,7 @@ var RtcTransportChannel = class extends Resource {
3123
3133
  this.closed.emit();
3124
3134
  log12("closed", void 0, {
3125
3135
  F: __dxlog_file13,
3126
- L: 86,
3136
+ L: 92,
3127
3137
  S: this,
3128
3138
  C: (f, a) => f(...a)
3129
3139
  });
@@ -3136,7 +3146,7 @@ var RtcTransportChannel = class extends Resource {
3136
3146
  topic: this._options.topic
3137
3147
  }, {
3138
3148
  F: __dxlog_file13,
3139
- L: 93,
3149
+ L: 99,
3140
3150
  S: this,
3141
3151
  C: (f, a) => f(...a)
3142
3152
  });
@@ -3145,7 +3155,7 @@ var RtcTransportChannel = class extends Resource {
3145
3155
  }
3146
3156
  log12("onopen", void 0, {
3147
3157
  F: __dxlog_file13,
3148
- L: 98,
3158
+ L: 104,
3149
3159
  S: this,
3150
3160
  C: (f, a) => f(...a)
3151
3161
  });
@@ -3163,7 +3173,7 @@ var RtcTransportChannel = class extends Resource {
3163
3173
  onclose: async () => {
3164
3174
  log12("onclose", void 0, {
3165
3175
  F: __dxlog_file13,
3166
- L: 111,
3176
+ L: 117,
3167
3177
  S: this,
3168
3178
  C: (f, a) => f(...a)
3169
3179
  });
@@ -3173,7 +3183,7 @@ var RtcTransportChannel = class extends Resource {
3173
3183
  if (!this._stream) {
3174
3184
  log12.warn("ignoring message on a closed channel", void 0, {
3175
3185
  F: __dxlog_file13,
3176
- L: 117,
3186
+ L: 123,
3177
3187
  S: this,
3178
3188
  C: (f, a) => f(...a)
3179
3189
  });
@@ -3202,7 +3212,7 @@ var RtcTransportChannel = class extends Resource {
3202
3212
  if (!this._channel) {
3203
3213
  log12.warn("writing to a channel after a connection was closed", void 0, {
3204
3214
  F: __dxlog_file13,
3205
- L: 145,
3215
+ L: 151,
3206
3216
  S: this,
3207
3217
  C: (f, a) => f(...a)
3208
3218
  });
@@ -3225,7 +3235,7 @@ var RtcTransportChannel = class extends Resource {
3225
3235
  if (this._streamDataFlushedCallback !== null) {
3226
3236
  log12.error("consumer trying to write before we are ready for more data", void 0, {
3227
3237
  F: __dxlog_file13,
3228
- L: 166,
3238
+ L: 172,
3229
3239
  S: this,
3230
3240
  C: (f, a) => f(...a)
3231
3241
  });
@@ -3241,7 +3251,7 @@ var RtcTransportChannel = class extends Resource {
3241
3251
  } catch (error) {
3242
3252
  log12.catch(error, void 0, {
3243
3253
  F: __dxlog_file13,
3244
- L: 178,
3254
+ L: 184,
3245
3255
  S: this,
3246
3256
  C: (f, a) => f(...a)
3247
3257
  });
@@ -3292,6 +3302,7 @@ function _ts_decorate6(decorators, target, key, desc) {
3292
3302
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3293
3303
  }
3294
3304
  var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-peer-connection.ts";
3305
+ var isLegacyInteropEnabled = () => Boolean(globalThis?.DEVICE_INVITE_INTEROP);
3295
3306
  var RtcPeerConnection = class {
3296
3307
  constructor(_factory, _options) {
3297
3308
  this._factory = _factory;
@@ -3301,7 +3312,7 @@ var RtcPeerConnection = class {
3301
3312
  this._dataChannels = /* @__PURE__ */ new Map();
3302
3313
  this._readyForCandidates = new Trigger3();
3303
3314
  this._offerProcessingMutex = new Mutex2();
3304
- this._initiator = chooseInitiatorPeer(_options.ownPeerKey, _options.remotePeerKey) === _options.ownPeerKey;
3315
+ this._initiator = isLegacyInteropEnabled() ? Boolean(this._options.legacyInitiator) : chooseInitiatorPeer(_options.ownPeerKey, _options.remotePeerKey) === _options.ownPeerKey;
3305
3316
  }
3306
3317
  get transportChannelCount() {
3307
3318
  return this._transportChannels.size;
@@ -3310,30 +3321,31 @@ var RtcPeerConnection = class {
3310
3321
  return this._connection;
3311
3322
  }
3312
3323
  async createDataChannel(topic) {
3324
+ const channelKey = isLegacyInteropEnabled() ? "dxos.mesh.transport" : topic;
3313
3325
  const connection = await this._openConnection();
3314
- if (!this._transportChannels.has(topic)) {
3326
+ if (isLegacyInteropEnabled() ? this._transportChannels.size === 0 : !this._transportChannels.has(channelKey)) {
3315
3327
  if (!this._transportChannels.size) {
3316
3328
  this._lockAndCloseConnection();
3317
3329
  }
3318
3330
  throw new Error("Transport closed while connection was being open");
3319
3331
  }
3320
3332
  if (this._initiator) {
3321
- const channel = connection.createDataChannel(topic);
3322
- this._dataChannels.set(topic, channel);
3333
+ const channel = connection.createDataChannel(channelKey);
3334
+ this._dataChannels.set(channelKey, channel);
3323
3335
  return channel;
3324
3336
  } else {
3325
- const existingChannel = this._dataChannels.get(topic);
3337
+ const existingChannel = this._dataChannels.get(channelKey);
3326
3338
  if (existingChannel) {
3327
3339
  return existingChannel;
3328
3340
  }
3329
3341
  log13("waiting for initiator-peer to open a data channel", void 0, {
3330
3342
  F: __dxlog_file14,
3331
- L: 90,
3343
+ L: 104,
3332
3344
  S: this,
3333
3345
  C: (f, a) => f(...a)
3334
3346
  });
3335
3347
  return new Promise((resolve, reject) => {
3336
- this._channelCreatedCallbacks.set(topic, {
3348
+ this._channelCreatedCallbacks.set(channelKey, {
3337
3349
  resolve,
3338
3350
  reject
3339
3351
  });
@@ -3359,7 +3371,7 @@ var RtcPeerConnection = class {
3359
3371
  remotePeer: this._options.remotePeerKey
3360
3372
  }), {
3361
3373
  F: __dxlog_file14,
3362
- L: 115,
3374
+ L: 129,
3363
3375
  S: this,
3364
3376
  C: (f, a) => f(...a)
3365
3377
  });
@@ -3370,7 +3382,7 @@ var RtcPeerConnection = class {
3370
3382
  onnegotiationneeded: async () => {
3371
3383
  invariant12(this._initiator, void 0, {
3372
3384
  F: __dxlog_file14,
3373
- L: 130,
3385
+ L: 144,
3374
3386
  S: this,
3375
3387
  A: [
3376
3388
  "this._initiator",
@@ -3383,7 +3395,7 @@ var RtcPeerConnection = class {
3383
3395
  }
3384
3396
  log13("onnegotiationneeded", void 0, {
3385
3397
  F: __dxlog_file14,
3386
- L: 137,
3398
+ L: 151,
3387
3399
  S: this,
3388
3400
  C: (f, a) => f(...a)
3389
3401
  });
@@ -3407,7 +3419,7 @@ var RtcPeerConnection = class {
3407
3419
  candidate: event.candidate.candidate
3408
3420
  }, {
3409
3421
  F: __dxlog_file14,
3410
- L: 156,
3422
+ L: 170,
3411
3423
  S: this,
3412
3424
  C: (f, a) => f(...a)
3413
3425
  });
@@ -3415,7 +3427,7 @@ var RtcPeerConnection = class {
3415
3427
  } else {
3416
3428
  log13("onicecandidate gathering complete", void 0, {
3417
3429
  F: __dxlog_file14,
3418
- L: 159,
3430
+ L: 173,
3419
3431
  S: this,
3420
3432
  C: (f, a) => f(...a)
3421
3433
  });
@@ -3443,7 +3455,7 @@ var RtcPeerConnection = class {
3443
3455
  state: connection.iceConnectionState
3444
3456
  }, {
3445
3457
  F: __dxlog_file14,
3446
- L: 179,
3458
+ L: 193,
3447
3459
  S: this,
3448
3460
  C: (f, a) => f(...a)
3449
3461
  });
@@ -3465,7 +3477,7 @@ var RtcPeerConnection = class {
3465
3477
  state: connection.connectionState
3466
3478
  }, {
3467
3479
  F: __dxlog_file14,
3468
- L: 196,
3480
+ L: 210,
3469
3481
  S: this,
3470
3482
  C: (f, a) => f(...a)
3471
3483
  });
@@ -3478,7 +3490,7 @@ var RtcPeerConnection = class {
3478
3490
  state: connection.signalingState
3479
3491
  }, {
3480
3492
  F: __dxlog_file14,
3481
- L: 203,
3493
+ L: 217,
3482
3494
  S: this,
3483
3495
  C: (f, a) => f(...a)
3484
3496
  });
@@ -3488,7 +3500,7 @@ var RtcPeerConnection = class {
3488
3500
  ondatachannel: (event) => {
3489
3501
  invariant12(!this._initiator, "Initiator is expected to create data channels.", {
3490
3502
  F: __dxlog_file14,
3491
- L: 209,
3503
+ L: 223,
3492
3504
  S: this,
3493
3505
  A: [
3494
3506
  "!this._initiator",
@@ -3503,7 +3515,7 @@ var RtcPeerConnection = class {
3503
3515
  label: event.channel.label
3504
3516
  }, {
3505
3517
  F: __dxlog_file14,
3506
- L: 216,
3518
+ L: 230,
3507
3519
  S: this,
3508
3520
  C: (f, a) => f(...a)
3509
3521
  });
@@ -3531,7 +3543,7 @@ var RtcPeerConnection = class {
3531
3543
  error
3532
3544
  }, {
3533
3545
  F: __dxlog_file14,
3534
- L: 241,
3546
+ L: 255,
3535
3547
  S: this,
3536
3548
  C: (f, a) => f(...a)
3537
3549
  });
@@ -3552,7 +3564,7 @@ var RtcPeerConnection = class {
3552
3564
  reason: error.message
3553
3565
  }, {
3554
3566
  F: __dxlog_file14,
3555
- L: 255,
3567
+ L: 269,
3556
3568
  S: this,
3557
3569
  C: (f, a) => f(...a)
3558
3570
  });
@@ -3560,7 +3572,7 @@ var RtcPeerConnection = class {
3560
3572
  _lockAndCloseConnection() {
3561
3573
  invariant12(this._transportChannels.size === 0, void 0, {
3562
3574
  F: __dxlog_file14,
3563
- L: 260,
3575
+ L: 274,
3564
3576
  S: this,
3565
3577
  A: [
3566
3578
  "this._transportChannels.size === 0",
@@ -3571,7 +3583,7 @@ var RtcPeerConnection = class {
3571
3583
  this._safeCloseConnection();
3572
3584
  log13("connection closed", void 0, {
3573
3585
  F: __dxlog_file14,
3574
- L: 263,
3586
+ L: 277,
3575
3587
  S: this,
3576
3588
  C: (f, a) => f(...a)
3577
3589
  });
@@ -3584,7 +3596,7 @@ var RtcPeerConnection = class {
3584
3596
  type: signal.payload.data.type
3585
3597
  }, {
3586
3598
  F: __dxlog_file14,
3587
- L: 271,
3599
+ L: 285,
3588
3600
  S: this,
3589
3601
  C: (f, a) => f(...a)
3590
3602
  });
@@ -3651,7 +3663,7 @@ var RtcPeerConnection = class {
3651
3663
  type: data.type
3652
3664
  }, {
3653
3665
  F: __dxlog_file14,
3654
- L: 330,
3666
+ L: 344,
3655
3667
  S: this,
3656
3668
  C: (f, a) => f(...a)
3657
3669
  });
@@ -3664,7 +3676,7 @@ var RtcPeerConnection = class {
3664
3676
  candidate
3665
3677
  }, {
3666
3678
  F: __dxlog_file14,
3667
- L: 338,
3679
+ L: 352,
3668
3680
  S: this,
3669
3681
  C: (f, a) => f(...a)
3670
3682
  });
@@ -3673,7 +3685,7 @@ var RtcPeerConnection = class {
3673
3685
  } catch (err) {
3674
3686
  log13.catch(err, void 0, {
3675
3687
  F: __dxlog_file14,
3676
- L: 342,
3688
+ L: 356,
3677
3689
  S: this,
3678
3690
  C: (f, a) => f(...a)
3679
3691
  });
@@ -3683,7 +3695,7 @@ var RtcPeerConnection = class {
3683
3695
  if (connection === this._connection) {
3684
3696
  log13("ready to process ice candidates", void 0, {
3685
3697
  F: __dxlog_file14,
3686
- L: 348,
3698
+ L: 362,
3687
3699
  S: this,
3688
3700
  C: (f, a) => f(...a)
3689
3701
  });
@@ -3691,7 +3703,7 @@ var RtcPeerConnection = class {
3691
3703
  } else {
3692
3704
  log13.warn("session was negotiated after connection became inactive", void 0, {
3693
3705
  F: __dxlog_file14,
3694
- L: 351,
3706
+ L: 365,
3695
3707
  S: this,
3696
3708
  C: (f, a) => f(...a)
3697
3709
  });
@@ -3703,7 +3715,7 @@ var RtcPeerConnection = class {
3703
3715
  state: connection.connectionState
3704
3716
  }, {
3705
3717
  F: __dxlog_file14,
3706
- L: 356,
3718
+ L: 370,
3707
3719
  S: this,
3708
3720
  C: (f, a) => f(...a)
3709
3721
  });
@@ -3716,7 +3728,7 @@ var RtcPeerConnection = class {
3716
3728
  } catch (err) {
3717
3729
  log13.catch(err, void 0, {
3718
3730
  F: __dxlog_file14,
3719
- L: 368,
3731
+ L: 382,
3720
3732
  S: this,
3721
3733
  C: (f, a) => f(...a)
3722
3734
  });
@@ -3727,7 +3739,7 @@ var RtcPeerConnection = class {
3727
3739
  this._readyForCandidates.wake();
3728
3740
  void this._factory.onConnectionDestroyed().catch((err) => log13.catch(err, void 0, {
3729
3741
  F: __dxlog_file14,
3730
- L: 374,
3742
+ L: 388,
3731
3743
  S: this,
3732
3744
  C: (f, a) => f(...a)
3733
3745
  }));
@@ -3752,7 +3764,7 @@ var RtcPeerConnection = class {
3752
3764
  } catch (error) {
3753
3765
  log13.catch(error, void 0, {
3754
3766
  F: __dxlog_file14,
3755
- L: 390,
3767
+ L: 404,
3756
3768
  S: this,
3757
3769
  C: (f, a) => f(...a)
3758
3770
  });
@@ -3779,7 +3791,7 @@ var RtcPeerConnection = class {
3779
3791
  err
3780
3792
  }, {
3781
3793
  F: __dxlog_file14,
3782
- L: 411,
3794
+ L: 425,
3783
3795
  S: this,
3784
3796
  C: (f, a) => f(...a)
3785
3797
  });
@@ -3869,6 +3881,7 @@ var createRtcTransportFactory = (webrtcConfig, iceProvider) => {
3869
3881
  ownPeerKey: options.ownPeerKey,
3870
3882
  remotePeerKey: options.remotePeerKey,
3871
3883
  sendSignal: options.sendSignal,
3884
+ legacyInitiator: options.initiator,
3872
3885
  webrtcConfig,
3873
3886
  iceProvider
3874
3887
  });
@@ -4222,7 +4235,6 @@ var RtcTransportService = class {
4222
4235
  connectorStream: transportStream,
4223
4236
  writeProcessedCallbacks: []
4224
4237
  };
4225
- pushNewState(ConnectionState4.CONNECTING);
4226
4238
  transport.connected.on(() => pushNewState(ConnectionState4.CONNECTED));
4227
4239
  transport.errors.handle(async (err) => {
4228
4240
  pushNewState(ConnectionState4.CLOSED, err);
@@ -4241,13 +4253,20 @@ var RtcTransportService = class {
4241
4253
  close(err);
4242
4254
  });
4243
4255
  ready();
4256
+ log15("stream ready", void 0, {
4257
+ F: __dxlog_file16,
4258
+ L: 115,
4259
+ S: this,
4260
+ C: (f, a) => f(...a)
4261
+ });
4262
+ pushNewState(ConnectionState4.CONNECTING);
4244
4263
  });
4245
4264
  }
4246
4265
  async sendSignal({ proxyId, signal }) {
4247
4266
  const transport = this._openTransports.get(proxyId);
4248
4267
  invariant14(transport, void 0, {
4249
4268
  F: __dxlog_file16,
4250
- L: 121,
4269
+ L: 123,
4251
4270
  S: this,
4252
4271
  A: [
4253
4272
  "transport",
@@ -4260,7 +4279,7 @@ var RtcTransportService = class {
4260
4279
  const transport = this._openTransports.get(proxyId);
4261
4280
  invariant14(transport, void 0, {
4262
4281
  F: __dxlog_file16,
4263
- L: 128,
4282
+ L: 130,
4264
4283
  S: this,
4265
4284
  A: [
4266
4285
  "transport",
@@ -4275,7 +4294,7 @@ var RtcTransportService = class {
4275
4294
  const transport = this._openTransports.get(proxyId);
4276
4295
  invariant14(transport, void 0, {
4277
4296
  F: __dxlog_file16,
4278
- L: 135,
4297
+ L: 137,
4279
4298
  S: this,
4280
4299
  A: [
4281
4300
  "transport",
@@ -4290,7 +4309,7 @@ var RtcTransportService = class {
4290
4309
  const transport = this._openTransports.get(proxyId);
4291
4310
  invariant14(transport, void 0, {
4292
4311
  F: __dxlog_file16,
4293
- L: 142,
4312
+ L: 144,
4294
4313
  S: this,
4295
4314
  A: [
4296
4315
  "transport",
@@ -4324,7 +4343,7 @@ var RtcTransportService = class {
4324
4343
  message: error?.message
4325
4344
  }, {
4326
4345
  F: __dxlog_file16,
4327
- L: 172,
4346
+ L: 174,
4328
4347
  S: this,
4329
4348
  C: (f, a) => f(...a)
4330
4349
  });
@@ -4336,14 +4355,14 @@ var RtcTransportService = class {
4336
4355
  message: error?.message
4337
4356
  }, {
4338
4357
  F: __dxlog_file16,
4339
- L: 177,
4358
+ L: 179,
4340
4359
  S: this,
4341
4360
  C: (f, a) => f(...a)
4342
4361
  });
4343
4362
  }
4344
4363
  log15("closed", void 0, {
4345
4364
  F: __dxlog_file16,
4346
- L: 179,
4365
+ L: 181,
4347
4366
  S: this,
4348
4367
  C: (f, a) => f(...a)
4349
4368
  });
@@ -4410,4 +4429,4 @@ export {
4410
4429
  RtcTransportService,
4411
4430
  createTeleportProtocolFactory
4412
4431
  };
4413
- //# sourceMappingURL=chunk-UEVA7BFW.mjs.map
4432
+ //# sourceMappingURL=chunk-MAR4A5JK.mjs.map