mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
Add Window class and options plugin decoration (#3485)
* Add Window class and optios plugin decoration * Propatation to BrowserWindow
This commit is contained in:
parent
1747c57bc3
commit
2d399baa87
4 changed files with 29 additions and 1 deletions
|
|
@ -19,7 +19,6 @@ const checkSquirrel = () => {
|
||||||
squirrel = require('electron-squirrel-startup');
|
squirrel = require('electron-squirrel-startup');
|
||||||
//eslint-disable-next-line no-empty
|
//eslint-disable-next-line no-empty
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
|
|
||||||
if (squirrel) {
|
if (squirrel) {
|
||||||
// eslint-disable-next-line unicorn/no-process-exit
|
// eslint-disable-next-line unicorn/no-process-exit
|
||||||
process.exit();
|
process.exit();
|
||||||
|
|
|
||||||
|
|
@ -318,6 +318,20 @@ exports.onApp = app_ => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.onWindowClass = win => {
|
||||||
|
modules.forEach(plugin => {
|
||||||
|
if (plugin.onWindowClass) {
|
||||||
|
try {
|
||||||
|
plugin.onWindowClass(win);
|
||||||
|
} catch (e) {
|
||||||
|
notify('Plugin error!', `"${plugin._name}" has encountered an error. Check Developer Tools for details.`, {
|
||||||
|
error: e
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
exports.onWindow = win => {
|
exports.onWindow = win => {
|
||||||
modules.forEach(plugin => {
|
modules.forEach(plugin => {
|
||||||
if (plugin.onWindow) {
|
if (plugin.onWindow) {
|
||||||
|
|
@ -417,6 +431,10 @@ exports.getDecoratedBrowserOptions = defaults => {
|
||||||
return decorateObject(defaults, 'decorateBrowserOptions');
|
return decorateObject(defaults, 'decorateBrowserOptions');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.decorateWindowClass = defaults => {
|
||||||
|
return decorateObject(defaults, 'decorateWindowClass');
|
||||||
|
};
|
||||||
|
|
||||||
exports.decorateSessionOptions = defaults => {
|
exports.decorateSessionOptions = defaults => {
|
||||||
return decorateObject(defaults, 'decorateSessionOptions');
|
return decorateObject(defaults, 'decorateSessionOptions');
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
availableExtensions: new Set([
|
availableExtensions: new Set([
|
||||||
'onApp',
|
'onApp',
|
||||||
|
'onWindowClass',
|
||||||
|
'decorateWindowClass',
|
||||||
'onWindow',
|
'onWindow',
|
||||||
'onRendererWindow',
|
'onRendererWindow',
|
||||||
'onUnload',
|
'onUnload',
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,12 @@ const {decorateSessionOptions, decorateSessionClass} = require('../plugins');
|
||||||
|
|
||||||
module.exports = class Window {
|
module.exports = class Window {
|
||||||
constructor(options_, cfg, fn) {
|
constructor(options_, cfg, fn) {
|
||||||
|
const classOpts = Object.assign({uid: uuid.v4()});
|
||||||
|
app.plugins.decorateWindowClass(classOpts);
|
||||||
|
this.uid = classOpts.uid;
|
||||||
|
|
||||||
|
app.plugins.onWindowClass(this);
|
||||||
|
|
||||||
const winOpts = Object.assign(
|
const winOpts = Object.assign(
|
||||||
{
|
{
|
||||||
minWidth: 370,
|
minWidth: 370,
|
||||||
|
|
@ -34,7 +40,10 @@ module.exports = class Window {
|
||||||
},
|
},
|
||||||
options_
|
options_
|
||||||
);
|
);
|
||||||
|
|
||||||
const window = new BrowserWindow(app.plugins.getDecoratedBrowserOptions(winOpts));
|
const window = new BrowserWindow(app.plugins.getDecoratedBrowserOptions(winOpts));
|
||||||
|
window.uid = classOpts.uid;
|
||||||
|
|
||||||
const rpc = createRPC(window);
|
const rpc = createRPC(window);
|
||||||
const sessions = new Map();
|
const sessions = new Map();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue