@dxos/network-manager 0.1.52 → 0.1.53-main.01cbc6b
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-U73XV3EJ.mjs → chunk-N5RZB7V4.mjs} +516 -498
- package/dist/lib/browser/chunk-N5RZB7V4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +11 -10
- package/dist/lib/browser/testing/index.mjs.map +1 -1
- package/dist/lib/node/index.cjs +514 -496
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +474 -455
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/connection-log.d.ts.map +1 -1
- package/dist/types/src/transport/memory-transport.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc-transport-proxy.d.ts.map +1 -1
- package/package.json +19 -18
- package/src/connection-log.ts +6 -0
- package/src/network-manager.ts +5 -5
- package/src/signal/swarm-messenger.ts +7 -7
- package/src/swarm/connection.ts +9 -9
- package/src/swarm/peer.ts +6 -6
- package/src/swarm/swarm.ts +8 -8
- package/src/topology/fully-connected-topology.ts +3 -3
- package/src/topology/mmst-topology.ts +5 -5
- package/src/topology/star-topology.ts +4 -4
- package/src/transport/memory-transport.ts +3 -6
- package/src/transport/webrtc-transport-proxy.ts +4 -3
- package/src/transport/webrtc-transport-service.ts +3 -3
- package/src/transport/webrtc-transport.ts +2 -2
- package/dist/lib/browser/chunk-U73XV3EJ.mjs.map +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "@dxos/node-std/globals"
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
2
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
3
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
4
|
}) : x)(function(x) {
|
|
@@ -8,7 +8,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
// packages/core/mesh/network-manager/src/swarm/connection.ts
|
|
11
|
-
import
|
|
11
|
+
import invariant from "tiny-invariant";
|
|
12
12
|
import { DeferredTask, Event, sleep, synchronized } from "@dxos/async";
|
|
13
13
|
import { Context, cancelWithContext } from "@dxos/context";
|
|
14
14
|
import { ErrorStream } from "@dxos/debug";
|
|
@@ -16,7 +16,7 @@ import { CancelledError } from "@dxos/errors";
|
|
|
16
16
|
import { PublicKey } from "@dxos/keys";
|
|
17
17
|
import { log } from "@dxos/log";
|
|
18
18
|
import { trace } from "@dxos/protocols";
|
|
19
|
-
|
|
19
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
20
20
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
21
21
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
22
22
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -25,7 +25,8 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
25
25
|
if (d = decorators[i])
|
|
26
26
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
27
27
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
|
|
29
30
|
var STARTING_SIGNALLING_DELAY = 10;
|
|
30
31
|
var MAX_SIGNALLING_DELAY = 300;
|
|
31
32
|
var ConnectionState;
|
|
@@ -98,29 +99,29 @@ var Connection = class {
|
|
|
98
99
|
*/
|
|
99
100
|
// TODO(burdon): Make async?
|
|
100
101
|
openConnection() {
|
|
101
|
-
|
|
102
|
+
invariant(this._state === ConnectionState.INITIAL, "Invalid state.");
|
|
102
103
|
log.trace("dxos.mesh.connection.open-connection", trace.begin({
|
|
103
104
|
id: this._instanceId
|
|
104
105
|
}), {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
F: __dxlog_file,
|
|
107
|
+
L: 115,
|
|
108
|
+
S: this,
|
|
109
|
+
C: (f, a) => f(...a)
|
|
109
110
|
});
|
|
110
111
|
this._changeState(ConnectionState.CONNECTING);
|
|
111
112
|
this._protocol.initialize().catch((err) => {
|
|
112
113
|
this.errors.raise(err);
|
|
113
114
|
});
|
|
114
115
|
this._protocol.stream.on("close", () => {
|
|
115
|
-
log("protocol stream closed",
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
log("protocol stream closed", void 0, {
|
|
117
|
+
F: __dxlog_file,
|
|
118
|
+
L: 126,
|
|
119
|
+
S: this,
|
|
120
|
+
C: (f, a) => f(...a)
|
|
120
121
|
});
|
|
121
122
|
this.close().catch((err) => this.errors.raise(err));
|
|
122
123
|
});
|
|
123
|
-
|
|
124
|
+
invariant(!this._transport);
|
|
124
125
|
this._transport = this._transportFactory.createTransport({
|
|
125
126
|
initiator: this.initiator,
|
|
126
127
|
stream: this._protocol.stream,
|
|
@@ -145,10 +146,10 @@ var Connection = class {
|
|
|
145
146
|
log.trace("dxos.mesh.connection.open-connection", trace.end({
|
|
146
147
|
id: this._instanceId
|
|
147
148
|
}), {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
F: __dxlog_file,
|
|
150
|
+
L: 159,
|
|
151
|
+
S: this,
|
|
152
|
+
C: (f, a) => f(...a)
|
|
152
153
|
});
|
|
153
154
|
}
|
|
154
155
|
async close() {
|
|
@@ -161,38 +162,38 @@ var Connection = class {
|
|
|
161
162
|
log("closing...", {
|
|
162
163
|
peerId: this.ownId
|
|
163
164
|
}, {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
F: __dxlog_file,
|
|
166
|
+
L: 171,
|
|
167
|
+
S: this,
|
|
168
|
+
C: (f, a) => f(...a)
|
|
168
169
|
});
|
|
169
170
|
try {
|
|
170
171
|
await this._protocol.destroy();
|
|
171
172
|
} catch (err) {
|
|
172
|
-
log.catch(err,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
173
|
+
log.catch(err, void 0, {
|
|
174
|
+
F: __dxlog_file,
|
|
175
|
+
L: 177,
|
|
176
|
+
S: this,
|
|
177
|
+
C: (f, a) => f(...a)
|
|
177
178
|
});
|
|
178
179
|
}
|
|
179
180
|
try {
|
|
180
181
|
await ((_a = this._transport) == null ? void 0 : _a.destroy());
|
|
181
|
-
} catch (
|
|
182
|
-
log.catch(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
} catch (err) {
|
|
183
|
+
log.catch(err, void 0, {
|
|
184
|
+
F: __dxlog_file,
|
|
185
|
+
L: 184,
|
|
186
|
+
S: this,
|
|
187
|
+
C: (f, a) => f(...a)
|
|
187
188
|
});
|
|
188
189
|
}
|
|
189
190
|
log("closed", {
|
|
190
191
|
peerId: this.ownId
|
|
191
192
|
}, {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
F: __dxlog_file,
|
|
194
|
+
L: 187,
|
|
195
|
+
S: this,
|
|
196
|
+
C: (f, a) => f(...a)
|
|
196
197
|
});
|
|
197
198
|
this._changeState(ConnectionState.CLOSED);
|
|
198
199
|
}
|
|
@@ -229,10 +230,10 @@ var Connection = class {
|
|
|
229
230
|
log.warn("Signal failed", {
|
|
230
231
|
err
|
|
231
232
|
}, {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
F: __dxlog_file,
|
|
234
|
+
L: 221,
|
|
235
|
+
S: this,
|
|
236
|
+
C: (f, a) => f(...a)
|
|
236
237
|
});
|
|
237
238
|
await this.close();
|
|
238
239
|
}
|
|
@@ -242,19 +243,19 @@ var Connection = class {
|
|
|
242
243
|
*/
|
|
243
244
|
async signal(msg) {
|
|
244
245
|
var _a, _b, _c;
|
|
245
|
-
|
|
246
|
+
invariant(msg.sessionId);
|
|
246
247
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
247
|
-
log("dropping signal for incorrect session id",
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
248
|
+
log("dropping signal for incorrect session id", void 0, {
|
|
249
|
+
F: __dxlog_file,
|
|
250
|
+
L: 232,
|
|
251
|
+
S: this,
|
|
252
|
+
C: (f, a) => f(...a)
|
|
252
253
|
});
|
|
253
254
|
return;
|
|
254
255
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
invariant(msg.data.signal || msg.data.signalBatch);
|
|
257
|
+
invariant((_a = msg.author) == null ? void 0 : _a.equals(this.remoteId));
|
|
258
|
+
invariant((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId));
|
|
258
259
|
const signals = msg.data.signalBatch ? (_c = msg.data.signalBatch.signals) != null ? _c : [] : [
|
|
259
260
|
msg.data.signal
|
|
260
261
|
];
|
|
@@ -268,23 +269,23 @@ var Connection = class {
|
|
|
268
269
|
remoteId: this.remoteId,
|
|
269
270
|
msg: msg.data
|
|
270
271
|
}, {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
272
|
+
F: __dxlog_file,
|
|
273
|
+
L: 246,
|
|
274
|
+
S: this,
|
|
275
|
+
C: (f, a) => f(...a)
|
|
275
276
|
});
|
|
276
277
|
this._incomingSignalBuffer.push(signal);
|
|
277
278
|
} else {
|
|
278
|
-
|
|
279
|
+
invariant(this._transport, "Connection not ready to accept signals.");
|
|
279
280
|
log("received signal", {
|
|
280
281
|
peerId: this.ownId,
|
|
281
282
|
remoteId: this.remoteId,
|
|
282
283
|
msg: msg.data
|
|
283
284
|
}, {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
285
|
+
F: __dxlog_file,
|
|
286
|
+
L: 250,
|
|
287
|
+
S: this,
|
|
288
|
+
C: (f, a) => f(...a)
|
|
288
289
|
});
|
|
289
290
|
await this._transport.signal(signal);
|
|
290
291
|
}
|
|
@@ -296,27 +297,28 @@ var Connection = class {
|
|
|
296
297
|
too: state,
|
|
297
298
|
peerId: this.ownId
|
|
298
299
|
}, {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
300
|
+
F: __dxlog_file,
|
|
301
|
+
L: 257,
|
|
302
|
+
S: this,
|
|
303
|
+
C: (f, a) => f(...a)
|
|
303
304
|
});
|
|
304
|
-
|
|
305
|
+
invariant(state !== this._state, "Already in this state.");
|
|
305
306
|
this._state = state;
|
|
306
307
|
this.stateChanged.emit(state);
|
|
307
308
|
}
|
|
308
309
|
};
|
|
309
|
-
|
|
310
|
+
_ts_decorate([
|
|
310
311
|
synchronized
|
|
311
312
|
], Connection.prototype, "close", null);
|
|
312
313
|
|
|
313
314
|
// packages/core/mesh/network-manager/src/signal/swarm-messenger.ts
|
|
314
|
-
import
|
|
315
|
+
import invariant2 from "tiny-invariant";
|
|
315
316
|
import { Context as Context2 } from "@dxos/context";
|
|
316
317
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
317
318
|
import { log as log2 } from "@dxos/log";
|
|
318
319
|
import { schema } from "@dxos/protocols";
|
|
319
320
|
import { ComplexMap } from "@dxos/util";
|
|
321
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
|
|
320
322
|
var SwarmMessenger = class {
|
|
321
323
|
constructor({ sendMessage, onSignal, onOffer, topic }) {
|
|
322
324
|
this._ctx = new Context2();
|
|
@@ -340,10 +342,10 @@ var SwarmMessenger = class {
|
|
|
340
342
|
to: recipient,
|
|
341
343
|
msg: message
|
|
342
344
|
}, {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
F: __dxlog_file2,
|
|
346
|
+
L: 68,
|
|
347
|
+
S: this,
|
|
348
|
+
C: (f, a) => f(...a)
|
|
347
349
|
});
|
|
348
350
|
if ((_a = message.data) == null ? void 0 : _a.offer) {
|
|
349
351
|
await this._handleOffer({
|
|
@@ -369,16 +371,16 @@ var SwarmMessenger = class {
|
|
|
369
371
|
log2.warn("unknown message", {
|
|
370
372
|
message
|
|
371
373
|
}, {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
374
|
+
F: __dxlog_file2,
|
|
375
|
+
L: 79,
|
|
376
|
+
S: this,
|
|
377
|
+
C: (f, a) => f(...a)
|
|
376
378
|
});
|
|
377
379
|
}
|
|
378
380
|
}
|
|
379
381
|
async signal(message) {
|
|
380
382
|
var _a, _b;
|
|
381
|
-
|
|
383
|
+
invariant2(((_a = message.data) == null ? void 0 : _a.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
|
|
382
384
|
await this._sendReliableMessage({
|
|
383
385
|
author: message.author,
|
|
384
386
|
recipient: message.recipient,
|
|
@@ -413,10 +415,10 @@ var SwarmMessenger = class {
|
|
|
413
415
|
to: recipient,
|
|
414
416
|
msg: networkMessage
|
|
415
417
|
}, {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
418
|
+
F: __dxlog_file2,
|
|
419
|
+
L: 122,
|
|
420
|
+
S: this,
|
|
421
|
+
C: (f, a) => f(...a)
|
|
420
422
|
});
|
|
421
423
|
await this._sendMessage({
|
|
422
424
|
author,
|
|
@@ -429,24 +431,24 @@ var SwarmMessenger = class {
|
|
|
429
431
|
}
|
|
430
432
|
async _resolveAnswers(message) {
|
|
431
433
|
var _a, _b, _c;
|
|
432
|
-
|
|
434
|
+
invariant2((_b = (_a = message.data) == null ? void 0 : _a.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
|
|
433
435
|
const offerRecord = this._offerRecords.get(message.data.answer.offerMessageId);
|
|
434
436
|
if (offerRecord) {
|
|
435
437
|
this._offerRecords.delete(message.data.answer.offerMessageId);
|
|
436
|
-
|
|
438
|
+
invariant2((_c = message.data) == null ? void 0 : _c.answer, "No answer");
|
|
437
439
|
log2("resolving", {
|
|
438
440
|
answer: message.data.answer
|
|
439
441
|
}, {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
442
|
+
F: __dxlog_file2,
|
|
443
|
+
L: 139,
|
|
444
|
+
S: this,
|
|
445
|
+
C: (f, a) => f(...a)
|
|
444
446
|
});
|
|
445
447
|
offerRecord.resolve(message.data.answer);
|
|
446
448
|
}
|
|
447
449
|
}
|
|
448
450
|
async _handleOffer({ author, recipient, message }) {
|
|
449
|
-
|
|
451
|
+
invariant2(message.data.offer, "No offer");
|
|
450
452
|
const offerMessage = {
|
|
451
453
|
author,
|
|
452
454
|
recipient,
|
|
@@ -473,16 +475,16 @@ var SwarmMessenger = class {
|
|
|
473
475
|
log2.warn("error sending answer", {
|
|
474
476
|
err
|
|
475
477
|
}, {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
478
|
+
F: __dxlog_file2,
|
|
479
|
+
L: 173,
|
|
480
|
+
S: this,
|
|
481
|
+
C: (f, a) => f(...a)
|
|
480
482
|
});
|
|
481
483
|
}
|
|
482
484
|
}
|
|
483
485
|
async _handleSignal({ author, recipient, message }) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
+
invariant2(message.messageId);
|
|
487
|
+
invariant2(message.data.signal || message.data.signalBatch, "Invalid message");
|
|
486
488
|
const signalMessage = {
|
|
487
489
|
author,
|
|
488
490
|
recipient,
|
|
@@ -497,7 +499,7 @@ var SwarmMessenger = class {
|
|
|
497
499
|
};
|
|
498
500
|
|
|
499
501
|
// packages/core/mesh/network-manager/src/swarm/swarm.ts
|
|
500
|
-
import
|
|
502
|
+
import invariant4 from "tiny-invariant";
|
|
501
503
|
import { Event as Event2, scheduleTask as scheduleTask2, sleep as sleep2, synchronized as synchronized3 } from "@dxos/async";
|
|
502
504
|
import { Context as Context4 } from "@dxos/context";
|
|
503
505
|
import { ErrorStream as ErrorStream2 } from "@dxos/debug";
|
|
@@ -507,12 +509,12 @@ import { trace as trace2 } from "@dxos/protocols";
|
|
|
507
509
|
import { ComplexMap as ComplexMap2, isNotNullOrUndefined } from "@dxos/util";
|
|
508
510
|
|
|
509
511
|
// packages/core/mesh/network-manager/src/swarm/peer.ts
|
|
510
|
-
import
|
|
512
|
+
import invariant3 from "tiny-invariant";
|
|
511
513
|
import { scheduleTask, synchronized as synchronized2 } from "@dxos/async";
|
|
512
514
|
import { Context as Context3 } from "@dxos/context";
|
|
513
515
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
514
516
|
import { log as log3 } from "@dxos/log";
|
|
515
|
-
|
|
517
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
516
518
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
517
519
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
518
520
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -521,7 +523,8 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
521
523
|
if (d = decorators[i])
|
|
522
524
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
523
525
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
524
|
-
}
|
|
526
|
+
}
|
|
527
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
|
|
525
528
|
var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
|
|
526
529
|
var Peer = class {
|
|
527
530
|
constructor(id, topic, localPeerId, _signalMessaging, _protocolProvider, _transportFactory, _callbacks) {
|
|
@@ -550,10 +553,10 @@ var Peer = class {
|
|
|
550
553
|
topic: this.topic,
|
|
551
554
|
peerId: this.localPeerId
|
|
552
555
|
}, {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
556
|
+
F: __dxlog_file3,
|
|
557
|
+
L: 105,
|
|
558
|
+
S: this,
|
|
559
|
+
C: (f, a) => f(...a)
|
|
557
560
|
});
|
|
558
561
|
if (this.connection) {
|
|
559
562
|
await this.closeConnection();
|
|
@@ -566,7 +569,7 @@ var Peer = class {
|
|
|
566
569
|
}
|
|
567
570
|
if (await this._callbacks.onOffer(remoteId)) {
|
|
568
571
|
if (!this.connection) {
|
|
569
|
-
|
|
572
|
+
invariant3(message.sessionId);
|
|
570
573
|
const connection = this._createConnection(false, message.sessionId);
|
|
571
574
|
try {
|
|
572
575
|
connection.openConnection();
|
|
@@ -577,10 +580,10 @@ var Peer = class {
|
|
|
577
580
|
remoteId: this.id,
|
|
578
581
|
err
|
|
579
582
|
}, {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
583
|
+
F: __dxlog_file3,
|
|
584
|
+
L: 129,
|
|
585
|
+
S: this,
|
|
586
|
+
C: (f, a) => f(...a)
|
|
584
587
|
});
|
|
585
588
|
await this.closeConnection();
|
|
586
589
|
}
|
|
@@ -597,8 +600,8 @@ var Peer = class {
|
|
|
597
600
|
* Initiate a connection to the remote peer.
|
|
598
601
|
*/
|
|
599
602
|
async initiateConnection() {
|
|
600
|
-
|
|
601
|
-
|
|
603
|
+
invariant3(!this.initiating, "Initiation in progress.");
|
|
604
|
+
invariant3(!this.connection, "Already connected.");
|
|
602
605
|
const sessionId = PublicKey3.random();
|
|
603
606
|
log3("initiating...", {
|
|
604
607
|
id: this.id,
|
|
@@ -606,10 +609,10 @@ var Peer = class {
|
|
|
606
609
|
peerId: this.id,
|
|
607
610
|
sessionId
|
|
608
611
|
}, {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
612
|
+
F: __dxlog_file3,
|
|
613
|
+
L: 147,
|
|
614
|
+
S: this,
|
|
615
|
+
C: (f, a) => f(...a)
|
|
613
616
|
});
|
|
614
617
|
const connection = this._createConnection(true, sessionId);
|
|
615
618
|
this.initiating = true;
|
|
@@ -629,17 +632,17 @@ var Peer = class {
|
|
|
629
632
|
ownId: this.localPeerId,
|
|
630
633
|
remoteId: this.id
|
|
631
634
|
}, {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
635
|
+
F: __dxlog_file3,
|
|
636
|
+
L: 159,
|
|
637
|
+
S: this,
|
|
638
|
+
C: (f, a) => f(...a)
|
|
636
639
|
});
|
|
637
640
|
if (connection.state !== ConnectionState.INITIAL) {
|
|
638
|
-
log3("ignoring response",
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
641
|
+
log3("ignoring response", void 0, {
|
|
642
|
+
F: __dxlog_file3,
|
|
643
|
+
L: 161,
|
|
644
|
+
S: this,
|
|
645
|
+
C: (f, a) => f(...a)
|
|
643
646
|
});
|
|
644
647
|
return;
|
|
645
648
|
}
|
|
@@ -656,10 +659,10 @@ var Peer = class {
|
|
|
656
659
|
peerId: this.localPeerId,
|
|
657
660
|
remoteId: this.id
|
|
658
661
|
}, {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
662
|
+
F: __dxlog_file3,
|
|
663
|
+
L: 172,
|
|
664
|
+
S: this,
|
|
665
|
+
C: (f, a) => f(...a)
|
|
663
666
|
});
|
|
664
667
|
await this.closeConnection();
|
|
665
668
|
throw err;
|
|
@@ -680,12 +683,12 @@ var Peer = class {
|
|
|
680
683
|
initiator,
|
|
681
684
|
sessionId
|
|
682
685
|
}, {
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
686
|
+
F: __dxlog_file3,
|
|
687
|
+
L: 186,
|
|
688
|
+
S: this,
|
|
689
|
+
C: (f, a) => f(...a)
|
|
687
690
|
});
|
|
688
|
-
|
|
691
|
+
invariant3(!this.connection, "Already connected.");
|
|
689
692
|
const connection = new Connection(
|
|
690
693
|
this.topic,
|
|
691
694
|
this.localPeerId,
|
|
@@ -720,12 +723,12 @@ var Peer = class {
|
|
|
720
723
|
remoteId: this.id,
|
|
721
724
|
initiator
|
|
722
725
|
}, {
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
726
|
+
F: __dxlog_file3,
|
|
727
|
+
L: 221,
|
|
728
|
+
S: this,
|
|
729
|
+
C: (f, a) => f(...a)
|
|
727
730
|
});
|
|
728
|
-
|
|
731
|
+
invariant3(this.connection === connection, "Connection mismatch (race condition).");
|
|
729
732
|
if (this._lastConnectionTime && this._lastConnectionTime + CONNECTION_COUNTS_STABLE_AFTER < Date.now()) {
|
|
730
733
|
this._availableAfter = 0;
|
|
731
734
|
} else {
|
|
@@ -750,10 +753,10 @@ var Peer = class {
|
|
|
750
753
|
initiator,
|
|
751
754
|
err
|
|
752
755
|
}, {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
756
|
+
F: __dxlog_file3,
|
|
757
|
+
L: 249,
|
|
758
|
+
S: this,
|
|
759
|
+
C: (f, a) => f(...a)
|
|
757
760
|
});
|
|
758
761
|
void this.closeConnection();
|
|
759
762
|
});
|
|
@@ -769,20 +772,20 @@ var Peer = class {
|
|
|
769
772
|
peerId: this.id,
|
|
770
773
|
sessionId: connection.sessionId
|
|
771
774
|
}, {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
775
|
+
F: __dxlog_file3,
|
|
776
|
+
L: 265,
|
|
777
|
+
S: this,
|
|
778
|
+
C: (f, a) => f(...a)
|
|
776
779
|
});
|
|
777
780
|
await connection.close();
|
|
778
781
|
log3("closed", {
|
|
779
782
|
peerId: this.id,
|
|
780
783
|
sessionId: connection.sessionId
|
|
781
784
|
}, {
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
785
|
+
F: __dxlog_file3,
|
|
786
|
+
L: 271,
|
|
787
|
+
S: this,
|
|
788
|
+
C: (f, a) => f(...a)
|
|
786
789
|
});
|
|
787
790
|
}
|
|
788
791
|
async onSignal(message) {
|
|
@@ -790,10 +793,10 @@ var Peer = class {
|
|
|
790
793
|
log3("dropping signal message for non-existent connection", {
|
|
791
794
|
message
|
|
792
795
|
}, {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
796
|
+
F: __dxlog_file3,
|
|
797
|
+
L: 276,
|
|
798
|
+
S: this,
|
|
799
|
+
C: (f, a) => f(...a)
|
|
797
800
|
});
|
|
798
801
|
return;
|
|
799
802
|
}
|
|
@@ -806,15 +809,15 @@ var Peer = class {
|
|
|
806
809
|
peerId: this.id,
|
|
807
810
|
topic: this.topic
|
|
808
811
|
}, {
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
812
|
+
F: __dxlog_file3,
|
|
813
|
+
L: 285,
|
|
814
|
+
S: this,
|
|
815
|
+
C: (f, a) => f(...a)
|
|
813
816
|
});
|
|
814
817
|
await ((_a = this == null ? void 0 : this.connection) == null ? void 0 : _a.close());
|
|
815
818
|
}
|
|
816
819
|
};
|
|
817
|
-
|
|
820
|
+
_ts_decorate2([
|
|
818
821
|
synchronized2
|
|
819
822
|
], Peer.prototype, "destroy", null);
|
|
820
823
|
var increaseInterval = (interval) => {
|
|
@@ -831,7 +834,7 @@ var increaseInterval = (interval) => {
|
|
|
831
834
|
};
|
|
832
835
|
|
|
833
836
|
// packages/core/mesh/network-manager/src/swarm/swarm.ts
|
|
834
|
-
|
|
837
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
835
838
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
836
839
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
837
840
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -840,7 +843,8 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
840
843
|
if (d = decorators[i])
|
|
841
844
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
842
845
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
843
|
-
}
|
|
846
|
+
}
|
|
847
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
|
|
844
848
|
var INITIATION_DELAY = 100;
|
|
845
849
|
var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
|
|
846
850
|
var Swarm = class {
|
|
@@ -857,11 +861,11 @@ var Swarm = class {
|
|
|
857
861
|
this._peers = new ComplexMap2(PublicKey4.hash);
|
|
858
862
|
this._ctx = new Context4();
|
|
859
863
|
this._listeningHandle = void 0;
|
|
864
|
+
this._instanceId = PublicKey4.random().toHex();
|
|
860
865
|
this.connectionAdded = new Event2();
|
|
861
866
|
this.disconnected = new Event2();
|
|
862
867
|
this.connected = new Event2();
|
|
863
868
|
this.errors = new ErrorStream2();
|
|
864
|
-
this._instanceId = PublicKey4.random().toHex();
|
|
865
869
|
log4.trace("dxos.mesh.swarm.constructor", trace2.begin({
|
|
866
870
|
id: this._instanceId,
|
|
867
871
|
data: {
|
|
@@ -869,18 +873,18 @@ var Swarm = class {
|
|
|
869
873
|
peerId: this._ownPeerId.toHex()
|
|
870
874
|
}
|
|
871
875
|
}), {
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
+
F: __dxlog_file4,
|
|
877
|
+
L: 86,
|
|
878
|
+
S: this,
|
|
879
|
+
C: (f, a) => f(...a)
|
|
876
880
|
});
|
|
877
881
|
log4("creating swarm", {
|
|
878
882
|
peerId: _ownPeerId
|
|
879
883
|
}, {
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
+
F: __dxlog_file4,
|
|
885
|
+
L: 90,
|
|
886
|
+
S: this,
|
|
887
|
+
C: (f, a) => f(...a)
|
|
884
888
|
});
|
|
885
889
|
_topology.init(this._getSwarmController());
|
|
886
890
|
this._swarmMessenger = new SwarmMessenger({
|
|
@@ -892,10 +896,10 @@ var Swarm = class {
|
|
|
892
896
|
log4.trace("dxos.mesh.swarm.constructor", trace2.end({
|
|
893
897
|
id: this._instanceId
|
|
894
898
|
}), {
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
+
F: __dxlog_file4,
|
|
900
|
+
L: 99,
|
|
901
|
+
S: this,
|
|
902
|
+
C: (f, a) => f(...a)
|
|
899
903
|
});
|
|
900
904
|
}
|
|
901
905
|
get connections() {
|
|
@@ -914,7 +918,7 @@ var Swarm = class {
|
|
|
914
918
|
return this._topic;
|
|
915
919
|
}
|
|
916
920
|
async open() {
|
|
917
|
-
|
|
921
|
+
invariant4(!this._listeningHandle);
|
|
918
922
|
this._listeningHandle = await this._messenger.listen({
|
|
919
923
|
peerId: this._ownPeerId,
|
|
920
924
|
payloadType: "dxos.mesh.swarm.SwarmMessage",
|
|
@@ -922,36 +926,36 @@ var Swarm = class {
|
|
|
922
926
|
await this._swarmMessenger.receiveMessage(message).catch((err) => log4.warn("Error while receiving message", {
|
|
923
927
|
err
|
|
924
928
|
}, {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
+
F: __dxlog_file4,
|
|
930
|
+
L: 133,
|
|
931
|
+
S: this,
|
|
932
|
+
C: (f, a) => f(...a)
|
|
929
933
|
}));
|
|
930
934
|
}
|
|
931
935
|
});
|
|
932
936
|
}
|
|
933
937
|
async destroy() {
|
|
934
938
|
var _a;
|
|
935
|
-
log4("destroying...",
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
939
|
+
log4("destroying...", void 0, {
|
|
940
|
+
F: __dxlog_file4,
|
|
941
|
+
L: 139,
|
|
942
|
+
S: this,
|
|
943
|
+
C: (f, a) => f(...a)
|
|
940
944
|
});
|
|
941
945
|
await ((_a = this._listeningHandle) == null ? void 0 : _a.unsubscribe());
|
|
942
946
|
this._listeningHandle = void 0;
|
|
943
947
|
await this._ctx.dispose();
|
|
944
948
|
await this._topology.destroy();
|
|
945
949
|
await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
|
|
946
|
-
log4("destroyed",
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
950
|
+
log4("destroyed", void 0, {
|
|
951
|
+
F: __dxlog_file4,
|
|
952
|
+
L: 146,
|
|
953
|
+
S: this,
|
|
954
|
+
C: (f, a) => f(...a)
|
|
951
955
|
});
|
|
952
956
|
}
|
|
953
957
|
async setTopology(topology) {
|
|
954
|
-
|
|
958
|
+
invariant4(!this._ctx.disposed, "Swarm is offline");
|
|
955
959
|
if (topology === this._topology) {
|
|
956
960
|
return;
|
|
957
961
|
}
|
|
@@ -959,10 +963,10 @@ var Swarm = class {
|
|
|
959
963
|
previous: getClassName(this._topology),
|
|
960
964
|
topology: getClassName(topology)
|
|
961
965
|
}, {
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
+
F: __dxlog_file4,
|
|
967
|
+
L: 154,
|
|
968
|
+
S: this,
|
|
969
|
+
C: (f, a) => f(...a)
|
|
966
970
|
});
|
|
967
971
|
await this._topology.destroy();
|
|
968
972
|
this._topology = topology;
|
|
@@ -974,17 +978,17 @@ var Swarm = class {
|
|
|
974
978
|
log4("swarm event", {
|
|
975
979
|
swarmEvent
|
|
976
980
|
}, {
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
+
F: __dxlog_file4,
|
|
982
|
+
L: 167,
|
|
983
|
+
S: this,
|
|
984
|
+
C: (f, a) => f(...a)
|
|
981
985
|
});
|
|
982
986
|
if (this._ctx.disposed) {
|
|
983
|
-
log4("swarm event ignored for disposed swarm",
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
987
|
+
log4("swarm event ignored for disposed swarm", void 0, {
|
|
988
|
+
F: __dxlog_file4,
|
|
989
|
+
L: 170,
|
|
990
|
+
S: this,
|
|
991
|
+
C: (f, a) => f(...a)
|
|
988
992
|
});
|
|
989
993
|
return;
|
|
990
994
|
}
|
|
@@ -993,25 +997,25 @@ var Swarm = class {
|
|
|
993
997
|
log4("new peer", {
|
|
994
998
|
peerId
|
|
995
999
|
}, {
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
+
F: __dxlog_file4,
|
|
1001
|
+
L: 176,
|
|
1002
|
+
S: this,
|
|
1003
|
+
C: (f, a) => f(...a)
|
|
1000
1004
|
});
|
|
1001
1005
|
if (!peerId.equals(this._ownPeerId)) {
|
|
1002
1006
|
const peer = this._getOrCreatePeer(peerId);
|
|
1003
1007
|
peer.advertizing = true;
|
|
1004
1008
|
}
|
|
1005
1009
|
} else if (swarmEvent.peerLeft) {
|
|
1006
|
-
const
|
|
1007
|
-
if (
|
|
1008
|
-
|
|
1009
|
-
if (((_a =
|
|
1010
|
-
void this._destroyPeer(
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1010
|
+
const peer = this._peers.get(PublicKey4.from(swarmEvent.peerLeft.peer));
|
|
1011
|
+
if (peer) {
|
|
1012
|
+
peer.advertizing = false;
|
|
1013
|
+
if (((_a = peer.connection) == null ? void 0 : _a.state) !== ConnectionState.CONNECTED) {
|
|
1014
|
+
void this._destroyPeer(peer.id).catch((err) => log4.catch(err, void 0, {
|
|
1015
|
+
F: __dxlog_file4,
|
|
1016
|
+
L: 187,
|
|
1017
|
+
S: this,
|
|
1018
|
+
C: (f, a) => f(...a)
|
|
1015
1019
|
}));
|
|
1016
1020
|
}
|
|
1017
1021
|
}
|
|
@@ -1023,31 +1027,31 @@ var Swarm = class {
|
|
|
1023
1027
|
log4("offer", {
|
|
1024
1028
|
message
|
|
1025
1029
|
}, {
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
+
F: __dxlog_file4,
|
|
1031
|
+
L: 197,
|
|
1032
|
+
S: this,
|
|
1033
|
+
C: (f, a) => f(...a)
|
|
1030
1034
|
});
|
|
1031
1035
|
if (this._ctx.disposed) {
|
|
1032
|
-
log4("ignored for disposed swarm",
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1036
|
+
log4("ignored for disposed swarm", void 0, {
|
|
1037
|
+
F: __dxlog_file4,
|
|
1038
|
+
L: 199,
|
|
1039
|
+
S: this,
|
|
1040
|
+
C: (f, a) => f(...a)
|
|
1037
1041
|
});
|
|
1038
1042
|
return {
|
|
1039
1043
|
accept: false
|
|
1040
1044
|
};
|
|
1041
1045
|
}
|
|
1042
|
-
|
|
1046
|
+
invariant4(message.author);
|
|
1043
1047
|
if (!((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId))) {
|
|
1044
1048
|
log4("rejecting offer with incorrect peerId", {
|
|
1045
1049
|
message
|
|
1046
1050
|
}, {
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
+
F: __dxlog_file4,
|
|
1052
|
+
L: 206,
|
|
1053
|
+
S: this,
|
|
1054
|
+
C: (f, a) => f(...a)
|
|
1051
1055
|
});
|
|
1052
1056
|
return {
|
|
1053
1057
|
accept: false
|
|
@@ -1057,10 +1061,10 @@ var Swarm = class {
|
|
|
1057
1061
|
log4("rejecting offer with incorrect topic", {
|
|
1058
1062
|
message
|
|
1059
1063
|
}, {
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
+
F: __dxlog_file4,
|
|
1065
|
+
L: 210,
|
|
1066
|
+
S: this,
|
|
1067
|
+
C: (f, a) => f(...a)
|
|
1064
1068
|
});
|
|
1065
1069
|
return {
|
|
1066
1070
|
accept: false
|
|
@@ -1076,23 +1080,23 @@ var Swarm = class {
|
|
|
1076
1080
|
log4("signal", {
|
|
1077
1081
|
message
|
|
1078
1082
|
}, {
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
+
F: __dxlog_file4,
|
|
1084
|
+
L: 222,
|
|
1085
|
+
S: this,
|
|
1086
|
+
C: (f, a) => f(...a)
|
|
1083
1087
|
});
|
|
1084
1088
|
if (this._ctx.disposed) {
|
|
1085
|
-
log4.info("ignored for offline swarm",
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1089
|
+
log4.info("ignored for offline swarm", void 0, {
|
|
1090
|
+
F: __dxlog_file4,
|
|
1091
|
+
L: 224,
|
|
1092
|
+
S: this,
|
|
1093
|
+
C: (f, a) => f(...a)
|
|
1090
1094
|
});
|
|
1091
1095
|
return;
|
|
1092
1096
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1097
|
+
invariant4((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
|
|
1098
|
+
invariant4((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
|
|
1099
|
+
invariant4(message.author);
|
|
1096
1100
|
const peer = this._getOrCreatePeer(message.author);
|
|
1097
1101
|
await peer.onSignal(message);
|
|
1098
1102
|
}
|
|
@@ -1144,7 +1148,7 @@ var Swarm = class {
|
|
|
1144
1148
|
return peer;
|
|
1145
1149
|
}
|
|
1146
1150
|
async _destroyPeer(peerId) {
|
|
1147
|
-
|
|
1151
|
+
invariant4(this._peers.has(peerId));
|
|
1148
1152
|
await this._peers.get(peerId).destroy();
|
|
1149
1153
|
this._peers.delete(peerId);
|
|
1150
1154
|
}
|
|
@@ -1164,10 +1168,10 @@ var Swarm = class {
|
|
|
1164
1168
|
await this._initiateConnection(peer);
|
|
1165
1169
|
} catch (err) {
|
|
1166
1170
|
log4("initiation error", err, {
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
+
F: __dxlog_file4,
|
|
1172
|
+
L: 327,
|
|
1173
|
+
S: this,
|
|
1174
|
+
C: (f, a) => f(...a)
|
|
1171
1175
|
});
|
|
1172
1176
|
}
|
|
1173
1177
|
});
|
|
@@ -1192,10 +1196,10 @@ var Swarm = class {
|
|
|
1192
1196
|
log4("initiation delay", {
|
|
1193
1197
|
remoteId
|
|
1194
1198
|
}, {
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
+
F: __dxlog_file4,
|
|
1200
|
+
L: 354,
|
|
1201
|
+
S: this,
|
|
1202
|
+
C: (f, a) => f(...a)
|
|
1199
1203
|
});
|
|
1200
1204
|
await sleep2(INITIATION_DELAY);
|
|
1201
1205
|
}
|
|
@@ -1209,20 +1213,20 @@ var Swarm = class {
|
|
|
1209
1213
|
log4("initiating connection...", {
|
|
1210
1214
|
remoteId
|
|
1211
1215
|
}, {
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
+
F: __dxlog_file4,
|
|
1217
|
+
L: 368,
|
|
1218
|
+
S: this,
|
|
1219
|
+
C: (f, a) => f(...a)
|
|
1216
1220
|
});
|
|
1217
1221
|
await peer.initiateConnection();
|
|
1218
1222
|
this._topology.update();
|
|
1219
1223
|
log4("initiated", {
|
|
1220
1224
|
remoteId
|
|
1221
1225
|
}, {
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
+
F: __dxlog_file4,
|
|
1227
|
+
L: 371,
|
|
1228
|
+
S: this,
|
|
1229
|
+
C: (f, a) => f(...a)
|
|
1226
1230
|
});
|
|
1227
1231
|
}
|
|
1228
1232
|
async _closeConnection(peerId) {
|
|
@@ -1233,28 +1237,28 @@ var Swarm = class {
|
|
|
1233
1237
|
await peer.closeConnection();
|
|
1234
1238
|
}
|
|
1235
1239
|
};
|
|
1236
|
-
|
|
1240
|
+
_ts_decorate3([
|
|
1237
1241
|
logInfo
|
|
1238
1242
|
], Swarm.prototype, "_instanceId", void 0);
|
|
1239
|
-
|
|
1243
|
+
_ts_decorate3([
|
|
1240
1244
|
logInfo
|
|
1241
1245
|
], Swarm.prototype, "ownPeerId", null);
|
|
1242
|
-
|
|
1246
|
+
_ts_decorate3([
|
|
1243
1247
|
logInfo
|
|
1244
1248
|
], Swarm.prototype, "topic", null);
|
|
1245
|
-
|
|
1249
|
+
_ts_decorate3([
|
|
1246
1250
|
synchronized3
|
|
1247
1251
|
], Swarm.prototype, "onSwarmEvent", null);
|
|
1248
|
-
|
|
1252
|
+
_ts_decorate3([
|
|
1249
1253
|
synchronized3
|
|
1250
1254
|
], Swarm.prototype, "onOffer", null);
|
|
1251
|
-
|
|
1255
|
+
_ts_decorate3([
|
|
1252
1256
|
synchronized3
|
|
1253
1257
|
], Swarm.prototype, "onSignal", null);
|
|
1254
|
-
|
|
1258
|
+
_ts_decorate3([
|
|
1255
1259
|
synchronized3
|
|
1256
1260
|
], Swarm.prototype, "goOffline", null);
|
|
1257
|
-
|
|
1261
|
+
_ts_decorate3([
|
|
1258
1262
|
synchronized3
|
|
1259
1263
|
], Swarm.prototype, "goOnline", null);
|
|
1260
1264
|
|
|
@@ -1263,6 +1267,7 @@ import { Event as Event3, EventSubscriptions } from "@dxos/async";
|
|
|
1263
1267
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1264
1268
|
import { log as log5 } from "@dxos/log";
|
|
1265
1269
|
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
1270
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
|
|
1266
1271
|
var SwarmMapper = class {
|
|
1267
1272
|
get peers() {
|
|
1268
1273
|
return Array.from(this._peers.values());
|
|
@@ -1289,11 +1294,11 @@ var SwarmMapper = class {
|
|
|
1289
1294
|
this._update();
|
|
1290
1295
|
}
|
|
1291
1296
|
_update() {
|
|
1292
|
-
log5("updating swarm",
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
+
log5("updating swarm", void 0, {
|
|
1298
|
+
F: __dxlog_file5,
|
|
1299
|
+
L: 75,
|
|
1300
|
+
S: this,
|
|
1301
|
+
C: (f, a) => f(...a)
|
|
1297
1302
|
});
|
|
1298
1303
|
this._peers.clear();
|
|
1299
1304
|
this._peers.set(this._swarm.ownPeerId, {
|
|
@@ -1314,10 +1319,10 @@ var SwarmMapper = class {
|
|
|
1314
1319
|
directConnections: this._swarm.connections.length,
|
|
1315
1320
|
totalPeersInSwarm: this._peers.size
|
|
1316
1321
|
}, {
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1322
|
+
F: __dxlog_file5,
|
|
1323
|
+
L: 116,
|
|
1324
|
+
S: this,
|
|
1325
|
+
C: (f, a) => f(...a)
|
|
1321
1326
|
});
|
|
1322
1327
|
this.mapUpdated.emit(Array.from(this._peers.values()));
|
|
1323
1328
|
}
|
|
@@ -1367,6 +1372,7 @@ var ConnectionLog = class {
|
|
|
1367
1372
|
this._swarms.set(PublicKey6.from(swarm._instanceId), info);
|
|
1368
1373
|
this.update.emit();
|
|
1369
1374
|
swarm.connectionAdded.on((connection) => {
|
|
1375
|
+
var _a, _b;
|
|
1370
1376
|
const connectionInfo = {
|
|
1371
1377
|
state: ConnectionState.INITIAL,
|
|
1372
1378
|
remotePeerId: connection.remoteId,
|
|
@@ -1385,6 +1391,10 @@ var ConnectionLog = class {
|
|
|
1385
1391
|
});
|
|
1386
1392
|
this.update.emit();
|
|
1387
1393
|
});
|
|
1394
|
+
(_b = (_a = connection.protocol) == null ? void 0 : _a.stats) == null ? void 0 : _b.on((stats) => {
|
|
1395
|
+
connectionInfo.streams = stats;
|
|
1396
|
+
this.update.emit();
|
|
1397
|
+
});
|
|
1388
1398
|
});
|
|
1389
1399
|
}
|
|
1390
1400
|
leftSwarm(swarm) {
|
|
@@ -1394,7 +1404,7 @@ var ConnectionLog = class {
|
|
|
1394
1404
|
};
|
|
1395
1405
|
|
|
1396
1406
|
// packages/core/mesh/network-manager/src/network-manager.ts
|
|
1397
|
-
import
|
|
1407
|
+
import invariant5 from "tiny-invariant";
|
|
1398
1408
|
import { Event as Event5 } from "@dxos/async";
|
|
1399
1409
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1400
1410
|
import { log as log6 } from "@dxos/log";
|
|
@@ -1402,8 +1412,9 @@ import { Messenger } from "@dxos/messaging";
|
|
|
1402
1412
|
import { trace as trace3 } from "@dxos/protocols";
|
|
1403
1413
|
import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1404
1414
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
1415
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
|
|
1405
1416
|
var NetworkManager = class {
|
|
1406
|
-
constructor({ transportFactory, signalManager, log:
|
|
1417
|
+
constructor({ transportFactory, signalManager, log: log1 }) {
|
|
1407
1418
|
this._swarms = new ComplexMap5(PublicKey7.hash);
|
|
1408
1419
|
this._mappers = new ComplexMap5(PublicKey7.hash);
|
|
1409
1420
|
this._connectionState = ConnectionState2.ONLINE;
|
|
@@ -1423,7 +1434,7 @@ var NetworkManager = class {
|
|
|
1423
1434
|
join: (opts) => this._signalManager.join(opts),
|
|
1424
1435
|
leave: (opts) => this._signalManager.leave(opts)
|
|
1425
1436
|
};
|
|
1426
|
-
if (
|
|
1437
|
+
if (log1) {
|
|
1427
1438
|
this._connectionLog = new ConnectionLog();
|
|
1428
1439
|
}
|
|
1429
1440
|
}
|
|
@@ -1448,30 +1459,30 @@ var NetworkManager = class {
|
|
|
1448
1459
|
log6.trace("dxos.mesh.network-manager.open", trace3.begin({
|
|
1449
1460
|
id: this._instanceId
|
|
1450
1461
|
}), {
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1462
|
+
F: __dxlog_file6,
|
|
1463
|
+
L: 127,
|
|
1464
|
+
S: this,
|
|
1465
|
+
C: (f, a) => f(...a)
|
|
1455
1466
|
});
|
|
1456
1467
|
await this._messenger.open();
|
|
1457
1468
|
await this._signalManager.open();
|
|
1458
1469
|
log6.trace("dxos.mesh.network-manager.open", trace3.end({
|
|
1459
1470
|
id: this._instanceId
|
|
1460
1471
|
}), {
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1472
|
+
F: __dxlog_file6,
|
|
1473
|
+
L: 130,
|
|
1474
|
+
S: this,
|
|
1475
|
+
C: (f, a) => f(...a)
|
|
1465
1476
|
});
|
|
1466
1477
|
}
|
|
1467
1478
|
async close() {
|
|
1468
1479
|
for (const topic of this._swarms.keys()) {
|
|
1469
1480
|
await this.leaveSwarm(topic).catch((err) => {
|
|
1470
|
-
log6(err,
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1481
|
+
log6(err, void 0, {
|
|
1482
|
+
F: __dxlog_file6,
|
|
1483
|
+
L: 136,
|
|
1484
|
+
S: this,
|
|
1485
|
+
C: (f, a) => f(...a)
|
|
1475
1486
|
});
|
|
1476
1487
|
});
|
|
1477
1488
|
}
|
|
@@ -1483,10 +1494,10 @@ var NetworkManager = class {
|
|
|
1483
1494
|
*/
|
|
1484
1495
|
async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
|
|
1485
1496
|
var _a;
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1497
|
+
invariant5(PublicKey7.isPublicKey(topic));
|
|
1498
|
+
invariant5(PublicKey7.isPublicKey(peerId));
|
|
1499
|
+
invariant5(topology);
|
|
1500
|
+
invariant5(typeof protocol === "function");
|
|
1490
1501
|
if (this._swarms.has(topic)) {
|
|
1491
1502
|
throw new Error(`Already connected to swarm: ${PublicKey7.from(topic)}`);
|
|
1492
1503
|
}
|
|
@@ -1495,20 +1506,20 @@ var NetworkManager = class {
|
|
|
1495
1506
|
peerId,
|
|
1496
1507
|
topology: topology.toString()
|
|
1497
1508
|
}, {
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1509
|
+
F: __dxlog_file6,
|
|
1510
|
+
L: 162,
|
|
1511
|
+
S: this,
|
|
1512
|
+
C: (f, a) => f(...a)
|
|
1502
1513
|
});
|
|
1503
1514
|
const swarm = new Swarm(topic, peerId, topology, protocol, this._messenger, this._transportFactory, label);
|
|
1504
1515
|
swarm.errors.handle((error) => {
|
|
1505
1516
|
log6("swarm error", {
|
|
1506
1517
|
error
|
|
1507
1518
|
}, {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1519
|
+
F: __dxlog_file6,
|
|
1520
|
+
L: 165,
|
|
1521
|
+
S: this,
|
|
1522
|
+
C: (f, a) => f(...a)
|
|
1512
1523
|
});
|
|
1513
1524
|
});
|
|
1514
1525
|
this._swarms.set(topic, swarm);
|
|
@@ -1517,11 +1528,11 @@ var NetworkManager = class {
|
|
|
1517
1528
|
this._signalConnection.join({
|
|
1518
1529
|
topic,
|
|
1519
1530
|
peerId
|
|
1520
|
-
}).catch((error) => log6.catch(error,
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1531
|
+
}).catch((error) => log6.catch(error, void 0, {
|
|
1532
|
+
F: __dxlog_file6,
|
|
1533
|
+
L: 174,
|
|
1534
|
+
S: this,
|
|
1535
|
+
C: (f, a) => f(...a)
|
|
1525
1536
|
}));
|
|
1526
1537
|
this.topicsUpdated.emit();
|
|
1527
1538
|
(_a = this._connectionLog) == null ? void 0 : _a.joinedSwarm(swarm);
|
|
@@ -1529,10 +1540,10 @@ var NetworkManager = class {
|
|
|
1529
1540
|
topic: PublicKey7.from(topic),
|
|
1530
1541
|
count: this._swarms.size
|
|
1531
1542
|
}, {
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1543
|
+
F: __dxlog_file6,
|
|
1544
|
+
L: 178,
|
|
1545
|
+
S: this,
|
|
1546
|
+
C: (f, a) => f(...a)
|
|
1536
1547
|
});
|
|
1537
1548
|
return {
|
|
1538
1549
|
close: () => this.leaveSwarm(topic)
|
|
@@ -1549,10 +1560,10 @@ var NetworkManager = class {
|
|
|
1549
1560
|
log6("leaving", {
|
|
1550
1561
|
topic: PublicKey7.from(topic)
|
|
1551
1562
|
}, {
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1563
|
+
F: __dxlog_file6,
|
|
1564
|
+
L: 194,
|
|
1565
|
+
S: this,
|
|
1566
|
+
C: (f, a) => f(...a)
|
|
1556
1567
|
});
|
|
1557
1568
|
const swarm = this._swarms.get(topic);
|
|
1558
1569
|
await this._signalConnection.leave({
|
|
@@ -1570,10 +1581,10 @@ var NetworkManager = class {
|
|
|
1570
1581
|
topic: PublicKey7.from(topic),
|
|
1571
1582
|
count: this._swarms.size
|
|
1572
1583
|
}, {
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1584
|
+
F: __dxlog_file6,
|
|
1585
|
+
L: 208,
|
|
1586
|
+
S: this,
|
|
1587
|
+
C: (f, a) => f(...a)
|
|
1577
1588
|
});
|
|
1578
1589
|
}
|
|
1579
1590
|
async setConnectionState(state) {
|
|
@@ -1605,17 +1616,17 @@ var NetworkManager = class {
|
|
|
1605
1616
|
};
|
|
1606
1617
|
|
|
1607
1618
|
// packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
|
|
1608
|
-
import
|
|
1619
|
+
import invariant6 from "tiny-invariant";
|
|
1609
1620
|
var FullyConnectedTopology = class {
|
|
1610
1621
|
toString() {
|
|
1611
1622
|
return "FullyConnectedTopology";
|
|
1612
1623
|
}
|
|
1613
1624
|
init(controller) {
|
|
1614
|
-
|
|
1625
|
+
invariant6(!this._controller, "Already initialized");
|
|
1615
1626
|
this._controller = controller;
|
|
1616
1627
|
}
|
|
1617
1628
|
update() {
|
|
1618
|
-
|
|
1629
|
+
invariant6(this._controller, "Not initialized");
|
|
1619
1630
|
const { candidates: discovered } = this._controller.getState();
|
|
1620
1631
|
for (const peer of discovered) {
|
|
1621
1632
|
this._controller.connect(peer);
|
|
@@ -1629,9 +1640,10 @@ var FullyConnectedTopology = class {
|
|
|
1629
1640
|
};
|
|
1630
1641
|
|
|
1631
1642
|
// packages/core/mesh/network-manager/src/topology/mmst-topology.ts
|
|
1632
|
-
import
|
|
1643
|
+
import invariant7 from "tiny-invariant";
|
|
1633
1644
|
import distance from "xor-distance";
|
|
1634
1645
|
import { log as log7 } from "@dxos/log";
|
|
1646
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
|
|
1635
1647
|
var MMSTTopology = class {
|
|
1636
1648
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
1637
1649
|
this._sampleCollected = false;
|
|
@@ -1640,62 +1652,62 @@ var MMSTTopology = class {
|
|
|
1640
1652
|
this._sampleSize = sampleSize;
|
|
1641
1653
|
}
|
|
1642
1654
|
init(controller) {
|
|
1643
|
-
|
|
1655
|
+
invariant7(!this._controller, "Already initialized");
|
|
1644
1656
|
this._controller = controller;
|
|
1645
1657
|
}
|
|
1646
1658
|
update() {
|
|
1647
|
-
|
|
1659
|
+
invariant7(this._controller, "Not initialized");
|
|
1648
1660
|
const { connected, candidates } = this._controller.getState();
|
|
1649
1661
|
if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
|
|
1650
|
-
log7("Running the algorithm.",
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1662
|
+
log7("Running the algorithm.", void 0, {
|
|
1663
|
+
F: __dxlog_file7,
|
|
1664
|
+
L: 55,
|
|
1665
|
+
S: this,
|
|
1666
|
+
C: (f, a) => f(...a)
|
|
1655
1667
|
});
|
|
1656
1668
|
this._sampleCollected = true;
|
|
1657
1669
|
this._runAlgorithm();
|
|
1658
1670
|
}
|
|
1659
1671
|
}
|
|
1660
1672
|
async onOffer(peer) {
|
|
1661
|
-
|
|
1673
|
+
invariant7(this._controller, "Not initialized");
|
|
1662
1674
|
const { connected } = this._controller.getState();
|
|
1663
1675
|
const accept = connected.length < this._maxPeers;
|
|
1664
|
-
log7(`Offer ${peer} accept=${accept}`,
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1676
|
+
log7(`Offer ${peer} accept=${accept}`, void 0, {
|
|
1677
|
+
F: __dxlog_file7,
|
|
1678
|
+
L: 65,
|
|
1679
|
+
S: this,
|
|
1680
|
+
C: (f, a) => f(...a)
|
|
1669
1681
|
});
|
|
1670
1682
|
return accept;
|
|
1671
1683
|
}
|
|
1672
1684
|
async destroy() {
|
|
1673
1685
|
}
|
|
1674
1686
|
_runAlgorithm() {
|
|
1675
|
-
|
|
1687
|
+
invariant7(this._controller, "Not initialized");
|
|
1676
1688
|
const { connected, candidates, ownPeerId } = this._controller.getState();
|
|
1677
1689
|
if (connected.length > this._maxPeers) {
|
|
1678
1690
|
const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
|
|
1679
1691
|
for (const peer of sorted) {
|
|
1680
|
-
log7(`Disconnect ${peer}.`,
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1692
|
+
log7(`Disconnect ${peer}.`, void 0, {
|
|
1693
|
+
F: __dxlog_file7,
|
|
1694
|
+
L: 83,
|
|
1695
|
+
S: this,
|
|
1696
|
+
C: (f, a) => f(...a)
|
|
1685
1697
|
});
|
|
1686
1698
|
this._controller.disconnect(peer);
|
|
1687
1699
|
}
|
|
1688
1700
|
} else if (connected.length < this._originateConnections) {
|
|
1689
1701
|
const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
|
|
1690
|
-
const
|
|
1691
|
-
for (const
|
|
1692
|
-
log7(`Connect ${
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1702
|
+
const sorted = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
|
|
1703
|
+
for (const peer of sorted) {
|
|
1704
|
+
log7(`Connect ${peer}.`, void 0, {
|
|
1705
|
+
F: __dxlog_file7,
|
|
1706
|
+
L: 91,
|
|
1707
|
+
S: this,
|
|
1708
|
+
C: (f, a) => f(...a)
|
|
1697
1709
|
});
|
|
1698
|
-
this._controller.connect(
|
|
1710
|
+
this._controller.connect(peer);
|
|
1699
1711
|
}
|
|
1700
1712
|
}
|
|
1701
1713
|
}
|
|
@@ -1706,8 +1718,9 @@ var MMSTTopology = class {
|
|
|
1706
1718
|
var sortByXorDistance = (keys, reference) => keys.sort((a, b) => distance.gt(distance(a.asBuffer(), reference.asBuffer()), distance(b.asBuffer(), reference.asBuffer())));
|
|
1707
1719
|
|
|
1708
1720
|
// packages/core/mesh/network-manager/src/topology/star-topology.ts
|
|
1709
|
-
import
|
|
1721
|
+
import invariant8 from "tiny-invariant";
|
|
1710
1722
|
import { log as log8 } from "@dxos/log";
|
|
1723
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
|
|
1711
1724
|
var StarTopology = class {
|
|
1712
1725
|
// prettier-ignore
|
|
1713
1726
|
constructor(_centralPeer) {
|
|
@@ -1717,59 +1730,59 @@ var StarTopology = class {
|
|
|
1717
1730
|
return `StarTopology(${this._centralPeer.truncate()})`;
|
|
1718
1731
|
}
|
|
1719
1732
|
init(controller) {
|
|
1720
|
-
|
|
1733
|
+
invariant8(!this._controller, "Already initialized.");
|
|
1721
1734
|
this._controller = controller;
|
|
1722
1735
|
}
|
|
1723
1736
|
update() {
|
|
1724
|
-
|
|
1737
|
+
invariant8(this._controller, "Not initialized.");
|
|
1725
1738
|
const { candidates, connected, ownPeerId } = this._controller.getState();
|
|
1726
1739
|
if (!ownPeerId.equals(this._centralPeer)) {
|
|
1727
|
-
log8("leaf peer dropping all connections apart from central peer.",
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1740
|
+
log8("leaf peer dropping all connections apart from central peer.", void 0, {
|
|
1741
|
+
F: __dxlog_file8,
|
|
1742
|
+
L: 33,
|
|
1743
|
+
S: this,
|
|
1744
|
+
C: (f, a) => f(...a)
|
|
1732
1745
|
});
|
|
1733
1746
|
for (const peer of connected) {
|
|
1734
1747
|
if (!peer.equals(this._centralPeer)) {
|
|
1735
1748
|
log8("dropping connection", {
|
|
1736
1749
|
peer
|
|
1737
1750
|
}, {
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1751
|
+
F: __dxlog_file8,
|
|
1752
|
+
L: 38,
|
|
1753
|
+
S: this,
|
|
1754
|
+
C: (f, a) => f(...a)
|
|
1742
1755
|
});
|
|
1743
1756
|
this._controller.disconnect(peer);
|
|
1744
1757
|
}
|
|
1745
1758
|
}
|
|
1746
1759
|
}
|
|
1747
|
-
for (const
|
|
1748
|
-
if (
|
|
1760
|
+
for (const peer of candidates) {
|
|
1761
|
+
if (peer.equals(this._centralPeer) || ownPeerId.equals(this._centralPeer)) {
|
|
1749
1762
|
log8("connecting to peer", {
|
|
1750
|
-
peer
|
|
1763
|
+
peer
|
|
1751
1764
|
}, {
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1765
|
+
F: __dxlog_file8,
|
|
1766
|
+
L: 47,
|
|
1767
|
+
S: this,
|
|
1768
|
+
C: (f, a) => f(...a)
|
|
1756
1769
|
});
|
|
1757
|
-
this._controller.connect(
|
|
1770
|
+
this._controller.connect(peer);
|
|
1758
1771
|
}
|
|
1759
1772
|
}
|
|
1760
1773
|
}
|
|
1761
1774
|
async onOffer(peer) {
|
|
1762
|
-
|
|
1775
|
+
invariant8(this._controller, "Not initialized.");
|
|
1763
1776
|
const { ownPeerId } = this._controller.getState();
|
|
1764
1777
|
log8("offer", {
|
|
1765
1778
|
peer,
|
|
1766
1779
|
isCentral: peer.equals(this._centralPeer),
|
|
1767
1780
|
isSelfCentral: ownPeerId.equals(this._centralPeer)
|
|
1768
1781
|
}, {
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1782
|
+
F: __dxlog_file8,
|
|
1783
|
+
L: 56,
|
|
1784
|
+
S: this,
|
|
1785
|
+
C: (f, a) => f(...a)
|
|
1773
1786
|
});
|
|
1774
1787
|
return ownPeerId.equals(this._centralPeer) || peer.equals(this._centralPeer);
|
|
1775
1788
|
}
|
|
@@ -1778,14 +1791,14 @@ var StarTopology = class {
|
|
|
1778
1791
|
};
|
|
1779
1792
|
|
|
1780
1793
|
// packages/core/mesh/network-manager/src/transport/memory-transport.ts
|
|
1781
|
-
import assert9 from "@dxos/node-std/assert";
|
|
1782
1794
|
import { Transform } from "@dxos/node-std/stream";
|
|
1795
|
+
import invariant9 from "tiny-invariant";
|
|
1783
1796
|
import { Event as Event6, Trigger } from "@dxos/async";
|
|
1784
1797
|
import { ErrorStream as ErrorStream3 } from "@dxos/debug";
|
|
1785
1798
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
1786
1799
|
import { log as log9, logInfo as logInfo2 } from "@dxos/log";
|
|
1787
1800
|
import { ComplexMap as ComplexMap6 } from "@dxos/util";
|
|
1788
|
-
|
|
1801
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
1789
1802
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1790
1803
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1791
1804
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1794,7 +1807,8 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
1794
1807
|
if (d = decorators[i])
|
|
1795
1808
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1796
1809
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1797
|
-
}
|
|
1810
|
+
}
|
|
1811
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
|
|
1798
1812
|
var MEMORY_TRANSPORT_DELAY = 1;
|
|
1799
1813
|
var createStreamDelay = (delay) => {
|
|
1800
1814
|
return new Transform({
|
|
@@ -1814,26 +1828,26 @@ var _MemoryTransport = class {
|
|
|
1814
1828
|
this.closed = new Event6();
|
|
1815
1829
|
this.connected = new Event6();
|
|
1816
1830
|
this.errors = new ErrorStream3();
|
|
1831
|
+
this._instanceId = PublicKey8.random();
|
|
1817
1832
|
this._remote = new Trigger();
|
|
1818
1833
|
this._outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
1819
1834
|
this._incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
1820
1835
|
this._destroyed = false;
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
callSite: (f, a) => f(...a)
|
|
1836
|
+
log9("creating", void 0, {
|
|
1837
|
+
F: __dxlog_file9,
|
|
1838
|
+
L: 64,
|
|
1839
|
+
S: this,
|
|
1840
|
+
C: (f, a) => f(...a)
|
|
1827
1841
|
});
|
|
1828
|
-
|
|
1842
|
+
invariant9(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
|
|
1829
1843
|
_MemoryTransport._connections.set(this._instanceId, this);
|
|
1830
1844
|
if (this.options.initiator) {
|
|
1831
1845
|
setTimeout(async () => {
|
|
1832
|
-
log9("sending signal",
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1846
|
+
log9("sending signal", void 0, {
|
|
1847
|
+
F: __dxlog_file9,
|
|
1848
|
+
L: 73,
|
|
1849
|
+
S: this,
|
|
1850
|
+
C: (f, a) => f(...a)
|
|
1837
1851
|
});
|
|
1838
1852
|
void this.options.sendSignal({
|
|
1839
1853
|
payload: {
|
|
@@ -1859,14 +1873,14 @@ var _MemoryTransport = class {
|
|
|
1859
1873
|
this.closed.emit();
|
|
1860
1874
|
return;
|
|
1861
1875
|
}
|
|
1862
|
-
|
|
1876
|
+
invariant9(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`);
|
|
1863
1877
|
this._remoteConnection._remoteConnection = this;
|
|
1864
1878
|
this._remoteConnection._remoteInstanceId = this._instanceId;
|
|
1865
|
-
log9("connected",
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1879
|
+
log9("connected", void 0, {
|
|
1880
|
+
F: __dxlog_file9,
|
|
1881
|
+
L: 103,
|
|
1882
|
+
S: this,
|
|
1883
|
+
C: (f, a) => f(...a)
|
|
1870
1884
|
});
|
|
1871
1885
|
this.options.stream.pipe(this._outgoingDelay).pipe(this._remoteConnection.options.stream).pipe(this._incomingDelay).pipe(this.options.stream);
|
|
1872
1886
|
this.connected.emit();
|
|
@@ -1880,20 +1894,20 @@ var _MemoryTransport = class {
|
|
|
1880
1894
|
}
|
|
1881
1895
|
}
|
|
1882
1896
|
async destroy() {
|
|
1883
|
-
log9("closing",
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1897
|
+
log9("closing", void 0, {
|
|
1898
|
+
F: __dxlog_file9,
|
|
1899
|
+
L: 124,
|
|
1900
|
+
S: this,
|
|
1901
|
+
C: (f, a) => f(...a)
|
|
1888
1902
|
});
|
|
1889
1903
|
this._destroyed = true;
|
|
1890
1904
|
_MemoryTransport._connections.delete(this._instanceId);
|
|
1891
1905
|
if (this._remoteConnection) {
|
|
1892
|
-
log9("closing",
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1906
|
+
log9("closing", void 0, {
|
|
1907
|
+
F: __dxlog_file9,
|
|
1908
|
+
L: 129,
|
|
1909
|
+
S: this,
|
|
1910
|
+
C: (f, a) => f(...a)
|
|
1897
1911
|
});
|
|
1898
1912
|
this._remoteConnection._destroyed = true;
|
|
1899
1913
|
_MemoryTransport._connections.delete(this._remoteInstanceId);
|
|
@@ -1902,29 +1916,29 @@ var _MemoryTransport = class {
|
|
|
1902
1916
|
this._remoteConnection.closed.emit();
|
|
1903
1917
|
this._remoteConnection._remoteConnection = void 0;
|
|
1904
1918
|
this._remoteConnection = void 0;
|
|
1905
|
-
log9("closed",
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1919
|
+
log9("closed", void 0, {
|
|
1920
|
+
F: __dxlog_file9,
|
|
1921
|
+
L: 147,
|
|
1922
|
+
S: this,
|
|
1923
|
+
C: (f, a) => f(...a)
|
|
1910
1924
|
});
|
|
1911
1925
|
}
|
|
1912
1926
|
this.closed.emit();
|
|
1913
|
-
log9("closed",
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1927
|
+
log9("closed", void 0, {
|
|
1928
|
+
F: __dxlog_file9,
|
|
1929
|
+
L: 151,
|
|
1930
|
+
S: this,
|
|
1931
|
+
C: (f, a) => f(...a)
|
|
1918
1932
|
});
|
|
1919
1933
|
}
|
|
1920
1934
|
signal({ payload }) {
|
|
1921
1935
|
log9("received signal", {
|
|
1922
1936
|
payload
|
|
1923
1937
|
}, {
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1938
|
+
F: __dxlog_file9,
|
|
1939
|
+
L: 155,
|
|
1940
|
+
S: this,
|
|
1941
|
+
C: (f, a) => f(...a)
|
|
1928
1942
|
});
|
|
1929
1943
|
if (!(payload == null ? void 0 : payload.transportId)) {
|
|
1930
1944
|
return;
|
|
@@ -1939,16 +1953,16 @@ var _MemoryTransport = class {
|
|
|
1939
1953
|
var MemoryTransport = _MemoryTransport;
|
|
1940
1954
|
// TODO(burdon): Remove static properties (inject context into constructor).
|
|
1941
1955
|
MemoryTransport._connections = new ComplexMap6(PublicKey8.hash);
|
|
1942
|
-
|
|
1956
|
+
_ts_decorate4([
|
|
1943
1957
|
logInfo2
|
|
1944
1958
|
], MemoryTransport.prototype, "_instanceId", void 0);
|
|
1945
|
-
|
|
1959
|
+
_ts_decorate4([
|
|
1946
1960
|
logInfo2
|
|
1947
1961
|
], MemoryTransport.prototype, "_remoteInstanceId", void 0);
|
|
1948
1962
|
|
|
1949
1963
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
|
|
1950
|
-
import assert10 from "@dxos/node-std/assert";
|
|
1951
1964
|
import SimplePeerConstructor from "simple-peer";
|
|
1965
|
+
import invariant10 from "tiny-invariant";
|
|
1952
1966
|
import { Event as Event7 } from "@dxos/async";
|
|
1953
1967
|
import { ErrorStream as ErrorStream4, raise as raise2 } from "@dxos/debug";
|
|
1954
1968
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
@@ -1963,6 +1977,7 @@ try {
|
|
|
1963
1977
|
}
|
|
1964
1978
|
|
|
1965
1979
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
|
|
1980
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts";
|
|
1966
1981
|
var WebRTCTransport = class {
|
|
1967
1982
|
constructor(params) {
|
|
1968
1983
|
var _a;
|
|
@@ -1975,16 +1990,16 @@ var WebRTCTransport = class {
|
|
|
1975
1990
|
log10.trace("dxos.mesh.webrtc-transport.constructor", trace4.begin({
|
|
1976
1991
|
id: this._instanceId
|
|
1977
1992
|
}), {
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1993
|
+
F: __dxlog_file10,
|
|
1994
|
+
L: 39,
|
|
1995
|
+
S: this,
|
|
1996
|
+
C: (f, a) => f(...a)
|
|
1982
1997
|
});
|
|
1983
1998
|
log10("created connection", params, {
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1999
|
+
F: __dxlog_file10,
|
|
2000
|
+
L: 40,
|
|
2001
|
+
S: this,
|
|
2002
|
+
C: (f, a) => f(...a)
|
|
1988
2003
|
});
|
|
1989
2004
|
this._peer = new SimplePeerConstructor({
|
|
1990
2005
|
initiator: this.params.initiator,
|
|
@@ -1993,10 +2008,10 @@ var WebRTCTransport = class {
|
|
|
1993
2008
|
});
|
|
1994
2009
|
this._peer.on("signal", async (data) => {
|
|
1995
2010
|
log10("signal", data, {
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2011
|
+
F: __dxlog_file10,
|
|
2012
|
+
L: 48,
|
|
2013
|
+
S: this,
|
|
2014
|
+
C: (f, a) => f(...a)
|
|
2000
2015
|
});
|
|
2001
2016
|
await this.params.sendSignal({
|
|
2002
2017
|
payload: {
|
|
@@ -2005,21 +2020,21 @@ var WebRTCTransport = class {
|
|
|
2005
2020
|
});
|
|
2006
2021
|
});
|
|
2007
2022
|
this._peer.on("connect", () => {
|
|
2008
|
-
log10("connected",
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2023
|
+
log10("connected", void 0, {
|
|
2024
|
+
F: __dxlog_file10,
|
|
2025
|
+
L: 53,
|
|
2026
|
+
S: this,
|
|
2027
|
+
C: (f, a) => f(...a)
|
|
2013
2028
|
});
|
|
2014
2029
|
this.params.stream.pipe(this._peer).pipe(this.params.stream);
|
|
2015
2030
|
this.connected.emit();
|
|
2016
2031
|
});
|
|
2017
2032
|
this._peer.on("close", async () => {
|
|
2018
|
-
log10("closed",
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2033
|
+
log10("closed", void 0, {
|
|
2034
|
+
F: __dxlog_file10,
|
|
2035
|
+
L: 59,
|
|
2036
|
+
S: this,
|
|
2037
|
+
C: (f, a) => f(...a)
|
|
2023
2038
|
});
|
|
2024
2039
|
await this._disconnectStreams();
|
|
2025
2040
|
this.closed.emit();
|
|
@@ -2034,10 +2049,10 @@ var WebRTCTransport = class {
|
|
|
2034
2049
|
config: this.params.webrtcConfig,
|
|
2035
2050
|
stats
|
|
2036
2051
|
}, {
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2052
|
+
F: __dxlog_file10,
|
|
2053
|
+
L: 71,
|
|
2054
|
+
S: this,
|
|
2055
|
+
C: (f, a) => f(...a)
|
|
2041
2056
|
});
|
|
2042
2057
|
});
|
|
2043
2058
|
}
|
|
@@ -2048,35 +2063,35 @@ var WebRTCTransport = class {
|
|
|
2048
2063
|
log10.trace("dxos.mesh.webrtc-transport.constructor", trace4.end({
|
|
2049
2064
|
id: this._instanceId
|
|
2050
2065
|
}), {
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2066
|
+
F: __dxlog_file10,
|
|
2067
|
+
L: 81,
|
|
2068
|
+
S: this,
|
|
2069
|
+
C: (f, a) => f(...a)
|
|
2055
2070
|
});
|
|
2056
2071
|
}
|
|
2057
2072
|
async destroy() {
|
|
2058
|
-
log10("closing...",
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2073
|
+
log10("closing...", void 0, {
|
|
2074
|
+
F: __dxlog_file10,
|
|
2075
|
+
L: 85,
|
|
2076
|
+
S: this,
|
|
2077
|
+
C: (f, a) => f(...a)
|
|
2063
2078
|
});
|
|
2064
2079
|
this._closed = true;
|
|
2065
2080
|
await this._disconnectStreams();
|
|
2066
2081
|
this._peer.destroy();
|
|
2067
2082
|
this.closed.emit();
|
|
2068
|
-
log10("closed",
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2083
|
+
log10("closed", void 0, {
|
|
2084
|
+
F: __dxlog_file10,
|
|
2085
|
+
L: 90,
|
|
2086
|
+
S: this,
|
|
2087
|
+
C: (f, a) => f(...a)
|
|
2073
2088
|
});
|
|
2074
2089
|
}
|
|
2075
2090
|
signal(signal) {
|
|
2076
2091
|
if (this._closed) {
|
|
2077
2092
|
return;
|
|
2078
2093
|
}
|
|
2079
|
-
|
|
2094
|
+
invariant10(signal.payload.data, "Signal message must contain signal data.");
|
|
2080
2095
|
this._peer.signal(signal.payload.data);
|
|
2081
2096
|
}
|
|
2082
2097
|
async _disconnectStreams() {
|
|
@@ -2092,13 +2107,14 @@ var createWebRTCTransportFactory = (webrtcConfig) => ({
|
|
|
2092
2107
|
});
|
|
2093
2108
|
|
|
2094
2109
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts
|
|
2095
|
-
import assert11 from "@dxos/node-std/assert";
|
|
2096
2110
|
import { Duplex } from "@dxos/node-std/stream";
|
|
2111
|
+
import invariant11 from "tiny-invariant";
|
|
2097
2112
|
import { Stream } from "@dxos/codec-protobuf";
|
|
2098
2113
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
2099
2114
|
import { log as log11 } from "@dxos/log";
|
|
2100
2115
|
import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
2101
2116
|
import { ComplexMap as ComplexMap7 } from "@dxos/util";
|
|
2117
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts";
|
|
2102
2118
|
var WebRTCTransportService = class {
|
|
2103
2119
|
// prettier-ignore
|
|
2104
2120
|
constructor(_webrtcConfig) {
|
|
@@ -2169,11 +2185,11 @@ var WebRTCTransportService = class {
|
|
|
2169
2185
|
return rpcStream;
|
|
2170
2186
|
}
|
|
2171
2187
|
async sendSignal({ proxyId, signal }) {
|
|
2172
|
-
|
|
2188
|
+
invariant11(this.transports.has(proxyId));
|
|
2173
2189
|
await this.transports.get(proxyId).transport.signal(signal);
|
|
2174
2190
|
}
|
|
2175
2191
|
async sendData({ proxyId, payload }) {
|
|
2176
|
-
|
|
2192
|
+
invariant11(this.transports.has(proxyId));
|
|
2177
2193
|
await this.transports.get(proxyId).stream.push(payload);
|
|
2178
2194
|
}
|
|
2179
2195
|
async close({ proxyId }) {
|
|
@@ -2181,23 +2197,25 @@ var WebRTCTransportService = class {
|
|
|
2181
2197
|
await ((_a = this.transports.get(proxyId)) == null ? void 0 : _a.transport.destroy());
|
|
2182
2198
|
await ((_b = this.transports.get(proxyId)) == null ? void 0 : _b.stream.end());
|
|
2183
2199
|
this.transports.delete(proxyId);
|
|
2184
|
-
log11("Closed.",
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2200
|
+
log11("Closed.", void 0, {
|
|
2201
|
+
F: __dxlog_file11,
|
|
2202
|
+
L: 109,
|
|
2203
|
+
S: this,
|
|
2204
|
+
C: (f, a) => f(...a)
|
|
2189
2205
|
});
|
|
2190
2206
|
}
|
|
2191
2207
|
};
|
|
2192
2208
|
|
|
2193
2209
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts
|
|
2194
|
-
import
|
|
2210
|
+
import invariant12 from "tiny-invariant";
|
|
2195
2211
|
import { Event as Event8 } from "@dxos/async";
|
|
2196
2212
|
import { Context as Context5 } from "@dxos/context";
|
|
2197
2213
|
import { ErrorStream as ErrorStream5 } from "@dxos/debug";
|
|
2198
2214
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
2199
2215
|
import { log as log12 } from "@dxos/log";
|
|
2200
2216
|
import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
2217
|
+
import { arrayToBuffer } from "@dxos/util";
|
|
2218
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts";
|
|
2201
2219
|
var WebRTCTransportProxy = class {
|
|
2202
2220
|
// prettier-ignore
|
|
2203
2221
|
constructor(_params) {
|
|
@@ -2215,10 +2233,10 @@ var WebRTCTransportProxy = class {
|
|
|
2215
2233
|
this._serviceStream.waitUntilReady().then(() => {
|
|
2216
2234
|
this._serviceStream.subscribe(async (event) => {
|
|
2217
2235
|
log12("WebRTCTransportProxy: event", event, {
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2236
|
+
F: __dxlog_file12,
|
|
2237
|
+
L: 50,
|
|
2238
|
+
S: this,
|
|
2239
|
+
C: (f, a) => f(...a)
|
|
2222
2240
|
});
|
|
2223
2241
|
if (event.connection) {
|
|
2224
2242
|
await this._handleConnection(event.connection);
|
|
@@ -2235,11 +2253,11 @@ var WebRTCTransportProxy = class {
|
|
|
2235
2253
|
payload: data
|
|
2236
2254
|
});
|
|
2237
2255
|
} catch (err) {
|
|
2238
|
-
log12.catch(err,
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2256
|
+
log12.catch(err, void 0, {
|
|
2257
|
+
F: __dxlog_file12,
|
|
2258
|
+
L: 67,
|
|
2259
|
+
S: this,
|
|
2260
|
+
C: (f, a) => f(...a)
|
|
2243
2261
|
});
|
|
2244
2262
|
}
|
|
2245
2263
|
};
|
|
@@ -2247,11 +2265,11 @@ var WebRTCTransportProxy = class {
|
|
|
2247
2265
|
this._ctx.onDispose(() => {
|
|
2248
2266
|
this._params.stream.off("data", dataListener);
|
|
2249
2267
|
});
|
|
2250
|
-
}, (error) => log12.catch(error,
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2268
|
+
}, (error) => log12.catch(error, void 0, {
|
|
2269
|
+
F: __dxlog_file12,
|
|
2270
|
+
L: 73,
|
|
2271
|
+
S: this,
|
|
2272
|
+
C: (f, a) => f(...a)
|
|
2255
2273
|
}));
|
|
2256
2274
|
}
|
|
2257
2275
|
async _handleConnection(connectionEvent) {
|
|
@@ -2270,7 +2288,7 @@ var WebRTCTransportProxy = class {
|
|
|
2270
2288
|
}
|
|
2271
2289
|
}
|
|
2272
2290
|
_handleData(dataEvent) {
|
|
2273
|
-
this._params.stream.write(
|
|
2291
|
+
this._params.stream.write(arrayToBuffer(dataEvent.payload));
|
|
2274
2292
|
}
|
|
2275
2293
|
async _handleSignal(signalEvent) {
|
|
2276
2294
|
await this._params.sendSignal(signalEvent.payload);
|
|
@@ -2293,11 +2311,11 @@ var WebRTCTransportProxy = class {
|
|
|
2293
2311
|
proxyId: this._proxyId
|
|
2294
2312
|
});
|
|
2295
2313
|
} catch (err) {
|
|
2296
|
-
log12.catch(err,
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2314
|
+
log12.catch(err, void 0, {
|
|
2315
|
+
F: __dxlog_file12,
|
|
2316
|
+
L: 124,
|
|
2317
|
+
S: this,
|
|
2318
|
+
C: (f, a) => f(...a)
|
|
2301
2319
|
});
|
|
2302
2320
|
}
|
|
2303
2321
|
this.closed.emit();
|
|
@@ -2329,7 +2347,7 @@ var WebRTCTransportProxyFactory = class {
|
|
|
2329
2347
|
return this;
|
|
2330
2348
|
}
|
|
2331
2349
|
createTransport(options) {
|
|
2332
|
-
|
|
2350
|
+
invariant12(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
|
|
2333
2351
|
const transport = new WebRTCTransportProxy({
|
|
2334
2352
|
...options,
|
|
2335
2353
|
bridgeService: this._bridgeService
|
|
@@ -2379,4 +2397,4 @@ export {
|
|
|
2379
2397
|
WebRTCTransportProxyFactory,
|
|
2380
2398
|
createTeleportProtocolFactory
|
|
2381
2399
|
};
|
|
2382
|
-
//# sourceMappingURL=chunk-
|
|
2400
|
+
//# sourceMappingURL=chunk-N5RZB7V4.mjs.map
|