mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Expose 'getWindows' and 'createWindow' to plugins (#248)
This commit is contained in:
parent
610d6c6d3e
commit
17af6cb85d
1 changed files with 9 additions and 4 deletions
13
index.js
13
index.js
|
|
@ -13,9 +13,12 @@ const config = require('./config');
|
|||
config.init();
|
||||
const plugins = require('./plugins');
|
||||
|
||||
const windowSet = new Set([]);
|
||||
|
||||
// expose to plugins
|
||||
app.config = config;
|
||||
app.plugins = plugins;
|
||||
app.getWindows = () => new Set([...windowSet]); // return a clone
|
||||
|
||||
if (isDev) {
|
||||
console.log('running in dev mode');
|
||||
|
|
@ -40,7 +43,6 @@ app.on('window-all-closed', () => {
|
|||
// terminal is closed
|
||||
});
|
||||
|
||||
let winCount = 0;
|
||||
app.on('ready', () => {
|
||||
function createWindow (fn) {
|
||||
const cfg = plugins.getDecoratedConfig();
|
||||
|
|
@ -60,7 +62,7 @@ app.on('ready', () => {
|
|||
show: process.env.HYPERTERM_DEBUG || isDev
|
||||
});
|
||||
|
||||
winCount++;
|
||||
windowSet.add(win);
|
||||
win.loadURL(url);
|
||||
|
||||
const rpc = createRPC(win);
|
||||
|
|
@ -195,7 +197,7 @@ app.on('ready', () => {
|
|||
|
||||
// the window can be closed by the browser process itself
|
||||
win.on('close', () => {
|
||||
winCount--;
|
||||
windowSet.delete(win);
|
||||
rpc.destroy();
|
||||
deleteSessions();
|
||||
cfgUnsubscribe();
|
||||
|
|
@ -206,11 +208,14 @@ app.on('ready', () => {
|
|||
// when opening create a new window
|
||||
createWindow();
|
||||
|
||||
// expose to plugins
|
||||
app.createWindow = createWindow;
|
||||
|
||||
// mac only. when the dock icon is clicked
|
||||
// and we don't have any active windows open,
|
||||
// we open one
|
||||
app.on('activate', () => {
|
||||
if (!winCount) {
|
||||
if (!windowSet.size) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue