New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

libaria2-ts

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libaria2-ts - npm Package Compare versions

Comparing version 1.0.572 to 1.0.601

.browserslistrc

445

dist/adapter.d.ts
/// <reference types="node" />
import type WebSocket from "ws";
import type EventEmitter from "events";
export declare abstract class Aria2ClientBaseClass<T> {
constructor(options: IAria2ClientOptions & T);
abstract events: EventEmitter;
abstract get system(): IAria2ClientSystem;
abstract getVersion(): Promise<IAria2Version>;
abstract shutdown(): Promise<TAria2ShutdownResult>;
abstract forceShutdown(): Promise<TAria2ShutdownResult>;
abstract saveSession(): Promise<TAria2SaveSessionResult>;
abstract getSessionInfo(): Promise<IAria2ClientSessionInfo>;
abstract addUri(uris: string[] | string, options?: TAria2ClientInputOption, position?: number): Promise<TAria2ClientGID>;
abstract addTorrent(torrent: Buffer | string, uris?: string[] | string, options?: IAria2ClientOptions, position?: number): Promise<TAria2ClientGID>;
abstract addMetalink(metalink: Buffer | string, options?: IAria2ClientOptions, position?: number): Promise<TAria2ClientGID[]>;
abstract remove(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
abstract forceRemove(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
abstract pause(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
abstract forcePause(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
abstract pauseAll(): Promise<TAria2PauseAllResult>;
abstract forcePauseAll(): Promise<TAria2PauseAllResult>;
abstract unpause(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
abstract unpauseAll(): Promise<TAria2PauseAllResult>;
abstract tellStatus(gid: TAria2ClientGID): Promise<IAria2DownloadStatus>;
abstract tellStatus<T extends keyof IAria2DownloadStatus>(gid: TAria2ClientGID, keys: T[]): Promise<Pick<IAria2DownloadStatus, T>>;
abstract getUris(gid: TAria2ClientGID): Promise<IAria2UriStatus[]>;
abstract getFiles(gid: TAria2ClientGID): Promise<IAria2FileStatus[]>;
abstract getPeers(gid: TAria2ClientGID): Promise<IAria2PeersInfo[]>;
abstract getServers(gid: TAria2ClientGID): Promise<TAria2ServersInfo>;
abstract tellActive(): Promise<IAria2DownloadStatus[]>;
abstract tellActive<T extends keyof IAria2DownloadStatus>(keys: T[]): Promise<Pick<IAria2DownloadStatus, T>[]>;
abstract tellWaiting(offset: number, num: number): Promise<IAria2DownloadStatus[]>;
abstract tellWaiting<T extends keyof IAria2DownloadStatus>(offset: number, num: number, keys: T[]): Promise<Pick<IAria2DownloadStatus, T>[]>;
abstract tellStopped(offset: number, num: number): Promise<IAria2DownloadStatus[]>;
abstract tellStopped<T extends keyof IAria2DownloadStatus>(offset: number, num: number, keys: T[]): Promise<Pick<IAria2DownloadStatus, T>[]>;
abstract changePosition(gid: TAria2ClientGID, pos: number, how: EAria2ChangePositionHow): Promise<TAria2ChangePositionResult>;
abstract changeUri(gid: TAria2ClientGID, fileIndex: TAria2DownloadFileIndex, delUris: string[], addUris: string[], position?: number): Promise<TAria2ChangeUriResult>;
abstract getOption(gid: TAria2ClientGID): Promise<TAria2ClientInputOption>;
abstract changeOption(gid: TAria2ClientGID, options: TAria2ClientInputOption): Promise<TAria2ChangeOptionResult>;
abstract getGlobalOption(): Promise<TAria2ClientInputOption>;
abstract changeGlobalOption(options: TAria2ClientInputOption): Promise<TAria2ChangeOptionResult>;
abstract getGlobalStat(): Promise<IAria2GlobalStat>;
abstract purgeDownloadResult(): Promise<TAria2PurgeDownloadResult>;
abstract removeDownloadResult(gid: TAria2ClientGID): Promise<TAria2RemoveDownloadResult>;
abstract rawCall<T, R>(methods: TAria2MethodNames, ...args: T[]): Promise<R>;
import When from "./when";
export declare abstract class Aria2ClientBaseClass<T> extends When {
/**
* @constructor
* @param options Options for creating a client.
*/
constructor();
/**
* ## Aria2 SystemMethods
* - #### `system.multicall`
* - #### `system.listMethods`
* - #### `system.listNotifications`
*/
abstract get system(): Aria2ClientSystemMethodsBaseClass<T>;
/**
* This method adds a Metalink download by uploading a ".metalink" file. metalink is a base64-encoded string which contains the contents of the ".metalink" file. options is a struct and its members are pairs of option name and value. See Options below for more details. If position is given, it must be an integer starting from 0. The new download will be inserted at position in the waiting queue. If position is omitted or position is larger than the current size of the queue, the new download is appended to the end of the queue. This method returns an array of GIDs of newly registered downloads. If `--rpc-save-upload-metadata` is `true`, the uploaded data is saved as a file named hex string of SHA-1 hash of data plus ".metalink" in the directory specified by `--dir` option. E.g. a file name might be `0a3893293e27ac0490424c06de4d09242215f0a6.metalink`. If a file with the same name already exists, it is overwritten! If the file cannot be saved successfully or `--rpc-save-upload-metadata` is `false`, the downloads added by this method are not saved by `--save-session`.
*
* @example
* ```ts
* await aria2.addMetalink(".....");
* ```
* @returns TAria2ClientGID[]
*/
addMetalink(metalink: string | Buffer, options?: IAria2ClientOptions, position?: number): Promise<TAria2ClientGID[]>;
/**
* This method removes the download denoted by gid (string). If the specified download is in progress, it is first stopped. The status of the removed download becomes removed. This method returns GID of `removed` download.
*
* The following examples remove a download with GID#2089b05ecca3d829.
* @example
* ```ts
* await aria2.remove('2089b05ecca3d829')
* ````
* @returns TAria2ClientGID
*/
remove(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
/**
* This method removes the download denoted by gid. This method behaves just like `aria2.remove()` except that this method removes the download without performing any actions which take time, such as contacting BitTorrent trackers to unregister the download first.
* @returns TAria2ClientGID
*/
forceRemove(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
/**
* This method pauses the download denoted by gid (string). The status of paused download becomes `paused`. If the download was active, the download is placed in the front of waiting queue. While the status is `paused`, the download is not started. To change status to waiting, use the `aria2.unpause()` method. This method returns GID of paused download.
* @returns TAria2ClientGID
*/
pause(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
/**
* This method pauses the download denoted by gid. This method behaves just like `aria2.pause()` except that this method pauses downloads without performing any actions which take time, such as contacting BitTorrent trackers to unregister the download first.
* @returns TAria2ClientGID
*/
forcePause(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
/**
* This method is equal to calling `aria2.pause()` for every active/waiting download. This methods returns `OK`.
* @returns TAria2PauseAllResult
*/
pauseAll(): Promise<TAria2PauseAllResult>;
/**
* This method is equal to calling `aria2.forcePause()` for every active/waiting download. This methods returns `OK`.
* @returns TAria2PauseAllResult
*/
forcePauseAll(): Promise<TAria2PauseAllResult>;
/**
* This method changes the status of the download denoted by gid (string) from `paused` to `waiting`, making the download eligible to be restarted. This method returns the GID of the unpaused download.
* @returns TAria2ClientGID
*/
unpause(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
/**
* This method is equal to calling `aria2.unpause()` for every paused download. This methods returns `OK`.
* @returns TAria2PauseAllResult
*/
unpauseAll(): Promise<TAria2PauseAllResult>;
/**
* This method returns the progress of the download denoted by gid (string). keys is an array of strings. If specified, the response contains only keys in the keys array. If keys is empty or omitted, the response contains all keys. This is useful when you just want specific keys and avoid unnecessary transfers. For example, `aria2.tellStatus("2089b05ecca3d829", ["gid", "status"])` returns the gid and status keys only. The response is a struct and contains following keys. Values are strings.
* @returns Pick<IAria2DownloadStatus, T> | IAria2DownloadStatus
*/
tellStatus(gid: TAria2ClientGID): Promise<IAria2DownloadStatus>;
tellStatus<T extends keyof IAria2DownloadStatus>(gid: TAria2ClientGID, keys: T[]): Promise<Pick<IAria2DownloadStatus, T>>;
/**
* This method returns the URIs used in the download denoted by gid (string). The response is an array of structs and it contains following keys. Values are string.
* @returns IAria2UriStatus[]
*/
getUris(gid: TAria2ClientGID): Promise<IAria2UriStatus[]>;
/**
* This method returns the file list of the download denoted by gid (string). The response is an array of structs which contain following keys. Values are strings.
* @returns IAria2FileStatus[]
*/
getFiles(gid: TAria2ClientGID): Promise<IAria2FileStatus[]>;
/**
* This method returns a list peers of the download denoted by gid (string). This method is for BitTorrent only. The response is an array of structs and contains the following keys. Values are strings.
* @returns IAria2PeersInfo[]
*/
getPeers(gid: TAria2ClientGID): Promise<IAria2PeersInfo[]>;
/**
* This method returns currently connected HTTP(S)/FTP/SFTP servers of the download denoted by gid (string). The response is an array of structs and contains the following keys. Values are strings.
* @returns TAria2ServersInfo
*/
getServers(gid: TAria2ClientGID): Promise<TAria2ServersInfo>;
/**
* This method returns a list of active downloads. The response is an array of the same structs as returned by the `aria2.tellStatus()` method. For the keys parameter, please refer to the `aria2.tellStatus()` method.
* @returns IAria2DownloadStatus[] | Pick<IAria2DownloadStatus, T>[]
*/
tellActive<T extends keyof IAria2DownloadStatus>(keys: T[]): Promise<Pick<IAria2DownloadStatus, T>[]>;
tellActive(): Promise<IAria2DownloadStatus[]>;
/**
* This method returns a list of waiting downloads, including paused ones. offset is an integer and specifies the offset from the download waiting at the front. num is an integer and specifies the max. number of downloads to be returned. For the keys parameter, please refer to the `aria2.tellStatus()` method.
*
* If offset is a positive integer, this method returns downloads in the range of [offset, offset + num).
*
* offset can be a negative integer. `offset == -1` points last download in the waiting queue and offset == -2 points the download before the last download, and so on. Downloads in the response are in reversed order then.
*
* For example, imagine three downloads "A", "B" and "C" are waiting in this order. `aria2.tellWaiting(0, 1)` returns `["A"]`. `aria2.tellWaiting(1, 2)` returns `["B", "C"]`. `aria2.tellWaiting(-1, 2)` returns `["C", "B"]`.
*
* The response is an array of the same structs as returned by `aria2.tellStatus()` method.
*
* @returns Pick<IAria2DownloadStatus, T>[] | IAria2DownloadStatus[]
*/
tellWaiting(offset: number, num: number): Promise<IAria2DownloadStatus[]>;
tellWaiting<T extends keyof IAria2DownloadStatus>(offset: number, num: number, keys: T[]): Promise<Pick<IAria2DownloadStatus, T>[]>;
/**
* This method returns a list of stopped downloads. offset is an integer and specifies the offset from the least recently stopped download. num is an integer and specifies the max. number of downloads to be returned. For the keys parameter, please refer to the `aria2.tellStatus()` method.
*
* offset and num have the same semantics as described in the `aria2.tellWaiting()` method.
*
* The response is an array of the same structs as returned by the `aria2.tellStatus()` method.
*
* @returns Pick<IAria2DownloadStatus, T>[] | IAria2DownloadStatus[]
*/
tellStopped(offset: number, num: number): Promise<IAria2DownloadStatus[]>;
tellStopped<T extends keyof IAria2DownloadStatus>(offset: number, num: number, keys: T[]): Promise<Pick<IAria2DownloadStatus, T>[]>;
/**
* This method changes the position of the download denoted by gid in the queue. pos is an integer. how is a string. If how is `POS_SET`, it moves the download to a position relative to the beginning of the queue. If how is `POS_CUR`, it moves the download to a position relative to the current position. If how is `POS_END`, it moves the download to a position relative to the end of the queue. If the destination position is less than 0 or beyond the end of the queue, it moves the download to the beginning or the end of the queue respectively. The response is an integer denoting the resulting position. (See enum `EAria2ChangePositionHow`)
*
* For example, if GID#2089b05ecca3d829 is currently in position 3, `aria2.changePosition('2089b05ecca3d829', -1, EAria2ChangePositionHow.Cur)` will change its position to 2. Additionally `aria2.changePosition('2089b05ecca3d829', 0, EAria2ChangePositionHow.Set)` will change its position to 0 (the beginning of the queue).
*
* The following examples move the download GID#2089b05ecca3d829 to the front of the queue.
* @example
* ```ts
* await aria2.changePosition('2089b05ecca3d829', 0, EAria2ChangePositionHow.Set);
* ```
* @returns TAria2ChangePositionResult
*/
changePosition(gid: TAria2ClientGID, pos: number, how: EAria2ChangePositionHow): Promise<TAria2ChangePositionResult>;
/**
* This method removes the URIs in delUris from and appends the URIs in addUris to download denoted by gid. delUris and addUris are lists of strings. A download can contain multiple files and URIs are attached to each file. fileIndex is used to select which file to remove/attach given URIs. fileIndex is 1-based. position is used to specify where URIs are inserted in the existing waiting URI list. position is 0-based. When position is omitted, URIs are appended to the back of the list. This method first executes the removal and then the addition. position is the position after URIs are removed, not the position when this method is called. When removing an URI, if the same URIs exist in download, only one of them is removed for each URI in delUris. In other words, if there are three URIs `http://example.org/aria2` and you want remove them all, you have to specify (at least) 3 `http://example.org/aria2` in delUris. This method returns a list which contains two integers. The first integer is the number of URIs deleted. The second integer is the number of URIs added.
*
* The following examples add the URI `http://example.org/file` to the file whose index is `1` and belongs to the download GID#2089b05ecca3d829.
* @returns TAria2ChangeUriResult
*/
changeUri(gid: TAria2ClientGID, fileIndex: TAria2DownloadFileIndex, delUris: string[], addUris: string[], position?: number): Promise<TAria2ChangeUriResult>;
/**
* This method returns options of the download denoted by gid. The response is a struct where keys are the names of options. The values are strings. Note that this method does not return options which have no default value and have not been set on the command-line, in configuration files or RPC methods.
*
* The following examples get options of the download GID#2089b05ecca3d829.
* @returns TAria2ClientInputOption
*/
getOption(gid: TAria2ClientGID): Promise<TAria2ClientInputOption>;
/**
* This method changes options of the download denoted by gid (string) dynamically. options is a struct. The options listed in Input File subsection are available, **except** for following options:
*
* - `dry-run`
* - `metalink-base-uri`
* - `parameterized-uri`
* - `pause`
* - `piece-length`
* - `rpc-save-upload-metadata`
*
* Except for the following options, changing the other options of active download makes it restart (restart itself is managed by aria2, and no user intervention is required):
*
* - `bt-max-peers`
* - `bt-request-peer-speed-limit`
* - `bt-remove-unselected-file`
* - `force-save`
* - `max-download-limit`
* - `max-upload-limit`
* This method returns OK for success.
*
* The following examples set the `max-download-limit` option to 20K for the download GID#2089b05ecca3d829.
*
* @example
* ```ts
* await aria2.changeOption(`2089b05ecca3d829`, {
* 'max-download-limit': '20K'
* });
* ```
*
* @returns TAria2ChangeOptionResult
*/
changeOption(gid: TAria2ClientGID, options: TAria2ClientInputOption): Promise<TAria2ChangeOptionResult>;
/**
* This method returns the global options. The response is a struct. Its keys are the names of options. Values are strings. Note that this method does not return options which have no default value and have not been set on the command-line, in configuration files or RPC methods. Because global options are used as a template for the options of newly added downloads, the response contains keys returned by the `aria2.getOption()` method.
* @returns TAria2ClientInputOption
*/
getGlobalOption(): Promise<TAria2ClientInputOption>;
/**
* This method changes global options dynamically. options is a struct. **The following options are available**:
*
* - `bt-max-open-files`
* - `download-result`
* - `keep-unfinished-download-result`
* - `log`
* - `log-level`
* - `max-concurrent-downloads`
* - `max-download-result`
* - `max-overall-download-limit`
* - `max-overall-upload-limit`
* - `optimize-concurrent-downloads`
* - `save-cookies`
* - `save-session`
* - `server-stat-of`
*
* In addition, options listed in the Input File subsection are available, **except for following options**: `checksum`, `index-out`, `out`, `pause` and s`elect-file`.
*
* With the log option, you can dynamically start logging or change log file. To stop logging, specify an empty string("") as the parameter value. Note that log file is always opened in append mode. This method returns OK for success.
*
* @returns TAria2ChangeOptionResult
*/
changeGlobalOption(options: TAria2ClientInputOption): Promise<TAria2ChangeOptionResult>;
/**
* This method returns global statistics such as the overall download and upload speeds.
* @returns IAria2GlobalStat
*/
getGlobalStat(): Promise<IAria2GlobalStat>;
/**
* This method purges completed/error/removed downloads to free memory. This method returns `OK`.
* @returns TAria2PurgeDownloadResult
*/
purgeDownloadResult(): Promise<TAria2PurgeDownloadResult>;
/**
* This method removes a completed/error/removed download denoted by gid from memory. This method returns `OK` for success.
*
* The following examples remove the download result of the download GID#2089b05ecca3d829.
*
* @example
* ```ts
* await aria2.removeDownloadResult('2089b05ecca3d829');
* ```
*
* @returns TAria2RemoveDownloadResult
*/
removeDownloadResult(gid: TAria2ClientGID): Promise<TAria2RemoveDownloadResult>;
/**
* This method returns the version of aria2 and the list of enabled features. The response is a struct and contains following keys.
*
* @example
* ```ts
* await aria2.getVersion();
* ```
* @returns IAria2Version
*/
getVersion(): Promise<IAria2Version>;
/**
* This method shuts down aria2. This method returns `OK`.
*
* @example
* ```ts
* await aria2.shutdown();
* ```
* @returns TAria2ShutdownResult
*/
shutdown(): Promise<TAria2ShutdownResult>;
/**
* This method shuts down aria2. This method behaves like function `aria2.shutdown()` without performing any actions which take time, such as contacting BitTorrent trackers to unregister downloads first. This method returns `OK`.
* @example
* ```ts
* await aria2.forceShutdown();
* ```
* @returns TAria2ShutdownResult
*/
forceShutdown(): Promise<TAria2ShutdownResult>;
/**
* This method saves the current session to a file specified by the `--save-session` option. This method returns `OK` if it succeeds.
* @example
* ```ts
* await aria2.saveSession();
* ```
* @returns TAria2SaveSessionResult
*/
saveSession(): Promise<TAria2SaveSessionResult>;
/**
* This method returns session information. The response is a struct and contains following key.
* @example
* ```ts
* await aria2.saveSession();
* ```
* @returns TAria2SaveSessionResult
*/
getSessionInfo(): Promise<IAria2ClientSessionInfo>;
/**
* This method adds a new download. uris is an array of HTTP/FTP/SFTP/BitTorrent URIs (strings) pointing to the same resource. If you mix URIs pointing to different resources, then the download may fail or be corrupted without aria2 complaining. When adding BitTorrent Magnet URIs, uris must have only one element and it should be BitTorrent Magnet URI. options is a struct and its members are pairs of option name and value. See Options below for more details. If position is given, it must be an integer starting from 0. The new download will be inserted at position in the waiting queue. If position is omitted or position is larger than the current size of the queue, the new download is appended to the end of the queue. This method returns the GID of the newly registered download.
* @param position `>= 0`
* @example
* ```ts
* await aria2.addUri('http://example.org/file', {}, 0);
* ```
* @returns TAria2ClientGID
*/
addUri(uris: string[] | string, options?: TAria2ClientInputOption, position?: number): Promise<TAria2ClientGID>;
/**
* This method adds a BitTorrent download by uploading a ".torrent" file. If you want to add a BitTorrent Magnet URI, use the `aria2.addUri()` method instead. torrent must be a base64-encoded string containing the contents of the ".torrent" file. uris is an array of URIs (string). uris is used for Web-seeding. For single file torrents, the URI can be a complete URI pointing to the resource; if URI ends with /, name in torrent file is added. For multi-file torrents, name and path in torrent are added to form a URI for each file. options is a struct and its members are pairs of option name and value. See Options below for more details. If position is given, it must be an integer starting from 0. The new download will be inserted at position in the waiting queue. If position is omitted or position is larger than the current size of the queue, the new download is appended to the end of the queue. This method returns the GID of the newly registered download. If `--rpc-save-upload-metadata` is `true`, the uploaded data is saved as a file named as the hex string of SHA-1 hash of data plus ".torrent" in the directory specified by `--dir` option. E.g. a file name might be `0a3893293e27ac0490424c06de4d09242215f0a6.torrent`. If a file with the same name already exists, it is overwritten! If the file cannot be saved successfully or `--rpc-save-upload-metadata` is `false`, the downloads added by this method are not saved by `--save-session`.
* @param position `>= 0`
* @example
* ```ts
* let torrent = fs.readFileSync('./file.torrent');
* await aria2.addTorrent(torrent);
* ```
* @returns TAria2ClientGID
*/
addTorrent(torrent: Buffer | string, uris?: string[] | string, options?: IAria2ClientOptions, position?: number): Promise<TAria2ClientGID>;
/**
* **[Unsafe]** Call any method with any params.
* @param methods The RPC Method.
* @param ...args Your Params.
* @example
* ```ts
* await aria2.rawCall('aria2.getVersion');
* ```
*/
abstract rawCall<T, R>(methods: string, ...args: T[]): Promise<R>;
/**
* **[Unsafe, Don't `await` or `.then`]** Send Any Data
* @param data Your Data, `Buffer`, `string`....
* ```ts
* await aria2.rawSend(JSON.stringify({}));
* ```
*/
abstract rawSend<T>(data: T): Promise<void>;
/**
* **[Unsafe]** Get Create Options *(Readonly)*
*/
abstract getCreateOptions(): Promise<Readonly<IAria2ClientOptions & T>>;
/**
* When `aria2.onDownloadStart` return.
*/
onDownloadStart(): Promise<IAria2NotificationEvent>;
/**
* When `aria2.onDownloadPause` return.
*/
onDownloadPause(): Promise<IAria2NotificationEvent>;
/**
* When `aria2.onDownloadStop` return.
*/
onDownloadStop(): Promise<IAria2NotificationEvent>;
/**
* When `aria2.onDownloadComplete` return.
*/
onDownloadComplete(): Promise<IAria2NotificationEvent>;
/**
* When `aria2.onDownloadError` return.
*/
onDownloadError(): Promise<IAria2NotificationEvent>;
/**
* When `aria2.onBtDownloadStart` return.
*/
onBtDownloadStart(): Promise<IAria2NotificationEvent>;
}

@@ -63,2 +373,5 @@ export declare type TAria2RemoveDownloadResult = string;

}
export interface IAria2NotificationEvent {
gid: string;
}
export declare type TAria2ChangeOptionResult = string;

@@ -242,10 +555,42 @@ export declare type TAria2DownloadFileIndex = number;

}
export interface IAria2ClientSystem {
multicall(...items: IAria2ClientMulticallItem[]): Promise<TAria2ClientMulticallResult>;
listMethods(): Promise<TAria2ClientMethodList>;
listNotifications(): Promise<TAria2ClientNotificationList>;
export declare abstract class Aria2ClientSystemMethodsBaseClass<T> {
protected $client: Aria2ClientBaseClass<T>;
constructor(client: Aria2ClientBaseClass<T>);
/**
* This methods encapsulates multiple method calls in a single request. methods is an array of structs. The structs contain two keys: `methodName` and `params`. `methodName` is the method name to call and `params` is array containing parameters to the method call. This method returns an array of responses. The elements will be either a one-item array containing the return value of the method call or a struct of fault element if an encapsulated method call fails.
* @example
* ```ts
* await aria2.system.multicall({
* methodName: "aria2.getVersion",
* params: []
* }, {
* methodName: "system.listMethods",
* params: []
*});
* ```
* @returns TAria2ClientMulticallResult
*/
abstract multicall<T0, T1>(...items: Readonly<IAria2ClientMulticallItem<T0>[]>): Promise<TAria2ClientMulticallResult<T1>>;
/**
* This method returns all the available RPC methods in an array of string. Unlike other methods, this method does not require secret token. This is safe because this method just returns the available method names.
* @example
* ```ts
* await aria2.system.listMethods();
* ```
* @returns TAria2ClientMethodList
*/
abstract listMethods(): Promise<TAria2ClientMethodList>;
/**
* This method returns all the available RPC notifications in an array of string. Unlike other methods, this method does not require secret token. This is safe because this method just returns the available notifications names.
* @example
* ```ts
* await aria2.system.listMethods();
* ```
* @returns TAria2ClientNotificationList
*/
abstract listNotifications(): Promise<TAria2ClientNotificationList>;
}
export declare type TAria2ClientMethodList = (string | TAria2MethodNames)[];
export declare type TAria2ClientNotificationList = (string | TAria2ClientNotificationNames)[];
export declare type TAria2ClientMulticallResult = Array<Promise<object>>;
export declare type TAria2ClientMulticallResult<T> = Array<Promise<T>>;
export interface IAria2ClientMulticallItem<T = unknown> {

@@ -263,2 +608,6 @@ methodName: TAria2MethodNames;

}
export interface IAria2HttpClientOptions {
protocol?: "http" | "https";
fetchOptions?: Readonly<RequestInit>;
}
export interface IAria2RpcOptions {

@@ -265,0 +614,0 @@ rpc: {

6

dist/lib.d.ts

@@ -1,6 +0,4 @@

import * as Rpc from "./rpc";
import { RpcWebSocket, RpcHttp } from "./rpc";
import * as Adapter from "./adapter";
export declare const WebSocketClient: typeof Rpc.Aria2.WebSocket.Client;
export declare const HttpClient: typeof Rpc.Aria2.Http.Client;
export { Rpc, Adapter };
export { RpcWebSocket as WebSocket, RpcHttp as Http, Adapter };
//# sourceMappingURL=lib.d.ts.map

@@ -1,440 +0,108 @@

/// <reference types="node" />
import { IAria2ClientOptions, IAria2Version, IAria2WSClientOptions, TAria2SaveSessionResult, TAria2ShutdownResult, IAria2ClientSystem, IJsonRPCResponse, TAria2ClientMethodList, TAria2ClientNotificationList, IAria2ClientMulticallItem, TAria2ClientMulticallResult, IAria2ClientSessionInfo, TAria2ClientGID, Aria2ClientBaseClass, EAria2ChangePositionHow, IAria2DownloadStatus, IAria2FileStatus, IAria2GlobalStat, IAria2PeersInfo, IAria2UriStatus, TAria2ChangeUriResult, TAria2ClientInputOption, TAria2ServersInfo, TAria2PauseAllResult, TAria2ChangePositionResult, TAria2DownloadFileIndex, TAria2ChangeOptionResult, TAria2PurgeDownloadResult, TAria2RemoveDownloadResult, TAria2MethodNames } from "./adapter";
import EventEmitter from "events";
import WebSocketClient from "ws";
export declare namespace Aria2 {
/** Aria2 WebSocket */
namespace WebSocket {
import { IAria2ClientOptions, IAria2WSClientOptions, IJsonRPCResponse, TAria2ClientMethodList, TAria2ClientNotificationList, IAria2ClientMulticallItem, TAria2ClientMulticallResult, Aria2ClientBaseClass, IAria2NotificationEvent } from "./adapter";
import { Aria2ClientSystemMethodsBaseClass, IAria2HttpClientOptions } from "./adapter";
export declare namespace RpcWebSocket {
/**
* ### Aria2 WebSocket Client
*
* aria2 provides JSON-RPC over HTTP and XML-RPC over HTTP interfaces that offer basically the same functionality. aria2 also provides JSON-RPC over WebSocket. JSON-RPC over WebSocket uses the same method signatures and response format as JSON-RPC over HTTP, but additionally provides server-initiated notifications. See JSON-RPC over WebSocket section for more information.
*
* **Events**
* - WebSocket
* * `ws.open`
* * `ws.message`
* * `ws.close`
* - Aria2 Notifications
* * `aria2.onDownloadStart`
* * `aria2.onDownloadPause`
* * `aria2.onDownloadStop`
* * `aria2.onDownloadComplete`
* * `aria2.onDownloadError`
* * `aria2.onBtDownloadComplete`;
*/
class Client extends Aria2ClientBaseClass<IAria2WSClientOptions> {
/** @ignore */
protected $ws: WebSocket;
/** @ignore */
protected $options: IAria2ClientOptions & IAria2WSClientOptions;
/** @ignore */
protected $respCallbacks: Map<string | number | undefined, (data: any) => void>;
/** @ignore */
protected $openCallbacks: Array<() => void>;
/** @ignore */
protected $opened: boolean;
constructor(options: Readonly<IAria2ClientOptions & IAria2WSClientOptions>);
/** @ignore */
protected $errorHandle(e: Error): void;
/**
* ### Aria2 WebSocket Client
*
* aria2 provides JSON-RPC over HTTP and XML-RPC over HTTP interfaces that offer basically the same functionality. aria2 also provides JSON-RPC over WebSocket. JSON-RPC over WebSocket uses the same method signatures and response format as JSON-RPC over HTTP, but additionally provides server-initiated notifications. See JSON-RPC over WebSocket section for more information.
* ## Wait WebSocket Open
* @ignore
* @returns Promise<void>
*/
class Client implements Aria2ClientBaseClass<IAria2WSClientOptions> {
/** @ignore */
protected $ws: WebSocketClient;
/** @ignore */
protected $options: IAria2ClientOptions & IAria2WSClientOptions;
/** @ignore */
protected $respCallbacks: Map<string | number | undefined, (data: any) => void>;
/** @ignore */
protected $openCallbacks: Array<() => void>;
/** @ignore */
protected $opened: boolean;
/**
* **Event Emitter**
*
* Events:
* - WebSocket
* - `ws.open`
* - `ws.message`
* - `ws.close`
* - Aria2 Notifications
* - `aria2.onDownloadStart`
* - `aria2.onDownloadPause`
* - `aria2.onDownloadStop`
* - `aria2.onDownloadComplete`
* - `aria2.onDownloadError`
* - `aria2.onBtDownloadComplete`;
*/
events: EventEmitter;
/**
* @constructor
* @param options Options for creating a client.
*/
constructor(options: Readonly<IAria2ClientOptions & IAria2WSClientOptions>);
/**
* This method adds a Metalink download by uploading a ".metalink" file. metalink is a base64-encoded string which contains the contents of the ".metalink" file. options is a struct and its members are pairs of option name and value. See Options below for more details. If position is given, it must be an integer starting from 0. The new download will be inserted at position in the waiting queue. If position is omitted or position is larger than the current size of the queue, the new download is appended to the end of the queue. This method returns an array of GIDs of newly registered downloads. If `--rpc-save-upload-metadata` is `true`, the uploaded data is saved as a file named hex string of SHA-1 hash of data plus ".metalink" in the directory specified by `--dir` option. E.g. a file name might be `0a3893293e27ac0490424c06de4d09242215f0a6.metalink`. If a file with the same name already exists, it is overwritten! If the file cannot be saved successfully or `--rpc-save-upload-metadata` is `false`, the downloads added by this method are not saved by `--save-session`.
*
* @example
* ```ts
* await aria2.addMetalink(".....");
* ```
* @returns TAria2ClientGID[]
*/
addMetalink(metalink: string | Buffer, options?: IAria2ClientOptions, position?: number): Promise<TAria2ClientGID[]>;
/**
* This method removes the download denoted by gid (string). If the specified download is in progress, it is first stopped. The status of the removed download becomes removed. This method returns GID of `removed` download.
*
* The following examples remove a download with GID#2089b05ecca3d829.
* @example
* ```ts
* await aria2.remove('2089b05ecca3d829')
* ````
* @returns TAria2ClientGID
*/
remove(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
/**
* This method removes the download denoted by gid. This method behaves just like `aria2.remove()` except that this method removes the download without performing any actions which take time, such as contacting BitTorrent trackers to unregister the download first.
* @returns TAria2ClientGID
*/
forceRemove(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
/**
* This method pauses the download denoted by gid (string). The status of paused download becomes `paused`. If the download was active, the download is placed in the front of waiting queue. While the status is `paused`, the download is not started. To change status to waiting, use the `aria2.unpause()` method. This method returns GID of paused download.
* @returns TAria2ClientGID
*/
pause(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
/**
* This method pauses the download denoted by gid. This method behaves just like `aria2.pause()` except that this method pauses downloads without performing any actions which take time, such as contacting BitTorrent trackers to unregister the download first.
* @returns TAria2ClientGID
*/
forcePause(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
/**
* This method is equal to calling `aria2.pause()` for every active/waiting download. This methods returns `OK`.
* @returns TAria2PauseAllResult
*/
pauseAll(): Promise<TAria2PauseAllResult>;
/**
* This method is equal to calling `aria2.forcePause()` for every active/waiting download. This methods returns `OK`.
* @returns TAria2PauseAllResult
*/
forcePauseAll(): Promise<TAria2PauseAllResult>;
/**
* This method changes the status of the download denoted by gid (string) from `paused` to `waiting`, making the download eligible to be restarted. This method returns the GID of the unpaused download.
* @returns TAria2ClientGID
*/
unpause(gid: TAria2ClientGID): Promise<TAria2ClientGID>;
/**
* This method is equal to calling `aria2.unpause()` for every paused download. This methods returns `OK`.
* @returns TAria2PauseAllResult
*/
unpauseAll(): Promise<TAria2PauseAllResult>;
/**
* This method returns the progress of the download denoted by gid (string). keys is an array of strings. If specified, the response contains only keys in the keys array. If keys is empty or omitted, the response contains all keys. This is useful when you just want specific keys and avoid unnecessary transfers. For example, `aria2.tellStatus("2089b05ecca3d829", ["gid", "status"])` returns the gid and status keys only. The response is a struct and contains following keys. Values are strings.
* @returns Pick<IAria2DownloadStatus, T> | IAria2DownloadStatus
*/
tellStatus(gid: TAria2ClientGID): Promise<IAria2DownloadStatus>;
tellStatus<T extends keyof IAria2DownloadStatus>(gid: TAria2ClientGID, keys: T[]): Promise<Pick<IAria2DownloadStatus, T>>;
/**
* This method returns the URIs used in the download denoted by gid (string). The response is an array of structs and it contains following keys. Values are string.
* @returns IAria2UriStatus[]
*/
getUris(gid: TAria2ClientGID): Promise<IAria2UriStatus[]>;
/**
* This method returns the file list of the download denoted by gid (string). The response is an array of structs which contain following keys. Values are strings.
* @returns IAria2FileStatus[]
*/
getFiles(gid: TAria2ClientGID): Promise<IAria2FileStatus[]>;
/**
* This method returns a list peers of the download denoted by gid (string). This method is for BitTorrent only. The response is an array of structs and contains the following keys. Values are strings.
* @returns IAria2PeersInfo[]
*/
getPeers(gid: TAria2ClientGID): Promise<IAria2PeersInfo[]>;
/**
* This method returns currently connected HTTP(S)/FTP/SFTP servers of the download denoted by gid (string). The response is an array of structs and contains the following keys. Values are strings.
* @returns TAria2ServersInfo
*/
getServers(gid: TAria2ClientGID): Promise<TAria2ServersInfo>;
/**
* This method returns a list of active downloads. The response is an array of the same structs as returned by the `aria2.tellStatus()` method. For the keys parameter, please refer to the `aria2.tellStatus()` method.
* @returns IAria2DownloadStatus[] | Pick<IAria2DownloadStatus, T>[]
*/
tellActive<T extends keyof IAria2DownloadStatus>(keys: T[]): Promise<Pick<IAria2DownloadStatus, T>[]>;
tellActive(): Promise<IAria2DownloadStatus[]>;
/**
* This method returns a list of waiting downloads, including paused ones. offset is an integer and specifies the offset from the download waiting at the front. num is an integer and specifies the max. number of downloads to be returned. For the keys parameter, please refer to the `aria2.tellStatus()` method.
*
* If offset is a positive integer, this method returns downloads in the range of [offset, offset + num).
*
* offset can be a negative integer. `offset == -1` points last download in the waiting queue and offset == -2 points the download before the last download, and so on. Downloads in the response are in reversed order then.
*
* For example, imagine three downloads "A", "B" and "C" are waiting in this order. `aria2.tellWaiting(0, 1)` returns `["A"]`. `aria2.tellWaiting(1, 2)` returns `["B", "C"]`. `aria2.tellWaiting(-1, 2)` returns `["C", "B"]`.
*
* The response is an array of the same structs as returned by `aria2.tellStatus()` method.
*
* @returns Pick<IAria2DownloadStatus, T>[] | IAria2DownloadStatus[]
*/
tellWaiting(offset: number, num: number): Promise<IAria2DownloadStatus[]>;
tellWaiting<T extends keyof IAria2DownloadStatus>(offset: number, num: number, keys: T[]): Promise<Pick<IAria2DownloadStatus, T>[]>;
/**
* This method returns a list of stopped downloads. offset is an integer and specifies the offset from the least recently stopped download. num is an integer and specifies the max. number of downloads to be returned. For the keys parameter, please refer to the `aria2.tellStatus()` method.
*
* offset and num have the same semantics as described in the `aria2.tellWaiting()` method.
*
* The response is an array of the same structs as returned by the `aria2.tellStatus()` method.
*
* @returns Pick<IAria2DownloadStatus, T>[] | IAria2DownloadStatus[]
*/
tellStopped(offset: number, num: number): Promise<IAria2DownloadStatus[]>;
tellStopped<T extends keyof IAria2DownloadStatus>(offset: number, num: number, keys: T[]): Promise<Pick<IAria2DownloadStatus, T>[]>;
/**
* This method changes the position of the download denoted by gid in the queue. pos is an integer. how is a string. If how is `POS_SET`, it moves the download to a position relative to the beginning of the queue. If how is `POS_CUR`, it moves the download to a position relative to the current position. If how is `POS_END`, it moves the download to a position relative to the end of the queue. If the destination position is less than 0 or beyond the end of the queue, it moves the download to the beginning or the end of the queue respectively. The response is an integer denoting the resulting position. (See enum `EAria2ChangePositionHow`)
*
* For example, if GID#2089b05ecca3d829 is currently in position 3, `aria2.changePosition('2089b05ecca3d829', -1, EAria2ChangePositionHow.Cur)` will change its position to 2. Additionally `aria2.changePosition('2089b05ecca3d829', 0, EAria2ChangePositionHow.Set)` will change its position to 0 (the beginning of the queue).
*
* The following examples move the download GID#2089b05ecca3d829 to the front of the queue.
* @example
* ```ts
* await aria2.changePosition('2089b05ecca3d829', 0, EAria2ChangePositionHow.Set);
* ```
* @returns TAria2ChangePositionResult
*/
changePosition(gid: TAria2ClientGID, pos: number, how: EAria2ChangePositionHow): Promise<TAria2ChangePositionResult>;
/**
* This method removes the URIs in delUris from and appends the URIs in addUris to download denoted by gid. delUris and addUris are lists of strings. A download can contain multiple files and URIs are attached to each file. fileIndex is used to select which file to remove/attach given URIs. fileIndex is 1-based. position is used to specify where URIs are inserted in the existing waiting URI list. position is 0-based. When position is omitted, URIs are appended to the back of the list. This method first executes the removal and then the addition. position is the position after URIs are removed, not the position when this method is called. When removing an URI, if the same URIs exist in download, only one of them is removed for each URI in delUris. In other words, if there are three URIs `http://example.org/aria2` and you want remove them all, you have to specify (at least) 3 `http://example.org/aria2` in delUris. This method returns a list which contains two integers. The first integer is the number of URIs deleted. The second integer is the number of URIs added.
*
* The following examples add the URI `http://example.org/file` to the file whose index is `1` and belongs to the download GID#2089b05ecca3d829.
* @returns TAria2ChangeUriResult
*/
changeUri(gid: TAria2ClientGID, fileIndex: TAria2DownloadFileIndex, delUris: string[], addUris: string[], position?: number): Promise<TAria2ChangeUriResult>;
/**
* This method returns options of the download denoted by gid. The response is a struct where keys are the names of options. The values are strings. Note that this method does not return options which have no default value and have not been set on the command-line, in configuration files or RPC methods.
*
* The following examples get options of the download GID#2089b05ecca3d829.
* @returns TAria2ClientInputOption
*/
getOption(gid: TAria2ClientGID): Promise<TAria2ClientInputOption>;
/**
* This method changes options of the download denoted by gid (string) dynamically. options is a struct. The options listed in Input File subsection are available, **except** for following options:
*
* - `dry-run`
* - `metalink-base-uri`
* - `parameterized-uri`
* - `pause`
* - `piece-length`
* - `rpc-save-upload-metadata`
*
* Except for the following options, changing the other options of active download makes it restart (restart itself is managed by aria2, and no user intervention is required):
*
* - `bt-max-peers`
* - `bt-request-peer-speed-limit`
* - `bt-remove-unselected-file`
* - `force-save`
* - `max-download-limit`
* - `max-upload-limit`
* This method returns OK for success.
*
* The following examples set the `max-download-limit` option to 20K for the download GID#2089b05ecca3d829.
*
* @example
* ```ts
* await aria2.changeOption(`2089b05ecca3d829`, {
* 'max-download-limit': '20K'
* });
* ```
*
* @returns TAria2ChangeOptionResult
*/
changeOption(gid: TAria2ClientGID, options: TAria2ClientInputOption): Promise<TAria2ChangeOptionResult>;
/**
* This method returns the global options. The response is a struct. Its keys are the names of options. Values are strings. Note that this method does not return options which have no default value and have not been set on the command-line, in configuration files or RPC methods. Because global options are used as a template for the options of newly added downloads, the response contains keys returned by the `aria2.getOption()` method.
* @returns TAria2ClientInputOption
*/
getGlobalOption(): Promise<TAria2ClientInputOption>;
/**
* This method changes global options dynamically. options is a struct. **The following options are available**:
*
* - `bt-max-open-files`
* - `download-result`
* - `keep-unfinished-download-result`
* - `log`
* - `log-level`
* - `max-concurrent-downloads`
* - `max-download-result`
* - `max-overall-download-limit`
* - `max-overall-upload-limit`
* - `optimize-concurrent-downloads`
* - `save-cookies`
* - `save-session`
* - `server-stat-of`
*
* In addition, options listed in the Input File subsection are available, **except for following options**: `checksum`, `index-out`, `out`, `pause` and s`elect-file`.
*
* With the log option, you can dynamically start logging or change log file. To stop logging, specify an empty string("") as the parameter value. Note that log file is always opened in append mode. This method returns OK for success.
*
* @returns TAria2ChangeOptionResult
*/
changeGlobalOption(options: TAria2ClientInputOption): Promise<TAria2ChangeOptionResult>;
/**
* This method returns global statistics such as the overall download and upload speeds.
* @returns IAria2GlobalStat
*/
getGlobalStat(): Promise<IAria2GlobalStat>;
/**
* This method purges completed/error/removed downloads to free memory. This method returns `OK`.
* @returns TAria2PurgeDownloadResult
*/
purgeDownloadResult(): Promise<TAria2PurgeDownloadResult>;
/**
* This method removes a completed/error/removed download denoted by gid from memory. This method returns `OK` for success.
*
* The following examples remove the download result of the download GID#2089b05ecca3d829.
*
* @example
* ```ts
* await aria2.removeDownloadResult('2089b05ecca3d829');
* ```
*
* @returns TAria2RemoveDownloadResult
*/
removeDownloadResult(gid: TAria2ClientGID): Promise<TAria2RemoveDownloadResult>;
/** @ignore */
protected $errorHandle: (e: Error | object) => void;
/**
* ## Wait WebSocket Open
* @ignore
* @returns Promise<void>
*/
protected $waitOpened: () => Promise<void>;
/**
* ## Send raw data
* @ignore
* @param data Data to be sent
*/
protected $sendRaw: (data: any) => Promise<void>;
/** @ignore */
protected $sendJson: (method: string, ...params: any[]) => Promise<IJsonRPCResponse>;
/**
* This method returns the version of aria2 and the list of enabled features. The response is a struct and contains following keys.
*
* @example
* ```ts
* await aria2.getVersion();
* ```
* @returns IAria2Version
*/
getVersion(): Promise<IAria2Version>;
/**
* This method shuts down aria2. This method returns `OK`.
*
* @example
* ```ts
* await aria2.shutdown();
* ```
* @returns TAria2ShutdownResult
*/
shutdown(): Promise<TAria2ShutdownResult>;
/**
* This method shuts down aria2. This method behaves like function `aria2.shutdown()` without performing any actions which take time, such as contacting BitTorrent trackers to unregister downloads first. This method returns `OK`.
* @example
* ```ts
* await aria2.forceShutdown();
* ```
* @returns TAria2ShutdownResult
*/
forceShutdown(): Promise<TAria2ShutdownResult>;
/**
* This method saves the current session to a file specified by the `--save-session` option. This method returns `OK` if it succeeds.
* @example
* ```ts
* await aria2.saveSession();
* ```
* @returns TAria2SaveSessionResult
*/
saveSession(): Promise<TAria2SaveSessionResult>;
/**
* This method returns session information. The response is a struct and contains following key.
* @example
* ```ts
* await aria2.saveSession();
* ```
* @returns TAria2SaveSessionResult
*/
getSessionInfo(): Promise<IAria2ClientSessionInfo>;
/**
* This method adds a new download. uris is an array of HTTP/FTP/SFTP/BitTorrent URIs (strings) pointing to the same resource. If you mix URIs pointing to different resources, then the download may fail or be corrupted without aria2 complaining. When adding BitTorrent Magnet URIs, uris must have only one element and it should be BitTorrent Magnet URI. options is a struct and its members are pairs of option name and value. See Options below for more details. If position is given, it must be an integer starting from 0. The new download will be inserted at position in the waiting queue. If position is omitted or position is larger than the current size of the queue, the new download is appended to the end of the queue. This method returns the GID of the newly registered download.
* @param position `>= 0`
* @example
* ```ts
* await aria2.addUri('http://example.org/file', {}, 0);
* ```
* @returns TAria2ClientGID
*/
addUri(uris: string[] | string, options?: TAria2ClientInputOption, position?: number): Promise<TAria2ClientGID>;
/**
* This method adds a BitTorrent download by uploading a ".torrent" file. If you want to add a BitTorrent Magnet URI, use the `aria2.addUri()` method instead. torrent must be a base64-encoded string containing the contents of the ".torrent" file. uris is an array of URIs (string). uris is used for Web-seeding. For single file torrents, the URI can be a complete URI pointing to the resource; if URI ends with /, name in torrent file is added. For multi-file torrents, name and path in torrent are added to form a URI for each file. options is a struct and its members are pairs of option name and value. See Options below for more details. If position is given, it must be an integer starting from 0. The new download will be inserted at position in the waiting queue. If position is omitted or position is larger than the current size of the queue, the new download is appended to the end of the queue. This method returns the GID of the newly registered download. If `--rpc-save-upload-metadata` is `true`, the uploaded data is saved as a file named as the hex string of SHA-1 hash of data plus ".torrent" in the directory specified by `--dir` option. E.g. a file name might be `0a3893293e27ac0490424c06de4d09242215f0a6.torrent`. If a file with the same name already exists, it is overwritten! If the file cannot be saved successfully or `--rpc-save-upload-metadata` is `false`, the downloads added by this method are not saved by `--save-session`.
* @param position `>= 0`
* @example
* ```ts
* let torrent = fs.readFileSync('./file.torrent');
* await aria2.addTorrent(torrent);
* ```
* @returns TAria2ClientGID
*/
addTorrent(torrent: Buffer | string, uris?: string[] | string, options?: IAria2ClientOptions, position?: number): Promise<TAria2ClientGID>;
/** @ignore */
protected $systemMethods: SystemMethods;
/**
* ## Aria2 SystemMethods
* - #### `system.multicall`
* - #### `system.listMethods`
* - #### `system.listNotifications`
*/
get system(): SystemMethods;
/**
* **[Unsafe]** Call any method with any params.
* @param methods The RPC Method.
* @param ...args Your Params.
* @example
* ```ts
* await aria2.rawCall('aria2.getVersion');
* ```
*/
rawCall<T, R>(methods: TAria2MethodNames, ...args: T[]): Promise<R>;
/**
* Close the WebSocket Connection.
* @param code Disconnect Code
* @param data Some string
*/
closeConnection<T extends string>(code?: number, data?: T): Promise<void>;
}
class SystemMethods implements IAria2ClientSystem {
/** @ignore */
private $sendJson;
/** @ignore */
private $sendRaw;
/** @ignore */
private $options;
/** @ignore */
private $respCallbacks;
/** @ignore */
private $waitOpened;
/** @ignore */
constructor(sendJson: any, sendRaw: any, options: any, respCallbacks: any, waitOpened: any);
/**
* This method returns all the available RPC methods in an array of string. Unlike other methods, this method does not require secret token. This is safe because this method just returns the available method names.
* @example
* ```ts
* await aria2.system.listMethods();
* ```
* @returns TAria2ClientMethodList
*/
listMethods(): Promise<TAria2ClientMethodList>;
/**
* This method returns all the available RPC notifications in an array of string. Unlike other methods, this method does not require secret token. This is safe because this method just returns the available notifications names.
* @example
* ```ts
* await aria2.system.listMethods();
* ```
* @returns TAria2ClientNotificationList
*/
listNotifications(): Promise<TAria2ClientNotificationList>;
/**
* This methods encapsulates multiple method calls in a single request. methods is an array of structs. The structs contain two keys: `methodName` and `params`. `methodName` is the method name to call and `params` is array containing parameters to the method call. This method returns an array of responses. The elements will be either a one-item array containing the return value of the method call or a struct of fault element if an encapsulated method call fails.
* @example
* ```ts
* await aria2.system.multicall({
* methodName: "aria2.getVersion",
* params: []
* }, {
* methodName: "system.listMethods",
* params: []
*});
* ```
* @returns TAria2ClientMulticallResult
*/
multicall(...items: IAria2ClientMulticallItem[]): Promise<TAria2ClientMulticallResult>;
}
}
namespace Http {
protected $waitOpened: () => Promise<void>;
/**
* ### Aria2 Http Client
* **Note: Work in progress**
*
* ## Send raw data
* @ignore
* @param data Data to be sent
*/
class Client {
constructor(...anything: any[]);
}
protected $sendRaw: (data: any) => Promise<void>;
/** @ignore */
protected $sendJson: (method: string, ...params: any[]) => Promise<IJsonRPCResponse>;
/** @ignore */
protected $systemMethods: SystemMethods;
get system(): SystemMethods;
rawCall<T, R>(methods: string, ...args: T[]): Promise<R>;
rawSend<T>(data: T): Promise<void>;
getCreateOptions(): Promise<Readonly<IAria2ClientOptions & IAria2WSClientOptions>>;
/**
* Close the WebSocket Connection.
* @param code Disconnect Code
* @param data Some string
*/
closeConnection<T extends string>(code?: number, data?: T): Promise<void>;
}
class SystemMethods extends Aria2ClientSystemMethodsBaseClass<IAria2WSClientOptions> {
listMethods(): Promise<TAria2ClientMethodList>;
listNotifications(): Promise<TAria2ClientNotificationList>;
multicall<T0, T1>(...items: IAria2ClientMulticallItem[]): Promise<TAria2ClientMulticallResult<T0>>;
}
}
export declare namespace RpcHttp {
/**
* ### Aria2 Http Client
* **Events**
* - WebSocket
* * `ws.open`
* * `ws.message`
* * `ws.close`
* - Aria2 Notifications
* * `aria2.onDownloadStart`
* * `aria2.onDownloadPause`
* * `aria2.onDownloadStop`
* * `aria2.onDownloadComplete`
* * `aria2.onDownloadError`
* * `aria2.onBtDownloadComplete`;
*/
class Client extends Aria2ClientBaseClass<IAria2HttpClientOptions> {
/** @ignore */
protected $options: IAria2ClientOptions & IAria2HttpClientOptions;
/** @ignore */
protected $system: SystemMethods;
constructor(options: Readonly<IAria2ClientOptions & IAria2HttpClientOptions>);
onDownloadStart(): Promise<IAria2NotificationEvent>;
onDownloadPause(): Promise<IAria2NotificationEvent>;
onDownloadStop(): Promise<IAria2NotificationEvent>;
onDownloadComplete(): Promise<IAria2NotificationEvent>;
onDownloadError(): Promise<IAria2NotificationEvent>;
onBtDownloadStart(): Promise<IAria2NotificationEvent>;
get system(): Aria2ClientSystemMethodsBaseClass<IAria2HttpClientOptions>;
rawCall<T, R>(methods: string, ...args: T[]): Promise<R>;
rawSend<T>(data: T): Promise<void>;
getCreateOptions(): Promise<Readonly<IAria2ClientOptions & IAria2HttpClientOptions>>;
}
class SystemMethods extends Aria2ClientSystemMethodsBaseClass<IAria2HttpClientOptions> {
multicall<T0, T1>(...items: Readonly<IAria2ClientMulticallItem<T0>[]>): Promise<TAria2ClientMulticallResult<T1>>;
listMethods(): Promise<TAria2ClientMethodList>;
listNotifications(): Promise<TAria2ClientNotificationList>;
}
}
//# sourceMappingURL=rpc.d.ts.map
{
"name": "libaria2-ts",
"version": "1.0.572",
"version": "1.0.601",
"description": "A full-typing wrapper around `aria2`, `The next generation download utility`.",

@@ -18,8 +18,19 @@ "repository": "https://github.com/im-oxygen/libaria2-ts",

],
"main": "dist/lib.js",
"main": "dist/libaria2.",
"types": "dist/lib.d.ts",
"license": "MIT",
"exports": {
".": {
"node": {
"module": "./dist/libaria2.node.esm.js",
"import": "./dist/libaria2.node.esm.js",
"require": "./dist/libaria2.node.cjs.js"
},
"default": "./dist/libaria2.browser.esm.js"
}
},
"scripts": {
"build:docs": "typedoc --tsconfig ./tsconfig.json ./src/lib.ts",
"build": "tsc --build ./tsconfig.json",
"build:prod": "rollup -c ./rollup.prod.config.js --sourcemap",
"build": "rollup -c ./rollup.config.js --sourcemap",
"test": "ts-node ./tests/index.ts",

@@ -29,2 +40,8 @@ "lint": "eslint -c ./.eslintrc"

"devDependencies": {
"@babel/core": "^7.13.8",
"@babel/preset-env": "^7.13.9",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@rollup/pluginutils": "^4.1.0",
"@types/isomorphic-fetch": "^0.0.35",
"@types/node": "^14.14.22",

@@ -40,6 +57,10 @@ "@types/uuid": "^8.3.0",

"eslint-plugin-promise": "4.2.1",
"isomorphic-fetch": "^3.0.0",
"rollup": "^2.40.0",
"rollup-plugin-dts": "^2.0.1",
"rollup-plugin-typescript2": "^0.30.0",
"tslib": "^2.1.0",
"typedoc": "^0.20.28",
"typescript": "^4.1.3"
},
"dependencies": {
"typescript": "^4.1.3",
"rollup-plugin-terser": "^7.0.2",
"uuid": "^8.3.2",

@@ -46,0 +67,0 @@ "ws": "^7.4.2"

@@ -11,3 +11,3 @@ **(note: This package is still under development, please don't use it in a production environment.)**

TypeScript (Node.js & ~~Browser~~(WIP) ) library for [aria2](https://aria2.github.io/).
TypeScript (Node.js & Browser ) library for [aria2](https://aria2.github.io/).

@@ -27,5 +27,5 @@ - [libaria2.ts](#libaria2ts)

## Features
- Node.js and ~~browsers support~~ (WIP)
- Node.js and browsers support
- Multiple Transports
- [~~HTTP~~ (WIP)](https://aria2.github.io/manual/en/html/aria2c.html#rpc-interface)
- [HTTP](https://aria2.github.io/manual/en/html/aria2c.html#rpc-interface)
- [WebSocket](https://aria2.github.io/manual/en/html/aria2c.html#json-rpc-over-websocket)

@@ -97,2 +97,4 @@ - Promise-based API

Methods, see [Aria2ClientBaseClient](./classes/adapter.aria2clientbaseclass.html)
## License

@@ -99,0 +101,0 @@ ```

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc