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

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