@dxos/network-manager 0.1.16 → 0.1.18

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 (60) hide show
  1. package/dist/lib/browser/index.mjs +144 -276
  2. package/dist/lib/browser/meta.json +1 -1
  3. package/dist/lib/browser/testing/index.mjs +153 -342
  4. package/dist/lib/node/index.cjs +145 -281
  5. package/dist/lib/node/meta.json +1 -1
  6. package/dist/lib/node/testing/index.cjs +153 -345
  7. package/dist/types/src/index.d.ts +0 -1
  8. package/dist/types/src/index.d.ts.map +1 -1
  9. package/dist/types/src/network-manager.d.ts +1 -5
  10. package/dist/types/src/network-manager.d.ts.map +1 -1
  11. package/dist/types/src/swarm/connection.d.ts +4 -0
  12. package/dist/types/src/swarm/connection.d.ts.map +1 -1
  13. package/dist/types/src/swarm/peer.d.ts.map +1 -1
  14. package/dist/types/src/swarm/swarm-mapper.d.ts +1 -3
  15. package/dist/types/src/swarm/swarm-mapper.d.ts.map +1 -1
  16. package/dist/types/src/testing/index.d.ts +0 -1
  17. package/dist/types/src/testing/index.d.ts.map +1 -1
  18. package/dist/types/src/testing/test-builder.d.ts +2 -2
  19. package/dist/types/src/testing/test-builder.d.ts.map +1 -1
  20. package/dist/types/src/testing/test-wire-protocol.d.ts +14 -0
  21. package/dist/types/src/testing/test-wire-protocol.d.ts.map +1 -0
  22. package/dist/types/src/tests/basic-test-suite.d.ts.map +1 -1
  23. package/dist/types/src/tests/property-test-suite.d.ts.map +1 -1
  24. package/dist/types/src/tests/utils.d.ts.map +1 -1
  25. package/dist/types/src/transport/memory-transport.d.ts +3 -3
  26. package/dist/types/src/transport/memory-transport.d.ts.map +1 -1
  27. package/dist/types/src/wire-protocol.d.ts +0 -10
  28. package/dist/types/src/wire-protocol.d.ts.map +1 -1
  29. package/package.json +16 -18
  30. package/src/connection-log.ts +26 -26
  31. package/src/index.ts +0 -1
  32. package/src/network-manager.ts +1 -8
  33. package/src/swarm/connection.ts +12 -1
  34. package/src/swarm/peer.ts +1 -3
  35. package/src/swarm/swarm-mapper.ts +29 -31
  36. package/src/swarm/swarm.test.ts +12 -34
  37. package/src/testing/index.ts +0 -1
  38. package/src/testing/test-builder.ts +4 -7
  39. package/src/testing/test-wire-protocol.ts +44 -0
  40. package/src/tests/basic-test-suite.ts +13 -53
  41. package/src/tests/property-test-suite.ts +13 -15
  42. package/src/tests/utils.ts +10 -37
  43. package/src/transport/memory-transport.test.ts +13 -52
  44. package/src/transport/memory-transport.ts +37 -29
  45. package/src/transport/webrtc-transport-proxy.test.ts +13 -73
  46. package/src/transport/webrtc-transport.test.ts +7 -38
  47. package/src/wire-protocol.ts +0 -24
  48. package/dist/lib/browser/index.mjs.map +0 -7
  49. package/dist/lib/browser/testing/index.mjs.map +0 -7
  50. package/dist/lib/node/index.cjs.map +0 -7
  51. package/dist/lib/node/testing/index.cjs.map +0 -7
  52. package/dist/types/src/protocol-factory.d.ts +0 -36
  53. package/dist/types/src/protocol-factory.d.ts.map +0 -1
  54. package/dist/types/src/testing/test-protocol.d.ts +0 -52
  55. package/dist/types/src/testing/test-protocol.d.ts.map +0 -1
  56. package/dist/types/src/tests/presence.test.d.ts +0 -2
  57. package/dist/types/src/tests/presence.test.d.ts.map +0 -1
  58. package/src/protocol-factory.ts +0 -88
  59. package/src/testing/test-protocol.ts +0 -166
  60. package/src/tests/presence.test.ts +0 -80
@@ -43,12 +43,8 @@ __export(src_exports, {
43
43
  WebRTCTransportProxy: () => WebRTCTransportProxy,
44
44
  WebRTCTransportProxyFactory: () => WebRTCTransportProxyFactory,
45
45
  WebRTCTransportService: () => WebRTCTransportService,
46
- adaptProtocolProvider: () => adaptProtocolProvider,
47
- createProtocolFactory: () => createProtocolFactory,
48
46
  createTeleportProtocolFactory: () => createTeleportProtocolFactory,
49
- createWebRTCTransportFactory: () => createWebRTCTransportFactory,
50
- protocolFactory: () => protocolFactory,
51
- transportProtocolProvider: () => transportProtocolProvider
47
+ createWebRTCTransportFactory: () => createWebRTCTransportFactory
52
48
  });
53
49
  module.exports = __toCommonJS(src_exports);
54
50
 
@@ -78,6 +74,7 @@ var ConnectionState;
78
74
  ConnectionState4["INITIAL"] = "INITIAL";
79
75
  ConnectionState4["CONNECTING"] = "CONNECTING";
80
76
  ConnectionState4["CONNECTED"] = "CONNECTED";
77
+ ConnectionState4["CLOSING"] = "CLOSING";
81
78
  ConnectionState4["CLOSED"] = "CLOSED";
82
79
  })(ConnectionState || (ConnectionState = {}));
83
80
  var Connection = class {
@@ -133,7 +130,11 @@ var Connection = class {
133
130
  this._transport = void 0;
134
131
  this.close().catch((err) => this.errors.raise(err));
135
132
  });
136
- this._transport.errors.pipeTo(this.errors);
133
+ this._transport.errors.handle((err) => {
134
+ if (this._state !== ConnectionState.CLOSED && this._state !== ConnectionState.CLOSING) {
135
+ this.errors.raise(err);
136
+ }
137
+ });
137
138
  for (const signal of this._bufferedSignals) {
138
139
  void this._transport.signal(signal);
139
140
  }
