mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18: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');
|
||||
//eslint-disable-next-line no-empty
|
||||
} catch (err) {}
|
||||
|
||||
if (squirrel) {
|
||||
// eslint-disable-next-line unicorn/no-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 => {
|
||||
modules.forEach(plugin => {
|
||||
if (plugin.onWindow) {
|
||||
|
|
@ -417,6 +431,10 @@ exports.getDecoratedBrowserOptions = defaults => {
|
|||
return decorateObject(defaults, 'decorateBrowserOptions');
|
||||
};
|
||||
|
||||
exports.decorateWindowClass = defaults => {
|
||||
return decorateObject(defaults, 'decorateWindowClass');
|
||||
};
|
||||
|
||||
exports.decorateSessionOptions = defaults => {
|
||||
return decorateObject(defaults, 'decorateSessionOptions');
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
module.exports = {
|
||||
availableExtensions: new Set([
|
||||
'onApp',
|
||||
'onWindowClass',
|
||||
'decorateWindowClass',
|
||||
'onWindow',
|
||||
'onRendererWindow',
|
||||
'onUnload',
|
||||
|
|
|
|||
|
|
@ -18,6 +18,12 @@ const {decorateSessionOptions, decorateSessionClass} = require('../plugins');
|
|||
|
||||
module.exports = class Window {
|
||||
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(
|
||||
{
|
||||
minWidth: 370,
|
||||
|
|
@ -34,7 +40,10 @@ module.exports = class Window {
|
|||
},
|
||||
options_
|
||||
);
|
||||
|
||||
const window = new BrowserWindow(app.plugins.getDecoratedBrowserOptions(winOpts));
|
||||
window.uid = classOpts.uid;
|
||||
|
||||
const rpc = createRPC(window);
|
||||
const sessions = new Map();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue