@dxos/network-manager 0.6.14-main.2b6a0f3 → 0.6.14-main.f49f251

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.
@@ -1,7 +1,4 @@
1
1
  import "@dxos/node-std/globals";
2
- import {
3
- Buffer
4
- } from "./chunk-GW3YM55A.mjs";
5
2
 
6
3
  // packages/core/mesh/network-manager/src/swarm/connection.ts
7
4
  import { DeferredTask, Event, sleep, scheduleTask, scheduleTaskInterval, synchronized, Trigger } from "@dxos/async";
@@ -568,20 +565,53 @@ _ts_decorate([
568
565
  synchronized
569
566
  ], Connection.prototype, "close", null);
570
567
 
568
+ // packages/core/mesh/network-manager/src/signal/ice.ts
569
+ import { asyncTimeout } from "@dxos/async";
570
+ import { log as log2 } from "@dxos/log";
571
+ import { isNotNullOrUndefined } from "@dxos/util";
572
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/ice.ts";
573
+ var createIceProvider = (iceProviders) => {
574
+ let cachedIceServers;
575
+ return {
576
+ getIceServers: async () => {
577
+ if (cachedIceServers) {
578
+ return cachedIceServers;
579
+ }
580
+ cachedIceServers = (await Promise.all(iceProviders.map(({ urls }) => asyncTimeout(fetch(urls, {
581
+ method: "GET"
582
+ }), 1e4).then((response) => response.json()).catch((err) => {
583
+ const isDev = typeof window !== "undefined" && window.location.href.includes("localhost");
584
+ if (!isDev) {
585
+ log2.error("Failed to fetch ICE servers from provider", {
586
+ urls,
587
+ err
588
+ }, {
589
+ F: __dxlog_file2,
590
+ L: 30,
591
+ S: void 0,
592
+ C: (f, a) => f(...a)
593
+ });
594
+ }
595
+ })))).filter(isNotNullOrUndefined).map(({ iceServers }) => iceServers).flat();
596
+ return cachedIceServers;
597
+ }
598
+ };
599
+ };
600
+
571
601
  // packages/core/mesh/network-manager/src/signal/swarm-messenger.ts
572
602
  import { Context as Context2 } from "@dxos/context";
573
603
  import { invariant as invariant2 } from "@dxos/invariant";
574
604
  import { PublicKey as PublicKey2 } from "@dxos/keys";
575
- import { log as log2 } from "@dxos/log";
605
+ import { log as log3 } from "@dxos/log";
576
606
  import { TimeoutError as TimeoutError2 } from "@dxos/protocols";
577
607
  import { schema } from "@dxos/protocols/proto";
578
608
  import { ComplexMap } from "@dxos/util";
579
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
609
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
580
610
  var SwarmMessage = schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
