@dxos/teleport 0.6.12-main.ed7cda7 → 0.6.12-staging.0b4bb48

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 (35) hide show
  1. package/dist/lib/{node-esm/chunk-K64VAYIG.mjs → browser/chunk-ISJQDU2V.mjs} +45 -164
  2. package/dist/lib/browser/chunk-ISJQDU2V.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +2 -7
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +1 -1
  7. package/dist/lib/node/{chunk-F45T5HZ2.cjs → chunk-TC7PLXKV.cjs} +47 -155
  8. package/dist/lib/node/chunk-TC7PLXKV.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +11 -11
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/testing/index.cjs +6 -6
  12. package/dist/lib/node/testing/index.cjs.map +1 -1
  13. package/dist/types/src/muxing/muxer.d.ts.map +1 -1
  14. package/dist/types/src/teleport.d.ts.map +1 -1
  15. package/package.json +17 -17
  16. package/src/muxing/balancer.test.ts +9 -5
  17. package/src/muxing/balancer.ts +1 -1
  18. package/src/muxing/framer.test.ts +10 -6
  19. package/src/muxing/muxer.test.ts +7 -3
  20. package/src/muxing/muxer.ts +0 -3
  21. package/src/muxing/rpc-port.test.ts +1 -2
  22. package/src/teleport.test.ts +5 -4
  23. package/src/teleport.ts +0 -1
  24. package/src/testing/test-extension-with-streams.ts +2 -2
  25. package/testing.d.ts +11 -0
  26. package/testing.js +5 -0
  27. package/dist/lib/browser/chunk-NLPOT6AJ.mjs +0 -2130
  28. package/dist/lib/browser/chunk-NLPOT6AJ.mjs.map +0 -7
  29. package/dist/lib/node/chunk-F45T5HZ2.cjs.map +0 -7
  30. package/dist/lib/node-esm/chunk-K64VAYIG.mjs.map +0 -7
  31. package/dist/lib/node-esm/index.mjs +0 -86
  32. package/dist/lib/node-esm/index.mjs.map +0 -7
  33. package/dist/lib/node-esm/meta.json +0 -1
  34. package/dist/lib/node-esm/testing/index.mjs +0 -16
  35. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
@@ -1,115 +1,14 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
-
28
- // node_modules/.pnpm/varint@6.0.0/node_modules/varint/encode.js
29
- var require_encode = __commonJS({
30
- "node_modules/.pnpm/varint@6.0.0/node_modules/varint/encode.js"(exports, module) {
31
- module.exports = encode;
32
- var MSB = 128;
33
- var REST = 127;
34
- var MSBALL = ~REST;
35
- var INT = Math.pow(2, 31);
36
- function encode(num, out, offset) {
37
- if (Number.MAX_SAFE_INTEGER && num > Number.MAX_SAFE_INTEGER) {
38
- encode.bytes = 0;
39
- throw new RangeError("Could not encode varint");
40
- }
41
- out = out || [];
42
- offset = offset || 0;
43
- var oldOffset = offset;
44
- while (num >= INT) {
45
- out[offset++] = num & 255 | MSB;
46
- num /= 128;
47
- }
48
- while (num & MSBALL) {
49
- out[offset++] = num & 255 | MSB;
50
- num >>>= 7;
51
- }
52
- out[offset] = num | 0;
53
- encode.bytes = offset - oldOffset + 1;
54
- return out;
55
- }
56
- }
57
- });
58
-
59
- // node_modules/.pnpm/varint@6.0.0/node_modules/varint/decode.js
60
- var require_decode = __commonJS({
61
- "node_modules/.pnpm/varint@6.0.0/node_modules/varint/decode.js"(exports, module) {
62
- module.exports = read;
63
- var MSB = 128;
64
- var REST = 127;
65
- function read(buf, offset) {
66
- var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
67
- do {
68
- if (counter >= l || shift > 49) {
69
- read.bytes = 0;
70
- throw new RangeError("Could not decode varint");
71
- }
72
- b = buf[counter++];
73
- res += shift < 28 ? (b & REST) << shift : (b & REST) * Math.pow(2, shift);
74
- shift += 7;
75
- } while (b >= MSB);
76
- read.bytes = counter - offset;
77
- return res;
78
- }
79
- }
80
- });
1
+ import "@dxos/node-std/globals";
81
2
 