@@ -144,11 +145,12 @@ var Connection = class {
144
145
  if (this._state === ConnectionState.CLOSED) {
145
146
  return;
146
147
  }
148
+ this._changeState(ConnectionState.CLOSING);
147
149
  (0, import_log.log)("closing...", {
148
150
  peerId: this.ownId
149
151
  }, {
150
152
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts",
151
- line: 131,
153
+ line: 142,
152
154
  scope: this,
153
155
  callSite: (f, a) => f(...a)
154
156
  });
@@ -157,7 +159,7 @@ var Connection = class {
157
159
  } catch (err) {
158
160
  import_log.log.catch(err, {}, {
159
161
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts",
160
- line: 137,
162
+ line: 148,
161
163
  scope: this,
162
164
  callSite: (f, a) => f(...a)
163
165
  });
@@ -167,7 +169,7 @@ var Connection = class {
167
169
  } catch (err1) {
168
170
  import_log.log.catch(err1, {}, {
169
171
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts",
170
- line: 144,
172
+ line: 155,
171
173
  scope: this,
172
174
  callSite: (f, a) => f(...a)
173
175
  });
@@ -176,7 +178,7 @@ var Connection = class {
176
178
  peerId: this.ownId
177
179
  }, {
178
180
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts",
179
- line: 147,
181
+ line: 158,
180
182
  scope: this,
181
183
  callSite: (f, a) => f(...a)
182
184
  });
@@ -188,7 +190,7 @@ var Connection = class {
188
190
  if (!msg.sessionId.equals(this.sessionId)) {
189
191
  (0, import_log.log)("dropping signal for incorrect session id", {}, {
190
192
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts",
191
- line: 154,
193
+ line: 165,
192
194
  scope: this,
193
195
  callSite: (f, a) => f(...a)
194
196
  });
@@ -204,7 +206,7 @@ var Connection = class {
204
206
  msg: msg.data
205
207
  }, {
206
208
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts",
207
- line: 162,
209
+ line: 173,
208
210
  scope: this,
209
211
  callSite: (f, a) => f(...a)
210
212
  });
@@ -218,7 +220,7 @@ var Connection = class {
218
220
  msg: msg.data
219
221
  }, {
220
222
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts",
221
- line: 168,
223
+ line: 179,
222
224
  scope: this,
223
225
  callSite: (f, a) => f(...a)
224
226
  });
@@ -625,14 +627,7 @@ var Peer = class {
625
627
  scope: this,
626
628
  callSite: (f, a) => f(...a)
627
629
  });
628
- void this.closeConnection().catch(() => {
629
- import_log3.log.catch(err, {}, {
630
- file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts",
631
- line: 207,
632
- scope: this,
633
- callSite: (f, a) => f(...a)
634
- });
635
- });
630
+ void this.closeConnection();
636
631
  });
637
632
  this.connection = connection;
638
633
  return connection;
@@ -647,7 +642,7 @@ var Peer = class {
647
642
  sessionId: connection.sessionId
648
643
  }, {
649
644
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts",
650
- line: 221,
645
+ line: 219,
651
646
  scope: this,
652
647
  callSite: (f, a) => f(...a)
653
648
  });
@@ -657,7 +652,7 @@ var Peer = class {
657
652
  sessionId: connection.sessionId
658
653
  }, {
659
654
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts",
660
- line: 227,
655
+ line: 225,
661
656
  scope: this,
662
657
  callSite: (f, a) => f(...a)
663
658
  });
@@ -668,7 +663,7 @@ var Peer = class {
668
663
  message
669
664
  }, {
670
665
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts",
671
- line: 232,
666
+ line: 230,
672
667
  scope: this,
673
668
  callSite: (f, a) => f(...a)
674
669
  });
@@ -683,7 +678,7 @@ var Peer = class {
683
678
  topic: this.topic
684
679
  }, {
685
680
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts",
686
- line: 240,
681
+ line: 238,
687
682
  scope: this,
688
683
  callSite: (f, a) => f(...a)
689
684
  });
@@ -1055,9 +1050,8 @@ var SwarmMapper = class {
1055
1050
  get peers() {
1056
1051
  return Array.from(this._peers.values());
1057
1052
  }
1058
- constructor(_swarm, _presence) {
1053
+ constructor(_swarm) {
1059
1054
  this._swarm = _swarm;
1060
- this._presence = _presence;
1061
1055
  this._subscriptions = new import_async4.EventSubscriptions();
1062
1056
  this._connectionSubscriptions = new import_util3.ComplexMap(import_keys4.PublicKey.hash);
1063
1057
  this._peers = new import_util3.ComplexMap(import_keys4.PublicKey.hash);
@@ -1074,17 +1068,12 @@ var SwarmMapper = class {
1074
1068
  this._connectionSubscriptions.delete(peerId);
1075
1069
  this._update();
1076
1070
  }));
1077
- if (_presence) {
1078
- this._subscriptions.add(_presence.graphUpdated.on(() => {
1079
- this._update();
1080
- }));
1081
- }
1082
1071
  this._update();
1083
1072
  }
1084
1073
  _update() {
1085
1074
  (0, import_log5.log)("updating swarm", {}, {
1086
1075
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts",
1087
- line: 77,
1076
+ line: 75,
1088
1077
  scope: this,
1089
1078
  callSite: (f, a) => f(...a)
1090
1079
  });
@@ -1103,32 +1092,12 @@ var SwarmMapper = class {
1103
1092
  ]
1104
1093
  });
1105
1094
  }
1106
- if (this._presence) {
1107
- this._presence.graph.forEachNode((node) => {
1108
- const id = import_keys4.PublicKey.fromHex(node.id);
1109
- if (this._peers.has(id)) {
1110
- return;
1111
- }
1112
- this._peers.set(id, {
1113
- id,
1114
- state: "INDIRECTLY_CONNECTED",
1115
- connections: []
1116
- });
1117
- });
1118
- this._presence.graph.forEachLink((link) => {
1119
- const from = import_keys4.PublicKey.from(link.fromId);
1120
- const to = import_keys4.PublicKey.from(link.toId);
1121
- if (!from.equals(this._swarm.ownPeerId) && !to.equals(this._swarm.ownPeerId)) {
1122
- this._peers.get(from).connections.push(to);
1123
- }
1124
- });
1125
- }
1126
1095
  (0, import_log5.log)("graph changed", {
1127
1096
  directConnections: this._swarm.connections.length,
1128
1097
  totalPeersInSwarm: this._peers.size
1129
1098
  }, {
1130
1099
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts",
1131
- line: 118,
1100
+ line: 116,
1132
1101
  scope: this,
1133
1102
  callSite: (f, a) => f(...a)
1134
1103
  });
