@dxos/network-manager 0.1.58-main.e460f33 → 0.1.58-main.e4cedde

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.
@@ -515,7 +515,7 @@ module.exports = __toCommonJS(testing_exports);
515
515
  var import_keys14 = require("@dxos/keys");
516
516
  var import_log17 = require("@dxos/log");
517
517
  var import_messaging2 = require("@dxos/messaging");
518
- var import_protocols9 = require("@dxos/protocols");
518
+ var import_protocols6 = require("@dxos/protocols");
519
519
  var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
520
520
  var import_rpc = require("@dxos/rpc");
521
521
  var import_util11 = require("@dxos/util");
@@ -526,7 +526,7 @@ var import_invariant6 = require("@dxos/invariant");
526
526
  var import_keys8 = require("@dxos/keys");
527
527
  var import_log7 = require("@dxos/log");
528
528
  var import_messaging = require("@dxos/messaging");
529
- var import_protocols6 = require("@dxos/protocols");
529
+ var import_protocols4 = require("@dxos/protocols");
530
530
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
531
531
  var import_util6 = require("@dxos/util");
532
532
 
@@ -540,6 +540,7 @@ var import_util5 = require("@dxos/util");
540
540
  var import_async = require("@dxos/async");
541
541
  var import_context = require("@dxos/context");
542
542
  var import_debug = require("@dxos/debug");
543
+ var import_errors = require("@dxos/errors");
543
544
  var import_invariant = require("@dxos/invariant");
544
545
  var import_keys = require("@dxos/keys");
545
546
  var import_log = require("@dxos/log");
@@ -687,7 +688,7 @@ var Connection = class {
687
688
  S: this,
688
689
  C: (f, a) => f(...a)
689
690
  });
690
- this.close(new import_protocols.ProtocolError("protocol stream closed")).catch((err) => this.errors.raise(err));
691
+ this.close(new import_errors.ProtocolError("protocol stream closed")).catch((err) => this.errors.raise(err));
691
692
  });