82
- // node_modules/.pnpm/varint@6.0.0/node_modules/varint/length.js
83
- var require_length = __commonJS({
84
- "node_modules/.pnpm/varint@6.0.0/node_modules/varint/length.js"(exports, module) {
85
- var N1 = Math.pow(2, 7);
86
- var N2 = Math.pow(2, 14);
87
- var N3 = Math.pow(2, 21);
88
- var N4 = Math.pow(2, 28);
89
- var N5 = Math.pow(2, 35);
90
- var N6 = Math.pow(2, 42);
91
- var N7 = Math.pow(2, 49);
92
- var N8 = Math.pow(2, 56);
93
- var N9 = Math.pow(2, 63);
94
- module.exports = function(value) {
95
- return value < N1 ? 1 : value < N2 ? 2 : value < N3 ? 3 : value < N4 ? 4 : value < N5 ? 5 : value < N6 ? 6 : value < N7 ? 7 : value < N8 ? 8 : value < N9 ? 9 : 10;
96
- };
97
- }
98
- });
99
-
100
- // node_modules/.pnpm/varint@6.0.0/node_modules/varint/index.js
101
- var require_varint = __commonJS({
102
- "node_modules/.pnpm/varint@6.0.0/node_modules/varint/index.js"(exports, module) {
103
- module.exports = {
104
- encode: require_encode(),
105
- decode: require_decode(),
106
- encodingLength: require_length()
107
- };
108
- }
109
- });
3
+ // inject-globals:@inject-globals
4
+ import {
5
+ global,
6
+ Buffer,
7
+ process
8
+ } from "@dxos/node-std/inject-globals";
110
9
 
111
10
  // packages/core/mesh/teleport/src/testing/test-builder.ts
112
- import { pipeline } from "node:stream";
11
+ import { pipeline } from "@dxos/node-std/stream";
113
12
  import { waitForCondition } from "@dxos/async";
114
13
  import { invariant as invariant5 } from "@dxos/invariant";
115
14
  import { PublicKey as PublicKey2 } from "@dxos/keys";
@@ -277,7 +176,7 @@ var ControlExtension = class {
277
176
  };
278
177
 
279
178
  // packages/core/mesh/teleport/src/muxing/framer.ts
280
- import { Duplex } from "node:stream";
179
+ import { Duplex } from "@dxos/node-std/stream";
281
180
  import { Event } from "@dxos/async";
282
181
  import { invariant } from "@dxos/invariant";
283
182
  import { log as log2 } from "@dxos/log";
@@ -443,7 +342,7 @@ var encodeFrame = (payload) => {
443
342
  };
444
343
 
445
344
  // packages/core/mesh/teleport/src/muxing/muxer.ts
446
- import { Duplex as Duplex2 } from "node:stream";
345
+ import { Duplex as Duplex2 } from "@dxos/node-std/stream";
447
346
  import { scheduleTaskInterval as scheduleTaskInterval2, Event as Event3, Trigger, asyncTimeout as asyncTimeout2 } from "@dxos/async";
448
347
  import { Context as Context2 } from "@dxos/context";
449
348
  import { failUndefined } from "@dxos/debug";
@@ -453,7 +352,7 @@ import { TimeoutError } from "@dxos/protocols";
453
352
  import { schema as schema2 } from "@dxos/protocols/proto";
454
353
 
455
354
  // packages/core/mesh/teleport/src/muxing/balancer.ts
456
- var import_varint = __toESM(require_varint());
355
+ import * as varint from "varint";
457
356
  import { Event as Event2 } from "@dxos/async";
458
357
  import { invariant as invariant2 } from "@dxos/invariant";
459
358
  import { log as log3 } from "@dxos/log";
@@ -635,23 +534,23 @@ var Balancer = class {
635
534
  }
636
535
  };
