@libp2p/webtransport 3.1.10 → 4.0.0

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/src/stream.ts CHANGED
@@ -1,12 +1,9 @@
1
- import { logger } from '@libp2p/logger'
2
1
  import { Uint8ArrayList } from 'uint8arraylist'
3
- import type { AbortOptions } from '@libp2p/interface'
4
- import type { Direction, Stream } from '@libp2p/interface/connection'
2
+ import type { AbortOptions, ComponentLogger, Direction, Stream } from '@libp2p/interface'
5
3
  import type { Source } from 'it-stream-types'
6
4
 
7
- const log = logger('libp2p:webtransport:stream')
8
-
9
- export async function webtransportBiDiStreamToStream (bidiStream: WebTransportBidirectionalStream, streamId: string, direction: Direction, activeStreams: Stream[], onStreamEnd: undefined | ((s: Stream) => void)): Promise<Stream> {
5
+ export async function webtransportBiDiStreamToStream (bidiStream: WebTransportBidirectionalStream, streamId: string, direction: Direction, activeStreams: Stream[], onStreamEnd: undefined | ((s: Stream) => void), logger: ComponentLogger): Promise<Stream> {
6
+ const log = logger.forComponent(`libp2p:webtransport:stream:${direction}:${streamId}`)
10
7
  const writer = bidiStream.writable.getWriter()
11
8
  const reader = bidiStream.readable.getReader()
12
9
  await writer.ready
@@ -179,7 +176,8 @@ export async function webtransportBiDiStreamToStream (bidiStream: WebTransportBi
179
176
 
180
177
  await stream.closeWrite()
181
178
  }
182
- }
179
+ },
180
+ log
183
181
  }
184
182
 
185
183
  return stream
@@ -1,9 +1,9 @@
1
- import { CodeError } from '@libp2p/interface/errors'
1
+ import { CodeError } from '@libp2p/interface'
2
2
  import { peerIdFromString } from '@libp2p/peer-id'
3
3
  import { type Multiaddr, protocols } from '@multiformats/multiaddr'
4
4
  import { WebTransport } from '@multiformats/multiaddr-matcher'
5
5
  import { bases, digest } from 'multiformats/basics'
6
- import type { PeerId } from '@libp2p/interface/peer-id'
6
+ import type { PeerId } from '@libp2p/interface'
7
7
  import type { MultihashDigest } from 'multiformats/hashes/interface'
8
8
 
9
9
  // @ts-expect-error - Not easy to combine these types.