@dxos/teleport 0.1.56-main.c19b7cd → 0.1.56-main.c277f68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"inputs":{"packages/core/mesh/teleport/src/muxing/framer.ts":{"bytes":15714,"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}]},"packages/core/mesh/teleport/src/muxing/balancer.ts":{"bytes":19951,"imports":[{"path":"varint","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/muxing/framer.ts","kind":"import-statement","original":"./framer"}]},"packages/core/mesh/teleport/src/muxing/muxer.ts":{"bytes":35408,"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/muxing/balancer.ts","kind":"import-statement","original":"./balancer"}]},"packages/core/mesh/teleport/src/muxing/rpc-port.ts":{"bytes":925,"imports":[]},"packages/core/mesh/teleport/src/muxing/index.ts":{"bytes":641,"imports":[{"path":"packages/core/mesh/teleport/src/muxing/framer.ts","kind":"import-statement","original":"./framer"},{"path":"packages/core/mesh/teleport/src/muxing/muxer.ts","kind":"import-statement","original":"./muxer"},{"path":"packages/core/mesh/teleport/src/muxing/rpc-port.ts","kind":"import-statement","original":"./rpc-port"}]},"packages/core/mesh/teleport/src/teleport.ts":{"bytes":31340,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/muxing/index.ts","kind":"import-statement","original":"./muxing"}]},"packages/core/mesh/teleport/src/testing/test-builder.ts":{"bytes":15622,"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/teleport.ts","kind":"import-statement","original":"../teleport"}]},"packages/core/mesh/teleport/src/testing/test-extension.ts":{"bytes":8917,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}]},"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts":{"bytes":26069,"imports":[{"path":"@dxos/node-std/crypto","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}]},"packages/core/mesh/teleport/src/testing/index.ts":{"bytes":728,"imports":[{"path":"packages/core/mesh/teleport/src/testing/test-builder.ts","kind":"import-statement","original":"./test-builder"},{"path":"packages/core/mesh/teleport/src/testing/test-extension.ts","kind":"import-statement","original":"./test-extension"},{"path":"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts","kind":"import-statement","original":"./test-extension-with-streams"}]},"packages/core/mesh/teleport/src/rpc-extension.ts":{"bytes":5617,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}]},"packages/core/mesh/teleport/src/index.ts":{"bytes":741,"imports":[{"path":"packages/core/mesh/teleport/src/muxing/index.ts","kind":"import-statement","original":"./muxing"},{"path":"packages/core/mesh/teleport/src/teleport.ts","kind":"import-statement","original":"./teleport"},{"path":"packages/core/mesh/teleport/src/testing/index.ts","kind":"import-statement","original":"./testing"},{"path":"packages/core/mesh/teleport/src/rpc-extension.ts","kind":"import-statement","original":"./rpc-extension"}]}},"outputs":{"packages/core/mesh/teleport/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2794},"packages/core/mesh/teleport/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/core/mesh/teleport/dist/lib/browser/chunk-3FNN6ZOF.mjs","kind":"import-statement"},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"exports":["Framer","Muxer","RpcExtension","Teleport","TestBuilder","TestConnection","TestExtension","TestExtensionWithStreams","TestPeer","decodeFrame","encodeFrame"],"entryPoint":"packages/core/mesh/teleport/src/index.ts","inputs":{"packages/core/mesh/teleport/src/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/rpc-extension.ts":{"bytesInOutput":1322}},"bytes":1811},"packages/core/mesh/teleport/dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/mesh/teleport/dist/lib/browser/testing/index.mjs":{"imports":[{"path":"packages/core/mesh/teleport/dist/lib/browser/chunk-3FNN6ZOF.mjs","kind":"import-statement"}],"exports":["TestBuilder","TestConnection","TestExtension","TestExtensionWithStreams","TestPeer"],"entryPoint":"packages/core/mesh/teleport/src/testing/index.ts","inputs":{},"bytes":299},"packages/core/mesh/teleport/dist/lib/browser/chunk-3FNN6ZOF.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":73327},"packages/core/mesh/teleport/dist/lib/browser/chunk-3FNN6ZOF.mjs":{"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"varint","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true},{"path":"@dxos/node-std/crypto","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"exports":["Framer","Muxer","Teleport","TestBuilder","TestConnection","TestExtension","TestExtensionWithStreams","TestPeer","decodeFrame","encodeFrame"],"inputs":{"packages/core/mesh/teleport/src/testing/test-builder.ts":{"bytesInOutput":4939},"packages/core/mesh/teleport/src/teleport.ts":{"bytesInOutput":9173},"packages/core/mesh/teleport/src/muxing/framer.ts":{"bytesInOutput":3715},"packages/core/mesh/teleport/src/muxing/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/muxing/muxer.ts":{"bytesInOutput":8557},"packages/core/mesh/teleport/src/muxing/balancer.ts":{"bytesInOutput":4654},"packages/core/mesh/teleport/src/testing/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/testing/test-extension.ts":{"bytesInOutput":2611},"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts":{"bytesInOutput":7400}},"bytes":41854}}}
1
+ {"inputs":{"packages/core/mesh/teleport/src/muxing/framer.ts":{"bytes":15714,"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport/src/muxing/balancer.ts":{"bytes":19951,"imports":[{"path":"varint","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/muxing/framer.ts","kind":"import-statement","original":"./framer"}],"format":"esm"},"packages/core/mesh/teleport/src/muxing/muxer.ts":{"bytes":39126,"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/muxing/balancer.ts","kind":"import-statement","original":"./balancer"}],"format":"esm"},"packages/core/mesh/teleport/src/muxing/rpc-port.ts":{"bytes":925,"imports":[],"format":"esm"},"packages/core/mesh/teleport/src/muxing/index.ts":{"bytes":641,"imports":[{"path":"packages/core/mesh/teleport/src/muxing/framer.ts","kind":"import-statement","original":"./framer"},{"path":"packages/core/mesh/teleport/src/muxing/muxer.ts","kind":"import-statement","original":"./muxer"},{"path":"packages/core/mesh/teleport/src/muxing/rpc-port.ts","kind":"import-statement","original":"./rpc-port"}],"format":"esm"},"packages/core/mesh/teleport/src/teleport.ts":{"bytes":31898,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/muxing/index.ts","kind":"import-statement","original":"./muxing"}],"format":"esm"},"packages/core/mesh/teleport/src/testing/test-builder.ts":{"bytes":15622,"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/teleport.ts","kind":"import-statement","original":"../teleport"}],"format":"esm"},"packages/core/mesh/teleport/src/testing/test-extension.ts":{"bytes":8917,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts":{"bytes":26069,"imports":[{"path":"@dxos/node-std/crypto","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport/src/testing/index.ts":{"bytes":728,"imports":[{"path":"packages/core/mesh/teleport/src/testing/test-builder.ts","kind":"import-statement","original":"./test-builder"},{"path":"packages/core/mesh/teleport/src/testing/test-extension.ts","kind":"import-statement","original":"./test-extension"},{"path":"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts","kind":"import-statement","original":"./test-extension-with-streams"}],"format":"esm"},"packages/core/mesh/teleport/src/rpc-extension.ts":{"bytes":5617,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport/src/index.ts":{"bytes":741,"imports":[{"path":"packages/core/mesh/teleport/src/muxing/index.ts","kind":"import-statement","original":"./muxing"},{"path":"packages/core/mesh/teleport/src/teleport.ts","kind":"import-statement","original":"./teleport"},{"path":"packages/core/mesh/teleport/src/testing/index.ts","kind":"import-statement","original":"./testing"},{"path":"packages/core/mesh/teleport/src/rpc-extension.ts","kind":"import-statement","original":"./rpc-extension"}],"format":"esm"}},"outputs":{"packages/core/mesh/teleport/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2787},"packages/core/mesh/teleport/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/core/mesh/teleport/dist/lib/browser/chunk-2MN5W64H.mjs","kind":"import-statement"},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"exports":["Framer","Muxer","RpcExtension","Teleport","TestBuilder","TestConnection","TestExtension","TestExtensionWithStreams","TestPeer","decodeFrame","encodeFrame"],"entryPoint":"packages/core/mesh/teleport/src/index.ts","inputs":{"packages/core/mesh/teleport/src/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/rpc-extension.ts":{"bytesInOutput":1280}},"bytes":1769},"packages/core/mesh/teleport/dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/mesh/teleport/dist/lib/browser/testing/index.mjs":{"imports":[{"path":"packages/core/mesh/teleport/dist/lib/browser/chunk-2MN5W64H.mjs","kind":"import-statement"}],"exports":["TestBuilder","TestConnection","TestExtension","TestExtensionWithStreams","TestPeer"],"entryPoint":"packages/core/mesh/teleport/src/testing/index.ts","inputs":{},"bytes":299},"packages/core/mesh/teleport/dist/lib/browser/chunk-2MN5W64H.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":75373},"packages/core/mesh/teleport/dist/lib/browser/chunk-2MN5W64H.mjs":{"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"varint","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true},{"path":"@dxos/node-std/crypto","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"exports":["Framer","Muxer","Teleport","TestBuilder","TestConnection","TestExtension","TestExtensionWithStreams","TestPeer","decodeFrame","encodeFrame"],"inputs":{"packages/core/mesh/teleport/src/testing/test-builder.ts":{"bytesInOutput":4939},"packages/core/mesh/teleport/src/teleport.ts":{"bytesInOutput":9238},"packages/core/mesh/teleport/src/muxing/framer.ts":{"bytesInOutput":3663},"packages/core/mesh/teleport/src/muxing/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/muxing/muxer.ts":{"bytesInOutput":9322},"packages/core/mesh/teleport/src/muxing/balancer.ts":{"bytesInOutput":4582},"packages/core/mesh/teleport/src/testing/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/testing/test-extension.ts":{"bytesInOutput":2379},"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts":{"bytesInOutput":7070}},"bytes":41998}}}
@@ -5,7 +5,7 @@ import {
5
5
  TestExtension,
6
6
  TestExtensionWithStreams,
7
7
  TestPeer
8
- } from "../chunk-3FNN6ZOF.mjs";
8
+ } from "../chunk-2MN5W64H.mjs";
9
9
  export {
10
10
  TestBuilder,
11
11
  TestConnection,
@@ -104,7 +104,6 @@ var Framer = class {
104
104
  });
105
105
  },
106
106
  subscribe: (callback) => {
107
- var _a;
108
107
  (0, import_invariant.invariant)(!this._messageCb, "Rpc port already has a message listener.", {
109
108
  F: __dxlog_file,
110
109
  L: 73,
@@ -115,7 +114,7 @@ var Framer = class {
115
114
  ]
116
115
  });
117
116
  this._messageCb = callback;
118
- (_a = this._subscribeCb) == null ? void 0 : _a.call(this);
117
+ this._subscribeCb?.();
119
118
  return () => {
120
119
  this._messageCb = void 0;
121
120
  };
@@ -304,16 +303,15 @@ var Balancer = class {
304
303
  return chunk;
305
304
  }
306
305
  async _sendChunks() {
307
- var _a, _b;
308
306
  if (this._sendBuffers.size === 0) {
309
307
  return;
310
308
  }
311
309
  const chunk = this._getNextChunk();
312
310
  try {
313
311
  await this._framer.port.send(chunk.msg);
314
- (_a = chunk.trigger) == null ? void 0 : _a.wake();
312
+ chunk.trigger?.wake();
315
313
  } catch (err) {
316
- (_b = chunk.trigger) == null ? void 0 : _b.throw(err);
314
+ chunk.trigger?.throw(err);
317
315
  }
318
316
  await this._sendChunks();
319
317
  }
@@ -363,6 +361,7 @@ var Muxer = class {
363
361
  this.close = new import_async2.Event();
364
362
  this.statsUpdated = new import_async2.Event();
365
363
  this.stream = this._balancer.stream;
364
+ this._lastChannelStats = /* @__PURE__ */ new Map();
366
365
  this._balancer.incomingData.on(async (msg) => {
367
366
  await this._handleCommand(Command.decode(msg));
368
367
  });
@@ -381,7 +380,7 @@ var Muxer = class {
381
380
  });
382
381
  (0, import_invariant2.invariant)(!channel.push, `Channel already open: ${tag}`, {
383
382
  F: __dxlog_file3,
384
- L: 91,
383
+ L: 131,
385
384
  S: this,
386
385
  A: [
387
386
  "!channel.push",
@@ -429,7 +428,7 @@ var Muxer = class {
429
428
  });
430
429
  (0, import_invariant2.invariant)(!channel.push, `Channel already open: ${tag}`, {
431
430
  F: __dxlog_file3,
432
- L: 143,
431
+ L: 183,
433
432
  S: this,
434
433
  A: [
435
434
  "!channel.push",
@@ -453,7 +452,7 @@ var Muxer = class {
453
452
  subscribe: (cb) => {
454
453
  (0, import_invariant2.invariant)(!callback, "Only one subscriber is allowed", {
455
454
  F: __dxlog_file3,
456
- L: 165,
455
+ L: 205,
457
456
  S: this,
458
457
  A: [
459
458
  "!callback",
@@ -491,7 +490,7 @@ var Muxer = class {
491
490
  this._destroying = true;
492
491
  this._sendCommand({
493
492
  destroy: {
494
- error: err == null ? void 0 : err.message
493
+ error: err?.message
495
494
  }
496
495
  }, SYSTEM_CHANNEL_ID).then(() => {
497
496
  this._dispose();
@@ -501,26 +500,24 @@ var Muxer = class {
501
500
  void this._ctx.dispose();
502
501
  }
503
502
  _dispose(err) {
504
- var _a;
505
503
  if (this._destroyed) {
506
504
  return;
507
505
  }
508
506
  this._destroyed = true;
509
507
  this._balancer.destroy();
510
508
  for (const channel of this._channelsByTag.values()) {
511
- (_a = channel.destroy) == null ? void 0 : _a.call(channel, err);
509
+ channel.destroy?.(err);
512
510
  }
513
511
  this.close.emit(err);
514
512
  this._channelsByLocalId.clear();
515
513
  this._channelsByTag.clear();
516
514
  }
517
515
  async _handleCommand(cmd) {
518
- var _a;
519
516
  (0, import_log2.log)("Received command", {
520
517
  cmd
521
518
  }, {
522
519
  F: __dxlog_file3,
523
- L: 240,
520
+ L: 280,
524
521
  S: this,
525
522
  C: (f, a) => f(...a)
526
523
  });
@@ -532,7 +529,7 @@ var Muxer = class {
532
529
  cmd
533
530
  }, {
534
531
  F: __dxlog_file3,
535
- L: 247,
532
+ L: 287,
536
533
  S: this,
537
534
  C: (f, a) => f(...a)
538
535
  });
@@ -554,13 +551,13 @@ var Muxer = class {
554
551
  }
555
552
  channel.buffer = [];
556
553
  } else if (cmd.data) {
557
- const stream = (_a = this._channelsByLocalId.get(cmd.data.channelId)) != null ? _a : (0, import_debug.failUndefined)();
554
+ const stream = this._channelsByLocalId.get(cmd.data.channelId) ?? (0, import_debug.failUndefined)();
558
555
  if (!stream.push) {
559
556
  import_log2.log.warn("Received data for channel before it was opened", {
560
557
  tag: stream.tag
561
558
  }, {
562
559
  F: __dxlog_file3,
563
- L: 274,
560
+ L: 314,
564
561
  S: this,
565
562
  C: (f, a) => f(...a)
566
563
  });
@@ -609,7 +606,7 @@ var Muxer = class {
609
606
  threshold: MAX_SAFE_FRAME_SIZE
610
607
  }, {
611
608
  F: __dxlog_file3,
612
- L: 318,
609
+ L: 359,
613
610
  S: this,
614
611
  C: (f, a) => f(...a)
615
612
  });
@@ -635,21 +632,40 @@ var Muxer = class {
635
632
  }
636
633
  async _emitStats() {
637
634
  if (this._destroyed || this._destroying) {
635
+ this._lastStats = void 0;
636
+ this._lastChannelStats.clear();
638
637
  return;
639
638
  }
640
639
  const bytesSent = this._balancer.bytesSent;
641
640
  const bytesReceived = this._balancer.bytesReceived;
642
- this.statsUpdated.emit({
643
- channels: Array.from(this._channelsByTag.values()).map((channel) => ({
644
- id: channel.id,
645
- tag: channel.tag,
646
- contentType: channel.contentType,
647
- bytesSent: channel.stats.bytesSent,
648
- bytesReceived: channel.stats.bytesReceived
649
- })),
641
+ const now = Date.now();
642
+ const interval = this._lastStats ? (now - this._lastStats.timestamp) / 1e3 : 0;
643
+ const calculateThroughput = (current, last) => last ? {
644
+ bytesSentRate: interval ? (current.bytesSent - last.bytesSent) / interval : void 0,
645
+ bytesReceivedRate: interval ? (current.bytesReceived - last.bytesReceived) / interval : void 0
646
+ } : {};
647
+ this._lastStats = {
648
+ timestamp: now,
649
+ channels: Array.from(this._channelsByTag.values()).map((channel) => {
650
+ const stats = {
651
+ id: channel.id,
652
+ tag: channel.tag,
653
+ contentType: channel.contentType,
654
+ bytesSent: channel.stats.bytesSent,
655
+ bytesReceived: channel.stats.bytesReceived,
656
+ ...calculateThroughput(channel.stats, this._lastChannelStats.get(channel.id))
657
+ };
658
+ this._lastChannelStats.set(channel.id, stats);
659
+ return stats;
660
+ }),
650
661
  bytesSent,
651
- bytesReceived
652
- });
662
+ bytesReceived,
663
+ ...calculateThroughput({
664
+ bytesSent,
665
+ bytesReceived
666
+ }, this._lastStats)
667
+ };
668
+ this.statsUpdated.emit(this._lastStats);
653
669
  }
654
670
  };
655
671
 
@@ -774,11 +790,13 @@ var Teleport = class {
774
790
  localPeerId,
775
791
  remotePeerId,
776
792
  bytesSent: stats.bytesSent,
793
+ bytesSentRate: stats.bytesSentRate,
777
794
  bytesReceived: stats.bytesReceived,
795
+ bytesReceivedRate: stats.bytesReceivedRate,
778
796
  channels: stats.channels
779
797
  }, {
780
798
  F: __dxlog_file4,
781
- L: 88,
799
+ L: 89,
782
800
  S: this,
783
801
  C: (f, a) => f(...a)
784
802
  });
@@ -812,7 +830,7 @@ var Teleport = class {
812
830
  } catch (err2) {
813
831
  import_log3.log.catch(err2, void 0, {
814
832
  F: __dxlog_file4,
815
- L: 132,
833
+ L: 137,
816
834
  S: this,
817
835
  C: (f, a) => f(...a)
818
836
  });
@@ -828,7 +846,7 @@ var Teleport = class {
828
846
  name
829
847
  }, {
830
848
  F: __dxlog_file4,
831
- L: 144,
849
+ L: 149,
832
850
  S: this,
833
851
  C: (f, a) => f(...a)
834
852
  });
@@ -852,7 +870,7 @@ var Teleport = class {
852
870
  _setExtension(extensionName, extension) {
853
871
  (0, import_invariant3.invariant)(!extensionName.includes("/"), "Invalid extension name", {
854
872
  F: __dxlog_file4,
855
- L: 168,
873
+ L: 173,
856
874
  S: this,
857
875
  A: [
858
876
  "!extensionName.includes('/')",
@@ -861,7 +879,7 @@ var Teleport = class {
861
879
  });
862
880
  (0, import_invariant3.invariant)(!this._extensions.has(extensionName), "Extension already exists", {
863
881
  F: __dxlog_file4,
864
- L: 169,
882
+ L: 174,
865
883
  S: this,
866
884
  A: [
867
885
  "!this._extensions.has(extensionName)",
@@ -871,16 +889,15 @@ var Teleport = class {
871
889
  this._extensions.set(extensionName, extension);
872
890
  }
873
891
  async _openExtension(extensionName) {
874
- var _a;
875
892
  (0, import_log3.log)("open extension", {
876
893
  extensionName
877
894
  }, {
878
895
  F: __dxlog_file4,
879
- L: 174,
896
+ L: 179,
880
897
  S: this,
881
898
  C: (f, a) => f(...a)
882
899
  });
883
- const extension = (_a = this._extensions.get(extensionName)) != null ? _a : (0, import_debug2.failUndefined)();
900
+ const extension = this._extensions.get(extensionName) ?? (0, import_debug2.failUndefined)();
884
901
  const context = {
885
902
  initiator: this.initiator,
886
903
  localPeerId: this.localPeerId,
@@ -888,7 +905,7 @@ var Teleport = class {
888
905
  createPort: async (channelName, opts) => {
889
906
  (0, import_invariant3.invariant)(!channelName.includes("/"), "Invalid channel name", {
890
907
  F: __dxlog_file4,
891
- L: 182,
908
+ L: 187,
892
909
  S: this,
893
910
  A: [
894
911
  "!channelName.includes('/')",
@@ -900,7 +917,7 @@ var Teleport = class {
900
917
  createStream: async (channelName, opts) => {
901
918
  (0, import_invariant3.invariant)(!channelName.includes("/"), "Invalid channel name", {
902
919
  F: __dxlog_file4,
903
- L: 186,
920
+ L: 191,
904
921
  S: this,
905
922
  A: [
906
923
  "!channelName.includes('/')",
@@ -920,7 +937,7 @@ var Teleport = class {
920
937
  extensionName
921
938
  }, {
922
939
  F: __dxlog_file4,
923
- L: 197,
940
+ L: 202,
924
941
  S: this,
925
942
  C: (f, a) => f(...a)
926
943
  });
@@ -1200,11 +1217,9 @@ var TestExtension = class {
1200
1217
  this.closed = new import_async4.Trigger();
1201
1218
  }
1202
1219
  get remotePeerId() {
1203
- var _a;
1204
- return (_a = this.extensionContext) == null ? void 0 : _a.remotePeerId;
1220
+ return this.extensionContext?.remotePeerId;
1205
1221
  }
1206
1222
  async onOpen(context) {
1207
- var _a, _b;
1208
1223
  (0, import_log5.log)("onOpen", {
1209
1224
  localPeerId: context.localPeerId,
1210
1225
  remotePeerId: context.remotePeerId
@@ -1239,11 +1254,10 @@ var TestExtension = class {
1239
1254
  timeout: 2e3
1240
1255
  });
1241
1256
  await this._rpc.open();
1242
- await ((_b = (_a = this.callbacks).onOpen) == null ? void 0 : _b.call(_a));
1257
+ await this.callbacks.onOpen?.();
1243
1258
  this.open.wake();
1244
1259
  }
1245
1260
  async onClose(err) {
1246
- var _a, _b, _c;
1247
1261
  (0, import_log5.log)("onClose", {
1248
1262
  err
1249
1263
  }, {
@@ -1252,9 +1266,9 @@ var TestExtension = class {
1252
1266
  S: this,
1253
1267
  C: (f, a) => f(...a)
1254
1268
  });
1255
- await ((_b = (_a = this.callbacks).onClose) == null ? void 0 : _b.call(_a));
1269
+ await this.callbacks.onClose?.();
1256
1270
  this.closed.wake();
1257
- await ((_c = this._rpc) == null ? void 0 : _c.close());
1271
+ await this._rpc?.close();
1258
1272
  }
1259
1273
  async test(message = "test") {
1260
1274
  await this.open.wait({
@@ -1277,8 +1291,7 @@ var TestExtension = class {
1277
1291
  * Force-close the connection.
1278
1292
  */
1279
1293
  async closeConnection(err) {
1280
- var _a;
1281
- (_a = this.extensionContext) == null ? void 0 : _a.close(err);
1294
+ this.extensionContext?.close(err);
1282
1295
  }
1283
1296
  };
1284
1297
 
@@ -1298,8 +1311,7 @@ var TestExtensionWithStreams = class {
1298
1311
  this._streams = /* @__PURE__ */ new Map();
1299
1312
  }
1300
1313
  get remotePeerId() {
1301
- var _a;
1302
- return (_a = this.extensionContext) == null ? void 0 : _a.remotePeerId;
1314
+ return this.extensionContext?.remotePeerId;
1303
1315
  }
1304
1316
  async _openStream(streamTag, interval = 5, chunkSize = 2048) {
1305
1317
  (0, import_invariant6.invariant)(!this._streams.has(streamTag), `Stream already exists: ${streamTag}`, {
@@ -1350,7 +1362,6 @@ var TestExtensionWithStreams = class {
1350
1362
  networkStream.removeAllListeners();
1351
1363
  });
1352
1364
  streamEntry.reportingTimer = setInterval(() => {
1353
- var _a, _b;
1354
1365
  const { bytesSent, bytesReceived, sendErrors, receiveErrors } = streamEntry;
1355
1366
  import_log6.log.trace("dxos.test.stream-stats", {
1356
1367
  streamTag,
@@ -1358,8 +1369,8 @@ var TestExtensionWithStreams = class {
1358
1369
  bytesReceived,
1359
1370
  sendErrors,
1360
1371
  receiveErrors,
1361
- from: (_a = this.extensionContext) == null ? void 0 : _a.localPeerId,
1362
- to: (_b = this.extensionContext) == null ? void 0 : _b.remotePeerId
1372
+ from: this.extensionContext?.localPeerId,
1373
+ to: this.extensionContext?.remotePeerId
1363
1374
  }, {
1364
1375
  F: __dxlog_file7,
1365
1376
  L: 91,
@@ -1389,11 +1400,10 @@ var TestExtensionWithStreams = class {
1389
1400
  bytesReceived,
1390
1401
  sendErrors,
1391
1402
  receiveErrors,
1392
- runningTime: Date.now() - (startTimestamp != null ? startTimestamp : 0)
1403
+ runningTime: Date.now() - (startTimestamp ?? 0)
1393
1404
  };
1394
1405
  }
1395
1406
  async onOpen(context) {
1396
- var _a, _b;
1397
1407
  (0, import_log6.log)("onOpen", {
1398
1408
  localPeerId: context.localPeerId,
1399
1409
  remotePeerId: context.remotePeerId
@@ -1440,11 +1450,10 @@ var TestExtensionWithStreams = class {
1440
1450
  timeout: 2e3
1441
1451
  });
1442
1452
  await this._rpc.open();
1443
- await ((_b = (_a = this.callbacks).onOpen) == null ? void 0 : _b.call(_a));
1453
+ await this.callbacks.onOpen?.();
1444
1454
  this.open.wake();
1445
1455
  }
1446
1456
  async onClose(err) {
1447
- var _a, _b, _c;
1448
1457
  (0, import_log6.log)("onClose", {
1449
1458
  err
1450
1459
  }, {
@@ -1453,7 +1462,7 @@ var TestExtensionWithStreams = class {
1453
1462
  S: this,
1454
1463
  C: (f, a) => f(...a)
1455
1464
  });
1456
- await ((_b = (_a = this.callbacks).onClose) == null ? void 0 : _b.call(_a));
1465
+ await this.callbacks.onClose?.();
1457
1466
  this.closed.wake();
1458
1467
  for (const [streamTag, stream] of Object.entries(this._streams)) {
1459
1468
  (0, import_log6.log)("closing stream", {
@@ -1467,7 +1476,7 @@ var TestExtensionWithStreams = class {
1467
1476
  clearTimeout(stream.interval);
1468
1477
  stream.networkStream.destroy();
1469
1478
  }
1470
- await ((_c = this._rpc) == null ? void 0 : _c.close());
1479
+ await this._rpc?.close();
1471
1480
  }
1472
1481
  async addNewStream(streamLoadInterval, streamLoadChunkSize, streamTag) {
1473
1482
  await this.open.wait({
@@ -1528,8 +1537,7 @@ var TestExtensionWithStreams = class {
1528
1537
  * Force-close the connection.
1529
1538
  */
1530
1539
  async closeConnection(err) {
1531
- var _a;
1532
- (_a = this.extensionContext) == null ? void 0 : _a.close(err);
1540
+ this.extensionContext?.close(err);
1533
1541
  }
1534
1542
  };
1535
1543
 
@@ -1580,9 +1588,8 @@ var RpcExtension = class {
1580
1588
  await this._rpc.open();
1581
1589
  }
1582
1590
  async onClose(err) {
1583
- var _a;
1584
1591
  this._isClosed = true;
1585
- await ((_a = this._rpc) == null ? void 0 : _a.close());
1592
+ await this._rpc?.close();
1586
1593
  }
1587
1594
  close() {
1588
1595
  this._extensionContext.close();