Skip to content

Commit

Permalink
Immediate download fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
theogravity committed Mar 22, 2024
1 parent 98b17b8 commit bf59114
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.2.1 (2024-03-21)

- More immediate download fixes

# 1.2.0 (2024-03-21)

- Fixes a major issue where a download would not complete if using the save as dialog
Expand Down
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,38 @@ interface DownloadParams {

```typescript
interface DownloadManagerCallbacks {
/**
* When the download has started. When using a "save as" dialog,
* this will be called after the user has selected a location.
*
* This will always be called first before the progress and completed events.
*/
onDownloadStarted: (data: DownloadManagerCallbackData) => void
/**
* When there is a progress update on a download. Note: This
* may be skipped entirely in some cases, where the download
* completes immediately. In that case, onDownloadCompleted
* will be called instead.
*/
onDownloadProgress: (data: DownloadManagerCallbackData) => void
/**
* When the download has completed
*/
onDownloadCompleted: (data: DownloadManagerCallbackData) => void
/**
* When the download has been cancelled. Also called if the user cancels
* from the save as dialog.
*/
onDownloadCancelled: (data: DownloadManagerCallbackData) => void
/**
* When the download has been interrupted. This could be due to a bad
* connection, the server going down, etc.
*/
onDownloadInterrupted: (data: DownloadManagerCallbackData) => void
// Note: data may be undefined or be incomplete
/**
* When an error has been encountered.
* Note: The signature is (error, <maybe some data>).
*/
onError: (error: Error, data?: Partial<DownloadManagerCallbackData>) => void
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "electron-dl-manager",
"version": "1.2.0",
"version": "1.2.1",
"description": "A library for implementing file downloads in Electron with 'save as' dialog and id support.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
19 changes: 14 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,36 @@ export interface DownloadManagerConstructorParams {

export interface DownloadManagerCallbacks {
/**
* When the download has started.
* When the download has started. When using a "save as" dialog,
* this will be called after the user has selected a location.
*
* This will always be called first before the progress and completed events.
*/
onDownloadStarted?: DownloadStartedFn
/**
* When there is a progress update on a download
* When there is a progress update on a download. Note: This
* may be skipped entirely in some cases, where the download
* completes immediately. In that case, onDownloadCompleted
* will be called instead.
*/
onDownloadProgress?: DownloadProgressFn
/**
* When the download has completed
*/
onDownloadCompleted?: DownloadCompletedFn
/**
* When the download has been cancelled
* When the download has been cancelled. Also called if the user cancels
* from the save as dialog.
*/
onDownloadCancelled?: DownloadCancelledFn
/**
* When the download has been interrupted
* When the download has been interrupted. This could be due to a bad
* connection, the server going down, etc.
*/
onDownloadInterrupted?: DownloadInterruptedFn
/**
* When an error has been encountered. Note the signature is (error, <maybe some data>).
* When an error has been encountered.
* Note: The signature is (error, <maybe some data>).
*/
onError?: ErrorFn
}
Expand Down

0 comments on commit bf59114

Please sign in to comment.