Created
September 7, 2018 08:25
-
-
Save bigbeno37/90e2af6225e8cd3aa15445f4183b79e3 to your computer and use it in GitHub Desktop.
electron dl typings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module ElectronDL { | |
interface ElectronDLOptions { | |
/** | |
* Show a 'Save As...' dialog instead of downloading immediately. Note: Only use this option | |
* when strictly necessary. Downloading directly without a prompt is a much better user experience. | |
* | |
* Defaults to false | |
*/ | |
saveAs: boolean; | |
/** | |
* Directory to save the file in. | |
* | |
* Defaults to user's downloads directory | |
*/ | |
directory: string; | |
/** | |
* Name of the saved file. This option only makes sense for electronDl.download(). | |
* | |
* Defaults to downloadItem.getFilename() | |
*/ | |
filename: string; | |
/** | |
* Title of the error dialog. Can be customized for localization. | |
* | |
* Defaults to Download Error | |
*/ | |
errorTitle: string; | |
/** | |
* Message of the error dialog. {filename} is replaced with the name of the actual file. | |
* Can be customized for localization. | |
* | |
* Defaults to 'The download of {filename} was interrupted | |
*/ | |
errorMessage: string; | |
/** | |
* Optional callback that receives the download item. You can use this for advanced handling | |
* such as cancelling the item with item.cancel(). | |
* @param item The item that has started downloading | |
*/ | |
onStarted: (item: DownloadItem) => any; | |
/** | |
* Optional callback that receives a number between 0 and 1 representing the progress of the current download. | |
* @param progress The progress that has been made, between 0 and 1 | |
*/ | |
onProgress: (progress: number) => any; | |
/** | |
* Optional callback that receives the downloadItem for which the download has been cancelled. | |
* @param item The download item that was cancelled | |
*/ | |
onCancel: (item: DownloadItem) => any; | |
/** | |
* Reveal the downloaded file in the system file manager, and if possible, select the file. | |
* | |
* Defaults to false | |
*/ | |
openFolderWhenDone: boolean; | |
/** | |
* Shows the file count badge on macOS/Linux dock icons when download is in progress. | |
* | |
* Defaults to true | |
*/ | |
showBadge: boolean; | |
} | |
/** | |
* Downloads a file from 'url' on the given window | |
* @param win The window to initiate the download | |
* @param url What to download | |
* @param options Optional options that can be specified | |
*/ | |
function download(win: BrowserWindow, url: string, options?: ElectronDLOptions): Promise<DownloadItem> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment