@dxos/network-manager 0.8.4-main.70d3990 → 0.8.4-main.74a063c4e0

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 (81) hide show
  1. package/dist/lib/browser/{chunk-5ISEIDVN.mjs → chunk-Y2FDDNGM.mjs} +479 -828
  2. package/dist/lib/browser/chunk-Y2FDDNGM.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 +14 -4
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/browser/transport/tcp/index.mjs +2 -33
  9. package/dist/lib/browser/transport/tcp/index.mjs.map +4 -4
  10. package/dist/lib/browser/transport/tcp/tcp-transport.browser.mjs +36 -0
  11. package/dist/lib/browser/transport/tcp/tcp-transport.browser.mjs.map +7 -0
  12. package/dist/lib/browser/transport/tcp/tcp-transport.mjs +160 -0
  13. package/dist/lib/browser/transport/tcp/tcp-transport.mjs.map +7 -0
  14. package/dist/lib/node-esm/{chunk-S7AVXKL7.mjs → chunk-OU3FYVBA.mjs} +479 -828
  15. package/dist/lib/node-esm/chunk-OU3FYVBA.mjs.map +7 -0
  16. package/dist/lib/node-esm/index.mjs +342 -4
  17. package/dist/lib/node-esm/index.mjs.map +4 -4
  18. package/dist/lib/node-esm/meta.json +1 -1
  19. package/dist/lib/node-esm/testing/index.mjs +14 -4
  20. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  21. package/dist/lib/node-esm/transport/tcp/index.mjs +2 -157
  22. package/dist/lib/node-esm/transport/tcp/index.mjs.map +4 -4
  23. package/dist/lib/node-esm/transport/tcp/tcp-transport.browser.mjs +36 -0
  24. package/dist/lib/node-esm/transport/tcp/tcp-transport.browser.mjs.map +7 -0
  25. package/dist/lib/node-esm/transport/tcp/tcp-transport.mjs +160 -0
  26. package/dist/lib/node-esm/transport/tcp/tcp-transport.mjs.map +7 -0
  27. package/dist/types/src/network-manager.d.ts +5 -4
  28. package/dist/types/src/network-manager.d.ts.map +1 -1
  29. package/dist/types/src/signal/signal-connection.d.ts +3 -2
  30. package/dist/types/src/signal/signal-connection.d.ts.map +1 -1
  31. package/dist/types/src/signal/signal-messenger.d.ts +3 -2
  32. package/dist/types/src/signal/signal-messenger.d.ts.map +1 -1
  33. package/dist/types/src/signal/swarm-messenger.d.ts +7 -7
  34. package/dist/types/src/signal/swarm-messenger.d.ts.map +1 -1
  35. package/dist/types/src/swarm/connection.d.ts +2 -1
  36. package/dist/types/src/swarm/connection.d.ts.map +1 -1
  37. package/dist/types/src/swarm/peer.d.ts +4 -3
  38. package/dist/types/src/swarm/peer.d.ts.map +1 -1
  39. package/dist/types/src/swarm/swarm.d.ts +3 -2
  40. package/dist/types/src/swarm/swarm.d.ts.map +1 -1
  41. package/dist/types/src/testing/test-builder.d.ts.map +1 -1
  42. package/dist/types/src/tests/basic-test-suite.d.ts.map +1 -1
  43. package/dist/types/src/tests/property-test-suite.d.ts.map +1 -1
  44. package/dist/types/src/transport/tcp/index.d.ts +1 -1
  45. package/dist/types/src/transport/tcp/index.d.ts.map +1 -1
  46. package/dist/types/src/transport/webrtc/rtc-peer-connection.d.ts.map +1 -1
  47. package/dist/types/src/transport/webrtc/rtc-transport-channel.d.ts.map +1 -1
  48. package/dist/types/src/transport/webrtc/rtc-transport-factory.d.ts.map +1 -1
  49. package/dist/types/src/transport/webrtc/rtc-transport-service.d.ts.map +1 -1
  50. package/dist/types/src/wire-protocol.d.ts +5 -5
  51. package/dist/types/src/wire-protocol.d.ts.map +1 -1
  52. package/dist/types/tsconfig.tsbuildinfo +1 -1
  53. package/package.json +32 -22
  54. package/src/network-manager.ts +19 -15
  55. package/src/signal/integration.node.test.ts +11 -10
  56. package/src/signal/signal-connection.ts +3 -2
  57. package/src/signal/signal-messenger.ts +3 -2
  58. package/src/signal/swarm-messenger.node.test.ts +25 -24
  59. package/src/signal/swarm-messenger.ts +65 -55
  60. package/src/swarm/connection.test.ts +6 -7
  61. package/src/swarm/connection.ts +5 -5
  62. package/src/swarm/peer.ts +6 -6
  63. package/src/swarm/swarm.test.ts +2 -3
  64. package/src/swarm/swarm.ts +9 -10
  65. package/src/testing/test-builder.ts +4 -4
  66. package/src/tests/basic-test-suite.ts +0 -1
  67. package/src/tests/memory-transport.test.ts +0 -2
  68. package/src/tests/property-test-suite.ts +4 -3
  69. package/src/tests/tcp-transport.node.test.ts +0 -2
  70. package/src/tests/webrtc-transport.test.ts +0 -1
  71. package/src/transport/tcp/index.ts +1 -1
  72. package/src/transport/webrtc/rtc-peer-connection.ts +0 -1
  73. package/src/transport/webrtc/rtc-transport-channel.test.ts +0 -2
  74. package/src/transport/webrtc/rtc-transport-channel.ts +0 -1
  75. package/src/transport/webrtc/rtc-transport-factory.ts +0 -1
  76. package/src/transport/webrtc/rtc-transport-proxy.test.ts +0 -2
  77. package/src/transport/webrtc/rtc-transport-service.ts +0 -1
  78. package/src/transport/webrtc/rtc-transport.test.ts +0 -1
  79. package/src/wire-protocol.ts +6 -6
  80. package/dist/lib/browser/chunk-5ISEIDVN.mjs.map +0 -7
  81. package/dist/lib/node-esm/chunk-S7AVXKL7.mjs.map +0 -7
