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

electron-about-window

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-about-window - npm Package Compare versions

Comparing version 1.14.0 to 1.15.0

CHANGELOG.md

14

package.json
{
"name": "electron-about-window",
"version": "1.14.0",
"version": "1.15.0",
"description": "'About App' window for Electron application",

@@ -37,10 +37,10 @@ "main": "src/index.js",

"devDependencies": {
"@types/node": "^14.x",
"electron": "^12.0.0",
"prettier": "^2.2.1",
"stylelint": "^13.12.0",
"stylelint-config-standard": "^21.0.0",
"@types/node": "^16.x",
"electron": "^15.1.0",
"prettier": "^2.4.1",
"stylelint": "^13.13.1",
"stylelint-config-standard": "^22.0.0",
"tslint": "^6.1.2",
"typescript": "^4.2.3"
"typescript": "^4.4.3"
}
}

@@ -24,2 +24,4 @@ 'About This App' Window for [Electron](https://github.com/atom/electron) Apps

## Usage
Only one function is exported as default. Please see [TypeScript type definition](index.d.ts).

@@ -45,2 +47,5 @@ The function can be called from both main process and renderer process.

show_close_button?: string;
app?: Electron.App;
BrowserWindow?: typeof Electron.BrowserWindow;
ipcMain?: Electron.IpcMain;
}): BrowserWindow

@@ -98,2 +103,5 @@ ```

| `about_page_dir` | Directory path which contains `about.html` which is rendered in 'About this app' window. **Optional** | string |
| `app` | [app](https://www.electronjs.org/docs/latest/api/app) instance to use. This property is necessary only when using on renderer processes. **Optional** | Electron.App |
| `BrowserWindow` | Constructor of [BrowserWindow](https://www.electronjs.org/docs/latest/api/browser-window) to use. This property is necessary only when using on renderer processes. **Optional** | Electron.App |
| `ipcMain` | [ipcMain](https://www.electronjs.org/docs/latest/api/ipc-main) instance to use. This property is necessary only when using on renderer processes. **Optional** | Electron.App |

@@ -103,2 +111,19 @@ **Note:** If you set `use_inner_html` to `true`, please ensure that contents don't contain any untrusted external input

### Open the window from non-main process
Since `openAboutWindow()` depends on several APIs only available on main process, they must be provided by caller when it is called on non-main process.
To mimic the APIs, use [`@electron/remote`](https://www.npmjs.com/package/@electron/remote) module.
```typescript
import {app, BrowserWindow, ipcMain} from '@electron/remote';
openAboutWindow({
icon_path: 'path/to/icon.png'
app,
BrowserWindow,
ipcMain,
});
```
## Screen Shots

@@ -105,0 +130,0 @@

@@ -6,4 +6,2 @@ "use strict";

const path = require("path");
const app = electron_1.app || (electron_1.remote === null || electron_1.remote === void 0 ? void 0 : electron_1.remote.app);
const BrowserWindow = electron_1.BrowserWindow || (electron_1.remote === null || electron_1.remote === void 0 ? void 0 : electron_1.remote.BrowserWindow);
function loadPackageJson(pkg_path) {

@@ -17,3 +15,3 @@ try {

}
function detectPackageJson(specified_dir) {
function detectPackageJson(specified_dir, app) {
if (specified_dir) {

@@ -35,3 +33,3 @@ const pkg = loadPackageJson(path.join(specified_dir, 'package.json'));

try {
const stats = fs_1.statSync(p);
const stats = (0, fs_1.statSync)(p);
if (stats.isFile()) {

@@ -49,4 +47,4 @@ const pkg = loadPackageJson(p);

}
function injectInfoFromPackageJson(info) {
const pkg = detectPackageJson(info.package_json_dir);
function injectInfoFromPackageJson(info, app) {
const pkg = detectPackageJson(info.package_json_dir, app);
if (pkg === null) {

@@ -97,2 +95,8 @@ return info;

let info = normalizeParam(info_or_img_path);
const ipc = electron_1.ipcMain !== null && electron_1.ipcMain !== void 0 ? electron_1.ipcMain : info.ipcMain;
const app = electron_1.app !== null && electron_1.app !== void 0 ? electron_1.app : info.app;
const BrowserWindow = electron_1.BrowserWindow !== null && electron_1.BrowserWindow !== void 0 ? electron_1.BrowserWindow : info.BrowserWindow;
if (!app || !BrowserWindow || !ipc) {
throw new Error("openAboutWindow() is called on non-main process. Set 'app', 'BrowserWindow' and 'ipcMain' properties in the 'info' argument of the function call");
}
if (window !== null) {

@@ -116,3 +120,2 @@ window.focus();

nodeIntegration: true,
enableRemoteModule: true,
contextIsolation: false,

@@ -122,4 +125,21 @@ },

window = new BrowserWindow(options);
const on_win_adjust_req = (_, width, height, show_close_button) => {
if (height > 0 && width > 0) {
if (show_close_button) {
window.setContentSize(width, height + 40);
}
else {
window.setContentSize(width, height + 52);
}
}
};
const on_win_close_req = () => {
window.close();
};
ipc.on('about-window:adjust-window-size', on_win_adjust_req);
ipc.on('about-window:close-window', on_win_close_req);
window.once('closed', () => {
window = null;
ipc.removeListener('about-window:adjust-window-size', on_win_adjust_req);
ipc.removeListener('about-window:close-window', on_win_close_req);
});

@@ -139,3 +159,5 @@ window.loadURL(index_html);

info.win_options = { title: win_title };
window.webContents.send('about-window:info', info);
const app_name = info.product_name || app.name || app.getName();
const version = app.getVersion();
window.webContents.send('about-window:info', info, app_name, version);
if (info.open_devtools) {

@@ -154,3 +176,3 @@ if (process.versions.electron >= '1.4') {

window.setMenu(null);
info = injectInfoFromPackageJson(info);
info = injectInfoFromPackageJson(info, app);
return window;

@@ -157,0 +179,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const electron_1 = require("electron");
electron_1.ipcRenderer.on('about-window:info', (_, info) => {
const app_name = info.product_name || electron_1.remote.app.name || electron_1.remote.app.getName();
electron_1.ipcRenderer.on('about-window:info', (_, info, app_name, version) => {
const open_home = () => electron_1.shell.openExternal(info.homepage);

@@ -10,3 +9,3 @@ const content = info.use_inner_html ? 'innerHTML' : 'innerText';

const title_elem = document.querySelector('.title');
title_elem.innerText = `${app_name} ${electron_1.remote.app.getVersion()}`;
title_elem.innerText = `${app_name} ${version}`;
if (info.homepage) {

@@ -52,11 +51,3 @@ title_elem.addEventListener('click', open_home);

const width = document.body.scrollWidth;
const win = electron_1.remote.getCurrentWindow();
if (height > 0 && width > 0) {
if (info.show_close_button) {
win.setContentSize(width, height + 40);
}
else {
win.setContentSize(width, height + 52);
}
}
electron_1.ipcRenderer.send('about-window:adjust-window-size', height, width, !!info.show_close_button);
}

@@ -85,3 +76,3 @@ if (!!info.use_version_info) {

e.preventDefault();
electron_1.remote.getCurrentWindow().close();
electron_1.ipcRenderer.send('about-window:close-window');
});

@@ -88,0 +79,0 @@ buttons.appendChild(close_button);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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