@@ -1172,13 +1141,12 @@ var ConnectionLog = class {
1172
1141
  this._swarms.set(swarm.instanceId, info);
1173
1142
  this.update.emit();
1174
1143
  swarm.connectionAdded.on((connection) => {
1175
- var _a, _b, _c, _d, _e;
1176
1144
  const connectionInfo = {
1177
1145
  state: ConnectionState.INITIAL,
1178
1146
  remotePeerId: connection.remoteId,
1179
1147
  sessionId: connection.sessionId,
1180
1148
  transport: connection.transport && Object.getPrototypeOf(connection.transport).constructor.name,
1181
- protocolExtensions: (_a = connection.protocol.protocol) == null ? void 0 : _a.extensionNames,
1149
+ protocolExtensions: [],
1182
1150
  events: []
1183
1151
  };
1184
1152
  info.connections.push(connectionInfo);
@@ -1191,32 +1159,6 @@ var ConnectionLog = class {
1191
1159
  });
1192
1160
  this.update.emit();
1193
1161
  });
1194
- (_b = connection.protocol.protocol) == null ? void 0 : _b.error.on((error) => {
1195
- var _a2;
1196
- connectionInfo.events.push({
1197
- type: EventType.PROTOCOL_ERROR,
1198
- error: (_a2 = error.stack) != null ? _a2 : error.message
1199
- });
1200
- this.update.emit();
1201
- });
1202
- (_c = connection.protocol.protocol) == null ? void 0 : _c.extensionsInitialized.on(() => {
1203
- connectionInfo.events.push({
1204
- type: EventType.PROTOCOL_EXTENSIONS_INITIALIZED
1205
- });
1206
- this.update.emit();
1207
- });
1208
- (_d = connection.protocol.protocol) == null ? void 0 : _d.extensionsHandshake.on(() => {
1209
- connectionInfo.events.push({
1210
- type: EventType.PROTOCOL_EXTENSIONS_HANDSHAKE
1211
- });
1212
- this.update.emit();
1213
- });
1214
- (_e = connection.protocol.protocol) == null ? void 0 : _e.handshake.on(() => {
1215
- connectionInfo.events.push({
1216
- type: EventType.PROTOCOL_HANDSHAKE
1217
- });
1218
- this.update.emit();
1219
- });
1220
1162
  });
1221
1163
  }
1222
1164
  swarmLeft(swarm) {
@@ -1233,7 +1175,7 @@ var import_log6 = require("@dxos/log");
1233
1175
  var import_messaging = require("@dxos/messaging");
1234
1176
  var import_util5 = require("@dxos/util");
1235
1177
  var NetworkManager = class {
1236
- constructor({ transportFactory, signalManager, log: log14 }) {
1178
+ constructor({ transportFactory, signalManager, log: log13 }) {
1237
1179
  this._swarms = new import_util5.ComplexMap(import_keys6.PublicKey.hash);
1238
1180
  this._mappers = new import_util5.ComplexMap(import_keys6.PublicKey.hash);
1239
1181
  this.topicsUpdated = new import_async6.Event();
@@ -1250,7 +1192,7 @@ var NetworkManager = class {
1250
1192
  join: (opts) => this._signalManager.join(opts),
1251
1193
  leave: (opts) => this._signalManager.leave(opts)
1252
1194
  };
1253
- if (log14) {
1195
+ if (log13) {
1254
1196
  this._connectionLog = new ConnectionLog();
1255
1197
  }
1256
1198
  }
@@ -1274,7 +1216,7 @@ var NetworkManager = class {
1274
1216
  await this.leaveSwarm(topic).catch((err) => {
1275
1217
  (0, import_log6.log)(err, {}, {
1276
1218
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts",
1277
- line: 128,
1219
+ line: 122,
1278
1220
  scope: this,
1279
1221
  callSite: (f, a) => f(...a)
1280
1222
  });
@@ -1282,7 +1224,7 @@ var NetworkManager = class {
1282
1224
  }
1283
1225
  await this._signalManager.destroy();
1284
1226
  }
1285
- async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, presence, label }) {
1227
+ async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
1286
1228
  var _a;
1287
1229
  (0, import_node_assert5.default)(import_keys6.PublicKey.isPublicKey(topic));
1288
1230
  (0, import_node_assert5.default)(import_keys6.PublicKey.isPublicKey(peerId));
@@ -1297,7 +1239,7 @@ var NetworkManager = class {
1297
1239
  topology: topology.toString()
1298
1240
  }, {
1299
1241
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts",
1300
- line: 155,
1242
+ line: 148,
1301
1243
  scope: this,
1302
1244
  callSite: (f, a) => f(...a)
1303
1245
  });
@@ -1307,7 +1249,7 @@ var NetworkManager = class {
1307
1249
  error
1308
1250
  }, {
1309
1251
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts",
1310
- line: 158,
1252
+ line: 151,
1311
1253
  scope: this,
1312
1254
  callSite: (f, a) => f(...a)
1313
1255
  });
@@ -1318,11 +1260,11 @@ var NetworkManager = class {
1318
1260
  peerId
1319
1261
  }).catch((error) => import_log6.log.catch(error, {}, {
1320
1262
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts",
1321
- line: 162,
1263
+ line: 155,
1322
1264
  scope: this,
1323
1265
  callSite: (f, a) => f(...a)
1324
1266
  }));
1325
- this._mappers.set(topic, new SwarmMapper(swarm, presence));
1267
+ this._mappers.set(topic, new SwarmMapper(swarm));
1326
1268
  this.topicsUpdated.emit();
1327
1269
  (_a = this._connectionLog) == null ? void 0 : _a.swarmJoined(swarm);
1328
1270
  (0, import_log6.log)("joined", {
@@ -1330,7 +1272,7 @@ var NetworkManager = class {
1330
1272
  count: this._swarms.size
1331
1273
  }, {
1332
1274
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts",
1333
- line: 167,
1275
+ line: 160,
1334
1276
  scope: this,
1335
1277
  callSite: (f, a) => f(...a)
1336
1278
  });
@@ -1345,7 +1287,7 @@ var NetworkManager = class {
1345
1287
  topic: import_keys6.PublicKey.from(topic)
1346
1288
  }, {
1347
1289
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts",
1348
- line: 179,
1290
+ line: 172,
1349
1291
  scope: this,
1350
1292
  callSite: (f, a) => f(...a)
1351
1293
  });
@@ -1355,7 +1297,7 @@ var NetworkManager = class {
1355
1297
  topic: import_keys6.PublicKey.from(topic)
1356
1298
  }, {
1357
1299
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts",
1358
- line: 183,
1300
+ line: 176,
1359
1301
  scope: this,
1360
1302
  callSite: (f, a) => f(...a)
1361
1303
  });
@@ -1376,85 +1318,25 @@ var NetworkManager = class {
1376
1318
  count: this._swarms.size
1377
1319
  }, {
1378
1320
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts",
1379
- line: 197,
1321
+ line: 190,
1380
1322
  scope: this,
1381
1323
  callSite: (f, a) => f(...a)
1382
1324
  });
