@minip2p/node 0.9.1 → 0.10.1

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/addon.d.ts CHANGED
@@ -17,8 +17,12 @@ export declare class NodeEndpoint {
17
17
  constructor(secretKey: Uint8Array, config: NodeEndpointConfig)
18
18
  /** Starts the detached driver with a strong event-loop doorbell. */
19
19
  start(doorbell: () => void): void
20
- /** Requests shutdown without waiting for the driver thread. */
21
- close(): void
20
+ /**
21
+ * Requests shutdown without waiting for the driver thread, which drains
22
+ * for up to `timeoutMs` and then delivers `EndpointClosed` as its last
23
+ * event.
24
+ */
25
+ close(timeoutMs: number): void
22
26
  /** Returns the local peer ID. */
23
27
  peerId(): string
24
28
  /** Returns bound peer addresses. */
@@ -78,9 +82,12 @@ export declare class NodeEndpoint {
78
82
  cancelConnect(id: bigint): void
79
83
  /** Disconnects one peer. */
80
84
  disconnect(peerId: string): void
81
- /** Returns the current path to a peer. */
85
+ /**
86
+ * Returns the path of a peer's established connection; `null` only
87
+ * while the peer is not connected.
88
+ */
82
89
  path(peerId: string): NativePathKind | null
83
- /** Returns the transport connection selected for a peer. */
90
+ /** Returns a snapshot of a peer's established connection. */
84
91
  connectionInfo(peerId: string): NativeConnectionInfo | null
85
92
  /** Returns the discovery address book. */
86
93
  knownPeers(): Array<NativeKnownPeerInfo>
@@ -1,41 +1,18 @@
1
1
  /**
2
- * Types of the values the native addon returns. `minip2p-ffi-core` derives
3
- * them with serde (its `js_shape` module pins the representation), and the
4
- * SDK's backend types describe the same shape, so each native type is the
5
- * SDK type with napi-rs's value encoding: `u64` arrives as `number`, or as a
6
- * `bigint` above `u32::MAX`, and bytes arrive as a `Buffer`.
2
+ * Types of the values the native addon returns: `minip2p-ffi-core`'s serde
3
+ * shape, with napi-rs's value encoding (`u64` as `number`, or `bigint` above
4
+ * `u32::MAX`; bytes as a `Buffer`). The shared serde backend defines them.
7
5
  *
8
6
  * The generated `addon.d.ts` imports these names through its header.
9
7
  */
10
8
 
11
- import type {
12
- ConnectionInfo,
13
- IdentifyInfo,
14
- KnownPeerInfo,
15
- RelayReservationInfo,
16
- } from "@minip2p/core";
17
- import type {
18
- BackendOpenStream,
19
- P2pEvent,
20
- PathKind,
21
- } from "@minip2p/core/backend";
22
-
23
- /** One SDK backend value as the addon encodes it. */
24
- export type NativeShape<Value> = Value extends ArrayBuffer
25
- ? Uint8Array
26
- : Value extends number
27
- ? number | bigint
28
- : Value extends string | boolean
29
- ? Value
30
- : Value extends readonly (infer Item)[]
31
- ? readonly NativeShape<Item>[]
32
- : { readonly [Key in keyof Value]: NativeShape<Value[Key]> };
33
-
34
- export type NativeEvent = NativeShape<P2pEvent>;
35
- export type NativeIdentifyInfo = NativeShape<IdentifyInfo>;
36
- export type NativeKnownPeerInfo = NativeShape<KnownPeerInfo>;
37
- export type NativeRelayReservationInfo = NativeShape<RelayReservationInfo>;
38
- export type NativeConnectionInfo = NativeShape<ConnectionInfo>;
39
- export type NativeOpenStream = NativeShape<BackendOpenStream>;
40
- export type NativePathKind = NativeShape<PathKind>;
9
+ export type {
10
+ NativeConnectionInfo,
11
+ NativeEvent,
12
+ NativeIdentifyInfo,
13
+ NativeKnownPeerInfo,
14
+ NativeOpenStream,
15
+ NativePathKind,
16
+ NativeRelayReservationInfo,
17
+ } from "@minip2p/core/serde-backend";
41
18
  export type { Reachability } from "@minip2p/core";