@dxos/network-manager 0.3.11-next.0fb359e → 0.3.11-next.e28df4f
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.
- package/dist/lib/browser/{chunk-XF474R3E.mjs → chunk-F6YEZ3WP.mjs} +34 -63
- package/dist/lib/browser/{chunk-XF474R3E.mjs.map → chunk-F6YEZ3WP.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/browser/testing/index.mjs.map +1 -1
- package/dist/lib/node/{chunk-Y2B5BDRH.cjs → chunk-RD2MHZQZ.cjs} +37 -66
- package/dist/lib/node/{chunk-Y2B5BDRH.cjs.map → chunk-RD2MHZQZ.cjs.map} +3 -3
- package/dist/lib/node/index.cjs +27 -27
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +18 -18
- package/dist/lib/node/testing/index.cjs.map +1 -1
- package/dist/types/src/transport/simplepeer-transport-proxy.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/transport/simplepeer-transport-proxy.ts +7 -4
|
@@ -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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
] = "
|
|
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 =
|
|
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 ===
|
|
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(
|
|
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(
|
|
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 !==
|
|
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 ===
|
|
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(
|
|
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(
|
|
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 ===
|
|
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(
|
|
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 ===
|
|
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(
|
|
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
|
-
|
|
517
|
-
|
|
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(
|
|
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:
|
|
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:
|
|
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 (
|
|
2075
|
+
if (log15) {
|
|
2107
2076
|
this._connectionLog = new ConnectionLog();
|
|
2108
2077
|
}
|
|
2109
2078
|
}
|
|
@@ -3313,11 +3282,13 @@ var SimplePeerTransportProxy = class {
|
|
|
3313
3282
|
this._params.bridgeService.sendData({
|
|
3314
3283
|
proxyId: this._proxyId,
|
|
3315
3284
|
payload: chunk
|
|
3285
|
+
}, {
|
|
3286
|
+
timeout: 1e4
|
|
3316
3287
|
}).then(() => {
|
|
3317
3288
|
if (performance.now() - then > RESP_MIN_THRESHOLD) {
|
|
3318
3289
|
log13("slow response, delaying callback", void 0, {
|
|
3319
3290
|
F: __dxlog_file14,
|
|
3320
|
-
L:
|
|
3291
|
+
L: 83,
|
|
3321
3292
|
S: this,
|
|
3322
3293
|
C: (f, a) => f(...a)
|
|
3323
3294
|
});
|
|
@@ -3333,7 +3304,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3333
3304
|
} else {
|
|
3334
3305
|
log13("timeout error, but still invoking callback", void 0, {
|
|
3335
3306
|
F: __dxlog_file14,
|
|
3336
|
-
L:
|
|
3307
|
+
L: 95,
|
|
3337
3308
|
S: this,
|
|
3338
3309
|
C: (f, a) => f(...a)
|
|
3339
3310
|
});
|
|
@@ -3342,7 +3313,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3342
3313
|
} else {
|
|
3343
3314
|
log13.catch(err, void 0, {
|
|
3344
3315
|
F: __dxlog_file14,
|
|
3345
|
-
L:
|
|
3316
|
+
L: 99,
|
|
3346
3317
|
S: this,
|
|
3347
3318
|
C: (f, a) => f(...a)
|
|
3348
3319
|
});
|
|
@@ -3355,7 +3326,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3355
3326
|
err
|
|
3356
3327
|
}, {
|
|
3357
3328
|
F: __dxlog_file14,
|
|
3358
|
-
L:
|
|
3329
|
+
L: 107,
|
|
3359
3330
|
S: this,
|
|
3360
3331
|
C: (f, a) => f(...a)
|
|
3361
3332
|
});
|
|
@@ -3363,7 +3334,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3363
3334
|
this._params.stream.pipe(proxyStream);
|
|
3364
3335
|
}, (error) => log13.catch(error, void 0, {
|
|
3365
3336
|
F: __dxlog_file14,
|
|
3366
|
-
L:
|
|
3337
|
+
L: 112,
|
|
3367
3338
|
S: this,
|
|
3368
3339
|
C: (f, a) => f(...a)
|
|
3369
3340
|
}));
|
|
@@ -3419,7 +3390,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3419
3390
|
} catch (err) {
|
|
3420
3391
|
log13.catch(err, void 0, {
|
|
3421
3392
|
F: __dxlog_file14,
|
|
3422
|
-
L:
|
|
3393
|
+
L: 171,
|
|
3423
3394
|
S: this,
|
|
3424
3395
|
C: (f, a) => f(...a)
|
|
3425
3396
|
});
|
|
@@ -3455,7 +3426,7 @@ var SimplePeerTransportProxyFactory = class {
|
|
|
3455
3426
|
createTransport(options) {
|
|
3456
3427
|
invariant13(this._bridgeService, "SimplePeerTransportProxyFactory is not ready to open connections", {
|
|
3457
3428
|
F: __dxlog_file14,
|
|
3458
|
-
L:
|
|
3429
|
+
L: 208,
|
|
3459
3430
|
S: this,
|
|
3460
3431
|
A: [
|
|
3461
3432
|
"this._bridgeService",
|
|
@@ -3975,4 +3946,4 @@ export {
|
|
|
3975
3946
|
TcpTransport,
|
|
3976
3947
|
createTeleportProtocolFactory
|
|
3977
3948
|
};
|
|
3978
|
-
//# sourceMappingURL=chunk-
|
|
3949
|
+
//# sourceMappingURL=chunk-F6YEZ3WP.mjs.map
|