@dxos/teleport 0.3.9-main.3a0f16f → 0.3.9-main.4e30508

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.
@@ -12,7 +12,7 @@ import { Context as Context3 } from "@dxos/context";
12
12
  import { failUndefined as failUndefined2 } from "@dxos/debug";
13
13
  import { invariant as invariant4 } from "@dxos/invariant";
14
14
  import { PublicKey } from "@dxos/keys";
15
- import { log as log5 } from "@dxos/log";
15
+ import { log as log5, logInfo as logInfo2 } from "@dxos/log";
16
16
  import { RpcClosedError as RpcClosedError2, TimeoutError as TimeoutError2 } from "@dxos/protocols";
17
17
 
18
18
  // packages/core/mesh/teleport/src/control-extension.ts
@@ -329,7 +329,7 @@ import { scheduleTaskInterval as scheduleTaskInterval2, Event as Event3, Trigger
329
329
  import { Context as Context2 } from "@dxos/context";
330
330
  import { failUndefined } from "@dxos/debug";
331
331
  import { invariant as invariant3 } from "@dxos/invariant";
332
- import { log as log4 } from "@dxos/log";
332
+ import { log as log4, logInfo } from "@dxos/log";
333
333
  import { schema as schema2, TimeoutError } from "@dxos/protocols";
334
334
 
335
335
  // packages/core/mesh/teleport/src/muxing/balancer.ts
@@ -542,6 +542,16 @@ var decodeChunk = (data, withLength) => {
542
542
  };
543
543
 
544
544
  // packages/core/mesh/teleport/src/muxing/muxer.ts
545
+ function _ts_decorate(decorators, target, key, desc) {
546
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
547
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
548
+ r = Reflect.decorate(decorators, target, key, desc);
549
+ else
550
+ for (var i = decorators.length - 1; i >= 0; i--)
551
+ if (d = decorators[i])
552
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
553
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
554
+ }
545
555
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/muxing/muxer.ts";
546
556
  var Command = schema2.getCodecForType("dxos.mesh.muxer.Command");
547
557
  var DEFAULT_SEND_COMMAND_TIMEOUT = 6e4;
@@ -569,6 +579,12 @@ var Muxer = class {
569
579
  await this._handleCommand(Command.decode(msg));
570
580
  });
571
581
  }
