Skip to content

Commit 7a1665c

Browse files
authored
chore: flatten interface dirs (#2947)
Makes the project slightly simpler to navigate
1 parent d5b399e commit 7a1665c

29 files changed

+79
-116
lines changed

packages/interface-internal/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@
5151
"@libp2p/interface": "^2.4.1",
5252
"@libp2p/peer-collections": "^6.0.16",
5353
"@multiformats/multiaddr": "^12.3.3",
54-
"progress-events": "^1.0.1",
55-
"uint8arraylist": "^2.4.8"
54+
"progress-events": "^1.0.1"
5655
},
5756
"devDependencies": {
5857
"aegir": "^45.0.5"
+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
export * from './address-manager/index.js'
2-
export * from './connection-manager/index.js'
3-
export * from './random-walk/index.js'
4-
export * from './record/index.js'
5-
export * from './registrar/index.js'
6-
export * from './transport-manager/index.js'
1+
export * from './address-manager.js'
2+
export * from './connection-manager.js'
3+
export * from './random-walk.js'
4+
export * from './registrar.js'
5+
export * from './transport-manager.js'

packages/interface-internal/src/record/index.ts

-35
This file was deleted.

packages/interface/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"aegir": "^45.0.5"
6060
},
6161
"browser": {
62-
"events": "./dist/src/events.browser.js"
62+
"./dist/src/events.js": "./dist/src/events.browser.js"
6363
},
6464
"react-native": {
6565
"./dist/src/events.js": "./dist/src/events.browser.js"

packages/interface/src/connection-encrypter/index.ts packages/interface/src/connection-encrypter.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { MultiaddrConnection } from '../connection/index.js'
2-
import type { AbortOptions } from '../index.js'
3-
import type { PeerId } from '../peer-id/index.js'
1+
import type { MultiaddrConnection } from './connection.js'
2+
import type { AbortOptions } from './index.js'
3+
import type { PeerId } from './peer-id.js'
44
import type { Duplex } from 'it-stream-types'
55
import type { Uint8ArrayList } from 'uint8arraylist'
66

packages/interface/src/connection-gater/index.ts packages/interface/src/connection-gater.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { MultiaddrConnection } from '../connection/index.js'
2-
import type { PeerId } from '../peer-id/index.js'
1+
import type { MultiaddrConnection } from './connection.js'
2+
import type { PeerId } from './peer-id.js'
33
import type { Multiaddr } from '@multiformats/multiaddr'
44

55
export interface ConnectionGater {

packages/interface/src/connection/index.ts packages/interface/src/connection.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { AbortOptions, Logger } from '../index.js'
2-
import type { PeerId } from '../peer-id/index.js'
1+
import type { AbortOptions, Logger } from './index.js'
2+
import type { PeerId } from './peer-id.js'
33
import type { Multiaddr } from '@multiformats/multiaddr'
44
import type { Duplex, Source } from 'it-stream-types'
55
import type { Uint8ArrayList } from 'uint8arraylist'

packages/interface/src/content-routing/index.ts packages/interface/src/content-routing.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { RoutingOptions } from '../index.js'
2-
import type { PeerInfo } from '../peer-info/index.js'
1+
import type { RoutingOptions } from './index.js'
2+
import type { PeerInfo } from './peer-info.js'
33
import type { CID } from 'multiformats/cid'
44

55
/**

packages/interface/src/events.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { setMaxListeners as nodeSetMaxListeners } from 'events'
1+
import { setMaxListeners as nodeSetMaxListeners } from 'node:events'
22

33
/**
44
* Create a setMaxListeners that doesn't break browser usage

packages/interface/src/index.ts

+28-29
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
* ```
1515
*/
1616

17-
import type { Connection, NewStreamOptions, Stream } from './connection/index.js'
18-
import type { ContentRouting } from './content-routing/index.js'
17+
import type { Connection, NewStreamOptions, Stream } from './connection.js'
18+
import type { ContentRouting } from './content-routing.js'
1919
import type { TypedEventTarget } from './event-target.js'
20-
import type { Ed25519PublicKey, PublicKey, RSAPublicKey, Secp256k1PublicKey } from './keys/index.js'
21-
import type { Metrics } from './metrics/index.js'
22-
import type { Ed25519PeerId, PeerId, RSAPeerId, Secp256k1PeerId, URLPeerId } from './peer-id/index.js'
23-
import type { PeerInfo } from './peer-info/index.js'
24-
import type { PeerRouting } from './peer-routing/index.js'
25-
import type { Address, Peer, PeerStore } from './peer-store/index.js'
20+
import type { Ed25519PublicKey, PublicKey, RSAPublicKey, Secp256k1PublicKey } from './keys.js'
21+
import type { Metrics } from './metrics.js'
22+
import type { Ed25519PeerId, PeerId, RSAPeerId, Secp256k1PeerId, URLPeerId } from './peer-id.js'
23+
import type { PeerInfo } from './peer-info.js'
24+
import type { PeerRouting } from './peer-routing.js'
25+
import type { Address, Peer, PeerStore } from './peer-store.js'
2626
import type { Startable } from './startable.js'
27-
import type { StreamHandler, StreamHandlerOptions } from './stream-handler/index.js'
28-
import type { Topology } from './topology/index.js'
29-
import type { Listener, OutboundConnectionUpgradeEvents } from './transport/index.js'
27+
import type { StreamHandler, StreamHandlerOptions } from './stream-handler.js'
28+
import type { Topology } from './topology.js'
29+
import type { Listener, OutboundConnectionUpgradeEvents } from './transport.js'
3030
import type { Multiaddr } from '@multiformats/multiaddr'
3131
import type { ProgressOptions, ProgressEvent } from 'progress-events'
3232

@@ -808,24 +808,23 @@ export const serviceCapabilities = Symbol.for('@libp2p/service-capabilities')
808808
*/
809809
export const serviceDependencies = Symbol.for('@libp2p/service-dependencies')
810810

811-
export * from './connection/index.js'
812-
export * from './connection-encrypter/index.js'
813-
export * from './connection-gater/index.js'
814-
export * from './content-routing/index.js'
815-
export * from './keys/index.js'
816-
export * from './metrics/index.js'
817-
export * from './peer-discovery/index.js'
818-
export * from './peer-id/index.js'
819-
export * from './peer-info/index.js'
820-
export * from './peer-routing/index.js'
821-
export * from './peer-store/index.js'
822-
export * from './peer-store/tags.js'
823-
export * from './pubsub/index.js'
824-
export * from './record/index.js'
825-
export * from './stream-handler/index.js'
826-
export * from './stream-muxer/index.js'
827-
export * from './topology/index.js'
828-
export * from './transport/index.js'
811+
export * from './connection.js'
812+
export * from './connection-encrypter.js'
813+
export * from './connection-gater.js'
814+
export * from './content-routing.js'
815+
export * from './keys.js'
816+
export * from './metrics.js'
817+
export * from './peer-discovery.js'
818+
export * from './peer-id.js'
819+
export * from './peer-info.js'
820+
export * from './peer-routing.js'
821+
export * from './peer-store.js'
822+
export * from './pubsub.js'
823+
export * from './record.js'
824+
export * from './stream-handler.js'
825+
export * from './stream-muxer.js'
826+
export * from './topology.js'
827+
export * from './transport.js'
829828
export * from './errors.js'
830829
export * from './event-target.js'
831830
export * from './events.js'
File renamed without changes.

packages/interface/src/metrics/index.ts packages/interface/src/metrics.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { MultiaddrConnection, Stream, Connection } from '../connection/index.js'
1+
import type { MultiaddrConnection, Stream, Connection } from './connection.js'
22

33
/**
44
* Create tracked metrics with these options. Loosely based on the

packages/interface/src/peer-discovery/index.ts packages/interface/src/peer-discovery.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { TypedEventTarget } from '../event-target.js'
2-
import type { PeerInfo } from '../peer-info/index.js'
1+
import type { TypedEventTarget } from './event-target.js'
2+
import type { PeerInfo } from './peer-info.js'
33

44
/**
55
* Any object that implements this Symbol as a property should return a

packages/interface/src/peer-id/index.ts packages/interface/src/peer-id.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Ed25519PublicKey, KeyType, RSAPublicKey, Secp256k1PublicKey } from '../keys/index.js'
1+
import type { Ed25519PublicKey, KeyType, RSAPublicKey, Secp256k1PublicKey } from './keys.js'
22
import type { CID } from 'multiformats/cid'
33
import type { MultihashDigest } from 'multiformats/hashes/interface'
44

packages/interface/src/peer-info/index.ts packages/interface/src/peer-info.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { PeerId } from '../peer-id/index.js'
1+
import type { PeerId } from './peer-id.js'
22
import type { Multiaddr } from '@multiformats/multiaddr'
33

44
/**

packages/interface/src/peer-routing/index.ts packages/interface/src/peer-routing.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { RoutingOptions } from '../index.js'
2-
import type { PeerId } from '../peer-id/index.js'
3-
import type { PeerInfo } from '../peer-info/index.js'
1+
import type { RoutingOptions } from './index.js'
2+
import type { PeerId } from './peer-id.js'
3+
import type { PeerInfo } from './peer-info.js'
44

55
/**
66
* Any object that implements this Symbol as a property should return a

packages/interface/src/peer-store/index.ts packages/interface/src/peer-store.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
import type { PublicKey } from '../keys/index.js'
2-
import type { PeerId } from '../peer-id/index.js'
1+
import type { PublicKey } from './keys.js'
2+
import type { PeerId } from './peer-id.js'
33
import type { Multiaddr } from '@multiformats/multiaddr'
44

5+
/**
6+
* When a peer that is tagged with this prefix disconnects, we will attempt to
7+
* redial it, up to a limit.
8+
*
9+
* To allow multiple components to add/remove their own keep-alive tags without
10+
* accidentally overwriting those of other components, attach a unique suffix to
11+
* the tag, e.g. `keep-alive-circuit-relay` or `keep-alive-kad-dht`, etc.
12+
*/
13+
export const KEEP_ALIVE = 'keep-alive'
14+
515
/**
616
* A multiaddr with an optional flag that indicates if its trustworthy
717
*/

packages/interface/src/peer-store/tags.ts

-9
This file was deleted.

packages/interface/src/pubsub/index.ts packages/interface/src/pubsub.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { Stream } from '../connection/index.js'
2-
import type { TypedEventTarget } from '../event-target.js'
3-
import type { PublicKey } from '../keys/index.js'
4-
import type { PeerId } from '../peer-id/index.js'
1+
import type { Stream } from './connection.js'
2+
import type { TypedEventTarget } from './event-target.js'
3+
import type { PublicKey } from './keys.js'
4+
import type { PeerId } from './peer-id.js'
55
import type { Pushable } from 'it-pushable'
66
import type { Uint8ArrayList } from 'uint8arraylist'
77

packages/interface/src/record/index.ts packages/interface/src/record.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { PublicKey } from '../keys/index.js'
1+
import type { PublicKey } from './keys.js'
22
import type { Uint8ArrayList } from 'uint8arraylist'
33

44
/**

packages/interface/src/stream-handler/index.ts packages/interface/src/stream-handler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Connection, Stream } from '../connection/index.js'
1+
import type { Connection, Stream } from './connection.js'
22

33
export interface IncomingStreamData {
44
/**

packages/interface/src/stream-muxer/index.ts packages/interface/src/stream-muxer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Direction, Stream } from '../connection/index.js'
2-
import type { AbortOptions } from '../index.js'
1+
import type { Direction, Stream } from './connection.js'
2+
import type { AbortOptions } from './index.js'
33
import type { Duplex } from 'it-stream-types'
44
import type { Uint8ArrayList } from 'uint8arraylist'
55

packages/interface/src/topology/index.ts packages/interface/src/topology.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Connection } from '../connection/index.js'
2-
import type { PeerId } from '../peer-id/index.js'
1+
import type { Connection } from './connection.js'
2+
import type { PeerId } from './peer-id.js'
33

44
/**
55
* A topology filter

packages/interface/src/transport/index.ts packages/interface/src/transport.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { Connection, ConnectionLimits, MultiaddrConnection } from '../connection/index.js'
2-
import type { TypedEventTarget } from '../event-target.js'
3-
import type { AbortOptions } from '../index.js'
4-
import type { StreamMuxerFactory } from '../stream-muxer/index.js'
1+
import type { Connection, ConnectionLimits, MultiaddrConnection } from './connection.js'
2+
import type { TypedEventTarget } from './event-target.js'
3+
import type { AbortOptions } from './index.js'
4+
import type { StreamMuxerFactory } from './stream-muxer.js'
55
import type { Multiaddr } from '@multiformats/multiaddr'
66
import type { ProgressOptions, ProgressEvent } from 'progress-events'
77

0 commit comments

Comments
 (0)