electron-prompt
Advanced tools
Comparing version 1.6.2 to 1.7.0
@@ -0,11 +1,40 @@ | ||
const path = require('path'); | ||
const electron = require('electron'); | ||
const BrowserWindow = electron.BrowserWindow || electron.remote.BrowserWindow; | ||
const ipcMain = electron.ipcMain || electron.remote.ipcMain; | ||
const url = require('url'); | ||
const path = require('path'); | ||
const DEFAULT_WIDTH = 370; | ||
const DEFAULT_HEIGHT = 160; | ||
function getElectronMainExport(id) { | ||
if (electron[id]) { | ||
return electron[id]; | ||
} | ||
let remote = electron.remote; | ||
if (!remote) { | ||
try { | ||
remote = require('@electron/remote'); | ||
} catch (originalError) { | ||
const error = new Error( | ||
'Install and set-up package `@electron/remote` to use this module from a renderer processs.\n' | ||
+ 'It is preferable to set up message exchanges for this using `ipcMain.handle()` and `ipcRenderer.invoke()`,\n' | ||
+ 'avoiding remote IPC overhead costs, and one morepackage dependancy.\n\n' | ||
+ 'Original error message:\n\n' | ||
+ originalError.message, | ||
); | ||
error.originalError = originalError; | ||
throw error; | ||
} | ||
} | ||
if (remote && remote[id]) { | ||
return remote[id]; | ||
} | ||
throw new Error('Unknown electron export: ' + String(id)); | ||
} | ||
const BrowserWindow = getElectronMainExport('BrowserWindow'); | ||
const ipcMain = getElectronMainExport('ipcMain'); | ||
function electronPrompt(options, parentWindow) { | ||
@@ -33,5 +62,5 @@ return new Promise((resolve, reject) => { | ||
menuBarVisible: false, | ||
skipTaskbar: true | ||
skipTaskbar: true, | ||
}, | ||
options || {} | ||
options || {}, | ||
); | ||
@@ -62,4 +91,4 @@ | ||
nodeIntegration: true, | ||
contextIsolation: false | ||
} | ||
contextIsolation: false, | ||
}, | ||
}); | ||
@@ -113,10 +142,6 @@ | ||
const promptUrl = url.format({ | ||
protocol: 'file', | ||
slashes: true, | ||
pathname: path.join(__dirname, 'page', 'prompt.html'), | ||
hash: id | ||
}); | ||
promptWindow.loadURL(promptUrl); | ||
promptWindow.loadFile( | ||
path.join(__dirname, 'page', 'prompt.html'), | ||
{hash: id}, | ||
); | ||
}); | ||
@@ -123,0 +148,0 @@ } |
const fs = require('fs'); | ||
const {ipcRenderer} = require('electron'); | ||
const docReady = require('doc-ready'); | ||
@@ -161,2 +160,2 @@ let promptId = null; | ||
docReady(promptRegister); | ||
document.addEventListener('DOMContentLoaded', promptRegister); |
{ | ||
"name": "electron-prompt", | ||
"version": "1.6.2", | ||
"version": "1.7.0", | ||
"description": "Electron helper to prompt for a value via input or select", | ||
@@ -33,11 +33,9 @@ "keywords": [ | ||
"rules": { | ||
"unicorn/prefer-ternary": 0 | ||
"unicorn/prefer-ternary": 0, | ||
"unicorn/prefer-module": 0 | ||
} | ||
}, | ||
"dependencies": { | ||
"doc-ready": "^1.0.4" | ||
}, | ||
"devDependencies": { | ||
"xo": "^0.38.2" | ||
"xo": "^0.44.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
15707
0
315
- Removeddoc-ready@^1.0.4
- Removeddoc-ready@1.0.4(transitive)
- Removedeventie@1.0.6(transitive)