1383
1325
  }
1384
1326
  };
1385
1327
 
1386
- // packages/core/mesh/network-manager/src/protocol-factory.ts
1387
- var import_node_assert6 = __toESM(require("node:assert"));
1388
- var import_crypto = require("@dxos/crypto");
1389
- var import_keys7 = require("@dxos/keys");
1390
- var import_log7 = require("@dxos/log");
1391
- var import_mesh_protocol = require("@dxos/mesh-protocol");
1392
- var protocolFactory = ({ session = {}, plugins = [], getTopics }) => {
1393
- (0, import_node_assert6.default)(getTopics);
1394
- return ({ channel, initiator }) => {
1395
- (0, import_log7.log)("creating protocol", {}, {
1396
- file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/protocol-factory.ts",
1397
- line: 41,
1398
- scope: void 0,
1399
- callSite: (f, a) => f(...a)
1400
- });
1401
- const protocol = new import_mesh_protocol.Protocol({
1402
- streamOptions: {
1403
- live: true
1404
- },
1405
- discoveryToPublicKey: (dk) => {
1406
- const publicKey = getTopics().find((topic) => (0, import_crypto.discoveryKey)(topic).equals(dk));
1407
- if (publicKey) {
1408
- protocol.setContext({
1409
- topic: import_keys7.PublicKey.stringify(publicKey)
1410
- });
1411
- }
1412
- (0, import_node_assert6.default)(publicKey, "PublicKey not found in discovery.");
1413
- return publicKey;
1414
- },
1415
- initiator,
1416
- userSession: session,
1417
- discoveryKey: channel
1418
- });
1419
- protocol.setExtensions(plugins.map((plugin) => plugin.createExtension())).init();
1420
- return protocol;
1421
- };
1422
- };
1423
- var createProtocolFactory = (topic, peerId, plugins) => protocolFactory({
1424
- getTopics: () => [
1425
- topic.asBuffer()
1426
- ],
1427
- session: {
1428
- peerId: import_keys7.PublicKey.stringify(peerId.asBuffer())
1429
- },
1430
- plugins
1431
- });
1432
- var transportProtocolProvider = (rendezvousKey, peerId, protocolPlugin) => {
1433
- return protocolFactory({
1434
- getTopics: () => [
1435
- rendezvousKey
1436
- ],
1437
- session: {
1438
- peerId: import_keys7.PublicKey.stringify(peerId)
1439
- },
1440
- plugins: [
1441
- protocolPlugin
1442
- ]
1443
- });
1444
- };
1445
-
1446
1328
  // packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
