@libp2p/webrtc 4.1.9 → 4.1.10-2bbaf4361
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -4
- package/dist/index.min.js +5 -6
- package/dist/src/error.d.ts +5 -25
- package/dist/src/error.d.ts.map +1 -1
- package/dist/src/error.js +18 -54
- package/dist/src/error.js.map +1 -1
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js +4 -4
- package/dist/src/pb/message.d.ts +2 -2
- package/dist/src/pb/message.d.ts.map +1 -1
- package/dist/src/pb/message.js +10 -7
- package/dist/src/pb/message.js.map +1 -1
- package/dist/src/private-to-private/initiate-connection.d.ts.map +1 -1
- package/dist/src/private-to-private/initiate-connection.js +10 -8
- package/dist/src/private-to-private/initiate-connection.js.map +1 -1
- package/dist/src/private-to-private/pb/message.d.ts +2 -2
- package/dist/src/private-to-private/pb/message.d.ts.map +1 -1
- package/dist/src/private-to-private/pb/message.js +10 -7
- package/dist/src/private-to-private/pb/message.js.map +1 -1
- package/dist/src/private-to-private/signaling-stream-handler.d.ts.map +1 -1
- package/dist/src/private-to-private/signaling-stream-handler.js +7 -6
- package/dist/src/private-to-private/signaling-stream-handler.js.map +1 -1
- package/dist/src/private-to-private/transport.d.ts.map +1 -1
- package/dist/src/private-to-private/transport.js +6 -7
- package/dist/src/private-to-private/transport.js.map +1 -1
- package/dist/src/private-to-private/util.js +3 -3
- package/dist/src/private-to-private/util.js.map +1 -1
- package/dist/src/private-to-public/sdp.d.ts.map +1 -1
- package/dist/src/private-to-public/sdp.js +7 -6
- package/dist/src/private-to-public/sdp.js.map +1 -1
- package/dist/src/private-to-public/transport.d.ts +2 -1
- package/dist/src/private-to-public/transport.d.ts.map +1 -1
- package/dist/src/private-to-public/transport.js +12 -10
- package/dist/src/private-to-public/transport.js.map +1 -1
- package/dist/src/stream.js +6 -6
- package/dist/src/stream.js.map +1 -1
- package/package.json +13 -13
- package/src/error.ts +18 -64
- package/src/index.ts +4 -4
- package/src/pb/message.ts +10 -8
- package/src/private-to-private/initiate-connection.ts +11 -8
- package/src/private-to-private/pb/message.ts +10 -8
- package/src/private-to-private/signaling-stream-handler.ts +8 -6
- package/src/private-to-private/transport.ts +6 -7
- package/src/private-to-private/util.ts +3 -3
- package/src/private-to-public/sdp.ts +7 -6
- package/src/private-to-public/transport.ts +14 -12
- package/src/stream.ts +6 -6
- package/dist/typedoc-urls.json +0 -8
package/src/stream.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import {
|
1
|
+
import { StreamStateError, TimeoutError } from '@libp2p/interface'
|
2
2
|
import { AbstractStream, type AbstractStreamInit } from '@libp2p/utils/abstract-stream'
|
3
3
|
import * as lengthPrefixed from 'it-length-prefixed'
|
4
4
|
import { type Pushable, pushable } from 'it-pushable'
|
5
5
|
import pDefer from 'p-defer'
|
6
|
-
import { pEvent
|
6
|
+
import { pEvent } from 'p-event'
|
7
7
|
import pTimeout from 'p-timeout'
|
8
8
|
import { raceSignal } from 'race-signal'
|
9
9
|
import { encodingLength } from 'uint8-varint'
|
@@ -174,7 +174,7 @@ export class WebRTCStream extends AbstractStream {
|
|
174
174
|
|
175
175
|
default:
|
176
176
|
this.log.error('unknown datachannel state %s', this.channel.readyState)
|
177
|
-
throw new
|
177
|
+
throw new StreamStateError('Unknown datachannel state')
|
178
178
|
}
|
179
179
|
|
180
180
|
// handle RTCDataChannel events
|
@@ -236,7 +236,7 @@ export class WebRTCStream extends AbstractStream {
|
|
236
236
|
await pEvent(this.channel, 'bufferedamountlow', { timeout: this.bufferedAmountLowEventTimeout })
|
237
237
|
} catch (err: any) {
|
238
238
|
if (err instanceof TimeoutError) {
|
239
|
-
throw new
|
239
|
+
throw new TimeoutError(`Timed out waiting for DataChannel buffer to clear after ${this.bufferedAmountLowEventTimeout}ms`)
|
240
240
|
}
|
241
241
|
|
242
242
|
throw err
|
@@ -244,7 +244,7 @@ export class WebRTCStream extends AbstractStream {
|
|
244
244
|
}
|
245
245
|
|
246
246
|
if (this.channel.readyState === 'closed' || this.channel.readyState === 'closing') {
|
247
|
-
throw new
|
247
|
+
throw new StreamStateError(`Invalid datachannel state - ${this.channel.readyState}`)
|
248
248
|
}
|
249
249
|
|
250
250
|
if (this.channel.readyState !== 'open') {
|
@@ -285,7 +285,7 @@ export class WebRTCStream extends AbstractStream {
|
|
285
285
|
try {
|
286
286
|
await raceSignal(this.receiveFinAck.promise, options?.signal, {
|
287
287
|
errorMessage: 'sending close-write was aborted before FIN_ACK was received',
|
288
|
-
|
288
|
+
errorName: 'FinAckNotReceivedError'
|
289
289
|
})
|
290
290
|
} catch (err) {
|
291
291
|
this.log.error('failed to await FIN_ACK', err)
|
package/dist/typedoc-urls.json
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"DataChannelOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.DataChannelOptions.html",
|
3
|
-
".:DataChannelOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.DataChannelOptions.html",
|
4
|
-
"webRTC": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTC.html",
|
5
|
-
".:webRTC": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTC.html",
|
6
|
-
"webRTCDirect": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTCDirect.html",
|
7
|
-
".:webRTCDirect": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTCDirect.html"
|
8
|
-
}
|