mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Adds plugin hook for decorating the electron browser options (#310)
* adds hook for decorating the electron browser options * pass browser options to decorator
This commit is contained in:
parent
c573001774
commit
b06f28ae10
2 changed files with 21 additions and 2 deletions
7
index.js
7
index.js
|
|
@ -48,7 +48,7 @@ app.on('ready', () => {
|
|||
function createWindow (fn) {
|
||||
const cfg = plugins.getDecoratedConfig();
|
||||
|
||||
const win = new BrowserWindow({
|
||||
const browserDefaults = {
|
||||
width: 540,
|
||||
height: 380,
|
||||
minHeight: 190,
|
||||
|
|
@ -61,7 +61,10 @@ app.on('ready', () => {
|
|||
// we only want to show when the prompt
|
||||
// is ready for user input
|
||||
show: process.env.HYPERTERM_DEBUG || isDev
|
||||
});
|
||||
};
|
||||
const browserOptions = plugins.getDecoratedBrowserOptions(browserDefaults);
|
||||
|
||||
const win = new BrowserWindow(browserOptions);
|
||||
|
||||
windowSet.add(win);
|
||||
win.loadURL(url);
|
||||
|
|
|
|||
16
plugins.js
16
plugins.js
|
|
@ -311,3 +311,19 @@ exports.getDecoratedConfig = function () {
|
|||
});
|
||||
return decorated;
|
||||
};
|
||||
|
||||
exports.getDecoratedBrowserOptions = function (defaults) {
|
||||
let decorated = defaults;
|
||||
modules.forEach((plugin) => {
|
||||
if (plugin.decorateBrowserOptions) {
|
||||
const res = plugin.decorateBrowserOptions(decorated);
|
||||
if (res && 'object' === typeof res) {
|
||||
decorated = res;
|
||||
} else {
|
||||
notify('Plugin error!', `"${plugin._name}": invalid return type for \`decorateBrowserOptions\``);
|
||||
}
|
||||
}
|
||||
});
|
||||
return decorated;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue