@dxos/network-manager 0.8.2-main.fbd8ed0 → 0.8.2-staging.4d6ad0f
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-LOUV2QRE.mjs → chunk-LFKR6BAF.mjs} +12 -24
- package/dist/lib/browser/chunk-LFKR6BAF.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 +1 -1
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/transport/tcp/index.mjs.map +2 -2
- package/dist/lib/node/{chunk-NGSQDQ6O.cjs → chunk-2G6RZMS5.cjs} +15 -27
- package/dist/lib/node/chunk-2G6RZMS5.cjs.map +7 -0
- package/dist/lib/node/index.cjs +23 -23
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +14 -14
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node/transport/tcp/index.cjs.map +3 -3
- package/dist/lib/node-esm/{chunk-2TV33CKS.mjs → chunk-QQY4BF6O.mjs} +12 -24
- package/dist/lib/node-esm/chunk-QQY4BF6O.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -1
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/transport/tcp/index.mjs.map +3 -3
- package/dist/types/src/connection-log.d.ts.map +1 -1
- package/dist/types/src/network-manager.d.ts.map +1 -1
- package/dist/types/src/swarm/connection-limiter.d.ts.map +1 -1
- 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/swarm/swarm-mapper.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.map +1 -1
- package/dist/types/src/testing/test-wire-protocol.d.ts.map +1 -1
- package/dist/types/src/topology/fully-connected-topology.d.ts.map +1 -1
- package/dist/types/src/topology/mmst-topology.d.ts.map +1 -1
- package/dist/types/src/topology/star-topology.d.ts.map +1 -1
- package/dist/types/src/transport/memory-transport.d.ts.map +1 -1
- package/dist/types/src/transport/tcp/tcp-transport.browser.d.ts.map +1 -1
- package/dist/types/src/transport/tcp/tcp-transport.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc/rtc-peer-connection.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc/rtc-transport-channel.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc/rtc-transport-proxy.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc/rtc-transport-service.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/connection-log.ts +3 -3
- package/src/network-manager.ts +5 -5
- package/src/swarm/connection-limiter.ts +1 -1
- package/src/swarm/connection.ts +10 -10
- package/src/swarm/peer.ts +5 -5
- package/src/swarm/swarm-mapper.ts +2 -2
- package/src/swarm/swarm.ts +10 -10
- package/src/testing/test-builder.ts +9 -9
- package/src/testing/test-wire-protocol.ts +2 -2
- package/src/topology/fully-connected-topology.ts +1 -1
- package/src/topology/mmst-topology.ts +3 -3
- package/src/topology/star-topology.ts +1 -1
- package/src/transport/memory-transport.ts +10 -5
- package/src/transport/tcp/tcp-transport.browser.ts +3 -3
- package/src/transport/tcp/tcp-transport.ts +4 -4
- package/src/transport/webrtc/rtc-connection-factory.ts +5 -5
- package/src/transport/webrtc/rtc-peer-connection.ts +9 -9
- package/src/transport/webrtc/rtc-transport-channel.ts +6 -6
- package/src/transport/webrtc/rtc-transport-proxy.ts +7 -7
- package/src/transport/webrtc/rtc-transport-service.ts +3 -3
- package/dist/lib/browser/chunk-LOUV2QRE.mjs.map +0 -7
- package/dist/lib/node/chunk-NGSQDQ6O.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-2TV33CKS.mjs.map +0 -7
|
@@ -241,7 +241,7 @@ export class RtcPeerConnection {
|
|
|
241
241
|
this._abortConnection(connection, error);
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
private _abortConnection(connection: RTCPeerConnection, error: Error) {
|
|
244
|
+
private _abortConnection(connection: RTCPeerConnection, error: Error): void {
|
|
245
245
|
if (connection !== this._connection) {
|
|
246
246
|
log.error('attempted to abort an inactive connection', { error });
|
|
247
247
|
this._safeCloseConnection(connection);
|
|
@@ -261,7 +261,7 @@ export class RtcPeerConnection {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
@synchronized
|
|
264
|
-
private async _lockAndCloseConnection() {
|
|
264
|
+
private async _lockAndCloseConnection(): Promise<void> {
|
|
265
265
|
invariant(this._transportChannels.size === 0);
|
|
266
266
|
if (this._connection) {
|
|
267
267
|
this._safeCloseConnection();
|
|
@@ -270,7 +270,7 @@ export class RtcPeerConnection {
|
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
@synchronized
|
|
273
|
-
public async onSignal(signal: Signal) {
|
|
273
|
+
public async onSignal(signal: Signal): Promise<void> {
|
|
274
274
|
const connection = this._connection;
|
|
275
275
|
if (!connection) {
|
|
276
276
|
log.warn('a signal ignored because the connection was closed', { type: signal.payload.data.type });
|
|
@@ -335,7 +335,7 @@ export class RtcPeerConnection {
|
|
|
335
335
|
log('signal processed', { type: data.type });
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
private async _processIceCandidate(connection: RTCPeerConnection, candidate: RTCIceCandidate) {
|
|
338
|
+
private async _processIceCandidate(connection: RTCPeerConnection, candidate: RTCIceCandidate): Promise<void> {
|
|
339
339
|
try {
|
|
340
340
|
// ICE candidates are associated with a session, so we need to wait for the remote description to be set.
|
|
341
341
|
await this._readyForCandidates.wait();
|
|
@@ -348,7 +348,7 @@ export class RtcPeerConnection {
|
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
private _onSessionNegotiated(connection: RTCPeerConnection) {
|
|
351
|
+
private _onSessionNegotiated(connection: RTCPeerConnection): void {
|
|
352
352
|
if (connection === this._connection) {
|
|
353
353
|
log('ready to process ice candidates');
|
|
354
354
|
this._readyForCandidates.wake();
|
|
@@ -357,7 +357,7 @@ export class RtcPeerConnection {
|
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
-
private _onConnectionCallbackAfterClose(callback: string, connection: RTCPeerConnection) {
|
|
360
|
+
private _onConnectionCallbackAfterClose(callback: string, connection: RTCPeerConnection): void {
|
|
361
361
|
log.warn('callback invoked after a connection was destroyed, this is probably a bug', {
|
|
362
362
|
callback,
|
|
363
363
|
state: connection.connectionState,
|
|
@@ -365,7 +365,7 @@ export class RtcPeerConnection {
|
|
|
365
365
|
this._safeCloseConnection(connection);
|
|
366
366
|
}
|
|
367
367
|
|
|
368
|
-
private _safeCloseConnection(connection: RTCPeerConnection | undefined = this._connection) {
|
|
368
|
+
private _safeCloseConnection(connection: RTCPeerConnection | undefined = this._connection): void {
|
|
369
369
|
const resetFields = this._connection && connection === this._connection;
|
|
370
370
|
try {
|
|
371
371
|
connection?.close();
|
|
@@ -397,7 +397,7 @@ export class RtcPeerConnection {
|
|
|
397
397
|
return config;
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
-
private async _sendIceCandidate(candidate: RTCIceCandidate) {
|
|
400
|
+
private async _sendIceCandidate(candidate: RTCIceCandidate): Promise<void> {
|
|
401
401
|
try {
|
|
402
402
|
await this._options.sendSignal({
|
|
403
403
|
payload: {
|
|
@@ -417,7 +417,7 @@ export class RtcPeerConnection {
|
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
-
private async _sendDescription(connection: RTCPeerConnection, description: RTCSessionDescriptionInit) {
|
|
420
|
+
private async _sendDescription(connection: RTCPeerConnection, description: RTCSessionDescriptionInit): Promise<void> {
|
|
421
421
|
if (connection !== this._connection) {
|
|
422
422
|
// Connection was closed while description was being created.
|
|
423
423
|
return;
|
|
@@ -46,13 +46,13 @@ export class RtcTransportChannel extends Resource implements Transport {
|
|
|
46
46
|
return this._isChannelCreationInProgress;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
public onConnectionError(error: Error) {
|
|
49
|
+
public onConnectionError(error: Error): void {
|
|
50
50
|
if (this.isOpen) {
|
|
51
51
|
this.errors.raise(error);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
protected override async _open() {
|
|
55
|
+
protected override async _open(): Promise<void> {
|
|
56
56
|
invariant(!this._isChannelCreationInProgress);
|
|
57
57
|
this._isChannelCreationInProgress = true;
|
|
58
58
|
this._connection
|
|
@@ -81,7 +81,7 @@ export class RtcTransportChannel extends Resource implements Transport {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
protected override async _close() {
|
|
84
|
+
protected override async _close(): Promise<void> {
|
|
85
85
|
if (this._channel) {
|
|
86
86
|
this._safeCloseChannel(this._channel);
|
|
87
87
|
this._channel = undefined;
|
|
@@ -92,7 +92,7 @@ export class RtcTransportChannel extends Resource implements Transport {
|
|
|
92
92
|
log('closed');
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
private _initChannel(channel: RTCDataChannel) {
|
|
95
|
+
private _initChannel(channel: RTCDataChannel): void {
|
|
96
96
|
Object.assign<RTCDataChannel, Partial<RTCDataChannel>>(channel, {
|
|
97
97
|
onopen: () => {
|
|
98
98
|
if (!this.isOpen) {
|
|
@@ -148,7 +148,7 @@ export class RtcTransportChannel extends Resource implements Transport {
|
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
private async _handleChannelWrite(chunk: any, callback: PendingStreamFlushedCallback) {
|
|
151
|
+
private async _handleChannelWrite(chunk: any, callback: PendingStreamFlushedCallback): Promise<void> {
|
|
152
152
|
if (!this._channel) {
|
|
153
153
|
log.warn('writing to a channel after a connection was closed');
|
|
154
154
|
return;
|
|
@@ -179,7 +179,7 @@ export class RtcTransportChannel extends Resource implements Transport {
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
private _safeCloseChannel(channel: RTCDataChannel) {
|
|
182
|
+
private _safeCloseChannel(channel: RTCDataChannel): void {
|
|
183
183
|
try {
|
|
184
184
|
channel.close();
|
|
185
185
|
} catch (error: any) {
|
|
@@ -39,7 +39,7 @@ export class RtcTransportProxy extends Resource implements Transport {
|
|
|
39
39
|
super();
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
protected override async _open() {
|
|
42
|
+
protected override async _open(): Promise<void> {
|
|
43
43
|
let stream: Stream<BridgeEvent>;
|
|
44
44
|
try {
|
|
45
45
|
stream = this._options.bridgeService.open(
|
|
@@ -120,7 +120,7 @@ export class RtcTransportProxy extends Resource implements Transport {
|
|
|
120
120
|
);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
protected override async _close() {
|
|
123
|
+
protected override async _close(): Promise<void> {
|
|
124
124
|
try {
|
|
125
125
|
await this._serviceStream?.close();
|
|
126
126
|
this._serviceStream = undefined;
|
|
@@ -137,7 +137,7 @@ export class RtcTransportProxy extends Resource implements Transport {
|
|
|
137
137
|
this.closed.emit();
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
async onSignal(signal: Signal) {
|
|
140
|
+
async onSignal(signal: Signal): Promise<void> {
|
|
141
141
|
this._options.bridgeService
|
|
142
142
|
.sendSignal({ proxyId: this._proxyId, signal }, { timeout: RPC_TIMEOUT })
|
|
143
143
|
.catch((err) => this._raiseIfOpen(decodeError(err)));
|
|
@@ -161,7 +161,7 @@ export class RtcTransportProxy extends Resource implements Transport {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
private _handleData(dataEvent: BridgeEvent.DataEvent) {
|
|
164
|
+
private _handleData(dataEvent: BridgeEvent.DataEvent): void {
|
|
165
165
|
try {
|
|
166
166
|
// NOTE: This must be a Buffer otherwise hypercore-protocol breaks.
|
|
167
167
|
this._options.stream.write(arrayToBuffer(dataEvent.payload));
|
|
@@ -170,7 +170,7 @@ export class RtcTransportProxy extends Resource implements Transport {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
private async _handleSignal(signalEvent: BridgeEvent.SignalEvent) {
|
|
173
|
+
private async _handleSignal(signalEvent: BridgeEvent.SignalEvent): Promise<void> {
|
|
174
174
|
try {
|
|
175
175
|
await this._options.sendSignal(signalEvent.payload);
|
|
176
176
|
} catch (error) {
|
|
@@ -208,7 +208,7 @@ export class RtcTransportProxy extends Resource implements Transport {
|
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
private _raiseIfOpen(error: any) {
|
|
211
|
+
private _raiseIfOpen(error: any): void {
|
|
212
212
|
if (this.isOpen) {
|
|
213
213
|
this.errors.raise(error);
|
|
214
214
|
} else {
|
|
@@ -219,7 +219,7 @@ export class RtcTransportProxy extends Resource implements Transport {
|
|
|
219
219
|
/**
|
|
220
220
|
* Called when underlying proxy service becomes unavailable.
|
|
221
221
|
*/
|
|
222
|
-
forceClose() {
|
|
222
|
+
forceClose(): void {
|
|
223
223
|
void this._serviceStream?.close();
|
|
224
224
|
this.closed.emit();
|
|
225
225
|
}
|
|
@@ -43,7 +43,7 @@ export class RtcTransportService implements BridgeService {
|
|
|
43
43
|
private readonly _transportFactory: TransportFactory = createRtcTransportFactory(webrtcConfig, iceProvider),
|
|
44
44
|
) {}
|
|
45
45
|
|
|
46
|
-
public hasOpenTransports() {
|
|
46
|
+
public hasOpenTransports(): boolean {
|
|
47
47
|
return this._openTransports.size > 0;
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -151,7 +151,7 @@ export class RtcTransportService implements BridgeService {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
async close({ proxyId }: CloseRequest) {
|
|
154
|
+
async close({ proxyId }: CloseRequest): Promise<void> {
|
|
155
155
|
const transport = this._openTransports.get(proxyId);
|
|
156
156
|
if (!transport) {
|
|
157
157
|
return;
|
|
@@ -161,7 +161,7 @@ export class RtcTransportService implements BridgeService {
|
|
|
161
161
|
await this._safeCloseTransport(transport);
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
private async _safeCloseTransport(transport: TransportState) {
|
|
164
|
+
private async _safeCloseTransport(transport: TransportState): Promise<void> {
|
|
165
165
|
if (this._openTransports.get(transport.proxyId) === transport) {
|
|
166
166
|
this._openTransports.delete(transport.proxyId);
|
|
167
167
|
}
|