581
611
  var SwarmMessenger = class {
582
612
  constructor({ sendMessage, onSignal, onOffer, topic }) {
583
613
  this._ctx = new Context2(void 0, {
584
- F: __dxlog_file2,
614
+ F: __dxlog_file3,
585
615
  L: 35
586
616
  });
587
617
  this._offerRecords = new ComplexMap((key) => key.toHex());
@@ -598,12 +628,12 @@ var SwarmMessenger = class {
598
628
  if (!this._topic.equals(message.topic)) {
599
629
  return;
600
630
  }
601
- log2("received", {
631
+ log3("received", {
602
632
  from: author,
603
633
  to: recipient,
604
634
  msg: message
605
635
  }, {
606
- F: __dxlog_file2,
636
+ F: __dxlog_file3,
607
637
  L: 71,
608
638
  S: this,
609
639
  C: (f, a) => f(...a)
@@ -629,10 +659,10 @@ var SwarmMessenger = class {
629
659
  message
630
660
  });
631
661
  } else {
632
- log2.warn("unknown message", {
662
+ log3.warn("unknown message", {
633
663
  message
634
664
  }, {
635
- F: __dxlog_file2,
665
+ F: __dxlog_file3,
636
666
  L: 82,
637
667
  S: this,
638
668
  C: (f, a) => f(...a)
@@ -641,7 +671,7 @@ var SwarmMessenger = class {
641
671
  }
642
672
  async signal(message) {
643
673
  invariant2(message.data?.signal || message.data?.signalBatch, "Invalid message", {
644
- F: __dxlog_file2,
674
+ F: __dxlog_file3,
645
675
  L: 87,
646
676
  S: this,
647
677
  A: [
@@ -677,12 +707,12 @@ var SwarmMessenger = class {
677
707
  // Setting unique message_id if it not specified yet.
678
708
  messageId: message.messageId ?? PublicKey2.random()
679
709
  };
680
- log2("sending", {
710
+ log3("sending", {
681
711
  from: author,
682
712
  to: recipient,
683
713
  msg: networkMessage
684
714
  }, {
685
- F: __dxlog_file2,
715
+ F: __dxlog_file3,
686
716
  L: 125,
687
717
  S: this,
688
718
  C: (f, a) => f(...a)
@@ -698,7 +728,7 @@ var SwarmMessenger = class {
698
728
  }
699
729
  async _resolveAnswers(message) {
700
730
  invariant2(message.data?.answer?.offerMessageId, "No offerMessageId", {
701
- F: __dxlog_file2,
731
+ F: __dxlog_file3,
702
732
  L: 137,
703
733
  S: this,
704
734
  A: [
@@ -710,7 +740,7 @@ var SwarmMessenger = class {
710
740
  if (offerRecord) {
711
741
  this._offerRecords.delete(message.data.answer.offerMessageId);
712
742
  invariant2(message.data?.answer, "No answer", {
713
- F: __dxlog_file2,
743
+ F: __dxlog_file3,
714
744
  L: 141,
715
745
  S: this,
716
746
  A: [
@@ -718,10 +748,10 @@ var SwarmMessenger = class {
718
748
  "'No answer'"
719
749
  ]
720
750
  });
721
- log2("resolving", {
751
+ log3("resolving", {
722
752
  answer: message.data.answer
723
753
  }, {
724
- F: __dxlog_file2,
754
+ F: __dxlog_file3,
725
755
  L: 142,
726
756
  S: this,
727
757
  C: (f, a) => f(...a)
@@ -731,7 +761,7 @@ var SwarmMessenger = class {
731
761
  }
732
762
  async _handleOffer({ author, recipient, message }) {
733
763
  invariant2(message.data.offer, "No offer", {
734
- F: __dxlog_file2,
764
+ F: __dxlog_file3,
735
765
  L: 156,
736
766
  S: this,
737
767
  A: [
@@ -763,19 +793,19 @@ var SwarmMessenger = class {
763
793
  });
764
794
  } catch (err) {
765
795
  if (err instanceof TimeoutError2) {
766
- log2.info("timeout sending answer to offer", {
796
+ log3.info("timeout sending answer to offer", {
767
797
  err
768
798
  }, {
769
- F: __dxlog_file2,
799
+ F: __dxlog_file3,
770
800
  L: 177,
771
801
  S: this,
772
802
  C: (f, a) => f(...a)
773
803
  });
774
804
  } else {
775
- log2.info("error sending answer to offer", {
805
+ log3.info("error sending answer to offer", {
776
806
  err
777
807
  }, {
778
- F: __dxlog_file2,
808
+ F: __dxlog_file3,
779
809
  L: 179,
780
810
  S: this,
781
811
  C: (f, a) => f(...a)
@@ -785,7 +815,7 @@ var SwarmMessenger = class {
785
815
  }
786
816
  async _handleSignal({ author, recipient, message }) {
787
817
  invariant2(message.messageId, void 0, {
788
- F: __dxlog_file2,
818
+ F: __dxlog_file3,
789
819
  L: 193,
790
820
  S: this,
791
821
  A: [
@@ -794,7 +824,7 @@ var SwarmMessenger = class {
794
824
  ]
795
825
  });
796
826
  invariant2(message.data.signal || message.data.signalBatch, "Invalid message", {
797
- F: __dxlog_file2,
827
+ F: __dxlog_file3,
798
828
  L: 194,
799
829
  S: this,
800
830
  A: [
@@ -821,17 +851,17 @@ import { Context as Context4 } from "@dxos/context";
821
851
  import { ErrorStream as ErrorStream2 } from "@dxos/debug";
822
852
  import { invariant as invariant4 } from "@dxos/invariant";
823
853
  import { PublicKey as PublicKey4 } from "@dxos/keys";
824
- import { log as log4, logInfo as logInfo2 } from "@dxos/log";
854
+ import { log as log5, logInfo as logInfo2 } from "@dxos/log";
825
855
  import { PeerInfoHash } from "@dxos/messaging";
826
856
  import { trace as trace2 } from "@dxos/protocols";
827
- import { ComplexMap as ComplexMap2, isNotNullOrUndefined } from "@dxos/util";
857
+ import { ComplexMap as ComplexMap2, isNotNullOrUndefined as isNotNullOrUndefined2 } from "@dxos/util";
828
858
 
829
859
  // packages/core/mesh/network-manager/src/swarm/peer.ts
830
860
  import { Event as Event2, scheduleTask as scheduleTask2, synchronized as synchronized2 } from "@dxos/async";
831
861
  import { Context as Context3 } from "@dxos/context";
832
862
  import { invariant as invariant3 } from "@dxos/invariant";
833
863
  import { PublicKey as PublicKey3 } from "@dxos/keys";
834
- import { log as log3 } from "@dxos/log";
864
+ import { log as log4 } from "@dxos/log";
835
865
  import { CancelledError as CancelledError2, SystemError } from "@dxos/protocols";
836
866
  function _ts_decorate2(decorators, target, key, desc) {
837
867
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -839,7 +869,7 @@ function _ts_decorate2(decorators, target, key, desc) {
839
869
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
840
870
  return c > 3 && r && Object.defineProperty(target, key, r), r;
841
871
  }
842
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
872
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
843
873
  var ConnectionDisplacedError = class extends SystemError {
844
874
  constructor() {
845
875
  super("Connection displaced by remote initiator.");
@@ -859,7 +889,7 @@ var Peer = class {
859
889
  this._availableAfter = 0;
860
890
  this.availableToConnect = true;
861
891
  this._ctx = new Context3(void 0, {
862
- F: __dxlog_file3,
892
+ F: __dxlog_file4,
863
893
  L: 80
864
894
  });
865
895
  this.advertizing = false;
@@ -876,8 +906,8 @@ var Peer = class {
876
906
  ConnectionState.INITIAL,
877
907
  ConnectionState.CONNECTING
878
908
  ].includes(this.connection.state)) {
879
- log3.info(`received offer when connection already in ${this.connection.state} state`, void 0, {
880
- F: __dxlog_file3,
909
+ log4.info(`received offer when connection already in ${this.connection.state} state`, void 0, {
910
+ F: __dxlog_file4,
881
911
  L: 115,
882
912
  S: this,
883
913
  C: (f, a) => f(...a)
@@ -888,13 +918,13 @@ var Peer = class {
888
918
  }
889
919
  if (this.connection || this.initiating) {
890
920
  if (remote.peerKey < this.localInfo.peerKey) {
891
- log3("close local connection", {
921
+ log4("close local connection", {
892
922
  localPeer: this.localInfo,
893
923
  topic: this.topic,
894
924
  remotePeer: this.remoteInfo,
895
925
  sessionId: this.connection?.sessionId
896
926
  }, {
897
- F: __dxlog_file3,
927
+ F: __dxlog_file4,
898
928
  L: 124,
899
929
  S: this,
900
930
  C: (f, a) => f(...a)
@@ -911,7 +941,7 @@ var Peer = class {
911
941
  if (await this._callbacks.onOffer(remote)) {
912
942
  if (!this.connection) {
913
943
  invariant3(message.sessionId, void 0, {
914
- F: __dxlog_file3,
944
+ F: __dxlog_file4,
915
945
  L: 144,
916
946
  S: this,
917
947
  A: [
@@ -926,13 +956,13 @@ var Peer = class {
926
956
  await connection.openConnection();
927
957
  } catch (err) {
928
958
  if (!(err instanceof CancelledError2)) {
929
- log3.info("connection error", {
959
+ log4.info("connection error", {
930
960
  topic: this.topic,
931
961
  peerId: this.localInfo,
932
962
  remoteId: this.remoteInfo,
933
963
  err
934
964
  }, {
935
- F: __dxlog_file3,
965
+ F: __dxlog_file4,
936
966
  L: 154,
937
967
  S: this,
938
968
  C: (f, a) => f(...a)
@@ -954,7 +984,7 @@ var Peer = class {
954
984
  */
955
985
  async initiateConnection() {
956
986
  invariant3(!this.initiating, "Initiation in progress.", {
957
- F: __dxlog_file3,
987
+ F: __dxlog_file4,
958
988
  L: 171,
959
989
  S: this,
960
990
  A: [
@@ -963,7 +993,7 @@ var Peer = class {
963
993
  ]
964
994
  });
965
995
  invariant3(!this.connection, "Already connected.", {
966
- F: __dxlog_file3,
996
+ F: __dxlog_file4,
967
997
  L: 172,
968
998
  S: this,
969
999
  A: [
@@ -972,13 +1002,13 @@ var Peer = class {
972
1002
  ]
973
1003
  });
974
1004
  const sessionId = PublicKey3.random();
975
- log3("initiating...", {
1005
+ log4("initiating...", {
976
1006
  local: this.localInfo,
977
1007
  topic: this.topic,
978
1008
  remote: this.remoteInfo,
979
1009
  sessionId
980
1010
  }, {
981
- F: __dxlog_file3,
1011
+ F: __dxlog_file4,
982
1012
  L: 174,
983
1013
  S: this,
984
1014
  C: (f, a) => f(...a)
@@ -998,20 +1028,20 @@ var Peer = class {
998
1028
  offer: {}
999
1029
  }
1000
1030
  });
1001
- log3("received", {
1031
+ log4("received", {
1002
1032
  answer,
1003
1033
  topic: this.topic,
1004
1034
  local: this.localInfo,
1005
1035
  remote: this.remoteInfo
1006
1036
  }, {
1007
- F: __dxlog_file3,
1037
+ F: __dxlog_file4,
1008
1038
  L: 191,
1009
1039
  S: this,
1010
1040
  C: (f, a) => f(...a)
1011
1041
  });
1012
1042
  if (connection.state !== ConnectionState.INITIAL) {
1013
- log3("ignoring response", void 0, {
1014
- F: __dxlog_file3,
1043
+ log4("ignoring response", void 0, {
1044
+ F: __dxlog_file4,
1015
1045
  L: 193,
1016
1046
  S: this,
1017
1047
  C: (f, a) => f(...a)
@@ -1019,13 +1049,13 @@ var Peer = class {
1019
1049
  return;
1020
1050
  }
1021
1051
  } catch (err) {
1022
- log3("initiation error: send offer", {
1052
+ log4("initiation error: send offer", {
1023
1053
  err,
1024
1054
  topic: this.topic,
1025
1055
  local: this.localInfo,
1026
1056
  remote: this.remoteInfo
1027
1057
  }, {
1028
- F: __dxlog_file3,
1058
+ F: __dxlog_file4,
1029
1059
  L: 197,
1030
1060
  S: this,
1031
1061
  C: (f, a) => f(...a)
@@ -1041,13 +1071,13 @@ var Peer = class {
1041
1071
  return;
1042
1072
  }
1043
1073
  } catch (err) {
1044
- log3("initiation error: accept answer", {
1074
+ log4("initiation error: accept answer", {
1045
1075
  err,
1046
1076
  topic: this.topic,
1047
1077
  local: this.localInfo,
1048
1078
  remote: this.remoteInfo
1049
1079
  }, {
1050
- F: __dxlog_file3,
1080
+ F: __dxlog_file4,
1051
1081
  L: 210,
1052
1082
  S: this,
1053
1083
  C: (f, a) => f(...a)
@@ -1058,8 +1088,8 @@ var Peer = class {
1058
1088
  this.initiating = false;
1059
1089
  }
1060
1090
  try {
1061
- log3("opening connection as initiator", void 0, {
1062
- F: __dxlog_file3,
1091
+ log4("opening connection as initiator", void 0, {
1092
+ F: __dxlog_file4,
1063
1093
  L: 223,
1064
1094
  S: this,
1065
1095
  C: (f, a) => f(...a)
@@ -1067,21 +1097,21 @@ var Peer = class {
1067
1097
  await connection.openConnection();
1068
1098
  this._callbacks.onAccepted();
1069
1099
  } catch (err) {
1070
- log3("initiation error: open connection", {
1100
+ log4("initiation error: open connection", {
1071
1101
  err,
1072
1102
  topic: this.topic,
1073
1103
  local: this.localInfo,
1074
1104
  remote: this.remoteInfo
1075
1105
  }, {
1076
- F: __dxlog_file3,
1106
+ F: __dxlog_file4,
1077
1107
  L: 227,
1078
1108
  S: this,
1079
1109
  C: (f, a) => f(...a)
1080
1110
  });
1081
- log3.warn("closing connection due to unhandled error on openConnection", {
1111
+ log4.warn("closing connection due to unhandled error on openConnection", {
1082
1112
  err
1083
1113
  }, {
1084
- F: __dxlog_file3,
1114
+ F: __dxlog_file4,
1085
1115
  L: 234,
1086
1116
  S: this,
1087
1117
  C: (f, a) => f(...a)
@@ -1097,20 +1127,20 @@ var Peer = class {
1097
1127
  * Either we're initiating a connection or creating one in response to an offer from the other peer.
1098
1128
  */
1099
1129
  _createConnection(initiator, sessionId) {
1100
- log3("creating connection", {
1130
+ log4("creating connection", {
1101
1131
  topic: this.topic,
1102
1132
  peerId: this.localInfo,
1103
1133
  remoteId: this.remoteInfo,
1104
1134
  initiator,
1105
1135
  sessionId
1106
1136
  }, {
1107
- F: __dxlog_file3,
1137
+ F: __dxlog_file4,
1108
1138
  L: 248,
1109
1139
  S: this,
1110
1140
  C: (f, a) => f(...a)
1111
1141
  });
1112
1142
  invariant3(!this.connection, "Already connected.", {
1113
- F: __dxlog_file3,
1143
+ F: __dxlog_file4,
1114
1144
  L: 255,
1115
1145
  S: this,
1116
1146
  A: [
@@ -1139,34 +1169,34 @@ var Peer = class {
1139
1169
  this._lastConnectionTime = Date.now();
1140
1170
  this._callbacks.onConnected();
1141
1171
  this._connectionLimiter.doneConnecting(sessionId);
1142
- log3.trace("dxos.mesh.connection.connected", {
1172
+ log4.trace("dxos.mesh.connection.connected", {
1143
1173
  topic: this.topic,
1144
1174
  localPeerId: this.localInfo,
1145
1175
  remotePeerId: this.remoteInfo,
1146
1176
  sessionId,
1147
1177
  initiator
1148
1178
  }, {
1149
- F: __dxlog_file3,
1179
+ F: __dxlog_file4,
1150
1180
  L: 279,
1151
1181
  S: this,
1152
1182
  C: (f, a) => f(...a)
1153
1183
  });
1154
1184
  },
1155
1185
  onClosed: (err) => {
1156
- log3("connection closed", {
1186
+ log4("connection closed", {
1157
1187
  topic: this.topic,
1158
1188
  peerId: this.localInfo,
1159
1189
  remoteId: this.remoteInfo,
1160
1190
  initiator
1161
1191
  }, {
1162
- F: __dxlog_file3,
1192
+ F: __dxlog_file4,
1163
1193
  L: 288,
1164
1194
  S: this,
1165
1195
  C: (f, a) => f(...a)
1166
1196
  });
1167
1197
  this._connectionLimiter.doneConnecting(sessionId);
1168
1198
  invariant3(this.connection === connection, "Connection mismatch (race condition).", {
1169
- F: __dxlog_file3,
1199
+ F: __dxlog_file4,
1170
1200
  L: 293,
1171
1201
  S: this,
1172
1202
  A: [
@@ -1174,14 +1204,14 @@ var Peer = class {
1174
1204
  "'Connection mismatch (race condition).'"
1175
1205
  ]
1176
1206
  });
1177
- log3.trace("dxos.mesh.connection.closed", {
1207
+ log4.trace("dxos.mesh.connection.closed", {
1178
1208
  topic: this.topic,
1179
1209
  localPeerId: this.localInfo,
1180
1210
  remotePeerId: this.remoteInfo,
1181
1211
  sessionId,
1182
1212
  initiator
1183
1213
  }, {
1184
- F: __dxlog_file3,
1214
+ F: __dxlog_file4,
1185
1215
  L: 295,
1186
1216
  S: this,
1187
1217
  C: (f, a) => f(...a)
@@ -1209,19 +1239,19 @@ var Peer = class {
1209
1239
  void this._connectionCtx?.dispose();
1210
1240
  this._connectionCtx = this._ctx.derive();
1211
1241
  connection.errors.handle((err) => {
1212
- log3.info("connection error, closing", {
1242
+ log4.info("connection error, closing", {
1213
1243
  topic: this.topic,
1214
1244
  peerId: this.localInfo,
1215
1245
  remoteId: this.remoteInfo,
1216
1246
  initiator,
1217
1247
  err
1218
1248
  }, {
1219
- F: __dxlog_file3,
1249
+ F: __dxlog_file4,
1220
1250
  L: 335,
1221
1251
  S: this,
1222
1252
  C: (f, a) => f(...a)
1223
1253
  });
1224
- log3.trace("dxos.mesh.connection.error", {
1254
+ log4.trace("dxos.mesh.connection.error", {
1225
1255
  topic: this.topic,
1226
1256
  localPeerId: this.localInfo,
1227
1257
  remotePeerId: this.remoteInfo,
@@ -1229,7 +1259,7 @@ var Peer = class {
1229
1259
  initiator,
1230
1260
  err
1231
1261
  }, {
1232
- F: __dxlog_file3,
1262
+ F: __dxlog_file4,
1233
1263
  L: 342,
1234
1264
  S: this,
1235
1265
  C: (f, a) => f(...a)
@@ -1244,21 +1274,21 @@ var Peer = class {
1244
1274
  return;
1245
1275
  }
1246
1276
  const connection = this.connection;
1247
- log3("closing...", {
1277
+ log4("closing...", {
1248
1278
  peerId: this.remoteInfo,
1249
1279
  sessionId: connection.sessionId
1250
1280
  }, {
1251
- F: __dxlog_file3,
1281
+ F: __dxlog_file4,
1252
1282
  L: 367,
1253
1283
  S: this,
1254
1284
  C: (f, a) => f(...a)
1255
1285
  });
1256
1286
  await connection.close(err);
1257
- log3("closed", {
1287
+ log4("closed", {
1258
1288
  peerId: this.remoteInfo,
1259
1289
  sessionId: connection.sessionId
1260
1290
  }, {
1261
- F: __dxlog_file3,
1291
+ F: __dxlog_file4,
1262
1292
  L: 373,
1263
1293
  S: this,
1264
1294
  C: (f, a) => f(...a)
@@ -1266,10 +1296,10 @@ var Peer = class {
1266
1296
  }
1267
1297
  async onSignal(message) {
1268
1298
  if (!this.connection) {
1269
- log3("dropping signal message for non-existent connection", {
1299
+ log4("dropping signal message for non-existent connection", {
1270
1300
  message
1271
1301
  }, {
1272
- F: __dxlog_file3,
1302
+ F: __dxlog_file4,
1273
1303
  L: 378,
1274
1304
  S: this,
1275
1305
  C: (f, a) => f(...a)
@@ -1280,11 +1310,11 @@ var Peer = class {
1280
1310
  }
1281
1311
  async safeDestroy(reason) {
1282
1312
  await this._ctx.dispose();
1283
- log3("Destroying peer", {
1313
+ log4("Destroying peer", {
1284
1314
  peerId: this.remoteInfo,
1285
1315
  topic: this.topic
1286
1316
  }, {
1287
- F: __dxlog_file3,
1317
+ F: __dxlog_file4,
1288
1318
  L: 388,
1289
1319
  S: this,
1290
1320
  C: (f, a) => f(...a)
@@ -1315,7 +1345,7 @@ function _ts_decorate3(decorators, target, key, desc) {
1315
1345
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1316
1346
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1317
1347
  }
1318
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
1348
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
1319
1349
  var INITIATION_DELAY = 100;
1320
1350
  var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
1321
1351
  var Swarm = class {
@@ -1332,7 +1362,7 @@ var Swarm = class {
1332
1362
  this._connectionLimiter = _connectionLimiter;
1333
1363
  this._initiationDelay = _initiationDelay;
1334
1364
  this._ctx = new Context4(void 0, {
1335
- F: __dxlog_file4,
1365
+ F: __dxlog_file5,
1336
1366
  L: 38
1337
1367
  });
1338
1368
  this._listeningHandle = void 0;
@@ -1342,22 +1372,22 @@ var Swarm = class {
1342
1372
  this.disconnected = new Event3();
1343
1373
  this.connected = new Event3();
1344
1374
  this.errors = new ErrorStream2();
1345
- log4.trace("dxos.mesh.swarm.constructor", trace2.begin({
1375
+ log5.trace("dxos.mesh.swarm.constructor", trace2.begin({
1346
1376
  id: this._instanceId,
1347
1377
  data: {
1348
1378
  topic: this._topic.toHex(),
1349
1379
  peer: this._ownPeer
1350
1380
  }
1351
1381
  }), {
1352
- F: __dxlog_file4,
1382
+ F: __dxlog_file5,
1353
1383
  L: 88,
1354
1384
  S: this,
1355
1385
  C: (f, a) => f(...a)
1356
1386
  });
1357
- log4("creating swarm", {
1387
+ log5("creating swarm", {
1358
1388
  peerId: _ownPeer
1359
1389
  }, {
1360
- F: __dxlog_file4,
1390
+ F: __dxlog_file5,
1361
1391
  L: 92,
1362
1392
  S: this,
1363
1393
  C: (f, a) => f(...a)
@@ -1369,17 +1399,17 @@ var Swarm = class {
1369
1399
  onOffer: async (msg) => await this.onOffer(msg),
1370
1400
  topic: this._topic
1371
1401
  });
1372
- log4.trace("dxos.mesh.swarm.constructor", trace2.end({
1402
+ log5.trace("dxos.mesh.swarm.constructor", trace2.end({
1373
1403
  id: this._instanceId
1374
1404
  }), {
1375
- F: __dxlog_file4,
1405
+ F: __dxlog_file5,
1376
1406
  L: 101,
1377
1407
  S: this,
1378
1408
  C: (f, a) => f(...a)
1379
1409
  });
1380
1410
  }
1381
1411
  get connections() {
1382
- return Array.from(this._peers.values()).map((peer) => peer.connection).filter(isNotNullOrUndefined);
1412
+ return Array.from(this._peers.values()).map((peer) => peer.connection).filter(isNotNullOrUndefined2);
1383
1413
  }
1384
1414
  get ownPeerId() {
1385
1415
  return PublicKey4.from(this._ownPeer.peerKey);
@@ -1398,7 +1428,7 @@ var Swarm = class {
1398
1428
  }
1399
1429
  async open() {
1400
1430
  invariant4(!this._listeningHandle, void 0, {
1401
- F: __dxlog_file4,
1431
+ F: __dxlog_file5,
1402
1432
  L: 132,
1403
1433
  S: this,
1404
1434
  A: [
@@ -1410,10 +1440,10 @@ var Swarm = class {
1410
1440
  peer: this._ownPeer,
1411
1441
  payloadType: "dxos.mesh.swarm.SwarmMessage",
1412
1442
  onMessage: async (message) => {
1413
- await this._swarmMessenger.receiveMessage(message).catch((err) => log4.info("Error while receiving message", {
1443
+ await this._swarmMessenger.receiveMessage(message).catch((err) => log5.info("Error while receiving message", {
1414
1444
  err
1415
1445
  }, {
1416
- F: __dxlog_file4,
1446
+ F: __dxlog_file5,
1417
1447
  L: 140,
1418
1448
  S: this,
1419
1449
  C: (f, a) => f(...a)
@@ -1422,8 +1452,8 @@ var Swarm = class {
1422
1452
  });
1423
1453
  }
1424
1454
  async destroy() {
1425
- log4("destroying...", void 0, {
1426
- F: __dxlog_file4,
1455
+ log5("destroying...", void 0, {
1456
+ F: __dxlog_file5,
1427
1457
  L: 146,
1428
1458
  S: this,
1429
1459
  C: (f, a) => f(...a)
@@ -1433,8 +1463,8 @@ var Swarm = class {
1433
1463
  await this._ctx.dispose();
1434
1464
  await this._topology.destroy();
1435
1465
  await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key, "swarm destroyed")));
1436
- log4("destroyed", void 0, {
1437
- F: __dxlog_file4,
1466
+ log5("destroyed", void 0, {
1467
+ F: __dxlog_file5,
1438
1468
  L: 153,
1439
1469
  S: this,
1440
1470
  C: (f, a) => f(...a)
@@ -1442,7 +1472,7 @@ var Swarm = class {
1442
1472
  }
1443
1473
  async setTopology(topology) {
1444
1474
  invariant4(!this._ctx.disposed, "Swarm is offline", {
1445
- F: __dxlog_file4,
1475
+ F: __dxlog_file5,
1446
1476
  L: 157,
1447
1477
  S: this,
1448
1478
  A: [
@@ -1453,11 +1483,11 @@ var Swarm = class {
1453
1483
  if (topology === this._topology) {
1454
1484
  return;
1455
1485
  }
1456
- log4("setting topology", {
1486
+ log5("setting topology", {
1457
1487
  previous: getClassName(this._topology),
1458
1488
  topology: getClassName(topology)
1459
1489
  }, {
1460
- F: __dxlog_file4,
1490
+ F: __dxlog_file5,
1461
1491
  L: 161,
1462
1492
  S: this,
1463
1493
  C: (f, a) => f(...a)
@@ -1468,17 +1498,17 @@ var Swarm = class {
1468
1498
  this._topology.update();
1469
1499
  }
1470
1500
  onSwarmEvent(swarmEvent) {
1471
- log4("swarm event", {
1501
+ log5("swarm event", {
1472
1502
  swarmEvent
1473
1503
  }, {
1474
- F: __dxlog_file4,
1504
+ F: __dxlog_file5,
1475
1505
  L: 174,
1476
1506
  S: this,
1477
1507
  C: (f, a) => f(...a)
1478
1508
  });
1479
1509
  if (this._ctx.disposed) {
1480
- log4("swarm event ignored for disposed swarm", void 0, {
1481
- F: __dxlog_file4,
1510
+ log5("swarm event ignored for disposed swarm", void 0, {
1511
+ F: __dxlog_file5,
1482
1512
  L: 177,
1483
1513
  S: this,
1484
1514
  C: (f, a) => f(...a)
@@ -1488,10 +1518,10 @@ var Swarm = class {
1488
1518
  if (swarmEvent.peerAvailable) {
1489
1519
  const peerId = swarmEvent.peerAvailable.peer.peerKey;
1490
1520
  if (peerId !== this._ownPeer.peerKey) {
1491
- log4("new peer", {
1521
+ log5("new peer", {
1492
1522
  peerId
1493
1523
  }, {
1494
- F: __dxlog_file4,
1524
+ F: __dxlog_file5,
1495
1525
  L: 184,
1496
1526
  S: this,
1497
1527
  C: (f, a) => f(...a)
@@ -1504,18 +1534,18 @@ var Swarm = class {
1504
1534
  if (peer) {
1505
1535
  peer.advertizing = false;
1506
1536
  if (peer.connection?.state !== ConnectionState.CONNECTED) {
1507
- void this._destroyPeer(swarmEvent.peerLeft.peer, "peer left").catch((err) => log4.catch(err, void 0, {
1508
- F: __dxlog_file4,
1537
+ void this._destroyPeer(swarmEvent.peerLeft.peer, "peer left").catch((err) => log5.catch(err, void 0, {
1538
+ F: __dxlog_file5,
1509
1539
  L: 194,
1510
1540
  S: this,
1511
1541
  C: (f, a) => f(...a)
1512
1542
  }));
1513
1543
  }
1514
1544
  } else {
1515
- log4("received peerLeft but no peer found", {
1545
+ log5("received peerLeft but no peer found", {
1516
1546
  peer: swarmEvent.peerLeft.peer.peerKey
1517
1547
  }, {
1518
- F: __dxlog_file4,
1548
+ F: __dxlog_file5,
1519
1549
  L: 197,
1520
1550
  S: this,
1521
1551
  C: (f, a) => f(...a)
@@ -1525,17 +1555,17 @@ var Swarm = class {
1525
1555
  this._topology.update();
1526
1556
  }
1527
1557
  async onOffer(message) {
1528
- log4("offer", {
1558
+ log5("offer", {
1529
1559
  message
1530
1560
  }, {
1531
- F: __dxlog_file4,
1561
+ F: __dxlog_file5,
1532
1562
  L: 206,
1533
1563
  S: this,
1534
1564
  C: (f, a) => f(...a)
1535
1565
  });
1536
1566
  if (this._ctx.disposed) {
1537
- log4("ignored for disposed swarm", void 0, {
1538
- F: __dxlog_file4,
1567
+ log5("ignored for disposed swarm", void 0, {
1568
+ F: __dxlog_file5,
1539
1569
  L: 208,
1540
1570
  S: this,
1541
1571
  C: (f, a) => f(...a)
@@ -1545,7 +1575,7 @@ var Swarm = class {
1545
1575
  };
1546
1576
  }
1547
1577
  invariant4(message.author, void 0, {
1548
- F: __dxlog_file4,
1578
+ F: __dxlog_file5,
1549
1579
  L: 213,
1550
1580
  S: this,
1551
1581
  A: [
@@ -1554,10 +1584,10 @@ var Swarm = class {
1554
1584
  ]
1555
1585
  });
1556
1586
  if (message.recipient.peerKey !== this._ownPeer.peerKey) {
1557
- log4("rejecting offer with incorrect peerId", {
1587
+ log5("rejecting offer with incorrect peerId", {
1558
1588
  message
1559
1589
  }, {
1560
- F: __dxlog_file4,
1590
+ F: __dxlog_file5,
1561
1591
  L: 215,
1562
1592
  S: this,
1563
1593
  C: (f, a) => f(...a)
@@ -1567,10 +1597,10 @@ var Swarm = class {
1567
1597
  };
1568
1598
  }
1569
1599
  if (!message.topic?.equals(this._topic)) {
1570
- log4("rejecting offer with incorrect topic", {
1600
+ log5("rejecting offer with incorrect topic", {
1571
1601
  message
1572
1602
  }, {
1573
- F: __dxlog_file4,
1603
+ F: __dxlog_file5,
1574
1604
  L: 219,
1575
1605
  S: this,
1576
1606
  C: (f, a) => f(...a)
@@ -1585,17 +1615,17 @@ var Swarm = class {
1585
1615
  return answer;
1586
1616
  }
1587
1617
  async onSignal(message) {
1588
- log4("signal", {
1618
+ log5("signal", {
1589
1619
  message
1590
1620
  }, {
1591
- F: __dxlog_file4,
1621
+ F: __dxlog_file5,
1592
1622
  L: 230,
1593
1623
  S: this,
1594
1624
  C: (f, a) => f(...a)
1595
1625
  });
1596
1626
  if (this._ctx.disposed) {
1597
- log4.info("ignored for offline swarm", void 0, {
1598
- F: __dxlog_file4,
1627
+ log5.info("ignored for offline swarm", void 0, {
1628
+ F: __dxlog_file5,
1599
1629
  L: 232,
1600
1630
  S: this,
1601
1631
  C: (f, a) => f(...a)
@@ -1603,7 +1633,7 @@ var Swarm = class {
1603
1633
  return;
1604
1634
  }
1605
1635
  invariant4(message.recipient.peerKey === this._ownPeer.peerKey, `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
1606
- F: __dxlog_file4,
1636
+ F: __dxlog_file5,
1607
1637
  L: 235,
1608
1638
  S: this,
1609
1639
  A: [
@@ -1612,7 +1642,7 @@ var Swarm = class {
1612
1642
  ]
1613
1643
  });
1614
1644
  invariant4(message.topic?.equals(this._topic), void 0, {
1615
- F: __dxlog_file4,
1645
+ F: __dxlog_file5,
1616
1646
  L: 239,
1617
1647
  S: this,
1618
1648
  A: [
@@ -1621,7 +1651,7 @@ var Swarm = class {
1621
1651
  ]
1622
1652
  });
1623
1653
  invariant4(message.author, void 0, {
1624
- F: __dxlog_file4,
1654
+ F: __dxlog_file5,
1625
1655
  L: 240,
1626
1656
  S: this,
1627
1657
  A: [
@@ -1642,13 +1672,13 @@ var Swarm = class {
1642
1672
  // For debug purposes
1643
1673
  async goOnline() {
1644
1674
  this._ctx = new Context4(void 0, {
1645
- F: __dxlog_file4,
1675
+ F: __dxlog_file5,
1646
1676
  L: 256
1647
1677
  });
1648
1678
  }
1649
1679
  _getOrCreatePeer(peerInfo) {
1650
1680
  invariant4(peerInfo.peerKey, "PeerInfo.peerKey is required", {
1651
- F: __dxlog_file4,
1681
+ F: __dxlog_file5,
1652
1682
  L: 260,
1653
1683
  S: this,
1654
1684
  A: [
@@ -1677,10 +1707,10 @@ var Swarm = class {
1677
1707
  },
1678
1708
  onRejected: () => {
1679
1709
  if (!this._isUnregistered(peer)) {
1680
- log4("peer rejected connection", {
1710
+ log5("peer rejected connection", {
1681
1711
  peerInfo
1682
1712
  }, {
1683
- F: __dxlog_file4,
1713
+ F: __dxlog_file5,
1684
1714
  L: 293,
1685
1715
  S: this,
1686
1716
  C: (f, a) => f(...a)
@@ -1705,7 +1735,7 @@ var Swarm = class {
1705
1735
  async _destroyPeer(peerInfo, reason) {
1706
1736
  const peer = this._peers.get(peerInfo);
1707
1737
  invariant4(peer, void 0, {
1708
- F: __dxlog_file4,
1738
+ F: __dxlog_file5,
1709
1739
  L: 316,
1710
1740
  S: this,
1711
1741
  A: [
@@ -1734,8 +1764,8 @@ var Swarm = class {
1734
1764
  peerKey: peer.toHex()
1735
1765
  });
1736
1766
  } catch (err) {
1737
- log4("initiation error", err, {
1738
- F: __dxlog_file4,
1767
+ log5("initiation error", err, {
1768
+ F: __dxlog_file5,
1739
1769
  L: 343,
1740
1770
  S: this,
1741
1771
  C: (f, a) => f(...a)
@@ -1763,10 +1793,10 @@ var Swarm = class {
1763
1793
  const ctx = this._ctx;
1764
1794
  const peer = this._getOrCreatePeer(remotePeer);
1765
1795
  if (remotePeer.peerKey < this._ownPeer.peerKey) {
1766
- log4("initiation delay", {
1796
+ log5("initiation delay", {
1767
1797
  remotePeer
1768
1798
  }, {
1769
- F: __dxlog_file4,
1799
+ F: __dxlog_file5,
1770
1800
  L: 371,
1771
1801
  S: this,
1772
1802
  C: (f, a) => f(...a)
@@ -1782,20 +1812,20 @@ var Swarm = class {
1782
1812
  if (peer.connection) {
1783
1813
  return;
1784
1814
  }
1785
- log4("initiating connection...", {
1815
+ log5("initiating connection...", {
1786
1816
  remotePeer
1787
1817
  }, {
1788
- F: __dxlog_file4,
1818
+ F: __dxlog_file5,
1789
1819
  L: 387,
1790
1820
  S: this,
1791
1821
  C: (f, a) => f(...a)
1792
1822
  });
1793
1823
  await peer.initiateConnection();
1794
1824
  this._topology.update();
1795
- log4("initiated", {
1825
+ log5("initiated", {
1796
1826
  remotePeer
1797
1827
  }, {
1798
- F: __dxlog_file4,
1828
+ F: __dxlog_file5,
1799
1829
  L: 390,
1800
1830
  S: this,
1801
1831
  C: (f, a) => f(...a)
@@ -1837,10 +1867,10 @@ _ts_decorate3([
1837
1867
  // packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts
1838
1868
  import { Event as Event4, EventSubscriptions } from "@dxos/async";
1839
1869
  import { PublicKey as PublicKey5 } from "@dxos/keys";
1840
- import { log as log5 } from "@dxos/log";
1870
+ import { log as log6 } from "@dxos/log";
1841
1871
  import { PeerInfoHash as PeerInfoHash2 } from "@dxos/messaging";
1842
1872
  import { ComplexMap as ComplexMap3 } from "@dxos/util";
1843
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
1873
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
1844
1874
  var SwarmMapper = class {
1845
1875
  get peers() {
1846
1876
  return Array.from(this._peers.values());
@@ -1865,8 +1895,8 @@ var SwarmMapper = class {
1865
1895
  this._update();
1866
1896
  }
1867
1897
  _update() {
1868
- log5("updating swarm", void 0, {
1869
- F: __dxlog_file5,
1898
+ log6("updating swarm", void 0, {
1899
+ F: __dxlog_file6,
1870
1900
  L: 73,
1871
1901
  S: this,
1872
1902
  C: (f, a) => f(...a)
@@ -1886,11 +1916,11 @@ var SwarmMapper = class {
1886
1916
  ]
1887
1917
  });
1888
1918
  }
1889
- log5("graph changed", {
1919
+ log6("graph changed", {
1890
1920
  directConnections: this._swarm.connections.length,
1891
1921
  totalPeersInSwarm: this._peers.size
1892
1922
  }, {
1893
- F: __dxlog_file5,
1923
+ F: __dxlog_file6,
1894
1924
  L: 114,
1895
1925
  S: this,
1896
1926
  C: (f, a) => f(...a)
@@ -1909,15 +1939,15 @@ import { DeferredTask as DeferredTask2 } from "@dxos/async";
1909
1939
  import { Context as Context5 } from "@dxos/context";
1910
1940
  import { invariant as invariant5 } from "@dxos/invariant";
1911
1941
  import { PublicKey as PublicKey6 } from "@dxos/keys";
1912
- import { log as log6 } from "@dxos/log";
1942
+ import { log as log7 } from "@dxos/log";
1913
1943
  import { CancelledError as CancelledError3 } from "@dxos/protocols";
1914
1944
  import { ComplexMap as ComplexMap4 } from "@dxos/util";
1915
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
1945
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
1916
1946
  var MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
1917
1947
  var ConnectionLimiter = class {
1918
1948
  constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
1919
1949
  this._ctx = new Context5(void 0, {
1920
- F: __dxlog_file6,
1950
+ F: __dxlog_file7,
1921
1951
  L: 23
1922
1952
  });
1923
1953
  /**
@@ -1936,7 +1966,7 @@ var ConnectionLimiter = class {
1936
1966
  */
1937
1967
  async connecting(sessionId) {
1938
1968
  invariant5(!this._waitingPromises.has(sessionId), "Peer is already waiting for connection", {
1939
- F: __dxlog_file6,
1969
+ F: __dxlog_file7,
1940
1970
  L: 48,
1941
1971
  S: this,
1942
1972
  A: [
@@ -1944,10 +1974,10 @@ var ConnectionLimiter = class {
1944
1974
  "'Peer is already waiting for connection'"
1945
1975
  ]
1946
1976
  });
1947
- log6("waiting", {
1977
+ log7("waiting", {
1948
1978
  sessionId
1949
1979
  }, {
1950
- F: __dxlog_file6,
1980
+ F: __dxlog_file7,
1951
1981
  L: 49,
1952
1982
  S: this,
1953
1983
  C: (f, a) => f(...a)
@@ -1959,10 +1989,10 @@ var ConnectionLimiter = class {
1959
1989
  });
1960
1990
  this.resolveWaitingPromises.schedule();
1961
1991
  });
1962
- log6("allow", {
1992
+ log7("allow", {
1963
1993
  sessionId
1964
1994
  }, {
1965
- F: __dxlog_file6,
1995
+ F: __dxlog_file7,
1966
1996
  L: 57,
1967
1997
  S: this,
1968
1998
  C: (f, a) => f(...a)
@@ -1972,10 +2002,10 @@ var ConnectionLimiter = class {
1972
2002
  * Rejects promise returned by `connecting` method.
1973
2003
  */
1974
2004
  doneConnecting(sessionId) {
1975
- log6("done", {
2005
+ log7("done", {
1976
2006
  sessionId
1977
2007
  }, {
1978
- F: __dxlog_file6,
2008
+ F: __dxlog_file7,
1979
2009
  L: 64,
1980
2010
  S: this,
1981
2011
  C: (f, a) => f(...a)
@@ -2085,7 +2115,7 @@ var gcSwarm = (swarm) => {
2085
2115
  import { Event as Event6, synchronized as synchronized4 } from "@dxos/async";
2086
2116
  import { invariant as invariant6 } from "@dxos/invariant";
2087
2117
  import { PublicKey as PublicKey8 } from "@dxos/keys";
2088
- import { log as log7 } from "@dxos/log";
2118
+ import { log as log8 } from "@dxos/log";
2089
2119
  import { Messenger } from "@dxos/messaging";
2090
2120
  import { trace as trace3 } from "@dxos/protocols";
2091
2121
  import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
@@ -2096,7 +2126,7 @@ function _ts_decorate4(decorators, target, key, desc) {
2096
2126
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2097
2127
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2098
2128
  }
2099
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
2129
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
2100
2130
  var SwarmNetworkManager = class {
2101
2131
  constructor({ transportFactory, signalManager, enableDevtoolsLogging, peerInfo }) {
2102
2132
  /**
@@ -2146,20 +2176,20 @@ var SwarmNetworkManager = class {
2146
2176
  this._peerInfo = peerInfo;
2147
2177
  }
2148
2178
  async open() {
2149
- log7.trace("dxos.mesh.network-manager.open", trace3.begin({
2179
+ log8.trace("dxos.mesh.network-manager.open", trace3.begin({
2150
2180
  id: this._instanceId
2151
2181
  }), {
2152
- F: __dxlog_file7,
2182
+ F: __dxlog_file8,
2153
2183
  L: 133,
2154
2184
  S: this,
2155
2185
  C: (f, a) => f(...a)
2156
2186
  });
2157
2187
  await this._messenger.open();
2158
2188
  await this._signalManager.open();
2159
- log7.trace("dxos.mesh.network-manager.open", trace3.end({
2189
+ log8.trace("dxos.mesh.network-manager.open", trace3.end({
2160
2190
  id: this._instanceId
2161
2191
  }), {
2162
- F: __dxlog_file7,
2192
+ F: __dxlog_file8,
2163
2193
  L: 136,
2164
2194
  S: this,
2165
2195
  C: (f, a) => f(...a)
@@ -2168,8 +2198,8 @@ var SwarmNetworkManager = class {
2168
2198
  async close() {
2169
2199
  for (const topic of this._swarms.keys()) {
2170
2200
  await this.leaveSwarm(topic).catch((err) => {
2171
- log7(err, void 0, {
2172
- F: __dxlog_file7,
2201
+ log8(err, void 0, {
2202
+ F: __dxlog_file8,
2173
2203
  L: 142,
2174
2204
  S: this,
2175
2205
  C: (f, a) => f(...a)
@@ -2184,7 +2214,7 @@ var SwarmNetworkManager = class {
2184
2214
  */
2185
2215
  async joinSwarm({ topic, topology, protocolProvider: protocol, label }) {
2186
2216
  invariant6(PublicKey8.isPublicKey(topic), void 0, {
2187
- F: __dxlog_file7,
2217
+ F: __dxlog_file8,
2188
2218
  L: 160,
2189
2219
  S: this,
2190
2220
  A: [
@@ -2193,7 +2223,7 @@ var SwarmNetworkManager = class {
2193
2223
  ]
2194
2224
  });
2195
2225
  invariant6(topology, void 0, {
2196
- F: __dxlog_file7,
2226
+ F: __dxlog_file8,
2197
2227
  L: 161,
2198
2228
  S: this,
2199
2229
  A: [
@@ -2202,7 +2232,7 @@ var SwarmNetworkManager = class {
2202
2232
  ]
2203
2233
  });
2204
2234
  invariant6(this._peerInfo, void 0, {
2205
- F: __dxlog_file7,
2235
+ F: __dxlog_file8,
2206
2236
  L: 162,
2207
2237
  S: this,
2208
2238
  A: [
@@ -2211,7 +2241,7 @@ var SwarmNetworkManager = class {
2211
2241
  ]
2212
2242
  });
2213
2243
  invariant6(typeof protocol === "function", void 0, {
2214
- F: __dxlog_file7,
2244
+ F: __dxlog_file8,
2215
2245
  L: 163,
2216
2246
  S: this,
2217
2247
  A: [
@@ -2222,22 +2252,22 @@ var SwarmNetworkManager = class {
2222
2252
  if (this._swarms.has(topic)) {
2223
2253
  throw new Error(`Already connected to swarm: ${PublicKey8.from(topic)}`);
2224
2254
  }
2225
- log7("joining", {
2255
+ log8("joining", {
2226
2256
  topic: PublicKey8.from(topic),
2227
2257
  peerInfo: this._peerInfo,
2228
2258
  topology: topology.toString()
2229
2259
  }, {
2230
- F: __dxlog_file7,
2260
+ F: __dxlog_file8,
2231
2261
  L: 168,
2232
2262
  S: this,
2233
2263
  C: (f, a) => f(...a)
2234
2264
  });
2235
2265
  const swarm = new Swarm(topic, this._peerInfo, topology, protocol, this._messenger, this._transportFactory, label, this._connectionLimiter);
2236
2266
  swarm.errors.handle((error) => {
2237
- log7("swarm error", {
2267
+ log8("swarm error", {
2238
2268
  error
2239
2269
  }, {
2240
- F: __dxlog_file7,
2270
+ F: __dxlog_file8,
2241
2271
  L: 181,
2242
2272
  S: this,
2243
2273
  C: (f, a) => f(...a)
@@ -2249,19 +2279,19 @@ var SwarmNetworkManager = class {
2249
2279
  this._signalConnection.join({
2250
2280
  topic,
2251
2281
  peer: this._peerInfo
2252
- }).catch((error) => log7.catch(error, void 0, {
2253
- F: __dxlog_file7,
2282
+ }).catch((error) => log8.catch(error, void 0, {
2283
+ F: __dxlog_file8,
2254
2284
  L: 190,
2255
2285
  S: this,
2256
2286
  C: (f, a) => f(...a)
2257
2287
  }));
2258
2288
  this.topicsUpdated.emit();
2259
2289
  this._connectionLog?.joinedSwarm(swarm);
2260
- log7("joined", {
2290
+ log8("joined", {
2261
2291
  topic: PublicKey8.from(topic),
2262
2292
  count: this._swarms.size
2263
2293
  }, {
2264
- F: __dxlog_file7,
2294
+ F: __dxlog_file8,
2265
2295
  L: 194,
2266
2296
  S: this,
2267
2297
  C: (f, a) => f(...a)
@@ -2277,10 +2307,10 @@ var SwarmNetworkManager = class {
2277
2307
  if (!this._swarms.has(topic)) {
2278
2308
  return;
2279
2309
  }
2280
- log7("leaving", {
2310
+ log8("leaving", {
2281
2311
  topic: PublicKey8.from(topic)
2282
2312
  }, {
2283
- F: __dxlog_file7,
2313
+ F: __dxlog_file8,
2284
2314
  L: 211,
2285
2315
  S: this,
2286
2316
  C: (f, a) => f(...a)
@@ -2297,11 +2327,11 @@ var SwarmNetworkManager = class {
2297
2327
  await swarm.destroy();
2298
2328
  this._swarms.delete(topic);
2299
2329
  this.topicsUpdated.emit();
2300
- log7("left", {
2330
+ log8("left", {
2301
2331
  topic: PublicKey8.from(topic),
2302
2332
  count: this._swarms.size
2303
2333
  }, {
2304
- F: __dxlog_file7,
2334
+ F: __dxlog_file8,
2305
2335
  L: 225,
2306
2336
  S: this,
2307
2337
  C: (f, a) => f(...a)
@@ -2343,14 +2373,14 @@ _ts_decorate4([
2343
2373
 
2344
2374
  // packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
2345
2375
  import { invariant as invariant7 } from "@dxos/invariant";
2346
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
2376
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
2347
2377
  var FullyConnectedTopology = class {
2348
2378
  toString() {
2349
2379
  return "FullyConnectedTopology";
2350
2380
  }
2351
2381
  init(controller) {
2352
2382
  invariant7(!this._controller, "Already initialized", {
2353
- F: __dxlog_file8,
2383
+ F: __dxlog_file9,
2354
2384
  L: 18,
2355
2385
  S: this,
2356
2386
  A: [
@@ -2362,7 +2392,7 @@ var FullyConnectedTopology = class {
2362
2392
  }
2363
2393
  update() {
2364
2394
  invariant7(this._controller, "Not initialized", {
2365
- F: __dxlog_file8,
2395
+ F: __dxlog_file9,
2366
2396
  L: 23,
2367
2397
  S: this,
2368
2398
  A: [
@@ -2382,13 +2412,315 @@ var FullyConnectedTopology = class {
2382
2412
  }
2383
2413
  };
2384
2414
 
2415
+ // packages/core/mesh/network-manager/src/topology/mmst-topology.ts
2416
+ import { invariant as invariant8 } from "@dxos/invariant";
2417
+ import { log as log9 } from "@dxos/log";
2418
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
2419
+ var MIN_UPDATE_INTERVAL = 1e3 * 10;
2420
+ var MAX_CHANGES_PER_UPDATE = 1;
2421
+ var MMSTTopology = class {
2422
+ constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
2423
+ this._sampleCollected = false;
2424
+ this._lastAction = /* @__PURE__ */ new Date(0);
2425
+ this._originateConnections = originateConnections;
2426
+ this._maxPeers = maxPeers;
2427
+ this._sampleSize = sampleSize;
2428
+ }
2429
+ init(controller) {
2430
+ invariant8(!this._controller, "Already initialized", {
2431
+ F: __dxlog_file10,
2432
+ L: 49,
2433
+ S: this,
2434
+ A: [
2435
+ "!this._controller",
2436
+ "'Already initialized'"
2437
+ ]
2438
+ });
2439
+ this._controller = controller;
2440
+ }
2441
+ update() {
2442
+ invariant8(this._controller, "Not initialized", {
2443
+ F: __dxlog_file10,
2444
+ L: 54,
2445
+ S: this,
2446
+ A: [
2447
+ "this._controller",
2448
+ "'Not initialized'"
2449
+ ]
2450
+ });
2451
+ const { connected, candidates } = this._controller.getState();
2452
+ if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
2453
+ log9("Running the algorithm.", void 0, {
2454
+ F: __dxlog_file10,
2455
+ L: 58,
2456
+ S: this,
2457
+ C: (f, a) => f(...a)
2458
+ });
2459
+ this._sampleCollected = true;
2460
+ this._runAlgorithm();
2461
+ }
2462
+ }
2463
+ forceUpdate() {
2464
+ this._lastAction = /* @__PURE__ */ new Date(0);
2465
+ this.update();
2466
+ }
2467
+ async onOffer(peer) {
2468
+ invariant8(this._controller, "Not initialized", {
2469
+ F: __dxlog_file10,
2470
+ L: 70,
2471
+ S: this,
2472
+ A: [
2473
+ "this._controller",
2474
+ "'Not initialized'"
2475
+ ]
2476
+ });
2477
+ const { connected } = this._controller.getState();
2478
+ const accept = connected.length < this._maxPeers;
2479
+ log9(`Offer ${peer} accept=${accept}`, void 0, {
2480
+ F: __dxlog_file10,
2481
+ L: 73,
2482
+ S: this,
2483
+ C: (f, a) => f(...a)
2484
+ });
2485
+ return accept;
2486
+ }
2487
+ async destroy() {
2488
+ }
2489
+ _runAlgorithm() {
2490
+ invariant8(this._controller, "Not initialized", {
2491
+ F: __dxlog_file10,
2492
+ L: 82,
2493
+ S: this,
2494
+ A: [
2495
+ "this._controller",
2496
+ "'Not initialized'"
2497
+ ]
2498
+ });
2499
+ const { connected, candidates, ownPeerId } = this._controller.getState();
2500
+ if (connected.length > this._maxPeers) {
2501
+ log9(`disconnect ${connected.length - this._maxPeers} peers.`, void 0, {
2502
+ F: __dxlog_file10,
2503
+ L: 88,
2504
+ S: this,
2505
+ C: (f, a) => f(...a)
2506
+ });
2507
+ const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
2508
+ invariant8(sorted.length === 0, void 0, {
2509
+ F: __dxlog_file10,
2510
+ L: 92,
2511
+ S: this,
2512
+ A: [
2513
+ "sorted.length === 0",
2514
+ ""
2515
+ ]
2516
+ });
2517
+ if (sorted.length > MAX_CHANGES_PER_UPDATE) {
2518
+ log9(`want to disconnect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`, void 0, {
2519
+ F: __dxlog_file10,
2520
+ L: 95,
2521
+ S: this,
2522
+ C: (f, a) => f(...a)
2523
+ });
2524
+ }
2525
+ if (Date.now() - this._lastAction.getTime() > MIN_UPDATE_INTERVAL) {
2526
+ for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
2527
+ log9(`Disconnect ${peer}.`, void 0, {
2528
+ F: __dxlog_file10,
2529
+ L: 100,
2530
+ S: this,
2531
+ C: (f, a) => f(...a)
2532
+ });
2533
+ this._controller.disconnect(peer);
2534
+ }
2535
+ this._lastAction = /* @__PURE__ */ new Date();
2536
+ } else {
2537
+ log9("rate limited disconnect", void 0, {
2538
+ F: __dxlog_file10,
2539
+ L: 105,
2540
+ S: this,
2541
+ C: (f, a) => f(...a)
2542
+ });
2543
+ }
2544
+ } else if (connected.length < this._originateConnections) {
2545
+ log9(`connect ${this._originateConnections - connected.length} peers.`, void 0, {
2546
+ F: __dxlog_file10,
2547
+ L: 109,
2548
+ S: this,
2549
+ C: (f, a) => f(...a)
2550
+ });
2551
+ const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
2552
+ const sorted = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
2553
+ if (sorted.length > MAX_CHANGES_PER_UPDATE) {
2554
+ log9(`want to connect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`, void 0, {
2555
+ F: __dxlog_file10,
2556
+ L: 114,
2557
+ S: this,
2558
+ C: (f, a) => f(...a)
2559
+ });
2560
+ }
2561
+ if (Date.now() - this._lastAction.getTime() > MIN_UPDATE_INTERVAL) {
2562
+ for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
2563
+ log9(`Connect ${peer}.`, void 0, {
2564
+ F: __dxlog_file10,
2565
+ L: 118,
2566
+ S: this,
2567
+ C: (f, a) => f(...a)
2568
+ });
2569
+ this._controller.connect(peer);
2570
+ }
2571
+ this._lastAction = /* @__PURE__ */ new Date();
2572
+ } else {
2573
+ log9("rate limited connect", void 0, {
2574
+ F: __dxlog_file10,
2575
+ L: 123,
2576
+ S: this,
2577
+ C: (f, a) => f(...a)
2578
+ });
2579
+ }
2580
+ }
2581
+ }
2582
+ toString() {
2583
+ return "MMSTTopology";
2584
+ }
2585
+ };
2586
+ var sortByXorDistance = (keys, reference) => {
2587
+ const sorted = keys.sort((a, b) => {
2588
+ return compareXor(distXor(a.asBuffer(), reference.asBuffer()), distXor(b.asBuffer(), reference.asBuffer()));
2589
+ });
2590
+ log9("Sorted keys", {
2591
+ keys,
2592
+ reference,
2593
+ sorted
2594
+ }, {
2595
+ F: __dxlog_file10,
2596
+ L: 137,
2597
+ S: void 0,
2598
+ C: (f, a) => f(...a)
2599
+ });
2600
+ return sorted;
2601
+ };
2602
+ var distXor = (a, b) => {
2603
+ const maxLength = Math.max(a.length, b.length);
2604
+ const result = Buffer.allocUnsafe(maxLength);
2605
+ for (let i = 0; i < maxLength; i++) {
2606
+ result[i] = (a[i] || 0) ^ (b[i] || 0);
2607
+ }
2608
+ return result;
2609
+ };
2610
+ var compareXor = (a, b) => {
2611
+ const maxLength = Math.max(a.length, b.length);
2612
+ for (let i = 0; i < maxLength; i++) {
2613
+ if ((a[i] || 0) === (b[i] || 0)) {
2614
+ continue;
2615
+ }
2616
+ return (a[i] || 0) < (b[i] || 0) ? -1 : 1;
2617
+ }
2618
+ return 0;
2619
+ };
2620
+
2621
+ // packages/core/mesh/network-manager/src/topology/star-topology.ts
2622
+ import { invariant as invariant9 } from "@dxos/invariant";
2623
+ import { log as log10 } from "@dxos/log";
2624
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
2625
+ var StarTopology = class {
2626
+ constructor(_centralPeer) {
2627
+ this._centralPeer = _centralPeer;
2628
+ }
2629
+ toString() {
2630
+ return `StarTopology(${this._centralPeer.truncate()})`;
2631
+ }
2632
+ init(controller) {
2633
+ invariant9(!this._controller, "Already initialized.", {
2634
+ F: __dxlog_file11,
2635
+ L: 21,
2636
+ S: this,
2637
+ A: [
2638
+ "!this._controller",
2639
+ "'Already initialized.'"
2640
+ ]
2641
+ });
2642
+ this._controller = controller;
2643
+ }
2644
+ update() {
2645
+ invariant9(this._controller, "Not initialized.", {
2646
+ F: __dxlog_file11,
2647
+ L: 26,
2648
+ S: this,
2649
+ A: [
2650
+ "this._controller",
2651
+ "'Not initialized.'"
2652
+ ]
2653
+ });
2654
+ const { candidates, connected, ownPeerId } = this._controller.getState();
2655
+ if (!ownPeerId.equals(this._centralPeer)) {
2656
+ log10("leaf peer dropping all connections apart from central peer.", void 0, {
2657
+ F: __dxlog_file11,
2658
+ L: 29,
2659
+ S: this,
2660
+ C: (f, a) => f(...a)
2661
+ });
2662
+ for (const peer of connected) {
2663
+ if (!peer.equals(this._centralPeer)) {
2664
+ log10("dropping connection", {
2665
+ peer
2666
+ }, {
2667
+ F: __dxlog_file11,
2668
+ L: 34,
2669
+ S: this,
2670
+ C: (f, a) => f(...a)
2671
+ });
2672
+ this._controller.disconnect(peer);
2673
+ }
2674
+ }
2675
+ }
2676
+ for (const peer of candidates) {
2677
+ if (peer.equals(this._centralPeer) || ownPeerId.equals(this._centralPeer)) {
2678
+ log10("connecting to peer", {
2679
+ peer
2680
+ }, {
2681
+ F: __dxlog_file11,
2682
+ L: 43,
2683
+ S: this,
2684
+ C: (f, a) => f(...a)
2685
+ });
2686
+ this._controller.connect(peer);
2687
+ }
2688
+ }
2689
+ }
2690
+ async onOffer(peer) {
2691
+ invariant9(this._controller, "Not initialized.", {
2692
+ F: __dxlog_file11,
2693
+ L: 50,
2694
+ S: this,
2695
+ A: [
2696
+ "this._controller",
2697
+ "'Not initialized.'"
2698
+ ]
2699
+ });
2700
+ const { ownPeerId } = this._controller.getState();
2701
+ log10("offer", {
2702
+ peer,
2703
+ isCentral: peer.equals(this._centralPeer),
2704
+ isSelfCentral: ownPeerId.equals(this._centralPeer)
2705
+ }, {
2706
+ F: __dxlog_file11,
2707
+ L: 52,
2708
+ S: this,
2709
+ C: (f, a) => f(...a)
2710
+ });
2711
+ return ownPeerId.equals(this._centralPeer) || peer.equals(this._centralPeer);
2712
+ }
2713
+ async destroy() {
2714
+ }
2715
+ };
2716
+
2385
2717
  // packages/core/mesh/network-manager/src/transport/memory-transport.ts
2386
2718
  import { Transform } from "@dxos/node-std/stream";
2387
2719
  import { Event as Event7, Trigger as Trigger2 } from "@dxos/async";
2388
2720
  import { ErrorStream as ErrorStream3 } from "@dxos/debug";
2389
- import { invariant as invariant8 } from "@dxos/invariant";
2721
+ import { invariant as invariant10 } from "@dxos/invariant";
2390
2722
  import { PublicKey as PublicKey9 } from "@dxos/keys";
2391
- import { log as log8, logInfo as logInfo3 } from "@dxos/log";
2723
+ import { log as log11, logInfo as logInfo3 } from "@dxos/log";
2392
2724
  import { ComplexMap as ComplexMap7 } from "@dxos/util";
2393
2725
  function _ts_decorate5(decorators, target, key, desc) {
2394
2726
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -2396,7 +2728,7 @@ function _ts_decorate5(decorators, target, key, desc) {
2396
2728
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2397
2729
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2398
2730
  }
2399
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
2731
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
2400
2732
  var MEMORY_TRANSPORT_DELAY = 1;
2401
2733
  var createStreamDelay = (delay) => {
2402
2734
  return new Transform({
@@ -2424,8 +2756,8 @@ var MemoryTransport = class _MemoryTransport {
2424
2756
  this.closed = new Event7();
2425
2757
  this.connected = new Event7();
2426
2758
  this.errors = new ErrorStream3();
2427
- invariant8(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection", {
2428
- F: __dxlog_file9,
2759
+ invariant10(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection", {
2760
+ F: __dxlog_file12,
2429
2761
  L: 64,
2430
2762
  S: this,
2431
2763
  A: [
@@ -2439,15 +2771,15 @@ var MemoryTransport = class _MemoryTransport {
2439
2771
  return !this._closed;
2440
2772
  }
2441
2773
  async open() {
2442
- log8("opening...", void 0, {
2443
- F: __dxlog_file9,
2774
+ log11("opening...", void 0, {
2775
+ F: __dxlog_file12,
2444
2776
  L: 74,
2445
2777
  S: this,
2446
2778
  C: (f, a) => f(...a)
2447
2779
  });
2448
2780
  if (this._options.initiator) {
2449
- log8("sending signal", void 0, {
2450
- F: __dxlog_file9,
2781
+ log11("sending signal", void 0, {
2782
+ F: __dxlog_file12,
2451
2783
  L: 78,
2452
2784
  S: this,
2453
2785
  C: (f, a) => f(...a)
@@ -2477,8 +2809,8 @@ var MemoryTransport = class _MemoryTransport {
2477
2809
  this.closed.emit();
2478
2810
  return;
2479
2811
  }
2480
- invariant8(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`, {
2481
- F: __dxlog_file9,
2812
+ invariant10(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`, {
2813
+ F: __dxlog_file12,
2482
2814
  L: 104,
2483
2815
  S: this,
2484
2816
  A: [
@@ -2488,8 +2820,8 @@ var MemoryTransport = class _MemoryTransport {
2488
2820
  });
2489
2821
  this._remoteConnection._remoteConnection = this;
2490
2822
  this._remoteConnection._remoteInstanceId = this._instanceId;
2491
- log8("connected", void 0, {
2492
- F: __dxlog_file9,
2823
+ log11("connected", void 0, {
2824
+ F: __dxlog_file12,
2493
2825
  L: 108,
2494
2826
  S: this,
2495
2827
  C: (f, a) => f(...a)
@@ -2507,8 +2839,8 @@ var MemoryTransport = class _MemoryTransport {
2507
2839
  return this;
2508
2840
  }
2509
2841
  async close() {
2510
- log8("closing...", void 0, {
2511
- F: __dxlog_file9,
2842
+ log11("closing...", void 0, {
2843
+ F: __dxlog_file12,
2512
2844
  L: 130,
2513
2845
  S: this,
2514
2846
  C: (f, a) => f(...a)
@@ -2528,8 +2860,8 @@ var MemoryTransport = class _MemoryTransport {
2528
2860
  this._remoteConnection = void 0;
2529
2861
  }
2530
2862
  this.closed.emit();
2531
- log8("closed", void 0, {
2532
- F: __dxlog_file9,
2863
+ log11("closed", void 0, {
2864
+ F: __dxlog_file12,
2533
2865
  L: 158,
2534
2866
  S: this,
2535
2867
  C: (f, a) => f(...a)
@@ -2537,10 +2869,10 @@ var MemoryTransport = class _MemoryTransport {
2537
2869
  return this;
2538
2870
  }
2539
2871
  async onSignal({ payload }) {
2540
- log8("received signal", {
2872
+ log11("received signal", {
2541
2873
  payload
2542
2874
  }, {
2543
- F: __dxlog_file9,
2875
+ F: __dxlog_file12,
2544
2876
  L: 163,
2545
2877
  S: this,
2546
2878
  C: (f, a) => f(...a)
@@ -2634,8 +2966,8 @@ var getRtcConnectionFactory = () => {
2634
2966
 
2635
2967
  // packages/core/mesh/network-manager/src/transport/webrtc/rtc-peer-connection.ts
2636
2968
  import { synchronized as synchronized5, Trigger as Trigger3, Mutex as Mutex2 } from "@dxos/async";
2637
- import { invariant as invariant10 } from "@dxos/invariant";
2638
- import { log as log10, logInfo as logInfo4 } from "@dxos/log";
2969
+ import { invariant as invariant12 } from "@dxos/invariant";
2970
+ import { log as log13, logInfo as logInfo4 } from "@dxos/log";
2639
2971
  import { ConnectivityError as ConnectivityError3 } from "@dxos/protocols";
2640
2972
  import { trace as trace4 } from "@dxos/tracing";
2641
2973
 
@@ -2644,8 +2976,8 @@ import { Duplex } from "@dxos/node-std/stream";
2644
2976
  import { Event as AsyncEvent } from "@dxos/async";
2645
2977
  import { Resource } from "@dxos/context";
2646
2978
  import { ErrorStream as ErrorStream4 } from "@dxos/debug";
2647
- import { invariant as invariant9 } from "@dxos/invariant";
2648
- import { log as log9 } from "@dxos/log";
2979
+ import { invariant as invariant11 } from "@dxos/invariant";
2980
+ import { log as log12 } from "@dxos/log";
2649
2981
  import { ConnectivityError as ConnectivityError2 } from "@dxos/protocols";
2650
2982
 
2651
2983
  // packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-stats.ts
@@ -2696,7 +3028,7 @@ var getRtcConnectionStats = async (connection, channelTopic) => {
2696
3028
  };
2697
3029
 
2698
3030
  // packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-channel.ts
2699
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-channel.ts";
3031
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-channel.ts";
2700
3032
  var MAX_MESSAGE_SIZE = 64 * 1024;
2701
3033
  var MAX_BUFFERED_AMOUNT = 64 * 1024;
2702
3034
  var RtcTransportChannel = class extends Resource {
@@ -2719,8 +3051,8 @@ var RtcTransportChannel = class extends Resource {
2719
3051
  }
2720
3052
  }
2721
3053
  async _open() {
2722
- invariant9(!this._isChannelCreationInProgress, void 0, {
2723
- F: __dxlog_file10,
3054
+ invariant11(!this._isChannelCreationInProgress, void 0, {
3055
+ F: __dxlog_file13,
2724
3056
  L: 56,
2725
3057
  S: this,
2726
3058
  A: [
@@ -2751,8 +3083,8 @@ var RtcTransportChannel = class extends Resource {
2751
3083
  this._stream = void 0;
2752
3084
  }
2753
3085
  this.closed.emit();
2754
- log9("closed", void 0, {
2755
- F: __dxlog_file10,
3086
+ log12("closed", void 0, {
3087
+ F: __dxlog_file13,
2756
3088
  L: 86,
2757
3089
  S: this,
2758
3090
  C: (f, a) => f(...a)
@@ -2762,10 +3094,10 @@ var RtcTransportChannel = class extends Resource {
2762
3094
  Object.assign(channel, {
2763
3095
  onopen: () => {
2764
3096
  if (!this.isOpen) {
2765
- log9.warn("channel opened in a closed transport", {
3097
+ log12.warn("channel opened in a closed transport", {
2766
3098
  topic: this._options.topic
2767
3099
  }, {
2768
- F: __dxlog_file10,
3100
+ F: __dxlog_file13,
2769
3101
  L: 93,
2770
3102
  S: this,
2771
3103
  C: (f, a) => f(...a)
@@ -2773,8 +3105,8 @@ var RtcTransportChannel = class extends Resource {
2773
3105
  this._safeCloseChannel(channel);
2774
3106
  return;
2775
3107
  }
2776
- log9("onopen", void 0, {
2777
- F: __dxlog_file10,
3108
+ log12("onopen", void 0, {
3109
+ F: __dxlog_file13,
2778
3110
  L: 98,
2779
3111
  S: this,
2780
3112
  C: (f, a) => f(...a)
@@ -2791,8 +3123,8 @@ var RtcTransportChannel = class extends Resource {
2791
3123
  this.connected.emit();
2792
3124
  },
2793
3125
  onclose: async () => {
2794
- log9("onclose", void 0, {
2795
- F: __dxlog_file10,
3126
+ log12("onclose", void 0, {
3127
+ F: __dxlog_file13,
2796
3128
  L: 111,
2797
3129
  S: this,
2798
3130
  C: (f, a) => f(...a)
@@ -2801,8 +3133,8 @@ var RtcTransportChannel = class extends Resource {
2801
3133
  },
2802
3134
  onmessage: (event) => {
2803
3135
  if (!this._stream) {
2804
- log9.warn("ignoring message on a closed channel", void 0, {
2805
- F: __dxlog_file10,
3136
+ log12.warn("ignoring message on a closed channel", void 0, {
3137
+ F: __dxlog_file13,
2806
3138
  L: 117,
2807
3139
  S: this,
2808
3140
  C: (f, a) => f(...a)
@@ -2830,8 +3162,8 @@ var RtcTransportChannel = class extends Resource {
2830
3162
  }
2831
3163
  async _handleChannelWrite(chunk, callback) {
2832
3164
  if (!this._channel) {
2833
- log9.warn("writing to a channel after a connection was closed", void 0, {
2834
- F: __dxlog_file10,
3165
+ log12.warn("writing to a channel after a connection was closed", void 0, {
3166
+ F: __dxlog_file13,
2835
3167
  L: 145,
2836
3168
  S: this,
2837
3169
  C: (f, a) => f(...a)
@@ -2853,8 +3185,8 @@ var RtcTransportChannel = class extends Resource {
2853
3185
  }
2854
3186
  if (this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT) {
2855
3187
  if (this._streamDataFlushedCallback !== null) {
2856
- log9.error("consumer trying to write before we are ready for more data", void 0, {
2857
- F: __dxlog_file10,
3188
+ log12.error("consumer trying to write before we are ready for more data", void 0, {
3189
+ F: __dxlog_file13,
2858
3190
  L: 166,
2859
3191
  S: this,
2860
3192
  C: (f, a) => f(...a)
@@ -2869,8 +3201,8 @@ var RtcTransportChannel = class extends Resource {
2869
3201
  try {
2870
3202
  channel.close();
2871
3203
  } catch (error) {
2872
- log9.catch(error, void 0, {
2873
- F: __dxlog_file10,
3204
+ log12.catch(error, void 0, {
3205
+ F: __dxlog_file13,
2874
3206
  L: 178,
2875
3207
  S: this,
2876
3208
  C: (f, a) => f(...a)
@@ -2921,7 +3253,7 @@ function _ts_decorate6(decorators, target, key, desc) {
2921
3253
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2922
3254
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2923
3255
  }
2924
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-peer-connection.ts";
3256
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-peer-connection.ts";
2925
3257
  var RtcPeerConnection = class {
2926
3258
  constructor(_factory, _options) {
2927
3259
  this._factory = _factory;
@@ -2956,8 +3288,8 @@ var RtcPeerConnection = class {
2956
3288
  if (existingChannel) {
2957
3289
  return existingChannel;
2958
3290
  }
2959
- log10("waiting for initiator-peer to open a data channel", void 0, {
2960
- F: __dxlog_file11,
3291
+ log13("waiting for initiator-peer to open a data channel", void 0, {
3292
+ F: __dxlog_file14,
2961
3293
  L: 90,
2962
3294
  S: this,
2963
3295
  C: (f, a) => f(...a)
@@ -2985,10 +3317,10 @@ var RtcPeerConnection = class {
2985
3317
  if (this._connection) {
2986
3318
  return this._connection;
2987
3319
  }
2988
- log10("initializing connection...", () => ({
3320
+ log13("initializing connection...", () => ({
2989
3321
  remotePeer: this._options.remotePeerKey
2990
3322
  }), {
2991
- F: __dxlog_file11,
3323
+ F: __dxlog_file14,
2992
3324
  L: 115,
2993
3325
  S: this,
2994
3326
  C: (f, a) => f(...a)
@@ -2998,8 +3330,8 @@ var RtcPeerConnection = class {
2998
3330
  const iceCandidateErrors = [];
2999
3331
  Object.assign(connection, {
3000
3332
  onnegotiationneeded: async () => {
3001
- invariant10(this._initiator, void 0, {
3002
- F: __dxlog_file11,
3333
+ invariant12(this._initiator, void 0, {
3334
+ F: __dxlog_file14,
3003
3335
  L: 130,
3004
3336
  S: this,
3005
3337
  A: [
@@ -3011,8 +3343,8 @@ var RtcPeerConnection = class {
3011
3343
  this._onConnectionCallbackAfterClose("onnegotiationneeded", connection);
3012
3344
  return;
3013
3345
  }
3014
- log10("onnegotiationneeded", void 0, {
3015
- F: __dxlog_file11,
3346
+ log13("onnegotiationneeded", void 0, {
3347
+ F: __dxlog_file14,
3016
3348
  L: 137,
3017
3349
  S: this,
3018
3350
  C: (f, a) => f(...a)
@@ -3033,18 +3365,18 @@ var RtcPeerConnection = class {
3033
3365
  return;
3034
3366
  }
3035
3367
  if (event.candidate) {
3036
- log10("onicecandidate", {
3368
+ log13("onicecandidate", {
3037
3369
  candidate: event.candidate.candidate
3038
3370
  }, {
3039
- F: __dxlog_file11,
3371
+ F: __dxlog_file14,
3040
3372
  L: 156,
3041
3373
  S: this,
3042
3374
  C: (f, a) => f(...a)
3043
3375
  });
3044
3376
  await this._sendIceCandidate(event.candidate);
3045
3377
  } else {
3046
- log10("onicecandidate gathering complete", void 0, {
3047
- F: __dxlog_file11,
3378
+ log13("onicecandidate gathering complete", void 0, {
3379
+ F: __dxlog_file14,
3048
3380
  L: 159,
3049
3381
  S: this,
3050
3382
  C: (f, a) => f(...a)
@@ -3069,10 +3401,10 @@ var RtcPeerConnection = class {
3069
3401
  this._onConnectionCallbackAfterClose("oniceconnectionstatechange", connection);
3070
3402
  return;
3071
3403
  }
3072
- log10("oniceconnectionstatechange", {
3404
+ log13("oniceconnectionstatechange", {
3073
3405
  state: connection.iceConnectionState
3074
3406
  }, {
3075
- F: __dxlog_file11,
3407
+ F: __dxlog_file14,
3076
3408
  L: 179,
3077
3409
  S: this,
3078
3410
  C: (f, a) => f(...a)
@@ -3091,10 +3423,10 @@ var RtcPeerConnection = class {
3091
3423
  }
3092
3424
  return;
3093
3425
  }
3094
- log10("onconnectionstatechange", {
3426
+ log13("onconnectionstatechange", {
3095
3427
  state: connection.connectionState
3096
3428
  }, {
3097
- F: __dxlog_file11,
3429
+ F: __dxlog_file14,
3098
3430
  L: 196,
3099
3431
  S: this,
3100
3432
  C: (f, a) => f(...a)
@@ -3104,10 +3436,10 @@ var RtcPeerConnection = class {
3104
3436
  }
3105
3437
  },
3106
3438
  onsignalingstatechange: () => {
3107
- log10("onsignalingstatechange", {
3439
+ log13("onsignalingstatechange", {
3108
3440
  state: connection.signalingState
3109
3441
  }, {
3110
- F: __dxlog_file11,
3442
+ F: __dxlog_file14,
3111
3443
  L: 203,
3112
3444
  S: this,
3113
3445
  C: (f, a) => f(...a)
@@ -3116,8 +3448,8 @@ var RtcPeerConnection = class {
3116
3448
  // When channel is added to connection.
3117
3449
  // https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/datachannel_event
3118
3450
  ondatachannel: (event) => {
3119
- invariant10(!this._initiator, "Initiator is expected to create data channels.", {
3120
- F: __dxlog_file11,
3451
+ invariant12(!this._initiator, "Initiator is expected to create data channels.", {
3452
+ F: __dxlog_file14,
3121
3453
  L: 209,
3122
3454
  S: this,
3123
3455
  A: [
@@ -3129,10 +3461,10 @@ var RtcPeerConnection = class {
3129
3461
  this._onConnectionCallbackAfterClose("ondatachannel", connection);
3130
3462
  return;
3131
3463
  }
3132
- log10("ondatachannel", {
3464
+ log13("ondatachannel", {
3133
3465
  label: event.channel.label
3134
3466
  }, {
3135
- F: __dxlog_file11,
3467
+ F: __dxlog_file14,
3136
3468
  L: 216,
3137
3469
  S: this,
3138
3470
  C: (f, a) => f(...a)
@@ -3157,10 +3489,10 @@ var RtcPeerConnection = class {
3157
3489
  }
3158
3490
  _abortConnection(connection, error) {
3159
3491
  if (connection !== this._connection) {
3160
- log10.error("attempted to abort an inactive connection", {
3492
+ log13.error("attempted to abort an inactive connection", {
3161
3493
  error
3162
3494
  }, {
3163
- F: __dxlog_file11,
3495
+ F: __dxlog_file14,
3164
3496
  L: 241,
3165
3497
  S: this,
3166
3498
  C: (f, a) => f(...a)
@@ -3178,18 +3510,18 @@ var RtcPeerConnection = class {
3178
3510
  }
3179
3511
  this._transportChannels.clear();
3180
3512
  this._safeCloseConnection();
3181
- log10("connection aborted", {
3513
+ log13("connection aborted", {
3182
3514
  reason: error.message
3183
3515
  }, {
3184
- F: __dxlog_file11,
3516
+ F: __dxlog_file14,
3185
3517
  L: 255,
3186
3518
  S: this,
3187
3519
  C: (f, a) => f(...a)
3188
3520
  });
3189
3521
  }
3190
3522
  _lockAndCloseConnection() {
3191
- invariant10(this._transportChannels.size === 0, void 0, {
3192
- F: __dxlog_file11,
3523
+ invariant12(this._transportChannels.size === 0, void 0, {
3524
+ F: __dxlog_file14,
3193
3525
  L: 260,
3194
3526
  S: this,
3195
3527
  A: [
@@ -3199,8 +3531,8 @@ var RtcPeerConnection = class {
3199
3531
  });
3200
3532
  if (this._connection) {
3201
3533
  this._safeCloseConnection();
3202
- log10("connection closed", void 0, {
3203
- F: __dxlog_file11,
3534
+ log13("connection closed", void 0, {
3535
+ F: __dxlog_file14,
3204
3536
  L: 263,
3205
3537
  S: this,
3206
3538
  C: (f, a) => f(...a)
@@ -3210,10 +3542,10 @@ var RtcPeerConnection = class {
3210
3542
  async onSignal(signal) {
3211
3543
  const connection = this._connection;
3212
3544
  if (!connection) {
3213
- log10.warn("a signal ignored because the connection was closed", {
3545
+ log13.warn("a signal ignored because the connection was closed", {
3214
3546
  type: signal.payload.data.type
3215
3547
  }, {
3216
- F: __dxlog_file11,
3548
+ F: __dxlog_file14,
3217
3549
  L: 271,
3218
3550
  S: this,
3219
3551
  C: (f, a) => f(...a)
@@ -3277,8 +3609,8 @@ var RtcPeerConnection = class {
3277
3609
  this._abortConnection(connection, new Error(`Unknown signal type ${data.type}.`));
3278
3610
  break;
3279
3611
  }
3280
- log10("signal processed", void 0, {
3281
- F: __dxlog_file11,
3612
+ log13("signal processed", void 0, {
3613
+ F: __dxlog_file14,
3282
3614
  L: 330,
3283
3615
  S: this,
3284
3616
  C: (f, a) => f(...a)
@@ -3288,10 +3620,10 @@ var RtcPeerConnection = class {
3288
3620
  try {
3289
3621
  await this._readyForCandidates.wait();
3290
3622
  if (connection === this._connection) {
3291
- log10("adding ice candidate", {
3623
+ log13("adding ice candidate", {
3292
3624
  candidate
3293
3625
  }, {
3294
- F: __dxlog_file11,
3626
+ F: __dxlog_file14,
3295
3627
  L: 338,
3296
3628
  S: this,
3297
3629
  C: (f, a) => f(...a)
@@ -3299,8 +3631,8 @@ var RtcPeerConnection = class {
3299
3631
  await connection.addIceCandidate(candidate);
3300
3632
  }
3301
3633
  } catch (err) {
3302
- log10.catch(err, void 0, {
3303
- F: __dxlog_file11,
3634
+ log13.catch(err, void 0, {
3635
+ F: __dxlog_file14,
3304
3636
  L: 342,
3305
3637
  S: this,
3306
3638
  C: (f, a) => f(...a)
@@ -3309,16 +3641,16 @@ var RtcPeerConnection = class {
3309
3641
  }
3310
3642
  _onSessionNegotiated(connection) {
3311
3643
  if (connection === this._connection) {
3312
- log10("ready to process ice candidates", void 0, {
3313
- F: __dxlog_file11,
3644
+ log13("ready to process ice candidates", void 0, {
3645
+ F: __dxlog_file14,
3314
3646
  L: 348,
3315
3647
  S: this,
3316
3648
  C: (f, a) => f(...a)
3317
3649
  });
3318
3650
  this._readyForCandidates.wake();
3319
3651
  } else {
3320
- log10.warn("session was negotiated after connection became inactive", void 0, {
3321
- F: __dxlog_file11,
3652
+ log13.warn("session was negotiated after connection became inactive", void 0, {
3653
+ F: __dxlog_file14,
3322
3654
  L: 351,
3323
3655
  S: this,
3324
3656
  C: (f, a) => f(...a)
@@ -3326,11 +3658,11 @@ var RtcPeerConnection = class {
3326
3658
  }
3327
3659
  }
3328
3660
  _onConnectionCallbackAfterClose(callback, connection) {
3329
- log10.warn("callback invoked after a connection was destroyed, this is probably a bug", {
3661
+ log13.warn("callback invoked after a connection was destroyed, this is probably a bug", {
3330
3662
  callback,
3331
3663
  state: connection.connectionState
3332
3664
  }, {
3333
- F: __dxlog_file11,
3665
+ F: __dxlog_file14,
3334
3666
  L: 356,
3335
3667
  S: this,
3336
3668
  C: (f, a) => f(...a)
@@ -3342,8 +3674,8 @@ var RtcPeerConnection = class {
3342
3674
  try {
3343
3675
  connection?.close();
3344
3676
  } catch (err) {
3345
- log10.catch(err, void 0, {
3346
- F: __dxlog_file11,
3677
+ log13.catch(err, void 0, {
3678
+ F: __dxlog_file14,
3347
3679
  L: 368,
3348
3680
  S: this,
3349
3681
  C: (f, a) => f(...a)
@@ -3353,8 +3685,8 @@ var RtcPeerConnection = class {
3353
3685
  this._connection = void 0;
3354
3686
  this._dataChannels.clear();
3355
3687
  this._readyForCandidates.wake();
3356
- void this._factory.onConnectionDestroyed().catch((err) => log10.catch(err, void 0, {
3357
- F: __dxlog_file11,
3688
+ void this._factory.onConnectionDestroyed().catch((err) => log13.catch(err, void 0, {
3689
+ F: __dxlog_file14,
3358
3690
  L: 374,
3359
3691
  S: this,
3360
3692
  C: (f, a) => f(...a)
@@ -3378,8 +3710,8 @@ var RtcPeerConnection = class {
3378
3710
  ];
3379
3711
  }
3380
3712
  } catch (error) {
3381
- log10.catch(error, void 0, {
3382
- F: __dxlog_file11,
3713
+ log13.catch(error, void 0, {
3714
+ F: __dxlog_file14,
3383
3715
  L: 390,
3384
3716
  S: this,
3385
3717
  C: (f, a) => f(...a)
@@ -3403,10 +3735,10 @@ var RtcPeerConnection = class {
3403
3735
  }
3404
3736
  });
3405
3737
  } catch (err) {
3406
- log10.warn("signaling error", {
3738
+ log13.warn("signaling error", {
3407
3739
  err
3408
3740
  }, {
3409
- F: __dxlog_file11,
3741
+ F: __dxlog_file14,
3410
3742
  L: 411,
3411
3743
  S: this,
3412
3744
  C: (f, a) => f(...a)
@@ -3510,13 +3842,13 @@ import { Writable } from "@dxos/node-std/stream";
3510
3842
  import { Event as Event8, scheduleTask as scheduleTask4 } from "@dxos/async";
3511
3843
  import { Resource as Resource2 } from "@dxos/context";
3512
3844
  import { ErrorStream as ErrorStream5 } from "@dxos/debug";
3513
- import { invariant as invariant11 } from "@dxos/invariant";
3845
+ import { invariant as invariant13 } from "@dxos/invariant";
3514
3846
  import { PublicKey as PublicKey10 } from "@dxos/keys";
3515
- import { log as log11 } from "@dxos/log";
3847
+ import { log as log14 } from "@dxos/log";
3516
3848
  import { ConnectionResetError as ConnectionResetError2, ConnectivityError as ConnectivityError4, TimeoutError as TimeoutError3 } from "@dxos/protocols";
3517
3849
  import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
3518
3850
  import { arrayToBuffer } from "@dxos/util";
3519
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-proxy.ts";
3851
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-proxy.ts";
3520
3852
  var RPC_TIMEOUT = 1e4;
3521
3853
  var CLOSE_RPC_TIMEOUT = 3e3;
3522
3854
  var RESP_MIN_THRESHOLD = 500;
@@ -3548,8 +3880,8 @@ var RtcTransportProxy = class extends Resource2 {
3548
3880
  this._serviceStream = stream;
3549
3881
  stream.waitUntilReady().then(() => {
3550
3882
  stream.subscribe(async (event) => {
3551
- log11("rtc transport proxy event", event, {
3552
- F: __dxlog_file12,
3883
+ log14("rtc transport proxy event", event, {
3884
+ F: __dxlog_file15,
3553
3885
  L: 66,
3554
3886
  S: this,
3555
3887
  C: (f, a) => f(...a)
@@ -3562,10 +3894,10 @@ var RtcTransportProxy = class extends Resource2 {
3562
3894
  await this._handleSignal(event.signal);
3563
3895
  }
3564
3896
  }, (err) => {
3565
- log11("rtc bridge stream closed", {
3897
+ log14("rtc bridge stream closed", {
3566
3898
  err
3567
3899
  }, {
3568
- F: __dxlog_file12,
3900
+ F: __dxlog_file15,
3569
3901
  L: 76,
3570
3902
  S: this,
3571
3903
  C: (f, a) => f(...a)
@@ -3586,8 +3918,8 @@ var RtcTransportProxy = class extends Resource2 {
3586
3918
  timeout: RPC_TIMEOUT
3587
3919
  }).then(() => {
3588
3920
  if (Date.now() - sendStartMs > RESP_MIN_THRESHOLD) {
3589
- log11("slow response, delaying callback", void 0, {
3590
- F: __dxlog_file12,
3921
+ log14("slow response, delaying callback", void 0, {
3922
+ F: __dxlog_file15,
3591
3923
  L: 93,
3592
3924
  S: this,
3593
3925
  C: (f, a) => f(...a)
@@ -3619,8 +3951,8 @@ var RtcTransportProxy = class extends Resource2 {
3619
3951
  await this._serviceStream?.close();
3620
3952
  this._serviceStream = void 0;
3621
3953
  } catch (err) {
3622
- log11.catch(err, void 0, {
3623
- F: __dxlog_file12,
3954
+ log14.catch(err, void 0, {
3955
+ F: __dxlog_file15,
3624
3956
  L: 128,
3625
3957
  S: this,
3626
3958
  C: (f, a) => f(...a)
@@ -3633,8 +3965,8 @@ var RtcTransportProxy = class extends Resource2 {
3633
3965
  timeout: CLOSE_RPC_TIMEOUT
3634
3966
  });
3635
3967
  } catch (err) {
3636
- log11.catch(err, void 0, {
3637
- F: __dxlog_file12,
3968
+ log14.catch(err, void 0, {
3969
+ F: __dxlog_file15,
3638
3970
  L: 134,
3639
3971
  S: this,
3640
3972
  C: (f, a) => f(...a)
@@ -3717,10 +4049,10 @@ var RtcTransportProxy = class extends Resource2 {
3717
4049
  if (this.isOpen) {
3718
4050
  this.errors.raise(error);
3719
4051
  } else {
3720
- log11.info("error swallowed because transport was closed", {
4052
+ log14.info("error swallowed because transport was closed", {
3721
4053
  message: error.message
3722
4054
  }, {
3723
- F: __dxlog_file12,
4055
+ F: __dxlog_file15,
3724
4056
  L: 215,
3725
4057
  S: this,
3726
4058
  C: (f, a) => f(...a)
@@ -3751,8 +4083,8 @@ var RtcTransportProxyFactory = class {
3751
4083
  return this;
3752
4084
  }
3753
4085
  createTransport(options) {
3754
- invariant11(this._bridgeService, "RtcTransportProxyFactory is not ready to open connections", {
3755
- F: __dxlog_file12,
4086
+ invariant13(this._bridgeService, "RtcTransportProxyFactory is not ready to open connections", {
4087
+ F: __dxlog_file15,
3756
4088
  L: 245,
3757
4089
  S: this,
3758
4090
  A: [
@@ -3785,12 +4117,12 @@ var decodeError = (err) => {
3785
4117
  // packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-service.ts
3786
4118
  import { Duplex as Duplex2 } from "@dxos/node-std/stream";
3787
4119
  import { Stream } from "@dxos/codec-protobuf";
3788
- import { invariant as invariant12 } from "@dxos/invariant";
4120
+ import { invariant as invariant14 } from "@dxos/invariant";
3789
4121
  import { PublicKey as PublicKey11 } from "@dxos/keys";
3790
- import { log as log12 } from "@dxos/log";
4122
+ import { log as log15 } from "@dxos/log";
3791
4123
  import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
3792
4124
  import { ComplexMap as ComplexMap8 } from "@dxos/util";
3793
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-service.ts";
4125
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-service.ts";
3794
4126
  var RtcTransportService = class {
3795
4127
  constructor(webrtcConfig, iceProvider, _transportFactory = createRtcTransportFactory(webrtcConfig, iceProvider)) {
3796
4128
  this._transportFactory = _transportFactory;
@@ -3802,8 +4134,8 @@ var RtcTransportService = class {
3802
4134
  open(request) {
3803
4135
  const existingTransport = this._openTransports.get(request.proxyId);
3804
4136
  if (existingTransport) {
3805
- log12.error("requesting a new transport bridge for an existing proxy", void 0, {
3806
- F: __dxlog_file13,
4137
+ log15.error("requesting a new transport bridge for an existing proxy", void 0, {
4138
+ F: __dxlog_file16,
3807
4139
  L: 53,
3808
4140
  S: this,
3809
4141
  C: (f, a) => f(...a)
@@ -3873,8 +4205,8 @@ var RtcTransportService = class {
3873
4205
  }
3874
4206
  async sendSignal({ proxyId, signal }) {
3875
4207
  const transport = this._openTransports.get(proxyId);
3876
- invariant12(transport, void 0, {
3877
- F: __dxlog_file13,
4208
+ invariant14(transport, void 0, {
4209
+ F: __dxlog_file16,
3878
4210
  L: 121,
3879
4211
  S: this,
3880
4212
  A: [
@@ -3886,8 +4218,8 @@ var RtcTransportService = class {
3886
4218
  }
3887
4219
  async getDetails({ proxyId }) {
3888
4220
  const transport = this._openTransports.get(proxyId);
3889
- invariant12(transport, void 0, {
3890
- F: __dxlog_file13,
4221
+ invariant14(transport, void 0, {
4222
+ F: __dxlog_file16,
3891
4223
  L: 128,
3892
4224
  S: this,
3893
4225
  A: [
@@ -3901,8 +4233,8 @@ var RtcTransportService = class {
3901
4233
  }
3902
4234
  async getStats({ proxyId }) {
3903
4235
  const transport = this._openTransports.get(proxyId);
3904
- invariant12(transport, void 0, {
3905
- F: __dxlog_file13,
4236
+ invariant14(transport, void 0, {
4237
+ F: __dxlog_file16,
3906
4238
  L: 135,
3907
4239
  S: this,
3908
4240
  A: [
@@ -3916,8 +4248,8 @@ var RtcTransportService = class {
3916
4248
  }
3917
4249
  async sendData({ proxyId, payload }) {
3918
4250
  const transport = this._openTransports.get(proxyId);
3919
- invariant12(transport, void 0, {
3920
- F: __dxlog_file13,
4251
+ invariant14(transport, void 0, {
4252
+ F: __dxlog_file16,
3921
4253
  L: 142,
3922
4254
  S: this,
3923
4255
  A: [
@@ -3948,10 +4280,10 @@ var RtcTransportService = class {
3948
4280
  try {
3949
4281
  await transport.transport.close();
3950
4282
  } catch (error) {
3951
- log12.warn("transport close error", {
4283
+ log15.warn("transport close error", {
3952
4284
  message: error?.message
3953
4285
  }, {
3954
- F: __dxlog_file13,
4286
+ F: __dxlog_file16,
3955
4287
  L: 172,
3956
4288
  S: this,
3957
4289
  C: (f, a) => f(...a)
@@ -3960,17 +4292,17 @@ var RtcTransportService = class {
3960
4292
  try {
3961
4293
  transport.connectorStream.end();
3962
4294
  } catch (error) {
3963
- log12.warn("connectorStream close error", {
4295
+ log15.warn("connectorStream close error", {
3964
4296
  message: error?.message
3965
4297
  }, {
3966
- F: __dxlog_file13,
4298
+ F: __dxlog_file16,
3967
4299
  L: 177,
3968
4300
  S: this,
3969
4301
  C: (f, a) => f(...a)
3970
4302
  });
3971
4303
  }
3972
- log12("closed", void 0, {
3973
- F: __dxlog_file13,
4304
+ log15("closed", void 0, {
4305
+ F: __dxlog_file16,
3974
4306
  L: 179,
3975
4307
  S: this,
3976
4308
  C: (f, a) => f(...a)
@@ -4017,6 +4349,7 @@ var createTeleportProtocolFactory = (onConnection, defaultParams) => {
4017
4349
  export {
4018
4350
  ConnectionState,
4019
4351
  Connection,
4352
+ createIceProvider,
4020
4353
  SwarmMessenger,
4021
4354
  Swarm,
4022
4355
  SwarmMapper,
@@ -4026,6 +4359,8 @@ export {
4026
4359
  ConnectionLog,
4027
4360
  SwarmNetworkManager,
4028
4361
  FullyConnectedTopology,
4362
+ MMSTTopology,
4363
+ StarTopology,
4029
4364
  MemoryTransportFactory,
4030
4365
  MemoryTransport,
4031
4366
  TransportKind,
@@ -4035,4 +4370,4 @@ export {
4035
4370
  RtcTransportService,
4036
4371
  createTeleportProtocolFactory
4037
4372
  };
4038
- //# sourceMappingURL=chunk-V3IRGRVX.mjs.map
4373
+ //# sourceMappingURL=chunk-RUNQZNCV.mjs.map