@dxos/teleport 0.8.4-main.a4bbb77 → 0.8.4-main.abd8ff62ef
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.
- package/dist/lib/{browser/chunk-32P6LS2F.mjs → neutral/chunk-LECANKBC.mjs} +299 -929
- package/dist/lib/neutral/chunk-LECANKBC.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/index.mjs +11 -32
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/{browser → neutral}/testing/index.mjs +1 -1
- package/dist/types/src/control-extension.d.ts.map +1 -1
- package/dist/types/src/muxing/balancer.d.ts.map +1 -1
- package/dist/types/src/muxing/framer.d.ts.map +1 -1
- package/dist/types/src/muxing/muxer.d.ts.map +1 -1
- package/dist/types/src/rpc-extension.d.ts +2 -2
- package/dist/types/src/rpc-extension.d.ts.map +1 -1
- package/dist/types/src/teleport.d.ts +2 -2
- package/dist/types/src/teleport.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-extension-with-streams.d.ts.map +1 -1
- package/dist/types/src/testing/test-extension.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -24
- package/src/muxing/balancer.test.ts +1 -2
- package/src/muxing/framer.test.ts +0 -1
- package/src/muxing/muxer.test.ts +0 -1
- package/src/muxing/muxer.ts +7 -3
- package/src/rpc-extension.ts +2 -2
- package/src/teleport.ts +3 -3
- package/dist/lib/browser/chunk-32P6LS2F.mjs.map +0 -7
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/node-esm/chunk-36FEQDYN.mjs +0 -2237
- package/dist/lib/node-esm/chunk-36FEQDYN.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -103
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/testing/index.mjs +0 -16
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- /package/dist/lib/{browser → neutral}/testing/index.mjs.map +0 -0
|
@@ -132,23 +132,26 @@ import { RpcClosedError } from "@dxos/protocols";
|
|
|
132
132
|
import { schema } from "@dxos/protocols/proto";
|
|
133
133
|
import { createProtoRpcPeer } from "@dxos/rpc";
|
|
134
134
|
import { Callback } from "@dxos/util";
|
|
135
|
-
function _define_property(obj, key, value) {
|
|
136
|
-
if (key in obj) {
|
|
137
|
-
Object.defineProperty(obj, key, {
|
|
138
|
-
value,
|
|
139
|
-
enumerable: true,
|
|
140
|
-
configurable: true,
|
|
141
|
-
writable: true
|
|
142
|
-
});
|
|
143
|
-
} else {
|
|
144
|
-
obj[key] = value;
|
|
145
|
-
}
|
|
146
|
-
return obj;
|
|
147
|
-
}
|
|
148
135
|
var __dxlog_file = "/__w/dxos/dxos/packages/core/mesh/teleport/src/control-extension.ts";
|
|
149
136
|
var HEARTBEAT_RTT_WARN_THRESH = 1e4;
|
|
150
137
|
var DEBUG_PRINT_HEARTBEAT = false;
|
|
151
138
|
var ControlExtension = class {
|
|
139
|
+
opts;
|
|
140
|
+
localPeerId;
|
|
141
|
+
remotePeerId;
|
|
142
|
+
_ctx = new Context({
|
|
143
|
+
onError: (err) => {
|
|
144
|
+
this._extensionContext.close(err);
|
|
145
|
+
}
|
|
146
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 17 });
|
|
147
|
+
onExtensionRegistered = new Callback();
|
|
148
|
+
_extensionContext;
|
|
149
|
+
_rpc;
|
|
150
|
+
constructor(opts, localPeerId, remotePeerId) {
|
|
151
|
+
this.opts = opts;
|
|
152
|
+
this.localPeerId = localPeerId;
|
|
153
|
+
this.remotePeerId = remotePeerId;
|
|
154
|
+
}
|
|
152
155
|
async registerExtension(name) {
|
|
153
156
|
await this._rpc.rpc.Control.registerExtension({
|
|
154
157
|
name
|
|
@@ -174,12 +177,7 @@ var ControlExtension = class {
|
|
|
174
177
|
ts: request.requestTimestamp,
|
|
175
178
|
localPeerId: this.localPeerId.truncate(),
|
|
176
179
|
remotePeerId: this.remotePeerId.truncate()
|
|
177
|
-
}, {
|
|
178
|
-
F: __dxlog_file,
|
|
179
|
-
L: 69,
|
|
180
|
-
S: this,
|
|
181
|
-
C: (f, a) => f(...a)
|
|
182
|
-
});
|
|
180
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 51, S: this });
|
|
183
181
|
}
|
|
184
182
|
return {
|
|
185
183
|
requestTimestamp: request.requestTimestamp
|
|
@@ -206,36 +204,21 @@ var ControlExtension = class {
|
|
|
206
204
|
rtt: now - resp.requestTimestamp.getTime(),
|
|
207
205
|
localPeerId: this.localPeerId.truncate(),
|
|
208
206
|
remotePeerId: this.remotePeerId.truncate()
|
|
209
|
-
}, {
|
|
210
|
-
F: __dxlog_file,
|
|
211
|
-
L: 107,
|
|
212
|
-
S: this,
|
|
213
|
-
C: (f, a) => f(...a)
|
|
214
|
-
});
|
|
207
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 79, S: this });
|
|
215
208
|
} else {
|
|
216
209
|
if (DEBUG_PRINT_HEARTBEAT) {
|
|
217
210
|
log("heartbeat RTT", {
|
|
218
211
|
rtt: now - resp.requestTimestamp.getTime(),
|
|
219
212
|
localPeerId: this.localPeerId.truncate(),
|
|
220
213
|
remotePeerId: this.remotePeerId.truncate()
|
|
221
|
-
}, {
|
|
222
|
-
F: __dxlog_file,
|
|
223
|
-
L: 114,
|
|
224
|
-
S: this,
|
|
225
|
-
C: (f, a) => f(...a)
|
|
226
|
-
});
|
|
214
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 86, S: this });
|
|
227
215
|
}
|
|
228
216
|
}
|
|
229
217
|
}
|
|
230
218
|
} catch (err) {
|
|
231
219
|
const now = Date.now();
|
|
232
220
|
if (err instanceof RpcClosedError) {
|
|
233
|
-
log("ignoring RpcClosedError in heartbeat", void 0, {
|
|
234
|
-
F: __dxlog_file,
|
|
235
|
-
L: 126,
|
|
236
|
-
S: this,
|
|
237
|
-
C: (f, a) => f(...a)
|
|
238
|
-
});
|
|
221
|
+
log("ignoring RpcClosedError in heartbeat", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 98, S: this });
|
|
239
222
|
this._extensionContext.close(err);
|
|
240
223
|
return;
|
|
241
224
|
}
|
|
@@ -243,23 +226,13 @@ var ControlExtension = class {
|
|
|
243
226
|
log("timeout waiting for heartbeat response", {
|
|
244
227
|
err,
|
|
245
228
|
delay: now - reqTS.getTime()
|
|
246
|
-
}, {
|
|
247
|
-
F: __dxlog_file,
|
|
248
|
-
L: 131,
|
|
249
|
-
S: this,
|
|
250
|
-
C: (f, a) => f(...a)
|
|
251
|
-
});
|
|
229
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 103, S: this });
|
|
252
230
|
this.opts.onTimeout(err);
|
|
253
231
|
} else {
|
|
254
232
|
log.info("other error waiting for heartbeat response", {
|
|
255
233
|
err,
|
|
256
234
|
delay: now - reqTS.getTime()
|
|
257
|
-
}, {
|
|
258
|
-
F: __dxlog_file,
|
|
259
|
-
L: 134,
|
|
260
|
-
S: this,
|
|
261
|
-
C: (f, a) => f(...a)
|
|
262
|
-
});
|
|
235
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 109, S: this });
|
|
263
236
|
this.opts.onTimeout(err);
|
|
264
237
|
}
|
|
265
238
|
}
|
|
@@ -273,27 +246,6 @@ var ControlExtension = class {
|
|
|
273
246
|
await this._ctx.dispose();
|
|
274
247
|
await this._rpc.abort();
|
|
275
248
|
}
|
|
276
|
-
constructor(opts, localPeerId, remotePeerId) {
|
|
277
|
-
_define_property(this, "opts", void 0);
|
|
278
|
-
_define_property(this, "localPeerId", void 0);
|
|
279
|
-
_define_property(this, "remotePeerId", void 0);
|
|
280
|
-
_define_property(this, "_ctx", void 0);
|
|
281
|
-
_define_property(this, "onExtensionRegistered", void 0);
|
|
282
|
-
_define_property(this, "_extensionContext", void 0);
|
|
283
|
-
_define_property(this, "_rpc", void 0);
|
|
284
|
-
this.opts = opts;
|
|
285
|
-
this.localPeerId = localPeerId;
|
|
286
|
-
this.remotePeerId = remotePeerId;
|
|
287
|
-
this._ctx = new Context({
|
|
288
|
-
onError: (err) => {
|
|
289
|
-
this._extensionContext.close(err);
|
|
290
|
-
}
|
|
291
|
-
}, {
|
|
292
|
-
F: __dxlog_file,
|
|
293
|
-
L: 31
|
|
294
|
-
});
|
|
295
|
-
this.onExtensionRegistered = new Callback();
|
|
296
|
-
}
|
|
297
249
|
};
|
|
298
250
|
|
|
299
251
|
// src/muxing/framer.ts
|
|
@@ -301,22 +253,69 @@ import { Duplex } from "@dxos/node-std/stream";
|
|
|
301
253
|
import { Event } from "@dxos/async";
|
|
302
254
|
import { invariant } from "@dxos/invariant";
|
|
303
255
|
import { log as log2 } from "@dxos/log";
|
|
304
|
-
function _define_property2(obj, key, value) {
|
|
305
|
-
if (key in obj) {
|
|
306
|
-
Object.defineProperty(obj, key, {
|
|
307
|
-
value,
|
|
308
|
-
enumerable: true,
|
|
309
|
-
configurable: true,
|
|
310
|
-
writable: true
|
|
311
|
-
});
|
|
312
|
-
} else {
|
|
313
|
-
obj[key] = value;
|
|
314
|
-
}
|
|
315
|
-
return obj;
|
|
316
|
-
}
|
|
317
256
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/mesh/teleport/src/muxing/framer.ts";
|
|
318
257
|
var FRAME_LENGTH_SIZE = 2;
|
|
319
258
|
var Framer = class {
|
|
259
|
+
// private readonly _tagBuffer = Buffer.alloc(4)
|
|
260
|
+
_messageCb = void 0;
|
|
261
|
+
_subscribeCb = void 0;
|
|
262
|
+
_buffer = void 0;
|
|
263
|
+
_sendCallbacks = [];
|
|
264
|
+
_bytesSent = 0;
|
|
265
|
+
_bytesReceived = 0;
|
|
266
|
+
_writable = true;
|
|
267
|
+
drain = new Event();
|
|
268
|
+
// TODO(egorgripasov): Consider using a Transform stream if it provides better backpressure handling.
|
|
269
|
+
_stream = new Duplex({
|
|
270
|
+
objectMode: false,
|
|
271
|
+
read: () => {
|
|
272
|
+
this._processResponseQueue();
|
|
273
|
+
},
|
|
274
|
+
write: (chunk, encoding, callback) => {
|
|
275
|
+
invariant(!this._subscribeCb, "Internal Framer bug. Concurrent writes detected.", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 29, S: this, A: ["!this._subscribeCb", "'Internal Framer bug. Concurrent writes detected.'"] });
|
|
276
|
+
this._bytesReceived += chunk.length;
|
|
277
|
+
if (this._buffer && this._buffer.length > 0) {
|
|
278
|
+
this._buffer = Buffer.concat([
|
|
279
|
+
this._buffer,
|
|
280
|
+
chunk
|
|
281
|
+
]);
|
|
282
|
+
} else {
|
|
283
|
+
this._buffer = chunk;
|
|
284
|
+
}
|
|
285
|
+
if (this._messageCb) {
|
|
286
|
+
this._popFrames();
|
|
287
|
+
callback();
|
|
288
|
+
} else {
|
|
289
|
+
this._subscribeCb = () => {
|
|
290
|
+
this._popFrames();
|
|
291
|
+
this._subscribeCb = void 0;
|
|
292
|
+
callback();
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
port = {
|
|
298
|
+
send: (message) => {
|
|
299
|
+
return new Promise((resolve) => {
|
|
300
|
+
const frame = encodeFrame(message);
|
|
301
|
+
this._bytesSent += frame.length;
|
|
302
|
+
this._writable = this._stream.push(frame);
|
|
303
|
+
if (!this._writable) {
|
|
304
|
+
this._sendCallbacks.push(resolve);
|
|
305
|
+
} else {
|
|
306
|
+
resolve();
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
},
|
|
310
|
+
subscribe: (callback) => {
|
|
311
|
+
invariant(!this._messageCb, "Rpc port already has a message listener.", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 67, S: this, A: ["!this._messageCb", "'Rpc port already has a message listener.'"] });
|
|
312
|
+
this._messageCb = callback;
|
|
313
|
+
this._subscribeCb?.();
|
|
314
|
+
return () => {
|
|
315
|
+
this._messageCb = void 0;
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
};
|
|
320
319
|
get stream() {
|
|
321
320
|
return this._stream;
|
|
322
321
|
}
|
|
@@ -357,99 +356,13 @@ var Framer = class {
|
|
|
357
356
|
}
|
|
358
357
|
destroy() {
|
|
359
358
|
if (this._stream.readableLength > 0) {
|
|
360
|
-
log2("framer destroyed while there are still read bytes in the buffer.", void 0, {
|
|
361
|
-
F: __dxlog_file2,
|
|
362
|
-
L: 140,
|
|
363
|
-
S: this,
|
|
364
|
-
C: (f, a) => f(...a)
|
|
365
|
-
});
|
|
359
|
+
log2("framer destroyed while there are still read bytes in the buffer.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 118, S: this });
|
|
366
360
|
}
|
|
367
361
|
if (this._stream.writableLength > 0) {
|
|
368
|
-
log2.warn("framer destroyed while there are still write bytes in the buffer.", void 0, {
|
|
369
|
-
F: __dxlog_file2,
|
|
370
|
-
L: 143,
|
|
371
|
-
S: this,
|
|
372
|
-
C: (f, a) => f(...a)
|
|
373
|
-
});
|
|
362
|
+
log2.warn("framer destroyed while there are still write bytes in the buffer.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 121, S: this });
|
|
374
363
|
}
|
|
375
364
|
this._stream.destroy();
|
|
376
365
|
}
|
|
377
|
-
constructor() {
|
|
378
|
-
_define_property2(this, "_messageCb", void 0);
|
|
379
|
-
_define_property2(this, "_subscribeCb", void 0);
|
|
380
|
-
_define_property2(this, "_buffer", void 0);
|
|
381
|
-
_define_property2(this, "_sendCallbacks", []);
|
|
382
|
-
_define_property2(this, "_bytesSent", 0);
|
|
383
|
-
_define_property2(this, "_bytesReceived", 0);
|
|
384
|
-
_define_property2(this, "_writable", true);
|
|
385
|
-
_define_property2(this, "drain", new Event());
|
|
386
|
-
_define_property2(this, "_stream", new Duplex({
|
|
387
|
-
objectMode: false,
|
|
388
|
-
read: () => {
|
|
389
|
-
this._processResponseQueue();
|
|
390
|
-
},
|
|
391
|
-
write: (chunk, encoding, callback) => {
|
|
392
|
-
invariant(!this._subscribeCb, "Internal Framer bug. Concurrent writes detected.", {
|
|
393
|
-
F: __dxlog_file2,
|
|
394
|
-
L: 40,
|
|
395
|
-
S: this,
|
|
396
|
-
A: [
|
|
397
|
-
"!this._subscribeCb",
|
|
398
|
-
"'Internal Framer bug. Concurrent writes detected.'"
|
|
399
|
-
]
|
|
400
|
-
});
|
|
401
|
-
this._bytesReceived += chunk.length;
|
|
402
|
-
if (this._buffer && this._buffer.length > 0) {
|
|
403
|
-
this._buffer = Buffer.concat([
|
|
404
|
-
this._buffer,
|
|
405
|
-
chunk
|
|
406
|
-
]);
|
|
407
|
-
} else {
|
|
408
|
-
this._buffer = chunk;
|
|
409
|
-
}
|
|
410
|
-
if (this._messageCb) {
|
|
411
|
-
this._popFrames();
|
|
412
|
-
callback();
|
|
413
|
-
} else {
|
|
414
|
-
this._subscribeCb = () => {
|
|
415
|
-
this._popFrames();
|
|
416
|
-
this._subscribeCb = void 0;
|
|
417
|
-
callback();
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}));
|
|
422
|
-
_define_property2(this, "port", {
|
|
423
|
-
send: (message) => {
|
|
424
|
-
return new Promise((resolve) => {
|
|
425
|
-
const frame = encodeFrame(message);
|
|
426
|
-
this._bytesSent += frame.length;
|
|
427
|
-
this._writable = this._stream.push(frame);
|
|
428
|
-
if (!this._writable) {
|
|
429
|
-
this._sendCallbacks.push(resolve);
|
|
430
|
-
} else {
|
|
431
|
-
resolve();
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
},
|
|
435
|
-
subscribe: (callback) => {
|
|
436
|
-
invariant(!this._messageCb, "Rpc port already has a message listener.", {
|
|
437
|
-
F: __dxlog_file2,
|
|
438
|
-
L: 79,
|
|
439
|
-
S: this,
|
|
440
|
-
A: [
|
|
441
|
-
"!this._messageCb",
|
|
442
|
-
"'Rpc port already has a message listener.'"
|
|
443
|
-
]
|
|
444
|
-
});
|
|
445
|
-
this._messageCb = callback;
|
|
446
|
-
this._subscribeCb?.();
|
|
447
|
-
return () => {
|
|
448
|
-
this._messageCb = void 0;
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
366
|
};
|
|
454
367
|
var decodeFrame = (buffer, offset) => {
|
|
455
368
|
if (buffer.length < offset + FRAME_LENGTH_SIZE) {
|
|
@@ -488,22 +401,24 @@ var import_varint = __toESM(require_varint(), 1);
|
|
|
488
401
|
import { Event as Event2 } from "@dxos/async";
|
|
489
402
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
490
403
|
import { log as log3 } from "@dxos/log";
|
|
491
|
-
function _define_property3(obj, key, value) {
|
|
492
|
-
if (key in obj) {
|
|
493
|
-
Object.defineProperty(obj, key, {
|
|
494
|
-
value,
|
|
495
|
-
enumerable: true,
|
|
496
|
-
configurable: true,
|
|
497
|
-
writable: true
|
|
498
|
-
});
|
|
499
|
-
} else {
|
|
500
|
-
obj[key] = value;
|
|
501
|
-
}
|
|
502
|
-
return obj;
|
|
503
|
-
}
|
|
504
404
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/mesh/teleport/src/muxing/balancer.ts";
|
|
505
405
|
var MAX_CHUNK_SIZE = 8192;
|
|
506
406
|
var Balancer = class {
|
|
407
|
+
_sysChannelId;
|
|
408
|
+
_lastCallerIndex = 0;
|
|
409
|
+
_channels = [];
|
|
410
|
+
_framer = new Framer();
|
|
411
|
+
// TODO(egorgripasov): Will cause a memory leak if channels do not appreciate the backpressure.
|
|
412
|
+
_sendBuffers = /* @__PURE__ */ new Map();
|
|
413
|
+
_receiveBuffers = /* @__PURE__ */ new Map();
|
|
414
|
+
_sending = false;
|
|
415
|
+
incomingData = new Event2();
|
|
416
|
+
stream = this._framer.stream;
|
|
417
|
+
constructor(_sysChannelId) {
|
|
418
|
+
this._sysChannelId = _sysChannelId;
|
|
419
|
+
this._channels.push(_sysChannelId);
|
|
420
|
+
this._framer.port.subscribe(this._processIncomingMessage.bind(this));
|
|
421
|
+
}
|
|
507
422
|
get bytesSent() {
|
|
508
423
|
return this._framer.bytesSent;
|
|
509
424
|
}
|
|
@@ -518,21 +433,11 @@ var Balancer = class {
|
|
|
518
433
|
}
|
|
519
434
|
pushData(data, trigger, channelId) {
|
|
520
435
|
this._enqueueChunk(data, trigger, channelId);
|
|
521
|
-
this._sendChunks().catch((err) => log3.catch(err, void 0, {
|
|
522
|
-
F: __dxlog_file3,
|
|
523
|
-
L: 75,
|
|
524
|
-
S: this,
|
|
525
|
-
C: (f, a) => f(...a)
|
|
526
|
-
}));
|
|
436
|
+
this._sendChunks().catch((err) => log3.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 46, S: this }));
|
|
527
437
|
}
|
|
528
438
|
destroy() {
|
|
529
439
|
if (this._sendBuffers.size !== 0) {
|
|
530
|
-
log3.info("destroying balancer with pending calls", void 0, {
|
|
531
|
-
F: __dxlog_file3,
|
|
532
|
-
L: 80,
|
|
533
|
-
S: this,
|
|
534
|
-
C: (f, a) => f(...a)
|
|
535
|
-
});
|
|
440
|
+
log3.info("destroying balancer with pending calls", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 50, S: this });
|
|
536
441
|
}
|
|
537
442
|
this._sendBuffers.clear();
|
|
538
443
|
this._framer.destroy();
|
|
@@ -623,19 +528,9 @@ var Balancer = class {
|
|
|
623
528
|
chunk = this._getNextChunk();
|
|
624
529
|
while (chunk) {
|
|
625
530
|
if (!this._framer.writable) {
|
|
626
|
-
log3("PAUSE for drain", void 0, {
|
|
627
|
-
F: __dxlog_file3,
|
|
628
|
-
L: 179,
|
|
629
|
-
S: this,
|
|
630
|
-
C: (f, a) => f(...a)
|
|
631
|
-
});
|
|
531
|
+
log3("PAUSE for drain", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 142, S: this });
|
|
632
532
|
await this._framer.drain.waitForCount(1);
|
|
633
|
-
log3("RESUME for drain", void 0, {
|
|
634
|
-
F: __dxlog_file3,
|
|
635
|
-
L: 181,
|
|
636
|
-
S: this,
|
|
637
|
-
C: (f, a) => f(...a)
|
|
638
|
-
});
|
|
533
|
+
log3("RESUME for drain", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 144, S: this });
|
|
639
534
|
}
|
|
640
535
|
try {
|
|
641
536
|
await this._framer.port.send(chunk.msg);
|
|
@@ -643,49 +538,14 @@ var Balancer = class {
|
|
|
643
538
|
} catch (err) {
|
|
644
539
|
log3("Error sending chunk", {
|
|
645
540
|
err
|
|
646
|
-
}, {
|
|
647
|
-
F: __dxlog_file3,
|
|
648
|
-
L: 187,
|
|
649
|
-
S: this,
|
|
650
|
-
C: (f, a) => f(...a)
|
|
651
|
-
});
|
|
541
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 150, S: this });
|
|
652
542
|
chunk.trigger?.throw(err);
|
|
653
543
|
}
|
|
654
544
|
chunk = this._getNextChunk();
|
|
655
545
|
}
|
|
656
|
-
invariant2(this._sendBuffers.size === 0, "sendBuffers not empty", {
|
|
657
|
-
F: __dxlog_file3,
|
|
658
|
-
L: 192,
|
|
659
|
-
S: this,
|
|
660
|
-
A: [
|
|
661
|
-
"this._sendBuffers.size === 0",
|
|
662
|
-
"'sendBuffers not empty'"
|
|
663
|
-
]
|
|
664
|
-
});
|
|
546
|
+
invariant2(this._sendBuffers.size === 0, "sendBuffers not empty", { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 157, S: this, A: ["this._sendBuffers.size === 0", "'sendBuffers not empty'"] });
|
|
665
547
|
this._sending = false;
|
|
666
548
|
}
|
|
667
|
-
constructor(_sysChannelId) {
|
|
668
|
-
_define_property3(this, "_sysChannelId", void 0);
|
|
669
|
-
_define_property3(this, "_lastCallerIndex", void 0);
|
|
670
|
-
_define_property3(this, "_channels", void 0);
|
|
671
|
-
_define_property3(this, "_framer", void 0);
|
|
672
|
-
_define_property3(this, "_sendBuffers", void 0);
|
|
673
|
-
_define_property3(this, "_receiveBuffers", void 0);
|
|
674
|
-
_define_property3(this, "_sending", void 0);
|
|
675
|
-
_define_property3(this, "incomingData", void 0);
|
|
676
|
-
_define_property3(this, "stream", void 0);
|
|
677
|
-
this._sysChannelId = _sysChannelId;
|
|
678
|
-
this._lastCallerIndex = 0;
|
|
679
|
-
this._channels = [];
|
|
680
|
-
this._framer = new Framer();
|
|
681
|
-
this._sendBuffers = /* @__PURE__ */ new Map();
|
|
682
|
-
this._receiveBuffers = /* @__PURE__ */ new Map();
|
|
683
|
-
this._sending = false;
|
|
684
|
-
this.incomingData = new Event2();
|
|
685
|
-
this.stream = this._framer.stream;
|
|
686
|
-
this._channels.push(_sysChannelId);
|
|
687
|
-
this._framer.port.subscribe(this._processIncomingMessage.bind(this));
|
|
688
|
-
}
|
|
689
549
|
};
|
|
690
550
|
var encodeChunk = ({ channelId, dataLength, chunk }) => {
|
|
691
551
|
const channelTagLength = import_varint.default.encodingLength(channelId);
|
|
@@ -715,26 +575,13 @@ var decodeChunk = (data, withLength) => {
|
|
|
715
575
|
};
|
|
716
576
|
|
|
717
577
|
// src/muxing/muxer.ts
|
|
718
|
-
|
|
719
|
-
if (key in obj) {
|
|
720
|
-
Object.defineProperty(obj, key, {
|
|
721
|
-
value,
|
|
722
|
-
enumerable: true,
|
|
723
|
-
configurable: true,
|
|
724
|
-
writable: true
|
|
725
|
-
});
|
|
726
|
-
} else {
|
|
727
|
-
obj[key] = value;
|
|
728
|
-
}
|
|
729
|
-
return obj;
|
|
730
|
-
}
|
|
578
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/mesh/teleport/src/muxing/muxer.ts";
|
|
731
579
|
function _ts_decorate(decorators, target, key, desc) {
|
|
732
580
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
733
581
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
734
582
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
735
583
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
736
584
|
}
|
|
737
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/core/mesh/teleport/src/muxing/muxer.ts";
|
|
738
585
|
var Command = schema2.getCodecForType("dxos.mesh.muxer.Command");
|
|
739
586
|
var DEFAULT_SEND_COMMAND_TIMEOUT = 6e4;
|
|
740
587
|
var DESTROY_COMMAND_SEND_TIMEOUT = 5e3;
|
|
@@ -743,6 +590,25 @@ var MAX_SAFE_FRAME_SIZE = 1e6;
|
|
|
743
590
|
var SYSTEM_CHANNEL_ID = 0;
|
|
744
591
|
var GRACEFUL_CLOSE_TIMEOUT = 3e3;
|
|
745
592
|
var Muxer = class {
|
|
593
|
+
_balancer = new Balancer(SYSTEM_CHANNEL_ID);
|
|
594
|
+
_channelsByLocalId = /* @__PURE__ */ new Map();
|
|
595
|
+
_channelsByTag = /* @__PURE__ */ new Map();
|
|
596
|
+
_ctx = new Context2(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 39 });
|
|
597
|
+
_sessionId;
|
|
598
|
+
_nextId = 1;
|
|
599
|
+
_closing = false;
|
|
600
|
+
_destroying = false;
|
|
601
|
+
_disposed = false;
|
|
602
|
+
_lastStats = void 0;
|
|
603
|
+
_lastChannelStats = /* @__PURE__ */ new Map();
|
|
604
|
+
afterClosed = new Event3();
|
|
605
|
+
statsUpdated = new Event3();
|
|
606
|
+
stream = this._balancer.stream;
|
|
607
|
+
constructor() {
|
|
608
|
+
this._balancer.incomingData.on(async (msg) => {
|
|
609
|
+
await this._handleCommand(Command.decode(msg));
|
|
610
|
+
});
|
|
611
|
+
}
|
|
746
612
|
setSessionId(sessionId) {
|
|
747
613
|
this._sessionId = sessionId;
|
|
748
614
|
}
|
|
@@ -760,15 +626,7 @@ var Muxer = class {
|
|
|
760
626
|
tag,
|
|
761
627
|
contentType: opts.contentType
|
|
762
628
|
});
|
|
763
|
-
invariant3(!channel.push, `Channel already open: ${tag}`, {
|
|
764
|
-
F: __dxlog_file4,
|
|
765
|
-
L: 152,
|
|
766
|
-
S: this,
|
|
767
|
-
A: [
|
|
768
|
-
"!channel.push",
|
|
769
|
-
"`Channel already open: ${tag}`"
|
|
770
|
-
]
|
|
771
|
-
});
|
|
629
|
+
invariant3(!channel.push, `Channel already open: ${tag}`, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 72, S: this, A: ["!channel.push", "`Channel already open: ${tag}`"] });
|
|
772
630
|
const stream = new Duplex2({
|
|
773
631
|
write: (data, encoding, callback) => {
|
|
774
632
|
this._sendData(channel, data).then(() => callback()).catch(callback);
|
|
@@ -816,15 +674,7 @@ var Muxer = class {
|
|
|
816
674
|
tag,
|
|
817
675
|
contentType: opts.contentType
|
|
818
676
|
});
|
|
819
|
-
invariant3(!channel.push, `Channel already open: ${tag}`, {
|
|
820
|
-
F: __dxlog_file4,
|
|
821
|
-
L: 212,
|
|
822
|
-
S: this,
|
|
823
|
-
A: [
|
|
824
|
-
"!channel.push",
|
|
825
|
-
"`Channel already open: ${tag}`"
|
|
826
|
-
]
|
|
827
|
-
});
|
|
677
|
+
invariant3(!channel.push, `Channel already open: ${tag}`, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 121, S: this, A: ["!channel.push", "`Channel already open: ${tag}`"] });
|
|
828
678
|
let inboundBuffer = [];
|
|
829
679
|
let callback;
|
|
830
680
|
channel.push = (data) => {
|
|
@@ -840,15 +690,7 @@ var Muxer = class {
|
|
|
840
690
|
await this._sendData(channel, data, timeout);
|
|
841
691
|
},
|
|
842
692
|
subscribe: (cb) => {
|
|
843
|
-
invariant3(!callback, "Only one subscriber is allowed", {
|
|
844
|
-
F: __dxlog_file4,
|
|
845
|
-
L: 234,
|
|
846
|
-
S: this,
|
|
847
|
-
A: [
|
|
848
|
-
"!callback",
|
|
849
|
-
"'Only one subscriber is allowed'"
|
|
850
|
-
]
|
|
851
|
-
});
|
|
693
|
+
invariant3(!callback, "Only one subscriber is allowed", { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 140, S: this, A: ["!callback", "'Only one subscriber is allowed'"] });
|
|
852
694
|
callback = cb;
|
|
853
695
|
for (const data of inboundBuffer) {
|
|
854
696
|
cb(data);
|
|
@@ -873,21 +715,11 @@ var Muxer = class {
|
|
|
873
715
|
// initiate graceful close
|
|
874
716
|
async close(err) {
|
|
875
717
|
if (this._destroying) {
|
|
876
|
-
log4("already destroying, ignoring graceful close request", void 0, {
|
|
877
|
-
F: __dxlog_file4,
|
|
878
|
-
L: 267,
|
|
879
|
-
S: this,
|
|
880
|
-
C: (f, a) => f(...a)
|
|
881
|
-
});
|
|
718
|
+
log4("already destroying, ignoring graceful close request", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 166, S: this });
|
|
882
719
|
return;
|
|
883
720
|
}
|
|
884
721
|
if (this._closing) {
|
|
885
|
-
log4("already closing, ignoring graceful close request", void 0, {
|
|
886
|
-
F: __dxlog_file4,
|
|
887
|
-
L: 271,
|
|
888
|
-
S: this,
|
|
889
|
-
C: (f, a) => f(...a)
|
|
890
|
-
});
|
|
722
|
+
log4("already closing, ignoring graceful close request", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 170, S: this });
|
|
891
723
|
return;
|
|
892
724
|
}
|
|
893
725
|
this._closing = true;
|
|
@@ -898,36 +730,23 @@ var Muxer = class {
|
|
|
898
730
|
}, SYSTEM_CHANNEL_ID, DESTROY_COMMAND_SEND_TIMEOUT).catch(async (err2) => {
|
|
899
731
|
log4("error sending close command", {
|
|
900
732
|
err: err2
|
|
901
|
-
}, {
|
|
902
|
-
F: __dxlog_file4,
|
|
903
|
-
L: 286,
|
|
904
|
-
S: this,
|
|
905
|
-
C: (f, a) => f(...a)
|
|
906
|
-
});
|
|
733
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 179, S: this });
|
|
907
734
|
await this._dispose(err2);
|
|
908
735
|
});
|
|
909
|
-
await asyncTimeout2(this._dispose(err), GRACEFUL_CLOSE_TIMEOUT, new TimeoutError(
|
|
736
|
+
await asyncTimeout2(this._dispose(err), GRACEFUL_CLOSE_TIMEOUT, new TimeoutError({
|
|
737
|
+
message: "gracefully closing muxer"
|
|
738
|
+
}));
|
|
910
739
|
}
|
|
911
740
|
// force close without confirmation
|
|
912
741
|
async destroy(err) {
|
|
913
742
|
if (this._destroying) {
|
|
914
|
-
log4("already destroying, ignoring destroy request", void 0, {
|
|
915
|
-
F: __dxlog_file4,
|
|
916
|
-
L: 299,
|
|
917
|
-
S: this,
|
|
918
|
-
C: (f, a) => f(...a)
|
|
919
|
-
});
|
|
743
|
+
log4("already destroying, ignoring destroy request", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 192, S: this });
|
|
920
744
|
return;
|
|
921
745
|
}
|
|
922
746
|
this._destroying = true;
|
|
923
747
|
void this._ctx.dispose();
|
|
924
748
|
if (this._closing) {
|
|
925
|
-
log4("destroy cancelling graceful close", void 0, {
|
|
926
|
-
F: __dxlog_file4,
|
|
927
|
-
L: 305,
|
|
928
|
-
S: this,
|
|
929
|
-
C: (f, a) => f(...a)
|
|
930
|
-
});
|
|
749
|
+
log4("destroy cancelling graceful close", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 198, S: this });
|
|
931
750
|
this._closing = false;
|
|
932
751
|
} else {
|
|
933
752
|
await this._sendCommand({
|
|
@@ -937,34 +756,19 @@ var Muxer = class {
|
|
|
937
756
|
}, SYSTEM_CHANNEL_ID).catch(async (err2) => {
|
|
938
757
|
log4("error sending courtesy close command", {
|
|
939
758
|
err: err2
|
|
940
|
-
}, {
|
|
941
|
-
F: __dxlog_file4,
|
|
942
|
-
L: 318,
|
|
943
|
-
S: this,
|
|
944
|
-
C: (f, a) => f(...a)
|
|
945
|
-
});
|
|
759
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 207, S: this });
|
|
946
760
|
});
|
|
947
761
|
}
|
|
948
762
|
this._dispose(err).catch((err2) => {
|
|
949
763
|
log4("error disposing after destroy", {
|
|
950
764
|
err: err2
|
|
951
|
-
}, {
|
|
952
|
-
F: __dxlog_file4,
|
|
953
|
-
L: 323,
|
|
954
|
-
S: this,
|
|
955
|
-
C: (f, a) => f(...a)
|
|
956
|
-
});
|
|
765
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 213, S: this });
|
|
957
766
|
});
|
|
958
767
|
}
|
|
959
768
|
// complete the termination, graceful or otherwise
|
|
960
769
|
async _dispose(err) {
|
|
961
770
|
if (this._disposed) {
|
|
962
|
-
log4("already destroyed, ignoring dispose request", void 0, {
|
|
963
|
-
F: __dxlog_file4,
|
|
964
|
-
L: 331,
|
|
965
|
-
S: this,
|
|
966
|
-
C: (f, a) => f(...a)
|
|
967
|
-
});
|
|
771
|
+
log4("already destroyed, ignoring dispose request", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 221, S: this });
|
|
968
772
|
return;
|
|
969
773
|
}
|
|
970
774
|
void this._ctx.dispose();
|
|
@@ -982,30 +786,15 @@ var Muxer = class {
|
|
|
982
786
|
if (this._disposed) {
|
|
983
787
|
log4.warn("Received command after disposed", {
|
|
984
788
|
cmd
|
|
985
|
-
}, {
|
|
986
|
-
F: __dxlog_file4,
|
|
987
|
-
L: 354,
|
|
988
|
-
S: this,
|
|
989
|
-
C: (f, a) => f(...a)
|
|
990
|
-
});
|
|
789
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 238, S: this });
|
|
991
790
|
return;
|
|
992
791
|
}
|
|
993
792
|
if (cmd.close) {
|
|
994
793
|
if (!this._closing) {
|
|
995
|
-
log4("received peer close, initiating my own graceful close", void 0, {
|
|
996
|
-
F: __dxlog_file4,
|
|
997
|
-
L: 360,
|
|
998
|
-
S: this,
|
|
999
|
-
C: (f, a) => f(...a)
|
|
1000
|
-
});
|
|
794
|
+
log4("received peer close, initiating my own graceful close", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 245, S: this });
|
|
1001
795
|
await this.close(new Error("received peer close"));
|
|
1002
796
|
} else {
|
|
1003
|
-
log4("received close from peer, already closing", void 0, {
|
|
1004
|
-
F: __dxlog_file4,
|
|
1005
|
-
L: 363,
|
|
1006
|
-
S: this,
|
|
1007
|
-
C: (f, a) => f(...a)
|
|
1008
|
-
});
|
|
797
|
+
log4("received close from peer, already closing", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 248, S: this });
|
|
1009
798
|
}
|
|
1010
799
|
return;
|
|
1011
800
|
}
|
|
@@ -1029,12 +818,7 @@ var Muxer = class {
|
|
|
1029
818
|
if (!stream.push) {
|
|
1030
819
|
log4.warn("Received data for channel before it was opened", {
|
|
1031
820
|
tag: stream.tag
|
|
1032
|
-
}, {
|
|
1033
|
-
F: __dxlog_file4,
|
|
1034
|
-
L: 392,
|
|
1035
|
-
S: this,
|
|
1036
|
-
C: (f, a) => f(...a)
|
|
1037
|
-
});
|
|
821
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 271, S: this });
|
|
1038
822
|
return;
|
|
1039
823
|
}
|
|
1040
824
|
stream.push(cmd.data.data);
|
|
@@ -1084,12 +868,7 @@ var Muxer = class {
|
|
|
1084
868
|
log4.warn("frame size exceeds maximum safe value", {
|
|
1085
869
|
size: data.length,
|
|
1086
870
|
threshold: MAX_SAFE_FRAME_SIZE
|
|
1087
|
-
}, {
|
|
1088
|
-
F: __dxlog_file4,
|
|
1089
|
-
L: 442,
|
|
1090
|
-
S: this,
|
|
1091
|
-
C: (f, a) => f(...a)
|
|
1092
|
-
});
|
|
871
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 321, S: this });
|
|
1093
872
|
}
|
|
1094
873
|
channel.stats.bytesSent += data.length;
|
|
1095
874
|
if (channel.remoteId === null) {
|
|
@@ -1107,12 +886,7 @@ var Muxer = class {
|
|
|
1107
886
|
if (err) {
|
|
1108
887
|
log4.warn("destroying channel with error", {
|
|
1109
888
|
err
|
|
1110
|
-
}, {
|
|
1111
|
-
F: __dxlog_file4,
|
|
1112
|
-
L: 465,
|
|
1113
|
-
S: this,
|
|
1114
|
-
C: (f, a) => f(...a)
|
|
1115
|
-
});
|
|
889
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 341, S: this });
|
|
1116
890
|
}
|
|
1117
891
|
if (channel.destroy) {
|
|
1118
892
|
channel.destroy(err);
|
|
@@ -1170,60 +944,104 @@ var Muxer = class {
|
|
|
1170
944
|
};
|
|
1171
945
|
this.statsUpdated.emit(this._lastStats);
|
|
1172
946
|
}
|
|
1173
|
-
constructor() {
|
|
1174
|
-
_define_property4(this, "_balancer", new Balancer(SYSTEM_CHANNEL_ID));
|
|
1175
|
-
_define_property4(this, "_channelsByLocalId", /* @__PURE__ */ new Map());
|
|
1176
|
-
_define_property4(this, "_channelsByTag", /* @__PURE__ */ new Map());
|
|
1177
|
-
_define_property4(this, "_ctx", new Context2(void 0, {
|
|
1178
|
-
F: __dxlog_file4,
|
|
1179
|
-
L: 108
|
|
1180
|
-
}));
|
|
1181
|
-
_define_property4(this, "_sessionId", void 0);
|
|
1182
|
-
_define_property4(this, "_nextId", 1);
|
|
1183
|
-
_define_property4(this, "_closing", false);
|
|
1184
|
-
_define_property4(this, "_destroying", false);
|
|
1185
|
-
_define_property4(this, "_disposed", false);
|
|
1186
|
-
_define_property4(this, "_lastStats", void 0);
|
|
1187
|
-
_define_property4(this, "_lastChannelStats", /* @__PURE__ */ new Map());
|
|
1188
|
-
_define_property4(this, "afterClosed", new Event3());
|
|
1189
|
-
_define_property4(this, "statsUpdated", new Event3());
|
|
1190
|
-
_define_property4(this, "stream", this._balancer.stream);
|
|
1191
|
-
this._balancer.incomingData.on(async (msg) => {
|
|
1192
|
-
await this._handleCommand(Command.decode(msg));
|
|
1193
|
-
});
|
|
1194
|
-
}
|
|
1195
947
|
};
|
|
1196
948
|
_ts_decorate([
|
|
1197
949
|
logInfo
|
|
1198
950
|
], Muxer.prototype, "sessionIdString", null);
|
|
1199
951
|
|
|
1200
952
|
// src/teleport.ts
|
|
1201
|
-
|
|
1202
|
-
if (key in obj) {
|
|
1203
|
-
Object.defineProperty(obj, key, {
|
|
1204
|
-
value,
|
|
1205
|
-
enumerable: true,
|
|
1206
|
-
configurable: true,
|
|
1207
|
-
writable: true
|
|
1208
|
-
});
|
|
1209
|
-
} else {
|
|
1210
|
-
obj[key] = value;
|
|
1211
|
-
}
|
|
1212
|
-
return obj;
|
|
1213
|
-
}
|
|
953
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/mesh/teleport/src/teleport.ts";
|
|
1214
954
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
1215
955
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1216
956
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1217
957
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1218
958
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1219
959
|
}
|
|
1220
|
-
var __dxlog_file5 = "/__w/dxos/dxos/packages/core/mesh/teleport/src/teleport.ts";
|
|
1221
960
|
var CONTROL_HEARTBEAT_INTERVAL = 1e4;
|
|
1222
961
|
var CONTROL_HEARTBEAT_TIMEOUT = 6e4;
|
|
1223
962
|
var Teleport = class {
|
|
963
|
+
initiator;
|
|
964
|
+
localPeerId;
|
|
965
|
+
remotePeerId;
|
|
966
|
+
_sessionId;
|
|
967
|
+
_ctx = new Context3({
|
|
968
|
+
onError: (err) => {
|
|
969
|
+
log5.info("error in teleport context", {
|
|
970
|
+
err
|
|
971
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 30, S: this });
|
|
972
|
+
void this.destroy(err).catch(() => {
|
|
973
|
+
log5.error("Error during destroy", err, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 34, S: this });
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 28 });
|
|
977
|
+
_muxer = new Muxer();
|
|
978
|
+
_control;
|
|
979
|
+
_extensions = /* @__PURE__ */ new Map();
|
|
980
|
+
_remoteExtensions = /* @__PURE__ */ new Set();
|
|
981
|
+
_open = false;
|
|
982
|
+
_destroying = false;
|
|
983
|
+
_aborting = false;
|
|
1224
984
|
get isOpen() {
|
|
1225
985
|
return this._open;
|
|
1226
986
|
}
|
|
987
|
+
constructor({ initiator, localPeerId, remotePeerId, ...rest }) {
|
|
988
|
+
invariant4(typeof initiator === "boolean", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 49, S: this, A: ["typeof initiator === 'boolean'", ""] });
|
|
989
|
+
invariant4(PublicKey.isPublicKey(localPeerId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 50, S: this, A: ["PublicKey.isPublicKey(localPeerId)", ""] });
|
|
990
|
+
invariant4(PublicKey.isPublicKey(remotePeerId), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 51, S: this, A: ["PublicKey.isPublicKey(remotePeerId)", ""] });
|
|
991
|
+
this.initiator = initiator;
|
|
992
|
+
this.localPeerId = localPeerId;
|
|
993
|
+
this.remotePeerId = remotePeerId;
|
|
994
|
+
this._control = new ControlExtension({
|
|
995
|
+
heartbeatInterval: rest.controlHeartbeatInterval ?? CONTROL_HEARTBEAT_INTERVAL,
|
|
996
|
+
heartbeatTimeout: rest.controlHeartbeatTimeout ?? CONTROL_HEARTBEAT_TIMEOUT,
|
|
997
|
+
onTimeout: () => {
|
|
998
|
+
if (this._destroying || this._aborting) {
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
log5.info("abort teleport due to onTimeout in ControlExtension", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 62, S: this });
|
|
1002
|
+
this.abort(new TimeoutError2({
|
|
1003
|
+
message: "control extension"
|
|
1004
|
+
})).catch((err) => log5.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 65, S: this }));
|
|
1005
|
+
}
|
|
1006
|
+
}, this.localPeerId, this.remotePeerId);
|
|
1007
|
+
this._control.onExtensionRegistered.set(async (name) => {
|
|
1008
|
+
log5("remote extension", {
|
|
1009
|
+
name
|
|
1010
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 69, S: this });
|
|
1011
|
+
invariant4(!this._remoteExtensions.has(name), "Remote extension already exists", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 72, S: this, A: ["!this._remoteExtensions.has(name)", "'Remote extension already exists'"] });
|
|
1012
|
+
this._remoteExtensions.add(name);
|
|
1013
|
+
if (this._extensions.has(name)) {
|
|
1014
|
+
try {
|
|
1015
|
+
await this._openExtension(name);
|
|
1016
|
+
} catch (err) {
|
|
1017
|
+
await this.destroy(err);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
{
|
|
1022
|
+
this._muxer.stream.on("close", async () => {
|
|
1023
|
+
if (this._destroying || this._aborting) {
|
|
1024
|
+
log5("destroy teleport due to muxer stream close, skipping due to already destroying/aborting", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 86, S: this });
|
|
1025
|
+
return;
|
|
1026
|
+
}
|
|
1027
|
+
await this.destroy();
|
|
1028
|
+
});
|
|
1029
|
+
this._muxer.stream.on("error", async (err) => {
|
|
1030
|
+
await this.destroy(err);
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
this._muxer.statsUpdated.on((stats) => {
|
|
1034
|
+
log5.trace("dxos.mesh.teleport.stats", {
|
|
1035
|
+
localPeerId,
|
|
1036
|
+
remotePeerId,
|
|
1037
|
+
bytesSent: stats.bytesSent,
|
|
1038
|
+
bytesSentRate: stats.bytesSentRate,
|
|
1039
|
+
bytesReceived: stats.bytesReceived,
|
|
1040
|
+
bytesReceivedRate: stats.bytesReceivedRate,
|
|
1041
|
+
channels: stats.channels
|
|
1042
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 97, S: this });
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1227
1045
|
get sessionIdString() {
|
|
1228
1046
|
return this._sessionId ? this._sessionId.truncate() : "none";
|
|
1229
1047
|
}
|
|
@@ -1238,12 +1056,7 @@ var Teleport = class {
|
|
|
1238
1056
|
*/
|
|
1239
1057
|
async open(sessionId = PublicKey.random()) {
|
|
1240
1058
|
this._sessionId = sessionId;
|
|
1241
|
-
log5("open", void 0, {
|
|
1242
|
-
F: __dxlog_file5,
|
|
1243
|
-
L: 151,
|
|
1244
|
-
S: this,
|
|
1245
|
-
C: (f, a) => f(...a)
|
|
1246
|
-
});
|
|
1059
|
+
log5("open", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 123, S: this });
|
|
1247
1060
|
this._setExtension("dxos.mesh.teleport.control", this._control);
|
|
1248
1061
|
await this._openExtension("dxos.mesh.teleport.control");
|
|
1249
1062
|
this._open = true;
|
|
@@ -1266,12 +1079,7 @@ var Teleport = class {
|
|
|
1266
1079
|
try {
|
|
1267
1080
|
await extension.onAbort(err);
|
|
1268
1081
|
} catch (err2) {
|
|
1269
|
-
log5.catch(err2, void 0, {
|
|
1270
|
-
F: __dxlog_file5,
|
|
1271
|
-
L: 181,
|
|
1272
|
-
S: this,
|
|
1273
|
-
C: (f, a) => f(...a)
|
|
1274
|
-
});
|
|
1082
|
+
log5.catch(err2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 147, S: this });
|
|
1275
1083
|
}
|
|
1276
1084
|
}
|
|
1277
1085
|
await this._muxer.destroy(err);
|
|
@@ -1282,12 +1090,7 @@ var Teleport = class {
|
|
|
1282
1090
|
}
|
|
1283
1091
|
log5("destroying teleport...", {
|
|
1284
1092
|
extensionsCount: this._extensions.size
|
|
1285
|
-
}, {
|
|
1286
|
-
F: __dxlog_file5,
|
|
1287
|
-
L: 194,
|
|
1288
|
-
S: this,
|
|
1289
|
-
C: (f, a) => f(...a)
|
|
1290
|
-
});
|
|
1093
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 156, S: this });
|
|
1291
1094
|
this._destroying = true;
|
|
1292
1095
|
this._open = false;
|
|
1293
1096
|
if (this._ctx.disposed) {
|
|
@@ -1298,37 +1101,17 @@ var Teleport = class {
|
|
|
1298
1101
|
try {
|
|
1299
1102
|
log5("destroying extension", {
|
|
1300
1103
|
name: extension.constructor.name
|
|
1301
|
-
}, {
|
|
1302
|
-
F: __dxlog_file5,
|
|
1303
|
-
L: 206,
|
|
1304
|
-
S: this,
|
|
1305
|
-
C: (f, a) => f(...a)
|
|
1306
|
-
});
|
|
1104
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 167, S: this });
|
|
1307
1105
|
await extension.onClose(err);
|
|
1308
1106
|
log5("destroyed extension", {
|
|
1309
1107
|
name: extension.constructor.name
|
|
1310
|
-
}, {
|
|
1311
|
-
F: __dxlog_file5,
|
|
1312
|
-
L: 208,
|
|
1313
|
-
S: this,
|
|
1314
|
-
C: (f, a) => f(...a)
|
|
1315
|
-
});
|
|
1108
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 171, S: this });
|
|
1316
1109
|
} catch (err2) {
|
|
1317
|
-
log5.catch(err2, void 0, {
|
|
1318
|
-
F: __dxlog_file5,
|
|
1319
|
-
L: 210,
|
|
1320
|
-
S: this,
|
|
1321
|
-
C: (f, a) => f(...a)
|
|
1322
|
-
});
|
|
1110
|
+
log5.catch(err2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 175, S: this });
|
|
1323
1111
|
}
|
|
1324
1112
|
}
|
|
1325
1113
|
await this._muxer.close();
|
|
1326
|
-
log5("teleport destroyed", void 0, {
|
|
1327
|
-
F: __dxlog_file5,
|
|
1328
|
-
L: 215,
|
|
1329
|
-
S: this,
|
|
1330
|
-
C: (f, a) => f(...a)
|
|
1331
|
-
});
|
|
1114
|
+
log5("teleport destroyed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 179, S: this });
|
|
1332
1115
|
}
|
|
1333
1116
|
addExtension(name, extension) {
|
|
1334
1117
|
if (!this._open) {
|
|
@@ -1336,12 +1119,7 @@ var Teleport = class {
|
|
|
1336
1119
|
}
|
|
1337
1120
|
log5("addExtension", {
|
|
1338
1121
|
name
|
|
1339
|
-
}, {
|
|
1340
|
-
F: __dxlog_file5,
|
|
1341
|
-
L: 223,
|
|
1342
|
-
S: this,
|
|
1343
|
-
C: (f, a) => f(...a)
|
|
1344
|
-
});
|
|
1122
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 185, S: this });
|
|
1345
1123
|
this._setExtension(name, extension);
|
|
1346
1124
|
scheduleTask(this._ctx, async () => {
|
|
1347
1125
|
try {
|
|
@@ -1360,62 +1138,25 @@ var Teleport = class {
|
|
|
1360
1138
|
}
|
|
1361
1139
|
}
|
|
1362
1140
|
_setExtension(extensionName, extension) {
|
|
1363
|
-
invariant4(!extensionName.includes("/"), "Invalid extension name", {
|
|
1364
|
-
|
|
1365
|
-
L: 247,
|
|
1366
|
-
S: this,
|
|
1367
|
-
A: [
|
|
1368
|
-
"!extensionName.includes('/')",
|
|
1369
|
-
"'Invalid extension name'"
|
|
1370
|
-
]
|
|
1371
|
-
});
|
|
1372
|
-
invariant4(!this._extensions.has(extensionName), "Extension already exists", {
|
|
1373
|
-
F: __dxlog_file5,
|
|
1374
|
-
L: 248,
|
|
1375
|
-
S: this,
|
|
1376
|
-
A: [
|
|
1377
|
-
"!this._extensions.has(extensionName)",
|
|
1378
|
-
"'Extension already exists'"
|
|
1379
|
-
]
|
|
1380
|
-
});
|
|
1141
|
+
invariant4(!extensionName.includes("/"), "Invalid extension name", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 208, S: this, A: ["!extensionName.includes('/')", "'Invalid extension name'"] });
|
|
1142
|
+
invariant4(!this._extensions.has(extensionName), "Extension already exists", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 209, S: this, A: ["!this._extensions.has(extensionName)", "'Extension already exists'"] });
|
|
1381
1143
|
this._extensions.set(extensionName, extension);
|
|
1382
1144
|
}
|
|
1383
1145
|
async _openExtension(extensionName) {
|
|
1384
1146
|
log5("open extension", {
|
|
1385
1147
|
extensionName
|
|
1386
|
-
}, {
|
|
1387
|
-
F: __dxlog_file5,
|
|
1388
|
-
L: 253,
|
|
1389
|
-
S: this,
|
|
1390
|
-
C: (f, a) => f(...a)
|
|
1391
|
-
});
|
|
1148
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 213, S: this });
|
|
1392
1149
|
const extension = this._extensions.get(extensionName) ?? failUndefined2();
|
|
1393
1150
|
const context = {
|
|
1394
1151
|
initiator: this.initiator,
|
|
1395
1152
|
localPeerId: this.localPeerId,
|
|
1396
1153
|
remotePeerId: this.remotePeerId,
|
|
1397
1154
|
createPort: async (channelName, opts) => {
|
|
1398
|
-
invariant4(!channelName.includes("/"), "Invalid channel name", {
|
|
1399
|
-
F: __dxlog_file5,
|
|
1400
|
-
L: 261,
|
|
1401
|
-
S: this,
|
|
1402
|
-
A: [
|
|
1403
|
-
"!channelName.includes('/')",
|
|
1404
|
-
"'Invalid channel name'"
|
|
1405
|
-
]
|
|
1406
|
-
});
|
|
1155
|
+
invariant4(!channelName.includes("/"), "Invalid channel name", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 222, S: this, A: ["!channelName.includes('/')", "'Invalid channel name'"] });
|
|
1407
1156
|
return this._muxer.createPort(`${extensionName}/${channelName}`, opts);
|
|
1408
1157
|
},
|
|
1409
1158
|
createStream: async (channelName, opts) => {
|
|
1410
|
-
invariant4(!channelName.includes("/"), "Invalid channel name", {
|
|
1411
|
-
F: __dxlog_file5,
|
|
1412
|
-
L: 265,
|
|
1413
|
-
S: this,
|
|
1414
|
-
A: [
|
|
1415
|
-
"!channelName.includes('/')",
|
|
1416
|
-
"'Invalid channel name'"
|
|
1417
|
-
]
|
|
1418
|
-
});
|
|
1159
|
+
invariant4(!channelName.includes("/"), "Invalid channel name", { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 226, S: this, A: ["!channelName.includes('/')", "'Invalid channel name'"] });
|
|
1419
1160
|
return this._muxer.createStream(`${extensionName}/${channelName}`, opts);
|
|
1420
1161
|
},
|
|
1421
1162
|
close: (err) => {
|
|
@@ -1427,159 +1168,7 @@ var Teleport = class {
|
|
|
1427
1168
|
await extension.onOpen(context);
|
|
1428
1169
|
log5("extension opened", {
|
|
1429
1170
|
extensionName
|
|
1430
|
-
}, {
|
|
1431
|
-
F: __dxlog_file5,
|
|
1432
|
-
L: 276,
|
|
1433
|
-
S: this,
|
|
1434
|
-
C: (f, a) => f(...a)
|
|
1435
|
-
});
|
|
1436
|
-
}
|
|
1437
|
-
constructor({ initiator, localPeerId, remotePeerId, ...rest }) {
|
|
1438
|
-
_define_property5(this, "initiator", void 0);
|
|
1439
|
-
_define_property5(this, "localPeerId", void 0);
|
|
1440
|
-
_define_property5(this, "remotePeerId", void 0);
|
|
1441
|
-
_define_property5(this, "_sessionId", void 0);
|
|
1442
|
-
_define_property5(this, "_ctx", new Context3({
|
|
1443
|
-
onError: (err) => {
|
|
1444
|
-
log5.info("error in teleport context", {
|
|
1445
|
-
err
|
|
1446
|
-
}, {
|
|
1447
|
-
F: __dxlog_file5,
|
|
1448
|
-
L: 40,
|
|
1449
|
-
S: this,
|
|
1450
|
-
C: (f, a) => f(...a)
|
|
1451
|
-
});
|
|
1452
|
-
void this.destroy(err).catch(() => {
|
|
1453
|
-
log5.error("Error during destroy", err, {
|
|
1454
|
-
F: __dxlog_file5,
|
|
1455
|
-
L: 42,
|
|
1456
|
-
S: this,
|
|
1457
|
-
C: (f, a) => f(...a)
|
|
1458
|
-
});
|
|
1459
|
-
});
|
|
1460
|
-
}
|
|
1461
|
-
}, {
|
|
1462
|
-
F: __dxlog_file5,
|
|
1463
|
-
L: 38
|
|
1464
|
-
}));
|
|
1465
|
-
_define_property5(this, "_muxer", new Muxer());
|
|
1466
|
-
_define_property5(this, "_control", void 0);
|
|
1467
|
-
_define_property5(this, "_extensions", /* @__PURE__ */ new Map());
|
|
1468
|
-
_define_property5(this, "_remoteExtensions", /* @__PURE__ */ new Set());
|
|
1469
|
-
_define_property5(this, "_open", false);
|
|
1470
|
-
_define_property5(this, "_destroying", false);
|
|
1471
|
-
_define_property5(this, "_aborting", false);
|
|
1472
|
-
invariant4(typeof initiator === "boolean", void 0, {
|
|
1473
|
-
F: __dxlog_file5,
|
|
1474
|
-
L: 63,
|
|
1475
|
-
S: this,
|
|
1476
|
-
A: [
|
|
1477
|
-
"typeof initiator === 'boolean'",
|
|
1478
|
-
""
|
|
1479
|
-
]
|
|
1480
|
-
});
|
|
1481
|
-
invariant4(PublicKey.isPublicKey(localPeerId), void 0, {
|
|
1482
|
-
F: __dxlog_file5,
|
|
1483
|
-
L: 64,
|
|
1484
|
-
S: this,
|
|
1485
|
-
A: [
|
|
1486
|
-
"PublicKey.isPublicKey(localPeerId)",
|
|
1487
|
-
""
|
|
1488
|
-
]
|
|
1489
|
-
});
|
|
1490
|
-
invariant4(PublicKey.isPublicKey(remotePeerId), void 0, {
|
|
1491
|
-
F: __dxlog_file5,
|
|
1492
|
-
L: 65,
|
|
1493
|
-
S: this,
|
|
1494
|
-
A: [
|
|
1495
|
-
"PublicKey.isPublicKey(remotePeerId)",
|
|
1496
|
-
""
|
|
1497
|
-
]
|
|
1498
|
-
});
|
|
1499
|
-
this.initiator = initiator;
|
|
1500
|
-
this.localPeerId = localPeerId;
|
|
1501
|
-
this.remotePeerId = remotePeerId;
|
|
1502
|
-
this._control = new ControlExtension({
|
|
1503
|
-
heartbeatInterval: rest.controlHeartbeatInterval ?? CONTROL_HEARTBEAT_INTERVAL,
|
|
1504
|
-
heartbeatTimeout: rest.controlHeartbeatTimeout ?? CONTROL_HEARTBEAT_TIMEOUT,
|
|
1505
|
-
onTimeout: () => {
|
|
1506
|
-
if (this._destroying || this._aborting) {
|
|
1507
|
-
return;
|
|
1508
|
-
}
|
|
1509
|
-
log5.info("abort teleport due to onTimeout in ControlExtension", void 0, {
|
|
1510
|
-
F: __dxlog_file5,
|
|
1511
|
-
L: 78,
|
|
1512
|
-
S: this,
|
|
1513
|
-
C: (f, a) => f(...a)
|
|
1514
|
-
});
|
|
1515
|
-
this.abort(new TimeoutError2("control extension")).catch((err) => log5.catch(err, void 0, {
|
|
1516
|
-
F: __dxlog_file5,
|
|
1517
|
-
L: 79,
|
|
1518
|
-
S: this,
|
|
1519
|
-
C: (f, a) => f(...a)
|
|
1520
|
-
}));
|
|
1521
|
-
}
|
|
1522
|
-
}, this.localPeerId, this.remotePeerId);
|
|
1523
|
-
this._control.onExtensionRegistered.set(async (name) => {
|
|
1524
|
-
log5("remote extension", {
|
|
1525
|
-
name
|
|
1526
|
-
}, {
|
|
1527
|
-
F: __dxlog_file5,
|
|
1528
|
-
L: 87,
|
|
1529
|
-
S: this,
|
|
1530
|
-
C: (f, a) => f(...a)
|
|
1531
|
-
});
|
|
1532
|
-
invariant4(!this._remoteExtensions.has(name), "Remote extension already exists", {
|
|
1533
|
-
F: __dxlog_file5,
|
|
1534
|
-
L: 88,
|
|
1535
|
-
S: this,
|
|
1536
|
-
A: [
|
|
1537
|
-
"!this._remoteExtensions.has(name)",
|
|
1538
|
-
"'Remote extension already exists'"
|
|
1539
|
-
]
|
|
1540
|
-
});
|
|
1541
|
-
this._remoteExtensions.add(name);
|
|
1542
|
-
if (this._extensions.has(name)) {
|
|
1543
|
-
try {
|
|
1544
|
-
await this._openExtension(name);
|
|
1545
|
-
} catch (err) {
|
|
1546
|
-
await this.destroy(err);
|
|
1547
|
-
}
|
|
1548
|
-
}
|
|
1549
|
-
});
|
|
1550
|
-
{
|
|
1551
|
-
this._muxer.stream.on("close", async () => {
|
|
1552
|
-
if (this._destroying || this._aborting) {
|
|
1553
|
-
log5("destroy teleport due to muxer stream close, skipping due to already destroying/aborting", void 0, {
|
|
1554
|
-
F: __dxlog_file5,
|
|
1555
|
-
L: 104,
|
|
1556
|
-
S: this,
|
|
1557
|
-
C: (f, a) => f(...a)
|
|
1558
|
-
});
|
|
1559
|
-
return;
|
|
1560
|
-
}
|
|
1561
|
-
await this.destroy();
|
|
1562
|
-
});
|
|
1563
|
-
this._muxer.stream.on("error", async (err) => {
|
|
1564
|
-
await this.destroy(err);
|
|
1565
|
-
});
|
|
1566
|
-
}
|
|
1567
|
-
this._muxer.statsUpdated.on((stats) => {
|
|
1568
|
-
log5.trace("dxos.mesh.teleport.stats", {
|
|
1569
|
-
localPeerId,
|
|
1570
|
-
remotePeerId,
|
|
1571
|
-
bytesSent: stats.bytesSent,
|
|
1572
|
-
bytesSentRate: stats.bytesSentRate,
|
|
1573
|
-
bytesReceived: stats.bytesReceived,
|
|
1574
|
-
bytesReceivedRate: stats.bytesReceivedRate,
|
|
1575
|
-
channels: stats.channels
|
|
1576
|
-
}, {
|
|
1577
|
-
F: __dxlog_file5,
|
|
1578
|
-
L: 117,
|
|
1579
|
-
S: this,
|
|
1580
|
-
C: (f, a) => f(...a)
|
|
1581
|
-
});
|
|
1582
|
-
});
|
|
1171
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 236, S: this });
|
|
1583
1172
|
}
|
|
1584
1173
|
};
|
|
1585
1174
|
_ts_decorate2([
|
|
@@ -1593,21 +1182,9 @@ _ts_decorate2([
|
|
|
1593
1182
|
], Teleport.prototype, "destroy", null);
|
|
1594
1183
|
|
|
1595
1184
|
// src/testing/test-builder.ts
|
|
1596
|
-
function _define_property6(obj, key, value) {
|
|
1597
|
-
if (key in obj) {
|
|
1598
|
-
Object.defineProperty(obj, key, {
|
|
1599
|
-
value,
|
|
1600
|
-
enumerable: true,
|
|
1601
|
-
configurable: true,
|
|
1602
|
-
writable: true
|
|
1603
|
-
});
|
|
1604
|
-
} else {
|
|
1605
|
-
obj[key] = value;
|
|
1606
|
-
}
|
|
1607
|
-
return obj;
|
|
1608
|
-
}
|
|
1609
1185
|
var __dxlog_file6 = "/__w/dxos/dxos/packages/core/mesh/teleport/src/testing/test-builder.ts";
|
|
1610
1186
|
var TestBuilder = class {
|
|
1187
|
+
_peers = /* @__PURE__ */ new Set();
|
|
1611
1188
|
createPeer(opts) {
|
|
1612
1189
|
const peer = opts.factory();
|
|
1613
1190
|
this._peers.add(peer);
|
|
@@ -1622,33 +1199,9 @@ var TestBuilder = class {
|
|
|
1622
1199
|
await Promise.all(Array.from(this._peers).map((agent) => agent.destroy()));
|
|
1623
1200
|
}
|
|
1624
1201
|
async connect(peer1, peer2) {
|
|
1625
|
-
invariant5(peer1 !== peer2, void 0, {
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
S: this,
|
|
1629
|
-
A: [
|
|
1630
|
-
"peer1 !== peer2",
|
|
1631
|
-
""
|
|
1632
|
-
]
|
|
1633
|
-
});
|
|
1634
|
-
invariant5(this._peers.has(peer1), void 0, {
|
|
1635
|
-
F: __dxlog_file6,
|
|
1636
|
-
L: 39,
|
|
1637
|
-
S: this,
|
|
1638
|
-
A: [
|
|
1639
|
-
"this._peers.has(peer1)",
|
|
1640
|
-
""
|
|
1641
|
-
]
|
|
1642
|
-
});
|
|
1643
|
-
invariant5(this._peers.has(peer1), void 0, {
|
|
1644
|
-
F: __dxlog_file6,
|
|
1645
|
-
L: 40,
|
|
1646
|
-
S: this,
|
|
1647
|
-
A: [
|
|
1648
|
-
"this._peers.has(peer1)",
|
|
1649
|
-
""
|
|
1650
|
-
]
|
|
1651
|
-
});
|
|
1202
|
+
invariant5(peer1 !== peer2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 26, S: this, A: ["peer1 !== peer2", ""] });
|
|
1203
|
+
invariant5(this._peers.has(peer1), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 27, S: this, A: ["this._peers.has(peer1)", ""] });
|
|
1204
|
+
invariant5(this._peers.has(peer1), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 28, S: this, A: ["this._peers.has(peer1)", ""] });
|
|
1652
1205
|
const connection1 = peer1.createConnection({
|
|
1653
1206
|
initiator: true,
|
|
1654
1207
|
remotePeerId: peer2.peerId
|
|
@@ -1668,63 +1221,25 @@ var TestBuilder = class {
|
|
|
1668
1221
|
];
|
|
1669
1222
|
}
|
|
1670
1223
|
async disconnect(peer1, peer2) {
|
|
1671
|
-
invariant5(peer1 !== peer2, void 0, {
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
S: this,
|
|
1675
|
-
A: [
|
|
1676
|
-
"peer1 !== peer2",
|
|
1677
|
-
""
|
|
1678
|
-
]
|
|
1679
|
-
});
|
|
1680
|
-
invariant5(this._peers.has(peer1), void 0, {
|
|
1681
|
-
F: __dxlog_file6,
|
|
1682
|
-
L: 53,
|
|
1683
|
-
S: this,
|
|
1684
|
-
A: [
|
|
1685
|
-
"this._peers.has(peer1)",
|
|
1686
|
-
""
|
|
1687
|
-
]
|
|
1688
|
-
});
|
|
1689
|
-
invariant5(this._peers.has(peer1), void 0, {
|
|
1690
|
-
F: __dxlog_file6,
|
|
1691
|
-
L: 54,
|
|
1692
|
-
S: this,
|
|
1693
|
-
A: [
|
|
1694
|
-
"this._peers.has(peer1)",
|
|
1695
|
-
""
|
|
1696
|
-
]
|
|
1697
|
-
});
|
|
1224
|
+
invariant5(peer1 !== peer2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 48, S: this, A: ["peer1 !== peer2", ""] });
|
|
1225
|
+
invariant5(this._peers.has(peer1), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 49, S: this, A: ["this._peers.has(peer1)", ""] });
|
|
1226
|
+
invariant5(this._peers.has(peer1), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 50, S: this, A: ["this._peers.has(peer1)", ""] });
|
|
1698
1227
|
const connection1 = Array.from(peer1.connections).find((connection) => connection.remotePeerId.equals(peer2.peerId));
|
|
1699
1228
|
const connection2 = Array.from(peer2.connections).find((connection) => connection.remotePeerId.equals(peer1.peerId));
|
|
1700
|
-
invariant5(connection1, void 0, {
|
|
1701
|
-
|
|
1702
|
-
L: 63,
|
|
1703
|
-
S: this,
|
|
1704
|
-
A: [
|
|
1705
|
-
"connection1",
|
|
1706
|
-
""
|
|
1707
|
-
]
|
|
1708
|
-
});
|
|
1709
|
-
invariant5(connection2, void 0, {
|
|
1710
|
-
F: __dxlog_file6,
|
|
1711
|
-
L: 64,
|
|
1712
|
-
S: this,
|
|
1713
|
-
A: [
|
|
1714
|
-
"connection2",
|
|
1715
|
-
""
|
|
1716
|
-
]
|
|
1717
|
-
});
|
|
1229
|
+
invariant5(connection1, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 53, S: this, A: ["connection1", ""] });
|
|
1230
|
+
invariant5(connection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 54, S: this, A: ["connection2", ""] });
|
|
1718
1231
|
await Promise.all([
|
|
1719
1232
|
peer1.closeConnection(connection1),
|
|
1720
1233
|
peer2.closeConnection(connection2)
|
|
1721
1234
|
]);
|
|
1722
1235
|
}
|
|
1723
|
-
constructor() {
|
|
1724
|
-
_define_property6(this, "_peers", /* @__PURE__ */ new Set());
|
|
1725
|
-
}
|
|
1726
1236
|
};
|
|
1727
1237
|
var TestPeer = class {
|
|
1238
|
+
peerId;
|
|
1239
|
+
connections = /* @__PURE__ */ new Set();
|
|
1240
|
+
constructor(peerId = PublicKey2.random()) {
|
|
1241
|
+
this.peerId = peerId;
|
|
1242
|
+
}
|
|
1728
1243
|
async onOpen(connection) {
|
|
1729
1244
|
}
|
|
1730
1245
|
async onClose(connection) {
|
|
@@ -1735,28 +1250,12 @@ var TestPeer = class {
|
|
|
1735
1250
|
return connection;
|
|
1736
1251
|
}
|
|
1737
1252
|
async openConnection(connection) {
|
|
1738
|
-
invariant5(this.connections.has(connection), void 0, {
|
|
1739
|
-
F: __dxlog_file6,
|
|
1740
|
-
L: 85,
|
|
1741
|
-
S: this,
|
|
1742
|
-
A: [
|
|
1743
|
-
"this.connections.has(connection)",
|
|
1744
|
-
""
|
|
1745
|
-
]
|
|
1746
|
-
});
|
|
1253
|
+
invariant5(this.connections.has(connection), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 75, S: this, A: ["this.connections.has(connection)", ""] });
|
|
1747
1254
|
await connection.teleport.open(PublicKey2.random());
|
|
1748
1255
|
await this.onOpen(connection);
|
|
1749
1256
|
}
|
|
1750
1257
|
async closeConnection(connection) {
|
|
1751
|
-
invariant5(this.connections.has(connection), void 0, {
|
|
1752
|
-
F: __dxlog_file6,
|
|
1753
|
-
L: 91,
|
|
1754
|
-
S: this,
|
|
1755
|
-
A: [
|
|
1756
|
-
"this.connections.has(connection)",
|
|
1757
|
-
""
|
|
1758
|
-
]
|
|
1759
|
-
});
|
|
1258
|
+
invariant5(this.connections.has(connection), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 80, S: this, A: ["this.connections.has(connection)", ""] });
|
|
1760
1259
|
await this.onClose(connection);
|
|
1761
1260
|
await connection.teleport.close();
|
|
1762
1261
|
this.connections.delete(connection);
|
|
@@ -1766,46 +1265,25 @@ var TestPeer = class {
|
|
|
1766
1265
|
await this.closeConnection(teleport);
|
|
1767
1266
|
}
|
|
1768
1267
|
}
|
|
1769
|
-
constructor(peerId = PublicKey2.random()) {
|
|
1770
|
-
_define_property6(this, "peerId", void 0);
|
|
1771
|
-
_define_property6(this, "connections", void 0);
|
|
1772
|
-
this.peerId = peerId;
|
|
1773
|
-
this.connections = /* @__PURE__ */ new Set();
|
|
1774
|
-
}
|
|
1775
1268
|
};
|
|
1776
1269
|
var pipeStreams = (stream1, stream2) => {
|
|
1777
1270
|
pipeline(stream1, stream2, (err) => {
|
|
1778
1271
|
if (err && err.code !== "ERR_STREAM_PREMATURE_CLOSE") {
|
|
1779
|
-
log6.catch(err, void 0, {
|
|
1780
|
-
F: __dxlog_file6,
|
|
1781
|
-
L: 107,
|
|
1782
|
-
S: void 0,
|
|
1783
|
-
C: (f, a) => f(...a)
|
|
1784
|
-
});
|
|
1272
|
+
log6.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 94, S: void 0 });
|
|
1785
1273
|
}
|
|
1786
1274
|
});
|
|
1787
1275
|
pipeline(stream2, stream1, (err) => {
|
|
1788
1276
|
if (err && err.code !== "ERR_STREAM_PREMATURE_CLOSE") {
|
|
1789
|
-
log6.catch(err, void 0, {
|
|
1790
|
-
F: __dxlog_file6,
|
|
1791
|
-
L: 112,
|
|
1792
|
-
S: void 0,
|
|
1793
|
-
C: (f, a) => f(...a)
|
|
1794
|
-
});
|
|
1277
|
+
log6.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 99, S: void 0 });
|
|
1795
1278
|
}
|
|
1796
1279
|
});
|
|
1797
1280
|
};
|
|
1798
1281
|
var TestConnection = class {
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
}
|
|
1282
|
+
localPeerId;
|
|
1283
|
+
remotePeerId;
|
|
1284
|
+
initiator;
|
|
1285
|
+
teleport;
|
|
1804
1286
|
constructor(localPeerId, remotePeerId, initiator) {
|
|
1805
|
-
_define_property6(this, "localPeerId", void 0);
|
|
1806
|
-
_define_property6(this, "remotePeerId", void 0);
|
|
1807
|
-
_define_property6(this, "initiator", void 0);
|
|
1808
|
-
_define_property6(this, "teleport", void 0);
|
|
1809
1287
|
this.localPeerId = localPeerId;
|
|
1810
1288
|
this.remotePeerId = remotePeerId;
|
|
1811
1289
|
this.initiator = initiator;
|
|
@@ -1815,6 +1293,11 @@ var TestConnection = class {
|
|
|
1815
1293
|
remotePeerId
|
|
1816
1294
|
});
|
|
1817
1295
|
}
|
|
1296
|
+
whenOpen(open) {
|
|
1297
|
+
return waitForCondition({
|
|
1298
|
+
condition: () => this.teleport.isOpen === open
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1818
1301
|
};
|
|
1819
1302
|
|
|
1820
1303
|
// src/testing/test-extension.ts
|
|
@@ -1823,21 +1306,17 @@ import { invariant as invariant6 } from "@dxos/invariant";
|
|
|
1823
1306
|
import { log as log7 } from "@dxos/log";
|
|
1824
1307
|
import { schema as schema3 } from "@dxos/protocols/proto";
|
|
1825
1308
|
import { createProtoRpcPeer as createProtoRpcPeer2 } from "@dxos/rpc";
|
|
1826
|
-
function _define_property7(obj, key, value) {
|
|
1827
|
-
if (key in obj) {
|
|
1828
|
-
Object.defineProperty(obj, key, {
|
|
1829
|
-
value,
|
|
1830
|
-
enumerable: true,
|
|
1831
|
-
configurable: true,
|
|
1832
|
-
writable: true
|
|
1833
|
-
});
|
|
1834
|
-
} else {
|
|
1835
|
-
obj[key] = value;
|
|
1836
|
-
}
|
|
1837
|
-
return obj;
|
|
1838
|
-
}
|
|
1839
1309
|
var __dxlog_file7 = "/__w/dxos/dxos/packages/core/mesh/teleport/src/testing/test-extension.ts";
|
|
1840
1310
|
var TestExtension = class {
|
|
1311
|
+
callbacks;
|
|
1312
|
+
open = new Trigger2();
|
|
1313
|
+
closed = new Trigger2();
|
|
1314
|
+
aborted = new Trigger2();
|
|
1315
|
+
extensionContext;
|
|
1316
|
+
_rpc;
|
|
1317
|
+
constructor(callbacks = {}) {
|
|
1318
|
+
this.callbacks = callbacks;
|
|
1319
|
+
}
|
|
1841
1320
|
get remotePeerId() {
|
|
1842
1321
|
return this.extensionContext?.remotePeerId;
|
|
1843
1322
|
}
|
|
@@ -1845,12 +1324,7 @@ var TestExtension = class {
|
|
|
1845
1324
|
log7("onOpen", {
|
|
1846
1325
|
localPeerId: context.localPeerId,
|
|
1847
1326
|
remotePeerId: context.remotePeerId
|
|
1848
|
-
}, {
|
|
1849
|
-
F: __dxlog_file7,
|
|
1850
|
-
L: 34,
|
|
1851
|
-
S: this,
|
|
1852
|
-
C: (f, a) => f(...a)
|
|
1853
|
-
});
|
|
1327
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 23, S: this });
|
|
1854
1328
|
this.extensionContext = context;
|
|
1855
1329
|
this._rpc = createProtoRpcPeer2({
|
|
1856
1330
|
port: await context.createPort("rpc", {
|
|
@@ -1882,12 +1356,7 @@ var TestExtension = class {
|
|
|
1882
1356
|
async onClose(err) {
|
|
1883
1357
|
log7("onClose", {
|
|
1884
1358
|
err
|
|
1885
|
-
}, {
|
|
1886
|
-
F: __dxlog_file7,
|
|
1887
|
-
L: 68,
|
|
1888
|
-
S: this,
|
|
1889
|
-
C: (f, a) => f(...a)
|
|
1890
|
-
});
|
|
1359
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 57, S: this });
|
|
1891
1360
|
await this.callbacks.onClose?.();
|
|
1892
1361
|
this.closed.wake();
|
|
1893
1362
|
await this._rpc?.close();
|
|
@@ -1895,12 +1364,7 @@ var TestExtension = class {
|
|
|
1895
1364
|
async onAbort(err) {
|
|
1896
1365
|
log7("onAbort", {
|
|
1897
1366
|
err
|
|
1898
|
-
}, {
|
|
1899
|
-
F: __dxlog_file7,
|
|
1900
|
-
L: 75,
|
|
1901
|
-
S: this,
|
|
1902
|
-
C: (f, a) => f(...a)
|
|
1903
|
-
});
|
|
1367
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 65, S: this });
|
|
1904
1368
|
await this.callbacks.onAbort?.();
|
|
1905
1369
|
this.aborted.wake();
|
|
1906
1370
|
await this._rpc?.abort();
|
|
@@ -1912,15 +1376,7 @@ var TestExtension = class {
|
|
|
1912
1376
|
const res = await asyncTimeout3(this._rpc.rpc.TestService.testCall({
|
|
1913
1377
|
data: message
|
|
1914
1378
|
}), 1500);
|
|
1915
|
-
invariant6(res.data === message, void 0, {
|
|
1916
|
-
F: __dxlog_file7,
|
|
1917
|
-
L: 84,
|
|
1918
|
-
S: this,
|
|
1919
|
-
A: [
|
|
1920
|
-
"res.data === message",
|
|
1921
|
-
""
|
|
1922
|
-
]
|
|
1923
|
-
});
|
|
1379
|
+
invariant6(res.data === message, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 79, S: this, A: ["res.data === message", ""] });
|
|
1924
1380
|
}
|
|
1925
1381
|
/**
|
|
1926
1382
|
* Force-close the connection.
|
|
@@ -1928,18 +1384,6 @@ var TestExtension = class {
|
|
|
1928
1384
|
async closeConnection(err) {
|
|
1929
1385
|
this.extensionContext?.close(err);
|
|
1930
1386
|
}
|
|
1931
|
-
constructor(callbacks = {}) {
|
|
1932
|
-
_define_property7(this, "callbacks", void 0);
|
|
1933
|
-
_define_property7(this, "open", void 0);
|
|
1934
|
-
_define_property7(this, "closed", void 0);
|
|
1935
|
-
_define_property7(this, "aborted", void 0);
|
|
1936
|
-
_define_property7(this, "extensionContext", void 0);
|
|
1937
|
-
_define_property7(this, "_rpc", void 0);
|
|
1938
|
-
this.callbacks = callbacks;
|
|
1939
|
-
this.open = new Trigger2();
|
|
1940
|
-
this.closed = new Trigger2();
|
|
1941
|
-
this.aborted = new Trigger2();
|
|
1942
|
-
}
|
|
1943
1387
|
};
|
|
1944
1388
|
|
|
1945
1389
|
// src/testing/test-extension-with-streams.ts
|
|
@@ -1949,34 +1393,23 @@ import { invariant as invariant7 } from "@dxos/invariant";
|
|
|
1949
1393
|
import { log as log8 } from "@dxos/log";
|
|
1950
1394
|
import { schema as schema4 } from "@dxos/protocols/proto";
|
|
1951
1395
|
import { createProtoRpcPeer as createProtoRpcPeer3 } from "@dxos/rpc";
|
|
1952
|
-
function _define_property8(obj, key, value) {
|
|
1953
|
-
if (key in obj) {
|
|
1954
|
-
Object.defineProperty(obj, key, {
|
|
1955
|
-
value,
|
|
1956
|
-
enumerable: true,
|
|
1957
|
-
configurable: true,
|
|
1958
|
-
writable: true
|
|
1959
|
-
});
|
|
1960
|
-
} else {
|
|
1961
|
-
obj[key] = value;
|
|
1962
|
-
}
|
|
1963
|
-
return obj;
|
|
1964
|
-
}
|
|
1965
1396
|
var __dxlog_file8 = "/__w/dxos/dxos/packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts";
|
|
1966
1397
|
var TestExtensionWithStreams = class {
|
|
1398
|
+
callbacks;
|
|
1399
|
+
open = new Trigger3();
|
|
1400
|
+
closed = new Trigger3();
|
|
1401
|
+
aborted = new Trigger3();
|
|
1402
|
+
_streams = /* @__PURE__ */ new Map();
|
|
1403
|
+
extensionContext;
|
|
1404
|
+
_rpc;
|
|
1405
|
+
constructor(callbacks = {}) {
|
|
1406
|
+
this.callbacks = callbacks;
|
|
1407
|
+
}
|
|
1967
1408
|
get remotePeerId() {
|
|
1968
1409
|
return this.extensionContext?.remotePeerId;
|
|
1969
1410
|
}
|
|
1970
1411
|
async _openStream(streamTag, interval = 5, chunkSize = 2048) {
|
|
1971
|
-
invariant7(!this._streams.has(streamTag), `Stream already exists: ${streamTag}`, {
|
|
1972
|
-
F: __dxlog_file8,
|
|
1973
|
-
L: 39,
|
|
1974
|
-
S: this,
|
|
1975
|
-
A: [
|
|
1976
|
-
"!this._streams.has(streamTag)",
|
|
1977
|
-
"`Stream already exists: ${streamTag}`"
|
|
1978
|
-
]
|
|
1979
|
-
});
|
|
1412
|
+
invariant7(!this._streams.has(streamTag), `Stream already exists: ${streamTag}`, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 25, S: this, A: ["!this._streams.has(streamTag)", "`Stream already exists: ${streamTag}`"] });
|
|
1980
1413
|
const networkStream = await this.extensionContext.createStream(streamTag, {
|
|
1981
1414
|
contentType: "application/x-test-stream"
|
|
1982
1415
|
});
|
|
@@ -2025,24 +1458,11 @@ var TestExtensionWithStreams = class {
|
|
|
2025
1458
|
receiveErrors,
|
|
2026
1459
|
from: this.extensionContext?.localPeerId,
|
|
2027
1460
|
to: this.extensionContext?.remotePeerId
|
|
2028
|
-
}, {
|
|
2029
|
-
F: __dxlog_file8,
|
|
2030
|
-
L: 93,
|
|
2031
|
-
S: this,
|
|
2032
|
-
C: (f, a) => f(...a)
|
|
2033
|
-
});
|
|
1461
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 67, S: this });
|
|
2034
1462
|
}, 100);
|
|
2035
1463
|
}
|
|
2036
1464
|
_closeStream(streamTag) {
|
|
2037
|
-
invariant7(this._streams.has(streamTag), `Stream does not exist: ${streamTag}`, {
|
|
2038
|
-
F: __dxlog_file8,
|
|
2039
|
-
L: 106,
|
|
2040
|
-
S: this,
|
|
2041
|
-
A: [
|
|
2042
|
-
"this._streams.has(streamTag)",
|
|
2043
|
-
"`Stream does not exist: ${streamTag}`"
|
|
2044
|
-
]
|
|
2045
|
-
});
|
|
1465
|
+
invariant7(this._streams.has(streamTag), `Stream does not exist: ${streamTag}`, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 79, S: this, A: ["this._streams.has(streamTag)", "`Stream does not exist: ${streamTag}`"] });
|
|
2046
1466
|
const stream = this._streams.get(streamTag);
|
|
2047
1467
|
clearTimeout(stream.timer);
|
|
2048
1468
|
clearTimeout(stream.reportingTimer);
|
|
@@ -2061,12 +1481,7 @@ var TestExtensionWithStreams = class {
|
|
|
2061
1481
|
log8("onOpen", {
|
|
2062
1482
|
localPeerId: context.localPeerId,
|
|
2063
1483
|
remotePeerId: context.remotePeerId
|
|
2064
|
-
}, {
|
|
2065
|
-
F: __dxlog_file8,
|
|
2066
|
-
L: 128,
|
|
2067
|
-
S: this,
|
|
2068
|
-
C: (f, a) => f(...a)
|
|
2069
|
-
});
|
|
1484
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 95, S: this });
|
|
2070
1485
|
this.extensionContext = context;
|
|
2071
1486
|
this._rpc = createProtoRpcPeer3({
|
|
2072
1487
|
port: await context.createPort("rpc", {
|
|
@@ -2110,23 +1525,13 @@ var TestExtensionWithStreams = class {
|
|
|
2110
1525
|
async onClose(err) {
|
|
2111
1526
|
log8("onClose", {
|
|
2112
1527
|
err
|
|
2113
|
-
}, {
|
|
2114
|
-
F: __dxlog_file8,
|
|
2115
|
-
L: 179,
|
|
2116
|
-
S: this,
|
|
2117
|
-
C: (f, a) => f(...a)
|
|
2118
|
-
});
|
|
1528
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 140, S: this });
|
|
2119
1529
|
await this.callbacks.onClose?.();
|
|
2120
1530
|
this.closed.wake();
|
|
2121
1531
|
for (const [streamTag, stream] of Object.entries(this._streams)) {
|
|
2122
1532
|
log8("closing stream", {
|
|
2123
1533
|
streamTag
|
|
2124
|
-
}, {
|
|
2125
|
-
F: __dxlog_file8,
|
|
2126
|
-
L: 183,
|
|
2127
|
-
S: this,
|
|
2128
|
-
C: (f, a) => f(...a)
|
|
2129
|
-
});
|
|
1534
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 146, S: this });
|
|
2130
1535
|
clearTimeout(stream.interval);
|
|
2131
1536
|
stream.networkStream.destroy();
|
|
2132
1537
|
}
|
|
@@ -2135,12 +1540,7 @@ var TestExtensionWithStreams = class {
|
|
|
2135
1540
|
async onAbort(err) {
|
|
2136
1541
|
log8("onAbort", {
|
|
2137
1542
|
err
|
|
2138
|
-
}, {
|
|
2139
|
-
F: __dxlog_file8,
|
|
2140
|
-
L: 191,
|
|
2141
|
-
S: this,
|
|
2142
|
-
C: (f, a) => f(...a)
|
|
2143
|
-
});
|
|
1543
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 155, S: this });
|
|
2144
1544
|
await this.callbacks.onAbort?.();
|
|
2145
1545
|
this.aborted.wake();
|
|
2146
1546
|
await this._rpc?.abort();
|
|
@@ -2157,15 +1557,7 @@ var TestExtensionWithStreams = class {
|
|
|
2157
1557
|
streamLoadInterval,
|
|
2158
1558
|
streamLoadChunkSize
|
|
2159
1559
|
});
|
|
2160
|
-
invariant7(data === streamTag, void 0, {
|
|
2161
|
-
F: __dxlog_file8,
|
|
2162
|
-
L: 207,
|
|
2163
|
-
S: this,
|
|
2164
|
-
A: [
|
|
2165
|
-
"data === streamTag",
|
|
2166
|
-
""
|
|
2167
|
-
]
|
|
2168
|
-
});
|
|
1560
|
+
invariant7(data === streamTag, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 174, S: this, A: ["data === streamTag", ""] });
|
|
2169
1561
|
await this._openStream(streamTag, streamLoadInterval, streamLoadChunkSize);
|
|
2170
1562
|
return streamTag;
|
|
2171
1563
|
}
|
|
@@ -2176,15 +1568,7 @@ var TestExtensionWithStreams = class {
|
|
|
2176
1568
|
const { data, bytesSent, bytesReceived, sendErrors, receiveErrors, runningTime } = await this._rpc.rpc.TestServiceWithStreams.closeTestStream({
|
|
2177
1569
|
data: streamTag
|
|
2178
1570
|
});
|
|
2179
|
-
invariant7(data === streamTag, void 0, {
|
|
2180
|
-
F: __dxlog_file8,
|
|
2181
|
-
L: 220,
|
|
2182
|
-
S: this,
|
|
2183
|
-
A: [
|
|
2184
|
-
"data === streamTag",
|
|
2185
|
-
""
|
|
2186
|
-
]
|
|
2187
|
-
});
|
|
1571
|
+
invariant7(data === streamTag, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 185, S: this, A: ["data === streamTag", ""] });
|
|
2188
1572
|
const local = this._closeStream(streamTag);
|
|
2189
1573
|
return {
|
|
2190
1574
|
streamTag,
|
|
@@ -2206,20 +1590,6 @@ var TestExtensionWithStreams = class {
|
|
|
2206
1590
|
async closeConnection(err) {
|
|
2207
1591
|
this.extensionContext?.close(err);
|
|
2208
1592
|
}
|
|
2209
|
-
constructor(callbacks = {}) {
|
|
2210
|
-
_define_property8(this, "callbacks", void 0);
|
|
2211
|
-
_define_property8(this, "open", void 0);
|
|
2212
|
-
_define_property8(this, "closed", void 0);
|
|
2213
|
-
_define_property8(this, "aborted", void 0);
|
|
2214
|
-
_define_property8(this, "_streams", void 0);
|
|
2215
|
-
_define_property8(this, "extensionContext", void 0);
|
|
2216
|
-
_define_property8(this, "_rpc", void 0);
|
|
2217
|
-
this.callbacks = callbacks;
|
|
2218
|
-
this.open = new Trigger3();
|
|
2219
|
-
this.closed = new Trigger3();
|
|
2220
|
-
this.aborted = new Trigger3();
|
|
2221
|
-
this._streams = /* @__PURE__ */ new Map();
|
|
2222
|
-
}
|
|
2223
1593
|
};
|
|
2224
1594
|
|
|
2225
1595
|
export {
|
|
@@ -2234,4 +1604,4 @@ export {
|
|
|
2234
1604
|
TestExtension,
|
|
2235
1605
|
TestExtensionWithStreams
|
|
2236
1606
|
};
|
|
2237
|
-
//# sourceMappingURL=chunk-
|
|
1607
|
+
//# sourceMappingURL=chunk-LECANKBC.mjs.map
|