Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electron-dl

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-dl - npm Package Compare versions

Comparing version 1.13.0 to 1.14.0

207

index.d.ts

@@ -1,110 +0,123 @@

export interface Options {
/**
* 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.
*
* @default false
*/
saveAs?: boolean;
import {BrowserWindow, DownloadItem} from 'electron';
/**
* Directory to save the file in.
*
* Default: [User's downloads directory](https://electronjs.org/docs/api/app/#appgetpathname)
*/
directory?: string;
declare namespace electronDl {
interface Options {
/**
Show a `Save As…` dialog instead of downloading immediately.
/**
* Name of the saved file.
* This option only makes sense for `electronDl.download()`.
*
* Default: [`downloadItem.getFilename()`](https://electronjs.org/docs/api/download-item/#downloaditemgetfilename)
*/
filename?: string;
Note: Only use this option when strictly necessary. Downloading directly without a prompt is a much better user experience.
/**
* Title of the error dialog. Can be customized for localization.
*
* @default 'Download Error'
*/
errorTitle?: string;
@default false
*/
readonly saveAs?: boolean;
/**
* Message of the error dialog. `{filename}` is replaced with the name of the actual file. Can be customized for localization.
*
* @default 'The download of {filename} was interrupted'
*/
errorMessage?: string;
/**
Directory to save the file in.
/**
* Optional callback that receives the [download item](https://electronjs.org/docs/api/download-item).
* You can use this for advanced handling such as canceling the item like `item.cancel()`.
*/
onStarted?: (item: Electron.DownloadItem) => void;
Default: [User's downloads directory](https://electronjs.org/docs/api/app/#appgetpathname)
*/
readonly directory?: string;
/**
* Optional callback that receives a number between `0` and `1` representing the progress of the current download.
*/
onProgress?: (percent: number) => void;
/**
Name of the saved file.
This option only makes sense for `electronDl.download()`.
/**
* Optional callback that receives the [download item](https://electronjs.org/docs/api/download-item) for which the download has been cancelled.
*/
onCancel?: (item: Electron.DownloadItem) => void;
Default: [`downloadItem.getFilename()`](https://electronjs.org/docs/api/download-item/#downloaditemgetfilename)
*/
readonly filename?: string;
/**
Title of the error dialog. Can be customized for localization.
@default 'Download Error'
*/
readonly errorTitle?: string;
/**
Message of the error dialog. `{filename}` is replaced with the name of the actual file. Can be customized for localization.
@default 'The download of {filename} was interrupted'
*/
readonly errorMessage?: string;
/**
Optional callback that receives the [download item](https://electronjs.org/docs/api/download-item).
You can use this for advanced handling such as canceling the item like `item.cancel()`.
*/
readonly onStarted?: (item: DownloadItem) => void;
/**
Optional callback that receives a number between `0` and `1` representing the progress of the current download.
*/
readonly onProgress?: (percent: number) => void;
/**
Optional callback that receives the [download item](https://electronjs.org/docs/api/download-item) for which the download has been cancelled.
*/
readonly onCancel?: (item: DownloadItem) => void;
/**
Reveal the downloaded file in the system file manager, and if possible, select the file.
@default false
*/
readonly openFolderWhenDone?: boolean;
/**
Shows the file count badge on macOS/Linux dock icons when download is in progress.
@default true
*/
readonly showBadge?: boolean;
}
}
declare const electronDl: {
/**
* Reveal the downloaded file in the system file manager, and if possible, select the file.
*
* @default false
*/
openFolderWhenDone?: boolean;
Register the helper for all windows.
@example
```
import {app, BrowserWindow} from 'electron';
import electronDl = require('electron-dl');
electronDl();
let win;
(async () => {
await app.whenReady();
win = new BrowserWindow();
})();
```
*/
(options?: electronDl.Options): void;
/**
* Shows the file count badge on macOS/Linux dock icons when download is in progress.
*
* @default true
*/
showBadge?: boolean;
}
This can be useful if you need download functionality in a reusable module.
/**
* Register the helper for all windows.
*
* @example
*
* import {app, BrowserWindow} from 'electron';
* import electronDl from 'electron-dl';
*
* electronDl();
*
* let win;
* app.on('ready', () => {
* win = new BrowserWindow();
* });
*/
export default function electronDl(options?: Options): void;
@param window - Window to register the behavior on.
@param url - URL to download.
@returns A promise for the downloaded file.
/**
* This can be useful if you need download functionality in a reusable module.
*
* @param window - Window to register the behavior on.
* @param url - URL to download.
* @param options
* @returns A promise for the downloaded file.
*
* @example
*
* import {BrowserWindow, ipcMain} from 'electron';
* import {download} from 'electron-dl';
*
* ipcMain.on('download-button', async (event, {url}) => {
* const win = BrowserWindow.getFocusedWindow();
* console.log(await download(win, url));
* });
*/
export function download(
window: Electron.BrowserWindow,
url: string,
options?: Options
): Promise<Electron.DownloadItem>;
@example
```
import {BrowserWindow, ipcMain} from 'electron';
import electronDl = require('electron-dl');
ipcMain.on('download-button', async (event, {url}) => {
const win = BrowserWindow.getFocusedWindow();
console.log(await electronDl.download(win, url));
});
```
*/
download(
window: BrowserWindow,
url: string,
options?: electronDl.Options
): Promise<DownloadItem>;
// TODO: Remove this for the next major release
default: typeof electronDl;
};
export = electronDl;

@@ -132,2 +132,3 @@ 'use strict';

// TODO: Remove this for the next major release
module.exports.default = module.exports;

@@ -134,0 +135,0 @@

{
"name": "electron-dl",
"version": "1.13.0",
"version": "1.14.0",
"description": "Simplified file downloads for your Electron app",

@@ -14,3 +14,3 @@ "license": "MIT",

"start": "electron run.js",
"test": "xo && ava && tsd-check"
"test": "xo && ava && tsd"
},

@@ -35,11 +35,12 @@ "files": [

"devDependencies": {
"ava": "^1.2.0",
"cp-file": "^6.0.0",
"@types/node": "^11.13.0",
"ava": "^1.4.1",
"cp-file": "^6.2.0",
"electron": "^3.1.2",
"minimist": "^1.2.0",
"node-static": "^0.7.9",
"node-static": "^0.7.11",
"pify": "^4.0.1",
"spectron": "^5.0.0",
"tsd-check": "^0.3.0",
"uuid": "^3.1.0",
"tsd": "^0.7.2",
"uuid": "^3.3.2",
"xo": "^0.24.0"

@@ -46,0 +47,0 @@ },

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