@dxos/network-manager 0.3.11-main.8feb6a5 → 0.3.11-main.927e4ba

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.
@@ -39,43 +39,12 @@ var TRANSPORT_STATS_INTERVAL = 5e3;
39
39
  var MAX_SIGNALLING_DELAY = 300;
40
40
  var ConnectionState;
41
41
  (function(ConnectionState5) {
42
- ConnectionState5[
43
- /**
44
- * Connection is created, but not yet passed through the connection limiter.
45
- */
46
- "CREATED"
47
- ] = "CREATED";
48
- ConnectionState5[
49
- /**
50
- * Initial state. Connection is registered but no attempt to connect to the remote peer has been performed.
51
- * Might mean that we are waiting for the answer signal from the remote peer.
52
- */
53
- "INITIAL"
54
- ] = "INITIAL";
55
- ConnectionState5[
56
- /**
57
- * Trying to establish connection.
58
- */
59
- "CONNECTING"
60
- ] = "CONNECTING";
61
- ConnectionState5[
62
- /**
63
- * Connection is established.
64
- */
65
- "CONNECTED"
66
- ] = "CONNECTED";
67
- ConnectionState5[
68
- /**
69
- * Connection is being closed.
70
- */
71
- "CLOSING"
72
- ] = "CLOSING";
73
- ConnectionState5[
74
- /**
75
- * Connection closed.
76
- */
77
- "CLOSED"
78
- ] = "CLOSED";
42
+ ConnectionState5["CREATED"] = "CREATED";
43
+ ConnectionState5["INITIAL"] = "INITIAL";
44
+ ConnectionState5["CONNECTING"] = "CONNECTING";
45
+ ConnectionState5["CONNECTED"] = "CONNECTED";
46
+ ConnectionState5["CLOSING"] = "CLOSING";
47
+ ConnectionState5["CLOSED"] = "CLOSED";
79
48
  ConnectionState5["ABORTING"] = "ABORTING";
80
49
  ConnectionState5["ABORTED"] = "ABORTED";
81
50
  })(ConnectionState || (ConnectionState = {}));