637
536
  var encodeChunk = ({ channelId, dataLength, chunk }) => {
638
- const channelTagLength = import_varint.default.encodingLength(channelId);
639
- const dataLengthLength = dataLength ? import_varint.default.encodingLength(dataLength) : 0;
537
+ const channelTagLength = varint.encodingLength(channelId);
538
+ const dataLengthLength = dataLength ? varint.encodingLength(dataLength) : 0;
640
539
  const message = Buffer.allocUnsafe(channelTagLength + dataLengthLength + chunk.length);
641
- import_varint.default.encode(channelId, message);
540
+ varint.encode(channelId, message);
642
541
  if (dataLength) {
643
- import_varint.default.encode(dataLength, message, channelTagLength);
542
+ varint.encode(dataLength, message, channelTagLength);
644
543
  }
645
544
  message.set(chunk, channelTagLength + dataLengthLength);
646
545
  return message;
647
546
  };
648
547
  var decodeChunk = (data, withLength) => {
649
- const channelId = import_varint.default.decode(data);
548
+ const channelId = varint.decode(data);
650
549
  let dataLength;
651
- let offset = import_varint.default.decode.bytes;
550
+ let offset = varint.decode.bytes;
652
551
  if (withLength(channelId)) {
653
- dataLength = import_varint.default.decode(data, offset);
654
- offset += import_varint.default.decode.bytes;
552
+ dataLength = varint.decode(data, offset);
553
+ offset += varint.decode.bytes;
655
554
  }
656
555
  const chunk = data.subarray(offset);
657
556
  return {
@@ -1059,16 +958,6 @@ var Muxer = class {
1059
958
  }, channel.id, timeout);
1060
959
  }
