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 3.0.3 to 3.1.0

4

index.d.ts

@@ -1,2 +0,2 @@

import {BrowserWindow, DownloadItem} from 'electron';
import {BrowserView, BrowserWindow, DownloadItem} from 'electron';

@@ -124,3 +124,3 @@ declare namespace electronDl {

download(
window: BrowserWindow,
window: BrowserWindow | BrowserView,
url: string,

@@ -127,0 +127,0 @@ options?: electronDl.Options

@@ -18,2 +18,35 @@ 'use strict';

const majorElectronVersion = () => {
const version = process.versions.electron.split('.');
return parseInt(version[0], 10);
};
const getWindowFromBrowserView = webContents => {
for (const currentWindow of BrowserWindow.getAllWindows()) {
for (const currentBrowserView of currentWindow.getBrowserViews()) {
if (currentBrowserView.webContents.id === webContents.id) {
return currentWindow;
}
}
}
};
const getWindowFromWebContents = webContents => {
let window_;
const webContentsType = webContents.getType();
switch (webContentsType) {
case 'webview':
window_ = BrowserWindow.fromWebContents(webContents.hostWebContents);
break;
case 'browserView':
window_ = getWindowFromBrowserView(webContents);
break;
default:
window_ = BrowserWindow.fromWebContents(webContents);
break;
}
return window_;
};
function registerListener(session, options, callback = () => {}) {

@@ -36,9 +69,4 @@ const downloadItems = new Set();

let hostWebContents = webContents;
if (webContents.getType() === 'webview') {
({hostWebContents} = webContents);
}
const window_ = majorElectronVersion() >= 12 ? BrowserWindow.fromWebContents(webContents) : getWindowFromWebContents(webContents);
const window_ = BrowserWindow.fromWebContents(hostWebContents);
const directory = options.directory || app.getPath('downloads');

@@ -45,0 +73,0 @@ let filePath;

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

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -11,2 +11,3 @@ # electron-dl

- Handles multiple downloads.
- Support for `BrowserWindow` and `BrowserView`.
- Shows badge count *(macOS & Linux only)* and download progress. Example on macOS:

@@ -67,5 +68,5 @@

Type: `BrowserWindow`
Type: `BrowserWindow | BrowserView`
Window to register the behavior on.
Window to register the behavior on. Alternatively, a `BrowserView` can be passed.

@@ -72,0 +73,0 @@ ### url

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