@libp2p/utils 3.0.9 → 3.0.11
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
2
2
|
import type { MultiaddrConnection } from '@libp2p/interface-connection';
|
|
3
|
-
import type { Duplex } from 'it-stream-types';
|
|
3
|
+
import type { Duplex, Source } from 'it-stream-types';
|
|
4
4
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
5
5
|
export interface Timeline {
|
|
6
6
|
/**
|
|
@@ -20,7 +20,7 @@ export interface StreamOptions {
|
|
|
20
20
|
signal?: AbortSignal;
|
|
21
21
|
}
|
|
22
22
|
export interface StreamProperties {
|
|
23
|
-
stream: Duplex<Uint8ArrayList
|
|
23
|
+
stream: Duplex<AsyncIterable<Uint8ArrayList>, Source<Uint8ArrayList | Uint8Array>>;
|
|
24
24
|
remoteAddr: Multiaddr;
|
|
25
25
|
localAddr: Multiaddr;
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-to-ma-conn.d.ts","sourceRoot":"","sources":["../../src/stream-to-ma-conn.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"stream-to-ma-conn.d.ts","sourceRoot":"","sources":["../../src/stream-to-ma-conn.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIpD,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAA;CAErB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,cAAc,GAAG,UAAU,CAAC,CAAC,CAAA;IAClF,UAAU,EAAE,SAAS,CAAA;IACrB,SAAS,EAAE,SAAS,CAAA;CACrB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,GAAE,aAAkB,GAAG,mBAAmB,CAoD/G"}
|
|
@@ -10,7 +10,12 @@ export function streamToMaConnection(props, options = {}) {
|
|
|
10
10
|
const { sink, source } = stream;
|
|
11
11
|
const mapSource = (async function* () {
|
|
12
12
|
for await (const list of source) {
|
|
13
|
-
|
|
13
|
+
if (list instanceof Uint8Array) {
|
|
14
|
+
yield list;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
yield* list;
|
|
18
|
+
}
|
|
14
19
|
}
|
|
15
20
|
}());
|
|
16
21
|
const maConn = {
|
|
@@ -34,7 +39,6 @@ export function streamToMaConnection(props, options = {}) {
|
|
|
34
39
|
},
|
|
35
40
|
source: (options.signal != null) ? abortableSource(mapSource, options.signal) : mapSource,
|
|
36
41
|
remoteAddr,
|
|
37
|
-
/** @type {Timeline} */
|
|
38
42
|
timeline: { open: Date.now(), close: undefined },
|
|
39
43
|
async close() {
|
|
40
44
|
await sink(async function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-to-ma-conn.js","sourceRoot":"","sources":["../../src/stream-to-ma-conn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAMvC,MAAM,GAAG,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAA;AA8B7C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAE,KAAuB,EAAE,UAAyB,EAAE;IACxF,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAA;IACpC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAE/B,MAAM,SAAS,GAAG,CAAC,KAAK,SAAU,CAAC;QACjC,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,MAAM,EAAE;YAC/B,KAAM,CAAC,CAAC,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"stream-to-ma-conn.js","sourceRoot":"","sources":["../../src/stream-to-ma-conn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAMvC,MAAM,GAAG,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAA;AA8B7C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAE,KAAuB,EAAE,UAAyB,EAAE;IACxF,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAA;IACpC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAE/B,MAAM,SAAS,GAAG,CAAC,KAAK,SAAU,CAAC;QACjC,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,MAAM,EAAE;YAC/B,IAAI,IAAI,YAAY,UAAU,EAAE;gBAC9B,MAAM,IAAI,CAAA;aACX;iBAAM;gBACL,KAAM,CAAC,CAAC,IAAI,CAAA;aACb;SACF;IACH,CAAC,EAAE,CAAC,CAAA;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
|
|
2
2
|
"name": "@libp2p/utils",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"description": "Package to aggregate shared logic and dependencies for the libp2p ecosystem",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p-utils#readme",
|
|
@@ -177,23 +177,22 @@
|
|
|
177
177
|
},
|
|
178
178
|
"dependencies": {
|
|
179
179
|
"@achingbrain/ip-address": "^8.1.0",
|
|
180
|
-
"@libp2p/interface-connection": "^
|
|
181
|
-
"@libp2p/interface-peer-store": "^
|
|
180
|
+
"@libp2p/interface-connection": "^5.0.1",
|
|
181
|
+
"@libp2p/interface-peer-store": "^2.0.0",
|
|
182
182
|
"@libp2p/interfaces": "^3.2.0",
|
|
183
183
|
"@libp2p/logger": "^2.0.0",
|
|
184
184
|
"@multiformats/multiaddr": "^12.0.0",
|
|
185
|
-
"abortable-iterator": "^
|
|
185
|
+
"abortable-iterator": "^5.0.0",
|
|
186
186
|
"is-loopback-addr": "^2.0.1",
|
|
187
|
-
"it-stream-types": "^
|
|
187
|
+
"it-stream-types": "^2.0.1",
|
|
188
188
|
"private-ip": "^3.0.0",
|
|
189
189
|
"uint8arraylist": "^2.3.2"
|
|
190
190
|
},
|
|
191
191
|
"devDependencies": {
|
|
192
192
|
"aegir": "^38.1.7",
|
|
193
193
|
"it-all": "^3.0.1",
|
|
194
|
-
"it-
|
|
194
|
+
"it-pair": "^2.0.6",
|
|
195
195
|
"it-pipe": "^3.0.0",
|
|
196
|
-
"p-defer": "^4.0.0",
|
|
197
196
|
"uint8arrays": "^4.0.2"
|
|
198
197
|
}
|
|
199
198
|
}
|
package/src/stream-to-ma-conn.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { abortableSource } from 'abortable-iterator'
|
|
|
2
2
|
import { logger } from '@libp2p/logger'
|
|
3
3
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
4
4
|
import type { MultiaddrConnection } from '@libp2p/interface-connection'
|
|
5
|
-
import type { Duplex } from 'it-stream-types'
|
|
5
|
+
import type { Duplex, Source } from 'it-stream-types'
|
|
6
6
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
7
7
|
|
|
8
8
|
const log = logger('libp2p:stream:converter')
|
|
@@ -30,7 +30,7 @@ export interface StreamOptions {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface StreamProperties {
|
|
33
|
-
stream: Duplex<Uint8ArrayList
|
|
33
|
+
stream: Duplex<AsyncIterable<Uint8ArrayList>, Source<Uint8ArrayList | Uint8Array>>
|
|
34
34
|
remoteAddr: Multiaddr
|
|
35
35
|
localAddr: Multiaddr
|
|
36
36
|
}
|
|
@@ -45,7 +45,11 @@ export function streamToMaConnection (props: StreamProperties, options: StreamOp
|
|
|
45
45
|
|
|
46
46
|
const mapSource = (async function * () {
|
|
47
47
|
for await (const list of source) {
|
|
48
|
-
|
|
48
|
+
if (list instanceof Uint8Array) {
|
|
49
|
+
yield list
|
|
50
|
+
} else {
|
|
51
|
+
yield * list
|
|
52
|
+
}
|
|
49
53
|
}
|
|
50
54
|
}())
|
|
51
55
|
|
|
@@ -70,7 +74,6 @@ export function streamToMaConnection (props: StreamProperties, options: StreamOp
|
|
|
70
74
|
},
|
|
71
75
|
source: (options.signal != null) ? abortableSource(mapSource, options.signal) : mapSource,
|
|
72
76
|
remoteAddr,
|
|
73
|
-
/** @type {Timeline} */
|
|
74
77
|
timeline: { open: Date.now(), close: undefined },
|
|
75
78
|
async close () {
|
|
76
79
|
await sink(async function * () {
|