1061
960
  _destroyChannel(channel, err) {
1062
- if (err) {
1063
- log4.warn("destroying channel with error", {
1064
- err
1065
- }, {
1066
- F: __dxlog_file4,
1067
- L: 465,
1068
- S: this,
1069
- C: (f, a) => f(...a)
1070
- });
1071
- }
1072
961
  if (channel.destroy) {
1073
962
  channel.destroy(err);
1074
963
  }
@@ -1144,18 +1033,10 @@ var Teleport = class {
1144
1033
  constructor({ initiator, localPeerId, remotePeerId, ...rest }) {
1145
1034
  this._ctx = new Context3({
1146
1035
  onError: (err) => {
1147
- log5.info("error in teleport context", {
1148
- err
1149
- }, {
1150
- F: __dxlog_file5,
1151
- L: 40,
1152
- S: this,
1153
- C: (f, a) => f(...a)
1154
- });
1155
1036
  void this.destroy(err).catch(() => {
1156
1037
  log5.error("Error during destroy", err, {
1157
1038
  F: __dxlog_file5,
1158
- L: 42,
1039
+ L: 41,
1159
1040
  S: this,
1160
1041
  C: (f, a) => f(...a)
1161
1042
  });
@@ -1173,7 +1054,7 @@ var Teleport = class {
1173
1054
  this._aborting = false;
1174
1055
  invariant4(typeof initiator === "boolean", void 0, {
1175
1056
  F: __dxlog_file5,
1176
- L: 63,
1057
+ L: 62,
1177
1058
  S: this,
1178
1059
  A: [
1179
1060
  "typeof initiator === 'boolean'",
@@ -1182,7 +1063,7 @@ var Teleport = class {
1182
1063
  });
1183
1064
  invariant4(PublicKey.isPublicKey(localPeerId), void 0, {
1184
1065
  F: __dxlog_file5,
1185
- L: 64,
1066
+ L: 63,
1186
1067
  S: this,
1187
1068
  A: [
1188
1069
  "PublicKey.isPublicKey(localPeerId)",
@@ -1191,7 +1072,7 @@ var Teleport = class {
1191
1072
  });
1192
1073
  invariant4(PublicKey.isPublicKey(remotePeerId), void 0, {
1193
1074
  F: __dxlog_file5,
1194
- L: 65,
1075
+ L: 64,
1195
1076
  S: this,
1196
1077
  A: [
1197
1078
  "PublicKey.isPublicKey(remotePeerId)",
@@ -1210,13 +1091,13 @@ var Teleport = class {
1210
1091
  }
1211
1092
  log5.info("abort teleport due to onTimeout in ControlExtension", void 0, {
1212
1093
  F: __dxlog_file5,
1213
- L: 78,
1094
+ L: 77,
1214
1095
  S: this,
1215
1096
  C: (f, a) => f(...a)
1216
1097
  });
1217
1098
  this.abort(new TimeoutError2("control extension")).catch((err) => log5.catch(err, void 0, {
1218
1099
  F: __dxlog_file5,
1219
- L: 79,
1100
+ L: 78,
1220
1101
  S: this,
1221
1102
  C: (f, a) => f(...a)
1222
1103
  }));
@@ -1227,13 +1108,13 @@ var Teleport = class {
1227
1108
  name
1228
1109
  }, {
1229
1110
  F: __dxlog_file5,
1230
- L: 87,
1111
+ L: 86,
1231
1112
  S: this,
1232
1113
  C: (f, a) => f(...a)
1233
1114
  });
1234
1115
  invariant4(!this._remoteExtensions.has(name), "Remote extension already exists", {
1235
1116
  F: __dxlog_file5,
1236
- L: 88,
1117
+ L: 87,
1237
1118
  S: this,
1238
1119
  A: [
1239
1120
  "!this._remoteExtensions.has(name)",
@@ -1254,7 +1135,7 @@ var Teleport = class {
1254
1135
  if (this._destroying || this._aborting) {
1255
1136
  log5("destroy teleport due to muxer stream close, skipping due to already destroying/aborting", void 0, {
1256
1137
  F: __dxlog_file5,
1257
- L: 104,
1138
+ L: 103,
1258
1139
  S: this,
1259
1140
  C: (f, a) => f(...a)
1260
1141
  });
@@ -1277,7 +1158,7 @@ var Teleport = class {
1277
1158
  channels: stats.channels
1278
1159
  }, {
1279
1160
  F: __dxlog_file5,
1280
- L: 117,
1161
+ L: 116,
1281
1162
  S: this,
1282
1163
  C: (f, a) => f(...a)
1283
1164
  });
@@ -1302,7 +1183,7 @@ var Teleport = class {
1302
1183
  this._sessionId = sessionId;
1303
1184
  log5("open", void 0, {
1304
1185
  F: __dxlog_file5,
1305
- L: 151,
1186
+ L: 150,
1306
1187
  S: this,
1307
1188
  C: (f, a) => f(...a)
1308
1189
  });
@@ -1330,7 +1211,7 @@ var Teleport = class {
1330
1211
  } catch (err2) {
1331
1212
  log5.catch(err2, void 0, {
1332
1213
  F: __dxlog_file5,
1333
- L: 181,
1214
+ L: 180,
1334
1215
  S: this,
1335
1216
  C: (f, a) => f(...a)
1336
1217
  });
@@ -1346,7 +1227,7 @@ var Teleport = class {
1346
1227
  extensionsCount: this._extensions.size
1347
1228
  }, {
1348
1229
  F: __dxlog_file5,
1349
- L: 194,
1230
+ L: 193,
1350
1231
  S: this,
1351
1232
  C: (f, a) => f(...a)
1352
1233
  });
@@ -1362,7 +1243,7 @@ var Teleport = class {
1362
1243
  name: extension.constructor.name
1363
1244
  }, {
1364
1245
  F: __dxlog_file5,
1365
- L: 206,
1246
+ L: 205,
1366
1247
  S: this,
1367
1248
  C: (f, a) => f(...a)
1368
1249
  });
@@ -1371,14 +1252,14 @@ var Teleport = class {
1371
1252
  name: extension.constructor.name
1372
1253
  }, {
1373
1254
  F: __dxlog_file5,
1374
- L: 208,
1255
+ L: 207,
1375
1256
  S: this,
1376
1257
  C: (f, a) => f(...a)
1377
1258
  });
1378
1259
  } catch (err2) {
1379
1260
  log5.catch(err2, void 0, {
1380
1261
  F: __dxlog_file5,
1381
- L: 210,
1262
+ L: 209,
1382
1263
  S: this,
1383
1264
  C: (f, a) => f(...a)
1384
1265
  });
@@ -1387,7 +1268,7 @@ var Teleport = class {
1387
1268
  await this._muxer.close();
1388
1269
  log5("teleport destroyed", void 0, {
1389
1270
  F: __dxlog_file5,
1390
- L: 215,
1271
+ L: 214,
1391
1272
  S: this,
1392
1273
  C: (f, a) => f(...a)
1393
1274
  });
@@ -1400,7 +1281,7 @@ var Teleport = class {
1400
1281
  name
1401
1282
  }, {
1402
1283
  F: __dxlog_file5,
1403
- L: 223,
1284
+ L: 222,
1404
1285
  S: this,
1405
1286
  C: (f, a) => f(...a)
1406
1287
  });
@@ -1424,7 +1305,7 @@ var Teleport = class {
1424
1305
  _setExtension(extensionName, extension) {
1425
1306
  invariant4(!extensionName.includes("/"), "Invalid extension name", {
1426
1307
  F: __dxlog_file5,
1427
- L: 247,
1308
+ L: 246,
1428
1309
  S: this,
1429
1310
  A: [
1430
1311
  "!extensionName.includes('/')",
@@ -1433,7 +1314,7 @@ var Teleport = class {
1433
1314
  });
1434
1315
  invariant4(!this._extensions.has(extensionName), "Extension already exists", {
1435
1316
  F: __dxlog_file5,
1436
- L: 248,
1317
+ L: 247,
1437
1318
  S: this,
1438
1319
  A: [
1439
1320
  "!this._extensions.has(extensionName)",
@@ -1447,7 +1328,7 @@ var Teleport = class {
1447
1328
  extensionName
1448
1329
  }, {
1449
1330
  F: __dxlog_file5,
1450
- L: 253,
1331
+ L: 252,
1451
1332
  S: this,
1452
1333
  C: (f, a) => f(...a)
1453
1334
  });
@@ -1459,7 +1340,7 @@ var Teleport = class {
1459
1340
  createPort: async (channelName, opts) => {
1460
1341
  invariant4(!channelName.includes("/"), "Invalid channel name", {
1461
1342
  F: __dxlog_file5,
1462
- L: 261,
1343
+ L: 260,
1463
1344
  S: this,
1464
1345
  A: [
1465
1346
  "!channelName.includes('/')",
@@ -1471,7 +1352,7 @@ var Teleport = class {
1471
1352
  createStream: async (channelName, opts) => {
1472
1353
  invariant4(!channelName.includes("/"), "Invalid channel name", {
1473
1354
  F: __dxlog_file5,
1474
- L: 265,
1355
+ L: 264,
1475
1356
  S: this,
1476
1357
  A: [
1477
1358
  "!channelName.includes('/')",
@@ -1491,7 +1372,7 @@ var Teleport = class {
1491
1372
  extensionName
1492
1373
  }, {
1493
1374
  F: __dxlog_file5,
1494
- L: 276,
1375
+ L: 275,
1495
1376
  S: this,
1496
1377
  C: (f, a) => f(...a)
1497
1378
  });
@@ -1820,7 +1701,7 @@ var TestExtension = class {
1820
1701
  };
1821
1702
 
1822
1703
  // packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts
1823
- import { randomBytes } from "node:crypto";
1704
+ import { randomBytes } from "@dxos/node-std/crypto";
1824
1705
  import { Trigger as Trigger3 } from "@dxos/async";
1825
1706
  import { invariant as invariant7 } from "@dxos/invariant";
1826
1707
  import { log as log8 } from "@dxos/log";
@@ -2091,4 +1972,4 @@ export {
2091
1972
  TestExtension,
2092
1973
  TestExtensionWithStreams
2093
1974
  };
2094
- //# sourceMappingURL=chunk-K64VAYIG.mjs.map
1975
+ //# sourceMappingURL=chunk-ISJQDU2V.mjs.map