electron-dl
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -9,2 +9,10 @@ import {BrowserView, BrowserWindow, DownloadItem} from 'electron'; | ||
} | ||
interface File { | ||
filename: string, | ||
path: string, | ||
fileSize: number, | ||
mimeType: string, | ||
url: string | ||
} | ||
@@ -64,2 +72,10 @@ interface Options { | ||
readonly onProgress?: (progress: Progress) => void; | ||
/** | ||
Optional callback that receives an object containing information about the combined progress of all download items done within any registered window. | ||
Each time a new download is started, the next callback will include it. The progress percentage could therefore become smaller again. | ||
This callback provides the same data that is used for the progress bar on the app icon. | ||
*/ | ||
readonly onTotalProgress?: (file: File) => void; | ||
@@ -70,2 +86,7 @@ /** | ||
readonly onCancel?: (item: DownloadItem) => void; | ||
/** | ||
Optional callback that receives an object with information about an item that has been completed. It is called for each completed item. | ||
*/ | ||
readonly onCompleted?: (completed: Completed) => void; | ||
@@ -72,0 +93,0 @@ /** |
18
index.js
@@ -116,2 +116,10 @@ 'use strict'; | ||
} | ||
if (typeof options.onTotalProgress === 'function') { | ||
options.onTotalProgress({ | ||
percent: progressDownloadItems(), | ||
transferredBytes: receivedBytes, | ||
totalBytes | ||
}); | ||
} | ||
}); | ||
@@ -154,2 +162,12 @@ | ||
if (typeof options.onCompleted === 'function') { | ||
options.onCompleted({ | ||
fileName: item.getFilename(), | ||
path: item.getSavePath(), | ||
fileSize: item.getReceivedBytes(), | ||
mimeType: item.getMimeType(), | ||
url: item.getURL() | ||
}); | ||
} | ||
callback(null, item); | ||
@@ -156,0 +174,0 @@ } |
{ | ||
"name": "electron-dl", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Simplified file downloads for your Electron app", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -145,2 +145,19 @@ # electron-dl | ||
#### onTotalProgress | ||
Type: `Function` | ||
Optional callback that receives an object containing information about the combined progress of all download items done within any registered window. | ||
Each time a new download is started, the next callback will include it. The progress percentage could therefore become smaller again. | ||
This callback provides the same data that is used for the progress bar on the app icon. | ||
```js | ||
{ | ||
percent: 0.1, | ||
transferredBytes: 100, | ||
totalBytes: 1000 | ||
} | ||
``` | ||
#### onCancel | ||
@@ -152,2 +169,17 @@ | ||
#### onCompleted | ||
Type: `Function` | ||
Optional callback that receives an object with information about an item that has been completed. It is called for each completed item. | ||
```js | ||
{ | ||
filename: 'file.zip', | ||
path: '/path/file.zip', | ||
fileSize: 503320, | ||
mimeType: 'application/zip', | ||
url: 'https://example.com/file.zip' | ||
} | ||
#### openFolderWhenDone | ||
@@ -154,0 +186,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17011
288
217