582
+ setSessionId(sessionId) {
583
+ this._sessionId = sessionId;
584
+ }
585
+ get sessionIdString() {
586
+ return this._sessionId ? this._sessionId.truncate() : "none";
587
+ }
572
588
  /**
573
589
  * Creates a duplex Node.js-style stream.
574
590
  * The remote peer is expected to call `createStream` with the same tag.
@@ -582,7 +598,7 @@ var Muxer = class {
582
598
  });
583
599
  invariant3(!channel.push, `Channel already open: ${tag}`, {
584
600
  F: __dxlog_file4,
585
- L: 140,
601
+ L: 151,
586
602
  S: this,
587
603
  A: [
588
604
  "!channel.push",
@@ -638,7 +654,7 @@ var Muxer = class {
638
654
  });
639
655
  invariant3(!channel.push, `Channel already open: ${tag}`, {
640
656
  F: __dxlog_file4,
641
- L: 200,
657
+ L: 211,
642
658
  S: this,
643
659
  A: [
644
660
  "!channel.push",
@@ -662,7 +678,7 @@ var Muxer = class {
662
678
  subscribe: (cb) => {
663
679
  invariant3(!callback, "Only one subscriber is allowed", {
664
680
  F: __dxlog_file4,
665
- L: 222,
681
+ L: 233,
666
682
  S: this,
667
683
  A: [
668
684
  "!callback",
@@ -695,7 +711,7 @@ var Muxer = class {
695
711
  if (this._destroying) {
696
712
  log4("already destroying, ignoring graceful close request", void 0, {
697
713
  F: __dxlog_file4,
698
- L: 255,
714
+ L: 266,
699
715
  S: this,
700
716
  C: (f, a) => f(...a)
701
717
  });
@@ -704,7 +720,7 @@ var Muxer = class {
704
720
  if (this._closing) {
705
721
  log4("already closing, ignoring graceful close request", void 0, {
706
722
  F: __dxlog_file4,
707
- L: 259,
723
+ L: 270,
708
724
  S: this,
709
725
  C: (f, a) => f(...a)
710
726
  });
@@ -720,7 +736,7 @@ var Muxer = class {
720
736
  err: err2
721
737
  }, {
722
738
  F: __dxlog_file4,
723
- L: 274,
739
+ L: 285,
724
740
  S: this,
725
741
  C: (f, a) => f(...a)
726
742
  });
@@ -742,7 +758,7 @@ var Muxer = class {
742
758
  if (this._destroying) {
743
759
  log4("already destroying, ignoring destroy request", void 0, {
744
760
  F: __dxlog_file4,
745
- L: 296,
761
+ L: 307,
746
762
  S: this,
747
763
  C: (f, a) => f(...a)
748
764
  });
@@ -753,7 +769,7 @@ var Muxer = class {
753
769
  if (this._closing) {
754
770
  log4("destroy cancelling graceful close", void 0, {
755
771
  F: __dxlog_file4,
756
- L: 302,
772
+ L: 313,
757
773
  S: this,
758
774
  C: (f, a) => f(...a)
759
775
  });
@@ -768,7 +784,7 @@ var Muxer = class {
768
784
  err: err2
769
785
  }, {
770
786
  F: __dxlog_file4,
771
- L: 315,
787
+ L: 326,
772
788
  S: this,
773
789
  C: (f, a) => f(...a)
774
790
  });
@@ -779,7 +795,7 @@ var Muxer = class {
779
795
  err: err2
780
796
  }, {
781
797
  F: __dxlog_file4,
782
- L: 320,
798
+ L: 331,
783
799
  S: this,
784
800
  C: (f, a) => f(...a)
785
801
  });
@@ -790,7 +806,7 @@ var Muxer = class {
790
806
  if (this._disposed) {
791
807
  log4("already destroyed, ignoring dispose request", void 0, {
792
808
  F: __dxlog_file4,
793
- L: 328,
809
+ L: 339,
794
810
  S: this,
795
811
  C: (f, a) => f(...a)
796
812
  });
@@ -813,7 +829,7 @@ var Muxer = class {
813
829
  cmd
814
830
  }, {
815
831
  F: __dxlog_file4,
816
- L: 351,
832
+ L: 362,
817
833
  S: this,
818
834
  C: (f, a) => f(...a)
819
835
  });
@@ -823,7 +839,7 @@ var Muxer = class {
823
839
  if (!this._closing) {
824
840
  log4("received peer close, initiating my own graceful close", void 0, {
825
841
  F: __dxlog_file4,
826
- L: 357,
842
+ L: 368,
827
843
  S: this,
828
844
  C: (f, a) => f(...a)
829
845
  });
@@ -831,7 +847,7 @@ var Muxer = class {
831
847
  } else {
832
848
  log4("received close from peer, already closing", void 0, {
833
849
  F: __dxlog_file4,
834
- L: 360,
850
+ L: 371,
835
851
  S: this,
836
852
  C: (f, a) => f(...a)
837
853
  });
@@ -860,7 +876,7 @@ var Muxer = class {
860
876
  tag: stream.tag
861
877
  }, {
862
878
  F: __dxlog_file4,
863
- L: 389,
879
+ L: 400,
864
880
  S: this,
865
881
  C: (f, a) => f(...a)
866
882
  });
@@ -875,7 +891,7 @@ var Muxer = class {
875
891
  cmd
876
892
  }, {
877
893
  F: __dxlog_file4,
878
- L: 398,
894
+ L: 409,
879
895
  S: this,
880
896
  C: (f, a) => f(...a)
881
897
  });
@@ -923,7 +939,7 @@ var Muxer = class {
923
939
  threshold: MAX_SAFE_FRAME_SIZE
924
940
  }, {
925
941
  F: __dxlog_file4,
926
- L: 439,
942
+ L: 450,
927
943
  S: this,
928
944
  C: (f, a) => f(...a)
929
945
  });
@@ -998,9 +1014,12 @@ var Muxer = class {
998
1014
  this.statsUpdated.emit(this._lastStats);
999
1015
  }
1000
1016
  };
1017
+ _ts_decorate([
1018
+ logInfo
1019
+ ], Muxer.prototype, "sessionIdString", null);
1001
1020
 
1002
1021
  // packages/core/mesh/teleport/src/teleport.ts
1003
- function _ts_decorate(decorators, target, key, desc) {
1022
+ function _ts_decorate2(decorators, target, key, desc) {
1004
1023
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1005
1024
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1006
1025
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1020,7 +1039,7 @@ var Teleport = class {
1020
1039
  void this.destroy(err).catch(() => {
1021
1040
  log5.error("Error during destroy", err, {
1022
1041
  F: __dxlog_file5,
1023
- L: 38,
1042
+ L: 39,
1024
1043
  S: this,
1025
1044
  C: (f, a) => f(...a)
1026
1045
  });
@@ -1035,7 +1054,7 @@ var Teleport = class {
1035
1054
  this._aborting = false;
1036
1055
  invariant4(typeof initiator === "boolean", void 0, {
1037
1056
  F: __dxlog_file5,
1038
- L: 55,
1057
+ L: 56,
1039
1058
  S: this,
1040
1059
  A: [
1041
1060
  "typeof initiator === 'boolean'",
@@ -1044,7 +1063,7 @@ var Teleport = class {
1044
1063
  });
1045
1064
  invariant4(PublicKey.isPublicKey(localPeerId), void 0, {
1046
1065
  F: __dxlog_file5,
1047
- L: 56,
1066
+ L: 57,
1048
1067
  S: this,
1049
1068
  A: [
1050
1069
  "PublicKey.isPublicKey(localPeerId)",
@@ -1053,7 +1072,7 @@ var Teleport = class {
1053
1072
  });
1054
1073
  invariant4(PublicKey.isPublicKey(remotePeerId), void 0, {
1055
1074
  F: __dxlog_file5,
1056
- L: 57,
1075
+ L: 58,
1057
1076
  S: this,
1058
1077
  A: [
1059
1078
  "PublicKey.isPublicKey(remotePeerId)",
@@ -1072,13 +1091,13 @@ var Teleport = class {
1072
1091
  }
1073
1092
  log5.info("abort teleport due to onTimeout in ControlExtension", void 0, {
1074
1093
  F: __dxlog_file5,
1075
- L: 70,
1094
+ L: 71,
1076
1095
  S: this,
1077
1096
  C: (f, a) => f(...a)
1078
1097
  });
1079
1098
  this.abort(new TimeoutError2("control extension")).catch((err) => log5.catch(err, void 0, {
1080
1099
  F: __dxlog_file5,
1081
- L: 71,
1100
+ L: 72,
1082
1101
  S: this,
1083
1102
  C: (f, a) => f(...a)
1084
1103
  }));
@@ -1089,13 +1108,13 @@ var Teleport = class {
1089
1108
  name
1090
1109
  }, {
1091
1110
  F: __dxlog_file5,
1092
- L: 79,
1111
+ L: 80,
1093
1112
  S: this,
1094
1113
  C: (f, a) => f(...a)
1095
1114
  });
1096
1115
  invariant4(!this._remoteExtensions.has(name), "Remote extension already exists", {
1097
1116
  F: __dxlog_file5,
1098
- L: 80,
1117
+ L: 81,
1099
1118
  S: this,
1100
1119
  A: [
1101
1120
  "!this._remoteExtensions.has(name)",
@@ -1116,7 +1135,7 @@ var Teleport = class {
1116
1135
  if (this._destroying || this._aborting) {
1117
1136
  log5("destroy teleport due to muxer stream close, skipping due to already destroying/aborting", void 0, {
1118
1137
  F: __dxlog_file5,
1119
- L: 96,
1138
+ L: 97,
1120
1139
  S: this,
1121
1140
  C: (f, a) => f(...a)
1122
1141
  });
@@ -1139,12 +1158,15 @@ var Teleport = class {
1139
1158
  channels: stats.channels
1140
1159
  }, {
1141
1160
  F: __dxlog_file5,
1142
- L: 109,
1161
+ L: 110,
1143
1162
  S: this,
1144
1163
  C: (f, a) => f(...a)
1145
1164
  });
1146
1165
  });
1147
1166
  }
1167
+ get sessionIdString() {
1168
+ return this._sessionId ? this._sessionId.truncate() : "none";
1169
+ }
1148
1170
  get stream() {
1149
1171
  return this._muxer.stream;
1150
1172
  }
@@ -1154,10 +1176,18 @@ var Teleport = class {
1154
1176
  /**
1155
1177
  * Blocks until the handshake is complete.
1156
1178
  */
