Skip to content

Commit

Permalink
chore: use chainsafe fork of napi cli
Browse files Browse the repository at this point in the history
  • Loading branch information
wemeetagain committed Oct 14, 2024
1 parent 2f31a0b commit 000d743
Show file tree
Hide file tree
Showing 6 changed files with 1,031 additions and 403 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
"homepage": "https://github.com/ChainSafe/js-libp2p-quic",
"scripts": {
"artifacts": "napi artifacts",
"build": "yarn build:rs:debug && scripts/postbuild.sh && yarn build:ts",
"build:ts": "aegir build",
"build:rs": "napi build --platform --release --dts src/napi.d.ts --js src/napi.js",
"build:rs:debug": "napi build --platform --dts src/napi.d.ts --js src/napi.js",
"build": "yarn build:rs:debug && yarn build:ts",
"build:ts": "aegir build && cp src/*.node dist/src",
"build:rs": "napi build --platform --release -o src --esm --dts napi.d.ts --js napi.js",
"build:rs:debug": "napi build --platform -o src --esm --dts napi.d.ts --js napi.js",
"dep-check": "aegir dep-check -P test -P src/napi.js",
"docs": "aegir docs",
"lint": "aegir lint",
Expand All @@ -65,9 +65,9 @@
"uint8arraylist": "^2.4.8"
},
"devDependencies": {
"@chainsafe/napi-rs-cli": "^3.0.0-alpha.63.1",
"@libp2p/interface-compliance-tests": "^6.0.1",
"@libp2p/logger": "^5.0.1",
"@napi-rs/cli": "^2.18.4",
"aegir": "^44.1.1"
},
"packageManager": "[email protected]+sha256.c17d3797fb9a9115bf375e31bfd30058cac6bc9c3b8807a3d8cb2094794b51ca"
Expand Down
9 changes: 0 additions & 9 deletions scripts/JS_GEN_PREFIX

This file was deleted.

17 changes: 0 additions & 17 deletions scripts/postbuild.sh

This file was deleted.

145 changes: 75 additions & 70 deletions src/napi.d.ts
Original file line number Diff line number Diff line change
@@ -1,59 +1,24 @@
/* tslint:disable */
/* eslint-disable */

/* auto-generated by NAPI-RS */

/** User-level configuration */
export interface Config {
/** Libp2p identity of the node, protobuf encoded. */
privateKeyProto: Uint8Array
/**
* Timeout for the initial handshake when establishing a connection.
* The actual timeout is the minimum of this and the [`Config::max_idle_timeout`].
*/
handshakeTimeout: number
/** Maximum duration of inactivity in ms to accept before timing out the connection. */
maxIdleTimeout: number
/**
* Period of inactivity before sending a keep-alive packet.
* Must be set lower than the idle_timeout of both
* peers to be effective.
*
* See [`quinn::TransportConfig::keep_alive_interval`] for more
* info.
*/
keepAliveInterval: number
/**
* Maximum number of incoming bidirectional streams that may be open
* concurrently by the remote peer.
*/
maxConcurrentStreamLimit: number
/** Max unacknowledged data in bytes that may be sent on a single stream. */
maxStreamData: number
/**
* Max unacknowledged data in bytes that may be sent in total on all streams
* of a connection.
*/
maxConnectionData: number
}
export const enum SocketFamily {
Ipv4 = 0,
Ipv6 = 1
}
/** Configuration used by the QUIC library */
export declare class QuinnConfig {
constructor(config: Config)
/* eslint-disable */
export declare class Client {
constructor(config: QuinnConfig, family: SocketFamily)
outboundConnection(ip: string, port: number): Promise<Connection>
abort(): void
stats(): EndpointStats
}
export declare class EndpointStats {
/** Cummulative number of Quic handshakes accepted by this Endpoint */
acceptedHandshakes: number
/** Cummulative number of Quic handshakees sent from this Endpoint */
outgoingHandshakes: number
/** Cummulative number of Quic handshakes refused on this Endpoint */
refusedHandshakes: number
/** Cummulative number of Quic handshakes ignored on this Endpoint */
ignoredHandshakes: number

export declare class Connection {
inboundStream(): Promise<Stream>
outboundStream(): Promise<Stream>
/** close the connection immediately */
abort(): void
rtt(): number
id(): string
remoteMultiaddr(): string
closed(): Promise<void>
stats(): ConnectionStats
}

export declare class ConnectionStats {
/**
* Statistics about UDP datagrams transmitted on a connection
Expand Down Expand Up @@ -357,29 +322,30 @@ export declare class ConnectionStats {
/** The number of times a black hole was detected in the path */
pathBlackHolesDetected: number
}

export declare class EndpointStats {
/** Cummulative number of Quic handshakes accepted by this Endpoint */
acceptedHandshakes: number
/** Cummulative number of Quic handshakees sent from this Endpoint */
outgoingHandshakes: number
/** Cummulative number of Quic handshakes refused on this Endpoint */
refusedHandshakes: number
/** Cummulative number of Quic handshakes ignored on this Endpoint */
ignoredHandshakes: number
}

/** Configuration used by the QUIC library */
export declare class QuinnConfig {
constructor(config: Config)
}

export declare class Server {
constructor(config: QuinnConfig, ip: string, port: number)
inboundConnection(): Promise<Connection>
abort(): Promise<void>
stats(): EndpointStats
}
export declare class Client {
constructor(config: QuinnConfig, family: SocketFamily)
outboundConnection(ip: string, port: number): Promise<Connection>
abort(): void
stats(): EndpointStats
}
export declare class Connection {
inboundStream(): Promise<Stream>
outboundStream(): Promise<Stream>
/** close the connection immediately */
abort(): void
rtt(): number
id(): string
remoteMultiaddr(): string
closed(): Promise<void>
stats(): ConnectionStats
}

export declare class Stream {
id(): string
read(buf: Uint8Array): Promise<number | null>
Expand All @@ -395,3 +361,42 @@ export declare class Stream {
resetWrite(): Promise<void>
stopRead(): Promise<void>
}

/** User-level configuration */
export interface Config {
/** Libp2p identity of the node, protobuf encoded. */
privateKeyProto: Uint8Array
/**
* Timeout for the initial handshake when establishing a connection.
* The actual timeout is the minimum of this and the [`Config::max_idle_timeout`].
*/
handshakeTimeout: number
/** Maximum duration of inactivity in ms to accept before timing out the connection. */
maxIdleTimeout: number
/**
* Period of inactivity before sending a keep-alive packet.
* Must be set lower than the idle_timeout of both
* peers to be effective.
*
* See [`quinn::TransportConfig::keep_alive_interval`] for more
* info.
*/
keepAliveInterval: number
/**
* Maximum number of incoming bidirectional streams that may be open
* concurrently by the remote peer.
*/
maxConcurrentStreamLimit: number
/** Max unacknowledged data in bytes that may be sent on a single stream. */
maxStreamData: number
/**
* Max unacknowledged data in bytes that may be sent in total on all streams
* of a connection.
*/
maxConnectionData: number
}

export declare const enum SocketFamily {
Ipv4 = 0,
Ipv6 = 1
}
Loading

0 comments on commit 000d743

Please sign in to comment.