@@ -92,7 +61,7 @@ var Connection = class {
92
61
  this._callbacks = _callbacks;
93
62
  this._ctx = new Context();
94
63
  this.connectedTimeoutContext = new Context();
95
- this._state = ConnectionState.CREATED;
64
+ this._state = "CREATED";
96
65
  this._incomingSignalBuffer = [];
97
66
  this._outgoingSignalBuffer = [];
98
67
  this.stateChanged = new Event();
@@ -132,7 +101,7 @@ var Connection = class {
132
101
  * Create an underlying transport and prepares it for the connection.
133
102
  */
134
103
  async openConnection() {
135
- invariant(this._state === ConnectionState.INITIAL, "Invalid state.", {
104
+ invariant(this._state === "INITIAL", "Invalid state.", {
136
105
  F: __dxlog_file,
137
106
  L: 164,
138
107
  S: this,
@@ -161,7 +130,7 @@ var Connection = class {
161
130
  S: this,
162
131
  C: (f, a) => f(...a)
163
132
  });
164
- this._changeState(ConnectionState.CONNECTING);
133
+ this._changeState("CONNECTING");
165
134
  this._protocol.open(this.sessionId).catch((err) => {
166
135
  this.errors.raise(err);
167
136
  });
@@ -199,7 +168,7 @@ var Connection = class {
199
168
  sessionId: this.sessionId
200
169
  });
201
170
  this._transport.connected.once(async () => {
202
- this._changeState(ConnectionState.CONNECTED);
171
+ this._changeState("CONNECTED");
203
172
  await this.connectedTimeoutContext.dispose();
204
173
  this._callbacks?.onConnected?.();
205
174
  scheduleTaskInterval(this._ctx, async () => this._emitTransportStats(), TRANSPORT_STATS_INTERVAL);
@@ -252,7 +221,7 @@ var Connection = class {
252
221
  C: (f, a) => f(...a)
253
222
  });
254
223
  }
255
- if (this._state !== ConnectionState.CLOSED && this._state !== ConnectionState.CLOSING) {
224
+ if (this._state !== "CLOSED" && this._state !== "CLOSING") {
256
225
  await this.connectedTimeoutContext.dispose();
257
226
  this.errors.raise(err);
258
227
  }
@@ -279,7 +248,7 @@ var Connection = class {
279
248
  S: this,
280
249
  C: (f, a) => f(...a)
281
250
  });
282
- if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
251
+ if (this._state === "CLOSED" || this._state === "ABORTED") {
283
252
  log(`abort ignored: already ${this._state}`, this.closeReason, {
284
253
  F: __dxlog_file,
285
254
  L: 259,
@@ -289,7 +258,7 @@ var Connection = class {
289
258
  return;
290
259
  }
291
260
  await this.connectedTimeoutContext.dispose();
292
- this._changeState(ConnectionState.ABORTING);
261
+ this._changeState("ABORTING");
293
262
  if (!this.closeReason) {
294
263
  this.closeReason = err?.message;
295
264
  }
@@ -330,7 +299,7 @@ var Connection = class {
330
299
  C: (f, a) => f(...a)
331
300
  });
332
301
  }
333
- this._changeState(ConnectionState.ABORTED);
302
+ this._changeState("ABORTED");
334
303
  }
335
304
  async close(err) {
336
305
  if (!this.closeReason) {
@@ -338,11 +307,11 @@ var Connection = class {
338
307
  } else {
339
308
  this.closeReason += `; ${err?.message}`;
340
309
  }
341
- if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTING || this._state === ConnectionState.ABORTED) {
310
+ if (this._state === "CLOSED" || this._state === "ABORTING" || this._state === "ABORTED") {
342
311
  return;
343
312
  }
344
313
  const lastState = this._state;
345
- this._changeState(ConnectionState.CLOSING);
314
+ this._changeState("CLOSING");
346
315
  await this.connectedTimeoutContext.dispose();
347
316
  await this._ctx.dispose();
348
317
  log("closing...", {
@@ -353,7 +322,7 @@ var Connection = class {
353
322
  S: this,
354
323
  C: (f, a) => f(...a)
355
324
  });
356
- if (lastState === ConnectionState.CONNECTED) {
325
+ if (lastState === "CONNECTED") {
357
326
  try {
358
327
  await this._protocol.close();
359
328
  } catch (err2) {
@@ -410,7 +379,7 @@ var Connection = class {
410
379
  S: this,
411
380
  C: (f, a) => f(...a)
412
381
  });
413
- this._changeState(ConnectionState.CLOSED);
382
+ this._changeState("CLOSED");
414
383
  this._callbacks?.onClosed?.(err);
415
384
  }
416
385
  _sendSignal(signal) {
@@ -513,8 +482,8 @@ var Connection = class {
513
482
  continue;
514
483
  }
515
484
  if ([
516
- ConnectionState.CREATED,
517
- ConnectionState.INITIAL
485
+ "CREATED",
486
+ "INITIAL"
518
487
  ].includes(this.state)) {
519
488
  log("buffered signal", {
520
489
  peerId: this.ownId,
@@ -552,7 +521,7 @@ var Connection = class {
552
521
  }
553
522
  }
554
523
  initiate() {
555
- this._changeState(ConnectionState.INITIAL);
524
+ this._changeState("INITIAL");
556
525
  }
557
526
  _changeState(state) {
558
527
  log("stateChanged", {
@@ -2035,7 +2004,7 @@ var ConnectionLog = class {
2035
2004
  connectionInfo.closeReason = connection.closeReason;
2036
2005
  connectionInfo.lastUpdate = /* @__PURE__ */ new Date();
2037
2006
  connectionInfo.events.push({
2038
- type: EventType.CONNECTION_STATE_CHANGED,
2007
+ type: "CONNECTION_STATE_CHANGED",
2039
2008
  newState: state
2040
2009
  });
2041
2010
  if (state === ConnectionState.CONNECTED) {
@@ -2082,7 +2051,7 @@ import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/
2082
2051
  import { ComplexMap as ComplexMap6 } from "@dxos/util";
2083
2052
  var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
2084
2053
  var NetworkManager = class {
2085
- constructor({ transportFactory, signalManager, log: log1 }) {
2054
+ constructor({ transportFactory, signalManager, log: log15 }) {
2086
2055
  /**
2087
2056
  * @internal
2088
2057
  */
@@ -2103,7 +2072,7 @@ var NetworkManager = class {
2103
2072
  leave: (opts) => this._signalManager.leave(opts)
2104
2073
  };
2105
2074
  this._connectionLimiter = new ConnectionLimiter();
2106
- if (log1) {
2075
+ if (log15) {
2107
2076
  this._connectionLog = new ConnectionLog();
2108
2077
  }
2109
2078
  }
@@ -3977,4 +3946,4 @@ export {
3977
3946
  TcpTransport,
3978
3947
  createTeleportProtocolFactory
3979
3948
  };
3980
- //# sourceMappingURL=chunk-PA5ZI6XS.mjs.map
3949
+ //# sourceMappingURL=chunk-F6YEZ3WP.mjs.map