@dxos/network-manager 0.1.58-main.6f6722d → 0.1.58-main.72c6b22
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-O2SMNRBC.mjs → chunk-XRCMC23N.mjs} +36 -27
- package/dist/lib/browser/chunk-XRCMC23N.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +155 -22
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/index.cjs +61 -52
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +219 -77
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/types/src/swarm/connection-limiter.d.ts +1 -1
- package/dist/types/src/swarm/connection-limiter.d.ts.map +1 -1
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/swarm/peer.d.ts +1 -1
- package/dist/types/src/swarm/peer.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/tests/tcp-transport.test.d.ts +2 -0
- package/dist/types/src/tests/tcp-transport.test.d.ts.map +1 -0
- package/dist/types/src/transport/simplepeer-transport.d.ts.map +1 -1
- package/dist/types/src/transport/tcp-transport.d.ts +23 -0
- package/dist/types/src/transport/tcp-transport.d.ts.map +1 -0
- package/dist/types/src/transport/transport.d.ts +2 -1
- package/dist/types/src/transport/transport.d.ts.map +1 -1
- package/package.json +17 -18
- package/src/swarm/connection-limiter.ts +2 -2
- package/src/swarm/connection.ts +5 -5
- package/src/swarm/peer.ts +1 -1
- package/src/testing/test-builder.ts +5 -1
- package/src/tests/tcp-transport.test.ts +67 -0
- package/src/transport/simplepeer-transport-proxy.ts +9 -9
- package/src/transport/simplepeer-transport.ts +4 -7
- package/src/transport/tcp-transport.ts +107 -0
- package/src/transport/transport.ts +1 -0
- package/dist/lib/browser/chunk-O2SMNRBC.mjs.map +0 -7
|
@@ -7,11 +7,10 @@ import {
|
|
|
7
7
|
import { DeferredTask, Event, sleep, synchronized } from "@dxos/async";
|
|
8
8
|
import { Context, cancelWithContext } from "@dxos/context";
|
|
9
9
|
import { ErrorStream } from "@dxos/debug";
|
|
10
|
-
import { CancelledError, ProtocolError, ConnectionResetError, ConnectivityError, UnknownProtocolError } from "@dxos/errors";
|
|
11
10
|
import { invariant } from "@dxos/invariant";
|
|
12
11
|
import { PublicKey } from "@dxos/keys";
|
|
13
12
|
import { log } from "@dxos/log";
|
|
14
|
-
import { trace } from "@dxos/protocols";
|
|
13
|
+
import { CancelledError, ProtocolError, ConnectionResetError, ConnectivityError, UnknownProtocolError, trace } from "@dxos/protocols";
|
|
15
14
|
function _ts_decorate(decorators, target, key, desc) {
|
|
16
15
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17
16
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -771,10 +770,10 @@ import { ComplexMap as ComplexMap2, isNotNullOrUndefined } from "@dxos/util";
|
|
|
771
770
|
// packages/core/mesh/network-manager/src/swarm/peer.ts
|
|
772
771
|
import { Event as Event2, scheduleTask, synchronized as synchronized2 } from "@dxos/async";
|
|
773
772
|
import { Context as Context3 } from "@dxos/context";
|
|
774
|
-
import { CancelledError as CancelledError2, SystemError, TimeoutError } from "@dxos/errors";
|
|
775
773
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
776
774
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
777
775
|
import { log as log3 } from "@dxos/log";
|
|
776
|
+
import { CancelledError as CancelledError2, SystemError, TimeoutError } from "@dxos/protocols";
|
|
778
777
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
779
778
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
780
779
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -1742,13 +1741,13 @@ var SwarmMapper = class {
|
|
|
1742
1741
|
// packages/core/mesh/network-manager/src/swarm/connection-limiter.ts
|
|
1743
1742
|
import { DeferredTask as DeferredTask2 } from "@dxos/async";
|
|
1744
1743
|
import { Context as Context5 } from "@dxos/context";
|
|
1745
|
-
import { CancelledError as CancelledError3 } from "@dxos/errors";
|
|
1746
1744
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1747
1745
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1748
1746
|
import { log as log6 } from "@dxos/log";
|
|
1747
|
+
import { CancelledError as CancelledError3 } from "@dxos/protocols";
|
|
1749
1748
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1750
1749
|
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
|
|
1751
|
-
var MAX_CONCURRENT_INITIATING_CONNECTIONS =
|
|
1750
|
+
var MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
|
|
1752
1751
|
var ConnectionLimiter = class {
|
|
1753
1752
|
constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
|
|
1754
1753
|
this._ctx = new Context5();
|
|
@@ -2575,6 +2574,7 @@ var TransportKind;
|
|
|
2575
2574
|
TransportKind2["LIBDATACHANNEL"] = "LIBDATACHANNEL";
|
|
2576
2575
|
TransportKind2["SIMPLE_PEER_PROXY"] = "SIMPLE_PEER_PROXY";
|
|
2577
2576
|
TransportKind2["MEMORY"] = "MEMORY";
|
|
2577
|
+
TransportKind2["TCP"] = "TCP";
|
|
2578
2578
|
})(TransportKind || (TransportKind = {}));
|
|
2579
2579
|
|
|
2580
2580
|
// packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts
|
|
@@ -2582,10 +2582,9 @@ import SimplePeerConstructor from "simple-peer";
|
|
|
2582
2582
|
import invariant11 from "tiny-invariant";
|
|
2583
2583
|
import { Event as Event8 } from "@dxos/async";
|
|
2584
2584
|
import { ErrorStream as ErrorStream4, raise as raise2 } from "@dxos/debug";
|
|
2585
|
-
import { ConnectionResetError as ConnectionResetError2, ConnectivityError as ConnectivityError2, ProtocolError as ProtocolError2, UnknownProtocolError as UnknownProtocolError2 } from "@dxos/errors";
|
|
2586
2585
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
2587
2586
|
import { log as log11 } from "@dxos/log";
|
|
2588
|
-
import { trace as trace4 } from "@dxos/protocols";
|
|
2587
|
+
import { ConnectionResetError as ConnectionResetError2, ConnectivityError as ConnectivityError2, ProtocolError as ProtocolError2, UnknownProtocolError as UnknownProtocolError2, trace as trace4 } from "@dxos/protocols";
|
|
2589
2588
|
|
|
2590
2589
|
// packages/core/mesh/network-manager/src/transport/webrtc.ts
|
|
2591
2590
|
var wrtc = null;
|
|
@@ -2608,13 +2607,13 @@ var SimplePeerTransport = class {
|
|
|
2608
2607
|
id: this._instanceId
|
|
2609
2608
|
}), {
|
|
2610
2609
|
F: __dxlog_file12,
|
|
2611
|
-
L:
|
|
2610
|
+
L: 40,
|
|
2612
2611
|
S: this,
|
|
2613
2612
|
C: (f, a) => f(...a)
|
|
2614
2613
|
});
|
|
2615
2614
|
log11("created connection", params, {
|
|
2616
2615
|
F: __dxlog_file12,
|
|
2617
|
-
L:
|
|
2616
|
+
L: 41,
|
|
2618
2617
|
S: this,
|
|
2619
2618
|
C: (f, a) => f(...a)
|
|
2620
2619
|
});
|
|
@@ -2627,7 +2626,7 @@ var SimplePeerTransport = class {
|
|
|
2627
2626
|
this._peer.on("signal", async (data) => {
|
|
2628
2627
|
log11("signal", data, {
|
|
2629
2628
|
F: __dxlog_file12,
|
|
2630
|
-
L:
|
|
2629
|
+
L: 50,
|
|
2631
2630
|
S: this,
|
|
2632
2631
|
C: (f, a) => f(...a)
|
|
2633
2632
|
});
|
|
@@ -2640,7 +2639,7 @@ var SimplePeerTransport = class {
|
|
|
2640
2639
|
this._peer.on("connect", () => {
|
|
2641
2640
|
log11("connected", void 0, {
|
|
2642
2641
|
F: __dxlog_file12,
|
|
2643
|
-
L:
|
|
2642
|
+
L: 55,
|
|
2644
2643
|
S: this,
|
|
2645
2644
|
C: (f, a) => f(...a)
|
|
2646
2645
|
});
|
|
@@ -2650,7 +2649,7 @@ var SimplePeerTransport = class {
|
|
|
2650
2649
|
this._peer.on("close", async () => {
|
|
2651
2650
|
log11("closed", void 0, {
|
|
2652
2651
|
F: __dxlog_file12,
|
|
2653
|
-
L:
|
|
2652
|
+
L: 61,
|
|
2654
2653
|
S: this,
|
|
2655
2654
|
C: (f, a) => f(...a)
|
|
2656
2655
|
});
|
|
@@ -2664,9 +2663,13 @@ var SimplePeerTransport = class {
|
|
|
2664
2663
|
} else {
|
|
2665
2664
|
this.errors.raise(new UnknownProtocolError2("unknown RTCError", err));
|
|
2666
2665
|
}
|
|
2667
|
-
} else if (err.name === "InvalidStateError") {
|
|
2668
|
-
this.errors.raise(new ConnectionResetError2("safari WebRTC error", err));
|
|
2669
2666
|
} else if ("code" in err) {
|
|
2667
|
+
log11.info("simple-peer error", err, {
|
|
2668
|
+
F: __dxlog_file12,
|
|
2669
|
+
L: 77,
|
|
2670
|
+
S: this,
|
|
2671
|
+
C: (f, a) => f(...a)
|
|
2672
|
+
});
|
|
2670
2673
|
switch (err.code) {
|
|
2671
2674
|
case "ERR_WEBRTC_SUPPORT":
|
|
2672
2675
|
this.errors.raise(new ProtocolError2("WebRTC not supported", err));
|
|
@@ -2685,17 +2688,23 @@ var SimplePeerTransport = class {
|
|
|
2685
2688
|
this.errors.raise(new Error("unknown simple-peer error"));
|
|
2686
2689
|
}
|
|
2687
2690
|
} else {
|
|
2691
|
+
log11.info("unknown peer connection error", err, {
|
|
2692
|
+
F: __dxlog_file12,
|
|
2693
|
+
L: 96,
|
|
2694
|
+
S: this,
|
|
2695
|
+
C: (f, a) => f(...a)
|
|
2696
|
+
});
|
|
2688
2697
|
this.errors.raise(err);
|
|
2689
2698
|
}
|
|
2690
2699
|
try {
|
|
2691
|
-
if (typeof this._peer?._pc
|
|
2700
|
+
if (typeof this._peer?._pc?.getStats === "function") {
|
|
2692
2701
|
this._peer._pc.getStats().then((stats) => {
|
|
2693
2702
|
log11.warn("report after webrtc error", {
|
|
2694
2703
|
config: this.params.webrtcConfig,
|
|
2695
2704
|
stats
|
|
2696
2705
|
}, {
|
|
2697
2706
|
F: __dxlog_file12,
|
|
2698
|
-
L:
|
|
2707
|
+
L: 104,
|
|
2699
2708
|
S: this,
|
|
2700
2709
|
C: (f, a) => f(...a)
|
|
2701
2710
|
});
|
|
@@ -2704,7 +2713,7 @@ var SimplePeerTransport = class {
|
|
|
2704
2713
|
} catch (err2) {
|
|
2705
2714
|
log11.catch(err2, void 0, {
|
|
2706
2715
|
F: __dxlog_file12,
|
|
2707
|
-
L:
|
|
2716
|
+
L: 111,
|
|
2708
2717
|
S: this,
|
|
2709
2718
|
C: (f, a) => f(...a)
|
|
2710
2719
|
});
|
|
@@ -2715,7 +2724,7 @@ var SimplePeerTransport = class {
|
|
|
2715
2724
|
id: this._instanceId
|
|
2716
2725
|
}), {
|
|
2717
2726
|
F: __dxlog_file12,
|
|
2718
|
-
L:
|
|
2727
|
+
L: 116,
|
|
2719
2728
|
S: this,
|
|
2720
2729
|
C: (f, a) => f(...a)
|
|
2721
2730
|
});
|
|
@@ -2723,7 +2732,7 @@ var SimplePeerTransport = class {
|
|
|
2723
2732
|
async destroy() {
|
|
2724
2733
|
log11("closing...", void 0, {
|
|
2725
2734
|
F: __dxlog_file12,
|
|
2726
|
-
L:
|
|
2735
|
+
L: 120,
|
|
2727
2736
|
S: this,
|
|
2728
2737
|
C: (f, a) => f(...a)
|
|
2729
2738
|
});
|
|
@@ -2733,7 +2742,7 @@ var SimplePeerTransport = class {
|
|
|
2733
2742
|
this.closed.emit();
|
|
2734
2743
|
log11("closed", void 0, {
|
|
2735
2744
|
F: __dxlog_file12,
|
|
2736
|
-
L:
|
|
2745
|
+
L: 125,
|
|
2737
2746
|
S: this,
|
|
2738
2747
|
C: (f, a) => f(...a)
|
|
2739
2748
|
});
|
|
@@ -2891,10 +2900,10 @@ import { Writable } from "@dxos/node-std/stream";
|
|
|
2891
2900
|
import { Event as Event9 } from "@dxos/async";
|
|
2892
2901
|
import { Context as Context6 } from "@dxos/context";
|
|
2893
2902
|
import { ErrorStream as ErrorStream5 } from "@dxos/debug";
|
|
2894
|
-
import { ConnectionResetError as ConnectionResetError3, TimeoutError as TimeoutError2, ProtocolError as ProtocolError3, ConnectivityError as ConnectivityError3, UnknownProtocolError as UnknownProtocolError3 } from "@dxos/errors";
|
|
2895
2903
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
2896
2904
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
2897
2905
|
import { log as log13 } from "@dxos/log";
|
|
2906
|
+
import { ConnectionResetError as ConnectionResetError3, TimeoutError as TimeoutError2, ProtocolError as ProtocolError3, ConnectivityError as ConnectivityError3, UnknownProtocolError as UnknownProtocolError3 } from "@dxos/protocols";
|
|
2898
2907
|
import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
2899
2908
|
import { arrayToBuffer } from "@dxos/util";
|
|
2900
2909
|
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts";
|
|
@@ -3045,15 +3054,15 @@ var SimplePeerTransportProxyFactory = class {
|
|
|
3045
3054
|
};
|
|
3046
3055
|
var decodeError = (err) => {
|
|
3047
3056
|
const message = typeof err === "string" ? err : err.message;
|
|
3048
|
-
if (message.includes("
|
|
3057
|
+
if (message.includes("CONNECTION_RESET")) {
|
|
3049
3058
|
return new ConnectionResetError3(message);
|
|
3050
|
-
} else if (message.includes("
|
|
3059
|
+
} else if (message.includes("TIMEOUT")) {
|
|
3051
3060
|
return new TimeoutError2(message);
|
|
3052
|
-
} else if (message.includes("
|
|
3061
|
+
} else if (message.includes("PROTOCOL_ERROR")) {
|
|
3053
3062
|
return new ProtocolError3(message);
|
|
3054
|
-
} else if (message.includes("
|
|
3063
|
+
} else if (message.includes("CONNECTIVITY_ERROR")) {
|
|
3055
3064
|
return new ConnectivityError3(message);
|
|
3056
|
-
} else if (message.includes("
|
|
3065
|
+
} else if (message.includes("UNKNOWN_PROTOCOL_ERROR")) {
|
|
3057
3066
|
return new UnknownProtocolError3(message);
|
|
3058
3067
|
} else {
|
|
3059
3068
|
return typeof err === "string" ? new Error(err) : err;
|
|
@@ -3446,4 +3455,4 @@ export {
|
|
|
3446
3455
|
createLibDataChannelTransportFactory,
|
|
3447
3456
|
createTeleportProtocolFactory
|
|
3448
3457
|
};
|
|
3449
|
-
//# sourceMappingURL=chunk-
|
|
3458
|
+
//# sourceMappingURL=chunk-XRCMC23N.mjs.map
|