Socket
Socket
Sign inDemoInstall

electron-log

Package Overview
Dependencies
Maintainers
1
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-log - npm Package Compare versions

Comparing version 5.1.0 to 5.1.1

src/main/__specs__/ElectronExternalApi.spec.js

2

package.json
{
"name": "electron-log",
"version": "5.1.0",
"version": "5.1.1",
"description": "Just a simple logging module for your Electron application",

@@ -5,0 +5,0 @@ "main": "src/index.js",

'use strict';
const electron = require('electron');
const path = require('path');

@@ -8,8 +7,24 @@ const NodeExternalApi = require('../node/NodeExternalApi');

class ElectronExternalApi extends NodeExternalApi {
/**
* @type {typeof Electron}
*/
electron = undefined;
/**
* @param {object} options
* @param {typeof Electron} [options.electron]
*/
constructor({ electron } = {}) {
super();
this.electron = electron;
}
getAppName() {
let appName;
try {
return electron.app?.name || electron.app?.getName();
appName = this.electron.app?.name || this.electron.app?.getName();
} catch {
return super.getAppName();
// fallback to default value below
}
return appName || super.getAppName();
}

@@ -22,7 +37,9 @@

getAppVersion() {
let appVersion;
try {
return electron.app?.getVersion();
appVersion = this.electron.app?.getVersion();
} catch {
return super.getAppVersion();
// fallback to default value below
}
return appVersion || super.getAppVersion();
}

@@ -41,3 +58,3 @@

try {
return electron.app?.getPath(name);
return this.electron.app?.getPath(name);
} catch {

@@ -61,4 +78,4 @@ return undefined;

isDev() {
if (electron.app?.isPackaged !== undefined) {
return !electron.app.isPackaged;
if (this.electron.app?.isPackaged !== undefined) {
return !this.electron.app.isPackaged;
}

@@ -75,6 +92,6 @@

onAppEvent(eventName, handler) {
electron.app?.on(eventName, handler);
this.electron.app?.on(eventName, handler);
return () => {
electron.app?.off(eventName, handler);
this.electron.app?.off(eventName, handler);
};

@@ -84,6 +101,6 @@ }

onAppReady(handler) {
if (electron.app?.isReady()) {
if (this.electron.app?.isReady()) {
handler();
} else if (electron.app?.once) {
electron.app?.once('ready', handler);
} else if (this.electron.app?.once) {
this.electron.app?.once('ready', handler);
} else {

@@ -95,14 +112,14 @@ handler();

onEveryWebContentsEvent(eventName, handler) {
electron.webContents?.getAllWebContents().forEach((webContents) => {
this.electron.webContents?.getAllWebContents()?.forEach((webContents) => {
webContents.on(eventName, handler);
});
electron.app?.on('web-contents-created', onWebContentsCreated);
this.electron.app?.on('web-contents-created', onWebContentsCreated);
return () => {
electron.webContents?.getAllWebContents().forEach((webContents) => {
this.electron.webContents?.getAllWebContents().forEach((webContents) => {
webContents.off(eventName, handler);
});
electron.app?.off('web-contents-created', onWebContentsCreated);
this.electron.app?.off('web-contents-created', onWebContentsCreated);
};

@@ -121,7 +138,7 @@

onIpc(channel, listener) {
electron.ipcMain?.on(channel, listener);
this.electron.ipcMain?.on(channel, listener);
}
onIpcInvoke(channel, listener) {
electron.ipcMain?.handle?.(channel, listener);
this.electron.ipcMain?.handle?.(channel, listener);
}

@@ -134,3 +151,3 @@

openUrl(url, logFunction = console.error) { // eslint-disable-line no-console
electron.shell?.openExternal(url).catch(logFunction);
this.electron.shell?.openExternal(url).catch(logFunction);
}

@@ -141,3 +158,3 @@

includeFutureSession = true,
getSessions = () => [electron.session?.defaultSession],
getSessions = () => [this.electron.session?.defaultSession],
}) {

@@ -168,3 +185,3 @@ for (const session of getSessions().filter(Boolean)) {

sendIpc(channel, message) {
electron.BrowserWindow?.getAllWindows().forEach((wnd) => {
this.electron.BrowserWindow?.getAllWindows()?.forEach((wnd) => {
if (wnd.webContents?.isDestroyed() === false) {

@@ -177,3 +194,3 @@ wnd.webContents.send(channel, message);

showErrorBox(title, message) {
electron.dialog?.showErrorBox(title, message);
this.electron.dialog?.showErrorBox(title, message);
}

@@ -180,0 +197,0 @@ }

'use strict';
const electron = require('electron');
const ElectronExternalApi = require('./ElectronExternalApi');

@@ -7,3 +8,3 @@ const { initialize } = require('./initialize');

const externalApi = new ElectronExternalApi();
const externalApi = new ElectronExternalApi({ electron });
const defaultLogger = createDefaultLogger({

@@ -10,0 +11,0 @@ dependencies: { externalApi },

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