@dxos/network-manager 0.5.3-main.f752aaa → 0.5.3-next.2c59258

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.
@@ -2079,7 +2079,7 @@ var gcSwarm = (swarm) => {
2079
2079
  };
2080
2080
 
2081
2081
  // packages/core/mesh/network-manager/src/network-manager.ts
2082
- import { Event as Event6 } from "@dxos/async";
2082
+ import { Event as Event6, synchronized as synchronized4 } from "@dxos/async";
2083
2083
  import { invariant as invariant6 } from "@dxos/invariant";
2084
2084
  import { PublicKey as PublicKey8 } from "@dxos/keys";
2085
2085
  import { log as log7 } from "@dxos/log";
@@ -2087,6 +2087,16 @@ import { Messenger } from "@dxos/messaging";
2087
2087
  import { trace as trace3 } from "@dxos/protocols";
2088
2088
  import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
2089
2089
  import { ComplexMap as ComplexMap6 } from "@dxos/util";
2090
+ function _ts_decorate4(decorators, target, key, desc) {
2091
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2092
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2093
+ r = Reflect.decorate(decorators, target, key, desc);
2094
+ else
2095
+ for (var i = decorators.length - 1; i >= 0; i--)
2096
+ if (d = decorators[i])
2097
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2098
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2099
+ }
2090
2100
  var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
