@dxos/network-manager 0.1.57-main.e87098f → 0.1.57
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-UAB4ONRL.mjs → chunk-UKMTAO4L.mjs} +553 -121
- package/dist/lib/browser/chunk-UKMTAO4L.mjs.map +7 -0
- package/dist/lib/browser/chunk-YERMWDRB.mjs +24 -0
- package/dist/lib/browser/chunk-YERMWDRB.mjs.map +7 -0
- package/dist/lib/browser/index.browser-O53CPVK3.mjs +14 -0
- package/dist/lib/browser/index.browser-O53CPVK3.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +29 -13
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +83 -38
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +1048 -124
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +1109 -151
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/types/src/swarm/connection.d.ts +6 -0
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/swarm/peer.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts +5 -2
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/transport/datachannel/index.browser.d.ts +15 -0
- package/dist/types/src/transport/datachannel/index.browser.d.ts.map +1 -0
- package/dist/types/src/transport/datachannel/index.d.ts +8 -0
- package/dist/types/src/transport/datachannel/index.d.ts.map +1 -0
- package/dist/types/src/transport/datachannel/rtc-data-channel.d.ts +29 -0
- package/dist/types/src/transport/datachannel/rtc-data-channel.d.ts.map +1 -0
- package/dist/types/src/transport/datachannel/rtc-events.d.ts +9 -0
- package/dist/types/src/transport/datachannel/rtc-events.d.ts.map +1 -0
- package/dist/types/src/transport/datachannel/rtc-ice-candidate.d.ts +22 -0
- package/dist/types/src/transport/datachannel/rtc-ice-candidate.d.ts.map +1 -0
- package/dist/types/src/transport/datachannel/rtc-peer-connection.d.ts +47 -0
- package/dist/types/src/transport/datachannel/rtc-peer-connection.d.ts.map +1 -0
- package/dist/types/src/transport/datachannel/rtc-peer-connection.test.d.ts +2 -0
- package/dist/types/src/transport/datachannel/rtc-peer-connection.test.d.ts.map +1 -0
- package/dist/types/src/transport/datachannel/rtc-session-description.d.ts +10 -0
- package/dist/types/src/transport/datachannel/rtc-session-description.d.ts.map +1 -0
- package/dist/types/src/transport/index.d.ts +5 -3
- package/dist/types/src/transport/index.d.ts.map +1 -1
- package/dist/types/src/transport/libdatachannel-transport.d.ts +35 -0
- package/dist/types/src/transport/libdatachannel-transport.d.ts.map +1 -0
- package/dist/types/src/transport/libdatachannel-transport.test.d.ts +2 -0
- package/dist/types/src/transport/libdatachannel-transport.test.d.ts.map +1 -0
- package/dist/types/src/transport/simplepeer-simple-peer.d.ts +2 -0
- package/dist/types/src/transport/simplepeer-simple-peer.d.ts.map +1 -0
- package/dist/types/src/transport/simplepeer-transport-proxy-test.d.ts +2 -0
- package/dist/types/src/transport/simplepeer-transport-proxy-test.d.ts.map +1 -0
- package/dist/types/src/transport/{webrtc-transport-proxy.d.ts → simplepeer-transport-proxy.d.ts} +5 -5
- package/dist/types/src/transport/simplepeer-transport-proxy.d.ts.map +1 -0
- package/dist/types/src/transport/{webrtc-transport-service.d.ts → simplepeer-transport-service.d.ts} +2 -2
- package/dist/types/src/transport/simplepeer-transport-service.d.ts.map +1 -0
- package/dist/types/src/transport/{webrtc-transport.d.ts → simplepeer-transport.d.ts} +8 -8
- package/dist/types/src/transport/simplepeer-transport.d.ts.map +1 -0
- package/dist/types/src/transport/simplepeer-transport.test.d.ts +2 -0
- package/dist/types/src/transport/simplepeer-transport.test.d.ts.map +1 -0
- package/dist/types/src/transport/transport.d.ts +6 -0
- package/dist/types/src/transport/transport.d.ts.map +1 -1
- package/dist/types/src/wire-protocol.d.ts +3 -2
- package/dist/types/src/wire-protocol.d.ts.map +1 -1
- package/package.json +25 -20
- package/src/connection-log.ts +1 -1
- package/src/swarm/connection.test.ts +8 -3
- package/src/swarm/connection.ts +58 -6
- package/src/swarm/peer.ts +4 -0
- package/src/swarm/swarm.test.ts +3 -2
- package/src/testing/test-builder.ts +72 -41
- package/src/transport/datachannel/README.md +2 -0
- package/src/transport/datachannel/index.browser.ts +8 -0
- package/src/transport/datachannel/index.ts +17 -0
- package/src/transport/datachannel/rtc-data-channel.ts +148 -0
- package/src/transport/datachannel/rtc-events.ts +23 -0
- package/src/transport/datachannel/rtc-ice-candidate.ts +54 -0
- package/src/transport/datachannel/rtc-peer-connection.test.ts +112 -0
- package/src/transport/datachannel/rtc-peer-connection.ts +347 -0
- package/src/transport/datachannel/rtc-session-description.ts +23 -0
- package/src/transport/index.ts +5 -3
- package/src/transport/libdatachannel-transport.test.ts +99 -0
- package/src/transport/libdatachannel-transport.ts +252 -0
- package/src/transport/{webrtc-transport-proxy.test.ts → simplepeer-transport-proxy-test.ts} +15 -15
- package/src/transport/{webrtc-transport-proxy.ts → simplepeer-transport-proxy.ts} +8 -8
- package/src/transport/{webrtc-transport-service.ts → simplepeer-transport-service.ts} +4 -4
- package/src/transport/{webrtc-transport.test.ts → simplepeer-transport.test.ts} +5 -5
- package/src/transport/{webrtc-transport.ts → simplepeer-transport.ts} +13 -27
- package/src/transport/transport.ts +7 -0
- package/src/wire-protocol.ts +8 -4
- package/dist/lib/browser/chunk-UAB4ONRL.mjs.map +0 -7
- package/dist/types/src/transport/webrtc-simple-peer.test.d.ts +0 -2
- package/dist/types/src/transport/webrtc-simple-peer.test.d.ts.map +0 -1
- package/dist/types/src/transport/webrtc-transport-proxy.d.ts.map +0 -1
- package/dist/types/src/transport/webrtc-transport-proxy.test.d.ts +0 -2
- package/dist/types/src/transport/webrtc-transport-proxy.test.d.ts.map +0 -1
- package/dist/types/src/transport/webrtc-transport-service.d.ts.map +0 -1
- package/dist/types/src/transport/webrtc-transport.d.ts.map +0 -1
- package/dist/types/src/transport/webrtc-transport.test.d.ts +0 -2
- package/dist/types/src/transport/webrtc-transport.test.d.ts.map +0 -1
- /package/src/transport/{webrtc-simple-peer.test.ts → simplepeer-simple-peer.ts} +0 -0
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
if (typeof require !== "undefined")
|
|
6
|
-
return require.apply(this, arguments);
|
|
7
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
-
});
|
|
2
|
+
import {
|
|
3
|
+
__require
|
|
4
|
+
} from "./chunk-YERMWDRB.mjs";
|
|
9
5
|
|
|
10
6
|
// packages/core/mesh/network-manager/src/swarm/connection.ts
|
|
11
7
|
import { DeferredTask, Event, sleep, synchronized } from "@dxos/async";
|
|
@@ -26,11 +22,17 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
26
22
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
27
23
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
28
24
|
}
|
|
29
|
-
var __dxlog_file = "/
|
|
25
|
+
var __dxlog_file = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/connection.ts";
|
|
30
26
|
var STARTING_SIGNALLING_DELAY = 10;
|
|
31
27
|
var MAX_SIGNALLING_DELAY = 300;
|
|
32
28
|
var ConnectionState;
|
|
33
29
|
(function(ConnectionState5) {
|
|
30
|
+
ConnectionState5[
|
|
31
|
+
/**
|
|
32
|
+
* Connection is created, but not yet passed through the connection limiter.
|
|
33
|
+
*/
|
|
34
|
+
"CREATED"
|
|
35
|
+
] = "CREATED";
|
|
34
36
|
ConnectionState5[
|
|
35
37
|
/**
|
|
36
38
|
* Initial state. Connection is registered but no attempt to connect to the remote peer has been performed.
|
|
@@ -75,7 +77,7 @@ var Connection = class {
|
|
|
75
77
|
this._transportFactory = _transportFactory;
|
|
76
78
|
this._callbacks = _callbacks;
|
|
77
79
|
this._ctx = new Context();
|
|
78
|
-
this._state = ConnectionState.
|
|
80
|
+
this._state = ConnectionState.CREATED;
|
|
79
81
|
this._incomingSignalBuffer = [];
|
|
80
82
|
this._outgoingSignalBuffer = [];
|
|
81
83
|
this.stateChanged = new Event();
|
|
@@ -93,7 +95,7 @@ var Connection = class {
|
|
|
93
95
|
initiator: this.initiator
|
|
94
96
|
}, {
|
|
95
97
|
F: __dxlog_file,
|
|
96
|
-
L:
|
|
98
|
+
L: 114,
|
|
97
99
|
S: this,
|
|
98
100
|
C: (f, a) => f(...a)
|
|
99
101
|
});
|
|
@@ -113,7 +115,7 @@ var Connection = class {
|
|
|
113
115
|
async openConnection() {
|
|
114
116
|
invariant(this._state === ConnectionState.INITIAL, "Invalid state.", {
|
|
115
117
|
F: __dxlog_file,
|
|
116
|
-
L:
|
|
118
|
+
L: 139,
|
|
117
119
|
S: this,
|
|
118
120
|
A: [
|
|
119
121
|
"this._state === ConnectionState.INITIAL",
|
|
@@ -124,7 +126,7 @@ var Connection = class {
|
|
|
124
126
|
id: this._instanceId
|
|
125
127
|
}), {
|
|
126
128
|
F: __dxlog_file,
|
|
127
|
-
L:
|
|
129
|
+
L: 140,
|
|
128
130
|
S: this,
|
|
129
131
|
C: (f, a) => f(...a)
|
|
130
132
|
});
|
|
@@ -136,18 +138,18 @@ var Connection = class {
|
|
|
136
138
|
initiator: this.initiator
|
|
137
139
|
}, {
|
|
138
140
|
F: __dxlog_file,
|
|
139
|
-
L:
|
|
141
|
+
L: 141,
|
|
140
142
|
S: this,
|
|
141
143
|
C: (f, a) => f(...a)
|
|
142
144
|
});
|
|
143
145
|
this._changeState(ConnectionState.CONNECTING);
|
|
144
|
-
this._protocol.
|
|
146
|
+
this._protocol.open().catch((err) => {
|
|
145
147
|
this.errors.raise(err);
|
|
146
148
|
});
|
|
147
149
|
this._protocol.stream.on("close", () => {
|
|
148
150
|
log("protocol stream closed", void 0, {
|
|
149
151
|
F: __dxlog_file,
|
|
150
|
-
L:
|
|
152
|
+
L: 158,
|
|
151
153
|
S: this,
|
|
152
154
|
C: (f, a) => f(...a)
|
|
153
155
|
});
|
|
@@ -155,7 +157,7 @@ var Connection = class {
|
|
|
155
157
|
});
|
|
156
158
|
invariant(!this._transport, void 0, {
|
|
157
159
|
F: __dxlog_file,
|
|
158
|
-
L:
|
|
160
|
+
L: 162,
|
|
159
161
|
S: this,
|
|
160
162
|
A: [
|
|
161
163
|
"!this._transport",
|
|
@@ -173,12 +175,35 @@ var Connection = class {
|
|
|
173
175
|
});
|
|
174
176
|
this._transport.closed.once(() => {
|
|
175
177
|
this._transport = void 0;
|
|
176
|
-
|
|
178
|
+
log("abort triggered by transport close", void 0, {
|
|
179
|
+
F: __dxlog_file,
|
|
180
|
+
L: 176,
|
|
181
|
+
S: this,
|
|
182
|
+
C: (f, a) => f(...a)
|
|
183
|
+
});
|
|
184
|
+
this.abort().catch((err) => this.errors.raise(err));
|
|
177
185
|
});
|
|
178
186
|
this._transport.errors.handle((err) => {
|
|
187
|
+
log("transport error:", {
|
|
188
|
+
err
|
|
189
|
+
}, {
|
|
190
|
+
F: __dxlog_file,
|
|
191
|
+
L: 181,
|
|
192
|
+
S: this,
|
|
193
|
+
C: (f, a) => f(...a)
|
|
194
|
+
});
|
|
179
195
|
if (!this.closeReason) {
|
|
180
196
|
this.closeReason = err?.message;
|
|
181
197
|
}
|
|
198
|
+
if (err?.message.includes("OperationError")) {
|
|
199
|
+
log("aborting due to transport OperationError", void 0, {
|
|
200
|
+
F: __dxlog_file,
|
|
201
|
+
L: 187,
|
|
202
|
+
S: this,
|
|
203
|
+
C: (f, a) => f(...a)
|
|
204
|
+
});
|
|
205
|
+
this.abort().catch((err2) => this.errors.raise(err2));
|
|
206
|
+
}
|
|
182
207
|
if (this._state !== ConnectionState.CLOSED && this._state !== ConnectionState.CLOSING) {
|
|
183
208
|
this.errors.raise(err);
|
|
184
209
|
}
|
|
@@ -191,11 +216,65 @@ var Connection = class {
|
|
|
191
216
|
id: this._instanceId
|
|
192
217
|
}), {
|
|
193
218
|
F: __dxlog_file,
|
|
194
|
-
L:
|
|
219
|
+
L: 203,
|
|
195
220
|
S: this,
|
|
196
221
|
C: (f, a) => f(...a)
|
|
197
222
|
});
|
|
198
223
|
}
|
|
224
|
+
async abort(err) {
|
|
225
|
+
log("aborting...", {
|
|
226
|
+
err
|
|
227
|
+
}, {
|
|
228
|
+
F: __dxlog_file,
|
|
229
|
+
L: 209,
|
|
230
|
+
S: this,
|
|
231
|
+
C: (f, a) => f(...a)
|
|
232
|
+
});
|
|
233
|
+
if (!this.closeReason) {
|
|
234
|
+
this.closeReason = err?.message;
|
|
235
|
+
}
|
|
236
|
+
if (this._state === ConnectionState.CLOSED) {
|
|
237
|
+
log("abort ignored: already closed", this.closeReason, {
|
|
238
|
+
F: __dxlog_file,
|
|
239
|
+
L: 214,
|
|
240
|
+
S: this,
|
|
241
|
+
C: (f, a) => f(...a)
|
|
242
|
+
});
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
this._changeState(ConnectionState.CLOSING);
|
|
246
|
+
await this._ctx.dispose();
|
|
247
|
+
try {
|
|
248
|
+
log("aborting protocol... ", {
|
|
249
|
+
proto: this._protocol
|
|
250
|
+
}, {
|
|
251
|
+
F: __dxlog_file,
|
|
252
|
+
L: 224,
|
|
253
|
+
S: this,
|
|
254
|
+
C: (f, a) => f(...a)
|
|
255
|
+
});
|
|
256
|
+
await this._protocol.abort();
|
|
257
|
+
} catch (err2) {
|
|
258
|
+
log.catch(err2, void 0, {
|
|
259
|
+
F: __dxlog_file,
|
|
260
|
+
L: 227,
|
|
261
|
+
S: this,
|
|
262
|
+
C: (f, a) => f(...a)
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
try {
|
|
266
|
+
await this._transport?.destroy();
|
|
267
|
+
} catch (err2) {
|
|
268
|
+
log.catch(err2, void 0, {
|
|
269
|
+
F: __dxlog_file,
|
|
270
|
+
L: 234,
|
|
271
|
+
S: this,
|
|
272
|
+
C: (f, a) => f(...a)
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
this._changeState(ConnectionState.CLOSED);
|
|
276
|
+
this._callbacks?.onClosed?.(err);
|
|
277
|
+
}
|
|
199
278
|
async close(err) {
|
|
200
279
|
if (!this.closeReason) {
|
|
201
280
|
this.closeReason = err?.message;
|
|
@@ -209,16 +288,16 @@ var Connection = class {
|
|
|
209
288
|
peerId: this.ownId
|
|
210
289
|
}, {
|
|
211
290
|
F: __dxlog_file,
|
|
212
|
-
L:
|
|
291
|
+
L: 253,
|
|
213
292
|
S: this,
|
|
214
293
|
C: (f, a) => f(...a)
|
|
215
294
|
});
|
|
216
295
|
try {
|
|
217
|
-
await this._protocol.
|
|
296
|
+
await this._protocol.close();
|
|
218
297
|
} catch (err2) {
|
|
219
298
|
log.catch(err2, void 0, {
|
|
220
299
|
F: __dxlog_file,
|
|
221
|
-
L:
|
|
300
|
+
L: 259,
|
|
222
301
|
S: this,
|
|
223
302
|
C: (f, a) => f(...a)
|
|
224
303
|
});
|
|
@@ -228,7 +307,7 @@ var Connection = class {
|
|
|
228
307
|
} catch (err2) {
|
|
229
308
|
log.catch(err2, void 0, {
|
|
230
309
|
F: __dxlog_file,
|
|
231
|
-
L:
|
|
310
|
+
L: 266,
|
|
232
311
|
S: this,
|
|
233
312
|
C: (f, a) => f(...a)
|
|
234
313
|
});
|
|
@@ -237,7 +316,7 @@ var Connection = class {
|
|
|
237
316
|
peerId: this.ownId
|
|
238
317
|
}, {
|
|
239
318
|
F: __dxlog_file,
|
|
240
|
-
L:
|
|
319
|
+
L: 269,
|
|
241
320
|
S: this,
|
|
242
321
|
C: (f, a) => f(...a)
|
|
243
322
|
});
|
|
@@ -276,11 +355,11 @@ var Connection = class {
|
|
|
276
355
|
if (err instanceof CancelledError) {
|
|
277
356
|
return;
|
|
278
357
|
}
|
|
279
|
-
log.warn("
|
|
358
|
+
log.warn("signal failed", {
|
|
280
359
|
err
|
|
281
360
|
}, {
|
|
282
361
|
F: __dxlog_file,
|
|
283
|
-
L:
|
|
362
|
+
L: 306,
|
|
284
363
|
S: this,
|
|
285
364
|
C: (f, a) => f(...a)
|
|
286
365
|
});
|
|
@@ -293,7 +372,7 @@ var Connection = class {
|
|
|
293
372
|
async signal(msg) {
|
|
294
373
|
invariant(msg.sessionId, void 0, {
|
|
295
374
|
F: __dxlog_file,
|
|
296
|
-
L:
|
|
375
|
+
L: 315,
|
|
297
376
|
S: this,
|
|
298
377
|
A: [
|
|
299
378
|
"msg.sessionId",
|
|
@@ -303,7 +382,7 @@ var Connection = class {
|
|
|
303
382
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
304
383
|
log("dropping signal for incorrect session id", void 0, {
|
|
305
384
|
F: __dxlog_file,
|
|
306
|
-
L:
|
|
385
|
+
L: 317,
|
|
307
386
|
S: this,
|
|
308
387
|
C: (f, a) => f(...a)
|
|
309
388
|
});
|
|
@@ -311,7 +390,7 @@ var Connection = class {
|
|
|
311
390
|
}
|
|
312
391
|
invariant(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
313
392
|
F: __dxlog_file,
|
|
314
|
-
L:
|
|
393
|
+
L: 320,
|
|
315
394
|
S: this,
|
|
316
395
|
A: [
|
|
317
396
|
"msg.data.signal || msg.data.signalBatch",
|
|
@@ -320,7 +399,7 @@ var Connection = class {
|
|
|
320
399
|
});
|
|
321
400
|
invariant(msg.author?.equals(this.remoteId), void 0, {
|
|
322
401
|
F: __dxlog_file,
|
|
323
|
-
L:
|
|
402
|
+
L: 321,
|
|
324
403
|
S: this,
|
|
325
404
|
A: [
|
|
326
405
|
"msg.author?.equals(this.remoteId)",
|
|
@@ -329,7 +408,7 @@ var Connection = class {
|
|
|
329
408
|
});
|
|
330
409
|
invariant(msg.recipient?.equals(this.ownId), void 0, {
|
|
331
410
|
F: __dxlog_file,
|
|
332
|
-
L:
|
|
411
|
+
L: 322,
|
|
333
412
|
S: this,
|
|
334
413
|
A: [
|
|
335
414
|
"msg.recipient?.equals(this.ownId)",
|
|
@@ -343,14 +422,17 @@ var Connection = class {
|
|
|
343
422
|
if (!signal) {
|
|
344
423
|
continue;
|
|
345
424
|
}
|
|
346
|
-
if (
|
|
425
|
+
if ([
|
|
426
|
+
ConnectionState.CREATED,
|
|
427
|
+
ConnectionState.INITIAL
|
|
428
|
+
].includes(this.state)) {
|
|
347
429
|
log("buffered signal", {
|
|
348
430
|
peerId: this.ownId,
|
|
349
431
|
remoteId: this.remoteId,
|
|
350
432
|
msg: msg.data
|
|
351
433
|
}, {
|
|
352
434
|
F: __dxlog_file,
|
|
353
|
-
L:
|
|
435
|
+
L: 331,
|
|
354
436
|
S: this,
|
|
355
437
|
C: (f, a) => f(...a)
|
|
356
438
|
});
|
|
@@ -358,7 +440,7 @@ var Connection = class {
|
|
|
358
440
|
} else {
|
|
359
441
|
invariant(this._transport, "Connection not ready to accept signals.", {
|
|
360
442
|
F: __dxlog_file,
|
|
361
|
-
L:
|
|
443
|
+
L: 334,
|
|
362
444
|
S: this,
|
|
363
445
|
A: [
|
|
364
446
|
"this._transport",
|
|
@@ -371,7 +453,7 @@ var Connection = class {
|
|
|
371
453
|
msg: msg.data
|
|
372
454
|
}, {
|
|
373
455
|
F: __dxlog_file,
|
|
374
|
-
L:
|
|
456
|
+
L: 335,
|
|
375
457
|
S: this,
|
|
376
458
|
C: (f, a) => f(...a)
|
|
377
459
|
});
|
|
@@ -379,6 +461,9 @@ var Connection = class {
|
|
|
379
461
|
}
|
|
380
462
|
}
|
|
381
463
|
}
|
|
464
|
+
initiate() {
|
|
465
|
+
this._changeState(ConnectionState.INITIAL);
|
|
466
|
+
}
|
|
382
467
|
_changeState(state) {
|
|
383
468
|
log("stateChanged", {
|
|
384
469
|
from: this._state,
|
|
@@ -386,13 +471,13 @@ var Connection = class {
|
|
|
386
471
|
peerId: this.ownId
|
|
387
472
|
}, {
|
|
388
473
|
F: __dxlog_file,
|
|
389
|
-
L:
|
|
474
|
+
L: 346,
|
|
390
475
|
S: this,
|
|
391
476
|
C: (f, a) => f(...a)
|
|
392
477
|
});
|
|
393
478
|
invariant(state !== this._state, "Already in this state.", {
|
|
394
479
|
F: __dxlog_file,
|
|
395
|
-
L:
|
|
480
|
+
L: 347,
|
|
396
481
|
S: this,
|
|
397
482
|
A: [
|
|
398
483
|
"state !== this._state",
|
|
@@ -403,6 +488,9 @@ var Connection = class {
|
|
|
403
488
|
this.stateChanged.emit(state);
|
|
404
489
|
}
|
|
405
490
|
};
|
|
491
|
+
_ts_decorate([
|
|
492
|
+
synchronized
|
|
493
|
+
], Connection.prototype, "abort", null);
|
|
406
494
|
_ts_decorate([
|
|
407
495
|
synchronized
|
|
408
496
|
], Connection.prototype, "close", null);
|
|
@@ -414,7 +502,7 @@ import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
|
414
502
|
import { log as log2 } from "@dxos/log";
|
|
415
503
|
import { schema } from "@dxos/protocols";
|
|
416
504
|
import { ComplexMap } from "@dxos/util";
|
|
417
|
-
var __dxlog_file2 = "/
|
|
505
|
+
var __dxlog_file2 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
|
|
418
506
|
var SwarmMessage = schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
|
|
419
507
|
var SwarmMessenger = class {
|
|
420
508
|
constructor({ sendMessage, onSignal, onOffer, topic }) {
|
|
@@ -666,7 +754,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
666
754
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
667
755
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
668
756
|
}
|
|
669
|
-
var __dxlog_file3 = "/
|
|
757
|
+
var __dxlog_file3 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/peer.ts";
|
|
670
758
|
var ConnectionDisplacedError = class extends SystemError {
|
|
671
759
|
constructor() {
|
|
672
760
|
super("Connection displaced by remote initiator.");
|
|
@@ -705,7 +793,7 @@ var Peer = class {
|
|
|
705
793
|
sessionId: this.connection?.sessionId
|
|
706
794
|
}, {
|
|
707
795
|
F: __dxlog_file3,
|
|
708
|
-
L:
|
|
796
|
+
L: 117,
|
|
709
797
|
S: this,
|
|
710
798
|
C: (f, a) => f(...a)
|
|
711
799
|
});
|
|
@@ -722,7 +810,7 @@ var Peer = class {
|
|
|
722
810
|
if (!this.connection) {
|
|
723
811
|
invariant3(message.sessionId, void 0, {
|
|
724
812
|
F: __dxlog_file3,
|
|
725
|
-
L:
|
|
813
|
+
L: 137,
|
|
726
814
|
S: this,
|
|
727
815
|
A: [
|
|
728
816
|
"message.sessionId",
|
|
@@ -732,6 +820,7 @@ var Peer = class {
|
|
|
732
820
|
const connection = this._createConnection(false, message.sessionId);
|
|
733
821
|
try {
|
|
734
822
|
await this._connectionLimiter.connecting(message.sessionId);
|
|
823
|
+
connection.initiate();
|
|
735
824
|
await connection.openConnection();
|
|
736
825
|
} catch (err) {
|
|
737
826
|
if (!(err instanceof CancelledError2)) {
|
|
@@ -742,7 +831,7 @@ var Peer = class {
|
|
|
742
831
|
err
|
|
743
832
|
}, {
|
|
744
833
|
F: __dxlog_file3,
|
|
745
|
-
L:
|
|
834
|
+
L: 147,
|
|
746
835
|
S: this,
|
|
747
836
|
C: (f, a) => f(...a)
|
|
748
837
|
});
|
|
@@ -764,7 +853,7 @@ var Peer = class {
|
|
|
764
853
|
async initiateConnection() {
|
|
765
854
|
invariant3(!this.initiating, "Initiation in progress.", {
|
|
766
855
|
F: __dxlog_file3,
|
|
767
|
-
L:
|
|
856
|
+
L: 164,
|
|
768
857
|
S: this,
|
|
769
858
|
A: [
|
|
770
859
|
"!this.initiating",
|
|
@@ -773,7 +862,7 @@ var Peer = class {
|
|
|
773
862
|
});
|
|
774
863
|
invariant3(!this.connection, "Already connected.", {
|
|
775
864
|
F: __dxlog_file3,
|
|
776
|
-
L:
|
|
865
|
+
L: 165,
|
|
777
866
|
S: this,
|
|
778
867
|
A: [
|
|
779
868
|
"!this.connection",
|
|
@@ -788,7 +877,7 @@ var Peer = class {
|
|
|
788
877
|
sessionId
|
|
789
878
|
}, {
|
|
790
879
|
F: __dxlog_file3,
|
|
791
|
-
L:
|
|
880
|
+
L: 167,
|
|
792
881
|
S: this,
|
|
793
882
|
C: (f, a) => f(...a)
|
|
794
883
|
});
|
|
@@ -796,6 +885,7 @@ var Peer = class {
|
|
|
796
885
|
this.initiating = true;
|
|
797
886
|
try {
|
|
798
887
|
await this._connectionLimiter.connecting(sessionId);
|
|
888
|
+
connection.initiate();
|
|
799
889
|
const answer = await this._signalMessaging.offer({
|
|
800
890
|
author: this.localPeerId,
|
|
801
891
|
recipient: this.id,
|
|
@@ -812,14 +902,14 @@ var Peer = class {
|
|
|
812
902
|
remoteId: this.id
|
|
813
903
|
}, {
|
|
814
904
|
F: __dxlog_file3,
|
|
815
|
-
L:
|
|
905
|
+
L: 183,
|
|
816
906
|
S: this,
|
|
817
907
|
C: (f, a) => f(...a)
|
|
818
908
|
});
|
|
819
909
|
if (connection.state !== ConnectionState.INITIAL) {
|
|
820
910
|
log3("ignoring response", void 0, {
|
|
821
911
|
F: __dxlog_file3,
|
|
822
|
-
L:
|
|
912
|
+
L: 185,
|
|
823
913
|
S: this,
|
|
824
914
|
C: (f, a) => f(...a)
|
|
825
915
|
});
|
|
@@ -839,7 +929,7 @@ var Peer = class {
|
|
|
839
929
|
remoteId: this.id
|
|
840
930
|
}, {
|
|
841
931
|
F: __dxlog_file3,
|
|
842
|
-
L:
|
|
932
|
+
L: 196,
|
|
843
933
|
S: this,
|
|
844
934
|
C: (f, a) => f(...a)
|
|
845
935
|
});
|
|
@@ -862,13 +952,13 @@ var Peer = class {
|
|
|
862
952
|
sessionId
|
|
863
953
|
}, {
|
|
864
954
|
F: __dxlog_file3,
|
|
865
|
-
L:
|
|
955
|
+
L: 210,
|
|
866
956
|
S: this,
|
|
867
957
|
C: (f, a) => f(...a)
|
|
868
958
|
});
|
|
869
959
|
invariant3(!this.connection, "Already connected.", {
|
|
870
960
|
F: __dxlog_file3,
|
|
871
|
-
L:
|
|
961
|
+
L: 217,
|
|
872
962
|
S: this,
|
|
873
963
|
A: [
|
|
874
964
|
"!this.connection",
|
|
@@ -904,7 +994,7 @@ var Peer = class {
|
|
|
904
994
|
initiator
|
|
905
995
|
}, {
|
|
906
996
|
F: __dxlog_file3,
|
|
907
|
-
L:
|
|
997
|
+
L: 236,
|
|
908
998
|
S: this,
|
|
909
999
|
C: (f, a) => f(...a)
|
|
910
1000
|
});
|
|
@@ -917,14 +1007,14 @@ var Peer = class {
|
|
|
917
1007
|
initiator
|
|
918
1008
|
}, {
|
|
919
1009
|
F: __dxlog_file3,
|
|
920
|
-
L:
|
|
1010
|
+
L: 245,
|
|
921
1011
|
S: this,
|
|
922
1012
|
C: (f, a) => f(...a)
|
|
923
1013
|
});
|
|
924
1014
|
this._connectionLimiter.doneConnecting(sessionId);
|
|
925
1015
|
invariant3(this.connection === connection, "Connection mismatch (race condition).", {
|
|
926
1016
|
F: __dxlog_file3,
|
|
927
|
-
L:
|
|
1017
|
+
L: 250,
|
|
928
1018
|
S: this,
|
|
929
1019
|
A: [
|
|
930
1020
|
"this.connection === connection",
|
|
@@ -939,7 +1029,7 @@ var Peer = class {
|
|
|
939
1029
|
initiator
|
|
940
1030
|
}, {
|
|
941
1031
|
F: __dxlog_file3,
|
|
942
|
-
L:
|
|
1032
|
+
L: 252,
|
|
943
1033
|
S: this,
|
|
944
1034
|
C: (f, a) => f(...a)
|
|
945
1035
|
});
|
|
@@ -974,7 +1064,7 @@ var Peer = class {
|
|
|
974
1064
|
err
|
|
975
1065
|
}, {
|
|
976
1066
|
F: __dxlog_file3,
|
|
977
|
-
L:
|
|
1067
|
+
L: 292,
|
|
978
1068
|
S: this,
|
|
979
1069
|
C: (f, a) => f(...a)
|
|
980
1070
|
});
|
|
@@ -987,7 +1077,7 @@ var Peer = class {
|
|
|
987
1077
|
err
|
|
988
1078
|
}, {
|
|
989
1079
|
F: __dxlog_file3,
|
|
990
|
-
L:
|
|
1080
|
+
L: 293,
|
|
991
1081
|
S: this,
|
|
992
1082
|
C: (f, a) => f(...a)
|
|
993
1083
|
});
|
|
@@ -1006,7 +1096,7 @@ var Peer = class {
|
|
|
1006
1096
|
sessionId: connection.sessionId
|
|
1007
1097
|
}, {
|
|
1008
1098
|
F: __dxlog_file3,
|
|
1009
|
-
L:
|
|
1099
|
+
L: 318,
|
|
1010
1100
|
S: this,
|
|
1011
1101
|
C: (f, a) => f(...a)
|
|
1012
1102
|
});
|
|
@@ -1016,7 +1106,7 @@ var Peer = class {
|
|
|
1016
1106
|
sessionId: connection.sessionId
|
|
1017
1107
|
}, {
|
|
1018
1108
|
F: __dxlog_file3,
|
|
1019
|
-
L:
|
|
1109
|
+
L: 324,
|
|
1020
1110
|
S: this,
|
|
1021
1111
|
C: (f, a) => f(...a)
|
|
1022
1112
|
});
|
|
@@ -1027,7 +1117,7 @@ var Peer = class {
|
|
|
1027
1117
|
message
|
|
1028
1118
|
}, {
|
|
1029
1119
|
F: __dxlog_file3,
|
|
1030
|
-
L:
|
|
1120
|
+
L: 329,
|
|
1031
1121
|
S: this,
|
|
1032
1122
|
C: (f, a) => f(...a)
|
|
1033
1123
|
});
|
|
@@ -1042,7 +1132,7 @@ var Peer = class {
|
|
|
1042
1132
|
topic: this.topic
|
|
1043
1133
|
}, {
|
|
1044
1134
|
F: __dxlog_file3,
|
|
1045
|
-
L:
|
|
1135
|
+
L: 339,
|
|
1046
1136
|
S: this,
|
|
1047
1137
|
C: (f, a) => f(...a)
|
|
1048
1138
|
});
|
|
@@ -1076,7 +1166,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
1076
1166
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1077
1167
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1078
1168
|
}
|
|
1079
|
-
var __dxlog_file4 = "/
|
|
1169
|
+
var __dxlog_file4 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/swarm.ts";
|
|
1080
1170
|
var INITIATION_DELAY = 100;
|
|
1081
1171
|
var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
|
|
1082
1172
|
var Swarm = class {
|
|
@@ -1550,7 +1640,7 @@ import { Event as Event4, EventSubscriptions } from "@dxos/async";
|
|
|
1550
1640
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1551
1641
|
import { log as log5 } from "@dxos/log";
|
|
1552
1642
|
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
1553
|
-
var __dxlog_file5 = "/
|
|
1643
|
+
var __dxlog_file5 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
|
|
1554
1644
|
var SwarmMapper = class {
|
|
1555
1645
|
get peers() {
|
|
1556
1646
|
return Array.from(this._peers.values());
|
|
@@ -1623,7 +1713,7 @@ import { invariant as invariant5 } from "@dxos/invariant";
|
|
|
1623
1713
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1624
1714
|
import { log as log6 } from "@dxos/log";
|
|
1625
1715
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1626
|
-
var __dxlog_file6 = "/
|
|
1716
|
+
var __dxlog_file6 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
|
|
1627
1717
|
var MAX_CONCURRENT_INITIATING_CONNECTIONS = 10;
|
|
1628
1718
|
var ConnectionLimiter = class {
|
|
1629
1719
|
constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
|
|
@@ -1736,7 +1826,7 @@ var ConnectionLog = class {
|
|
|
1736
1826
|
this.update.emit();
|
|
1737
1827
|
swarm.connectionAdded.on((connection) => {
|
|
1738
1828
|
const connectionInfo = {
|
|
1739
|
-
state: ConnectionState.
|
|
1829
|
+
state: ConnectionState.CREATED,
|
|
1740
1830
|
closeReason: connection.closeReason,
|
|
1741
1831
|
remotePeerId: connection.remoteId,
|
|
1742
1832
|
sessionId: connection.sessionId,
|
|
@@ -1776,7 +1866,7 @@ import { Messenger } from "@dxos/messaging";
|
|
|
1776
1866
|
import { trace as trace3 } from "@dxos/protocols";
|
|
1777
1867
|
import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1778
1868
|
import { ComplexMap as ComplexMap6 } from "@dxos/util";
|
|
1779
|
-
var __dxlog_file7 = "/
|
|
1869
|
+
var __dxlog_file7 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/network-manager.ts";
|
|
1780
1870
|
var NetworkManager = class {
|
|
1781
1871
|
constructor({ transportFactory, signalManager, log: log1 }) {
|
|
1782
1872
|
/**
|
|
@@ -2012,7 +2102,7 @@ var NetworkManager = class {
|
|
|
2012
2102
|
|
|
2013
2103
|
// packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
|
|
2014
2104
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2015
|
-
var __dxlog_file8 = "/
|
|
2105
|
+
var __dxlog_file8 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
|
|
2016
2106
|
var FullyConnectedTopology = class {
|
|
2017
2107
|
toString() {
|
|
2018
2108
|
return "FullyConnectedTopology";
|
|
@@ -2055,7 +2145,7 @@ var FullyConnectedTopology = class {
|
|
|
2055
2145
|
import distance from "xor-distance";
|
|
2056
2146
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2057
2147
|
import { log as log8 } from "@dxos/log";
|
|
2058
|
-
var __dxlog_file9 = "/
|
|
2148
|
+
var __dxlog_file9 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
|
|
2059
2149
|
var MMSTTopology = class {
|
|
2060
2150
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
2061
2151
|
this._sampleCollected = false;
|
|
@@ -2164,7 +2254,7 @@ var sortByXorDistance = (keys, reference) => keys.sort((a, b) => distance.gt(dis
|
|
|
2164
2254
|
// packages/core/mesh/network-manager/src/topology/star-topology.ts
|
|
2165
2255
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2166
2256
|
import { log as log9 } from "@dxos/log";
|
|
2167
|
-
var __dxlog_file10 = "/
|
|
2257
|
+
var __dxlog_file10 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/topology/star-topology.ts";
|
|
2168
2258
|
var StarTopology = class {
|
|
2169
2259
|
// prettier-ignore
|
|
2170
2260
|
constructor(_centralPeer) {
|
|
@@ -2276,7 +2366,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2276
2366
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2277
2367
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2278
2368
|
}
|
|
2279
|
-
var __dxlog_file11 = "/
|
|
2369
|
+
var __dxlog_file11 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
|
|
2280
2370
|
var MEMORY_TRANSPORT_DELAY = 1;
|
|
2281
2371
|
var createStreamDelay = (delay) => {
|
|
2282
2372
|
return new Transform({
|
|
@@ -2444,11 +2534,20 @@ _ts_decorate4([
|
|
|
2444
2534
|
logInfo2
|
|
2445
2535
|
], MemoryTransport.prototype, "_remoteInstanceId", void 0);
|
|
2446
2536
|
|
|
2447
|
-
// packages/core/mesh/network-manager/src/transport/
|
|
2537
|
+
// packages/core/mesh/network-manager/src/transport/transport.ts
|
|
2538
|
+
var TransportKind;
|
|
2539
|
+
(function(TransportKind2) {
|
|
2540
|
+
TransportKind2["SIMPLE_PEER"] = "SIMPLE_PEER";
|
|
2541
|
+
TransportKind2["LIBDATACHANNEL"] = "LIBDATACHANNEL";
|
|
2542
|
+
TransportKind2["SIMPLE_PEER_PROXY"] = "SIMPLE_PEER_PROXY";
|
|
2543
|
+
TransportKind2["MEMORY"] = "MEMORY";
|
|
2544
|
+
})(TransportKind || (TransportKind = {}));
|
|
2545
|
+
|
|
2546
|
+
// packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts
|
|
2448
2547
|
import SimplePeerConstructor from "simple-peer";
|
|
2548
|
+
import invariant11 from "tiny-invariant";
|
|
2449
2549
|
import { Event as Event8 } from "@dxos/async";
|
|
2450
2550
|
import { ErrorStream as ErrorStream4, raise as raise2 } from "@dxos/debug";
|
|
2451
|
-
import { invariant as invariant11 } from "@dxos/invariant";
|
|
2452
2551
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
2453
2552
|
import { log as log11 } from "@dxos/log";
|
|
2454
2553
|
import { trace as trace4 } from "@dxos/protocols";
|
|
@@ -2460,44 +2559,40 @@ try {
|
|
|
2460
2559
|
} catch {
|
|
2461
2560
|
}
|
|
2462
2561
|
|
|
2463
|
-
// packages/core/mesh/network-manager/src/transport/
|
|
2464
|
-
var __dxlog_file12 = "/
|
|
2465
|
-
var
|
|
2562
|
+
// packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts
|
|
2563
|
+
var __dxlog_file12 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts";
|
|
2564
|
+
var SimplePeerTransport = class {
|
|
2466
2565
|
constructor(params) {
|
|
2467
2566
|
this.params = params;
|
|
2468
|
-
this._instanceId = PublicKey10.random().toHex();
|
|
2469
2567
|
this._closed = false;
|
|
2470
2568
|
this.closed = new Event8();
|
|
2471
2569
|
this.connected = new Event8();
|
|
2472
2570
|
this.errors = new ErrorStream4();
|
|
2571
|
+
this._instanceId = PublicKey10.random().toHex();
|
|
2473
2572
|
log11.trace("dxos.mesh.webrtc-transport.constructor", trace4.begin({
|
|
2474
2573
|
id: this._instanceId
|
|
2475
2574
|
}), {
|
|
2476
2575
|
F: __dxlog_file12,
|
|
2477
|
-
L:
|
|
2576
|
+
L: 39,
|
|
2478
2577
|
S: this,
|
|
2479
2578
|
C: (f, a) => f(...a)
|
|
2480
2579
|
});
|
|
2481
2580
|
log11("created connection", params, {
|
|
2482
2581
|
F: __dxlog_file12,
|
|
2483
|
-
L:
|
|
2582
|
+
L: 40,
|
|
2484
2583
|
S: this,
|
|
2485
2584
|
C: (f, a) => f(...a)
|
|
2486
2585
|
});
|
|
2487
2586
|
this._peer = new SimplePeerConstructor({
|
|
2587
|
+
channelName: "dxos.mesh.transport",
|
|
2488
2588
|
initiator: this.params.initiator,
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
channelConfig: {
|
|
2492
|
-
protocol: "dxos.mesh"
|
|
2493
|
-
},
|
|
2494
|
-
// Custom WebRTC implementation (for Node); otherwise get-browser-rtc.
|
|
2495
|
-
wrtc: SimplePeerConstructor.WEBRTC_SUPPORT ? void 0 : wrtc ?? raise2(new Error("wrtc not available"))
|
|
2589
|
+
wrtc: SimplePeerConstructor.WEBRTC_SUPPORT ? void 0 : wrtc ?? raise2(new Error("wrtc not available")),
|
|
2590
|
+
config: this.params.webrtcConfig
|
|
2496
2591
|
});
|
|
2497
2592
|
this._peer.on("signal", async (data) => {
|
|
2498
2593
|
log11("signal", data, {
|
|
2499
2594
|
F: __dxlog_file12,
|
|
2500
|
-
L:
|
|
2595
|
+
L: 49,
|
|
2501
2596
|
S: this,
|
|
2502
2597
|
C: (f, a) => f(...a)
|
|
2503
2598
|
});
|
|
@@ -2510,7 +2605,7 @@ var WebRTCTransport = class {
|
|
|
2510
2605
|
this._peer.on("connect", () => {
|
|
2511
2606
|
log11("connected", void 0, {
|
|
2512
2607
|
F: __dxlog_file12,
|
|
2513
|
-
L:
|
|
2608
|
+
L: 54,
|
|
2514
2609
|
S: this,
|
|
2515
2610
|
C: (f, a) => f(...a)
|
|
2516
2611
|
});
|
|
@@ -2520,7 +2615,7 @@ var WebRTCTransport = class {
|
|
|
2520
2615
|
this._peer.on("close", async () => {
|
|
2521
2616
|
log11("closed", void 0, {
|
|
2522
2617
|
F: __dxlog_file12,
|
|
2523
|
-
L:
|
|
2618
|
+
L: 60,
|
|
2524
2619
|
S: this,
|
|
2525
2620
|
C: (f, a) => f(...a)
|
|
2526
2621
|
});
|
|
@@ -2537,7 +2632,7 @@ var WebRTCTransport = class {
|
|
|
2537
2632
|
stats
|
|
2538
2633
|
}, {
|
|
2539
2634
|
F: __dxlog_file12,
|
|
2540
|
-
L:
|
|
2635
|
+
L: 72,
|
|
2541
2636
|
S: this,
|
|
2542
2637
|
C: (f, a) => f(...a)
|
|
2543
2638
|
});
|
|
@@ -2551,7 +2646,7 @@ var WebRTCTransport = class {
|
|
|
2551
2646
|
id: this._instanceId
|
|
2552
2647
|
}), {
|
|
2553
2648
|
F: __dxlog_file12,
|
|
2554
|
-
L:
|
|
2649
|
+
L: 82,
|
|
2555
2650
|
S: this,
|
|
2556
2651
|
C: (f, a) => f(...a)
|
|
2557
2652
|
});
|
|
@@ -2559,7 +2654,7 @@ var WebRTCTransport = class {
|
|
|
2559
2654
|
async destroy() {
|
|
2560
2655
|
log11("closing...", void 0, {
|
|
2561
2656
|
F: __dxlog_file12,
|
|
2562
|
-
L:
|
|
2657
|
+
L: 86,
|
|
2563
2658
|
S: this,
|
|
2564
2659
|
C: (f, a) => f(...a)
|
|
2565
2660
|
});
|
|
@@ -2569,7 +2664,7 @@ var WebRTCTransport = class {
|
|
|
2569
2664
|
this.closed.emit();
|
|
2570
2665
|
log11("closed", void 0, {
|
|
2571
2666
|
F: __dxlog_file12,
|
|
2572
|
-
L:
|
|
2667
|
+
L: 91,
|
|
2573
2668
|
S: this,
|
|
2574
2669
|
C: (f, a) => f(...a)
|
|
2575
2670
|
});
|
|
@@ -2578,29 +2673,21 @@ var WebRTCTransport = class {
|
|
|
2578
2673
|
if (this._closed) {
|
|
2579
2674
|
return;
|
|
2580
2675
|
}
|
|
2581
|
-
invariant11(signal.payload.data, "Signal message must contain signal data."
|
|
2582
|
-
F: __dxlog_file12,
|
|
2583
|
-
L: 112,
|
|
2584
|
-
S: this,
|
|
2585
|
-
A: [
|
|
2586
|
-
"signal.payload.data",
|
|
2587
|
-
"'Signal message must contain signal data.'"
|
|
2588
|
-
]
|
|
2589
|
-
});
|
|
2676
|
+
invariant11(signal.payload.data, "Signal message must contain signal data.");
|
|
2590
2677
|
this._peer.signal(signal.payload.data);
|
|
2591
2678
|
}
|
|
2592
2679
|
async _disconnectStreams() {
|
|
2593
2680
|
this.params.stream.unpipe?.(this._peer)?.unpipe?.(this.params.stream);
|
|
2594
2681
|
}
|
|
2595
2682
|
};
|
|
2596
|
-
var
|
|
2597
|
-
createTransport: (params) => new
|
|
2683
|
+
var createSimplePeerTransportFactory = (webrtcConfig) => ({
|
|
2684
|
+
createTransport: (params) => new SimplePeerTransport({
|
|
2598
2685
|
...params,
|
|
2599
2686
|
webrtcConfig
|
|
2600
2687
|
})
|
|
2601
2688
|
});
|
|
2602
2689
|
|
|
2603
|
-
// packages/core/mesh/network-manager/src/transport/
|
|
2690
|
+
// packages/core/mesh/network-manager/src/transport/simplepeer-transport-service.ts
|
|
2604
2691
|
import { Duplex } from "@dxos/node-std/stream";
|
|
2605
2692
|
import { Stream } from "@dxos/codec-protobuf";
|
|
2606
2693
|
import { invariant as invariant12 } from "@dxos/invariant";
|
|
@@ -2608,8 +2695,8 @@ import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
|
2608
2695
|
import { log as log12 } from "@dxos/log";
|
|
2609
2696
|
import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
2610
2697
|
import { ComplexMap as ComplexMap8 } from "@dxos/util";
|
|
2611
|
-
var __dxlog_file13 = "/
|
|
2612
|
-
var
|
|
2698
|
+
var __dxlog_file13 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/simplepeer-transport-service.ts";
|
|
2699
|
+
var SimplePeerTransportService = class {
|
|
2613
2700
|
// prettier-ignore
|
|
2614
2701
|
constructor(_webrtcConfig) {
|
|
2615
2702
|
this._webrtcConfig = _webrtcConfig;
|
|
@@ -2636,7 +2723,7 @@ var WebRTCTransportService = class {
|
|
|
2636
2723
|
callback();
|
|
2637
2724
|
}
|
|
2638
2725
|
});
|
|
2639
|
-
const transport = new
|
|
2726
|
+
const transport = new SimplePeerTransport({
|
|
2640
2727
|
initiator: request.initiator,
|
|
2641
2728
|
stream: duplex,
|
|
2642
2729
|
webrtcConfig: this._webrtcConfig,
|
|
@@ -2730,7 +2817,7 @@ var WebRTCTransportService = class {
|
|
|
2730
2817
|
}
|
|
2731
2818
|
};
|
|
2732
2819
|
|
|
2733
|
-
// packages/core/mesh/network-manager/src/transport/
|
|
2820
|
+
// packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts
|
|
2734
2821
|
import { Writable } from "@dxos/node-std/stream";
|
|
2735
2822
|
import { Event as Event9 } from "@dxos/async";
|
|
2736
2823
|
import { Context as Context6 } from "@dxos/context";
|
|
@@ -2740,8 +2827,8 @@ import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
|
2740
2827
|
import { log as log13 } from "@dxos/log";
|
|
2741
2828
|
import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
2742
2829
|
import { arrayToBuffer } from "@dxos/util";
|
|
2743
|
-
var __dxlog_file14 = "/
|
|
2744
|
-
var
|
|
2830
|
+
var __dxlog_file14 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts";
|
|
2831
|
+
var SimplePeerTransportProxy = class {
|
|
2745
2832
|
// prettier-ignore
|
|
2746
2833
|
constructor(_params) {
|
|
2747
2834
|
this._params = _params;
|
|
@@ -2757,7 +2844,7 @@ var WebRTCTransportProxy = class {
|
|
|
2757
2844
|
});
|
|
2758
2845
|
this._serviceStream.waitUntilReady().then(() => {
|
|
2759
2846
|
this._serviceStream.subscribe(async (event) => {
|
|
2760
|
-
log13("
|
|
2847
|
+
log13("SimplePeerTransportProxy: event", event, {
|
|
2761
2848
|
F: __dxlog_file14,
|
|
2762
2849
|
L: 51,
|
|
2763
2850
|
S: this,
|
|
@@ -2852,7 +2939,7 @@ var WebRTCTransportProxy = class {
|
|
|
2852
2939
|
this._closed = true;
|
|
2853
2940
|
}
|
|
2854
2941
|
};
|
|
2855
|
-
var
|
|
2942
|
+
var SimplePeerTransportProxyFactory = class {
|
|
2856
2943
|
constructor() {
|
|
2857
2944
|
this._connections = /* @__PURE__ */ new Set();
|
|
2858
2945
|
}
|
|
@@ -2868,16 +2955,16 @@ var WebRTCTransportProxyFactory = class {
|
|
|
2868
2955
|
return this;
|
|
2869
2956
|
}
|
|
2870
2957
|
createTransport(options) {
|
|
2871
|
-
invariant13(this._bridgeService, "
|
|
2958
|
+
invariant13(this._bridgeService, "SimplePeerTransportProxyFactory is not ready to open connections", {
|
|
2872
2959
|
F: __dxlog_file14,
|
|
2873
2960
|
L: 163,
|
|
2874
2961
|
S: this,
|
|
2875
2962
|
A: [
|
|
2876
2963
|
"this._bridgeService",
|
|
2877
|
-
"'
|
|
2964
|
+
"'SimplePeerTransportProxyFactory is not ready to open connections'"
|
|
2878
2965
|
]
|
|
2879
2966
|
});
|
|
2880
|
-
const transport = new
|
|
2967
|
+
const transport = new SimplePeerTransportProxy({
|
|
2881
2968
|
...options,
|
|
2882
2969
|
bridgeService: this._bridgeService
|
|
2883
2970
|
});
|
|
@@ -2887,6 +2974,345 @@ var WebRTCTransportProxyFactory = class {
|
|
|
2887
2974
|
}
|
|
2888
2975
|
};
|
|
2889
2976
|
|
|
2977
|
+
// packages/core/mesh/network-manager/src/transport/libdatachannel-transport.ts
|
|
2978
|
+
import { Duplex as Duplex2 } from "stream";
|
|
2979
|
+
import { Event as Event10, Trigger as Trigger2, synchronized as synchronized4 } from "@dxos/async";
|
|
2980
|
+
import { ErrorStream as ErrorStream6 } from "@dxos/debug";
|
|
2981
|
+
import { log as log14 } from "@dxos/log";
|
|
2982
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
2983
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2984
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2985
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2986
|
+
else
|
|
2987
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
2988
|
+
if (d = decorators[i])
|
|
2989
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2990
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2991
|
+
}
|
|
2992
|
+
var __dxlog_file15 = "/mnt/ramdisk/work/packages/core/mesh/network-manager/src/transport/libdatachannel-transport.ts";
|
|
2993
|
+
var DATACHANNEL_LABEL = "dxos.mesh.transport";
|
|
2994
|
+
var MAX_BUFFERED_AMOUNT = 64 * 1024;
|
|
2995
|
+
var MAX_MESSAGE_SIZE = 64 * 1024;
|
|
2996
|
+
var LibDataChannelTransport = class {
|
|
2997
|
+
constructor(params) {
|
|
2998
|
+
this.params = params;
|
|
2999
|
+
this._closed = false;
|
|
3000
|
+
this.closed = new Event10();
|
|
3001
|
+
this._connected = false;
|
|
3002
|
+
this.connected = new Event10();
|
|
3003
|
+
this.errors = new ErrorStream6();
|
|
3004
|
+
this._readyForCandidates = new Trigger2();
|
|
3005
|
+
this._writeCallback = null;
|
|
3006
|
+
this._peer = (async () => {
|
|
3007
|
+
const { RTCPeerConnection: PeerConnection } = await import("./index.browser-O53CPVK3.mjs");
|
|
3008
|
+
if (this._closed) {
|
|
3009
|
+
this.errors.raise(new Error("connection already closed"));
|
|
3010
|
+
}
|
|
3011
|
+
const peer = new PeerConnection(params.webrtcConfig);
|
|
3012
|
+
peer.onicecandidateerror = (event) => {
|
|
3013
|
+
log14.error("peer.onicecandidateerror", {
|
|
3014
|
+
event
|
|
3015
|
+
}, {
|
|
3016
|
+
F: __dxlog_file15,
|
|
3017
|
+
L: 53,
|
|
3018
|
+
S: this,
|
|
3019
|
+
C: (f, a) => f(...a)
|
|
3020
|
+
});
|
|
3021
|
+
};
|
|
3022
|
+
peer.onconnectionstatechange = (event) => {
|
|
3023
|
+
log14.debug("peer.onconnectionstatechange", {
|
|
3024
|
+
event,
|
|
3025
|
+
peerConnectionState: peer.connectionState,
|
|
3026
|
+
transportConnectionState: this._connected
|
|
3027
|
+
}, {
|
|
3028
|
+
F: __dxlog_file15,
|
|
3029
|
+
L: 57,
|
|
3030
|
+
S: this,
|
|
3031
|
+
C: (f, a) => f(...a)
|
|
3032
|
+
});
|
|
3033
|
+
};
|
|
3034
|
+
peer.onicecandidate = async (event) => {
|
|
3035
|
+
log14.debug("peer.onicecandidate", {
|
|
3036
|
+
event
|
|
3037
|
+
}, {
|
|
3038
|
+
F: __dxlog_file15,
|
|
3039
|
+
L: 66,
|
|
3040
|
+
S: this,
|
|
3041
|
+
C: (f, a) => f(...a)
|
|
3042
|
+
});
|
|
3043
|
+
if (event.candidate) {
|
|
3044
|
+
try {
|
|
3045
|
+
await params.sendSignal({
|
|
3046
|
+
payload: {
|
|
3047
|
+
data: {
|
|
3048
|
+
type: "candidate",
|
|
3049
|
+
candidate: {
|
|
3050
|
+
candidate: event.candidate.candidate,
|
|
3051
|
+
// these fields never seem to be not null, but connecting to Chrome doesn't work if they are
|
|
3052
|
+
sdpMLineIndex: event.candidate.sdpMLineIndex ?? 0,
|
|
3053
|
+
sdpMid: event.candidate.sdpMid ?? 0
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
});
|
|
3058
|
+
} catch (err) {
|
|
3059
|
+
log14.warn("signaling errror", {
|
|
3060
|
+
err
|
|
3061
|
+
}, {
|
|
3062
|
+
F: __dxlog_file15,
|
|
3063
|
+
L: 83,
|
|
3064
|
+
S: this,
|
|
3065
|
+
C: (f, a) => f(...a)
|
|
3066
|
+
});
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
};
|
|
3070
|
+
if (params.initiator) {
|
|
3071
|
+
peer.createOffer().then(async (offer) => {
|
|
3072
|
+
if (peer.connectionState !== "connecting") {
|
|
3073
|
+
log14.error("i am initiator but peer not in state connecting", {
|
|
3074
|
+
peer
|
|
3075
|
+
}, {
|
|
3076
|
+
F: __dxlog_file15,
|
|
3077
|
+
L: 92,
|
|
3078
|
+
S: this,
|
|
3079
|
+
C: (f, a) => f(...a)
|
|
3080
|
+
});
|
|
3081
|
+
this.errors.raise(new Error("invalid state: peer is initiator, but other peer not in state connecting"));
|
|
3082
|
+
}
|
|
3083
|
+
log14.debug(`im the initiator, creating offer, peer is in state ${peer.connectionState}`, {
|
|
3084
|
+
offer
|
|
3085
|
+
}, {
|
|
3086
|
+
F: __dxlog_file15,
|
|
3087
|
+
L: 95,
|
|
3088
|
+
S: this,
|
|
3089
|
+
C: (f, a) => f(...a)
|
|
3090
|
+
});
|
|
3091
|
+
await peer.setLocalDescription(offer);
|
|
3092
|
+
await params.sendSignal({
|
|
3093
|
+
payload: {
|
|
3094
|
+
data: {
|
|
3095
|
+
type: offer.type,
|
|
3096
|
+
sdp: offer.sdp
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
});
|
|
3100
|
+
return offer;
|
|
3101
|
+
}).catch((err) => {
|
|
3102
|
+
this.errors.raise(err);
|
|
3103
|
+
});
|
|
3104
|
+
this.handleChannel(peer.createDataChannel(DATACHANNEL_LABEL));
|
|
3105
|
+
log14.debug("created data channel", void 0, {
|
|
3106
|
+
F: __dxlog_file15,
|
|
3107
|
+
L: 104,
|
|
3108
|
+
S: this,
|
|
3109
|
+
C: (f, a) => f(...a)
|
|
3110
|
+
});
|
|
3111
|
+
peer.ondatachannel = (event) => {
|
|
3112
|
+
this.errors.raise(new Error("got ondatachannel when i am the initiator?"));
|
|
3113
|
+
};
|
|
3114
|
+
} else {
|
|
3115
|
+
peer.ondatachannel = (event) => {
|
|
3116
|
+
log14.debug("peer.ondatachannel (non-initiator)", {
|
|
3117
|
+
event
|
|
3118
|
+
}, {
|
|
3119
|
+
F: __dxlog_file15,
|
|
3120
|
+
L: 110,
|
|
3121
|
+
S: this,
|
|
3122
|
+
C: (f, a) => f(...a)
|
|
3123
|
+
});
|
|
3124
|
+
if (event.channel.label !== DATACHANNEL_LABEL) {
|
|
3125
|
+
this.errors.raise(new Error(`unexpected channel label ${event.channel.label}`));
|
|
3126
|
+
}
|
|
3127
|
+
this.handleChannel(event.channel);
|
|
3128
|
+
};
|
|
3129
|
+
}
|
|
3130
|
+
return peer;
|
|
3131
|
+
})();
|
|
3132
|
+
}
|
|
3133
|
+
handleChannel(dataChannel) {
|
|
3134
|
+
this._channel = dataChannel;
|
|
3135
|
+
this._channel.onopen = () => {
|
|
3136
|
+
log14.debug("dataChannel.onopen", void 0, {
|
|
3137
|
+
F: __dxlog_file15,
|
|
3138
|
+
L: 126,
|
|
3139
|
+
S: this,
|
|
3140
|
+
C: (f, a) => f(...a)
|
|
3141
|
+
});
|
|
3142
|
+
const duplex = new Duplex2({
|
|
3143
|
+
read: () => {
|
|
3144
|
+
},
|
|
3145
|
+
write: (chunk, encoding, callback) => {
|
|
3146
|
+
if (chunk.length > MAX_MESSAGE_SIZE) {
|
|
3147
|
+
this.errors.raise(new Error(`message too large: ${chunk.length} > ${MAX_MESSAGE_SIZE}`));
|
|
3148
|
+
}
|
|
3149
|
+
dataChannel.send(chunk);
|
|
3150
|
+
if (this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT) {
|
|
3151
|
+
if (this._writeCallback !== null) {
|
|
3152
|
+
log14.error("consumer trying to write before we're ready for more data", void 0, {
|
|
3153
|
+
F: __dxlog_file15,
|
|
3154
|
+
L: 139,
|
|
3155
|
+
S: this,
|
|
3156
|
+
C: (f, a) => f(...a)
|
|
3157
|
+
});
|
|
3158
|
+
}
|
|
3159
|
+
this._writeCallback = callback;
|
|
3160
|
+
} else {
|
|
3161
|
+
callback();
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3164
|
+
});
|
|
3165
|
+
duplex.pipe(this.params.stream).pipe(duplex);
|
|
3166
|
+
this._stream = duplex;
|
|
3167
|
+
this._connected = true;
|
|
3168
|
+
this.connected.emit();
|
|
3169
|
+
};
|
|
3170
|
+
this._channel.onerror = async (err) => {
|
|
3171
|
+
this.errors.raise(new Error("channel error: " + err.toString()));
|
|
3172
|
+
await this._close();
|
|
3173
|
+
};
|
|
3174
|
+
this._channel.onclose = async (err) => {
|
|
3175
|
+
log14.info("channel onclose", {
|
|
3176
|
+
err
|
|
3177
|
+
}, {
|
|
3178
|
+
F: __dxlog_file15,
|
|
3179
|
+
L: 159,
|
|
3180
|
+
S: this,
|
|
3181
|
+
C: (f, a) => f(...a)
|
|
3182
|
+
});
|
|
3183
|
+
await this._close();
|
|
3184
|
+
};
|
|
3185
|
+
this._channel.onmessage = (event) => {
|
|
3186
|
+
let data = event.data;
|
|
3187
|
+
if (data instanceof ArrayBuffer) {
|
|
3188
|
+
data = Buffer.from(data);
|
|
3189
|
+
}
|
|
3190
|
+
this._stream.push(data);
|
|
3191
|
+
};
|
|
3192
|
+
this._channel.onbufferedamountlow = () => {
|
|
3193
|
+
const cb = this._writeCallback;
|
|
3194
|
+
this._writeCallback = null;
|
|
3195
|
+
cb?.();
|
|
3196
|
+
};
|
|
3197
|
+
}
|
|
3198
|
+
async _close() {
|
|
3199
|
+
if (this._closed) {
|
|
3200
|
+
return;
|
|
3201
|
+
}
|
|
3202
|
+
await this._disconnectStreams();
|
|
3203
|
+
this._closed = true;
|
|
3204
|
+
this.closed.emit();
|
|
3205
|
+
}
|
|
3206
|
+
signal(signal) {
|
|
3207
|
+
this._peer.then(async (peer) => {
|
|
3208
|
+
const data = signal.payload.data;
|
|
3209
|
+
switch (data.type) {
|
|
3210
|
+
case "offer": {
|
|
3211
|
+
if ((await this._peer).connectionState !== "new") {
|
|
3212
|
+
log14.error("received offer but peer not in state new", {
|
|
3213
|
+
peer
|
|
3214
|
+
}, {
|
|
3215
|
+
F: __dxlog_file15,
|
|
3216
|
+
L: 194,
|
|
3217
|
+
S: this,
|
|
3218
|
+
C: (f, a) => f(...a)
|
|
3219
|
+
});
|
|
3220
|
+
this.errors.raise(new Error("invalid signalling state: received offer when peer is not in state new"));
|
|
3221
|
+
break;
|
|
3222
|
+
}
|
|
3223
|
+
try {
|
|
3224
|
+
await peer.setRemoteDescription({
|
|
3225
|
+
type: data.type,
|
|
3226
|
+
sdp: data.sdp
|
|
3227
|
+
});
|
|
3228
|
+
const answer = await peer.createAnswer();
|
|
3229
|
+
await peer.setLocalDescription(answer);
|
|
3230
|
+
await this.params.sendSignal({
|
|
3231
|
+
payload: {
|
|
3232
|
+
data: {
|
|
3233
|
+
type: answer.type,
|
|
3234
|
+
sdp: answer.sdp
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
});
|
|
3238
|
+
this._readyForCandidates.wake();
|
|
3239
|
+
} catch (err) {
|
|
3240
|
+
log14.error("can't handle offer from signalling server", {
|
|
3241
|
+
err
|
|
3242
|
+
}, {
|
|
3243
|
+
F: __dxlog_file15,
|
|
3244
|
+
L: 205,
|
|
3245
|
+
S: this,
|
|
3246
|
+
C: (f, a) => f(...a)
|
|
3247
|
+
});
|
|
3248
|
+
this.errors.raise(new Error("error handling offer"));
|
|
3249
|
+
}
|
|
3250
|
+
break;
|
|
3251
|
+
}
|
|
3252
|
+
case "answer":
|
|
3253
|
+
try {
|
|
3254
|
+
await peer.setRemoteDescription({
|
|
3255
|
+
type: data.type,
|
|
3256
|
+
sdp: data.sdp
|
|
3257
|
+
});
|
|
3258
|
+
this._readyForCandidates.wake();
|
|
3259
|
+
} catch (err) {
|
|
3260
|
+
log14.error("can't handle answer from signalling server", {
|
|
3261
|
+
err
|
|
3262
|
+
}, {
|
|
3263
|
+
F: __dxlog_file15,
|
|
3264
|
+
L: 216,
|
|
3265
|
+
S: this,
|
|
3266
|
+
C: (f, a) => f(...a)
|
|
3267
|
+
});
|
|
3268
|
+
this.errors.raise(new Error("error handling answer"));
|
|
3269
|
+
}
|
|
3270
|
+
break;
|
|
3271
|
+
case "candidate":
|
|
3272
|
+
await this._readyForCandidates.wait();
|
|
3273
|
+
await peer.addIceCandidate({
|
|
3274
|
+
candidate: data.candidate.candidate
|
|
3275
|
+
});
|
|
3276
|
+
break;
|
|
3277
|
+
default:
|
|
3278
|
+
log14.error("unhandled signal type", {
|
|
3279
|
+
type: data.type,
|
|
3280
|
+
signal
|
|
3281
|
+
}, {
|
|
3282
|
+
F: __dxlog_file15,
|
|
3283
|
+
L: 227,
|
|
3284
|
+
S: this,
|
|
3285
|
+
C: (f, a) => f(...a)
|
|
3286
|
+
});
|
|
3287
|
+
this.errors.raise(new Error(`unhandled signal type ${data.type}`));
|
|
3288
|
+
}
|
|
3289
|
+
}).catch((err) => {
|
|
3290
|
+
log14.catch(err, void 0, {
|
|
3291
|
+
F: __dxlog_file15,
|
|
3292
|
+
L: 232,
|
|
3293
|
+
S: this,
|
|
3294
|
+
C: (f, a) => f(...a)
|
|
3295
|
+
});
|
|
3296
|
+
});
|
|
3297
|
+
}
|
|
3298
|
+
// TODO(nf): add classmethod to call node-datachannel.cleanup() when all instances have been destroyed?
|
|
3299
|
+
async destroy() {
|
|
3300
|
+
await this._close();
|
|
3301
|
+
}
|
|
3302
|
+
async _disconnectStreams() {
|
|
3303
|
+
this.params.stream.unpipe?.(this._stream)?.unpipe?.(this.params.stream);
|
|
3304
|
+
}
|
|
3305
|
+
};
|
|
3306
|
+
_ts_decorate5([
|
|
3307
|
+
synchronized4
|
|
3308
|
+
], LibDataChannelTransport.prototype, "_close", null);
|
|
3309
|
+
var createLibDataChannelTransportFactory = (webrtcConfig) => ({
|
|
3310
|
+
createTransport: (params) => new LibDataChannelTransport({
|
|
3311
|
+
...params,
|
|
3312
|
+
webrtcConfig
|
|
3313
|
+
})
|
|
3314
|
+
});
|
|
3315
|
+
|
|
2890
3316
|
// packages/core/mesh/network-manager/src/wire-protocol.ts
|
|
2891
3317
|
import { Teleport } from "@dxos/teleport";
|
|
2892
3318
|
var createTeleportProtocolFactory = (onConnection) => {
|
|
@@ -2894,12 +3320,15 @@ var createTeleportProtocolFactory = (onConnection) => {
|
|
|
2894
3320
|
const teleport = new Teleport(params);
|
|
2895
3321
|
return {
|
|
2896
3322
|
stream: teleport.stream,
|
|
2897
|
-
|
|
3323
|
+
open: async () => {
|
|
2898
3324
|
await teleport.open();
|
|
2899
3325
|
await onConnection(teleport);
|
|
2900
3326
|
},
|
|
2901
|
-
|
|
3327
|
+
close: async () => {
|
|
2902
3328
|
await teleport.close();
|
|
3329
|
+
},
|
|
3330
|
+
abort: async () => {
|
|
3331
|
+
await teleport.abort();
|
|
2903
3332
|
}
|
|
2904
3333
|
};
|
|
2905
3334
|
};
|
|
@@ -2921,11 +3350,14 @@ export {
|
|
|
2921
3350
|
StarTopology,
|
|
2922
3351
|
MemoryTransportFactory,
|
|
2923
3352
|
MemoryTransport,
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
3353
|
+
TransportKind,
|
|
3354
|
+
SimplePeerTransport,
|
|
3355
|
+
createSimplePeerTransportFactory,
|
|
3356
|
+
SimplePeerTransportService,
|
|
3357
|
+
SimplePeerTransportProxy,
|
|
3358
|
+
SimplePeerTransportProxyFactory,
|
|
3359
|
+
LibDataChannelTransport,
|
|
3360
|
+
createLibDataChannelTransportFactory,
|
|
2929
3361
|
createTeleportProtocolFactory
|
|
2930
3362
|
};
|
|
2931
|
-
//# sourceMappingURL=chunk-
|
|
3363
|
+
//# sourceMappingURL=chunk-UKMTAO4L.mjs.map
|