@@ -60,7 +60,7 @@ var Connection = class {
60
60
  _instanceId = PublicKey.random().toHex();
61
61
  transportStats = new Event();
62
62
  _signalSendTask = new DeferredTask(this._ctx, async () => {
63
- await this._flushSignalBuffer();
63
+ await this._flushSignalBuffer(this._ctx);
64
64
  });
65
65
  _signallingDelay = STARTING_SIGNALLING_DELAY;
66
66
  constructor(topic, localInfo, remoteInfo, sessionId, initiator, _signalMessaging, _protocol, _transportFactory, _callbacks) {
@@ -433,20 +433,20 @@ var Connection = class {
433
433
  this._outgoingSignalBuffer.push(signal);
434
434
  this._signalSendTask.schedule();
435
435
  }
436
- async _flushSignalBuffer() {
436
+ async _flushSignalBuffer(ctx) {
437
437
  if (this._outgoingSignalBuffer.length === 0) {
438
438
  return;
439
439
  }
440
440
  try {
441
441
  if (true) {
442
- await cancelWithContext(this._ctx, sleep(this._signallingDelay));
442
+ await cancelWithContext(ctx, sleep(this._signallingDelay));
443
443
  this._signallingDelay = Math.min(this._signallingDelay * 2, MAX_SIGNALLING_DELAY);
444
444
  }
445
445
  const signals = [
446
446
  ...this._outgoingSignalBuffer
447
447
  ];
448
448
  this._outgoingSignalBuffer.length = 0;
449
- await this._signalMessaging.signal({
449
+ await this._signalMessaging.signal(ctx, {
450
450
  author: this.localInfo,
451
451
  recipient: this.remoteInfo,
452
452
  sessionId: this.sessionId,
@@ -480,7 +480,7 @@ var Connection = class {
480
480
  /**
481
481
  * Receive a signal from the remote peer.
482
482
  */
483
- async signal(msg) {
483
+ async signal(_ctx, msg) {
484
484
  invariant(msg.sessionId, void 0, {
485
485
  F: __dxlog_file,
486
486
  L: 410,
@@ -615,54 +615,16 @@ _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
- import { Context as Context2 } from "@dxos/context";
653
619
  import { invariant as invariant2 } from "@dxos/invariant";
654
620
  import { PublicKey as PublicKey2 } from "@dxos/keys";
655
- import { log as log3 } from "@dxos/log";
621
+ import { log as log2 } from "@dxos/log";
656
622
  import { TimeoutError as TimeoutError2 } from "@dxos/protocols";
657
623
  import { schema } from "@dxos/protocols/proto";
658
624
  import { ComplexMap } from "@dxos/util";
659
- var __dxlog_file3 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
625
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
660
626
  var SwarmMessage = schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
661
627
  var SwarmMessenger = class {
662
- _ctx = new Context2(void 0, {
663
- F: __dxlog_file3,
664
- L: 35
665
- });
666
628
  _sendMessage;
667
629
  _onSignal;
668
630
  _onOffer;
@@ -674,7 +636,7 @@ var SwarmMessenger = class {
674
636
  this._onOffer = onOffer;
675
637
  this._topic = topic;
676
638
  }
677
- async receiveMessage({ author, recipient, payload }) {
639
+ async receiveMessage(ctx, { author, recipient, payload }) {
678
640
  if (payload.type_url !== "dxos.mesh.swarm.SwarmMessage") {
679
641
  return;
680
642
  }
@@ -682,18 +644,18 @@ var SwarmMessenger = class {
682
644
  if (!this._topic.equals(message.topic)) {
683
645
  return;
684
646
  }
685
- log3("received", {
647
+ log2("received", {
686
648
  from: author,
687
649
  to: recipient,
688
650
  msg: message
689
651
  }, {
690
- F: __dxlog_file3,
691
- L: 71,
652
+ F: __dxlog_file2,
653
+ L: 72,
692
654
  S: this,
693
655
  C: (f, a) => f(...a)
694
656
  });
695
657
  if (message.data?.offer) {
696
- await this._handleOffer({
658
+ await this._handleOffer(ctx, {
697
659
  author,
698
660
  recipient,
699
661
  message
@@ -701,45 +663,45 @@ var SwarmMessenger = class {
701
663
  } else if (message.data?.answer) {
702
664
  await this._resolveAnswers(message);
703
665
  } else if (message.data?.signal) {
704
- await this._handleSignal({
666
+ await this._handleSignal(ctx, {
705
667
  author,
706
668
  recipient,
707
669
  message
708
670
  });
709
671
  } else if (message.data?.signalBatch) {
710
- await this._handleSignal({
672
+ await this._handleSignal(ctx, {
711
673
  author,
712
674
  recipient,
713
675
  message
714
676
  });
715
677
  } else {
716
- log3.warn("unknown message", {
678
+ log2.warn("unknown message", {
717
679
  message
718
680
  }, {
719
- F: __dxlog_file3,
720
- L: 82,
681
+ F: __dxlog_file2,
682
+ L: 83,
721
683
  S: this,
722
684
  C: (f, a) => f(...a)
723
685
  });
724
686
  }
725
687
  }
726
- async signal(message) {
688
+ async signal(ctx, message) {
727
689
  invariant2(message.data?.signal || message.data?.signalBatch, "Invalid message", {
728
- F: __dxlog_file3,
729
- L: 87,
690
+ F: __dxlog_file2,
691
+ L: 88,
730
692
  S: this,
731
693
  A: [
732
694
  "message.data?.signal || message.data?.signalBatch",
733
695
  "'Invalid message'"
734
696
  ]
735
697
  });
736
- await this._sendReliableMessage({
698
+ await this._sendReliableMessage(ctx, {
737
699
  author: message.author,
738
700
  recipient: message.recipient,
739
701
  message
740
702
  });
741
703
  }
742
- async offer(message) {
704
+ async offer(ctx, message) {
743
705
  const networkMessage = {
744
706
  ...message,
745
707
  messageId: PublicKey2.random()
@@ -748,30 +710,30 @@ var SwarmMessenger = class {
748
710
  this._offerRecords.set(networkMessage.messageId, {
749
711
  resolve
750
712
  });
751
- this._sendReliableMessage({
713
+ this._sendReliableMessage(ctx, {
752
714
  author: message.author,
753
715
  recipient: message.recipient,
754
716
  message: networkMessage
755
717
  }).catch((err) => reject(err));
756
718
  });
757
719
  }
758
- async _sendReliableMessage({ author, recipient, message }) {
720
+ async _sendReliableMessage(ctx, { author, recipient, message }) {
759
721
  const networkMessage = {
760
722
  ...message,
761
723
  // Setting unique message_id if it not specified yet.
762
724
  messageId: message.messageId ?? PublicKey2.random()
763
725
  };
764
- log3("sending", {
726
+ log2("sending", {
765
727
  from: author,
766
728
  to: recipient,
767
729
  msg: networkMessage
768
730
  }, {
769
- F: __dxlog_file3,
770
- L: 125,
731
+ F: __dxlog_file2,
732
+ L: 129,
771
733
  S: this,
772
734
  C: (f, a) => f(...a)
773
735
  });
774
- await this._sendMessage({
736
+ await this._sendMessage(ctx, {
775
737
  author,
776
738
  recipient,
777
739
  payload: {
@@ -782,8 +744,8 @@ var SwarmMessenger = class {
782
744
  }
783
745
  async _resolveAnswers(message) {
784
746
  invariant2(message.data?.answer?.offerMessageId, "No offerMessageId", {
785
- F: __dxlog_file3,
786
- L: 137,
747
+ F: __dxlog_file2,
748
+ L: 141,
787
749
  S: this,
788
750
  A: [
789
751
  "message.data?.answer?.offerMessageId",
@@ -794,29 +756,29 @@ var SwarmMessenger = class {
794
756
  if (offerRecord) {
795
757
  this._offerRecords.delete(message.data.answer.offerMessageId);
796
758
  invariant2(message.data?.answer, "No answer", {
797
- F: __dxlog_file3,
798
- L: 141,
759
+ F: __dxlog_file2,
760
+ L: 145,
799
761
  S: this,
800
762
  A: [
801
763
  "message.data?.answer",
802
764
  "'No answer'"
803
765
  ]
804
766
  });
805
- log3("resolving", {
767
+ log2("resolving", {
806
768
  answer: message.data.answer
807
769
  }, {
808
- F: __dxlog_file3,
809
- L: 142,
770
+ F: __dxlog_file2,
771
+ L: 146,
810
772
  S: this,
811
773
  C: (f, a) => f(...a)
812
774
  });
813
775
  offerRecord.resolve(message.data.answer);
814
776
  }
815
777
  }
816
- async _handleOffer({ author, recipient, message }) {
778
+ async _handleOffer(ctx, { author, recipient, message }) {
817
779
  invariant2(message.data.offer, "No offer", {
818
- F: __dxlog_file3,
819
- L: 156,
780
+ F: __dxlog_file2,
781
+ L: 163,
820
782
  S: this,
821
783
  A: [
822
784
  "message.data.offer",
@@ -831,10 +793,10 @@ var SwarmMessenger = class {
831
793
  offer: message.data.offer
832
794
  }
833
795
  };
834
- const answer = await this._onOffer(offerMessage);
796
+ const answer = await this._onOffer(ctx, offerMessage);
835
797
  answer.offerMessageId = message.messageId;
836
798
  try {
837
- await this._sendReliableMessage({
799
+ await this._sendReliableMessage(ctx, {
838
800
  author: recipient,
839
801
  recipient: author,
840
802
  message: {
@@ -847,30 +809,30 @@ var SwarmMessenger = class {
847
809
  });
848
810
  } catch (err) {
849
811
  if (err instanceof TimeoutError2) {
850
- log3.info("timeout sending answer to offer", {
812
+ log2.info("timeout sending answer to offer", {
851
813
  err
852
814
  }, {
853
- F: __dxlog_file3,
854
- L: 177,
815
+ F: __dxlog_file2,
816
+ L: 184,
855
817
  S: this,
856
818
  C: (f, a) => f(...a)
857
819
  });
858
820
  } else {
859
- log3.info("error sending answer to offer", {
821
+ log2.info("error sending answer to offer", {
860
822
  err
861
823
  }, {
862
- F: __dxlog_file3,
863
- L: 179,
824
+ F: __dxlog_file2,
825
+ L: 186,
864
826
  S: this,
865
827
  C: (f, a) => f(...a)
866
828
  });
867
829
  }
868
830
  }
869
831
  }
870
- async _handleSignal({ author, recipient, message }) {
832
+ async _handleSignal(ctx, { author, recipient, message }) {
871
833
  invariant2(message.messageId, void 0, {
872
- F: __dxlog_file3,
873
- L: 193,
834
+ F: __dxlog_file2,
835
+ L: 203,
874
836
  S: this,
875
837
  A: [
876
838
  "message.messageId",
@@ -878,8 +840,8 @@ var SwarmMessenger = class {
878
840
  ]
879
841
  });
880
842
  invariant2(message.data.signal || message.data.signalBatch, "Invalid message", {
881
- F: __dxlog_file3,
882
- L: 194,
843
+ F: __dxlog_file2,
844
+ L: 204,
883
845
  S: this,
884
846
  A: [
885
847
  "message.data.signal || message.data.signalBatch",
@@ -895,27 +857,27 @@ var SwarmMessenger = class {
895
857
  signalBatch: message.data.signalBatch
896
858
  }
897
859
  };
898
- await this._onSignal(signalMessage);
860
+ await this._onSignal(ctx, signalMessage);
899
861
  }
900
862
  };
901
863
 
902
864
  // src/swarm/swarm.ts
903
865
  import { Event as Event3, scheduleTask as scheduleTask3, sleep as sleep2, synchronized as synchronized3 } from "@dxos/async";
904
- import { Context as Context4 } from "@dxos/context";
866
+ import { Context as Context3 } from "@dxos/context";
905
867
  import { ErrorStream as ErrorStream2 } from "@dxos/debug";
906
868
  import { invariant as invariant4 } from "@dxos/invariant";
907
869
  import { PublicKey as PublicKey4 } from "@dxos/keys";
908
- import { log as log5, logInfo as logInfo2 } from "@dxos/log";
870
+ import { log as log4, logInfo as logInfo2 } from "@dxos/log";
909
871
  import { PeerInfoHash } from "@dxos/messaging";
910
872
  import { trace as trace2 } from "@dxos/protocols";
911
- import { ComplexMap as ComplexMap2, isNonNullable as isNonNullable2 } from "@dxos/util";
873
+ import { ComplexMap as ComplexMap2, isNonNullable } from "@dxos/util";
912
874
 
913
875
  // src/swarm/peer.ts
914
876
  import { Event as Event2, scheduleTask as scheduleTask2, synchronized as synchronized2 } from "@dxos/async";
915
- import { Context as Context3 } from "@dxos/context";
877
+ import { Context as Context2 } from "@dxos/context";
916
878
  import { invariant as invariant3 } from "@dxos/invariant";
917
879
  import { PublicKey as PublicKey3 } from "@dxos/keys";
918
- import { log as log4 } from "@dxos/log";
880
+ import { log as log3 } from "@dxos/log";
919
881
  import { CancelledError as CancelledError2, SystemError } from "@dxos/protocols";
920
882
  function _ts_decorate2(decorators, target, key, desc) {
921
883
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -923,7 +885,7 @@ function _ts_decorate2(decorators, target, key, desc) {
923
885
  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
886
  return c > 3 && r && Object.defineProperty(target, key, r), r;
925
887
  }
926
- var __dxlog_file4 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
888
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
927
889
  var ConnectionDisplacedError = class extends SystemError {
928
890
  constructor() {
929
891
  super({
@@ -947,9 +909,9 @@ var Peer = class {
947
909
  _availableAfter = 0;
948
910
  availableToConnect = true;
949
911
  _lastConnectionTime;
950
- _ctx = new Context3(void 0, {
951
- F: __dxlog_file4,
952
- L: 81
912
+ _ctx = new Context2(void 0, {
913
+ F: __dxlog_file3,
914
+ L: 80
953
915
  });
954
916
  _connectionCtx;
955
917
  connection;
@@ -972,16 +934,16 @@ var Peer = class {
972
934
  /**
973
935
  * Respond to remote offer.
974
936
  */
975
- async onOffer(message) {
937
+ async onOffer(_ctx, message) {
976
938
  const remote = message.author;
977
939
  if (this.connection && ![
978
940
  ConnectionState.CREATED,
979
941
  ConnectionState.INITIAL,
980
942
  ConnectionState.CONNECTING
981
943
  ].includes(this.connection.state)) {
982
- log4.info(`received offer when connection already in ${this.connection.state} state`, void 0, {
983
- F: __dxlog_file4,
984
- L: 116,
944
+ log3.info(`received offer when connection already in ${this.connection.state} state`, void 0, {
945
+ F: __dxlog_file3,
946
+ L: 115,
985
947
  S: this,
986
948
  C: (f, a) => f(...a)
987
949
  });
@@ -991,14 +953,14 @@ var Peer = class {
991
953
  }
992
954
  if (this.connection || this.initiating) {
993
955
  if (remote.peerKey < this.localInfo.peerKey) {
994
- log4("close local connection", {
956
+ log3("close local connection", {
995
957
  localPeer: this.localInfo,
996
958
  topic: this.topic,
997
959
  remotePeer: this.remoteInfo,
998
960
  sessionId: this.connection?.sessionId
999
961
  }, {
1000
- F: __dxlog_file4,
1001
- L: 125,
962
+ F: __dxlog_file3,
963
+ L: 124,
1002
964
  S: this,
1003
965
  C: (f, a) => f(...a)
1004
966
  });
@@ -1014,8 +976,8 @@ var Peer = class {
1014
976
  if (await this._callbacks.onOffer(remote)) {
1015
977
  if (!this.connection) {
1016
978
  invariant3(message.sessionId, void 0, {
1017
- F: __dxlog_file4,
1018
- L: 145,
979
+ F: __dxlog_file3,
980
+ L: 144,
1019
981
  S: this,
1020
982
  A: [
1021
983
  "message.sessionId",
@@ -1029,14 +991,14 @@ var Peer = class {
1029
991
  await connection.openConnection();
1030
992
  } catch (err) {
1031
993
  if (!(err instanceof CancelledError2)) {
1032
- log4.info("connection error", {
994
+ log3.info("connection error", {
1033
995
  topic: this.topic,
1034
996
  peerId: this.localInfo,
1035
997
  remoteId: this.remoteInfo,
1036
998
  err
1037
999
  }, {
1038
- F: __dxlog_file4,
1039
- L: 155,
1000
+ F: __dxlog_file3,
1001
+ L: 154,
1040
1002
  S: this,
1041
1003
  C: (f, a) => f(...a)
1042
1004
  });
@@ -1055,9 +1017,9 @@ var Peer = class {
1055
1017
  /**
1056
1018
  * Initiate a connection to the remote peer.
1057
1019
  */
1058
- async initiateConnection() {
1020
+ async initiateConnection(ctx) {
1059
1021
  invariant3(!this.initiating, "Initiation in progress.", {
1060
- F: __dxlog_file4,
1022
+ F: __dxlog_file3,
1061
1023
  L: 172,
1062
1024
  S: this,
1063
1025
  A: [
@@ -1066,7 +1028,7 @@ var Peer = class {
1066
1028
  ]
1067
1029
  });
1068
1030
  invariant3(!this.connection, "Already connected.", {
1069
- F: __dxlog_file4,
1031
+ F: __dxlog_file3,
1070
1032
  L: 173,
1071
1033
  S: this,
1072
1034
  A: [
@@ -1075,13 +1037,13 @@ var Peer = class {
1075
1037
  ]
1076
1038
  });
1077
1039
  const sessionId = PublicKey3.random();
1078
- log4("initiating...", {
1040
+ log3("initiating...", {
1079
1041
  local: this.localInfo,
1080
1042
  topic: this.topic,
1081
1043
  remote: this.remoteInfo,
1082
1044
  sessionId
1083
1045
  }, {
1084
- F: __dxlog_file4,
1046
+ F: __dxlog_file3,
1085
1047
  L: 175,
1086
1048
  S: this,
1087
1049
  C: (f, a) => f(...a)
@@ -1092,7 +1054,7 @@ var Peer = class {
1092
1054
  try {
1093
1055
  await this._connectionLimiter.connecting(sessionId);
1094
1056
  connection.initiate();
1095
- answer = await this._signalMessaging.offer({
1057
+ answer = await this._signalMessaging.offer(ctx, {
1096
1058
  author: this.localInfo,
1097
1059
  recipient: this.remoteInfo,
1098
1060
  sessionId,
@@ -1101,20 +1063,20 @@ var Peer = class {
1101
1063
  offer: {}
1102
1064
  }
1103
1065
  });
1104
- log4("received", {
1066
+ log3("received", {
1105
1067
  answer,
1106
1068
  topic: this.topic,
1107
1069
  local: this.localInfo,
1108
1070
  remote: this.remoteInfo
1109
1071
  }, {
1110
- F: __dxlog_file4,
1072
+ F: __dxlog_file3,
1111
1073
  L: 192,
1112
1074
  S: this,
1113
1075
  C: (f, a) => f(...a)
1114
1076
  });
1115
1077
  if (connection.state !== ConnectionState.INITIAL) {
1116
- log4("ignoring response", void 0, {
1117
- F: __dxlog_file4,
1078
+ log3("ignoring response", void 0, {
1079
+ F: __dxlog_file3,
1118
1080
  L: 194,
1119
1081
  S: this,
1120
1082
  C: (f, a) => f(...a)
@@ -1122,13 +1084,13 @@ var Peer = class {
1122
1084
  return;
1123
1085
  }
1124
1086
  } catch (err) {
1125
- log4("initiation error: send offer", {
1087
+ log3("initiation error: send offer", {
1126
1088
  err,
1127
1089
  topic: this.topic,
1128
1090
  local: this.localInfo,
1129
1091
  remote: this.remoteInfo
1130
1092
  }, {
1131
- F: __dxlog_file4,
1093
+ F: __dxlog_file3,
1132
1094
  L: 198,
1133
1095
  S: this,
1134
1096
  C: (f, a) => f(...a)
@@ -1144,13 +1106,13 @@ var Peer = class {
1144
1106
  return;
1145
1107
  }
1146
1108
  } catch (err) {
1147
- log4("initiation error: accept answer", {
1109
+ log3("initiation error: accept answer", {
1148
1110
  err,
1149
1111
  topic: this.topic,
1150
1112
  local: this.localInfo,
1151
1113
  remote: this.remoteInfo
1152
1114
  }, {
1153
- F: __dxlog_file4,
1115
+ F: __dxlog_file3,
1154
1116
  L: 211,
1155
1117
  S: this,
1156
1118
  C: (f, a) => f(...a)
@@ -1161,8 +1123,8 @@ var Peer = class {
1161
1123
  this.initiating = false;
1162
1124
  }
1163
1125
  try {
1164
- log4("opening connection as initiator", void 0, {
1165
- F: __dxlog_file4,
1126
+ log3("opening connection as initiator", void 0, {
1127
+ F: __dxlog_file3,
1166
1128
  L: 224,
1167
1129
  S: this,
1168
1130
  C: (f, a) => f(...a)
@@ -1170,21 +1132,21 @@ var Peer = class {
1170
1132
  await connection.openConnection();
1171
1133
  this._callbacks.onAccepted();
1172
1134
  } catch (err) {
1173
- log4("initiation error: open connection", {
1135
+ log3("initiation error: open connection", {
1174
1136
  err,
1175
1137
  topic: this.topic,
1176
1138
  local: this.localInfo,
1177
1139
  remote: this.remoteInfo
1178
1140
  }, {
1179
- F: __dxlog_file4,
1141
+ F: __dxlog_file3,
1180
1142
  L: 228,
1181
1143
  S: this,
1182
1144
  C: (f, a) => f(...a)
1183
1145
  });
1184
- log4.warn("closing connection due to unhandled error on openConnection", {
1146
+ log3.warn("closing connection due to unhandled error on openConnection", {
1185
1147
  err
1186
1148
  }, {
1187
- F: __dxlog_file4,
1149
+ F: __dxlog_file3,
1188
1150
  L: 235,
1189
1151
  S: this,
1190
1152
  C: (f, a) => f(...a)
@@ -1200,20 +1162,20 @@ var Peer = class {
1200
1162
  * Either we're initiating a connection or creating one in response to an offer from the other peer.
1201
1163
  */
1202
1164
  _createConnection(initiator, sessionId) {
1203
- log4("creating connection", {
1165
+ log3("creating connection", {
1204
1166
  topic: this.topic,
1205
1167
  peerId: this.localInfo,
1206
1168
  remoteId: this.remoteInfo,
1207
1169
  initiator,
1208
1170
  sessionId
1209
1171
  }, {
1210
- F: __dxlog_file4,
1172
+ F: __dxlog_file3,
1211
1173
  L: 249,
1212
1174
  S: this,
1213
1175
  C: (f, a) => f(...a)
1214
1176
  });
1215
1177
  invariant3(!this.connection, "Already connected.", {
1216
- F: __dxlog_file4,
1178
+ F: __dxlog_file3,
1217
1179
  L: 256,
1218
1180
  S: this,
1219
1181
  A: [
@@ -1242,14 +1204,14 @@ var Peer = class {
1242
1204
  this._lastConnectionTime = Date.now();
1243
1205
  this._callbacks.onConnected();
1244
1206
  this._connectionLimiter.doneConnecting(sessionId);
1245
- log4.trace("dxos.mesh.connection.connected", {
1207
+ log3.trace("dxos.mesh.connection.connected", {
1246
1208
  topic: this.topic,
1247
1209
  localPeerId: this.localInfo,
1248
1210
  remotePeerId: this.remoteInfo,
1249
1211
  sessionId,
1250
1212
  initiator
1251
1213
  }, {
1252
- F: __dxlog_file4,
1214
+ F: __dxlog_file3,
1253
1215
  L: 280,
1254
1216
  S: this,
1255
1217
  C: (f, a) => f(...a)
@@ -1262,15 +1224,15 @@ var Peer = class {
1262
1224
  remoteId: this.remoteInfo,
1263
1225
  initiator
1264
1226
  };
1265
- log4("connection closed", logMeta, {
1266
- F: __dxlog_file4,
1227
+ log3("connection closed", logMeta, {
1228
+ F: __dxlog_file3,
1267
1229
  L: 290,
1268
1230
  S: this,
1269
1231
  C: (f, a) => f(...a)
1270
1232
  });
1271
1233
  this._connectionLimiter.doneConnecting(sessionId);
1272
1234
  invariant3(this.connection === connection, "Connection mismatch (race condition).", {
1273
- F: __dxlog_file4,
1235
+ F: __dxlog_file3,
1274
1236
  L: 295,
1275
1237
  S: this,
1276
1238
  A: [
@@ -1278,14 +1240,14 @@ var Peer = class {
1278
1240
  "'Connection mismatch (race condition).'"
1279
1241
  ]
1280
1242
  });
1281
- log4.trace("dxos.mesh.connection.closed", {
1243
+ log3.trace("dxos.mesh.connection.closed", {
1282
1244
  topic: this.topic,
1283
1245
  localPeerId: this.localInfo,
1284
1246
  remotePeerId: this.remoteInfo,
1285
1247
  sessionId,
1286
1248
  initiator
1287
1249
  }, {
1288
- F: __dxlog_file4,
1250
+ F: __dxlog_file3,
1289
1251
  L: 297,
1290
1252
  S: this,
1291
1253
  C: (f, a) => f(...a)
@@ -1301,8 +1263,8 @@ var Peer = class {
1301
1263
  }
1302
1264
  this._callbacks.onDisconnected();
1303
1265
  scheduleTask2(this._connectionCtx, () => {
1304
- log4("peer became available", logMeta, {
1305
- F: __dxlog_file4,
1266
+ log3("peer became available", logMeta, {
1267
+ F: __dxlog_file3,
1306
1268
  L: 321,
1307
1269
  S: this,
1308
1270
  C: (f, a) => f(...a)
@@ -1319,19 +1281,19 @@ var Peer = class {
1319
1281
  void this._connectionCtx?.dispose();
1320
1282
  this._connectionCtx = this._ctx.derive();
1321
1283
  connection.errors.handle((err) => {
1322
- log4.info("connection error, closing", {
1284
+ log3.info("connection error, closing", {
1323
1285
  topic: this.topic,
1324
1286
  peerId: this.localInfo,
1325
1287
  remoteId: this.remoteInfo,
1326
1288
  initiator,
1327
1289
  err
1328
1290
  }, {
1329
- F: __dxlog_file4,
1291
+ F: __dxlog_file3,
1330
1292
  L: 339,
1331
1293
  S: this,
1332
1294
  C: (f, a) => f(...a)
1333
1295
  });
1334
- log4.trace("dxos.mesh.connection.error", {
1296
+ log3.trace("dxos.mesh.connection.error", {
1335
1297
  topic: this.topic,
1336
1298
  localPeerId: this.localInfo,
1337
1299
  remotePeerId: this.remoteInfo,
@@ -1339,7 +1301,7 @@ var Peer = class {
1339
1301
  initiator,
1340
1302
  err
1341
1303
  }, {
1342
- F: __dxlog_file4,
1304
+ F: __dxlog_file3,
1343
1305
  L: 346,
1344
1306
  S: this,
1345
1307
  C: (f, a) => f(...a)
@@ -1354,11 +1316,11 @@ var Peer = class {
1354
1316
  return;
1355
1317
  }
1356
1318
  const connection = this.connection;
1357
- log4("closing...", {
1319
+ log3("closing...", {
1358
1320
  peerId: this.remoteInfo,
1359
1321
  sessionId: connection.sessionId
1360
1322
  }, {
1361
- F: __dxlog_file4,
1323
+ F: __dxlog_file3,
1362
1324
  L: 371,
1363
1325
  S: this,
1364
1326
  C: (f, a) => f(...a)
@@ -1366,37 +1328,37 @@ var Peer = class {
1366
1328
  await connection.close({
1367
1329
  error: err
1368
1330
  });
1369
- log4("closed", {
1331
+ log3("closed", {
1370
1332
  peerId: this.remoteInfo,
1371
1333
  sessionId: connection.sessionId
1372
1334
  }, {
1373
- F: __dxlog_file4,
1335
+ F: __dxlog_file3,
1374
1336
  L: 377,
1375
1337
  S: this,
1376
1338
  C: (f, a) => f(...a)
1377
1339
  });
1378
1340
  }
1379
- async onSignal(message) {
1341
+ async onSignal(ctx, message) {
1380
1342
  if (!this.connection) {
1381
- log4("dropping signal message for non-existent connection", {
1343
+ log3("dropping signal message for non-existent connection", {
1382
1344
  message
1383
1345
  }, {
1384
- F: __dxlog_file4,
1346
+ F: __dxlog_file3,
1385
1347
  L: 382,
1386
1348
  S: this,
1387
1349
  C: (f, a) => f(...a)
1388
1350
  });
1389
1351
  return;
1390
1352
  }
1391
- await this.connection.signal(message);
1353
+ await this.connection.signal(ctx, message);
1392
1354
  }
1393
1355
  async safeDestroy(reason) {
1394
1356
  await this._ctx.dispose();
1395
- log4("Destroying peer", {
1357
+ log3("Destroying peer", {
1396
1358
  peerId: this.remoteInfo,
1397
1359
  topic: this.topic
1398
1360
  }, {
1399
- F: __dxlog_file4,
1361
+ F: __dxlog_file3,
1400
1362
  L: 392,
1401
1363
  S: this,
1402
1364
  C: (f, a) => f(...a)
@@ -1429,7 +1391,7 @@ function _ts_decorate3(decorators, target, key, desc) {
1429
1391
  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
1392
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1431
1393
  }
1432
- var __dxlog_file5 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
1394
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
1433
1395
  var INITIATION_DELAY = 100;
1434
1396
  var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
1435
1397
  var Swarm = class {
@@ -1443,9 +1405,9 @@ var Swarm = class {
1443
1405
  _connectionLimiter;
1444
1406
  _initiationDelay;
1445
1407
  _swarmMessenger;
1446
- _ctx = new Context4(void 0, {
1447
- F: __dxlog_file5,
1448
- L: 39
1408
+ _ctx = new Context3(void 0, {
1409
+ F: __dxlog_file4,
1410
+ L: 38
1449
1411
  });
1450
1412
  _listeningHandle = void 0;
1451
1413
  /**
@@ -1485,44 +1447,44 @@ var Swarm = class {
1485
1447
  this._label = _label;
1486
1448
  this._connectionLimiter = _connectionLimiter;
1487
1449
  this._initiationDelay = _initiationDelay;
1488
- log5.trace("dxos.mesh.swarm.constructor", trace2.begin({
1450
+ log4.trace("dxos.mesh.swarm.constructor", trace2.begin({
1489
1451
  id: this._instanceId,
1490
1452
  data: {
1491
1453
  topic: this._topic.toHex(),
1492
1454
  peer: this._ownPeer
1493
1455
  }
1494
1456
  }), {
1495
- F: __dxlog_file5,
1496
- L: 89,
1457
+ F: __dxlog_file4,
1458
+ L: 88,
1497
1459
  S: this,
1498
1460
  C: (f, a) => f(...a)
1499
1461
  });
1500
- log5("creating swarm", {
1462
+ log4("creating swarm", {
1501
1463
  peerId: _ownPeer
1502
1464
  }, {
1503
- F: __dxlog_file5,
1504
- L: 93,
1465
+ F: __dxlog_file4,
1466
+ L: 92,
1505
1467
  S: this,
1506
1468
  C: (f, a) => f(...a)
1507
1469
  });
1508
1470
  _topology.init(this._getSwarmController());
1509
1471
  this._swarmMessenger = new SwarmMessenger({
1510
- sendMessage: async (msg) => await this._messenger.sendMessage(msg),
1511
- onSignal: async (msg) => await this.onSignal(msg),
1512
- onOffer: async (msg) => await this.onOffer(msg),
1472
+ sendMessage: async (ctx, msg) => await this._messenger.sendMessage(ctx, msg),
1473
+ onSignal: async (ctx, msg) => await this.onSignal(ctx, msg),
1474
+ onOffer: async (ctx, msg) => await this.onOffer(ctx, msg),
1513
1475
  topic: this._topic
1514
1476
  });
1515
- log5.trace("dxos.mesh.swarm.constructor", trace2.end({
1477
+ log4.trace("dxos.mesh.swarm.constructor", trace2.end({
1516
1478
  id: this._instanceId
1517
1479
  }), {
1518
- F: __dxlog_file5,
1519
- L: 102,
1480
+ F: __dxlog_file4,
1481
+ L: 101,
1520
1482
  S: this,
1521
1483
  C: (f, a) => f(...a)
1522
1484
  });
1523
1485
  }
1524
1486
  get connections() {
1525
- return Array.from(this._peers.values()).map((peer) => peer.connection).filter(isNonNullable2);
1487
+ return Array.from(this._peers.values()).map((peer) => peer.connection).filter(isNonNullable);
1526
1488
  }
1527
1489
  get ownPeerId() {
1528
1490
  return PublicKey4.from(this._ownPeer.peerKey);
@@ -1541,8 +1503,8 @@ var Swarm = class {
1541
1503
  }
1542
1504
  async open() {
1543
1505
  invariant4(!this._listeningHandle, void 0, {
1544
- F: __dxlog_file5,
1545
- L: 133,
1506
+ F: __dxlog_file4,
1507
+ L: 132,
1546
1508
  S: this,
1547
1509
  A: [
1548
1510
  "!this._listeningHandle",
@@ -1553,11 +1515,11 @@ var Swarm = class {
1553
1515
  peer: this._ownPeer,
1554
1516
  payloadType: "dxos.mesh.swarm.SwarmMessage",
1555
1517
  onMessage: async (message) => {
1556
- await this._swarmMessenger.receiveMessage(message).catch((err) => log5.info("Error while receiving message", {
1518
+ await this._swarmMessenger.receiveMessage(this._ctx, message).catch((err) => log4.info("Error while receiving message", {
1557
1519
  err
1558
1520
  }, {
1559
- F: __dxlog_file5,
1560
- L: 141,
1521
+ F: __dxlog_file4,
1522
+ L: 140,
1561
1523
  S: this,
1562
1524
  C: (f, a) => f(...a)
1563
1525
  }));
@@ -1565,9 +1527,9 @@ var Swarm = class {
1565
1527
  });
1566
1528
  }
1567
1529
  async destroy() {
1568
- log5("destroying...", void 0, {
1569
- F: __dxlog_file5,
1570
- L: 147,
1530
+ log4("destroying...", void 0, {
1531
+ F: __dxlog_file4,
1532
+ L: 146,
1571
1533
  S: this,
1572
1534
  C: (f, a) => f(...a)
1573
1535
  });
@@ -1576,17 +1538,17 @@ var Swarm = class {
1576
1538
  await this._ctx.dispose();
1577
1539
  await this._topology.destroy();
1578
1540
  await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key, "swarm destroyed")));
1579
- log5("destroyed", void 0, {
1580
- F: __dxlog_file5,
1581
- L: 154,
1541
+ log4("destroyed", void 0, {
1542
+ F: __dxlog_file4,
1543
+ L: 153,
1582
1544
  S: this,
1583
1545
  C: (f, a) => f(...a)
1584
1546
  });
1585
1547
  }
1586
1548
  async setTopology(topology) {
1587
1549
  invariant4(!this._ctx.disposed, "Swarm is offline", {
1588
- F: __dxlog_file5,
1589
- L: 158,
1550
+ F: __dxlog_file4,
1551
+ L: 157,
1590
1552
  S: this,
1591
1553
  A: [
1592
1554
  "!this._ctx.disposed",
@@ -1596,12 +1558,12 @@ var Swarm = class {
1596
1558
  if (topology === this._topology) {
1597
1559
  return;
1598
1560
  }
1599
- log5("setting topology", {
1561
+ log4("setting topology", {
1600
1562
  previous: getClassName(this._topology),
1601
1563
  topology: getClassName(topology)
1602
1564
  }, {
1603
- F: __dxlog_file5,
1604
- L: 162,
1565
+ F: __dxlog_file4,
1566
+ L: 161,
1605
1567
  S: this,
1606
1568
  C: (f, a) => f(...a)
1607
1569
  });
@@ -1611,18 +1573,18 @@ var Swarm = class {
1611
1573
  this._topology.update();
1612
1574
  }
1613
1575
  async onSwarmEvent(swarmEvent) {
1614
- log5("swarm event", {
1576
+ log4("swarm event", {
1615
1577
  swarmEvent
1616
1578
  }, {
1617
- F: __dxlog_file5,
1618
- L: 175,
1579
+ F: __dxlog_file4,
1580
+ L: 174,
1619
1581
  S: this,
1620
1582
  C: (f, a) => f(...a)
1621
1583
  });
1622
1584
  if (this._ctx.disposed) {
1623
- log5("swarm event ignored for disposed swarm", void 0, {
1624
- F: __dxlog_file5,
1625
- L: 178,
1585
+ log4("swarm event ignored for disposed swarm", void 0, {
1586
+ F: __dxlog_file4,
1587
+ L: 177,
1626
1588
  S: this,
1627
1589
  C: (f, a) => f(...a)
1628
1590
  });
@@ -1631,11 +1593,11 @@ var Swarm = class {
1631
1593
  if (swarmEvent.peerAvailable) {
1632
1594
  const peerId = swarmEvent.peerAvailable.peer.peerKey;
1633
1595
  if (peerId !== this._ownPeer.peerKey) {
1634
- log5("new peer", {
1596
+ log4("new peer", {
1635
1597
  peerId
1636
1598
  }, {
1637
- F: __dxlog_file5,
1638
- L: 185,
1599
+ F: __dxlog_file4,
1600
+ L: 184,
1639
1601
  S: this,
1640
1602
  C: (f, a) => f(...a)
1641
1603
  });
@@ -1647,25 +1609,25 @@ var Swarm = class {
1647
1609
  if (peer) {
1648
1610
  peer.advertizing = false;
1649
1611
  if (this._isConnectionEstablishmentInProgress(peer)) {
1650
- log5(`destroying peer, state: ${peer.connection?.state}`, void 0, {
1651
- F: __dxlog_file5,
1652
- L: 196,
1612
+ log4(`destroying peer, state: ${peer.connection?.state}`, void 0, {
1613
+ F: __dxlog_file4,
1614
+ L: 195,
1653
1615
  S: this,
1654
1616
  C: (f, a) => f(...a)
1655
1617
  });
1656
- void this._destroyPeer(swarmEvent.peerLeft.peer, "peer left").catch((err) => log5.catch(err, void 0, {
1657
- F: __dxlog_file5,
1658
- L: 197,
1618
+ void this._destroyPeer(swarmEvent.peerLeft.peer, "peer left").catch((err) => log4.catch(err, void 0, {
1619
+ F: __dxlog_file4,
1620
+ L: 196,
1659
1621
  S: this,
1660
1622
  C: (f, a) => f(...a)
1661
1623
  }));
1662
1624
  }
1663
1625
  } else {
1664
- log5("received peerLeft but no peer found", {
1626
+ log4("received peerLeft but no peer found", {
1665
1627
  peer: swarmEvent.peerLeft.peer.peerKey
1666
1628
  }, {
1667
- F: __dxlog_file5,
1668
- L: 200,
1629
+ F: __dxlog_file4,
1630
+ L: 199,
1669
1631
  S: this,
1670
1632
  C: (f, a) => f(...a)
1671
1633
  });
@@ -1673,19 +1635,19 @@ var Swarm = class {
1673
1635
  }
1674
1636
  this._topology.update();
1675
1637
  }
1676
- async onOffer(message) {
1677
- log5("offer", {
1638
+ async onOffer(ctx, message) {
1639
+ log4("offer", {
1678
1640
  message
1679
1641
  }, {
1680
- F: __dxlog_file5,
1681
- L: 209,
1642
+ F: __dxlog_file4,
1643
+ L: 208,
1682
1644
  S: this,
1683
1645
  C: (f, a) => f(...a)
1684
1646
  });
1685
1647
  if (this._ctx.disposed) {
1686
- log5("ignored for disposed swarm", void 0, {
1687
- F: __dxlog_file5,
1688
- L: 211,
1648
+ log4("ignored for disposed swarm", void 0, {
1649
+ F: __dxlog_file4,
1650
+ L: 210,
1689
1651
  S: this,
1690
1652
  C: (f, a) => f(...a)
1691
1653
  });
@@ -1694,8 +1656,8 @@ var Swarm = class {
1694
1656
  };
1695
1657
  }
1696
1658
  invariant4(message.author, void 0, {
1697
- F: __dxlog_file5,
1698
- L: 216,
1659
+ F: __dxlog_file4,
1660
+ L: 215,
1699
1661
  S: this,
1700
1662
  A: [
1701
1663
  "message.author",
@@ -1703,11 +1665,11 @@ var Swarm = class {
1703
1665
  ]
1704
1666
  });
1705
1667
  if (message.recipient.peerKey !== this._ownPeer.peerKey) {
1706
- log5("rejecting offer with incorrect peerId", {
1668
+ log4("rejecting offer with incorrect peerId", {
1707
1669
  message
1708
1670
  }, {
1709
- F: __dxlog_file5,
1710
- L: 218,
1671
+ F: __dxlog_file4,
1672
+ L: 217,
1711
1673
  S: this,
1712
1674
  C: (f, a) => f(...a)
1713
1675
  });
@@ -1716,11 +1678,11 @@ var Swarm = class {
1716
1678
  };
1717
1679
  }
1718
1680
  if (!message.topic?.equals(this._topic)) {
1719
- log5("rejecting offer with incorrect topic", {
1681
+ log4("rejecting offer with incorrect topic", {
1720
1682
  message
1721
1683
  }, {
1722
- F: __dxlog_file5,
1723
- L: 222,
1684
+ F: __dxlog_file4,
1685
+ L: 221,
1724
1686
  S: this,
1725
1687
  C: (f, a) => f(...a)
1726
1688
  });
@@ -1729,7 +1691,7 @@ var Swarm = class {
1729
1691
  };
1730
1692
  }
1731
1693
  const peer = this._getOfferSenderPeer(message.author);
1732
- const answer = await peer.onOffer(message);
1694
+ const answer = await peer.onOffer(ctx, message);
1733
1695
  this._topology.update();
1734
1696
  return answer;
1735
1697
  }
@@ -1743,27 +1705,27 @@ var Swarm = class {
1743
1705
  }
1744
1706
  return peer;
1745
1707
  }
1746
- async onSignal(message) {
1747
- log5("signal", {
1708
+ async onSignal(ctx, message) {
1709
+ log4("signal", {
1748
1710
  message
1749
1711
  }, {
1750
- F: __dxlog_file5,
1751
- L: 247,
1712
+ F: __dxlog_file4,
1713
+ L: 246,
1752
1714
  S: this,
1753
1715
  C: (f, a) => f(...a)
1754
1716
  });
1755
1717
  if (this._ctx.disposed) {
1756
- log5.info("ignored for offline swarm", void 0, {
1757
- F: __dxlog_file5,
1758
- L: 249,
1718
+ log4.info("ignored for offline swarm", void 0, {
1719
+ F: __dxlog_file4,
1720
+ L: 248,
1759
1721
  S: this,
1760
1722
  C: (f, a) => f(...a)
1761
1723
  });
1762
1724
  return;
1763
1725
  }
1764
1726
  invariant4(message.recipient.peerKey === this._ownPeer.peerKey, `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
1765
- F: __dxlog_file5,
1766
- L: 252,
1727
+ F: __dxlog_file4,
1728
+ L: 251,
1767
1729
  S: this,
1768
1730
  A: [
1769
1731
  "message.recipient.peerKey === this._ownPeer.peerKey",
@@ -1771,8 +1733,8 @@ var Swarm = class {
1771
1733
  ]
1772
1734
  });
1773
1735
  invariant4(message.topic?.equals(this._topic), void 0, {
1774
- F: __dxlog_file5,
1775
- L: 256,
1736
+ F: __dxlog_file4,
1737
+ L: 255,
1776
1738
  S: this,
1777
1739
  A: [
1778
1740
  "message.topic?.equals(this._topic)",
@@ -1780,8 +1742,8 @@ var Swarm = class {
1780
1742
  ]
1781
1743
  });
1782
1744
  invariant4(message.author, void 0, {
1783
- F: __dxlog_file5,
1784
- L: 257,
1745
+ F: __dxlog_file4,
1746
+ L: 256,
1785
1747
  S: this,
1786
1748
  A: [
1787
1749
  "message.author",
@@ -1789,7 +1751,7 @@ var Swarm = class {
1789
1751
  ]
1790
1752
  });
1791
1753
  const peer = this._getOrCreatePeer(message.author);
1792
- await peer.onSignal(message);
1754
+ await peer.onSignal(ctx, message);
1793
1755
  }
1794
1756
  // For debug purposes
1795
1757
  async goOffline() {
@@ -1800,15 +1762,15 @@ var Swarm = class {
1800
1762
  }
1801
1763
  // For debug purposes
1802
1764
  async goOnline() {
1803
- this._ctx = new Context4(void 0, {
1804
- F: __dxlog_file5,
1805
- L: 273
1765
+ this._ctx = new Context3(void 0, {
1766
+ F: __dxlog_file4,
1767
+ L: 272
1806
1768
  });
1807
1769
  }
1808
1770
  _getOrCreatePeer(peerInfo) {
1809
1771
  invariant4(peerInfo.peerKey, "PeerInfo.peerKey is required", {
1810
- F: __dxlog_file5,
1811
- L: 277,
1772
+ F: __dxlog_file4,
1773
+ L: 276,
1812
1774
  S: this,
1813
1775
  A: [
1814
1776
  "peerInfo.peerKey",
@@ -1826,9 +1788,9 @@ var Swarm = class {
1826
1788
  },
1827
1789
  onDisconnected: async () => {
1828
1790
  if (this._isUnregistered(peer)) {
1829
- log5.verbose("ignored onDisconnected for unregistered peer", void 0, {
1830
- F: __dxlog_file5,
1831
- L: 297,
1791
+ log4.verbose("ignored onDisconnected for unregistered peer", void 0, {
1792
+ F: __dxlog_file4,
1793
+ L: 296,
1832
1794
  S: this,
1833
1795
  C: (f, a) => f(...a)
1834
1796
  });
@@ -1842,11 +1804,11 @@ var Swarm = class {
1842
1804
  },
1843
1805
  onRejected: () => {
1844
1806
  if (!this._isUnregistered(peer)) {
1845
- log5("peer rejected connection", {
1807
+ log4("peer rejected connection", {
1846
1808
  peerInfo
1847
1809
  }, {
1848
- F: __dxlog_file5,
1849
- L: 311,
1810
+ F: __dxlog_file4,
1811
+ L: 310,
1850
1812
  S: this,
1851
1813
  C: (f, a) => f(...a)
1852
1814
  });
@@ -1868,19 +1830,19 @@ var Swarm = class {
1868
1830
  return peer;
1869
1831
  }
1870
1832
  async _destroyPeer(peerInfo, reason) {
1871
- log5("destroy peer", {
1833
+ log4("destroy peer", {
1872
1834
  peerKey: peerInfo.peerKey,
1873
1835
  reason
1874
1836
  }, {
1875
- F: __dxlog_file5,
1876
- L: 333,
1837
+ F: __dxlog_file4,
1838
+ L: 332,
1877
1839
  S: this,
1878
1840
  C: (f, a) => f(...a)
1879
1841
  });
1880
1842
  const peer = this._peers.get(peerInfo);
1881
1843
  invariant4(peer, void 0, {
1882
- F: __dxlog_file5,
1883
- L: 335,
1844
+ F: __dxlog_file4,
1845
+ L: 334,
1884
1846
  S: this,
1885
1847
  A: [
1886
1848
  "peer",
@@ -1908,9 +1870,9 @@ var Swarm = class {
1908
1870
  peerKey: peer.toHex()
1909
1871
  });
1910
1872
  } catch (err) {
1911
- log5("initiation error", err, {
1912
- F: __dxlog_file5,
1913
- L: 362,
1873
+ log4("initiation error", err, {
1874
+ F: __dxlog_file4,
1875
+ L: 361,
1914
1876
  S: this,
1915
1877
  C: (f, a) => f(...a)
1916
1878
  });
@@ -1937,11 +1899,11 @@ var Swarm = class {
1937
1899
  const ctx = this._ctx;
1938
1900
  const peer = this._getOrCreatePeer(remotePeer);
1939
1901
  if (remotePeer.peerKey < this._ownPeer.peerKey) {
1940
- log5("initiation delay", {
1902
+ log4("initiation delay", {
1941
1903
  remotePeer
1942
1904
  }, {
1943
- F: __dxlog_file5,
1944
- L: 390,
1905
+ F: __dxlog_file4,
1906
+ L: 389,
1945
1907
  S: this,
1946
1908
  C: (f, a) => f(...a)
1947
1909
  });
@@ -1956,21 +1918,21 @@ var Swarm = class {
1956
1918
  if (peer.connection) {
1957
1919
  return;
1958
1920
  }
1959
- log5("initiating connection...", {
1921
+ log4("initiating connection...", {
1960
1922
  remotePeer
1961
1923
  }, {
1962
- F: __dxlog_file5,
1963
- L: 406,
1924
+ F: __dxlog_file4,
1925
+ L: 405,
1964
1926
  S: this,
1965
1927
  C: (f, a) => f(...a)
1966
1928
  });
1967
- await peer.initiateConnection();
1929
+ await peer.initiateConnection(ctx);
1968
1930
  this._topology.update();
1969
- log5("initiated", {
1931
+ log4("initiated", {
1970
1932
  remotePeer
1971
1933
  }, {
1972
- F: __dxlog_file5,
1973
- L: 409,
1934
+ F: __dxlog_file4,
1935
+ L: 408,
1974
1936
  S: this,
1975
1937
  C: (f, a) => f(...a)
1976
1938
  });
@@ -2021,10 +1983,10 @@ _ts_decorate3([
2021
1983
  // src/swarm/swarm-mapper.ts
2022
1984
  import { Event as Event4, SubscriptionList } from "@dxos/async";
2023
1985
  import { PublicKey as PublicKey5 } from "@dxos/keys";
2024
- import { log as log6 } from "@dxos/log";
1986
+ import { log as log5 } from "@dxos/log";
2025
1987
  import { PeerInfoHash as PeerInfoHash2 } from "@dxos/messaging";
2026
1988
  import { ComplexMap as ComplexMap3 } from "@dxos/util";
2027
- var __dxlog_file6 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
1989
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
2028
1990
  var SwarmMapper = class {
2029
1991
  _swarm;
2030
1992
  _subscriptions = new SubscriptionList();
@@ -2050,8 +2012,8 @@ var SwarmMapper = class {
2050
2012
  this._update();
2051
2013
  }
2052
2014
  _update() {
2053
- log6("updating swarm", void 0, {
2054
- F: __dxlog_file6,
2015
+ log5("updating swarm", void 0, {
2016
+ F: __dxlog_file5,
2055
2017
  L: 71,
2056
2018
  S: this,
2057
2019
  C: (f, a) => f(...a)
@@ -2071,11 +2033,11 @@ var SwarmMapper = class {
2071
2033
  ]
2072
2034
  });
2073
2035
  }
2074
- log6("graph changed", {
2036
+ log5("graph changed", {
2075
2037
  directConnections: this._swarm.connections.length,
2076
2038
  totalPeersInSwarm: this._peers.size
2077
2039
  }, {
2078
- F: __dxlog_file6,
2040
+ F: __dxlog_file5,
2079
2041
  L: 112,
2080
2042
  S: this,
2081
2043
  C: (f, a) => f(...a)
@@ -2092,17 +2054,17 @@ var SwarmMapper = class {
2092
2054
 
2093
2055
  // src/swarm/connection-limiter.ts
2094
2056
  import { DeferredTask as DeferredTask2 } from "@dxos/async";
2095
- import { Context as Context5 } from "@dxos/context";
2057
+ import { Context as Context4 } from "@dxos/context";
2096
2058
  import { invariant as invariant5 } from "@dxos/invariant";
2097
2059
  import { PublicKey as PublicKey6 } from "@dxos/keys";
2098
- import { log as log7 } from "@dxos/log";
2060
+ import { log as log6 } from "@dxos/log";
2099
2061
  import { CancelledError as CancelledError3 } from "@dxos/protocols";
2100
2062
  import { ComplexMap as ComplexMap4 } from "@dxos/util";
2101
- var __dxlog_file7 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
2063
+ var __dxlog_file6 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
2102
2064
  var MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
2103
2065
  var ConnectionLimiter = class {
2104
- _ctx = new Context5(void 0, {
2105
- F: __dxlog_file7,
2066
+ _ctx = new Context4(void 0, {
2067
+ F: __dxlog_file6,
2106
2068
  L: 23
2107
2069
  });
2108
2070
  _maxConcurrentInitConnections;
@@ -2123,7 +2085,7 @@ var ConnectionLimiter = class {
2123
2085
  */
2124
2086
  async connecting(sessionId) {
2125
2087
  invariant5(!this._waitingPromises.has(sessionId), "Peer is already waiting for connection", {
2126
- F: __dxlog_file7,
2088
+ F: __dxlog_file6,
2127
2089
  L: 48,
2128
2090
  S: this,
2129
2091
  A: [
@@ -2131,10 +2093,10 @@ var ConnectionLimiter = class {
2131
2093
  "'Peer is already waiting for connection'"
2132
2094
  ]
2133
2095
  });
2134
- log7("waiting", {
2096
+ log6("waiting", {
2135
2097
  sessionId
2136
2098
  }, {
2137
- F: __dxlog_file7,
2099
+ F: __dxlog_file6,
2138
2100
  L: 49,
2139
2101
  S: this,
2140
2102
  C: (f, a) => f(...a)
@@ -2146,10 +2108,10 @@ var ConnectionLimiter = class {
2146
2108
  });
2147
2109
  this.resolveWaitingPromises.schedule();
2148
2110
  });
2149
- log7("allow", {
2111
+ log6("allow", {
2150
2112
  sessionId
2151
2113
  }, {
2152
- F: __dxlog_file7,
2114
+ F: __dxlog_file6,
2153
2115
  L: 57,
2154
2116
  S: this,
2155
2117
  C: (f, a) => f(...a)
@@ -2159,10 +2121,10 @@ var ConnectionLimiter = class {
2159
2121
  * Rejects promise returned by `connecting` method.
2160
2122
  */
2161
2123
  doneConnecting(sessionId) {
2162
- log7("done", {
2124
+ log6("done", {
2163
2125
  sessionId
2164
2126
  }, {
2165
- F: __dxlog_file7,
2127
+ F: __dxlog_file6,
2166
2128
  L: 64,
2167
2129
  S: this,
2168
2130
  C: (f, a) => f(...a)
@@ -2270,7 +2232,7 @@ var gcSwarm = (swarm) => {
2270
2232
  import { Event as Event6, synchronized as synchronized4 } from "@dxos/async";
2271
2233
  import { invariant as invariant6 } from "@dxos/invariant";
2272
2234
  import { PublicKey as PublicKey8 } from "@dxos/keys";
2273
- import { log as log8 } from "@dxos/log";
2235
+ import { log as log7 } from "@dxos/log";
2274
2236
  import { Messenger } from "@dxos/messaging";
2275
2237
  import { trace as trace3 } from "@dxos/protocols";
2276
2238
  import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
@@ -2281,7 +2243,7 @@ function _ts_decorate4(decorators, target, key, desc) {
2281
2243
  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
2244
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2283
2245
  }
2284
- var __dxlog_file8 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
2246
+ var __dxlog_file7 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
2285
2247
  var SwarmNetworkManager = class {
2286
2248
  /**
2287
2249
  * @internal
@@ -2307,8 +2269,8 @@ var SwarmNetworkManager = class {
2307
2269
  signalManager: this._signalManager
2308
2270
  });
2309
2271
  this._signalConnection = {
2310
- join: (opts) => this._signalManager.join(opts),
2311
- leave: (opts) => this._signalManager.leave(opts)
2272
+ join: (ctx, opts) => this._signalManager.join(ctx, opts),
2273
+ leave: (ctx, opts) => this._signalManager.leave(ctx, opts)
2312
2274
  };
2313
2275
  this._peerInfo = peerInfo;
2314
2276
  this._connectionLimiter = new ConnectionLimiter();
@@ -2337,31 +2299,31 @@ var SwarmNetworkManager = class {
2337
2299
  this._peerInfo = peerInfo;
2338
2300
  }
2339
2301
  async open() {
2340
- log8.trace("dxos.mesh.network-manager.open", trace3.begin({
2302
+ log7.trace("dxos.mesh.network-manager.open", trace3.begin({
2341
2303
  id: this._instanceId
2342
2304
  }), {
2343
- F: __dxlog_file8,
2344
- L: 133,
2305
+ F: __dxlog_file7,
2306
+ L: 134,
2345
2307
  S: this,
2346
2308
  C: (f, a) => f(...a)
2347
2309
  });
2348
2310
  await this._messenger.open();
2349
2311
  await this._signalManager.open();
2350
- log8.trace("dxos.mesh.network-manager.open", trace3.end({
2312
+ log7.trace("dxos.mesh.network-manager.open", trace3.end({
2351
2313
  id: this._instanceId
2352
2314
  }), {
2353
- F: __dxlog_file8,
2354
- L: 136,
2315
+ F: __dxlog_file7,
2316
+ L: 137,
2355
2317
  S: this,
2356
2318
  C: (f, a) => f(...a)
2357
2319
  });
2358
2320
  }
2359
- async close() {
2321
+ async close(ctx) {
2360
2322
  for (const topic of this._swarms.keys()) {
2361
- await this.leaveSwarm(topic).catch((err) => {
2362
- log8(err, void 0, {
2363
- F: __dxlog_file8,
2364
- L: 142,
2323
+ await this.leaveSwarm(ctx, topic).catch((err) => {
2324
+ log7(err, void 0, {
2325
+ F: __dxlog_file7,
2326
+ L: 143,
2365
2327
  S: this,
2366
2328
  C: (f, a) => f(...a)
2367
2329
  });
@@ -2373,10 +2335,10 @@ var SwarmNetworkManager = class {
2373
2335
  /**
2374
2336
  * Join the swarm.
2375
2337
  */
2376
- async joinSwarm({ topic, topology, protocolProvider: protocol, label }) {
2338
+ async joinSwarm(ctx, { topic, topology, protocolProvider: protocol, label }) {
2377
2339
  invariant6(PublicKey8.isPublicKey(topic), void 0, {
2378
- F: __dxlog_file8,
2379
- L: 160,
2340
+ F: __dxlog_file7,
2341
+ L: 164,
2380
2342
  S: this,
2381
2343
  A: [
2382
2344
  "PublicKey.isPublicKey(topic)",
@@ -2384,8 +2346,8 @@ var SwarmNetworkManager = class {
2384
2346
  ]
2385
2347
  });
2386
2348
  invariant6(topology, void 0, {
2387
- F: __dxlog_file8,
2388
- L: 161,
2349
+ F: __dxlog_file7,
2350
+ L: 165,
2389
2351
  S: this,
2390
2352
  A: [
2391
2353
  "topology",
@@ -2393,8 +2355,8 @@ var SwarmNetworkManager = class {
2393
2355
  ]
2394
2356
  });
2395
2357
  invariant6(this._peerInfo, void 0, {
2396
- F: __dxlog_file8,
2397
- L: 162,
2358
+ F: __dxlog_file7,
2359
+ L: 166,
2398
2360
  S: this,
2399
2361
  A: [
2400
2362
  "this._peerInfo",
@@ -2402,8 +2364,8 @@ var SwarmNetworkManager = class {
2402
2364
  ]
2403
2365
  });
2404
2366
  invariant6(typeof protocol === "function", void 0, {
2405
- F: __dxlog_file8,
2406
- L: 163,
2367
+ F: __dxlog_file7,
2368
+ L: 167,
2407
2369
  S: this,
2408
2370
  A: [
2409
2371
  "typeof protocol === 'function'",
@@ -2413,23 +2375,23 @@ var SwarmNetworkManager = class {
2413
2375
  if (this._swarms.has(topic)) {
2414
2376
  throw new Error(`Already connected to swarm: ${PublicKey8.from(topic)}`);
2415
2377
  }
2416
- log8("joining", {
2378
+ log7("joining", {
2417
2379
  topic: PublicKey8.from(topic),
2418
2380
  peerInfo: this._peerInfo,
2419
2381
  topology: topology.toString()
2420
2382
  }, {
2421
- F: __dxlog_file8,
2422
- L: 168,
2383
+ F: __dxlog_file7,
2384
+ L: 172,
2423
2385
  S: this,
2424
2386
  C: (f, a) => f(...a)
2425
2387
  });
2426
2388
  const swarm = new Swarm(topic, this._peerInfo, topology, protocol, this._messenger, this._transportFactory, label, this._connectionLimiter);
2427
2389
  swarm.errors.handle((error) => {
2428
- log8("swarm error", {
2390
+ log7("swarm error", {
2429
2391
  error
2430
2392
  }, {
2431
- F: __dxlog_file8,
2432
- L: 181,
2393
+ F: __dxlog_file7,
2394
+ L: 185,
2433
2395
  S: this,
2434
2396
  C: (f, a) => f(...a)
2435
2397
  });
@@ -2437,47 +2399,47 @@ var SwarmNetworkManager = class {
2437
2399
  this._swarms.set(topic, swarm);
2438
2400
  this._mappers.set(topic, new SwarmMapper(swarm));
2439
2401
  await swarm.open();
2440
- this._signalConnection.join({
2402
+ this._signalConnection.join(ctx, {
2441
2403
  topic,
2442
2404
  peer: this._peerInfo
2443
- }).catch((error) => log8.catch(error, void 0, {
2444
- F: __dxlog_file8,
2445
- L: 190,
2405
+ }).catch((error) => log7.catch(error, void 0, {
2406
+ F: __dxlog_file7,
2407
+ L: 194,
2446
2408
  S: this,
2447
2409
  C: (f, a) => f(...a)
2448
2410
  }));
2449
2411
  this.topicsUpdated.emit();
2450
2412
  this._connectionLog?.joinedSwarm(swarm);
2451
- log8("joined", {
2413
+ log7("joined", {
2452
2414
  topic: PublicKey8.from(topic),
2453
2415
  count: this._swarms.size
2454
2416
  }, {
2455
- F: __dxlog_file8,
2456
- L: 194,
2417
+ F: __dxlog_file7,
2418
+ L: 198,
2457
2419
  S: this,
2458
2420
  C: (f, a) => f(...a)
2459
2421
  });
2460
2422
  return {
2461
- close: () => this.leaveSwarm(topic)
2423
+ close: (ctx2) => this.leaveSwarm(ctx2, topic)
2462
2424
  };
2463
2425
  }
2464
2426
  /**
2465
2427
  * Close the connection.
2466
2428
  */
2467
- async leaveSwarm(topic) {
2429
+ async leaveSwarm(ctx, topic) {
2468
2430
  if (!this._swarms.has(topic)) {
2469
2431
  return;
2470
2432
  }
2471
- log8("leaving", {
2433
+ log7("leaving", {
2472
2434
  topic: PublicKey8.from(topic)
2473
2435
  }, {
2474
- F: __dxlog_file8,
2475
- L: 211,
2436
+ F: __dxlog_file7,
2437
+ L: 215,
2476
2438
  S: this,
2477
2439
  C: (f, a) => f(...a)
2478
2440
  });
2479
2441
  const swarm = this._swarms.get(topic);
2480
- await this._signalConnection.leave({
2442
+ await this._signalConnection.leave(ctx, {
2481
2443
  topic,
2482
2444
  peer: swarm.ownPeer
2483
2445
  });
@@ -2488,12 +2450,12 @@ var SwarmNetworkManager = class {
2488
2450
  await swarm.destroy();
2489
2451
  this._swarms.delete(topic);
2490
2452
  this.topicsUpdated.emit();
2491
- log8("left", {
2453
+ log7("left", {
2492
2454
  topic: PublicKey8.from(topic),
2493
2455
  count: this._swarms.size
2494
2456
  }, {
2495
- F: __dxlog_file8,
2496
- L: 225,
2457
+ F: __dxlog_file7,
2458
+ L: 229,
2497
2459
  S: this,
2498
2460
  C: (f, a) => f(...a)
2499
2461
  });
@@ -2534,7 +2496,7 @@ _ts_decorate4([
2534
2496
 
2535
2497
  // src/topology/fully-connected-topology.ts
2536
2498
  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";
2499
+ var __dxlog_file8 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
2538
2500
  var FullyConnectedTopology = class {
2539
2501
  _controller;
2540
2502
  toString() {
@@ -2542,7 +2504,7 @@ var FullyConnectedTopology = class {
2542
2504
  }
2543
2505
  init(controller) {
2544
2506
  invariant7(!this._controller, "Already initialized", {
2545
- F: __dxlog_file9,
2507
+ F: __dxlog_file8,
2546
2508
  L: 18,
2547
2509
  S: this,
2548
2510
  A: [
@@ -2554,7 +2516,7 @@ var FullyConnectedTopology = class {
2554
2516
  }
2555
2517
  update() {
2556
2518
  invariant7(this._controller, "Not initialized", {
2557
- F: __dxlog_file9,
2519
+ F: __dxlog_file8,
2558
2520
  L: 23,
2559
2521
  S: this,
2560
2522
  A: [
@@ -2574,321 +2536,13 @@ var FullyConnectedTopology = class {
2574
2536
  }
2575
2537
  };
2576
2538
 
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
2539
  // src/transport/memory-transport.ts
2886
2540
  import { Transform } from "@dxos/node-std/stream";
2887
2541
  import { Event as Event7, Trigger as Trigger2 } from "@dxos/async";
2888
2542
  import { ErrorStream as ErrorStream3 } from "@dxos/debug";
2889
- import { invariant as invariant10 } from "@dxos/invariant";
2543
+ import { invariant as invariant8 } from "@dxos/invariant";
2890
2544
  import { PublicKey as PublicKey9 } from "@dxos/keys";
2891
- import { log as log11, logInfo as logInfo3 } from "@dxos/log";
2545
+ import { log as log8, logInfo as logInfo3 } from "@dxos/log";
2892
2546
  import { ComplexMap as ComplexMap7 } from "@dxos/util";
2893
2547
  function _ts_decorate5(decorators, target, key, desc) {
2894
2548
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -2896,7 +2550,7 @@ function _ts_decorate5(decorators, target, key, desc) {
2896
2550
  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
2551
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2898
2552
  }
2899
- var __dxlog_file12 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
2553
+ var __dxlog_file9 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
2900
2554
  var MEMORY_TRANSPORT_DELAY = 1;
2901
2555
  var createStreamDelay = (delay) => {
2902
2556
  return new Transform({
@@ -2925,8 +2579,8 @@ var MemoryTransport = class _MemoryTransport {
2925
2579
  errors = new ErrorStream3();
2926
2580
  constructor(_options) {
2927
2581
  this._options = _options;
2928
- invariant10(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection", {
2929
- F: __dxlog_file12,
2582
+ invariant8(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection", {
2583
+ F: __dxlog_file9,
2930
2584
  L: 64,
2931
2585
  S: this,
2932
2586
  A: [
@@ -2940,15 +2594,15 @@ var MemoryTransport = class _MemoryTransport {
2940
2594
  return !this._closed;
2941
2595
  }
2942
2596
  async open() {
2943
- log11("opening...", void 0, {
2944
- F: __dxlog_file12,
2597
+ log8("opening...", void 0, {
2598
+ F: __dxlog_file9,
2945
2599
  L: 74,
2946
2600
  S: this,
2947
2601
  C: (f, a) => f(...a)
2948
2602
  });
2949
2603
  if (this._options.initiator) {
2950
- log11("sending signal", void 0, {
2951
- F: __dxlog_file12,
2604
+ log8("sending signal", void 0, {
2605
+ F: __dxlog_file9,
2952
2606
  L: 78,
2953
2607
  S: this,
2954
2608
  C: (f, a) => f(...a)
@@ -2978,8 +2632,8 @@ var MemoryTransport = class _MemoryTransport {
2978
2632
  this.closed.emit();
2979
2633
  return;
2980
2634
  }
2981
- invariant10(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`, {
2982
- F: __dxlog_file12,
2635
+ invariant8(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`, {
2636
+ F: __dxlog_file9,
2983
2637
  L: 104,
2984
2638
  S: this,
2985
2639
  A: [
@@ -2989,8 +2643,8 @@ var MemoryTransport = class _MemoryTransport {
2989
2643
  });
2990
2644
  this._remoteConnection._remoteConnection = this;
2991
2645
  this._remoteConnection._remoteInstanceId = this._instanceId;
2992
- log11("connected", void 0, {
2993
- F: __dxlog_file12,
2646
+ log8("connected", void 0, {
2647
+ F: __dxlog_file9,
2994
2648
  L: 108,
2995
2649
  S: this,
2996
2650
  C: (f, a) => f(...a)
@@ -3008,8 +2662,8 @@ var MemoryTransport = class _MemoryTransport {
3008
2662
  return this;
3009
2663
  }
3010
2664
  async close() {
3011
- log11("closing...", void 0, {
3012
- F: __dxlog_file12,
2665
+ log8("closing...", void 0, {
2666
+ F: __dxlog_file9,
3013
2667
  L: 130,
3014
2668
  S: this,
3015
2669
  C: (f, a) => f(...a)
@@ -3029,8 +2683,8 @@ var MemoryTransport = class _MemoryTransport {
3029
2683
  this._remoteConnection = void 0;
3030
2684
  }
3031
2685
  this.closed.emit();
3032
- log11("closed", void 0, {
3033
- F: __dxlog_file12,
2686
+ log8("closed", void 0, {
2687
+ F: __dxlog_file9,
3034
2688
  L: 158,
3035
2689
  S: this,
3036
2690
  C: (f, a) => f(...a)
@@ -3038,10 +2692,10 @@ var MemoryTransport = class _MemoryTransport {
3038
2692
  return this;
3039
2693
  }
3040
2694
  async onSignal({ payload }) {
3041
- log11("received signal", {
2695
+ log8("received signal", {
3042
2696
  payload
3043
2697
  }, {
3044
- F: __dxlog_file12,
2698
+ F: __dxlog_file9,
3045
2699
  L: 163,
3046
2700
  S: this,
3047
2701
  C: (f, a) => f(...a)
@@ -3131,8 +2785,8 @@ var getRtcConnectionFactory = () => {
3131
2785
 
3132
2786
  // src/transport/webrtc/rtc-peer-connection.ts
3133
2787
  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";
2788
+ import { invariant as invariant10 } from "@dxos/invariant";
2789
+ import { log as log10, logInfo as logInfo4 } from "@dxos/log";
3136
2790
  import { ConnectivityError as ConnectivityError3 } from "@dxos/protocols";
3137
2791
  import { trace as trace4 } from "@dxos/tracing";
3138
2792
 
@@ -3141,8 +2795,8 @@ import { Duplex } from "@dxos/node-std/stream";
3141
2795
  import { Event as AsyncEvent } from "@dxos/async";
3142
2796
  import { Resource } from "@dxos/context";
3143
2797
  import { ErrorStream as ErrorStream4 } from "@dxos/debug";
3144
- import { invariant as invariant11 } from "@dxos/invariant";
3145
- import { log as log12 } from "@dxos/log";
2798
+ import { invariant as invariant9 } from "@dxos/invariant";
2799
+ import { log as log9 } from "@dxos/log";
3146
2800
  import { ConnectivityError as ConnectivityError2 } from "@dxos/protocols";
3147
2801
 
3148
2802
  // src/transport/webrtc/rtc-transport-stats.ts
@@ -3193,7 +2847,7 @@ var getRtcConnectionStats = async (connection, channelTopic) => {
3193
2847
  };
3194
2848
 
3195
2849
  // 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";
2850
+ var __dxlog_file10 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-channel.ts";
3197
2851
  var MAX_MESSAGE_SIZE = 64 * 1024;
3198
2852
  var MAX_BUFFERED_AMOUNT = 64 * 1024;
3199
2853
  var RtcTransportChannel = class extends Resource {
@@ -3218,9 +2872,9 @@ var RtcTransportChannel = class extends Resource {
3218
2872
  }
3219
2873
  }
3220
2874
  async _open() {
3221
- invariant11(!this._isChannelCreationInProgress, void 0, {
3222
- F: __dxlog_file13,
3223
- L: 57,
2875
+ invariant9(!this._isChannelCreationInProgress, void 0, {
2876
+ F: __dxlog_file10,
2877
+ L: 56,
3224
2878
  S: this,
3225
2879
  A: [
3226
2880
  "!this._isChannelCreationInProgress",
@@ -3242,11 +2896,11 @@ var RtcTransportChannel = class extends Resource {
3242
2896
  });
3243
2897
  this.errors.raise(error);
3244
2898
  } else {
3245
- log12.verbose("connection establishment failed after transport was closed", {
2899
+ log9.verbose("connection establishment failed after transport was closed", {
3246
2900
  err
3247
2901
  }, {
3248
- F: __dxlog_file13,
3249
- L: 77,
2902
+ F: __dxlog_file10,
2903
+ L: 76,
3250
2904
  S: this,
3251
2905
  C: (f, a) => f(...a)
3252
2906
  });
@@ -3262,9 +2916,9 @@ var RtcTransportChannel = class extends Resource {
3262
2916
  this._stream = void 0;
3263
2917
  }
3264
2918
  this.closed.emit();
3265
- log12("closed", void 0, {
3266
- F: __dxlog_file13,
3267
- L: 93,
2919
+ log9("closed", void 0, {
2920
+ F: __dxlog_file10,
2921
+ L: 92,
3268
2922
  S: this,
3269
2923
  C: (f, a) => f(...a)
3270
2924
  });
@@ -3273,20 +2927,20 @@ var RtcTransportChannel = class extends Resource {
3273
2927
  Object.assign(channel, {
3274
2928
  onopen: () => {
3275
2929
  if (!this.isOpen) {
3276
- log12.warn("channel opened in a closed transport", {
2930
+ log9.warn("channel opened in a closed transport", {
3277
2931
  topic: this._options.topic
3278
2932
  }, {
3279
- F: __dxlog_file13,
3280
- L: 100,
2933
+ F: __dxlog_file10,
2934
+ L: 99,
3281
2935
  S: this,
3282
2936
  C: (f, a) => f(...a)
3283
2937
  });
3284
2938
  this._safeCloseChannel(channel);
3285
2939
  return;
3286
2940
  }
3287
- log12("onopen", void 0, {
3288
- F: __dxlog_file13,
3289
- L: 105,
2941
+ log9("onopen", void 0, {
2942
+ F: __dxlog_file10,
2943
+ L: 104,
3290
2944
  S: this,
3291
2945
  C: (f, a) => f(...a)
3292
2946
  });
@@ -3302,9 +2956,9 @@ var RtcTransportChannel = class extends Resource {
3302
2956
  this.connected.emit();
3303
2957
  },
3304
2958
  onclose: async () => {
3305
- log12("onclose", void 0, {
3306
- F: __dxlog_file13,
3307
- L: 118,
2959
+ log9("onclose", void 0, {
2960
+ F: __dxlog_file10,
2961
+ L: 117,
3308
2962
  S: this,
3309
2963
  C: (f, a) => f(...a)
3310
2964
  });
@@ -3312,9 +2966,9 @@ var RtcTransportChannel = class extends Resource {
3312
2966
  },
3313
2967
  onmessage: async (event) => {
3314
2968
  if (!this._stream) {
3315
- log12.warn("ignoring message on a closed channel", void 0, {
3316
- F: __dxlog_file13,
3317
- L: 124,
2969
+ log9.warn("ignoring message on a closed channel", void 0, {
2970
+ F: __dxlog_file10,
2971
+ L: 123,
3318
2972
  S: this,
3319
2973
  C: (f, a) => f(...a)
3320
2974
  });
@@ -3343,9 +2997,9 @@ var RtcTransportChannel = class extends Resource {
3343
2997
  }
3344
2998
  async _handleChannelWrite(chunk, callback) {
3345
2999
  if (!this._channel) {
3346
- log12.warn("writing to a channel after a connection was closed", void 0, {
3347
- F: __dxlog_file13,
3348
- L: 154,
3000
+ log9.warn("writing to a channel after a connection was closed", void 0, {
3001
+ F: __dxlog_file10,
3002
+ L: 153,
3349
3003
  S: this,
3350
3004
  C: (f, a) => f(...a)
3351
3005
  });
@@ -3366,9 +3020,9 @@ var RtcTransportChannel = class extends Resource {
3366
3020
  }
3367
3021
  if (this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT) {
3368
3022
  if (this._streamDataFlushedCallback !== null) {
3369
- log12.error("consumer trying to write before we are ready for more data", void 0, {
3370
- F: __dxlog_file13,
3371
- L: 175,
3023
+ log9.error("consumer trying to write before we are ready for more data", void 0, {
3024
+ F: __dxlog_file10,
3025
+ L: 174,
3372
3026
  S: this,
3373
3027
  C: (f, a) => f(...a)
3374
3028
  });
@@ -3382,9 +3036,9 @@ var RtcTransportChannel = class extends Resource {
3382
3036
  try {
3383
3037
  channel.close();
3384
3038
  } catch (error) {
3385
- log12.catch(error, void 0, {
3386
- F: __dxlog_file13,
3387
- L: 187,
3039
+ log9.catch(error, void 0, {
3040
+ F: __dxlog_file10,
3041
+ L: 186,
3388
3042
  S: this,
3389
3043
  C: (f, a) => f(...a)
3390
3044
  });
@@ -3434,7 +3088,7 @@ function _ts_decorate6(decorators, target, key, desc) {
3434
3088
  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
3089
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3436
3090
  }
3437
- var __dxlog_file14 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-peer-connection.ts";
3091
+ var __dxlog_file11 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-peer-connection.ts";
3438
3092
  var RtcPeerConnection = class {
3439
3093
  _factory;
3440
3094
  _options;
@@ -3482,9 +3136,9 @@ var RtcPeerConnection = class {
3482
3136
  if (existingChannel) {
3483
3137
  return existingChannel;
3484
3138
  }
3485
- log13("waiting for initiator-peer to open a data channel", void 0, {
3486
- F: __dxlog_file14,
3487
- L: 96,
3139
+ log10("waiting for initiator-peer to open a data channel", void 0, {
3140
+ F: __dxlog_file11,
3141
+ L: 95,
3488
3142
  S: this,
3489
3143
  C: (f, a) => f(...a)
3490
3144
  });
@@ -3511,11 +3165,11 @@ var RtcPeerConnection = class {
3511
3165
  if (this._connection) {
3512
3166
  return this._connection;
3513
3167
  }
3514
- log13("initializing connection...", () => ({
3168
+ log10("initializing connection...", () => ({
3515
3169
  remotePeer: this._options.remotePeerKey
3516
3170
  }), {
3517
- F: __dxlog_file14,
3518
- L: 121,
3171
+ F: __dxlog_file11,
3172
+ L: 120,
3519
3173
  S: this,
3520
3174
  C: (f, a) => f(...a)
3521
3175
  });
@@ -3524,9 +3178,9 @@ var RtcPeerConnection = class {
3524
3178
  const iceCandidateErrors = [];
3525
3179
  Object.assign(connection, {
3526
3180
  onnegotiationneeded: async () => {
3527
- invariant12(this._initiator, void 0, {
3528
- F: __dxlog_file14,
3529
- L: 136,
3181
+ invariant10(this._initiator, void 0, {
3182
+ F: __dxlog_file11,
3183
+ L: 135,
3530
3184
  S: this,
3531
3185
  A: [
3532
3186
  "this._initiator",
@@ -3537,9 +3191,9 @@ var RtcPeerConnection = class {
3537
3191
  this._onConnectionCallbackAfterClose("onnegotiationneeded", connection);
3538
3192
  return;
3539
3193
  }
3540
- log13("onnegotiationneeded", void 0, {
3541
- F: __dxlog_file14,
3542
- L: 143,
3194
+ log10("onnegotiationneeded", void 0, {
3195
+ F: __dxlog_file11,
3196
+ L: 142,
3543
3197
  S: this,
3544
3198
  C: (f, a) => f(...a)
3545
3199
  });
@@ -3559,19 +3213,19 @@ var RtcPeerConnection = class {
3559
3213
  return;
3560
3214
  }
3561
3215
  if (event.candidate) {
3562
- log13("onicecandidate", {
3216
+ log10("onicecandidate", {
3563
3217
  candidate: event.candidate.candidate
3564
3218
  }, {
3565
- F: __dxlog_file14,
3566
- L: 162,
3219
+ F: __dxlog_file11,
3220
+ L: 161,
3567
3221
  S: this,
3568
3222
  C: (f, a) => f(...a)
3569
3223
  });
3570
3224
  await this._sendIceCandidate(event.candidate);
3571
3225
  } else {
3572
- log13("onicecandidate gathering complete", void 0, {
3573
- F: __dxlog_file14,
3574
- L: 165,
3226
+ log10("onicecandidate gathering complete", void 0, {
3227
+ F: __dxlog_file11,
3228
+ L: 164,
3575
3229
  S: this,
3576
3230
  C: (f, a) => f(...a)
3577
3231
  });
@@ -3595,11 +3249,11 @@ var RtcPeerConnection = class {
3595
3249
  this._onConnectionCallbackAfterClose("oniceconnectionstatechange", connection);
3596
3250
  return;
3597
3251
  }
3598
- log13("oniceconnectionstatechange", {
3252
+ log10("oniceconnectionstatechange", {
3599
3253
  state: connection.iceConnectionState
3600
3254
  }, {
3601
- F: __dxlog_file14,
3602
- L: 185,
3255
+ F: __dxlog_file11,
3256
+ L: 184,
3603
3257
  S: this,
3604
3258
  C: (f, a) => f(...a)
3605
3259
  });
@@ -3617,11 +3271,11 @@ var RtcPeerConnection = class {
3617
3271
  }
3618
3272
  return;
3619
3273
  }
3620
- log13("onconnectionstatechange", {
3274
+ log10("onconnectionstatechange", {
3621
3275
  state: connection.connectionState
3622
3276
  }, {
3623
- F: __dxlog_file14,
3624
- L: 202,
3277
+ F: __dxlog_file11,
3278
+ L: 201,
3625
3279
  S: this,
3626
3280
  C: (f, a) => f(...a)
3627
3281
  });
@@ -3630,11 +3284,11 @@ var RtcPeerConnection = class {
3630
3284
  }
3631
3285
  },
3632
3286
  onsignalingstatechange: () => {
3633
- log13("onsignalingstatechange", {
3287
+ log10("onsignalingstatechange", {
3634
3288
  state: connection.signalingState
3635
3289
  }, {
3636
- F: __dxlog_file14,
3637
- L: 209,
3290
+ F: __dxlog_file11,
3291
+ L: 208,
3638
3292
  S: this,
3639
3293
  C: (f, a) => f(...a)
3640
3294
  });
@@ -3642,9 +3296,9 @@ var RtcPeerConnection = class {
3642
3296
  // When channel is added to connection.
3643
3297
  // https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/datachannel_event
3644
3298
  ondatachannel: (event) => {
3645
- invariant12(!this._initiator, "Initiator is expected to create data channels.", {
3646
- F: __dxlog_file14,
3647
- L: 215,
3299
+ invariant10(!this._initiator, "Initiator is expected to create data channels.", {
3300
+ F: __dxlog_file11,
3301
+ L: 214,
3648
3302
  S: this,
3649
3303
  A: [
3650
3304
  "!this._initiator",
@@ -3655,11 +3309,11 @@ var RtcPeerConnection = class {
3655
3309
  this._onConnectionCallbackAfterClose("ondatachannel", connection);
3656
3310
  return;
3657
3311
  }
3658
- log13("ondatachannel", {
3312
+ log10("ondatachannel", {
3659
3313
  label: event.channel.label
3660
3314
  }, {
3661
- F: __dxlog_file14,
3662
- L: 222,
3315
+ F: __dxlog_file11,
3316
+ L: 221,
3663
3317
  S: this,
3664
3318
  C: (f, a) => f(...a)
3665
3319
  });
@@ -3683,11 +3337,11 @@ var RtcPeerConnection = class {
3683
3337
  }
3684
3338
  _abortConnection(connection, error) {
3685
3339
  if (connection !== this._connection) {
3686
- log13.error("attempted to abort an inactive connection", {
3340
+ log10.error("attempted to abort an inactive connection", {
3687
3341
  error
3688
3342
  }, {
3689
- F: __dxlog_file14,
3690
- L: 247,
3343
+ F: __dxlog_file11,
3344
+ L: 246,
3691
3345
  S: this,
3692
3346
  C: (f, a) => f(...a)
3693
3347
  });
@@ -3704,19 +3358,19 @@ var RtcPeerConnection = class {
3704
3358
  }
3705
3359
  this._transportChannels.clear();
3706
3360
  this._safeCloseConnection();
3707
- log13("connection aborted", {
3361
+ log10("connection aborted", {
3708
3362
  reason: error.message
3709
3363
  }, {
3710
- F: __dxlog_file14,
3711
- L: 261,
3364
+ F: __dxlog_file11,
3365
+ L: 260,
3712
3366
  S: this,
3713
3367
  C: (f, a) => f(...a)
3714
3368
  });
3715
3369
  }
3716
3370
  async _lockAndCloseConnection() {
3717
- invariant12(this._transportChannels.size === 0, void 0, {
3718
- F: __dxlog_file14,
3719
- L: 266,
3371
+ invariant10(this._transportChannels.size === 0, void 0, {
3372
+ F: __dxlog_file11,
3373
+ L: 265,
3720
3374
  S: this,
3721
3375
  A: [
3722
3376
  "this._transportChannels.size === 0",
@@ -3725,9 +3379,9 @@ var RtcPeerConnection = class {
3725
3379
  });
3726
3380
  if (this._connection) {
3727
3381
  this._safeCloseConnection();
3728
- log13("connection closed", void 0, {
3729
- F: __dxlog_file14,
3730
- L: 269,
3382
+ log10("connection closed", void 0, {
3383
+ F: __dxlog_file11,
3384
+ L: 268,
3731
3385
  S: this,
3732
3386
  C: (f, a) => f(...a)
3733
3387
  });
@@ -3736,11 +3390,11 @@ var RtcPeerConnection = class {
3736
3390
  async onSignal(signal) {
3737
3391
  const connection = this._connection;
3738
3392
  if (!connection) {
3739
- log13.warn("a signal ignored because the connection was closed", {
3393
+ log10.warn("a signal ignored because the connection was closed", {
3740
3394
  type: signal.payload.data.type
3741
3395
  }, {
3742
- F: __dxlog_file14,
3743
- L: 277,
3396
+ F: __dxlog_file11,
3397
+ L: 276,
3744
3398
  S: this,
3745
3399
  C: (f, a) => f(...a)
3746
3400
  });
@@ -3803,11 +3457,11 @@ var RtcPeerConnection = class {
3803
3457
  this._abortConnection(connection, new Error(`Unknown signal type ${data.type}.`));
3804
3458
  break;
3805
3459
  }
3806
- log13("signal processed", {
3460
+ log10("signal processed", {
3807
3461
  type: data.type
3808
3462
  }, {
3809
- F: __dxlog_file14,
3810
- L: 336,
3463
+ F: __dxlog_file11,
3464
+ L: 335,
3811
3465
  S: this,
3812
3466
  C: (f, a) => f(...a)
3813
3467
  });
@@ -3816,20 +3470,20 @@ var RtcPeerConnection = class {
3816
3470
  try {
3817
3471
  await this._readyForCandidates.wait();
3818
3472
  if (connection === this._connection) {
3819
- log13("adding ice candidate", {
3473
+ log10("adding ice candidate", {
3820
3474
  candidate
3821
3475
  }, {
3822
- F: __dxlog_file14,
3823
- L: 344,
3476
+ F: __dxlog_file11,
3477
+ L: 343,
3824
3478
  S: this,
3825
3479
  C: (f, a) => f(...a)
3826
3480
  });
3827
3481
  await connection.addIceCandidate(candidate);
3828
3482
  }
3829
3483
  } catch (err) {
3830
- log13.catch(err, void 0, {
3831
- F: __dxlog_file14,
3832
- L: 348,
3484
+ log10.catch(err, void 0, {
3485
+ F: __dxlog_file11,
3486
+ L: 347,
3833
3487
  S: this,
3834
3488
  C: (f, a) => f(...a)
3835
3489
  });
@@ -3837,29 +3491,29 @@ var RtcPeerConnection = class {
3837
3491
  }
3838
3492
  _onSessionNegotiated(connection) {
3839
3493
  if (connection === this._connection) {
3840
- log13("ready to process ice candidates", void 0, {
3841
- F: __dxlog_file14,
3842
- L: 354,
3494
+ log10("ready to process ice candidates", void 0, {
3495
+ F: __dxlog_file11,
3496
+ L: 353,
3843
3497
  S: this,
3844
3498
  C: (f, a) => f(...a)
3845
3499
  });
3846
3500
  this._readyForCandidates.wake();
3847
3501
  } else {
3848
- log13.warn("session was negotiated after connection became inactive", void 0, {
3849
- F: __dxlog_file14,
3850
- L: 357,
3502
+ log10.warn("session was negotiated after connection became inactive", void 0, {
3503
+ F: __dxlog_file11,
3504
+ L: 356,
3851
3505
  S: this,
3852
3506
  C: (f, a) => f(...a)
3853
3507
  });
3854
3508
  }
3855
3509
  }
3856
3510
  _onConnectionCallbackAfterClose(callback, connection) {
3857
- log13.warn("callback invoked after a connection was destroyed, this is probably a bug", {
3511
+ log10.warn("callback invoked after a connection was destroyed, this is probably a bug", {
3858
3512
  callback,
3859
3513
  state: connection.connectionState
3860
3514
  }, {
3861
- F: __dxlog_file14,
3862
- L: 362,
3515
+ F: __dxlog_file11,
3516
+ L: 361,
3863
3517
  S: this,
3864
3518
  C: (f, a) => f(...a)
3865
3519
  });
@@ -3870,9 +3524,9 @@ var RtcPeerConnection = class {
3870
3524
  try {
3871
3525
  connection?.close();
3872
3526
  } catch (err) {
3873
- log13.catch(err, void 0, {
3874
- F: __dxlog_file14,
3875
- L: 374,
3527
+ log10.catch(err, void 0, {
3528
+ F: __dxlog_file11,
3529
+ L: 373,
3876
3530
  S: this,
3877
3531
  C: (f, a) => f(...a)
3878
3532
  });
@@ -3881,9 +3535,9 @@ var RtcPeerConnection = class {
3881
3535
  this._connection = void 0;
3882
3536
  this._dataChannels.clear();
3883
3537
  this._readyForCandidates.wake();
3884
- void this._factory.onConnectionDestroyed().catch((err) => log13.catch(err, void 0, {
3885
- F: __dxlog_file14,
3886
- L: 380,
3538
+ void this._factory.onConnectionDestroyed().catch((err) => log10.catch(err, void 0, {
3539
+ F: __dxlog_file11,
3540
+ L: 379,
3887
3541
  S: this,
3888
3542
  C: (f, a) => f(...a)
3889
3543
  }));
@@ -3906,9 +3560,9 @@ var RtcPeerConnection = class {
3906
3560
  ];
3907
3561
  }
3908
3562
  } catch (error) {
3909
- log13.catch(error, void 0, {
3910
- F: __dxlog_file14,
3911
- L: 396,
3563
+ log10.catch(error, void 0, {
3564
+ F: __dxlog_file11,
3565
+ L: 395,
3912
3566
  S: this,
3913
3567
  C: (f, a) => f(...a)
3914
3568
  });
@@ -3931,11 +3585,11 @@ var RtcPeerConnection = class {
3931
3585
  }
3932
3586
  });
3933
3587
  } catch (err) {
3934
- log13.warn("signaling error", {
3588
+ log10.warn("signaling error", {
3935
3589
  err
3936
3590
  }, {
3937
- F: __dxlog_file14,
3938
- L: 417,
3591
+ F: __dxlog_file11,
3592
+ L: 416,
3939
3593
  S: this,
3940
3594
  C: (f, a) => f(...a)
3941
3595
  });
@@ -4041,13 +3695,13 @@ import { Writable } from "@dxos/node-std/stream";
4041
3695
  import { Event as Event8, scheduleTask as scheduleTask4 } from "@dxos/async";
4042
3696
  import { Resource as Resource2 } from "@dxos/context";
4043
3697
  import { ErrorStream as ErrorStream5 } from "@dxos/debug";
4044
- import { invariant as invariant13 } from "@dxos/invariant";
3698
+ import { invariant as invariant11 } from "@dxos/invariant";
4045
3699
  import { PublicKey as PublicKey10 } from "@dxos/keys";
4046
- import { log as log14 } from "@dxos/log";
3700
+ import { log as log11 } from "@dxos/log";
4047
3701
  import { ConnectionResetError as ConnectionResetError2, ConnectivityError as ConnectivityError4, TimeoutError as TimeoutError3 } from "@dxos/protocols";
4048
3702
  import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
4049
3703
  import { arrayToBuffer } from "@dxos/util";
4050
- var __dxlog_file15 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-proxy.ts";
3704
+ var __dxlog_file12 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-proxy.ts";
4051
3705
  var RPC_TIMEOUT = 1e4;
4052
3706
  var CLOSE_RPC_TIMEOUT = 3e3;
4053
3707
  var RESP_MIN_THRESHOLD = 500;
@@ -4080,8 +3734,8 @@ var RtcTransportProxy = class extends Resource2 {
4080
3734
  this._serviceStream = stream;
4081
3735
  stream.waitUntilReady().then(() => {
4082
3736
  stream.subscribe(async (event) => {
4083
- log14("rtc transport proxy event", event, {
4084
- F: __dxlog_file15,
3737
+ log11("rtc transport proxy event", event, {
3738
+ F: __dxlog_file12,
4085
3739
  L: 66,
4086
3740
  S: this,
4087
3741
  C: (f, a) => f(...a)
@@ -4094,10 +3748,10 @@ var RtcTransportProxy = class extends Resource2 {
4094
3748
  await this._handleSignal(event.signal);
4095
3749
  }
4096
3750
  }, (err) => {
4097
- log14("rtc bridge stream closed", {
3751
+ log11("rtc bridge stream closed", {
4098
3752
  err
4099
3753
  }, {
4100
- F: __dxlog_file15,
3754
+ F: __dxlog_file12,
4101
3755
  L: 76,
4102
3756
  S: this,
4103
3757
  C: (f, a) => f(...a)
@@ -4118,8 +3772,8 @@ var RtcTransportProxy = class extends Resource2 {
4118
3772
  timeout: RPC_TIMEOUT
4119
3773
  }).then(() => {
4120
3774
  if (Date.now() - sendStartMs > RESP_MIN_THRESHOLD) {
4121
- log14("slow response, delaying callback", void 0, {
4122
- F: __dxlog_file15,
3775
+ log11("slow response, delaying callback", void 0, {
3776
+ F: __dxlog_file12,
4123
3777
  L: 93,
4124
3778
  S: this,
4125
3779
  C: (f, a) => f(...a)
@@ -4151,8 +3805,8 @@ var RtcTransportProxy = class extends Resource2 {
4151
3805
  await this._serviceStream?.close();
4152
3806
  this._serviceStream = void 0;
4153
3807
  } catch (err) {
4154
- log14.catch(err, void 0, {
4155
- F: __dxlog_file15,
3808
+ log11.catch(err, void 0, {
3809
+ F: __dxlog_file12,
4156
3810
  L: 128,
4157
3811
  S: this,
4158
3812
  C: (f, a) => f(...a)
@@ -4165,8 +3819,8 @@ var RtcTransportProxy = class extends Resource2 {
4165
3819
  timeout: CLOSE_RPC_TIMEOUT
4166
3820
  });
4167
3821
  } catch (err) {
4168
- log14.catch(err, void 0, {
4169
- F: __dxlog_file15,
3822
+ log11.catch(err, void 0, {
3823
+ F: __dxlog_file12,
4170
3824
  L: 134,
4171
3825
  S: this,
4172
3826
  C: (f, a) => f(...a)
@@ -4251,10 +3905,10 @@ var RtcTransportProxy = class extends Resource2 {
4251
3905
  if (this.isOpen) {
4252
3906
  this.errors.raise(error);
4253
3907
  } else {
4254
- log14.info("error swallowed because transport was closed", {
3908
+ log11.info("error swallowed because transport was closed", {
4255
3909
  message: error.message
4256
3910
  }, {
4257
- F: __dxlog_file15,
3911
+ F: __dxlog_file12,
4258
3912
  L: 217,
4259
3913
  S: this,
4260
3914
  C: (f, a) => f(...a)
@@ -4284,8 +3938,8 @@ var RtcTransportProxyFactory = class {
4284
3938
  return this;
4285
3939
  }
4286
3940
  createTransport(options) {
4287
- invariant13(this._bridgeService, "RtcTransportProxyFactory is not ready to open connections", {
4288
- F: __dxlog_file15,
3941
+ invariant11(this._bridgeService, "RtcTransportProxyFactory is not ready to open connections", {
3942
+ F: __dxlog_file12,
4289
3943
  L: 247,
4290
3944
  S: this,
4291
3945
  A: [
@@ -4326,12 +3980,12 @@ var decodeError = (err) => {
4326
3980
  // src/transport/webrtc/rtc-transport-service.ts
4327
3981
  import { Duplex as Duplex2 } from "@dxos/node-std/stream";
4328
3982
  import { Stream } from "@dxos/codec-protobuf/stream";
4329
- import { invariant as invariant14 } from "@dxos/invariant";
3983
+ import { invariant as invariant12 } from "@dxos/invariant";
4330
3984
  import { PublicKey as PublicKey11 } from "@dxos/keys";
4331
- import { log as log15 } from "@dxos/log";
3985
+ import { log as log12 } from "@dxos/log";
4332
3986
  import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
4333
3987
  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";
3988
+ var __dxlog_file13 = "/__w/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc/rtc-transport-service.ts";
4335
3989
  var RtcTransportService = class {
4336
3990
  _transportFactory;
4337
3991
  _openTransports = new ComplexMap8(PublicKey11.hash);
@@ -4344,9 +3998,9 @@ var RtcTransportService = class {
4344
3998
  open(request) {
4345
3999
  const existingTransport = this._openTransports.get(request.proxyId);
4346
4000
  if (existingTransport) {
4347
- log15.error("requesting a new transport bridge for an existing proxy", void 0, {
4348
- F: __dxlog_file16,
4349
- L: 54,
4001
+ log12.error("requesting a new transport bridge for an existing proxy", void 0, {
4002
+ F: __dxlog_file13,
4003
+ L: 53,
4350
4004
  S: this,
4351
4005
  C: (f, a) => f(...a)
4352
4006
  });
@@ -4410,9 +4064,9 @@ var RtcTransportService = class {
4410
4064
  close(err);
4411
4065
  });
4412
4066
  ready();
4413
- log15("stream ready", void 0, {
4414
- F: __dxlog_file16,
4415
- L: 116,
4067
+ log12("stream ready", void 0, {
4068
+ F: __dxlog_file13,
4069
+ L: 115,
4416
4070
  S: this,
4417
4071
  C: (f, a) => f(...a)
4418
4072
  });
@@ -4421,9 +4075,9 @@ var RtcTransportService = class {
4421
4075
  }
4422
4076
  async sendSignal({ proxyId, signal }) {
4423
4077
  const transport = this._openTransports.get(proxyId);
4424
- invariant14(transport, void 0, {
4425
- F: __dxlog_file16,
4426
- L: 124,
4078
+ invariant12(transport, void 0, {
4079
+ F: __dxlog_file13,
4080
+ L: 123,
4427
4081
  S: this,
4428
4082
  A: [
4429
4083
  "transport",
@@ -4434,9 +4088,9 @@ var RtcTransportService = class {
4434
4088
  }
4435
4089
  async getDetails({ proxyId }) {
4436
4090
  const transport = this._openTransports.get(proxyId);
4437
- invariant14(transport, void 0, {
4438
- F: __dxlog_file16,
4439
- L: 131,
4091
+ invariant12(transport, void 0, {
4092
+ F: __dxlog_file13,
4093
+ L: 130,
4440
4094
  S: this,
4441
4095
  A: [
4442
4096
  "transport",
@@ -4449,9 +4103,9 @@ var RtcTransportService = class {
4449
4103
  }
4450
4104
  async getStats({ proxyId }) {
4451
4105
  const transport = this._openTransports.get(proxyId);
4452
- invariant14(transport, void 0, {
4453
- F: __dxlog_file16,
4454
- L: 138,
4106
+ invariant12(transport, void 0, {
4107
+ F: __dxlog_file13,
4108
+ L: 137,
4455
4109
  S: this,
4456
4110
  A: [
4457
4111
  "transport",
@@ -4464,9 +4118,9 @@ var RtcTransportService = class {
4464
4118
  }
4465
4119
  async sendData({ proxyId, payload }) {
4466
4120
  const transport = this._openTransports.get(proxyId);
4467
- invariant14(transport, void 0, {
4468
- F: __dxlog_file16,
4469
- L: 145,
4121
+ invariant12(transport, void 0, {
4122
+ F: __dxlog_file13,
4123
+ L: 144,
4470
4124
  S: this,
4471
4125
  A: [
4472
4126
  "transport",
@@ -4496,11 +4150,11 @@ var RtcTransportService = class {
4496
4150
  try {
4497
4151
  await transport.transport.close();
4498
4152
  } catch (error) {
4499
- log15.warn("transport close error", {
4153
+ log12.warn("transport close error", {
4500
4154
  message: error?.message
4501
4155
  }, {
4502
- F: __dxlog_file16,
4503
- L: 175,
4156
+ F: __dxlog_file13,
4157
+ L: 174,
4504
4158
  S: this,
4505
4159
  C: (f, a) => f(...a)
4506
4160
  });
@@ -4508,18 +4162,18 @@ var RtcTransportService = class {
4508
4162
  try {
4509
4163
  transport.connectorStream.end();
4510
4164
  } catch (error) {
4511
- log15.warn("connectorStream close error", {
4165
+ log12.warn("connectorStream close error", {
4512
4166
  message: error?.message
4513
4167
  }, {
4514
- F: __dxlog_file16,
4515
- L: 180,
4168
+ F: __dxlog_file13,
4169
+ L: 179,
4516
4170
  S: this,
4517
4171
  C: (f, a) => f(...a)
4518
4172
  });
4519
4173
  }
4520
- log15("closed", void 0, {
4521
- F: __dxlog_file16,
4522
- L: 182,
4174
+ log12("closed", void 0, {
4175
+ F: __dxlog_file13,
4176
+ L: 181,
4523
4177
  S: this,
4524
4178
  C: (f, a) => f(...a)
4525
4179
  });
@@ -4540,10 +4194,10 @@ var createStateUpdater = (next) => {
4540
4194
 
4541
4195
  // src/wire-protocol.ts
4542
4196
  import { Teleport } from "@dxos/teleport";
4543
- var createTeleportProtocolFactory = (onConnection, defaultParams) => {
4197
+ var createTeleportProtocolFactory = (onConnection, defaultProps) => {
4544
4198
  return (params) => {
4545
4199
  const teleport = new Teleport({
4546
- ...defaultParams,
4200
+ ...defaultProps,
4547
4201
  ...params
4548
4202
  });
4549
4203
  return {
@@ -4565,7 +4219,6 @@ var createTeleportProtocolFactory = (onConnection, defaultParams) => {
4565
4219
  export {
4566
4220
  ConnectionState,
4567
4221
  Connection,
4568
- createIceProvider,
4569
4222
  SwarmMessenger,
4570
4223
  Swarm,
4571
4224
  SwarmMapper,
@@ -4575,8 +4228,6 @@ export {
4575
4228
  ConnectionLog,
4576
4229
  SwarmNetworkManager,
4577
4230
  FullyConnectedTopology,
4578
- MMSTTopology,
4579
- StarTopology,
4580
4231
  MemoryTransportFactory,
4581
4232
  MemoryTransport,
4582
4233
  TransportKind,
@@ -4586,4 +4237,4 @@ export {
4586
4237
  RtcTransportService,
4587
4238
  createTeleportProtocolFactory
4588
4239
  };
4589
- //# sourceMappingURL=chunk-5ISEIDVN.mjs.map
4240
+ //# sourceMappingURL=chunk-Y2FDDNGM.mjs.map