442: maintain references between socket.io connection events

https://github.com/ElectronNET/Electron.NET/issues/442

remove deletes of modules during disconnect
add delete of hostHook during disconnect
check if modules exist before importing them curring connect
move local caches of modules into global scope.
This commit is contained in:
Dan Gidman
2020-10-06 11:29:53 -05:00
parent b525bf1a9a
commit e73655bd68
11 changed files with 429 additions and 412 deletions

View File

@@ -1,41 +1,56 @@
"use strict";
const electron_1 = require("electron");
let browserViews = [];
let browserView, electronSocket;
module.exports = (socket) => {
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var electron_1 = require("electron");
var browserViews = (global['browserViews'] = global['browserViews'] || []);
var browserView, electronSocket;
module.exports = function (socket) {
electronSocket = socket;
socket.on('createBrowserView', (options) => {
socket.on('createBrowserView', function (options) {
if (!hasOwnChildreen(options, 'webPreferences', 'nodeIntegration')) {
options = { ...options, webPreferences: { nodeIntegration: true } };
options = __assign(__assign({}, options), { webPreferences: { nodeIntegration: true } });
}
browserView = new electron_1.BrowserView(options);
browserViews.push(browserView);
electronSocket.emit('BrowserViewCreated', browserView.id);
});
socket.on('browserView-isDestroyed', (id) => {
const isDestroyed = getBrowserViewById(id).isDestroyed();
socket.on('browserView-isDestroyed', function (id) {
var isDestroyed = getBrowserViewById(id).isDestroyed();
electronSocket.emit('browserView-isDestroyed-reply', isDestroyed);
});
socket.on('browserView-getBounds', (id) => {
const bounds = getBrowserViewById(id).getBounds();
socket.on('browserView-getBounds', function (id) {
var bounds = getBrowserViewById(id).getBounds();
electronSocket.emit('browserView-getBounds-reply', bounds);
});
socket.on('browserView-setBounds', (id, bounds) => {
socket.on('browserView-setBounds', function (id, bounds) {
getBrowserViewById(id).setBounds(bounds);
});
socket.on('browserView-destroy', (id) => {
const browserViewIndex = browserViews.findIndex(b => b.id === id);
socket.on('browserView-destroy', function (id) {
var browserViewIndex = browserViews.findIndex(function (b) { return b.id === id; });
getBrowserViewById(id).destroy();
browserViews.splice(browserViewIndex, 1);
});
socket.on('browserView-setAutoResize', (id, options) => {
socket.on('browserView-setAutoResize', function (id, options) {
getBrowserViewById(id).setAutoResize(options);
});
socket.on('browserView-setBackgroundColor', (id, color) => {
socket.on('browserView-setBackgroundColor', function (id, color) {
getBrowserViewById(id).setBackgroundColor(color);
});
function hasOwnChildreen(obj, ...childNames) {
for (let i = 0; i < childNames.length; i++) {
function hasOwnChildreen(obj) {
var childNames = [];
for (var _i = 1; _i < arguments.length; _i++) {
childNames[_i - 1] = arguments[_i];
}
for (var i = 0; i < childNames.length; i++) {
if (!obj || !obj.hasOwnProperty(childNames[i])) {
return false;
}
@@ -44,12 +59,11 @@ module.exports = (socket) => {
return true;
}
function getBrowserViewById(id) {
for (let index = 0; index < browserViews.length; index++) {
const browserViewItem = browserViews[index];
for (var index = 0; index < browserViews.length; index++) {
var browserViewItem = browserViews[index];
if (browserViewItem.id === id) {
return browserViewItem;
}
}
}
};
//# sourceMappingURL=browserView.js.map

View File

@@ -1,5 +1,5 @@
import { BrowserView } from 'electron';
let browserViews: Electron.BrowserView[] = [];
let browserViews: BrowserView[] = (global['browserViews'] = global['browserViews'] || []) as BrowserView[];
let browserView: BrowserView, electronSocket;
export = (socket: SocketIO.Socket) => {

View File

@@ -1,173 +1,184 @@
"use strict";
const electron_1 = require("electron");
const path = require('path');
const windows = [];
let readyToShowWindowsIds = [];
let window, lastOptions, electronSocket;
let mainWindowURL;
module.exports = (socket, app) => {
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var electron_1 = require("electron");
var path = require('path');
var windows = (global['browserWindows'] = global['browserWindows'] || []);
var readyToShowWindowsIds = [];
var window, lastOptions, electronSocket;
var mainWindowURL;
module.exports = function (socket, app) {
electronSocket = socket;
socket.on('register-browserWindow-ready-to-show', (id) => {
socket.on('register-browserWindow-ready-to-show', function (id) {
if (readyToShowWindowsIds.includes(id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== id);
readyToShowWindowsIds = readyToShowWindowsIds.filter(function (value) { return value !== id; });
electronSocket.emit('browserWindow-ready-to-show' + id);
}
getWindowById(id).on('ready-to-show', () => {
getWindowById(id).on('ready-to-show', function () {
readyToShowWindowsIds.push(id);
electronSocket.emit('browserWindow-ready-to-show' + id);
});
});
socket.on('register-browserWindow-page-title-updated', (id) => {
getWindowById(id).on('page-title-updated', (event, title) => {
socket.on('register-browserWindow-page-title-updated', function (id) {
getWindowById(id).on('page-title-updated', function (event, title) {
electronSocket.emit('browserWindow-page-title-updated' + id, title);
});
});
socket.on('register-browserWindow-close', (id) => {
getWindowById(id).on('close', () => {
socket.on('register-browserWindow-close', function (id) {
getWindowById(id).on('close', function () {
electronSocket.emit('browserWindow-close' + id);
});
});
socket.on('register-browserWindow-closed', (id) => {
getWindowById(id).on('closed', () => {
socket.on('register-browserWindow-closed', function (id) {
getWindowById(id).on('closed', function () {
electronSocket.emit('browserWindow-closed' + id);
});
});
socket.on('register-browserWindow-session-end', (id) => {
getWindowById(id).on('session-end', () => {
socket.on('register-browserWindow-session-end', function (id) {
getWindowById(id).on('session-end', function () {
electronSocket.emit('browserWindow-session-end' + id);
});
});
socket.on('register-browserWindow-unresponsive', (id) => {
getWindowById(id).on('unresponsive', () => {
socket.on('register-browserWindow-unresponsive', function (id) {
getWindowById(id).on('unresponsive', function () {
electronSocket.emit('browserWindow-unresponsive' + id);
});
});
socket.on('register-browserWindow-responsive', (id) => {
getWindowById(id).on('responsive', () => {
socket.on('register-browserWindow-responsive', function (id) {
getWindowById(id).on('responsive', function () {
electronSocket.emit('browserWindow-responsive' + id);
});
});
socket.on('register-browserWindow-blur', (id) => {
getWindowById(id).on('blur', () => {
socket.on('register-browserWindow-blur', function (id) {
getWindowById(id).on('blur', function () {
electronSocket.emit('browserWindow-blur' + id);
});
});
socket.on('register-browserWindow-focus', (id) => {
getWindowById(id).on('focus', () => {
socket.on('register-browserWindow-focus', function (id) {
getWindowById(id).on('focus', function () {
electronSocket.emit('browserWindow-focus' + id);
});
});
socket.on('register-browserWindow-show', (id) => {
getWindowById(id).on('show', () => {
socket.on('register-browserWindow-show', function (id) {
getWindowById(id).on('show', function () {
electronSocket.emit('browserWindow-show' + id);
});
});
socket.on('register-browserWindow-hide', (id) => {
getWindowById(id).on('hide', () => {
socket.on('register-browserWindow-hide', function (id) {
getWindowById(id).on('hide', function () {
electronSocket.emit('browserWindow-hide' + id);
});
});
socket.on('register-browserWindow-maximize', (id) => {
getWindowById(id).on('maximize', () => {
socket.on('register-browserWindow-maximize', function (id) {
getWindowById(id).on('maximize', function () {
electronSocket.emit('browserWindow-maximize' + id);
});
});
socket.on('register-browserWindow-unmaximize', (id) => {
getWindowById(id).on('unmaximize', () => {
socket.on('register-browserWindow-unmaximize', function (id) {
getWindowById(id).on('unmaximize', function () {
electronSocket.emit('browserWindow-unmaximize' + id);
});
});
socket.on('register-browserWindow-minimize', (id) => {
getWindowById(id).on('minimize', () => {
socket.on('register-browserWindow-minimize', function (id) {
getWindowById(id).on('minimize', function () {
electronSocket.emit('browserWindow-minimize' + id);
});
});
socket.on('register-browserWindow-restore', (id) => {
getWindowById(id).on('restore', () => {
socket.on('register-browserWindow-restore', function (id) {
getWindowById(id).on('restore', function () {
electronSocket.emit('browserWindow-restore' + id);
});
});
socket.on('register-browserWindow-resize', (id) => {
getWindowById(id).on('resize', () => {
socket.on('register-browserWindow-resize', function (id) {
getWindowById(id).on('resize', function () {
electronSocket.emit('browserWindow-resize' + id);
});
});
socket.on('register-browserWindow-move', (id) => {
getWindowById(id).on('move', () => {
socket.on('register-browserWindow-move', function (id) {
getWindowById(id).on('move', function () {
electronSocket.emit('browserWindow-move' + id);
});
});
socket.on('register-browserWindow-moved', (id) => {
getWindowById(id).on('moved', () => {
socket.on('register-browserWindow-moved', function (id) {
getWindowById(id).on('moved', function () {
electronSocket.emit('browserWindow-moved' + id);
});
});
socket.on('register-browserWindow-enter-full-screen', (id) => {
getWindowById(id).on('enter-full-screen', () => {
socket.on('register-browserWindow-enter-full-screen', function (id) {
getWindowById(id).on('enter-full-screen', function () {
electronSocket.emit('browserWindow-enter-full-screen' + id);
});
});
socket.on('register-browserWindow-leave-full-screen', (id) => {
getWindowById(id).on('leave-full-screen', () => {
socket.on('register-browserWindow-leave-full-screen', function (id) {
getWindowById(id).on('leave-full-screen', function () {
electronSocket.emit('browserWindow-leave-full-screen' + id);
});
});
socket.on('register-browserWindow-enter-html-full-screen', (id) => {
getWindowById(id).on('enter-html-full-screen', () => {
socket.on('register-browserWindow-enter-html-full-screen', function (id) {
getWindowById(id).on('enter-html-full-screen', function () {
electronSocket.emit('browserWindow-enter-html-full-screen' + id);
});
});
socket.on('register-browserWindow-leave-html-full-screen', (id) => {
getWindowById(id).on('leave-html-full-screen', () => {
socket.on('register-browserWindow-leave-html-full-screen', function (id) {
getWindowById(id).on('leave-html-full-screen', function () {
electronSocket.emit('browserWindow-leave-html-full-screen' + id);
});
});
socket.on('register-browserWindow-app-command', (id) => {
getWindowById(id).on('app-command', (event, command) => {
socket.on('register-browserWindow-app-command', function (id) {
getWindowById(id).on('app-command', function (event, command) {
electronSocket.emit('browserWindow-app-command' + id, command);
});
});
socket.on('register-browserWindow-scroll-touch-begin', (id) => {
getWindowById(id).on('scroll-touch-begin', () => {
socket.on('register-browserWindow-scroll-touch-begin', function (id) {
getWindowById(id).on('scroll-touch-begin', function () {
electronSocket.emit('browserWindow-scroll-touch-begin' + id);
});
});
socket.on('register-browserWindow-scroll-touch-end', (id) => {
getWindowById(id).on('scroll-touch-end', () => {
socket.on('register-browserWindow-scroll-touch-end', function (id) {
getWindowById(id).on('scroll-touch-end', function () {
electronSocket.emit('browserWindow-scroll-touch-end' + id);
});
});
socket.on('register-browserWindow-scroll-touch-edge', (id) => {
getWindowById(id).on('scroll-touch-edge', () => {
socket.on('register-browserWindow-scroll-touch-edge', function (id) {
getWindowById(id).on('scroll-touch-edge', function () {
electronSocket.emit('browserWindow-scroll-touch-edge' + id);
});
});
socket.on('register-browserWindow-swipe', (id) => {
getWindowById(id).on('swipe', (event, direction) => {
socket.on('register-browserWindow-swipe', function (id) {
getWindowById(id).on('swipe', function (event, direction) {
electronSocket.emit('browserWindow-swipe' + id, direction);
});
});
socket.on('register-browserWindow-sheet-begin', (id) => {
getWindowById(id).on('sheet-begin', () => {
socket.on('register-browserWindow-sheet-begin', function (id) {
getWindowById(id).on('sheet-begin', function () {
electronSocket.emit('browserWindow-sheet-begin' + id);
});
});
socket.on('register-browserWindow-sheet-end', (id) => {
getWindowById(id).on('sheet-end', () => {
socket.on('register-browserWindow-sheet-end', function (id) {
getWindowById(id).on('sheet-end', function () {
electronSocket.emit('browserWindow-sheet-end' + id);
});
});
socket.on('register-browserWindow-new-window-for-tab', (id) => {
getWindowById(id).on('new-window-for-tab', () => {
socket.on('register-browserWindow-new-window-for-tab', function (id) {
getWindowById(id).on('new-window-for-tab', function () {
electronSocket.emit('browserWindow-new-window-for-tab' + id);
});
});
socket.on('createBrowserWindow', (options, loadUrl) => {
socket.on('createBrowserWindow', function (options, loadUrl) {
if (options.webPreferences && !('nodeIntegration' in options.webPreferences)) {
options = { ...options, webPreferences: { ...options.webPreferences, nodeIntegration: true } };
options = __assign(__assign({}, options), { webPreferences: __assign(__assign({}, options.webPreferences), { nodeIntegration: true }) });
}
else if (!options.webPreferences) {
options = { ...options, webPreferences: { nodeIntegration: true } };
options = __assign(__assign({}, options), { webPreferences: { nodeIntegration: true } });
}
// we dont want to recreate the window when watch is ready.
if (app.commandLine.hasSwitch('watch') && app['mainWindowURL'] === loadUrl) {
@@ -182,32 +193,35 @@ module.exports = (socket, app) => {
else {
window = new electron_1.BrowserWindow(options);
}
window.on('ready-to-show', () => {
window.on('ready-to-show', function () {
if (readyToShowWindowsIds.includes(window.id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== window.id);
readyToShowWindowsIds = readyToShowWindowsIds.filter(function (value) { return value !== window.id; });
}
else {
readyToShowWindowsIds.push(window.id);
}
});
lastOptions = options;
window.on('closed', (sender) => {
for (let index = 0; index < windows.length; index++) {
const windowItem = windows[index];
window.on('closed', function (sender) {
var _loop_1 = function (index) {
var windowItem = windows[index];
try {
windowItem.id;
}
catch (error) {
if (error.message === 'Object has been destroyed') {
windows.splice(index, 1);
const ids = [];
windows.forEach(x => ids.push(x.id));
electronSocket.emit('BrowserWindowClosed', ids);
var ids_1 = [];
windows.forEach(function (x) { return ids_1.push(x.id); });
electronSocket.emit('BrowserWindowClosed', ids_1);
}
}
};
for (var index = 0; index < windows.length; index++) {
_loop_1(index);
}
});
app.on('activate', () => {
app.on('activate', function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (window === null && lastOptions) {
@@ -230,191 +244,191 @@ module.exports = (socket, app) => {
windows.push(window);
electronSocket.emit('BrowserWindowCreated', window.id);
});
socket.on('browserWindowDestroy', (id) => {
socket.on('browserWindowDestroy', function (id) {
getWindowById(id).destroy();
});
socket.on('browserWindowClose', (id) => {
socket.on('browserWindowClose', function (id) {
getWindowById(id).close();
});
socket.on('browserWindowFocus', (id) => {
socket.on('browserWindowFocus', function (id) {
getWindowById(id).focus();
});
socket.on('browserWindowBlur', (id) => {
socket.on('browserWindowBlur', function (id) {
getWindowById(id).blur();
});
socket.on('browserWindowIsFocused', (id) => {
const isFocused = getWindowById(id).isFocused();
socket.on('browserWindowIsFocused', function (id) {
var isFocused = getWindowById(id).isFocused();
electronSocket.emit('browserWindow-isFocused-completed', isFocused);
});
socket.on('browserWindowIsDestroyed', (id) => {
const isDestroyed = getWindowById(id).isDestroyed();
socket.on('browserWindowIsDestroyed', function (id) {
var isDestroyed = getWindowById(id).isDestroyed();
electronSocket.emit('browserWindow-isDestroyed-completed', isDestroyed);
});
socket.on('browserWindowShow', (id) => {
socket.on('browserWindowShow', function (id) {
getWindowById(id).show();
});
socket.on('browserWindowShowInactive', (id) => {
socket.on('browserWindowShowInactive', function (id) {
getWindowById(id).showInactive();
});
socket.on('browserWindowHide', (id) => {
socket.on('browserWindowHide', function (id) {
getWindowById(id).hide();
});
socket.on('browserWindowIsVisible', (id) => {
const isVisible = getWindowById(id).isVisible();
socket.on('browserWindowIsVisible', function (id) {
var isVisible = getWindowById(id).isVisible();
electronSocket.emit('browserWindow-isVisible-completed', isVisible);
});
socket.on('browserWindowIsModal', (id) => {
const isModal = getWindowById(id).isModal();
socket.on('browserWindowIsModal', function (id) {
var isModal = getWindowById(id).isModal();
electronSocket.emit('browserWindow-isModal-completed', isModal);
});
socket.on('browserWindowMaximize', (id) => {
socket.on('browserWindowMaximize', function (id) {
getWindowById(id).maximize();
});
socket.on('browserWindowUnmaximize', (id) => {
socket.on('browserWindowUnmaximize', function (id) {
getWindowById(id).unmaximize();
});
socket.on('browserWindowIsMaximized', (id) => {
const isMaximized = getWindowById(id).isMaximized();
socket.on('browserWindowIsMaximized', function (id) {
var isMaximized = getWindowById(id).isMaximized();
electronSocket.emit('browserWindow-isMaximized-completed', isMaximized);
});
socket.on('browserWindowMinimize', (id) => {
socket.on('browserWindowMinimize', function (id) {
getWindowById(id).minimize();
});
socket.on('browserWindowRestore', (id) => {
socket.on('browserWindowRestore', function (id) {
getWindowById(id).restore();
});
socket.on('browserWindowIsMinimized', (id) => {
const isMinimized = getWindowById(id).isMinimized();
socket.on('browserWindowIsMinimized', function (id) {
var isMinimized = getWindowById(id).isMinimized();
electronSocket.emit('browserWindow-isMinimized-completed', isMinimized);
});
socket.on('browserWindowSetFullScreen', (id, fullscreen) => {
socket.on('browserWindowSetFullScreen', function (id, fullscreen) {
getWindowById(id).setFullScreen(fullscreen);
});
socket.on('browserWindowIsFullScreen', (id) => {
const isFullScreen = getWindowById(id).isFullScreen();
socket.on('browserWindowIsFullScreen', function (id) {
var isFullScreen = getWindowById(id).isFullScreen();
electronSocket.emit('browserWindow-isFullScreen-completed', isFullScreen);
});
socket.on('browserWindowSetAspectRatio', (id, aspectRatio, extraSize) => {
socket.on('browserWindowSetAspectRatio', function (id, aspectRatio, extraSize) {
getWindowById(id).setAspectRatio(aspectRatio, extraSize);
});
socket.on('browserWindowPreviewFile', (id, path, displayname) => {
socket.on('browserWindowPreviewFile', function (id, path, displayname) {
getWindowById(id).previewFile(path, displayname);
});
socket.on('browserWindowCloseFilePreview', (id) => {
socket.on('browserWindowCloseFilePreview', function (id) {
getWindowById(id).closeFilePreview();
});
socket.on('browserWindowSetBounds', (id, bounds, animate) => {
socket.on('browserWindowSetBounds', function (id, bounds, animate) {
getWindowById(id).setBounds(bounds, animate);
});
socket.on('browserWindowGetBounds', (id) => {
const rectangle = getWindowById(id).getBounds();
socket.on('browserWindowGetBounds', function (id) {
var rectangle = getWindowById(id).getBounds();
electronSocket.emit('browserWindow-getBounds-completed', rectangle);
});
socket.on('browserWindowSetContentBounds', (id, bounds, animate) => {
socket.on('browserWindowSetContentBounds', function (id, bounds, animate) {
getWindowById(id).setContentBounds(bounds, animate);
});
socket.on('browserWindowGetContentBounds', (id) => {
const rectangle = getWindowById(id).getContentBounds();
socket.on('browserWindowGetContentBounds', function (id) {
var rectangle = getWindowById(id).getContentBounds();
electronSocket.emit('browserWindow-getContentBounds-completed', rectangle);
});
socket.on('browserWindowSetSize', (id, width, height, animate) => {
socket.on('browserWindowSetSize', function (id, width, height, animate) {
getWindowById(id).setSize(width, height, animate);
});
socket.on('browserWindowGetSize', (id) => {
const size = getWindowById(id).getSize();
socket.on('browserWindowGetSize', function (id) {
var size = getWindowById(id).getSize();
electronSocket.emit('browserWindow-getSize-completed', size);
});
socket.on('browserWindowSetContentSize', (id, width, height, animate) => {
socket.on('browserWindowSetContentSize', function (id, width, height, animate) {
getWindowById(id).setContentSize(width, height, animate);
});
socket.on('browserWindowGetContentSize', (id) => {
const size = getWindowById(id).getContentSize();
socket.on('browserWindowGetContentSize', function (id) {
var size = getWindowById(id).getContentSize();
electronSocket.emit('browserWindow-getContentSize-completed', size);
});
socket.on('browserWindowSetMinimumSize', (id, width, height) => {
socket.on('browserWindowSetMinimumSize', function (id, width, height) {
getWindowById(id).setMinimumSize(width, height);
});
socket.on('browserWindowGetMinimumSize', (id) => {
const size = getWindowById(id).getMinimumSize();
socket.on('browserWindowGetMinimumSize', function (id) {
var size = getWindowById(id).getMinimumSize();
electronSocket.emit('browserWindow-getMinimumSize-completed', size);
});
socket.on('browserWindowSetMaximumSize', (id, width, height) => {
socket.on('browserWindowSetMaximumSize', function (id, width, height) {
getWindowById(id).setMaximumSize(width, height);
});
socket.on('browserWindowGetMaximumSize', (id) => {
const size = getWindowById(id).getMaximumSize();
socket.on('browserWindowGetMaximumSize', function (id) {
var size = getWindowById(id).getMaximumSize();
electronSocket.emit('browserWindow-getMaximumSize-completed', size);
});
socket.on('browserWindowSetResizable', (id, resizable) => {
socket.on('browserWindowSetResizable', function (id, resizable) {
getWindowById(id).setResizable(resizable);
});
socket.on('browserWindowIsResizable', (id) => {
const resizable = getWindowById(id).isResizable();
socket.on('browserWindowIsResizable', function (id) {
var resizable = getWindowById(id).isResizable();
electronSocket.emit('browserWindow-isResizable-completed', resizable);
});
socket.on('browserWindowSetMovable', (id, movable) => {
socket.on('browserWindowSetMovable', function (id, movable) {
getWindowById(id).setMovable(movable);
});
socket.on('browserWindowIsMovable', (id) => {
const movable = getWindowById(id).isMovable();
socket.on('browserWindowIsMovable', function (id) {
var movable = getWindowById(id).isMovable();
electronSocket.emit('browserWindow-isMovable-completed', movable);
});
socket.on('browserWindowSetMinimizable', (id, minimizable) => {
socket.on('browserWindowSetMinimizable', function (id, minimizable) {
getWindowById(id).setMinimizable(minimizable);
});
socket.on('browserWindowIsMinimizable', (id) => {
const minimizable = getWindowById(id).isMinimizable();
socket.on('browserWindowIsMinimizable', function (id) {
var minimizable = getWindowById(id).isMinimizable();
electronSocket.emit('browserWindow-isMinimizable-completed', minimizable);
});
socket.on('browserWindowSetMaximizable', (id, maximizable) => {
socket.on('browserWindowSetMaximizable', function (id, maximizable) {
getWindowById(id).setMaximizable(maximizable);
});
socket.on('browserWindowIsMaximizable', (id) => {
const maximizable = getWindowById(id).isMaximizable();
socket.on('browserWindowIsMaximizable', function (id) {
var maximizable = getWindowById(id).isMaximizable();
electronSocket.emit('browserWindow-isMaximizable-completed', maximizable);
});
socket.on('browserWindowSetFullScreenable', (id, fullscreenable) => {
socket.on('browserWindowSetFullScreenable', function (id, fullscreenable) {
getWindowById(id).setFullScreenable(fullscreenable);
});
socket.on('browserWindowIsFullScreenable', (id) => {
const fullscreenable = getWindowById(id).isFullScreenable();
socket.on('browserWindowIsFullScreenable', function (id) {
var fullscreenable = getWindowById(id).isFullScreenable();
electronSocket.emit('browserWindow-isFullScreenable-completed', fullscreenable);
});
socket.on('browserWindowSetClosable', (id, closable) => {
socket.on('browserWindowSetClosable', function (id, closable) {
getWindowById(id).setClosable(closable);
});
socket.on('browserWindowIsClosable', (id) => {
const closable = getWindowById(id).isClosable();
socket.on('browserWindowIsClosable', function (id) {
var closable = getWindowById(id).isClosable();
electronSocket.emit('browserWindow-isClosable-completed', closable);
});
socket.on('browserWindowSetAlwaysOnTop', (id, flag, level, relativeLevel) => {
socket.on('browserWindowSetAlwaysOnTop', function (id, flag, level, relativeLevel) {
getWindowById(id).setAlwaysOnTop(flag, level, relativeLevel);
});
socket.on('browserWindowIsAlwaysOnTop', (id) => {
const isAlwaysOnTop = getWindowById(id).isAlwaysOnTop();
socket.on('browserWindowIsAlwaysOnTop', function (id) {
var isAlwaysOnTop = getWindowById(id).isAlwaysOnTop();
electronSocket.emit('browserWindow-isAlwaysOnTop-completed', isAlwaysOnTop);
});
socket.on('browserWindowCenter', (id) => {
socket.on('browserWindowCenter', function (id) {
getWindowById(id).center();
});
socket.on('browserWindowSetPosition', (id, x, y, animate) => {
socket.on('browserWindowSetPosition', function (id, x, y, animate) {
getWindowById(id).setPosition(x, y, animate);
});
socket.on('browserWindowGetPosition', (id) => {
const position = getWindowById(id).getPosition();
socket.on('browserWindowGetPosition', function (id) {
var position = getWindowById(id).getPosition();
electronSocket.emit('browserWindow-getPosition-completed', position);
});
socket.on('browserWindowSetTitle', (id, title) => {
socket.on('browserWindowSetTitle', function (id, title) {
getWindowById(id).setTitle(title);
});
socket.on('browserWindowGetTitle', (id) => {
const title = getWindowById(id).getTitle();
socket.on('browserWindowGetTitle', function (id) {
var title = getWindowById(id).getTitle();
electronSocket.emit('browserWindow-getTitle-completed', title);
});
socket.on('browserWindowSetTitle', (id, title) => {
socket.on('browserWindowSetTitle', function (id, title) {
getWindowById(id).setTitle(title);
});
socket.on('browserWindowSetSheetOffset', (id, offsetY, offsetX) => {
socket.on('browserWindowSetSheetOffset', function (id, offsetY, offsetX) {
if (offsetX) {
getWindowById(id).setSheetOffset(offsetY, offsetX);
}
@@ -422,186 +436,185 @@ module.exports = (socket, app) => {
getWindowById(id).setSheetOffset(offsetY);
}
});
socket.on('browserWindowFlashFrame', (id, flag) => {
socket.on('browserWindowFlashFrame', function (id, flag) {
getWindowById(id).flashFrame(flag);
});
socket.on('browserWindowSetSkipTaskbar', (id, skip) => {
socket.on('browserWindowSetSkipTaskbar', function (id, skip) {
getWindowById(id).setSkipTaskbar(skip);
});
socket.on('browserWindowSetKiosk', (id, flag) => {
socket.on('browserWindowSetKiosk', function (id, flag) {
getWindowById(id).setKiosk(flag);
});
socket.on('browserWindowIsKiosk', (id) => {
const isKiosk = getWindowById(id).isKiosk();
socket.on('browserWindowIsKiosk', function (id) {
var isKiosk = getWindowById(id).isKiosk();
electronSocket.emit('browserWindow-isKiosk-completed', isKiosk);
});
socket.on('browserWindowGetNativeWindowHandle', (id) => {
const nativeWindowHandle = getWindowById(id).getNativeWindowHandle().readInt32LE(0).toString(16);
socket.on('browserWindowGetNativeWindowHandle', function (id) {
var nativeWindowHandle = getWindowById(id).getNativeWindowHandle().readInt32LE(0).toString(16);
electronSocket.emit('browserWindow-getNativeWindowHandle-completed', nativeWindowHandle);
});
socket.on('browserWindowSetRepresentedFilename', (id, filename) => {
socket.on('browserWindowSetRepresentedFilename', function (id, filename) {
getWindowById(id).setRepresentedFilename(filename);
});
socket.on('browserWindowGetRepresentedFilename', (id) => {
const pathname = getWindowById(id).getRepresentedFilename();
socket.on('browserWindowGetRepresentedFilename', function (id) {
var pathname = getWindowById(id).getRepresentedFilename();
electronSocket.emit('browserWindow-getRepresentedFilename-completed', pathname);
});
socket.on('browserWindowSetDocumentEdited', (id, edited) => {
socket.on('browserWindowSetDocumentEdited', function (id, edited) {
getWindowById(id).setDocumentEdited(edited);
});
socket.on('browserWindowIsDocumentEdited', (id) => {
const edited = getWindowById(id).isDocumentEdited();
socket.on('browserWindowIsDocumentEdited', function (id) {
var edited = getWindowById(id).isDocumentEdited();
electronSocket.emit('browserWindow-isDocumentEdited-completed', edited);
});
socket.on('browserWindowFocusOnWebView', (id) => {
socket.on('browserWindowFocusOnWebView', function (id) {
getWindowById(id).focusOnWebView();
});
socket.on('browserWindowBlurWebView', (id) => {
socket.on('browserWindowBlurWebView', function (id) {
getWindowById(id).blurWebView();
});
socket.on('browserWindowLoadURL', (id, url, options) => {
socket.on('browserWindowLoadURL', function (id, url, options) {
getWindowById(id).loadURL(url, options);
});
socket.on('browserWindowReload', (id) => {
socket.on('browserWindowReload', function (id) {
getWindowById(id).reload();
});
socket.on('browserWindowSetMenu', (id, menuItems) => {
let menu = null;
socket.on('browserWindowSetMenu', function (id, menuItems) {
var menu = null;
if (menuItems) {
menu = electron_1.Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
addMenuItemClickConnector(menu.items, function (id) {
electronSocket.emit('windowMenuItemClicked', id);
});
}
getWindowById(id).setMenu(menu);
});
socket.on('browserWindowRemoveMenu', (id) => {
socket.on('browserWindowRemoveMenu', function (id) {
getWindowById(id).removeMenu();
});
function addMenuItemClickConnector(menuItems, callback) {
menuItems.forEach((item) => {
menuItems.forEach(function (item) {
if (item.submenu && item.submenu.items.length > 0) {
addMenuItemClickConnector(item.submenu.items, callback);
}
if ('id' in item && item.id) {
item.click = () => { callback(item.id); };
item.click = function () { callback(item.id); };
}
});
}
socket.on('browserWindowSetProgressBar', (id, progress) => {
socket.on('browserWindowSetProgressBar', function (id, progress) {
getWindowById(id).setProgressBar(progress);
});
socket.on('browserWindowSetProgressBar', (id, progress, options) => {
socket.on('browserWindowSetProgressBar', function (id, progress, options) {
getWindowById(id).setProgressBar(progress, options);
});
socket.on('browserWindowSetHasShadow', (id, hasShadow) => {
socket.on('browserWindowSetHasShadow', function (id, hasShadow) {
getWindowById(id).setHasShadow(hasShadow);
});
socket.on('browserWindowHasShadow', (id) => {
const hasShadow = getWindowById(id).hasShadow();
socket.on('browserWindowHasShadow', function (id) {
var hasShadow = getWindowById(id).hasShadow();
electronSocket.emit('browserWindow-hasShadow-completed', hasShadow);
});
socket.on('browserWindowSetThumbarButtons', (id, thumbarButtons) => {
thumbarButtons.forEach(thumbarButton => {
const imagePath = path.join(__dirname.replace('api', ''), 'bin', thumbarButton.icon.toString());
socket.on('browserWindowSetThumbarButtons', function (id, thumbarButtons) {
thumbarButtons.forEach(function (thumbarButton) {
var imagePath = path.join(__dirname.replace('api', ''), 'bin', thumbarButton.icon.toString());
thumbarButton.icon = electron_1.nativeImage.createFromPath(imagePath);
thumbarButton.click = () => {
thumbarButton.click = function () {
electronSocket.emit('thumbarButtonClicked', thumbarButton['id']);
};
});
const success = getWindowById(id).setThumbarButtons(thumbarButtons);
var success = getWindowById(id).setThumbarButtons(thumbarButtons);
electronSocket.emit('browserWindowSetThumbarButtons-completed', success);
});
socket.on('browserWindowSetThumbnailClip', (id, rectangle) => {
socket.on('browserWindowSetThumbnailClip', function (id, rectangle) {
getWindowById(id).setThumbnailClip(rectangle);
});
socket.on('browserWindowSetThumbnailToolTip', (id, toolTip) => {
socket.on('browserWindowSetThumbnailToolTip', function (id, toolTip) {
getWindowById(id).setThumbnailToolTip(toolTip);
});
socket.on('browserWindowSetAppDetails', (id, options) => {
socket.on('browserWindowSetAppDetails', function (id, options) {
getWindowById(id).setAppDetails(options);
});
socket.on('browserWindowShowDefinitionForSelection', (id) => {
socket.on('browserWindowShowDefinitionForSelection', function (id) {
getWindowById(id).showDefinitionForSelection();
});
socket.on('browserWindowSetAutoHideMenuBar', (id, hide) => {
socket.on('browserWindowSetAutoHideMenuBar', function (id, hide) {
getWindowById(id).setAutoHideMenuBar(hide);
});
socket.on('browserWindowIsMenuBarAutoHide', (id) => {
const isMenuBarAutoHide = getWindowById(id).isMenuBarAutoHide();
socket.on('browserWindowIsMenuBarAutoHide', function (id) {
var isMenuBarAutoHide = getWindowById(id).isMenuBarAutoHide();
electronSocket.emit('browserWindow-isMenuBarAutoHide-completed', isMenuBarAutoHide);
});
socket.on('browserWindowSetMenuBarVisibility', (id, visible) => {
socket.on('browserWindowSetMenuBarVisibility', function (id, visible) {
getWindowById(id).setMenuBarVisibility(visible);
});
socket.on('browserWindowIsMenuBarVisible', (id) => {
const isMenuBarVisible = getWindowById(id).isMenuBarVisible();
socket.on('browserWindowIsMenuBarVisible', function (id) {
var isMenuBarVisible = getWindowById(id).isMenuBarVisible();
electronSocket.emit('browserWindow-isMenuBarVisible-completed', isMenuBarVisible);
});
socket.on('browserWindowSetVisibleOnAllWorkspaces', (id, visible) => {
socket.on('browserWindowSetVisibleOnAllWorkspaces', function (id, visible) {
getWindowById(id).setVisibleOnAllWorkspaces(visible);
});
socket.on('browserWindowIsVisibleOnAllWorkspaces', (id) => {
const isVisibleOnAllWorkspaces = getWindowById(id).isVisibleOnAllWorkspaces();
socket.on('browserWindowIsVisibleOnAllWorkspaces', function (id) {
var isVisibleOnAllWorkspaces = getWindowById(id).isVisibleOnAllWorkspaces();
electronSocket.emit('browserWindow-isVisibleOnAllWorkspaces-completed', isVisibleOnAllWorkspaces);
});
socket.on('browserWindowSetIgnoreMouseEvents', (id, ignore) => {
socket.on('browserWindowSetIgnoreMouseEvents', function (id, ignore) {
getWindowById(id).setIgnoreMouseEvents(ignore);
});
socket.on('browserWindowSetContentProtection', (id, enable) => {
socket.on('browserWindowSetContentProtection', function (id, enable) {
getWindowById(id).setContentProtection(enable);
});
socket.on('browserWindowSetFocusable', (id, focusable) => {
socket.on('browserWindowSetFocusable', function (id, focusable) {
getWindowById(id).setFocusable(focusable);
});
socket.on('browserWindowSetParentWindow', (id, parent) => {
const browserWindow = electron_1.BrowserWindow.fromId(parent.id);
socket.on('browserWindowSetParentWindow', function (id, parent) {
var browserWindow = electron_1.BrowserWindow.fromId(parent.id);
getWindowById(id).setParentWindow(browserWindow);
});
socket.on('browserWindowGetParentWindow', (id) => {
const browserWindow = getWindowById(id).getParentWindow();
socket.on('browserWindowGetParentWindow', function (id) {
var browserWindow = getWindowById(id).getParentWindow();
electronSocket.emit('browserWindow-getParentWindow-completed', browserWindow.id);
});
socket.on('browserWindowGetChildWindows', (id) => {
const browserWindows = getWindowById(id).getChildWindows();
const ids = [];
browserWindows.forEach(x => {
socket.on('browserWindowGetChildWindows', function (id) {
var browserWindows = getWindowById(id).getChildWindows();
var ids = [];
browserWindows.forEach(function (x) {
ids.push(x.id);
});
electronSocket.emit('browserWindow-getChildWindows-completed', ids);
});
socket.on('browserWindowSetAutoHideCursor', (id, autoHide) => {
socket.on('browserWindowSetAutoHideCursor', function (id, autoHide) {
getWindowById(id).setAutoHideCursor(autoHide);
});
socket.on('browserWindowSetVibrancy', (id, type) => {
socket.on('browserWindowSetVibrancy', function (id, type) {
getWindowById(id).setVibrancy(type);
});
socket.on('browserWindowAddExtension', (path) => {
const extensionName = electron_1.BrowserWindow.addExtension(path);
socket.on('browserWindowAddExtension', function (path) {
var extensionName = electron_1.BrowserWindow.addExtension(path);
electronSocket.emit('browserWindow-addExtension-completed', extensionName);
});
socket.on('browserWindowRemoveExtension', (name) => {
socket.on('browserWindowRemoveExtension', function (name) {
electron_1.BrowserWindow.removeExtension(name);
});
socket.on('browserWindowGetExtensions', () => {
const extensionsList = electron_1.BrowserWindow.getExtensions();
const chromeExtensionInfo = [];
Object.keys(extensionsList).forEach(key => {
socket.on('browserWindowGetExtensions', function () {
var extensionsList = electron_1.BrowserWindow.getExtensions();
var chromeExtensionInfo = [];
Object.keys(extensionsList).forEach(function (key) {
chromeExtensionInfo.push(extensionsList[key]);
});
electronSocket.emit('browserWindow-getExtensions-completed', chromeExtensionInfo);
});
socket.on('browserWindow-setBrowserView', (id, browserViewId) => {
const browserView = electron_1.BrowserView.fromId(browserViewId);
socket.on('browserWindow-setBrowserView', function (id, browserViewId) {
var browserView = electron_1.BrowserView.fromId(browserViewId);
getWindowById(id).setBrowserView(browserView);
});
function getWindowById(id) {
for (let index = 0; index < windows.length; index++) {
const element = windows[index];
for (var index = 0; index < windows.length; index++) {
var element = windows[index];
if (element.id == id) {
return element;
}
}
}
};
//# sourceMappingURL=browserWindows.js.map

View File

@@ -1,6 +1,6 @@
import { BrowserWindow, Menu, nativeImage, BrowserView } from 'electron';
const path = require('path');
const windows: Electron.BrowserWindow[] = [];
const windows: Electron.BrowserWindow[] = (global['browserWindows'] = global['browserWindows'] || []) as Electron.BrowserWindow[];
let readyToShowWindowsIds: number[] = [];
let window, lastOptions, electronSocket;
let mainWindowURL;

View File

@@ -1,16 +1,16 @@
"use strict";
const electron_1 = require("electron");
const contextMenuItems = [];
let electronSocket;
module.exports = (socket) => {
var electron_1 = require("electron");
var contextMenuItems = (global['contextMenuItems'] = global['contextMenuItems'] || []);
var electronSocket;
module.exports = function (socket) {
electronSocket = socket;
socket.on('menu-setContextMenu', (browserWindowId, menuItems) => {
const menu = electron_1.Menu.buildFromTemplate(menuItems);
addContextMenuItemClickConnector(menu.items, browserWindowId, (id, browserWindowId) => {
socket.on('menu-setContextMenu', function (browserWindowId, menuItems) {
var menu = electron_1.Menu.buildFromTemplate(menuItems);
addContextMenuItemClickConnector(menu.items, browserWindowId, function (id, browserWindowId) {
electronSocket.emit('contextMenuItemClicked', [id, browserWindowId]);
});
const index = contextMenuItems.findIndex(contextMenu => contextMenu.browserWindowId === browserWindowId);
const contextMenuItem = {
var index = contextMenuItems.findIndex(function (contextMenu) { return contextMenu.browserWindowId === browserWindowId; });
var contextMenuItem = {
menu: menu,
browserWindowId: browserWindowId
};
@@ -22,39 +22,38 @@ module.exports = (socket) => {
}
});
function addContextMenuItemClickConnector(menuItems, browserWindowId, callback) {
menuItems.forEach((item) => {
menuItems.forEach(function (item) {
if (item.submenu && item.submenu.items.length > 0) {
addContextMenuItemClickConnector(item.submenu.items, browserWindowId, callback);
}
if ('id' in item && item.id) {
item.click = () => { callback(item.id, browserWindowId); };
item.click = function () { callback(item.id, browserWindowId); };
}
});
}
socket.on('menu-contextMenuPopup', (browserWindowId) => {
contextMenuItems.forEach(x => {
socket.on('menu-contextMenuPopup', function (browserWindowId) {
contextMenuItems.forEach(function (x) {
if (x.browserWindowId === browserWindowId) {
const browserWindow = electron_1.BrowserWindow.fromId(browserWindowId);
var browserWindow = electron_1.BrowserWindow.fromId(browserWindowId);
x.menu.popup(browserWindow);
}
});
});
socket.on('menu-setApplicationMenu', (menuItems) => {
const menu = electron_1.Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
socket.on('menu-setApplicationMenu', function (menuItems) {
var menu = electron_1.Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, function (id) {
electronSocket.emit('menuItemClicked', id);
});
electron_1.Menu.setApplicationMenu(menu);
});
function addMenuItemClickConnector(menuItems, callback) {
menuItems.forEach((item) => {
menuItems.forEach(function (item) {
if (item.submenu && item.submenu.items.length > 0) {
addMenuItemClickConnector(item.submenu.items, callback);
}
if ('id' in item && item.id) {
item.click = () => { callback(item.id); };
item.click = function () { callback(item.id); };
}
});
}
};
//# sourceMappingURL=menu.js.map

View File

@@ -1,5 +1,5 @@
import { Menu, BrowserWindow } from 'electron';
const contextMenuItems = [];
const contextMenuItems = (global['contextMenuItems'] = global['contextMenuItems'] || []);
let electronSocket;
export = (socket: SocketIO.Socket) => {

View File

@@ -1,39 +1,39 @@
"use strict";
const electron_1 = require("electron");
const notifications = [];
let electronSocket;
module.exports = (socket) => {
var electron_1 = require("electron");
var notifications = (global['notifications'] = global['notifications'] || []);
var electronSocket;
module.exports = function (socket) {
electronSocket = socket;
socket.on('createNotification', (options) => {
const notification = new electron_1.Notification(options);
let haveEvent = false;
socket.on('createNotification', function (options) {
var notification = new electron_1.Notification(options);
var haveEvent = false;
if (options.showID) {
haveEvent = true;
notification.on('show', () => {
notification.on('show', function () {
electronSocket.emit('NotificationEventShow', options.showID);
});
}
if (options.clickID) {
haveEvent = true;
notification.on('click', () => {
notification.on('click', function () {
electronSocket.emit('NotificationEventClick', options.clickID);
});
}
if (options.closeID) {
haveEvent = true;
notification.on('close', () => {
notification.on('close', function () {
electronSocket.emit('NotificationEventClose', options.closeID);
});
}
if (options.replyID) {
haveEvent = true;
notification.on('reply', (event, value) => {
notification.on('reply', function (event, value) {
electronSocket.emit('NotificationEventReply', [options.replyID, value]);
});
}
if (options.actionID) {
haveEvent = true;
notification.on('action', (event, value) => {
notification.on('action', function (event, value) {
electronSocket.emit('NotificationEventAction', [options.actionID, value]);
});
}
@@ -42,9 +42,8 @@ module.exports = (socket) => {
}
notification.show();
});
socket.on('notificationIsSupported', () => {
const isSupported = electron_1.Notification.isSupported;
socket.on('notificationIsSupported', function () {
var isSupported = electron_1.Notification.isSupported;
electronSocket.emit('notificationIsSupportedComplete', isSupported);
});
};
//# sourceMappingURL=notification.js.map

View File

@@ -1,5 +1,5 @@
import { Notification } from 'electron';
const notifications: Electron.Notification[] = [];
const notifications: Electron.Notification[] = (global['notifications'] = global['notifications'] || []) as Electron.Notification[];
let electronSocket;
export = (socket: SocketIO.Socket) => {

View File

@@ -1,108 +1,107 @@
"use strict";
const electron_1 = require("electron");
let tray;
let electronSocket;
module.exports = (socket) => {
var electron_1 = require("electron");
var tray = (global['tray'] = global['tray'] || { value: null });
var electronSocket;
module.exports = function (socket) {
electronSocket = socket;
socket.on('register-tray-click', (id) => {
if (tray) {
tray.on('click', (event, bounds) => {
socket.on('register-tray-click', function (id) {
if (tray.value) {
tray.value.on('click', function (event, bounds) {
electronSocket.emit('tray-click-event' + id, [event.__proto__, bounds]);
});
}
});
socket.on('register-tray-right-click', (id) => {
if (tray) {
tray.on('right-click', (event, bounds) => {
socket.on('register-tray-right-click', function (id) {
if (tray.value) {
tray.value.on('right-click', function (event, bounds) {
electronSocket.emit('tray-right-click-event' + id, [event.__proto__, bounds]);
});
}
});
socket.on('register-tray-double-click', (id) => {
if (tray) {
tray.on('double-click', (event, bounds) => {
socket.on('register-tray-double-click', function (id) {
if (tray.value) {
tray.value.on('double-click', function (event, bounds) {
electronSocket.emit('tray-double-click-event' + id, [event.__proto__, bounds]);
});
}
});
socket.on('register-tray-balloon-show', (id) => {
if (tray) {
tray.on('balloon-show', () => {
socket.on('register-tray-balloon-show', function (id) {
if (tray.value) {
tray.value.on('balloon-show', function () {
electronSocket.emit('tray-balloon-show-event' + id);
});
}
});
socket.on('register-tray-balloon-click', (id) => {
if (tray) {
tray.on('balloon-click', () => {
socket.on('register-tray-balloon-click', function (id) {
if (tray.value) {
tray.value.on('balloon-click', function () {
electronSocket.emit('tray-balloon-click-event' + id);
});
}
});
socket.on('register-tray-balloon-closed', (id) => {
if (tray) {
tray.on('balloon-closed', () => {
socket.on('register-tray-balloon-closed', function (id) {
if (tray.value) {
tray.value.on('balloon-closed', function () {
electronSocket.emit('tray-balloon-closed-event' + id);
});
}
});
socket.on('create-tray', (image, menuItems) => {
const trayIcon = electron_1.nativeImage.createFromPath(image);
tray = new electron_1.Tray(trayIcon);
socket.on('create-tray', function (image, menuItems) {
var trayIcon = electron_1.nativeImage.createFromPath(image);
tray.value = new electron_1.Tray(trayIcon);
if (menuItems) {
const menu = electron_1.Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, (id) => {
var menu = electron_1.Menu.buildFromTemplate(menuItems);
addMenuItemClickConnector(menu.items, function (id) {
electronSocket.emit('trayMenuItemClicked', id);
});
tray.setContextMenu(menu);
tray.value.setContextMenu(menu);
}
});
socket.on('tray-destroy', () => {
if (tray) {
tray.destroy();
socket.on('tray-destroy', function () {
if (tray.value) {
tray.value.destroy();
}
});
socket.on('tray-setImage', (image) => {
if (tray) {
tray.setImage(image);
socket.on('tray-setImage', function (image) {
if (tray.value) {
tray.value.setImage(image);
}
});
socket.on('tray-setPressedImage', (image) => {
if (tray) {
const img = electron_1.nativeImage.createFromPath(image);
tray.setPressedImage(img);
socket.on('tray-setPressedImage', function (image) {
if (tray.value) {
var img = electron_1.nativeImage.createFromPath(image);
tray.value.setPressedImage(img);
}
});
socket.on('tray-setToolTip', (toolTip) => {
if (tray) {
tray.setToolTip(toolTip);
socket.on('tray-setToolTip', function (toolTip) {
if (tray.value) {
tray.value.setToolTip(toolTip);
}
});
socket.on('tray-setTitle', (title) => {
if (tray) {
tray.setTitle(title);
socket.on('tray-setTitle', function (title) {
if (tray.value) {
tray.value.setTitle(title);
}
});
socket.on('tray-displayBalloon', (options) => {
if (tray) {
tray.displayBalloon(options);
socket.on('tray-displayBalloon', function (options) {
if (tray.value) {
tray.value.displayBalloon(options);
}
});
socket.on('tray-isDestroyed', () => {
if (tray) {
const isDestroyed = tray.isDestroyed();
socket.on('tray-isDestroyed', function () {
if (tray.value) {
var isDestroyed = tray.value.isDestroyed();
electronSocket.emit('tray-isDestroyedCompleted', isDestroyed);
}
});
function addMenuItemClickConnector(menuItems, callback) {
menuItems.forEach((item) => {
menuItems.forEach(function (item) {
if (item.submenu && item.submenu.items.length > 0) {
addMenuItemClickConnector(item.submenu.items, callback);
}
if ('id' in item && item.id) {
item.click = () => { callback(item.id); };
item.click = function () { callback(item.id); };
}
});
}
};
//# sourceMappingURL=tray.js.map

View File

@@ -1,52 +1,52 @@
import { Menu, Tray, nativeImage } from 'electron';
let tray: Electron.Tray;
let tray: { value: Electron.Tray } = (global['$tray'] = global['tray'] || { value: null });
let electronSocket;
export = (socket: SocketIO.Socket) => {
electronSocket = socket;
socket.on('register-tray-click', (id) => {
if (tray) {
tray.on('click', (event, bounds) => {
if (tray.value) {
tray.value.on('click', (event, bounds) => {
electronSocket.emit('tray-click-event' + id, [(<any>event).__proto__, bounds]);
});
}
});
socket.on('register-tray-right-click', (id) => {
if (tray) {
tray.on('right-click', (event, bounds) => {
if (tray.value) {
tray.value.on('right-click', (event, bounds) => {
electronSocket.emit('tray-right-click-event' + id, [(<any>event).__proto__, bounds]);
});
}
});
socket.on('register-tray-double-click', (id) => {
if (tray) {
tray.on('double-click', (event, bounds) => {
if (tray.value) {
tray.value.on('double-click', (event, bounds) => {
electronSocket.emit('tray-double-click-event' + id, [(<any>event).__proto__, bounds]);
});
}
});
socket.on('register-tray-balloon-show', (id) => {
if (tray) {
tray.on('balloon-show', () => {
if (tray.value) {
tray.value.on('balloon-show', () => {
electronSocket.emit('tray-balloon-show-event' + id);
});
}
});
socket.on('register-tray-balloon-click', (id) => {
if (tray) {
tray.on('balloon-click', () => {
if (tray.value) {
tray.value.on('balloon-click', () => {
electronSocket.emit('tray-balloon-click-event' + id);
});
}
});
socket.on('register-tray-balloon-closed', (id) => {
if (tray) {
tray.on('balloon-closed', () => {
if (tray.value) {
tray.value.on('balloon-closed', () => {
electronSocket.emit('tray-balloon-closed-event' + id);
});
}
@@ -55,7 +55,7 @@ export = (socket: SocketIO.Socket) => {
socket.on('create-tray', (image, menuItems) => {
const trayIcon = nativeImage.createFromPath(image);
tray = new Tray(trayIcon);
tray.value = new Tray(trayIcon);
if (menuItems) {
const menu = Menu.buildFromTemplate(menuItems);
@@ -63,50 +63,50 @@ export = (socket: SocketIO.Socket) => {
addMenuItemClickConnector(menu.items, (id) => {
electronSocket.emit('trayMenuItemClicked', id);
});
tray.setContextMenu(menu);
tray.value.setContextMenu(menu);
}
});
socket.on('tray-destroy', () => {
if (tray) {
tray.destroy();
if (tray.value) {
tray.value.destroy();
}
});
socket.on('tray-setImage', (image) => {
if (tray) {
tray.setImage(image);
if (tray.value) {
tray.value.setImage(image);
}
});
socket.on('tray-setPressedImage', (image) => {
if (tray) {
if (tray.value) {
const img = nativeImage.createFromPath(image);
tray.setPressedImage(img);
tray.value.setPressedImage(img);
}
});
socket.on('tray-setToolTip', (toolTip) => {
if (tray) {
tray.setToolTip(toolTip);
if (tray.value) {
tray.value.setToolTip(toolTip);
}
});
socket.on('tray-setTitle', (title) => {
if (tray) {
tray.setTitle(title);
if (tray.value) {
tray.value.setTitle(title);
}
});
socket.on('tray-displayBalloon', (options) => {
if (tray) {
tray.displayBalloon(options);
if (tray.value) {
tray.value.displayBalloon(options);
}
});
socket.on('tray-isDestroyed', () => {
if (tray) {
const isDestroyed = tray.isDestroyed();
if (tray.value) {
const isDestroyed = tray.value.isDestroyed();
electronSocket.emit('tray-isDestroyedCompleted', isDestroyed);
}
});

View File

@@ -59,7 +59,7 @@ app.on('ready', () => {
const pathname = request.url.replace('file:///', '');
callback(pathname);
});
if (isSplashScreenEnabled()) {
startSplashScreen();
}
@@ -148,53 +148,46 @@ function startSocketApiBridge(port) {
io.on('connection', (socket) => {
// we need to remove previously cache instances
// otherwise it will fire the same event multiple depends how many time
// live reload watch happen.
socket.on('disconnect', function (reason) {
console.log('Got disconnect! Reason: ' + reason);
delete require.cache[require.resolve('./api/app')];
delete require.cache[require.resolve('./api/browserWindows')];
delete require.cache[require.resolve('./api/commandLine')];
delete require.cache[require.resolve('./api/autoUpdater')];
delete require.cache[require.resolve('./api/ipc')];
delete require.cache[require.resolve('./api/menu')];
delete require.cache[require.resolve('./api/dialog')];
delete require.cache[require.resolve('./api/notification')];
delete require.cache[require.resolve('./api/tray')];
delete require.cache[require.resolve('./api/webContents')];
delete require.cache[require.resolve('./api/globalShortcut')];
delete require.cache[require.resolve('./api/shell')];
delete require.cache[require.resolve('./api/screen')];
delete require.cache[require.resolve('./api/clipboard')];
delete require.cache[require.resolve('./api/browserView')];
delete require.cache[require.resolve('./api/powerMonitor')];
delete require.cache[require.resolve('./api/nativeTheme')];
delete require.cache[require.resolve('./api/dock')];
try {
if (hostHook) {
const hostHookScriptFilePath = path.join(__dirname, 'ElectronHostHook', 'index.js');
delete require.cache[require.resolve(hostHookScriptFilePath)];
hostHook = undefined;
}
} catch (error) {
console.error(error.message);
}
});
global['electronsocket'] = socket;
global['electronsocket'].setMaxListeners(0);
if (global['electronsocket'] === undefined) {
global['electronsocket'] = socket;
global['electronsocket'].setMaxListeners(0);
}
console.log('ASP.NET Core Application connected...', 'global.electronsocket', global['electronsocket'].id, new Date());
appApi = require('./api/app')(socket, app);
browserWindows = require('./api/browserWindows')(socket, app);
commandLine = require('./api/commandLine')(socket, app);
autoUpdater = require('./api/autoUpdater')(socket);
ipc = require('./api/ipc')(socket);
menu = require('./api/menu')(socket);
dialogApi = require('./api/dialog')(socket);
notification = require('./api/notification')(socket);
tray = require('./api/tray')(socket);
webContents = require('./api/webContents')(socket);
globalShortcut = require('./api/globalShortcut')(socket);
shellApi = require('./api/shell')(socket);
screen = require('./api/screen')(socket);
clipboard = require('./api/clipboard')(socket);
browserView = require('./api/browserView')(socket);
powerMonitor = require('./api/powerMonitor')(socket);
nativeTheme = require('./api/nativeTheme')(socket);
dock = require('./api/dock')(socket);
if (appApi === undefined) appApi = require('./api/app')(socket, app);
if (browserWindows === undefined) browserWindows = require('./api/browserWindows')(socket, app);
if (commandLine === undefined) commandLine = require('./api/commandLine')(socket, app);
if (autoUpdater === undefined) autoUpdater = require('./api/autoUpdater')(socket);
if (ipc === undefined) ipc = require('./api/ipc')(socket);
if (menu === undefined) menu = require('./api/menu')(socket);
if (dialogApi === undefined) dialogApi = require('./api/dialog')(socket);
if (notification === undefined) notification = require('./api/notification')(socket);
if (tray === undefined) tray = require('./api/tray')(socket);
if (webContents === undefined) webContents = require('./api/webContents')(socket);
if (globalShortcut === undefined) globalShortcut = require('./api/globalShortcut')(socket);
if (shellApi === undefined) shellApi = require('./api/shell')(socket);
if (screen === undefined) screen = require('./api/screen')(socket);
if (clipboard === undefined) clipboard = require('./api/clipboard')(socket);
if (browserView === undefined) browserView = require('./api/browserView')(socket);
if (powerMonitor === undefined) powerMonitor = require('./api/powerMonitor')(socket);
if (nativeTheme === undefined) nativeTheme = require('./api/nativeTheme')(socket);
if (dock === undefined) dock = require('./api/dock')(socket);
try {
const hostHookScriptFilePath = path.join(__dirname, 'ElectronHostHook', 'index.js');
@@ -277,7 +270,7 @@ function startAspCoreBackendWithWatch(electronPort) {
}
function getEnvironmentParameter() {
if(manifestJsonFile.environment) {
if (manifestJsonFile.environment) {
return '--environment=' + manifestJsonFile.environment;
}