2091
2101
  var NetworkManager = class {
2092
2102
  constructor({ transportFactory, signalManager, log: log15 }) {
@@ -2171,7 +2181,7 @@ var NetworkManager = class {
2171
2181
  async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
2172
2182
  invariant6(PublicKey8.isPublicKey(topic), void 0, {
2173
2183
  F: __dxlog_file7,
2174
- L: 157,
2184
+ L: 158,
2175
2185
  S: this,
2176
2186
  A: [
2177
2187
  "PublicKey.isPublicKey(topic)",
@@ -2180,7 +2190,7 @@ var NetworkManager = class {
2180
2190
  });
2181
2191
  invariant6(PublicKey8.isPublicKey(peerId), void 0, {
2182
2192
  F: __dxlog_file7,
2183
- L: 158,
2193
+ L: 159,
2184
2194
  S: this,
2185
2195
  A: [
2186
2196
  "PublicKey.isPublicKey(peerId)",
@@ -2189,7 +2199,7 @@ var NetworkManager = class {
2189
2199
  });
2190
2200
  invariant6(topology, void 0, {
2191
2201
  F: __dxlog_file7,
2192
- L: 159,
2202
+ L: 160,
2193
2203
  S: this,
2194
2204
  A: [
2195
2205
  "topology",
@@ -2198,7 +2208,7 @@ var NetworkManager = class {
2198
2208
  });
2199
2209
  invariant6(typeof protocol === "function", void 0, {
2200
2210
  F: __dxlog_file7,
2201
- L: 160,
2211
+ L: 161,
2202
2212
  S: this,
2203
2213
  A: [
2204
2214
  "typeof protocol === 'function'",
@@ -2214,7 +2224,7 @@ var NetworkManager = class {
2214
2224
  topology: topology.toString()
2215
2225
  }, {
2216
2226
  F: __dxlog_file7,
2217
- L: 165,
2227
+ L: 166,
2218
2228
  S: this,
2219
2229
  C: (f, a) => f(...a)
2220
2230
  });
@@ -2224,7 +2234,7 @@ var NetworkManager = class {
2224
2234
  error
2225
2235
  }, {
2226
2236
  F: __dxlog_file7,
2227
- L: 178,
2237
+ L: 179,
2228
2238
  S: this,
2229
2239
  C: (f, a) => f(...a)
2230
2240
  });
@@ -2237,7 +2247,7 @@ var NetworkManager = class {
2237
2247
  peerId
2238
2248
  }).catch((error) => log7.catch(error, void 0, {
2239
2249
  F: __dxlog_file7,
2240
- L: 187,
2250
+ L: 188,
2241
2251
  S: this,
2242
2252
  C: (f, a) => f(...a)
2243
2253
  }));
@@ -2248,7 +2258,7 @@ var NetworkManager = class {
2248
2258
  count: this._swarms.size
2249
2259
  }, {
2250
2260
  F: __dxlog_file7,
2251
- L: 191,
2261
+ L: 192,
2252
2262
  S: this,
2253
2263
  C: (f, a) => f(...a)
2254
2264
  });
@@ -2267,7 +2277,7 @@ var NetworkManager = class {
2267
2277
  topic: PublicKey8.from(topic)
2268
2278
  }, {
2269
2279
  F: __dxlog_file7,
2270
- L: 207,
2280
+ L: 209,
2271
2281
  S: this,
2272
2282
  C: (f, a) => f(...a)
2273
2283
  });
@@ -2288,7 +2298,7 @@ var NetworkManager = class {
2288
2298
  count: this._swarms.size
2289
2299
  }, {
2290
2300
  F: __dxlog_file7,
2291
- L: 221,
2301
+ L: 223,
2292
2302
  S: this,
2293
2303
  C: (f, a) => f(...a)
2294
2304
  });
@@ -2320,6 +2330,12 @@ var NetworkManager = class {
2320
2330
  this.connectionStateChanged.emit(this._connectionState);
2321
2331
  }
2322
2332
  };
2333
+ _ts_decorate4([
2334
+ synchronized4
2335
+ ], NetworkManager.prototype, "joinSwarm", null);
2336
+ _ts_decorate4([
2337
+ synchronized4
2338
+ ], NetworkManager.prototype, "leaveSwarm", null);
2323
2339
 
2324
2340
  // packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
2325
2341
  import { invariant as invariant7 } from "@dxos/invariant";
@@ -2411,10 +2427,14 @@ var MMSTTopology = class {
2411
2427
  this._runAlgorithm();
2412
2428
  }
2413
2429
  }
2430
+ forceUpdate() {
2431
+ this._lastAction = /* @__PURE__ */ new Date(0);
2432
+ this.update();
2433
+ }
2414
2434
  async onOffer(peer) {
2415
2435
  invariant8(this._controller, "Not initialized", {
2416
2436
  F: __dxlog_file9,
2417
- L: 67,
2437
+ L: 72,
2418
2438
  S: this,
2419
2439
  A: [
2420
2440
  "this._controller",
@@ -2425,7 +2445,7 @@ var MMSTTopology = class {
2425
2445
  const accept = connected.length < this._maxPeers;
2426
2446
  log8(`Offer ${peer} accept=${accept}`, void 0, {
2427
2447
  F: __dxlog_file9,
2428
- L: 70,
2448
+ L: 75,
2429
2449
  S: this,
2430
2450
  C: (f, a) => f(...a)
2431
2451
  });
@@ -2436,7 +2456,7 @@ var MMSTTopology = class {
2436
2456
  _runAlgorithm() {
2437
2457
  invariant8(this._controller, "Not initialized", {
2438
2458
  F: __dxlog_file9,
2439
- L: 79,
2459
+ L: 84,
2440
2460
  S: this,
2441
2461
  A: [
2442
2462
  "this._controller",
@@ -2447,14 +2467,14 @@ var MMSTTopology = class {
2447
2467
  if (connected.length > this._maxPeers) {
2448
2468
  log8(`disconnect ${connected.length - this._maxPeers} peers.`, void 0, {
2449
2469
  F: __dxlog_file9,
2450
- L: 85,
2470
+ L: 90,
2451
2471
  S: this,
2452
2472
  C: (f, a) => f(...a)
2453
2473
  });
2454
2474
  const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
2455
2475
  invariant8(sorted.length === 0, void 0, {
2456
2476
  F: __dxlog_file9,
2457
- L: 89,
2477
+ L: 94,
2458
2478
  S: this,
2459
2479
  A: [
2460
2480
  "sorted.length === 0",
@@ -2464,7 +2484,7 @@ var MMSTTopology = class {
2464
2484
  if (sorted.length > MAX_CHANGES_PER_UPDATE) {
2465
2485
  log8(`want to disconnect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`, void 0, {
2466
2486
  F: __dxlog_file9,
2467
- L: 92,
2487
+ L: 97,
2468
2488
  S: this,
2469
2489
  C: (f, a) => f(...a)
2470
2490
  });
@@ -2473,7 +2493,7 @@ var MMSTTopology = class {
2473
2493
  for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
2474
2494
  log8(`Disconnect ${peer}.`, void 0, {
2475
2495
  F: __dxlog_file9,
2476
- L: 97,
2496
+ L: 102,
2477
2497
  S: this,
2478
2498
  C: (f, a) => f(...a)
2479
2499
  });
@@ -2481,9 +2501,9 @@ var MMSTTopology = class {
2481
2501
  }
2482
2502
  this._lastAction = /* @__PURE__ */ new Date();
2483
2503
  } else {
2484
- log8("rate limited discconnect", void 0, {
2504
+ log8("rate limited disconnect", void 0, {
2485
2505
  F: __dxlog_file9,
2486
- L: 102,
2506
+ L: 107,
2487
2507
  S: this,
2488
2508
  C: (f, a) => f(...a)
2489
2509
  });
@@ -2491,7 +2511,7 @@ var MMSTTopology = class {
2491
2511
  } else if (connected.length < this._originateConnections) {
2492
2512
  log8(`connect ${this._originateConnections - connected.length} peers.`, void 0, {
2493
2513
  F: __dxlog_file9,
2494
- L: 106,
2514
+ L: 111,
2495
2515
  S: this,
2496
2516
  C: (f, a) => f(...a)
2497
2517
  });
@@ -2500,7 +2520,7 @@ var MMSTTopology = class {
2500
2520
  if (sorted.length > MAX_CHANGES_PER_UPDATE) {
2501
2521
  log8(`want to connect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`, void 0, {
2502
2522
  F: __dxlog_file9,
2503
- L: 111,
2523
+ L: 116,
2504
2524
  S: this,
2505
2525
  C: (f, a) => f(...a)
2506
2526
  });
@@ -2509,7 +2529,7 @@ var MMSTTopology = class {
2509
2529
  for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
2510
2530
  log8(`Connect ${peer}.`, void 0, {
2511
2531
  F: __dxlog_file9,
2512
- L: 115,
2532
+ L: 120,
2513
2533
  S: this,
2514
2534
  C: (f, a) => f(...a)
2515
2535
  });
@@ -2519,7 +2539,7 @@ var MMSTTopology = class {
2519
2539
  } else {
2520
2540
  log8("rate limited connect", void 0, {
2521
2541
  F: __dxlog_file9,
2522
- L: 120,
2542
+ L: 125,
2523
2543
  S: this,
2524
2544
  C: (f, a) => f(...a)
2525
2545
  });
@@ -2636,7 +2656,7 @@ import { invariant as invariant10 } from "@dxos/invariant";
2636
2656
  import { PublicKey as PublicKey9 } from "@dxos/keys";
2637
2657
  import { log as log10, logInfo as logInfo3 } from "@dxos/log";
2638
2658
  import { ComplexMap as ComplexMap7 } from "@dxos/util";
2639
- function _ts_decorate4(decorators, target, key, desc) {
2659
+ function _ts_decorate5(decorators, target, key, desc) {
2640
2660
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2641
2661
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2642
2662
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2814,10 +2834,10 @@ var MemoryTransport = class _MemoryTransport {
2814
2834
  };
2815
2835
  }
2816
2836
  };
2817
- _ts_decorate4([
2837
+ _ts_decorate5([
2818
2838
  logInfo3
2819
2839
  ], MemoryTransport.prototype, "_instanceId", void 0);
2820
- _ts_decorate4([
2840
+ _ts_decorate5([
2821
2841
  logInfo3
2822
2842
  ], MemoryTransport.prototype, "_remoteInstanceId", void 0);
2823
2843
  var toError = (err) => err instanceof Error ? err : new Error(String(err));
@@ -3514,11 +3534,11 @@ var decodeError = (err) => {
3514
3534
 
3515
3535
  // packages/core/mesh/network-manager/src/transport/libdatachannel-transport.ts
3516
3536
  import { Duplex as Duplex2 } from "stream";
3517
- import { Event as Event10, Trigger as Trigger3, synchronized as synchronized4 } from "@dxos/async";
3537
+ import { Event as Event10, Trigger as Trigger3, synchronized as synchronized5 } from "@dxos/async";
3518
3538
  import { ErrorStream as ErrorStream6 } from "@dxos/debug";
3519
3539
  import { invariant as invariant14 } from "@dxos/invariant";
3520
3540
  import { log as log14 } from "@dxos/log";
3521
- function _ts_decorate5(decorators, target, key, desc) {
3541
+ function _ts_decorate6(decorators, target, key, desc) {
3522
3542
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3523
3543
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3524
3544
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3955,8 +3975,8 @@ var LibDataChannelTransport = class _LibDataChannelTransport {
3955
3975
  this._options.stream.unpipe?.(this._stream)?.unpipe?.(this._options.stream);
3956
3976
  }
3957
3977
  };
3958
- _ts_decorate5([
3959
- synchronized4
3978
+ _ts_decorate6([
3979
+ synchronized5
3960
3980
  ], LibDataChannelTransport.prototype, "_close", null);
3961
3981
  var importESM = Function("path", "return import(path)");
3962
3982
 
@@ -4043,4 +4063,4 @@ export {
4043
4063
  TcpTransport,
4044
4064
  createTeleportProtocolFactory
4045
4065
  };
4046
- //# sourceMappingURL=chunk-66SM4LDV.mjs.map
4066
+ //# sourceMappingURL=chunk-4L3ORJC4.mjs.map