electron-dl-manager
Version:
A library for implementing file downloads in Electron with 'save as' dialog and id support.
47 lines (46 loc) • 1.67 kB
TypeScript
import type { DownloadData, RestoreDownloadData } from "./DownloadData";
import type { DebugLoggerFn, DownloadConfig, DownloadManagerConstructorParams, IElectronDownloadManager, RestoreDownloadConfig } from "./types";
/**
* Enables handling downloads in Electron.
*/
export declare class ElectronDownloadManager implements IElectronDownloadManager {
protected downloadData: Record<string, DownloadData>;
protected logger: DebugLoggerFn;
private downloadQueue;
constructor(params?: DownloadManagerConstructorParams);
protected log(message: string): void;
/**
* Returns the current download data
*/
getDownloadData(id: string): DownloadData;
/**
* Cancels a download
*/
cancelDownload(id: string): void;
/**
* Pauses a download and returns the data necessary
* to restore it later via restoreDownload() if the download exists.
*/
pauseDownload(id: string): RestoreDownloadData | undefined;
/**
* Resumes a download
*/
resumeDownload(id: string): void;
/**
* Returns the number of active downloads
*/
getActiveDownloadCount(): number;
/**
* Restores a download that is not registered in the download manager.
* If it is already registered, calls resumeDownload() instead.
*/
restoreDownload(params: RestoreDownloadConfig): Promise<string>;
/**
* Starts a download. If saveDialogOptions has been defined in the config,
* the saveAs dialog will show up first.
*
* Returns the id of the download.
*/
download(params: DownloadConfig): Promise<string>;
protected cleanup(data: DownloadData): void;
}