Comparing version
import * as maria2_index from 'maria2/index'; | ||
import { Conn, Socket, Aria2ServerVersion, Aria2ServerGlobalStat } from 'maria2'; | ||
import { PartialDeep } from 'type-fest'; | ||
import { Conn, Socket, Aria2ServerVersion, Aria2ServerGlobalStat } from 'maria2'; | ||
import { Aria2InputOptions } from '@naria2/options'; | ||
@@ -8,2 +8,16 @@ export * from '@naria2/options'; | ||
declare class Task { | ||
private readonly conn; | ||
readonly gid: string; | ||
private _timestamp; | ||
private _status; | ||
constructor(conn: Conn, gid: string); | ||
get status(): Pick<maria2_index.Aria2DownloadStatus, keyof maria2_index.Aria2DownloadStatus>; | ||
updateStatus(): Promise<Pick<maria2_index.Aria2DownloadStatus, keyof maria2_index.Aria2DownloadStatus>>; | ||
get progress(): number; | ||
} | ||
declare class Torrent extends Task { | ||
constructor(client: Conn, gid: string); | ||
} | ||
interface ClientOptions { | ||
@@ -34,19 +48,15 @@ secret?: string; | ||
type Aria2MonitorEvents = { | ||
'download.start': string; | ||
'download.pause': string; | ||
'download.stop': string; | ||
'download.complete': string; | ||
'bt.download.complete': string; | ||
'download.error': string; | ||
}; | ||
type Aria2MonitorEvents = Record<`start:${string}` | `pause:${string}` | `stop:${string}` | `complete:${string}` | `error:${string}`, Task> & Record<`bt-complete:${string}`, Torrent>; | ||
type GenericEventHandler = Handler<Aria2MonitorEvents[keyof Aria2MonitorEvents]> | WildcardHandler<Aria2MonitorEvents>; | ||
declare class Aria2Monitor implements Pick<Emitter<Aria2MonitorEvents>, 'on' | 'off'> { | ||
private _conn; | ||
private conn; | ||
private disposables; | ||
private emitter; | ||
private map; | ||
constructor(conn: Conn); | ||
start(): Promise<void>; | ||
close(): void; | ||
watchStatus(gid: string): Promise<void>; | ||
listActive(): Promise<Task[]>; | ||
getTask(gid: string): Promise<Task>; | ||
watchStatus(gid: string): Promise<Task>; | ||
on<Key extends keyof Aria2MonitorEvents>(key: Key, handler: GenericEventHandler): void; | ||
@@ -84,5 +94,5 @@ off<Key extends keyof Aria2MonitorEvents>(key: Key, handler?: GenericEventHandler): void; | ||
globalStat(): Promise<Aria2ServerGlobalStat>; | ||
downloadTorrent(torrent: string, options?: PartialDeep<Aria2InputOptions> & DownloadOptions): Promise<void>; | ||
downloadUri(uri: string | string[], options?: PartialDeep<Aria2InputOptions> & DownloadOptions): Promise<void>; | ||
listActive(): Promise<maria2_index.Aria2DownloadStatus[]>; | ||
downloadTorrent(torrent: string, options?: PartialDeep<Aria2InputOptions> & DownloadOptions): Promise<Task>; | ||
downloadUri(uri: string | string[], options?: PartialDeep<Aria2InputOptions> & DownloadOptions): Promise<Task>; | ||
listActive(): Promise<Task[]>; | ||
listWaiting(offset: number, num: number): Promise<maria2_index.Aria2DownloadStatus[]>; | ||
@@ -93,5 +103,2 @@ listStopped(offset: number, num: number): Promise<maria2_index.Aria2DownloadStatus[]>; | ||
declare class Torrent { | ||
} | ||
export { Aria2Client, type ClientOptions, type DownloadOptions, Torrent, type TorrentFile, type TorrentPiece, createClient }; | ||
export { Aria2Client, type ClientOptions, type DownloadOptions, Task, Torrent, type TorrentFile, type TorrentPiece, createClient }; |
{ | ||
"name": "naria2", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "High-level and Convenient BitTorrent Client based on aria2 JSON-RPC", | ||
@@ -60,3 +60,3 @@ "keywords": [ | ||
"type-fest": "^4.6.0", | ||
"@naria2/options": "0.0.15" | ||
"@naria2/options": "0.0.16" | ||
}, | ||
@@ -67,6 +67,6 @@ "devDependencies": { | ||
"ws": "^8.14.2", | ||
"@naria2/node": "0.0.15" | ||
"@naria2/node": "0.0.16" | ||
}, | ||
"peerDependencies": { | ||
"@naria2/node": "0.0.15" | ||
"@naria2/node": "0.0.16" | ||
}, | ||
@@ -73,0 +73,0 @@ "peerDependenciesMeta": { |
@@ -1,2 +0,2 @@ | ||
# naria2 (WIP) | ||
# naria2 | ||
@@ -8,5 +8,4 @@ [](https://www.npmjs.com/package/naria2) | ||
+ [x] Download aria2 for your platform | ||
+ [ ] Simple BitTorrent downloading API | ||
+ [ ] Event bus for progress, state change, and so on | ||
+ Simple BitTorrent downloading API | ||
+ Event bus for progress, state change, and so on | ||
@@ -13,0 +12,0 @@ ## Installation |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
33606
24.82%602
33.78%72
-1.37%+ Added
+ Added
- Removed
- Removed
Updated