692
693
  (0, import_invariant.invariant)(!this._transport, void 0, {
693
694
  F: __dxlog_file,
@@ -729,7 +730,7 @@ var Connection = class {
729
730
  if (!this.closeReason) {
730
731
  this.closeReason = err?.message;
731
732
  }
732
- if (err instanceof import_protocols.ConnectionResetError) {
733
+ if (err instanceof import_errors.ConnectionResetError) {
733
734
  (0, import_log.log)("aborting due to transport ConnectionResetError", void 0, {
734
735
  F: __dxlog_file,
735
736
  L: 197,
@@ -737,7 +738,7 @@ var Connection = class {
737
738
  C: (f, a) => f(...a)
738
739
  });
739
740
  this.abort().catch((err2) => this.errors.raise(err2));
740
- } else if (err instanceof import_protocols.ConnectivityError) {
741
+ } else if (err instanceof import_errors.ConnectivityError) {
741
742
  (0, import_log.log)("aborting due to transport ConnectivityError", void 0, {
742
743
  F: __dxlog_file,
743
744
  L: 200,
@@ -745,7 +746,7 @@ var Connection = class {
745
746
  C: (f, a) => f(...a)
746
747
  });
747
748
  this.abort().catch((err2) => this.errors.raise(err2));
748
- } else if (err instanceof import_protocols.UnknownProtocolError) {
749
+ } else if (err instanceof import_errors.UnknownProtocolError) {
749
750
  (0, import_log.log)("unsure what to do for UnknownProtocolError", {
750
751
  err
751
752
  }, {
@@ -915,7 +916,7 @@ var Connection = class {
915
916
  }
916
917
  });
917
918
  } catch (err) {
918
- if (err instanceof import_protocols.CancelledError) {
919
+ if (err instanceof import_errors.CancelledError) {
919
920
  return;
920
921
  }
921
922
  import_log.log.warn("signal failed", {
@@ -1065,7 +1066,7 @@ var import_debug2 = require("@dxos/debug");
1065
1066
  var import_invariant4 = require("@dxos/invariant");
1066
1067
  var import_keys4 = require("@dxos/keys");
1067
1068
  var import_log4 = require("@dxos/log");
1068
- var import_protocols4 = require("@dxos/protocols");
1069
+ var import_protocols3 = require("@dxos/protocols");
1069
1070
  var import_util2 = require("@dxos/util");
1070
1071
 
1071
1072
  // packages/core/mesh/network-manager/src/signal/swarm-messenger.ts
@@ -1303,10 +1304,10 @@ var SwarmMessenger = class {
1303
1304
  // packages/core/mesh/network-manager/src/swarm/peer.ts
1304
1305
  var import_async2 = require("@dxos/async");
1305
1306
  var import_context3 = require("@dxos/context");
1307
+ var import_errors2 = require("@dxos/errors");
1306
1308
  var import_invariant3 = require("@dxos/invariant");
1307
1309
  var import_keys3 = require("@dxos/keys");
1308
1310
  var import_log3 = require("@dxos/log");
1309
- var import_protocols3 = require("@dxos/protocols");
1310
1311
  function _ts_decorate2(decorators, target, key, desc) {
1311
1312
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1312
1313
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -1318,7 +1319,7 @@ function _ts_decorate2(decorators, target, key, desc) {
1318
1319
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1319
1320
  }
1320
1321
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
1321
- var ConnectionDisplacedError = class extends import_protocols3.SystemError {
1322
+ var ConnectionDisplacedError = class extends import_errors2.SystemError {
1322
1323
  constructor() {
1323
1324
  super("Connection displaced by remote initiator.");
1324
1325
  }
@@ -1386,7 +1387,7 @@ var Peer = class {
1386
1387
  connection.initiate();
1387
1388
  await connection.openConnection();
1388
1389
  } catch (err) {
1389
- if (!(err instanceof import_protocols3.CancelledError)) {
1390
+ if (!(err instanceof import_errors2.CancelledError)) {
1390
1391
  import_log3.log.warn("connection error", {
1391
1392
  topic: this.topic,
1392
1393
  peerId: this.localPeerId,
@@ -1496,7 +1497,7 @@ var Peer = class {
1496
1497
  S: this,
1497
1498
  C: (f, a) => f(...a)
1498
1499
  });
1499
- if (err instanceof import_protocols3.TimeoutError) {
1500
+ if (err instanceof import_errors2.TimeoutError) {
1500
1501
  await connection.abort(err);
1501
1502
  }
1502
1503
  await this.closeConnection(err);
@@ -1756,7 +1757,7 @@ var Swarm = class {
1756
1757
  this.disconnected = new import_async3.Event();
1757
1758
  this.connected = new import_async3.Event();
1758
1759
  this.errors = new import_debug2.ErrorStream();
1759
- import_log4.log.trace("dxos.mesh.swarm.constructor", import_protocols4.trace.begin({
1760
+ import_log4.log.trace("dxos.mesh.swarm.constructor", import_protocols3.trace.begin({
1760
1761
  id: this._instanceId,
1761
1762
  data: {
1762
1763
  topic: this._topic.toHex(),
@@ -1783,7 +1784,7 @@ var Swarm = class {
1783
1784
  onOffer: async (msg) => await this.onOffer(msg),
1784
1785
  topic: this._topic
1785
1786
  });
1786
- import_log4.log.trace("dxos.mesh.swarm.constructor", import_protocols4.trace.end({
1787
+ import_log4.log.trace("dxos.mesh.swarm.constructor", import_protocols3.trace.end({
1787
1788
  id: this._instanceId
1788
1789
  }), {
1789
1790
  F: __dxlog_file4,
@@ -2274,13 +2275,13 @@ var SwarmMapper = class {
2274
2275
  // packages/core/mesh/network-manager/src/swarm/connection-limiter.ts
2275
2276
  var import_async5 = require("@dxos/async");
2276
2277
  var import_context5 = require("@dxos/context");
2278
+ var import_errors3 = require("@dxos/errors");
2277
2279
  var import_invariant5 = require("@dxos/invariant");
2278
2280
  var import_keys6 = require("@dxos/keys");
2279
2281
  var import_log6 = require("@dxos/log");
2280
- var import_protocols5 = require("@dxos/protocols");
2281
2282
  var import_util4 = require("@dxos/util");
2282
2283
  var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
2283
- var MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
2284
+ var MAX_CONCURRENT_INITIATING_CONNECTIONS = 10;
2284
2285
  var ConnectionLimiter = class {
2285
2286
  constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
2286
2287
  this._ctx = new import_context5.Context();
@@ -2347,7 +2348,7 @@ var ConnectionLimiter = class {
2347
2348
  if (!this._waitingPromises.has(sessionId)) {
2348
2349
  return;
2349
2350
  }
2350
- this._waitingPromises.get(sessionId).reject(new import_protocols5.CancelledError());
2351
+ this._waitingPromises.get(sessionId).reject(new import_errors3.CancelledError());
2351
2352
  this._waitingPromises.delete(sessionId);
2352
2353
  this.resolveWaitingPromises.schedule();
2353
2354
  }
@@ -2465,7 +2466,7 @@ var NetworkManager = class {
2465
2466
  return this._swarms.get(topic);
2466
2467
  }
2467
2468
  async open() {
2468
- import_log7.log.trace("dxos.mesh.network-manager.open", import_protocols6.trace.begin({
2469
+ import_log7.log.trace("dxos.mesh.network-manager.open", import_protocols4.trace.begin({
2469
2470
  id: this._instanceId
2470
2471
  }), {
2471
2472
  F: __dxlog_file7,
@@ -2475,7 +2476,7 @@ var NetworkManager = class {
2475
2476
  });
2476
2477
  await this._messenger.open();
2477
2478
  await this._signalManager.open();
2478
- import_log7.log.trace("dxos.mesh.network-manager.open", import_protocols6.trace.end({
2479
+ import_log7.log.trace("dxos.mesh.network-manager.open", import_protocols4.trace.end({
2479
2480
  id: this._instanceId
2480
2481
  }), {
2481
2482
  F: __dxlog_file7,
@@ -2905,9 +2906,10 @@ var import_simple_peer = __toESM(require("simple-peer"));
2905
2906
  var import_tiny_invariant = __toESM(require("tiny-invariant"));
2906
2907
  var import_async9 = require("@dxos/async");
2907
2908
  var import_debug5 = require("@dxos/debug");
2909
+ var import_errors4 = require("@dxos/errors");
2908
2910
  var import_keys10 = require("@dxos/keys");
2909
2911
  var import_log11 = require("@dxos/log");
2910
- var import_protocols7 = require("@dxos/protocols");
2912
+ var import_protocols5 = require("@dxos/protocols");
2911
2913
 
2912
2914
  // packages/core/mesh/network-manager/src/transport/webrtc.ts
2913
2915
  var wrtc = null;
@@ -2926,17 +2928,17 @@ var SimplePeerTransport = class {
2926
2928
  this.connected = new import_async9.Event();
2927
2929
  this.errors = new import_debug5.ErrorStream();
2928
2930
  this._instanceId = import_keys10.PublicKey.random().toHex();
2929
- import_log11.log.trace("dxos.mesh.webrtc-transport.constructor", import_protocols7.trace.begin({
2931
+ import_log11.log.trace("dxos.mesh.webrtc-transport.constructor", import_protocols5.trace.begin({
2930
2932
  id: this._instanceId
2931
2933
  }), {
2932
2934
  F: __dxlog_file10,
2933
- L: 40,
2935
+ L: 41,
2934
2936
  S: this,
2935
2937
  C: (f, a) => f(...a)
2936
2938
  });
2937
2939
  (0, import_log11.log)("created connection", params, {
2938
2940
  F: __dxlog_file10,
2939
- L: 41,
2941
+ L: 42,
2940
2942
  S: this,
2941
2943
  C: (f, a) => f(...a)
2942
2944
  });
@@ -2949,7 +2951,7 @@ var SimplePeerTransport = class {
2949
2951
  this._peer.on("signal", async (data) => {
2950
2952
  (0, import_log11.log)("signal", data, {
2951
2953
  F: __dxlog_file10,
2952
- L: 50,
2954
+ L: 51,
2953
2955
  S: this,
2954
2956
  C: (f, a) => f(...a)
2955
2957
  });
@@ -2962,7 +2964,7 @@ var SimplePeerTransport = class {
2962
2964
  this._peer.on("connect", () => {
2963
2965
  (0, import_log11.log)("connected", void 0, {
2964
2966
  F: __dxlog_file10,
2965
- L: 55,
2967
+ L: 56,
2966
2968
  S: this,
2967
2969
  C: (f, a) => f(...a)
2968
2970
  });
@@ -2972,7 +2974,7 @@ var SimplePeerTransport = class {
2972
2974
  this._peer.on("close", async () => {
2973
2975
  (0, import_log11.log)("closed", void 0, {
2974
2976
  F: __dxlog_file10,
2975
- L: 61,
2977
+ L: 62,
2976
2978
  S: this,
2977
2979
  C: (f, a) => f(...a)
2978
2980
  });
@@ -2982,27 +2984,27 @@ var SimplePeerTransport = class {
2982
2984
  this._peer.on("error", async (err) => {
2983
2985
  if (typeof RTCError !== "undefined" && err instanceof RTCError) {
2984
2986
  if (err.errorDetail === "sctp-failure") {
2985
- this.errors.raise(new import_protocols7.ConnectionResetError("sctp-failure from RTCError", err));
2987
+ this.errors.raise(new import_errors4.ConnectionResetError("sctp-failure from RTCError", err));
2986
2988
  } else {
2987
- this.errors.raise(new import_protocols7.UnknownProtocolError("unknown RTCError", err));
2989
+ this.errors.raise(new import_errors4.UnknownProtocolError("unknown RTCError", err));
2988
2990
  }
2989
2991
  } else if (err.name === "InvalidStateError") {
2990
- this.errors.raise(new import_protocols7.ConnectionResetError("safari WebRTC error", err));
2992
+ this.errors.raise(new import_errors4.ConnectionResetError("safari WebRTC error", err));
2991
2993
  } else if ("code" in err) {
2992
2994
  switch (err.code) {
2993
2995
  case "ERR_WEBRTC_SUPPORT":
2994
- this.errors.raise(new import_protocols7.ProtocolError("WebRTC not supported", err));
2996
+ this.errors.raise(new import_errors4.ProtocolError("WebRTC not supported", err));
2995
2997
  case "ERR_ICE_CONNECTION_FAILURE":
2996
2998
  case "ERR_DATA_CHANNEL":
2997
2999
  case "ERR_CONNECTION_FAILURE":
2998
3000
  case "ERR_SIGNALING":
2999
- this.errors.raise(new import_protocols7.ConnectivityError("unknown communication failure", err));
3001
+ this.errors.raise(new import_errors4.ConnectivityError("unknown communication failure", err));
3000
3002
  case "ERR_CREATE_OFFER":
3001
3003
  case "ERR_CREATE_ANSWER":
3002
3004
  case "ERR_SET_LOCAL_DESCRIPTION":
3003
3005
  case "ERR_SET_REMOTE_DESCRIPTION":
3004
3006
  case "ERR_ADD_ICE_CANDIDATE":
3005
- this.errors.raise(new import_protocols7.UnknownProtocolError("unknown simple-peer library failure", err));
3007
+ this.errors.raise(new import_errors4.UnknownProtocolError("unknown simple-peer library failure", err));
3006
3008
  default:
3007
3009
  this.errors.raise(new Error("unknown simple-peer error"));
3008
3010
  }
@@ -3017,7 +3019,7 @@ var SimplePeerTransport = class {
3017
3019
  stats
3018
3020
  }, {
3019
3021
  F: __dxlog_file10,
3020
- L: 106,
3022
+ L: 107,
3021
3023
  S: this,
3022
3024
  C: (f, a) => f(...a)
3023
3025
  });
@@ -3026,18 +3028,18 @@ var SimplePeerTransport = class {
3026
3028
  } catch (err2) {
3027
3029
  import_log11.log.catch(err2, void 0, {
3028
3030
  F: __dxlog_file10,
3029
- L: 113,
3031
+ L: 114,
3030
3032
  S: this,
3031
3033
  C: (f, a) => f(...a)
3032
3034
  });
3033
3035
  }
3034
3036
  await this.destroy();
3035
3037
  });
3036
- import_log11.log.trace("dxos.mesh.webrtc-transport.constructor", import_protocols7.trace.end({
3038
+ import_log11.log.trace("dxos.mesh.webrtc-transport.constructor", import_protocols5.trace.end({
3037
3039
  id: this._instanceId
3038
3040
  }), {
3039
3041
  F: __dxlog_file10,
3040
- L: 118,
3042
+ L: 119,
3041
3043
  S: this,
3042
3044
  C: (f, a) => f(...a)
3043
3045
  });
@@ -3045,7 +3047,7 @@ var SimplePeerTransport = class {
3045
3047
  async destroy() {
3046
3048
  (0, import_log11.log)("closing...", void 0, {
3047
3049
  F: __dxlog_file10,
3048
- L: 122,
3050
+ L: 123,
3049
3051
  S: this,
3050
3052
  C: (f, a) => f(...a)
3051
3053
  });
@@ -3055,7 +3057,7 @@ var SimplePeerTransport = class {
3055
3057
  this.closed.emit();
3056
3058
  (0, import_log11.log)("closed", void 0, {
3057
3059
  F: __dxlog_file10,
3058
- L: 127,
3060
+ L: 128,
3059
3061
  S: this,
3060
3062
  C: (f, a) => f(...a)
3061
3063
  });
@@ -3213,10 +3215,10 @@ var import_node_stream3 = require("node:stream");
3213
3215
  var import_async10 = require("@dxos/async");
3214
3216
  var import_context6 = require("@dxos/context");
3215
3217
  var import_debug6 = require("@dxos/debug");
3218
+ var import_errors5 = require("@dxos/errors");
3216
3219
  var import_invariant12 = require("@dxos/invariant");
3217
3220
  var import_keys12 = require("@dxos/keys");
3218
3221
  var import_log13 = require("@dxos/log");
3219
- var import_protocols8 = require("@dxos/protocols");
3220
3222
  var import_bridge2 = require("@dxos/protocols/proto/dxos/mesh/bridge");
3221
3223
  var import_util9 = require("@dxos/util");
3222
3224
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts";
@@ -3368,15 +3370,15 @@ var SimplePeerTransportProxyFactory = class {
3368
3370
  var decodeError = (err) => {
3369
3371
  const message = typeof err === "string" ? err : err.message;
3370
3372
  if (message.includes("ConnectionResetError")) {
3371
- return new import_protocols8.ConnectionResetError(message);
3373
+ return new import_errors5.ConnectionResetError(message);
3372
3374
  } else if (message.includes("TimeoutError")) {
3373
- return new import_protocols8.TimeoutError(message);
3375
+ return new import_errors5.TimeoutError(message);
3374
3376
  } else if (message.includes("ProtocolError")) {
3375
- return new import_protocols8.ProtocolError(message);
3377
+ return new import_errors5.ProtocolError(message);
3376
3378
  } else if (message.includes("ConnectivityError")) {
3377
- return new import_protocols8.ConnectivityError(message);
3379
+ return new import_errors5.ConnectivityError(message);
3378
3380
  } else if (message.includes("UnknownProtocolError")) {
3379
- return new import_protocols8.UnknownProtocolError(message);
3381
+ return new import_errors5.UnknownProtocolError(message);
3380
3382
  } else {
3381
3383
  return typeof err === "string" ? new Error(err) : err;
3382
3384
  }
@@ -4033,7 +4035,7 @@ var TestPeer = class {
4033
4035
  this._proxy = (0, import_rpc.createProtoRpcPeer)({
4034
4036
  port: proxyPort,
4035
4037
  requested: {
4036
- BridgeService: import_protocols9.schema.getService("dxos.mesh.bridge.BridgeService")
4038
+ BridgeService: import_protocols6.schema.getService("dxos.mesh.bridge.BridgeService")
4037
4039
  },
4038
4040
  noHandshake: true,
4039
4041
  encodingOptions: {
@@ -4043,7 +4045,7 @@ var TestPeer = class {
4043
4045
  this._service = (0, import_rpc.createProtoRpcPeer)({
4044
4046
  port: servicePort,
4045
4047
  exposed: {
4046
- BridgeService: import_protocols9.schema.getService("dxos.mesh.bridge.BridgeService")
4048
+ BridgeService: import_protocols6.schema.getService("dxos.mesh.bridge.BridgeService")
4047
4049
  },
4048
4050
  handlers: {
4049
4051
  BridgeService: new SimplePeerTransportService()