1157
- async open() {
1179
+ async open(sessionId = PublicKey.random()) {
1180
+ this._sessionId = sessionId;
1181
+ log5("open", void 0, {
1182
+ F: __dxlog_file5,
1183
+ L: 144,
1184
+ S: this,
1185
+ C: (f, a) => f(...a)
1186
+ });
1158
1187
  this._setExtension("dxos.mesh.teleport.control", this._control);
1159
1188
  await this._openExtension("dxos.mesh.teleport.control");
1160
1189
  this._open = true;
1190
+ this._muxer.setSessionId(sessionId);
1161
1191
  }
1162
1192
  async close(err) {
1163
1193
  await this.destroy(err);
@@ -1177,7 +1207,7 @@ var Teleport = class {
1177
1207
  } catch (err2) {
1178
1208
  log5.catch(err2, void 0, {
1179
1209
  F: __dxlog_file5,
1180
- L: 162,
1210
+ L: 173,
1181
1211
  S: this,
1182
1212
  C: (f, a) => f(...a)
1183
1213
  });
@@ -1200,7 +1230,7 @@ var Teleport = class {
1200
1230
  } catch (err2) {
1201
1231
  log5.catch(err2, void 0, {
1202
1232
  F: __dxlog_file5,
1203
- L: 186,
1233
+ L: 197,
1204
1234
  S: this,
1205
1235
  C: (f, a) => f(...a)
1206
1236
  });
@@ -1216,7 +1246,7 @@ var Teleport = class {
1216
1246
  name
1217
1247
  }, {
1218
1248
  F: __dxlog_file5,
1219
- L: 198,
1249
+ L: 209,
1220
1250
  S: this,
1221
1251
  C: (f, a) => f(...a)
1222
1252
  });
@@ -1240,7 +1270,7 @@ var Teleport = class {
1240
1270
  _setExtension(extensionName, extension) {
1241
1271
  invariant4(!extensionName.includes("/"), "Invalid extension name", {
1242
1272
  F: __dxlog_file5,
1243
- L: 222,
1273
+ L: 233,
1244
1274
  S: this,
1245
1275
  A: [
1246
1276
  "!extensionName.includes('/')",
@@ -1249,7 +1279,7 @@ var Teleport = class {
1249
1279
  });
1250
1280
  invariant4(!this._extensions.has(extensionName), "Extension already exists", {
1251
1281
  F: __dxlog_file5,
1252
- L: 223,
1282
+ L: 234,
1253
1283
  S: this,
1254
1284
  A: [
1255
1285
  "!this._extensions.has(extensionName)",
@@ -1263,7 +1293,7 @@ var Teleport = class {
1263
1293
  extensionName
1264
1294
  }, {
1265
1295
  F: __dxlog_file5,
1266
- L: 228,
1296
+ L: 239,
1267
1297
  S: this,
1268
1298
  C: (f, a) => f(...a)
1269
1299
  });
@@ -1275,7 +1305,7 @@ var Teleport = class {
1275
1305
  createPort: async (channelName, opts) => {
1276
1306
  invariant4(!channelName.includes("/"), "Invalid channel name", {
1277
1307
  F: __dxlog_file5,
1278
- L: 236,
1308
+ L: 247,
1279
1309
  S: this,
1280
1310
  A: [
1281
1311
  "!channelName.includes('/')",
@@ -1287,7 +1317,7 @@ var Teleport = class {
1287
1317
  createStream: async (channelName, opts) => {
1288
1318
  invariant4(!channelName.includes("/"), "Invalid channel name", {
1289
1319
  F: __dxlog_file5,
1290
- L: 240,
1320
+ L: 251,
1291
1321
  S: this,
1292
1322
  A: [
1293
1323
  "!channelName.includes('/')",
@@ -1307,16 +1337,19 @@ var Teleport = class {
1307
1337
  extensionName
1308
1338
  }, {
1309
1339
  F: __dxlog_file5,
1310
- L: 251,
1340
+ L: 262,
1311
1341
  S: this,
1312
1342
  C: (f, a) => f(...a)
1313
1343
  });
1314
1344
  }
1315
1345
  };
1316
- _ts_decorate([
1346
+ _ts_decorate2([
1347
+ logInfo2
1348
+ ], Teleport.prototype, "sessionIdString", null);
1349
+ _ts_decorate2([
1317
1350
  synchronized
1318
1351
  ], Teleport.prototype, "abort", null);
1319
- _ts_decorate([
1352
+ _ts_decorate2([
1320
1353
  synchronized
1321
1354
  ], Teleport.prototype, "destroy", null);
1322
1355
 
@@ -1463,7 +1496,7 @@ var TestPeer = class {
1463
1496
  ""
1464
1497
  ]
1465
1498
  });
1466
- await connection.teleport.open();
1499
+ await connection.teleport.open(PublicKey2.random());
1467
1500
  await this.onOpen(connection);
1468
1501
  }
1469
1502
  async closeConnection(connection) {
@@ -1899,4 +1932,4 @@ export {
1899
1932
  TestExtension,
1900
1933
  TestExtensionWithStreams
1901
1934
  };
1902
- //# sourceMappingURL=chunk-HMQK4NR4.mjs.map
1935
+ //# sourceMappingURL=chunk-M7U4KJA7.mjs.map