@dxos/network-manager 0.1.56-next.a63ce79 → 0.1.56
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-5TRIVLI6.mjs → chunk-BYYPWP6O.mjs} +105 -89
- package/dist/lib/browser/chunk-BYYPWP6O.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +19 -9
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +104 -88
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +120 -94
- 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/signal/swarm-messenger.d.ts +1 -1
- package/dist/types/src/signal/swarm-messenger.d.ts.map +1 -1
- package/dist/types/src/swarm/connection-limiter.d.ts +1 -1
- package/dist/types/src/swarm/connection-limiter.d.ts.map +1 -1
- package/dist/types/src/swarm/connection.d.ts +2 -1
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/swarm/peer.d.ts +1 -1
- package/dist/types/src/swarm/peer.d.ts.map +1 -1
- package/dist/types/src/swarm/swarm.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts +4 -3
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-wire-protocol.d.ts +13 -2
- package/dist/types/src/testing/test-wire-protocol.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc-transport-proxy.d.ts +1 -1
- package/dist/types/src/transport/webrtc-transport-proxy.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc-transport.d.ts +3 -3
- package/dist/types/src/transport/webrtc-transport.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/connection-log.ts +2 -0
- package/src/signal/swarm-messenger.ts +2 -2
- package/src/swarm/connection-limiter.ts +1 -1
- package/src/swarm/connection.ts +12 -3
- package/src/swarm/peer.ts +8 -6
- package/src/swarm/swarm.ts +5 -5
- package/src/testing/test-builder.ts +9 -5
- package/src/testing/test-wire-protocol.ts +22 -2
- package/src/tests/memory-transport.test.ts +1 -1
- package/src/transport/webrtc-transport-proxy.ts +4 -4
- package/src/transport/webrtc-transport.ts +20 -6
- package/dist/lib/browser/chunk-5TRIVLI6.mjs.map +0 -7
|
@@ -26,7 +26,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
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 = "/
|
|
29
|
+
var __dxlog_file = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/connection.ts";
|
|
30
30
|
var STARTING_SIGNALLING_DELAY = 10;
|
|
31
31
|
var MAX_SIGNALLING_DELAY = 300;
|
|
32
32
|
var ConnectionState;
|
|
@@ -92,7 +92,7 @@ var Connection = class {
|
|
|
92
92
|
initiator: this.initiator
|
|
93
93
|
}, {
|
|
94
94
|
F: __dxlog_file,
|
|
95
|
-
L:
|
|
95
|
+
L: 96,
|
|
96
96
|
S: this,
|
|
97
97
|
C: (f, a) => f(...a)
|
|
98
98
|
});
|
|
@@ -112,7 +112,7 @@ var Connection = class {
|
|
|
112
112
|
async openConnection() {
|
|
113
113
|
invariant(this._state === ConnectionState.INITIAL, "Invalid state.", {
|
|
114
114
|
F: __dxlog_file,
|
|
115
|
-
L:
|
|
115
|
+
L: 121,
|
|
116
116
|
S: this,
|
|
117
117
|
A: [
|
|
118
118
|
"this._state === ConnectionState.INITIAL",
|
|
@@ -123,7 +123,7 @@ var Connection = class {
|
|
|
123
123
|
id: this._instanceId
|
|
124
124
|
}), {
|
|
125
125
|
F: __dxlog_file,
|
|
126
|
-
L:
|
|
126
|
+
L: 122,
|
|
127
127
|
S: this,
|
|
128
128
|
C: (f, a) => f(...a)
|
|
129
129
|
});
|
|
@@ -135,7 +135,7 @@ var Connection = class {
|
|
|
135
135
|
initiator: this.initiator
|
|
136
136
|
}, {
|
|
137
137
|
F: __dxlog_file,
|
|
138
|
-
L:
|
|
138
|
+
L: 123,
|
|
139
139
|
S: this,
|
|
140
140
|
C: (f, a) => f(...a)
|
|
141
141
|
});
|
|
@@ -146,7 +146,7 @@ var Connection = class {
|
|
|
146
146
|
this._protocol.stream.on("close", () => {
|
|
147
147
|
log("protocol stream closed", void 0, {
|
|
148
148
|
F: __dxlog_file,
|
|
149
|
-
L:
|
|
149
|
+
L: 140,
|
|
150
150
|
S: this,
|
|
151
151
|
C: (f, a) => f(...a)
|
|
152
152
|
});
|
|
@@ -154,7 +154,7 @@ var Connection = class {
|
|
|
154
154
|
});
|
|
155
155
|
invariant(!this._transport, void 0, {
|
|
156
156
|
F: __dxlog_file,
|
|
157
|
-
L:
|
|
157
|
+
L: 144,
|
|
158
158
|
S: this,
|
|
159
159
|
A: [
|
|
160
160
|
"!this._transport",
|
|
@@ -174,6 +174,9 @@ var Connection = class {
|
|
|
174
174
|
this.close().catch((err) => this.errors.raise(err));
|
|
175
175
|
});
|
|
176
176
|
this._transport.errors.handle((err) => {
|
|
177
|
+
if (!this.closeReason) {
|
|
178
|
+
this.closeReason = err?.message;
|
|
179
|
+
}
|
|
177
180
|
if (this._state !== ConnectionState.CLOSED && this._state !== ConnectionState.CLOSING) {
|
|
178
181
|
this.errors.raise(err);
|
|
179
182
|
}
|
|
@@ -186,12 +189,15 @@ var Connection = class {
|
|
|
186
189
|
id: this._instanceId
|
|
187
190
|
}), {
|
|
188
191
|
F: __dxlog_file,
|
|
189
|
-
L:
|
|
192
|
+
L: 176,
|
|
190
193
|
S: this,
|
|
191
194
|
C: (f, a) => f(...a)
|
|
192
195
|
});
|
|
193
196
|
}
|
|
194
|
-
async close() {
|
|
197
|
+
async close(err) {
|
|
198
|
+
if (!this.closeReason) {
|
|
199
|
+
this.closeReason = err?.message;
|
|
200
|
+
}
|
|
195
201
|
if (this._state === ConnectionState.CLOSED) {
|
|
196
202
|
return;
|
|
197
203
|
}
|
|
@@ -201,26 +207,26 @@ var Connection = class {
|
|
|
201
207
|
peerId: this.ownId
|
|
202
208
|
}, {
|
|
203
209
|
F: __dxlog_file,
|
|
204
|
-
L:
|
|
210
|
+
L: 191,
|
|
205
211
|
S: this,
|
|
206
212
|
C: (f, a) => f(...a)
|
|
207
213
|
});
|
|
208
214
|
try {
|
|
209
215
|
await this._protocol.destroy();
|
|
210
|
-
} catch (
|
|
211
|
-
log.catch(
|
|
216
|
+
} catch (err2) {
|
|
217
|
+
log.catch(err2, void 0, {
|
|
212
218
|
F: __dxlog_file,
|
|
213
|
-
L:
|
|
219
|
+
L: 197,
|
|
214
220
|
S: this,
|
|
215
221
|
C: (f, a) => f(...a)
|
|
216
222
|
});
|
|
217
223
|
}
|
|
218
224
|
try {
|
|
219
225
|
await this._transport?.destroy();
|
|
220
|
-
} catch (
|
|
221
|
-
log.catch(
|
|
226
|
+
} catch (err2) {
|
|
227
|
+
log.catch(err2, void 0, {
|
|
222
228
|
F: __dxlog_file,
|
|
223
|
-
L:
|
|
229
|
+
L: 204,
|
|
224
230
|
S: this,
|
|
225
231
|
C: (f, a) => f(...a)
|
|
226
232
|
});
|
|
@@ -229,7 +235,7 @@ var Connection = class {
|
|
|
229
235
|
peerId: this.ownId
|
|
230
236
|
}, {
|
|
231
237
|
F: __dxlog_file,
|
|
232
|
-
L:
|
|
238
|
+
L: 207,
|
|
233
239
|
S: this,
|
|
234
240
|
C: (f, a) => f(...a)
|
|
235
241
|
});
|
|
@@ -244,8 +250,10 @@ var Connection = class {
|
|
|
244
250
|
return;
|
|
245
251
|
}
|
|
246
252
|
try {
|
|
247
|
-
|
|
248
|
-
|
|
253
|
+
if (true) {
|
|
254
|
+
await cancelWithContext(this._ctx, sleep(this._signallingDelay));
|
|
255
|
+
this._signallingDelay = Math.min(this._signallingDelay * 2, MAX_SIGNALLING_DELAY);
|
|
256
|
+
}
|
|
249
257
|
const signals = [
|
|
250
258
|
...this._outgoingSignalBuffer
|
|
251
259
|
];
|
|
@@ -269,7 +277,7 @@ var Connection = class {
|
|
|
269
277
|
err
|
|
270
278
|
}, {
|
|
271
279
|
F: __dxlog_file,
|
|
272
|
-
L:
|
|
280
|
+
L: 243,
|
|
273
281
|
S: this,
|
|
274
282
|
C: (f, a) => f(...a)
|
|
275
283
|
});
|
|
@@ -282,7 +290,7 @@ var Connection = class {
|
|
|
282
290
|
async signal(msg) {
|
|
283
291
|
invariant(msg.sessionId, void 0, {
|
|
284
292
|
F: __dxlog_file,
|
|
285
|
-
L:
|
|
293
|
+
L: 252,
|
|
286
294
|
S: this,
|
|
287
295
|
A: [
|
|
288
296
|
"msg.sessionId",
|
|
@@ -292,7 +300,7 @@ var Connection = class {
|
|
|
292
300
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
293
301
|
log("dropping signal for incorrect session id", void 0, {
|
|
294
302
|
F: __dxlog_file,
|
|
295
|
-
L:
|
|
303
|
+
L: 254,
|
|
296
304
|
S: this,
|
|
297
305
|
C: (f, a) => f(...a)
|
|
298
306
|
});
|
|
@@ -300,7 +308,7 @@ var Connection = class {
|
|
|
300
308
|
}
|
|
301
309
|
invariant(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
302
310
|
F: __dxlog_file,
|
|
303
|
-
L:
|
|
311
|
+
L: 257,
|
|
304
312
|
S: this,
|
|
305
313
|
A: [
|
|
306
314
|
"msg.data.signal || msg.data.signalBatch",
|
|
@@ -309,7 +317,7 @@ var Connection = class {
|
|
|
309
317
|
});
|
|
310
318
|
invariant(msg.author?.equals(this.remoteId), void 0, {
|
|
311
319
|
F: __dxlog_file,
|
|
312
|
-
L:
|
|
320
|
+
L: 258,
|
|
313
321
|
S: this,
|
|
314
322
|
A: [
|
|
315
323
|
"msg.author?.equals(this.remoteId)",
|
|
@@ -318,7 +326,7 @@ var Connection = class {
|
|
|
318
326
|
});
|
|
319
327
|
invariant(msg.recipient?.equals(this.ownId), void 0, {
|
|
320
328
|
F: __dxlog_file,
|
|
321
|
-
L:
|
|
329
|
+
L: 259,
|
|
322
330
|
S: this,
|
|
323
331
|
A: [
|
|
324
332
|
"msg.recipient?.equals(this.ownId)",
|
|
@@ -339,7 +347,7 @@ var Connection = class {
|
|
|
339
347
|
msg: msg.data
|
|
340
348
|
}, {
|
|
341
349
|
F: __dxlog_file,
|
|
342
|
-
L:
|
|
350
|
+
L: 268,
|
|
343
351
|
S: this,
|
|
344
352
|
C: (f, a) => f(...a)
|
|
345
353
|
});
|
|
@@ -347,7 +355,7 @@ var Connection = class {
|
|
|
347
355
|
} else {
|
|
348
356
|
invariant(this._transport, "Connection not ready to accept signals.", {
|
|
349
357
|
F: __dxlog_file,
|
|
350
|
-
L:
|
|
358
|
+
L: 271,
|
|
351
359
|
S: this,
|
|
352
360
|
A: [
|
|
353
361
|
"this._transport",
|
|
@@ -360,7 +368,7 @@ var Connection = class {
|
|
|
360
368
|
msg: msg.data
|
|
361
369
|
}, {
|
|
362
370
|
F: __dxlog_file,
|
|
363
|
-
L:
|
|
371
|
+
L: 272,
|
|
364
372
|
S: this,
|
|
365
373
|
C: (f, a) => f(...a)
|
|
366
374
|
});
|
|
@@ -375,13 +383,13 @@ var Connection = class {
|
|
|
375
383
|
peerId: this.ownId
|
|
376
384
|
}, {
|
|
377
385
|
F: __dxlog_file,
|
|
378
|
-
L:
|
|
386
|
+
L: 279,
|
|
379
387
|
S: this,
|
|
380
388
|
C: (f, a) => f(...a)
|
|
381
389
|
});
|
|
382
390
|
invariant(state !== this._state, "Already in this state.", {
|
|
383
391
|
F: __dxlog_file,
|
|
384
|
-
L:
|
|
392
|
+
L: 280,
|
|
385
393
|
S: this,
|
|
386
394
|
A: [
|
|
387
395
|
"state !== this._state",
|
|
@@ -403,7 +411,7 @@ import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
|
403
411
|
import { log as log2 } from "@dxos/log";
|
|
404
412
|
import { schema } from "@dxos/protocols";
|
|
405
413
|
import { ComplexMap } from "@dxos/util";
|
|
406
|
-
var __dxlog_file2 = "/
|
|
414
|
+
var __dxlog_file2 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
|
|
407
415
|
var SwarmMessage = schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
|
|
408
416
|
var SwarmMessenger = class {
|
|
409
417
|
constructor({ sendMessage, onSignal, onOffer, topic }) {
|
|
@@ -655,9 +663,10 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
655
663
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
656
664
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
657
665
|
}
|
|
658
|
-
var __dxlog_file3 = "/
|
|
666
|
+
var __dxlog_file3 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/peer.ts";
|
|
659
667
|
var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
|
|
660
668
|
var Peer = class {
|
|
669
|
+
// TODO(burdon): Convert to map?
|
|
661
670
|
constructor(id, topic, localPeerId, _signalMessaging, _protocolProvider, _transportFactory, _connectionLimiter, _callbacks) {
|
|
662
671
|
this.id = id;
|
|
663
672
|
this.topic = topic;
|
|
@@ -687,12 +696,12 @@ var Peer = class {
|
|
|
687
696
|
sessionId: this.connection?.sessionId
|
|
688
697
|
}, {
|
|
689
698
|
F: __dxlog_file3,
|
|
690
|
-
L:
|
|
699
|
+
L: 108,
|
|
691
700
|
S: this,
|
|
692
701
|
C: (f, a) => f(...a)
|
|
693
702
|
});
|
|
694
703
|
if (this.connection) {
|
|
695
|
-
await this.closeConnection();
|
|
704
|
+
await this.closeConnection(new Error("Connection displaced by remote initiator."));
|
|
696
705
|
}
|
|
697
706
|
} else {
|
|
698
707
|
return {
|
|
@@ -704,7 +713,7 @@ var Peer = class {
|
|
|
704
713
|
if (!this.connection) {
|
|
705
714
|
invariant3(message.sessionId, void 0, {
|
|
706
715
|
F: __dxlog_file3,
|
|
707
|
-
L:
|
|
716
|
+
L: 128,
|
|
708
717
|
S: this,
|
|
709
718
|
A: [
|
|
710
719
|
"message.sessionId",
|
|
@@ -724,12 +733,12 @@ var Peer = class {
|
|
|
724
733
|
err
|
|
725
734
|
}, {
|
|
726
735
|
F: __dxlog_file3,
|
|
727
|
-
L:
|
|
736
|
+
L: 136,
|
|
728
737
|
S: this,
|
|
729
738
|
C: (f, a) => f(...a)
|
|
730
739
|
});
|
|
731
740
|
}
|
|
732
|
-
await this.closeConnection();
|
|
741
|
+
await this.closeConnection(err);
|
|
733
742
|
}
|
|
734
743
|
return {
|
|
735
744
|
accept: true
|
|
@@ -746,7 +755,7 @@ var Peer = class {
|
|
|
746
755
|
async initiateConnection() {
|
|
747
756
|
invariant3(!this.initiating, "Initiation in progress.", {
|
|
748
757
|
F: __dxlog_file3,
|
|
749
|
-
L:
|
|
758
|
+
L: 153,
|
|
750
759
|
S: this,
|
|
751
760
|
A: [
|
|
752
761
|
"!this.initiating",
|
|
@@ -755,7 +764,7 @@ var Peer = class {
|
|
|
755
764
|
});
|
|
756
765
|
invariant3(!this.connection, "Already connected.", {
|
|
757
766
|
F: __dxlog_file3,
|
|
758
|
-
L:
|
|
767
|
+
L: 154,
|
|
759
768
|
S: this,
|
|
760
769
|
A: [
|
|
761
770
|
"!this.connection",
|
|
@@ -770,7 +779,7 @@ var Peer = class {
|
|
|
770
779
|
sessionId
|
|
771
780
|
}, {
|
|
772
781
|
F: __dxlog_file3,
|
|
773
|
-
L:
|
|
782
|
+
L: 156,
|
|
774
783
|
S: this,
|
|
775
784
|
C: (f, a) => f(...a)
|
|
776
785
|
});
|
|
@@ -794,14 +803,14 @@ var Peer = class {
|
|
|
794
803
|
remoteId: this.id
|
|
795
804
|
}, {
|
|
796
805
|
F: __dxlog_file3,
|
|
797
|
-
L:
|
|
806
|
+
L: 171,
|
|
798
807
|
S: this,
|
|
799
808
|
C: (f, a) => f(...a)
|
|
800
809
|
});
|
|
801
810
|
if (connection.state !== ConnectionState.INITIAL) {
|
|
802
811
|
log3("ignoring response", void 0, {
|
|
803
812
|
F: __dxlog_file3,
|
|
804
|
-
L:
|
|
813
|
+
L: 173,
|
|
805
814
|
S: this,
|
|
806
815
|
C: (f, a) => f(...a)
|
|
807
816
|
});
|
|
@@ -821,11 +830,11 @@ var Peer = class {
|
|
|
821
830
|
remoteId: this.id
|
|
822
831
|
}, {
|
|
823
832
|
F: __dxlog_file3,
|
|
824
|
-
L:
|
|
833
|
+
L: 184,
|
|
825
834
|
S: this,
|
|
826
835
|
C: (f, a) => f(...a)
|
|
827
836
|
});
|
|
828
|
-
await this.closeConnection();
|
|
837
|
+
await this.closeConnection(err);
|
|
829
838
|
throw err;
|
|
830
839
|
} finally {
|
|
831
840
|
this.initiating = false;
|
|
@@ -844,13 +853,13 @@ var Peer = class {
|
|
|
844
853
|
sessionId
|
|
845
854
|
}, {
|
|
846
855
|
F: __dxlog_file3,
|
|
847
|
-
L:
|
|
856
|
+
L: 198,
|
|
848
857
|
S: this,
|
|
849
858
|
C: (f, a) => f(...a)
|
|
850
859
|
});
|
|
851
860
|
invariant3(!this.connection, "Already connected.", {
|
|
852
861
|
F: __dxlog_file3,
|
|
853
|
-
L:
|
|
862
|
+
L: 205,
|
|
854
863
|
S: this,
|
|
855
864
|
A: [
|
|
856
865
|
"!this.connection",
|
|
@@ -891,7 +900,7 @@ var Peer = class {
|
|
|
891
900
|
initiator
|
|
892
901
|
}, {
|
|
893
902
|
F: __dxlog_file3,
|
|
894
|
-
L:
|
|
903
|
+
L: 231,
|
|
895
904
|
S: this,
|
|
896
905
|
C: (f, a) => f(...a)
|
|
897
906
|
});
|
|
@@ -905,13 +914,13 @@ var Peer = class {
|
|
|
905
914
|
initiator
|
|
906
915
|
}, {
|
|
907
916
|
F: __dxlog_file3,
|
|
908
|
-
L:
|
|
917
|
+
L: 242,
|
|
909
918
|
S: this,
|
|
910
919
|
C: (f, a) => f(...a)
|
|
911
920
|
});
|
|
912
921
|
invariant3(this.connection === connection, "Connection mismatch (race condition).", {
|
|
913
922
|
F: __dxlog_file3,
|
|
914
|
-
L:
|
|
923
|
+
L: 243,
|
|
915
924
|
S: this,
|
|
916
925
|
A: [
|
|
917
926
|
"this.connection === connection",
|
|
@@ -926,7 +935,7 @@ var Peer = class {
|
|
|
926
935
|
initiator
|
|
927
936
|
}, {
|
|
928
937
|
F: __dxlog_file3,
|
|
929
|
-
L:
|
|
938
|
+
L: 245,
|
|
930
939
|
S: this,
|
|
931
940
|
C: (f, a) => f(...a)
|
|
932
941
|
});
|
|
@@ -956,7 +965,7 @@ var Peer = class {
|
|
|
956
965
|
err
|
|
957
966
|
}, {
|
|
958
967
|
F: __dxlog_file3,
|
|
959
|
-
L:
|
|
968
|
+
L: 279,
|
|
960
969
|
S: this,
|
|
961
970
|
C: (f, a) => f(...a)
|
|
962
971
|
});
|
|
@@ -969,16 +978,16 @@ var Peer = class {
|
|
|
969
978
|
err
|
|
970
979
|
}, {
|
|
971
980
|
F: __dxlog_file3,
|
|
972
|
-
L:
|
|
981
|
+
L: 280,
|
|
973
982
|
S: this,
|
|
974
983
|
C: (f, a) => f(...a)
|
|
975
984
|
});
|
|
976
|
-
void this.closeConnection();
|
|
985
|
+
void this.closeConnection(err);
|
|
977
986
|
});
|
|
978
987
|
this.connection = connection;
|
|
979
988
|
return connection;
|
|
980
989
|
}
|
|
981
|
-
async closeConnection() {
|
|
990
|
+
async closeConnection(err) {
|
|
982
991
|
if (!this.connection) {
|
|
983
992
|
return;
|
|
984
993
|
}
|
|
@@ -988,17 +997,17 @@ var Peer = class {
|
|
|
988
997
|
sessionId: connection.sessionId
|
|
989
998
|
}, {
|
|
990
999
|
F: __dxlog_file3,
|
|
991
|
-
L:
|
|
1000
|
+
L: 303,
|
|
992
1001
|
S: this,
|
|
993
1002
|
C: (f, a) => f(...a)
|
|
994
1003
|
});
|
|
995
|
-
await connection.close();
|
|
1004
|
+
await connection.close(err);
|
|
996
1005
|
log3("closed", {
|
|
997
1006
|
peerId: this.id,
|
|
998
1007
|
sessionId: connection.sessionId
|
|
999
1008
|
}, {
|
|
1000
1009
|
F: __dxlog_file3,
|
|
1001
|
-
L:
|
|
1010
|
+
L: 309,
|
|
1002
1011
|
S: this,
|
|
1003
1012
|
C: (f, a) => f(...a)
|
|
1004
1013
|
});
|
|
@@ -1009,7 +1018,7 @@ var Peer = class {
|
|
|
1009
1018
|
message
|
|
1010
1019
|
}, {
|
|
1011
1020
|
F: __dxlog_file3,
|
|
1012
|
-
L:
|
|
1021
|
+
L: 314,
|
|
1013
1022
|
S: this,
|
|
1014
1023
|
C: (f, a) => f(...a)
|
|
1015
1024
|
});
|
|
@@ -1024,7 +1033,7 @@ var Peer = class {
|
|
|
1024
1033
|
topic: this.topic
|
|
1025
1034
|
}, {
|
|
1026
1035
|
F: __dxlog_file3,
|
|
1027
|
-
L:
|
|
1036
|
+
L: 324,
|
|
1028
1037
|
S: this,
|
|
1029
1038
|
C: (f, a) => f(...a)
|
|
1030
1039
|
});
|
|
@@ -1058,7 +1067,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
1058
1067
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1059
1068
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1060
1069
|
}
|
|
1061
|
-
var __dxlog_file4 = "/
|
|
1070
|
+
var __dxlog_file4 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/swarm.ts";
|
|
1062
1071
|
var INITIATION_DELAY = 100;
|
|
1063
1072
|
var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
|
|
1064
1073
|
var Swarm = class {
|
|
@@ -1073,9 +1082,9 @@ var Swarm = class {
|
|
|
1073
1082
|
this._transportFactory = _transportFactory;
|
|
1074
1083
|
this._label = _label;
|
|
1075
1084
|
this._connectionLimiter = _connectionLimiter;
|
|
1076
|
-
this._peers = new ComplexMap2(PublicKey4.hash);
|
|
1077
1085
|
this._ctx = new Context4();
|
|
1078
1086
|
this._listeningHandle = void 0;
|
|
1087
|
+
this._peers = new ComplexMap2(PublicKey4.hash);
|
|
1079
1088
|
this._instanceId = PublicKey4.random().toHex();
|
|
1080
1089
|
this.connectionAdded = new Event2();
|
|
1081
1090
|
this.disconnected = new Event2();
|
|
@@ -1531,7 +1540,7 @@ import { Event as Event3, EventSubscriptions } from "@dxos/async";
|
|
|
1531
1540
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1532
1541
|
import { log as log5 } from "@dxos/log";
|
|
1533
1542
|
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
1534
|
-
var __dxlog_file5 = "/
|
|
1543
|
+
var __dxlog_file5 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
|
|
1535
1544
|
var SwarmMapper = class {
|
|
1536
1545
|
get peers() {
|
|
1537
1546
|
return Array.from(this._peers.values());
|
|
@@ -1604,8 +1613,8 @@ import { invariant as invariant5 } from "@dxos/invariant";
|
|
|
1604
1613
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1605
1614
|
import { log as log6 } from "@dxos/log";
|
|
1606
1615
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1607
|
-
var __dxlog_file6 = "/
|
|
1608
|
-
var MAX_CONCURRENT_INITIATING_CONNECTIONS =
|
|
1616
|
+
var __dxlog_file6 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
|
|
1617
|
+
var MAX_CONCURRENT_INITIATING_CONNECTIONS = 10;
|
|
1609
1618
|
var ConnectionLimiter = class {
|
|
1610
1619
|
constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
|
|
1611
1620
|
this._ctx = new Context5();
|
|
@@ -1718,6 +1727,7 @@ var ConnectionLog = class {
|
|
|
1718
1727
|
swarm.connectionAdded.on((connection) => {
|
|
1719
1728
|
const connectionInfo = {
|
|
1720
1729
|
state: ConnectionState.INITIAL,
|
|
1730
|
+
closeReason: connection.closeReason,
|
|
1721
1731
|
remotePeerId: connection.remoteId,
|
|
1722
1732
|
sessionId: connection.sessionId,
|
|
1723
1733
|
transport: connection.transport && Object.getPrototypeOf(connection.transport).constructor.name,
|
|
@@ -1728,6 +1738,7 @@ var ConnectionLog = class {
|
|
|
1728
1738
|
this.update.emit();
|
|
1729
1739
|
connection.stateChanged.on((state) => {
|
|
1730
1740
|
connectionInfo.state = state;
|
|
1741
|
+
connectionInfo.closeReason = connection.closeReason;
|
|
1731
1742
|
connectionInfo.events.push({
|
|
1732
1743
|
type: EventType.CONNECTION_STATE_CHANGED,
|
|
1733
1744
|
newState: state
|
|
@@ -1755,7 +1766,7 @@ import { Messenger } from "@dxos/messaging";
|
|
|
1755
1766
|
import { trace as trace3 } from "@dxos/protocols";
|
|
1756
1767
|
import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1757
1768
|
import { ComplexMap as ComplexMap6 } from "@dxos/util";
|
|
1758
|
-
var __dxlog_file7 = "/
|
|
1769
|
+
var __dxlog_file7 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/network-manager.ts";
|
|
1759
1770
|
var NetworkManager = class {
|
|
1760
1771
|
constructor({ transportFactory, signalManager, log: log1 }) {
|
|
1761
1772
|
/**
|
|
@@ -1991,7 +2002,7 @@ var NetworkManager = class {
|
|
|
1991
2002
|
|
|
1992
2003
|
// packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
|
|
1993
2004
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
1994
|
-
var __dxlog_file8 = "/
|
|
2005
|
+
var __dxlog_file8 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
|
|
1995
2006
|
var FullyConnectedTopology = class {
|
|
1996
2007
|
toString() {
|
|
1997
2008
|
return "FullyConnectedTopology";
|
|
@@ -2034,7 +2045,7 @@ var FullyConnectedTopology = class {
|
|
|
2034
2045
|
import distance from "xor-distance";
|
|
2035
2046
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2036
2047
|
import { log as log8 } from "@dxos/log";
|
|
2037
|
-
var __dxlog_file9 = "/
|
|
2048
|
+
var __dxlog_file9 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
|
|
2038
2049
|
var MMSTTopology = class {
|
|
2039
2050
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
2040
2051
|
this._sampleCollected = false;
|
|
@@ -2143,7 +2154,7 @@ var sortByXorDistance = (keys, reference) => keys.sort((a, b) => distance.gt(dis
|
|
|
2143
2154
|
// packages/core/mesh/network-manager/src/topology/star-topology.ts
|
|
2144
2155
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2145
2156
|
import { log as log9 } from "@dxos/log";
|
|
2146
|
-
var __dxlog_file10 = "/
|
|
2157
|
+
var __dxlog_file10 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/topology/star-topology.ts";
|
|
2147
2158
|
var StarTopology = class {
|
|
2148
2159
|
// prettier-ignore
|
|
2149
2160
|
constructor(_centralPeer) {
|
|
@@ -2255,7 +2266,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2255
2266
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2256
2267
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2257
2268
|
}
|
|
2258
|
-
var __dxlog_file11 = "/
|
|
2269
|
+
var __dxlog_file11 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
|
|
2259
2270
|
var MEMORY_TRANSPORT_DELAY = 1;
|
|
2260
2271
|
var createStreamDelay = (delay) => {
|
|
2261
2272
|
return new Transform({
|
|
@@ -2440,38 +2451,43 @@ try {
|
|
|
2440
2451
|
}
|
|
2441
2452
|
|
|
2442
2453
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
|
|
2443
|
-
var __dxlog_file12 = "/
|
|
2454
|
+
var __dxlog_file12 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/webrtc-transport.ts";
|
|
2444
2455
|
var WebRTCTransport = class {
|
|
2445
2456
|
constructor(params) {
|
|
2446
2457
|
this.params = params;
|
|
2458
|
+
this._instanceId = PublicKey10.random().toHex();
|
|
2447
2459
|
this._closed = false;
|
|
2448
2460
|
this.closed = new Event7();
|
|
2449
2461
|
this.connected = new Event7();
|
|
2450
2462
|
this.errors = new ErrorStream4();
|
|
2451
|
-
this._instanceId = PublicKey10.random().toHex();
|
|
2452
2463
|
log11.trace("dxos.mesh.webrtc-transport.constructor", trace4.begin({
|
|
2453
2464
|
id: this._instanceId
|
|
2454
2465
|
}), {
|
|
2455
2466
|
F: __dxlog_file12,
|
|
2456
|
-
L:
|
|
2467
|
+
L: 44,
|
|
2457
2468
|
S: this,
|
|
2458
2469
|
C: (f, a) => f(...a)
|
|
2459
2470
|
});
|
|
2460
2471
|
log11("created connection", params, {
|
|
2461
2472
|
F: __dxlog_file12,
|
|
2462
|
-
L:
|
|
2473
|
+
L: 45,
|
|
2463
2474
|
S: this,
|
|
2464
2475
|
C: (f, a) => f(...a)
|
|
2465
2476
|
});
|
|
2466
2477
|
this._peer = new SimplePeerConstructor({
|
|
2467
2478
|
initiator: this.params.initiator,
|
|
2468
|
-
|
|
2469
|
-
|
|
2479
|
+
config: this.params.webrtcConfig,
|
|
2480
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/createDataChannel
|
|
2481
|
+
channelConfig: {
|
|
2482
|
+
protocol: "dxos.mesh"
|
|
2483
|
+
},
|
|
2484
|
+
// Custom WebRTC implementation (for Node); otherwise get-browser-rtc.
|
|
2485
|
+
wrtc: SimplePeerConstructor.WEBRTC_SUPPORT ? void 0 : wrtc ?? raise2(new Error("wrtc not available"))
|
|
2470
2486
|
});
|
|
2471
2487
|
this._peer.on("signal", async (data) => {
|
|
2472
2488
|
log11("signal", data, {
|
|
2473
2489
|
F: __dxlog_file12,
|
|
2474
|
-
L:
|
|
2490
|
+
L: 62,
|
|
2475
2491
|
S: this,
|
|
2476
2492
|
C: (f, a) => f(...a)
|
|
2477
2493
|
});
|
|
@@ -2484,7 +2500,7 @@ var WebRTCTransport = class {
|
|
|
2484
2500
|
this._peer.on("connect", () => {
|
|
2485
2501
|
log11("connected", void 0, {
|
|
2486
2502
|
F: __dxlog_file12,
|
|
2487
|
-
L:
|
|
2503
|
+
L: 67,
|
|
2488
2504
|
S: this,
|
|
2489
2505
|
C: (f, a) => f(...a)
|
|
2490
2506
|
});
|
|
@@ -2494,7 +2510,7 @@ var WebRTCTransport = class {
|
|
|
2494
2510
|
this._peer.on("close", async () => {
|
|
2495
2511
|
log11("closed", void 0, {
|
|
2496
2512
|
F: __dxlog_file12,
|
|
2497
|
-
L:
|
|
2513
|
+
L: 73,
|
|
2498
2514
|
S: this,
|
|
2499
2515
|
C: (f, a) => f(...a)
|
|
2500
2516
|
});
|
|
@@ -2511,7 +2527,7 @@ var WebRTCTransport = class {
|
|
|
2511
2527
|
stats
|
|
2512
2528
|
}, {
|
|
2513
2529
|
F: __dxlog_file12,
|
|
2514
|
-
L:
|
|
2530
|
+
L: 85,
|
|
2515
2531
|
S: this,
|
|
2516
2532
|
C: (f, a) => f(...a)
|
|
2517
2533
|
});
|
|
@@ -2525,7 +2541,7 @@ var WebRTCTransport = class {
|
|
|
2525
2541
|
id: this._instanceId
|
|
2526
2542
|
}), {
|
|
2527
2543
|
F: __dxlog_file12,
|
|
2528
|
-
L:
|
|
2544
|
+
L: 95,
|
|
2529
2545
|
S: this,
|
|
2530
2546
|
C: (f, a) => f(...a)
|
|
2531
2547
|
});
|
|
@@ -2533,7 +2549,7 @@ var WebRTCTransport = class {
|
|
|
2533
2549
|
async destroy() {
|
|
2534
2550
|
log11("closing...", void 0, {
|
|
2535
2551
|
F: __dxlog_file12,
|
|
2536
|
-
L:
|
|
2552
|
+
L: 99,
|
|
2537
2553
|
S: this,
|
|
2538
2554
|
C: (f, a) => f(...a)
|
|
2539
2555
|
});
|
|
@@ -2543,7 +2559,7 @@ var WebRTCTransport = class {
|
|
|
2543
2559
|
this.closed.emit();
|
|
2544
2560
|
log11("closed", void 0, {
|
|
2545
2561
|
F: __dxlog_file12,
|
|
2546
|
-
L:
|
|
2562
|
+
L: 104,
|
|
2547
2563
|
S: this,
|
|
2548
2564
|
C: (f, a) => f(...a)
|
|
2549
2565
|
});
|
|
@@ -2554,7 +2570,7 @@ var WebRTCTransport = class {
|
|
|
2554
2570
|
}
|
|
2555
2571
|
invariant11(signal.payload.data, "Signal message must contain signal data.", {
|
|
2556
2572
|
F: __dxlog_file12,
|
|
2557
|
-
L:
|
|
2573
|
+
L: 112,
|
|
2558
2574
|
S: this,
|
|
2559
2575
|
A: [
|
|
2560
2576
|
"signal.payload.data",
|
|
@@ -2582,7 +2598,7 @@ import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
|
2582
2598
|
import { log as log12 } from "@dxos/log";
|
|
2583
2599
|
import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
2584
2600
|
import { ComplexMap as ComplexMap8 } from "@dxos/util";
|
|
2585
|
-
var __dxlog_file13 = "/
|
|
2601
|
+
var __dxlog_file13 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts";
|
|
2586
2602
|
var WebRTCTransportService = class {
|
|
2587
2603
|
// prettier-ignore
|
|
2588
2604
|
constructor(_webrtcConfig) {
|
|
@@ -2714,7 +2730,7 @@ import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
|
2714
2730
|
import { log as log13 } from "@dxos/log";
|
|
2715
2731
|
import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
2716
2732
|
import { arrayToBuffer } from "@dxos/util";
|
|
2717
|
-
var __dxlog_file14 = "/
|
|
2733
|
+
var __dxlog_file14 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts";
|
|
2718
2734
|
var WebRTCTransportProxy = class {
|
|
2719
2735
|
// prettier-ignore
|
|
2720
2736
|
constructor(_params) {
|
|
@@ -2722,9 +2738,9 @@ var WebRTCTransportProxy = class {
|
|
|
2722
2738
|
this._proxyId = PublicKey12.random();
|
|
2723
2739
|
this._ctx = new Context6();
|
|
2724
2740
|
this.closed = new Event8();
|
|
2725
|
-
this._closed = false;
|
|
2726
2741
|
this.connected = new Event8();
|
|
2727
2742
|
this.errors = new ErrorStream5();
|
|
2743
|
+
this._closed = false;
|
|
2728
2744
|
this._serviceStream = this._params.bridgeService.open({
|
|
2729
2745
|
proxyId: this._proxyId,
|
|
2730
2746
|
initiator: this._params.initiator
|
|
@@ -2800,7 +2816,7 @@ var WebRTCTransportProxy = class {
|
|
|
2800
2816
|
if (this._closed) {
|
|
2801
2817
|
return;
|
|
2802
2818
|
}
|
|
2803
|
-
this._serviceStream.close();
|
|
2819
|
+
await this._serviceStream.close();
|
|
2804
2820
|
try {
|
|
2805
2821
|
await this._params.bridgeService.close({
|
|
2806
2822
|
proxyId: this._proxyId
|
|
@@ -2821,7 +2837,7 @@ var WebRTCTransportProxy = class {
|
|
|
2821
2837
|
*/
|
|
2822
2838
|
// TODO(burdon): Option on close method.
|
|
2823
2839
|
forceClose() {
|
|
2824
|
-
this._serviceStream.close();
|
|
2840
|
+
void this._serviceStream.close();
|
|
2825
2841
|
this.closed.emit();
|
|
2826
2842
|
this._closed = true;
|
|
2827
2843
|
}
|
|
@@ -2902,4 +2918,4 @@ export {
|
|
|
2902
2918
|
WebRTCTransportProxyFactory,
|
|
2903
2919
|
createTeleportProtocolFactory
|
|
2904
2920
|
};
|
|
2905
|
-
//# sourceMappingURL=chunk-
|
|
2921
|
+
//# sourceMappingURL=chunk-BYYPWP6O.mjs.map
|