@dxos/network-manager 0.8.4-main.7ace549 → 0.8.4-main.937b3ca

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.
Files changed (36) hide show
  1. package/dist/lib/browser/{chunk-5ISEIDVN.mjs → chunk-AQSYW43M.mjs} +343 -687
  2. package/dist/lib/browser/chunk-AQSYW43M.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +342 -4
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +1 -1
  7. package/dist/lib/browser/transport/tcp/index.mjs +2 -33
  8. package/dist/lib/browser/transport/tcp/index.mjs.map +4 -4
  9. package/dist/lib/browser/transport/tcp/tcp-transport.browser.mjs +36 -0
  10. package/dist/lib/browser/transport/tcp/tcp-transport.browser.mjs.map +7 -0
  11. package/dist/lib/browser/transport/tcp/tcp-transport.mjs +160 -0
  12. package/dist/lib/browser/transport/tcp/tcp-transport.mjs.map +7 -0
  13. package/dist/lib/node-esm/{chunk-S7AVXKL7.mjs → chunk-SCX3PZRE.mjs} +343 -687
  14. package/dist/lib/node-esm/chunk-SCX3PZRE.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +342 -4
  16. package/dist/lib/node-esm/index.mjs.map +4 -4
  17. package/dist/lib/node-esm/meta.json +1 -1
  18. package/dist/lib/node-esm/testing/index.mjs +1 -1
  19. package/dist/lib/node-esm/transport/tcp/index.mjs +2 -157
  20. package/dist/lib/node-esm/transport/tcp/index.mjs.map +4 -4
  21. package/dist/lib/node-esm/transport/tcp/tcp-transport.browser.mjs +36 -0
  22. package/dist/lib/node-esm/transport/tcp/tcp-transport.browser.mjs.map +7 -0
  23. package/dist/lib/node-esm/transport/tcp/tcp-transport.mjs +160 -0
  24. package/dist/lib/node-esm/transport/tcp/tcp-transport.mjs.map +7 -0
  25. package/dist/types/src/swarm/peer.d.ts.map +1 -1
  26. package/dist/types/src/transport/tcp/index.d.ts +1 -1
  27. package/dist/types/src/transport/tcp/index.d.ts.map +1 -1
  28. package/dist/types/src/wire-protocol.d.ts +5 -5
  29. package/dist/types/src/wire-protocol.d.ts.map +1 -1
  30. package/dist/types/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +32 -22
  32. package/src/swarm/peer.ts +1 -0
  33. package/src/transport/tcp/index.ts +1 -1
  34. package/src/wire-protocol.ts +6 -6
  35. package/dist/lib/browser/chunk-5ISEIDVN.mjs.map +0 -7
  36. package/dist/lib/node-esm/chunk-S7AVXKL7.mjs.map +0 -7
@@ -615,52 +615,19 @@ _ts_decorate([
615
615
  synchronized
616
616
  ], Connection.prototype, "close", null);
617
617
 
618
- // src/signal/ice.ts
619
- import { asyncTimeout } from "@dxos/async";
620
- import { log as log2 } from "@dxos/log";
621
- import { isNonNullable } from "@dxos/util";
622
- var __dxlog_file2 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/signal/ice.ts";
623
- var createIceProvider = (iceProviders) => {
624
- let cachedIceServers;
625
- return {
626
- getIceServers: async () => {
627
- if (cachedIceServers) {
628
- return cachedIceServers;
629
- }
630
- cachedIceServers = (await Promise.all(iceProviders.map(({ urls }) => asyncTimeout(fetch(urls, {
631
- method: "GET"
632
- }), 1e4).then((response) => response.json()).catch((err) => {
633
- const isDev = typeof window !== "undefined" && window.location.href.includes("localhost");
634
- if (!isDev) {
635
- log2.error("Failed to fetch ICE servers from provider", {
636
- urls,
637
- err
638
- }, {
639
- F: __dxlog_file2,
640
- L: 30,
641
- S: void 0,
642
- C: (f, a) => f(...a)
643
- });
644
- }
645
- })))).filter(isNonNullable).map(({ iceServers }) => iceServers).flat();
646
- return cachedIceServers;
647
- }
648
- };
649
- };
650
-
651
618
  // src/signal/swarm-messenger.ts
652
619
  import { Context as Context2 } from "@dxos/context";
653
620
  import { invariant as invariant2 } from "@dxos/invariant";
654
621
  import { PublicKey as PublicKey2 } from "@dxos/keys";
655
- import { log as log3 } from "@dxos/log";
622
+ import { log as log2 } from "@dxos/log";
656
623
  import { TimeoutError as TimeoutError2 } from "@dxos/protocols";
657
624
  import { schema } from "@dxos/protocols/proto";
658
625
  import { ComplexMap } from "@dxos/util";
659
- var __dxlog_file3 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
626
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
660
627
  var SwarmMessage = schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
