@dxos/network-manager 0.1.53-main.d095ee3 → 0.1.53-main.d2dd40b
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-6CP5XM3F.mjs → chunk-SA5ALANV.mjs} +65 -65
- package/dist/lib/browser/chunk-SA5ALANV.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 +2 -2
- package/dist/lib/node/index.cjs +63 -63
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +56 -54
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/transport/memory-transport.d.ts.map +1 -1
- package/package.json +18 -17
- 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 +2 -2
- package/src/transport/webrtc-transport-service.ts +3 -3
- package/src/transport/webrtc-transport.ts +2 -2
- package/dist/lib/browser/chunk-6CP5XM3F.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";
|
|
@@ -98,7 +98,7 @@ var Connection = class {
|
|
|
98
98
|
*/
|
|
99
99
|
// TODO(burdon): Make async?
|
|
100
100
|
openConnection() {
|
|
101
|
-
|
|
101
|
+
invariant(this._state === ConnectionState.INITIAL, "Invalid state.");
|
|
102
102
|
log.trace("dxos.mesh.connection.open-connection", trace.begin({
|
|
103
103
|
id: this._instanceId
|
|
104
104
|
}), {
|
|
@@ -120,7 +120,7 @@ var Connection = class {
|
|
|
120
120
|
});
|
|
121
121
|
this.close().catch((err) => this.errors.raise(err));
|
|
122
122
|
});
|
|
123
|
-
|
|
123
|
+
invariant(!this._transport);
|
|
124
124
|
this._transport = this._transportFactory.createTransport({
|
|
125
125
|
initiator: this.initiator,
|
|
126
126
|
stream: this._protocol.stream,
|
|
@@ -242,7 +242,7 @@ var Connection = class {
|
|
|
242
242
|
*/
|
|
243
243
|
async signal(msg) {
|
|
244
244
|
var _a, _b, _c;
|
|
245
|
-
|
|
245
|
+
invariant(msg.sessionId);
|
|
246
246
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
247
247
|
log("dropping signal for incorrect session id", {}, {
|
|
248
248
|
file: "connection.ts",
|
|
@@ -252,9 +252,9 @@ var Connection = class {
|
|
|
252
252
|
});
|
|
253
253
|
return;
|
|
254
254
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
invariant(msg.data.signal || msg.data.signalBatch);
|
|
256
|
+
invariant((_a = msg.author) == null ? void 0 : _a.equals(this.remoteId));
|
|
257
|
+
invariant((_b = msg.recipient) == null ? void 0 : _b.equals(this.ownId));
|
|
258
258
|
const signals = msg.data.signalBatch ? (_c = msg.data.signalBatch.signals) != null ? _c : [] : [
|
|
259
259
|
msg.data.signal
|
|
260
260
|
];
|
|
@@ -275,7 +275,7 @@ var Connection = class {
|
|
|
275
275
|
});
|
|
276
276
|
this._incomingSignalBuffer.push(signal);
|
|
277
277
|
} else {
|
|
278
|
-
|
|
278
|
+
invariant(this._transport, "Connection not ready to accept signals.");
|
|
279
279
|
log("received signal", {
|
|
280
280
|
peerId: this.ownId,
|
|
281
281
|
remoteId: this.remoteId,
|
|
@@ -301,7 +301,7 @@ var Connection = class {
|
|
|
301
301
|
scope: this,
|
|
302
302
|
callSite: (f, a) => f(...a)
|
|
303
303
|
});
|
|
304
|
-
|
|
304
|
+
invariant(state !== this._state, "Already in this state.");
|
|
305
305
|
this._state = state;
|
|
306
306
|
this.stateChanged.emit(state);
|
|
307
307
|
}
|
|
@@ -311,7 +311,7 @@ __decorate([
|
|
|
311
311
|
], Connection.prototype, "close", null);
|
|
312
312
|
|
|
313
313
|
// packages/core/mesh/network-manager/src/signal/swarm-messenger.ts
|
|
314
|
-
import
|
|
314
|
+
import invariant2 from "tiny-invariant";
|
|
315
315
|
import { Context as Context2 } from "@dxos/context";
|
|
316
316
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
317
317
|
import { log as log2 } from "@dxos/log";
|
|
@@ -378,7 +378,7 @@ var SwarmMessenger = class {
|
|
|
378
378
|
}
|
|
379
379
|
async signal(message) {
|
|
380
380
|
var _a, _b;
|
|
381
|
-
|
|
381
|
+
invariant2(((_a = message.data) == null ? void 0 : _a.signal) || ((_b = message.data) == null ? void 0 : _b.signalBatch), "Invalid message");
|
|
382
382
|
await this._sendReliableMessage({
|
|
383
383
|
author: message.author,
|
|
384
384
|
recipient: message.recipient,
|
|
@@ -429,11 +429,11 @@ var SwarmMessenger = class {
|
|
|
429
429
|
}
|
|
430
430
|
async _resolveAnswers(message) {
|
|
431
431
|
var _a, _b, _c;
|
|
432
|
-
|
|
432
|
+
invariant2((_b = (_a = message.data) == null ? void 0 : _a.answer) == null ? void 0 : _b.offerMessageId, "No offerMessageId");
|
|
433
433
|
const offerRecord = this._offerRecords.get(message.data.answer.offerMessageId);
|
|
434
434
|
if (offerRecord) {
|
|
435
435
|
this._offerRecords.delete(message.data.answer.offerMessageId);
|
|
436
|
-
|
|
436
|
+
invariant2((_c = message.data) == null ? void 0 : _c.answer, "No answer");
|
|
437
437
|
log2("resolving", {
|
|
438
438
|
answer: message.data.answer
|
|
439
439
|
}, {
|
|
@@ -446,7 +446,7 @@ var SwarmMessenger = class {
|
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
448
|
async _handleOffer({ author, recipient, message }) {
|
|
449
|
-
|
|
449
|
+
invariant2(message.data.offer, "No offer");
|
|
450
450
|
const offerMessage = {
|
|
451
451
|
author,
|
|
452
452
|
recipient,
|
|
@@ -481,8 +481,8 @@ var SwarmMessenger = class {
|
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
483
|
async _handleSignal({ author, recipient, message }) {
|
|
484
|
-
|
|
485
|
-
|
|
484
|
+
invariant2(message.messageId);
|
|
485
|
+
invariant2(message.data.signal || message.data.signalBatch, "Invalid message");
|
|
486
486
|
const signalMessage = {
|
|
487
487
|
author,
|
|
488
488
|
recipient,
|
|
@@ -497,7 +497,7 @@ var SwarmMessenger = class {
|
|
|
497
497
|
};
|
|
498
498
|
|
|
499
499
|
// packages/core/mesh/network-manager/src/swarm/swarm.ts
|
|
500
|
-
import
|
|
500
|
+
import invariant4 from "tiny-invariant";
|
|
501
501
|
import { Event as Event2, scheduleTask as scheduleTask2, sleep as sleep2, synchronized as synchronized3 } from "@dxos/async";
|
|
502
502
|
import { Context as Context4 } from "@dxos/context";
|
|
503
503
|
import { ErrorStream as ErrorStream2 } from "@dxos/debug";
|
|
@@ -507,7 +507,7 @@ import { trace as trace2 } from "@dxos/protocols";
|
|
|
507
507
|
import { ComplexMap as ComplexMap2, isNotNullOrUndefined } from "@dxos/util";
|
|
508
508
|
|
|
509
509
|
// packages/core/mesh/network-manager/src/swarm/peer.ts
|
|
510
|
-
import
|
|
510
|
+
import invariant3 from "tiny-invariant";
|
|
511
511
|
import { scheduleTask, synchronized as synchronized2 } from "@dxos/async";
|
|
512
512
|
import { Context as Context3 } from "@dxos/context";
|
|
513
513
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
@@ -566,7 +566,7 @@ var Peer = class {
|
|
|
566
566
|
}
|
|
567
567
|
if (await this._callbacks.onOffer(remoteId)) {
|
|
568
568
|
if (!this.connection) {
|
|
569
|
-
|
|
569
|
+
invariant3(message.sessionId);
|
|
570
570
|
const connection = this._createConnection(false, message.sessionId);
|
|
571
571
|
try {
|
|
572
572
|
connection.openConnection();
|
|
@@ -597,8 +597,8 @@ var Peer = class {
|
|
|
597
597
|
* Initiate a connection to the remote peer.
|
|
598
598
|
*/
|
|
599
599
|
async initiateConnection() {
|
|
600
|
-
|
|
601
|
-
|
|
600
|
+
invariant3(!this.initiating, "Initiation in progress.");
|
|
601
|
+
invariant3(!this.connection, "Already connected.");
|
|
602
602
|
const sessionId = PublicKey3.random();
|
|
603
603
|
log3("initiating...", {
|
|
604
604
|
id: this.id,
|
|
@@ -685,7 +685,7 @@ var Peer = class {
|
|
|
685
685
|
scope: this,
|
|
686
686
|
callSite: (f, a) => f(...a)
|
|
687
687
|
});
|
|
688
|
-
|
|
688
|
+
invariant3(!this.connection, "Already connected.");
|
|
689
689
|
const connection = new Connection(
|
|
690
690
|
this.topic,
|
|
691
691
|
this.localPeerId,
|
|
@@ -725,7 +725,7 @@ var Peer = class {
|
|
|
725
725
|
scope: this,
|
|
726
726
|
callSite: (f, a) => f(...a)
|
|
727
727
|
});
|
|
728
|
-
|
|
728
|
+
invariant3(this.connection === connection, "Connection mismatch (race condition).");
|
|
729
729
|
if (this._lastConnectionTime && this._lastConnectionTime + CONNECTION_COUNTS_STABLE_AFTER < Date.now()) {
|
|
730
730
|
this._availableAfter = 0;
|
|
731
731
|
} else {
|
|
@@ -914,7 +914,7 @@ var Swarm = class {
|
|
|
914
914
|
return this._topic;
|
|
915
915
|
}
|
|
916
916
|
async open() {
|
|
917
|
-
|
|
917
|
+
invariant4(!this._listeningHandle);
|
|
918
918
|
this._listeningHandle = await this._messenger.listen({
|
|
919
919
|
peerId: this._ownPeerId,
|
|
920
920
|
payloadType: "dxos.mesh.swarm.SwarmMessage",
|
|
@@ -951,7 +951,7 @@ var Swarm = class {
|
|
|
951
951
|
});
|
|
952
952
|
}
|
|
953
953
|
async setTopology(topology) {
|
|
954
|
-
|
|
954
|
+
invariant4(!this._ctx.disposed, "Swarm is offline");
|
|
955
955
|
if (topology === this._topology) {
|
|
956
956
|
return;
|
|
957
957
|
}
|
|
@@ -1039,7 +1039,7 @@ var Swarm = class {
|
|
|
1039
1039
|
accept: false
|
|
1040
1040
|
};
|
|
1041
1041
|
}
|
|
1042
|
-
|
|
1042
|
+
invariant4(message.author);
|
|
1043
1043
|
if (!((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId))) {
|
|
1044
1044
|
log4("rejecting offer with incorrect peerId", {
|
|
1045
1045
|
message
|
|
@@ -1090,9 +1090,9 @@ var Swarm = class {
|
|
|
1090
1090
|
});
|
|
1091
1091
|
return;
|
|
1092
1092
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1093
|
+
invariant4((_a = message.recipient) == null ? void 0 : _a.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`);
|
|
1094
|
+
invariant4((_b = message.topic) == null ? void 0 : _b.equals(this._topic));
|
|
1095
|
+
invariant4(message.author);
|
|
1096
1096
|
const peer = this._getOrCreatePeer(message.author);
|
|
1097
1097
|
await peer.onSignal(message);
|
|
1098
1098
|
}
|
|
@@ -1144,7 +1144,7 @@ var Swarm = class {
|
|
|
1144
1144
|
return peer;
|
|
1145
1145
|
}
|
|
1146
1146
|
async _destroyPeer(peerId) {
|
|
1147
|
-
|
|
1147
|
+
invariant4(this._peers.has(peerId));
|
|
1148
1148
|
await this._peers.get(peerId).destroy();
|
|
1149
1149
|
this._peers.delete(peerId);
|
|
1150
1150
|
}
|
|
@@ -1399,7 +1399,7 @@ var ConnectionLog = class {
|
|
|
1399
1399
|
};
|
|
1400
1400
|
|
|
1401
1401
|
// packages/core/mesh/network-manager/src/network-manager.ts
|
|
1402
|
-
import
|
|
1402
|
+
import invariant5 from "tiny-invariant";
|
|
1403
1403
|
import { Event as Event5 } from "@dxos/async";
|
|
1404
1404
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1405
1405
|
import { log as log6 } from "@dxos/log";
|
|
@@ -1488,10 +1488,10 @@ var NetworkManager = class {
|
|
|
1488
1488
|
*/
|
|
1489
1489
|
async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
|
|
1490
1490
|
var _a;
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1491
|
+
invariant5(PublicKey7.isPublicKey(topic));
|
|
1492
|
+
invariant5(PublicKey7.isPublicKey(peerId));
|
|
1493
|
+
invariant5(topology);
|
|
1494
|
+
invariant5(typeof protocol === "function");
|
|
1495
1495
|
if (this._swarms.has(topic)) {
|
|
1496
1496
|
throw new Error(`Already connected to swarm: ${PublicKey7.from(topic)}`);
|
|
1497
1497
|
}
|
|
@@ -1610,17 +1610,17 @@ var NetworkManager = class {
|
|
|
1610
1610
|
};
|
|
1611
1611
|
|
|
1612
1612
|
// packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
|
|
1613
|
-
import
|
|
1613
|
+
import invariant6 from "tiny-invariant";
|
|
1614
1614
|
var FullyConnectedTopology = class {
|
|
1615
1615
|
toString() {
|
|
1616
1616
|
return "FullyConnectedTopology";
|
|
1617
1617
|
}
|
|
1618
1618
|
init(controller) {
|
|
1619
|
-
|
|
1619
|
+
invariant6(!this._controller, "Already initialized");
|
|
1620
1620
|
this._controller = controller;
|
|
1621
1621
|
}
|
|
1622
1622
|
update() {
|
|
1623
|
-
|
|
1623
|
+
invariant6(this._controller, "Not initialized");
|
|
1624
1624
|
const { candidates: discovered } = this._controller.getState();
|
|
1625
1625
|
for (const peer of discovered) {
|
|
1626
1626
|
this._controller.connect(peer);
|
|
@@ -1634,7 +1634,7 @@ var FullyConnectedTopology = class {
|
|
|
1634
1634
|
};
|
|
1635
1635
|
|
|
1636
1636
|
// packages/core/mesh/network-manager/src/topology/mmst-topology.ts
|
|
1637
|
-
import
|
|
1637
|
+
import invariant7 from "tiny-invariant";
|
|
1638
1638
|
import distance from "xor-distance";
|
|
1639
1639
|
import { log as log7 } from "@dxos/log";
|
|
1640
1640
|
var MMSTTopology = class {
|
|
@@ -1645,11 +1645,11 @@ var MMSTTopology = class {
|
|
|
1645
1645
|
this._sampleSize = sampleSize;
|
|
1646
1646
|
}
|
|
1647
1647
|
init(controller) {
|
|
1648
|
-
|
|
1648
|
+
invariant7(!this._controller, "Already initialized");
|
|
1649
1649
|
this._controller = controller;
|
|
1650
1650
|
}
|
|
1651
1651
|
update() {
|
|
1652
|
-
|
|
1652
|
+
invariant7(this._controller, "Not initialized");
|
|
1653
1653
|
const { connected, candidates } = this._controller.getState();
|
|
1654
1654
|
if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
|
|
1655
1655
|
log7("Running the algorithm.", {}, {
|
|
@@ -1663,7 +1663,7 @@ var MMSTTopology = class {
|
|
|
1663
1663
|
}
|
|
1664
1664
|
}
|
|
1665
1665
|
async onOffer(peer) {
|
|
1666
|
-
|
|
1666
|
+
invariant7(this._controller, "Not initialized");
|
|
1667
1667
|
const { connected } = this._controller.getState();
|
|
1668
1668
|
const accept = connected.length < this._maxPeers;
|
|
1669
1669
|
log7(`Offer ${peer} accept=${accept}`, {}, {
|
|
@@ -1677,7 +1677,7 @@ var MMSTTopology = class {
|
|
|
1677
1677
|
async destroy() {
|
|
1678
1678
|
}
|
|
1679
1679
|
_runAlgorithm() {
|
|
1680
|
-
|
|
1680
|
+
invariant7(this._controller, "Not initialized");
|
|
1681
1681
|
const { connected, candidates, ownPeerId } = this._controller.getState();
|
|
1682
1682
|
if (connected.length > this._maxPeers) {
|
|
1683
1683
|
const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
|
|
@@ -1711,7 +1711,7 @@ var MMSTTopology = class {
|
|
|
1711
1711
|
var sortByXorDistance = (keys, reference) => keys.sort((a, b) => distance.gt(distance(a.asBuffer(), reference.asBuffer()), distance(b.asBuffer(), reference.asBuffer())));
|
|
1712
1712
|
|
|
1713
1713
|
// packages/core/mesh/network-manager/src/topology/star-topology.ts
|
|
1714
|
-
import
|
|
1714
|
+
import invariant8 from "tiny-invariant";
|
|
1715
1715
|
import { log as log8 } from "@dxos/log";
|
|
1716
1716
|
var StarTopology = class {
|
|
1717
1717
|
// prettier-ignore
|
|
@@ -1722,11 +1722,11 @@ var StarTopology = class {
|
|
|
1722
1722
|
return `StarTopology(${this._centralPeer.truncate()})`;
|
|
1723
1723
|
}
|
|
1724
1724
|
init(controller) {
|
|
1725
|
-
|
|
1725
|
+
invariant8(!this._controller, "Already initialized.");
|
|
1726
1726
|
this._controller = controller;
|
|
1727
1727
|
}
|
|
1728
1728
|
update() {
|
|
1729
|
-
|
|
1729
|
+
invariant8(this._controller, "Not initialized.");
|
|
1730
1730
|
const { candidates, connected, ownPeerId } = this._controller.getState();
|
|
1731
1731
|
if (!ownPeerId.equals(this._centralPeer)) {
|
|
1732
1732
|
log8("leaf peer dropping all connections apart from central peer.", {}, {
|
|
@@ -1764,7 +1764,7 @@ var StarTopology = class {
|
|
|
1764
1764
|
}
|
|
1765
1765
|
}
|
|
1766
1766
|
async onOffer(peer) {
|
|
1767
|
-
|
|
1767
|
+
invariant8(this._controller, "Not initialized.");
|
|
1768
1768
|
const { ownPeerId } = this._controller.getState();
|
|
1769
1769
|
log8("offer", {
|
|
1770
1770
|
peer,
|
|
@@ -1783,8 +1783,8 @@ var StarTopology = class {
|
|
|
1783
1783
|
};
|
|
1784
1784
|
|
|
1785
1785
|
// packages/core/mesh/network-manager/src/transport/memory-transport.ts
|
|
1786
|
-
import assert9 from "@dxos/node-std/assert";
|
|
1787
1786
|
import { Transform } from "@dxos/node-std/stream";
|
|
1787
|
+
import invariant9 from "tiny-invariant";
|
|
1788
1788
|
import { Event as Event6, Trigger } from "@dxos/async";
|
|
1789
1789
|
import { ErrorStream as ErrorStream3 } from "@dxos/debug";
|
|
1790
1790
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
@@ -1830,7 +1830,7 @@ var _MemoryTransport = class {
|
|
|
1830
1830
|
scope: this,
|
|
1831
1831
|
callSite: (f, a) => f(...a)
|
|
1832
1832
|
});
|
|
1833
|
-
|
|
1833
|
+
invariant9(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection");
|
|
1834
1834
|
_MemoryTransport._connections.set(this._instanceId, this);
|
|
1835
1835
|
if (this.options.initiator) {
|
|
1836
1836
|
setTimeout(async () => {
|
|
@@ -1864,12 +1864,12 @@ var _MemoryTransport = class {
|
|
|
1864
1864
|
this.closed.emit();
|
|
1865
1865
|
return;
|
|
1866
1866
|
}
|
|
1867
|
-
|
|
1867
|
+
invariant9(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`);
|
|
1868
1868
|
this._remoteConnection._remoteConnection = this;
|
|
1869
1869
|
this._remoteConnection._remoteInstanceId = this._instanceId;
|
|
1870
1870
|
log9("connected", {}, {
|
|
1871
1871
|
file: "memory-transport.ts",
|
|
1872
|
-
line:
|
|
1872
|
+
line: 103,
|
|
1873
1873
|
scope: this,
|
|
1874
1874
|
callSite: (f, a) => f(...a)
|
|
1875
1875
|
});
|
|
@@ -1887,7 +1887,7 @@ var _MemoryTransport = class {
|
|
|
1887
1887
|
async destroy() {
|
|
1888
1888
|
log9("closing", {}, {
|
|
1889
1889
|
file: "memory-transport.ts",
|
|
1890
|
-
line:
|
|
1890
|
+
line: 124,
|
|
1891
1891
|
scope: this,
|
|
1892
1892
|
callSite: (f, a) => f(...a)
|
|
1893
1893
|
});
|
|
@@ -1896,7 +1896,7 @@ var _MemoryTransport = class {
|
|
|
1896
1896
|
if (this._remoteConnection) {
|
|
1897
1897
|
log9("closing", {}, {
|
|
1898
1898
|
file: "memory-transport.ts",
|
|
1899
|
-
line:
|
|
1899
|
+
line: 129,
|
|
1900
1900
|
scope: this,
|
|
1901
1901
|
callSite: (f, a) => f(...a)
|
|
1902
1902
|
});
|
|
@@ -1909,7 +1909,7 @@ var _MemoryTransport = class {
|
|
|
1909
1909
|
this._remoteConnection = void 0;
|
|
1910
1910
|
log9("closed", {}, {
|
|
1911
1911
|
file: "memory-transport.ts",
|
|
1912
|
-
line:
|
|
1912
|
+
line: 147,
|
|
1913
1913
|
scope: this,
|
|
1914
1914
|
callSite: (f, a) => f(...a)
|
|
1915
1915
|
});
|
|
@@ -1917,7 +1917,7 @@ var _MemoryTransport = class {
|
|
|
1917
1917
|
this.closed.emit();
|
|
1918
1918
|
log9("closed", {}, {
|
|
1919
1919
|
file: "memory-transport.ts",
|
|
1920
|
-
line:
|
|
1920
|
+
line: 151,
|
|
1921
1921
|
scope: this,
|
|
1922
1922
|
callSite: (f, a) => f(...a)
|
|
1923
1923
|
});
|
|
@@ -1927,7 +1927,7 @@ var _MemoryTransport = class {
|
|
|
1927
1927
|
payload
|
|
1928
1928
|
}, {
|
|
1929
1929
|
file: "memory-transport.ts",
|
|
1930
|
-
line:
|
|
1930
|
+
line: 155,
|
|
1931
1931
|
scope: this,
|
|
1932
1932
|
callSite: (f, a) => f(...a)
|
|
1933
1933
|
});
|
|
@@ -1952,8 +1952,8 @@ __decorate4([
|
|
|
1952
1952
|
], MemoryTransport.prototype, "_remoteInstanceId", void 0);
|
|
1953
1953
|
|
|
1954
1954
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport.ts
|
|
1955
|
-
import assert10 from "@dxos/node-std/assert";
|
|
1956
1955
|
import SimplePeerConstructor from "simple-peer";
|
|
1956
|
+
import invariant10 from "tiny-invariant";
|
|
1957
1957
|
import { Event as Event7 } from "@dxos/async";
|
|
1958
1958
|
import { ErrorStream as ErrorStream4, raise as raise2 } from "@dxos/debug";
|
|
1959
1959
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
@@ -2081,7 +2081,7 @@ var WebRTCTransport = class {
|
|
|
2081
2081
|
if (this._closed) {
|
|
2082
2082
|
return;
|
|
2083
2083
|
}
|
|
2084
|
-
|
|
2084
|
+
invariant10(signal.payload.data, "Signal message must contain signal data.");
|
|
2085
2085
|
this._peer.signal(signal.payload.data);
|
|
2086
2086
|
}
|
|
2087
2087
|
async _disconnectStreams() {
|
|
@@ -2097,8 +2097,8 @@ var createWebRTCTransportFactory = (webrtcConfig) => ({
|
|
|
2097
2097
|
});
|
|
2098
2098
|
|
|
2099
2099
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport-service.ts
|
|
2100
|
-
import assert11 from "@dxos/node-std/assert";
|
|
2101
2100
|
import { Duplex } from "@dxos/node-std/stream";
|
|
2101
|
+
import invariant11 from "tiny-invariant";
|
|
2102
2102
|
import { Stream } from "@dxos/codec-protobuf";
|
|
2103
2103
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
2104
2104
|
import { log as log11 } from "@dxos/log";
|
|
@@ -2174,11 +2174,11 @@ var WebRTCTransportService = class {
|
|
|
2174
2174
|
return rpcStream;
|
|
2175
2175
|
}
|
|
2176
2176
|
async sendSignal({ proxyId, signal }) {
|
|
2177
|
-
|
|
2177
|
+
invariant11(this.transports.has(proxyId));
|
|
2178
2178
|
await this.transports.get(proxyId).transport.signal(signal);
|
|
2179
2179
|
}
|
|
2180
2180
|
async sendData({ proxyId, payload }) {
|
|
2181
|
-
|
|
2181
|
+
invariant11(this.transports.has(proxyId));
|
|
2182
2182
|
await this.transports.get(proxyId).stream.push(payload);
|
|
2183
2183
|
}
|
|
2184
2184
|
async close({ proxyId }) {
|
|
@@ -2196,7 +2196,7 @@ var WebRTCTransportService = class {
|
|
|
2196
2196
|
};
|
|
2197
2197
|
|
|
2198
2198
|
// packages/core/mesh/network-manager/src/transport/webrtc-transport-proxy.ts
|
|
2199
|
-
import
|
|
2199
|
+
import invariant12 from "tiny-invariant";
|
|
2200
2200
|
import { Event as Event8 } from "@dxos/async";
|
|
2201
2201
|
import { Context as Context5 } from "@dxos/context";
|
|
2202
2202
|
import { ErrorStream as ErrorStream5 } from "@dxos/debug";
|
|
@@ -2335,7 +2335,7 @@ var WebRTCTransportProxyFactory = class {
|
|
|
2335
2335
|
return this;
|
|
2336
2336
|
}
|
|
2337
2337
|
createTransport(options) {
|
|
2338
|
-
|
|
2338
|
+
invariant12(this._bridgeService, "WebRTCTransportProxyFactory is not ready to open connections");
|
|
2339
2339
|
const transport = new WebRTCTransportProxy({
|
|
2340
2340
|
...options,
|
|
2341
2341
|
bridgeService: this._bridgeService
|
|
@@ -2385,4 +2385,4 @@ export {
|
|
|
2385
2385
|
WebRTCTransportProxyFactory,
|
|
2386
2386
|
createTeleportProtocolFactory
|
|
2387
2387
|
};
|
|
2388
|
-
//# sourceMappingURL=chunk-
|
|
2388
|
+
//# sourceMappingURL=chunk-SA5ALANV.mjs.map
|