@dxos/network-manager 0.1.57 → 0.1.58-main.0e9c99e
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-UKMTAO4L.mjs → chunk-CNQ55TFQ.mjs} +197 -112
- package/dist/lib/browser/chunk-CNQ55TFQ.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 +207 -122
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +363 -145
- 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 +3 -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-proxy.d.ts.map +1 -1
- 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 +53 -27
- package/src/swarm/peer.ts +4 -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 +28 -2
- package/src/transport/simplepeer-transport.ts +39 -3
- package/src/transport/tcp-transport.ts +107 -0
- package/src/transport/transport.ts +1 -0
- package/dist/lib/browser/chunk-UKMTAO4L.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -545,7 +545,6 @@ var import_util5 = require("@dxos/util");
|
|
|
545
545
|
var import_async = require("@dxos/async");
|
|
546
546
|
var import_context = require("@dxos/context");
|
|
547
547
|
var import_debug = require("@dxos/debug");
|
|
548
|
-
var import_errors = require("@dxos/errors");
|
|
549
548
|
var import_invariant = require("@dxos/invariant");
|
|
550
549
|
var import_keys = require("@dxos/keys");
|
|
551
550
|
var import_log = require("@dxos/log");
|
|
@@ -560,7 +559,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
560
559
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
561
560
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
562
561
|
}
|
|
563
|
-
var __dxlog_file = "/
|
|
562
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
|
|
564
563
|
var STARTING_SIGNALLING_DELAY = 10;
|
|
565
564
|
var MAX_SIGNALLING_DELAY = 300;
|
|
566
565
|
var ConnectionState;
|
|
@@ -602,6 +601,8 @@ var ConnectionState;
|
|
|
602
601
|
*/
|
|
603
602
|
"CLOSED"
|
|
604
603
|
] = "CLOSED";
|
|
604
|
+
ConnectionState5["ABORTING"] = "ABORTING";
|
|
605
|
+
ConnectionState5["ABORTED"] = "ABORTED";
|
|
605
606
|
})(ConnectionState || (ConnectionState = {}));
|
|
606
607
|
var Connection = class {
|
|
607
608
|
constructor(topic, ownId, remoteId, sessionId, initiator, _signalMessaging, _protocol, _transportFactory, _callbacks) {
|
|
@@ -633,7 +634,7 @@ var Connection = class {
|
|
|
633
634
|
initiator: this.initiator
|
|
634
635
|
}, {
|
|
635
636
|
F: __dxlog_file,
|
|
636
|
-
L:
|
|
637
|
+
L: 123,
|
|
637
638
|
S: this,
|
|
638
639
|
C: (f, a) => f(...a)
|
|
639
640
|
});
|
|
@@ -653,7 +654,7 @@ var Connection = class {
|
|
|
653
654
|
async openConnection() {
|
|
654
655
|
(0, import_invariant.invariant)(this._state === ConnectionState.INITIAL, "Invalid state.", {
|
|
655
656
|
F: __dxlog_file,
|
|
656
|
-
L:
|
|
657
|
+
L: 148,
|
|
657
658
|
S: this,
|
|
658
659
|
A: [
|
|
659
660
|
"this._state === ConnectionState.INITIAL",
|
|
@@ -664,7 +665,7 @@ var Connection = class {
|
|
|
664
665
|
id: this._instanceId
|
|
665
666
|
}), {
|
|
666
667
|
F: __dxlog_file,
|
|
667
|
-
L:
|
|
668
|
+
L: 149,
|
|
668
669
|
S: this,
|
|
669
670
|
C: (f, a) => f(...a)
|
|
670
671
|
});
|
|
@@ -676,7 +677,7 @@ var Connection = class {
|
|
|
676
677
|
initiator: this.initiator
|
|
677
678
|
}, {
|
|
678
679
|
F: __dxlog_file,
|
|
679
|
-
L:
|
|
680
|
+
L: 150,
|
|
680
681
|
S: this,
|
|
681
682
|
C: (f, a) => f(...a)
|
|
682
683
|
});
|
|
@@ -687,15 +688,15 @@ var Connection = class {
|
|
|
687
688
|
this._protocol.stream.on("close", () => {
|
|
688
689
|
(0, import_log.log)("protocol stream closed", void 0, {
|
|
689
690
|
F: __dxlog_file,
|
|
690
|
-
L:
|
|
691
|
+
L: 167,
|
|
691
692
|
S: this,
|
|
692
693
|
C: (f, a) => f(...a)
|
|
693
694
|
});
|
|
694
|
-
this.close().catch((err) => this.errors.raise(err));
|
|
695
|
+
this.close(new import_protocols.ProtocolError("protocol stream closed")).catch((err) => this.errors.raise(err));
|
|
695
696
|
});
|
|
696
697
|
(0, import_invariant.invariant)(!this._transport, void 0, {
|
|
697
698
|
F: __dxlog_file,
|
|
698
|
-
L:
|
|
699
|
+
L: 171,
|
|
699
700
|
S: this,
|
|
700
701
|
A: [
|
|
701
702
|
"!this._transport",
|
|
@@ -715,7 +716,7 @@ var Connection = class {
|
|
|
715
716
|
this._transport = void 0;
|
|
716
717
|
(0, import_log.log)("abort triggered by transport close", void 0, {
|
|
717
718
|
F: __dxlog_file,
|
|
718
|
-
L:
|
|
719
|
+
L: 185,
|
|
719
720
|
S: this,
|
|
720
721
|
C: (f, a) => f(...a)
|
|
721
722
|
});
|
|
@@ -726,21 +727,38 @@ var Connection = class {
|
|
|
726
727
|
err
|
|
727
728
|
}, {
|
|
728
729
|
F: __dxlog_file,
|
|
729
|
-
L:
|
|
730
|
+
L: 190,
|
|
730
731
|
S: this,
|
|
731
732
|
C: (f, a) => f(...a)
|
|
732
733
|
});
|
|
733
734
|
if (!this.closeReason) {
|
|
734
735
|
this.closeReason = err?.message;
|
|
735
736
|
}
|
|
736
|
-
if (err
|
|
737
|
-
(0, import_log.log)("aborting due to transport
|
|
737
|
+
if (err instanceof import_protocols.ConnectionResetError) {
|
|
738
|
+
(0, import_log.log)("aborting due to transport ConnectionResetError", void 0, {
|
|
739
|
+
F: __dxlog_file,
|
|
740
|
+
L: 197,
|
|
741
|
+
S: this,
|
|
742
|
+
C: (f, a) => f(...a)
|
|
743
|
+
});
|
|
744
|
+
this.abort().catch((err2) => this.errors.raise(err2));
|
|
745
|
+
} else if (err instanceof import_protocols.ConnectivityError) {
|
|
746
|
+
(0, import_log.log)("aborting due to transport ConnectivityError", void 0, {
|
|
738
747
|
F: __dxlog_file,
|
|
739
|
-
L:
|
|
748
|
+
L: 200,
|
|
740
749
|
S: this,
|
|
741
750
|
C: (f, a) => f(...a)
|
|
742
751
|
});
|
|
743
752
|
this.abort().catch((err2) => this.errors.raise(err2));
|
|
753
|
+
} else if (err instanceof import_protocols.UnknownProtocolError) {
|
|
754
|
+
(0, import_log.log)("unsure what to do for UnknownProtocolError", {
|
|
755
|
+
err
|
|
756
|
+
}, {
|
|
757
|
+
F: __dxlog_file,
|
|
758
|
+
L: 203,
|
|
759
|
+
S: this,
|
|
760
|
+
C: (f, a) => f(...a)
|
|
761
|
+
});
|
|
744
762
|
}
|
|
745
763
|
if (this._state !== ConnectionState.CLOSED && this._state !== ConnectionState.CLOSING) {
|
|
746
764
|
this.errors.raise(err);
|
|
@@ -754,7 +772,7 @@ var Connection = class {
|
|
|
754
772
|
id: this._instanceId
|
|
755
773
|
}), {
|
|
756
774
|
F: __dxlog_file,
|
|
757
|
-
L:
|
|
775
|
+
L: 218,
|
|
758
776
|
S: this,
|
|
759
777
|
C: (f, a) => f(...a)
|
|
760
778
|
});
|
|
@@ -764,30 +782,30 @@ var Connection = class {
|
|
|
764
782
|
err
|
|
765
783
|
}, {
|
|
766
784
|
F: __dxlog_file,
|
|
767
|
-
L:
|
|
785
|
+
L: 224,
|
|
768
786
|
S: this,
|
|
769
787
|
C: (f, a) => f(...a)
|
|
770
788
|
});
|
|
771
|
-
if (
|
|
772
|
-
this.closeReason
|
|
773
|
-
}
|
|
774
|
-
if (this._state === ConnectionState.CLOSED) {
|
|
775
|
-
(0, import_log.log)("abort ignored: already closed", this.closeReason, {
|
|
789
|
+
if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
|
|
790
|
+
(0, import_log.log)(`abort ignored: already ${this._state}`, this.closeReason, {
|
|
776
791
|
F: __dxlog_file,
|
|
777
|
-
L:
|
|
792
|
+
L: 226,
|
|
778
793
|
S: this,
|
|
779
794
|
C: (f, a) => f(...a)
|
|
780
795
|
});
|
|
781
796
|
return;
|
|
782
797
|
}
|
|
783
|
-
this._changeState(ConnectionState.
|
|
798
|
+
this._changeState(ConnectionState.ABORTING);
|
|
799
|
+
if (!this.closeReason) {
|
|
800
|
+
this.closeReason = err?.message;
|
|
801
|
+
}
|
|
784
802
|
await this._ctx.dispose();
|
|
785
803
|
try {
|
|
786
804
|
(0, import_log.log)("aborting protocol... ", {
|
|
787
805
|
proto: this._protocol
|
|
788
806
|
}, {
|
|
789
807
|
F: __dxlog_file,
|
|
790
|
-
L:
|
|
808
|
+
L: 239,
|
|
791
809
|
S: this,
|
|
792
810
|
C: (f, a) => f(...a)
|
|
793
811
|
});
|
|
@@ -795,7 +813,7 @@ var Connection = class {
|
|
|
795
813
|
} catch (err2) {
|
|
796
814
|
import_log.log.catch(err2, void 0, {
|
|
797
815
|
F: __dxlog_file,
|
|
798
|
-
L:
|
|
816
|
+
L: 242,
|
|
799
817
|
S: this,
|
|
800
818
|
C: (f, a) => f(...a)
|
|
801
819
|
});
|
|
@@ -805,56 +823,68 @@ var Connection = class {
|
|
|
805
823
|
} catch (err2) {
|
|
806
824
|
import_log.log.catch(err2, void 0, {
|
|
807
825
|
F: __dxlog_file,
|
|
808
|
-
L:
|
|
826
|
+
L: 249,
|
|
809
827
|
S: this,
|
|
810
828
|
C: (f, a) => f(...a)
|
|
811
829
|
});
|
|
812
830
|
}
|
|
813
|
-
|
|
814
|
-
|
|
831
|
+
try {
|
|
832
|
+
this._callbacks?.onClosed?.(err);
|
|
833
|
+
} catch (err2) {
|
|
834
|
+
import_log.log.catch(err2, void 0, {
|
|
835
|
+
F: __dxlog_file,
|
|
836
|
+
L: 255,
|
|
837
|
+
S: this,
|
|
838
|
+
C: (f, a) => f(...a)
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
this._changeState(ConnectionState.ABORTED);
|
|
815
842
|
}
|
|
816
843
|
async close(err) {
|
|
817
844
|
if (!this.closeReason) {
|
|
818
845
|
this.closeReason = err?.message;
|
|
819
846
|
}
|
|
820
|
-
if (this._state === ConnectionState.CLOSED) {
|
|
847
|
+
if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTING || this._state === ConnectionState.ABORTED) {
|
|
821
848
|
return;
|
|
822
849
|
}
|
|
850
|
+
const lastState = this._state;
|
|
823
851
|
this._changeState(ConnectionState.CLOSING);
|
|
824
852
|
await this._ctx.dispose();
|
|
825
853
|
(0, import_log.log)("closing...", {
|
|
826
854
|
peerId: this.ownId
|
|
827
855
|
}, {
|
|
828
856
|
F: __dxlog_file,
|
|
829
|
-
L:
|
|
857
|
+
L: 277,
|
|
830
858
|
S: this,
|
|
831
859
|
C: (f, a) => f(...a)
|
|
832
860
|
});
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
861
|
+
if (lastState === ConnectionState.CONNECTED) {
|
|
862
|
+
try {
|
|
863
|
+
await this._protocol.close();
|
|
864
|
+
} catch (err2) {
|
|
865
|
+
import_log.log.catch(err2, void 0, {
|
|
866
|
+
F: __dxlog_file,
|
|
867
|
+
L: 284,
|
|
868
|
+
S: this,
|
|
869
|
+
C: (f, a) => f(...a)
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
try {
|
|
873
|
+
await this._transport?.destroy();
|
|
874
|
+
} catch (err2) {
|
|
875
|
+
import_log.log.catch(err2, void 0, {
|
|
876
|
+
F: __dxlog_file,
|
|
877
|
+
L: 291,
|
|
878
|
+
S: this,
|
|
879
|
+
C: (f, a) => f(...a)
|
|
880
|
+
});
|
|
881
|
+
}
|
|
852
882
|
}
|
|
853
883
|
(0, import_log.log)("closed", {
|
|
854
884
|
peerId: this.ownId
|
|
855
885
|
}, {
|
|
856
886
|
F: __dxlog_file,
|
|
857
|
-
L:
|
|
887
|
+
L: 295,
|
|
858
888
|
S: this,
|
|
859
889
|
C: (f, a) => f(...a)
|
|
860
890
|
});
|
|
@@ -890,14 +920,14 @@ var Connection = class {
|
|
|
890
920
|
}
|
|
891
921
|
});
|
|
892
922
|
} catch (err) {
|
|
893
|
-
if (err instanceof
|
|
923
|
+
if (err instanceof import_protocols.CancelledError) {
|
|
894
924
|
return;
|
|
895
925
|
}
|
|
896
926
|
import_log.log.warn("signal failed", {
|
|
897
927
|
err
|
|
898
928
|
}, {
|
|
899
929
|
F: __dxlog_file,
|
|
900
|
-
L:
|
|
930
|
+
L: 332,
|
|
901
931
|
S: this,
|
|
902
932
|
C: (f, a) => f(...a)
|
|
903
933
|
});
|
|
@@ -910,7 +940,7 @@ var Connection = class {
|
|
|
910
940
|
async signal(msg) {
|
|
911
941
|
(0, import_invariant.invariant)(msg.sessionId, void 0, {
|
|
912
942
|
F: __dxlog_file,
|
|
913
|
-
L:
|
|
943
|
+
L: 341,
|
|
914
944
|
S: this,
|
|
915
945
|
A: [
|
|
916
946
|
"msg.sessionId",
|
|
@@ -920,7 +950,7 @@ var Connection = class {
|
|
|
920
950
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
921
951
|
(0, import_log.log)("dropping signal for incorrect session id", void 0, {
|
|
922
952
|
F: __dxlog_file,
|
|
923
|
-
L:
|
|
953
|
+
L: 343,
|
|
924
954
|
S: this,
|
|
925
955
|
C: (f, a) => f(...a)
|
|
926
956
|
});
|
|
@@ -928,7 +958,7 @@ var Connection = class {
|
|
|
928
958
|
}
|
|
929
959
|
(0, import_invariant.invariant)(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
930
960
|
F: __dxlog_file,
|
|
931
|
-
L:
|
|
961
|
+
L: 346,
|
|
932
962
|
S: this,
|
|
933
963
|
A: [
|
|
934
964
|
"msg.data.signal || msg.data.signalBatch",
|
|
@@ -937,7 +967,7 @@ var Connection = class {
|
|
|
937
967
|
});
|
|
938
968
|
(0, import_invariant.invariant)(msg.author?.equals(this.remoteId), void 0, {
|
|
939
969
|
F: __dxlog_file,
|
|
940
|
-
L:
|
|
970
|
+
L: 347,
|
|
941
971
|
S: this,
|
|
942
972
|
A: [
|
|
943
973
|
"msg.author?.equals(this.remoteId)",
|
|
@@ -946,7 +976,7 @@ var Connection = class {
|
|
|
946
976
|
});
|
|
947
977
|
(0, import_invariant.invariant)(msg.recipient?.equals(this.ownId), void 0, {
|
|
948
978
|
F: __dxlog_file,
|
|
949
|
-
L:
|
|
979
|
+
L: 348,
|
|
950
980
|
S: this,
|
|
951
981
|
A: [
|
|
952
982
|
"msg.recipient?.equals(this.ownId)",
|
|
@@ -970,7 +1000,7 @@ var Connection = class {
|
|
|
970
1000
|
msg: msg.data
|
|
971
1001
|
}, {
|
|
972
1002
|
F: __dxlog_file,
|
|
973
|
-
L:
|
|
1003
|
+
L: 357,
|
|
974
1004
|
S: this,
|
|
975
1005
|
C: (f, a) => f(...a)
|
|
976
1006
|
});
|
|
@@ -978,7 +1008,7 @@ var Connection = class {
|
|
|
978
1008
|
} else {
|
|
979
1009
|
(0, import_invariant.invariant)(this._transport, "Connection not ready to accept signals.", {
|
|
980
1010
|
F: __dxlog_file,
|
|
981
|
-
L:
|
|
1011
|
+
L: 360,
|
|
982
1012
|
S: this,
|
|
983
1013
|
A: [
|
|
984
1014
|
"this._transport",
|
|
@@ -991,7 +1021,7 @@ var Connection = class {
|
|
|
991
1021
|
msg: msg.data
|
|
992
1022
|
}, {
|
|
993
1023
|
F: __dxlog_file,
|
|
994
|
-
L:
|
|
1024
|
+
L: 361,
|
|
995
1025
|
S: this,
|
|
996
1026
|
C: (f, a) => f(...a)
|
|
997
1027
|
});
|
|
@@ -1005,17 +1035,17 @@ var Connection = class {
|
|
|
1005
1035
|
_changeState(state) {
|
|
1006
1036
|
(0, import_log.log)("stateChanged", {
|
|
1007
1037
|
from: this._state,
|
|
1008
|
-
|
|
1038
|
+
to: state,
|
|
1009
1039
|
peerId: this.ownId
|
|
1010
1040
|
}, {
|
|
1011
1041
|
F: __dxlog_file,
|
|
1012
|
-
L:
|
|
1042
|
+
L: 372,
|
|
1013
1043
|
S: this,
|
|
1014
1044
|
C: (f, a) => f(...a)
|
|
1015
1045
|
});
|
|
1016
1046
|
(0, import_invariant.invariant)(state !== this._state, "Already in this state.", {
|
|
1017
1047
|
F: __dxlog_file,
|
|
1018
|
-
L:
|
|
1048
|
+
L: 373,
|
|
1019
1049
|
S: this,
|
|
1020
1050
|
A: [
|
|
1021
1051
|
"state !== this._state",
|
|
@@ -1040,7 +1070,7 @@ var import_debug2 = require("@dxos/debug");
|
|
|
1040
1070
|
var import_invariant4 = require("@dxos/invariant");
|
|
1041
1071
|
var import_keys4 = require("@dxos/keys");
|
|
1042
1072
|
var import_log4 = require("@dxos/log");
|
|
1043
|
-
var
|
|
1073
|
+
var import_protocols4 = require("@dxos/protocols");
|
|
1044
1074
|
var import_util2 = require("@dxos/util");
|
|
1045
1075
|
|
|
1046
1076
|
// packages/core/mesh/network-manager/src/signal/swarm-messenger.ts
|
|
@@ -1050,7 +1080,7 @@ var import_keys2 = require("@dxos/keys");
|
|
|
1050
1080
|
var import_log2 = require("@dxos/log");
|
|
1051
1081
|
var import_protocols2 = require("@dxos/protocols");
|
|
1052
1082
|
var import_util = require("@dxos/util");
|
|
1053
|
-
var __dxlog_file2 = "/
|
|
1083
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
|
|
1054
1084
|
var SwarmMessage = import_protocols2.schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
|
|
1055
1085
|
var SwarmMessenger = class {
|
|
1056
1086
|
constructor({ sendMessage, onSignal, onOffer, topic }) {
|
|
@@ -1278,10 +1308,10 @@ var SwarmMessenger = class {
|
|
|
1278
1308
|
// packages/core/mesh/network-manager/src/swarm/peer.ts
|
|
1279
1309
|
var import_async2 = require("@dxos/async");
|
|
1280
1310
|
var import_context3 = require("@dxos/context");
|
|
1281
|
-
var import_errors2 = require("@dxos/errors");
|
|
1282
1311
|
var import_invariant3 = require("@dxos/invariant");
|
|
1283
1312
|
var import_keys3 = require("@dxos/keys");
|
|
1284
1313
|
var import_log3 = require("@dxos/log");
|
|
1314
|
+
var import_protocols3 = require("@dxos/protocols");
|
|
1285
1315
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
1286
1316
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1287
1317
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -1292,8 +1322,8 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
1292
1322
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1293
1323
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1294
1324
|
}
|
|
1295
|
-
var __dxlog_file3 = "/
|
|
1296
|
-
var ConnectionDisplacedError = class extends
|
|
1325
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
|
|
1326
|
+
var ConnectionDisplacedError = class extends import_protocols3.SystemError {
|
|
1297
1327
|
constructor() {
|
|
1298
1328
|
super("Connection displaced by remote initiator.");
|
|
1299
1329
|
}
|
|
@@ -1361,7 +1391,7 @@ var Peer = class {
|
|
|
1361
1391
|
connection.initiate();
|
|
1362
1392
|
await connection.openConnection();
|
|
1363
1393
|
} catch (err) {
|
|
1364
|
-
if (!(err instanceof
|
|
1394
|
+
if (!(err instanceof import_protocols3.CancelledError)) {
|
|
1365
1395
|
import_log3.log.warn("connection error", {
|
|
1366
1396
|
topic: this.topic,
|
|
1367
1397
|
peerId: this.localPeerId,
|
|
@@ -1471,6 +1501,9 @@ var Peer = class {
|
|
|
1471
1501
|
S: this,
|
|
1472
1502
|
C: (f, a) => f(...a)
|
|
1473
1503
|
});
|
|
1504
|
+
if (err instanceof import_protocols3.TimeoutError) {
|
|
1505
|
+
await connection.abort(err);
|
|
1506
|
+
}
|
|
1474
1507
|
await this.closeConnection(err);
|
|
1475
1508
|
throw err;
|
|
1476
1509
|
} finally {
|
|
@@ -1490,13 +1523,13 @@ var Peer = class {
|
|
|
1490
1523
|
sessionId
|
|
1491
1524
|
}, {
|
|
1492
1525
|
F: __dxlog_file3,
|
|
1493
|
-
L:
|
|
1526
|
+
L: 213,
|
|
1494
1527
|
S: this,
|
|
1495
1528
|
C: (f, a) => f(...a)
|
|
1496
1529
|
});
|
|
1497
1530
|
(0, import_invariant3.invariant)(!this.connection, "Already connected.", {
|
|
1498
1531
|
F: __dxlog_file3,
|
|
1499
|
-
L:
|
|
1532
|
+
L: 220,
|
|
1500
1533
|
S: this,
|
|
1501
1534
|
A: [
|
|
1502
1535
|
"!this.connection",
|
|
@@ -1532,7 +1565,7 @@ var Peer = class {
|
|
|
1532
1565
|
initiator
|
|
1533
1566
|
}, {
|
|
1534
1567
|
F: __dxlog_file3,
|
|
1535
|
-
L:
|
|
1568
|
+
L: 239,
|
|
1536
1569
|
S: this,
|
|
1537
1570
|
C: (f, a) => f(...a)
|
|
1538
1571
|
});
|
|
@@ -1545,14 +1578,14 @@ var Peer = class {
|
|
|
1545
1578
|
initiator
|
|
1546
1579
|
}, {
|
|
1547
1580
|
F: __dxlog_file3,
|
|
1548
|
-
L:
|
|
1581
|
+
L: 248,
|
|
1549
1582
|
S: this,
|
|
1550
1583
|
C: (f, a) => f(...a)
|
|
1551
1584
|
});
|
|
1552
1585
|
this._connectionLimiter.doneConnecting(sessionId);
|
|
1553
1586
|
(0, import_invariant3.invariant)(this.connection === connection, "Connection mismatch (race condition).", {
|
|
1554
1587
|
F: __dxlog_file3,
|
|
1555
|
-
L:
|
|
1588
|
+
L: 253,
|
|
1556
1589
|
S: this,
|
|
1557
1590
|
A: [
|
|
1558
1591
|
"this.connection === connection",
|
|
@@ -1567,7 +1600,7 @@ var Peer = class {
|
|
|
1567
1600
|
initiator
|
|
1568
1601
|
}, {
|
|
1569
1602
|
F: __dxlog_file3,
|
|
1570
|
-
L:
|
|
1603
|
+
L: 255,
|
|
1571
1604
|
S: this,
|
|
1572
1605
|
C: (f, a) => f(...a)
|
|
1573
1606
|
});
|
|
@@ -1602,7 +1635,7 @@ var Peer = class {
|
|
|
1602
1635
|
err
|
|
1603
1636
|
}, {
|
|
1604
1637
|
F: __dxlog_file3,
|
|
1605
|
-
L:
|
|
1638
|
+
L: 295,
|
|
1606
1639
|
S: this,
|
|
1607
1640
|
C: (f, a) => f(...a)
|
|
1608
1641
|
});
|
|
@@ -1615,7 +1648,7 @@ var Peer = class {
|
|
|
1615
1648
|
err
|
|
1616
1649
|
}, {
|
|
1617
1650
|
F: __dxlog_file3,
|
|
1618
|
-
L:
|
|
1651
|
+
L: 296,
|
|
1619
1652
|
S: this,
|
|
1620
1653
|
C: (f, a) => f(...a)
|
|
1621
1654
|
});
|
|
@@ -1634,7 +1667,7 @@ var Peer = class {
|
|
|
1634
1667
|
sessionId: connection.sessionId
|
|
1635
1668
|
}, {
|
|
1636
1669
|
F: __dxlog_file3,
|
|
1637
|
-
L:
|
|
1670
|
+
L: 321,
|
|
1638
1671
|
S: this,
|
|
1639
1672
|
C: (f, a) => f(...a)
|
|
1640
1673
|
});
|
|
@@ -1644,7 +1677,7 @@ var Peer = class {
|
|
|
1644
1677
|
sessionId: connection.sessionId
|
|
1645
1678
|
}, {
|
|
1646
1679
|
F: __dxlog_file3,
|
|
1647
|
-
L:
|
|
1680
|
+
L: 327,
|
|
1648
1681
|
S: this,
|
|
1649
1682
|
C: (f, a) => f(...a)
|
|
1650
1683
|
});
|
|
@@ -1655,7 +1688,7 @@ var Peer = class {
|
|
|
1655
1688
|
message
|
|
1656
1689
|
}, {
|
|
1657
1690
|
F: __dxlog_file3,
|
|
1658
|
-
L:
|
|
1691
|
+
L: 332,
|
|
1659
1692
|
S: this,
|
|
1660
1693
|
C: (f, a) => f(...a)
|
|
1661
1694
|
});
|
|
@@ -1670,7 +1703,7 @@ var Peer = class {
|
|
|
1670
1703
|
topic: this.topic
|
|
1671
1704
|
}, {
|
|
1672
1705
|
F: __dxlog_file3,
|
|
1673
|
-
L:
|
|
1706
|
+
L: 342,
|
|
1674
1707
|
S: this,
|
|
1675
1708
|
C: (f, a) => f(...a)
|
|
1676
1709
|
});
|
|
@@ -1704,7 +1737,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
1704
1737
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1705
1738
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1706
1739
|
}
|
|
1707
|
-
var __dxlog_file4 = "/
|
|
1740
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
|
|
1708
1741
|
var INITIATION_DELAY = 100;
|
|
1709
1742
|
var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
|
|
1710
1743
|
var Swarm = class {
|
|
@@ -1728,7 +1761,7 @@ var Swarm = class {
|
|
|
1728
1761
|
this.disconnected = new import_async3.Event();
|
|
1729
1762
|
this.connected = new import_async3.Event();
|
|
1730
1763
|
this.errors = new import_debug2.ErrorStream();
|
|
1731
|
-
import_log4.log.trace("dxos.mesh.swarm.constructor",
|
|
1764
|
+
import_log4.log.trace("dxos.mesh.swarm.constructor", import_protocols4.trace.begin({
|
|
1732
1765
|
id: this._instanceId,
|
|
1733
1766
|
data: {
|
|
1734
1767
|
topic: this._topic.toHex(),
|
|
@@ -1755,7 +1788,7 @@ var Swarm = class {
|
|
|
1755
1788
|
onOffer: async (msg) => await this.onOffer(msg),
|
|
1756
1789
|
topic: this._topic
|
|
1757
1790
|
});
|
|
1758
|
-
import_log4.log.trace("dxos.mesh.swarm.constructor",
|
|
1791
|
+
import_log4.log.trace("dxos.mesh.swarm.constructor", import_protocols4.trace.end({
|
|
1759
1792
|
id: this._instanceId
|
|
1760
1793
|
}), {
|
|
1761
1794
|
F: __dxlog_file4,
|
|
@@ -2178,7 +2211,7 @@ var import_async4 = require("@dxos/async");
|
|
|
2178
2211
|
var import_keys5 = require("@dxos/keys");
|
|
2179
2212
|
var import_log5 = require("@dxos/log");
|
|
2180
2213
|
var import_util3 = require("@dxos/util");
|
|
2181
|
-
var __dxlog_file5 = "/
|
|
2214
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
|
|
2182
2215
|
var SwarmMapper = class {
|
|
2183
2216
|
get peers() {
|
|
2184
2217
|
return Array.from(this._peers.values());
|
|
@@ -2246,13 +2279,13 @@ var SwarmMapper = class {
|
|
|
2246
2279
|
// packages/core/mesh/network-manager/src/swarm/connection-limiter.ts
|
|
2247
2280
|
var import_async5 = require("@dxos/async");
|
|
2248
2281
|
var import_context5 = require("@dxos/context");
|
|
2249
|
-
var import_errors3 = require("@dxos/errors");
|
|
2250
2282
|
var import_invariant5 = require("@dxos/invariant");
|
|
2251
2283
|
var import_keys6 = require("@dxos/keys");
|
|
2252
2284
|
var import_log6 = require("@dxos/log");
|
|
2285
|
+
var import_protocols5 = require("@dxos/protocols");
|
|
2253
2286
|
var import_util4 = require("@dxos/util");
|
|
2254
|
-
var __dxlog_file6 = "/
|
|
2255
|
-
var MAX_CONCURRENT_INITIATING_CONNECTIONS =
|
|
2287
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
|
|
2288
|
+
var MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
|
|
2256
2289
|
var ConnectionLimiter = class {
|
|
2257
2290
|
constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
|
|
2258
2291
|
this._ctx = new import_context5.Context();
|
|
@@ -2319,7 +2352,7 @@ var ConnectionLimiter = class {
|
|
|
2319
2352
|
if (!this._waitingPromises.has(sessionId)) {
|
|
2320
2353
|
return;
|
|
2321
2354
|
}
|
|
2322
|
-
this._waitingPromises.get(sessionId).reject(new
|
|
2355
|
+
this._waitingPromises.get(sessionId).reject(new import_protocols5.CancelledError());
|
|
2323
2356
|
this._waitingPromises.delete(sessionId);
|
|
2324
2357
|
this.resolveWaitingPromises.schedule();
|
|
2325
2358
|
}
|
|
@@ -2397,10 +2430,10 @@ var import_invariant6 = require("@dxos/invariant");
|
|
|
2397
2430
|
var import_keys8 = require("@dxos/keys");
|
|
2398
2431
|
var import_log7 = require("@dxos/log");
|
|
2399
2432
|
var import_messaging = require("@dxos/messaging");
|
|
2400
|
-
var
|
|
2433
|
+
var import_protocols6 = require("@dxos/protocols");
|
|
2401
2434
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
2402
2435
|
var import_util6 = require("@dxos/util");
|
|
2403
|
-
var __dxlog_file7 = "/
|
|
2436
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
|
|
2404
2437
|
var NetworkManager = class {
|
|
2405
2438
|
constructor({ transportFactory, signalManager, log: log1 }) {
|
|
2406
2439
|
/**
|
|
@@ -2445,7 +2478,7 @@ var NetworkManager = class {
|
|
|
2445
2478
|
return this._swarms.get(topic);
|
|
2446
2479
|
}
|
|
2447
2480
|
async open() {
|
|
2448
|
-
import_log7.log.trace("dxos.mesh.network-manager.open",
|
|
2481
|
+
import_log7.log.trace("dxos.mesh.network-manager.open", import_protocols6.trace.begin({
|
|
2449
2482
|
id: this._instanceId
|
|
2450
2483
|
}), {
|
|
2451
2484
|
F: __dxlog_file7,
|
|
@@ -2455,7 +2488,7 @@ var NetworkManager = class {
|
|
|
2455
2488
|
});
|
|
2456
2489
|
await this._messenger.open();
|
|
2457
2490
|
await this._signalManager.open();
|
|
2458
|
-
import_log7.log.trace("dxos.mesh.network-manager.open",
|
|
2491
|
+
import_log7.log.trace("dxos.mesh.network-manager.open", import_protocols6.trace.end({
|
|
2459
2492
|
id: this._instanceId
|
|
2460
2493
|
}), {
|
|
2461
2494
|
F: __dxlog_file7,
|
|
@@ -2636,7 +2669,7 @@ var NetworkManager = class {
|
|
|
2636
2669
|
|
|
2637
2670
|
// packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
|
|
2638
2671
|
var import_invariant7 = require("@dxos/invariant");
|
|
2639
|
-
var __dxlog_file8 = "/
|
|
2672
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
|
|
2640
2673
|
var FullyConnectedTopology = class {
|
|
2641
2674
|
toString() {
|
|
2642
2675
|
return "FullyConnectedTopology";
|
|
@@ -2679,7 +2712,7 @@ var FullyConnectedTopology = class {
|
|
|
2679
2712
|
var import_xor_distance = __toESM(require("xor-distance"));
|
|
2680
2713
|
var import_invariant8 = require("@dxos/invariant");
|
|
2681
2714
|
var import_log8 = require("@dxos/log");
|
|
2682
|
-
var __dxlog_file9 = "/
|
|
2715
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
|
|
2683
2716
|
var MMSTTopology = class {
|
|
2684
2717
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
2685
2718
|
this._sampleCollected = false;
|
|
@@ -2788,7 +2821,7 @@ var sortByXorDistance = (keys, reference) => keys.sort((a, b) => import_xor_dist
|
|
|
2788
2821
|
// packages/core/mesh/network-manager/src/topology/star-topology.ts
|
|
2789
2822
|
var import_invariant9 = require("@dxos/invariant");
|
|
2790
2823
|
var import_log9 = require("@dxos/log");
|
|
2791
|
-
var __dxlog_file10 = "/
|
|
2824
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
|
|
2792
2825
|
var StarTopology = class {
|
|
2793
2826
|
// prettier-ignore
|
|
2794
2827
|
constructor(_centralPeer) {
|
|
@@ -2900,7 +2933,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2900
2933
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2901
2934
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2902
2935
|
}
|
|
2903
|
-
var __dxlog_file11 = "/
|
|
2936
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
|
|
2904
2937
|
var MEMORY_TRANSPORT_DELAY = 1;
|
|
2905
2938
|
var createStreamDelay = (delay) => {
|
|
2906
2939
|
return new import_node_stream.Transform({
|
|
@@ -3075,6 +3108,7 @@ var TransportKind;
|
|
|
3075
3108
|
TransportKind2["LIBDATACHANNEL"] = "LIBDATACHANNEL";
|
|
3076
3109
|
TransportKind2["SIMPLE_PEER_PROXY"] = "SIMPLE_PEER_PROXY";
|
|
3077
3110
|
TransportKind2["MEMORY"] = "MEMORY";
|
|
3111
|
+
TransportKind2["TCP"] = "TCP";
|
|
3078
3112
|
})(TransportKind || (TransportKind = {}));
|
|
3079
3113
|
|
|
3080
3114
|
// packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts
|
|
@@ -3084,7 +3118,7 @@ var import_async9 = require("@dxos/async");
|
|
|
3084
3118
|
var import_debug5 = require("@dxos/debug");
|
|
3085
3119
|
var import_keys10 = require("@dxos/keys");
|
|
3086
3120
|
var import_log11 = require("@dxos/log");
|
|
3087
|
-
var
|
|
3121
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
3088
3122
|
|
|
3089
3123
|
// packages/core/mesh/network-manager/src/transport/webrtc.ts
|
|
3090
3124
|
var wrtc = null;
|
|
@@ -3094,7 +3128,7 @@ try {
|
|
|
3094
3128
|
}
|
|
3095
3129
|
|
|
3096
3130
|
// packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts
|
|
3097
|
-
var __dxlog_file12 = "/
|
|
3131
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts";
|
|
3098
3132
|
var SimplePeerTransport = class {
|
|
3099
3133
|
constructor(params) {
|
|
3100
3134
|
this.params = params;
|
|
@@ -3103,17 +3137,17 @@ var SimplePeerTransport = class {
|
|
|
3103
3137
|
this.connected = new import_async9.Event();
|
|
3104
3138
|
this.errors = new import_debug5.ErrorStream();
|
|
3105
3139
|
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
3106
|
-
import_log11.log.trace("dxos.mesh.webrtc-transport.constructor",
|
|
3140
|
+
import_log11.log.trace("dxos.mesh.webrtc-transport.constructor", import_protocols7.trace.begin({
|
|
3107
3141
|
id: this._instanceId
|
|
3108
3142
|
}), {
|
|
3109
3143
|
F: __dxlog_file12,
|
|
3110
|
-
L:
|
|
3144
|
+
L: 40,
|
|
3111
3145
|
S: this,
|
|
3112
3146
|
C: (f, a) => f(...a)
|
|
3113
3147
|
});
|
|
3114
3148
|
(0, import_log11.log)("created connection", params, {
|
|
3115
3149
|
F: __dxlog_file12,
|
|
3116
|
-
L:
|
|
3150
|
+
L: 41,
|
|
3117
3151
|
S: this,
|
|
3118
3152
|
C: (f, a) => f(...a)
|
|
3119
3153
|
});
|
|
@@ -3126,7 +3160,7 @@ var SimplePeerTransport = class {
|
|
|
3126
3160
|
this._peer.on("signal", async (data) => {
|
|
3127
3161
|
(0, import_log11.log)("signal", data, {
|
|
3128
3162
|
F: __dxlog_file12,
|
|
3129
|
-
L:
|
|
3163
|
+
L: 50,
|
|
3130
3164
|
S: this,
|
|
3131
3165
|
C: (f, a) => f(...a)
|
|
3132
3166
|
});
|
|
@@ -3139,7 +3173,7 @@ var SimplePeerTransport = class {
|
|
|
3139
3173
|
this._peer.on("connect", () => {
|
|
3140
3174
|
(0, import_log11.log)("connected", void 0, {
|
|
3141
3175
|
F: __dxlog_file12,
|
|
3142
|
-
L:
|
|
3176
|
+
L: 55,
|
|
3143
3177
|
S: this,
|
|
3144
3178
|
C: (f, a) => f(...a)
|
|
3145
3179
|
});
|
|
@@ -3149,7 +3183,7 @@ var SimplePeerTransport = class {
|
|
|
3149
3183
|
this._peer.on("close", async () => {
|
|
3150
3184
|
(0, import_log11.log)("closed", void 0, {
|
|
3151
3185
|
F: __dxlog_file12,
|
|
3152
|
-
L:
|
|
3186
|
+
L: 61,
|
|
3153
3187
|
S: this,
|
|
3154
3188
|
C: (f, a) => f(...a)
|
|
3155
3189
|
});
|
|
@@ -3157,7 +3191,35 @@ var SimplePeerTransport = class {
|
|
|
3157
3191
|
this.closed.emit();
|
|
3158
3192
|
});
|
|
3159
3193
|
this._peer.on("error", async (err) => {
|
|
3160
|
-
|
|
3194
|
+
if (typeof RTCError !== "undefined" && err instanceof RTCError) {
|
|
3195
|
+
if (err.errorDetail === "sctp-failure") {
|
|
3196
|
+
this.errors.raise(new import_protocols7.ConnectionResetError("sctp-failure from RTCError", err));
|
|
3197
|
+
} else {
|
|
3198
|
+
this.errors.raise(new import_protocols7.UnknownProtocolError("unknown RTCError", err));
|
|
3199
|
+
}
|
|
3200
|
+
} else if (err.name === "InvalidStateError") {
|
|
3201
|
+
this.errors.raise(new import_protocols7.ConnectionResetError("safari WebRTC error", err));
|
|
3202
|
+
} else if ("code" in err) {
|
|
3203
|
+
switch (err.code) {
|
|
3204
|
+
case "ERR_WEBRTC_SUPPORT":
|
|
3205
|
+
this.errors.raise(new import_protocols7.ProtocolError("WebRTC not supported", err));
|
|
3206
|
+
case "ERR_ICE_CONNECTION_FAILURE":
|
|
3207
|
+
case "ERR_DATA_CHANNEL":
|
|
3208
|
+
case "ERR_CONNECTION_FAILURE":
|
|
3209
|
+
case "ERR_SIGNALING":
|
|
3210
|
+
this.errors.raise(new import_protocols7.ConnectivityError("unknown communication failure", err));
|
|
3211
|
+
case "ERR_CREATE_OFFER":
|
|
3212
|
+
case "ERR_CREATE_ANSWER":
|
|
3213
|
+
case "ERR_SET_LOCAL_DESCRIPTION":
|
|
3214
|
+
case "ERR_SET_REMOTE_DESCRIPTION":
|
|
3215
|
+
case "ERR_ADD_ICE_CANDIDATE":
|
|
3216
|
+
this.errors.raise(new import_protocols7.UnknownProtocolError("unknown simple-peer library failure", err));
|
|
3217
|
+
default:
|
|
3218
|
+
this.errors.raise(new Error("unknown simple-peer error"));
|
|
3219
|
+
}
|
|
3220
|
+
} else {
|
|
3221
|
+
this.errors.raise(err);
|
|
3222
|
+
}
|
|
3161
3223
|
try {
|
|
3162
3224
|
if (typeof this._peer?._pc.getStats === "function") {
|
|
3163
3225
|
this._peer._pc.getStats().then((stats) => {
|
|
@@ -3166,21 +3228,27 @@ var SimplePeerTransport = class {
|
|
|
3166
3228
|
stats
|
|
3167
3229
|
}, {
|
|
3168
3230
|
F: __dxlog_file12,
|
|
3169
|
-
L:
|
|
3231
|
+
L: 106,
|
|
3170
3232
|
S: this,
|
|
3171
3233
|
C: (f, a) => f(...a)
|
|
3172
3234
|
});
|
|
3173
3235
|
});
|
|
3174
3236
|
}
|
|
3175
|
-
} catch {
|
|
3237
|
+
} catch (err2) {
|
|
3238
|
+
import_log11.log.catch(err2, void 0, {
|
|
3239
|
+
F: __dxlog_file12,
|
|
3240
|
+
L: 113,
|
|
3241
|
+
S: this,
|
|
3242
|
+
C: (f, a) => f(...a)
|
|
3243
|
+
});
|
|
3176
3244
|
}
|
|
3177
3245
|
await this.destroy();
|
|
3178
3246
|
});
|
|
3179
|
-
import_log11.log.trace("dxos.mesh.webrtc-transport.constructor",
|
|
3247
|
+
import_log11.log.trace("dxos.mesh.webrtc-transport.constructor", import_protocols7.trace.end({
|
|
3180
3248
|
id: this._instanceId
|
|
3181
3249
|
}), {
|
|
3182
3250
|
F: __dxlog_file12,
|
|
3183
|
-
L:
|
|
3251
|
+
L: 118,
|
|
3184
3252
|
S: this,
|
|
3185
3253
|
C: (f, a) => f(...a)
|
|
3186
3254
|
});
|
|
@@ -3188,7 +3256,7 @@ var SimplePeerTransport = class {
|
|
|
3188
3256
|
async destroy() {
|
|
3189
3257
|
(0, import_log11.log)("closing...", void 0, {
|
|
3190
3258
|
F: __dxlog_file12,
|
|
3191
|
-
L:
|
|
3259
|
+
L: 122,
|
|
3192
3260
|
S: this,
|
|
3193
3261
|
C: (f, a) => f(...a)
|
|
3194
3262
|
});
|
|
@@ -3198,7 +3266,7 @@ var SimplePeerTransport = class {
|
|
|
3198
3266
|
this.closed.emit();
|
|
3199
3267
|
(0, import_log11.log)("closed", void 0, {
|
|
3200
3268
|
F: __dxlog_file12,
|
|
3201
|
-
L:
|
|
3269
|
+
L: 127,
|
|
3202
3270
|
S: this,
|
|
3203
3271
|
C: (f, a) => f(...a)
|
|
3204
3272
|
});
|
|
@@ -3229,7 +3297,7 @@ var import_keys11 = require("@dxos/keys");
|
|
|
3229
3297
|
var import_log12 = require("@dxos/log");
|
|
3230
3298
|
var import_bridge = require("@dxos/protocols/proto/dxos/mesh/bridge");
|
|
3231
3299
|
var import_util8 = require("@dxos/util");
|
|
3232
|
-
var __dxlog_file13 = "/
|
|
3300
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-service.ts";
|
|
3233
3301
|
var SimplePeerTransportService = class {
|
|
3234
3302
|
// prettier-ignore
|
|
3235
3303
|
constructor(_webrtcConfig) {
|
|
@@ -3359,9 +3427,10 @@ var import_debug6 = require("@dxos/debug");
|
|
|
3359
3427
|
var import_invariant12 = require("@dxos/invariant");
|
|
3360
3428
|
var import_keys12 = require("@dxos/keys");
|
|
3361
3429
|
var import_log13 = require("@dxos/log");
|
|
3430
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
3362
3431
|
var import_bridge2 = require("@dxos/protocols/proto/dxos/mesh/bridge");
|
|
3363
3432
|
var import_util9 = require("@dxos/util");
|
|
3364
|
-
var __dxlog_file14 = "/
|
|
3433
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts";
|
|
3365
3434
|
var SimplePeerTransportProxy = class {
|
|
3366
3435
|
// prettier-ignore
|
|
3367
3436
|
constructor(_params) {
|
|
@@ -3380,7 +3449,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3380
3449
|
this._serviceStream.subscribe(async (event) => {
|
|
3381
3450
|
(0, import_log13.log)("SimplePeerTransportProxy: event", event, {
|
|
3382
3451
|
F: __dxlog_file14,
|
|
3383
|
-
L:
|
|
3452
|
+
L: 58,
|
|
3384
3453
|
S: this,
|
|
3385
3454
|
C: (f, a) => f(...a)
|
|
3386
3455
|
});
|
|
@@ -3400,7 +3469,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3400
3469
|
}).then(() => callback(), (err) => {
|
|
3401
3470
|
import_log13.log.catch(err, void 0, {
|
|
3402
3471
|
F: __dxlog_file14,
|
|
3403
|
-
L:
|
|
3472
|
+
L: 76,
|
|
3404
3473
|
S: this,
|
|
3405
3474
|
C: (f, a) => f(...a)
|
|
3406
3475
|
});
|
|
@@ -3409,14 +3478,14 @@ var SimplePeerTransportProxy = class {
|
|
|
3409
3478
|
}));
|
|
3410
3479
|
}, (error) => import_log13.log.catch(error, void 0, {
|
|
3411
3480
|
F: __dxlog_file14,
|
|
3412
|
-
L:
|
|
3481
|
+
L: 82,
|
|
3413
3482
|
S: this,
|
|
3414
3483
|
C: (f, a) => f(...a)
|
|
3415
3484
|
}));
|
|
3416
3485
|
}
|
|
3417
3486
|
async _handleConnection(connectionEvent) {
|
|
3418
3487
|
if (connectionEvent.error) {
|
|
3419
|
-
this.errors.raise(
|
|
3488
|
+
this.errors.raise(decodeError(connectionEvent.error));
|
|
3420
3489
|
}
|
|
3421
3490
|
switch (connectionEvent.state) {
|
|
3422
3491
|
case import_bridge2.ConnectionState.CONNECTED: {
|
|
@@ -3439,7 +3508,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3439
3508
|
this._params.bridgeService.sendSignal({
|
|
3440
3509
|
proxyId: this._proxyId,
|
|
3441
3510
|
signal
|
|
3442
|
-
}).catch((err) => this.errors.raise(err));
|
|
3511
|
+
}).catch((err) => this.errors.raise(decodeError(err)));
|
|
3443
3512
|
}
|
|
3444
3513
|
// TODO(burdon): Move open from constructor.
|
|
3445
3514
|
async destroy() {
|
|
@@ -3455,7 +3524,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3455
3524
|
} catch (err) {
|
|
3456
3525
|
import_log13.log.catch(err, void 0, {
|
|
3457
3526
|
F: __dxlog_file14,
|
|
3458
|
-
L:
|
|
3527
|
+
L: 133,
|
|
3459
3528
|
S: this,
|
|
3460
3529
|
C: (f, a) => f(...a)
|
|
3461
3530
|
});
|
|
@@ -3491,7 +3560,7 @@ var SimplePeerTransportProxyFactory = class {
|
|
|
3491
3560
|
createTransport(options) {
|
|
3492
3561
|
(0, import_invariant12.invariant)(this._bridgeService, "SimplePeerTransportProxyFactory is not ready to open connections", {
|
|
3493
3562
|
F: __dxlog_file14,
|
|
3494
|
-
L:
|
|
3563
|
+
L: 170,
|
|
3495
3564
|
S: this,
|
|
3496
3565
|
A: [
|
|
3497
3566
|
"this._bridgeService",
|
|
@@ -3507,6 +3576,22 @@ var SimplePeerTransportProxyFactory = class {
|
|
|
3507
3576
|
return transport;
|
|
3508
3577
|
}
|
|
3509
3578
|
};
|
|
3579
|
+
var decodeError = (err) => {
|
|
3580
|
+
const message = typeof err === "string" ? err : err.message;
|
|
3581
|
+
if (message.includes("ConnectionResetError")) {
|
|
3582
|
+
return new import_protocols8.ConnectionResetError(message);
|
|
3583
|
+
} else if (message.includes("TimeoutError")) {
|
|
3584
|
+
return new import_protocols8.TimeoutError(message);
|
|
3585
|
+
} else if (message.includes("ProtocolError")) {
|
|
3586
|
+
return new import_protocols8.ProtocolError(message);
|
|
3587
|
+
} else if (message.includes("ConnectivityError")) {
|
|
3588
|
+
return new import_protocols8.ConnectivityError(message);
|
|
3589
|
+
} else if (message.includes("UnknownProtocolError")) {
|
|
3590
|
+
return new import_protocols8.UnknownProtocolError(message);
|
|
3591
|
+
} else {
|
|
3592
|
+
return typeof err === "string" ? new Error(err) : err;
|
|
3593
|
+
}
|
|
3594
|
+
};
|
|
3510
3595
|
|
|
3511
3596
|
// packages/core/mesh/network-manager/src/transport/index.ts
|
|
3512
3597
|
init_datachannel();
|
|
@@ -3526,7 +3611,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3526
3611
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3527
3612
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3528
3613
|
}
|
|
3529
|
-
var __dxlog_file15 = "/
|
|
3614
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/libdatachannel-transport.ts";
|
|
3530
3615
|
var DATACHANNEL_LABEL = "dxos.mesh.transport";
|
|
3531
3616
|
var MAX_BUFFERED_AMOUNT = 64 * 1024;
|
|
3532
3617
|
var MAX_MESSAGE_SIZE = 64 * 1024;
|