661
628
  var SwarmMessenger = class {
662
629
  _ctx = new Context2(void 0, {
663
- F: __dxlog_file3,
630
+ F: __dxlog_file2,
664
631
  L: 35
665
632
  });
666
633
  _sendMessage;
@@ -682,12 +649,12 @@ var SwarmMessenger = class {
682
649
  if (!this._topic.equals(message.topic)) {
683
650
  return;
684
651
  }
685
- log3("received", {
652
+ log2("received", {
686
653
  from: author,
687
654
  to: recipient,
688
655
  msg: message
689
656
  }, {
690
- F: __dxlog_file3,
657
+ F: __dxlog_file2,
691
658
  L: 71,
692
659
  S: this,
693
660
  C: (f, a) => f(...a)
@@ -713,10 +680,10 @@ var SwarmMessenger = class {
713
680
  message
714
681
  });
715
682
  } else {
716
- log3.warn("unknown message", {
683
+ log2.warn("unknown message", {
717
684
  message
718
685
  }, {
719
- F: __dxlog_file3,
686
+ F: __dxlog_file2,
720
687
  L: 82,
721
688
  S: this,
722
689
  C: (f, a) => f(...a)
@@ -725,7 +692,7 @@ var SwarmMessenger = class {
725
692
  }
726
693
  async signal(message) {
727
694
  invariant2(message.data?.signal || message.data?.signalBatch, "Invalid message", {
728
- F: __dxlog_file3,
695
+ F: __dxlog_file2,
729
696
  L: 87,
730
697
  S: this,
731
698
  A: [
@@ -761,12 +728,12 @@ var SwarmMessenger = class {
761
728
  // Setting unique message_id if it not specified yet.
762
729
  messageId: message.messageId ?? PublicKey2.random()
763
730
  };
764
- log3("sending", {
731
+ log2("sending", {
765
732
  from: author,
766
733
  to: recipient,
767
734
  msg: networkMessage
768
735
  }, {
769
- F: __dxlog_file3,
736
+ F: __dxlog_file2,
770
737
  L: 125,
771
738
  S: this,
772
739
  C: (f, a) => f(...a)
@@ -782,7 +749,7 @@ var SwarmMessenger = class {
782
749
  }
783
750
  async _resolveAnswers(message) {
784
751
  invariant2(message.data?.answer?.offerMessageId, "No offerMessageId", {
785
- F: __dxlog_file3,
752
+ F: __dxlog_file2,
786
753
  L: 137,
787
754
  S: this,
788
755
  A: [
@@ -794,7 +761,7 @@ var SwarmMessenger = class {
794
761
  if (offerRecord) {
795
762
  this._offerRecords.delete(message.data.answer.offerMessageId);
796
763
  invariant2(message.data?.answer, "No answer", {
797
- F: __dxlog_file3,
764
+ F: __dxlog_file2,
798
765
  L: 141,
799
766
  S: this,
800
767
  A: [
@@ -802,10 +769,10 @@ var SwarmMessenger = class {
802
769
  "'No answer'"
803
770
  ]
804
771
  });
805
- log3("resolving", {
772
+ log2("resolving", {
806
773
  answer: message.data.answer
807
774
  }, {
808
- F: __dxlog_file3,
775
+ F: __dxlog_file2,
809
776
  L: 142,
810
777
  S: this,
811
778
  C: (f, a) => f(...a)
@@ -815,7 +782,7 @@ var SwarmMessenger = class {
815
782
  }
816
783
  async _handleOffer({ author, recipient, message }) {
817
784
  invariant2(message.data.offer, "No offer", {
818
- F: __dxlog_file3,
785
+ F: __dxlog_file2,
819
786
  L: 156,
820
787
  S: this,
821
788
  A: [
@@ -847,19 +814,19 @@ var SwarmMessenger = class {
847
814
  });
848
815
  } catch (err) {
849
816
  if (err instanceof TimeoutError2) {
850
- log3.info("timeout sending answer to offer", {
817
+ log2.info("timeout sending answer to offer", {
851
818
  err
852
819
  }, {
853
- F: __dxlog_file3,
820
+ F: __dxlog_file2,
854
821
  L: 177,
855
822
  S: this,
856
823
  C: (f, a) => f(...a)
857
824
  });
858
825
  } else {
859
- log3.info("error sending answer to offer", {
826
+ log2.info("error sending answer to offer", {
860
827
  err
861
828
  }, {
862
- F: __dxlog_file3,
829
+ F: __dxlog_file2,
863
830
  L: 179,
864
831
  S: this,
865
832
  C: (f, a) => f(...a)
@@ -869,7 +836,7 @@ var SwarmMessenger = class {
869
836
  }
870
837
  async _handleSignal({ author, recipient, message }) {
871
838
  invariant2(message.messageId, void 0, {
872
- F: __dxlog_file3,
839
+ F: __dxlog_file2,
873
840
  L: 193,
874
841
  S: this,
875
842
  A: [
@@ -878,7 +845,7 @@ var SwarmMessenger = class {
878
845
  ]
879
846
  });
880
847
  invariant2(message.data.signal || message.data.signalBatch, "Invalid message", {
881
- F: __dxlog_file3,
848
+ F: __dxlog_file2,
882
849
  L: 194,
883
850
  S: this,
884
851
  A: [
@@ -905,17 +872,17 @@ import { Context as Context4 } from "@dxos/context";
905
872
  import { ErrorStream as ErrorStream2 } from "@dxos/debug";
906
873
  import { invariant as invariant4 } from "@dxos/invariant";
907
874
  import { PublicKey as PublicKey4 } from "@dxos/keys";
908
- import { log as log5, logInfo as logInfo2 } from "@dxos/log";
875
+ import { log as log4, logInfo as logInfo2 } from "@dxos/log";
909
876
  import { PeerInfoHash } from "@dxos/messaging";
910
877
  import { trace as trace2 } from "@dxos/protocols";
911
- import { ComplexMap as ComplexMap2, isNonNullable as isNonNullable2 } from "@dxos/util";
878
+ import { ComplexMap as ComplexMap2, isNonNullable } from "@dxos/util";
912
879
 
913
880
  // src/swarm/peer.ts
914
881
  import { Event as Event2, scheduleTask as scheduleTask2, synchronized as synchronized2 } from "@dxos/async";
915
882
  import { Context as Context3 } from "@dxos/context";
916
883
  import { invariant as invariant3 } from "@dxos/invariant";
917
884
  import { PublicKey as PublicKey3 } from "@dxos/keys";
918
- import { log as log4 } from "@dxos/log";
885
+ import { log as log3 } from "@dxos/log";
919
886
  import { CancelledError as CancelledError2, SystemError } from "@dxos/protocols";
920
887
  function _ts_decorate2(decorators, target, key, desc) {
921
888
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -923,7 +890,7 @@ function _ts_decorate2(decorators, target, key, desc) {
923
890
  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;
924
891
  return c > 3 && r && Object.defineProperty(target, key, r), r;
925
892
  }
926
- var __dxlog_file4 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
893
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
927
894
  var ConnectionDisplacedError = class extends SystemError {
928
895
  constructor() {
929
896
  super({
@@ -948,7 +915,7 @@ var Peer = class {
948
915
  availableToConnect = true;
949
916
  _lastConnectionTime;
950
917
  _ctx = new Context3(void 0, {
951
- F: __dxlog_file4,
918
+ F: __dxlog_file3,
952
919
  L: 81
953
920
  });
954
921
  _connectionCtx;
@@ -979,8 +946,8 @@ var Peer = class {
979
946
  ConnectionState.INITIAL,
980
947
  ConnectionState.CONNECTING
981
948
  ].includes(this.connection.state)) {
982
- log4.info(`received offer when connection already in ${this.connection.state} state`, void 0, {
983
- F: __dxlog_file4,
949
+ log3.info(`received offer when connection already in ${this.connection.state} state`, void 0, {
950
+ F: __dxlog_file3,
984
951
  L: 116,
985
952
  S: this,
986
953
  C: (f, a) => f(...a)
@@ -991,13 +958,13 @@ var Peer = class {
991
958
  }
992
959
  if (this.connection || this.initiating) {
993
960
  if (remote.peerKey < this.localInfo.peerKey) {
994
- log4("close local connection", {
961
+ log3("close local connection", {
995
962
  localPeer: this.localInfo,
996
963
  topic: this.topic,
997
964
  remotePeer: this.remoteInfo,
998
965
  sessionId: this.connection?.sessionId
999
966
  }, {
1000
- F: __dxlog_file4,
967
+ F: __dxlog_file3,
1001
968
  L: 125,
1002
969
  S: this,
1003
970
  C: (f, a) => f(...a)
@@ -1014,7 +981,7 @@ var Peer = class {
1014
981
  if (await this._callbacks.onOffer(remote)) {
1015
982
  if (!this.connection) {
1016
983
  invariant3(message.sessionId, void 0, {
1017
- F: __dxlog_file4,
984
+ F: __dxlog_file3,
1018
985
  L: 145,
1019
986
  S: this,
1020
987
  A: [
@@ -1029,13 +996,13 @@ var Peer = class {
1029
996
  await connection.openConnection();
1030
997
  } catch (err) {
1031
998
  if (!(err instanceof CancelledError2)) {
1032
- log4.info("connection error", {
999
+ log3.info("connection error", {
1033
1000
  topic: this.topic,
1034
1001
  peerId: this.localInfo,
1035
1002
  remoteId: this.remoteInfo,
1036
1003
  err
1037
1004
  }, {
1038
- F: __dxlog_file4,
1005
+ F: __dxlog_file3,
1039
1006
  L: 155,
1040
1007
  S: this,
1041
1008
  C: (f, a) => f(...a)
@@ -1057,8 +1024,8 @@ var Peer = class {
1057
1024
  */
1058
1025
  async initiateConnection() {
1059
1026
  invariant3(!this.initiating, "Initiation in progress.", {
1060
- F: __dxlog_file4,
1061
- L: 172,
1027
+ F: __dxlog_file3,
1028
+ L: 173,
1062
1029
  S: this,
1063
1030
  A: [
1064
1031
  "!this.initiating",
@@ -1066,8 +1033,8 @@ var Peer = class {
1066
1033
  ]
1067
1034
  });
1068
1035
  invariant3(!this.connection, "Already connected.", {
1069
- F: __dxlog_file4,
1070
- L: 173,
1036
+ F: __dxlog_file3,
1037
+ L: 174,
1071
1038
  S: this,
1072
1039
  A: [
1073
1040
  "!this.connection",
@@ -1075,14 +1042,14 @@ var Peer = class {
1075
1042
  ]
1076
1043
  });
1077
1044
  const sessionId = PublicKey3.random();
1078
- log4("initiating...", {
1045
+ log3("initiating...", {
1079
1046
  local: this.localInfo,
1080
1047
  topic: this.topic,
1081
1048
  remote: this.remoteInfo,
1082
1049
  sessionId
1083
1050
  }, {
1084
- F: __dxlog_file4,
1085
- L: 175,
1051
+ F: __dxlog_file3,
1052
+ L: 176,
1086
1053
  S: this,
1087
1054
  C: (f, a) => f(...a)
1088
1055
  });
@@ -1101,35 +1068,35 @@ var Peer = class {
1101
1068
  offer: {}
1102
1069
  }
1103
1070
  });
1104
- log4("received", {
1071
+ log3("received", {
1105
1072
  answer,
1106
1073
  topic: this.topic,
1107
1074
  local: this.localInfo,
1108
1075
  remote: this.remoteInfo
1109
1076
  }, {
1110
- F: __dxlog_file4,
1111
- L: 192,
1077
+ F: __dxlog_file3,
1078
+ L: 193,
1112
1079
  S: this,
1113
1080
  C: (f, a) => f(...a)
1114
1081
  });
1115
1082
  if (connection.state !== ConnectionState.INITIAL) {
1116
- log4("ignoring response", void 0, {
1117
- F: __dxlog_file4,
1118
- L: 194,
1083
+ log3("ignoring response", void 0, {
1084
+ F: __dxlog_file3,
1085
+ L: 195,
1119
1086
  S: this,
1120
1087
  C: (f, a) => f(...a)
1121
1088
  });
1122
1089
  return;
1123
1090
  }
1124
1091
  } catch (err) {
1125
- log4("initiation error: send offer", {
1092
+ log3("initiation error: send offer", {
1126
1093
  err,
1127
1094
  topic: this.topic,
1128
1095
  local: this.localInfo,
1129
1096
  remote: this.remoteInfo
1130
1097
  }, {
1131
- F: __dxlog_file4,
1132
- L: 198,
1098
+ F: __dxlog_file3,
1099
+ L: 199,
1133
1100
  S: this,
1134
1101
  C: (f, a) => f(...a)
1135
1102
  });
@@ -1144,14 +1111,14 @@ var Peer = class {
1144
1111
  return;
1145
1112
  }
1146
1113
  } catch (err) {
1147
- log4("initiation error: accept answer", {
1114
+ log3("initiation error: accept answer", {
1148
1115
  err,
1149
1116
  topic: this.topic,
1150
1117
  local: this.localInfo,
1151
1118
  remote: this.remoteInfo
1152
1119
  }, {
1153
- F: __dxlog_file4,
1154
- L: 211,
1120
+ F: __dxlog_file3,
1121
+ L: 212,
1155
1122
  S: this,
1156
1123
  C: (f, a) => f(...a)
1157
1124
  });
@@ -1161,31 +1128,31 @@ var Peer = class {
1161
1128
  this.initiating = false;
1162
1129
  }
1163
1130
  try {
1164
- log4("opening connection as initiator", void 0, {
1165
- F: __dxlog_file4,
1166
- L: 224,
1131
+ log3("opening connection as initiator", void 0, {
1132
+ F: __dxlog_file3,
1133
+ L: 225,
1167
1134
  S: this,
1168
1135
  C: (f, a) => f(...a)
1169
1136
  });
1170
1137
  await connection.openConnection();
1171
1138
  this._callbacks.onAccepted();
1172
1139
  } catch (err) {
1173
- log4("initiation error: open connection", {
1140
+ log3("initiation error: open connection", {
1174
1141
  err,
1175
1142
  topic: this.topic,
1176
1143
  local: this.localInfo,
1177
1144
  remote: this.remoteInfo
1178
1145
  }, {
1179
- F: __dxlog_file4,
1180
- L: 228,
1146
+ F: __dxlog_file3,
1147
+ L: 229,
1181
1148
  S: this,
1182
1149
  C: (f, a) => f(...a)
1183
1150
  });
1184
- log4.warn("closing connection due to unhandled error on openConnection", {
1151
+ log3.warn("closing connection due to unhandled error on openConnection", {
1185
1152
  err
1186
1153
  }, {
1187
- F: __dxlog_file4,
1188
- L: 235,
1154
+ F: __dxlog_file3,
1155
+ L: 236,
1189
1156
  S: this,
1190
1157
  C: (f, a) => f(...a)
1191
1158
  });
@@ -1200,21 +1167,21 @@ var Peer = class {
1200
1167
  * Either we're initiating a connection or creating one in response to an offer from the other peer.
1201
1168
  */
1202
1169
  _createConnection(initiator, sessionId) {
1203
- log4("creating connection", {
1170
+ log3("creating connection", {
1204
1171
  topic: this.topic,
1205
1172
  peerId: this.localInfo,
1206
1173
  remoteId: this.remoteInfo,
1207
1174
  initiator,
1208
1175
  sessionId
1209
1176
  }, {
1210
- F: __dxlog_file4,
1211
- L: 249,
1177
+ F: __dxlog_file3,
1178
+ L: 250,
1212
1179
  S: this,
1213
1180
  C: (f, a) => f(...a)
1214
1181
  });
1215
1182
  invariant3(!this.connection, "Already connected.", {
1216
- F: __dxlog_file4,
1217
- L: 256,
1183
+ F: __dxlog_file3,
1184
+ L: 257,
1218
1185
  S: this,
1219
1186
  A: [
1220
1187
  "!this.connection",
@@ -1242,15 +1209,15 @@ var Peer = class {
1242
1209
  this._lastConnectionTime = Date.now();
1243
1210
  this._callbacks.onConnected();
1244
1211
  this._connectionLimiter.doneConnecting(sessionId);
1245
- log4.trace("dxos.mesh.connection.connected", {
1212
+ log3.trace("dxos.mesh.connection.connected", {
1246
1213
  topic: this.topic,
1247
1214
  localPeerId: this.localInfo,
1248
1215
  remotePeerId: this.remoteInfo,
1249
1216
  sessionId,
1250
1217
  initiator
1251
1218
  }, {
1252
- F: __dxlog_file4,
1253
- L: 280,
1219
+ F: __dxlog_file3,
1220
+ L: 281,
1254
1221
  S: this,
1255
1222
  C: (f, a) => f(...a)
1256
1223
  });
@@ -1262,31 +1229,31 @@ var Peer = class {
1262
1229
  remoteId: this.remoteInfo,
1263
1230
  initiator
1264
1231
  };
1265
- log4("connection closed", logMeta, {
1266
- F: __dxlog_file4,
1267
- L: 290,
1232
+ log3("connection closed", logMeta, {
1233
+ F: __dxlog_file3,
1234
+ L: 291,
1268
1235
  S: this,
1269
1236
  C: (f, a) => f(...a)
1270
1237
  });
1271
1238
  this._connectionLimiter.doneConnecting(sessionId);
1272
1239
  invariant3(this.connection === connection, "Connection mismatch (race condition).", {
1273
- F: __dxlog_file4,
1274
- L: 295,
1240
+ F: __dxlog_file3,
1241
+ L: 296,
1275
1242
  S: this,
1276
1243
  A: [
1277
1244
  "this.connection === connection",
1278
1245
  "'Connection mismatch (race condition).'"
1279
1246
  ]
1280
1247
  });
1281
- log4.trace("dxos.mesh.connection.closed", {
1248
+ log3.trace("dxos.mesh.connection.closed", {
1282
1249
  topic: this.topic,
1283
1250
  localPeerId: this.localInfo,
1284
1251
  remotePeerId: this.remoteInfo,
1285
1252
  sessionId,
1286
1253
  initiator
1287
1254
  }, {
1288
- F: __dxlog_file4,
1289
- L: 297,
1255
+ F: __dxlog_file3,
1256
+ L: 298,
1290
1257
  S: this,
1291
1258
  C: (f, a) => f(...a)
1292
1259
  });
@@ -1301,9 +1268,9 @@ var Peer = class {
1301
1268
  }
1302
1269
  this._callbacks.onDisconnected();
1303
1270
  scheduleTask2(this._connectionCtx, () => {
1304
- log4("peer became available", logMeta, {
1305
- F: __dxlog_file4,
1306
- L: 321,
1271
+ log3("peer became available", logMeta, {
1272
+ F: __dxlog_file3,
1273
+ L: 322,
1307
1274
  S: this,
1308
1275
  C: (f, a) => f(...a)
1309
1276
  });
@@ -1319,19 +1286,19 @@ var Peer = class {
1319
1286
  void this._connectionCtx?.dispose();
1320
1287
  this._connectionCtx = this._ctx.derive();
1321
1288
  connection.errors.handle((err) => {
1322
- log4.info("connection error, closing", {
1289
+ log3.info("connection error, closing", {
1323
1290
  topic: this.topic,
1324
1291
  peerId: this.localInfo,
1325
1292
  remoteId: this.remoteInfo,
1326
1293
  initiator,
1327
1294
  err
1328
1295
  }, {
1329
- F: __dxlog_file4,
1330
- L: 339,
1296
+ F: __dxlog_file3,
1297
+ L: 340,
1331
1298
  S: this,
1332
1299
  C: (f, a) => f(...a)
1333
1300
  });
1334
- log4.trace("dxos.mesh.connection.error", {
1301
+ log3.trace("dxos.mesh.connection.error", {
1335
1302
  topic: this.topic,
1336
1303
  localPeerId: this.localInfo,
1337
1304
  remotePeerId: this.remoteInfo,
@@ -1339,8 +1306,8 @@ var Peer = class {
1339
1306
  initiator,
1340
1307
  err
1341
1308
  }, {
1342
- F: __dxlog_file4,
1343
- L: 346,
1309
+ F: __dxlog_file3,
1310
+ L: 347,
1344
1311
  S: this,
1345
1312
  C: (f, a) => f(...a)
1346
1313
  });
@@ -1354,35 +1321,35 @@ var Peer = class {
1354
1321
  return;
1355
1322
  }
1356
1323
  const connection = this.connection;
1357
- log4("closing...", {
1324
+ log3("closing...", {
1358
1325
  peerId: this.remoteInfo,
1359
1326
  sessionId: connection.sessionId
1360
1327
  }, {
1361
- F: __dxlog_file4,
1362
- L: 371,
1328
+ F: __dxlog_file3,
1329
+ L: 372,
1363
1330
  S: this,
1364
1331
  C: (f, a) => f(...a)
1365
1332
  });
1366
1333
  await connection.close({
1367
1334
  error: err
1368
1335
  });
1369
- log4("closed", {
1336
+ log3("closed", {
1370
1337
  peerId: this.remoteInfo,
1371
1338
  sessionId: connection.sessionId
1372
1339
  }, {
1373
- F: __dxlog_file4,
1374
- L: 377,
1340
+ F: __dxlog_file3,
1341
+ L: 378,
1375
1342
  S: this,
1376
1343
  C: (f, a) => f(...a)
1377
1344
  });
1378
1345
  }
1379
1346
  async onSignal(message) {
1380
1347
  if (!this.connection) {
1381
- log4("dropping signal message for non-existent connection", {
1348
+ log3("dropping signal message for non-existent connection", {
1382
1349
  message
1383
1350
  }, {
1384
- F: __dxlog_file4,
1385
- L: 382,
1351
+ F: __dxlog_file3,
1352
+ L: 383,
1386
1353
  S: this,
1387
1354
  C: (f, a) => f(...a)
1388
1355
  });
@@ -1392,12 +1359,12 @@ var Peer = class {
1392
1359
  }
1393
1360
  async safeDestroy(reason) {
1394
1361
  await this._ctx.dispose();
1395
- log4("Destroying peer", {
1362
+ log3("Destroying peer", {
1396
1363
  peerId: this.remoteInfo,
1397
1364
  topic: this.topic
1398
1365
  }, {
1399
- F: __dxlog_file4,
1400
- L: 392,
1366
+ F: __dxlog_file3,
1367
+ L: 393,
1401
1368
  S: this,
1402
1369
  C: (f, a) => f(...a)
1403
1370
  });
@@ -1429,7 +1396,7 @@ function _ts_decorate3(decorators, target, key, desc) {
1429
1396
  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;
1430
1397
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1431
1398
  }
1432
- var __dxlog_file5 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
1399
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
1433
1400
  var INITIATION_DELAY = 100;
1434
1401
  var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
1435
1402
  var Swarm = class {
@@ -1444,7 +1411,7 @@ var Swarm = class {
1444
1411
  _initiationDelay;
1445
1412
  _swarmMessenger;
1446
1413
  _ctx = new Context4(void 0, {
1447
- F: __dxlog_file5,
1414
+ F: __dxlog_file4,
1448
1415
  L: 39
1449
1416
  });
1450
1417
  _listeningHandle = void 0;
@@ -1485,22 +1452,22 @@ var Swarm = class {
1485
1452
  this._label = _label;
1486
1453
  this._connectionLimiter = _connectionLimiter;
1487
1454
  this._initiationDelay = _initiationDelay;
1488
- log5.trace("dxos.mesh.swarm.constructor", trace2.begin({
1455
+ log4.trace("dxos.mesh.swarm.constructor", trace2.begin({
1489
1456
  id: this._instanceId,
1490
1457
  data: {
1491
1458
  topic: this._topic.toHex(),
1492
1459
  peer: this._ownPeer
1493
1460
  }
1494
1461
  }), {
1495
- F: __dxlog_file5,
1462
+ F: __dxlog_file4,
1496
1463
  L: 89,
1497
1464
  S: this,
1498
1465
  C: (f, a) => f(...a)
1499
1466
  });
1500
- log5("creating swarm", {
1467
+ log4("creating swarm", {
1501
1468
  peerId: _ownPeer
1502
1469
  }, {
1503
- F: __dxlog_file5,
1470
+ F: __dxlog_file4,
1504
1471
  L: 93,
1505
1472
  S: this,
1506
1473
  C: (f, a) => f(...a)
@@ -1512,17 +1479,17 @@ var Swarm = class {
1512
1479
  onOffer: async (msg) => await this.onOffer(msg),
1513
1480
  topic: this._topic
1514
1481
  });
1515
- log5.trace("dxos.mesh.swarm.constructor", trace2.end({
1482
+ log4.trace("dxos.mesh.swarm.constructor", trace2.end({
1516
1483
  id: this._instanceId
1517
1484
  }), {
1518
- F: __dxlog_file5,
1485
+ F: __dxlog_file4,
1519
1486
  L: 102,
1520
1487
  S: this,
1521
1488
  C: (f, a) => f(...a)
1522
1489
  });
1523
1490
  }
1524
1491
  get connections() {
1525
- return Array.from(this._peers.values()).map((peer) => peer.connection).filter(isNonNullable2);
1492
+ return Array.from(this._peers.values()).map((peer) => peer.connection).filter(isNonNullable);
1526
1493
  }
1527
1494
  get ownPeerId() {
1528
1495
  return PublicKey4.from(this._ownPeer.peerKey);
@@ -1541,7 +1508,7 @@ var Swarm = class {
1541
1508
  }
1542
1509
  async open() {
1543
1510
  invariant4(!this._listeningHandle, void 0, {
1544
- F: __dxlog_file5,
1511
+ F: __dxlog_file4,
1545
1512
  L: 133,
1546
1513
  S: this,
1547
1514
  A: [
@@ -1553,10 +1520,10 @@ var Swarm = class {
1553
1520
  peer: this._ownPeer,
1554
1521
  payloadType: "dxos.mesh.swarm.SwarmMessage",
1555
1522
  onMessage: async (message) => {
1556
- await this._swarmMessenger.receiveMessage(message).catch((err) => log5.info("Error while receiving message", {
1523
+ await this._swarmMessenger.receiveMessage(message).catch((err) => log4.info("Error while receiving message", {
1557
1524
  err
1558
1525
  }, {
1559
- F: __dxlog_file5,
1526
+ F: __dxlog_file4,
1560
1527
  L: 141,
1561
1528
  S: this,
1562
1529
  C: (f, a) => f(...a)
@@ -1565,8 +1532,8 @@ var Swarm = class {
1565
1532
  });
1566
1533
  }
1567
1534
  async destroy() {
1568
- log5("destroying...", void 0, {
1569
- F: __dxlog_file5,
1535
+ log4("destroying...", void 0, {
1536
+ F: __dxlog_file4,
1570
1537
  L: 147,
1571
1538
  S: this,
1572
1539
  C: (f, a) => f(...a)
@@ -1576,8 +1543,8 @@ var Swarm = class {
1576
1543
  await this._ctx.dispose();
1577
1544
  await this._topology.destroy();
1578
1545
  await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key, "swarm destroyed")));
1579
- log5("destroyed", void 0, {
1580
- F: __dxlog_file5,
1546
+ log4("destroyed", void 0, {
1547
+ F: __dxlog_file4,
1581
1548
  L: 154,
1582
1549
  S: this,
1583
1550
  C: (f, a) => f(...a)
@@ -1585,7 +1552,7 @@ var Swarm = class {
1585
1552
  }
1586
1553
  async setTopology(topology) {
1587
1554
  invariant4(!this._ctx.disposed, "Swarm is offline", {
1588
- F: __dxlog_file5,
1555
+ F: __dxlog_file4,
1589
1556
  L: 158,
1590
1557
  S: this,
1591
1558
  A: [
@@ -1596,11 +1563,11 @@ var Swarm = class {
1596
1563
  if (topology === this._topology) {
1597
1564
  return;
1598
1565
  }
1599
- log5("setting topology", {
1566
+ log4("setting topology", {
1600
1567
  previous: getClassName(this._topology),
1601
1568
  topology: getClassName(topology)
1602
1569
  }, {
1603
- F: __dxlog_file5,
1570
+ F: __dxlog_file4,
1604
1571
  L: 162,
1605
1572
  S: this,
1606
1573
  C: (f, a) => f(...a)
@@ -1611,17 +1578,17 @@ var Swarm = class {
1611
1578
  this._topology.update();
1612
1579
  }
1613
1580
  async onSwarmEvent(swarmEvent) {
1614
- log5("swarm event", {
1581
+ log4("swarm event", {
1615
1582
  swarmEvent
1616
1583
  }, {
1617
- F: __dxlog_file5,
1584
+ F: __dxlog_file4,
1618
1585
  L: 175,
1619
1586
  S: this,
1620
1587
  C: (f, a) => f(...a)
1621
1588
  });
1622
1589
  if (this._ctx.disposed) {
1623
- log5("swarm event ignored for disposed swarm", void 0, {
1624
- F: __dxlog_file5,
1590
+ log4("swarm event ignored for disposed swarm", void 0, {
1591
+ F: __dxlog_file4,
1625
1592
  L: 178,
1626
1593
  S: this,
1627
1594
  C: (f, a) => f(...a)
@@ -1631,10 +1598,10 @@ var Swarm = class {
1631
1598
  if (swarmEvent.peerAvailable) {
1632
1599
  const peerId = swarmEvent.peerAvailable.peer.peerKey;
1633
1600
  if (peerId !== this._ownPeer.peerKey) {
1634
- log5("new peer", {
1601
+ log4("new peer", {
1635
1602
  peerId
1636
1603
  }, {
1637
- F: __dxlog_file5,
1604
+ F: __dxlog_file4,
1638
1605
  L: 185,
1639
1606
  S: this,
1640
1607
  C: (f, a) => f(...a)
@@ -1647,24 +1614,24 @@ var Swarm = class {
1647
1614
  if (peer) {
1648
1615
  peer.advertizing = false;
1649
1616
  if (this._isConnectionEstablishmentInProgress(peer)) {
1650
- log5(`destroying peer, state: ${peer.connection?.state}`, void 0, {
1651
- F: __dxlog_file5,
1617
+ log4(`destroying peer, state: ${peer.connection?.state}`, void 0, {
1618
+ F: __dxlog_file4,
1652
1619
  L: 196,
1653
1620
  S: this,
1654
1621
  C: (f, a) => f(...a)
1655
1622
  });
1656
- void this._destroyPeer(swarmEvent.peerLeft.peer, "peer left").catch((err) => log5.catch(err, void 0, {
1657
- F: __dxlog_file5,
1623
+ void this._destroyPeer(swarmEvent.peerLeft.peer, "peer left").catch((err) => log4.catch(err, void 0, {
1624
+ F: __dxlog_file4,
1658
1625
  L: 197,
1659
1626
  S: this,
1660
1627
  C: (f, a) => f(...a)
1661
1628
  }));
1662
1629
  }
1663
1630
  } else {
1664
- log5("received peerLeft but no peer found", {
1631
+ log4("received peerLeft but no peer found", {
1665
1632
  peer: swarmEvent.peerLeft.peer.peerKey
1666
1633
  }, {
1667
- F: __dxlog_file5,
1634
+ F: __dxlog_file4,
1668
1635
  L: 200,
1669
1636
  S: this,
1670
1637
  C: (f, a) => f(...a)
@@ -1674,17 +1641,17 @@ var Swarm = class {
1674
1641
  this._topology.update();
1675
1642
  }
1676
1643
  async onOffer(message) {
1677
- log5("offer", {
1644
+ log4("offer", {
1678
1645
  message
1679
1646
  }, {
1680
- F: __dxlog_file5,
1647
+ F: __dxlog_file4,
1681
1648
  L: 209,
1682
1649
  S: this,
1683
1650
  C: (f, a) => f(...a)
1684
1651
  });
1685
1652
  if (this._ctx.disposed) {
1686
- log5("ignored for disposed swarm", void 0, {
1687
- F: __dxlog_file5,
1653
+ log4("ignored for disposed swarm", void 0, {
1654
+ F: __dxlog_file4,
1688
1655
  L: 211,
1689
1656
  S: this,
1690
1657
  C: (f, a) => f(...a)
@@ -1694,7 +1661,7 @@ var Swarm = class {
1694
1661
  };
1695
1662
  }
1696
1663
  invariant4(message.author, void 0, {
1697
- F: __dxlog_file5,
1664
+ F: __dxlog_file4,
1698
1665
  L: 216,
1699
1666
  S: this,
1700
1667
  A: [
@@ -1703,10 +1670,10 @@ var Swarm = class {
1703
1670
  ]
1704
1671
  });
1705
1672
  if (message.recipient.peerKey !== this._ownPeer.peerKey) {
1706
- log5("rejecting offer with incorrect peerId", {
1673
+ log4("rejecting offer with incorrect peerId", {
1707
1674
  message
1708
1675
  }, {
1709
- F: __dxlog_file5,
1676
+ F: __dxlog_file4,
1710
1677
  L: 218,
1711
1678
  S: this,
1712
1679
  C: (f, a) => f(...a)
@@ -1716,10 +1683,10 @@ var Swarm = class {
1716
1683
  };
1717
1684
  }
1718
1685
  if (!message.topic?.equals(this._topic)) {
1719
- log5("rejecting offer with incorrect topic", {
1686
+ log4("rejecting offer with incorrect topic", {
1720
1687
  message
1721
1688
  }, {
1722
- F: __dxlog_file5,
1689
+ F: __dxlog_file4,
1723
1690
  L: 222,
1724
1691
  S: this,
1725
1692
  C: (f, a) => f(...a)
@@ -1744,17 +1711,17 @@ var Swarm = class {
1744
1711
  return peer;
1745
1712
  }
1746
1713
  async onSignal(message) {
1747
- log5("signal", {
1714
+ log4("signal", {
1748
1715
  message
1749
1716
  }, {
1750
- F: __dxlog_file5,
1717
+ F: __dxlog_file4,
1751
1718
  L: 247,
1752
1719
  S: this,
1753
1720
  C: (f, a) => f(...a)
1754
1721
  });
1755
1722
  if (this._ctx.disposed) {
1756
- log5.info("ignored for offline swarm", void 0, {
1757
- F: __dxlog_file5,
1723
+ log4.info("ignored for offline swarm", void 0, {
1724
+ F: __dxlog_file4,
1758
1725
  L: 249,
1759
1726
  S: this,
1760
1727
  C: (f, a) => f(...a)
@@ -1762,7 +1729,7 @@ var Swarm = class {
1762
1729
  return;
1763
1730
  }
1764
1731
  invariant4(message.recipient.peerKey === this._ownPeer.peerKey, `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
1765
- F: __dxlog_file5,
1732
+ F: __dxlog_file4,
1766
1733
  L: 252,
1767
1734
  S: this,
1768
1735
  A: [
@@ -1771,7 +1738,7 @@ var Swarm = class {
1771
1738
  ]
1772
1739
  });
1773
1740
  invariant4(message.topic?.equals(this._topic), void 0, {
1774
- F: __dxlog_file5,
1741
+ F: __dxlog_file4,
1775
1742
  L: 256,
1776
1743
  S: this,
1777
1744
  A: [
@@ -1780,7 +1747,7 @@ var Swarm = class {
1780
1747
  ]
1781
1748
  });
1782
1749
  invariant4(message.author, void 0, {
1783
- F: __dxlog_file5,
1750
+ F: __dxlog_file4,
1784
1751
  L: 257,
1785
1752
  S: this,
1786
1753
  A: [
@@ -1801,13 +1768,13 @@ var Swarm = class {
1801
1768
  // For debug purposes
1802
1769
  async goOnline() {
1803
1770
  this._ctx = new Context4(void 0, {
1804
- F: __dxlog_file5,
1771
+ F: __dxlog_file4,
1805
1772
  L: 273
1806
1773
  });
1807
1774
  }
1808
1775
  _getOrCreatePeer(peerInfo) {
1809
1776
  invariant4(peerInfo.peerKey, "PeerInfo.peerKey is required", {
1810
- F: __dxlog_file5,
1777
+ F: __dxlog_file4,
1811
1778
  L: 277,
1812
1779
  S: this,
1813
1780
  A: [
@@ -1826,8 +1793,8 @@ var Swarm = class {
1826
1793
  },
1827
1794
  onDisconnected: async () => {
1828
1795
  if (this._isUnregistered(peer)) {
1829
- log5.verbose("ignored onDisconnected for unregistered peer", void 0, {
1830
- F: __dxlog_file5,
1796
+ log4.verbose("ignored onDisconnected for unregistered peer", void 0, {
1797
+ F: __dxlog_file4,
1831
1798
  L: 297,
1832
1799
  S: this,
1833
1800
  C: (f, a) => f(...a)
@@ -1842,10 +1809,10 @@ var Swarm = class {
1842
1809
  },
1843
1810
  onRejected: () => {
1844
1811
  if (!this._isUnregistered(peer)) {
1845
- log5("peer rejected connection", {
1812
+ log4("peer rejected connection", {
1846
1813
  peerInfo
1847
1814
  }, {
1848
- F: __dxlog_file5,
1815
+ F: __dxlog_file4,
1849
1816
  L: 311,
1850
1817
  S: this,
1851
1818
  C: (f, a) => f(...a)
@@ -1868,18 +1835,18 @@ var Swarm = class {
1868
1835
  return peer;
1869
1836
  }
1870
1837
  async _destroyPeer(peerInfo, reason) {
1871
- log5("destroy peer", {
1838
+ log4("destroy peer", {
1872
1839
  peerKey: peerInfo.peerKey,
1873
1840
  reason
1874
1841
  }, {
1875
- F: __dxlog_file5,
1842
+ F: __dxlog_file4,
1876
1843
  L: 333,
1877
1844
  S: this,
1878
1845
  C: (f, a) => f(...a)
1879
1846
  });
1880
1847
  const peer = this._peers.get(peerInfo);
1881
1848
  invariant4(peer, void 0, {
1882
- F: __dxlog_file5,
1849
+ F: __dxlog_file4,
1883
1850
  L: 335,
1884
1851
  S: this,
1885
1852
  A: [
@@ -1908,8 +1875,8 @@ var Swarm = class {
1908
1875
  peerKey: peer.toHex()
1909
1876
  });
1910
1877
  } catch (err) {
1911
- log5("initiation error", err, {
1912
- F: __dxlog_file5,
1878
+ log4("initiation error", err, {
1879
+ F: __dxlog_file4,
1913
1880
  L: 362,
1914
1881
  S: this,
1915
1882
  C: (f, a) => f(...a)
@@ -1937,10 +1904,10 @@ var Swarm = class {
1937
1904
  const ctx = this._ctx;
1938
1905
  const peer = this._getOrCreatePeer(remotePeer);
1939
1906
  if (remotePeer.peerKey < this._ownPeer.peerKey) {
1940
- log5("initiation delay", {
1907
+ log4("initiation delay", {
1941
1908
  remotePeer
1942
1909
  }, {
1943
- F: __dxlog_file5,
1910
+ F: __dxlog_file4,
1944
1911
  L: 390,
1945
1912
  S: this,
1946
1913
  C: (f, a) => f(...a)
@@ -1956,20 +1923,20 @@ var Swarm = class {
1956
1923
  if (peer.connection) {
1957
1924
  return;
1958
1925
  }
1959
- log5("initiating connection...", {
1926
+ log4("initiating connection...", {
1960
1927
  remotePeer
1961
1928
  }, {
1962
- F: __dxlog_file5,
1929
+ F: __dxlog_file4,
1963
1930
  L: 406,
1964
1931
  S: this,
1965
1932
  C: (f, a) => f(...a)
1966
1933
  });
1967
1934
  await peer.initiateConnection();
1968
1935
  this._topology.update();
1969
- log5("initiated", {
1936
+ log4("initiated", {
1970
1937
  remotePeer
1971
1938
  }, {
1972
- F: __dxlog_file5,
1939
+ F: __dxlog_file4,
1973
1940
  L: 409,
1974
1941
  S: this,
1975
1942
  C: (f, a) => f(...a)
@@ -2021,10 +1988,10 @@ _ts_decorate3([
2021
1988
  // src/swarm/swarm-mapper.ts
2022
1989
  import { Event as Event4, SubscriptionList } from "@dxos/async";
2023
1990
  import { PublicKey as PublicKey5 } from "@dxos/keys";
2024
- import { log as log6 } from "@dxos/log";
1991
+ import { log as log5 } from "@dxos/log";
2025
1992
  import { PeerInfoHash as PeerInfoHash2 } from "@dxos/messaging";
2026
1993
  import { ComplexMap as ComplexMap3 } from "@dxos/util";
2027
- var __dxlog_file6 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
1994
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
2028
1995
  var SwarmMapper = class {
2029
1996
  _swarm;
2030
1997
  _subscriptions = new SubscriptionList();
@@ -2050,8 +2017,8 @@ var SwarmMapper = class {
2050
2017
  this._update();
2051
2018
  }
2052
2019
  _update() {
2053
- log6("updating swarm", void 0, {
2054
- F: __dxlog_file6,
2020
+ log5("updating swarm", void 0, {
2021
+ F: __dxlog_file5,
2055
2022
  L: 71,
2056
2023
  S: this,
2057
2024
  C: (f, a) => f(...a)
@@ -2071,11 +2038,11 @@ var SwarmMapper = class {
2071
2038
  ]
2072
2039
  });
2073
2040
  }
2074
- log6("graph changed", {
2041
+ log5("graph changed", {
2075
2042
  directConnections: this._swarm.connections.length,
2076
2043
  totalPeersInSwarm: this._peers.size
2077
2044
  }, {
2078
- F: __dxlog_file6,
2045
+ F: __dxlog_file5,
2079
2046
  L: 112,
2080
2047
  S: this,
2081
2048
  C: (f, a) => f(...a)
@@ -2095,14 +2062,14 @@ import { DeferredTask as DeferredTask2 } from "@dxos/async";
2095
2062
  import { Context as Context5 } from "@dxos/context";
2096
2063
  import { invariant as invariant5 } from "@dxos/invariant";
2097
2064
  import { PublicKey as PublicKey6 } from "@dxos/keys";
2098
- import { log as log7 } from "@dxos/log";
2065
+ import { log as log6 } from "@dxos/log";
2099
2066
  import { CancelledError as CancelledError3 } from "@dxos/protocols";
2100
2067
  import { ComplexMap as ComplexMap4 } from "@dxos/util";
2101
- var __dxlog_file7 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
2068
+ var __dxlog_file6 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
2102
2069
  var MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
2103
2070
  var ConnectionLimiter = class {
2104
2071
  _ctx = new Context5(void 0, {
2105
- F: __dxlog_file7,
2072
+ F: __dxlog_file6,
2106
2073
  L: 23
2107
2074
  });
2108
2075
  _maxConcurrentInitConnections;
@@ -2123,7 +2090,7 @@ var ConnectionLimiter = class {
2123
2090
  */
2124
2091
  async connecting(sessionId) {
2125
2092
  invariant5(!this._waitingPromises.has(sessionId), "Peer is already waiting for connection", {
2126
- F: __dxlog_file7,
2093
+ F: __dxlog_file6,
2127
2094
  L: 48,
2128
2095
  S: this,
2129
2096
  A: [
@@ -2131,10 +2098,10 @@ var ConnectionLimiter = class {
2131
2098
  "'Peer is already waiting for connection'"
2132
2099
  ]
2133
2100
  });
2134
- log7("waiting", {
2101
+ log6("waiting", {
2135
2102
  sessionId
2136
2103
  }, {
2137
- F: __dxlog_file7,
2104
+ F: __dxlog_file6,
2138
2105
  L: 49,
2139
2106
  S: this,
2140
2107
  C: (f, a) => f(...a)
@@ -2146,10 +2113,10 @@ var ConnectionLimiter = class {
2146
2113
  });
2147
2114
  this.resolveWaitingPromises.schedule();
2148
2115
  });
2149
- log7("allow", {
2116
+ log6("allow", {
2150
2117
  sessionId
2151
2118
  }, {
2152
- F: __dxlog_file7,
2119
+ F: __dxlog_file6,
2153
2120
  L: 57,
2154
2121
  S: this,
2155
2122
  C: (f, a) => f(...a)
@@ -2159,10 +2126,10 @@ var ConnectionLimiter = class {
2159
2126
  * Rejects promise returned by `connecting` method.
2160
2127
  */
2161
2128
  doneConnecting(sessionId) {
2162
- log7("done", {
2129
+ log6("done", {
2163
2130
  sessionId
2164
2131
  }, {
2165
- F: __dxlog_file7,
2132
+ F: __dxlog_file6,
2166
2133
  L: 64,
2167
2134
  S: this,
2168
2135
  C: (f, a) => f(...a)
@@ -2270,7 +2237,7 @@ var gcSwarm = (swarm) => {
2270
2237
  import { Event as Event6, synchronized as synchronized4 } from "@dxos/async";
2271
2238
  import { invariant as invariant6 } from "@dxos/invariant";
2272
2239
  import { PublicKey as PublicKey8 } from "@dxos/keys";
2273
- import { log as log8 } from "@dxos/log";
2240
+ import { log as log7 } from "@dxos/log";
2274
2241
  import { Messenger } from "@dxos/messaging";
2275
2242
  import { trace as trace3 } from "@dxos/protocols";
2276
2243
  import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
@@ -2281,7 +2248,7 @@ function _ts_decorate4(decorators, target, key, desc) {
2281
2248
  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;
2282
2249
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2283
2250
  }
2284
- var __dxlog_file8 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
2251
+ var __dxlog_file7 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
2285
2252
  var SwarmNetworkManager = class {
2286
2253
  /**
2287
2254
  * @internal
@@ -2337,20 +2304,20 @@ var SwarmNetworkManager = class {
2337
2304
  this._peerInfo = peerInfo;
2338
2305
  }
2339
2306
  async open() {
2340
- log8.trace("dxos.mesh.network-manager.open", trace3.begin({
2307
+ log7.trace("dxos.mesh.network-manager.open", trace3.begin({
2341
2308
  id: this._instanceId
2342
2309
  }), {
2343
- F: __dxlog_file8,
2310
+ F: __dxlog_file7,
2344
2311
  L: 133,
2345
2312
  S: this,
2346
2313
  C: (f, a) => f(...a)
2347
2314
  });
2348
2315
  await this._messenger.open();
2349
2316
  await this._signalManager.open();
2350
- log8.trace("dxos.mesh.network-manager.open", trace3.end({
2317
+ log7.trace("dxos.mesh.network-manager.open", trace3.end({
2351
2318
  id: this._instanceId
2352
2319
  }), {
2353
- F: __dxlog_file8,
2320
+ F: __dxlog_file7,
2354
2321
  L: 136,
2355
2322
  S: this,
2356
2323
  C: (f, a) => f(...a)
@@ -2359,8 +2326,8 @@ var SwarmNetworkManager = class {
2359
2326
  async close() {
2360
2327
  for (const topic of this._swarms.keys()) {
2361
2328
  await this.leaveSwarm(topic).catch((err) => {
2362
- log8(err, void 0, {
2363
- F: __dxlog_file8,
2329
+ log7(err, void 0, {
2330
+ F: __dxlog_file7,
2364
2331
  L: 142,
2365
2332
  S: this,
2366
2333
  C: (f, a) => f(...a)
@@ -2375,7 +2342,7 @@ var SwarmNetworkManager = class {
2375
2342
  */
2376
2343
  async joinSwarm({ topic, topology, protocolProvider: protocol, label }) {
2377
2344
  invariant6(PublicKey8.isPublicKey(topic), void 0, {
2378
- F: __dxlog_file8,
2345
+ F: __dxlog_file7,
2379
2346
  L: 160,
2380
2347
  S: this,
2381
2348
  A: [
@@ -2384,7 +2351,7 @@ var SwarmNetworkManager = class {
2384
2351
  ]
2385
2352
  });
2386
2353
  invariant6(topology, void 0, {
2387
- F: __dxlog_file8,
2354
+ F: __dxlog_file7,
2388
2355
  L: 161,
2389
2356
  S: this,
2390
2357
  A: [
@@ -2393,7 +2360,7 @@ var SwarmNetworkManager = class {
2393
2360
  ]
2394
2361
  });
2395
2362
  invariant6(this._peerInfo, void 0, {
2396
- F: __dxlog_file8,
2363
+ F: __dxlog_file7,
2397
2364
  L: 162,
2398
2365
  S: this,
2399
2366
  A: [
@@ -2402,7 +2369,7 @@ var SwarmNetworkManager = class {
2402
2369
  ]
2403
2370
  });
2404
2371
  invariant6(typeof protocol === "function", void 0, {
2405
- F: __dxlog_file8,
2372
+ F: __dxlog_file7,
2406
2373
  L: 163,
2407
2374
  S: this,
2408
2375
  A: [
@@ -2413,22 +2380,22 @@ var SwarmNetworkManager = class {
2413
2380
  if (this._swarms.has(topic)) {
2414
2381
  throw new Error(`Already connected to swarm: ${PublicKey8.from(topic)}`);
2415
2382
  }
2416
- log8("joining", {
2383
+ log7("joining", {
2417
2384
  topic: PublicKey8.from(topic),
2418
2385
  peerInfo: this._peerInfo,
2419
2386
  topology: topology.toString()
2420
2387
  }, {
2421
- F: __dxlog_file8,
2388
+ F: __dxlog_file7,
2422
2389
  L: 168,
2423
2390
  S: this,
2424
2391
  C: (f, a) => f(...a)
2425
2392
  });
2426
2393
  const swarm = new Swarm(topic, this._peerInfo, topology, protocol, this._messenger, this._transportFactory, label, this._connectionLimiter);
2427
2394
  swarm.errors.handle((error) => {
2428
- log8("swarm error", {
2395
+ log7("swarm error", {
2429
2396
  error
2430
2397
  }, {
2431
- F: __dxlog_file8,
2398
+ F: __dxlog_file7,
2432
2399
  L: 181,
2433
2400
  S: this,
2434
2401
  C: (f, a) => f(...a)
@@ -2440,19 +2407,19 @@ var SwarmNetworkManager = class {
2440
2407
  this._signalConnection.join({
2441
2408
  topic,
2442
2409
  peer: this._peerInfo
2443
- }).catch((error) => log8.catch(error, void 0, {
2444
- F: __dxlog_file8,
2410
+ }).catch((error) => log7.catch(error, void 0, {
2411
+ F: __dxlog_file7,
2445
2412
  L: 190,
2446
2413
  S: this,
2447
2414
  C: (f, a) => f(...a)
2448
2415
  }));
2449
2416
  this.topicsUpdated.emit();
2450
2417
  this._connectionLog?.joinedSwarm(swarm);
2451
- log8("joined", {
2418
+ log7("joined", {
2452
2419
  topic: PublicKey8.from(topic),
2453
2420
  count: this._swarms.size
2454
2421
  }, {
2455
- F: __dxlog_file8,
2422
+ F: __dxlog_file7,
2456
2423
  L: 194,
2457
2424
  S: this,
2458
2425
  C: (f, a) => f(...a)
@@ -2468,10 +2435,10 @@ var SwarmNetworkManager = class {
2468
2435
  if (!this._swarms.has(topic)) {
2469
2436
  return;
2470
2437
  }
2471
- log8("leaving", {
2438
+ log7("leaving", {
2472
2439
  topic: PublicKey8.from(topic)
2473
2440
  }, {
2474
- F: __dxlog_file8,
2441
+ F: __dxlog_file7,
2475
2442
  L: 211,
2476
2443
  S: this,
2477
2444
  C: (f, a) => f(...a)
@@ -2488,11 +2455,11 @@ var SwarmNetworkManager = class {
2488
2455
  await swarm.destroy();
2489
2456
  this._swarms.delete(topic);
2490
2457
  this.topicsUpdated.emit();
2491
- log8("left", {
2458
+ log7("left", {
2492
2459
  topic: PublicKey8.from(topic),
2493
2460
  count: this._swarms.size
2494
2461
  }, {
2495
- F: __dxlog_file8,
2462
+ F: __dxlog_file7,
2496
2463
  L: 225,
2497
2464
  S: this,
2498
2465
  C: (f, a) => f(...a)
@@ -2534,7 +2501,7 @@ _ts_decorate4([
2534
2501
 
2535
2502
  // src/topology/fully-connected-topology.ts
2536
2503
  import { invariant as invariant7 } from "@dxos/invariant";
2537
- var __dxlog_file9 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
2504
+ var __dxlog_file8 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
2538
2505
  var FullyConnectedTopology = class {
2539
2506
  _controller;
2540
2507
  toString() {
@@ -2542,7 +2509,7 @@ var FullyConnectedTopology = class {
2542
2509
  }
2543
2510
  init(controller) {
2544
2511
  invariant7(!this._controller, "Already initialized", {
2545
- F: __dxlog_file9,
2512
+ F: __dxlog_file8,
2546
2513
  L: 18,
2547
2514
  S: this,
2548
2515
  A: [
@@ -2554,7 +2521,7 @@ var FullyConnectedTopology = class {
2554
2521
  }
2555
2522
  update() {
2556
2523
  invariant7(this._controller, "Not initialized", {
2557
- F: __dxlog_file9,
2524
+ F: __dxlog_file8,
2558
2525
  L: 23,
2559
2526
  S: this,
2560
2527
  A: [
@@ -2574,321 +2541,13 @@ var FullyConnectedTopology = class {
2574
2541
  }
2575
2542
  };
2576
2543
 
2577
- // src/topology/mmst-topology.ts
2578
- import { invariant as invariant8 } from "@dxos/invariant";
2579
- import { log as log9 } from "@dxos/log";
2580
- var __dxlog_file10 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
2581
- var MIN_UPDATE_INTERVAL = 1e3 * 10;
2582
- var MAX_CHANGES_PER_UPDATE = 1;
2583
- var MMSTTopology = class {
2584
- _originateConnections;
2585
- _maxPeers;
2586
- _sampleSize;
2587
- _controller;
2588
- _sampleCollected = false;
2589
- _lastAction = /* @__PURE__ */ new Date(0);
2590
- constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
2591
- this._originateConnections = originateConnections;
2592
- this._maxPeers = maxPeers;
2593
- this._sampleSize = sampleSize;
2594
- }
2595
- init(controller) {
2596
- invariant8(!this._controller, "Already initialized", {
2597
- F: __dxlog_file10,
2598
- L: 49,
2599
- S: this,
2600
- A: [
2601
- "!this._controller",
2602
- "'Already initialized'"
2603
- ]
2604
- });
2605
- this._controller = controller;
2606
- }
2607
- update() {
2608
- invariant8(this._controller, "Not initialized", {
2609
- F: __dxlog_file10,
2610
- L: 54,
2611
- S: this,
2612
- A: [
2613
- "this._controller",
2614
- "'Not initialized'"
2615
- ]
2616
- });
2617
- const { connected, candidates } = this._controller.getState();
2618
- if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
2619
- log9("Running the algorithm.", void 0, {
2620
- F: __dxlog_file10,
2621
- L: 58,
2622
- S: this,
2623
- C: (f, a) => f(...a)
2624
- });
2625
- this._sampleCollected = true;
2626
- this._runAlgorithm();
2627
- }
2628
- }
2629
- forceUpdate() {
2630
- this._lastAction = /* @__PURE__ */ new Date(0);
2631
- this.update();
2632
- }
2633
- async onOffer(peer) {
2634
- invariant8(this._controller, "Not initialized", {
2635
- F: __dxlog_file10,
2636
- L: 70,
2637
- S: this,
2638
- A: [
2639
- "this._controller",
2640
- "'Not initialized'"
2641
- ]
2642
- });
2643
- const { connected } = this._controller.getState();
2644
- const accept = connected.length < this._maxPeers;
2645
- log9(`Offer ${peer} accept=${accept}`, void 0, {
2646
- F: __dxlog_file10,
2647
- L: 73,
2648
- S: this,
2649
- C: (f, a) => f(...a)
2650
- });
2651
- return accept;
2652
- }
2653
- async destroy() {
2654
- }
2655
- _runAlgorithm() {
2656
- invariant8(this._controller, "Not initialized", {
2657
- F: __dxlog_file10,
2658
- L: 82,
2659
- S: this,
2660
- A: [
2661
- "this._controller",
2662
- "'Not initialized'"
2663
- ]
2664
- });
2665
- const { connected, candidates, ownPeerId } = this._controller.getState();
2666
- if (connected.length > this._maxPeers) {
2667
- log9(`disconnect ${connected.length - this._maxPeers} peers.`, void 0, {
2668
- F: __dxlog_file10,
2669
- L: 88,
2670
- S: this,
2671
- C: (f, a) => f(...a)
2672
- });
2673
- const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
2674
- invariant8(sorted.length === 0, void 0, {
2675
- F: __dxlog_file10,
2676
- L: 92,
2677
- S: this,
2678
- A: [
2679
- "sorted.length === 0",
2680
- ""
2681
- ]
2682
- });
2683
- if (sorted.length > MAX_CHANGES_PER_UPDATE) {
2684
- log9(`want to disconnect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`, void 0, {
2685
- F: __dxlog_file10,
2686
- L: 95,
2687
- S: this,
2688
- C: (f, a) => f(...a)
2689
- });
2690
- }
2691
- if (Date.now() - this._lastAction.getTime() > MIN_UPDATE_INTERVAL) {
2692
- for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
2693
- log9(`Disconnect ${peer}.`, void 0, {
2694
- F: __dxlog_file10,
2695
- L: 100,
2696
- S: this,
2697
- C: (f, a) => f(...a)
2698
- });
2699
- this._controller.disconnect(peer);
2700
- }
2701
- this._lastAction = /* @__PURE__ */ new Date();
2702
- } else {
2703
- log9("rate limited disconnect", void 0, {
2704
- F: __dxlog_file10,
2705
- L: 105,
2706
- S: this,
2707
- C: (f, a) => f(...a)
2708
- });
2709
- }
2710
- } else if (connected.length < this._originateConnections) {
2711
- log9(`connect ${this._originateConnections - connected.length} peers.`, void 0, {
2712
- F: __dxlog_file10,
2713
- L: 109,
2714
- S: this,
2715
- C: (f, a) => f(...a)
2716
- });
2717
- const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
2718
- const sorted = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
2719
- if (sorted.length > MAX_CHANGES_PER_UPDATE) {
2720
- log9(`want to connect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`, void 0, {
2721
- F: __dxlog_file10,
2722
- L: 114,
2723
- S: this,
2724
- C: (f, a) => f(...a)
2725
- });
2726
- }
2727
- if (Date.now() - this._lastAction.getTime() > MIN_UPDATE_INTERVAL) {
2728
- for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
2729
- log9(`Connect ${peer}.`, void 0, {
2730
- F: __dxlog_file10,
2731
- L: 118,
2732
- S: this,
2733
- C: (f, a) => f(...a)
2734
- });
2735
- this._controller.connect(peer);
2736
- }
2737
- this._lastAction = /* @__PURE__ */ new Date();
2738
- } else {
2739
- log9("rate limited connect", void 0, {
2740
- F: __dxlog_file10,
2741
- L: 123,
2742
- S: this,
2743
- C: (f, a) => f(...a)
2744
- });
2745
- }
2746
- }
2747
- }
2748
- toString() {
2749
- return "MMSTTopology";
2750
- }
2751
- };
2752
- var sortByXorDistance = (keys, reference) => {
2753
- const sorted = keys.sort((a, b) => {
2754
- return compareXor(distXor(a.asBuffer(), reference.asBuffer()), distXor(b.asBuffer(), reference.asBuffer()));
2755
- });
2756
- log9("Sorted keys", {
2757
- keys,
2758
- reference,
2759
- sorted
2760
- }, {
2761
- F: __dxlog_file10,
2762
- L: 137,
2763
- S: void 0,
2764
- C: (f, a) => f(...a)
2765
- });
2766
- return sorted;
2767
- };
2768
- var distXor = (a, b) => {
2769
- const maxLength = Math.max(a.length, b.length);
2770
- const result = Buffer.allocUnsafe(maxLength);
2771
- for (let i = 0; i < maxLength; i++) {
2772
- result[i] = (a[i] || 0) ^ (b[i] || 0);
2773
- }
2774
- return result;
2775
- };
2776
- var compareXor = (a, b) => {
2777
- const maxLength = Math.max(a.length, b.length);
2778
- for (let i = 0; i < maxLength; i++) {
2779
- if ((a[i] || 0) === (b[i] || 0)) {
2780
- continue;
2781
- }
2782
- return (a[i] || 0) < (b[i] || 0) ? -1 : 1;
2783
- }
2784
- return 0;
2785
- };
2786
-
2787
- // src/topology/star-topology.ts
2788
- import { invariant as invariant9 } from "@dxos/invariant";
2789
- import { log as log10 } from "@dxos/log";
2790
- var __dxlog_file11 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
2791
- var StarTopology = class {
2792
- _centralPeer;
2793
- _controller;
2794
- constructor(_centralPeer) {
2795
- this._centralPeer = _centralPeer;
2796
- }
2797
- toString() {
2798
- return `StarTopology(${this._centralPeer.truncate()})`;
2799
- }
2800
- init(controller) {
2801
- invariant9(!this._controller, "Already initialized.", {
2802
- F: __dxlog_file11,
2803
- L: 21,
2804
- S: this,
2805
- A: [
2806
- "!this._controller",
2807
- "'Already initialized.'"
2808
- ]
2809
- });
2810
- this._controller = controller;
2811
- }
2812
- update() {
2813
- invariant9(this._controller, "Not initialized.", {
2814
- F: __dxlog_file11,
2815
- L: 26,
2816
- S: this,
2817
- A: [
2818
- "this._controller",
2819
- "'Not initialized.'"
2820
- ]
2821
- });
2822
- const { candidates, connected, ownPeerId } = this._controller.getState();
2823
- if (!ownPeerId.equals(this._centralPeer)) {
2824
- log10("leaf peer dropping all connections apart from central peer.", void 0, {
2825
- F: __dxlog_file11,
2826
- L: 29,
2827
- S: this,
2828
- C: (f, a) => f(...a)
2829
- });
2830
- for (const peer of connected) {
2831
- if (!peer.equals(this._centralPeer)) {
2832
- log10("dropping connection", {
2833
- peer
2834
- }, {
2835
- F: __dxlog_file11,
2836
- L: 34,
2837
- S: this,
2838
- C: (f, a) => f(...a)
2839
- });
2840
- this._controller.disconnect(peer);
2841
- }
2842
- }
2843
- }
2844
- for (const peer of candidates) {
2845
- if (peer.equals(this._centralPeer) || ownPeerId.equals(this._centralPeer)) {
2846
- log10("connecting to peer", {
2847
- peer
2848
- }, {
2849
- F: __dxlog_file11,
2850
- L: 43,
2851
- S: this,
2852
- C: (f, a) => f(...a)
2853
- });
2854
- this._controller.connect(peer);
2855
- }
2856
- }
2857
- }
2858
- async onOffer(peer) {
2859
- invariant9(this._controller, "Not initialized.", {
2860
- F: __dxlog_file11,
2861
- L: 50,
2862
- S: this,
2863
- A: [
2864
- "this._controller",
2865
- "'Not initialized.'"
2866
- ]
2867
- });
2868
- const { ownPeerId } = this._controller.getState();
2869
- log10("offer", {
2870
- peer,
2871
- isCentral: peer.equals(this._centralPeer),
2872
- isSelfCentral: ownPeerId.equals(this._centralPeer)
2873
- }, {
2874
- F: __dxlog_file11,
2875
- L: 52,
2876
- S: this,
2877
- C: (f, a) => f(...a)
2878
- });
2879
- return ownPeerId.equals(this._centralPeer) || peer.equals(this._centralPeer);
2880
- }
2881
- async destroy() {
2882
- }
2883
- };
2884
-
2885
2544
  // src/transport/memory-transport.ts
2886
2545
  import { Transform } from "@dxos/node-std/stream";
2887
2546
  import { Event as Event7, Trigger as Trigger2 } from "@dxos/async";
2888
2547
  import { ErrorStream as ErrorStream3 } from "@dxos/debug";
2889
- import { invariant as invariant10 } from "@dxos/invariant";
2548
+ import { invariant as invariant8 } from "@dxos/invariant";
2890
2549
  import { PublicKey as PublicKey9 } from "@dxos/keys";
2891
- import { log as log11, logInfo as logInfo3 } from "@dxos/log";
2550
+ import { log as log8, logInfo as logInfo3 } from "@dxos/log";
2892
2551
  import { ComplexMap as ComplexMap7 } from "@dxos/util";
2893
2552
  function _ts_decorate5(decorators, target, key, desc) {
2894
2553
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -2896,7 +2555,7 @@ function _ts_decorate5(decorators, target, key, desc) {
2896
2555
  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;
2897
2556
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2898
2557
  }
2899
- var __dxlog_file12 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
2558
+ var __dxlog_file9 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
2900
2559
  var MEMORY_TRANSPORT_DELAY = 1;
2901
2560
  var createStreamDelay = (delay) => {
2902
2561
  return new Transform({
@@ -2925,8 +2584,8 @@ var MemoryTransport = class _MemoryTransport {
2925
2584
  errors = new ErrorStream3();
2926
2585
  constructor(_options) {
2927
2586
  this._options = _options;
2928
- invariant10(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection", {
2929
- F: __dxlog_file12,
2587
+ invariant8(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection", {
2588
+ F: __dxlog_file9,
2930
2589
  L: 64,
2931
2590
  S: this,
2932
2591
  A: [
@@ -2940,15 +2599,15 @@ var MemoryTransport = class _MemoryTransport {
2940
2599
  return !this._closed;
2941
2600
  }
2942
2601
  async open() {
2943
- log11("opening...", void 0, {
2944
- F: __dxlog_file12,
2602
+ log8("opening...", void 0, {
2603
+ F: __dxlog_file9,
2945
2604
  L: 74,
2946
2605
  S: this,
2947
2606
  C: (f, a) => f(...a)
2948
2607
  });
2949
2608
  if (this._options.initiator) {
2950
- log11("sending signal", void 0, {
2951
- F: __dxlog_file12,
2609
+ log8("sending signal", void 0, {
2610
+ F: __dxlog_file9,
2952
2611
  L: 78,
2953
2612
  S: this,
2954
2613
  C: (f, a) => f(...a)
@@ -2978,8 +2637,8 @@ var MemoryTransport = class _MemoryTransport {
2978
2637
  this.closed.emit();
2979
2638
  return;
2980
2639
  }
2981
- invariant10(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`, {
2982
- F: __dxlog_file12,
2640
+ invariant8(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`, {
2641
+ F: __dxlog_file9,
2983
2642
  L: 104,
2984
2643
  S: this,
2985
2644
  A: [
@@ -2989,8 +2648,8 @@ var MemoryTransport = class _MemoryTransport {
2989
2648
  });
2990
2649
  this._remoteConnection._remoteConnection = this;
2991
2650
  this._remoteConnection._remoteInstanceId = this._instanceId;
2992
- log11("connected", void 0, {
2993
- F: __dxlog_file12,
2651
+ log8("connected", void 0, {
2652
+ F: __dxlog_file9,
2994
2653
  L: 108,
2995
2654
  S: this,
2996
2655
  C: (f, a) => f(...a)
@@ -3008,8 +2667,8 @@ var MemoryTransport = class _MemoryTransport {
3008
2667
  return this;
3009
2668
  }
3010
2669
  async close() {
3011
- log11("closing...", void 0, {
3012
- F: __dxlog_file12,
2670
+ log8("closing...", void 0, {
2671
+ F: __dxlog_file9,
3013
2672
  L: 130,
3014
2673
  S: this,
3015
2674
  C: (f, a) => f(...a)
@@ -3029,8 +2688,8 @@ var MemoryTransport = class _MemoryTransport {
3029
2688
  this._remoteConnection = void 0;
3030
2689
  }
3031
2690
  this.closed.emit();
3032
- log11("closed", void 0, {
3033
- F: __dxlog_file12,
2691
+ log8("closed", void 0, {
2692
+ F: __dxlog_file9,
3034
2693
  L: 158,
3035
2694
  S: this,
3036
2695
  C: (f, a) => f(...a)
@@ -3038,10 +2697,10 @@ var MemoryTransport = class _MemoryTransport {
3038
2697
  return this;
3039
2698
  }
3040
2699
  async onSignal({ payload }) {
3041
- log11("received signal", {
2700
+ log8("received signal", {
3042
2701
  payload
3043
2702
  }, {
3044
- F: __dxlog_file12,
2703
+ F: __dxlog_file9,
3045
2704
  L: 163,
3046
2705
  S: this,
3047
2706
  C: (f, a) => f(...a)
@@ -3131,8 +2790,8 @@ var getRtcConnectionFactory = () => {
3131
2790
 
3132
2791
  // src/transport/webrtc/rtc-peer-connection.ts
3133
2792
  import { Mutex as Mutex2, Trigger as Trigger3, synchronized as synchronized5 } from "@dxos/async";
3134
- import { invariant as invariant12 } from "@dxos/invariant";
3135
- import { log as log13, logInfo as logInfo4 } from "@dxos/log";
2793
+ import { invariant as invariant10 } from "@dxos/invariant";
2794
+ import { log as log10, logInfo as logInfo4 } from "@dxos/log";
3136
2795
  import { ConnectivityError as ConnectivityError3 } from "@dxos/protocols";
3137
2796
  import { trace as trace4 } from "@dxos/tracing";
3138
2797
 
@@ -3141,8 +2800,8 @@ import { Duplex } from "@dxos/node-std/stream";
3141
2800
  import { Event as AsyncEvent } from "@dxos/async";
3142
2801
  import { Resource } from "@dxos/context";
3143
2802
  import { ErrorStream as ErrorStream4 } from "@dxos/debug";
3144
- import { invariant as invariant11 } from "@dxos/invariant";
3145
- import { log as log12 } from "@dxos/log";
2803
+ import { invariant as invariant9 } from "@dxos/invariant";
2804
+ import { log as log9 } from "@dxos/log";
3146
2805
  import { ConnectivityError as ConnectivityError2 } from "@dxos/protocols";
3147
2806
 
3148
2807
  // src/transport/webrtc/rtc-transport-stats.ts
@@ -3193,7 +2852,7 @@ var getRtcConnectionStats = async (connection, channelTopic) => {
3193
2852
  };
3194
2853
 
3195
2854
  // src/transport/webrtc/rtc-transport-channel.ts
3196
- var __dxlog_file13 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-channel.ts";
2855
+ var __dxlog_file10 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-channel.ts";
3197
2856
  var MAX_MESSAGE_SIZE = 64 * 1024;
3198
2857
  var MAX_BUFFERED_AMOUNT = 64 * 1024;
3199
2858
  var RtcTransportChannel = class extends Resource {
@@ -3218,8 +2877,8 @@ var RtcTransportChannel = class extends Resource {
3218
2877
  }
3219
2878
  }
3220
2879
  async _open() {
3221
- invariant11(!this._isChannelCreationInProgress, void 0, {
3222
- F: __dxlog_file13,
2880
+ invariant9(!this._isChannelCreationInProgress, void 0, {
2881
+ F: __dxlog_file10,
3223
2882
  L: 57,
3224
2883
  S: this,
3225
2884
  A: [
@@ -3242,10 +2901,10 @@ var RtcTransportChannel = class extends Resource {
3242
2901
  });
3243
2902
  this.errors.raise(error);
3244
2903
  } else {
3245
- log12.verbose("connection establishment failed after transport was closed", {
2904
+ log9.verbose("connection establishment failed after transport was closed", {
3246
2905
  err
3247
2906
  }, {
3248
- F: __dxlog_file13,
2907
+ F: __dxlog_file10,
3249
2908
  L: 77,
3250
2909
  S: this,
3251
2910
  C: (f, a) => f(...a)
@@ -3262,8 +2921,8 @@ var RtcTransportChannel = class extends Resource {
3262
2921
  this._stream = void 0;
3263
2922
  }
3264
2923
  this.closed.emit();
3265
- log12("closed", void 0, {
3266
- F: __dxlog_file13,
2924
+ log9("closed", void 0, {
2925
+ F: __dxlog_file10,
3267
2926
  L: 93,
3268
2927
  S: this,
3269
2928
  C: (f, a) => f(...a)
@@ -3273,10 +2932,10 @@ var RtcTransportChannel = class extends Resource {
3273
2932
  Object.assign(channel, {
3274
2933
  onopen: () => {
3275
2934
  if (!this.isOpen) {
3276
- log12.warn("channel opened in a closed transport", {
2935
+ log9.warn("channel opened in a closed transport", {
3277
2936
  topic: this._options.topic
3278
2937
  }, {
3279
- F: __dxlog_file13,
2938
+ F: __dxlog_file10,
3280
2939
  L: 100,
3281
2940
  S: this,
3282
2941
  C: (f, a) => f(...a)
@@ -3284,8 +2943,8 @@ var RtcTransportChannel = class extends Resource {
3284
2943
  this._safeCloseChannel(channel);
3285
2944
  return;
3286
2945
  }
3287
- log12("onopen", void 0, {
3288
- F: __dxlog_file13,
2946
+ log9("onopen", void 0, {
2947
+ F: __dxlog_file10,
3289
2948
  L: 105,
3290
2949
  S: this,
3291
2950
  C: (f, a) => f(...a)
@@ -3302,8 +2961,8 @@ var RtcTransportChannel = class extends Resource {
3302
2961
  this.connected.emit();
3303
2962
  },
3304
2963
  onclose: async () => {
3305
- log12("onclose", void 0, {
3306
- F: __dxlog_file13,
2964
+ log9("onclose", void 0, {
2965
+ F: __dxlog_file10,
3307
2966
  L: 118,
3308
2967
  S: this,
3309
2968
  C: (f, a) => f(...a)
@@ -3312,8 +2971,8 @@ var RtcTransportChannel = class extends Resource {
3312
2971
  },
3313
2972
  onmessage: async (event) => {
3314
2973
  if (!this._stream) {
3315
- log12.warn("ignoring message on a closed channel", void 0, {
3316
- F: __dxlog_file13,
2974
+ log9.warn("ignoring message on a closed channel", void 0, {
2975
+ F: __dxlog_file10,
3317
2976
  L: 124,
3318
2977
  S: this,
3319
2978
  C: (f, a) => f(...a)
@@ -3343,8 +3002,8 @@ var RtcTransportChannel = class extends Resource {
3343
3002
  }
3344
3003
  async _handleChannelWrite(chunk, callback) {
3345
3004
  if (!this._channel) {
3346
- log12.warn("writing to a channel after a connection was closed", void 0, {
3347
- F: __dxlog_file13,
3005
+ log9.warn("writing to a channel after a connection was closed", void 0, {
3006
+ F: __dxlog_file10,
3348
3007
  L: 154,
3349
3008
  S: this,
3350
3009
  C: (f, a) => f(...a)
@@ -3366,8 +3025,8 @@ var RtcTransportChannel = class extends Resource {
3366
3025
  }
3367
3026
  if (this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT) {
3368
3027
  if (this._streamDataFlushedCallback !== null) {
3369
- log12.error("consumer trying to write before we are ready for more data", void 0, {
3370
- F: __dxlog_file13,
3028
+ log9.error("consumer trying to write before we are ready for more data", void 0, {
3029
+ F: __dxlog_file10,
3371
3030
  L: 175,
3372
3031
  S: this,
3373
3032
  C: (f, a) => f(...a)
@@ -3382,8 +3041,8 @@ var RtcTransportChannel = class extends Resource {
3382
3041
  try {
3383
3042
  channel.close();
3384
3043
  } catch (error) {
3385
- log12.catch(error, void 0, {
3386
- F: __dxlog_file13,
3044
+ log9.catch(error, void 0, {
3045
+ F: __dxlog_file10,
3387
3046
  L: 187,
3388
3047
  S: this,
3389
3048
  C: (f, a) => f(...a)
@@ -3434,7 +3093,7 @@ function _ts_decorate6(decorators, target, key, desc) {
3434
3093
  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;
3435
3094
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3436
3095
  }
3437
- var __dxlog_file14 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-peer-connection.ts";
3096
+ var __dxlog_file11 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-peer-connection.ts";
3438
3097
  var RtcPeerConnection = class {
3439
3098
  _factory;
3440
3099
  _options;
@@ -3482,8 +3141,8 @@ var RtcPeerConnection = class {
3482
3141
  if (existingChannel) {
3483
3142
  return existingChannel;
3484
3143
  }
3485
- log13("waiting for initiator-peer to open a data channel", void 0, {
3486
- F: __dxlog_file14,
3144
+ log10("waiting for initiator-peer to open a data channel", void 0, {
3145
+ F: __dxlog_file11,
3487
3146
  L: 96,
3488
3147
  S: this,
3489
3148
  C: (f, a) => f(...a)
@@ -3511,10 +3170,10 @@ var RtcPeerConnection = class {
3511
3170
  if (this._connection) {
3512
3171
  return this._connection;
3513
3172
  }
3514
- log13("initializing connection...", () => ({
3173
+ log10("initializing connection...", () => ({
3515
3174
  remotePeer: this._options.remotePeerKey
3516
3175
  }), {
3517
- F: __dxlog_file14,
3176
+ F: __dxlog_file11,
3518
3177
  L: 121,
3519
3178
  S: this,
3520
3179
  C: (f, a) => f(...a)
@@ -3524,8 +3183,8 @@ var RtcPeerConnection = class {
3524
3183
  const iceCandidateErrors = [];
3525
3184
  Object.assign(connection, {
3526
3185
  onnegotiationneeded: async () => {
3527
- invariant12(this._initiator, void 0, {
3528
- F: __dxlog_file14,
3186
+ invariant10(this._initiator, void 0, {
3187
+ F: __dxlog_file11,
3529
3188
  L: 136,
3530
3189
  S: this,
3531
3190
  A: [
@@ -3537,8 +3196,8 @@ var RtcPeerConnection = class {
3537
3196
  this._onConnectionCallbackAfterClose("onnegotiationneeded", connection);
3538
3197
  return;
3539
3198
  }
3540
- log13("onnegotiationneeded", void 0, {
3541
- F: __dxlog_file14,
3199
+ log10("onnegotiationneeded", void 0, {
3200
+ F: __dxlog_file11,
3542
3201
  L: 143,
3543
3202
  S: this,
3544
3203
  C: (f, a) => f(...a)
@@ -3559,18 +3218,18 @@ var RtcPeerConnection = class {
3559
3218
  return;
3560
3219
  }
3561
3220
  if (event.candidate) {
3562
- log13("onicecandidate", {
3221
+ log10("onicecandidate", {
3563
3222
  candidate: event.candidate.candidate
3564
3223
  }, {
3565
- F: __dxlog_file14,
3224
+ F: __dxlog_file11,
3566
3225
  L: 162,
3567
3226
  S: this,
3568
3227
  C: (f, a) => f(...a)
3569
3228
  });
3570
3229
  await this._sendIceCandidate(event.candidate);
3571
3230
  } else {
3572
- log13("onicecandidate gathering complete", void 0, {
3573
- F: __dxlog_file14,
3231
+ log10("onicecandidate gathering complete", void 0, {
3232
+ F: __dxlog_file11,
3574
3233
  L: 165,
3575
3234
  S: this,
3576
3235
  C: (f, a) => f(...a)
@@ -3595,10 +3254,10 @@ var RtcPeerConnection = class {
3595
3254
  this._onConnectionCallbackAfterClose("oniceconnectionstatechange", connection);
3596
3255
  return;
3597
3256
  }
3598
- log13("oniceconnectionstatechange", {
3257
+ log10("oniceconnectionstatechange", {
3599
3258
  state: connection.iceConnectionState
3600
3259
  }, {
3601
- F: __dxlog_file14,
3260
+ F: __dxlog_file11,
3602
3261
  L: 185,
3603
3262
  S: this,
3604
3263
  C: (f, a) => f(...a)
@@ -3617,10 +3276,10 @@ var RtcPeerConnection = class {
3617
3276
  }
3618
3277
  return;
3619
3278
  }
3620
- log13("onconnectionstatechange", {
3279
+ log10("onconnectionstatechange", {
3621
3280
  state: connection.connectionState
3622
3281
  }, {
3623
- F: __dxlog_file14,
3282
+ F: __dxlog_file11,
3624
3283
  L: 202,
3625
3284
  S: this,
3626
3285
  C: (f, a) => f(...a)
@@ -3630,10 +3289,10 @@ var RtcPeerConnection = class {
3630
3289
  }
3631
3290
  },
3632
3291
  onsignalingstatechange: () => {
3633
- log13("onsignalingstatechange", {
3292
+ log10("onsignalingstatechange", {
3634
3293
  state: connection.signalingState
3635
3294
  }, {
3636
- F: __dxlog_file14,
3295
+ F: __dxlog_file11,
3637
3296
  L: 209,
3638
3297
  S: this,
3639
3298
  C: (f, a) => f(...a)
@@ -3642,8 +3301,8 @@ var RtcPeerConnection = class {
3642
3301
  // When channel is added to connection.
3643
3302
  // https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/datachannel_event
3644
3303
  ondatachannel: (event) => {
3645
- invariant12(!this._initiator, "Initiator is expected to create data channels.", {
3646
- F: __dxlog_file14,
3304
+ invariant10(!this._initiator, "Initiator is expected to create data channels.", {
3305
+ F: __dxlog_file11,
3647
3306
  L: 215,
3648
3307
  S: this,
3649
3308
  A: [
@@ -3655,10 +3314,10 @@ var RtcPeerConnection = class {
3655
3314
  this._onConnectionCallbackAfterClose("ondatachannel", connection);
3656
3315
  return;
3657
3316
  }
3658
- log13("ondatachannel", {
3317
+ log10("ondatachannel", {
3659
3318
  label: event.channel.label
3660
3319
  }, {
3661
- F: __dxlog_file14,
3320
+ F: __dxlog_file11,
3662
3321
  L: 222,
3663
3322
  S: this,
3664
3323
  C: (f, a) => f(...a)
@@ -3683,10 +3342,10 @@ var RtcPeerConnection = class {
3683
3342
  }
3684
3343
  _abortConnection(connection, error) {
3685
3344
  if (connection !== this._connection) {
3686
- log13.error("attempted to abort an inactive connection", {
3345
+ log10.error("attempted to abort an inactive connection", {
3687
3346
  error
3688
3347
  }, {
3689
- F: __dxlog_file14,
3348
+ F: __dxlog_file11,
3690
3349
  L: 247,
3691
3350
  S: this,
3692
3351
  C: (f, a) => f(...a)
@@ -3704,18 +3363,18 @@ var RtcPeerConnection = class {
3704
3363
  }
3705
3364
  this._transportChannels.clear();
3706
3365
  this._safeCloseConnection();
3707
- log13("connection aborted", {
3366
+ log10("connection aborted", {
3708
3367
  reason: error.message
3709
3368
  }, {
3710
- F: __dxlog_file14,
3369
+ F: __dxlog_file11,
3711
3370
  L: 261,
3712
3371
  S: this,
3713
3372
  C: (f, a) => f(...a)
3714
3373
  });
3715
3374
  }
3716
3375
  async _lockAndCloseConnection() {
3717
- invariant12(this._transportChannels.size === 0, void 0, {
3718
- F: __dxlog_file14,
3376
+ invariant10(this._transportChannels.size === 0, void 0, {
3377
+ F: __dxlog_file11,
3719
3378
  L: 266,
3720
3379
  S: this,
3721
3380
  A: [
@@ -3725,8 +3384,8 @@ var RtcPeerConnection = class {
3725
3384
  });
3726
3385
  if (this._connection) {
3727
3386
  this._safeCloseConnection();
3728
- log13("connection closed", void 0, {
3729
- F: __dxlog_file14,
3387
+ log10("connection closed", void 0, {
3388
+ F: __dxlog_file11,
3730
3389
  L: 269,
3731
3390
  S: this,
3732
3391
  C: (f, a) => f(...a)
@@ -3736,10 +3395,10 @@ var RtcPeerConnection = class {
3736
3395
  async onSignal(signal) {
3737
3396
  const connection = this._connection;
3738
3397
  if (!connection) {
3739
- log13.warn("a signal ignored because the connection was closed", {
3398
+ log10.warn("a signal ignored because the connection was closed", {
3740
3399
  type: signal.payload.data.type
3741
3400
  }, {
3742
- F: __dxlog_file14,
3401
+ F: __dxlog_file11,
3743
3402
  L: 277,
3744
3403
  S: this,
3745
3404
  C: (f, a) => f(...a)
@@ -3803,10 +3462,10 @@ var RtcPeerConnection = class {
3803
3462
  this._abortConnection(connection, new Error(`Unknown signal type ${data.type}.`));
3804
3463
  break;
3805
3464
  }
3806
- log13("signal processed", {
3465
+ log10("signal processed", {
3807
3466
  type: data.type
3808
3467
  }, {
3809
- F: __dxlog_file14,
3468
+ F: __dxlog_file11,
3810
3469
  L: 336,
3811
3470
  S: this,
3812
3471
  C: (f, a) => f(...a)
@@ -3816,10 +3475,10 @@ var RtcPeerConnection = class {
3816
3475
  try {
3817
3476
  await this._readyForCandidates.wait();
3818
3477
  if (connection === this._connection) {
3819
- log13("adding ice candidate", {
3478
+ log10("adding ice candidate", {
3820
3479
  candidate
3821
3480
  }, {
3822
- F: __dxlog_file14,
3481
+ F: __dxlog_file11,
3823
3482
  L: 344,
3824
3483
  S: this,
3825
3484
  C: (f, a) => f(...a)
@@ -3827,8 +3486,8 @@ var RtcPeerConnection = class {
3827
3486
  await connection.addIceCandidate(candidate);
3828
3487
  }
3829
3488
  } catch (err) {
3830
- log13.catch(err, void 0, {
3831
- F: __dxlog_file14,
3489
+ log10.catch(err, void 0, {
3490
+ F: __dxlog_file11,
3832
3491
  L: 348,
3833
3492
  S: this,
3834
3493
  C: (f, a) => f(...a)
@@ -3837,16 +3496,16 @@ var RtcPeerConnection = class {
3837
3496
  }
3838
3497
  _onSessionNegotiated(connection) {
3839
3498
  if (connection === this._connection) {
3840
- log13("ready to process ice candidates", void 0, {
3841
- F: __dxlog_file14,
3499
+ log10("ready to process ice candidates", void 0, {
3500
+ F: __dxlog_file11,
3842
3501
  L: 354,
3843
3502
  S: this,
3844
3503
  C: (f, a) => f(...a)
3845
3504
  });
3846
3505
  this._readyForCandidates.wake();
3847
3506
  } else {
3848
- log13.warn("session was negotiated after connection became inactive", void 0, {
3849
- F: __dxlog_file14,
3507
+ log10.warn("session was negotiated after connection became inactive", void 0, {
3508
+ F: __dxlog_file11,
3850
3509
  L: 357,
3851
3510
  S: this,
3852
3511
  C: (f, a) => f(...a)
@@ -3854,11 +3513,11 @@ var RtcPeerConnection = class {
3854
3513
  }
3855
3514
  }
3856
3515
  _onConnectionCallbackAfterClose(callback, connection) {
3857
- log13.warn("callback invoked after a connection was destroyed, this is probably a bug", {
3516
+ log10.warn("callback invoked after a connection was destroyed, this is probably a bug", {
3858
3517
  callback,
3859
3518
  state: connection.connectionState
3860
3519
  }, {
3861
- F: __dxlog_file14,
3520
+ F: __dxlog_file11,
3862
3521
  L: 362,
3863
3522
  S: this,
3864
3523
  C: (f, a) => f(...a)
@@ -3870,8 +3529,8 @@ var RtcPeerConnection = class {
3870
3529
  try {
3871
3530
  connection?.close();
3872
3531
  } catch (err) {
3873
- log13.catch(err, void 0, {
3874
- F: __dxlog_file14,
3532
+ log10.catch(err, void 0, {
3533
+ F: __dxlog_file11,
3875
3534
  L: 374,
3876
3535
  S: this,
3877
3536
  C: (f, a) => f(...a)
@@ -3881,8 +3540,8 @@ var RtcPeerConnection = class {
3881
3540
  this._connection = void 0;
3882
3541
  this._dataChannels.clear();
3883
3542
  this._readyForCandidates.wake();
3884
- void this._factory.onConnectionDestroyed().catch((err) => log13.catch(err, void 0, {
3885
- F: __dxlog_file14,
3543
+ void this._factory.onConnectionDestroyed().catch((err) => log10.catch(err, void 0, {
3544
+ F: __dxlog_file11,
3886
3545
  L: 380,
3887
3546
  S: this,
3888
3547
  C: (f, a) => f(...a)
@@ -3906,8 +3565,8 @@ var RtcPeerConnection = class {
3906
3565
  ];
3907
3566
  }
3908
3567
  } catch (error) {
3909
- log13.catch(error, void 0, {
3910
- F: __dxlog_file14,
3568
+ log10.catch(error, void 0, {
3569
+ F: __dxlog_file11,
3911
3570
  L: 396,
3912
3571
  S: this,
3913
3572
  C: (f, a) => f(...a)
@@ -3931,10 +3590,10 @@ var RtcPeerConnection = class {
3931
3590
  }
3932
3591
  });
3933
3592
  } catch (err) {
3934
- log13.warn("signaling error", {
3593
+ log10.warn("signaling error", {
3935
3594
  err
3936
3595
  }, {
3937
- F: __dxlog_file14,
3596
+ F: __dxlog_file11,
3938
3597
  L: 417,
3939
3598
  S: this,
3940
3599
  C: (f, a) => f(...a)
@@ -4041,13 +3700,13 @@ import { Writable } from "@dxos/node-std/stream";
4041
3700
  import { Event as Event8, scheduleTask as scheduleTask4 } from "@dxos/async";
4042
3701
  import { Resource as Resource2 } from "@dxos/context";
4043
3702
  import { ErrorStream as ErrorStream5 } from "@dxos/debug";
4044
- import { invariant as invariant13 } from "@dxos/invariant";
3703
+ import { invariant as invariant11 } from "@dxos/invariant";
4045
3704
  import { PublicKey as PublicKey10 } from "@dxos/keys";
4046
- import { log as log14 } from "@dxos/log";
3705
+ import { log as log11 } from "@dxos/log";
4047
3706
  import { ConnectionResetError as ConnectionResetError2, ConnectivityError as ConnectivityError4, TimeoutError as TimeoutError3 } from "@dxos/protocols";
4048
3707
  import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
4049
3708
  import { arrayToBuffer } from "@dxos/util";
4050
- var __dxlog_file15 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-proxy.ts";
3709
+ var __dxlog_file12 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-proxy.ts";
4051
3710
  var RPC_TIMEOUT = 1e4;
4052
3711
  var CLOSE_RPC_TIMEOUT = 3e3;
4053
3712
  var RESP_MIN_THRESHOLD = 500;
@@ -4080,8 +3739,8 @@ var RtcTransportProxy = class extends Resource2 {
4080
3739
  this._serviceStream = stream;
4081
3740
  stream.waitUntilReady().then(() => {
4082
3741
  stream.subscribe(async (event) => {
4083
- log14("rtc transport proxy event", event, {
4084
- F: __dxlog_file15,
3742
+ log11("rtc transport proxy event", event, {
3743
+ F: __dxlog_file12,
4085
3744
  L: 66,
4086
3745
  S: this,
4087
3746
  C: (f, a) => f(...a)
@@ -4094,10 +3753,10 @@ var RtcTransportProxy = class extends Resource2 {
4094
3753
  await this._handleSignal(event.signal);
4095
3754
  }
4096
3755
  }, (err) => {
4097
- log14("rtc bridge stream closed", {
3756
+ log11("rtc bridge stream closed", {
4098
3757
  err
4099
3758
  }, {
4100
- F: __dxlog_file15,
3759
+ F: __dxlog_file12,
4101
3760
  L: 76,
4102
3761
  S: this,
4103
3762
  C: (f, a) => f(...a)
@@ -4118,8 +3777,8 @@ var RtcTransportProxy = class extends Resource2 {
4118
3777
  timeout: RPC_TIMEOUT
4119
3778
  }).then(() => {
4120
3779
  if (Date.now() - sendStartMs > RESP_MIN_THRESHOLD) {
4121
- log14("slow response, delaying callback", void 0, {
4122
- F: __dxlog_file15,
3780
+ log11("slow response, delaying callback", void 0, {
3781
+ F: __dxlog_file12,
4123
3782
  L: 93,
4124
3783
  S: this,
4125
3784
  C: (f, a) => f(...a)
@@ -4151,8 +3810,8 @@ var RtcTransportProxy = class extends Resource2 {
4151
3810
  await this._serviceStream?.close();
4152
3811
  this._serviceStream = void 0;
4153
3812
  } catch (err) {
4154
- log14.catch(err, void 0, {
4155
- F: __dxlog_file15,
3813
+ log11.catch(err, void 0, {
3814
+ F: __dxlog_file12,
4156
3815
  L: 128,
4157
3816
  S: this,
4158
3817
  C: (f, a) => f(...a)
@@ -4165,8 +3824,8 @@ var RtcTransportProxy = class extends Resource2 {
4165
3824
  timeout: CLOSE_RPC_TIMEOUT
4166
3825
  });
4167
3826
  } catch (err) {
4168
- log14.catch(err, void 0, {
4169
- F: __dxlog_file15,
3827
+ log11.catch(err, void 0, {
3828
+ F: __dxlog_file12,
4170
3829
  L: 134,
4171
3830
  S: this,
4172
3831
  C: (f, a) => f(...a)
@@ -4251,10 +3910,10 @@ var RtcTransportProxy = class extends Resource2 {
4251
3910
  if (this.isOpen) {
4252
3911
  this.errors.raise(error);
4253
3912
  } else {
4254
- log14.info("error swallowed because transport was closed", {
3913
+ log11.info("error swallowed because transport was closed", {
4255
3914
  message: error.message
4256
3915
  }, {
4257
- F: __dxlog_file15,
3916
+ F: __dxlog_file12,
4258
3917
  L: 217,
4259
3918
  S: this,
4260
3919
  C: (f, a) => f(...a)
@@ -4284,8 +3943,8 @@ var RtcTransportProxyFactory = class {
4284
3943
  return this;
4285
3944
  }
4286
3945
  createTransport(options) {
4287
- invariant13(this._bridgeService, "RtcTransportProxyFactory is not ready to open connections", {
4288
- F: __dxlog_file15,
3946
+ invariant11(this._bridgeService, "RtcTransportProxyFactory is not ready to open connections", {
3947
+ F: __dxlog_file12,
4289
3948
  L: 247,
4290
3949
  S: this,
4291
3950
  A: [
@@ -4326,12 +3985,12 @@ var decodeError = (err) => {
4326
3985
  // src/transport/webrtc/rtc-transport-service.ts
4327
3986
  import { Duplex as Duplex2 } from "@dxos/node-std/stream";
4328
3987
  import { Stream } from "@dxos/codec-protobuf/stream";
4329
- import { invariant as invariant14 } from "@dxos/invariant";
3988
+ import { invariant as invariant12 } from "@dxos/invariant";
4330
3989
  import { PublicKey as PublicKey11 } from "@dxos/keys";
4331
- import { log as log15 } from "@dxos/log";
3990
+ import { log as log12 } from "@dxos/log";
4332
3991
  import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
4333
3992
  import { ComplexMap as ComplexMap8 } from "@dxos/util";
4334
- var __dxlog_file16 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-service.ts";
3993
+ var __dxlog_file13 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-service.ts";
4335
3994
  var RtcTransportService = class {
4336
3995
  _transportFactory;
4337
3996
  _openTransports = new ComplexMap8(PublicKey11.hash);
@@ -4344,8 +4003,8 @@ var RtcTransportService = class {
4344
4003
  open(request) {
4345
4004
  const existingTransport = this._openTransports.get(request.proxyId);
4346
4005
  if (existingTransport) {
4347
- log15.error("requesting a new transport bridge for an existing proxy", void 0, {
4348
- F: __dxlog_file16,
4006
+ log12.error("requesting a new transport bridge for an existing proxy", void 0, {
4007
+ F: __dxlog_file13,
4349
4008
  L: 54,
4350
4009
  S: this,
4351
4010
  C: (f, a) => f(...a)
@@ -4410,8 +4069,8 @@ var RtcTransportService = class {
4410
4069
  close(err);
4411
4070
  });
4412
4071
  ready();
4413
- log15("stream ready", void 0, {
4414
- F: __dxlog_file16,
4072
+ log12("stream ready", void 0, {
4073
+ F: __dxlog_file13,
4415
4074
  L: 116,
4416
4075
  S: this,
4417
4076
  C: (f, a) => f(...a)
@@ -4421,8 +4080,8 @@ var RtcTransportService = class {
4421
4080
  }
4422
4081
  async sendSignal({ proxyId, signal }) {
4423
4082
  const transport = this._openTransports.get(proxyId);
4424
- invariant14(transport, void 0, {
4425
- F: __dxlog_file16,
4083
+ invariant12(transport, void 0, {
4084
+ F: __dxlog_file13,
4426
4085
  L: 124,
4427
4086
  S: this,
4428
4087
  A: [
@@ -4434,8 +4093,8 @@ var RtcTransportService = class {
4434
4093
  }
4435
4094
  async getDetails({ proxyId }) {
4436
4095
  const transport = this._openTransports.get(proxyId);
4437
- invariant14(transport, void 0, {
4438
- F: __dxlog_file16,
4096
+ invariant12(transport, void 0, {
4097
+ F: __dxlog_file13,
4439
4098
  L: 131,
4440
4099
  S: this,
4441
4100
  A: [
@@ -4449,8 +4108,8 @@ var RtcTransportService = class {
4449
4108
  }
4450
4109
  async getStats({ proxyId }) {
4451
4110
  const transport = this._openTransports.get(proxyId);
4452
- invariant14(transport, void 0, {
4453
- F: __dxlog_file16,
4111
+ invariant12(transport, void 0, {
4112
+ F: __dxlog_file13,
4454
4113
  L: 138,
4455
4114
  S: this,
4456
4115
  A: [
@@ -4464,8 +4123,8 @@ var RtcTransportService = class {
4464
4123
  }
4465
4124
  async sendData({ proxyId, payload }) {
4466
4125
  const transport = this._openTransports.get(proxyId);
4467
- invariant14(transport, void 0, {
4468
- F: __dxlog_file16,
4126
+ invariant12(transport, void 0, {
4127
+ F: __dxlog_file13,
4469
4128
  L: 145,
4470
4129
  S: this,
4471
4130
  A: [
@@ -4496,10 +4155,10 @@ var RtcTransportService = class {
4496
4155
  try {
4497
4156
  await transport.transport.close();
4498
4157
  } catch (error) {
4499
- log15.warn("transport close error", {
4158
+ log12.warn("transport close error", {
4500
4159
  message: error?.message
4501
4160
  }, {
4502
- F: __dxlog_file16,
4161
+ F: __dxlog_file13,
4503
4162
  L: 175,
4504
4163
  S: this,
4505
4164
  C: (f, a) => f(...a)
@@ -4508,17 +4167,17 @@ var RtcTransportService = class {
4508
4167
  try {
4509
4168
  transport.connectorStream.end();
4510
4169
  } catch (error) {
4511
- log15.warn("connectorStream close error", {
4170
+ log12.warn("connectorStream close error", {
4512
4171
  message: error?.message
4513
4172
  }, {
4514
- F: __dxlog_file16,
4173
+ F: __dxlog_file13,
4515
4174
  L: 180,
4516
4175
  S: this,
4517
4176
  C: (f, a) => f(...a)
4518
4177
  });
4519
4178
  }
4520
- log15("closed", void 0, {
4521
- F: __dxlog_file16,
4179
+ log12("closed", void 0, {
4180
+ F: __dxlog_file13,
4522
4181
  L: 182,
4523
4182
  S: this,
4524
4183
  C: (f, a) => f(...a)
@@ -4540,10 +4199,10 @@ var createStateUpdater = (next) => {
4540
4199
 
4541
4200
  // src/wire-protocol.ts
4542
4201
  import { Teleport } from "@dxos/teleport";
4543
- var createTeleportProtocolFactory = (onConnection, defaultParams) => {
4202
+ var createTeleportProtocolFactory = (onConnection, defaultProps) => {
4544
4203
  return (params) => {
4545
4204
  const teleport = new Teleport({
4546
- ...defaultParams,
4205
+ ...defaultProps,
4547
4206
  ...params
4548
4207
  });
4549
4208
  return {
@@ -4565,7 +4224,6 @@ var createTeleportProtocolFactory = (onConnection, defaultParams) => {
4565
4224
  export {
4566
4225
  ConnectionState,
4567
4226
  Connection,
4568
- createIceProvider,
4569
4227
  SwarmMessenger,
4570
4228
  Swarm,
4571
4229
  SwarmMapper,
@@ -4575,8 +4233,6 @@ export {
4575
4233
  ConnectionLog,
4576
4234
  SwarmNetworkManager,
4577
4235
  FullyConnectedTopology,
4578
- MMSTTopology,
4579
- StarTopology,
4580
4236
  MemoryTransportFactory,
4581
4237
  MemoryTransport,
4582
4238
  TransportKind,
@@ -4586,4 +4242,4 @@ export {
4586
4242
  RtcTransportService,
4587
4243
  createTeleportProtocolFactory
4588
4244
  };
4589
- //# sourceMappingURL=chunk-5ISEIDVN.mjs.map
4245
+ //# sourceMappingURL=chunk-AQSYW43M.mjs.map