1447
- var import_node_assert7 = __toESM(require("node:assert"));
1329
+ var import_node_assert6 = __toESM(require("node:assert"));
1448
1330
  var FullyConnectedTopology = class {
1449
1331
  toString() {
1450
1332
  return "FullyConnectedTopology";
1451
1333
  }
1452
1334
  init(controller) {
1453
- (0, import_node_assert7.default)(!this._controller, "Already initialized");
1335
+ (0, import_node_assert6.default)(!this._controller, "Already initialized");
1454
1336
  this._controller = controller;
1455
1337
  }
1456
1338
  update() {
1457
- (0, import_node_assert7.default)(this._controller, "Not initialized");
1339
+ (0, import_node_assert6.default)(this._controller, "Not initialized");
1458
1340
  const { candidates: discovered } = this._controller.getState();
1459
1341
  for (const peer of discovered) {
1460
1342
  this._controller.connect(peer);
@@ -1468,9 +1350,9 @@ var FullyConnectedTopology = class {
1468
1350
  };
1469
1351
 
1470
1352
  // packages/core/mesh/network-manager/src/topology/mmst-topology.ts
1471
- var import_node_assert8 = __toESM(require("node:assert"));
1353
+ var import_node_assert7 = __toESM(require("node:assert"));
1472
1354
  var import_xor_distance = __toESM(require("xor-distance"));
1473
- var import_log8 = require("@dxos/log");
1355
+ var import_log7 = require("@dxos/log");
1474
1356
  var MMSTTopology = class {
1475
1357
  constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
1476
1358
  this._sampleCollected = false;
@@ -1479,14 +1361,14 @@ var MMSTTopology = class {
1479
1361
  this._sampleSize = sampleSize;
1480
1362
  }
1481
1363
  init(controller) {
1482
- (0, import_node_assert8.default)(!this._controller, "Already initialized");
1364
+ (0, import_node_assert7.default)(!this._controller, "Already initialized");
1483
1365
  this._controller = controller;
1484
1366
  }
1485
1367
  update() {
1486
- (0, import_node_assert8.default)(this._controller, "Not initialized");
1368
+ (0, import_node_assert7.default)(this._controller, "Not initialized");
1487
1369
  const { connected, candidates } = this._controller.getState();
1488
1370
  if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
1489
- (0, import_log8.log)("Running the algorithm.", {}, {
1371
+ (0, import_log7.log)("Running the algorithm.", {}, {
1490
1372
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts",
1491
1373
  line: 55,
1492
1374
  scope: this,
@@ -1497,10 +1379,10 @@ var MMSTTopology = class {
1497
1379
  }
1498
1380
  }
1499
1381
  async onOffer(peer) {
1500
- (0, import_node_assert8.default)(this._controller, "Not initialized");
1382
+ (0, import_node_assert7.default)(this._controller, "Not initialized");
1501
1383
  const { connected } = this._controller.getState();
1502
1384
  const accept = connected.length < this._maxPeers;
1503
- (0, import_log8.log)(`Offer ${peer} accept=${accept}`, {}, {
1385
+ (0, import_log7.log)(`Offer ${peer} accept=${accept}`, {}, {
1504
1386
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts",
1505
1387
  line: 65,
1506
1388
  scope: this,
@@ -1511,12 +1393,12 @@ var MMSTTopology = class {
1511
1393
  async destroy() {
1512
1394
  }
1513
1395
  _runAlgorithm() {
1514
- (0, import_node_assert8.default)(this._controller, "Not initialized");
1396
+ (0, import_node_assert7.default)(this._controller, "Not initialized");
1515
1397
  const { connected, candidates, ownPeerId } = this._controller.getState();
1516
1398
  if (connected.length > this._maxPeers) {
1517
1399
  const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
1518
1400
  for (const peer of sorted) {
1519
- (0, import_log8.log)(`Disconnect ${peer}.`, {}, {
1401
+ (0, import_log7.log)(`Disconnect ${peer}.`, {}, {
1520
1402
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts",
1521
1403
  line: 83,
1522
1404
  scope: this,
@@ -1528,7 +1410,7 @@ var MMSTTopology = class {
1528
1410
  const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
1529
1411
  const sorted1 = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
1530
1412
  for (const peer1 of sorted1) {
1531
- (0, import_log8.log)(`Connect ${peer1}.`, {}, {
1413
+ (0, import_log7.log)(`Connect ${peer1}.`, {}, {
1532
1414
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts",
1533
1415
  line: 91,
1534
1416
  scope: this,
@@ -1545,8 +1427,8 @@ var MMSTTopology = class {
1545
1427
  var sortByXorDistance = (keys, reference) => keys.sort((a, b) => import_xor_distance.default.gt((0, import_xor_distance.default)(a.asBuffer(), reference.asBuffer()), (0, import_xor_distance.default)(b.asBuffer(), reference.asBuffer())));
1546
1428
 
1547
1429
  // packages/core/mesh/network-manager/src/topology/star-topology.ts
1548
- var import_node_assert9 = __toESM(require("node:assert"));
1549
- var import_log9 = require("@dxos/log");
1430
+ var import_node_assert8 = __toESM(require("node:assert"));
1431
+ var import_log8 = require("@dxos/log");
1550
1432
  var StarTopology = class {
1551
1433
  constructor(_centralPeer) {
1552
1434
  this._centralPeer = _centralPeer;
@@ -1555,14 +1437,14 @@ var StarTopology = class {
1555
1437
  return `StarTopology(${this._centralPeer.truncate()})`;
1556
1438
  }
1557
1439
  init(controller) {
1558
- (0, import_node_assert9.default)(!this._controller, "Already initialized.");
1440
+ (0, import_node_assert8.default)(!this._controller, "Already initialized.");
1559
1441
  this._controller = controller;
1560
1442
  }
1561
1443
  update() {
1562
- (0, import_node_assert9.default)(this._controller, "Not initialized.");
1444
+ (0, import_node_assert8.default)(this._controller, "Not initialized.");
1563
1445
  const { candidates, connected, ownPeerId } = this._controller.getState();
1564
1446
  if (!ownPeerId.equals(this._centralPeer)) {
1565
- (0, import_log9.log)("leaf peer dropping all connections apart from central peer.", {}, {
1447
+ (0, import_log8.log)("leaf peer dropping all connections apart from central peer.", {}, {
1566
1448
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts",
1567
1449
  line: 33,
1568
1450
  scope: this,
@@ -1570,7 +1452,7 @@ var StarTopology = class {
1570
1452
  });
1571
1453
  for (const peer of connected) {
1572
1454
  if (!peer.equals(this._centralPeer)) {
1573
- (0, import_log9.log)("dropping connection", {
1455
+ (0, import_log8.log)("dropping connection", {
1574
1456
  peer
1575
1457
  }, {
1576
1458
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts",
@@ -1584,7 +1466,7 @@ var StarTopology = class {
1584
1466
  }
1585
1467
  for (const peer1 of candidates) {
1586
1468
  if (peer1.equals(this._centralPeer) || ownPeerId.equals(this._centralPeer)) {
1587
- (0, import_log9.log)("connecting to peer", {
1469
+ (0, import_log8.log)("connecting to peer", {
1588
1470
  peer: peer1
1589
1471
  }, {
1590
1472
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts",
@@ -1597,9 +1479,9 @@ var StarTopology = class {
1597
1479
  }
1598
1480
  }
1599
1481
  async onOffer(peer) {
1600
- (0, import_node_assert9.default)(this._controller, "Not initialized.");
1482
+ (0, import_node_assert8.default)(this._controller, "Not initialized.");
1601
1483
  const { ownPeerId } = this._controller.getState();
1602
- (0, import_log9.log)("offer", {
1484
+ (0, import_log8.log)("offer", {
1603
1485
  peer,
1604
1486
  isCentral: peer.equals(this._centralPeer),
1605
1487
  isSelfCentral: ownPeerId.equals(this._centralPeer)
@@ -1616,13 +1498,23 @@ var StarTopology = class {
1616
1498
  };
1617
1499
 
1618
1500
  // packages/core/mesh/network-manager/src/transport/memory-transport.ts
1619
- var import_node_assert10 = __toESM(require("node:assert"));
1501
+ var import_node_assert9 = __toESM(require("node:assert"));
1620
1502
  var import_node_stream = require("node:stream");
1621
1503
  var import_async7 = require("@dxos/async");
1622
1504
  var import_debug4 = require("@dxos/debug");
1623
- var import_keys8 = require("@dxos/keys");
1624
- var import_log10 = require("@dxos/log");
1505
+ var import_keys7 = require("@dxos/keys");
1506
+ var import_log9 = require("@dxos/log");
1625
1507
  var import_util6 = require("@dxos/util");
1508
+ var __decorate4 = function(decorators, target, key, desc) {
1509
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1510
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1511
+ r = Reflect.decorate(decorators, target, key, desc);
1512
+ else
1513
+ for (var i = decorators.length - 1; i >= 0; i--)
1514
+ if (d = decorators[i])
1515
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1516
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1517
+ };
1626
1518
  var MEMORY_TRANSPORT_DELAY = 1;
1627
1519
  var createStreamDelay = (delay) => {
1628
1520
  return new import_node_stream.Transform({
@@ -1642,34 +1534,30 @@ var _MemoryTransport = class {
1642
1534
  this.closed = new import_async7.Event();
1643
1535
  this.connected = new import_async7.Event();
1644
1536
  this.errors = new import_debug4.ErrorStream();
1645
- this._id = import_keys8.PublicKey.random();
1646
1537
  this._remote = new import_async7.Trigger();
1647
1538
  this._outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
1648
1539
  this._incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
1649
1540
  this._destroyed = false;
1650
- (0, import_log10.log)("creating", {
1651
- id: this._id
1652
- }, {
1541
+ this._instanceId = import_keys7.PublicKey.random();
1542
+ (0, import_log9.log)("creating", {}, {
1653
1543
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
1654
- line: 59,
1544
+ line: 64,
1655
1545
  scope: this,
1656
1546
  callSite: (f, a) => f(...a)
1657
1547
  });
1658
- (0, import_node_assert10.default)(!_MemoryTransport._connections.has(this._id), "Duplicate memory connection");
1659
- _MemoryTransport._connections.set(this._id, this);
1548
+ (0, import_node_assert9.default)(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
1549
+ _MemoryTransport._connections.set(this._instanceId, this);
1660
1550
  if (this.options.initiator) {
1661
1551
  setTimeout(async () => {
1662
- (0, import_log10.log)("sending signal", {
1663
- transportId: this._id
1664
- }, {
1552
+ (0, import_log9.log)("sending signal", {}, {
1665
1553
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
1666
- line: 68,
1554
+ line: 73,
1667
1555
  scope: this,
1668
1556
  callSite: (f, a) => f(...a)
1669
1557
  });
1670
1558
  void this.options.sendSignal({
1671
1559
  payload: {
1672
- transportId: this._id.toHex()
1560
+ transportId: this._instanceId.toHex()
1673
1561
  }
1674
1562
  });
1675
1563
  });
@@ -1680,22 +1568,19 @@ var _MemoryTransport = class {
1680
1568
  if (this._destroyed) {
1681
1569
  return;
1682
1570
  }
1683
- this._remoteId = remoteId;
1684
- this._remoteConnection = _MemoryTransport._connections.get(this._remoteId);
1571
+ this._remoteInstanceId = remoteId;
1572
+ this._remoteConnection = _MemoryTransport._connections.get(this._remoteInstanceId);
1685
1573
  if (!this._remoteConnection) {
1686
1574
  this._destroyed = true;
1687
1575
  this.closed.emit();
1688
1576
  return;
1689
1577
  }
1690
- (0, import_node_assert10.default)(!this._remoteConnection._remoteConnection, new Error(`Remote already connected: ${this._remoteId}`));
1578
+ (0, import_node_assert9.default)(!this._remoteConnection._remoteConnection, new Error(`Remote already connected: ${this._remoteInstanceId}`));
1691
1579
  this._remoteConnection._remoteConnection = this;
1692
- this._remoteConnection._remoteId = this._id;
1693
- (0, import_log10.log)("connected", {
1694
- id: this._id,
1695
- remote: this._remoteId
1696
- }, {
1580
+ this._remoteConnection._remoteInstanceId = this._instanceId;
1581
+ (0, import_log9.log)("connected", {}, {
1697
1582
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
1698
- line: 94,
1583
+ line: 102,
1699
1584
  scope: this,
1700
1585
  callSite: (f, a) => f(...a)
1701
1586
  });
@@ -1711,80 +1596,77 @@ var _MemoryTransport = class {
1711
1596
  }
1712
1597
  }
1713
1598
  async destroy() {
1714
- (0, import_log10.log)("closing", {
1715
- id: this._id
1716
- }, {
1599
+ (0, import_log9.log)("closing", {}, {
1717
1600
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
1718
- line: 115,
1601
+ line: 123,
1719
1602
  scope: this,
1720
1603
  callSite: (f, a) => f(...a)
1721
1604
  });
1722
1605
  this._destroyed = true;
1723
- _MemoryTransport._connections.delete(this._id);
1606
+ _MemoryTransport._connections.delete(this._instanceId);
1724
1607
  if (this._remoteConnection) {
1725
- (0, import_log10.log)("closing", {
1726
- id: this._remoteId
1727
- }, {
1608
+ (0, import_log9.log)("closing", {}, {
1728
1609
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
1729
- line: 120,
1610
+ line: 128,
1730
1611
  scope: this,
1731
1612
  callSite: (f, a) => f(...a)
1732
1613
  });
1733
1614
  this._remoteConnection._destroyed = true;
1734
- _MemoryTransport._connections.delete(this._remoteId);
1615
+ _MemoryTransport._connections.delete(this._remoteInstanceId);
1735
1616
  this._outgoingDelay.unpipe();
1736
1617
  this._incomingDelay.unpipe();
1737
1618
  this._remoteConnection.closed.emit();
1738
1619
  this._remoteConnection._remoteConnection = void 0;
1739
1620
  this._remoteConnection = void 0;
1740
- (0, import_log10.log)("closed", {
1741
- id: this._remoteId
1742
- }, {
1621
+ (0, import_log9.log)("closed", {}, {
1743
1622
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
1744
- line: 138,
1623
+ line: 146,
1745
1624
  scope: this,
1746
1625
  callSite: (f, a) => f(...a)
1747
1626
  });
1748
1627
  }
1749
1628
  this.closed.emit();
1750
- (0, import_log10.log)("closed", {
1751
- id: this._id
1752
- }, {
1629
+ (0, import_log9.log)("closed", {}, {
1753
1630
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
1754
- line: 142,
1631
+ line: 150,
1755
1632
  scope: this,
1756
1633
  callSite: (f, a) => f(...a)
1757
1634
  });
1758
1635
  }
1759
- signal(signal) {
1760
- const { payload: json } = signal;
1761
- if (json && json.transportId) {
1762
- const transportId = json.transportId;
1763
- if (transportId) {
1764
- const remoteId = import_keys8.PublicKey.fromHex(transportId);
1765
- (0, import_log10.log)("received signal", {
1766
- id: this._id,
1767
- remoteId
1768
- }, {
1769
- file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
1770
- line: 152,
1771
- scope: this,
1772
- callSite: (f, a) => f(...a)
1773
- });
1774
- this._remote.wake(remoteId);
1775
- }
1636
+ signal({ payload }) {
1637
+ (0, import_log9.log)("received signal", {
1638
+ payload
1639
+ }, {
1640
+ file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts",
1641
+ line: 154,
1642
+ scope: this,
1643
+ callSite: (f, a) => f(...a)
1644
+ });
1645
+ if (!(payload == null ? void 0 : payload.transportId)) {
1646
+ return;
1647
+ }
1648
+ const transportId = payload.transportId;
1649
+ if (transportId) {
1650
+ const remoteId = import_keys7.PublicKey.fromHex(transportId);
1651
+ this._remote.wake(remoteId);
1776
1652
  }
1777
1653
  }
1778
1654
  };
1779
1655
  var MemoryTransport = _MemoryTransport;
1780
- MemoryTransport._connections = new import_util6.ComplexMap(import_keys8.PublicKey.hash);
1656
+ MemoryTransport._connections = new import_util6.ComplexMap(import_keys7.PublicKey.hash);
1657
+ __decorate4([
1658
+ import_log9.logInfo
1659
+ ], MemoryTransport.prototype, "_instanceId", void 0);
1660
+ __decorate4([
1661
+ import_log9.logInfo
1662
+ ], MemoryTransport.prototype, "_remoteInstanceId", void 0);
1781
1663
 
1782
1664
  // packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
1783
- var import_node_assert11 = __toESM(require("node:assert"));
1665
+ var import_node_assert10 = __toESM(require("node:assert"));
1784
1666
  var import_simple_peer = __toESM(require("simple-peer"));
1785
1667
  var import_async8 = require("@dxos/async");
1786
1668
  var import_debug5 = require("@dxos/debug");
1787
- var import_log11 = require("@dxos/log");
1669
+ var import_log10 = require("@dxos/log");
1788
1670
 
1789
1671
  // packages/core/mesh/network-manager/src/transport/webrtc.ts
1790
1672
  var wrtc = null;
@@ -1801,7 +1683,7 @@ var WebRTCTransport = class {
1801
1683
  this.closed = new import_async8.Event();
1802
1684
  this.connected = new import_async8.Event();
1803
1685
  this.errors = new import_debug5.ErrorStream();
1804
- (0, import_log11.log)("created connection", params, {
1686
+ (0, import_log10.log)("created connection", params, {
1805
1687
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts",
1806
1688
  line: 34,
1807
1689
  scope: this,
@@ -1813,7 +1695,7 @@ var WebRTCTransport = class {
1813
1695
  config: this.params.webrtcConfig
1814
1696
  });
1815
1697
  this._peer.on("signal", async (data) => {
1816
- (0, import_log11.log)("signal", data, {
1698
+ (0, import_log10.log)("signal", data, {
1817
1699
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts",
1818
1700
  line: 42,
1819
1701
  scope: this,
@@ -1826,7 +1708,7 @@ var WebRTCTransport = class {
1826
1708
  });
1827
1709
  });
1828
1710
  this._peer.on("connect", () => {
1829
- (0, import_log11.log)("connected", {}, {
1711
+ (0, import_log10.log)("connected", {}, {
1830
1712
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts",
1831
1713
  line: 47,
1832
1714
  scope: this,
@@ -1836,7 +1718,7 @@ var WebRTCTransport = class {
1836
1718
  this.connected.emit();
1837
1719
  });
1838
1720
  this._peer.on("close", async () => {
1839
- (0, import_log11.log)("closed", {}, {
1721
+ (0, import_log10.log)("closed", {}, {
1840
1722
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts",
1841
1723
  line: 53,
1842
1724
  scope: this,
@@ -1851,7 +1733,7 @@ var WebRTCTransport = class {
1851
1733
  });
1852
1734
  }
1853
1735
  async destroy() {
1854
- (0, import_log11.log)("closing...", {}, {
1736
+ (0, import_log10.log)("closing...", {}, {
1855
1737
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts",
1856
1738
  line: 65,
1857
1739
  scope: this,
@@ -1860,7 +1742,7 @@ var WebRTCTransport = class {
1860
1742
  await this._disconnectStreams();
1861
1743
  this._peer.destroy();
1862
1744
  this.closed.emit();
1863
- (0, import_log11.log)("closed", {}, {
1745
+ (0, import_log10.log)("closed", {}, {
1864
1746
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts",
1865
1747
  line: 69,
1866
1748
  scope: this,
@@ -1868,8 +1750,8 @@ var WebRTCTransport = class {
1868
1750
  });
1869
1751
  }
1870
1752
  signal(signal) {
1871
- (0, import_node_assert11.default)(this._peer, "Connection not ready to accept signals.");
1872
- (0, import_node_assert11.default)(signal.payload.data, "Signal message must contain signal data.");
1753
+ (0, import_node_assert10.default)(this._peer, "Connection not ready to accept signals.");
1754
+ (0, import_node_assert10.default)(signal.payload.data, "Signal message must contain signal data.");
1873
1755
  this._peer.signal(signal.payload.data);
1874
1756
  }
1875
1757
  async _disconnectStreams() {
@@ -1885,17 +1767,17 @@ var createWebRTCTransportFactory = (webrtcConfig) => ({
1885
1767
  });
1886
1768
 
1887
1769
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts
1888
- var import_node_assert12 = __toESM(require("node:assert"));
1770
+ var import_node_assert11 = __toESM(require("node:assert"));
1889
1771
  var import_node_stream2 = require("node:stream");
1890
1772
  var import_codec_protobuf = require("@dxos/codec-protobuf");
1891
- var import_keys9 = require("@dxos/keys");
1892
- var import_log12 = require("@dxos/log");
1773
+ var import_keys8 = require("@dxos/keys");
1774
+ var import_log11 = require("@dxos/log");
1893
1775
  var import_bridge = require("@dxos/protocols/proto/dxos/mesh/bridge");
1894
1776
  var import_util7 = require("@dxos/util");
1895
1777
  var WebRTCTransportService = class {
1896
1778
  constructor(_webrtcConfig) {
1897
1779
  this._webrtcConfig = _webrtcConfig;
1898
- this.transports = new import_util7.ComplexMap(import_keys9.PublicKey.hash);
1780
+ this.transports = new import_util7.ComplexMap(import_keys8.PublicKey.hash);
1899
1781
  }
1900
1782
  open(request) {
1901
1783
  const rpcStream = new import_codec_protobuf.Stream(({ ready, next, close }) => {
@@ -1960,11 +1842,11 @@ var WebRTCTransportService = class {
1960
1842
  return rpcStream;
1961
1843
  }
1962
1844
  async sendSignal({ proxyId, signal }) {
1963
- (0, import_node_assert12.default)(this.transports.has(proxyId));
1845
+ (0, import_node_assert11.default)(this.transports.has(proxyId));
1964
1846
  await this.transports.get(proxyId).transport.signal(signal);
1965
1847
  }
1966
1848
  async sendData({ proxyId, payload }) {
1967
- (0, import_node_assert12.default)(this.transports.has(proxyId));
1849
+ (0, import_node_assert11.default)(this.transports.has(proxyId));
1968
1850
  await this.transports.get(proxyId).stream.push(payload);
1969
1851
  }
1970
1852
  async close({ proxyId }) {
@@ -1972,7 +1854,7 @@ var WebRTCTransportService = class {
1972
1854
  await ((_a = this.transports.get(proxyId)) == null ? void 0 : _a.transport.destroy());
1973
1855
  await ((_b = this.transports.get(proxyId)) == null ? void 0 : _b.stream.end());
1974
1856
  this.transports.delete(proxyId);
1975
- (0, import_log12.log)("Closed.", {}, {
1857
+ (0, import_log11.log)("Closed.", {}, {
1976
1858
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts",
1977
1859
  line: 108,
1978
1860
  scope: this,
@@ -1982,11 +1864,11 @@ var WebRTCTransportService = class {
1982
1864
  };
1983
1865
 
1984
1866
  // packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts
1985
- var import_node_assert13 = __toESM(require("node:assert"));
1867
+ var import_node_assert12 = __toESM(require("node:assert"));
1986
1868
  var import_async9 = require("@dxos/async");
1987
1869
  var import_debug6 = require("@dxos/debug");
1988
- var import_keys10 = require("@dxos/keys");
1989
- var import_log13 = require("@dxos/log");
1870
+ var import_keys9 = require("@dxos/keys");
1871
+ var import_log12 = require("@dxos/log");
1990
1872
  var import_bridge2 = require("@dxos/protocols/proto/dxos/mesh/bridge");
1991
1873
  var WebRTCTransportProxy = class {
1992
1874
  constructor(_params) {
@@ -1995,14 +1877,14 @@ var WebRTCTransportProxy = class {
1995
1877
  this._closed = false;
1996
1878
  this.connected = new import_async9.Event();
1997
1879
  this.errors = new import_debug6.ErrorStream();
1998
- this._proxyId = import_keys10.PublicKey.random();
1880
+ this._proxyId = import_keys9.PublicKey.random();
1999
1881
  this._serviceStream = this._params.bridgeService.open({
2000
1882
  proxyId: this._proxyId,
2001
1883
  initiator: this._params.initiator
2002
1884
  });
2003
1885
  this._serviceStream.waitUntilReady().then(() => {
2004
1886
  this._serviceStream.subscribe(async (event) => {
2005
- (0, import_log13.log)("WebRTCTransportProxy: event", event, {
1887
+ (0, import_log12.log)("WebRTCTransportProxy: event", event, {
2006
1888
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts",
2007
1889
  line: 46,
2008
1890
  scope: this,
@@ -2023,7 +1905,7 @@ var WebRTCTransportProxy = class {
2023
1905
  payload: data
2024
1906
  });
2025
1907
  } catch (err) {
2026
- import_log13.log.catch(err, {}, {
1908
+ import_log12.log.catch(err, {}, {
2027
1909
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts",
2028
1910
  line: 63,
2029
1911
  scope: this,
@@ -2031,7 +1913,7 @@ var WebRTCTransportProxy = class {
2031
1913
  });
2032
1914
  }
2033
1915
  });
2034
- }, (error) => import_log13.log.catch(error, {}, {
1916
+ }, (error) => import_log12.log.catch(error, {}, {
2035
1917
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts",
2036
1918
  line: 67,
2037
1919
  scope: this,
@@ -2075,7 +1957,7 @@ var WebRTCTransportProxy = class {
2075
1957
  proxyId: this._proxyId
2076
1958
  });
2077
1959
  } catch (err) {
2078
- import_log13.log.catch(err, {}, {
1960
+ import_log12.log.catch(err, {}, {
2079
1961
  file: "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts",
2080
1962
  line: 117,
2081
1963
  scope: this,
@@ -2103,7 +1985,7 @@ var WebRTCTransportProxyFactory = class {
2103
1985
  return this;
2104
1986
  }
2105
1987
  createTransport(options) {
2106
- (0, import_node_assert13.default)(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
1988
+ (0, import_node_assert12.default)(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
2107
1989
  const transport = new WebRTCTransportProxy({
2108
1990
  ...options,
2109
1991
  bridgeService: this._bridgeService
@@ -2115,20 +1997,7 @@ var WebRTCTransportProxyFactory = class {
2115
1997
  };
2116
1998
 
2117
1999
  // packages/core/mesh/network-manager/src/wire-protocol.ts
2118
- var import_crypto2 = require("@dxos/crypto");
2119
2000
  var import_teleport = require("@dxos/teleport");
2120
- var adaptProtocolProvider = (factory) => ({ initiator, localPeerId, remotePeerId, topic }) => {
2121
- const protocol = factory({
2122
- channel: (0, import_crypto2.discoveryKey)(topic),
2123
- initiator
2124
- });
2125
- return {
2126
- initialize: () => protocol.open(),
2127
- destroy: () => protocol.close(),
2128
- stream: protocol.stream,
2129
- protocol
2130
- };
2131
- };
2132
2001
  var createTeleportProtocolFactory = (onConnection) => {
2133
2002
  return (params) => {
2134
2003
  const teleport = new import_teleport.Teleport(params);
@@ -2163,11 +2032,6 @@ var createTeleportProtocolFactory = (onConnection) => {
2163
2032
  WebRTCTransportProxy,
2164
2033
  WebRTCTransportProxyFactory,
2165
2034
  WebRTCTransportService,
2166
- adaptProtocolProvider,
2167
- createProtocolFactory,
2168
2035
  createTeleportProtocolFactory,
2169
- createWebRTCTransportFactory,
2170
- protocolFactory,
2171
- transportProtocolProvider
2036
+ createWebRTCTransportFactory
2172
2037
  });
2173
- //# sourceMappingURL=index.cjs.map